diff --git a/about.po b/about.po index 77bc15a07..cc25fb828 100644 --- a/about.po +++ b/about.po @@ -17,25 +17,25 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../about.rst:3 msgid "About this documentation" msgstr "このドキュメントについて" -#: ../../about.rst:6 msgid "" "Python's documentation is generated from `reStructuredText`_ sources using " "`Sphinx`_, a documentation generator originally created for Python and now " "maintained as an independent project." msgstr "" -"Pythonのドキュメントは、`Sphinx`_ を使って、`reStructuredText`_ のソースから" -"生成されています。 Sphinx はもともとPythonのために作られ、現在は独立したプロ" -"ジェクトとして保守されています。" +"Python のドキュメントは、`Sphinx`_ を使って `reStructuredText`_ のソースから" +"生成されています。\n" +"Sphinx はもともと Python のために作られたドキュメント生成ツールで、現在は独立" +"したプロジェクトとして保守されています。" #: ../../about.rst:16 msgid "" diff --git a/bugs.po b/bugs.po index 574d67aa8..c589f686b 100644 --- a/bugs.po +++ b/bugs.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../bugs.rst:5 @@ -68,8 +68,7 @@ msgid "" "`_ instead." msgstr "" "このドキュメントの翻訳に関する不備や改善の提案の場合は、代わりに `翻訳用リポ" -"ジトリ `_ へ報告してくださ" -"い。" +"ジトリ `_ へ報告してください。" #: ../../bugs.rst:31 msgid "" @@ -193,13 +192,13 @@ msgid "The submission form has two fields, \"Title\" and \"Comment\"." msgstr "" "報告のフォームには、「Title」と「Comment」の2つのフィールドがあります。" -#: ../../bugs.rst:80 msgid "" "For the \"Title\" field, enter a *very* short description of the problem; " "fewer than ten words is good." msgstr "" "「Title」フィールドには、問題の *とても* 短い説明を(訳注: 英語で)入力してく" -"ださい。10語以内が望ましいです。" +"ださい。\n" +"10 語未満が望ましいです。" #: ../../bugs.rst:83 msgid "" @@ -238,13 +237,12 @@ msgstr "" "有益なバグ報告について詳しく説明した記事です。どんな情報が、なぜ有益なのかを" "説明しています。" -#: ../../bugs.rst:99 msgid "" "`Bug Writing Guidelines `_" msgstr "" -"`Bug Writing Guidelines `_" +"`Bug Writing Guidelines `_" #: ../../bugs.rst:100 msgid "" diff --git a/builtins/constants.po b/builtins/constants.po index 888c19d72..8e7402ec4 100644 --- a/builtins/constants.po +++ b/builtins/constants.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: Rafael Fontenelle , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../builtins/constants.rst:4 @@ -46,15 +46,17 @@ msgstr "" ":class:`bool` 型の真値です。``True`` への代入は不正で、:exc:`SyntaxError` を" "送出します。" -#: ../../builtins/constants.rst:22 msgid "" "An object frequently used to represent the absence of a value, as when " "default arguments are not passed to a function. Assignments to ``None`` are " "illegal and raise a :exc:`SyntaxError`. ``None`` is the sole instance of " "the :class:`~types.NoneType` type." msgstr "" +"関数にデフォルト引数が渡されなかった場合など、値が存在しないことを表すために" +"よく使われるオブジェクトです。\n" +"``None`` への代入は不正で、:exc:`SyntaxError` を送出します。\n" +"``None`` は :class:`~types.NoneType` 型の唯一のインスタンスです。" -#: ../../builtins/constants.rst:30 msgid "" "A special value which should be returned by the binary special methods (e." "g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :" @@ -65,8 +67,16 @@ msgid "" "boolean context. :data:`!NotImplemented` is the sole instance of the :class:" "`types.NotImplementedType` type." msgstr "" +"二項演算の特殊メソッド (例えば :meth:`~object.__eq__`、:meth:`~object." +"__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` など) が、\n" +"もう一方の型に対する演算を実装していないことを示すために返すべき特殊な値で" +"す。\n" +"インプレースの二項演算の特殊メソッド (例えば :meth:`~object.__imul__`、:meth:" +"`~object.__iand__` など) も、同じ目的でこの値を返せます。\n" +"真偽値として評価してはいけません。\n" +":data:`!NotImplemented` は :class:`types.NotImplementedType` 型の唯一のインス" +"タンスです。" -#: ../../builtins/constants.rst:40 msgid "" "When a binary (or in-place) method returns :data:`!NotImplemented` the " "interpreter will try the reflected operation on the other type (or some " @@ -76,44 +86,56 @@ msgid "" "error message or the :data:`!NotImplemented` value being returned to Python " "code." msgstr "" -"二項演算の (あるいはインプレースの) メソッドが :data:`!NotImplemented` を返し" -"た場合、インタープリタはもう一方の型で定義された対の演算で代用を試みます (あ" -"るいは演算によっては他の代替手段も試みます)。試行された演算全てが :data:`!" -"NotImplemented` を返した場合、インタープリタは適切な例外を送出します。 :data:" -"`!NotImplemented` を正しく返さないと、誤解を招きかねないエラーメッセージに" -"なったり、 :data:`!NotImplemented` が Python コードに返されるようなことになり" -"ます。" +"二項演算 (またはインプレース演算) のメソッドが :data:`!NotImplemented` を返し" +"た場合、\n" +"インタープリタはもう一方の型に定義された対の演算を試みます (演算子によっては" +"別の代替手段を試みます)。\n" +"すべての試行が :data:`!NotImplemented` を返した場合、インタープリタは適切な例" +"外を送出します。\n" +"誤って :data:`!NotImplemented` を返すと、誤解を招くエラーメッセージが表示され" +"たり、\n" +":data:`!NotImplemented` の値が Python コードに返されたりします。" #: ../../builtins/constants.rst:47 msgid "See :ref:`implementing-the-arithmetic-operations` for examples." msgstr "" "例として :ref:`implementing-the-arithmetic-operations` を参照してください。" -#: ../../builtins/constants.rst:51 msgid "" ":data:`!NotImplemented` and :exc:`!NotImplementedError` are not " "interchangeable. This constant should only be used as described above; see :" "exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" +":data:`!NotImplemented` と :exc:`!NotImplementedError` は互いに置き換えられま" +"せん。\n" +"この定数は、上で説明した用途にのみ使ってください。\n" +"例外の正しい使い方については :exc:`NotImplementedError` を参照してください。" -#: ../../builtins/constants.rst:56 msgid "Evaluating :data:`!NotImplemented` in a boolean context was deprecated." msgstr "" +":data:`!NotImplemented` を真偽値として評価することは非推奨となりました。" -#: ../../builtins/constants.rst:59 msgid "" "Evaluating :data:`!NotImplemented` in a boolean context now raises a :exc:" "`TypeError`. It previously evaluated to :const:`True` and emitted a :exc:" "`DeprecationWarning` since Python 3.9." msgstr "" +":data:`!NotImplemented` を真偽値として評価すると、:exc:`TypeError` が送出され" +"るようになりました。\n" +"以前は :const:`True` と評価され、Python 3.9 以降では :exc:" +"`DeprecationWarning` も発生していました。" -#: ../../builtins/constants.rst:68 msgid "" "The same as the ellipsis literal \"``...``\", an object frequently used to " "indicate that something is omitted. Assignment to ``Ellipsis`` is possible, " "but assignment to ``...`` raises a :exc:`SyntaxError`. ``Ellipsis`` is the " "sole instance of the :class:`types.EllipsisType` type." msgstr "" +"省略を示すリテラル \"``...``\" と同じオブジェクトで、何かが省略されていること" +"を示すためによく使われます。\n" +"``Ellipsis`` には代入できますが、``...`` に代入すると :exc:`SyntaxError` が送" +"出されます。\n" +"``Ellipsis`` は :class:`types.EllipsisType` 型の唯一のインスタンスです。" #: ../../builtins/constants.rst:76 msgid "" @@ -150,20 +172,26 @@ msgstr "" "かの定数を追加します。それらは対話的インタープリタシェルで有用ですが、プログ" "ラム中では使うべきではありません。" -#: ../../builtins/constants.rst:100 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when accessed directly in the interactive interpreter or " "called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" +"表示すると \"Use quit() or Ctrl-D (i.e. EOF) to exit\" のようなメッセージを表" +"示するオブジェクトです。\n" +"対話型インタープリタで直接入力するか、関数として呼び出すと、指定した終了コー" +"ドで :exc:`SystemExit` を送出します。" -#: ../../builtins/constants.rst:108 msgid "" "Object that when printed, prints the message \"Type help() for interactive " "help, or help(object) for help about object.\", and when accessed directly " "in the interactive interpreter, invokes the built-in help system (see :func:" "`help`)." msgstr "" +"表示すると \"Type help() for interactive help, or help(object) for help " +"about object.\" というメッセージを表示するオブジェクトです。\n" +"対話型インタープリタで直接入力すると、組み込みヘルプシステムを起動します (:" +"func:`help` を参照してください)。" #: ../../builtins/constants.rst:116 msgid "" diff --git a/builtins/exceptions.po b/builtins/exceptions.po index 106fde657..d45d016da 100644 --- a/builtins/exceptions.po +++ b/builtins/exceptions.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: Rafael Fontenelle , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../builtins/exceptions.rst:4 @@ -88,14 +88,12 @@ msgstr "" msgid "Exception context" msgstr "例外コンテキスト" -#: ../../builtins/exceptions.rst:46 msgid "" "Three attributes on exception objects provide information about the context " "in which the exception was raised:" msgstr "" -"例外オブジェクトの3つの属性は、例外が送出された常用に関する情報を提供します:" +"例外オブジェクトの3つの属性は、例外が送出された状況に関する情報を提供します:" -#: ../../builtins/exceptions.rst:53 msgid "" "When raising a new exception while another exception is already being " "handled, the new exception's :attr:`!__context__` attribute is automatically " @@ -103,18 +101,21 @@ msgid "" "`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " "used." msgstr "" +"別の例外の処理中に新しい例外を送出すると、新しい例外の :attr:`!__context__` " +"属性には、処理中の例外が自動的に設定されます。\n" +"例外の処理は、:keyword:`except` 節、:keyword:`finally` 節、:keyword:`with` 文" +"を使うときに行われることがあります。" -#: ../../builtins/exceptions.rst:59 msgid "" "This implicit exception context can be supplemented with an explicit cause " "by using :keyword:`!from` with :keyword:`raise`::" msgstr "" +":keyword:`raise` とともに :keyword:`!from` を使うと、この暗黙の例外コンテキス" +"トに明示的な原因を付け加えられます。 ::" -#: ../../builtins/exceptions.rst:63 msgid "raise new_exc from original_exc" -msgstr "" +msgstr "raise new_exc from original_exc" -#: ../../builtins/exceptions.rst:65 msgid "" "The expression following :keyword:`from` must be an exception or " "``None``. It will be set as :attr:`!__cause__` on the raised exception. " @@ -125,13 +126,14 @@ msgid "" "while leaving the old exception available in :attr:`!__context__` for " "introspection when debugging." msgstr "" -":keyword:`from ` に続く式は例外か ``None`` でなくてはなりません。\n" -"式は送出される例外の :attr:`!__cause__` として設定されます。\n" -":attr:`!__cause__` を設定することは、 :attr:`!__suppress_context__` 属性を暗" -"黙的に ``True`` に設定することにもなるので、 ``raise new_exc from None`` を使" -"うことで効率的に古い例外を新しいもので置き換えて表示する (例えば、 :exc:" -"`KeyError` を :exc:`AttributeError` に置き換え)、古い例外はデバッグ時の調査で" -"使えるよう :attr:`!__context__` に残すことができます。" +":keyword:`from` に続く式は、例外か ``None`` でなければなりません。\n" +"送出される例外の :attr:`!__cause__` には、その値が設定されます。\n" +":attr:`!__cause__` を設定すると、:attr:`!__suppress_context__` 属性も暗黙的" +"に ``True`` に設定されます。\n" +"そのため、``raise new_exc from None`` を使うと、表示上は古い例外を新しい例外" +"で置き換えられます (例えば :exc:`KeyError` から :exc:`AttributeError` への変" +"換)。\n" +"古い例外はデバッグ時に調べられるよう :attr:`!__context__` に残ります。" #: ../../builtins/exceptions.rst:74 msgid "" @@ -160,15 +162,17 @@ msgstr "" msgid "Inheriting from built-in exceptions" msgstr "組み込み例外から継承する" -#: ../../builtins/exceptions.rst:88 msgid "" "User code can create subclasses that inherit from an exception type. It's " "recommended to only subclass one exception type at a time to avoid any " "possible conflicts between how the bases handle the ``args`` attribute, as " "well as due to possible memory layout incompatibilities." msgstr "" +"ユーザコードでは、例外型を継承したサブクラスを作成できます。\n" +"基底クラス間で ``args`` 属性の扱いが衝突したり、メモリレイアウトの互換性に問" +"題が生じたりする可能性があるため、\n" +"一度に継承する例外型は一つだけにすることを推奨します。" -#: ../../builtins/exceptions.rst:95 msgid "" "Most built-in exceptions are implemented in C for efficiency, see: :source:" "`Objects/exceptions.c`. Some have custom memory layouts which makes it " @@ -177,6 +181,13 @@ msgid "" "between Python versions, leading to new conflicts in the future. Therefore, " "it's recommended to avoid subclassing multiple exception types altogether." msgstr "" +"ほとんどの組み込み例外は効率のために C で実装されています (:source:`Objects/" +"exceptions.c` を参照してください)。\n" +"一部の例外は独自のメモリレイアウトを持つため、そうした例外型の組み合わせでは" +"多重継承できません。\n" +"型のメモリレイアウトは実装の詳細であり、Python のバージョンによって変わり、将" +"来新たな衝突が生じる可能性があります。\n" +"そのため、複数の例外型からの継承は避けることを推奨します。" #: ../../builtins/exceptions.rst:105 msgid "Base classes" @@ -213,7 +224,6 @@ msgstr "" "`OSError` など) いくつかの引数を必要とし、このタプルの要素に特別な意味を込め" "るものもあります。" -#: ../../builtins/exceptions.rst:126 msgid "" "This method sets *tb* as the new traceback for the exception and returns the " "exception object. It was more commonly used before the exception chaining " @@ -224,8 +234,17 @@ msgid "" "happened to the traceback of the original ``SomeException`` had we allowed " "it to propagate to the caller. ::" msgstr "" +"このメソッドは、例外の新しいトレースバックに *tb* を設定し、その例外オブジェ" +"クトを返します。\n" +":pep:`3134` の例外連鎖機能が使えるようになる前は、より広く使われていまし" +"た。\n" +"次の例は、トレースバックを保持しながら ``SomeException`` のインスタンスを " +"``OtherException`` のインスタンスに変換する方法を示します。\n" +"``OtherException`` を送出すると、そのトレースバックに現在のフレームが追加され" +"ます。\n" +"元の ``SomeException`` を呼び出し元に伝播させた場合にも、そのトレースバックに" +"同じようにフレームが追加されます。 ::" -#: ../../builtins/exceptions.rst:135 msgid "" "try:\n" " ...\n" @@ -233,12 +252,19 @@ msgid "" " tb = sys.exception().__traceback__\n" " raise OtherException(...).with_traceback(tb)" msgstr "" +"try:\n" +" ...\n" +"except SomeException:\n" +" tb = sys.exception().__traceback__\n" +" raise OtherException(...).with_traceback(tb)" -#: ../../builtins/exceptions.rst:143 msgid "" "A writable field that holds the :ref:`traceback object ` " "associated with this exception. See also: :ref:`raise`." msgstr "" +"この例外に関連付けられた :ref:`トレースバックオブジェクト ` を保持する、書き込み可能なフィールドです。\n" +":ref:`raise` も参照してください。" #: ../../builtins/exceptions.rst:149 msgid "" @@ -315,30 +341,32 @@ msgstr "" "ます (オブジェクトが属性の参照や属性の代入をまったくサポートしていない場合に" "は :exc:`TypeError` が送出されます)。" -#: ../../builtins/exceptions.rst:207 msgid "" "The optional *name* and *obj* keyword-only arguments set the corresponding " "attributes:" msgstr "" +"オプションのキーワード専用引数 *name* と *obj* は、対応する属性に値を設定しま" +"す:" -#: ../../builtins/exceptions.rst:212 msgid "The name of the attribute that was attempted to be accessed." -msgstr "" +msgstr "アクセスしようとした属性の名前。" -#: ../../builtins/exceptions.rst:216 msgid "The object that was accessed for the named attribute." -msgstr "" +msgstr "指定した名前の属性にアクセスしようとした対象のオブジェクト。" #: ../../builtins/exceptions.rst:218 msgid "Added the :attr:`name` and :attr:`obj` attributes." msgstr ":attr:`name` および :attr:`obj` 属性が追加されました。" -#: ../../builtins/exceptions.rst:223 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " "without reading any data. (Note: the :meth:`io.TextIOBase.read` and :meth:" "`io.IOBase.readline` methods return an empty string when they hit EOF.)" msgstr "" +":func:`input` 関数がデータを何も読み込まずにファイル終端 (EOF) に達した場合に" +"送出されます。\n" +"(注: :meth:`io.TextIOBase.read` メソッドと :meth:`io.IOBase.readline` メソッ" +"ドは、EOF に達すると空文字列を返します。)" #: ../../builtins/exceptions.rst:230 msgid "Not currently used." @@ -356,7 +384,6 @@ msgstr "" "参照してください。この例外は厳密に言えばエラーではないので、 :exc:" "`Exception` ではなく :exc:`BaseException` を直接継承しています。" -#: ../../builtins/exceptions.rst:243 msgid "" "Raised when the :keyword:`import` statement has troubles trying to load a " "module. Also raised when the \"from list\" in ``from ... import`` has a " @@ -364,8 +391,8 @@ msgid "" msgstr "" ":keyword:`import` 文でモジュールをロードしようとして問題が発生すると送出され" "ます。\n" -"``from ... import`` の中の\"from list\" (訳注:``...`` の部分)の名前が見つか" -"らないときにも送出されます。" +"``from ... import`` の \"from list\" に、見つからない名前が含まれている場合に" +"も送出されます。" #: ../../builtins/exceptions.rst:247 msgid "" @@ -397,11 +424,12 @@ msgstr "" "ない場合に送出されます。また、 :data:`sys.modules` に ``None`` が含まれる場合" "にも送出されます。" -#: ../../builtins/exceptions.rst:271 msgid "" "A subclass of :exc:`ImportError` which is raised when a lazy import fails " "because it (directly or indirectly) tries to import itself." msgstr "" +":exc:`ImportError` のサブクラスで、遅延インポートが自身を直接または間接的にイ" +"ンポートしようとして失敗した場合に送出されます。" #: ../../builtins/exceptions.rst:278 msgid "" @@ -434,7 +462,6 @@ msgstr "" "を捕捉するコードに誤って捕捉されてインタプリタの終了が阻害されないように、こ" "の例外は :exc:`BaseException` を継承しています。" -#: ../../builtins/exceptions.rst:302 msgid "" "Catching a :exc:`KeyboardInterrupt` requires special consideration. Because " "it can be raised at unpredictable points, it may, in some circumstances, " @@ -442,6 +469,13 @@ msgid "" "allow :exc:`KeyboardInterrupt` to end the program as quickly as possible or " "avoid raising it entirely. (See :ref:`handlers-and-exceptions`.)" msgstr "" +":exc:`KeyboardInterrupt` の捕捉には特別な配慮が必要です。\n" +"この例外は予測できない箇所で送出される可能性があるため、状況によっては、実行" +"中のプログラムが不整合な状態になることがあります。\n" +"一般には、:exc:`KeyboardInterrupt` によってできるだけ速やかにプログラムを終了" +"させるか、\n" +"この例外の送出自体を避けるのが最善です (:ref:`handlers-and-exceptions` を参照" +"してください)。" #: ../../builtins/exceptions.rst:312 msgid "" @@ -471,46 +505,48 @@ msgstr "" "修飾の (訳注: ``spam.egg`` ではなく単に ``egg`` のような) 名前のみに適用され" "ます。関連値は見つからなかった名前を含むエラーメッセージです。" -#: ../../builtins/exceptions.rst:327 msgid "The optional *name* keyword-only argument sets the attribute:" -msgstr "" +msgstr "オプションのキーワード専用引数 *name* は、次の属性に値を設定します:" -#: ../../builtins/exceptions.rst:331 msgid "The name of the variable that was attempted to be accessed." -msgstr "" +msgstr "アクセスしようとした変数の名前。" #: ../../builtins/exceptions.rst:333 msgid "Added the :attr:`name` attribute." msgstr ":attr:`name` 属性が追加されました。" -#: ../../builtins/exceptions.rst:339 msgid "" "This exception is derived from :exc:`RuntimeError`. In user defined base " "classes, abstract methods should raise this exception when they require " "derived classes to override the method, or while the class is being " "developed to indicate that the real implementation still needs to be added." msgstr "" -"この例外は :exc:`RuntimeError` から派生しています。ユーザ定義の基底クラスにお" -"いて、抽象メソッドが派生クラスでオーバライドされることを要求する場合にこの例" -"外を送出しなくてはなりません。またはクラスは実装中であり本来の実装を追加する" -"必要があることを示します。" +"この例外は :exc:`RuntimeError` から派生しています。\n" +"ユーザ定義の基底クラスでは、派生クラスにメソッドのオーバーライドを求める場合" +"に、抽象メソッドからこの例外を送出するべきです。\n" +"また、クラスの開発中に、実際の実装をまだ追加する必要があることを示すためにも" +"送出するべきです。" -#: ../../builtins/exceptions.rst:346 msgid "" "It should not be used to indicate that an operator or method is not meant to " "be supported at all -- in that case either leave the operator / method " "undefined or, if a subclass, set it to :data:`None`." msgstr "" -"演算子やメソッドがサポートされていないことを示す目的でこの例外を使用するべき" -"ではありません。そのようなケースではオペレータやメソッドを未定義のままとする" -"か、サブクラスの場合は :data:`None` を設定してください。" +"演算子やメソッドをそもそもサポートする意図がないことを示すために、この例外を" +"使うべきではありません。\n" +"その場合は演算子やメソッドを未定義のままにするか、サブクラスであれば :data:" +"`None` を設定してください。" -#: ../../builtins/exceptions.rst:352 msgid "" ":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " "interchangeable. This exception should only be used as described above; see :" "data:`NotImplemented` for details on correct usage of the built-in constant." msgstr "" +":exc:`!NotImplementedError` と :data:`!NotImplemented` は互いに置き換えられま" +"せん。\n" +"この例外は、上で説明した用途にのみ使ってください。\n" +"組み込み定数の正しい使い方については :data:`NotImplemented` を参照してくださ" +"い。" #: ../../builtins/exceptions.rst:363 msgid "" @@ -535,7 +571,6 @@ msgstr "" "れた場合、:attr:`~BaseException.args` 属性は最初の2つの要素のみからなるタプル" "を持ちます。" -#: ../../builtins/exceptions.rst:373 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " @@ -543,23 +578,24 @@ msgid "" "exc:`OSError` directly or via an alias, and is not inherited when " "subclassing." msgstr "" -"コンストラクタは実際には、 `OS exceptions`_ で述べられている :exc:`OSError` " -"のサブクラスを返すことがよくあります。特定のサブクラスは最終的な :attr:`." -"errno` 値によります。この挙動は :exc:`OSError` を直接またはエイリアスで構築" -"し、サブクラス化時に継承されなかった場合にのみ発生します。" +"コンストラクタは、下の `OS exceptions`_ で説明する :exc:`OSError` のサブクラ" +"スを実際に返すことがよくあります。\n" +"どのサブクラスを返すかは、最終的な :attr:`.errno` の値によって決まります。\n" +"この挙動は、:exc:`OSError` を直接またはエイリアスを通して構築した場合にのみ発" +"生し、サブクラスには継承されません。" #: ../../builtins/exceptions.rst:381 msgid "A numeric error code from the C variable :c:data:`errno`." msgstr "C 変数 :c:data:`errno` に由来する数値エラーコードです。" -#: ../../builtins/exceptions.rst:385 msgid "" "Under Windows, this gives you the native Windows error code. The :attr:`." "errno` attribute is then an approximate translation, in POSIX terms, of that " "native error code." msgstr "" -"Windows において、ネイティブ Windows エラーコードを与えます。そして :attr:" -"`errno` 属性は POSIX でいうネイティブエラーコードへのおよその翻訳です。" +"Windows では、ネイティブの Windows エラーコードを表します。\n" +"この場合、:attr:`.errno` 属性は、そのネイティブエラーコードを POSIX のエラー" +"コードにおおよそ変換した値です。" #: ../../builtins/exceptions.rst:389 msgid "" @@ -593,24 +629,26 @@ msgstr "" "ファイルシステムパスが2つ関与する関数 (例えば :func:`os.rename`) の場合、:" "attr:`filename2` は関数に渡された2つ目のファイル名です。" -#: ../../builtins/exceptions.rst:412 msgid "" ":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." "error`, :exc:`select.error` and :exc:`!mmap.error` have been merged into :" "exc:`OSError`, and the constructor may return a subclass." msgstr "" +":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." +"error`、:exc:`select.error`、:exc:`!mmap.error` は :exc:`OSError` に統合さ" +"れ、\n" +"コンストラクタはサブクラスを返すことがあります。" -#: ../../builtins/exceptions.rst:418 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " "function, instead of the name encoded to or decoded from the :term:" "`filesystem encoding and error handler`. Also, the *filename2* constructor " "argument and attribute was added." msgstr "" -":attr:`filename` 属性が :term:`filesystem encoding and error handler` のエン" -"コーディングでエンコードやデコードされた名前から、関数に渡された元々のファイ" -"ル名になりました。\n" -"また、*filename2* コンストラクタ引数が追加されました。" +":attr:`filename` 属性は、:term:`filesystem encoding and error handler` に従っ" +"てエンコードまたはデコードされた名前ではなく、関数に渡された元のファイル名に" +"なりました。\n" +"また、コンストラクタ引数と属性の *filename2* が追加されました。" #: ../../builtins/exceptions.rst:427 msgid "" @@ -627,36 +665,37 @@ msgstr "" "出されることがあります。C の浮動小数点演算の例外処理は標準化されていないの" "で、ほとんどの浮動小数点演算もチェックされません。" -#: ../../builtins/exceptions.rst:437 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when an " "operation is blocked during interpreter shutdown also known as :term:`Python " "finalization `." msgstr "" +"この例外は :exc:`RuntimeError` から派生しています。\n" +":term:`Python の終了処理 ` とも呼ばれるインタープリタの" +"シャットダウン中に、操作が阻止された場合に送出されます。" -#: ../../builtins/exceptions.rst:441 msgid "" "Examples of operations which can be blocked with a :exc:" "`PythonFinalizationError` during the Python finalization:" msgstr "" +"Python の終了処理中に :exc:`PythonFinalizationError` によって阻止されることが" +"ある操作の例:" -#: ../../builtins/exceptions.rst:444 msgid "Creating a new Python thread." -msgstr "" +msgstr "新しい Python スレッドの作成。" -#: ../../builtins/exceptions.rst:445 msgid ":meth:`Joining ` a running daemon thread." -msgstr "" +msgstr "実行中のデーモンスレッドの :meth:`終了待機 `。" -#: ../../builtins/exceptions.rst:446 msgid ":func:`os.fork`," -msgstr "" +msgstr ":func:`os.fork` の呼び出し。" -#: ../../builtins/exceptions.rst:447 msgid "" "acquiring a lock such as :class:`threading.Lock`, when it is known that the " "operation would otherwise deadlock." msgstr "" +"そのまま操作を進めるとデッドロックすると分かっている場合の、:class:" +"`threading.Lock` などのロックの獲得。" #: ../../builtins/exceptions.rst:450 msgid "See also the :func:`sys.is_finalizing` function." @@ -666,9 +705,10 @@ msgstr ":func:`sys.is_finalizing` 関数も参照してください。" msgid "Previously, a plain :exc:`RuntimeError` was raised." msgstr "以前は :exc:`RuntimeError` をそのまま送出していました。" -#: ../../builtins/exceptions.rst:457 msgid ":meth:`threading.Thread.join` can now raise this exception." msgstr "" +":meth:`threading.Thread.join` がこの例外を送出することがあるようになりまし" +"た。" #: ../../builtins/exceptions.rst:461 msgid "" @@ -769,24 +809,24 @@ msgstr "" ":pep:`479` が全てのコードでデフォルトで有効化されました: ジェネレータから送出" "された :exc:`StopIteration` は :exc:`RuntimeError` に変換されます。" -#: ../../builtins/exceptions.rst:524 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." msgstr "" -"イテレーションを停止するために、 :term:`asynchronous iterator` オブジェクト" -"の :meth:`~object.__anext__` メソッドによって返される必要があります。" +"イテレーションを停止するために、:term:`asynchronous iterator` オブジェクト" +"の :meth:`~object.__anext__` メソッドから送出しなければなりません。" -#: ../../builtins/exceptions.rst:531 msgid "" "Raised when the parser encounters a syntax error. This may occur in an :" "keyword:`import` statement, in a call to the built-in functions :func:" "`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " "or standard input (also interactively)." msgstr "" -"パーザが構文エラーに遭遇した場合に送出されます。この例外は :keyword:`import` " -"文、組み込み関数 :func:`compile`、:func:`exec` や :func:`eval` 、初期化スクリ" -"プトの読み込みや標準入力で (対話的な実行時にも) 起こる可能性があります。" +"パーザが構文エラーに遭遇した場合に送出されます。\n" +"この例外は、:keyword:`import` 文、組み込み関数 :func:`compile`、:func:" +"`exec`、:func:`eval` の呼び出し、\n" +"最初に実行するスクリプトや標準入力の読み込み時 (対話的な実行時も含みます) に" +"起こる可能性があります。" #: ../../builtins/exceptions.rst:537 msgid "" @@ -864,7 +904,6 @@ msgstr "" "タブとスペースを一貫しない方法でインデントに使っているときに送出されます。こ" "れは :exc:`IndentationError` のサブクラスです。" -#: ../../builtins/exceptions.rst:590 msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " @@ -872,8 +911,12 @@ msgid "" "`CPython`, this could be raised by incorrectly using Python's C API, such as " "returning a ``NULL`` value without an exception set." msgstr "" +"インタープリタが内部エラーを検出したものの、実行の継続を断念するほど深刻な状" +"況ではない場合に送出されます。\n" +"関連値は、何が問題だったのかを低水準の用語で示す文字列です。\n" +":term:`CPython` では、例外を設定せずに ``NULL`` 値を返すなど、Python の C " +"API を誤って使うと送出されることがあります。" -#: ../../builtins/exceptions.rst:596 msgid "" "If you're confident that this exception wasn't your fault, or the fault of a " "package you're using, you should report this to the author or maintainer of " @@ -883,8 +926,14 @@ msgid "" "associated value) and if possible the source of the program that triggered " "the error." msgstr "" +"この例外の原因が自分のコードにも使用中のパッケージにもないと確信できる場合" +"は、\n" +"使用している Python インタープリタの作者やメンテナに報告してください。\n" +"Python インタープリタのバージョン (``sys.version`` の値で、対話型 Python セッ" +"ションの開始時にも表示されます)、\n" +"正確なエラーメッセージ (例外の関連値)、可能であればエラーを引き起こしたプログ" +"ラムのソースを必ず報告してください。" -#: ../../builtins/exceptions.rst:607 msgid "" "This exception is raised by the :func:`sys.exit` function. It inherits " "from :exc:`BaseException` instead of :exc:`Exception` so that it is not " @@ -897,6 +946,18 @@ msgid "" "is zero; if it has another type (such as a string), the object's value is " "printed and the exit status is one." msgstr "" +"この例外は :func:`sys.exit` 関数によって送出されます。\n" +":exc:`Exception` を捕捉するコードに誤って捕捉されないように、:exc:" +"`Exception` ではなく :exc:`BaseException` を継承しています。\n" +"これにより、例外が適切に伝播し、インタープリタを終了できます。\n" +"この例外が処理されない場合、Python インタープリタは終了し、スタックトレース" +"バックは表示されません。\n" +"コンストラクタには、:func:`sys.exit` と同じオプションの引数を渡せます。\n" +"値が整数の場合は、システムの終了ステータスを指定します (C の :c:func:`!exit` " +"関数に渡されます)。\n" +"``None`` の場合、終了ステータスはゼロです。\n" +"それ以外の型 (文字列など) の場合、オブジェクトの値が表示され、終了ステータス" +"は1になります。" #: ../../builtins/exceptions.rst:618 msgid "" @@ -921,26 +982,25 @@ msgstr "" "コンストラクタに渡された終了ステータス又はエラーメッセージ。(デフォルトは " "``None``)" -#: ../../builtins/exceptions.rst:633 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " "the type mismatch." msgstr "" -"組み込み演算または関数が適切でない型のオブジェクトに対して適用された際に送出" -"されます。関連値は型の不整合に関して詳細を述べた文字列です。" +"演算や関数を適切でない型のオブジェクトに適用した場合に送出されます。\n" +"関連値は、型の不整合の詳細を示す文字列です。" -#: ../../builtins/exceptions.rst:636 msgid "" "This exception may be raised by user code to indicate that an attempted " "operation on an object is not supported, and is not meant to be. If an " "object is meant to support a given operation but has not yet provided an " "implementation, :exc:`NotImplementedError` is the proper exception to raise." msgstr "" -"この例外は、そのオブジェクトで実行しようとした操作がサポートされておらず、そ" -"の予定もない場合にユーザーコードから送出されるかもしれません。オブジェクトで" -"その操作をサポートするつもりだが、まだ実装を提供していないのであれば、送出す" -"る適切な例外は :exc:`NotImplementedError` です。" +"そのオブジェクトで実行しようとした操作がサポートされておらず、サポートする意" +"図もないことを示すために、\n" +"ユーザコードからこの例外を送出することもできます。\n" +"操作をサポートする意図はあるものの、まだ実装していない場合には、:exc:" +"`NotImplementedError` を送出するのが適切です。" #: ../../builtins/exceptions.rst:641 msgid "" @@ -997,11 +1057,12 @@ msgstr "コーデックがエンコードまたはデコードしようとした msgid "The first index of invalid data in :attr:`object`." msgstr ":attr:`object` の最初の無効なデータのインデクスです。" -#: ../../builtins/exceptions.rst:678 ../../builtins/exceptions.rst:685 msgid "" "This value should not be negative as it is interpreted as an absolute offset " "but this constraint is not enforced at runtime." msgstr "" +"この値は絶対オフセットとして解釈されるため、負の値にすべきではありませんが、" +"この制約は実行時には強制されません。" #: ../../builtins/exceptions.rst:683 msgid "The index after the last invalid data in :attr:`object`." @@ -1031,23 +1092,22 @@ msgstr "" "Unicode 関連のエラーが変換中に発生した際に送出されます。 :exc:`UnicodeError` " "のサブクラスです。" -#: ../../builtins/exceptions.rst:709 msgid "" "Raised when an operation or function receives an argument that has the right " "type but an inappropriate value, and the situation is not described by a " "more precise exception such as :exc:`IndexError`." msgstr "" -"演算子や関数が、正しい型だが適切でない値を持つ引数を受け取ったときや、 :exc:" -"`IndexError` のようなより詳細な例外では記述できない状況で送出されます。" +"演算や関数が、型は正しいものの値が適切でない実引数を受け取り、\n" +"かつ、その状況を :exc:`IndexError` などのより具体的な例外で表せない場合に送出" +"されます。" -#: ../../builtins/exceptions.rst:716 msgid "" "Raised when the second argument of a division or modulo operation is zero. " "The associated value is a string indicating the type of the operands and the " "operation." msgstr "" -"除算や剰余演算の第二引数が 0 であった場合に送出されます。関連値は文字列で、そ" -"の演算における被演算子と演算子の型を示します。" +"除算や剰余演算の第2引数がゼロの場合に送出されます。\n" +"関連値は、被演算子の型と演算の種類を示す文字列です。" #: ../../builtins/exceptions.rst:721 msgid "" @@ -1073,17 +1133,16 @@ msgstr "" "以下の例外は :exc:`OSError` のサブクラスで、システムエラーコードに依存して送" "出されます。" -#: ../../builtins/exceptions.rst:741 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" "blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." "EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" "const:`~errno.EINPROGRESS`." msgstr "" -"ある操作が、ノンブロッキング操作に設定されたオブジェクト (例えばソケット) を" -"ブロックしそうになった場合に送出されます。:c:data:`errno` :py:const:`~errno." -"EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` および :" -"py:const:`~errno.EINPROGRESS` に対応します。" +"ノンブロッキング操作に設定されたオブジェクト (例えばソケット) に対する操作を" +"すぐに完了できず、待機が必要な場合に送出されます。\n" +":c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:py:" +"const:`~errno.EWOULDBLOCK`、:py:const:`~errno.EINPROGRESS` に対応します。" #: ../../builtins/exceptions.rst:746 msgid "" @@ -1093,12 +1152,14 @@ msgstr "" ":exc:`BlockingIOError` は、 :exc:`OSError` の属性に加えて一つの属性を持ちま" "す:" -#: ../../builtins/exceptions.rst:751 msgid "" "An integer containing the number of **bytes** written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " "from the :mod:`io` module." msgstr "" +"ブロックするまでにストリームへ書き込まれた **バイト数** を表す整数です。\n" +"この属性は、:mod:`io` モジュールのバッファ付き I/O クラスを使う場合に利用でき" +"ます。" #: ../../builtins/exceptions.rst:757 msgid "" @@ -1120,17 +1181,18 @@ msgstr "" "サブクラスは :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" "`ConnectionRefusedError`, :exc:`ConnectionResetError` です。" -#: ../../builtins/exceptions.rst:769 msgid "" "A subclass of :exc:`ConnectionError`, raised when trying to write on a pipe " "while the other end has been closed, or trying to write on a socket which " "has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" "`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" -":exc:`ConnectionError` のサブクラスで、もう一方の端が閉じられたパイプに書き込" -"こもうとするか、書き込みのためにシャットダウンされたソケットに書き込こもうと" -"した場合に発生します。 :c:data:`errno` :py:const:`~errno.EPIPE` と :py:" -"const:`~errno.ESHUTDOWN` に対応します。" +":exc:`ConnectionError` のサブクラスです。\n" +"もう一方の端が閉じられたパイプに書き込もうとした場合や、\n" +"書き込み側がシャットダウンされたソケットに書き込もうとした場合に送出されま" +"す。\n" +":c:data:`errno` :py:const:`~errno.EPIPE` と :py:const:`~errno.ESHUTDOWN` に対" +"応します。" #: ../../builtins/exceptions.rst:776 msgid "" @@ -1176,13 +1238,12 @@ msgstr "" "要求されたファイルやディレクトリが存在しない場合に送出されます。:c:data:" "`errno` :py:const:`~errno.ENOENT` に対応します。" -#: ../../builtins/exceptions.rst:804 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" -"システムコールが入力信号によって中断された場合に送出されます。:c:data:" -"`errno` :py:const:`~errno.EINTR` に対応します。" +"システムコールが受信したシグナルによって中断された場合に送出されます。\n" +":c:data:`errno` :py:const:`~errno.EINTR` に対応します。" #: ../../builtins/exceptions.rst:807 msgid "" @@ -1202,7 +1263,6 @@ msgstr "" "ディレクトリに (:func:`os.remove` などの) ファイル操作が要求された場合に送出" "されます。:c:data:`errno` :py:const:`~errno.EISDIR` に対応します。" -#: ../../builtins/exceptions.rst:820 msgid "" "Raised when a directory operation (such as :func:`os.listdir`) is requested " "on something which is not a directory. On most POSIX platforms, it may also " @@ -1210,10 +1270,12 @@ msgid "" "as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." "ENOTDIR`." msgstr "" -"ディレクトリへの操作(たとえば :func:`os.listdir`)をディレクトリ以外に対して要" -"求された場合に送出されます。多くのPOSIXプラットフォームではディレクトリではな" -"いファイルをディレクトリとして開いたり移動するときにも発生する場合がありま" -"す。:c:data:`errno` :py:const:`~errno.ENOTDIR` に対応します。" +"ディレクトリに対する操作 (例えば :func:`os.listdir`) がディレクトリ以外の対象" +"に要求された場合に送出されます。\n" +"ほとんどの POSIX プラットフォームでは、ディレクトリでないファイルをディレクト" +"リとして開いたり、\n" +"パスをたどろうとしたりした場合にも送出されることがあります。\n" +":c:data:`errno` :py:const:`~errno.ENOTDIR` に対応します。" #: ../../builtins/exceptions.rst:828 msgid "" @@ -1278,13 +1340,11 @@ msgstr "警告カテゴリの基底クラスです。" msgid "Base class for warnings generated by user code." msgstr "ユーザコードによって生成される警告の基底クラスです。" -#: ../../builtins/exceptions.rst:876 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "" -"他の Python 開発者へ向けて警告を発するときの、廃止予定の機能についての警告の" -"基底クラスです。" +"非推奨の機能について、他の Python 開発者に向けて発する警告の基底クラスです。" #: ../../builtins/exceptions.rst:879 msgid "" @@ -1296,27 +1356,24 @@ msgstr "" "化されています。:ref:`Python Development Mode ` を有効にするとこの警" "告が表示されます。" -#: ../../builtins/exceptions.rst:883 ../../builtins/exceptions.rst:899 msgid "The deprecation policy is described in :pep:`387`." -msgstr "" +msgstr "非推奨化の方針は :pep:`387` で説明されています。" -#: ../../builtins/exceptions.rst:888 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." msgstr "" -"古くなって将来的に廃止される予定だが、今のところは廃止されていない機能につい" -"ての警告の基底クラスです。" +"古くなっており、将来は非推奨になる見込みですが、現時点では非推奨ではない機能" +"についての警告の基底クラスです。" -#: ../../builtins/exceptions.rst:892 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " "already active deprecations." msgstr "" -"近々起こる可能性のある機能廃止について警告を発することはまれなので、このクラ" -"スはめったに使われず、既に決まっている廃止については :exc:" -"`DeprecationWarning` が望ましいです。" +"将来、非推奨になる可能性を事前に警告することは一般的ではないため、このクラス" +"はめったに使われません。\n" +"すでに非推奨となっている機能には :exc:`DeprecationWarning` が推奨されます。" #: ../../builtins/exceptions.rst:896 ../../builtins/exceptions.rst:925 #: ../../builtins/exceptions.rst:952 @@ -1327,19 +1384,18 @@ msgstr "" "デフォルトの警告フィルターで無効化されています。:ref:`Python Development " "Mode ` を有効にするとこの警告が表示されます。" -#: ../../builtins/exceptions.rst:904 msgid "Base class for warnings about dubious syntax." -msgstr "曖昧な構文に対する警告の基底クラスです。" +msgstr "疑わしい構文についての警告の基底クラスです。" -#: ../../builtins/exceptions.rst:906 msgid "" "This warning is typically emitted when compiling Python source code, and " "usually won't be reported when running already compiled code." msgstr "" +"この警告は通常、Python ソースコードのコンパイル時に発生し、コンパイル済みの" +"コードの実行時には通常は報告されません。" -#: ../../builtins/exceptions.rst:912 msgid "Base class for warnings about dubious runtime behavior." -msgstr "あいまいなランタイム挙動に対する警告の基底クラスです。" +msgstr "疑わしい実行時の動作についての警告の基底クラスです。" #: ../../builtins/exceptions.rst:917 msgid "" @@ -1391,7 +1447,6 @@ msgstr "" "す。また、:keyword:`except*` によって判別でき、例外グループに含" "まれている例外の型に基づいてサブグループにマッチします。" -#: ../../builtins/exceptions.rst:972 msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " @@ -1401,15 +1456,15 @@ msgid "" "is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" "exc:`BaseExceptionGroup`." msgstr "" -"この2つの例外型は一連の例外 ``excs`` を包含します。``msg`` 引数は文字列の必要" -"があります。2つのクラスの異なる点は、:exc:`BaseException` は :exc:" -"`BaseExceptionGroup` を拡張して任意の例外を含められますが、:exc:" -"`ExceptionGroup` は :exc:`Exception` を拡張して :exc:`Exception` のサブクラス" -"のみを含められます。この設計により ``except Exception`` は :exc:" -"`ExceptionGroup` をキャッチしますが、:exc:`BaseExceptionGroup` はキャッチしま" -"せん。" +"どちらの例外型も、シーケンス ``excs`` に含まれる例外をまとめて保持します。\n" +"``msg`` パラメータは文字列でなければなりません。\n" +"2つのクラスの違いは、:exc:`BaseExceptionGroup` が :exc:`BaseException` を拡張" +"して任意の例外を保持できるのに対し、\n" +":exc:`ExceptionGroup` は :exc:`Exception` を拡張し、:exc:`Exception` のサブク" +"ラスの例外のみを保持できることです。\n" +"この設計により、``except Exception`` は :exc:`ExceptionGroup` を捕捉します" +"が、:exc:`BaseExceptionGroup` は捕捉しません。" -#: ../../builtins/exceptions.rst:980 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " "rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" @@ -1417,24 +1472,29 @@ msgid "" "The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" "`TypeError` if any contained exception is not an :exc:`Exception` subclass." msgstr "" -":exc:`BaseExceptionGroup` のコンストラクターは含まれる例外がすべて :exc:" -"`Exception` の場合は :exc:`BaseExceptionGroup` ではなく :exc:" -"`ExceptionGroup` を返すように自動的に選択されます。一方 :exc:" -"`ExceptionGroup` コンストラクタは、:exc:`Exception` サブクラス以外の例外を含" -"む場合は :exc:`TypeError` を送出します。" +":exc:`BaseExceptionGroup` のコンストラクタは、保持する例外がすべて :exc:" +"`Exception` のインスタンスである場合、\n" +":exc:`BaseExceptionGroup` ではなく :exc:`ExceptionGroup` を返すので、クラスの" +"選択を自動化するために利用できます。\n" +"一方、:exc:`ExceptionGroup` のコンストラクタは、:exc:`Exception` のサブクラス" +"のインスタンスでない例外が一つでも含まれていると :exc:`TypeError` を送出しま" +"す。" -#: ../../builtins/exceptions.rst:987 msgid "" "Exception groups are :ref:`generic ` over the type of their " "contained exceptions." msgstr "" +"例外グループは、保持する例外の型をパラメータとする :ref:`ジェネリック型 " +"` です。" -#: ../../builtins/exceptions.rst:992 msgid "" "The ``excs`` parameter may be any sequence, but lists and tuples are " "specifically processed more efficiently here. For optimal performance, pass " "a tuple as ``excs``." msgstr "" +"``excs`` パラメータには任意のシーケンスを指定できますが、リストとタプルは特に" +"効率よく処理されます。\n" +"最適なパフォーマンスを得るには、``excs`` にタプルを渡してください。" #: ../../builtins/exceptions.rst:998 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." @@ -1448,15 +1508,14 @@ msgstr "" "コンストラクタに渡された一連の ``excs`` に含まれる例外のタプルです。この属性" "は読み込み専用です。" -#: ../../builtins/exceptions.rst:1007 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." msgstr "" -"現在のグループで *条件* にマッチする礼儀のみを含む例外グループを返します。結" -"果が空の場合は ``None`` を返します。" +"現在のグループの例外のうち、*condition* にマッチするものだけを含む例外グルー" +"プを返します。\n" +"結果が空の場合は ``None`` を返します。" -#: ../../builtins/exceptions.rst:1010 msgid "" "The condition can be an exception type or tuple of exception types, in which " "case each exception is checked for a match using the same check that is used " @@ -1464,8 +1523,11 @@ msgid "" "type object) that accepts an exception as its single argument and returns " "true for the exceptions that should be in the subgroup." msgstr "" +"条件には例外型または例外型のタプルを指定でき、\n" +"その場合は ``except`` 節と同じ判定方法で各例外がマッチするかを調べます。\n" +"また、例外を唯一の引数として受け取り、サブグループに含めるべき例外に対して真" +"を返す呼び出し可能オブジェクト (型オブジェクトを除く) も指定できます。" -#: ../../builtins/exceptions.rst:1016 msgid "" "The nesting structure of the current exception is preserved in the result, " "as are the values of its :attr:`message`, :attr:`~BaseException." @@ -1473,17 +1535,25 @@ msgid "" "__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " "groups are omitted from the result." msgstr "" +"結果には、現在の例外の入れ子構造と、:attr:`message`、:attr:`~BaseException." +"__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException." +"__context__`、:attr:`~BaseException.__notes__` の各フィールドの値が保持されま" +"す。\n" +"入れ子になった空のグループは結果から除かれます。" -#: ../../builtins/exceptions.rst:1023 msgid "" "The condition is checked for all exceptions in the nested exception group, " "including the top-level and any nested exception groups. If the condition is " "true for such an exception group, it is included in the result in full." msgstr "" +"条件は、最上位の例外グループと入れ子になったすべての例外グループも含め、\n" +"入れ子の例外グループ内のすべての例外に対して調べられます。\n" +"例外グループに対して条件が真となる場合、そのグループ全体が結果に含まれます。" -#: ../../builtins/exceptions.rst:1027 msgid "``condition`` can be any callable which is not a type object." msgstr "" +"``condition`` に、型オブジェクト以外の任意の呼び出し可能オブジェクトを指定で" +"きるようになりました。" #: ../../builtins/exceptions.rst:1032 msgid "" @@ -1502,13 +1572,17 @@ msgstr "" "同じ :attr:`message` の例外グループを返しますが、``excs`` の例外を含んでいま" "す。" -#: ../../builtins/exceptions.rst:1041 msgid "" "This method is used by :meth:`subgroup` and :meth:`split`, which are used in " "various contexts to break up an exception group. A subclass needs to " "override it in order to make :meth:`subgroup` and :meth:`split` return " "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" +"このメソッドは、さまざまな状況で例外グループを分割するために使われる :meth:" +"`subgroup` と :meth:`split` から呼び出されます。\n" +"サブクラスで :meth:`subgroup` と :meth:`split` が :exc:`ExceptionGroup` では" +"なくそのサブクラスのインスタンスを返すようにするには、\n" +"このメソッドをオーバーライドする必要があります。" #: ../../builtins/exceptions.rst:1047 msgid "" @@ -1524,7 +1598,6 @@ msgstr "" "返す例外グループにコピーするため、:meth:`derive` ではこれらのフィールドを更新" "する必要がありません。" -#: ../../builtins/exceptions.rst:1054 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1552,8 +1625,32 @@ msgid "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" msgstr "" +">>> class MyGroup(ExceptionGroup):\n" +"... def derive(self, excs):\n" +"... return MyGroup(self.message, excs)\n" +"...\n" +">>> e = MyGroup(\"eg\", [ValueError(1), TypeError(2)])\n" +">>> e.add_note(\"a note\")\n" +">>> e.__context__ = Exception(\"context\")\n" +">>> e.__cause__ = Exception(\"cause\")\n" +">>> try:\n" +"... raise e\n" +"... except Exception as e:\n" +"... exc = e\n" +"...\n" +">>> match, rest = exc.split(ValueError)\n" +">>> exc, exc.__context__, exc.__cause__, exc.__notes__\n" +"(MyGroup('eg', [ValueError(1), TypeError(2)]), Exception('context'), " +"Exception('cause'), ['a note'])\n" +">>> match, match.__context__, match.__cause__, match.__notes__\n" +"(MyGroup('eg', [ValueError(1)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> rest, rest.__context__, rest.__cause__, rest.__notes__\n" +"(MyGroup('eg', [TypeError(2)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" +"True" -#: ../../builtins/exceptions.rst:1080 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1561,8 +1658,12 @@ msgid "" "exception group subclass which accepts an exit_code and constructs the " "group's message from it. ::" msgstr "" +":exc:`BaseExceptionGroup` は :meth:`~object.__new__` を定義しているため、\n" +"異なるコンストラクタシグネチャが必要なサブクラスでは、:meth:`~object." +"__init__` ではなく ``__new__()`` をオーバーライドする必要があります。\n" +"例えば、次のコードでは ``exit_code`` を受け取り、そこからグループのメッセージ" +"を作成する例外グループのサブクラスを定義しています。 ::" -#: ../../builtins/exceptions.rst:1086 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1573,13 +1674,24 @@ msgid "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" msgstr "" +"class Errors(ExceptionGroup):\n" +" def __new__(cls, errors, exit_code):\n" +" self = super().__new__(Errors, f\"exit code: {exit_code}\", errors)\n" +" self.exit_code = exit_code\n" +" return self\n" +"\n" +" def derive(self, excs):\n" +" return Errors(excs, self.exit_code)" -#: ../../builtins/exceptions.rst:1095 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " "is also a subclass of :exc:`Exception` can only wrap instances of :exc:" "`Exception`." msgstr "" +":exc:`ExceptionGroup` と同様に、:exc:`BaseExceptionGroup` のサブクラスであ" +"り、\n" +"かつ :exc:`Exception` のサブクラスでもあるクラスは、:exc:`Exception` のインス" +"タンスのみを保持できます。" #: ../../builtins/exceptions.rst:1103 msgid "Exception hierarchy" diff --git a/builtins/functions.po b/builtins/functions.po index 3e707994f..5de112075 100644 --- a/builtins/functions.po +++ b/builtins/functions.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: Rafael Fontenelle , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../builtins/functions.rst:5 @@ -457,11 +457,14 @@ msgstr "" " return False\n" " return True" -#: ../../builtins/functions.rst:91 msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is :term:`exhausted`." msgstr "" +"待ち受けると、指定した :term:`非同期イテレータ ` の次" +"の要素を返します。\n" +"イテレータが :term:`枯渇して ` おり、*default* が指定されている場" +"合は、その値を返します。" #: ../../builtins/functions.rst:94 msgid "" @@ -469,7 +472,6 @@ msgid "" msgstr "" "これは組み込みの :func:`next` 関数の非同期版であり、同じように動作します。" -#: ../../builtins/functions.rst:97 msgid "" "This calls the :meth:`~object.__anext__` method of *async_iterator*, " "returning an :term:`awaitable`. Awaiting this returns the next value of the " @@ -477,10 +479,10 @@ msgid "" "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" "これは *async_iterator* の :meth:`~object.__anext__` メソッドを呼び出し、待ち" -"受け可能オブジェクト (:term:`awaitable`) を返します。待ち受けることによりイテ" -"レータの次の値を返します。 *default* が与えられた場合、イテレータが枯渇したと" -"きにその値が返されます。 *default* が与えられない場合は :exc:" -"`StopAsyncIteration` が送出されます。" +"受け可能オブジェクト (:term:`awaitable`) を返します。\n" +"これを待ち受けると、イテレータの次の値が返されます。\n" +"イテレータが枯渇した場合、*default* が指定されていればその値が返され、\n" +"指定されていなければ :exc:`StopAsyncIteration` が送出されます。" #: ../../builtins/functions.rst:106 msgid "" @@ -504,17 +506,16 @@ msgstr "" " return True\n" " return False" -#: ../../builtins/functions.rst:118 msgid "" "As :func:`repr`, return a string containing a printable representation of an " "object, but escape the non-ASCII characters in the string returned by :func:" "`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " "similar to that returned by :func:`repr` in Python 2." msgstr "" -":func:`repr` と同様、オブジェクトの印字可能な表現を含む文字列を返しますが、:" -"func:`repr` によって返された文字列中の非 ASCII 文字は ``\\x`` 、 ``\\u`` 、 " -"``\\U`` エスケープを使ってエスケープされます。これは Python 2 の :func:" -"`repr` によって返されるのと同じ文字列を作ります。" +":func:`repr` と同様に、オブジェクトの印字可能な表現を含む文字列を返します。\n" +"ただし、:func:`repr` が返す文字列中の非 ASCII 文字は、``\\x``、``\\u``、" +"``\\U`` エスケープを使ってエスケープされます。\n" +"これにより、Python 2 の :func:`repr` が返すものと似た文字列が生成されます。" #: ../../builtins/functions.rst:126 msgid "" @@ -617,17 +618,19 @@ msgstr "" "引数 ``breakpointhook`` 付きで :ref:`監査イベント ` ``builtins." "breakpoint`` を送出します。" -#: ../../builtins/functions.rst:193 msgid "" "Return a new array of bytes. The :class:`bytearray` class is a mutable " "sequence of integers in the range 0 <= x < 256. It has most of the usual " "methods of mutable sequences, described in :ref:`typesseq-mutable`, as well " "as most methods that the :class:`bytes` type has, see :ref:`bytes-methods`." msgstr "" -"新しいバイト配列を返します。:class:`bytearray` クラスは0 <= x < 256の範囲の整" -"数からなる変更可能な配列です。:ref:`typesseq-mutable` に記述されている変更可" -"能な配列に対する普通のメソッドの大半を備えています。また、:class:`bytes` 型が" -"持つメソッドの大半も備えています(see :ref:`bytes-methods`)。" +"新しいバイト配列を返します。\n" +":class:`bytearray` クラスは、0 <= x < 256 の範囲の整数からなる可変シーケンス" +"です。\n" +":ref:`typesseq-mutable` で説明されている可変シーケンスの通常のメソッドの大半" +"に加え、\n" +":class:`bytes` 型のメソッドの大半も備えています (:ref:`bytes-methods` を参照" +"してください)。" #: ../../builtins/functions.rst:198 msgid "" @@ -706,7 +709,6 @@ msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "" ":ref:`binaryseq`, :ref:`typebytes`, :ref:`bytes-methods` も参照してください。" -#: ../../builtins/functions.rst:238 msgid "" "Return :const:`True` if the *object* argument appears callable, :const:" "`False` if not. If this returns ``True``, it is still possible that a call " @@ -714,12 +716,13 @@ msgid "" "that classes are callable (calling a class returns a new instance); " "instances are callable if their class has a :meth:`~object.__call__` method." msgstr "" -"*object* 引数が呼び出し可能オブジェクトであれば :const:`True` を、そうでなけ" -"れば :const:`False` を返します。この関数が ``True`` を返しても、呼び出しは失" -"敗する可能性がありますが、``False`` であれば、 *object* の呼び出しは決して成" -"功しません。なお、クラスは呼び出し可能 (クラスを呼び出すと新しいインスタンス" -"を返します) です。また、インスタンスはクラスが :meth:`~object.__call__` メ" -"ソッドを持つなら呼び出し可能です。" +"*object* 引数が呼び出せそうなオブジェクトであれば :const:`True` を、そうでな" +"ければ :const:`False` を返します。\n" +"この関数が ``True`` を返しても呼び出しが失敗する可能性はありますが、\n" +"``False`` であれば *object* の呼び出しは決して成功しません。\n" +"クラスは呼び出し可能です (クラスを呼び出すと新しいインスタンスを返します)。\n" +"インスタンスは、そのクラスが :meth:`~object.__call__` メソッドを持つ場合に呼" +"び出し可能です。" #: ../../builtins/functions.rst:244 msgid "" @@ -728,15 +731,15 @@ msgid "" msgstr "" "この関数は Python 3.0 で一度取り除かれましたが、Python 3.2 で復活しました。" -#: ../../builtins/functions.rst:251 msgid "" "Return the string representing a character with the specified Unicode code " "point. For example, ``chr(97)`` returns the string ``'a'``, while " "``chr(8364)`` returns the string ``'€'``. This is the inverse of :func:`ord`." msgstr "" -"指定されたUnicode コードポイントが文字を表す文字列を返します。例えば " -"``chr(97)`` は文字列 ``'a'`` を、 ``chr(8364)`` は文字列 ``'€'`` を返しま" -"す。 :func:`ord` の逆です。" +"指定された Unicode コードポイントを持つ文字を表す文字列を返します。\n" +"例えば、``chr(97)`` は文字列 ``'a'`` を、``chr(8364)`` は文字列 ``'€'`` を返" +"します。\n" +":func:`ord` の逆の操作です。" #: ../../builtins/functions.rst:255 msgid "" @@ -829,28 +832,28 @@ msgstr "" "クラスメソッドは :func:`property` など、他の :term:`デスクリプタ " "` をラップすることができなくなりました。" -#: ../../builtins/functions.rst:303 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " "string, a byte string, or an AST object. Refer to the :mod:`ast` module " "documentation for information on how to work with AST objects." msgstr "" -"*source* をコードオブジェクト、もしくは、 AST オブジェクトにコンパイルしま" -"す。 コードオブジェクトは :func:`exec` 文で実行したり、 :func:`eval` 呼び出し" -"で評価できます。 *source* は通常の文字列、 バイト列、 AST オブジェクトのいず" -"れでもかまいません。 AST オブジェクトへの、また、 AST オブジェクトからのコン" -"パイルの方法は、 :mod:`ast` モジュールのドキュメントを参照してください。" +"*source* をコードオブジェクトまたは AST オブジェクトにコンパイルします。\n" +"コードオブジェクトは :func:`exec` や :func:`eval` で実行できます。\n" +"*source* には、通常の文字列、バイト列、AST オブジェクトのいずれかを指定できま" +"す。\n" +"AST オブジェクトの扱い方については、:mod:`ast` モジュールのドキュメントを参照" +"してください。" -#: ../../builtins/functions.rst:308 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " "is commonly used)." msgstr "" -"*filename* 引数には、コードの読み出し元のファイルを与えなければなりません; " -"ファイルから読み出されるのでなければ、認識可能な値を渡して下さい " -"(``''`` が一般的に使われます)。" +"*filename* 引数には、コードの読み出し元のファイルを示す値を指定してくださ" +"い。\n" +"ファイルから読み出していない場合は、識別できる値を渡してください " +"(``''`` がよく使われます)。" #: ../../builtins/functions.rst:312 msgid "" @@ -927,7 +930,6 @@ msgstr "" "オプションの実引数 *module* には、モジュール名を指定します。 これはモジュール" "名で構文警告を明確に :ref:`filter ` するために必要です。" -#: ../../builtins/functions.rst:347 msgid "" "This function raises :exc:`SyntaxError` if the compiled source is invalid, " "including a *source* containing a null character or that cannot be decoded; :" @@ -937,6 +939,15 @@ msgid "" "with many thousands of nested operators; and :exc:`OverflowError` if " "*source* is too large." msgstr "" +"コンパイルするソースが不正な場合は :exc:`SyntaxError` を送出します。\n" +"これには、*source* にヌル文字が含まれている場合や、*source* をデコードできな" +"い場合も含まれます。\n" +"*mode* または *flags* が不正な場合や、文字列の *source* にサロゲート文字が含" +"まれている場合は :exc:`ValueError` を送出します。\n" +"数千もの演算子が入れ子になった式など、*source* が複雑すぎて解析やコンパイルが" +"できない場合は、:exc:`MemoryError` または :exc:`RecursionError` を送出しま" +"す。\n" +"*source* が大きすぎる場合は :exc:`OverflowError` を送出します。" #: ../../builtins/functions.rst:356 msgid "" @@ -1002,11 +1013,12 @@ msgstr "" "``async for``, および ``async with`` のサポートを有効化することができるように" "なりました。" -#: ../../builtins/functions.rst:390 msgid "" ":exc:`SyntaxError` is raised instead of :exc:`ValueError` when null bytes " "are encountered in *source*." msgstr "" +"*source* にヌルバイトが含まれている場合、:exc:`ValueError` ではなく :exc:" +"`SyntaxError` が送出されるようになりました。" #: ../../builtins/functions.rst:394 msgid "Added the *module* parameter." @@ -1061,7 +1073,6 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../builtins/functions.rst:426 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -1077,7 +1088,7 @@ msgid "" msgstr "" "引数が文字列の場合、実数部( :func:`float` と同じ形式)、虚数部(同様の形式" "で ``'j'`` または ``'J'`` 接尾辞)どちらか、あるいは両方(この場合、虚数部の" -"符号は必須)を含まなければなりません。文字列 は空白や括弧 ``'('`` と``')'`` " +"符号は必須)を含まなければなりません。文字列 は空白や括弧 ``'('`` と ``')'`` " "で囲むこともできますが、無視されます。文字列は、 ``'+'`` 、``'-'`` 、 " "``'j'`` または ``'J'`` 接尾辞 、そして10進数の間に空白を含んではなりません。" "たとえば ``complex('1+2j')`` はよいですが、 ``complex('1 + 2j')`` は :exc:" @@ -1132,10 +1143,8 @@ msgstr "引数がすべて省略された場合は、 ``0j`` を返します。" msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複素数型については :ref:`typesnumeric` に説明があります。" -#: ../../builtins/functions.rst:470 ../../builtins/functions.rst:847 -#: ../../builtins/functions.rst:1104 msgid "Grouping digits with underscores as in code literals is allowed." -msgstr "コードリテラル中で桁をグループ化するのにアンダースコアを利用できます。" +msgstr "コードリテラルと同様に、アンダースコアで桁を区切れるようになりました。" #: ../../builtins/functions.rst:473 msgid "" @@ -1221,14 +1230,13 @@ msgstr "" "だけ情報を集めようとします。結果のリストは必ずしも完全ではなく、カスタムの :" "func:`~object.__getattr__` を持つ場合は不正確かもしれません。" -#: ../../builtins/functions.rst:523 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " "complete, information:" msgstr "" -"デフォルトの :func:`dir` メカニズムは、完全というより最重要な情報を作成しよう" -"とするため、異なる型のオブジェクトでは異なって振る舞います:" +"デフォルトの :func:`dir` の仕組みは、網羅的な情報よりも関連性の高い情報を返そ" +"うとするため、オブジェクトの型によって異なる動作をします:" #: ../../builtins/functions.rst:527 msgid "" @@ -1238,13 +1246,12 @@ msgstr "" "オブジェクトがモジュールオブジェクトの場合、リストにはモジュールの属性の名前" "が含まれます。" -#: ../../builtins/functions.rst:530 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." msgstr "" -"オブジェクトが型オブジェクトやクラスオブジェクトの場合、リストにはその属性の" -"名前と、再帰的にたどったその基底クラスの属性が含まれます。" +"オブジェクトが型オブジェクトまたはクラスオブジェクトの場合、リストにはその属" +"性の名前と、基底クラスを再帰的にたどった属性の名前が含まれます。" #: ../../builtins/functions.rst:533 msgid "" @@ -1463,9 +1470,8 @@ msgstr "" "デフォルトの *locals* 名前空間のセマンティクスは、 組み込み :func:`locals` の" "説明のように調整された。" -#: ../../builtins/functions.rst:682 ../../builtins/functions.rst:764 msgid "*globals* can now be a :class:`frozendict`." -msgstr "*globals* は :class:`frozendict` になるようになった。" +msgstr "*globals* に :class:`frozendict` も指定できるようになりました。" #: ../../builtins/functions.rst:693 msgid "" @@ -1521,7 +1527,6 @@ msgstr "" "を意味します(「トップレベル」変数はクラス定義にてクラス変数として扱われるた" "め)。" -#: ../../builtins/functions.rst:720 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in module :mod:" @@ -1529,6 +1534,11 @@ msgid "" "used to restrict or change the available names, but this is **not** a " "security mechanism: the executed code can still access all builtins." msgstr "" +"*globals* 辞書にキー ``__builtins__`` の値が含まれていない場合、\n" +"そのキーに組み込みモジュール :mod:`builtins` の辞書への参照が挿入されます。\n" +"``__builtins__`` を上書きすると、利用できる名前を制限したり変更したりできます" +"が、これはセキュリティ機構では **ありません**。\n" +"実行されるコードは、依然としてすべての組み込み機能にアクセスできます。" #: ../../builtins/functions.rst:727 msgid "" @@ -1562,36 +1572,37 @@ msgstr "" msgid "Added the *closure* parameter." msgstr "*closure* パラメータが追加されました。" -#: ../../builtins/functions.rst:769 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " "iteration, or an iterator. If *function* is ``None``, the identity function " "is assumed, that is, all elements of *iterable* that are false are removed." msgstr "" -"*iterable* の要素のうち、 *function* が真であるものからイテレータを構築しま" -"す。 *iterable* にはシーケンスか、イテレーションをサポートするコンテナか、イ" -"テレータを渡せます。 *function* が ``None`` のときは恒等関数が指定されたもの" -"として扱われ、 *iterable* のうち偽であるものがすべて取り除かれます。" +"*iterable* の要素のうち、*function* を適用した結果が真になる要素からイテレー" +"タを構築します。\n" +"*iterable* には、シーケンス、イテレーションをサポートするコンテナ、イテレータ" +"のいずれかを指定できます。\n" +"*function* が ``None`` の場合は恒等関数が指定されたものとして扱われ、" +"*iterable* の要素のうち偽であるものがすべて取り除かれます。" -#: ../../builtins/functions.rst:775 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " "not ``None`` and ``(item for item in iterable if item)`` if function is " "``None``." msgstr "" -"なお、``filter(function, iterable)`` は、関数が ``None`` でなければジェネレー" -"タ式 ``(item for item in iterable if function(item))`` と同等で、関数が " -"``None`` なら ``(item for item in iterable if item)`` と同等です。" +"``filter(function, iterable)`` は、``function`` が ``None`` でなければジェネ" +"レータ式 ``(item for item in iterable if function(item))`` と等価です。\n" +"``function`` が ``None`` なら、``(item for item in iterable if item)`` と等価" +"です。" -#: ../../builtins/functions.rst:780 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." msgstr "" -"逆の働きをする関数については、 :func:`itertools.filterfalse` を参照してくださ" -"い。 *iterable* の要素のうち、 *function* が偽であるものを返します。" +"逆の働きをする関数については :func:`itertools.filterfalse` を参照してくださ" +"い。\n" +"*iterable* の要素のうち、*function* を適用した結果が偽になる要素を返します。" #: ../../builtins/functions.rst:791 msgid "Return a floating-point number constructed from a number or a string." @@ -1621,7 +1632,6 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../builtins/functions.rst:808 msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " @@ -1631,12 +1641,13 @@ msgid "" "conform to the :token:`~float:floatvalue` production rule in the following " "grammar, after leading and trailing whitespace characters are removed:" msgstr "" -"引数が文字列の場合、10進数でなければなりません。先頭に符号または空白を含んで" -"もかまいません。符号は ``'+'`` か ``'-'`` のいずれかです。正符号 ``'+'`` は生" -"成される値に対して何の効果もありません。引数は NaN (not-a-number) や正または" -"負の無限大をあらわす文字列でもかまいません。より正確にいうと、入力は先頭と末" -"尾の空白文字を除き、以下に示す :token:`~float:floatvalue` の生成規則に従う必" -"要があります:" +"引数が文字列の場合、10進数を含み、必要に応じて先頭に符号を付けたり、前後に空" +"白文字を付けたりできます。\n" +"符号は ``'+'`` または ``'-'`` で、``'+'`` は生成される値に影響しません。\n" +"引数には、NaN (not-a-number)、正または負の無限大を表す文字列も指定できま" +"す。\n" +"より正確には、先頭と末尾の空白文字を取り除いた入力が、以下の文法の :token:" +"`~float:floatvalue` の生成規則に従う必要があります:" #: ../../builtins/functions.rst:829 msgid "" @@ -1657,14 +1668,13 @@ msgstr "" "値の浮動小数点数が返されます。 引数が Python の浮動小数点数の範囲外なら、 :" "exc:`OverflowError` が送出されます。" -#: ../../builtins/functions.rst:837 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " "back to :meth:`~object.__index__`." msgstr "" "一般の Python オブジェクト ``x`` に対して、``float(x)`` は ``x.__float__()`` " -"に委譲します。 :meth:`~object.__float__()` が定義されていない場合、:meth:" +"に委譲します。 :meth:`~object.__float__` が定義されていない場合、:meth:" "`~object.__index__` へフォールバックします。" #: ../../builtins/functions.rst:841 @@ -1708,7 +1718,6 @@ msgstr "" "デフォルトの *format_spec* は空の文字列です。それは通常 :func:`str(value) " "` の呼び出しと同じ結果になります。" -#: ../../builtins/functions.rst:871 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1717,12 +1726,14 @@ msgid "" "and the *format_spec* is non-empty, or if either the *format_spec* or the " "return value are not strings." msgstr "" -"``format(value, format_spec)`` の呼び出しは、 ``type(value)." -"__format__(value, format_spec)`` に翻訳され、これは value の :meth:`~object." -"__format__` メソッドの検索をするとき、インスタンス辞書を回避します。このメ" -"ソッドの探索が :mod:`object` に到達しても *format_spec* が空にならなかった" -"り、 *format_spec* や返り値が文字列でなかったりした場合、 :exc:`TypeError` が" -"送出されます。" +"``format(value, format_spec)`` の呼び出しは、``type(value).__format__(value, " +"format_spec)`` に置き換えられ、\n" +"``value`` の :meth:`~object.__format__` メソッドを探す際にインスタンスの辞書" +"を参照しません。\n" +"メソッドの探索が :mod:`object` に到達し、かつ *format_spec* が空でない場合" +"や、\n" +"*format_spec* または返り値が文字列でない場合は、:exc:`TypeError` が送出されま" +"す。" #: ../../builtins/functions.rst:878 msgid "" @@ -1732,24 +1743,31 @@ msgstr "" "*format_spec* が空の文字列でない場合 ``object().__format__(format_spec)`` " "は :exc:`TypeError` を送出します。" -#: ../../builtins/functions.rst:889 msgid "" "Create a new frozen dictionary. The :class:`frozendict` object is a built-" "in class. See also :ref:`typesmapping` for documentation about this class." msgstr "" +"新しい凍結辞書を作成します。\n" +":class:`frozendict` オブジェクトは組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`typesmapping` も参照してください。" -#: ../../builtins/functions.rst:892 msgid "" "For other containers see the built-in :class:`dict`, :class:`list`, :class:" "`set`, and :class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" +"他のコンテナについては、組み込みの :class:`dict`、:class:`list`、:class:" +"`set`、:class:`tuple` クラスや、:mod:`collections` モジュールを参照してくださ" +"い。" -#: ../../builtins/functions.rst:902 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. :class:`frozenset` is a built-in class. See also :ref:`types-" "set` for documentation about this class." msgstr "" +"新しい :class:`frozenset` オブジェクトを返します。\n" +"必要に応じて *iterable* から要素を取り込むこともできます。\n" +":class:`frozenset` は組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`types-set` も参照してください。" #: ../../builtins/functions.rst:906 msgid "" @@ -1788,15 +1806,14 @@ msgstr "" "名前を持つ属性) の値を :func:`getattr` で取り出すためには、属性名を手動でマン" "グリングする必要があります。" -#: ../../builtins/functions.rst:931 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " "same regardless of where the function is called." msgstr "" -"現在のモジュールの名前空間を実装した辞書を返します。関数内のコードに対して" -"は、関数が定義されるときに辞書が設定され、その関数がどこから呼ばれたかにかか" -"わらず同じ内容になります。" +"現在のモジュールの名前空間を実装する辞書を返します。\n" +"関数内のコードでは、この辞書は関数の定義時に決まり、関数がどこから呼び出され" +"ても同じ辞書が使われます。" #: ../../builtins/functions.rst:938 msgid "" @@ -1859,11 +1876,10 @@ msgstr "" "さい。より詳しい情報は、 :ref:`位置専用引数についての FAQ の項目 ` を参照してください。" -#: ../../builtins/functions.rst:972 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "" -"この関数は、 :mod:`site` モジュールから、組み込みの名前空間に移されました。" +"この関数は :mod:`site` モジュールによって組み込み名前空間に追加されます。" #: ../../builtins/functions.rst:974 msgid "" @@ -1923,24 +1939,24 @@ msgstr "" msgid "This is the address of the object in memory." msgstr "これはオブジェクトのメモリアドレスです。" -#: ../../builtins/functions.rst:1020 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引数 ``id`` を指定して :ref:`監査イベント ` ``builtins.id`` を送出" -"します。 " +"します。" -#: ../../builtins/functions.rst:1026 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " "converts it to a string (stripping a trailing newline), and returns that. " "When EOF is read, :exc:`EOFError` is raised. Example::" msgstr "" -"引数 *prompt* が存在すれば、それが末尾の改行を除いて標準出力に書き出されま" -"す。次に、この関数は入力から 1 行を読み込み、文字列に変換して (末尾の改行を除" -"いて) 返します。 EOF が読み込まれたとき、 :exc:`EOFError` が送出されます。" +"実引数 *prompt* が指定されている場合、その値を末尾に改行を付けずに標準出力に" +"書き出します。\n" +"次に、入力から1行を読み取り、文字列に変換して末尾の改行を取り除き、その文字列" +"を返します。\n" +"EOF を読み取ると :exc:`EOFError` が送出されます。\n" "例::" #: ../../builtins/functions.rst:1031 @@ -2041,7 +2057,6 @@ msgstr "" "の先頭に任意の数のゼロを付けたり、前後に空白文字を付けたり、各桁を単一の下線" "で区切ったりしても有効です。" -#: ../../builtins/functions.rst:1084 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -2054,17 +2069,17 @@ msgid "" "prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not legal, " "while ``int('010')`` and ``int('010', 8)`` are." msgstr "" -"n-進数の整数文字列は、各桁が0から n-1 の数値で表されます。ユニコードの10進数" -"では、各桁は0から9のいずれかです。また10から35までの値は ``a`` から ``z`` (ま" -"たは ``A`` から ``Z``) で表されます。デフォルトの *base* は10です。基数に指定" -"可能な値は0および2から36までの整数です。2進数、8進数、16進数の文字列は、整数" -"リテラルと同様に、それぞれ ``0b``/``0B``, ``0o``/``0O``, または ``0x``/" -"``0X`` をプレフィックスとして追加することができます。基数を0に指定した場合、" -"文字列は :ref:`コードにおける整数リテラル ` と同じように解釈されま" -"す。すなわち、プレフィックスによって基数が2, 8, 10, または 16 のどれになるか" -"が決まります。基数を0にした場合先頭にゼロを追加することはできません: すなわ" -"ち ``int('010', 0)`` は基数を0に指定しているため不正ですが、 ``int('010')`` " -"や ``int('010', 8)`` は有効です。" +"n 進数の整数文字列は、各桁が 0 から n-1 の値を表す数字で構成されます。\n" +"0 から 9 の値は、任意の Unicode 10進数字で表せます。\n" +"10 から 35 の値は、``a`` から ``z`` (または ``A`` から ``Z``) で表せます。\n" +"*base* のデフォルト値は 10 で、指定できる基数は 0 および 2 から 36 です。\n" +"2 進、8 進、16 進の文字列には、コード中の整数リテラルと同様に、それぞれ " +"``0b``/``0B``、``0o``/``0O``、``0x``/``0X`` という接頭辞を付けられます。\n" +"基数が 0 の場合は、:ref:`コード中の整数リテラル ` と同じように、接" +"頭辞によって実際の基数が 2、8、10、16 のいずれかに決まります。\n" +"基数が 0 の場合は先頭に余分なゼロを付けることもできません。\n" +"``int('010', 0)`` は無効ですが、``int('010')`` と ``int('010', 8)`` は有効で" +"す。" #: ../../builtins/functions.rst:1095 msgid "The integer type is described in :ref:`typesnumeric`." @@ -2110,10 +2125,11 @@ msgstr "" "`ValueError` が送出されます。詳しくは :ref:`整数文字列の変換における長さ制限 " "` を参照してください。" -#: ../../builtins/functions.rst:1121 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." msgstr "" +":func:`int` は :meth:`~object.__trunc__` メソッドに処理を委譲しなくなりまし" +"た。" #: ../../builtins/functions.rst:1126 msgid "" @@ -2142,7 +2158,6 @@ msgstr "" msgid "*classinfo* can be a :ref:`types-union`." msgstr "*classinfo* に :ref:`types-union` を指定できるようになりました。" -#: ../../builtins/functions.rst:1143 msgid "" "Return ``True`` if *cls* is a subclass (direct, indirect, or :term:`virtual " "`) of *classinfo*. A class is considered a subclass of " @@ -2151,6 +2166,14 @@ msgid "" "is a subclass of any entry in *classinfo*. In any other case, a :exc:" "`TypeError` exception is raised." msgstr "" +"*cls* が *classinfo* のサブクラス (直接、間接、または :term:`仮想 ` のサブクラス) である場合、``True`` を返します。\n" +"クラスは、それ自体のサブクラスと見なされます。\n" +"*classinfo* には、クラスオブジェクトのタプル (または再帰的にそのようなタプル" +"を含むタプル) や :ref:`types-union` も指定できます。\n" +"その場合、*cls* が *classinfo* 内のいずれかのサブクラスであれば ``True`` を返" +"します。\n" +"*classinfo* がこれらのいずれでもない場合は、:exc:`TypeError` が送出されます。" #: ../../builtins/functions.rst:1158 msgid "" @@ -2249,20 +2272,19 @@ msgstr "" "モジュール スコープでは、単一の名前空間で :func:`exec` や :func:`eval` を使う" "場合と同じく、この関数は :func:`globals` と同じ名前空間を返します。" -#: ../../builtins/functions.rst:1214 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" -"クラス スコープでは、メタクラス コンストラクタに渡された名前空間を返します。" +"クラススコープでは、メタクラスのコンストラクタに渡される名前空間を返します。" -#: ../../builtins/functions.rst:1217 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" -"``exec()`` や ``eval()`` が引数 local と global が分けて使われてる場合では、" -"関数の呼び出しで渡されたローカル名前空間を返します。" +"ローカル用とグローバル用に別々の実引数を渡して ``exec()`` や ``eval()`` を使" +"う場合、\n" +"その関数呼び出しに渡されたローカル名前空間を返します。" #: ../../builtins/functions.rst:1220 msgid "" @@ -2339,7 +2361,6 @@ msgstr "" "の振る舞いは上記のようになりました。定義されただけで、その他のスコープの振る" "舞いは以前のバージョンのままです。" -#: ../../builtins/functions.rst:1259 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2350,6 +2371,17 @@ msgid "" "raised. For cases where the function inputs are already arranged into " "argument tuples, see :func:`itertools.starmap`." msgstr "" +"*iterable* の各要素に *function* を適用し、その結果を生成するイテレータを返し" +"ます。\n" +"追加の *iterables* 引数が渡された場合、*function* はイテラブルの数だけ引数を" +"受け取れる必要があります。\n" +"この関数は、すべてのイテラブルから並行して取り出した要素に適用されます。\n" +"複数のイテラブルがある場合、最も短いイテラブルが :term:`枯渇する " +"` とイテレータは停止します。\n" +"*strict* が ``True`` で、いずれかのイテラブルが他より先に枯渇した場合は、:" +"exc:`ValueError` が送出されます。\n" +"関数への入力がすでに引数のタプルにまとめられている場合は、:func:`itertools." +"starmap` を参照してください。" #: ../../builtins/functions.rst:1268 msgid "Added the *strict* parameter." @@ -2362,15 +2394,14 @@ msgid "" msgstr "" "iterable の中で最大の要素、または2つ以上の引数の中で最大のものを返します。" -#: ../../builtins/functions.rst:1279 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " "arguments are provided, the largest of the positional arguments is returned." msgstr "" -"位置引数が1つだけ与えられた場合、それは空でない :term:`iterable` でなくてはい" -"けません。その iterable の最大の要素が返されます。2 つ以上のキーワード無しの" -"位置引数が与えられた場合、その位置引数の中で最大のものが返されます。" +"位置引数が1つの場合は、:term:`iterable` を指定します。\n" +"そのイテラブルの最大の要素を返します。\n" +"位置引数が2つ以上の場合は、それらのうち最大のものを返します。" #: ../../builtins/functions.rst:1284 ../../builtins/functions.rst:1322 msgid "" @@ -2423,15 +2454,14 @@ msgid "" msgstr "" "iterable の中で最小の要素、または2つ以上の引数の中で最小のものを返します。" -#: ../../builtins/functions.rst:1317 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " "arguments are provided, the smallest of the positional arguments is returned." msgstr "" -"位置引数が1つだけ与えられた場合、それは空でない :term:`iterable` でなくてはい" -"けません。その iterable の最小の要素が返されます。2 つ以上のキーワード無しの" -"位置引数が与えられた場合、その位置引数の中で最小のものが返されます。" +"位置引数が1つの場合は、:term:`iterable` を指定します。\n" +"そのイテラブルの最小の要素を返します。\n" +"位置引数が2つ以上の場合は、それらのうち最小のものを返します。" #: ../../builtins/functions.rst:1328 msgid "" @@ -2444,12 +2474,16 @@ msgstr "" "は、``sorted(iterable, key=keyfunc)[0]`` や ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` のような、他のソート安定性を維持するツールと両立します。" -#: ../../builtins/functions.rst:1343 msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " "iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised." msgstr "" +":term:`イテレータ ` の :meth:`~iterator.__next__` メソッドを呼び出" +"して、次の要素を取得します。\n" +"イテレータが :term:`枯渇した ` 場合、*default* が指定されていれば" +"その値を返し、\n" +"指定されていなければ :exc:`StopIteration` を送出します。" #: ../../builtins/functions.rst:1350 msgid "" @@ -2503,7 +2537,6 @@ msgstr "" "す。ファイルを開くことができなければ、:exc:`OSError` が送出されます。\n" "この関数の利用例について、 :ref:`tut-files` を参照してください。" -#: ../../builtins/functions.rst:1395 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2511,13 +2544,13 @@ msgid "" "given, it is closed when the returned I/O object is closed unless *closefd* " "is set to ``False``.)" msgstr "" -"*file* は :term:`path-like object` で、開くファイルのパス名 (絶対パスまたは現" -"在の作業ディレクトリからの相対パス) あるいはラップするファイルの整数のファイ" -"ルデスクリプタを与えます。 (ファイルデスクリプタが与えられた場合、 *closefd* " -"が ``False`` に設定されていないかぎり、この関数が返す I/O オブジェクトがク" -"ローズされるときにファイルデスクリプタもクローズされます。)" +"*file* には、開くファイルのパス名 (絶対パスまたは現在の作業ディレクトリからの" +"相対パス) を示す :term:`path-like object` か、\n" +"ラップするファイルの整数のファイル記述子を指定します。\n" +"(ファイル記述子を指定した場合、*closefd* が ``False`` に設定されていなけれ" +"ば、\n" +"返された I/O オブジェクトを閉じるときにそのファイル記述子も閉じられます。)" -#: ../../builtins/functions.rst:1401 msgid "" "*mode* is an optional string that specifies the mode in which the file is " "opened. It defaults to ``'r'`` which means open for reading in text mode. " @@ -2530,6 +2563,21 @@ msgid "" "the current locale encoding. (For reading and writing raw bytes use binary " "mode and leave *encoding* unspecified.) The available modes are:" msgstr "" +"*mode* は、ファイルを開くモードを指定するオプションの文字列です。\n" +"デフォルト値は、テキストモードの読み込み用に開くことを意味する ``'r'`` で" +"す。\n" +"他によく使われる値には、書き込み用の ``'w'`` (ファイルがすでに存在する場合は" +"内容を切り詰めます)、\n" +"排他的な作成用の ``'x'``、追記用の ``'a'`` があります\n" +"(*一部の* Unix システムでは、追記用モードでは現在のシーク位置にかかわらず *す" +"べての* 書き込みがファイルの末尾に追加されます)。\n" +"テキストモードで *encoding* を指定しない場合、デフォルトで UTF-8 が使われま" +"す。\n" +":ref:`Python UTF-8 モード ` が無効の場合は、:func:`locale." +"getencoding` を呼び出して現在のロケールエンコーディングを取得します。\n" +"(生のバイト列を読み書きするには、バイナリモードを使い、*encoding* は指定しな" +"いでください。)\n" +"利用できるモードは次のとおりです:" #: ../../builtins/functions.rst:1419 msgid "Character" @@ -2595,17 +2643,16 @@ msgstr "``'+'``" msgid "open for updating (reading and writing)" msgstr "更新用に開く (読み込み・書き込み用)" -#: ../../builtins/functions.rst:1430 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " "``'r+b'`` open the file with no truncation." msgstr "" -"デフォルトのモードは ``'r'`` (テキストの読み込み用に開く、 ``'rt'`` と同義) " -"です。 ``'w+'`` と ``'w+b'`` はファイルを開いて上書きします。 ``'r+'`` と " -"``'r+b'`` はファイルを上書きせずに開きます。" +"デフォルトのモードは ``'r'`` です (テキストの読み込み用に開き、``'rt'`` と同" +"義です)。\n" +"モード ``'w+'`` と ``'w+b'`` はファイルを開いて内容を切り詰めます。\n" +"モード ``'r+'`` と ``'r+b'`` は、内容を切り詰めずにファイルを開きます。" -#: ../../builtins/functions.rst:1434 msgid "" "As mentioned in the :ref:`io-overview`, Python distinguishes between binary " "and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* " @@ -2615,6 +2662,15 @@ msgid "" "having been first decoded using the default encoding or using the specified " "*encoding* if given." msgstr "" +":ref:`io-overview` で説明したように、Python はバイナリ I/O とテキスト I/O を" +"区別します。\n" +"バイナリモード (*mode* 引数に ``'b'`` を含めます) で開いたファイルは、デコー" +"ドせずに内容を :class:`bytes` オブジェクトとして返します。\n" +"テキストモード (デフォルト、または *mode* 引数に ``'t'`` を含めた場合) で" +"は、\n" +"デフォルトのエンコーディング、または *encoding* に指定されたエンコーディング" +"でバイト列をデコードしてから、\n" +"ファイルの内容を :class:`str` として返します。" #: ../../builtins/functions.rst:1444 msgid "" @@ -2673,7 +2729,6 @@ msgstr "" "ファイル) は行バッファリングを使用します。 その他のテキストファイルは、上で説" "明したバイナリファイル用の方針を使用します。" -#: ../../builtins/functions.rst:1467 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " "This should only be used in text mode. The default encoding is UTF-8; if :" @@ -2683,8 +2738,19 @@ msgid "" "specifies the current locale encoding explicitly. See the :mod:`codecs` " "module for the list of supported encodings." msgstr "" +"*encoding* は、ファイルのデコードやエンコードに使うエンコーディングの名前で" +"す。\n" +"テキストモードでのみ使ってください。\n" +"デフォルトのエンコーディングは UTF-8 です。\n" +":ref:`Python UTF-8 モード ` が無効の場合、デフォルト値はプラット" +"フォームに依存します (:func:`locale.getencoding` が返す値になります)。\n" +"Python がサポートする任意の :term:`テキストエンコーディング ` " +"を使うことができ、\n" +"``encoding=\"locale\"`` を指定すると現在のロケールエンコーディングを明示的に" +"選べます。\n" +"サポートするエンコーディングの一覧は :mod:`codecs` モジュールを参照してくださ" +"い。" -#: ../../builtins/functions.rst:1475 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " @@ -2692,6 +2758,12 @@ msgid "" "has been registered with :func:`codecs.register_error` is also valid. The " "standard names can be found in :ref:`error-handlers`." msgstr "" +"*errors* は、エンコードやデコードのエラーをどう処理するかを指定するオプション" +"の文字列です。\n" +"バイナリモードでは使えません。\n" +"さまざまな標準のエラーハンドラが利用できるほか、:func:`codecs." +"register_error` で登録された任意のエラー処理名も指定できます。\n" +"標準の名前は :ref:`error-handlers` に記載されています。" #: ../../builtins/functions.rst:1487 msgid "" @@ -2894,23 +2966,23 @@ msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "" ":class:`os.PathLike` を実装したオブジェクトを受け入れるようになりました。" -#: ../../builtins/functions.rst:1583 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." msgstr "" -"Windowsでは、コンソールバッファのオープンは、:class:`io.FileIO` ではなく、:" -"class:`io.RawIOBase` のサブクラスを返すでしょう。" +"Windows では、コンソールバッファを開くと、:class:`io.FileIO` 以外の :class:" +"`io.RawIOBase` のサブクラスが返される場合があります。" #: ../../builtins/functions.rst:1586 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` モードは削除されました。" -#: ../../builtins/functions.rst:1589 msgid "" "UTF-8 is now the default encoding, instead of the platform-dependent locale " "encoding (:pep:`686`)." msgstr "" +"プラットフォームに依存するロケールエンコーディングに代わり、UTF-8 がデフォル" +"トのエンコーディングになりました (:pep:`686`)。" #: ../../builtins/functions.rst:1595 msgid "Return the ordinal value of a character." @@ -2936,16 +3008,16 @@ msgstr "" "引数が 長さ1の :class:`bytes` または :class:`bytearray` である場合は、そのバ" "イト値を返します。例えば、 ``ord(b'a')`` は ``97`` になります。" -#: ../../builtins/functions.rst:1609 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " "mod``). The two-argument form ``pow(base, exp)`` is equivalent to using the " "power operator: ``base**exp``." msgstr "" -"*base* の *exp* 乗を返します; *mod* があれば、*base* の *exp* 乗に対する " -"*mod* の剰余を返します (``pow(base, exp) % mod`` より効率よく計算されます)。" -"二引数の形式 ``pow(base, exp)`` は、冪乗演算子を使った ``base**exp`` と等価で" +"*base* の *exp* 乗を返します。\n" +"*mod* を指定した場合は、*base* の *exp* 乗を *mod* で割った余りを返します " +"(``pow(base, exp) % mod`` より効率よく計算されます)。\n" +"2引数形式の ``pow(base, exp)`` は、冪乗演算子を使う ``base**exp`` と等価で" "す。" #: ../../builtins/functions.rst:1614 @@ -3073,9 +3145,8 @@ msgstr "" "です。*fdel* は属性値を削除するための関数です。*doc* は属性の docstring を作" "成します。" -#: ../../builtins/functions.rst:1682 msgid "A typical use is to define a managed attribute ``x``::" -msgstr "典型的な使用法は、属性 ``x`` の処理の定義です::" +msgstr "典型的な用途は、アクセスを管理する属性 ``x`` を定義することです。 ::" #: ../../builtins/functions.rst:1684 msgid "" @@ -3117,13 +3188,18 @@ msgstr "" "*c* が *C* のインスタンスならば、``c.x`` は getter を呼び出し、``c.x = " "value`` は setter を、``del c.x`` は deleter を呼び出します。" -#: ../../builtins/functions.rst:1702 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " "possible to create read-only properties easily using :deco:`property` as a :" "term:`decorator`::" msgstr "" +"*doc* が指定されていれば、その値がプロパティ属性のドキュメンテーション文字列" +"になります。\n" +"指定されていなければ、*fget* にドキュメンテーション文字列がある場合に、プロパ" +"ティがその文字列をコピーします。\n" +"これにより、:deco:`property` を :term:`デコレータ ` として使うこと" +"で、読み出し専用のプロパティを簡単に作成できます。 ::" #: ../../builtins/functions.rst:1706 msgid "" @@ -3220,9 +3296,10 @@ msgstr "" "返される property オブジェクトも、コンストラクタの引数に対応した ``fget``, " "``fset``, および ``fdel`` 属性を持ちます。" -#: ../../builtins/functions.rst:1754 msgid "The docstrings of property objects are now writeable." -msgstr "属性オブジェクトのドックストリングが書き込み可能になりました。" +msgstr "" +"プロパティオブジェクトのドキュメンテーション文字列が書き込み可能になりまし" +"た。" #: ../../builtins/functions.rst:1759 msgid "" @@ -3238,7 +3315,6 @@ msgstr "" ":class:`range` は、実際には関数ではなくイミュータブルなシーケンス型で、 :ref:" "`typesseq-range` と :ref:`typesseq` にドキュメント化されています。" -#: ../../builtins/functions.rst:1776 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -3250,20 +3326,21 @@ msgid "" "method. If :func:`sys.displayhook` is not accessible, this function will " "raise :exc:`RuntimeError`." msgstr "" -"オブジェクトの印字可能な表現を含む文字列を返します。この関数は多くの型につい" -"て、 :func:`eval` に渡されたときと同じ値を持つようなオブジェクトを表す文字列" -"を生成しようとします。そうでない場合は、山括弧に囲まれたオブジェクトの型の名" -"前と追加の情報 (大抵の場合はオブジェクトの名前とアドレスを含みます) を返しま" -"す。クラスは、 :meth:`~object.__repr__` メソッドを定義することで、この関数に" -"よりそのクラスのインスタンスが返すものを制御することができます。:func:`sys." -"displayhook` にアクセスできない場合、この関数は :exc:`RuntimeError` を送出し" -"ます。" +"オブジェクトの印字可能な表現を含む文字列を返します。\n" +"多くの型では、:func:`eval` に渡すと元のオブジェクトと同じ値を持つオブジェクト" +"が得られるような文字列を返そうとします。\n" +"それ以外の場合、オブジェクトの型名と追加情報を含む、山括弧で囲まれた文字列を" +"返します。\n" +"追加情報には、オブジェクトの名前やアドレスが含まれることがよくあります。\n" +"クラスに :meth:`~object.__repr__` メソッドを定義すると、そのクラスのインスタ" +"ンスに対してこの関数が返すものを制御できます。\n" +":func:`sys.displayhook` にアクセスできない場合、この関数は :exc:" +"`RuntimeError` を送出します。" #: ../../builtins/functions.rst:1787 msgid "This class has a custom representation that can be evaluated::" msgstr "このクラスは、eval 評価可能な独自の representation を持ちます::" -#: ../../builtins/functions.rst:1789 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3273,6 +3350,13 @@ msgid "" " def __repr__(self):\n" " return f\"Person({self.name!r}, {self.age!r})\"" msgstr "" +"class Person:\n" +" def __init__(self, name, age):\n" +" self.name = name\n" +" self.age = age\n" +"\n" +" def __repr__(self):\n" +" return f\"Person({self.name!r}, {self.age!r})\"" #: ../../builtins/functions.rst:1800 msgid "" @@ -3314,13 +3398,12 @@ msgstr "" "返り値は *ndigits* が指定されていないか ``None`` の場合は整数、そうでなければ" "返り値は *number* と同じ型です。" -#: ../../builtins/functions.rst:1821 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -"一般的な Python オブジェクト ``number`` に対して、``round`` は処理を `number." -"__round__` に移譲します。" +"一般的な Python オブジェクト ``number`` に対して、``round`` は処理を " +"``number.__round__`` に委譲します。" #: ../../builtins/functions.rst:1826 msgid "" @@ -3335,12 +3418,15 @@ msgstr "" "これはバグではありません: これはほとんどの小数が浮動小数点数で正確に表せない" "ことの結果です。詳しくは :ref:`tut-fp-issues` を参照してください。" -#: ../../builtins/functions.rst:1837 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. :class:`set` is a built-in class. See also :ref:`types-set` " "for documentation about this class." msgstr "" +"新しい :class:`set` オブジェクトを返します。\n" +"必要に応じて *iterable* から要素を取り込むこともできます。\n" +":class:`set` は組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`types-set` も参照してください。" #: ../../builtins/functions.rst:1841 msgid "" @@ -3390,65 +3476,77 @@ msgstr "" "名前を持つ属性) の値を :func:`setattr` でセットするためには、属性名を手動でマ" "ングリングする必要があります。" -#: ../../builtins/functions.rst:1870 msgid "" "Return a new unique sentinel object. *name* must be a :class:`str`, and is " "used by default as the returned object's representation::" msgstr "" +"一意な新しいセンチネルオブジェクトを返します。\n" +"*name* は :class:`str` でなければならず、デフォルトでは返されるオブジェクトの" +"文字列表現として使われます。 ::" -#: ../../builtins/functions.rst:1873 msgid "" ">>> MISSING = sentinel(\"MISSING\")\n" ">>> MISSING\n" "MISSING" msgstr "" +">>> MISSING = sentinel(\"MISSING\")\n" +">>> MISSING\n" +"MISSING" -#: ../../builtins/functions.rst:1877 msgid "" "The optional *repr* argument can be used to specify a different " "representation::" -msgstr "" +msgstr "オプションの *repr* 引数を使うと、別の文字列表現を指定できます。 ::" -#: ../../builtins/functions.rst:1879 msgid "" ">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" ">>> MISSING\n" "" msgstr "" +">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" +">>> MISSING\n" +"" -#: ../../builtins/functions.rst:1883 msgid "" "Sentinel objects are truthy and compare equal only to themselves. They are " "intended to be compared with the :keyword:`is` operator." msgstr "" +"センチネルオブジェクトは真と評価され、自分自身との比較でのみ等しいと判定され" +"ます。\n" +"比較には :keyword:`is` 演算子を使うことを想定しています。" -#: ../../builtins/functions.rst:1886 msgid "``sentinel`` does not support subclassing." -msgstr "" +msgstr "``sentinel`` はサブクラス化をサポートしません。" -#: ../../builtins/functions.rst:1888 msgid "Shallow and deep copies of a sentinel object return the object itself." msgstr "" +"センチネルオブジェクトの浅いコピーと深いコピーは、そのオブジェクト自身を返し" +"ます。" -#: ../../builtins/functions.rst:1890 msgid "" "Sentinels are conventionally assigned to a variable with a matching name. " "Sentinels defined in this way can be used in :term:`type hints `::" msgstr "" +"慣例として、センチネルはその名前と一致する変数に代入します。\n" +"このように定義したセンチネルは :term:`型ヒント ` に使えます。 ::" -#: ../../builtins/functions.rst:1893 msgid "" "MISSING = sentinel(\"MISSING\")\n" "\n" "def next_value(default: int | MISSING = MISSING):\n" " ..." msgstr "" +"MISSING = sentinel(\"MISSING\")\n" +"\n" +"def next_value(default: int | MISSING = MISSING):\n" +" ..." -#: ../../builtins/functions.rst:1898 msgid "" "Sentinel objects support the :ref:`| ` operator for use in type " "expressions." msgstr "" +"センチネルオブジェクトは、型の式で使うための :ref:`| ` 演算子をサ" +"ポートします。" #: ../../builtins/functions.rst:1900 msgid "" @@ -3460,7 +3558,6 @@ msgid "" "preserved after pickling::" msgstr "" -#: ../../builtins/functions.rst:1907 msgid "" "import pickle\n" "\n" @@ -3473,20 +3570,29 @@ msgid "" "\n" "assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" msgstr "" +"import pickle\n" +"\n" +"PICKLABLE = sentinel(\"PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(PICKLABLE)) is PICKLABLE\n" +"\n" +"class Cls:\n" +" PICKLABLE = sentinel(\"Cls.PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" -#: ../../builtins/functions.rst:1918 msgid "Sentinel objects have the following attributes:" -msgstr "" +msgstr "センチネルオブジェクトには、次の属性があります:" -#: ../../builtins/functions.rst:1922 msgid "The sentinel's name." -msgstr "" +msgstr "センチネルの名前。" -#: ../../builtins/functions.rst:1926 msgid "" "The name of the module where the sentinel was created. This attribute is " "writable." msgstr "" +"センチネルが作成されたモジュールの名前。\n" +"この属性は書き込み可能です。" #: ../../builtins/functions.rst:1934 msgid "" @@ -3542,14 +3648,13 @@ msgstr "" "2 つのオプション引数があり、これらはキーワード引数として指定されなければなり" "ません。" -#: ../../builtins/functions.rst:1962 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -"*key* には 1 引数関数を指定します。これは *iterable* の各要素から比較キーを展" -"開するのに使われます (例えば、 ``key=str.lower`` のように指定します)。\n" +"*key* には、*iterable* の各要素から比較キーを取り出すための1引数関数を指定し" +"ます (例えば ``key=str.lower``)。\n" "デフォルト値は ``None`` です (要素を直接比較します)。" #: ../../builtins/functions.rst:1966 @@ -3580,7 +3685,6 @@ msgstr "" "でソートを行なうのに役立ちます(例えば部署でソートしてから給与の等級でソート" "する場合)。" -#: ../../builtins/functions.rst:1977 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3591,14 +3695,14 @@ msgid "" "mixed type comparisons which can call the reflected :meth:`~object.__gt__` " "method." msgstr "" -"ソートアルゴリズムは、要素間の比較に ``<`` 演算子だけを使います。したがって" -"ソートのためには :meth:`~object.__lt__` メソッドを定義すれば十分なはずです" -"が、 :PEP:`8` は6つの :ref:`比較演算子 ` を全て実装することを推" -"奨しています。これにより、異なるメソッドを必要とする :func:`max` のような他の" -"ソートツールを、同じデータに対して適用することによって起こりうるバグを避ける" -"助けになります。6つの比較演算子を全て実装することは、リフレクションによって :" -"meth:`~object.__gt__` メソッドを呼び出す可能性のある型混合の比較での混乱を避" -"けることにも役立ちます。 " +"ソートアルゴリズムは、要素間の比較に ``<`` だけを使います。\n" +"ソートには :meth:`~object.__lt__` メソッドを定義すれば十分ですが、:PEP:`8` は" +"6つの :ref:`拡張比較 ` をすべて実装することを推奨しています。\n" +"これにより、異なるメソッドに依存する :func:`max` などの順序付けを行うツールで" +"同じデータを使うときに、バグを避けやすくなります。\n" +"6つの比較をすべて実装すると、異なる型の比較で、被演算子を入れ替えた比較に対応" +"する :meth:`~object.__gt__` メソッドが呼び出される場合の混乱も避けやすくなり" +"ます。" #: ../../builtins/functions.rst:1986 msgid "" @@ -3648,12 +3752,14 @@ msgstr "" "ソッド :term:`descriptor` は呼び出し可能でもあるため、(``f()`` のように) クラ" "ス定義の中でも使用できます。" -#: ../../builtins/functions.rst:2007 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :deco:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" +"Python の静的メソッドは、Java や C++ の静的メソッドに似ています。\n" +"別のコンストラクタをクラスに用意する際に便利な :deco:`classmethod` も参照して" +"ください。" #: ../../builtins/functions.rst:2011 msgid "" @@ -3687,13 +3793,17 @@ msgstr "" msgid "For more information on static methods, see :ref:`types`." msgstr "静的メソッドについて詳しい情報は :ref:`types` を参照してください。" -#: ../../builtins/functions.rst:2025 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" "attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " "``__wrapped__`` attribute, and are now callable as regular functions." msgstr "" +"静的メソッドは、メソッドの属性 (:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__`、:attr:`~function.__annotations__`) を継承し、\n" +"新しい ``__wrapped__`` 属性を持つようになりました。\n" +"また、通常の関数として呼び出せるようになりました。" #: ../../builtins/functions.rst:2043 msgid "" @@ -3710,14 +3820,13 @@ msgstr "" "``str`` は組み込みの文字列 :term:`クラス` です。文字列に関する一般的な" "情報は、:ref:`textseq` を参照してください。" -#: ../../builtins/functions.rst:2051 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -"*start* と *iterable* の要素を左から右へ合計し、総和を返します。 *iterable* " -"の要素は通常は数値で、start の値は文字列であってはなりません。" +"*start* と *iterable* の要素を左から右へ加算し、総和を返します。\n" +"*iterable* の要素は通常は数値で、``start`` の値には文字列を指定できません。" #: ../../builtins/functions.rst:2055 msgid "" @@ -3739,19 +3848,20 @@ msgstr "" "*start* パラメータをキーワード引数として指定することができるようになりまし" "た。" -#: ../../builtins/functions.rst:2064 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -"浮動小数点数の総和を計算するとき、ほとんどの環境でより高精度な結果とより良い" -"互換性が得られるアルゴリズムを使用するようになりました。" +"浮動小数点数の総和を計算するアルゴリズムが変更され、\n" +"ほとんどのビルドで精度が向上し、加算する順序を入れ替えたときも結果がより一致" +"しやすくなりました。" -#: ../../builtins/functions.rst:2067 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." msgstr "" +"浮動小数点数の総和と同じアルゴリズムを使う、複素数の総和に特化した処理が追加" +"されました。" #: ../../builtins/functions.rst:2075 msgid "" @@ -3781,13 +3891,15 @@ msgstr "" "> object`` であり、 *type* の値が ``B`` だとすると、 :func:`super` は ``C -> " "A -> object`` の順番でメソッドを検索します。" -#: ../../builtins/functions.rst:2087 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" +"*object_or_type* に対応するクラスの :attr:`~type.__mro__` 属性には、:func:" +"`getattr` と :func:`super` の両方が使うメソッド解決順序が記載されています。\n" +"この属性は動的であり、継承階層が更新されると変わることがあります。" #: ../../builtins/functions.rst:2092 msgid "" @@ -3828,7 +3940,6 @@ msgstr "" "メンテナンスしやすくなります。この用途は他のプログラミング言語で見られる " "*super* の用途によく似ています。" -#: ../../builtins/functions.rst:2109 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3840,14 +3951,15 @@ msgid "" "changes in the class hierarchy, and because that order can include sibling " "classes that are unknown prior to runtime)." msgstr "" -"2つ目の用途は動的な実行環境において協調的 (cooperative) な多重継承をサポート" -"することです。これは Python に特有の用途で、静的にコンパイルされる言語や、単" -"継承のみをサポートする言語には見られないものです。この機能により、同じ名前の" -"メソッドを実装する複数の基底クラスを使った \"ダイヤモンド型* の継承構造を実装" -"することができます。良い設計は、そのような実装において、どのような場合でも同" -"じ呼び出しシグネチャを持つように強制します。 (理由は呼び出しの順序が実行時に" -"決定されること、呼び出し順序はクラス階層構造の変化に順応すること、そして呼び" -"出し順序が実行時まで未知の兄弟クラスが含まれる場合があることです)。" +"2つ目の用途は、動的な実行環境で協調的な多重継承をサポートすることです。\n" +"これは Python 特有の用途であり、静的にコンパイルされる言語や単継承だけをサ" +"ポートする言語には見られません。\n" +"これにより、複数の基底クラスが同じメソッドを実装する「ダイヤモンド型」の継承" +"構造を実現できます。\n" +"適切に設計するには、これらの実装の呼び出しシグネチャをすべて同じにする必要が" +"あります\n" +"(呼び出しの順序が実行時に決まり、その順序はクラス階層の変化に応じて変わり、\n" +"実行時まで分からない兄弟クラスもその順序に含まれる可能性があるためです)。" #: ../../builtins/functions.rst:2119 msgid "For both use cases, a typical superclass call looks like this::" @@ -3892,7 +4004,6 @@ msgstr "" "文や ``super()[name]`` のような演算子を使った暗黙の探索向けには定義されていま" "せん。" -#: ../../builtins/functions.rst:2138 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3901,11 +4012,12 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" -"また、 :func:`super` の使用は引数無しの形式を除きメソッド内部に限定されないこ" -"とにも注目して下さい。2引数の形式は、必要な要素を正確に指定するので、適当な参" -"照を作ることができます。クラス定義中における引数無しの形式は、定義されている" -"クラスを取り出すのに必要な詳細を、通常の方法で現在のインスタンスにアクセスす" -"るようにコンパイラが埋めるのではたらきます。" +"引数なしの形式を除き、:func:`super` はメソッドの外でも使えます。\n" +"2引数形式では、引数を明示的に指定し、適切な参照を作成します。\n" +"引数なしの形式がクラス定義内でのみ機能するのは、\n" +"定義中のクラスを正しく取得し、通常のメソッドでは現在のインスタンスにもアクセ" +"スできるように、\n" +"コンパイラが必要な情報を補うためです。" #: ../../builtins/functions.rst:2145 msgid "" @@ -3922,8 +4034,8 @@ msgid "" ":class:`super` objects are now :mod:`pickleable ` and :mod:" "`copyable `." msgstr "" -":class:`super` オブジェクトは :term:`pickle 可能 ` かつ :term:`コピー" -"可能 ` になりました。" +":class:`super` オブジェクトは :mod:`pickle 可能 ` かつ :mod:`コピー可" +"能 ` になりました。" #: ../../builtins/functions.rst:2158 msgid "" @@ -3975,13 +4087,11 @@ msgstr "" msgid "See also:" msgstr "下記を参照してください。" -#: ../../builtins/functions.rst:2191 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -":ref:`Documentation on attributes and methods on classes `." +":ref:`クラスの属性とメソッドに関するドキュメント `。" #: ../../builtins/functions.rst:2192 msgid ":ref:`bltin-type-objects`" @@ -3998,12 +4108,15 @@ msgstr "" "定義におけるキーワード引数と同様に、適切なメタクラスの機構 (通常は :meth:" "`~object.__init_subclass__`) に渡されます。" -#: ../../builtins/functions.rst:2199 msgid "" "Unlike a :keyword:`class` statement, the three argument form does not call " "the metaclass ``__prepare__`` method (see :ref:`prepare`). Use :func:`types." "new_class` to dynamically create a class using the appropriate metaclass." msgstr "" +":keyword:`class` 文とは異なり、3引数形式ではメタクラスの ``__prepare__`` メ" +"ソッドを呼び出しません (:ref:`prepare` を参照してください)。\n" +"適切なメタクラスを使って動的にクラスを作成するには、:func:`types.new_class` " +"を使ってください。" #: ../../builtins/functions.rst:2204 msgid "See also :ref:`class-customization`." @@ -4017,9 +4130,8 @@ msgstr "" "``type.__new__`` をオーバーライドしていない :class:`!type` のサブクラスは、オ" "ブジェクトの型を得るのに1引数形式を利用することができません。" -#: ../../builtins/functions.rst:2212 msgid "*dict* can now be a :class:`frozendict`." -msgstr "" +msgstr "``dict`` に :class:`frozendict` を指定できるようになりました。" #: ../../builtins/functions.rst:2217 msgid "" @@ -4132,12 +4244,15 @@ msgstr "" "備するコードにおけるバグのこともあるでしょう。 Python はこの問題に対して3つの" "異なるアプローチを提供します:" -#: ../../builtins/functions.rst:2267 msgid "" "By default, :func:`zip` stops when the shortest iterable is :term:" "`exhausted`. It will ignore the remaining items in the longer iterables, " "cutting off the result to the length of the shortest iterable::" msgstr "" +"デフォルトでは、最も短いイテラブルが :term:`枯渇する ` と :func:" +"`zip` は停止します。\n" +"より長いイテラブルに残った要素は無視し、結果を最も短いイテラブルの長さに切り" +"詰めます。 ::" #: ../../builtins/functions.rst:2271 msgid "" @@ -4165,21 +4280,21 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../builtins/functions.rst:2281 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is :term:`exhausted` before the others:" msgstr "" +"デフォルトの動作とは異なり、いずれかのイテラブルが他より先に :term:`枯渇した " +"` 場合は、:exc:`ValueError` を送出します:" -#: ../../builtins/functions.rst:2299 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -"``strict=True`` 引数なしの場合、長さの異なるイテラブルを生じる原因となるいか" -"なるバグも、この時点では問題なく処理されます。そして代わりにプログラムの別の" -"場所で、原因を特定しにくいバグとして検出されることになるでしょう。" +"``strict=True`` を指定しないと、イテラブルの長さが異なる原因となるバグが表面" +"化せず、\n" +"プログラムの別の場所で発見しにくいバグとして現れる場合があります。" #: ../../builtins/functions.rst:2303 msgid "" @@ -4217,12 +4332,11 @@ msgstr "" "``n`` 回呼び出した結果となるよう、 *同じ* イテレータを ``n`` 回繰り返します。" "これは入力を長さ n のチャンクに分割する効果があります。" -#: ../../builtins/functions.rst:2318 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -":func:`zip` に続けて ``*`` 演算子を使うと、zip したリストを元に戻せます::" +":func:`zip` と ``*`` 演算子を組み合わせると、zip したリストを元に戻せます::" #: ../../builtins/functions.rst:2321 msgid "" @@ -4274,7 +4388,6 @@ msgstr "" "`__import__` を直接使用することも推奨されず、 :func:`importlib." "import_module` の方が好まれます。" -#: ../../builtins/functions.rst:2353 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -4283,14 +4396,14 @@ msgid "" "does not use its *locals* argument at all and uses its *globals* only to " "determine the package context of the :keyword:`import` statement." msgstr "" -"この関数は、モジュール *name* をインポートし、 *globals* と *locals* が与えら" -"れれば、パッケージのコンテキストで名前をどう解釈するか決定するのに使います。 " -"*fromlist* は *name* で与えられるモジュールからインポートされるべきオブジェク" -"トまたはサブモジュールの名前を与ます。標準の実装では *locals* 引数はまったく" -"使われず、 *globals* は :keyword:`import` 文のパッケージコンテキストを決定す" -"るためにのみ使われます。" +"この関数はモジュール *name* をインポートします。\n" +"その際、指定された *globals* と *locals* を使って、パッケージのコンテキストで" +"名前をどう解釈するかを決めることがあります。\n" +"*fromlist* には、*name* が指定するモジュールからインポートするオブジェクトや" +"サブモジュールの名前を指定します。\n" +"標準の実装では *locals* 引数をまったく使わず、:keyword:`import` 文のパッケー" +"ジコンテキストを決めるためにのみ *globals* を使います。" -#: ../../builtins/functions.rst:2360 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -4298,10 +4411,12 @@ msgid "" "directory of the module calling :func:`__import__` (see :pep:`328` for the " "details)." msgstr "" -"*level* は絶対と相対どちらのインポートを使うかを指定します。 ``0`` (デフォル" -"ト) は絶対インポートのみ実行します。正の *level* の値は、 :func:`__import__` " -"を呼び出したディレクトリから検索対象となる親ディレクトリの数を示します (詳細" -"は :pep:`328` を参照してください)。" +"*level* は、絶対インポートと相対インポートのどちらを使うかを指定します。\n" +"``0`` (デフォルト) は、絶対インポートだけを行うことを意味します。\n" +"正の *level* は、:func:`__import__` を呼び出すモジュールのディレクトリを基準" +"に、\n" +"検索対象となる親ディレクトリの数を示します (詳細は :pep:`328` を参照してくだ" +"さい)。" #: ../../builtins/functions.rst:2366 msgid "" @@ -4334,14 +4449,12 @@ msgstr "文 ``import spam.ham`` は、この呼び出しになります::" msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../builtins/functions.rst:2380 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -"ここで :func:`__import__` がどのように最上位モジュールを返しているかに注意し" -"て下さい。 :keyword:`import` 文により名前が束縛されたオブジェクトになっていま" -"す。" +"ここで :func:`__import__` が最上位のモジュールを返すのは、:keyword:`import` " +"文がそのオブジェクトに名前を束縛するためです。" #: ../../builtins/functions.rst:2383 msgid "" @@ -4387,13 +4500,12 @@ msgstr "" "負の *level* の値はサポートされなくなりました (デフォルト値の 0 に変更されま" "す)。" -#: ../../builtins/functions.rst:2401 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -"コマンドラインオプション :option:`-E` or :option:`-I` が指定された場合、環境" -"変数 :envvar:`PYTHONCASEOK` は無視されるようになりました。" +"コマンドラインオプション :option:`-E` または :option:`-I` が使われている場" +"合、環境変数 :envvar:`PYTHONCASEOK` は無視されるようになりました。" #: ../../builtins/functions.rst:2406 msgid "Footnotes" diff --git a/builtins/index.po b/builtins/index.po index f4a8601ee..91e14c511 100644 --- a/builtins/index.po +++ b/builtins/index.po @@ -12,38 +12,45 @@ msgstr "" "PO-Revision-Date: 2026-09-13 17:09+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../builtins/index.rst:5 msgid "Python built-ins reference" -msgstr "" +msgstr "Python 組み込み機能リファレンス" -#: ../../builtins/index.rst:7 msgid "Python comes with a number of built-in functions and classes." -msgstr "" +msgstr "Python には、数多くの組み込み関数と組み込みクラスが用意されています。" -#: ../../builtins/index.rst:9 msgid "" "The built-in classes include data types that would normally be considered " "part of the \"core\" of a language, such as numbers and lists. For these " "types, the Python language core defines the form of literals and places some " "constraints on their semantics, but does not fully define the semantics." msgstr "" +"組み込みクラスには、数値やリストなど、通常は言語の「中核」の一部と見なされる" +"データ型が含まれます。\n" +"Python 言語の中核部分は、これらの型のリテラルの形式を定義し、意味にもいくつか" +"の制約を設けていますが、意味のすべてを定義しているわけではありません。" -#: ../../builtins/index.rst:14 msgid "" "The built-ins also include functions and exceptions --- objects that can be " "used by all Python code without the need of an :keyword:`import` statement. " "Some of these are defined by the core language, but many are not essential " "for the core semantics and are only described here." msgstr "" +"組み込み機能には、関数や例外も含まれます。\n" +"これらは :keyword:`import` 文を使わずに、あらゆる Python コードから利用できる" +"オブジェクトです。\n" +"その一部は言語の中核部分で定義されていますが、多くは中核部分の意味に不可欠な" +"ものではなく、このリファレンスでのみ説明しています。" -#: ../../builtins/index.rst:21 msgid "" "In addition to the built-ins, Python provides an extensive importable " "standard library, see :ref:`library-index`." msgstr "" +"Python は組み込み機能に加えて、インポートして使える豊富な標準ライブラリを提供" +"しています。\n" +":ref:`library-index` を参照してください。" diff --git a/builtins/stdtypes.po b/builtins/stdtypes.po index 3004708a7..4da5fb698 100644 --- a/builtins/stdtypes.po +++ b/builtins/stdtypes.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Rafael Fontenelle , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../builtins/stdtypes.rst:8 @@ -53,7 +53,6 @@ msgstr "" "インプレースに足し、引き、または並べ替えて、特定の要素を返さないメソッドは、" "コレクション自身ではなく ``None`` を返します。" -#: ../../builtins/stdtypes.rst:22 msgid "" "Some operations are supported by several object types; in particular, " "practically all objects can be compared for equality, tested for truth " @@ -61,10 +60,12 @@ msgid "" "slightly different :func:`str` function). The latter function is implicitly " "used when an object is written by the :func:`print` function." msgstr "" -"演算には、複数の型でサポートされているものがあります; 特に、ほぼ全てのオブ" -"ジェクトは、等価比較でき、真理値を判定でき、 (:func:`repr` 関数や、わずかに異" -"なる :func:`str` 関数によって) 文字列に変換できます。オブジェクトが :func:" -"`print` 関数で印字されるとき、文字列に変換する関数が暗黙に使われます。" +"いくつかの演算は、複数のオブジェクト型でサポートされています。\n" +"特に、ほぼすべてのオブジェクトでは、等価性の比較、真理値の判定、文字列への変" +"換ができます (文字列への変換には :func:`repr` 関数や、それとは少し異なる :" +"func:`str` 関数を使います)。\n" +":func:`print` 関数でオブジェクトを出力する際には、後者の関数が暗黙的に使われ" +"ます。" #: ../../builtins/stdtypes.rst:32 msgid "Truth Value Testing" @@ -78,7 +79,6 @@ msgstr "" "どのようなオブジェクトでも真理値として判定でき、 :keyword:`if` や :keyword:" "`while` の条件あるいは以下のブール演算の被演算子として使えます。" -#: ../../builtins/stdtypes.rst:46 msgid "" "By default, an object is considered true unless its class defines either a :" "meth:`~object.__bool__` method that returns ``False`` or a :meth:`~object." @@ -87,6 +87,13 @@ msgid "" "and the object does not have a truth value (for example, :data:" "`NotImplemented`). Here are most of the built-in objects considered false:" msgstr "" +"通常、オブジェクトは真とみなされます。\n" +"ただし、そのオブジェクトを渡して呼び出したときに ``False`` を返す :meth:" +"`~object.__bool__` メソッドか、ゼロを返す :meth:`~object.__len__` メソッドが" +"クラスに定義されている場合は偽とみなされます。[1]_\n" +"いずれかのメソッドの呼び出しで例外が送出されると、その例外が伝播し、オブジェ" +"クトは真理値を持ちません (例えば :data:`NotImplemented`)。\n" +"偽とみなされる主な組み込みオブジェクトは次のとおりです:" #: ../../builtins/stdtypes.rst:58 msgid "constants defined to be false: ``None`` and ``False``" @@ -427,47 +434,50 @@ msgstr "" "コンストラクタ :func:`int` 、 :func:`float` 、 :func:`complex` で、特定の型の" "数を生成できます。" -#: ../../builtins/stdtypes.rst:270 msgid "" "Python fully supports mixed arithmetic: when a binary arithmetic operator " "has operands of different built-in numeric types, the operand with the " "\"narrower\" type is widened to that of the other:" msgstr "" +"Python は異なる型を混在させた算術演算を完全にサポートしています。\n" +"二項算術演算子のオペランドが異なる組み込み数値型の場合、「狭い」型のオペラン" +"ドがもう一方の型に拡張されます:" -#: ../../builtins/stdtypes.rst:274 msgid "If both arguments are complex numbers, no conversion is performed;" -msgstr "" +msgstr "両方の引数が複素数の場合、変換は行われません。" -#: ../../builtins/stdtypes.rst:275 msgid "" "if either argument is a complex or a floating-point number, the other is " "converted to a floating-point number;" msgstr "" +"それ以外で、一方の引数が複素数または浮動小数点数の場合、もう一方は浮動小数点" +"数に変換されます。" #: ../../builtins/stdtypes.rst:277 msgid "otherwise, both must be integers and no conversion is necessary." msgstr "" "それ以外場合は、両方の引数は整数でなければならず、変換の必要はありません。" -#: ../../builtins/stdtypes.rst:279 msgid "" "Arithmetic with complex and real operands is defined by the usual " "mathematical formula, for example::" msgstr "" +"複素数と実数をオペランドとする演算は、通常の数学の式で定義されます。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:282 msgid "" "x + complex(u, v) = complex(x + u, v)\n" "x * complex(u, v) = complex(x * u, x * v)" msgstr "" -"x + complex(u, v) = complex(x + u, v)x * complex(u, v) = complex(x * u, x * " -"v)" +"x + complex(u, v) = complex(x + u, v)\n" +"x * complex(u, v) = complex(x * u, x * v)" -#: ../../builtins/stdtypes.rst:285 msgid "" "A comparison between numbers of different types behaves as though the exact " "values of those numbers were being compared. [2]_" msgstr "" +"異なる型の数値を比較すると、それぞれの数値の正確な値を比較した場合と同じ結果" +"になります。[2]_" #: ../../builtins/stdtypes.rst:288 msgid "" @@ -779,15 +789,14 @@ msgstr "" msgid "Bitwise Operations on Integer Types" msgstr "整数型におけるビット単位演算" -#: ../../builtins/stdtypes.rst:421 msgid "" "Bitwise operations only make sense for integers. The result of bitwise " "operations is calculated as though carried out in two's complement with an " "infinite number of sign bits." msgstr "" -"ビット単位演算は整数についてのみ意味を持ちます。\n" -"ビット単位演算の結果は、あたかも両方の値の先頭を無限個の符号ビットで埋めたも" -"のに対して計算したかのような値になります。" +"ビット単位演算は、整数についてのみ意味を持ちます。\n" +"その結果は、符号ビットを無限個持つ2の補数表現で演算した場合と同じになるよう計" +"算されます。" #: ../../builtins/stdtypes.rst:425 msgid "" @@ -882,17 +891,16 @@ msgid "" "A right shift by *n* bits is equivalent to floor division by ``pow(2, n)``." msgstr "*n* ビットの右シフトは、 ``pow(2, n)`` による切り捨て除算と等価です。" -#: ../../builtins/stdtypes.rst:462 msgid "" "Performing these calculations with at least one extra sign extension bit in " "a finite two's complement representation (a working bit-width of ``1 + max(x." "bit_length(), y.bit_length())`` or more) is sufficient to get the same " "result as if there were an infinite number of sign bits." msgstr "" -"桁の長い方の値に少なくとも 1 つ余計に符号ビットを付け加えた幅 (計算するビット" -"幅は ``1 + max(x.bit_length(), y.bit_length())`` かそれ以上) でこれらの計算を" -"行えば、無限個の符号ビットがあるかのように計算したのと同じ結果を得るのに十分" -"です。" +"有限ビット幅の2の補数表現に、少なくとも1ビットの符号拡張ビットを追加してこれ" +"らの計算を行えば、符号ビットを無限個使う場合と同じ結果が得られます。\n" +"計算に使うビット幅は ``1 + max(x.bit_length(), y.bit_length())`` 以上で十分で" +"す。" #: ../../builtins/stdtypes.rst:469 msgid "Additional Methods on Integer Types" @@ -913,14 +921,18 @@ msgid "" msgstr "" "整数を、符号と先頭の 0 は除いて二進法で表すために必要なビットの数を返します::" -#: ../../builtins/stdtypes.rst:479 msgid "" ">>> n = -37\n" ">>> bin(n)\n" "'-0b100101'\n" ">>> n.bit_length()\n" "6" -msgstr ">>> n = -37>>> bin(n)'-0b100101'>>> n.bit_length()6" +msgstr "" +">>> n = -37\n" +">>> bin(n)\n" +"'-0b100101'\n" +">>> n.bit_length()\n" +"6" #: ../../builtins/stdtypes.rst:485 msgid "" @@ -940,13 +952,16 @@ msgstr "" msgid "Equivalent to::" msgstr "次と等価です::" -#: ../../builtins/stdtypes.rst:493 msgid "" "def bit_length(self):\n" " s = bin(self) # binary representation: bin(-37) --> '-0b100101'\n" " s = s.lstrip('-0b') # remove leading zeros and minus sign\n" " return len(s) # len('100101') --> 6" msgstr "" +"def bit_length(self):\n" +" s = bin(self) # 2進表現: bin(-37) --> '-0b100101'\n" +" s = s.lstrip('-0b') # 先頭のゼロと負符号を除去する\n" +" return len(s) # len('100101') --> 6" #: ../../builtins/stdtypes.rst:502 msgid "" @@ -956,7 +971,6 @@ msgstr "" "整数の絶対値の二進数表現における 1 の数を返します。これは population count と" "しても知られています。 例::" -#: ../../builtins/stdtypes.rst:506 msgid "" ">>> n = 19\n" ">>> bin(n)\n" @@ -965,13 +979,21 @@ msgid "" "3\n" ">>> (-n).bit_count()\n" "3" -msgstr ">>> n = 19>>> bin(n)'0b10011'>>> n.bit_count()3>>> (-n).bit_count()3" +msgstr "" +">>> n = 19\n" +">>> bin(n)\n" +"'0b10011'\n" +">>> n.bit_count()\n" +"3\n" +">>> (-n).bit_count()\n" +"3" -#: ../../builtins/stdtypes.rst:516 msgid "" "def bit_count(self):\n" " return bin(self).count(\"1\")" msgstr "" +"def bit_count(self):\n" +" return bin(self).count(\"1\")" #: ../../builtins/stdtypes.rst:523 msgid "Return an array of bytes representing an integer." @@ -1017,11 +1039,12 @@ msgstr "" "上記のデフォルト値は整数を 1 バイトのオブジェクトに適切に変換するのに使うこと" "ができます::" -#: ../../builtins/stdtypes.rst:553 msgid "" ">>> (65).to_bytes()\n" "b'A'" msgstr "" +">>> (65).to_bytes()\n" +"b'A'" #: ../../builtins/stdtypes.rst:556 msgid "" @@ -1052,13 +1075,12 @@ msgstr "``length`` と ``byteorder`` 引数にデフォルト値を追加しま msgid "Return the integer represented by the given array of bytes." msgstr "与えられたバイト列の整数表現を返します。" -#: ../../builtins/stdtypes.rst:590 msgid "" "The argument *bytes* must either be a :term:`bytes-like object` or an " "iterable producing bytes." msgstr "" -"引数 *bytes* は :term:`bytes-like object` か、または bytes を生成する " -"iterable でなければなりません。" +"引数 ``bytes`` は :term:`bytes-like object` か、バイト値を生成するイテラブル" +"でなければなりません。" #: ../../builtins/stdtypes.rst:593 msgid "" @@ -1149,14 +1171,13 @@ msgstr "" "浮動小数点数が返されます。 引数が Python の浮動小数点数の範囲外なら、 :exc:" "`OverflowError` が送出されます。" -#: ../../builtins/stdtypes.rst:653 msgid "" "For a general Python object ``x``, ``float.from_number(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " "back to :meth:`~object.__index__`." msgstr "" "一般の Python オブジェクト ``x`` に対して、``float.from_number(x)`` は ``x." -"__float__()`` に委譲します。 :meth:`~object.__float__()` が定義されていない場" +"__float__()`` に委譲します。 :meth:`~object.__float__` が定義されていない場" "合、:meth:`~object.__index__` へフォールバックします。" #: ../../builtins/stdtypes.rst:663 @@ -1177,15 +1198,17 @@ msgstr "" "浮動小数点数インスタンスが有限の整数値なら ``True`` を、そうでなければ " "``False`` を返します::" -#: ../../builtins/stdtypes.rst:673 msgid "" ">>> (-2.0).is_integer()\n" "True\n" ">>> (3.2).is_integer()\n" "False" -msgstr ">>> (-2.0).is_integer()True>>> (3.2).is_integer()False" +msgstr "" +">>> (-2.0).is_integer()\n" +"True\n" +">>> (3.2).is_integer()\n" +"False" -#: ../../builtins/stdtypes.rst:678 msgid "" "Two methods support conversion to and from hexadecimal strings. Since " "Python's floats are stored internally as binary numbers, converting a float " @@ -1194,11 +1217,11 @@ msgid "" "of floating-point numbers. This can be useful when debugging, and in " "numerical work." msgstr "" -"16 進表記の文字列へ、または、 16 進表記からの変換をサポートする二つのメソッド" -"があります。 Python の浮動小数点数は内部的には2進数で保持されるので、浮動小数" -"点数の *10進数* へまたは *10進数* からの変換には若干の丸め誤差があります。そ" -"れに対し、16 進表記では、浮動小数点数を正確に表現できます。これはデバッグのと" -"きや、数学的な用途 (numerical work) に便利でしょう。" +"16進文字列との相互変換をサポートするメソッドが二つあります。\n" +"Python の浮動小数点数は内部では2進数として格納されるため、浮動小数点数と *10" +"進文字列* との相互変換では通常、小さな丸め誤差が生じます。\n" +"一方、16進文字列では浮動小数点数を正確に表現したり指定したりできます。\n" +"これはデバッグや数値計算に役立つことがあります。" #: ../../builtins/stdtypes.rst:689 msgid "" @@ -1233,7 +1256,6 @@ msgstr "16 進文字列表現は以下の書式となります::" msgid "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" msgstr "[sign] ['0x'] integer ['.' fraction] ['p' exponent]" -#: ../../builtins/stdtypes.rst:709 msgid "" "where the optional ``sign`` may be either ``+`` or ``-``, ``integer`` and " "``fraction`` are strings of hexadecimal digits, and ``exponent`` is a " @@ -1246,6 +1268,17 @@ msgid "" "by C's ``%a`` format character or Java's ``Double.toHexString`` are accepted " "by :meth:`float.fromhex`." msgstr "" +"ここで、省略可能な ``sign`` は ``+`` または ``-``、``integer`` と " +"``fraction`` は16進数字の文字列、``exponent`` は先頭に符号を付けてもよい10進" +"整数です。\n" +"大文字と小文字は区別されず、整数部か小数部のいずれかに少なくとも1桁の16進数字" +"が必要です。\n" +"この構文は、C99 規格の6.4.4.2節で指定されている構文や、Java 1.5 以降で使われ" +"ている構文に似ています。\n" +"特に、:meth:`float.hex` の出力は C や Java のコードで16進浮動小数点リテラルと" +"して使えます。\n" +"また、C の ``%a`` 書式文字や Java の ``Double.toHexString`` で生成された16進" +"文字列は :meth:`float.fromhex` で受け付けられます。" #: ../../builtins/stdtypes.rst:722 msgid "" @@ -1258,11 +1291,12 @@ msgstr "" "えます。例えば、16 進文字列 ``0x3.a7p10`` は浮動小数点数 ``(3 + 10./16 + " "7./16**2) * 2.0**10`` すなわち ``3740.0`` を表します::" -#: ../../builtins/stdtypes.rst:728 msgid "" ">>> float.fromhex('0x3.a7p10')\n" "3740.0" -msgstr ">>> float.fromhex('0x3.a7p10')3740.0" +msgstr "" +">>> float.fromhex('0x3.a7p10')\n" +"3740.0" #: ../../builtins/stdtypes.rst:732 msgid "" @@ -1272,11 +1306,12 @@ msgstr "" "逆変換を ``3740.0`` に適用すると、同じ数を表す異なる 16 進文字列表現を返しま" "す::" -#: ../../builtins/stdtypes.rst:735 msgid "" ">>> float.hex(3740.0)\n" "'0x1.d380000000000p+11'" -msgstr ">>> float.hex(3740.0)'0x1.d380000000000p+11'" +msgstr "" +">>> float.hex(3740.0)\n" +"'0x1.d380000000000p+11'" #: ../../builtins/stdtypes.rst:740 msgid "Additional Methods on Complex" @@ -1404,17 +1439,15 @@ msgstr "" "``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width - 1))`` に収ま" "ります。再び、結果が ``-1`` なら、 ``-2`` で置き換えられます。" -#: ../../builtins/stdtypes.rst:808 msgid "" "To clarify the above rules, here's some example Python code, equivalent to " "the built-in hash, for computing the hash of a rational number, :class:" "`float`, or :class:`complex`::" msgstr "" -"上述の規則をわかりやすくするため、有理数 :class:`float` や、 :class:" -"`complex` のハッシュを計算する組み込みのハッシュと等価な Python コードの例を" -"挙げます::" +"上の規則を明確にするため、有理数、:class:`float`、:class:`complex` のハッシュ" +"を計算する Python コードの例を示します。\n" +"このコードは組み込みのハッシュ計算と等価です::" -#: ../../builtins/stdtypes.rst:813 msgid "" "import sys, math\n" "\n" @@ -1465,6 +1498,53 @@ msgid "" " hash_value = -2\n" " return hash_value" msgstr "" +"import sys, math\n" +"\n" +"def hash_fraction(m, n):\n" +" \"\"\"有理数 m / n のハッシュを計算する。\n" +"\n" +" m と n は整数で、n は正と仮定する。\n" +" hash(fractions.Fraction(m, n)) と等価。\n" +"\n" +" \"\"\"\n" +" P = sys.hash_info.modulus\n" +" # P の共通因子を除く (m と n がすでに互いに素なら不要)。\n" +" while m % P == n % P == 0:\n" +" m, n = m // P, n // P\n" +"\n" +" if n % P == 0:\n" +" hash_value = sys.hash_info.inf\n" +" else:\n" +" # フェルマーの小定理により pow(n, P-1, P) は1なので、\n" +" # pow(n, P-2, P) は P を法とする n の逆数を与える。\n" +" hash_value = (abs(m) % P) * pow(n, P - 2, P) % P\n" +" if m < 0:\n" +" hash_value = -hash_value\n" +" if hash_value == -1:\n" +" hash_value = -2\n" +" return hash_value\n" +"\n" +"def hash_float(x):\n" +" \"\"\"浮動小数点数 x のハッシュを計算する。\"\"\"\n" +"\n" +" if math.isnan(x):\n" +" return object.__hash__(x)\n" +" elif math.isinf(x):\n" +" return sys.hash_info.inf if x > 0 else -sys.hash_info.inf\n" +" else:\n" +" return hash_fraction(*x.as_integer_ratio())\n" +"\n" +"def hash_complex(z):\n" +" \"\"\"複素数 z のハッシュを計算する。\"\"\"\n" +"\n" +" hash_value = hash_float(z.real) + sys.hash_info.imag * hash_float(z." +"imag)\n" +" # 2**sys.hash_info.width を法として、符号付きの剰余に還元する\n" +" M = 2**(sys.hash_info.width - 1)\n" +" hash_value = (hash_value & (M - 1)) - (hash_value & M)\n" +" if hash_value == -1:\n" +" hash_value = -2\n" +" return hash_value" #: ../../builtins/stdtypes.rst:864 msgid "Boolean Type - :class:`bool`" @@ -1500,11 +1580,12 @@ msgstr "" "ブール値を返します。しかしながら、論理演算子 ``and``, ``or`` および ``!=`` を" "使うほうが ``&``, ``|`` や ``^`` を使うよりも好ましいです。" -#: ../../builtins/stdtypes.rst:886 msgid "" "The use of the bitwise inversion operator ``~`` is deprecated and will raise " "an error in Python 3.16." msgstr "" +"ビット反転演算子 ``~`` の使用は非推奨となり、Python 3.16 ではエラーが送出され" +"るようになります。" #: ../../builtins/stdtypes.rst:889 msgid "" @@ -1519,9 +1600,8 @@ msgstr "" "信頼することは推奨されません; :func:`int` を使って明示的に整数値に変換してく" "ださい。" -#: ../../builtins/stdtypes.rst:899 msgid "Iteration-related types" -msgstr "" +msgstr "反復に関連する型" #: ../../builtins/stdtypes.rst:907 msgid "" @@ -1535,9 +1615,8 @@ msgstr "" "クラスで反復を行えるようにできます。後に詳しく述べるシーケンスは、必ず反復処" "理メソッドをサポートしています。" -#: ../../builtins/stdtypes.rst:913 msgid "Iterables" -msgstr "" +msgstr "イテラブル" #: ../../builtins/stdtypes.rst:915 msgid "" @@ -1624,25 +1703,27 @@ msgstr "" "を送出したなら、以降の呼び出しでも例外を送出し続けなければなりません。この特" "性に従わない実装は壊れているとみなされます。" -#: ../../builtins/stdtypes.rst:968 msgid "Generator types" -msgstr "" +msgstr "ジェネレータ型" -#: ../../builtins/stdtypes.rst:970 msgid "" "Python's :term:`generators ` -- or more precisely, :term:" "`generator functions ` and :term:`generator iterators " "` -- provide a convenient way to implement the iterator " "protocol." msgstr "" +"Python の :term:`ジェネレータ `、より正確には :term:`ジェネレータ" +"関数 ` と :term:`ジェネレータイテレータ ` を使うと、イテレータプロトコルを簡単に実装できます。" -#: ../../builtins/stdtypes.rst:975 msgid "" "A function that contains one or more :ref:`yield expressions ` is " "a :term:`generator function`. For example::" msgstr "" +":ref:`yield 式 ` を一つ以上含む関数は :term:`ジェネレータ関数 " +"` です。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:979 msgid "" ">>> def count_to_three():\n" "... yield 0\n" @@ -1650,28 +1731,37 @@ msgid "" "... yield 2\n" "... yield 3" msgstr "" +">>> def count_to_three():\n" +"... yield 0\n" +"... yield 1\n" +"... yield 2\n" +"... yield 3" -#: ../../builtins/stdtypes.rst:985 msgid "" "Generator functions behave as regular :ref:`user-defined functions ` (for example, they have the same attributes), except that " "calling a generator function returns a :ref:`generator iterator `::" msgstr "" +"ジェネレータ関数は通常の :ref:`ユーザ定義関数 ` と同様に" +"振る舞います (例えば、同じ属性を持ちます)。\n" +"ただし、呼び出すと :ref:`ジェネレータイテレータ ` を返しま" +"す。 ::" -#: ../../builtins/stdtypes.rst:990 msgid "" ">>> count_to_three()\n" "" msgstr "" +">>> count_to_three()\n" +"" -#: ../../builtins/stdtypes.rst:993 msgid "" "Iterating a generator iterator executes code of the underlying generator " "function, producing each :keyword:`yield`\\ed value in turn::" msgstr "" +"ジェネレータイテレータを反復すると、元のジェネレータ関数のコードが実行され、:" +"keyword:`yield` された値が順番に生成されます。 ::" -#: ../../builtins/stdtypes.rst:996 msgid "" ">>> for number in count_to_three():\n" "... print(number)\n" @@ -1683,14 +1773,24 @@ msgid "" ">>> list(count_to_three())\n" "[0, 1, 2, 3]" msgstr "" +">>> for number in count_to_three():\n" +"... print(number)\n" +"0\n" +"1\n" +"2\n" +"3\n" +"\n" +">>> list(count_to_three())\n" +"[0, 1, 2, 3]" -#: ../../builtins/stdtypes.rst:1006 msgid "" "One common use for generator functions is implementing the :meth:`~object." "__iter__` method of custom iterable objects. For example::" msgstr "" +"ジェネレータ関数は、独自のイテラブルオブジェクトの :meth:`~object.__iter__` " +"メソッドを実装する際によく使われます。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:1010 msgid "" ">>> class CardDeck:\n" "... def __iter__(self):\n" @@ -1700,19 +1800,26 @@ msgid "" ">>> list(CardDeck())\n" "['three of clubs', 'ace of hearts']" msgstr "" +">>> class CardDeck:\n" +"... def __iter__(self):\n" +"... yield 'three of clubs'\n" +"... yield 'ace of hearts'\n" +"\n" +">>> list(CardDeck())\n" +"['three of clubs', 'ace of hearts']" -#: ../../builtins/stdtypes.rst:1023 msgid "Generator iterators" -msgstr "" +msgstr "ジェネレータイテレータ" -#: ../../builtins/stdtypes.rst:1025 msgid "" "Generator iterators implement the :ref:`iterator protocol `. Iterating them drives execution of the underlying generator " "function." msgstr "" +"ジェネレータイテレータは :ref:`イテレータプロトコル ` を" +"実装しています。\n" +"反復すると、元のジェネレータ関数の実行が進みます。" -#: ../../builtins/stdtypes.rst:1033 msgid "" "Starts the execution of a generator function or resumes it at the :ref:" "`yield expression ` where the function is currently suspended. " @@ -1725,45 +1832,60 @@ msgid "" "raises a :exc:`StopIteration` exception, signalling that iteration has " "completed." msgstr "" +"ジェネレータ関数の実行を開始するか、現在中断している :ref:`yield 式 " +"` から実行を再開します。\n" +":meth:`~generator.__next__` メソッドでジェネレータ関数を再開すると、現在の " +"yield 式は常に :const:`None` と評価されます。\n" +"その後、次の yield 式まで実行が進み、そこでジェネレータは再び中断します。\n" +":keyword:`yield` キーワードの後の式の値が :meth:`~generator.__next__` の呼び" +"出し元に返されます。\n" +"別の値を yield することなくジェネレータが終了すると、:meth:`~generator." +"__next__` は :exc:`StopIteration` 例外を送出し、反復の完了を知らせます。" -#: ../../builtins/stdtypes.rst:1045 msgid "" "This method is normally called implicitly, for example by a :keyword:`for` " "loop, or by the built-in :func:`next` function." msgstr "" +"通常、このメソッドは :keyword:`for` ループや組み込みの :func:`next` 関数など" +"によって暗黙的に呼び出されます。" -#: ../../builtins/stdtypes.rst:1048 msgid "" "Generator iterators have a few more methods than generic iterators, which " "can be used to control the execution of the underlying generator function:" msgstr "" +"ジェネレータイテレータは一般的なイテレータに加えていくつかのメソッドを持ち、" +"元のジェネレータ関数の実行を制御できます:" -#: ../../builtins/stdtypes.rst:1053 msgid "" "\"Sends\" a value into the generator function: the *value* argument becomes " "the result of the current yield expression." msgstr "" +"ジェネレータ関数に値を「送信」します。\n" +"``value`` 引数が現在の yield 式の結果になります。" -#: ../../builtins/stdtypes.rst:1056 msgid "" "Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes " "the underlying function and either returns the next yielded value or raises :" "exc:`StopIteration`." msgstr "" +"それ以外の点では、このメソッドは :meth:`~generator.__next__` と同様に動作しま" +"す。\n" +"元の関数の実行を再開し、次に yield された値を返すか、:exc:`StopIteration` を" +"送出します。" -#: ../../builtins/stdtypes.rst:1060 msgid "" "When :meth:`send` is called to start the generator, it must be called with :" "const:`None` as the argument, because there is no current yield expression " "that could receive the value." msgstr "" +"ジェネレータを開始するために :meth:`send` を呼び出す場合は、引数として :" +"const:`None` を渡さなければなりません。\n" +"まだ値を受け取れる yield 式がないためです。" -#: ../../builtins/stdtypes.rst:1068 msgid "" "Raises an exception at the point where the generator is currently suspended." -msgstr "" +msgstr "ジェネレータが現在中断している箇所で例外を送出します。" -#: ../../builtins/stdtypes.rst:1070 msgid "" "Otherwise, this method behaves like :meth:`~generator.__next__`: it resumes " "the underlying function and either returns the next yielded value or raises :" @@ -1771,22 +1893,31 @@ msgid "" "exception, or raises a different exception, then that exception propagates " "to the caller." msgstr "" +"それ以外の点では、このメソッドは :meth:`~generator.__next__` と同様に動作しま" +"す。\n" +"元の関数の実行を再開し、次に yield された値を返すか、:exc:`StopIteration` を" +"送出します。\n" +"ジェネレータ関数が渡された例外を捕捉しないか、別の例外を送出した場合、その例" +"外は呼び出し元に伝播します。" -#: ../../builtins/stdtypes.rst:1076 msgid "" "When :meth:`throw` is called to start the generator, the generator " "immediately exits (that is, subsequent calls to :meth:`~generator.__next__` " "will raise :exc:`StopIteration`) and the thrown exception is propagated to :" "meth:`throw`'s caller." msgstr "" +"ジェネレータを開始するために :meth:`throw` を呼び出すと、ジェネレータは直ちに" +"終了し (以降の :meth:`~generator.__next__` の呼び出しでは :exc:" +"`StopIteration` が送出されます)、送出された例外は :meth:`throw` の呼び出し元" +"に伝播します。" -#: ../../builtins/stdtypes.rst:1081 ../../builtins/stdtypes.rst:1202 msgid "" "In typical use, this is called with a single argument, an exception " "instance, similar to the way the :keyword:`raise` keyword is used." msgstr "" +"通常は :keyword:`raise` キーワードと同様に、例外インスタンスを一つの引数とし" +"て渡して呼び出します。" -#: ../../builtins/stdtypes.rst:1084 msgid "" "For backwards compatibility, however, the second signature is supported, " "following a convention from older versions of Python. The *type* argument " @@ -1796,21 +1927,31 @@ msgid "" "any existing :attr:`~BaseException.__traceback__` attribute stored in " "*value* may be cleared." msgstr "" +"ただし、後方互換性のため、以前のバージョンの Python の慣例に従った2番目のシグ" +"ネチャもサポートされています。\n" +"``type`` 引数には例外クラスを、``value`` には例外インスタンスを指定してくださ" +"い。\n" +"``value`` を指定しない場合は、``type`` のコンストラクタを呼び出してインスタン" +"スを取得します。\n" +"``traceback`` を指定した場合は例外に設定されます。\n" +"指定しない場合は、``value`` に格納されている既存の :attr:`~BaseException." +"__traceback__` 属性がクリアされることがあります。" -#: ../../builtins/stdtypes.rst:1095 ../../builtins/stdtypes.rst:1212 msgid "" "The second signature \\(type\\[, value\\[, traceback\\]\\]\\) is deprecated " "and may be removed in a future version of Python." msgstr "" +"2番目のシグネチャ \\(type\\[, value\\[, traceback\\]\\]\\) は非推奨となり、将" +"来のバージョンの Python で削除される可能性があります。" -#: ../../builtins/stdtypes.rst:1102 msgid "" "Raises a :exc:`GeneratorExit` exception at the point where the generator " "function is currently suspended (equivalent to calling " "``throw(GeneratorExit)``)." msgstr "" +"ジェネレータ関数が現在中断している箇所で :exc:`GeneratorExit` 例外を送出しま" +"す (``throw(GeneratorExit)`` の呼び出しと等価です)。" -#: ../../builtins/stdtypes.rst:1105 msgid "" "If the generator function has already exited (due to an exception or normal " "return), or raises :exc:`GeneratorExit` (by not catching the exception), :" @@ -1819,39 +1960,52 @@ msgid "" "propagated to the caller. If a generator returns a value upon being closed, " "that value is returned by :meth:`close`." msgstr "" +"ジェネレータ関数がすでに終了している場合 (例外による終了と正常な return のど" +"ちらも含みます)、または例外を捕捉せず :exc:`GeneratorExit` を送出した場合、:" +"meth:`close` は :const:`None` を返します。\n" +"ジェネレータが値を yield すると、:exc:`RuntimeError` が送出されます。\n" +"ジェネレータがそれ以外の例外を送出した場合、その例外は呼び出し元に伝播しま" +"す。\n" +"クローズ時にジェネレータが値を return した場合、:meth:`close` はその値を返し" +"ます。" -#: ../../builtins/stdtypes.rst:1113 msgid "" "When a generator iterator is garbage collected before it has exited, :meth:" "`~generator.close` is called automatically." msgstr "" +"ジェネレータイテレータが終了する前にガベージコレクションで回収されると、:" +"meth:`~generator.close` が自動的に呼び出されます。" -#: ../../builtins/stdtypes.rst:1118 msgid "" "If a generator returns a value upon being closed, the value is returned by :" "meth:`close`. Previously, it returned ``None``." msgstr "" +"クローズ時にジェネレータが値を return した場合、:meth:`close` はその値を返す" +"ようになりました。\n" +"以前は ``None`` を返していました。" -#: ../../builtins/stdtypes.rst:1123 msgid "" "Calling any of the generator methods (:meth:`~generator.__next__`, :meth:" "`~generator.send`, :meth:`~generator.throw`, :meth:`~generator.close`) while " "one of these methods is already executing raises a :exc:`ValueError` " "exception." msgstr "" +"ジェネレータのメソッド (:meth:`~generator.__next__`、:meth:`~generator." +"send`、:meth:`~generator.throw`、:meth:`~generator.close`) のいずれかを実行中" +"に、これらのメソッドのいずれかを呼び出すと :exc:`ValueError` 例外が送出されま" +"す。" -#: ../../builtins/stdtypes.rst:1133 msgid "Asynchronous generator iterators" -msgstr "" +msgstr "非同期ジェネレータイテレータ" -#: ../../builtins/stdtypes.rst:1135 msgid "" "This subsection describes the methods of an asynchronous generator iterator, " "which are used to control the execution of an asynchronous generator " "function." msgstr "" +"この節では、非同期ジェネレータ関数の実行を制御する、非同期ジェネレータイテ" +"レータのメソッドを説明します。" -#: ../../builtins/stdtypes.rst:1144 msgid "" "Returns an :term:`awaitable` which when run starts to execute the " "asynchronous generator function or resumes it at the :ref:`yield expression " @@ -1865,49 +2019,71 @@ msgid "" "awaitable instead raises a :exc:`StopAsyncIteration` exception, signalling " "that the asynchronous iteration has completed." msgstr "" +"実行すると非同期ジェネレータ関数の実行を開始するか、現在中断している :ref:" +"`yield 式 ` から実行を再開する :term:`待ち受け可能オブジェクト " +"` を返します。\n" +":meth:`~agen.__anext__` メソッドで非同期ジェネレータ関数を再開すると、返され" +"た待ち受け可能オブジェクト内で現在の yield 式は常に :const:`None` と評価され" +"ます。\n" +"この待ち受け可能オブジェクトを実行すると、次の yield 式まで実行が進みます。\n" +":keyword:`yield` キーワードの後の式の値は、完了するコルーチンが送出する :exc:" +"`StopIteration` 例外の値になります。\n" +"別の値を yield することなく非同期ジェネレータが終了すると、待ち受け可能オブ" +"ジェクトは代わりに :exc:`StopAsyncIteration` 例外を送出し、非同期反復の完了を" +"知らせます。" -#: ../../builtins/stdtypes.rst:1157 msgid "" "This method is normally called implicitly by an :keyword:`async for` loop, " "or by the built-in :func:`anext` function." msgstr "" +"通常、このメソッドは :keyword:`async for` ループや組み込みの :func:`anext` 関" +"数によって暗黙的に呼び出されます。" -#: ../../builtins/stdtypes.rst:1161 msgid "" "Asynchronous generator-iterators have a few more methods than generic " "asynchronous iterators, which can be used to control the execution of the " "underlying generator function:" msgstr "" +"非同期ジェネレータイテレータは一般的な非同期イテレータに加えていくつかのメ" +"ソッドを持ち、元のジェネレータ関数の実行を制御できます:" -#: ../../builtins/stdtypes.rst:1168 msgid "" "Returns an awaitable which, when run, \"sends\" a value into the underlying " "asynchronous generator function: the *value* argument becomes the result of " "the current yield expression." msgstr "" +"実行すると元の非同期ジェネレータ関数に値を「送信」する待ち受け可能オブジェク" +"トを返します。\n" +"``value`` 引数が現在の yield 式の結果になります。" -#: ../../builtins/stdtypes.rst:1172 msgid "" "Otherwise, this method behaves like :meth:`~agen.__anext__`: when the " "returned awaitable runs, it resumes the underlying function and either " "returns the next yielded value as the value of the raised :exc:" "`StopIteration`, or raises :exc:`StopAsyncIteration`." msgstr "" +"それ以外の点では、このメソッドは :meth:`~agen.__anext__` と同様に動作しま" +"す。\n" +"返された待ち受け可能オブジェクトを実行すると、元の関数の実行が再開され、次に " +"yield された値を :exc:`StopIteration` 例外の値として返すか、:exc:" +"`StopAsyncIteration` を送出します。" -#: ../../builtins/stdtypes.rst:1177 msgid "" "When :meth:`asend` is called to start the asynchronous generator, it must be " "called with :const:`None` as the argument, because there is no yield " "expression that could receive the value." msgstr "" +"非同期ジェネレータを開始するために :meth:`asend` を呼び出す場合は、引数とし" +"て :const:`None` を渡さなければなりません。\n" +"まだ値を受け取れる yield 式がないためです。" -#: ../../builtins/stdtypes.rst:1186 msgid "" "Returns an awaitable that, when run, raises an exception at the point where " "the underlying asynchronous generator function is currently suspended." msgstr "" +"実行すると元の非同期ジェネレータ関数が現在中断している箇所で例外を送出する待" +"ち受け可能オブジェクトを返します。" -#: ../../builtins/stdtypes.rst:1189 msgid "" "Otherwise, this method behaves like :meth:`~agen.__anext__`: when the " "returned awaitable runs, it resumes the underlying function (with an " @@ -1917,28 +2093,43 @@ msgid "" "different exception, then when the awaitable is run, that exception " "propagates to the caller of the awaitable." msgstr "" +"それ以外の点では、このメソッドは :meth:`~agen.__anext__` と同様に動作しま" +"す。\n" +"返された待ち受け可能オブジェクトを実行すると、元の関数の実行が例外を送出した" +"状態で再開され、次に yield された値を :exc:`StopIteration` 例外の値として返す" +"か、:exc:`StopAsyncIteration` を送出します。\n" +"元の関数が渡された例外を捕捉しないか、別の例外を送出した場合、待ち受け可能オ" +"ブジェクトの実行時に、その例外は待ち受け可能オブジェクトの呼び出し元に伝播し" +"ます。" -#: ../../builtins/stdtypes.rst:1197 msgid "" "When :meth:`~agen.athrow` is called to start the generator, the generator " "exits when the awaitable runs (that is, subsequent results from :meth:`~agen." "__anext__` will raise :exc:`StopAsyncIteration` when run) and the thrown " "exception is propagated to the awaitable's caller." msgstr "" +"ジェネレータを開始するために :meth:`~agen.athrow` を呼び出すと、待ち受け可能" +"オブジェクトの実行時にジェネレータは終了し (以降の :meth:`~agen.__anext__` の" +"結果を実行すると :exc:`StopAsyncIteration` が送出されます)、送出された例外は" +"待ち受け可能オブジェクトの呼び出し元に伝播します。" -#: ../../builtins/stdtypes.rst:1205 msgid "" "For backwards compatibility, however, the second signature is supported. An " "exception instance is created from three arguments in the same way as in :" "meth:`generator.throw`." msgstr "" +"ただし、後方互換性のため、2番目のシグネチャもサポートされています。\n" +":meth:`generator.throw` と同様に、三つの引数から例外インスタンスを作成しま" +"す。" -#: ../../builtins/stdtypes.rst:1221 msgid "" "Returns an awaitable that when run will throw a :exc:`GeneratorExit` into " "the underlying asynchronous generator function at the point where it is " "currently suspended (equivalent to calling ``athrow(GeneratorExit)``)." msgstr "" +"実行すると元の非同期ジェネレータ関数が現在中断している箇所で :exc:" +"`GeneratorExit` を送出する待ち受け可能オブジェクトを返します " +"(``athrow(GeneratorExit)`` の呼び出しと等価です)。" #: ../../builtins/stdtypes.rst:1225 msgid "" @@ -1949,19 +2140,24 @@ msgid "" "generator will raise a :exc:`StopAsyncIteration` exception." msgstr "" -#: ../../builtins/stdtypes.rst:1231 msgid "" "If the asynchronous generator yields a value, a :exc:`RuntimeError` is " "raised by the awaitable. If the asynchronous generator raises any other " "exception, that exception is propagated to the caller of the awaitable." msgstr "" +"非同期ジェネレータが値を yield すると、待ち受け可能オブジェクトは :exc:" +"`RuntimeError` を送出します。\n" +"非同期ジェネレータがそれ以外の例外を送出した場合、その例外は待ち受け可能オブ" +"ジェクトの呼び出し元に伝播します。" -#: ../../builtins/stdtypes.rst:1236 msgid "" "If the asynchronous generator has already exited due to an exception or " "normal exit, then further calls to :meth:`aclose` will return an awaitable " "that does nothing." msgstr "" +"非同期ジェネレータが例外または正常終了によってすでに終了している場合、以降" +"の :meth:`aclose` の呼び出しは、何もしない待ち受け可能オブジェクトを返しま" +"す。" #: ../../builtins/stdtypes.rst:1244 msgid "Sequence Types --- :class:`list`, :class:`tuple`, :class:`range`" @@ -1982,17 +2178,16 @@ msgstr "" msgid "Common Sequence Operations" msgstr "共通のシーケンス演算" -#: ../../builtins/stdtypes.rst:1259 msgid "" "The operations in the following table are supported by most sequence types, " "both mutable and immutable. The :class:`collections.abc.Sequence` ABC is " "provided to make it easier to correctly implement these operations on custom " "sequence types." msgstr "" -"以下の表にある演算は、ほとんどのミュータブル、イミュータブル両方のシーケンス" -"でサポートされています。カスタムのシーケンス型にこれらの演算を完全に実装する" -"のが簡単になるように、 :class:`collections.abc.Sequence` ABC が提供されていま" -"す。" +"以下の表にある演算は、ミュータブルとイミュータブルの両方を含む、ほとんどの" +"シーケンス型でサポートされています。\n" +"独自のシーケンス型でこれらの演算を正しく実装しやすくするために、:class:" +"`collections.abc.Sequence` ABC が提供されています。" #: ../../builtins/stdtypes.rst:1264 msgid "" @@ -2015,10 +2210,11 @@ msgstr "" "``in`` および ``not in`` 演算の優先順位は比較演算と同じです。``+`` (結合) お" "よび ``*`` (繰り返し)の優先順位は対応する数値演算と同じです。 [3]_" -#: ../../builtins/stdtypes.rst:1273 msgid "" "See :ref:`time-complexity` for the costs of the various sequence operations." msgstr "" +"各種シーケンス演算の計算量については、:ref:`time-complexity` を参照してくださ" +"い。" #: ../../builtins/stdtypes.rst:1291 msgid "``x in s``" @@ -2158,25 +2354,26 @@ msgstr "" "class:`str`, :class:`bytes`, :class:`bytearray` のような) 特殊なシーケンスで" "は部分シーケンス判定にも使われます::" -#: ../../builtins/stdtypes.rst:1341 msgid "" ">>> \"gg\" in \"eggs\"\n" "True" -msgstr ">>> \"gg\" in \"eggs\"True" +msgstr "" +">>> \"gg\" in \"eggs\"\n" +"True" -#: ../../builtins/stdtypes.rst:1345 msgid "" "Values of *n* less than ``0`` are treated as ``0`` (which yields an empty " "sequence of the same type as *s*). Note that items in the sequence *s* are " "not copied; they are referenced multiple times. This often haunts new " "Python programmers; consider::" msgstr "" -"``0`` 未満の値 *n* は ``0`` として扱われます (これは *s* と同じ型の空のシーケ" -"ンスを表します)。シーケンス *s* の要素はコピーされないので注意してください; " -"コピーではなく要素に対する参照カウントが増えます。これは Python に慣れていな" -"いプログラマをよく悩ませます。例えば以下のコードを考えます:" +"``0`` 未満の *n* は ``0`` として扱われます (結果は *s* と同じ型の空のシーケン" +"スになります)。\n" +"シーケンス *s* の要素はコピーされず、同じ要素が複数回参照されることに注意して" +"ください。\n" +"これは Python に慣れていないプログラマをよく悩ませます。\n" +"次のコードを考えてみてください::" -#: ../../builtins/stdtypes.rst:1350 msgid "" ">>> lists = [[]] * 3\n" ">>> lists\n" @@ -2185,6 +2382,12 @@ msgid "" ">>> lists\n" "[[3], [3], [3]]" msgstr "" +">>> lists = [[]] * 3\n" +">>> lists\n" +"[[], [], []]\n" +">>> lists[0].append(3)\n" +">>> lists\n" +"[[3], [3], [3]]" #: ../../builtins/stdtypes.rst:1357 msgid "" @@ -2198,7 +2401,6 @@ msgstr "" "と、その一つのリストが変更されます。別々のリストのリストを作るにはこうしま" "す::" -#: ../../builtins/stdtypes.rst:1362 msgid "" ">>> lists = [[] for i in range(3)]\n" ">>> lists[0].append(3)\n" @@ -2207,6 +2409,12 @@ msgid "" ">>> lists\n" "[[3], [5], [7]]" msgstr "" +">>> lists = [[] for i in range(3)]\n" +">>> lists[0].append(3)\n" +">>> lists[1].append(5)\n" +">>> lists[2].append(7)\n" +">>> lists\n" +"[[3], [5], [7]]" #: ../../builtins/stdtypes.rst:1369 msgid "" @@ -2225,31 +2433,27 @@ msgstr "" "す。\n" "ただし ``-0`` はやはり ``0`` であることに注意してください。" -#: ../../builtins/stdtypes.rst:1378 msgid "" "The slice of *s* from *i* to *j* is defined as the sequence of items with " "index *k* such that ``i <= k < j``." msgstr "" +"*s* の *i* から *j* までのスライスは、``i <= k < j`` を満たすインデックス " +"*k* の要素からなるシーケンスとして定義されます。" -#: ../../builtins/stdtypes.rst:1381 msgid "If *i* is omitted or ``None``, use ``0``." -msgstr "" +msgstr "*i* が省略された場合や ``None`` の場合は ``0`` を使います。" -#: ../../builtins/stdtypes.rst:1382 msgid "If *j* is omitted or ``None``, use ``len(s)``." -msgstr "" +msgstr "*j* が省略された場合や ``None`` の場合は ``len(s)`` を使います。" -#: ../../builtins/stdtypes.rst:1383 msgid "If *i* or *j* is less than ``-len(s)``, use ``0``." -msgstr "" +msgstr "*i* または *j* が ``-len(s)`` 未満の場合は ``0`` を使います。" -#: ../../builtins/stdtypes.rst:1384 msgid "If *i* or *j* is greater than ``len(s)``, use ``len(s)``." -msgstr "" +msgstr "*i* または *j* が ``len(s)`` より大きい場合は ``len(s)`` を使います。" -#: ../../builtins/stdtypes.rst:1385 msgid "If *i* is greater than or equal to *j*, the slice is empty." -msgstr "" +msgstr "*i* が *j* 以上の場合、スライスは空になります。" #: ../../builtins/stdtypes.rst:1388 msgid "" @@ -2329,9 +2533,8 @@ msgstr "" "ンスのみをサポートするものがあり、それらはシーケンスの結合や繰り返しをサポー" "トしません。" -#: ../../builtins/stdtypes.rst:1426 msgid "An :exc:`IndexError` is raised if *i* is outside the sequence range." -msgstr "" +msgstr "*i* がシーケンスの範囲外の場合、:exc:`IndexError` が送出されます。" #: ../../builtins/stdtypes.rst:1429 msgid "Sequence Methods" @@ -2354,18 +2557,22 @@ msgid "Raises :exc:`ValueError` if *value* is not found in *sequence*." msgstr "" "*sequence* に *value* が見つからなければ :exc:`ValueError` を送出します。" -#: ../../builtins/stdtypes.rst:1454 msgid "" "The *start* or *stop* arguments allow for efficient searching of subsections " "of the sequence, beginning at *start* and ending at *stop*. This is roughly " "equivalent to ``start + sequence[start:stop].index(value)``, only without " "copying any data." msgstr "" +"``start`` または ``stop`` 引数を使うと、シーケンスの ``start`` から ``stop`` " +"までの部分を効率よく検索できます。\n" +"これはおおむね ``start + sequence[start:stop].index(value)`` と等価ですが、" +"データをコピーしません。" -#: ../../builtins/stdtypes.rst:1460 msgid "" "Not all sequence types support passing the *start* and *stop* arguments." msgstr "" +"``start`` および ``stop`` 引数の指定をサポートしていないシーケンス型もありま" +"す。" #: ../../builtins/stdtypes.rst:1466 msgid "Immutable Sequence Types" @@ -2402,15 +2609,14 @@ msgstr "" msgid "Mutable Sequence Types" msgstr "ミュータブルなシーケンス型" -#: ../../builtins/stdtypes.rst:1495 msgid "" "The operations in the following table are defined on mutable sequence types. " "The :class:`collections.abc.MutableSequence` ABC is provided to make it " "easier to correctly implement these operations on custom sequence types." msgstr "" -"以下のテーブルにある演算は、ほとんどのミュータブルなシーケンスでサポートされ" -"ています。カスタムのシーケンス型にこれらの演算を完全に実装するのが簡単になる" -"ように、 :class:`collections.abc.MutableSequence` ABC が提供されています。" +"以下の表にある演算は、ミュータブルなシーケンス型で定義されています。\n" +"独自のシーケンス型でこれらの演算を正しく実装しやすくするために、:class:" +"`collections.abc.MutableSequence` ABC が提供されています。" #: ../../builtins/stdtypes.rst:1499 msgid "" @@ -2502,18 +2708,16 @@ msgstr "" "*k* が ``1`` と等しくない場合、 *t* はそれが入れ替えるスライスと同じ長さでな" "ければなりません。" -#: ../../builtins/stdtypes.rst:1549 msgid "" "The value *n* is an integer, or an object implementing :meth:`~object." "__index__`. Zero and negative values of *n* clear the sequence. Items in " "the sequence are not copied; they are referenced multiple times, as " "explained for ``s * n`` under :ref:`typesseq-common`." msgstr "" -"値 *n* は整数であるか、:meth:`~object.__index__` を実装したオブジェクトで" -"す。 *n* の値がゼロまたは負数の場合、シーケンスをクリアします。:ref:" -"`typesseq-common` で ``s * n`` について説明したとおり、シーケンスの要素はコ" -"ピーされないので注意してください; コピーではなく要素に対する参照カウントが増" -"えます。" +"*n* は整数または :meth:`~object.__index__` を実装したオブジェクトです。\n" +"*n* がゼロまたは負の値の場合、シーケンスを空にします。\n" +":ref:`typesseq-common` の ``s * n`` の説明と同様に、シーケンスの要素はコピー" +"されず、同じ要素が複数回参照されます。" #: ../../builtins/stdtypes.rst:1555 msgid "Mutable Sequence Methods" @@ -2523,59 +2727,71 @@ msgstr "ミュータブルなシーケンスのメソッド" msgid "Mutable sequence types also support the following methods:" msgstr "ミュータブルなシーケンス型は以下のようなメソッドをサポートしています:" -#: ../../builtins/stdtypes.rst:1565 msgid "" "Append *value* to the end of the sequence. This is equivalent to writing " "``seq[len(seq):len(seq)] = [value]``." msgstr "" +"シーケンスの末尾に ``value`` を追加します。\n" +"これは ``seq[len(seq):len(seq)] = [value]`` と書くことと等価です。" -#: ../../builtins/stdtypes.rst:1577 msgid "" "Remove all items from *sequence*. This is equivalent to writing ``del " "sequence[:]``." msgstr "" +"*sequence* からすべての要素を削除します。\n" +"これは ``del sequence[:]`` と書くことと等価です。" -#: ../../builtins/stdtypes.rst:1589 msgid "" "Create a shallow copy of *sequence*. This is equivalent to writing " "``sequence[:]``." msgstr "" +"*sequence* の浅いコピーを作成します。\n" +"これは ``sequence[:]`` と書くことと等価です。" -#: ../../builtins/stdtypes.rst:1592 msgid "" "The :meth:`!copy` method is not part of the :class:`~collections.abc." "MutableSequence` :class:`~abc.ABC`, but most concrete mutable sequence types " "provide it." msgstr "" +":meth:`!copy` メソッドは :class:`~collections.abc.MutableSequence` :class:" +"`~abc.ABC` には含まれませんが、ほとんどの具体的なミュータブルシーケンス型で提" +"供されています。" -#: ../../builtins/stdtypes.rst:1603 msgid "" "Extend *sequence* with the contents of *iterable*. For the most part, this " "is the same as writing ``seq[len(seq):len(seq)] = iterable``." msgstr "" +"*sequence* を ``iterable`` の内容で拡張します。\n" +"これはほとんどの場合、``seq[len(seq):len(seq)] = iterable`` と書くことと同じ" +"です。" -#: ../../builtins/stdtypes.rst:1614 msgid "" "Insert *value* into *sequence* at the given *index*. This is equivalent to " "writing ``sequence[index:index] = [value]``." msgstr "" +"*sequence* の指定された ``index`` に ``value`` を挿入します。\n" +"これは ``sequence[index:index] = [value]`` と書くことと等価です。" -#: ../../builtins/stdtypes.rst:1624 msgid "" "Retrieve the item at *index* and also remove it from *sequence*. By default, " "the last item in *sequence* is removed and returned." msgstr "" +"``index`` の要素を取得し、*sequence* から削除します。\n" +"デフォルトでは、*sequence* の最後の要素を削除して返します。" -#: ../../builtins/stdtypes.rst:1634 msgid "Remove the first item from *sequence* where ``sequence[i] == value``." msgstr "" +"``sequence[i] == value`` を満たす最初の要素を *sequence* から削除します。" -#: ../../builtins/stdtypes.rst:1645 msgid "" "Reverse the items of *sequence* in place. This method maintains economy of " "space when reversing a large sequence. To remind users that it operates by " "side-effect, it returns ``None``." msgstr "" +"*sequence* の要素をインプレースで逆順に並べ替えます。\n" +"このメソッドは、大きなシーケンスを逆順にするときにもメモリ使用量を抑えま" +"す。\n" +"副作用によって動作することを利用者に意識させるため、``None`` を返します。" #: ../../builtins/stdtypes.rst:1653 msgid "Lists" @@ -2636,9 +2852,8 @@ msgid "" msgstr "" "リストを作る方法は、他にも組み込み関数 :func:`sorted` などいろいろあります。" -#: ../../builtins/stdtypes.rst:1682 msgid "Lists are :ref:`generic ` over the types of their items." -msgstr "" +msgstr "リストは要素の型について :ref:`ジェネリック ` です。" #: ../../builtins/stdtypes.rst:1684 msgid "" @@ -2728,23 +2943,24 @@ msgid "" msgstr "" "ソートの例と簡単なチュートリアルは :ref:`sortinghowto` を参照して下さい。" -#: ../../builtins/stdtypes.rst:1725 msgid "" "While a list is being sorted, the effect of attempting to mutate, or even " "inspect, the list is undefined. The C implementation of Python makes the " "list appear empty for the duration, and raises :exc:`ValueError` if it can " "detect that the list has been mutated during a sort." msgstr "" -"リストがソートされている間、または変更しようとする試みの影響中、あるいは検査" -"中でさえ、リストは未定義です。Python の C 実装では、それらが続いている間、リ" -"ストは空として出力され、リストがソート中に変更されていることを検知できたら :" -"exc:`ValueError` を送出します。" +"リストのソート中にそのリストを変更したり、内容を調べたりしようとした場合の動" +"作は未定義です。\n" +"Python の C 実装では、ソート中はリストが空に見えるようにし、\n" +"ソート中にリストが変更されたことを検出できた場合は :exc:`ValueError` を送出し" +"ます。" -#: ../../builtins/stdtypes.rst:1732 msgid "" "For detailed information on thread-safety guarantees for :class:`list` " "objects, see :ref:`thread-safety-list`." msgstr "" +":class:`list` オブジェクトのスレッドセーフ性の保証については、:ref:`thread-" +"safety-list` を参照してください。" #: ../../builtins/stdtypes.rst:1739 msgid "Tuples" @@ -2822,12 +3038,14 @@ msgid "" msgstr "" "タプルは :ref:`共通の ` シーケンス演算をすべて実装します。" -#: ../../builtins/stdtypes.rst:1775 msgid "" "Tuples are :ref:`generic ` over the types of their contents. For " "more information, refer to :ref:`the typing documentation on annotating " "tuples `." msgstr "" +"タプルは内容の型について :ref:`ジェネリック ` です。\n" +"詳しくは、:ref:`タプルのアノテーションに関する typing ドキュメント " +"` を参照してください。" #: ../../builtins/stdtypes.rst:1779 msgid "" @@ -2905,7 +3123,6 @@ msgstr "" msgid "Range examples::" msgstr "range の例::" -#: ../../builtins/stdtypes.rst:1823 msgid "" ">>> list(range(10))\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" @@ -2922,6 +3139,20 @@ msgid "" ">>> list(range(1, 0))\n" "[]" msgstr "" +">>> list(range(10))\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" +">>> list(range(1, 11))\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n" +">>> list(range(0, 30, 5))\n" +"[0, 5, 10, 15, 20, 25]\n" +">>> list(range(0, 10, 3))\n" +"[0, 3, 6, 9]\n" +">>> list(range(0, -10, -1))\n" +"[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n" +">>> list(range(0))\n" +"[]\n" +">>> list(range(1, 0))\n" +"[]" #: ../../builtins/stdtypes.rst:1838 msgid "" @@ -3025,15 +3256,15 @@ msgstr "" "numbers-linspace/>`_ は浮動小数点数向けの遅延評価版 range を実装する方法を紹" "介しています。" -#: ../../builtins/stdtypes.rst:1918 msgid "Text and Binary Sequence Type Methods Summary" -msgstr "" +msgstr "テキストおよびバイナリシーケンス型のメソッド一覧" -#: ../../builtins/stdtypes.rst:1919 msgid "" "The following table summarizes the text and binary sequence types methods by " "category." msgstr "" +"次の表は、テキストおよびバイナリシーケンス型のメソッドを分類ごとにまとめたも" +"のです。" #: ../../builtins/stdtypes.rst:1924 msgid "Category" @@ -3047,9 +3278,8 @@ msgstr ":class:`str` メソッド" msgid ":class:`bytes` and :class:`bytearray` methods" msgstr ":class:`bytes` または :class:`bytearray` メソッド" -#: ../../builtins/stdtypes.rst:1926 msgid "Formatting" -msgstr "" +msgstr "書式化" #: ../../builtins/stdtypes.rst:1926 msgid ":meth:`str.format`" @@ -3071,9 +3301,8 @@ msgstr ":ref:`old-string-formatting`" msgid ":ref:`bytes-formatting`" msgstr ":ref:`bytes-formatting`" -#: ../../builtins/stdtypes.rst:1934 msgid "Searching and Replacing" -msgstr "" +msgstr "検索と置換" #: ../../builtins/stdtypes.rst:1934 msgid ":meth:`str.find`" @@ -3139,9 +3368,8 @@ msgstr ":meth:`str.replace`" msgid ":meth:`bytes.replace`" msgstr ":meth:`bytes.replace`" -#: ../../builtins/stdtypes.rst:1946 msgid "Splitting and Joining" -msgstr "" +msgstr "分割と結合" #: ../../builtins/stdtypes.rst:1946 msgid ":meth:`str.split`" @@ -3191,9 +3419,8 @@ msgstr ":meth:`str.join`" msgid ":meth:`bytes.join`" msgstr ":meth:`bytes.join`" -#: ../../builtins/stdtypes.rst:1956 msgid "String Classification" -msgstr "" +msgstr "文字列の分類" #: ../../builtins/stdtypes.rst:1956 msgid ":meth:`str.isalpha`" @@ -3267,9 +3494,8 @@ msgstr ":meth:`bytes.isspace`" msgid ":meth:`str.isprintable`" msgstr ":meth:`str.isprintable`" -#: ../../builtins/stdtypes.rst:1978 msgid "Case Manipulation" -msgstr "" +msgstr "大文字と小文字の操作" #: ../../builtins/stdtypes.rst:1978 msgid ":meth:`str.lower`" @@ -3315,9 +3541,8 @@ msgstr ":meth:`str.swapcase`" msgid ":meth:`bytes.swapcase`" msgstr ":meth:`bytes.swapcase`" -#: ../../builtins/stdtypes.rst:1990 msgid "Padding and Stripping" -msgstr "" +msgstr "パディングと除去" #: ../../builtins/stdtypes.rst:1990 msgid ":meth:`str.ljust`" @@ -3375,25 +3600,20 @@ msgstr ":meth:`bytes.lstrip`" msgid ":meth:`bytes.rstrip`" msgstr ":meth:`bytes.rstrip`" -#: ../../builtins/stdtypes.rst:2000 msgid ":meth:`str.removeprefix`" -msgstr "" +msgstr ":meth:`str.removeprefix`" -#: ../../builtins/stdtypes.rst:2000 msgid ":meth:`bytes.removeprefix`" -msgstr "" +msgstr ":meth:`bytes.removeprefix`" -#: ../../builtins/stdtypes.rst:2002 msgid ":meth:`str.removesuffix`" -msgstr "" +msgstr ":meth:`str.removesuffix`" -#: ../../builtins/stdtypes.rst:2002 msgid ":meth:`bytes.removesuffix`" -msgstr "" +msgstr ":meth:`bytes.removesuffix`" -#: ../../builtins/stdtypes.rst:2004 msgid "Translation and Encoding" -msgstr "" +msgstr "変換とエンコーディング" #: ../../builtins/stdtypes.rst:2004 msgid ":meth:`str.translate`" @@ -3493,14 +3713,13 @@ msgstr "" "指定を行うと長さ 1 の文字列を作成します。つまり、空でない文字列 *s* に対し、" "``s[0] == s[0:1]`` です。" -#: ../../builtins/stdtypes.rst:2047 msgid "" "There is also no mutable string type, but :meth:`str.join` or :class:`io." "StringIO` can be used to efficiently construct strings from multiple " "fragments." msgstr "" -"ミュータブルな文字列型もありませんが、ミュータブルな断片から効率よく文字列を" -"構成するのに :meth:`str.join` や :class:`io.StringIO` が使えます。" +"ミュータブルな文字列型もありませんが、複数の断片から効率よく文字列を構築する" +"には :meth:`str.join` や :class:`io.StringIO` を使えます。" #: ../../builtins/stdtypes.rst:2051 msgid "" @@ -3569,23 +3788,24 @@ msgstr "" "`str` に渡すと、略式の文字列表現を返す 1 つ目の場合に該当します。(Python のコ" "マンドラインオプション :option:`-b` も参照してください) 例えば::" -#: ../../builtins/stdtypes.rst:2095 msgid "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" msgstr "" +">>> str(b'Zoot!')\n" +"\"b'Zoot!'\"" -#: ../../builtins/stdtypes.rst:2098 msgid "" "For more information on the ``str`` class and its methods, see :ref:" "`textseq` and the :ref:`string-methods` section below. To output formatted " "strings, see the :ref:`f-strings` and :ref:`formatstrings` sections. In " "addition, see the :ref:`stringservices` section." msgstr "" -"``str`` クラスとそのメソッドについて詳しくは、 :ref:`テキストシーケンス型 — " -"str ` や :ref:`string-methods` の節を参照してください。フォーマット" -"された文字列を出力するには、 :ref:`f-strings` と :ref:`string-formatting` の" -"節を参照してください。加えて、 :ref:`stringservices` の節も参照してください。" +"``str`` クラスとそのメソッドについて詳しくは、:ref:`textseq` と後述の :ref:" +"`string-methods` 節を参照してください。\n" +"書式化した文字列の出力については、:ref:`f-strings` と :ref:`formatstrings` の" +"節を参照してください。\n" +"また、:ref:`stringservices` 節も参照してください。" #: ../../builtins/stdtypes.rst:2110 msgid "String Methods" @@ -3648,7 +3868,6 @@ msgstr "" "文字列の casefold されたコピーを返します。casefold された文字列は、大文字小文" "字に関係ないマッチに使えます。" -#: ../../builtins/stdtypes.rst:2144 msgid "" "Casefolding is similar to lowercasing but more aggressive because it is " "intended to remove all case distinctions in a string. For example, the " @@ -3656,30 +3875,44 @@ msgid "" "already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:" "`casefold` converts it to ``\"ss\"``. For example:" msgstr "" +"casefold は小文字化に似ていますが、文字列内の大文字と小文字の区別をすべて取り" +"除くことを目的とするため、より徹底した変換を行います。\n" +"例えば、ドイツ語の小文字 ``'ß'`` は ``\"ss\"`` と等価です。\n" +"``'ß'`` はすでに小文字なので :meth:`lower` では変わりませんが、:meth:" +"`casefold` では ``\"ss\"`` に変換されます。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2151 msgid "" ">>> 'straße'.lower()\n" "'straße'\n" ">>> 'straße'.casefold()\n" "'strasse'" msgstr "" +">>> 'straße'.lower()\n" +"'straße'\n" +">>> 'straße'.casefold()\n" +"'strasse'" -#: ../../builtins/stdtypes.rst:2158 msgid "" "The casefolding algorithm is `described in section 3.13.3 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" +"casefold のアルゴリズムは `Unicode 標準の3.13.3節「Default Case Folding」 " +"`__ に記載されています。" -#: ../../builtins/stdtypes.rst:2167 msgid "" "Return centered in a string of length *width*. Padding is done using the " "specified *fillchar* (default is an ASCII space). The original string is " "returned if *width* is less than or equal to ``len(s)``. For example::" msgstr "" +"長さ ``width`` の文字列の中央に配置して返します。\n" +"パディングには指定された ``fillchar`` (デフォルトは ASCII スペース) を使いま" +"す。\n" +"``width`` が ``len(s)`` 以下の場合は元の文字列を返します。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:2171 msgid "" ">>> 'Python'.center(10)\n" "' Python '\n" @@ -3688,6 +3921,12 @@ msgid "" ">>> 'Python'.center(4)\n" "'Python'" msgstr "" +">>> 'Python'.center(10)\n" +"' Python '\n" +">>> 'Python'.center(10, '-')\n" +"'--Python--'\n" +">>> 'Python'.center(4)\n" +"'Python'" #: ../../builtins/stdtypes.rst:2181 msgid "" @@ -3705,7 +3944,6 @@ msgid "" "which is the length of the string plus one. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:2188 msgid "" ">>> 'spam, spam, spam'.count('spam')\n" "3\n" @@ -3718,6 +3956,16 @@ msgid "" ">>> 'spam, spam, spam'.count('')\n" "17" msgstr "" +">>> 'spam, spam, spam'.count('spam')\n" +"3\n" +">>> 'spam, spam, spam'.count('spam', 5)\n" +"2\n" +">>> 'spam, spam, spam'.count('spam', 5, 10)\n" +"1\n" +">>> 'spam, spam, spam'.count('eggs')\n" +"0\n" +">>> 'spam, spam, spam'.count('')\n" +"17" #: ../../builtins/stdtypes.rst:2201 msgid "Return the string encoded to :class:`bytes`." @@ -3745,14 +3993,16 @@ msgstr "" "``'backslashreplace'`` と、そして :func:`codecs.register_error` で登録された" "名前です。詳しくは :ref:`error-handlers` を参照してください。" -#: ../../builtins/stdtypes.rst:2213 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless an encoding error actually occurs, :ref:`devmode` is enabled or a :" "ref:`debug build ` is used. For example::" msgstr "" +"パフォーマンス上の理由から、実際にエンコーディングエラーが発生した場合、:ref:" +"`devmode` が有効な場合、または :ref:`デバッグビルド ` を使ってい" +"る場合にのみ、``errors`` の値の妥当性を検査します。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:2219 msgid "" ">>> encoded_str_to_bytes = 'Python'.encode()\n" ">>> type(encoded_str_to_bytes)\n" @@ -3760,6 +4010,11 @@ msgid "" ">>> encoded_str_to_bytes\n" "b'Python'" msgstr "" +">>> encoded_str_to_bytes = 'Python'.encode()\n" +">>> type(encoded_str_to_bytes)\n" +"\n" +">>> encoded_str_to_bytes\n" +"b'Python'" #: ../../builtins/stdtypes.rst:2226 ../../builtins/stdtypes.rst:3972 msgid "Added support for keyword arguments." @@ -3782,7 +4037,6 @@ msgid "" "equivalent to ``str[start:end].endswith(suffix)``. For example::" msgstr "" -#: ../../builtins/stdtypes.rst:2242 msgid "" ">>> 'Python'.endswith('on')\n" "True\n" @@ -3793,12 +4047,18 @@ msgid "" ">>> 'Python is amazing'.endswith('is', 0, 9)\n" "True" msgstr "" +">>> 'Python'.endswith('on')\n" +"True\n" +">>> 'a tuple of suffixes'.endswith(('at', 'in'))\n" +"False\n" +">>> 'a tuple of suffixes'.endswith(('at', 'es'))\n" +"True\n" +">>> 'Python is amazing'.endswith('is', 0, 9)\n" +"True" -#: ../../builtins/stdtypes.rst:2251 msgid "See also :meth:`startswith` and :meth:`removesuffix`." -msgstr "" +msgstr ":meth:`startswith` と :meth:`removesuffix` も参照してください。" -#: ../../builtins/stdtypes.rst:2256 msgid "" "Return a copy of the string where all tab characters are replaced by one or " "more spaces, depending on the current column and the given tab size. Tab " @@ -3813,8 +4073,19 @@ msgid "" "incremented by one regardless of how the character is represented when " "printed. For example::" msgstr "" +"すべてのタブ文字を、現在の列と指定されたタブサイズに応じて一つ以上のスペース" +"に置き換えた文字列のコピーを返します。\n" +"タブ位置は ``tabsize`` 文字ごとにあります (デフォルトは8で、列0、8、16などが" +"タブ位置になります)。\n" +"文字列を展開する際には、現在の列をゼロに設定し、文字列を1文字ずつ調べます。\n" +"文字がタブ (``\\t``) の場合、現在の列が次のタブ位置に達するまで、結果に一つ以" +"上のスペース文字を挿入します (タブ文字自体はコピーしません)。\n" +"文字が改行 (``\\n``) または復帰 (``\\r``) の場合、その文字をコピーして現在の" +"列をゼロに戻します。\n" +"それ以外の文字はそのままコピーし、表示したときの表現に関係なく現在の列を一つ" +"進めます。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:2269 msgid "" ">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" "'01 012 0123 01234'\n" @@ -3824,26 +4095,39 @@ msgid "" "01 012\n" "0123 01234" msgstr "" +">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" +"'01 012 0123 01234'\n" +">>> '01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"'01 012 0123 01234'\n" +">>> print('01\\t012\\n0123\\t01234'.expandtabs(4))\n" +"01 012\n" +"0123 01234" -#: ../../builtins/stdtypes.rst:2280 msgid "" "Return the lowest index in the string where substring *sub* is found within " "the slice ``s[start:end]``. Optional arguments *start* and *end* are " "interpreted as in slice notation. Return ``-1`` if *sub* is not found. For " "example::" msgstr "" +"スライス ``s[start:end]`` 内で部分文字列 ``sub`` が見つかる、文字列内の最小の" +"インデックスを返します。\n" +"省略可能な ``start`` と ``end`` 引数はスライス表記と同様に解釈されます。\n" +"``sub`` が見つからない場合は ``-1`` を返します。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:2285 msgid "" ">>> 'spam, spam, spam'.find('sp')\n" "0\n" ">>> 'spam, spam, spam'.find('sp', 5)\n" "6" msgstr "" +">>> 'spam, spam, spam'.find('sp')\n" +"0\n" +">>> 'spam, spam, spam'.find('sp', 5)\n" +"6" -#: ../../builtins/stdtypes.rst:2290 msgid "See also :meth:`rfind` and :meth:`index`." -msgstr "" +msgstr ":meth:`rfind` と :meth:`index` も参照してください。" #: ../../builtins/stdtypes.rst:2294 msgid "" @@ -3855,11 +4139,12 @@ msgstr "" "す。 *sub* が部分文字列であるかどうかのみを調べるには、 :keyword:`in` 演算子" "を使ってください::" -#: ../../builtins/stdtypes.rst:2298 msgid "" ">>> 'Py' in 'Python'\n" "True" msgstr "" +">>> 'Py' in 'Python'\n" +"True" #: ../../builtins/stdtypes.rst:2304 msgid "" @@ -3871,7 +4156,6 @@ msgid "" "the corresponding argument. For example:" msgstr "" -#: ../../builtins/stdtypes.rst:2311 msgid "" ">>> \"The sum of 1 + 2 is {0}\".format(1+2)\n" "'The sum of 1 + 2 is 3'\n" @@ -3880,6 +4164,12 @@ msgid "" ">>> \"{1} expects the {0} Inquisition!\".format(\"Spanish\", \"Nobody\")\n" "'Nobody expects the Spanish Inquisition!'" msgstr "" +">>> \"The sum of 1 + 2 is {0}\".format(1+2)\n" +"'The sum of 1 + 2 is 3'\n" +">>> \"The sum of {a} + {b} is {answer}\".format(answer=1+2, a=1, b=2)\n" +"'The sum of 1 + 2 is 3'\n" +">>> \"{1} expects the {0} Inquisition!\".format(\"Spanish\", \"Nobody\")\n" +"'Nobody expects the Spanish Inquisition!'" #: ../../builtins/stdtypes.rst:2320 msgid "" @@ -3889,7 +4179,6 @@ msgstr "" "書式指定のオプションについては、書式指定文字列を規定する :ref:" "`formatstrings` を参照してください。" -#: ../../builtins/stdtypes.rst:2324 msgid "" "When formatting a number (:class:`int`, :class:`float`, :class:`complex`, :" "class:`decimal.Decimal` and subclasses) with the ``n`` type (ex: ``'{:n}'." @@ -3899,21 +4188,22 @@ msgid "" "and the ``LC_NUMERIC`` locale is different than the ``LC_CTYPE`` locale. " "This temporary change affects other threads." msgstr "" -"数値 (:class:`int`, :class:`float`, :class:`complex`, :class:`decimal." -"Decimal` とサブクラス) を ``n`` の整数表現型 (例: ``'{:n}'.format(1234)``) で" -"フォーマットするとき、``LC_CTYPE`` ロケールと ``LC_NUMERIC`` ロケールの一方ま" -"たは両方が 1 バイトより長い非 ASCII 文字であると同時に異なる値である場合、こ" -"の関数は :c:func:`localeconv` の ``decimal_point`` と ``thousands_sep`` " -"フィールドを読み取るため一時的に ``LC_CTYPE`` ロケールに ``LC_NUMERIC`` のロ" -"ケール値を設定します。この一時的な変更は他のスレッドの動作に影響します。" +"数値 (:class:`int`、:class:`float`、:class:`complex`、:class:`decimal." +"Decimal` とそのサブクラス) を ``n`` 型で書式化する場合 (例: ``'{:n}'." +"format(1234)``)、\n" +":c:func:`localeconv` の ``decimal_point`` または ``thousands_sep`` フィールド" +"が非 ASCII 文字を含むか1バイトより長く、\n" +"かつ ``LC_NUMERIC`` ロケールが ``LC_CTYPE`` ロケールと異なるときは、\n" +"それらのフィールドをデコードするために、一時的に ``LC_CTYPE`` ロケールを " +"``LC_NUMERIC`` ロケールに設定します。\n" +"この一時的な変更は他のスレッドにも影響します。" -#: ../../builtins/stdtypes.rst:2333 msgid "" "When formatting a number with the ``n`` type, the function sets temporarily " "the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` locale in some cases." msgstr "" -"数値を ``n`` の整数表現型でフォーマットするとき、この関数は一時的に " -"``LC_CTYPE`` ロケールに ``LC_NUMERIC`` のロケール値を設定する場合があります。" +"数値を ``n`` 型で書式化するとき、一時的に ``LC_CTYPE`` ロケールを " +"``LC_NUMERIC`` ロケールに設定する場合があります。" #: ../../builtins/stdtypes.rst:2341 msgid "" @@ -3925,13 +4215,14 @@ msgstr "" "ピーされず、直接使われます。これは例えば ``mapping`` が dict のサブクラスであ" "るときに便利です:" -#: ../../builtins/stdtypes.rst:2357 msgid "" "Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is " "not found. For example:" msgstr "" +":meth:`~str.find` と同様ですが、部分文字列が見つからない場合は :exc:" +"`ValueError` を送出します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2360 msgid "" ">>> 'spam, spam, spam'.index('spam')\n" "0\n" @@ -3942,20 +4233,31 @@ msgid "" " ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" msgstr "" +">>> 'spam, spam, spam'.index('spam')\n" +"0\n" +">>> 'spam, spam, spam'.index('eggs')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 'spam, spam, spam'.index('eggs')\n" +" ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" +"ValueError: substring not found" -#: ../../builtins/stdtypes.rst:2371 msgid "See also :meth:`rindex`." -msgstr "" +msgstr ":meth:`rindex` も参照してください。" -#: ../../builtins/stdtypes.rst:2376 msgid "" "Return ``True`` if all characters in the string are alphanumeric and there " "is at least one character, ``False`` otherwise. A character ``c`` is " "alphanumeric if one of the following returns ``True``: ``c.isalpha()``, ``c." "isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``. For example:" msgstr "" +"文字列内のすべての文字が字母または数字で、かつ1文字以上ある場合は ``True`` " +"を、それ以外の場合は ``False`` を返します。\n" +"文字 ``c`` は、``c.isalpha()``、``c.isdecimal()``、``c.isdigit()``、``c." +"isnumeric()`` のいずれかが ``True`` を返す場合に字母または数字とみなされま" +"す。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2381 msgid "" ">>> 'abc123'.isalnum()\n" "True\n" @@ -3966,8 +4268,15 @@ msgid "" ">>> ' '.isalnum()\n" "False" msgstr "" +">>> 'abc123'.isalnum()\n" +"True\n" +">>> 'abc123!@#'.isalnum()\n" +"False\n" +">>> ''.isalnum()\n" +"False\n" +">>> ' '.isalnum()\n" +"False" -#: ../../builtins/stdtypes.rst:2395 msgid "" "Return ``True`` if all characters in the string are alphabetic and there is " "at least one character, ``False`` otherwise. Alphabetic characters are " @@ -3978,8 +4287,17 @@ msgid "" "the Unicode Standard `__. For example:" msgstr "" +"文字列内のすべての文字が字母で、かつ1文字以上ある場合は ``True`` を、それ以外" +"の場合は ``False`` を返します。\n" +"字母とは、Unicode 文字データベースで「Letter」と定義されている文字、すなわち" +"一般カテゴリのプロパティが \"Lm\"、\"Lt\"、\"Lu\"、\"Ll\"、\"Lo\" のいずれか" +"である文字です。\n" +"これは `Unicode 標準の4.10節「Letters, Alphabetic, and Ideographic」で定義さ" +"れている Alphabetic プロパティ `__ とは異なることに注意してくださ" +"い。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2404 msgid "" ">>> 'Letters and spaces'.isalpha()\n" "False\n" @@ -3989,27 +4307,37 @@ msgid "" "too\n" "True" msgstr "" +">>> 'Letters and spaces'.isalpha()\n" +"False\n" +">>> 'LettersOnly'.isalpha()\n" +"True\n" +">>> 'µ'.isalpha() # 非 ASCII 文字も字母とみなされる場合がある\n" +"True" + +msgid "See :ref:`unicode-properties`." +msgstr ":ref:`unicode-properties` を参照してください。" -#: ../../builtins/stdtypes.rst:2413 -msgid "See :ref:`unicode-properties`." -msgstr "" - -#: ../../builtins/stdtypes.rst:2418 msgid "" "Return ``True`` if the string is empty or all characters in the string are " "ASCII, ``False`` otherwise. ASCII characters have code points in the range " "U+0000-U+007F. For example:" msgstr "" +"文字列が空であるか、文字列内のすべての文字が ASCII 文字である場合は ``True`` " +"を、それ以外の場合は ``False`` を返します。\n" +"ASCII 文字のコードポイントは U+0000-U+007F の範囲です。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2422 msgid "" ">>> 'ASCII characters'.isascii()\n" "True\n" ">>> 'µ'.isascii()\n" "False" msgstr "" +">>> 'ASCII characters'.isascii()\n" +"True\n" +">>> 'µ'.isascii()\n" +"False" -#: ../../builtins/stdtypes.rst:2434 msgid "" "Return ``True`` if all characters in the string are decimal characters and " "there is at least one character, ``False`` otherwise. Decimal characters are " @@ -4017,8 +4345,13 @@ msgid "" "INDIC DIGIT ZERO. Formally a decimal character is a character in the " "Unicode General Category \"Nd\". For example:" msgstr "" +"文字列内のすべての文字が10進数字で、かつ1文字以上ある場合は ``True`` を、それ" +"以外の場合は ``False`` を返します。\n" +"10進数字とは、U+0660 (ARABIC-INDIC DIGIT ZERO) のように10進数を構成するために" +"使える文字です。\n" +"厳密には、Unicode の一般カテゴリが \"Nd\" である文字を指します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2441 msgid "" ">>> '0123456789'.isdecimal()\n" "True\n" @@ -4027,8 +4360,13 @@ msgid "" ">>> 'alphabetic'.isdecimal()\n" "False" msgstr "" +">>> '0123456789'.isdecimal()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isdecimal() # アラビア・インド数字の0から9\n" +"True\n" +">>> 'alphabetic'.isdecimal()\n" +"False" -#: ../../builtins/stdtypes.rst:2453 msgid "" "Return ``True`` if all characters in the string are digits and there is at " "least one character, ``False`` otherwise. Digits include decimal characters " @@ -4038,6 +4376,14 @@ msgid "" "Kharosthi#Numerals>`__. Formally, a digit is a character that has the " "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" +"文字列内のすべての文字が数字で、かつ1文字以上ある場合は ``True`` を、それ以外" +"の場合は ``False`` を返します。\n" +"数字には10進数字と、互換文字である上付き数字のように特別な扱いが必要な数字が" +"含まれます。\n" +"これには、`カローシュティー数字 `__ のように10進数の構成には使えない数字も含まれます。\n" +"厳密には、プロパティ値 Numeric_Type=Digit または Numeric_Type=Decimal を持つ" +"文字を指します。" #: ../../builtins/stdtypes.rst:2461 ../../builtins/stdtypes.rst:2542 #: ../../builtins/stdtypes.rst:2559 ../../builtins/stdtypes.rst:2586 @@ -4050,7 +4396,6 @@ msgstr "" msgid "For example:" msgstr "例えば:" -#: ../../builtins/stdtypes.rst:2463 msgid "" ">>> '0123456789'.isdigit()\n" "True\n" @@ -4061,10 +4406,17 @@ msgid "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" msgstr "" +">>> '0123456789'.isdigit()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # アラビア・インド数字の0から9\n" +"True\n" +">>> '⅕'.isdigit() # 分数の5分の1\n" +"False\n" +">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" +"(False, True, True)" -#: ../../builtins/stdtypes.rst:2474 msgid "See also :meth:`isdecimal` and :meth:`isnumeric`." -msgstr "" +msgstr ":meth:`isdecimal` と :meth:`isnumeric` も参照してください。" #: ../../builtins/stdtypes.rst:2479 msgid "" @@ -4086,7 +4438,6 @@ msgstr "" msgid "Example: ::" msgstr "例: ::" -#: ../../builtins/stdtypes.rst:2488 msgid "" ">>> from keyword import iskeyword\n" "\n" @@ -4095,6 +4446,12 @@ msgid "" ">>> 'def'.isidentifier(), iskeyword('def')\n" "(True, True)" msgstr "" +">>> from keyword import iskeyword\n" +"\n" +">>> 'hello'.isidentifier(), iskeyword('hello')\n" +"(True, False)\n" +">>> 'def'.isidentifier(), iskeyword('def')\n" +"(True, True)" #: ../../builtins/stdtypes.rst:2498 msgid "" @@ -4105,7 +4462,6 @@ msgstr "" "ある文字が 1 文字以上あるなら ``True`` を、そうでなければ ``False`` を返しま" "す。" -#: ../../builtins/stdtypes.rst:2504 msgid "" "Return ``True`` if all characters in the string are numeric characters, and " "there is at least one character, ``False`` otherwise. Numeric characters " @@ -4114,8 +4470,14 @@ msgid "" "characters are those with the property value Numeric_Type=Digit, " "Numeric_Type=Decimal or Numeric_Type=Numeric. For example:" msgstr "" +"文字列内のすべての文字が数を表す文字で、かつ1文字以上ある場合は ``True`` を、" +"それ以外の場合は ``False`` を返します。\n" +"数を表す文字には、数字や、U+2155 (VULGAR FRACTION ONE FIFTH) のように " +"Unicode の数値プロパティを持つすべての文字が含まれます。\n" +"厳密には、プロパティ値 Numeric_Type=Digit、Numeric_Type=Decimal、" +"Numeric_Type=Numeric のいずれかを持つ文字を指します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2512 msgid "" ">>> '0123456789'.isnumeric()\n" "True\n" @@ -4126,26 +4488,38 @@ msgid "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" msgstr "" +">>> '0123456789'.isnumeric()\n" +"True\n" +">>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # アラビア・インド数字の0から9\n" +"True\n" +">>> '⅕'.isnumeric() # 分数の5分の1\n" +"True\n" +">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" +"(False, True, True)" -#: ../../builtins/stdtypes.rst:2523 msgid "See also :meth:`isdecimal` and :meth:`isdigit`." -msgstr "" +msgstr ":meth:`isdecimal` と :meth:`isdigit` も参照してください。" -#: ../../builtins/stdtypes.rst:2528 msgid "" "Return ``True`` if all characters in the string are printable, ``False`` if " "it contains at least one non-printable character." msgstr "" +"文字列内のすべての文字が表示可能な場合は ``True`` を、表示できない文字が一つ" +"でも含まれる場合は ``False`` を返します。" -#: ../../builtins/stdtypes.rst:2531 msgid "" "Here \"printable\" means the character is suitable for :func:`repr` to use " "in its output; \"non-printable\" means that :func:`repr` on built-in types " "will hex-escape the character. It has no bearing on the handling of strings " "written to :data:`sys.stdout` or :data:`sys.stderr`." msgstr "" +"ここで「表示可能」とは、その文字を :func:`repr` の出力にそのまま使えることを" +"意味します。\n" +"「表示できない」とは、組み込み型に対する :func:`repr` がその文字を16進エス" +"ケープで表すことを意味します。\n" +":data:`sys.stdout` や :data:`sys.stderr` に書き出す文字列の扱いには関係ありま" +"せん。" -#: ../../builtins/stdtypes.rst:2536 msgid "" "The printable characters are those which in the Unicode character database " "(see :mod:`unicodedata`) have a general category in group Letter, Mark, " @@ -4153,18 +4527,25 @@ msgid "" "0x20. Nonprintable characters are those in group Separator or Other (Z or " "C), except the ASCII space." msgstr "" +"表示可能な文字は、Unicode 文字データベース (:mod:`unicodedata` を参照) で一般" +"カテゴリが Letter、Mark、Number、Punctuation、Symbol のグループ (L、M、N、P、" +"S) に属する文字と、ASCII スペース 0x20 です。\n" +"表示できない文字は、ASCII スペースを除く、Separator または Other のグループ " +"(Z、C) に属する文字です。" -#: ../../builtins/stdtypes.rst:2544 msgid "" ">>> ''.isprintable(), ' '.isprintable()\n" "(True, True)\n" ">>> '\\t'.isprintable(), '\\n'.isprintable()\n" "(False, False)" msgstr "" +">>> ''.isprintable(), ' '.isprintable()\n" +"(True, True)\n" +">>> '\\t'.isprintable(), '\\n'.isprintable()\n" +"(False, False)" -#: ../../builtins/stdtypes.rst:2551 msgid "See also :meth:`isspace`." -msgstr "" +msgstr ":meth:`isspace` も参照してください。" #: ../../builtins/stdtypes.rst:2556 msgid "" @@ -4174,7 +4555,6 @@ msgstr "" "文字列が空白文字だけからなり、かつ 1 文字以上ある場合には ``True`` を返し、そ" "うでない場合は ``False`` を返します。" -#: ../../builtins/stdtypes.rst:2561 msgid "" ">>> ''.isspace()\n" "False\n" @@ -4185,8 +4565,15 @@ msgid "" ">>> '\\u3000'.isspace() # IDEOGRAPHIC SPACE\n" "True" msgstr "" +">>> ''.isspace()\n" +"False\n" +">>> ' '.isspace()\n" +"True\n" +">>> '\\t\\n'.isspace() # タブと改行\n" +"True\n" +">>> '\\u3000'.isspace() # 全角スペース\n" +"True" -#: ../../builtins/stdtypes.rst:2572 msgid "" "A character is *whitespace* if in the Unicode character database (see :mod:" "`unicodedata`), either its general category is ``Zs`` (\"Separator, " @@ -4194,11 +4581,10 @@ msgid "" msgstr "" "Unicode 文字データベース (:mod:`unicodedata` を参照) で一般カテゴリが ``Zs`` " "(\"Seperator, space\") であるか、 双方向クラスが ``WS``、``B``、 ``S`` のい" -"ずれかである場合、その文字は *空白文字(whitespace)* です。 " +"ずれかである場合、その文字は *空白文字(whitespace)* です。" -#: ../../builtins/stdtypes.rst:2577 msgid "See also :meth:`isprintable`." -msgstr "" +msgstr ":meth:`isprintable` も参照してください。" #: ../../builtins/stdtypes.rst:2582 msgid "" @@ -4212,7 +4598,6 @@ msgstr "" "にのみ続く場合には ``True`` を返します。そうでない場合は ``False`` を返しま" "す。" -#: ../../builtins/stdtypes.rst:2588 msgid "" ">>> 'Spam, Spam, Spam'.istitle()\n" "True\n" @@ -4221,10 +4606,15 @@ msgid "" ">>> 'SPAM, SPAM, SPAM'.istitle()\n" "False" msgstr "" +">>> 'Spam, Spam, Spam'.istitle()\n" +"True\n" +">>> 'spam, spam, spam'.istitle()\n" +"False\n" +">>> 'SPAM, SPAM, SPAM'.istitle()\n" +"False" -#: ../../builtins/stdtypes.rst:2597 msgid "See also :meth:`title`." -msgstr "" +msgstr ":meth:`title` も参照してください。" #: ../../builtins/stdtypes.rst:2602 msgid "" @@ -4235,25 +4625,31 @@ msgstr "" "ある文字が 1 文字以上あるなら ``True`` を、そうでなければ ``False`` を返しま" "す。" -#: ../../builtins/stdtypes.rst:2620 msgid "" "Return a string which is the concatenation of the strings in *iterable*. A :" "exc:`TypeError` will be raised if there are any non-string values in " "*iterable*, including :class:`bytes` objects. The separator between " "elements is the string providing this method. For example:" msgstr "" +"``iterable`` 内の文字列を結合した文字列を返します。\n" +"``iterable`` に :class:`bytes` オブジェクトを含む文字列以外の値が一つでもある" +"場合は、:exc:`TypeError` が送出されます。\n" +"要素間の区切りには、このメソッドを呼び出す文字列を使います。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2625 msgid "" ">>> ', '.join(['spam', 'spam', 'spam'])\n" "'spam, spam, spam'\n" ">>> '-'.join('Python')\n" "'P-y-t-h-o-n'" msgstr "" +">>> ', '.join(['spam', 'spam', 'spam'])\n" +"'spam, spam, spam'\n" +">>> '-'.join('Python')\n" +"'P-y-t-h-o-n'" -#: ../../builtins/stdtypes.rst:2632 msgid "See also :meth:`split`." -msgstr "" +msgstr ":meth:`split` も参照してください。" #: ../../builtins/stdtypes.rst:2637 msgid "" @@ -4265,7 +4661,6 @@ msgstr "" "(デフォルトでは ASCII スペース) を使って行われます。 *width* が ``len(s)`` 以" "下ならば、元の文字列が返されます。" -#: ../../builtins/stdtypes.rst:2643 msgid "" ">>> 'Python'.ljust(10)\n" "'Python '\n" @@ -4274,29 +4669,39 @@ msgid "" ">>> 'Monty Python'.ljust(10, '.')\n" "'Monty Python'" msgstr "" +">>> 'Python'.ljust(10)\n" +"'Python '\n" +">>> 'Python'.ljust(10, '.')\n" +"'Python....'\n" +">>> 'Monty Python'.ljust(10, '.')\n" +"'Monty Python'" -#: ../../builtins/stdtypes.rst:2652 ../../builtins/stdtypes.rst:3199 msgid "See also :meth:`rjust`." -msgstr "" +msgstr ":meth:`rjust` も参照してください。" -#: ../../builtins/stdtypes.rst:2657 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "lowercase. For example:" msgstr "" +"大小文字の区別のある文字 [4]_ をすべて小文字に変換した文字列のコピーを返しま" +"す。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2660 msgid "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" msgstr "" +">>> 'Lower Method Example'.lower()\n" +"'lower method example'" -#: ../../builtins/stdtypes.rst:2665 msgid "" "The lowercasing algorithm used is `described in section 3.13.2 'Default Case " "Conversion' of the Unicode Standard `__." msgstr "" +"小文字化のアルゴリズムは `Unicode 標準の3.13.2節「Default Case Conversion」 " +"`__ に記載されています。" #: ../../builtins/stdtypes.rst:2672 msgid "" @@ -4311,13 +4716,16 @@ msgstr "" "除去されます。 *chars* 文字列は接頭辞ではなく、その値に含まれる文字の組み合わ" "せ全てがはぎ取られます::" -#: ../../builtins/stdtypes.rst:2677 msgid "" ">>> ' spacious '.lstrip()\n" "'spacious '\n" ">>> 'www.example.com'.lstrip('cmowz.')\n" "'example.com'" msgstr "" +">>> ' spacious '.lstrip()\n" +"'spacious '\n" +">>> 'www.example.com'.lstrip('cmowz.')\n" +"'example.com'" #: ../../builtins/stdtypes.rst:2682 msgid "" @@ -4327,13 +4735,16 @@ msgstr "" "文字の集合全てではなく、指定した文字列そのものを接頭辞として削除するメソッド" "については、 :meth:`str.removeprefix` を参照してください。使用例::" -#: ../../builtins/stdtypes.rst:2685 msgid "" ">>> 'Arthur: three!'.lstrip('Arthur: ')\n" "'ee!'\n" ">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" "'three!'" msgstr "" +">>> 'Arthur: three!'.lstrip('Arthur: ')\n" +"'ee!'\n" +">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" +"'three!'" #: ../../builtins/stdtypes.rst:2694 msgid "" @@ -4353,17 +4764,20 @@ msgstr "" "文字列) を、Unicode 序数、(任意長の) 文字列、または ``None`` に対応づける辞書" "でなければなりません。このとき、文字で指定したキーは序数に変換されます。" -#: ../../builtins/stdtypes.rst:2701 msgid "" "If there are two arguments, they must be strings of equal length, and in the " "resulting dictionary, each character in *from* will be mapped to the " "character at the same position in *to*. If there is a third argument, it " "must be a string, whose characters will be mapped to ``None`` in the result." msgstr "" +"引数が二つの場合、どちらも同じ長さの文字列でなければなりません。\n" +"結果の辞書では、``from`` の各文字が ``to`` の同じ位置の文字にマップされま" +"す。\n" +"3番目の引数を指定する場合、その引数は文字列でなければならず、その各文字は結果" +"で ``None`` にマップされます。" -#: ../../builtins/stdtypes.rst:2708 msgid "*dict* can now be a :class:`frozendict`." -msgstr "" +msgstr "``dict`` に :class:`frozendict` を指定できるようになりました。" #: ../../builtins/stdtypes.rst:2713 msgid "" @@ -4377,7 +4791,6 @@ msgstr "" "す。もし区切れなければ、タプルには元の文字列そのものとその後ろに二つの空文字" "列が入ります。" -#: ../../builtins/stdtypes.rst:2720 msgid "" ">>> 'Monty Python'.partition(' ')\n" "('Monty', ' ', 'Python')\n" @@ -4386,95 +4799,123 @@ msgid "" ">>> 'Monty Python'.partition('-')\n" "('Monty Python', '', '')" msgstr "" +">>> 'Monty Python'.partition(' ')\n" +"('Monty', ' ', 'Python')\n" +">>> \"Monty Python's Flying Circus\".partition(' ')\n" +"('Monty', ' ', \"Python's Flying Circus\")\n" +">>> 'Monty Python'.partition('-')\n" +"('Monty Python', '', '')" -#: ../../builtins/stdtypes.rst:2729 msgid "See also :meth:`rpartition`." -msgstr "" +msgstr ":meth:`rpartition` も参照してください。" -#: ../../builtins/stdtypes.rst:2734 msgid "" "If the string starts with the *prefix* string, return " "``string[len(prefix):]``. Otherwise, return a copy of the original string:" msgstr "" +"文字列が ``prefix`` で始まる場合は ``string[len(prefix):]`` を返します。\n" +"それ以外の場合は、元の文字列のコピーを返します:" -#: ../../builtins/stdtypes.rst:2738 msgid "" ">>> 'TestHook'.removeprefix('Test')\n" "'Hook'\n" ">>> 'BaseTestCase'.removeprefix('Test')\n" "'BaseTestCase'" msgstr "" +">>> 'TestHook'.removeprefix('Test')\n" +"'Hook'\n" +">>> 'BaseTestCase'.removeprefix('Test')\n" +"'BaseTestCase'" -#: ../../builtins/stdtypes.rst:2747 msgid "See also :meth:`removesuffix` and :meth:`startswith`." -msgstr "" +msgstr ":meth:`removesuffix` と :meth:`startswith` も参照してください。" -#: ../../builtins/stdtypes.rst:2752 msgid "" "If the string ends with the *suffix* string and that *suffix* is not empty, " "return ``string[:-len(suffix)]``. Otherwise, return a copy of the original " "string:" msgstr "" +"文字列が ``suffix`` で終わり、かつ ``suffix`` が空でない場合は ``string[:-" +"len(suffix)]`` を返します。\n" +"それ以外の場合は、元の文字列のコピーを返します:" -#: ../../builtins/stdtypes.rst:2756 msgid "" ">>> 'MiscTests'.removesuffix('Tests')\n" "'Misc'\n" ">>> 'TmpDirMixin'.removesuffix('Tests')\n" "'TmpDirMixin'" msgstr "" +">>> 'MiscTests'.removesuffix('Tests')\n" +"'Misc'\n" +">>> 'TmpDirMixin'.removesuffix('Tests')\n" +"'TmpDirMixin'" -#: ../../builtins/stdtypes.rst:2765 msgid "See also :meth:`removeprefix` and :meth:`endswith`." -msgstr "" +msgstr ":meth:`removeprefix` と :meth:`endswith` も参照してください。" -#: ../../builtins/stdtypes.rst:2770 msgid "" "Return a copy of the string with all occurrences of substring *old* replaced " "by *new*. If *count* is given, only the first *count* occurrences are " "replaced. If *count* is not specified or ``-1``, then all occurrences are " "replaced. For example:" msgstr "" +"部分文字列 ``old`` のすべての出現箇所を ``new`` に置き換えた文字列のコピーを" +"返します。\n" +"``count`` を指定した場合は、先頭から ``count`` 個の出現箇所だけを置き換えま" +"す。\n" +"``count`` を指定しない場合や ``-1`` を指定した場合は、すべての出現箇所を置き" +"換えます。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2775 msgid "" ">>> 'spam, spam, spam'.replace('spam', 'eggs')\n" "'eggs, eggs, eggs'\n" ">>> 'spam, spam, spam'.replace('spam', 'eggs', 1)\n" "'eggs, spam, spam'" msgstr "" +">>> 'spam, spam, spam'.replace('spam', 'eggs')\n" +"'eggs, eggs, eggs'\n" +">>> 'spam, spam, spam'.replace('spam', 'eggs', 1)\n" +"'eggs, spam, spam'" #: ../../builtins/stdtypes.rst:2782 ../../builtins/stdtypes.rst:4079 msgid "*count* is now supported as a keyword argument." msgstr "*count* はキーワード引数として指定可能になりました。" -#: ../../builtins/stdtypes.rst:2788 msgid "" "Return the highest index in the string where substring *sub* is found, such " "that *sub* is contained within ``s[start:end]``. Optional arguments *start* " "and *end* are interpreted as in slice notation. Return ``-1`` on failure. " "For example:" msgstr "" +"部分文字列 ``sub`` が ``s[start:end]`` に収まる位置で見つかる、文字列内の最大" +"のインデックスを返します。\n" +"省略可能な ``start`` と ``end`` 引数はスライス表記と同様に解釈されます。\n" +"見つからない場合は ``-1`` を返します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2793 msgid "" ">>> 'spam, spam, spam'.rfind('sp')\n" "12\n" ">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" "6" msgstr "" +">>> 'spam, spam, spam'.rfind('sp')\n" +"12\n" +">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" +"6" -#: ../../builtins/stdtypes.rst:2800 msgid "See also :meth:`find` and :meth:`rindex`." -msgstr "" +msgstr ":meth:`find` と :meth:`rindex` も参照してください。" -#: ../../builtins/stdtypes.rst:2805 msgid "" "Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is " "not found. For example:" msgstr "" +":meth:`rfind` と同様ですが、部分文字列 ``sub`` が見つからない場合は :exc:" +"`ValueError` を送出します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2809 msgid "" ">>> 'spam, spam, spam'.rindex('spam')\n" "12\n" @@ -4485,10 +4926,17 @@ msgid "" " ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" msgstr "" +">>> 'spam, spam, spam'.rindex('spam')\n" +"12\n" +">>> 'spam, spam, spam'.rindex('eggs')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" 'spam, spam, spam'.rindex('eggs')\n" +" ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" +"ValueError: substring not found" -#: ../../builtins/stdtypes.rst:2820 msgid "See also :meth:`index` and :meth:`find`." -msgstr "" +msgstr ":meth:`index` と :meth:`find` も参照してください。" #: ../../builtins/stdtypes.rst:2825 msgid "" @@ -4500,7 +4948,6 @@ msgstr "" "指定された文字(デフォルトでは ASCII スペース)が使われます。 *width* が " "``len(s)`` 以下の場合、元の文字列が返されます。" -#: ../../builtins/stdtypes.rst:2831 msgid "" ">>> 'Python'.rjust(10)\n" "' Python'\n" @@ -4509,10 +4956,15 @@ msgid "" ">>> 'Monty Python'.rjust(10, '.')\n" "'Monty Python'" msgstr "" +">>> 'Python'.rjust(10)\n" +"' Python'\n" +">>> 'Python'.rjust(10, '.')\n" +"'....Python'\n" +">>> 'Monty Python'.rjust(10, '.')\n" +"'Monty Python'" -#: ../../builtins/stdtypes.rst:2840 msgid "See also :meth:`ljust` and :meth:`zfill`." -msgstr "" +msgstr ":meth:`ljust` と :meth:`zfill` も参照してください。" #: ../../builtins/stdtypes.rst:2845 msgid "" @@ -4526,7 +4978,6 @@ msgstr "" "す。もし区切れなければ、タプルには二つの空文字列とその後ろに元の文字列そのも" "のが入ります。" -#: ../../builtins/stdtypes.rst:2852 msgid "" ">>> 'Monty Python'.rpartition(' ')\n" "('Monty', ' ', 'Python')\n" @@ -4535,12 +4986,16 @@ msgid "" ">>> 'Monty Python'.rpartition('-')\n" "('', '', 'Monty Python')" msgstr "" +">>> 'Monty Python'.rpartition(' ')\n" +"('Monty', ' ', 'Python')\n" +">>> \"Monty Python's Flying Circus\".rpartition(' ')\n" +"(\"Monty Python's Flying\", ' ', 'Circus')\n" +">>> 'Monty Python'.rpartition('-')\n" +"('', '', 'Monty Python')" -#: ../../builtins/stdtypes.rst:2861 msgid "See also :meth:`partition`." -msgstr "" +msgstr ":meth:`partition` も参照してください。" -#: ../../builtins/stdtypes.rst:2866 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done, the " @@ -4549,8 +5004,13 @@ msgid "" "the right, :meth:`rsplit` behaves like :meth:`split` which is described in " "detail below." msgstr "" +"区切り文字列として ``sep`` を使い、文字列内の単語のリストを返します。\n" +"``maxsplit`` を指定した場合は、*右端から* 最大 ``maxsplit`` 回分割します。\n" +"``sep`` を指定しない場合や ``None`` を指定した場合は、任意の :meth:`空白文字 " +"` の文字列を区切りとします。\n" +"右から分割する点を除いて、:meth:`rsplit` は後で詳しく説明する :meth:`split` " +"と同様に動作します。" -#: ../../builtins/stdtypes.rst:2876 msgid "" "Return a copy of the string with trailing characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -4558,32 +5018,46 @@ msgid "" "The *chars* argument is not a suffix; rather, all combinations of its values " "are stripped. For example:" msgstr "" +"末尾の文字を除去した文字列のコピーを返します。\n" +"``chars`` 引数は、除去する文字の集合を指定する文字列です。\n" +"``chars`` 引数を省略した場合や ``None`` を指定した場合は、デフォルトで空白文" +"字を除去します。\n" +"``chars`` 引数を接尾辞として扱うのではなく、その値を構成する文字を組み合わせ" +"に関係なく除去します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:2882 msgid "" ">>> ' spacious '.rstrip()\n" "' spacious'\n" ">>> 'mississippi'.rstrip('ipz')\n" "'mississ'" msgstr "" +">>> ' spacious '.rstrip()\n" +"' spacious'\n" +">>> 'mississippi'.rstrip('ipz')\n" +"'mississ'" -#: ../../builtins/stdtypes.rst:2889 msgid "" "See :meth:`removesuffix` for a method that will remove a single suffix " "string rather than all of a set of characters. For example::" msgstr "" +"文字の集合に含まれる文字をすべて除去するのではなく、一つの接尾辞文字列を除去" +"するメソッドについては、:meth:`removesuffix` を参照してください。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:2892 msgid "" ">>> 'Monty Python'.rstrip(' Python')\n" "'M'\n" ">>> 'Monty Python'.removesuffix(' Python')\n" "'Monty'" msgstr "" +">>> 'Monty Python'.rstrip(' Python')\n" +"'M'\n" +">>> 'Monty Python'.removesuffix(' Python')\n" +"'Monty'" -#: ../../builtins/stdtypes.rst:2897 msgid "See also :meth:`strip`." -msgstr "" +msgstr ":meth:`strip` も参照してください。" #: ../../builtins/stdtypes.rst:2902 msgid "" @@ -4613,7 +5087,6 @@ msgstr "" "字で分割するには :func:`re.split` を使用します)。区切り文字を指定して空の文字" "列を分割すると、 ``['']`` を返します。" -#: ../../builtins/stdtypes.rst:2917 msgid "" ">>> '1,2,3'.split(',')\n" "['1', '2', '3']\n" @@ -4624,8 +5097,15 @@ msgid "" ">>> '1<>2<>3<4'.split('<>')\n" "['1', '2', '3<4']" msgstr "" +">>> '1,2,3'.split(',')\n" +"['1', '2', '3']\n" +">>> '1,2,3'.split(',', maxsplit=1)\n" +"['1', '2,3']\n" +">>> '1,2,,3,'.split(',')\n" +"['1', '2', '', '3', '']\n" +">>> '1<>2<>3<4'.split('<>')\n" +"['1', '2', '3<4']" -#: ../../builtins/stdtypes.rst:2928 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive :meth:`whitespace ` are regarded " @@ -4634,8 +5114,15 @@ msgid "" "Consequently, splitting an empty string or a string consisting of just " "whitespace with a ``None`` separator returns ``[]``." msgstr "" +"``sep`` を指定しない場合や ``None`` を指定した場合は、別の分割アルゴリズムを" +"適用します。\n" +"連続する :meth:`空白文字 ` のまとまりを一つの区切りとみなしま" +"す。\n" +"文字列の先頭や末尾に空白文字があっても、結果の先頭や末尾に空文字列は含まれま" +"せん。\n" +"そのため、区切りとして ``None`` を使って空文字列や空白文字のみの文字列を分割" +"すると、``[]`` が返されます。" -#: ../../builtins/stdtypes.rst:2938 msgid "" ">>> '1 2 3'.split()\n" "['1', '2', '3']\n" @@ -4644,14 +5131,20 @@ msgid "" ">>> ' 1 2 3 '.split()\n" "['1', '2', '3']" msgstr "" +">>> '1 2 3'.split()\n" +"['1', '2', '3']\n" +">>> '1 2 3'.split(maxsplit=1)\n" +"['1', '2 3']\n" +">>> ' 1 2 3 '.split()\n" +"['1', '2', '3']" -#: ../../builtins/stdtypes.rst:2947 msgid "" "If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only " "leading runs of consecutive whitespace are considered." msgstr "" +"``sep`` を指定しないか ``None`` を指定し、かつ ``maxsplit`` が ``0`` の場合" +"は、先頭の連続する空白文字だけを扱います。" -#: ../../builtins/stdtypes.rst:2952 msgid "" ">>> \"\".split(None, 0)\n" "[]\n" @@ -4660,10 +5153,15 @@ msgid "" ">>> \" foo \".split(maxsplit=0)\n" "['foo ']" msgstr "" +">>> \"\".split(None, 0)\n" +"[]\n" +">>> \" \".split(None, 0)\n" +"[]\n" +">>> \" foo \".split(maxsplit=0)\n" +"['foo ']" -#: ../../builtins/stdtypes.rst:2961 msgid "See also :meth:`join` and :meth:`rsplit`." -msgstr "" +msgstr ":meth:`join` と :meth:`rsplit` も参照してください。" #: ../../builtins/stdtypes.rst:2969 msgid "" @@ -4710,9 +5208,8 @@ msgstr "復帰" msgid "``\\r\\n``" msgstr "``\\r\\n``" -#: ../../builtins/stdtypes.rst:2983 msgid "Carriage Return + Line Feed" -msgstr "改行 + 復帰" +msgstr "復帰 + 改行" #: ../../builtins/stdtypes.rst:2985 msgid "``\\v`` or ``\\x0b``" @@ -4794,42 +5291,51 @@ msgstr "``\\v`` と ``\\f`` が行境界のリストに追加されました。" msgid "For example::" msgstr "例えば::" -#: ../../builtins/stdtypes.rst:3008 msgid "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "['ab c', '', 'de fg', 'kl']\n" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" msgstr "" +">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" +"['ab c', '', 'de fg', 'kl']\n" +">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" +"['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" -#: ../../builtins/stdtypes.rst:3013 msgid "" "Unlike :meth:`~str.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -":meth:`~str.split` とは違って、デリミタ文字列 *sep* が与えられたとき、このメ" -"ソッドは空文字列に空リストを返し、終末の改行は結果に行を追加しません::" +"区切り文字列 *sep* を指定した :meth:`~str.split` とは異なり、\n" +"このメソッドは空文字列に対して空のリストを返し、末尾に改行があっても余分な行" +"を追加しません::" -#: ../../builtins/stdtypes.rst:3017 msgid "" ">>> \"\".splitlines()\n" "[]\n" ">>> \"One line\\n\".splitlines()\n" "['One line']" msgstr "" +">>> \"\".splitlines()\n" +"[]\n" +">>> \"One line\\n\".splitlines()\n" +"['One line']" #: ../../builtins/stdtypes.rst:3022 msgid "For comparison, ``split('\\n')`` gives::" msgstr "比較のために ``split('\\n')`` は以下のようになります::" -#: ../../builtins/stdtypes.rst:3024 msgid "" ">>> ''.split('\\n')\n" "['']\n" ">>> 'Two lines\\n'.split('\\n')\n" "['Two lines', '']" msgstr "" +">>> ''.split('\\n')\n" +"['']\n" +">>> 'Two lines\\n'.split('\\n')\n" +"['Two lines', '']" #: ../../builtins/stdtypes.rst:3032 msgid "" @@ -4843,7 +5349,6 @@ msgstr "" "ん。オプションの *start* があれば、その位置から判定を始めます。オプションの " "*end* があれば、その位置で比較を止めます。" -#: ../../builtins/stdtypes.rst:3039 msgid "" ">>> 'Python'.startswith('Py')\n" "True\n" @@ -4852,12 +5357,16 @@ msgid "" ">>> 'Python is amazing'.startswith('is', 7)\n" "True" msgstr "" +">>> 'Python'.startswith('Py')\n" +"True\n" +">>> 'a tuple of prefixes'.startswith(('at', 'a'))\n" +"True\n" +">>> 'Python is amazing'.startswith('is', 7)\n" +"True" -#: ../../builtins/stdtypes.rst:3048 msgid "See also :meth:`endswith` and :meth:`removeprefix`." -msgstr "" +msgstr ":meth:`endswith` と :meth:`removeprefix` も参照してください。" -#: ../../builtins/stdtypes.rst:3053 msgid "" "Return a copy of the string with the leading and trailing characters " "removed. The *chars* argument is a string specifying the set of characters " @@ -4865,65 +5374,82 @@ msgid "" "removing whitespace. The *chars* argument is not a prefix or suffix; rather, " "all combinations of its values are stripped." msgstr "" +"先頭と末尾の文字を除去した文字列のコピーを返します。\n" +"``chars`` 引数は、除去する文字の集合を指定する文字列です。\n" +"``chars`` 引数を省略した場合や ``None`` を指定した場合は、デフォルトで空白文" +"字を除去します。\n" +"``chars`` 引数を接頭辞や接尾辞として扱うのではなく、その値を構成する文字を組" +"み合わせに関係なく除去します。" -#: ../../builtins/stdtypes.rst:3059 msgid "Whitespace characters are defined by :meth:`str.isspace`." -msgstr "" +msgstr "空白文字は :meth:`str.isspace` で定義されています。" -#: ../../builtins/stdtypes.rst:3063 msgid "" ">>> ' spacious '.strip()\n" "'spacious'\n" ">>> 'www.example.com'.strip('cmowz.')\n" "'example'" msgstr "" +">>> ' spacious '.strip()\n" +"'spacious'\n" +">>> 'www.example.com'.strip('cmowz.')\n" +"'example'" -#: ../../builtins/stdtypes.rst:3070 msgid "" "The outermost leading and trailing *chars* argument values are stripped from " "the string. Characters are removed from the leading end until reaching a " "string character that is not contained in the set of characters in *chars*. " "A similar action takes place on the trailing end." msgstr "" +"文字列の先頭と末尾の最も外側から、``chars`` 引数に含まれる文字を除去しま" +"す。\n" +"先頭では、``chars`` の文字の集合に含まれない文字に達するまで文字を除去しま" +"す。\n" +"末尾でも同様に処理します。" -#: ../../builtins/stdtypes.rst:3077 msgid "" ">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" ">>> comment_string.strip('.#! ')\n" "'Section 3.2.1 Issue #32'" msgstr "" +">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" +">>> comment_string.strip('.#! ')\n" +"'Section 3.2.1 Issue #32'" -#: ../../builtins/stdtypes.rst:3083 msgid "See also :meth:`rstrip`." -msgstr "" +msgstr ":meth:`rstrip` も参照してください。" -#: ../../builtins/stdtypes.rst:3088 msgid "" "Return a copy of the string with uppercase characters converted to lowercase " "and vice versa. For example:" msgstr "" +"大文字を小文字に、小文字を大文字に変換した文字列のコピーを返します。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:3091 msgid "" ">>> 'Hello World'.swapcase()\n" "'hELLO wORLD'" msgstr "" +">>> 'Hello World'.swapcase()\n" +"'hELLO wORLD'" -#: ../../builtins/stdtypes.rst:3096 msgid "" "Note that it is not necessarily true that ``s.swapcase().swapcase() == s``. " "For example:" msgstr "" +"``s.swapcase().swapcase() == s`` が常に成り立つとは限らないことに注意してくだ" +"さい。\n" +"例えば、次のようになります:" -#: ../../builtins/stdtypes.rst:3099 msgid "" ">>> 'straße'.swapcase().swapcase()\n" "'strasse'" msgstr "" +">>> 'straße'.swapcase().swapcase()\n" +"'strasse'" -#: ../../builtins/stdtypes.rst:3104 msgid "See also :meth:`str.lower` and :meth:`str.upper`." -msgstr "" +msgstr ":meth:`str.lower` と :meth:`str.upper` も参照してください。" #: ../../builtins/stdtypes.rst:3109 msgid "" @@ -4933,11 +5459,12 @@ msgstr "" "文字列を、単語ごとに大文字から始まり、残りの文字のうち大小文字の区別があるも" "のは全て小文字にする、タイトルケースにして返します。" -#: ../../builtins/stdtypes.rst:3114 msgid "" ">>> 'Hello world'.title()\n" "'Hello World'" msgstr "" +">>> 'Hello world'.title()\n" +"'Hello World'" #: ../../builtins/stdtypes.rst:3117 ../../builtins/stdtypes.rst:4607 msgid "" @@ -4951,11 +5478,12 @@ msgstr "" "アポストロフィが単語の境界になってしまい、望みの結果を得られない場合がありま" "す::" -#: ../../builtins/stdtypes.rst:3122 msgid "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" msgstr "" +">>> \"they're bill's friends from the UK\".title()\n" +"\"They'Re Bill'S Friends From The Uk\"" #: ../../builtins/stdtypes.rst:3125 msgid "" @@ -4971,7 +5499,6 @@ msgid "" "expressions::" msgstr "または、正規表現を使うことでアポストロフィに対応できます::" -#: ../../builtins/stdtypes.rst:3131 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -4982,10 +5509,17 @@ msgid "" ">>> titlecase(\"they're bill's friends.\")\n" "\"They're Bill's Friends.\"" msgstr "" +">>> import re\n" +">>> def titlecase(s):\n" +"... return re.sub(r\"[A-Za-z]+('[A-Za-z]+)?\",\n" +"... lambda mo: mo.group(0).capitalize(),\n" +"... s)\n" +"...\n" +">>> titlecase(\"they're bill's friends.\")\n" +"\"They're Bill's Friends.\"" -#: ../../builtins/stdtypes.rst:3140 msgid "See also :meth:`istitle`." -msgstr "" +msgstr ":meth:`istitle` も参照してください。" #: ../../builtins/stdtypes.rst:3145 msgid "" @@ -5016,17 +5550,19 @@ msgstr "" "文字から文字への異なる形式のマッピングから変換マップを作成するために、 :meth:" "`str.maketrans` が使えます。" -#: ../../builtins/stdtypes.rst:3157 msgid "" "The following example uses a mapping to replace ``'a'`` with ``'X'``, " "``'b'`` with ``'Y'``, and delete ``'c'``:" msgstr "" +"次の例では、マッピングを使って ``'a'`` を ``'X'`` に、``'b'`` を ``'Y'`` に置" +"き換え、``'c'`` を削除します:" -#: ../../builtins/stdtypes.rst:3160 msgid "" ">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n" "'XY123'" msgstr "" +">>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None})\n" +"'XY123'" #: ../../builtins/stdtypes.rst:3165 msgid "" @@ -5049,54 +5585,58 @@ msgstr "" "含まなかったり、結果の文字の Unicode カテゴリが \"Lu\" ではなく例えば " "\"Lt\" (Letter, titlecase) などであったら、 ``False`` になりえます。" -#: ../../builtins/stdtypes.rst:3177 msgid "" "The uppercasing algorithm used is `described in section 3.13.2 'Default Case " "Conversion' of the Unicode Standard `__." msgstr "" +"大文字化のアルゴリズムは `Unicode 標準の3.13.2節「Default Case Conversion」 " +"`__ に記載されています。" -#: ../../builtins/stdtypes.rst:3184 msgid "" "Return a copy of the string left filled with ASCII ``'0'`` digits to make a " "string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled " "by inserting the padding *after* the sign character rather than before. The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -"長さが *width* になるよう ASCII ``'0'`` で左詰めした文字列のコピーを返しま" -"す。先頭が符号接頭辞 (``'+'``/``'-'``) だった場合、 ``'0'`` は符号の前ではな" -"く *後* に挿入されます。*width* が ``len(s)`` 以下の場合元の文字列を返しま" -"す。" +"長さが ``width`` になるよう、左側を ASCII ``'0'`` で埋めた文字列のコピーを返" +"します。\n" +"先頭に符号接頭辞 (``'+'``/``'-'``) がある場合は、符号文字の前ではなく *後* に" +"パディングを挿入します。\n" +"``width`` が ``len(s)`` 以下の場合は元の文字列を返します。" -#: ../../builtins/stdtypes.rst:3192 msgid "" ">>> \"42\".zfill(5)\n" "'00042'\n" ">>> \"-42\".zfill(5)\n" "'-0042'" msgstr "" +">>> \"42\".zfill(5)\n" +"'00042'\n" +">>> \"-42\".zfill(5)\n" +"'-0042'" -#: ../../builtins/stdtypes.rst:3219 msgid "Formatted String Literals (f-strings)" -msgstr "" +msgstr "フォーマット済み文字列リテラル (f-string)" -#: ../../builtins/stdtypes.rst:3222 msgid "" "The :keyword:`await` and :keyword:`async for` can be used in expressions " "within f-strings." msgstr "" +"f-string 内の式で :keyword:`await` と :keyword:`async for` を使えるようになり" +"ました。" -#: ../../builtins/stdtypes.rst:3225 msgid "Added the debug specifier (``=``)" -msgstr "" +msgstr "デバッグ指定子 (``=``) を追加しました" -#: ../../builtins/stdtypes.rst:3227 msgid "" "Many restrictions on expressions within f-strings have been removed. " "Notably, nested strings, comments, and backslashes are now permitted." msgstr "" +"f-string 内の式に対する多くの制限が取り除かれました。\n" +"特に、文字列の入れ子、コメント、バックスラッシュが使えるようになりました。" -#: ../../builtins/stdtypes.rst:3231 msgid "" "An :dfn:`f-string` (formally a :dfn:`formatted string literal`) is a string " "literal that is prefixed with ``f`` or ``F``. This type of string literal " @@ -5104,59 +5644,68 @@ msgid "" "*replacement fields*, which are delimited by curly brackets (``{}``). Each " "replacement field must contain an expression, optionally followed by:" msgstr "" +"接頭辞 ``f`` または ``F`` を付けた文字列リテラルを :dfn:`f-string` (正式に" +"は :dfn:`フォーマット済み文字列リテラル`) と呼びます。\n" +"この文字列リテラルでは、波括弧 (``{}``) で区切った *置換フィールド* に、任意" +"の Python 式の結果を埋め込めます。\n" +"各置換フィールドには式が必要で、その後に必要に応じて次のものを指定できます:" -#: ../../builtins/stdtypes.rst:3238 msgid "a *debug specifier* -- an equal sign (``=``);" -msgstr "" +msgstr "*デバッグ指定子* である等号 (``=``)。" -#: ../../builtins/stdtypes.rst:3239 msgid "a *conversion specifier* -- ``!s``, ``!r`` or ``!a``; and/or" msgstr "" +"*変換指定子* である ``!s``、``!r``、``!a`` のいずれか。\n" +"これと次の書式指定子は、どちらか一方または両方を指定できます。" -#: ../../builtins/stdtypes.rst:3240 msgid "a *format specifier* prefixed with a colon (``:``)." -msgstr "" +msgstr "コロン (``:``) を先頭に付けた *書式指定子*。" -#: ../../builtins/stdtypes.rst:3242 msgid "" "See the :ref:`Lexical Analysis section on f-strings ` for details " "on the syntax of these fields." msgstr "" +"これらのフィールドの構文について詳しくは、:ref:`字句解析の f-string に関する" +"節 ` を参照してください。" -#: ../../builtins/stdtypes.rst:3246 msgid "Debug specifier" -msgstr "" +msgstr "デバッグ指定子" -#: ../../builtins/stdtypes.rst:3250 msgid "" "If a debug specifier -- an equal sign (``=``) -- appears after the " "replacement field expression, the resulting f-string will contain the " "expression's source, the equal sign, and the value of the expression. This " "is often useful for debugging::" msgstr "" +"置換フィールドの式の後にデバッグ指定子である等号 (``=``) を付けると、結果の " +"f-string には式のソース、等号、式の値が含まれます。\n" +"これはデバッグに役立つことがよくあります。 ::" -#: ../../builtins/stdtypes.rst:3255 msgid "" ">>> number = 14.3\n" ">>> f'{number=}'\n" "'number=14.3'" msgstr "" +">>> number = 14.3\n" +">>> f'{number=}'\n" +"'number=14.3'" -#: ../../builtins/stdtypes.rst:3259 msgid "" "Whitespace before, inside and after the expression, as well as whitespace " "after the equal sign, is significant --- it is retained in the result::" msgstr "" +"式の前後や内部の空白、および等号の後の空白には意味があり、そのまま結果に残り" +"ます。 ::" -#: ../../builtins/stdtypes.rst:3262 msgid "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" msgstr "" +">>> f'{ number - 4 = }'\n" +"' number - 4 = 10.3'" -#: ../../builtins/stdtypes.rst:3267 msgid "Conversion specifier" -msgstr "" +msgstr "変換指定子" #: ../../builtins/stdtypes.rst:3269 msgid "" @@ -5164,44 +5713,44 @@ msgid "" "string using :func:`str`::" msgstr "" -#: ../../builtins/stdtypes.rst:3272 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" ">>> f'{one_third}'\n" "'1/3'" msgstr "" +">>> from fractions import Fraction\n" +">>> one_third = Fraction(1, 3)\n" +">>> f'{one_third}'\n" +"'1/3'" -#: ../../builtins/stdtypes.rst:3277 msgid "" "When a debug specifier but no format specifier is used, the default " "conversion instead uses :func:`repr`::" msgstr "" +"デバッグ指定子があり書式指定子がない場合、デフォルトの変換には代わりに :func:" +"`repr` を使います。 ::" -#: ../../builtins/stdtypes.rst:3280 msgid "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" msgstr "" +">>> f'{one_third = }'\n" +"'one_third = Fraction(1, 3)'" -#: ../../builtins/stdtypes.rst:3283 msgid "" "The conversion can be specified explicitly using one of these specifiers:" -msgstr "" +msgstr "次のいずれかの指定子を使って、変換を明示的に指定できます:" -#: ../../builtins/stdtypes.rst:3285 msgid "``!s`` for :func:`str`" -msgstr "" +msgstr ":func:`str` に対しては ``!s``" -#: ../../builtins/stdtypes.rst:3286 msgid "``!r`` for :func:`repr`" -msgstr "" +msgstr ":func:`repr` に対しては ``!r``" -#: ../../builtins/stdtypes.rst:3287 msgid "``!a`` for :func:`ascii`" -msgstr "" +msgstr ":func:`ascii` に対しては ``!a``" -#: ../../builtins/stdtypes.rst:3291 msgid "" ">>> str(one_third)\n" "'1/3'\n" @@ -5218,12 +5767,24 @@ msgid "" ">>> f'{string = !a}'\n" "\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" msgstr "" +">>> str(one_third)\n" +"'1/3'\n" +">>> repr(one_third)\n" +"'Fraction(1, 3)'\n" +"\n" +">>> f'{one_third!s} is {one_third!r}'\n" +"'1/3 is Fraction(1, 3)'\n" +"\n" +">>> string = \"¡kočka 😸!\"\n" +">>> ascii(string)\n" +"\"'\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"\n" +"\n" +">>> f'{string = !a}'\n" +"\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" -#: ../../builtins/stdtypes.rst:3308 msgid "Format specifier" -msgstr "" +msgstr "書式指定子" -#: ../../builtins/stdtypes.rst:3310 msgid "" "After the expression has been evaluated, and possibly converted using an " "explicit conversion specifier, it is formatted using the :func:`format` " @@ -5232,8 +5793,13 @@ msgid "" "argument. The result of :func:`!format` is then used as the final value for " "the replacement field. For example::" msgstr "" +"式を評価し、明示的な変換指定子がある場合は変換を行った後、:func:`format` 関数" +"で書式化します。\n" +"置換フィールドにコロン (``:``) に続く *書式指定子* が含まれている場合、その指" +"定子を :func:`!format` の第2引数として渡します。\n" +":func:`!format` の結果を置換フィールドの最終的な値として使います。\n" +"例えば、次のようになります。 ::" -#: ../../builtins/stdtypes.rst:3317 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -5246,30 +5812,41 @@ msgid "" ">>> f'{one_third = :~>10}~'\n" "'one_third = ~~~~~~~1/3~'" msgstr "" +">>> from fractions import Fraction\n" +">>> one_third = Fraction(1, 3)\n" +">>> f'{one_third:.6f}'\n" +"'0.333333'\n" +">>> f'{one_third:_^+10}'\n" +"'___+1/3___'\n" +">>> f'{one_third!r:_^20}'\n" +"'___Fraction(1, 3)___'\n" +">>> f'{one_third = :~>10}~'\n" +"'one_third = ~~~~~~~1/3~'" -#: ../../builtins/stdtypes.rst:3331 msgid "Template String Literals (t-strings)" -msgstr "" +msgstr "テンプレート文字列リテラル (t-string)" -#: ../../builtins/stdtypes.rst:3333 msgid "" "A :dfn:`t-string` (formally a :dfn:`template string literal`) is a string " "literal that is prefixed with ``t`` or ``T``." msgstr "" +"接頭辞 ``t`` または ``T`` を付けた文字列リテラルを :dfn:`t-string` (正式に" +"は :dfn:`テンプレート文字列リテラル`) と呼びます。" -#: ../../builtins/stdtypes.rst:3336 msgid "" "These strings follow the same syntax and evaluation rules as :ref:`formatted " "string literals `, with the following differences:" msgstr "" +"これらの文字列は、次の点を除いて :ref:`フォーマット済み文字列リテラル " +"` と同じ構文と評価規則に従います:" -#: ../../builtins/stdtypes.rst:3340 msgid "" "Rather than evaluating to a ``str`` object, template string literals " "evaluate to a :class:`string.templatelib.Template` object." msgstr "" +"テンプレート文字列リテラルを評価すると、``str`` オブジェクトの代わりに :" +"class:`string.templatelib.Template` オブジェクトが得られます。" -#: ../../builtins/stdtypes.rst:3343 msgid "" "The :func:`format` protocol is not used. Instead, the format specifier and " "conversions (if any) are passed to a new :class:`~string.templatelib." @@ -5277,8 +5854,13 @@ msgid "" "up to code that processes the resulting :class:`~string.templatelib." "Template` object to decide how to handle format specifiers and conversions." msgstr "" +":func:`format` プロトコルは使われません。\n" +"代わりに、評価した式ごとに新しい :class:`~string.templatelib.Interpolation` " +"オブジェクトが作成され、書式指定子や変換の指定があれば、そのオブジェクトに渡" +"されます。\n" +"書式指定子と変換をどのように扱うかは、結果の :class:`~string.templatelib." +"Template` オブジェクトを処理するコードが決めます。" -#: ../../builtins/stdtypes.rst:3350 msgid "" "Format specifiers containing nested replacement fields are evaluated " "eagerly, prior to being passed to the :class:`~string.templatelib." @@ -5287,8 +5869,12 @@ msgid "" "determine the value of the ``format_spec`` attribute. If ``precision`` were " "to be ``2``, the resulting format specifier would be ``'.2f'``." msgstr "" +"入れ子になった置換フィールドを含む書式指定子は、:class:`~string.templatelib." +"Interpolation` オブジェクトに渡される前に即座に評価されます。\n" +"例えば、``{amount:.{precision}f}`` 形式の補間では、内部の式 ``{precision}`` " +"を評価して ``format_spec`` 属性の値を決めます。\n" +"``precision`` が ``2`` なら、結果の書式指定子は ``'.2f'`` になります。" -#: ../../builtins/stdtypes.rst:3358 msgid "" "When the equals sign ``'='`` is provided in an interpolation expression, the " "text of the expression is appended to the literal string that precedes the " @@ -5299,25 +5885,38 @@ msgid "" "conversion or format specifier is provided, this will override the default " "behaviour." msgstr "" +"補間式に等号 ``'='`` を指定すると、その式のテキストが、対応する補間の直前のリ" +"テラル文字列に追加されます。\n" +"これには等号とその周囲の空白も含まれます。\n" +"その式に対する :class:`!Interpolation` インスタンスは通常どおり作成されます" +"が、:attr:`~string.templatelib.Interpolation.conversion` はデフォルトで " +"'``r``' (:func:`repr`) に設定されます。\n" +"変換や書式指定子を明示的に指定した場合は、このデフォルトの動作が上書きされま" +"す。" #: ../../builtins/stdtypes.rst:3372 msgid "``printf``-style String Formatting" msgstr "``printf`` 形式の文字列書式化" -#: ../../builtins/stdtypes.rst:3385 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " "dictionaries correctly)." msgstr "" +"ここで説明する書式化演算にはさまざまな癖があり、タプルや辞書を正しく表示でき" +"ないなど、よくある誤りの原因となります。" -#: ../../builtins/stdtypes.rst:3389 msgid "" "Using :ref:`formatted string literals `, the :meth:`str.format` " "interface, or :class:`string.Template` may help avoid these errors. Each of " "these alternatives provides their own trade-offs and benefits of simplicity, " "flexibility, and/or extensibility." msgstr "" +"これらの誤りは、:ref:`フォーマット済み文字列リテラル `、:meth:" +"`str.format` インターフェース、:class:`string.Template` を使うことで避けられ" +"る場合があります。\n" +"それぞれの方法には、簡潔さ、柔軟さ、拡張性の点で利点やトレードオフがありま" +"す。" #: ../../builtins/stdtypes.rst:3394 msgid "" @@ -5334,11 +5933,12 @@ msgstr "" "の ``%`` による変換の指定は0こ以上の *values* の要素で置き換えられます。この" "動作は C 言語における :c:func:`sprintf` 関数の利用方法に似ています。使用例:" -#: ../../builtins/stdtypes.rst:3401 msgid "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." msgstr "" +">>> print('%s has %d quote types.' % ('Python', 2))\n" +"Python has 2 quote types." #: ../../builtins/stdtypes.rst:3406 msgid "" @@ -5400,9 +6000,8 @@ msgstr "" "``'*'`` (アスタリスク) を指定した場合、精度の桁数は *values* タプルの次の要素" "から読み出されます。タプルには精度指定の後に変換したい値がくるようにします。" -#: ../../builtins/stdtypes.rst:3436 ../../builtins/stdtypes.rst:4738 msgid "Length modifier (optional)." -msgstr "精度長変換子 (オプション)。" +msgstr "長さ修飾子 (省略可能)。" #: ../../builtins/stdtypes.rst:3438 ../../builtins/stdtypes.rst:4740 msgid "Conversion type." @@ -5469,13 +6068,12 @@ msgstr "" msgid "``' '``" msgstr "``' '``" -#: ../../builtins/stdtypes.rst:3471 ../../builtins/stdtypes.rst:4773 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -"(スペース) 符号付きの変換で正の数の場合、前に一つスペースを空けます (そうでな" -"い場合は空文字になります) 。" +"(スペース) 符号付き変換で生成された正の数 (または空文字列) の前に、空白を一つ" +"置きます。" #: ../../builtins/stdtypes.rst:3474 ../../builtins/stdtypes.rst:4776 msgid "``'+'``" @@ -5489,13 +6087,13 @@ msgstr "" "変換の先頭に符号文字 (``'+'`` または ``'-'``) を付けます(\"スペース\" フラグ" "を上書きします) 。" -#: ../../builtins/stdtypes.rst:3478 ../../builtins/stdtypes.rst:4780 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -"精度長変換子(``h``, ``l``,または ``L``) を使うことができますが、 Python では" -"必要ないため無視されます。 -- つまり、例えば ``%ld`` は ``%d`` と等価です。" +"長さ修飾子 (``h``、``l``、``L``) を指定しても構いませんが、Python では必要な" +"いため無視されます。\n" +"例えば、``%ld`` は ``%d`` と同じです。" #: ../../builtins/stdtypes.rst:3481 ../../builtins/stdtypes.rst:4783 msgid "The conversion types are:" @@ -5583,25 +6181,25 @@ msgstr "``'F'``" msgid "``'g'``" msgstr "``'g'``" -#: ../../builtins/stdtypes.rst:3506 ../../builtins/stdtypes.rst:4808 msgid "" "Floating-point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -"浮動小数点数。指数部が -4 以上または精度以下の場合には小文字指数表記、それ以" -"外の場合には10進表記。" +"浮動小数点数の書式。\n" +"指数が -4 未満または指定精度以上の場合は小文字の指数表記を使い、それ以外は10" +"進表記を使います。" #: ../../builtins/stdtypes.rst:3510 ../../builtins/stdtypes.rst:4812 msgid "``'G'``" msgstr "``'G'``" -#: ../../builtins/stdtypes.rst:3510 ../../builtins/stdtypes.rst:4812 msgid "" "Floating-point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -"浮動小数点数。指数部が -4 以上または精度以下の場合には大文字指数表記、それ以" -"外の場合には10進表記。" +"浮動小数点数の書式。\n" +"指数が -4 未満または指定精度以上の場合は大文字の指数表記を使い、それ以外は10" +"進表記を使います。" #: ../../builtins/stdtypes.rst:3514 ../../builtins/stdtypes.rst:4816 msgid "``'c'``" @@ -5850,16 +6448,15 @@ msgstr "既存のバイナリデータからバッファプロトコルでコピ msgid "Also see the :ref:`bytes ` built-in." msgstr ":ref:`bytes ` ビルトイン関数も参照してください。" -#: ../../builtins/stdtypes.rst:3645 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " "Accordingly, the bytes type has an additional class method to read data in " "that format:" msgstr "" -"16 進数で 2 桁の数は正確に 1 バイトに相当するため、16 進整はバイナリデータを" -"表現する形式として広く使われています。 従って、 bytes 型にはその形式でデータ" -"を読み取るための追加のクラスメソッドがあります。" +"16進数字2桁がちょうど1バイトに対応するため、16進数はバイナリデータを表す形式" +"としてよく使われます。\n" +"そのため、bytes 型にはその形式のデータを読み取るクラスメソッドもあります:" #: ../../builtins/stdtypes.rst:3651 msgid "" @@ -5879,11 +6476,12 @@ msgstr "" ":meth:`bytes.fromhex` は文字列にある空白だけでなく、 ASCII の空白文字全てをス" "キップするようになりました。" -#: ../../builtins/stdtypes.rst:3662 msgid "" ":meth:`bytes.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-like " "objects ` as input." msgstr "" +":meth:`bytes.fromhex` が入力として ASCII の :class:`bytes` および :term:" +"`bytes-like オブジェクト ` を受け付けるようになりました。" #: ../../builtins/stdtypes.rst:3666 msgid "" @@ -5893,13 +6491,11 @@ msgstr "" "bytes オブジェクトをその 16 進表記に変換するための、反対向きの変換関数があり" "ます。" -#: ../../builtins/stdtypes.rst:3672 ../../builtins/stdtypes.rst:3763 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the instance." msgstr "" -"インスタンス内の 1 バイトにつき 2 つの 16 進数を含む、文字列オブジェクトを返" -"します。" +"インスタンス内の各バイトを2桁の16進数字で表した文字列オブジェクトを返します。" #: ../../builtins/stdtypes.rst:3678 msgid "" @@ -5998,23 +6594,25 @@ msgstr "" msgid "Also see the :ref:`bytearray ` built-in." msgstr ":ref:`bytearray ` ビルトイン関数も参照してください。" -#: ../../builtins/stdtypes.rst:3736 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " "Accordingly, the bytearray type has an additional class method to read data " "in that format:" msgstr "" -"16 進数で 2 桁の数は正確に 1 バイトに相当するため、16 進整はバイナリデータを" -"表現する形式として広く使われています。 従って、 bytearray 型にはその形式で" -"データを読み取るための追加のクラスメソッドがあります。" +"16進数字2桁がちょうど1バイトに対応するため、16進数はバイナリデータを表す形式" +"としてよく使われます。\n" +"そのため、bytearray 型にはその形式のデータを読み取るクラスメソッドもあります:" -#: ../../builtins/stdtypes.rst:3742 msgid "" "This :class:`bytearray` class method returns a bytearray object, decoding " "the given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" +"この :class:`bytearray` クラスメソッドは、指定された文字列オブジェクトをデ" +"コードした bytearray オブジェクトを返します。\n" +"文字列には1バイトにつき2桁の16進数字を含める必要があり、ASCII 空白文字は無視" +"されます。" #: ../../builtins/stdtypes.rst:3749 msgid "" @@ -6024,11 +6622,12 @@ msgstr "" ":meth:`bytearray.fromhex` は文字列にある空白だけでなく、 ASCII の空白文字全て" "をスキップするようになりました。" -#: ../../builtins/stdtypes.rst:3753 msgid "" ":meth:`bytearray.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-" "like objects ` as input." msgstr "" +":meth:`bytearray.fromhex` が入力として ASCII の :class:`bytes` および :term:" +"`bytes-like オブジェクト ` を受け付けるようになりました。" #: ../../builtins/stdtypes.rst:3757 msgid "" @@ -6048,16 +6647,18 @@ msgstr "" "分割するセパレータを挿入するためのオプションパラメータ *sep* と " "*bytes_per_sep* をサポートするようになりました。" -#: ../../builtins/stdtypes.rst:3778 msgid "" "Resize the :class:`bytearray` to contain *size* bytes. *size* must be " "greater than or equal to 0." msgstr "" +":class:`bytearray` のサイズを ``size`` バイトに変更します。\n" +"``size`` は0以上でなければなりません。" -#: ../../builtins/stdtypes.rst:3781 msgid "" "If the :class:`bytearray` needs to shrink, bytes beyond *size* are truncated." msgstr "" +":class:`bytearray` を縮小する場合は、``size`` を超える部分のバイトを切り捨て" +"ます。" #: ../../builtins/stdtypes.rst:3783 msgid "" @@ -6065,45 +6666,54 @@ msgid "" "will be set to null bytes." msgstr "" -#: ../../builtins/stdtypes.rst:3787 msgid "This is equivalent to:" -msgstr "" +msgstr "これは次と等価です:" #: ../../builtins/stdtypes.rst:3795 msgid "Examples:" msgstr "例:" -#: ../../builtins/stdtypes.rst:3810 msgid "" "Remove the first *n* bytes from the bytearray and return them as an " "immutable :class:`bytes`. By default (if *n* is ``None``), return all bytes " "and clear the bytearray." msgstr "" +"bytearray の先頭から ``n`` バイトを削除し、イミュータブルな :class:`bytes` と" +"して返します。\n" +"デフォルトでは (``n`` が ``None`` の場合)、すべてのバイトを返し、bytearray を" +"空にします。" -#: ../../builtins/stdtypes.rst:3814 msgid "" "If *n* is negative, index from the end and take the first :func:`len` plus " "*n* bytes. If *n* is out of bounds, raise :exc:`IndexError`." msgstr "" +"``n`` が負の場合は末尾から数え、先頭から :func:`len` と ``n`` の和のバイト数" +"を取り出します。\n" +"``n`` が範囲外の場合は :exc:`IndexError` を送出します。" -#: ../../builtins/stdtypes.rst:3817 msgid "" "Taking less than the full length will leave remaining bytes in the :class:" "`bytearray`, which requires a copy. If the remaining bytes should be " "discarded, use :func:`~bytearray.resize` or :keyword:`del` to truncate then :" "func:`~bytearray.take_bytes` without a size." msgstr "" +"全体の長さより少ないバイト数を取り出す場合は、:class:`bytearray` にバイトが残" +"るため、コピーが必要です。\n" +"残りのバイトを破棄する場合は、:func:`~bytearray.resize` または :keyword:" +"`del` で切り詰めてから、サイズを指定せず :func:`~bytearray.take_bytes` を使っ" +"てください。" -#: ../../builtins/stdtypes.rst:3824 msgid "Taking all bytes is a zero-copy operation." -msgstr "" +msgstr "すべてのバイトを取り出す操作ではコピーが行われません。" -#: ../../builtins/stdtypes.rst:3828 msgid "" "See the :ref:`What's New ` entry for " "common code patterns which can be optimized with :meth:`bytearray." "take_bytes`." msgstr "" +":meth:`bytearray.take_bytes` によって最適化できる一般的なコードパターンについ" +"ては、:ref:`新機能の紹介 ` を参照してくださ" +"い。" #: ../../builtins/stdtypes.rst:3832 msgid "" @@ -6129,17 +6739,17 @@ msgstr "" "ためです。\n" "bytearray オブジェクトはいつでも ``list(b)`` で整数のリストに変換できます。" -#: ../../builtins/stdtypes.rst:3844 msgid "" "For detailed information on thread-safety guarantees for :class:`bytearray` " "objects, see :ref:`thread-safety-bytearray`." msgstr "" +":class:`bytearray` オブジェクトのスレッドセーフ性の保証については、:ref:" +"`thread-safety-bytearray` を参照してください。" #: ../../builtins/stdtypes.rst:3851 msgid "Bytes and Bytearray Operations" msgstr "bytes と bytearray の操作" -#: ../../builtins/stdtypes.rst:3856 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -6147,11 +6757,13 @@ msgid "" "can be freely mixed in operations without causing errors. However, the " "return type of the result may depend on the order of operands." msgstr "" -"bytes と bytearray は両方共 :ref:`一般のシーケンス操作 ` を" -"サポートしています。また、両方とも :term:`bytes-like object` をサポートしてい" -"る任意のオブジェクトを対象に操作することもできます。この柔軟性により bytes " -"と bytearray を自由に混ぜてもエラーを起こすことなく扱うことができます。ただ" -"し、操作の結果のオブジェクトはその操作の順序に依存することになります。" +"bytes オブジェクトと bytearray オブジェクトは、どちらも :ref:`共通のシーケン" +"ス演算 ` をサポートします。\n" +"同じ型のオペランドだけでなく、任意の :term:`bytes-like object` とも相互に演算" +"できます。\n" +"この柔軟性により、これらの型を演算で自由に混在させてもエラーにはなりませ" +"ん。\n" +"ただし、結果の型はオペランドの順序によって異なる場合があります。" #: ../../builtins/stdtypes.rst:3864 msgid "" @@ -6163,31 +6775,32 @@ msgstr "" "と bytearray オブジェクトのメソッドは引数として文字列を受け付けません。例え" "ば、以下のように書かなければなりません::" -#: ../../builtins/stdtypes.rst:3868 msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" msgstr "" +"a = \"abc\"\n" +"b = a.replace(\"a\", \"f\")" #: ../../builtins/stdtypes.rst:3871 msgid "and::" msgstr "および::" -#: ../../builtins/stdtypes.rst:3873 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" msgstr "" +"a = b\"abc\"\n" +"b = a.replace(b\"a\", b\"f\")" -#: ../../builtins/stdtypes.rst:3876 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -"いくつかの bytes と bytearray の操作は ASCII と互換性のあるバイナリフォーマッ" -"トが使われていると仮定していますので、フォーマットの不明なバイナリデータに対" -"して使うことは避けるべきです。こうした制約については以下で説明します。" +"bytes と bytearray の一部の操作は、ASCII 互換のバイナリ形式を前提としているた" +"め、任意のバイナリデータを扱う際には避けるべきです。\n" +"これらの制約については後述します。" #: ../../builtins/stdtypes.rst:3881 msgid "" @@ -6249,13 +6862,16 @@ msgstr "" "バリナリーデータが文字列 *prefix* で始まる場合、 ``bytes[len(prefix):]`` を" "返します。それ以外の場合、元のバイナリーデータのコピーを返します::" -#: ../../builtins/stdtypes.rst:3911 msgid "" ">>> b'TestHook'.removeprefix(b'Test')\n" "b'Hook'\n" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" msgstr "" +">>> b'TestHook'.removeprefix(b'Test')\n" +"b'Hook'\n" +">>> b'BaseTestCase'.removeprefix(b'Test')\n" +"b'BaseTestCase'" #: ../../builtins/stdtypes.rst:3916 msgid "The *prefix* may be any :term:`bytes-like object`." @@ -6287,13 +6903,16 @@ msgstr "" "``bytes[:-len(suffix)]`` を返します。それ以外の場合、元のバイナリーデータのコ" "ピーを返します::" -#: ../../builtins/stdtypes.rst:3933 msgid "" ">>> b'MiscTests'.removesuffix(b'Tests')\n" "b'Misc'\n" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" msgstr "" +">>> b'MiscTests'.removesuffix(b'Tests')\n" +"b'Misc'\n" +">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" +"b'TmpDirMixin'" #: ../../builtins/stdtypes.rst:3938 msgid "The *suffix* may be any :term:`bytes-like object`." @@ -6375,11 +6994,12 @@ msgstr "" "す。 *sub* が部分文字列 (訳注: おそらく原文の誤り、正しくは部分シーケンス) で" "あるかどうかのみを調べるには、 :keyword:`in` 演算子を使ってください::" -#: ../../builtins/stdtypes.rst:4008 msgid "" ">>> b'Py' in b'Python'\n" "True" msgstr "" +">>> b'Py' in b'Python'\n" +"True" #: ../../builtins/stdtypes.rst:4018 msgid "" @@ -6404,17 +7024,17 @@ msgstr "" "が送出されます。なお要素間のセパレータは、このメソッドを提供する bytes また" "は bytearray オブジェクトとなります。" -#: ../../builtins/stdtypes.rst:4042 msgid "" "This static method returns a translation table usable for :meth:`bytes." "translate` that will map each character in *from* into the character at the " "same position in *to*; *from* and *to* must both be :term:`bytes-like " "objects ` and have the same length." msgstr "" -"この静的メソッドは、 :func:`bytes.translate` に渡すのに適した変換テーブルを返" -"します。このテーブルは、 *from* 中の各バイトを *to* の同じ位置にあるバイトに" -"マッピングします。 *from* と *to* は両方とも同じ長さの :term:`bytes-like " -"objects ` でなければなりません。" +"この静的メソッドは、:meth:`bytes.translate` に使える変換テーブルを返しま" +"す。\n" +"このテーブルは ``from`` の各文字を ``to`` の同じ位置の文字にマップします。\n" +"``from`` と ``to`` は両方とも :term:`bytes-like オブジェクト ` で、同じ長さでなければなりません。" #: ../../builtins/stdtypes.rst:4053 msgid "" @@ -6435,13 +7055,18 @@ msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" "検索する区切りとしては、任意の :term:`bytes-like object` を指定できます。" -#: ../../builtins/stdtypes.rst:4066 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " "replaced by *new*. If *count* is given, only the first *count* occurrences " "are replaced. If *count* is not specified or ``-1``, then all occurrences " "are replaced." msgstr "" +"部分シーケンス ``old`` のすべての出現箇所を ``new`` に置き換えたシーケンスの" +"コピーを返します。\n" +"``count`` を指定した場合は、先頭から ``count`` 個の出現箇所だけを置き換えま" +"す。\n" +"``count`` を指定しない場合や ``-1`` を指定した場合は、すべての出現箇所を置き" +"換えます。" #: ../../builtins/stdtypes.rst:4071 msgid "" @@ -6526,11 +7151,12 @@ msgid "" msgstr "" "文字を削除するだけの変換には、 *table* 引数を ``None`` に設定してください::" -#: ../../builtins/stdtypes.rst:4149 msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" msgstr "" +">>> b'read this short text'.translate(None, b'aeiou')\n" +"b'rd ths shrt txt'" #: ../../builtins/stdtypes.rst:4152 msgid "*delete* is now supported as a keyword argument." @@ -6574,7 +7200,6 @@ msgstr "" "class:`bytes` オブジェクトの場合、 *width* が ``len(s)`` 以下なら元のシーケン" "スが返されます。" -#: ../../builtins/stdtypes.rst:4193 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -6582,14 +7207,23 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a prefix; rather, all combinations of its values are stripped::" msgstr "" +"先頭から指定されたバイトを除去したシーケンスのコピーを返します。\n" +"``bytes`` 引数は、除去するバイト値の集合を指定するバイナリシーケンスです。\n" +"``bytes`` 引数を省略した場合や ``None`` を指定した場合は、デフォルトで :meth:" +"`ASCII 空白文字 ` を除去します。\n" +"``bytes`` 引数を接頭辞として扱うのではなく、その値を構成するバイトを組み合わ" +"せに関係なく除去します。 ::" -#: ../../builtins/stdtypes.rst:4200 msgid "" ">>> b' spacious '.lstrip()\n" "b'spacious '\n" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" msgstr "" +">>> b' spacious '.lstrip()\n" +"b'spacious '\n" +">>> b'www.example.com'.lstrip(b'cmowz.')\n" +"b'example.com'" #: ../../builtins/stdtypes.rst:4205 msgid "" @@ -6602,13 +7236,16 @@ msgstr "" "した文字列そのものを接頭辞として削除するメソッドについては、 :meth:`~bytes." "removeprefix` を参照してください。使用例::" -#: ../../builtins/stdtypes.rst:4210 msgid "" ">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" "b'ee!'\n" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" msgstr "" +">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" +"b'ee!'\n" +">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" +"b'three!'" #: ../../builtins/stdtypes.rst:4224 msgid "" @@ -6622,7 +7259,6 @@ msgstr "" "class:`bytes` オブジェクトの場合、 *width* が ``len(s)`` 以下なら元のシーケン" "スが返されます。" -#: ../../builtins/stdtypes.rst:4238 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -6631,8 +7267,14 @@ msgid "" "a separator. Except for splitting from the right, :meth:`rsplit` behaves " "like :meth:`split` which is described in detail below." msgstr "" +"区切り文字列として ``sep`` を使い、バイナリシーケンスを同じ型の部分シーケンス" +"に分割します。\n" +"``maxsplit`` を指定した場合は、*右端から* 最大 ``maxsplit`` 回分割します。\n" +"``sep`` を指定しない場合や ``None`` を指定した場合は、:meth:`ASCII 空白文字 " +"` のみで構成される任意の部分シーケンスを区切りとします。\n" +"右から分割する点を除いて、:meth:`rsplit` は後で詳しく説明する :meth:`split` " +"と同様に動作します。" -#: ../../builtins/stdtypes.rst:4250 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -6640,14 +7282,23 @@ msgid "" "removing :meth:`ASCII whitespace `. The *bytes* argument is " "not a suffix; rather, all combinations of its values are stripped::" msgstr "" +"末尾から指定されたバイトを除去したシーケンスのコピーを返します。\n" +"``bytes`` 引数は、除去するバイト値の集合を指定するバイナリシーケンスです。\n" +"``bytes`` 引数を省略した場合や ``None`` を指定した場合は、デフォルトで :meth:" +"`ASCII 空白文字 ` を除去します。\n" +"``bytes`` 引数を接尾辞として扱うのではなく、その値を構成するバイトを組み合わ" +"せに関係なく除去します。 ::" -#: ../../builtins/stdtypes.rst:4257 msgid "" ">>> b' spacious '.rstrip()\n" "b' spacious'\n" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" msgstr "" +">>> b' spacious '.rstrip()\n" +"b' spacious'\n" +">>> b'mississippi'.rstrip(b'ipz')\n" +"b'mississ'" #: ../../builtins/stdtypes.rst:4262 msgid "" @@ -6660,13 +7311,16 @@ msgstr "" "した文字列そのものを接尾辞として削除するメソッドについては、 :meth:`~bytes." "removesuffix` を参照してください。使用例::" -#: ../../builtins/stdtypes.rst:4267 msgid "" ">>> b'Monty Python'.rstrip(b' Python')\n" "b'M'\n" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" msgstr "" +">>> b'Monty Python'.rstrip(b' Python')\n" +"b'M'\n" +">>> b'Monty Python'.removesuffix(b' Python')\n" +"b'Monty'" #: ../../builtins/stdtypes.rst:4281 msgid "" @@ -6682,7 +7336,6 @@ msgstr "" "す)。 *maxsplit* が指定されていないか ``-1`` のとき、分割の回数に制限はありま" "せん (可能なだけ分割されます)。" -#: ../../builtins/stdtypes.rst:4287 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -6692,14 +7345,14 @@ msgid "" "the type of object being split. The *sep* argument may be any :term:`bytes-" "like object`." msgstr "" -"*sep* が与えられた場合、連続した区切り用バイト値はまとめられず、空の部分シー" -"ケンスを区切っていると判断されます(例えば ``b'1,,2'.split(b',')`` は " -"``[b'1', b'', b'2']`` を返します)。引数 *sep* は複数バイトのシーケンスを1つの" -"区切り文字にもできます。空のシーケンスを分割すると、分割するオブジェクトの型" -"によって ``[b'']`` または ``[bytearray(b'')]`` が返ります。引数 *sep* には、" -"あらゆる :term:`bytes-like object` を指定できます。" +"*sep* を指定した場合、連続する区切りは一つにまとめられず、空の部分シーケンス" +"を区切るものとみなされます (例えば ``b'1,,2'.split(b',')`` は ``[b'1', b'', " +"b'2']`` を返します)。\n" +"*sep* には、複数バイトのシーケンスを一つの区切りとして指定できます。\n" +"区切りを指定して空のシーケンスを分割すると、分割するオブジェクトの型に応じて " +"``[b'']`` または ``[bytearray(b'')]`` が返されます。\n" +"*sep* には、任意の :term:`bytes-like object` を指定できます。" -#: ../../builtins/stdtypes.rst:4297 msgid "" ">>> b'1,2,3'.split(b',')\n" "[b'1', b'2', b'3']\n" @@ -6710,8 +7363,15 @@ msgid "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" msgstr "" +">>> b'1,2,3'.split(b',')\n" +"[b'1', b'2', b'3']\n" +">>> b'1,2,3'.split(b',', maxsplit=1)\n" +"[b'1', b'2,3']\n" +">>> b'1,2,,3,'.split(b',')\n" +"[b'1', b'2', b'', b'3', b'']\n" +">>> b'1<>2<>3<4'.split(b'<>')\n" +"[b'1', b'2', b'3<4']" -#: ../../builtins/stdtypes.rst:4306 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive :meth:`ASCII whitespace ` are " @@ -6720,8 +7380,15 @@ msgid "" "Consequently, splitting an empty sequence or a sequence consisting solely of " "ASCII whitespace without a specified separator returns ``[]``." msgstr "" +"``sep`` を指定しない場合や ``None`` を指定した場合は、別の分割アルゴリズムを" +"適用します。\n" +"連続する :meth:`ASCII 空白文字 ` のまとまりを一つの区切りとみ" +"なします。\n" +"シーケンスの先頭や末尾に空白文字があっても、結果の先頭や末尾に空文字列は含ま" +"れません。\n" +"そのため、区切りを指定せずに空のシーケンスや ASCII 空白文字のみのシーケンスを" +"分割すると、``[]`` が返されます。" -#: ../../builtins/stdtypes.rst:4317 msgid "" ">>> b'1 2 3'.split()\n" "[b'1', b'2', b'3']\n" @@ -6730,8 +7397,13 @@ msgid "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" msgstr "" +">>> b'1 2 3'.split()\n" +"[b'1', b'2', b'3']\n" +">>> b'1 2 3'.split(maxsplit=1)\n" +"[b'1', b'2 3']\n" +">>> b' 1 2 3 '.split()\n" +"[b'1', b'2', b'3']" -#: ../../builtins/stdtypes.rst:4328 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *bytes* argument is a binary sequence specifying the set of " @@ -6740,14 +7412,23 @@ msgid "" "argument is not a prefix or suffix; rather, all combinations of its values " "are stripped::" msgstr "" +"先頭と末尾から指定されたバイトを除去したシーケンスのコピーを返します。\n" +"``bytes`` 引数は、除去するバイト値の集合を指定するバイナリシーケンスです。\n" +"``bytes`` 引数を省略した場合や ``None`` を指定した場合は、デフォルトで :meth:" +"`ASCII 空白文字 ` を除去します。\n" +"``bytes`` 引数を接頭辞や接尾辞として扱うのではなく、その値を構成するバイトを" +"組み合わせに関係なく除去します。 ::" -#: ../../builtins/stdtypes.rst:4336 msgid "" ">>> b' spacious '.strip()\n" "b'spacious'\n" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" msgstr "" +">>> b' spacious '.strip()\n" +"b'spacious'\n" +">>> b'www.example.com'.strip(b'cmowz.')\n" +"b'example'" #: ../../builtins/stdtypes.rst:4341 msgid "" @@ -6807,13 +7488,16 @@ msgstr "" "ト値の表示のされ方(訳注: 全角、半角など)に関わらず現桁位置を 1 つ増加させま" "す::" -#: ../../builtins/stdtypes.rst:4385 msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" "b'01 012 0123 01234'\n" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" msgstr "" +">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" +"b'01 012 0123 01234'\n" +">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" +"b'01 012 0123 01234'" #: ../../builtins/stdtypes.rst:4399 msgid "" @@ -6829,13 +7513,16 @@ msgstr "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`` に含まれるバイト" "値です。 ASCII 文字の数字とは ``b'0123456789'`` に含まれるバイト値です。" -#: ../../builtins/stdtypes.rst:4407 msgid "" ">>> b'ABCabc1'.isalnum()\n" "True\n" ">>> b'ABC abc1'.isalnum()\n" "False" msgstr "" +">>> b'ABCabc1'.isalnum()\n" +"True\n" +">>> b'ABC abc1'.isalnum()\n" +"False" #: ../../builtins/stdtypes.rst:4416 msgid "" @@ -6850,13 +7537,16 @@ msgstr "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'`` に含まれるバイト" "値です。" -#: ../../builtins/stdtypes.rst:4423 msgid "" ">>> b'ABCabc'.isalpha()\n" "True\n" ">>> b'ABCabc1'.isalpha()\n" "False" msgstr "" +">>> b'ABCabc'.isalpha()\n" +"True\n" +">>> b'ABCabc1'.isalpha()\n" +"False" #: ../../builtins/stdtypes.rst:4432 msgid "" @@ -6877,13 +7567,16 @@ msgstr "" "``True`` を、そうでなければ ``False`` を返します。ここでの ASCII 文字の数字と" "は ``b'0123456789'`` に含まれるバイト値です。" -#: ../../builtins/stdtypes.rst:4448 msgid "" ">>> b'1234'.isdigit()\n" "True\n" ">>> b'1.23'.isdigit()\n" "False" msgstr "" +">>> b'1234'.isdigit()\n" +"True\n" +">>> b'1.23'.isdigit()\n" +"False" #: ../../builtins/stdtypes.rst:4457 msgid "" @@ -6894,13 +7587,16 @@ msgstr "" "ファベットの ASCII 文字が一つも無い場合に ``True`` を返します。そうでなけれ" "ば ``False`` を返します。" -#: ../../builtins/stdtypes.rst:4462 msgid "" ">>> b'hello world'.islower()\n" "True\n" ">>> b'Hello world'.islower()\n" "False" msgstr "" +">>> b'hello world'.islower()\n" +"True\n" +">>> b'Hello world'.islower()\n" +"False" #: ../../builtins/stdtypes.rst:4467 ../../builtins/stdtypes.rst:4509 #: ../../builtins/stdtypes.rst:4525 ../../builtins/stdtypes.rst:4575 @@ -6936,13 +7632,16 @@ msgstr "" "``True`` を、そうでなければ ``False`` を返します。「タイトルケース文字列」の" "定義については :meth:`bytes.title` を参照してください。" -#: ../../builtins/stdtypes.rst:4490 msgid "" ">>> b'Hello World'.istitle()\n" "True\n" ">>> b'Hello world'.istitle()\n" "False" msgstr "" +">>> b'Hello World'.istitle()\n" +"True\n" +">>> b'Hello world'.istitle()\n" +"False" #: ../../builtins/stdtypes.rst:4499 msgid "" @@ -6954,13 +7653,16 @@ msgstr "" "ファベットの ASCII 文字が一つも無い場合に ``True`` を返します。そうでなけれ" "ば ``False`` を返します。" -#: ../../builtins/stdtypes.rst:4504 msgid "" ">>> b'HELLO WORLD'.isupper()\n" "True\n" ">>> b'Hello world'.isupper()\n" "False" msgstr "" +">>> b'HELLO WORLD'.isupper()\n" +"True\n" +">>> b'Hello world'.isupper()\n" +"False" #: ../../builtins/stdtypes.rst:4517 msgid "" @@ -6970,11 +7672,12 @@ msgstr "" "シーケンスに含まれる大文字アルファベットの ASCII 文字を全て小文字アルファベッ" "トに変換したシーケンスのコピーを返します。" -#: ../../builtins/stdtypes.rst:4522 msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" msgstr "" +">>> b'Hello World'.lower()\n" +"b'hello world'" #: ../../builtins/stdtypes.rst:4542 msgid "" @@ -6988,54 +7691,61 @@ msgstr "" "*keepends* 引数に真を与えた場合を除き、改行コードは結果のリストに含まれませ" "ん。" -#: ../../builtins/stdtypes.rst:4549 msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "[b'ab c', b'', b'de fg', b'kl']\n" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" msgstr "" +">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" +"[b'ab c', b'', b'de fg', b'kl']\n" +">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" +"[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" -#: ../../builtins/stdtypes.rst:4554 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -":meth:`~bytes.split` とは違って、空シーケンスに対して区切り *sep* を与えて呼" -"び出すと空のリストを返します。またシーケンス末尾に改行コードがある場合、(訳" -"註: その後ろに空行があるとは判断せず)余分な行を生成することはありません::" +"区切り文字列 *sep* を指定した :meth:`~bytes.split` とは異なり、\n" +"このメソッドは空のシーケンスに対して空のリストを返し、末尾に改行があっても余" +"分な行を追加しません::" -#: ../../builtins/stdtypes.rst:4558 msgid "" ">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" "([b''], [b'Two lines', b''])\n" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" msgstr "" +">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" +"([b''], [b'Two lines', b''])\n" +">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" +"([], [b'One line'])" -#: ../../builtins/stdtypes.rst:4567 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -"シーケンスに含まれる小文字アルファベットの ASCII 文字を全て大文字アルファベッ" -"トに変換し、さらに大文字アルファベットを同様に小文字アルファベットに変換した" -"シーケンスのコピーを返します。" +"シーケンス内の小文字の ASCII 文字を対応する大文字に、大文字の ASCII 文字を対" +"応する小文字に変換したコピーを返します。" -#: ../../builtins/stdtypes.rst:4572 msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" msgstr "" +">>> b'Hello World'.swapcase()\n" +"b'hELLO wORLD'" -#: ../../builtins/stdtypes.rst:4579 msgid "" "Unlike :func:`str.swapcase`, it is always the case that ``bin.swapcase()." "swapcase() == bin`` for the binary versions. Case conversions are " "symmetrical in ASCII, even though that is not generally true for arbitrary " "Unicode code points." msgstr "" +":func:`str.swapcase` とは異なり、バイナリ版では ``bin.swapcase().swapcase() " +"== bin`` が常に成り立ちます。\n" +"任意の Unicode コードポイントについては一般に成り立ちませんが、ASCII では大文" +"字と小文字の変換が対称だからです。" #: ../../builtins/stdtypes.rst:4593 msgid "" @@ -7048,11 +7758,12 @@ msgstr "" "なっているシーケンスが返ります。大文字小文字の区別が無いバイト値については変" "更されずそのままになります。" -#: ../../builtins/stdtypes.rst:4599 msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" msgstr "" +">>> b'Hello world'.title()\n" +"b'Hello World'" #: ../../builtins/stdtypes.rst:4602 msgid "" @@ -7066,18 +7777,18 @@ msgstr "" "に含まれるバイト値です。その他のバイト値については、大文字小文字の区別はあり" "ません。" -#: ../../builtins/stdtypes.rst:4612 msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" msgstr "" +">>> b\"they're bill's friends from the UK\".title()\n" +"b\"They'Re Bill'S Friends From The Uk\"" #: ../../builtins/stdtypes.rst:4615 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "正規表現を使うことでアポストロフィに対応できます::" -#: ../../builtins/stdtypes.rst:4617 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -7089,6 +7800,15 @@ msgid "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" msgstr "" +">>> import re\n" +">>> def titlecase(s):\n" +"... return re.sub(rb\"[A-Za-z]+('[A-Za-z]+)?\",\n" +"... lambda mo: mo.group(0)[0:1].upper() +\n" +"... mo.group(0)[1:].lower(),\n" +"... s)\n" +"...\n" +">>> titlecase(b\"they're bill's friends.\")\n" +"b\"They're Bill's Friends.\"" #: ../../builtins/stdtypes.rst:4636 msgid "" @@ -7098,13 +7818,13 @@ msgstr "" "シーケンスに含まれる小文字アルファベットの ASCII 文字を全て大文字アルファベッ" "トに変換したシーケンスのコピーを返します。" -#: ../../builtins/stdtypes.rst:4641 msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" msgstr "" +">>> b'Hello World'.upper()\n" +"b'HELLO WORLD'" -#: ../../builtins/stdtypes.rst:4657 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -7112,18 +7832,23 @@ msgid "" "before. For :class:`bytes` objects, the original sequence is returned if " "*width* is less than or equal to ``len(seq)``." msgstr "" -"長さが *width* になるよう ASCII ``b'0'`` で左詰めしたシーケンスのコピーを返し" -"ます。先頭が符号接頭辞 (``b'+'``/``b'-'``) だった場合、 ``b'0'`` は符号の前で" -"はなく *後* に挿入されます。 :class:`bytes` オブジェクトの場合、 *width* が " -"``len(seq)`` 以下であれば元のシーケンスが返ります。" +"長さが ``width`` になるよう、左側を ASCII ``b'0'`` で埋めたシーケンスのコピー" +"を返します。\n" +"先頭に符号接頭辞 (``b'+'``/ ``b'-'``) がある場合は、符号文字の前ではなく *後" +"* にパディングを挿入します。\n" +":class:`bytes` オブジェクトの場合、``width`` が ``len(seq)`` 以下なら元のシー" +"ケンスを返します。" -#: ../../builtins/stdtypes.rst:4665 msgid "" ">>> b\"42\".zfill(5)\n" "b'00042'\n" ">>> b\"-42\".zfill(5)\n" "b'-0042'" msgstr "" +">>> b\"42\".zfill(5)\n" +"b'00042'\n" +">>> b\"-42\".zfill(5)\n" +"b'-0042'" #: ../../builtins/stdtypes.rst:4679 msgid "``printf``-style Bytes Formatting" @@ -7140,7 +7865,6 @@ msgstr "" "ルや辞書を正しく表示できないなど)。もし表示する値がタプルや辞書かもしれない場" "合、それをタプルに包むようにしてください。" -#: ../../builtins/stdtypes.rst:4701 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " @@ -7149,6 +7873,12 @@ msgid "" "zero or more elements of *values*. The effect is similar to using the :c:" "func:`sprintf` function in the C language." msgstr "" +"bytes オブジェクト (``bytes``/``bytearray``) に固有の組み込み演算として、" +"``%`` 演算子 (剰余) があります。\n" +"これは、bytes の *書式化* 演算子または *補間* 演算子とも呼ばれます。\n" +"``format % values`` (ここで *format* は bytes オブジェクト) では、*format* 内" +"の ``%`` 変換指定が *values* の0個以上の要素に置き換えられます。\n" +"その効果は C 言語の :c:func:`sprintf` 関数の使用に似ています。" #: ../../builtins/stdtypes.rst:4708 msgid "" @@ -7274,26 +8004,28 @@ msgstr "" "`bytearray` では、要素は単バイトになりますが、他の :class:`array.array` 等の" "型では、要素はより大きくなりえます。" -#: ../../builtins/stdtypes.rst:4903 msgid "" ":class:`!memoryview`\\s are :ref:`generic ` over the type of their " "underlying data." msgstr "" +":class:`!memoryview` は元のデータの型について :ref:`ジェネリック ` " +"です。" -#: ../../builtins/stdtypes.rst:4906 msgid "" "``len(view)`` is equal to the length of :meth:`~memoryview.tolist`, which is " "the nested list representation of the view. If ``view.ndim == 1``, this is " "equal to the number of elements in the view." msgstr "" +"``len(view)`` は、ビューを入れ子のリストで表す :meth:`~memoryview.tolist` の" +"結果の長さと等しくなります。\n" +"``view.ndim == 1`` の場合、これはビュー内の要素数と等しくなります。" -#: ../../builtins/stdtypes.rst:4910 msgid "" "If ``view.ndim == 0``, ``len(view)`` now raises :exc:`TypeError` instead of " "returning 1." msgstr "" -"``view.ndim == 0`` で ``len(view)`` の場合、1の代わりに :exc:`TypeError` を返" -"すようになりました。" +"``view.ndim == 0`` の場合、``len(view)`` は 1 を返す代わりに :exc:" +"`TypeError` を送出するようになりました。" #: ../../builtins/stdtypes.rst:4913 msgid "" @@ -7309,7 +8041,6 @@ msgstr "" ":class:`memoryview` はスライスおよびインデックス指定で内容を取得できます。一" "次元のスライスは部分ビューになります::" -#: ../../builtins/stdtypes.rst:4919 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> v[1]\n" @@ -7321,6 +8052,15 @@ msgid "" ">>> bytes(v[1:4])\n" "b'bce'" msgstr "" +">>> v = memoryview(b'abcefg')\n" +">>> v[1]\n" +"98\n" +">>> v[-1]\n" +"103\n" +">>> v[1:4]\n" +"\n" +">>> bytes(v[1:4])\n" +"b'bce'" #: ../../builtins/stdtypes.rst:4929 msgid "" @@ -7342,9 +8082,8 @@ msgstr "" #: ../../builtins/stdtypes.rst:4938 msgid "Here is an example with a non-byte format::" -msgstr ":class:`~memoryview.format` が単バイト単位ではない例を示します::" +msgstr "``format`` が単バイト単位ではない例を示します::" -#: ../../builtins/stdtypes.rst:4940 msgid "" ">>> import array\n" ">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" @@ -7356,6 +8095,15 @@ msgid "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" msgstr "" +">>> import array\n" +">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" +">>> m = memoryview(a)\n" +">>> m[0]\n" +"-11111111\n" +">>> m[-1]\n" +"44444444\n" +">>> m[::2].tolist()\n" +"[-11111111, -33333333]" #: ../../builtins/stdtypes.rst:4950 msgid "" @@ -7365,7 +8113,6 @@ msgstr "" "メモリビューの参照しているオブジェクトが書き込み可能であれば、一次元スライス" "での代入が可能です。ただしサイズの変更はできません::" -#: ../../builtins/stdtypes.rst:4953 msgid "" ">>> data = bytearray(b'abcefg')\n" ">>> v = memoryview(data)\n" @@ -7386,6 +8133,24 @@ msgid "" ">>> data\n" "bytearray(b'z1spam')" msgstr "" +">>> data = bytearray(b'abcefg')\n" +">>> v = memoryview(data)\n" +">>> v.readonly\n" +"False\n" +">>> v[0] = ord(b'z')\n" +">>> data\n" +"bytearray(b'zbcefg')\n" +">>> v[1:4] = b'123'\n" +">>> data\n" +"bytearray(b'z123fg')\n" +">>> v[2:3] = b'spam'\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: memoryview assignment: lvalue and rvalue have different " +"structures\n" +">>> v[2:6] = b'spam'\n" +">>> data\n" +"bytearray(b'z1spam')" #: ../../builtins/stdtypes.rst:4971 msgid "" @@ -7397,7 +8162,6 @@ msgstr "" "み出し専用の) 型の1次元メモリビューもまた、ハッシュ可能です。ハッシュは " "``hash(m) == hash(m.tobytes())`` として定義されています::" -#: ../../builtins/stdtypes.rst:4975 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> hash(v) == hash(b'abcefg')\n" @@ -7407,6 +8171,13 @@ msgid "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" msgstr "" +">>> v = memoryview(b'abcefg')\n" +">>> hash(v) == hash(b'abcefg')\n" +"True\n" +">>> hash(v[2:4]) == hash(b'ce')\n" +"True\n" +">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" +"True" #: ../../builtins/stdtypes.rst:4983 msgid "" @@ -7425,13 +8196,11 @@ msgstr "" "memoryview は自動的に :class:`collections.abc.Sequence` へ登録されるようにな" "りました。" -#: ../../builtins/stdtypes.rst:4991 msgid "memoryviews can now be indexed with a tuple of integers." -msgstr "" +msgstr "整数のタプルで memoryview のインデックスを指定できるようになりました。" -#: ../../builtins/stdtypes.rst:4994 msgid "memoryview is now a :term:`generic type`." -msgstr "" +msgstr "memoryview が :term:`ジェネリック型 ` になりました。" #: ../../builtins/stdtypes.rst:4997 msgid ":class:`memoryview` has several methods:" @@ -7454,7 +8223,6 @@ msgstr "" ":meth:`tolist` がサポートしている :mod:`struct` フォーマットの一部では、 ``v." "tolist() == w.tolist()`` が成り立つときに ``v`` == ``w`` になります::" -#: ../../builtins/stdtypes.rst:5008 msgid "" ">>> import array\n" ">>> a = array.array('I', [1, 2, 3, 4, 5])\n" @@ -7472,6 +8240,21 @@ msgid "" ">>> z.tolist() == c.tolist()\n" "True" msgstr "" +">>> import array\n" +">>> a = array.array('I', [1, 2, 3, 4, 5])\n" +">>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0])\n" +">>> c = array.array('b', [5, 3, 1])\n" +">>> x = memoryview(a)\n" +">>> y = memoryview(b)\n" +">>> x == a == y == b\n" +"True\n" +">>> x.tolist() == a.tolist() == y.tolist() == b.tolist()\n" +"True\n" +">>> z = y[::-2]\n" +">>> z == c\n" +"True\n" +">>> z.tolist() == c.tolist()\n" +"True" #: ../../builtins/stdtypes.rst:5024 msgid "" @@ -7483,7 +8266,6 @@ msgstr "" "(書式文字列とバッファの内容が同一でも) オブジェクトは常に等しくないものとして" "比較されます::" -#: ../../builtins/stdtypes.rst:5028 msgid "" ">>> from ctypes import BigEndianStructure, c_long\n" ">>> class BEPoint(BigEndianStructure):\n" @@ -7497,6 +8279,17 @@ msgid "" ">>> a == b\n" "False" msgstr "" +">>> from ctypes import BigEndianStructure, c_long\n" +">>> class BEPoint(BigEndianStructure):\n" +"... _fields_ = [(\"x\", c_long), (\"y\", c_long)]\n" +"...\n" +">>> point = BEPoint(100, 200)\n" +">>> a = memoryview(point)\n" +">>> b = memoryview(point)\n" +">>> a == point\n" +"False\n" +">>> a == b\n" +"False" #: ../../builtins/stdtypes.rst:5040 msgid "" @@ -7522,7 +8315,6 @@ msgstr "" "バッファ中のデータをバイト文字列として返します。これはメモリビューに対して :" "class:`bytes` コンストラクタを呼び出すのと同等です。 ::" -#: ../../builtins/stdtypes.rst:5052 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.tobytes()\n" @@ -7530,6 +8322,11 @@ msgid "" ">>> bytes(m)\n" "b'abc'" msgstr "" +">>> m = memoryview(b\"abc\")\n" +">>> m.tobytes()\n" +"b'abc'\n" +">>> bytes(m)\n" +"b'abc'" #: ../../builtins/stdtypes.rst:5058 msgid "" @@ -7557,18 +8354,20 @@ msgstr "" "連続なデータに対するビューの場合、データはまず C のデータ並びに変換されま" "す。 *order=None* は *order='C'* と同じです。" -#: ../../builtins/stdtypes.rst:5073 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" -msgstr "バッファ中の各バイトを 2 つの 16 進数で表した文字列を返します::" +msgstr "" +"バッファ内の各バイトを2桁の16進数字で表した文字列オブジェクトを返します。 ::" -#: ../../builtins/stdtypes.rst:5076 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.hex()\n" "'616263'" msgstr "" +">>> m = memoryview(b\"abc\")\n" +">>> m.hex()\n" +"'616263'" #: ../../builtins/stdtypes.rst:5082 msgid "" @@ -7584,7 +8383,6 @@ msgstr "" msgid "Return the data in the buffer as a list of elements. ::" msgstr "バッファ中のデータを要素のリストとして返します。 ::" -#: ../../builtins/stdtypes.rst:5091 msgid "" ">>> memoryview(b'abc').tolist()\n" "[97, 98, 99]\n" @@ -7594,6 +8392,13 @@ msgid "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" msgstr "" +">>> memoryview(b'abc').tolist()\n" +"[97, 98, 99]\n" +">>> import array\n" +">>> a = array.array('d', [1.1, 2.2, 3.3])\n" +">>> m = memoryview(a)\n" +">>> m.tolist()\n" +"[1.1, 2.2, 3.3]" #: ../../builtins/stdtypes.rst:5099 msgid "" @@ -7611,7 +8416,6 @@ msgstr "" "読み込み専用のメモリビューオブジェクトを返します。元のメモリビューオブジェク" "トは変更されません。 ::" -#: ../../builtins/stdtypes.rst:5109 msgid "" ">>> m = memoryview(bytearray(b'abc'))\n" ">>> mm = m.toreadonly()\n" @@ -7625,6 +8429,17 @@ msgid "" ">>> mm.tolist()\n" "[43, 98, 99]" msgstr "" +">>> m = memoryview(bytearray(b'abc'))\n" +">>> mm = m.toreadonly()\n" +">>> mm.tolist()\n" +"[97, 98, 99]\n" +">>> mm[0] = 42\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: cannot modify read-only memory\n" +">>> m[0] = 43\n" +">>> mm.tolist()\n" +"[43, 98, 99]" #: ../../builtins/stdtypes.rst:5125 msgid "" @@ -7647,7 +8462,6 @@ msgid "" "multiple times)::" msgstr "" -#: ../../builtins/stdtypes.rst:5135 msgid "" ">>> m = memoryview(b'abc')\n" ">>> m.release()\n" @@ -7656,6 +8470,12 @@ msgid "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" msgstr "" +">>> m = memoryview(b'abc')\n" +">>> m.release()\n" +">>> m[0]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: operation forbidden on released memoryview object" #: ../../builtins/stdtypes.rst:5142 msgid "" @@ -7665,7 +8485,6 @@ msgstr "" "コンテキストマネージャプロトコルは、 ``with`` 文を使って同様の効果を得るのに" "使えます::" -#: ../../builtins/stdtypes.rst:5145 msgid "" ">>> with memoryview(b'abc') as m:\n" "... m[0]\n" @@ -7676,8 +8495,15 @@ msgid "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" msgstr "" +">>> with memoryview(b'abc') as m:\n" +"... m[0]\n" +"...\n" +"97\n" +">>> m[0]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: operation forbidden on released memoryview object" -#: ../../builtins/stdtypes.rst:5159 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -7685,30 +8511,31 @@ msgid "" "is not copied. Supported casts are 1D -> C-:term:`contiguous` and C-" "contiguous -> 1D." msgstr "" -"memoryview を新しいフォーマットか shape にキャストします。 *shape* はデフォル" -"トで ``[byte_length//new_itemsize]`` で、 1次元配列になります。戻り値は " -"memoryview ですが、バッファー自体はコピーされません。サポートされている変換" -"は 1次元配列 -> C言語型の連続配列 と C言語型の連続配列 -> 1次元配列 です(参" -"考: :term:`contiguous`)。" +"memoryview を新しいフォーマットまたは形状にキャストします。\n" +"*shape* のデフォルト値は ``[byte_length//new_itemsize]`` で、結果のビューは1" +"次元になります。\n" +"返り値は新しい memoryview ですが、バッファ自体はコピーされません。\n" +"サポートされるキャストは、1次元から C-:term:`連続 ` への変換と、" +"C-連続から1次元への変換です。" -#: ../../builtins/stdtypes.rst:5165 msgid "" "The destination format is restricted to a single element native format in :" "mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' or " "'c'). The byte length of the result must be the same as the original length. " "Note that all byte lengths may depend on the operating system." msgstr "" -"キャスト後のフォーマットは単一要素のネイティブフォーマットに限定され、 :mod:" -"`struct` の文法で指定します。利用可能なフォーマットのひとつはバイトフォーマッ" -"ト ('B', 'b' または 'c') です。キャスト後のバイト長は元の長さと同じでなけれ" -"ばなりません。全てのフォーマットのバイト長は、オペレーティングシステムに依存" -"することに注意してください。" +"変換先のフォーマットは、:mod:`struct` の構文による単一要素のネイティブフォー" +"マットに限定されます。\n" +"変換元と変換先のフォーマットの少なくとも一方は、バイトフォーマット " +"('B'、'b'、'c') でなければなりません。\n" +"結果のバイト長は元の長さと同じでなければなりません。\n" +"各フォーマットのバイト長はオペレーティングシステムによって異なる場合があるこ" +"とに注意してください。" #: ../../builtins/stdtypes.rst:5171 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "1次元 long から 1次元 unsigned byte へのキャスト::" -#: ../../builtins/stdtypes.rst:5173 msgid "" ">>> import array\n" ">>> a = array.array('l', [1,2,3])\n" @@ -7731,12 +8558,31 @@ msgid "" ">>> y.nbytes\n" "24" msgstr "" +">>> import array\n" +">>> a = array.array('l', [1,2,3])\n" +">>> x = memoryview(a)\n" +">>> x.format\n" +"'l'\n" +">>> x.itemsize\n" +"8\n" +">>> len(x)\n" +"3\n" +">>> x.nbytes\n" +"24\n" +">>> y = x.cast('B')\n" +">>> y.format\n" +"'B'\n" +">>> y.itemsize\n" +"1\n" +">>> len(y)\n" +"24\n" +">>> y.nbytes\n" +"24" #: ../../builtins/stdtypes.rst:5194 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "1次元 unsigned byte から 1次元 char へのキャスト::" -#: ../../builtins/stdtypes.rst:5196 msgid "" ">>> b = bytearray(b'zyz')\n" ">>> x = memoryview(b)\n" @@ -7749,12 +8595,21 @@ msgid "" ">>> b\n" "bytearray(b'ayz')" msgstr "" +">>> b = bytearray(b'zyz')\n" +">>> x = memoryview(b)\n" +">>> x[0] = b'a'\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: memoryview: invalid type for format 'B'\n" +">>> y = x.cast('c')\n" +">>> y[0] = b'a'\n" +">>> b\n" +"bytearray(b'ayz')" #: ../../builtins/stdtypes.rst:5207 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "1次元 byte から 3次元 int へ、そして 1次元 signed char へのキャスト::" -#: ../../builtins/stdtypes.rst:5209 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" @@ -7780,12 +8635,34 @@ msgid "" ">>> z.nbytes\n" "48" msgstr "" +">>> import struct\n" +">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('i', shape=[2,2,3])\n" +">>> y.tolist()\n" +"[[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]\n" +">>> y.format\n" +"'i'\n" +">>> y.itemsize\n" +"4\n" +">>> len(y)\n" +"2\n" +">>> y.nbytes\n" +"48\n" +">>> z = y.cast('b')\n" +">>> z.format\n" +"'b'\n" +">>> z.itemsize\n" +"1\n" +">>> len(z)\n" +"48\n" +">>> z.nbytes\n" +"48" #: ../../builtins/stdtypes.rst:5233 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "1次元 unsigned long から 2次元 unsigned long へのキャスト::" -#: ../../builtins/stdtypes.rst:5235 msgid "" ">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" ">>> x = memoryview(buf)\n" @@ -7797,6 +8674,15 @@ msgid "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" msgstr "" +">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('L', shape=[2,3])\n" +">>> len(y)\n" +"2\n" +">>> y.nbytes\n" +"48\n" +">>> y.tolist()\n" +"[[0, 1, 2], [3, 4, 5]]" #: ../../builtins/stdtypes.rst:5247 msgid "The source format is no longer restricted when casting to a byte view." @@ -7804,19 +8690,18 @@ msgstr "" "単バイトのビューへキャストする場合、キャスト元のフォーマットについて制約は無" "くなりました。" -#: ../../builtins/stdtypes.rst:5252 msgid "Count the number of occurrences of *value*." -msgstr "" +msgstr "``value`` の出現回数を数えます。" -#: ../../builtins/stdtypes.rst:5258 msgid "" "Return the index of the first occurrence of *value* (at or after index " "*start* and before index *stop*)." msgstr "" +"``value`` が最初に出現する位置のインデックスを返します (インデックス " +"``start`` 以上、``stop`` 未満の範囲で検索します)。" -#: ../../builtins/stdtypes.rst:5261 msgid "Raises a :exc:`ValueError` if *value* cannot be found." -msgstr "" +msgstr "``value`` が見つからない場合は :exc:`ValueError` を送出します。" #: ../../builtins/stdtypes.rst:5265 msgid "There are also several readonly attributes available:" @@ -7826,24 +8711,26 @@ msgstr "読み出し専用の属性もいくつか使えます:" msgid "The underlying object of the memoryview::" msgstr "memoryview が参照しているオブジェクト::" -#: ../../builtins/stdtypes.rst:5271 msgid "" ">>> b = bytearray(b'xyz')\n" ">>> m = memoryview(b)\n" ">>> m.obj is b\n" "True" msgstr "" +">>> b = bytearray(b'xyz')\n" +">>> m = memoryview(b)\n" +">>> m.obj is b\n" +"True" -#: ../../builtins/stdtypes.rst:5280 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -"``nbytes == product(shape) * itemsize == len(m.tobytes())``. その配列が連続表" -"現において利用するスペースです。これは ``len(m)`` と一致するとは限りません::" +"``nbytes == product(shape) * itemsize == len(m.tobytes())`` です。\n" +"これは、配列を連続した表現にした場合に使う領域のバイト数です。\n" +"``len(m)`` と等しいとは限りません。 ::" -#: ../../builtins/stdtypes.rst:5284 msgid "" ">>> import array\n" ">>> a = array.array('i', [1,2,3,4,5])\n" @@ -7860,12 +8747,25 @@ msgid "" ">>> len(y.tobytes())\n" "12" msgstr "" +">>> import array\n" +">>> a = array.array('i', [1,2,3,4,5])\n" +">>> m = memoryview(a)\n" +">>> len(m)\n" +"5\n" +">>> m.nbytes\n" +"20\n" +">>> y = m[::2]\n" +">>> len(y)\n" +"3\n" +">>> y.nbytes\n" +"12\n" +">>> len(y.tobytes())\n" +"12" #: ../../builtins/stdtypes.rst:5299 msgid "Multi-dimensional arrays::" msgstr "多次元配列::" -#: ../../builtins/stdtypes.rst:5301 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" @@ -7878,6 +8778,16 @@ msgid "" ">>> y.nbytes\n" "96" msgstr "" +">>> import struct\n" +">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" +">>> x = memoryview(buf)\n" +">>> y = x.cast('d', shape=[3,4])\n" +">>> y.tolist()\n" +"[[0.0, 1.5, 3.0, 4.5], [6.0, 7.5, 9.0, 10.5], [12.0, 13.5, 15.0, 16.5]]\n" +">>> len(y)\n" +"3\n" +">>> y.nbytes\n" +"96" #: ../../builtins/stdtypes.rst:5316 msgid "A bool indicating whether the memory is read only." @@ -7907,7 +8817,6 @@ msgstr "" msgid "The size in bytes of each element of the memoryview::" msgstr "memoryview の各要素のバイト単位の大きさ::" -#: ../../builtins/stdtypes.rst:5333 msgid "" ">>> import array, struct\n" ">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" @@ -7918,6 +8827,14 @@ msgid "" ">>> struct.calcsize('H') == m.itemsize\n" "True" msgstr "" +">>> import array, struct\n" +">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" +">>> m.itemsize\n" +"2\n" +">>> m[0]\n" +"32000\n" +">>> struct.calcsize('H') == m.itemsize\n" +"True" #: ../../builtins/stdtypes.rst:5344 msgid "" @@ -7969,17 +8886,18 @@ msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" "メモリーが連続しているかどうかを示す真偽値(参考: :term:`contiguous` )。" -#: ../../builtins/stdtypes.rst:5385 msgid "" "For information on the thread safety of :class:`memoryview` objects in the :" "term:`free-threaded build`, see :ref:`thread-safety-memoryview`." msgstr "" +":term:`フリースレッドビルド ` における :class:" +"`memoryview` オブジェクトのスレッドセーフ性については、:ref:`thread-safety-" +"memoryview` を参照してください。" #: ../../builtins/stdtypes.rst:5392 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "set(集合)型 --- :class:`set`, :class:`frozenset`" -#: ../../builtins/stdtypes.rst:5396 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " @@ -7989,20 +8907,27 @@ msgid "" "`collections` module.) See :ref:`time-complexity` for the costs of the " "various set operations." msgstr "" +":dfn:`集合 (set)` オブジェクトは、互いに異なる :term:`ハッシュ可能 " +"` なオブジェクトからなる順序を持たないコレクションです。\n" +"主な用途には、帰属判定、シーケンスからの重複の除去、積集合・和集合・差集合・" +"対称差といった数学的演算の計算があります。\n" +"(その他のコンテナについては、組み込みの :class:`dict`、:class:`list`、:class:" +"`tuple` クラス、および :mod:`collections` モジュールを参照してください。)\n" +"各種集合演算の計算量については、:ref:`time-complexity` を参照してください。" -#: ../../builtins/stdtypes.rst:5404 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " "position or order of insertion. Accordingly, sets do not support indexing, " "slicing, or other sequence-like behavior." msgstr "" -"集合は、他のコレクションと同様、 ``x in set``, ``len(set)``, ``for x in " -"set`` をサポートします。コレクションには順序がないので、集合は挿入の順序や要" -"素の位置を記録しません。従って、集合はインデクシング、スライシング、その他の" -"シーケンス的な振舞いをサポートしません。" +"集合は他のコレクションと同様に、``x in set``、``len(set)``、``for x in set`` " +"をサポートします。\n" +"集合は順序を持たないコレクションなので、要素の位置や挿入順序を記録しませ" +"ん。\n" +"そのため、インデックス指定やスライスなど、シーケンスのような動作はサポートし" +"ません。" -#: ../../builtins/stdtypes.rst:5409 msgid "" "There are currently two built-in set types, :class:`set` and :class:" "`frozenset`. The :class:`set` type is mutable --- the contents can be " @@ -8013,6 +8938,15 @@ msgid "" "it is created; it can therefore be used as a dictionary key or as an element " "of another set." msgstr "" +"現在、組み込みの集合型には :class:`set` と :class:`frozenset` の二つがありま" +"す。\n" +":class:`set` 型はミュータブルで、:meth:`~set.add` や :meth:`~set.remove` など" +"のメソッドで内容を変更できます。\n" +"ミュータブルなのでハッシュ値を持たず、辞書のキーにも別の集合の要素にも使えま" +"せん。\n" +":class:`frozenset` 型はイミュータブルで :term:`ハッシュ可能 ` で" +"す。\n" +"作成後に内容を変更できないため、辞書のキーや別の集合の要素として使えます。" #: ../../builtins/stdtypes.rst:5418 msgid "" @@ -8020,9 +8954,9 @@ msgid "" "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -"空でない :class:`set` (:class:`frozenset` ではない) は、:class:`set` コンスト" -"ラクタに加え、要素を波括弧中にカンマで区切って列挙することでも生成できます。" -"例: ``{'jack', 'sjoerd'}``。" +"空でない ``set`` (``frozenset`` ではない) は、:class:`set` コンストラクタに加" +"え、要素を波括弧中にカンマで区切って列挙することでも生成できます。例: " +"``{'jack', 'sjoerd'}``。" #: ../../builtins/stdtypes.rst:5422 msgid "The constructors for both classes work the same:" @@ -8035,11 +8969,11 @@ msgid "" "sets of sets, the inner sets must be :class:`frozenset` objects. If " "*iterable* is not specified, a new empty set is returned." msgstr "" -"*iterable* から要素を取り込んだ、新しい :class:`set` もしくは :class:" -"`frozenset` オブジェクトを返します。 集合の要素は :term:`ハッシュ可能 " -"` なものでなくてはなりません。集合の集合を表現するためには、内側の" -"集合は :class:`frozenset` オブジェクトでなくてはなりません。*iterable* が指定" -"されない場合、新しい空の集合が返されます。" +"*iterable* から要素を取り込んだ、新しい ``set`` もしくは ``frozenset`` オブ" +"ジェクトを返します。 集合の要素は :term:`ハッシュ可能 ` なものでな" +"くてはなりません。集合の集合を表現するためには、内側の集合は :class:" +"`frozenset` オブジェクトでなくてはなりません。*iterable* が指定されない場合、" +"新しい空の集合が返されます。" #: ../../builtins/stdtypes.rst:5433 msgid "Sets can be created by several means:" @@ -8139,7 +9073,6 @@ msgstr "" msgid "Return a shallow copy of the set." msgstr "集合の浅いコピーを返します。" -#: ../../builtins/stdtypes.rst:5512 msgid "" "Note, the non-operator versions of :meth:`~frozenset.union`, :meth:" "`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset." @@ -8149,6 +9082,14 @@ msgid "" "precludes error-prone constructions like ``set('abc') & 'cbs'`` in favor of " "the more readable ``set('abc').intersection('cbs')``." msgstr "" +"演算子を使わない :meth:`~frozenset.union`、:meth:`~frozenset.intersection`、:" +"meth:`~frozenset.difference`、:meth:`~frozenset.symmetric_difference`、:meth:" +"`~frozenset.issubset`、:meth:`~frozenset.issuperset` メソッドは、任意のイテラ" +"ブルを引数として受け付けます。\n" +"一方、対応する演算子を使う場合、引数は集合でなければなりません。\n" +"これにより、間違いを起こしやすい ``set('abc') & 'cbs'`` のような書き方ができ" +"なくなり、より読みやすい ``set('abc').intersection('cbs')`` を使うようになり" +"ます。" #: ../../builtins/stdtypes.rst:5519 msgid "" @@ -8203,15 +9144,15 @@ msgstr "" "集合の要素は、辞書のキーのように、 :term:`ハッシュ可能 ` でなければ" "なりません。" -#: ../../builtins/stdtypes.rst:5540 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -":class:`set` インスタンスと :class:`frozenset` インスタンスを取り混ぜての二項" -"演算は、第一被演算子の型を返します。例えば: ``frozenset('ab') | set('bc')`` " -"は :class:`frozenset` インスタンスを返します。" +":class:`set` と :class:`frozenset` のインスタンスを混在させた二項演算は、最初" +"のオペランドと同じ型のオブジェクトを返します。\n" +"例えば、``frozenset('ab') | set('bc')`` は :class:`frozenset` のインスタンス" +"を返します。" #: ../../builtins/stdtypes.rst:5544 msgid "" @@ -8266,12 +9207,14 @@ msgstr "" msgid "Remove all elements from the set." msgstr "set の全ての要素を取り除きます。" -#: ../../builtins/stdtypes.rst:5590 msgid "" "Note, the non-operator versions of the :meth:`~set.update`, :meth:`~set." "intersection_update`, :meth:`~set.difference_update`, and :meth:`~set." "symmetric_difference_update` methods will accept any iterable as an argument." msgstr "" +"演算子を使わない :meth:`~set.update`、:meth:`~set.intersection_update`、:" +"meth:`~set.difference_update`、:meth:`~set.symmetric_difference_update` メ" +"ソッドは、任意のイテラブルを引数として受け付けます。" #: ../../builtins/stdtypes.rst:5595 msgid "" @@ -8281,23 +9224,22 @@ msgid "" "*elem*." msgstr "" -#: ../../builtins/stdtypes.rst:5600 msgid "" "Sets and frozensets are :ref:`generic ` over the type of their " "elements." msgstr "" +"set と frozenset は要素の型について :ref:`ジェネリック ` です。" -#: ../../builtins/stdtypes.rst:5604 msgid "" "For detailed information on thread-safety guarantees for :class:`set` " "objects, see :ref:`thread-safety-set`." msgstr "" +":class:`set` オブジェクトのスレッドセーフ性の保証については、:ref:`thread-" +"safety-set` を参照してください。" -#: ../../builtins/stdtypes.rst:5611 msgid "Mapping types --- :class:`!dict`, :class:`!frozendict`" -msgstr "" +msgstr "マッピング型 --- :class:`!dict`、:class:`!frozendict`" -#: ../../builtins/stdtypes.rst:5621 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " "There are currently two standard mapping types, the :dfn:`dictionary` and :" @@ -8306,8 +9248,14 @@ msgid "" "See :ref:`time-complexity` for the costs of the various dictionary " "operations." msgstr "" +":term:`マッピング ` オブジェクトは、:term:`ハッシュ可能 ` " +"な値を任意のオブジェクトに対応付けます。\n" +"現在、標準のマッピング型には :dfn:`辞書 (dictionary)` と :class:`frozendict` " +"の二つがあります。\n" +"(その他のコンテナについては、組み込みの :class:`list`、:class:`set`、:class:" +"`tuple` クラス、および :mod:`collections` モジュールを参照してください。)\n" +"各種辞書演算の計算量については、:ref:`time-complexity` を参照してください。" -#: ../../builtins/stdtypes.rst:5630 msgid "" "A dictionary's keys are *almost* arbitrary values. Values that are not :" "term:`hashable`, that is, values containing lists, dictionaries or other " @@ -8315,12 +9263,12 @@ msgid "" "may not be used as keys. Values that compare equal (such as ``1``, ``1.0``, " "and ``True``) can be used interchangeably to index the same dictionary entry." msgstr "" -"辞書のキーには、 *ほぼ* どんな値も使うことができます。\n" -"キーとして使えないのは、 :term:`hashable` (ハッシュ可能) でない値、すなわちリ" -"ストや辞書のようなミュータブルな型 (内包する値ではなくオブジェクト自体が同一" -"であるかによって比較が行われるような型)です。\n" -"比較した際に等しいとみなされる値 (例えば ``1`` と ``1.0`` と ``True``) は、ど" -"れを使っても同じエントリーに関連付けられます。" +"辞書のキーには、*ほぼ* 任意の値を使えます。\n" +":term:`ハッシュ可能 ` でない値、すなわちリスト、辞書、その他の" +"ミュータブルな型 (オブジェクトの同一性ではなく値によって比較されるもの) を含" +"む値は、キーとして使えません。\n" +"比較すると等しい値 (例えば ``1``、``1.0``、``True``) は、どれを使っても同じ辞" +"書の項目にアクセスできます。" #: ../../builtins/stdtypes.rst:5641 msgid "" @@ -8354,7 +9302,6 @@ msgstr "" "型コンストラクタを使う: ``dict()``, ``dict([('foo', 100), ('bar', 200)])``, " "``dict(foo=100, bar=200)``" -#: ../../builtins/stdtypes.rst:5652 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it defines a ``keys()`` method, a " @@ -8366,6 +9313,18 @@ msgid "" "corresponding value. If a key occurs more than once, the last value for " "that key becomes the corresponding value in the new dictionary." msgstr "" +"位置引数を指定しない場合は、空の辞書を作成します。\n" +"位置引数を指定し、そのオブジェクトに ``keys()`` メソッドが定義されている場合" +"は、そのメソッドが返す各キーを使って位置引数の :meth:`~object.__getitem__` を" +"呼び出し、辞書を作成します。\n" +"それ以外の場合、位置引数は :term:`イテラブル ` オブジェクトでなけれ" +"ばなりません。\n" +"そのイテラブル内の各要素も、それぞれちょうど二つの要素を持つイテラブルでなけ" +"ればなりません。\n" +"各要素の1番目の値が新しい辞書のキーとなり、2番目の値が対応する値となりま" +"す。\n" +"同じキーが複数回出現した場合は、そのキーの最後の値が新しい辞書での対応する値" +"となります。" #: ../../builtins/stdtypes.rst:5662 msgid "" @@ -8378,7 +9337,6 @@ msgstr "" "辞書に追加されます。既に存在しているキーが追加された場合、キーワード引数の値" "は位置引数の値を置き換えます。" -#: ../../builtins/stdtypes.rst:5667 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " @@ -8386,8 +9344,12 @@ msgid "" "equality, the following examples all return a dictionary equal to " "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" +"辞書同士は、順序に関係なく同じ ``(key, value)`` 対を持つ場合に限り等しいとみ" +"なされます。\n" +"順序比較 ('<'、'<='、'>='、'>') は :exc:`TypeError` を送出します。\n" +"辞書の作成と等価性を示す次の例は、すべて ``{\"one\": 1, \"two\": 2, " +"\"three\": 3}`` と等しい辞書を返します。 ::" -#: ../../builtins/stdtypes.rst:5673 msgid "" ">>> a = dict(one=1, two=2, three=3)\n" ">>> b = {'one': 1, 'two': 2, 'three': 3}\n" @@ -8398,6 +9360,14 @@ msgid "" ">>> a == b == c == d == e == f\n" "True" msgstr "" +">>> a = dict(one=1, two=2, three=3)\n" +">>> b = {'one': 1, 'two': 2, 'three': 3}\n" +">>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))\n" +">>> d = dict([('two', 2), ('one', 1), ('three', 3)])\n" +">>> e = dict({'three': 3, 'one': 1, 'two': 2})\n" +">>> f = dict({'one': 1, 'three': 3}, two=2)\n" +">>> a == b == c == d == e == f\n" +"True" #: ../../builtins/stdtypes.rst:5682 msgid "" @@ -8417,7 +9387,6 @@ msgstr "" "キーの更新は順序には影響が無いことに注意してください。\n" "いったん削除されてから再度追加されたキーは末尾に挿入されます。::" -#: ../../builtins/stdtypes.rst:5688 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -8434,6 +9403,20 @@ msgid "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" msgstr "" +">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" +">>> d\n" +"{'one': 1, 'two': 2, 'three': 3, 'four': 4}\n" +">>> list(d)\n" +"['one', 'two', 'three', 'four']\n" +">>> list(d.values())\n" +"[1, 2, 3, 4]\n" +">>> d[\"one\"] = 42\n" +">>> d\n" +"{'one': 42, 'two': 2, 'three': 3, 'four': 4}\n" +">>> del d[\"two\"]\n" +">>> d[\"two\"] = None\n" +">>> d\n" +"{'one': 42, 'three': 3, 'four': 4, 'two': None}" #: ../../builtins/stdtypes.rst:5703 msgid "" @@ -8443,11 +9426,12 @@ msgstr "" "辞書の順序が挿入順序であることが保証されるようになりました。この振る舞いは " "CPython 3.6 の実装詳細でした。" -#: ../../builtins/stdtypes.rst:5707 msgid "" "Dictionaries are :ref:`generic ` over two types, signifying " "(respectively) the types of the dictionary's keys and values." msgstr "" +"辞書は、キーと値の型をそれぞれ表す二つの型について :ref:`ジェネリック " +"` です。" #: ../../builtins/stdtypes.rst:5710 msgid "" @@ -8473,7 +9457,6 @@ msgstr "" "*d* のキー *key* の項目を返します。マップに *key* が存在しなければ、 :exc:" "`KeyError` を送出します。" -#: ../../builtins/stdtypes.rst:5728 msgid "" "If a subclass of dict defines a method :meth:`~object.__missing__` and *key* " "is not present, the ``d[key]`` operation calls that method with the key " @@ -8483,8 +9466,17 @@ msgid "" "__missing__` is not defined, :exc:`KeyError` is raised. :meth:`~object." "__missing__` must be a method; it cannot be an instance variable::" msgstr "" +"dict のサブクラスに :meth:`~object.__missing__` メソッドが定義されていて " +"*key* が存在しない場合、``d[key]`` 演算はキー *key* を引数としてそのメソッド" +"を呼び出します。\n" +"``d[key]`` 演算は、``__missing__(key)`` の呼び出しが返す値をそのまま返し、送" +"出する例外をそのまま送出します。\n" +"それ以外の演算やメソッドは :meth:`~object.__missing__` を呼び出しません。\n" +":meth:`~object.__missing__` が定義されていない場合は :exc:`KeyError` が送出さ" +"れます。\n" +":meth:`~object.__missing__` はメソッドでなければならず、インスタンス変数には" +"できません。 ::" -#: ../../builtins/stdtypes.rst:5736 msgid "" ">>> class Counter(dict):\n" "... def __missing__(self, key):\n" @@ -8497,13 +9489,25 @@ msgid "" ">>> c['red']\n" "1" msgstr "" +">>> class Counter(dict):\n" +"... def __missing__(self, key):\n" +"... return 0\n" +"...\n" +">>> c = Counter()\n" +">>> c['red']\n" +"0\n" +">>> c['red'] += 1\n" +">>> c['red']\n" +"1" -#: ../../builtins/stdtypes.rst:5747 msgid "" "The example above shows part of the implementation of :class:`collections." "Counter`. A different :meth:`!__missing__` method is used by :class:" "`collections.defaultdict`." msgstr "" +"上の例は :class:`collections.Counter` の実装の一部を示しています。\n" +":class:`collections.defaultdict` では、異なる :meth:`!__missing__` メソッドを" +"使っています。" #: ../../builtins/stdtypes.rst:5754 msgid "Set ``d[key]`` to *value*." @@ -8601,13 +9605,12 @@ msgstr "" "*default* を返します。 *default* が与えられず、かつ *key* が辞書に存在しなけ" "れば :exc:`KeyError` を送出します。" -#: ../../builtins/stdtypes.rst:5817 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -"任意の ``(key, value)`` 対を辞書から消去して返します。\n" -"対は :abbr:`LIFO (後入れ、先出し)` の順序で返却されます。" +"辞書から ``(key, value)`` 対を削除し、その対を返します。\n" +"対は :abbr:`LIFO (後入れ、先出し)` の順序で返されます。" #: ../../builtins/stdtypes.rst:5820 msgid "" @@ -8645,13 +9648,14 @@ msgstr "" "*default* として *key* を挿入し、 *default* を返します。 *default* のデフォル" "トは ``None`` です。" -#: ../../builtins/stdtypes.rst:5845 msgid "" "Update the dictionary with the key/value pairs from *mapping* or *iterable* " "and *kwargs*, overwriting existing keys. Return ``None``." msgstr "" +"``mapping`` または ``iterable`` と ``kwargs`` のキーと値の対で辞書を更新し、" +"既存のキーを上書きします。\n" +"``None`` を返します。" -#: ../../builtins/stdtypes.rst:5848 msgid "" ":meth:`update` accepts either another object with a ``keys()`` method (in " "which case :meth:`~object.__getitem__` is called with every key returned " @@ -8659,6 +9663,13 @@ msgid "" "iterables of length two). If keyword arguments are specified, the dictionary " "is then updated with those key/value pairs: ``d.update(red=1, blue=2)``." msgstr "" +":meth:`update` は、``keys()`` メソッドを持つ別のオブジェクトか、キーと値の対" +"のイテラブル (各対はタプル、または長さ2のその他のイテラブル) を受け付けま" +"す。\n" +"前者の場合、そのメソッドが返す各キーを使って :meth:`~object.__getitem__` を呼" +"び出します。\n" +"キーワード引数を指定した場合は、続いてそれらのキーと値の対で辞書を更新しま" +"す: ``d.update(red=1, blue=2)``。" #: ../../builtins/stdtypes.rst:5856 msgid "" @@ -8678,21 +9689,23 @@ msgstr "" "が返ります。\n" "``dict.values()`` どうしを比較したときも同様です::" -#: ../../builtins/stdtypes.rst:5863 msgid "" ">>> d = {'a': 1}\n" ">>> d.values() == d.values()\n" "False" msgstr "" +">>> d = {'a': 1}\n" +">>> d.values() == d.values()\n" +"False" -#: ../../builtins/stdtypes.rst:5869 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" "*d* と *other* のキーと値を統合した新しい辞書を作成します。\n" -"*d* と *other* のキーに重複がある場合は、 *other* の方の値が優先されます。" +"*d* と *other* は両方とも辞書でなければなりません。\n" +"*d* と *other* でキーが重複する場合は、*other* の値が優先されます。" #: ../../builtins/stdtypes.rst:5877 msgid "" @@ -8709,7 +9722,6 @@ msgstr "" msgid "Dictionaries and dictionary views are reversible. ::" msgstr "辞書と辞書のビューは ``reversed()`` で順序を逆にすることができます::" -#: ../../builtins/stdtypes.rst:5885 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -8721,6 +9733,15 @@ msgid "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" msgstr "" +">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" +">>> d\n" +"{'one': 1, 'two': 2, 'three': 3, 'four': 4}\n" +">>> list(reversed(d))\n" +"['four', 'three', 'two', 'one']\n" +">>> list(reversed(d.values()))\n" +"[4, 3, 2, 1]\n" +">>> list(reversed(d.items()))\n" +"[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" #: ../../builtins/stdtypes.rst:5895 msgid "Dictionaries are now reversible." @@ -8732,11 +9753,12 @@ msgid "" "create a read-only view of a :class:`dict`." msgstr "" -#: ../../builtins/stdtypes.rst:5905 msgid "" "For detailed information on thread-safety guarantees for :class:`dict` " "objects, see :ref:`thread-safety-dict`." msgstr "" +":class:`dict` オブジェクトのスレッドセーフ性の保証については、:ref:`thread-" +"safety-dict` を参照してください。" #: ../../builtins/stdtypes.rst:5912 msgid "Dictionary view objects" @@ -8806,13 +9828,12 @@ msgstr "" "*x* が元の辞書のキー、値、または項目 (項目の場合、 *x* は ``(key, value)`` タ" "プルです) にあるとき ``True`` を返します。" -#: ../../builtins/stdtypes.rst:5949 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -"辞書のキーもしくは値、項目の順序を逆にしたイテレーターを返します。\n" -"戻り値のビューは、挿入された順とは逆の順でイテレートします。" +"辞書のキー、値、または項目を逆順にたどるイテレータを返します。\n" +"ビューは挿入順序とは逆の順序で反復されます。" #: ../../builtins/stdtypes.rst:5952 msgid "Dictionary views are now reversible." @@ -8826,7 +9847,6 @@ msgstr "" "ビューの参照先の辞書をラップする :class:`types.MappingProxyType` オブジェク" "ト を返します。" -#: ../../builtins/stdtypes.rst:5962 msgid "" "Keys views are set-like since their entries are unique and :term:`hashable`. " "Items views also have set-like operations since the (key, value) pairs are " @@ -8848,13 +9868,12 @@ msgstr "" "れた全ての演算が利用可能です (たとえば ``==``, ``<`` や ``^`` など)。 集合演" "算に対しては、集合はオペランドとして集合しか取ることができないのに対して、こ" "れら集合の特性を持つビューはオペランドとして任意のイテラブルを取ることができ" -"ます。 " +"ます。" #: ../../builtins/stdtypes.rst:5974 msgid "An example of dictionary view usage::" msgstr "辞書ビューの使用法の例::" -#: ../../builtins/stdtypes.rst:5976 msgid "" ">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" ">>> keys = dishes.keys()\n" @@ -8894,78 +9913,112 @@ msgid "" ">>> values.mapping['spam']\n" "500" msgstr "" +">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" +">>> keys = dishes.keys()\n" +">>> values = dishes.values()\n" +"\n" +">>> # 反復\n" +">>> n = 0\n" +">>> for val in values:\n" +"... n += val\n" +"...\n" +">>> print(n)\n" +"504\n" +"\n" +">>> # キーと値は同じ順序 (挿入順序) で反復される\n" +">>> list(keys)\n" +"['eggs', 'sausage', 'bacon', 'spam']\n" +">>> list(values)\n" +"[2, 1, 1, 500]\n" +"\n" +">>> # ビューオブジェクトは動的で、辞書の変更を反映する\n" +">>> del dishes['eggs']\n" +">>> del dishes['sausage']\n" +">>> list(keys)\n" +"['bacon', 'spam']\n" +"\n" +">>> # 集合演算\n" +">>> keys & {'eggs', 'bacon', 'salad'}\n" +"{'bacon'}\n" +">>> keys ^ {'sausage', 'juice'} == {'juice', 'sausage', 'bacon', 'spam'}\n" +"True\n" +">>> keys | ['juice', 'juice', 'juice'] == {'bacon', 'spam', 'juice'}\n" +"True\n" +"\n" +">>> # 元の辞書の読み出し専用プロキシを取得する\n" +">>> values.mapping\n" +"mappingproxy({'bacon': 1, 'spam': 500})\n" +">>> values.mapping['spam']\n" +"500" -#: ../../builtins/stdtypes.rst:6016 msgid "Frozen dictionaries" -msgstr "" +msgstr "凍結辞書" -#: ../../builtins/stdtypes.rst:6022 msgid "" "Return a new frozen dictionary initialized from an optional positional " "argument and a possibly empty set of keyword arguments." msgstr "" +"省略可能な位置引数と、空でもよいキーワード引数の集まりから初期化した、新しい" +"凍結辞書を返します。" -#: ../../builtins/stdtypes.rst:6025 msgid "" "A :class:`!frozendict` has a similar API to the :class:`dict` API, with the " "following differences:" msgstr "" +":class:`!frozendict` の API は :class:`dict` の API と似ていますが、次の点が" +"異なります:" -#: ../../builtins/stdtypes.rst:6028 msgid ":class:`!dict` has more methods than :class:`!frozendict`:" -msgstr "" +msgstr ":class:`!dict` は :class:`!frozendict` より多くのメソッドを持ちます:" -#: ../../builtins/stdtypes.rst:6030 msgid ":meth:`!__delitem__`" -msgstr "" +msgstr ":meth:`!__delitem__`" -#: ../../builtins/stdtypes.rst:6031 msgid ":meth:`!__setitem__`" -msgstr "" +msgstr ":meth:`!__setitem__`" -#: ../../builtins/stdtypes.rst:6032 msgid ":meth:`~dict.clear`" -msgstr "" +msgstr ":meth:`~dict.clear`" -#: ../../builtins/stdtypes.rst:6033 msgid ":meth:`~dict.pop`" -msgstr "" +msgstr ":meth:`~dict.pop`" -#: ../../builtins/stdtypes.rst:6034 msgid ":meth:`~dict.popitem`" -msgstr "" +msgstr ":meth:`~dict.popitem`" -#: ../../builtins/stdtypes.rst:6035 msgid ":meth:`~dict.setdefault`" -msgstr "" +msgstr ":meth:`~dict.setdefault`" -#: ../../builtins/stdtypes.rst:6036 msgid ":meth:`~dict.update`" -msgstr "" +msgstr ":meth:`~dict.update`" -#: ../../builtins/stdtypes.rst:6038 msgid "" "A :class:`!frozendict` can be hashed with ``hash(frozendict)`` if all keys " "and values can be hashed." msgstr "" +":class:`!frozendict` のすべてのキーと値がハッシュ可能であれば、" +"``hash(frozendict)`` でハッシュ値を計算できます。" -#: ../../builtins/stdtypes.rst:6041 msgid "" "``frozendict |= other`` does not modify the :class:`!frozendict` in-place " "but creates a new frozen dictionary." msgstr "" +"``frozendict |= other`` は :class:`!frozendict` をインプレースで変更せず、新" +"しい凍結辞書を作成します。" -#: ../../builtins/stdtypes.rst:6044 msgid "" ":class:`!frozendict` is not a :class:`!dict` subclass but inherits directly " "from ``object``." msgstr "" +":class:`!frozendict` は :class:`!dict` のサブクラスではなく、``object`` を直" +"接継承します。" -#: ../../builtins/stdtypes.rst:6047 msgid "" "Like dictionaries, frozendicts are :ref:`generic ` over two types, " "signifying (respectively) the types of the frozendict's keys and values." msgstr "" +"辞書と同様に、frozendict はキーと値の型をそれぞれ表す二つの型について :ref:`" +"ジェネリック ` です。" #: ../../builtins/stdtypes.rst:6052 msgid "" @@ -8990,16 +10043,16 @@ msgstr "" "文の終わりで脱出する実行時コンテキストを、ユーザ定義クラスが定義できるように" "する一対のメソッドで実装されます:" -#: ../../builtins/stdtypes.rst:6078 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " "to the identifier in the :keyword:`!as` clause of :keyword:`with` statements " "using this context manager." msgstr "" -"実行時コンテキストに入り、このオブジェクトまたは他の実行時コンテキストに関連" -"したオブジェクトを返します。このメソッドが返す値はこのコンテキストマネージャ" -"を使う :keyword:`with` 文の :keyword:`!as` 節の識別子に束縛されます。" +"実行時コンテキストに入り、このオブジェクト自体か、実行時コンテキストに関連す" +"る別のオブジェクトを返します。\n" +"このメソッドの返り値は、このコンテキストマネージャを使う :keyword:`with` 文" +"の :keyword:`!as` 節の識別子に束縛されます。" #: ../../builtins/stdtypes.rst:6083 msgid "" @@ -9040,20 +10093,24 @@ msgstr "" "合、引数にはその例外の型と値とトレースバック情報を渡します。そうでない場合、" "引数は全て ``None`` となります。" -#: ../../builtins/stdtypes.rst:6102 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " "statement immediately following the :keyword:`!with` statement. Otherwise " "the exception continues propagating after this method has finished executing." msgstr "" +"このメソッドが真の値を返すと、:keyword:`with` 文は例外を抑制し、:keyword:`!" +"with` 文の直後の文から実行を続けます。\n" +"それ以外の場合は、このメソッドの実行が終わった後も例外が伝播し続けます。" -#: ../../builtins/stdtypes.rst:6107 msgid "" "If this method raises an exception while handling an earlier exception from " "the :keyword:`with` block, the new exception is raised, and the original " "exception is stored in its :attr:`~BaseException.__context__` attribute." msgstr "" +"このメソッドが :keyword:`with` ブロックで発生した例外を処理している間に別の例" +"外を送出すると、新しい例外が送出され、元の例外はその :attr:`~BaseException." +"__context__` 属性に格納されます。" #: ../../builtins/stdtypes.rst:6111 msgid "" @@ -9092,12 +10149,11 @@ msgid "" "rather than the iterator produced by an undecorated generator function." msgstr "" "Python の :term:`ジェネレータ ` と :class:`contextlib." -"contextmanager` :term:`デコレータ ` はこのプロトコルの簡便な実装" -"方法を提供します。ジェネレータ関数を :class:`contextlib.contextmanager` デコ" -"レータでデコレートすると、デコレートされないジェネレータ関数が作成するイテ" -"レータの代わりに、必要な :meth:`~contextmanager.__enter__` および :meth:" -"`~contextmanager.__exit__` メソッドを実装したコンテキストマネージャを返すよう" -"になります。" +"contextmanager` デコレータはこのプロトコルの簡便な実装方法を提供します。ジェ" +"ネレータ関数を :class:`contextlib.contextmanager` デコレータでデコレートする" +"と、デコレートされないジェネレータ関数が作成するイテレータの代わりに、必要" +"な :meth:`~contextmanager.__enter__` および :meth:`~contextmanager.__exit__` " +"メソッドを実装したコンテキストマネージャを返すようになります。" #: ../../builtins/stdtypes.rst:6130 msgid "" @@ -9221,7 +10277,6 @@ msgstr "" "アノテーションでは、このような :ref:`re.Match ` オブジェクト" "は ``re.Match[bytes]`` と表現することになるでしょう。" -#: ../../builtins/stdtypes.rst:6196 msgid "" "``GenericAlias`` objects are instances of the class :class:`types." "GenericAlias`, which can also be used to create ``GenericAlias`` objects " @@ -9229,6 +10284,13 @@ msgid "" "classes>` may not be instances of :class:`types.GenericAlias`, but they " "provide similar functionality." msgstr "" +"``GenericAlias`` オブジェクトは :class:`types.GenericAlias` クラスのインスタ" +"ンスです。\n" +"このクラスを使って ``GenericAlias`` オブジェクトを直接作成することもできま" +"す。\n" +"ユーザ定義の :ref:`ジェネリッククラス ` を特殊化したものは :" +"class:`types.GenericAlias` のインスタンスとは限りませんが、同様の機能を提供し" +"ます。" #: ../../builtins/stdtypes.rst:6203 msgid "" @@ -9241,11 +10303,12 @@ msgstr "" "す。たとえば、 :class:`float` 型の要素を含む :class:`list` を引数にとる関数の" "型アノテーションは次のようになります::" -#: ../../builtins/stdtypes.rst:6208 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" msgstr "" +"def average(values: list[float]) -> float:\n" +" return sum(values) / len(values)" #: ../../builtins/stdtypes.rst:6211 msgid "" @@ -9259,11 +10322,12 @@ msgstr "" "ています。この例では、関数はキーが :class:`str` 型、値が :class:`int` 型であ" "るような ``dict`` を引数にとります::" -#: ../../builtins/stdtypes.rst:6216 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." msgstr "" +"def send_post_request(url: str, body: dict[str, int]) -> None:\n" +" ..." #: ../../builtins/stdtypes.rst:6219 msgid "" @@ -9273,13 +10337,16 @@ msgstr "" "組み込み関数 :func:`isinstance` と :func:`issubclass` は第二引数として " "``GenericAlias`` 型を指定することはできません::" -#: ../../builtins/stdtypes.rst:6222 msgid "" ">>> isinstance([1, 2], list[str])\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" +">>> isinstance([1, 2], list[str])\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: isinstance() argument 2 cannot be a parameterized generic" #: ../../builtins/stdtypes.rst:6227 msgid "" @@ -9295,12 +10362,14 @@ msgstr "" "せん。たとえば、以下のコードは推奨されませんが、エラーになることなく実行でき" "ます::" -#: ../../builtins/stdtypes.rst:6233 msgid "" ">>> t = list[str]\n" ">>> t([1, 2, 3])\n" "[1, 2, 3]" msgstr "" +">>> t = list[str]\n" +">>> t([1, 2, 3])\n" +"[1, 2, 3]" #: ../../builtins/stdtypes.rst:6237 msgid "" @@ -9310,7 +10379,6 @@ msgstr "" "しかも、パラメータ付きジェネリック型は、オブジェクト生成時にパラメータの型情" "報を削除します::" -#: ../../builtins/stdtypes.rst:6240 msgid "" ">>> t = list[str]\n" ">>> type(t)\n" @@ -9320,34 +10388,43 @@ msgid "" ">>> type(l)\n" "" msgstr "" +">>> t = list[str]\n" +">>> type(t)\n" +"\n" +"\n" +">>> l = t()\n" +">>> type(l)\n" +"" -#: ../../builtins/stdtypes.rst:6249 msgid "" "Instances of ``GenericAlias`` are not classes at runtime, even though they " "behave like classes (they can be instantiated and subclassed)::" msgstr "" +"``GenericAlias`` のインスタンスは、インスタンス化やサブクラス化ができるなどク" +"ラスのように振る舞いますが、実行時にはクラスではありません。 ::" -#: ../../builtins/stdtypes.rst:6251 msgid "" ">>> import inspect\n" ">>> inspect.isclass(list[int])\n" "False" msgstr "" +">>> import inspect\n" +">>> inspect.isclass(list[int])\n" +"False" -#: ../../builtins/stdtypes.rst:6255 msgid "" "This is true for :ref:`user-defined generics ` also." msgstr "" +"これは :ref:`ユーザ定義のジェネリック型 ` にも当てはま" +"ります。" -#: ../../builtins/stdtypes.rst:6257 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "" -":func:`repr` や :func:`str` のジェネリック型に対する呼び出しは、パラメータ型" -"を表示します::" +"パラメータ付きジェネリック型に :func:`repr` や :func:`str` を呼び出すと、パラ" +"メータを含む型が表示されます::" -#: ../../builtins/stdtypes.rst:6259 msgid "" ">>> repr(list[int])\n" "'list[int]'\n" @@ -9355,6 +10432,11 @@ msgid "" ">>> str(list[int])\n" "'list[int]'" msgstr "" +">>> repr(list[int])\n" +"'list[int]'\n" +"\n" +">>> str(list[int])\n" +"'list[int]'" #: ../../builtins/stdtypes.rst:6265 msgid "" @@ -9364,43 +10446,48 @@ msgstr "" "ジェネリックコンテナ型の :meth:`~object.__getitem__` メソッドは、 ``dict[str]" "[str]`` のようなミスを許さないように、例外を送出します::" -#: ../../builtins/stdtypes.rst:6268 msgid "" ">>> dict[str][str]\n" "Traceback (most recent call last):\n" " ...\n" "TypeError: dict[str] is not a generic class" msgstr "" +">>> dict[str][str]\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: dict[str] is not a generic class" -#: ../../builtins/stdtypes.rst:6273 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " "items in the ``GenericAlias`` object's :attr:`~genericalias.__args__`. ::" msgstr "" "一方で、同様の式は :ref:`型変数 ` が使われた場合は有効です。添字の" -"数は``GenericAlias`` オブジェクトの :attr:`~genericalias.__args__` 属性におけ" -"る型変数の数と同じでなければなりません::" +"数は ``GenericAlias`` オブジェクトの :attr:`~genericalias.__args__` 属性にお" +"ける型変数の数と同じでなければなりません::" -#: ../../builtins/stdtypes.rst:6277 msgid "" ">>> from typing import TypeVar\n" ">>> Y = TypeVar('Y')\n" ">>> dict[str, Y][int]\n" "dict[str, int]" msgstr "" +">>> from typing import TypeVar\n" +">>> Y = TypeVar('Y')\n" +">>> dict[str, Y][int]\n" +"dict[str, int]" #: ../../builtins/stdtypes.rst:6284 msgid "Standard Generic Classes" msgstr "標準ジェネリッククラス" -#: ../../builtins/stdtypes.rst:6286 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "" -"以下の標準ライブラリクラスは、パラメータ付きジェネリック型をサポートします。" -"このリストは完全に網羅されていない可能性があります。" +"以下の標準ライブラリのクラスは、パラメータ付きジェネリック型をサポートしてい" +"ます。\n" +"このリストはすべてを網羅しているわけではありません。" #: ../../builtins/stdtypes.rst:6289 msgid ":class:`tuple`" @@ -9418,9 +10505,8 @@ msgstr ":class:`dict`" msgid ":class:`set`" msgstr ":class:`set`" -#: ../../builtins/stdtypes.rst:6293 msgid ":class:`frozendict`" -msgstr "" +msgstr ":class:`frozendict`" #: ../../builtins/stdtypes.rst:6294 msgid ":class:`frozenset`" @@ -9430,13 +10516,11 @@ msgstr ":class:`frozenset`" msgid ":class:`type`" msgstr ":class:`type`" -#: ../../builtins/stdtypes.rst:6296 msgid ":class:`asyncio.Future`" -msgstr "" +msgstr ":class:`asyncio.Future`" -#: ../../builtins/stdtypes.rst:6297 msgid ":class:`asyncio.Task`" -msgstr "" +msgstr ":class:`asyncio.Task`" #: ../../builtins/stdtypes.rst:6298 msgid ":class:`collections.deque`" @@ -9458,9 +10542,8 @@ msgstr ":class:`collections.Counter`" msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../builtins/stdtypes.rst:6303 msgid ":class:`collections.abc.Awaitable`" -msgstr "’’:class:`collections.abc.Awaitable`" +msgstr ":class:`collections.abc.Awaitable`" #: ../../builtins/stdtypes.rst:6304 msgid ":class:`collections.abc.Coroutine`" @@ -9644,36 +10727,36 @@ msgstr "" msgid "This attribute points at the non-parameterized generic class::" msgstr "この属性は、対応するパラメータ付きでないジェネリッククラスを指します::" -#: ../../builtins/stdtypes.rst:6358 msgid "" ">>> list[int].__origin__\n" "" msgstr "" +">>> list[int].__origin__\n" +"" -#: ../../builtins/stdtypes.rst:6364 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " "class::" msgstr "" "この属性は、ジェネリッククラスの元の :meth:`~object.__class_getitem__` に渡さ" -"れた :class:`tuple` です (長さが1の場合もあります)::" +"れたジェネリック型を要素とする :class:`tuple` です (長さが1の場合もありま" +"す)::" -#: ../../builtins/stdtypes.rst:6368 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" msgstr "" +">>> dict[str, list[int]].__args__\n" +"(, list[int])" -#: ../../builtins/stdtypes.rst:6374 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" msgstr "" -"この属性は、 ``__args__`` にある固有の型変数のタプルで、必要に応じて遅延計算" -"されます (空の可能性もあります)::" +"この属性は、``__args__`` に含まれる型変数を重複なく集めた、遅延計算されるタプ" +"ルです (空の場合もあります)。 ::" -#: ../../builtins/stdtypes.rst:6377 msgid "" ">>> from typing import TypeVar\n" "\n" @@ -9681,16 +10764,21 @@ msgid "" ">>> list[T].__parameters__\n" "(~T,)" msgstr "" +">>> from typing import TypeVar\n" +"\n" +">>> T = TypeVar('T')\n" +">>> list[T].__parameters__\n" +"(~T,)" -#: ../../builtins/stdtypes.rst:6385 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " "have correct ``__parameters__`` after substitution because :class:`typing." "ParamSpec` is intended primarily for static type checking." msgstr "" -":class:`typing.ParamSpec` パラメータを含む ``GenericAlias`` オブジェクトは、" -"代入後に正しい ``__parameters__`` を持たない可能性があります。これは :class:" -"`typing.ParamSpec` が主に静的な型チェックを目的としているためです。" +":class:`typing.ParamSpec` パラメータを持つ ``GenericAlias`` オブジェクトは、" +"置換後の ``__parameters__`` が正しくない場合があります。\n" +"これは :class:`typing.ParamSpec` が主に静的な型チェックを目的としているためで" +"す。" #: ../../builtins/stdtypes.rst:6392 msgid "" @@ -9743,7 +10831,6 @@ msgstr "" msgid "Union Type" msgstr "Union 型" -#: ../../builtins/stdtypes.rst:6424 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " @@ -9751,26 +10838,31 @@ msgid "" "expression enables cleaner type hinting syntax compared to subscripting :" "class:`typing.Union`." msgstr "" +"ユニオンオブジェクトは、複数の :ref:`型オブジェクト ` に" +"対する ``|`` (ビット単位の論理和) 演算の値を保持します。\n" +"これらの型は主に :term:`型アノテーション ` で使うことを想定してい" +"ます。\n" +"ユニオン型の式を使うと、:class:`typing.Union` の添字表記よりも簡潔な型ヒント" +"の構文で書けます。" -#: ../../builtins/stdtypes.rst:6431 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " "example, the following function expects an argument of type :class:`int` or :" "class:`float`::" msgstr "" -"*X* と *Y* などの型を保持するUnionオブジェクトを定義すします。``X | Y`` はXと" -"Yのいずれかを意味します。これは ``typing.Union[X, Y]`` と等価です。たとえば、" -"以下の関数は引数として :class:`int` 型または :class:`float` 型を想定していま" -"す。::" +"*X*、*Y* などの型を保持するユニオンオブジェクトを定義します。\n" +"``X | Y`` は X または Y を意味し、``typing.Union[X, Y]`` と等価です。\n" +"例えば、次の関数は :class:`int` 型または :class:`float` 型の引数を想定してい" +"ます。 ::" -#: ../../builtins/stdtypes.rst:6436 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" msgstr "" +"def square(number: int | float) -> int | float:\n" +" return number ** 2" -#: ../../builtins/stdtypes.rst:6441 msgid "" "The ``|`` operator cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -9778,6 +10870,12 @@ msgid "" "For unions which include forward references, present the whole expression as " "a string, e.g. ``\"int | Foo\"``." msgstr "" +"一つ以上のメンバーが前方参照であるユニオンを実行時に定義するために、``|`` 演" +"算子を使うことはできません。\n" +"例えば、まだ定義されていないクラスを ``\"Foo\"`` で参照する ``int | " +"\"Foo\"`` は、実行時に失敗します。\n" +"前方参照を含むユニオンは、``\"int | Foo\"`` のように式全体を文字列として記述" +"してください。" #: ../../builtins/stdtypes.rst:6449 msgid "" @@ -9786,61 +10884,56 @@ msgstr "" "Unionオブジェクトは他のUnionオブジェクトとの等価性をテストできます。以下は詳" "細です:" -#: ../../builtins/stdtypes.rst:6451 msgid "Unions of unions are flattened::" -msgstr "ユニオン型のユニオン型は平滑化されます::" +msgstr "ユニオンのユニオンは平坦化されます。 ::" -#: ../../builtins/stdtypes.rst:6453 msgid "(int | str) | float == int | str | float" -msgstr "" +msgstr "(int | str) | float == int | str | float" #: ../../builtins/stdtypes.rst:6455 msgid "Redundant types are removed::" msgstr "余分な型は削除されます::" -#: ../../builtins/stdtypes.rst:6457 msgid "int | str | int == int | str" -msgstr "" +msgstr "int | str | int == int | str" #: ../../builtins/stdtypes.rst:6459 msgid "When comparing unions, the order is ignored::" msgstr "ユニオン型を比較すると順序は無視されます::" -#: ../../builtins/stdtypes.rst:6461 msgid "int | str == str | int" -msgstr "" +msgstr "int | str == str | int" -#: ../../builtins/stdtypes.rst:6463 msgid "It creates instances of :class:`typing.Union`::" -msgstr "" +msgstr ":class:`typing.Union` のインスタンスを作成します。 ::" -#: ../../builtins/stdtypes.rst:6465 msgid "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" msgstr "" +"int | str == typing.Union[int, str]\n" +"type(int | str) is typing.Union" #: ../../builtins/stdtypes.rst:6468 msgid "Optional types can be spelled as a union with ``None``::" msgstr "Optional型は ``None`` とのUnion型で記述できます::" -#: ../../builtins/stdtypes.rst:6470 msgid "str | None == typing.Optional[str]" -msgstr "" +msgstr "str | None == typing.Optional[str]" -#: ../../builtins/stdtypes.rst:6475 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "" -":func:`isinstance` と :func:`issubclass` の呼び出しはどちらもUnionオブジェク" -"トをサポートしています。 " +"ユニオンオブジェクトを使った :func:`isinstance` と :func:`issubclass` の呼び" +"出しもサポートされています。 ::" -#: ../../builtins/stdtypes.rst:6478 msgid "" ">>> isinstance(\"\", int | str)\n" "True" msgstr "" +">>> isinstance(\"\", int | str)\n" +"True" #: ../../builtins/stdtypes.rst:6481 msgid "" @@ -9850,7 +10943,6 @@ msgstr "" "しかし、Unionオブジェクトの中の :ref:`parameterized generics ` はチェックできません::" -#: ../../builtins/stdtypes.rst:6484 msgid "" ">>> isinstance(1, int | list[int]) # short-circuit evaluation\n" "True\n" @@ -9859,14 +10951,21 @@ msgid "" " ...\n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" +">>> isinstance(1, int | list[int]) # 短絡評価\n" +"True\n" +">>> isinstance([1], int | list[int])\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../builtins/stdtypes.rst:6491 msgid "" "The user-exposed type for the union object can be accessed from :class:" "`typing.Union` and used for :func:`isinstance` checks::" msgstr "" +"利用者がユニオンオブジェクトの型にアクセスするには :class:`typing.Union` を使" +"います。\n" +":func:`isinstance` による検査にも使えます。 ::" -#: ../../builtins/stdtypes.rst:6494 msgid "" ">>> import typing\n" ">>> isinstance(int | str, typing.Union)\n" @@ -9876,6 +10975,13 @@ msgid "" " File \"\", line 1, in \n" "TypeError: cannot create 'typing.Union' instances" msgstr "" +">>> import typing\n" +">>> isinstance(int | str, typing.Union)\n" +"True\n" +">>> typing.Union()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: cannot create 'typing.Union' instances" #: ../../builtins/stdtypes.rst:6503 msgid "" @@ -9887,7 +10993,6 @@ msgstr "" "が追加されました。メタクラスで :meth:`!__or__` を実装するとUnionをオーバーラ" "イドする場合があります::" -#: ../../builtins/stdtypes.rst:6507 msgid "" ">>> class M(type):\n" "... def __or__(self, other):\n" @@ -9901,17 +11006,30 @@ msgid "" ">>> int | C\n" "int | C" msgstr "" +">>> class M(type):\n" +"... def __or__(self, other):\n" +"... return \"Hello\"\n" +"...\n" +">>> class C(metaclass=M):\n" +"... pass\n" +"...\n" +">>> C | int\n" +"'Hello'\n" +">>> int | C\n" +"int | C" #: ../../builtins/stdtypes.rst:6523 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr ":pep:`604` -- ``X | Y`` 構文とUnion型を提案しているPEP" -#: ../../builtins/stdtypes.rst:6529 msgid "" "Union objects are now instances of :class:`typing.Union`. Previously, they " "were instances of :class:`types.UnionType`, which remains an alias for :" "class:`typing.Union`." msgstr "" +"ユニオンオブジェクトは :class:`typing.Union` のインスタンスになりました。\n" +"以前は :class:`types.UnionType` のインスタンスでしたが、この型名は :class:" +"`typing.Union` のエイリアスとして残っています。" #: ../../builtins/stdtypes.rst:6536 msgid "Other Built-in Types" @@ -10014,13 +11132,17 @@ msgstr "詳細は、 :ref:`function` を参照してください。" msgid "Methods" msgstr "メソッド" -#: ../../builtins/stdtypes.rst:6597 msgid "" "Methods are functions that are called using the attribute notation. There " "are two flavors: :ref:`built-in methods ` (such as :meth:" "`~list.append` on lists) and :ref:`class instance methods `. Built-in methods are described with the types that support them." msgstr "" +"メソッドは属性表記を使って呼び出す関数です。\n" +":ref:`組み込みメソッド ` (リストの :meth:`~list.append` な" +"ど) と :ref:`クラスのインスタンスメソッド ` の2種類がありま" +"す。\n" +"組み込みメソッドは、それをサポートする型の説明で扱います。" #: ../../builtins/stdtypes.rst:6603 msgid "" @@ -10062,7 +11184,6 @@ msgstr "" "ためには、次のようにその下層の関数オブジェクトに明示的に設定する必要がありま" "す::" -#: ../../builtins/stdtypes.rst:6622 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -10077,6 +11198,19 @@ msgid "" ">>> c.method.whoami\n" "'my name is method'" msgstr "" +">>> class C:\n" +"... def method(self):\n" +"... pass\n" +"...\n" +">>> c = C()\n" +">>> c.method.whoami = 'my name is method' # メソッドに設定することはできな" +"い\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"AttributeError: 'method' object has no attribute 'whoami'\n" +">>> c.method.__func__.whoami = 'my name is method'\n" +">>> c.method.whoami\n" +"'my name is method'" #: ../../builtins/stdtypes.rst:6637 msgid "See :ref:`instance-methods` for more information." @@ -10102,15 +11236,14 @@ msgstr "" "の :attr:`~function.__code__` 属性として取り出せます。 :mod:`code` モジュール" "も参照してください。" -#: ../../builtins/stdtypes.rst:6658 msgid "" "Accessing :attr:`~function.__code__` raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and " "``\"__code__\"``." msgstr "" -":attr:`~function.__code__` へのアクセスは ``object.__getattr__`` に ``obj`` " -"と ``\"__code__\"`` を渡して行いますが、 :ref:`監査イベント ` を送" -"出します。" +":attr:`~function.__code__` にアクセスすると、実引数 ``obj`` と " +"``\"__code__\"`` を伴う :ref:`監査イベント ` ``object." +"__getattr__`` が送出されます。" #: ../../builtins/stdtypes.rst:6665 msgid "" @@ -10166,65 +11299,77 @@ msgstr "``None`` と書き表されます。" msgid "The Ellipsis Object" msgstr "Ellipsis オブジェクト" -#: ../../builtins/stdtypes.rst:6706 msgid "" "This object is commonly used to indicate that something is omitted. It " "supports no special operations. There is exactly one ellipsis object, " "named :const:`Ellipsis` (a built-in name). ``type(Ellipsis)()`` produces " "the :const:`Ellipsis` singleton." msgstr "" +"このオブジェクトは、何かが省略されていることを表すためによく使われます。\n" +"特別な演算はサポートしていません。\n" +"省略記号オブジェクトはちょうど一つだけ存在し、組み込み名 :const:`Ellipsis` が" +"付いています。\n" +"``type(Ellipsis)()`` は :const:`Ellipsis` シングルトンを生成します。" #: ../../builtins/stdtypes.rst:6711 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "``Ellipsis`` または ``...`` と書き表されます。" -#: ../../builtins/stdtypes.rst:6713 msgid "" "In typical use, ``...`` as the ``Ellipsis`` object appears in a few " "different places, for instance:" msgstr "" +"通常、``Ellipsis`` オブジェクトとしての ``...`` は、例えば次のような箇所で使" +"われます:" -#: ../../builtins/stdtypes.rst:6716 msgid "" "In type annotations, such as :ref:`callable arguments ` or :ref:`tuple elements `." msgstr "" +":ref:`呼び出し可能オブジェクトの引数 ` や :ref:`タプル" +"の要素 ` などの型アノテーション。" -#: ../../builtins/stdtypes.rst:6719 msgid "" "As the body of a function instead of a :ref:`pass statement `." -msgstr "" +msgstr ":ref:`pass 文 ` の代わりとなる関数本体。" -#: ../../builtins/stdtypes.rst:6721 msgid "" "In third-party libraries, such as `Numpy's slicing and striding `_." msgstr "" +"`NumPy のスライスとストライド `_ などのサードパーティライブラリ。" -#: ../../builtins/stdtypes.rst:6724 msgid "" "Python also uses three dots in ways that are not ``Ellipsis`` objects, for " "instance:" msgstr "" +"Python では、``Ellipsis`` オブジェクト以外の意味でも3個のドットを使います。\n" +"例えば、次のような場合です:" -#: ../../builtins/stdtypes.rst:6726 msgid "" "Doctest's :const:`ELLIPSIS `, as a pattern for missing " "content." msgstr "" +"省略された内容にマッチするパターンとしての、doctest の :const:`ELLIPSIS " +"`。" -#: ../../builtins/stdtypes.rst:6728 msgid "" "The default Python prompt of the :term:`interactive` shell when partial " "input is incomplete." msgstr "" +"入力がまだ完了していないときの、:term:`対話型 ` シェルの Python " +"のデフォルトプロンプト。" -#: ../../builtins/stdtypes.rst:6730 msgid "" "Lastly, the Python documentation often uses three dots in conventional " "English usage to mean omitted content, even in code examples that also use " "them as the ``Ellipsis``." msgstr "" +"最後に、Python ドキュメントでは内容の省略を意味する通常の英語の用法でも3個の" +"ドットをよく使います。\n" +"これは、``Ellipsis`` としても3個のドットを使っているコード例にも当てはまりま" +"す。" #: ../../builtins/stdtypes.rst:6738 msgid "The NotImplemented Object" @@ -10287,21 +11432,23 @@ msgstr "" "クラス、関数、メソッド、デスクリプタ、ジェネレータインスタンスの :term:`修飾" "名 ` です。" -#: ../../builtins/stdtypes.rst:6784 msgid "The name of the module in which a class or function was defined." -msgstr "" +msgstr "クラスまたは関数が定義されたモジュールの名前。" -#: ../../builtins/stdtypes.rst:6789 msgid "" "The documentation string of a class or function, or ``None`` if undefined." msgstr "" +"クラスまたは関数のドキュメンテーション文字列。\n" +"未定義の場合は ``None``。" -#: ../../builtins/stdtypes.rst:6794 msgid "" "The :ref:`type parameters ` of generic classes, functions, and :" "ref:`type aliases `. For classes and functions that are not " "generic, this will be an empty tuple." msgstr "" +"ジェネリッククラスや関数、および :ref:`型エイリアス ` の :ref:`" +"型パラメータ `。\n" +"ジェネリックでないクラスや関数では空のタプルになります。" #: ../../builtins/stdtypes.rst:6804 msgid "Integer string conversion length limitation" @@ -10319,7 +11466,6 @@ msgstr "" "に *のみ* 適用されます。16進数、8進数と2進数は制限がありません。上限値は設定" "できます。" -#: ../../builtins/stdtypes.rst:6811 msgid "" "The :class:`int` type in CPython is an arbitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -10328,13 +11474,13 @@ msgid "" "algorithms for base 10 have sub-quadratic complexity. Converting a large " "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -"CPython の :class:`int` 型は、任意の長さの数をバイナリ形式で保存したものです " -"(一般に \"bignum\" または多倍長整数として知られています)。基数が2のべき乗でな" -"い限り、線形の時間で文字列をバイナリ整数に、あるいはバイナリ整数を文字列に変" -"換できるアルゴリズムは存在しません。10進数に対するアルゴリズムでは、最もよく" -"知られているものでさえ、2次に近い (sub-quadratic) 複雑さになります。高速な " -"CPU でも、 ``int('1' * 500_000)`` のような大きな数の変換は1秒以上かかる可能性" -"があります。" +"CPython の :class:`int` 型は、任意の長さの数を2進形式で格納します (一般に" +"「bignum」と呼ばれます)。\n" +"基数が2のべき乗でない限り、文字列と2進整数を線形時間で相互変換できるアルゴリ" +"ズムは存在しません。\n" +"10進数に対する既知の最良のアルゴリズムでも、計算量は二次未満です。\n" +"``int('1' * 500_000)`` のような大きな値の変換には、高速な CPU でも1秒を超える" +"時間が掛かる場合があります。" #: ../../builtins/stdtypes.rst:6818 msgid "" @@ -10357,7 +11503,6 @@ msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "演算の結果が制限を超えると、:exc:`ValueError` が送出されます:" -#: ../../builtins/stdtypes.rst:6826 msgid "" ">>> import sys\n" ">>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.\n" @@ -10380,6 +11525,26 @@ msgid "" "7144\n" ">>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited." msgstr "" +">>> import sys\n" +">>> sys.set_int_max_str_digits(4300) # 例示用。これはデフォルト値。\n" +">>> _ = int('2' * 5432)\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Exceeds the limit (4300 digits) for integer string conversion: " +"value has 5432 digits; use sys.set_int_max_str_digits() to increase the " +"limit\n" +">>> i = int('2' * 4300)\n" +">>> len(str(i))\n" +"4300\n" +">>> i_squared = i*i\n" +">>> len(str(i_squared))\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Exceeds the limit (4300 digits) for integer string conversion; " +"use sys.set_int_max_str_digits() to increase the limit\n" +">>> len(hex(i_squared))\n" +"7144\n" +">>> assert int(hex(i_squared), base=16) == i*i # 16進数は制限されない。" #: ../../builtins/stdtypes.rst:6846 msgid "" @@ -10397,7 +11562,6 @@ msgstr "" msgid "Verification:" msgstr "確認:" -#: ../../builtins/stdtypes.rst:6853 msgid "" ">>> import sys\n" ">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" @@ -10407,6 +11571,13 @@ msgid "" "... '571186405732').to_bytes(53, 'big')\n" "..." msgstr "" +">>> import sys\n" +">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" +">>> assert sys.int_info.str_digits_check_threshold == 640, sys.int_info\n" +">>> msg = int('578966293710682886880994035146873798396722250538762761564'\n" +"... '9252925514383915483333812743580549779436104706260696366600'\n" +"... '571186405732').to_bytes(53, 'big')\n" +"..." #: ../../builtins/stdtypes.rst:6866 msgid "Affected APIs" @@ -10436,13 +11607,12 @@ msgstr "``str(integer)``" msgid "``repr(integer)``." msgstr "``repr(integer)``" -#: ../../builtins/stdtypes.rst:6875 msgid "" "any other string conversion to base 10, for example ``f\"{integer}\"``, " "``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" "他の10進数での文字列変換。たとえば ``f\"{integer}\"``、``\"{}\"." -"format(integer)`` や ``b\"%d\" % integer``。 " +"format(integer)`` や ``b\"%d\" % integer``。" #: ../../builtins/stdtypes.rst:6878 msgid "The limitations do not apply to functions with a linear algorithm:" @@ -10557,7 +11727,6 @@ msgstr "" ":data:`sys.int_info.str_digits_check_threshold ` は上限値として" "指定できる最低の値です(0の場合は無効になります)。" -#: ../../builtins/stdtypes.rst:6922 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -10568,14 +11737,15 @@ msgid "" "exist for the code. A workaround for source that contains such large " "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -"小さな上限値を設定することで、問題が起きる *可能性があります* 。まれではあり" -"ますが、ソースコード内で閾値を超える定数が10進数の整数として存在するコードが" -"存在します。値に制限をつけることの帰結は、10進数の整数リテラルで制限を超える" -"長さを持つ定数を含むコードのパース時、すなわち通常は起動時、モジュールのイン" -"ポート時、またはインストール時など、そのコードのための ``.pyc`` ファイルが作" -"られるまでのどこかの時点でのエラーです。大きな定数を含むソースコードに対する" -"回避策は、その定数を、 ``0x`` を使って値の制限を持たない16進数の値に変換する" -"ことです。" +"小さな上限値を設定すると、問題が起きる *可能性があります* 。\n" +"まれですが、ソース内に最小の閾値を超える10進整数定数を含むコードが存在しま" +"す。\n" +"上限値を設定すると、その上限より長い10進整数リテラルを含む Python ソースコー" +"ドのパース時にエラーが発生します。\n" +"これは、通常は起動時やインポート時、場合によってはインストール時など、その" +"コードに対応する最新の ``.pyc`` がまだ存在しないときに起こります。\n" +"このような大きな定数を含むソースでは、制限のない ``0x`` 形式の16進数へ定数を" +"変換することで回避できます。" #: ../../builtins/stdtypes.rst:6931 msgid "" @@ -10611,7 +11781,6 @@ msgstr "" msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../builtins/stdtypes.rst:6946 msgid "" ">>> import sys\n" ">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" @@ -10623,6 +11792,15 @@ msgid "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" msgstr "" +">>> import sys\n" +">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" +"... upper_bound = 68000\n" +"... lower_bound = 4004\n" +"... current_limit = sys.get_int_max_str_digits()\n" +"... if current_limit == 0 or current_limit > upper_bound:\n" +"... sys.set_int_max_str_digits(upper_bound)\n" +"... elif current_limit < lower_bound:\n" +"... sys.set_int_max_str_digits(lower_bound)" #: ../../builtins/stdtypes.rst:6956 msgid "If you need to disable it entirely, set it to ``0``." @@ -10648,11 +11826,10 @@ msgstr "" "この結果として、リスト ``[1, 2]`` は ``[1.0, 2.0]`` と等しいと見なされます。" "タプルの場合も同様です。" -#: ../../builtins/stdtypes.rst:6967 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -"パーザが演算対象の型を識別できるようにするために、このような優先順位でなけれ" -"ばならないのです。" +"パーザはオペランドの型を判別できないため、これらの演算子の優先順位は対応する" +"数値演算子と同じでなければなりません。" #: ../../builtins/stdtypes.rst:6969 msgid "" @@ -10895,9 +12072,8 @@ msgstr "16進数" msgid "octal" msgstr "8進数" -#: ../../builtins/stdtypes.rst:231 msgid "binary" -msgstr "2進数" +msgstr "二項" #: ../../builtins/stdtypes.rst:251 msgid "arithmetic" @@ -11084,13 +12260,11 @@ msgstr "StopIteration" msgid "GeneratorExit" msgstr "GeneratorExit" -#: ../../builtins/stdtypes.rst:1129 msgid "asynchronous-generator" -msgstr "" +msgstr "非同期ジェネレータ" -#: ../../builtins/stdtypes.rst:1139 msgid "StopAsyncIteration" -msgstr "" +msgstr "StopAsyncIteration" #: ../../builtins/stdtypes.rst:1276 ../../builtins/stdtypes.rst:5613 msgid "len" @@ -11233,49 +12407,39 @@ msgstr "universal newlines" msgid "str.splitlines method" msgstr "str.splitlines メソッド" -#: ../../builtins/stdtypes.rst:3202 msgid "! formatted string literal" -msgstr "" +msgstr "! フォーマット済み文字列リテラル" -#: ../../builtins/stdtypes.rst:3202 msgid "formatted string literals" -msgstr "" +msgstr "フォーマット済み文字列リテラル" -#: ../../builtins/stdtypes.rst:3202 msgid "! f-string" -msgstr "" +msgstr "! f-string" -#: ../../builtins/stdtypes.rst:3202 msgid "f-strings" -msgstr "" +msgstr "f-strings" -#: ../../builtins/stdtypes.rst:3202 msgid "fstring" -msgstr "" +msgstr "fstring" -#: ../../builtins/stdtypes.rst:3202 msgid "interpolated string literal" -msgstr "" +msgstr "補間文字列リテラル" -#: ../../builtins/stdtypes.rst:3202 msgid "formatted literal" -msgstr "" +msgstr "フォーマット済みリテラル" -#: ../../builtins/stdtypes.rst:3202 msgid "interpolated literal" -msgstr "" +msgstr "補間リテラル" #: ../../builtins/stdtypes.rst:3202 msgid "{} (curly brackets)" msgstr "{} (波括弧)" -#: ../../builtins/stdtypes.rst:3202 msgid "in formatted string literal" -msgstr "" +msgstr "フォーマット済み文字列リテラル内" -#: ../../builtins/stdtypes.rst:3202 msgid "! (exclamation mark)" -msgstr "" +msgstr "! (感嘆符)" #: ../../builtins/stdtypes.rst:3202 msgid ": (colon)" @@ -11285,9 +12449,8 @@ msgstr ": (コロン)" msgid "= (equals)" msgstr "= (等号)" -#: ../../builtins/stdtypes.rst:3202 msgid "for help in debugging using string literals" -msgstr "" +msgstr "文字列リテラルを使ったデバッグの補助" #: ../../builtins/stdtypes.rst:3374 msgid "formatting, string (%)" @@ -11400,7 +12563,7 @@ msgstr "コンテキスト管理" #: ../../builtins/stdtypes.rst:6140 msgid "annotation" -msgstr "注釈" +msgstr "annotation" #: ../../builtins/stdtypes.rst:6140 msgid "type annotation; type hint" diff --git a/builtins/threadsafety.po b/builtins/threadsafety.po index bd1b17464..c9a8dd632 100644 --- a/builtins/threadsafety.po +++ b/builtins/threadsafety.po @@ -12,65 +12,71 @@ msgstr "" "PO-Revision-Date: 2026-09-13 17:09+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../builtins/threadsafety.rst:5 msgid "Thread Safety Guarantees" -msgstr "" +msgstr "スレッドセーフ性の保証" -#: ../../builtins/threadsafety.rst:7 msgid "" "This page documents thread-safety guarantees for built-in types in Python's " "free-threaded build. The guarantees described here apply when using Python " "with the :term:`GIL` disabled (free-threaded mode). When the GIL is enabled, " "most operations are implicitly serialized." msgstr "" +"このページでは、Python のフリースレッドビルドにおける組み込み型のスレッドセー" +"フ性の保証を説明します。\n" +"ここで説明する保証は、:term:`GIL` を無効にして Python を使う場合 (フリース" +"レッドモード) に適用されます。\n" +"GIL が有効な場合、ほとんどの操作は暗黙に直列化されます。" -#: ../../builtins/threadsafety.rst:12 msgid "" "For general guidance on writing thread-safe code in free-threaded Python, " "see :ref:`freethreading-python-howto`." msgstr "" +"フリースレッドの Python でスレッドセーフなコードを書くための一般的な指針は、:" +"ref:`freethreading-python-howto` を参照してください。" -#: ../../builtins/threadsafety.rst:19 msgid "Thread safety levels" -msgstr "" +msgstr "スレッドセーフ性のレベル" -#: ../../builtins/threadsafety.rst:21 msgid "" "The C API documentation uses the following levels to describe the thread " "safety guarantees of each function. The levels are listed from least to most " "safe." msgstr "" +"C API のドキュメントでは、各関数のスレッドセーフ性の保証を次のレベルで表しま" +"す。\n" +"安全性の低いものから高いものの順に示します。" -#: ../../builtins/threadsafety.rst:28 msgid "Incompatible" -msgstr "" +msgstr "並行使用不可 (Incompatible)" -#: ../../builtins/threadsafety.rst:30 msgid "" "A function or operation that cannot be made safe for concurrent use even " "with external synchronization. Incompatible code typically accesses global " "state in an unsynchronized way and must only be called from a single thread " "throughout the program's lifetime." msgstr "" +"外部で同期しても、安全に並行使用できない関数や操作です。\n" +"このレベルのコードは通常、同期せずにグローバル状態へアクセスするため、プログ" +"ラムの存続期間を通して、単一のスレッドからだけ呼び出さなければなりません。" -#: ../../builtins/threadsafety.rst:35 msgid "" "Example: a function that modifies process-wide state such as signal handlers " "or environment variables, where concurrent calls from any threads, even with " "external locking, can conflict with the runtime or other libraries." msgstr "" +"例: シグナルハンドラや環境変数など、プロセス全体の状態を変更する関数です。\n" +"外部でロックを取得していても、複数のスレッドからの並行呼び出しが、ランタイム" +"やほかのライブラリと競合する可能性があります。" -#: ../../builtins/threadsafety.rst:42 msgid "Compatible" -msgstr "" +msgstr "外部同期により並行使用可能 (Compatible)" -#: ../../builtins/threadsafety.rst:44 msgid "" "A function or operation that is safe to call from multiple threads " "*provided* the caller supplies appropriate external synchronization, for " @@ -78,19 +84,25 @@ msgid "" "such synchronization, concurrent calls may produce :term:`race conditions " "` or :term:`data races `." msgstr "" +"呼び出し側が外部で適切に同期する *ことを条件に*、複数のスレッドから安全に呼び" +"出せる関数や操作です。\n" +"たとえば、呼び出しのたびに、呼び出しが続く間 :term:`ロック ` を保持して" +"同期します。\n" +"こうした同期がないと、並行呼び出しによって :term:`競合状態 ` " +"や :term:`データ競合 ` が発生する可能性があります。" -#: ../../builtins/threadsafety.rst:50 msgid "" "Example: a function that reads from or writes to an object whose internal " "state is not protected by a lock. Callers must ensure that no two threads " "access the same object at the same time." msgstr "" +"例: 内部状態がロックで保護されていないオブジェクトを読み書きする関数です。\n" +"呼び出し側は、二つのスレッドが同じオブジェクトに同時にアクセスしないことを保" +"証しなければなりません。" -#: ../../builtins/threadsafety.rst:57 msgid "Safe on distinct objects" -msgstr "" +msgstr "異なるオブジェクトなら安全" -#: ../../builtins/threadsafety.rst:59 msgid "" "A function or operation that is safe to call from multiple threads without " "external synchronization, as long as each thread operates on a **different** " @@ -98,20 +110,26 @@ msgid "" "not pass the same object (or objects that share underlying state) as " "arguments." msgstr "" +"各スレッドが **異なる** オブジェクトを操作する限り、外部で同期せずに複数のス" +"レッドから安全に呼び出せる関数や操作です。\n" +"二つのスレッドが同時にこの関数を呼び出してもかまいませんが、同じオブジェクト " +"(または内部の状態を共有するオブジェクト) を引数に渡してはなりません。" -#: ../../builtins/threadsafety.rst:65 msgid "" "Example: a function that modifies fields of a struct using non-atomic " "writes. Two threads can each call the function on their own struct instance " "safely, but concurrent calls on the *same* instance require external " "synchronization." msgstr "" +"例: アトミックでない書き込みを使って、構造体のフィールドを変更する関数で" +"す。\n" +"二つのスレッドがそれぞれ自分の構造体インスタンスに対してこの関数を呼び出すの" +"は安全ですが、*同じ* インスタンスに対する並行呼び出しには、外部での同期が必要" +"です。" -#: ../../builtins/threadsafety.rst:73 msgid "Safe on shared objects" -msgstr "" +msgstr "共有オブジェクトでも安全" -#: ../../builtins/threadsafety.rst:75 msgid "" "A function or operation that is safe for concurrent use on the **same** " "object. The implementation uses internal synchronization (such as :term:`per-" @@ -119,6 +137,11 @@ msgid "" "section-api>`) to protect shared mutable state, so callers do not need to " "supply their own locking." msgstr "" +"**同じ** オブジェクトに対して安全に並行使用できる関数や操作です。\n" +"実装が内部で同期 (:term:`オブジェクトごとのロック ` や :ref:" +"`クリティカルセクション ` など) を行って共有され" +"た可変の状態を保護するため、呼び出し側で独自にロックを用意する必要はありませ" +"ん。" #: ../../builtins/threadsafety.rst:81 msgid "" @@ -127,50 +150,56 @@ msgid "" "serialize access." msgstr "" -#: ../../builtins/threadsafety.rst:88 msgid "Atomic" -msgstr "" +msgstr "アトミック" -#: ../../builtins/threadsafety.rst:90 msgid "" "A function or operation that appears :term:`atomic ` with " "respect to other threads - it executes instantaneously from the perspective " "of other threads. This is the strongest form of thread safety." msgstr "" +"ほかのスレッドから見ると :term:`アトミック ` に実行される関" +"数や操作です。\n" +"つまり、ほかのスレッドの視点では、一瞬で実行されるように見えます。\n" +"これはスレッドセーフ性の最も強い保証です。" -#: ../../builtins/threadsafety.rst:94 msgid "" "Example: :c:func:`PyMutex_IsLocked` performs an atomic read of the mutex " "state and can be called from any thread at any time." msgstr "" +"例: :c:func:`PyMutex_IsLocked` はミューテックスの状態をアトミックに読み取り、" +"どのスレッドからでも、いつでも呼び出せます。" -#: ../../builtins/threadsafety.rst:101 msgid "Thread safety for list objects" -msgstr "" +msgstr "``list`` オブジェクトのスレッドセーフ性" -#: ../../builtins/threadsafety.rst:103 msgid "" "Reading a single element from a :class:`list` is :term:`atomic `:" msgstr "" +":class:`list` からの単一要素の読み取りは :term:`アトミック ` です。" -#: ../../builtins/threadsafety.rst:106 msgid "lst[i] # list.__getitem__" -msgstr "" +msgstr "lst[i] # list.__getitem__" -#: ../../builtins/threadsafety.rst:111 msgid "" "The following methods traverse the list and use :term:`atomic ` reads of each item to perform their function. That means that " "they may return results affected by concurrent modifications:" msgstr "" +"次のメソッドはリストを走査し、各要素を :term:`アトミック ` " +"に読み取って処理を行います。\n" +"そのため、並行して行われる変更の影響を受けた結果を返すことがあります。" -#: ../../builtins/threadsafety.rst:115 msgid "" "item in lst\n" "lst.index(item)\n" "lst.count(item)" msgstr "" +"item in lst\n" +"lst.index(item)\n" +"lst.count(item)" #: ../../builtins/threadsafety.rst:122 msgid "" @@ -179,76 +208,92 @@ msgid "" "that hold a lock will not block these from observing intermediate states." msgstr "" -#: ../../builtins/threadsafety.rst:127 msgid "" "All other operations from here on block using the :term:`per-object lock`." msgstr "" +"これ以降のほかの操作はすべて、:term:`オブジェクトごとのロック ` を使ってブロックします。" -#: ../../builtins/threadsafety.rst:129 msgid "" "Writing a single item via ``lst[i] = x`` is safe to call from multiple " "threads and will not corrupt the list." msgstr "" +"``lst[i] = x`` による単一要素の書き込みは、複数のスレッドから安全に実行でき、" +"リストを破損させません。" -#: ../../builtins/threadsafety.rst:132 msgid "" "The following operations return new objects and appear :term:`atomic ` to other threads:" msgstr "" +"次の操作は新しいオブジェクトを返し、ほかのスレッドから見ると :term:`アトミッ" +"ク ` に実行されます。" -#: ../../builtins/threadsafety.rst:135 msgid "" "lst1 + lst2 # concatenates two lists into a new list\n" "x * lst # repeats lst x times into a new list\n" "lst.copy() # returns a shallow copy of the list" msgstr "" +"lst1 + lst2 # 二つのリストを結合して新しいリストを作成する\n" +"x * lst # lst を x 回繰り返して新しいリストを作成する\n" +"lst.copy() # リストの浅いコピーを返す" -#: ../../builtins/threadsafety.rst:142 msgid "" "The following methods that only operate on a single element with no shifting " "required are :term:`atomic `:" msgstr "" +"次のメソッドは、要素をずらす必要がなく、単一の要素だけを操作するため、:term:`" +"アトミック ` です。" -#: ../../builtins/threadsafety.rst:145 msgid "" "lst.append(x) # append to the end of the list, no shifting required\n" "lst.pop() # pop element from the end of the list, no shifting required" msgstr "" +"lst.append(x) # リストの末尾に追加するため、要素をずらす必要はない\n" +"lst.pop() # リストの末尾の要素を取り出して削除するため、要素をずらす必要" +"はない" -#: ../../builtins/threadsafety.rst:151 msgid "" "The :meth:`~list.clear` method is also :term:`atomic `. " "Other threads cannot observe elements being removed." msgstr "" +":meth:`~list.clear` メソッドも :term:`アトミック ` です。\n" +"ほかのスレッドから、要素が削除されていく途中の状態は観測できません。" -#: ../../builtins/threadsafety.rst:154 msgid "" "The :meth:`~list.sort` method is not :term:`atomic `. " "Other threads cannot observe intermediate states during sorting, but the " "list appears empty for the duration of the sort." msgstr "" +":meth:`~list.sort` メソッドは :term:`アトミック ` ではあり" +"ません。\n" +"ほかのスレッドからソート途中の状態は観測できませんが、ソート中のリストは空に" +"見えます。" -#: ../../builtins/threadsafety.rst:158 msgid "" "The following operations may allow :term:`lock-free` operations to observe " "intermediate states since they modify multiple elements in place:" msgstr "" +"次の操作は複数の要素をその場で変更するため、:term:`ロックフリーな ` 操作から途中の状態が観測されることがあります。" -#: ../../builtins/threadsafety.rst:161 msgid "" "lst.insert(idx, item) # shifts elements\n" "lst.pop(idx) # idx not at the end of the list, shifts elements\n" "lst *= x # copies elements in place" msgstr "" +"lst.insert(idx, item) # 要素をずらす\n" +"lst.pop(idx) # idx がリストの末尾でなければ、要素をずらす\n" +"lst *= x # 要素をその場でコピーする" -#: ../../builtins/threadsafety.rst:168 msgid "" "The :meth:`~list.remove` method may allow concurrent modifications since " "element comparison may execute arbitrary Python code (via :meth:`~object." "__eq__`)." msgstr "" +"要素の比較で (:meth:`~object.__eq__` を通じて) 任意の Python コードを実行する" +"可能性があるため、:meth:`~list.remove` メソッドの実行中に並行して変更が行われ" +"ることがあります。" -#: ../../builtins/threadsafety.rst:172 msgid "" ":meth:`~list.extend` is safe to call from multiple threads. However, its " "guarantees depend on the iterable passed to it. If it is a :class:`list`, a :" @@ -259,21 +304,33 @@ msgid "" "another thread. The same applies to inplace concatenation of a list with " "other iterables when using ``lst += iterable``." msgstr "" +":meth:`~list.extend` は複数のスレッドから安全に呼び出せます。\n" +"ただし、その保証は渡されたイテラブルによって異なります。\n" +"渡されたイテラブルが :class:`list`、:class:`tuple`、:class:`set`、:class:" +"`frozenset`、:class:`dict`、:ref:`辞書ビューオブジェクト ` のいず" +"れか (サブクラスは除く) である場合、``extend`` 操作はそのイテラブルに対する並" +"行変更から保護されます。\n" +"それ以外の場合は、ほかのスレッドによって並行して変更される可能性があるイテ" +"レータが作成されます。\n" +"``lst += iterable`` を使ってリストとほかのイテラブルをインプレースに結合する" +"場合も、同じことが当てはまります。" -#: ../../builtins/threadsafety.rst:181 msgid "" "Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe to " "call from multiple threads, but ``iterable`` is only locked when it is also " "a :class:`list` (but not its subclasses)." msgstr "" +"同様に、``lst[i:j] = iterable`` によるリストのスライスへの代入も、複数のス" +"レッドから安全に実行できますが、``iterable`` がロックされるのは、" +"``iterable`` も :class:`list` (サブクラスは除く) である場合だけです。" -#: ../../builtins/threadsafety.rst:185 msgid "" "Operations that involve multiple accesses, as well as iteration, are never " "atomic. For example:" msgstr "" +"複数回のアクセスを伴う操作やイテレーションは、アトミックではありません。\n" +"たとえば、次のような操作です。" -#: ../../builtins/threadsafety.rst:188 msgid "" "# NOT atomic: read-modify-write\n" "lst[i] = lst[i] + 1\n" @@ -286,16 +343,26 @@ msgid "" "for item in lst:\n" " process(item) # another thread may modify lst" msgstr "" +"# アトミックではない: 読み取り、変更、書き込み\n" +"lst[i] = lst[i] + 1\n" +"\n" +"# アトミックではない: 確認してから実行\n" +"if lst:\n" +" item = lst.pop()\n" +"\n" +"# スレッドセーフではない: 変更中のイテレーション\n" +"for item in lst:\n" +" process(item) # ほかのスレッドが lst を変更する可能性がある" -#: ../../builtins/threadsafety.rst:202 msgid "" "Consider external synchronization when sharing :class:`list` instances " "across threads." msgstr "" +"スレッド間で :class:`list` インスタンスを共有する場合は、外部での同期を検討し" +"てください。" -#: ../../builtins/threadsafety.rst:209 msgid "Thread safety for dict objects" -msgstr "" +msgstr "``dict`` オブジェクトのスレッドセーフ性" #: ../../builtins/threadsafety.rst:211 msgid "" @@ -311,25 +378,28 @@ msgid "" "`atomic `." msgstr "" -#: ../../builtins/threadsafety.rst:220 msgid "" "d[key] # dict.__getitem__\n" "d.get(key) # dict.get\n" "key in d # dict.__contains__\n" "len(d) # dict.__len__" msgstr "" +"d[key] # dict.__getitem__\n" +"d.get(key) # dict.get\n" +"key in d # dict.__contains__\n" +"len(d) # dict.__len__" #: ../../builtins/threadsafety.rst:228 msgid "All other operations from here on hold the :term:`per-object lock`." msgstr "" -#: ../../builtins/threadsafety.rst:230 msgid "" "Writing or removing a single item is safe to call from multiple threads and " "will not corrupt the dictionary:" msgstr "" +"単一の要素の書き込みや削除は、複数のスレッドから安全に実行でき、辞書を破損さ" +"せません。" -#: ../../builtins/threadsafety.rst:233 msgid "" "d[key] = value # write\n" "del d[key] # delete\n" @@ -337,8 +407,12 @@ msgid "" "d.popitem() # remove and return last item\n" "d.setdefault(key, v) # insert if missing" msgstr "" +"d[key] = value # 書き込む\n" +"del d[key] # 削除する\n" +"d.pop(key) # 削除して返す\n" +"d.popitem() # 最後の要素を削除して返す\n" +"d.setdefault(key, v) # 存在しなければ挿入する" -#: ../../builtins/threadsafety.rst:242 msgid "" "These operations may compare keys using :meth:`~object.__eq__`, which can " "execute arbitrary Python code. During such comparisons, the dictionary may " @@ -346,6 +420,12 @@ msgid "" "`int`, and :class:`float`, that implement :meth:`~object.__eq__` in C, the " "underlying lock is not released during comparisons and this is not a concern." msgstr "" +"これらの操作は :meth:`~object.__eq__` を使ってキーを比較することがあり、その" +"際に任意の Python コードを実行する可能性があります。\n" +"このような比較中に、ほかのスレッドが辞書を変更する可能性があります。\n" +":meth:`~object.__eq__` を C で実装している :class:`str`、:class:`int`、:" +"class:`float` などの組み込み型では、比較中に内部のロックを解放しないため、こ" +"の心配はありません。" #: ../../builtins/threadsafety.rst:249 msgid "" @@ -353,7 +433,6 @@ msgid "" "lock` for the duration of the operation:" msgstr "" -#: ../../builtins/threadsafety.rst:252 msgid "" "d.copy() # returns a shallow copy of the dictionary\n" "d | other # merges two dicts into a new dict\n" @@ -361,14 +440,19 @@ msgid "" "d.values() # returns a new dict_values view object\n" "d.items() # returns a new dict_items view object" msgstr "" +"d.copy() # 辞書の浅いコピーを返す\n" +"d | other # 二つの辞書をマージして新しい辞書を作成する\n" +"d.keys() # 新しい dict_keys ビューオブジェクトを返す\n" +"d.values() # 新しい dict_values ビューオブジェクトを返す\n" +"d.items() # 新しい dict_items ビューオブジェクトを返す" -#: ../../builtins/threadsafety.rst:261 msgid "" "The :meth:`~dict.clear` method holds the lock for its duration. Other " "threads cannot observe elements being removed." msgstr "" +":meth:`~dict.clear` メソッドは、処理中ずっとロックを保持します。\n" +"ほかのスレッドから、要素が削除されていく途中の状態は観測できません。" -#: ../../builtins/threadsafety.rst:264 msgid "" "The following operations lock both dictionaries. For :meth:`~dict.update` " "and ``|=``, this applies only when the other operand is a :class:`dict` that " @@ -376,56 +460,70 @@ msgid "" "iteration). For equality comparison, this applies to :class:`dict` and its " "subclasses:" msgstr "" +"次の操作は両方の辞書をロックします。\n" +":meth:`~dict.update` と ``|=`` では、もう一方のオペランドが標準の辞書イテレー" +"タを使う :class:`dict` である場合だけ、この保証が適用されます (イテレーション" +"をオーバーライドするサブクラスは除きます)。\n" +"等値比較では、:class:`dict` とそのサブクラスにこの保証が適用されます。" -#: ../../builtins/threadsafety.rst:270 msgid "" "d.update(other_dict) # both locked when other_dict is a dict\n" "d |= other_dict # both locked when other_dict is a dict\n" "d == other_dict # both locked for dict and subclasses" msgstr "" +"d.update(other_dict) # other_dict が dict の場合は両方をロックする\n" +"d |= other_dict # other_dict が dict の場合は両方をロックする\n" +"d == other_dict # dict とそのサブクラスの場合は両方をロックする" -#: ../../builtins/threadsafety.rst:277 msgid "" "All comparison operations also compare values using :meth:`~object.__eq__`, " "so for non-built-in types the lock may be released during comparison." msgstr "" +"比較操作はすべて、値の比較にも :meth:`~object.__eq__` を使うため、組み込み型" +"でない場合は比較中にロックを解放することがあります。" -#: ../../builtins/threadsafety.rst:280 msgid "" ":meth:`~dict.fromkeys` locks both the new dictionary and the iterable when " "the iterable is exactly a :class:`dict`, :class:`set`, or :class:`frozenset` " "(not subclasses):" msgstr "" +"イテラブルが :class:`dict`、:class:`set`、:class:`frozenset` そのもの (サブク" +"ラスは除く) である場合、:meth:`~dict.fromkeys` は新しい辞書とそのイテラブルの" +"両方をロックします。" -#: ../../builtins/threadsafety.rst:284 msgid "" "dict.fromkeys(a_dict) # locks both\n" "dict.fromkeys(a_set) # locks both\n" "dict.fromkeys(a_frozenset) # locks both" msgstr "" +"dict.fromkeys(a_dict) # 両方をロックする\n" +"dict.fromkeys(a_set) # 両方をロックする\n" +"dict.fromkeys(a_frozenset) # 両方をロックする" -#: ../../builtins/threadsafety.rst:291 msgid "" "When updating from a non-dict iterable, only the target dictionary is " "locked. The iterable may be concurrently modified by another thread:" msgstr "" +"辞書ではないイテラブルから更新する場合、更新先の辞書だけをロックします。\n" +"イテラブルは、ほかのスレッドによって並行して変更される可能性があります。" -#: ../../builtins/threadsafety.rst:294 msgid "" "d.update(iterable) # iterable is not a dict: only d locked\n" "d |= iterable # iterable is not a dict: only d locked\n" "dict.fromkeys(iterable) # iterable is not a dict/set/frozenset: only " "result locked" msgstr "" +"d.update(iterable) # iterable が dict ではない: d だけをロックする\n" +"d |= iterable # iterable が dict ではない: d だけをロックする\n" +"dict.fromkeys(iterable) # iterable が dict/set/frozenset ではない: 結果だけ" +"をロックする" -#: ../../builtins/threadsafety.rst:301 ../../builtins/threadsafety.rst:434 -#: ../../builtins/threadsafety.rst:525 msgid "" "Operations that involve multiple accesses, as well as iteration, are never " "atomic:" msgstr "" +"複数回のアクセスを伴う操作やイテレーションは、アトミックではありません。" -#: ../../builtins/threadsafety.rst:304 msgid "" "# NOT atomic: read-modify-write\n" "d[key] = d[key] + 1\n" @@ -438,14 +536,24 @@ msgid "" "for key, value in d.items():\n" " process(key) # another thread may modify d" msgstr "" +"# アトミックではない: 読み取り、変更、書き込み\n" +"d[key] = d[key] + 1\n" +"\n" +"# アトミックではない: 確認してから実行 (TOCTOU)\n" +"if key in d:\n" +" del d[key]\n" +"\n" +"# スレッドセーフではない: 変更中のイテレーション\n" +"for key, value in d.items():\n" +" process(key) # ほかのスレッドが d を変更する可能性がある" -#: ../../builtins/threadsafety.rst:318 msgid "" "To avoid time-of-check to time-of-use (TOCTOU) issues, use atomic operations " "or handle exceptions:" msgstr "" +"確認から使用までの間に状態が変わる問題 (TOCTOU: time-of-check to time-of-" +"use) を避けるには、アトミックな操作を使うか、例外を処理してください。" -#: ../../builtins/threadsafety.rst:321 msgid "" "# Use pop() with default instead of check-then-delete\n" "d.pop(key, None)\n" @@ -456,34 +564,46 @@ msgid "" "except KeyError:\n" " pass" msgstr "" +"# 確認してから削除する代わりに、デフォルト値付きの pop() を使う\n" +"d.pop(key, None)\n" +"\n" +"# または例外を処理する\n" +"try:\n" +" del d[key]\n" +"except KeyError:\n" +" pass" -#: ../../builtins/threadsafety.rst:333 msgid "" "To safely iterate over a dictionary that may be modified by another thread, " "iterate over a copy:" msgstr "" +"ほかのスレッドによって変更される可能性のある辞書を安全にイテレートするには、" +"コピーをイテレートしてください。" -#: ../../builtins/threadsafety.rst:336 msgid "" "# Make a copy to iterate safely\n" "for key, value in d.copy().items():\n" " process(key)" msgstr "" +"# 安全にイテレートするためにコピーを作成する\n" +"for key, value in d.copy().items():\n" +" process(key)" -#: ../../builtins/threadsafety.rst:343 msgid "" "Consider external synchronization when sharing :class:`dict` instances " "across threads." msgstr "" +"スレッド間で :class:`dict` インスタンスを共有する場合は、外部での同期を検討し" +"てください。" -#: ../../builtins/threadsafety.rst:350 msgid "Thread safety for set objects" -msgstr "" +msgstr "``set`` オブジェクトのスレッドセーフ性" -#: ../../builtins/threadsafety.rst:352 ../../builtins/threadsafety.rst:457 msgid "" "The :func:`len` function is lock-free and :term:`atomic `." msgstr "" +":func:`len` 関数はロックフリーで、:term:`アトミック ` で" +"す。" #: ../../builtins/threadsafety.rst:354 msgid "" @@ -492,9 +612,8 @@ msgid "" "the per-object lock:" msgstr "" -#: ../../builtins/threadsafety.rst:358 msgid "elem in s # set.__contains__" -msgstr "" +msgstr "elem in s # set.__contains__" #: ../../builtins/threadsafety.rst:363 msgid "" @@ -505,41 +624,47 @@ msgid "" "lock during comparisons and this is not a concern." msgstr "" -#: ../../builtins/threadsafety.rst:369 ../../builtins/threadsafety.rst:470 msgid "All other operations from here on hold the per-object lock." -msgstr "" +msgstr "これ以降のほかの操作はすべて、オブジェクトごとのロックを保持します。" -#: ../../builtins/threadsafety.rst:371 msgid "" "Adding or removing a single element is safe to call from multiple threads " "and will not corrupt the set:" msgstr "" +"単一の要素の追加や削除は、複数のスレッドから安全に実行でき、集合を破損させま" +"せん。" -#: ../../builtins/threadsafety.rst:374 msgid "" "s.add(elem) # add element\n" "s.remove(elem) # remove element, raise if missing\n" "s.discard(elem) # remove element if present\n" "s.pop() # remove and return arbitrary element" msgstr "" +"s.add(elem) # 要素を追加する\n" +"s.remove(elem) # 要素を削除し、存在しなければ例外を送出する\n" +"s.discard(elem) # 要素が存在すれば削除する\n" +"s.pop() # 任意の要素を削除して返す" -#: ../../builtins/threadsafety.rst:382 msgid "" "These operations also compare elements, so the same :meth:`~object.__eq__` " "considerations as above apply." msgstr "" +"これらの操作も要素を比較するため、:meth:`~object.__eq__` についての上記と同じ" +"注意事項が当てはまります。" -#: ../../builtins/threadsafety.rst:385 msgid "" "The :meth:`~set.copy` method returns a new object and holds the per-object " "lock for the duration so that it is always atomic." msgstr "" +":meth:`~set.copy` メソッドは新しいオブジェクトを返し、処理中ずっとオブジェク" +"トごとのロックを保持するため、常にアトミックです。" -#: ../../builtins/threadsafety.rst:388 msgid "" "The :meth:`~set.clear` method holds the lock for its duration. Other threads " "cannot observe elements being removed." msgstr "" +":meth:`~set.clear` メソッドは、処理中ずっとロックを保持します。\n" +"ほかのスレッドから、要素が削除されていく途中の状態は観測できません。" #: ../../builtins/threadsafety.rst:391 msgid "" @@ -547,7 +672,6 @@ msgid "" "operands and always lock both objects:" msgstr "" -#: ../../builtins/threadsafety.rst:394 msgid "" "s |= other # other must be set/frozenset\n" "s &= other # other must be set/frozenset\n" @@ -558,13 +682,24 @@ msgid "" "s - other # other must be set/frozenset\n" "s ^ other # other must be set/frozenset" msgstr "" +"s |= other # other は set/frozenset でなければならない\n" +"s &= other # other は set/frozenset でなければならない\n" +"s -= other # other は set/frozenset でなければならない\n" +"s ^= other # other は set/frozenset でなければならない\n" +"s & other # other は set/frozenset でなければならない\n" +"s | other # other は set/frozenset でなければならない\n" +"s - other # other は set/frozenset でなければならない\n" +"s ^ other # other は set/frozenset でなければならない" -#: ../../builtins/threadsafety.rst:406 msgid "" ":meth:`set.update`, :meth:`set.union`, :meth:`set.intersection` and :meth:" "`set.difference` can take multiple iterables as arguments. They all iterate " "through all the passed iterables and do the following:" msgstr "" +":meth:`set.update`、:meth:`set.union`、:meth:`set.intersection`、:meth:`set." +"difference` は、引数として複数のイテラブルを受け取れます。\n" +"これらはいずれも、渡されたすべてのイテラブルをイテレートし、次の処理を行いま" +"す。" #: ../../builtins/threadsafety.rst:410 msgid "" @@ -572,46 +707,48 @@ msgid "" "other operand is a :class:`set`, :class:`frozenset`, or :class:`dict`." msgstr "" -#: ../../builtins/threadsafety.rst:412 msgid "" ":meth:`set.intersection` and :meth:`set.difference` always try to lock all " "objects." msgstr "" +":meth:`set.intersection` と :meth:`set.difference` は、常にすべてのオブジェク" +"トのロックを試みます。" -#: ../../builtins/threadsafety.rst:415 msgid ":meth:`set.symmetric_difference` tries to lock both objects." msgstr "" +":meth:`set.symmetric_difference` は両方のオブジェクトのロックを試みます。" -#: ../../builtins/threadsafety.rst:417 msgid "" "The update variants of the above methods also have some differences between " "them:" -msgstr "" +msgstr "上記のメソッドに対応する更新用メソッドにも、次のような違いがあります。" -#: ../../builtins/threadsafety.rst:420 msgid "" ":meth:`set.difference_update` and :meth:`set.intersection_update` try to " "lock all objects one-by-one." msgstr "" +":meth:`set.difference_update` と :meth:`set.intersection_update` は、すべての" +"オブジェクトを一つずつロックしようとします。" -#: ../../builtins/threadsafety.rst:422 msgid "" ":meth:`set.symmetric_difference_update` only locks the arguments if it is of " "type :class:`set`, :class:`frozenset`, or :class:`dict`." msgstr "" +":meth:`set.symmetric_difference_update` は、引数の型が :class:`set`、:class:" +"`frozenset`、:class:`dict` のいずれかである場合だけ、その引数をロックします。" -#: ../../builtins/threadsafety.rst:425 msgid "The following methods always try to lock both objects:" -msgstr "" +msgstr "次のメソッドは、常に両方のオブジェクトのロックを試みます。" -#: ../../builtins/threadsafety.rst:427 msgid "" "s.isdisjoint(other) # both locked\n" "s.issubset(other) # both locked\n" "s.issuperset(other) # both locked" msgstr "" +"s.isdisjoint(other) # 両方をロックする\n" +"s.issubset(other) # 両方をロックする\n" +"s.issuperset(other) # 両方をロックする" -#: ../../builtins/threadsafety.rst:437 msgid "" "# NOT atomic: check-then-act\n" "if elem in s:\n" @@ -621,49 +758,62 @@ msgid "" "for elem in s:\n" " process(elem) # another thread may modify s" msgstr "" +"# アトミックではない: 確認してから実行\n" +"if elem in s:\n" +" s.remove(elem)\n" +"\n" +"# スレッドセーフではない: 変更中のイテレーション\n" +"for elem in s:\n" +" process(elem) # ほかのスレッドが s を変更する可能性がある" -#: ../../builtins/threadsafety.rst:448 msgid "" "Consider external synchronization when sharing :class:`set` instances across " "threads. See :ref:`freethreading-python-howto` for more information." msgstr "" +"スレッド間で :class:`set` インスタンスを共有する場合は、外部での同期を検討し" +"てください。\n" +"詳細については、:ref:`freethreading-python-howto` を参照してください。" -#: ../../builtins/threadsafety.rst:455 msgid "Thread safety for bytearray objects" -msgstr "" +msgstr "``bytearray`` オブジェクトのスレッドセーフ性" -#: ../../builtins/threadsafety.rst:459 msgid "" "Concatenation and comparisons use the buffer protocol, which prevents " "resizing but does not hold the per-object lock. These operations may observe " "intermediate states from concurrent modifications:" msgstr "" +"結合と比較はバッファプロトコルを使います。\n" +"バッファプロトコルはサイズの変更を防ぎますが、オブジェクトごとのロックは保持" +"しません。\n" +"これらの操作は、並行して行われる変更の途中の状態を観測することがあります。" -#: ../../builtins/threadsafety.rst:463 msgid "" "ba + other # may observe concurrent writes\n" "ba == other # may observe concurrent writes\n" "ba < other # may observe concurrent writes" msgstr "" +"ba + other # 並行して行われる書き込みを観測する可能性がある\n" +"ba == other # 並行して行われる書き込みを観測する可能性がある\n" +"ba < other # 並行して行われる書き込みを観測する可能性がある" -#: ../../builtins/threadsafety.rst:472 msgid "" "Reading a single element or slice is safe to call from multiple threads:" msgstr "" +"単一の要素やスライスの読み取りは、複数のスレッドから安全に実行できます。" -#: ../../builtins/threadsafety.rst:474 msgid "" "ba[i] # bytearray.__getitem__\n" "ba[i:j] # slice" msgstr "" +"ba[i] # bytearray.__getitem__\n" +"ba[i:j] # スライス" -#: ../../builtins/threadsafety.rst:480 msgid "" "The following operations are safe to call from multiple threads and will not " "corrupt the bytearray:" msgstr "" +"次の操作は複数のスレッドから安全に実行でき、バイト配列を破損させません。" -#: ../../builtins/threadsafety.rst:483 msgid "" "ba[i] = x # write single byte\n" "ba[i:j] = values # write slice\n" @@ -676,35 +826,45 @@ msgid "" "ba.reverse() # reverse in place\n" "ba.clear() # remove all bytes" msgstr "" +"ba[i] = x # 単一のバイトを書き込む\n" +"ba[i:j] = values # スライスに書き込む\n" +"ba.append(x) # 単一のバイトを末尾に追加する\n" +"ba.extend(other) # イテラブルを使って拡張する\n" +"ba.insert(i, x) # 単一のバイトを挿入する\n" +"ba.pop() # 最後のバイトを削除して返す\n" +"ba.pop(i) # 指定のインデックスのバイトを削除して返す\n" +"ba.remove(x) # 最初に現れた値を削除する\n" +"ba.reverse() # その場で順序を反転する\n" +"ba.clear() # すべてのバイトを削除する" -#: ../../builtins/threadsafety.rst:497 msgid "" "Slice assignment locks both objects when *values* is a :class:`bytearray`:" msgstr "" +"``values`` が :class:`bytearray` の場合、スライスへの代入は両方のオブジェクト" +"をロックします。" -#: ../../builtins/threadsafety.rst:499 msgid "ba[i:j] = other_bytearray # both locked" -msgstr "" +msgstr "ba[i:j] = other_bytearray # 両方をロックする" -#: ../../builtins/threadsafety.rst:504 msgid "" "The following operations return new objects and hold the per-object lock for " "the duration:" msgstr "" +"次の操作は新しいオブジェクトを返し、処理中ずっとオブジェクトごとのロックを保" +"持します。" -#: ../../builtins/threadsafety.rst:507 msgid "" "ba.copy() # returns a shallow copy\n" "ba * n # repeat into new bytearray" msgstr "" +"ba.copy() # 浅いコピーを返す\n" +"ba * n # 繰り返して新しいバイト配列を作成する" -#: ../../builtins/threadsafety.rst:513 msgid "The membership test holds the lock for its duration:" -msgstr "" +msgstr "要素が含まれるかどうかの判定では、処理中ずっとロックを保持します。" -#: ../../builtins/threadsafety.rst:515 msgid "x in ba # bytearray.__contains__" -msgstr "" +msgstr "x in ba # bytearray.__contains__" #: ../../builtins/threadsafety.rst:520 msgid "" @@ -713,7 +873,6 @@ msgid "" "etc.) hold the per-object lock for their duration." msgstr "" -#: ../../builtins/threadsafety.rst:528 msgid "" "# NOT atomic: check-then-act\n" "if x in ba:\n" @@ -723,36 +882,50 @@ msgid "" "for byte in ba:\n" " process(byte) # another thread may modify ba" msgstr "" +"# アトミックではない: 確認してから実行\n" +"if x in ba:\n" +" ba.remove(x)\n" +"\n" +"# スレッドセーフではない: 変更中のイテレーション\n" +"for byte in ba:\n" +" process(byte) # ほかのスレッドが ba を変更する可能性がある" -#: ../../builtins/threadsafety.rst:539 msgid "" "To safely iterate over a bytearray that may be modified by another thread, " "iterate over a copy:" msgstr "" +"ほかのスレッドによって変更される可能性のあるバイト配列を安全にイテレートする" +"には、コピーをイテレートしてください。" -#: ../../builtins/threadsafety.rst:542 msgid "" "# Make a copy to iterate safely\n" "for byte in ba.copy():\n" " process(byte)" msgstr "" +"# 安全にイテレートするためにコピーを作成する\n" +"for byte in ba.copy():\n" +" process(byte)" -#: ../../builtins/threadsafety.rst:549 msgid "" "Consider external synchronization when sharing :class:`bytearray` instances " "across threads. See :ref:`freethreading-python-howto` for more information." msgstr "" +"スレッド間で :class:`bytearray` インスタンスを共有する場合は、外部での同期を" +"検討してください。\n" +"詳細については、:ref:`freethreading-python-howto` を参照してください。" -#: ../../builtins/threadsafety.rst:556 msgid "Thread safety for memoryview objects" -msgstr "" +msgstr "``memoryview`` オブジェクトのスレッドセーフ性" -#: ../../builtins/threadsafety.rst:558 msgid "" ":class:`memoryview` objects provide access to the internal data of an " "underlying object without copying. Thread safety depends on both the " "memoryview itself and the underlying buffer exporter." msgstr "" +":class:`memoryview` オブジェクトは、参照先のオブジェクトの内部データに、コ" +"ピーせずにアクセスする手段を提供します。\n" +"スレッドセーフ性は、メモリービュー自体と、参照先のバッファを提供するオブジェ" +"クトの両方によって決まります。" #: ../../builtins/threadsafety.rst:562 msgid "" @@ -764,20 +937,23 @@ msgid "" "memoryview has not been released." msgstr "" -#: ../../builtins/threadsafety.rst:569 msgid "" "However, the actual data accessed through the memoryview is owned by the " "underlying object. Concurrent access to this data is only safe if the " "underlying object supports it:" msgstr "" +"ただし、メモリービューを通じてアクセスする実際のデータは、参照先のオブジェク" +"トが所有しています。\n" +"このデータへの並行アクセスが安全なのは、参照先のオブジェクトがそれをサポート" +"している場合だけです。" -#: ../../builtins/threadsafety.rst:573 msgid "" "For immutable objects like :class:`bytes`, concurrent reads through multiple " "memoryviews are safe." msgstr "" +":class:`bytes` のような不変のオブジェクトでは、複数のメモリービューを通じて並" +"行して読み取っても安全です。" -#: ../../builtins/threadsafety.rst:576 msgid "" "For mutable objects like :class:`bytearray`, reading and writing the same " "memory region from multiple threads without external synchronization is not " @@ -785,8 +961,13 @@ msgid "" "of mutable objects do not prevent data races if the underlying object is " "modified from another thread." msgstr "" +":class:`bytearray` のような可変のオブジェクトでは、外部で同期せずに、複数のス" +"レッドから同じメモリー領域を読み書きするのは安全ではなく、データの破損を引き" +"起こす可能性があります。\n" +"可変のオブジェクトに対する読み取り専用のメモリービューであっても、ほかのス" +"レッドから参照先のオブジェクトが変更されると、データ競合を防げないことに注意" +"してください。" -#: ../../builtins/threadsafety.rst:583 msgid "" "# NOT safe: concurrent writes to the same buffer\n" "data = bytearray(1000)\n" @@ -794,8 +975,12 @@ msgid "" "# Thread 1: view[0:500] = b'x' * 500\n" "# Thread 2: view[0:500] = b'y' * 500" msgstr "" +"# 安全ではない: 同じバッファへの並行書き込み\n" +"data = bytearray(1000)\n" +"view = memoryview(data)\n" +"# スレッド 1: view[0:500] = b'x' * 500\n" +"# スレッド 2: view[0:500] = b'y' * 500" -#: ../../builtins/threadsafety.rst:592 msgid "" "# Safe: use a lock for concurrent access\n" "import threading\n" @@ -806,10 +991,21 @@ msgid "" "with lock:\n" " view[0:500] = b'x' * 500" msgstr "" +"# 安全: 並行アクセスにはロックを使う\n" +"import threading\n" +"lock = threading.Lock()\n" +"data = bytearray(1000)\n" +"view = memoryview(data)\n" +"\n" +"with lock:\n" +" view[0:500] = b'x' * 500" -#: ../../builtins/threadsafety.rst:604 msgid "" "Resizing or reallocating the underlying object (such as calling :meth:" "`bytearray.resize`) while a memoryview is exported raises :exc:" "`BufferError`. This is enforced regardless of threading." msgstr "" +"メモリービューによってバッファが公開されている間に、参照先のオブジェクトのサ" +"イズを変更したり、メモリーを再割り当てしたりすると (:meth:`bytearray.resize` " +"の呼び出しなど)、:exc:`BufferError` が送出されます。\n" +"これは、スレッドの使用に関係なく適用されます。" diff --git a/builtins/time-complexity.po b/builtins/time-complexity.po index d953f0abd..40837b98e 100644 --- a/builtins/time-complexity.po +++ b/builtins/time-complexity.po @@ -16,35 +16,40 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../builtins/time-complexity.rst:5 msgid "Time complexity of operations on built-in types" -msgstr "" +msgstr "組み込み型の操作の時間計算量" -#: ../../builtins/time-complexity.rst:7 msgid "" "This page documents the time complexity of various operations on built-in " "types in CPython. Other Python implementations may have different " "performance characteristics. Additionally, the listed costs assume exact " "built-in types, as instances of subclasses may have different costs." msgstr "" +"このページでは、CPython の組み込み型に対するさまざまな操作の時間計算量を説明" +"します。\n" +"ほかの Python 実装では、性能の特性が異なる場合があります。\n" +"また、サブクラスのインスタンスではコストが異なる場合があるため、ここに示すコ" +"ストは組み込み型そのものを前提としています。" -#: ../../builtins/time-complexity.rst:12 msgid "" "We use |big O notation|_ to describe how the running time of an operation " "grows with the size of its inputs. Unless stated otherwise, *n* denotes the " "number of elements currently in the container, and *k* is the value of a " "numeric parameter, such as an index or a repeat count." msgstr "" +"|big O notation|_ を使って、入力のサイズに応じて操作の実行時間がどのように増" +"加するかを説明します。\n" +"特に断りのない限り、*n* は現在コンテナに含まれる要素の数を表し、*k* はイン" +"デックスや繰り返し回数などの数値引数の値を表します。" -#: ../../builtins/time-complexity.rst:22 msgid ":class:`!list`" -msgstr "" +msgstr ":class:`!list`" #: ../../builtins/time-complexity.rst:24 msgid "" @@ -65,92 +70,38 @@ msgstr "" msgid "Operation" msgstr "演算" -#: ../../builtins/time-complexity.rst:35 ../../builtins/time-complexity.rst:86 -#: ../../builtins/time-complexity.rst:125 -#: ../../builtins/time-complexity.rst:160 -#: ../../builtins/time-complexity.rst:203 -#: ../../builtins/time-complexity.rst:236 -#: ../../builtins/time-complexity.rst:263 msgid "Complexity" -msgstr "" +msgstr "計算量" -#: ../../builtins/time-complexity.rst:36 msgid "Copy (``l.copy()``)" -msgstr "" +msgstr "コピー (``l.copy()``)" -#: ../../builtins/time-complexity.rst:37 ../../builtins/time-complexity.rst:51 -#: ../../builtins/time-complexity.rst:68 ../../builtins/time-complexity.rst:70 -#: ../../builtins/time-complexity.rst:98 ../../builtins/time-complexity.rst:100 -#: ../../builtins/time-complexity.rst:102 -#: ../../builtins/time-complexity.rst:129 -#: ../../builtins/time-complexity.rst:139 -#: ../../builtins/time-complexity.rst:164 -#: ../../builtins/time-complexity.rst:213 -#: ../../builtins/time-complexity.rst:217 -#: ../../builtins/time-complexity.rst:219 -#: ../../builtins/time-complexity.rst:244 -#: ../../builtins/time-complexity.rst:246 -#: ../../builtins/time-complexity.rst:248 -#: ../../builtins/time-complexity.rst:273 -#: ../../builtins/time-complexity.rst:275 msgid "*O*\\ (*n*)" -msgstr "" +msgstr "*O*\\ (*n*)" -#: ../../builtins/time-complexity.rst:38 msgid "Append (``l.append(x)``) [1]_" -msgstr "" +msgstr "末尾への追加 (``l.append(x)``) [1]_" -#: ../../builtins/time-complexity.rst:39 ../../builtins/time-complexity.rst:45 -#: ../../builtins/time-complexity.rst:47 ../../builtins/time-complexity.rst:72 -#: ../../builtins/time-complexity.rst:88 ../../builtins/time-complexity.rst:90 -#: ../../builtins/time-complexity.rst:104 -#: ../../builtins/time-complexity.rst:127 -#: ../../builtins/time-complexity.rst:131 -#: ../../builtins/time-complexity.rst:133 -#: ../../builtins/time-complexity.rst:135 -#: ../../builtins/time-complexity.rst:141 -#: ../../builtins/time-complexity.rst:162 -#: ../../builtins/time-complexity.rst:166 -#: ../../builtins/time-complexity.rst:168 -#: ../../builtins/time-complexity.rst:186 -#: ../../builtins/time-complexity.rst:205 -#: ../../builtins/time-complexity.rst:221 -#: ../../builtins/time-complexity.rst:238 -#: ../../builtins/time-complexity.rst:240 -#: ../../builtins/time-complexity.rst:242 -#: ../../builtins/time-complexity.rst:250 -#: ../../builtins/time-complexity.rst:265 -#: ../../builtins/time-complexity.rst:267 -#: ../../builtins/time-complexity.rst:269 -#: ../../builtins/time-complexity.rst:271 -#: ../../builtins/time-complexity.rst:277 msgid "*O*\\ (1)" -msgstr "" +msgstr "*O*\\ (1)" -#: ../../builtins/time-complexity.rst:40 msgid "Pop (``l.pop(k)``) [1]_ [2]_" -msgstr "" +msgstr "取り出して削除 (``l.pop(k)``) [1]_ [2]_" -#: ../../builtins/time-complexity.rst:41 ../../builtins/time-complexity.rst:43 -#: ../../builtins/time-complexity.rst:49 msgid "*O*\\ (*n* - *k*)" -msgstr "" +msgstr "*O*\\ (*n* - *k*)" -#: ../../builtins/time-complexity.rst:42 msgid "Insert (``l.insert(k, x)``) [1]_ [2]_" -msgstr "" +msgstr "挿入 (``l.insert(k, x)``) [1]_ [2]_" -#: ../../builtins/time-complexity.rst:44 msgid "Get item (``l[k]``)" -msgstr "" +msgstr "要素の取得 (``l[k]``)" -#: ../../builtins/time-complexity.rst:46 msgid "Set item (``l[k] = x``)" -msgstr "" +msgstr "要素の設定 (``l[k] = x``)" -#: ../../builtins/time-complexity.rst:48 msgid "Delete item (``del l[k]``) [2]_" -msgstr "" +msgstr "要素の削除 (``del l[k]``) [2]_" #: ../../builtins/time-complexity.rst:50 ../../builtins/time-complexity.rst:97 #: ../../builtins/time-complexity.rst:218 @@ -158,130 +109,104 @@ msgstr "" msgid "Iteration" msgstr "イテレーション" -#: ../../builtins/time-complexity.rst:52 msgid "Get slice (``l[i:j]``)" -msgstr "" +msgstr "スライスの取得 (``l[i:j]``)" -#: ../../builtins/time-complexity.rst:53 ../../builtins/time-complexity.rst:92 -#: ../../builtins/time-complexity.rst:207 msgid "*O*\\ (*j* - *i*)" -msgstr "" +msgstr "*O*\\ (*j* - *i*)" -#: ../../builtins/time-complexity.rst:54 msgid "Set slice (``l[i:j] = t``) [1]_" -msgstr "" +msgstr "スライスへの代入 (``l[i:j] = t``) [1]_" -#: ../../builtins/time-complexity.rst:55 msgid "" "*O*\\ (*j* - *i*) if len(*t*) == *j* - *i*, otherwise *O*\\ (*n* - *i* + " "len(*t*))" msgstr "" +"len(*t*) == *j* - *i* の場合は *O*\\ (*j* - *i*)、それ以外の場合は *O*\\ " +"(*n* - *i* + len(*t*))" -#: ../../builtins/time-complexity.rst:57 msgid "Delete slice (``del l[i:j]``)" -msgstr "" +msgstr "スライスの削除 (``del l[i:j]``)" -#: ../../builtins/time-complexity.rst:58 msgid "*O*\\ (*n* - *i*)" -msgstr "" +msgstr "*O*\\ (*n* - *i*)" -#: ../../builtins/time-complexity.rst:59 msgid "Extend (``l.extend(t)``) [1]_ [3]_" -msgstr "" +msgstr "拡張 (``l.extend(t)``) [1]_ [3]_" -#: ../../builtins/time-complexity.rst:60 ../../builtins/time-complexity.rst:137 msgid "*O*\\ (len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*t*))" -#: ../../builtins/time-complexity.rst:61 msgid "Sort (``l.sort()``) [4]_" -msgstr "" +msgstr "ソート (``l.sort()``) [4]_" -#: ../../builtins/time-complexity.rst:62 msgid "*O*\\ (*n* log *n*)" -msgstr "" +msgstr "*O*\\ (*n* log *n*)" -#: ../../builtins/time-complexity.rst:63 msgid "Concatenate (``l1 + l2``)" -msgstr "" +msgstr "結合 (``l1 + l2``)" -#: ../../builtins/time-complexity.rst:64 msgid "*O*\\ (len(*l1*) + len(*l2*))" -msgstr "" +msgstr "*O*\\ (len(*l1*) + len(*l2*))" -#: ../../builtins/time-complexity.rst:65 msgid "Multiply (``l * k``)" -msgstr "" +msgstr "繰り返し (``l * k``)" -#: ../../builtins/time-complexity.rst:66 ../../builtins/time-complexity.rst:96 -#: ../../builtins/time-complexity.rst:211 msgid "*O*\\ (*nk*)" -msgstr "" +msgstr "*O*\\ (*nk*)" -#: ../../builtins/time-complexity.rst:67 msgid "``x in l``" -msgstr "" +msgstr "``x in l``" -#: ../../builtins/time-complexity.rst:69 msgid "``min(l)``, ``max(l)``" -msgstr "" +msgstr "``min(l)``, ``max(l)``" -#: ../../builtins/time-complexity.rst:71 msgid "Get length (``len(l)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(l)``) [5]_" -#: ../../builtins/time-complexity.rst:76 msgid ":class:`!tuple`" -msgstr "" +msgstr ":class:`!tuple`" -#: ../../builtins/time-complexity.rst:78 msgid "" "A :class:`tuple` is an :term:`immutable` sequence. Because a tuple can never " "change, there are no insertion or deletion costs, and making a copy simply " "returns the same object, so is constant time (*O*\\ (1))." msgstr "" +":class:`tuple` は :term:`不変の ` シーケンスです。\n" +"タプルは変更できないため、挿入や削除のコストはありません。\n" +"また、コピーの作成では同じオブジェクトを返すだけなので、定数時間 (*O*\\ (1)) " +"で済みます。" -#: ../../builtins/time-complexity.rst:87 msgid "Copy (``tuple(t)``)" -msgstr "" +msgstr "コピー (``tuple(t)``)" -#: ../../builtins/time-complexity.rst:89 msgid "Get item (``t[k]``)" -msgstr "" +msgstr "要素の取得 (``t[k]``)" -#: ../../builtins/time-complexity.rst:91 msgid "Get slice (``t[i:j]``)" -msgstr "" +msgstr "スライスの取得 (``t[i:j]``)" -#: ../../builtins/time-complexity.rst:93 msgid "Concatenate (``t1 + t2``)" -msgstr "" +msgstr "結合 (``t1 + t2``)" -#: ../../builtins/time-complexity.rst:94 msgid "*O*\\ (len(*t1*) + len(*t2*))" -msgstr "" +msgstr "*O*\\ (len(*t1*) + len(*t2*))" -#: ../../builtins/time-complexity.rst:95 msgid "Multiply (``t * k``)" -msgstr "" +msgstr "繰り返し (``t * k``)" -#: ../../builtins/time-complexity.rst:99 msgid "``x in t``" -msgstr "" +msgstr "``x in t``" -#: ../../builtins/time-complexity.rst:101 msgid "``min(t)``, ``max(t)``" -msgstr "" +msgstr "``min(t)``, ``max(t)``" -#: ../../builtins/time-complexity.rst:103 msgid "Get length (``len(t)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(t)``) [5]_" -#: ../../builtins/time-complexity.rst:108 msgid ":class:`!dict`, :class:`!frozendict`" -msgstr "" +msgstr ":class:`!dict`, :class:`!frozendict`" -#: ../../builtins/time-complexity.rst:110 msgid "" "The times listed for dict objects are average-case times, as they assume the " "hash function for the objects is sufficiently robust to make collisions " @@ -291,149 +216,140 @@ msgid "" "also assume that hashing and comparing a key is *O*\\ (1). For more detail " "on the implementation, see :ref:`how-are-dictionaries-implemented`." msgstr "" +"``dict`` オブジェクトについて示す時間は、平均的な場合の時間です。\n" +"オブジェクトのハッシュ関数が十分に堅牢で、衝突がめったに起こらないことを前提" +"としているためです。\n" +"また、取り得るキーの集合の中で、キーが偏りなく分布していることも前提としてい" +"ます。\n" +"すべてのキーが同じハッシュ値を持つ最悪の場合には、以下で *O*\\ (1) と示す各操" +"作に *O*\\ (*n*) の時間がかかります。\n" +"さらに、キーのハッシュ値の計算と比較が *O*\\ (1) であることも前提としていま" +"す。\n" +"実装の詳細については、:ref:`how-are-dictionaries-implemented` を参照してくだ" +"さい。" -#: ../../builtins/time-complexity.rst:118 msgid "" "A :class:`frozendict` is immutable, so it does not support setting, " "deleting, or updating items. The other operations below apply to it at the " "same costs." msgstr "" +":class:`frozendict` は不変なので、要素の設定、削除、更新をサポートしませ" +"ん。\n" +"以下のほかの操作は、同じコストで適用できます。" -#: ../../builtins/time-complexity.rst:126 msgid "``key in d``" -msgstr "" +msgstr "``key in d``" -#: ../../builtins/time-complexity.rst:128 msgid "Copy (``d.copy()``) [6]_ [7]_" -msgstr "" +msgstr "コピー (``d.copy()``) [6]_ [7]_" -#: ../../builtins/time-complexity.rst:130 msgid "Get item (``d[key]``, ``d.get(key)``)" -msgstr "" +msgstr "要素の取得 (``d[key]``, ``d.get(key)``)" -#: ../../builtins/time-complexity.rst:132 msgid "Set item (``d[key] = value``) [1]_" -msgstr "" +msgstr "要素の設定 (``d[key] = value``) [1]_" -#: ../../builtins/time-complexity.rst:134 msgid "Delete item (``del d[key]``, ``d.pop(key)``)" -msgstr "" +msgstr "要素の削除 (``del d[key]``, ``d.pop(key)``)" -#: ../../builtins/time-complexity.rst:136 msgid "Update (``d.update(t)``, ``d |= t``) [1]_ [3]_ [7]_" -msgstr "" +msgstr "更新 (``d.update(t)``, ``d |= t``) [1]_ [3]_ [7]_" -#: ../../builtins/time-complexity.rst:138 msgid "Iteration [7]_" -msgstr "" +msgstr "イテレーション [7]_" -#: ../../builtins/time-complexity.rst:140 msgid "Get length (``len(d)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(d)``) [5]_" -#: ../../builtins/time-complexity.rst:145 msgid ":class:`!set`, :class:`!frozenset`" -msgstr "" +msgstr ":class:`!set`, :class:`!frozenset`" -#: ../../builtins/time-complexity.rst:147 msgid "" "See :class:`dict` as the :class:`set` and :class:`frozenset` implementations " "are similar, and the same caveats apply. In the worst case, *O*\\ (1) " "operations instead take *O*\\ (*n*) time, and operations that look up every " "element degrade accordingly." msgstr "" +":class:`set` と :class:`frozenset` の実装は辞書と似ていて、同じ注意事項が当て" +"はまるため、:class:`dict` の説明を参照してください。\n" +"最悪の場合、*O*\\ (1) の操作に *O*\\ (*n*) の時間がかかり、すべての要素を検索" +"する操作の性能もそれに応じて低下します。" -#: ../../builtins/time-complexity.rst:152 msgid "" "A :class:`frozenset` is :term:`immutable`, so it does not support adding, " "discarding, or the in-place update operations. The others below apply to it " "at the same costs." msgstr "" +":class:`frozenset` は :term:`不変 ` なので、要素の追加や除去、イン" +"プレースの更新操作をサポートしません。\n" +"以下のほかの操作は、同じコストで適用できます。" #: ../../builtins/time-complexity.rst:161 msgid "``x in s``" msgstr "``x in s``" -#: ../../builtins/time-complexity.rst:163 msgid "Copy (``s.copy()``) [6]_ [7]_" -msgstr "" +msgstr "コピー (``s.copy()``) [6]_ [7]_" -#: ../../builtins/time-complexity.rst:165 msgid "Add (``s.add(x)``) [1]_" -msgstr "" +msgstr "追加 (``s.add(x)``) [1]_" -#: ../../builtins/time-complexity.rst:167 msgid "Discard (``s.discard(x)``, ``s.remove(x)``)" -msgstr "" +msgstr "除去 (``s.discard(x)``, ``s.remove(x)``)" -#: ../../builtins/time-complexity.rst:169 msgid "Union (``s1 | s2``, ``s1.union(s2)``) [7]_" -msgstr "" +msgstr "和集合 (``s1 | s2``, ``s1.union(s2)``) [7]_" -#: ../../builtins/time-complexity.rst:170 -#: ../../builtins/time-complexity.rst:182 msgid "*O*\\ (len(*s1*) + len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s1*) + len(*s2*))" -#: ../../builtins/time-complexity.rst:171 msgid "Update (``s1 |= s2``, ``s1.update(s2)``) [1]_ [7]_" -msgstr "" +msgstr "更新 (``s1 |= s2``, ``s1.update(s2)``) [1]_ [7]_" -#: ../../builtins/time-complexity.rst:172 -#: ../../builtins/time-complexity.rst:184 msgid "*O*\\ (len(*s2*))" -msgstr "" +msgstr "*O*\\ (len(*s2*))" -#: ../../builtins/time-complexity.rst:173 msgid "Intersection (``s1 & s2``, ``s1.intersection(s2)``) [7]_ [8]_" -msgstr "" +msgstr "共通集合 (``s1 & s2``, ``s1.intersection(s2)``) [7]_ [8]_" -#: ../../builtins/time-complexity.rst:174 -#: ../../builtins/time-complexity.rst:176 -#: ../../builtins/time-complexity.rst:180 msgid "*O*\\ (min(len(*s1*), len(*s2*)))" -msgstr "" +msgstr "*O*\\ (min(len(*s1*), len(*s2*)))" -#: ../../builtins/time-complexity.rst:175 msgid "" "Intersection update (``s1 &= s2``, ``s1.intersection_update(s2)``) [1]_ [7]_ " "[8]_" msgstr "" +"共通集合による更新 (``s1 &= s2``, ``s1.intersection_update(s2)``) [1]_ [7]_ " +"[8]_" -#: ../../builtins/time-complexity.rst:177 msgid "Difference (``s1 - s2``, ``s1.difference(s2)``) [7]_ [9]_" -msgstr "" +msgstr "差集合 (``s1 - s2``, ``s1.difference(s2)``) [7]_ [9]_" -#: ../../builtins/time-complexity.rst:178 msgid "*O*\\ (len(*s1*))" -msgstr "" +msgstr "*O*\\ (len(*s1*))" -#: ../../builtins/time-complexity.rst:179 msgid "" "Difference update (``s1 -= s2``, ``s1.difference_update(s2)``) [1]_ [7]_ [8]_" msgstr "" +"差集合による更新 (``s1 -= s2``, ``s1.difference_update(s2)``) [1]_ [7]_ [8]_" -#: ../../builtins/time-complexity.rst:181 msgid "" "Symmetric difference (``s1 ^ s2``, ``s1.symmetric_difference(s2)``) [7]_" -msgstr "" +msgstr "対称差 (``s1 ^ s2``, ``s1.symmetric_difference(s2)``) [7]_" -#: ../../builtins/time-complexity.rst:183 msgid "" "Symmetric difference update (``s1 ^= s2``, ``s1." "symmetric_difference_update(s2)``) [1]_ [7]_" msgstr "" +"対称差による更新 (``s1 ^= s2``, ``s1.symmetric_difference_update(s2)``) [1]_ " +"[7]_" -#: ../../builtins/time-complexity.rst:185 -#: ../../builtins/time-complexity.rst:220 msgid "Get length (``len(s)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(s)``) [5]_" -#: ../../builtins/time-complexity.rst:190 msgid ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" -msgstr "" +msgstr ":class:`!str`, :class:`!bytes`, :class:`!bytearray`" -#: ../../builtins/time-complexity.rst:192 msgid "" ":class:`str` and :class:`bytes` objects are immutable sequences of " "characters and bytes, respectively. As with tuples, copying one returns the " @@ -443,130 +359,121 @@ msgid "" "k]``) only advances the start of the buffer instead of moving the remaining " "bytes, and is amortized *O*\\ (1)." msgstr "" +":class:`str` と :class:`bytes` のオブジェクトは、それぞれ文字とバイトからなる" +"不変のシーケンスです。\n" +"タプルと同様に、コピーすると元のオブジェクトが返されます。\n" +":class:`bytearray` は可変で、:class:`list` の変更操作 (:meth:`!sort` を除く) " +"も同じコストでサポートします。\n" +"ただし、``del`` で先頭の要素を削除する場合 (``del b[0]``、``del b[:k]``) は、" +"残りのバイトを移動せず、バッファの開始位置を進めるだけなので、償却計算量は " +"*O*\\ (1) です。" -#: ../../builtins/time-complexity.rst:204 msgid "Get item (``s[k]``)" -msgstr "" +msgstr "要素の取得 (``s[k]``)" -#: ../../builtins/time-complexity.rst:206 msgid "Get slice (``s[i:j]``)" -msgstr "" +msgstr "スライスの取得 (``s[i:j]``)" -#: ../../builtins/time-complexity.rst:208 msgid "Concatenate (``s + t``) [10]_" -msgstr "" +msgstr "結合 (``s + t``) [10]_" -#: ../../builtins/time-complexity.rst:209 msgid "*O*\\ (len(*s*) + len(*t*))" -msgstr "" +msgstr "*O*\\ (len(*s*) + len(*t*))" -#: ../../builtins/time-complexity.rst:210 msgid "Multiply (``s * k``)" -msgstr "" +msgstr "繰り返し (``s * k``)" -#: ../../builtins/time-complexity.rst:212 msgid "Substring search (``x in s``, ``s.find(x)``, ``s.index(x)``) [11]_" -msgstr "" +msgstr "部分文字列の検索 (``x in s``, ``s.find(x)``, ``s.index(x)``) [11]_" -#: ../../builtins/time-complexity.rst:214 msgid "Reverse substring search (``s.rfind(x)``, ``s.rindex(x)``) [11]_ [12]_" -msgstr "" +msgstr "逆方向の部分文字列の検索 (``s.rfind(x)``, ``s.rindex(x)``) [11]_ [12]_" -#: ../../builtins/time-complexity.rst:215 msgid "*O*\\ (*n* × len(*x*))" -msgstr "" +msgstr "*O*\\ (*n* × len(*x*))" -#: ../../builtins/time-complexity.rst:216 msgid "Encode or decode [13]_" -msgstr "" +msgstr "エンコードまたはデコード [13]_" -#: ../../builtins/time-complexity.rst:225 msgid ":class:`!memoryview`" -msgstr "" +msgstr ":class:`!memoryview`" -#: ../../builtins/time-complexity.rst:227 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying. In particular, slicing a memory view returns a new view onto the " "same buffer." msgstr "" +":class:`memoryview` オブジェクトを使うと、Python コードから :ref:`バッファプ" +"ロトコル ` をサポートするオブジェクトの内部データに、コピーせ" +"ずにアクセスできます。\n" +"特に、メモリービューのスライスは、同じバッファを参照する新しいビューを返しま" +"す。" -#: ../../builtins/time-complexity.rst:237 msgid "Create (``memoryview(obj)``)" -msgstr "" +msgstr "作成 (``memoryview(obj)``)" -#: ../../builtins/time-complexity.rst:239 msgid "Get item (``v[k]``)" -msgstr "" +msgstr "要素の取得 (``v[k]``)" -#: ../../builtins/time-complexity.rst:241 msgid "Get slice (``v[i:j]``)" -msgstr "" +msgstr "スライスの取得 (``v[i:j]``)" -#: ../../builtins/time-complexity.rst:243 msgid "Index (``v.index(x)``) [11]_ [14]_" -msgstr "" +msgstr "インデックスの検索 (``v.index(x)``) [11]_ [14]_" -#: ../../builtins/time-complexity.rst:245 msgid "Count (``v.count(x)``) [14]_" -msgstr "" +msgstr "出現回数の取得 (``v.count(x)``) [14]_" -#: ../../builtins/time-complexity.rst:247 msgid "Convert to bytes (``v.tobytes()``, ``bytes(v)``)" -msgstr "" +msgstr "バイト列への変換 (``v.tobytes()``, ``bytes(v)``)" -#: ../../builtins/time-complexity.rst:249 msgid "Get length (``len(v)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(v)``) [5]_" -#: ../../builtins/time-complexity.rst:254 msgid ":class:`!range`" -msgstr "" +msgstr ":class:`!range`" -#: ../../builtins/time-complexity.rst:256 msgid "" "A :class:`range` object computes its items on demand from its *start*, " "*stop* and *step* values, so most operations do not depend on the length of " "the range." msgstr "" +":class:`range` オブジェクトは、``start``、``stop``、``step`` の値から必要に応" +"じて要素を計算するため、ほとんどの操作は範囲の長さに依存しません。" -#: ../../builtins/time-complexity.rst:264 msgid "Get item (``r[k]``)" -msgstr "" +msgstr "要素の取得 (``r[k]``)" -#: ../../builtins/time-complexity.rst:266 msgid "Get slice (``r[i:j]``)" -msgstr "" +msgstr "スライスの取得 (``r[i:j]``)" -#: ../../builtins/time-complexity.rst:268 msgid "``x in r`` [15]_" -msgstr "" +msgstr "``x in r`` [15]_" -#: ../../builtins/time-complexity.rst:270 msgid "Index and count (``r.index(x)``, ``r.count(x)``) [15]_" -msgstr "" +msgstr "インデックスと出現回数の取得 (``r.index(x)``, ``r.count(x)``) [15]_" -#: ../../builtins/time-complexity.rst:274 msgid "``min(r)``, ``max(r)``" -msgstr "" +msgstr "``min(r)``, ``max(r)``" -#: ../../builtins/time-complexity.rst:276 msgid "Get length (``len(r)``) [5]_" -msgstr "" +msgstr "長さの取得 (``len(r)``) [5]_" #: ../../builtins/time-complexity.rst:281 msgid "Notes" msgstr "注釈" -#: ../../builtins/time-complexity.rst:283 msgid "" "Amortized. An individual operation may occasionally be *O*\\ (*n*) when the " "underlying storage is resized, but this cost is spread over many operations, " "depending on the history of the container." msgstr "" +"償却計算量です。\n" +"内部の記憶領域のサイズを変更するときに、個々の操作が *O*\\ (*n*) になることが" +"ありますが、コンテナに対してそれまでに行った操作に応じて、このコストは多数の" +"操作に分散されます。" -#: ../../builtins/time-complexity.rst:287 msgid "" "Popping or deleting the element at index *k* of a list of size *n* shifts " "all elements after *k* one slot to the left, moving *n* - *k* - 1 elements; " @@ -576,31 +483,47 @@ msgid "" "of the list, takes *O*\\ (*n*/2) = *O*\\ (*n*) operations; and operating at " "the end of the list moves nothing and is *O*\\ (1)." msgstr "" +"要素数 *n* のリストで、インデックス *k* の要素を取り出して削除するか、単に削" +"除すると、*k* より後のすべての要素が 1 要素分ずつ左にずれ、*n* - *k* - 1 個の" +"要素が移動します。\n" +"インデックス *k* に挿入すると、*k* 以降の要素が 1 要素分ずつ右にずれ、*n* - " +"*k* 個の要素が移動します。\n" +"最悪の場合はインデックスが 0 のときで、リストの残りの要素すべてを移動しなけれ" +"ばなりません。\n" +"平均的な場合はリストの中央のインデックスで、*O*\\ (*n*/2) = *O*\\ (*n*) の操" +"作が必要です。\n" +"リストの末尾で操作する場合は何も移動せず、*O*\\ (1) です。" -#: ../../builtins/time-complexity.rst:296 msgid "" "Plus the cost of iterating over *t*, which may be expensive for an arbitrary " "iterable." msgstr "" +"これに加えて、*t* をイテレートするコストがかかります。\n" +"任意のイテラブルでは、このコストが高くなる場合があります。" -#: ../../builtins/time-complexity.rst:299 msgid "" "This is the worst case scenario. Sorting is adaptive and input that is " "already sorted or reverse-sorted takes only *O*\\ (*n*) comparisons. See :" "source:`Objects/listsort.txt` for more information." msgstr "" +"これは最悪の場合です。\n" +"ソートは入力の状態に適応するため、すでにソート済み、または逆順にソート済みの" +"入力では、比較は *O*\\ (*n*) 回で済みます。\n" +"詳細については、:source:`Objects/listsort.txt` を参照してください。" -#: ../../builtins/time-complexity.rst:303 msgid "" "The number of elements is stored in the object, so ``len()`` does not need " "to count them." msgstr "" +"要素数はオブジェクトに格納されているため、``len()`` が要素を数える必要はあり" +"ません。" -#: ../../builtins/time-complexity.rst:306 msgid "" "Copying a :class:`frozendict` or a :class:`frozenset` is *O*\\ (1) as it " "returns the original object." msgstr "" +":class:`frozendict` または :class:`frozenset` のコピーは元のオブジェクトを返" +"すため、*O*\\ (1) です。" #: ../../builtins/time-complexity.rst:309 msgid "" @@ -610,21 +533,23 @@ msgid "" "insertion triggers a resize." msgstr "" -#: ../../builtins/time-complexity.rst:314 msgid "*O*\\ (len(*t*)) if *t* is not a set." -msgstr "" +msgstr "*t* が集合型のオブジェクトでない場合は *O*\\ (len(*t*)) です。" -#: ../../builtins/time-complexity.rst:316 msgid "*O*\\ (len(*s*) + len(*t*)) if *t* is not a set." msgstr "" +"*t* が集合型のオブジェクトでない場合は *O*\\ (len(*s*) + len(*t*)) です。" -#: ../../builtins/time-complexity.rst:318 msgid "" "Each concatenation builds a new object, so building a string by " "concatenating many pieces in a loop is quadratic in the total length. See " "the :ref:`note on concatenating immutable sequences ` for alternatives." msgstr "" +"結合のたびに新しいオブジェクトが作成されるため、ループ内で多数の断片を結合し" +"て文字列を構築すると、実行時間は全体の長さの二乗に比例します。\n" +"ほかの方法については、:ref:`不変のシーケンスの結合に関する注記 ` を参照してください。" #: ../../builtins/time-complexity.rst:323 msgid "" @@ -632,26 +557,33 @@ msgid "" "rather than of *s*, and unlike slicing nothing is copied." msgstr "" -#: ../../builtins/time-complexity.rst:326 msgid "" "This is the worst case. Reverse searches are *O*\\ (*n*) on typical input. " "Forward searches instead use a more elaborate algorithm with a linear worst " "case, described in :source:`Objects/stringlib/stringlib_find_two_way_notes." "txt`." msgstr "" +"これは最悪の場合です。\n" +"通常の入力では、逆方向の検索は *O*\\ (*n*) です。\n" +"一方、順方向の検索は、最悪の場合でも線形時間となる、より精巧なアルゴリズムを" +"使います。\n" +"このアルゴリズムは :source:`Objects/stringlib/stringlib_find_two_way_notes." +"txt` で説明しています。" -#: ../../builtins/time-complexity.rst:331 msgid "This assumes a codec that does a constant amount of work per character." -msgstr "" +msgstr "1 文字ごとに一定量の処理を行うコーデックを前提としています。" -#: ../../builtins/time-complexity.rst:333 msgid "" "These unpack and compare each element individually, so they are much slower " "than the equivalent :class:`bytes` methods." msgstr "" +"これらの操作は各要素を個別にアンパックして比較するため、対応する :class:" +"`bytes` のメソッドよりはるかに遅くなります。" -#: ../../builtins/time-complexity.rst:336 msgid "" "Assuming :class:`int` or :class:`bool` arguments. For other types, the range " "is searched like any other sequence in *O*\\ (*n*) time." msgstr "" +"引数が :class:`int` または :class:`bool` であることを前提としています。\n" +"ほかの型の場合は、ほかのシーケンスと同様に、``range`` オブジェクト内を *O*\\ " +"(*n*) の時間で検索します。" diff --git a/c-api/abstract.po b/c-api/abstract.po index 47db780f4..76d907464 100644 --- a/c-api/abstract.po +++ b/c-api/abstract.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/abstract.rst:7 diff --git a/c-api/allocation.po b/c-api/allocation.po index 1ed7b4a11..5a4e95895 100644 --- a/c-api/allocation.po +++ b/c-api/allocation.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/allocation.rst:6 msgid "Allocating objects on the heap" -msgstr "" +msgstr "ヒープ上でのオブジェクトの割り当て" -#: ../../c-api/allocation.rst:17 msgid "" "Initialize a newly allocated object *op* with its type and initial " "reference. Returns the initialized object. Other fields of the object are " @@ -35,20 +33,32 @@ msgid "" "slot). Specifically, this function does **not** call the object's :meth:`!" "__init__` method." msgstr "" +"新しく割り当てたオブジェクト *op* の型と初期の参照を設定し、初期化したオブ" +"ジェクトを返します。\n" +"オブジェクトの他のフィールドは初期化しません。\n" +"名前に反して、この関数はオブジェクトの :meth:`~object.__init__` メソッド (:c:" +"member:`~PyTypeObject.tp_init` スロット) とは無関係です。\n" +"特に、この関数はオブジェクトの :meth:`!__init__` メソッドを呼び出し **ません" +"**。" -#: ../../c-api/allocation.rst:24 msgid "" "In general, consider this function to be a low-level routine. Use :c:member:" "`~PyTypeObject.tp_alloc` where possible. For implementing :c:member:`!" "tp_alloc` for your type, prefer :c:func:`PyType_GenericAlloc` or :c:func:" "`PyObject_New`." msgstr "" +"一般に、この関数は低レベルのルーチンとして扱ってください。\n" +"可能な場合は :c:member:`~PyTypeObject.tp_alloc` を使ってください。\n" +"自分の型の :c:member:`!tp_alloc` を実装する場合は、:c:func:" +"`PyType_GenericAlloc` または :c:func:`PyObject_New` を優先してください。" -#: ../../c-api/allocation.rst:31 msgid "" "This function only initializes the object's memory corresponding to the " "initial :c:type:`PyObject` structure. It does not zero the rest." msgstr "" +"この関数が初期化するのは、オブジェクトのメモリのうち先頭の :c:type:" +"`PyObject` 構造体に対応する部分だけです。\n" +"残りの部分をゼロで埋めることはありません。" #: ../../c-api/allocation.rst:37 msgid "" @@ -58,13 +68,13 @@ msgstr "" ":c:func:`PyObject_Init` の全ての処理を行い、可変サイズオブジェクトの場合には" "長さ情報も初期化します。" -#: ../../c-api/allocation.rst:42 msgid "" "This function only initializes some of the object's memory. It does not " "zero the rest." msgstr "" +"この関数が初期化するのは、オブジェクトのメモリの一部だけです。\n" +"残りの部分をゼロで埋めることはありません。" -#: ../../c-api/allocation.rst:48 msgid "" "Allocates a new Python object using the C structure type *TYPE* and the " "Python type object *typeobj* (``PyTypeObject*``) by calling :c:func:" @@ -72,56 +82,75 @@ msgid "" "`PyObject_Init`. The caller will own the only reference to the object (i.e. " "its reference count will be one)." msgstr "" +"C の構造体型 *TYPE* と Python の型オブジェクト *typeobj* (``PyTypeObject*``) " +"を使って、新しい Python オブジェクトを割り当てます。\n" +":c:func:`PyObject_Malloc` を呼び出してメモリを割り当て、:c:func:" +"`PyObject_Init` と同じように初期化します。\n" +"呼び出し側がオブジェクトへの唯一の参照を所有します (つまり参照カウントは 1 に" +"なります)。" -#: ../../c-api/allocation.rst:54 ../../c-api/allocation.rst:107 msgid "" "Avoid calling this directly to allocate memory for an object; call the " "type's :c:member:`~PyTypeObject.tp_alloc` slot instead." msgstr "" +"オブジェクトのメモリを割り当てるためにこれを直接呼び出すのは避け、代わりに型" +"の :c:member:`~PyTypeObject.tp_alloc` スロットを呼び出してください。" -#: ../../c-api/allocation.rst:57 ../../c-api/allocation.rst:110 msgid "" "When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot, :c:func:" "`PyType_GenericAlloc` is preferred over a custom function that simply calls " "this macro." msgstr "" +"型の :c:member:`~PyTypeObject.tp_alloc` スロットには、このマクロを呼び出すだ" +"けの独自の関数よりも :c:func:`PyType_GenericAlloc` を設定することが推奨されま" +"す。" -#: ../../c-api/allocation.rst:61 msgid "" "This macro does not call :c:member:`~PyTypeObject.tp_alloc`, :c:member:" "`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or :c:member:" "`~PyTypeObject.tp_init` (:meth:`~object.__init__`)." msgstr "" +"このマクロは :c:member:`~PyTypeObject.tp_alloc`、:c:member:`~PyTypeObject." +"tp_new` (:meth:`~object.__new__`)、:c:member:`~PyTypeObject.tp_init` (:meth:" +"`~object.__init__`) を呼び出しません。" -#: ../../c-api/allocation.rst:65 msgid "" "This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:" "member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` instead." msgstr "" +":c:member:`~PyTypeObject.tp_flags` に :c:macro:`Py_TPFLAGS_HAVE_GC` が設定さ" +"れたオブジェクトには使えません。\n" +"代わりに :c:macro:`PyObject_GC_New` を使ってください。" -#: ../../c-api/allocation.rst:68 msgid "" "Memory allocated by this macro must be freed with :c:func:`PyObject_Free` " "(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." msgstr "" +"このマクロで割り当てたメモリは :c:func:`PyObject_Free` で解放しなければなりま" +"せん (通常はオブジェクトの :c:member:`~PyTypeObject.tp_free` スロットを介して" +"呼び出します)。" -#: ../../c-api/allocation.rst:73 ../../c-api/allocation.rst:123 msgid "" "The returned memory is not guaranteed to have been completely zeroed before " "it was initialized." -msgstr "" +msgstr "返されるメモリが初期化前にすべてゼロで埋められているとは限りません。" -#: ../../c-api/allocation.rst:78 ../../c-api/allocation.rst:128 msgid "" "This macro does not construct a fully initialized object of the given type; " "it merely allocates memory and prepares it for further initialization by :c:" "member:`~PyTypeObject.tp_init`. To construct a fully initialized object, " "call *typeobj* instead. For example::" msgstr "" +"このマクロは指定された型の完全に初期化されたオブジェクトを構築するものではあ" +"りません。\n" +"メモリを割り当て、:c:member:`~PyTypeObject.tp_init` によるさらなる初期化の準" +"備をするだけです。\n" +"完全に初期化されたオブジェクトを構築するには、代わりに *typeobj* を呼び出して" +"ください。\n" +"例えば次のようにします。 ::" -#: ../../c-api/allocation.rst:83 msgid "PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);" -msgstr "" +msgstr "PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);" #: ../../c-api/allocation.rst:87 ../../c-api/allocation.rst:137 #: ../../c-api/allocation.rst:184 ../../c-api/allocation.rst:186 @@ -129,61 +158,65 @@ msgstr "" msgid ":c:func:`PyObject_Free`" msgstr ":c:func:`PyObject_Free`" -#: ../../c-api/allocation.rst:88 msgid ":c:macro:`PyObject_GC_New`" -msgstr "" +msgstr ":c:macro:`PyObject_GC_New`" -#: ../../c-api/allocation.rst:89 ../../c-api/allocation.rst:139 msgid ":c:func:`PyType_GenericAlloc`" -msgstr "" +msgstr ":c:func:`PyType_GenericAlloc`" #: ../../c-api/allocation.rst:90 ../../c-api/allocation.rst:140 msgid ":c:member:`~PyTypeObject.tp_alloc`" msgstr ":c:member:`~PyTypeObject.tp_alloc`" -#: ../../c-api/allocation.rst:95 msgid "Like :c:macro:`PyObject_New` except:" -msgstr "" +msgstr ":c:macro:`PyObject_New` と同じですが、次の点が異なります。" -#: ../../c-api/allocation.rst:97 msgid "" "It allocates enough memory for the *TYPE* structure plus *size* " "(``Py_ssize_t``) fields of the size given by the :c:member:`~PyTypeObject." "tp_itemsize` field of *typeobj*." msgstr "" +"*TYPE* 構造体に加え、*typeobj* の :c:member:`~PyTypeObject.tp_itemsize` " +"フィールドが指定するサイズのフィールド *size* 個分 (``Py_ssize_t``) のメモリ" +"を割り当てます。" -#: ../../c-api/allocation.rst:100 msgid "The memory is initialized like :c:func:`PyObject_InitVar`." -msgstr "" +msgstr "メモリは :c:func:`PyObject_InitVar` と同じように初期化されます。" -#: ../../c-api/allocation.rst:102 msgid "" "This is useful for implementing objects like tuples, which are able to " "determine their size at construction time. Embedding the array of fields " "into the same allocation decreases the number of allocations, improving the " "memory management efficiency." msgstr "" +"これはタプルのように構築時にサイズを決定できるオブジェクトの実装に役立ちま" +"す。\n" +"フィールドの配列を同じ割り当て領域に埋め込むことで、割り当て回数を減らし、メ" +"モリ管理の効率を高められます。" -#: ../../c-api/allocation.rst:114 msgid "" "This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:" "member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar` instead." msgstr "" +":c:member:`~PyTypeObject.tp_flags` に :c:macro:`Py_TPFLAGS_HAVE_GC` が設定さ" +"れたオブジェクトには使えません。\n" +"代わりに :c:macro:`PyObject_GC_NewVar` を使ってください。" -#: ../../c-api/allocation.rst:118 msgid "" "Memory allocated by this function must be freed with :c:func:`PyObject_Free` " "(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." msgstr "" +"この関数で割り当てたメモリは :c:func:`PyObject_Free` で解放しなければなりませ" +"ん (通常はオブジェクトの :c:member:`~PyTypeObject.tp_free` スロットを介して呼" +"び出します)。" -#: ../../c-api/allocation.rst:133 msgid "" "PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);" msgstr "" +"PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);" -#: ../../c-api/allocation.rst:138 msgid ":c:macro:`PyObject_GC_NewVar`" -msgstr "" +msgstr ":c:macro:`PyObject_GC_NewVar`" #: ../../c-api/allocation.rst:145 msgid "" @@ -195,47 +228,41 @@ msgstr "" "ブジェクトへのポインタを評価する :c:macro:`Py_None` マクロを使わなければなり" "ません。" -#: ../../c-api/allocation.rst:152 msgid ":ref:`moduleobjects`" -msgstr "" +msgstr ":ref:`moduleobjects`" #: ../../c-api/allocation.rst:153 msgid "To allocate and create extension modules." msgstr "拡張モジュールのアロケートと生成。" -#: ../../c-api/allocation.rst:157 msgid "Soft-deprecated aliases" -msgstr "" +msgstr "緩やかに非推奨となった別名" -#: ../../c-api/allocation.rst:161 msgid "" "These are aliases to existing functions and macros. They exist solely for " "backwards compatibility." msgstr "" +"これらは既存の関数やマクロの別名です。\n" +"後方互換性のためだけに残されています。" -#: ../../c-api/allocation.rst:169 msgid "Soft-deprecated alias" -msgstr "" +msgstr "緩やかに非推奨となった別名" #: ../../c-api/allocation.rst:170 msgid "Function" msgstr "関数" -#: ../../c-api/allocation.rst:172 msgid ":c:macro:`PyObject_New`" -msgstr "" +msgstr ":c:macro:`PyObject_New`" -#: ../../c-api/allocation.rst:174 msgid ":c:macro:`PyObject_NewVar`" -msgstr "" +msgstr ":c:macro:`PyObject_NewVar`" -#: ../../c-api/allocation.rst:176 msgid ":c:func:`PyObject_Init`" -msgstr "" +msgstr ":c:func:`PyObject_Init`" -#: ../../c-api/allocation.rst:178 msgid ":c:func:`PyObject_InitVar`" -msgstr "" +msgstr ":c:func:`PyObject_InitVar`" #: ../../c-api/allocation.rst:180 msgid ":c:func:`PyObject_Malloc`" diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index ecbe5790b..0e6e4622e 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -16,26 +16,27 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/apiabiversion.rst:7 msgid "API and ABI Versioning" msgstr "API と ABI のバージョニング" -#: ../../c-api/apiabiversion.rst:11 msgid "Build-time version constants" -msgstr "" +msgstr "ビルド時のバージョン定数" -#: ../../c-api/apiabiversion.rst:13 msgid "" "CPython exposes its version number in the following macros. Note that these " "correspond to the version code is **built** with. See :c:var:`Py_Version` " "for the version used at **run time**." msgstr "" +"CPython は以下のマクロでバージョン番号を公開しています。\n" +"これらはコードの **ビルド時** のバージョンに対応します。\n" +"**実行時** のバージョンについては :c:var:`Py_Version` を参照してください。" #: ../../c-api/apiabiversion.rst:17 msgid "" @@ -64,119 +65,112 @@ msgstr "" "``3.4.1a2`` の ``a`` 。アルファでは ``0xA`` 、ベータでは ``0xB`` 、リリース候" "補では ``0xC`` 、最終版では ``0xF`` となります。" -#: ../../c-api/apiabiversion.rst:48 msgid "" "For completeness, the values are available as macros: :c:macro:`!" "PY_RELEASE_LEVEL_ALPHA` (``0xA``), :c:macro:`!PY_RELEASE_LEVEL_BETA` " "(``0xB``), :c:macro:`!PY_RELEASE_LEVEL_GAMMA` (``0xC``), and :c:macro:`!" "PY_RELEASE_LEVEL_FINAL` (``0xF``)." msgstr "" +"これらの値には対応するマクロもあります。\n" +":c:macro:`!PY_RELEASE_LEVEL_ALPHA` (``0xA``)、:c:macro:`!" +"PY_RELEASE_LEVEL_BETA` (``0xB``)、:c:macro:`!PY_RELEASE_LEVEL_GAMMA` " +"(``0xC``)、:c:macro:`!PY_RELEASE_LEVEL_FINAL` (``0xF``) です。" #: ../../c-api/apiabiversion.rst:56 msgid "The ``2`` in ``3.4.1a2``. Zero for final releases." msgstr "``3.4.1a2`` の ``2`` 。最終リリースでは 0 になります。" -#: ../../c-api/apiabiversion.rst:60 msgid "" "The Python version number encoded in a single integer. See :c:func:" "`Py_PACK_FULL_VERSION` for the encoding details." msgstr "" +"Python のバージョン番号を一つの整数にエンコードした値です。\n" +"エンコードの詳細は :c:func:`Py_PACK_FULL_VERSION` を参照してください。" -#: ../../c-api/apiabiversion.rst:63 msgid "" "Use this for numeric comparisons, for example, ``#if PY_VERSION_HEX >= ...``." msgstr "" +"``#if PY_VERSION_HEX >= ...`` のように、数値として比較するときに使います。" -#: ../../c-api/apiabiversion.rst:68 msgid "The Python version as a string, for example, ``\"3.4.1a2\"``." msgstr "" +"Python のバージョンを表す文字列です。\n" +"例えば ``\"3.4.1a2\"`` です。" -#: ../../c-api/apiabiversion.rst:70 msgid "These macros are defined in :source:`Include/patchlevel.h`." -msgstr "" +msgstr "これらのマクロは :source:`Include/patchlevel.h` で定義されています。" -#: ../../c-api/apiabiversion.rst:74 msgid "Run-time version" -msgstr "" +msgstr "実行時のバージョン" -#: ../../c-api/apiabiversion.rst:78 msgid "" "The Python runtime version number encoded in a single constant integer. See :" "c:func:`Py_PACK_FULL_VERSION` for the encoding details. This contains the " "Python version used at run time." msgstr "" +"Python ランタイムのバージョン番号を一つの整数定数にエンコードした値です。\n" +"エンコードの詳細は :c:func:`Py_PACK_FULL_VERSION` を参照してください。\n" +"実行時に使われている Python のバージョンを表します。" -#: ../../c-api/apiabiversion.rst:82 msgid "" "Use this for numeric comparisons, for example, ``if (Py_Version >= ...)``." msgstr "" +"``if (Py_Version >= ...)`` のように、数値として比較するときに使います。" -#: ../../c-api/apiabiversion.rst:88 msgid "Bit-packing macros" -msgstr "" +msgstr "ビットを詰め合わせるマクロ" -#: ../../c-api/apiabiversion.rst:92 msgid "" "Return the given version, encoded as a single 32-bit integer with the " "following structure:" msgstr "" +"指定されたバージョンを、以下の構造を持つ一つの 32 ビット整数にエンコードして" +"返します。" -#: ../../c-api/apiabiversion.rst:98 msgid "Argument" -msgstr "" +msgstr "引数" -#: ../../c-api/apiabiversion.rst:96 msgid "No. of bits" -msgstr "" +msgstr "ビット数" -#: ../../c-api/apiabiversion.rst:98 msgid "Bit mask" -msgstr "" +msgstr "ビットマスク" -#: ../../c-api/apiabiversion.rst:98 msgid "Bit shift" -msgstr "" +msgstr "ビットシフト" -#: ../../c-api/apiabiversion.rst:96 msgid "Example values" -msgstr "" +msgstr "値の例" -#: ../../c-api/apiabiversion.rst:98 ../../c-api/apiabiversion.rst:116 msgid "``3.4.1a2``" -msgstr "" +msgstr "``3.4.1a2``" -#: ../../c-api/apiabiversion.rst:98 ../../c-api/apiabiversion.rst:118 msgid "``3.10.0``" -msgstr "" +msgstr "``3.10.0``" -#: ../../c-api/apiabiversion.rst:100 msgid "*major*" -msgstr "" +msgstr "*major*" #: ../../c-api/apiabiversion.rst:100 ../../c-api/apiabiversion.rst:102 #: ../../c-api/apiabiversion.rst:104 msgid "8" msgstr "8" -#: ../../c-api/apiabiversion.rst:100 msgid "``0xFF000000``" -msgstr "" +msgstr "``0xFF000000``" -#: ../../c-api/apiabiversion.rst:100 msgid "24" -msgstr "" +msgstr "24" #: ../../c-api/apiabiversion.rst:100 msgid "``0x03``" msgstr "``0x03``" -#: ../../c-api/apiabiversion.rst:102 msgid "*minor*" -msgstr "" +msgstr "*minor*" -#: ../../c-api/apiabiversion.rst:102 msgid "``0x00FF0000``" -msgstr "" +msgstr "``0x00FF0000``" #: ../../c-api/apiabiversion.rst:102 msgid "16" @@ -186,53 +180,44 @@ msgstr "16" msgid "``0x04``" msgstr "``0x04``" -#: ../../c-api/apiabiversion.rst:102 msgid "``0x0A``" -msgstr "" +msgstr "``0x0A``" -#: ../../c-api/apiabiversion.rst:104 msgid "*micro*" -msgstr "" +msgstr "*micro*" -#: ../../c-api/apiabiversion.rst:104 msgid "``0x0000FF00``" -msgstr "" +msgstr "``0x0000FF00``" #: ../../c-api/apiabiversion.rst:104 msgid "``0x01``" msgstr "``0x01``" -#: ../../c-api/apiabiversion.rst:104 msgid "``0x00``" -msgstr "" +msgstr "``0x00``" -#: ../../c-api/apiabiversion.rst:106 msgid "*release_level*" -msgstr "" +msgstr "*release_level*" #: ../../c-api/apiabiversion.rst:106 ../../c-api/apiabiversion.rst:108 msgid "4" msgstr "4" -#: ../../c-api/apiabiversion.rst:106 msgid "``0x000000F0``" -msgstr "" +msgstr "``0x000000F0``" #: ../../c-api/apiabiversion.rst:106 msgid "``0xA``" msgstr "``0xA``" -#: ../../c-api/apiabiversion.rst:106 msgid "``0xF``" -msgstr "" +msgstr "``0xF``" -#: ../../c-api/apiabiversion.rst:108 msgid "*release_serial*" -msgstr "" +msgstr "*release_serial*" -#: ../../c-api/apiabiversion.rst:108 msgid "``0x0000000F``" -msgstr "" +msgstr "``0x0000000F``" #: ../../c-api/apiabiversion.rst:108 msgid "0" @@ -242,9 +227,8 @@ msgstr "0" msgid "``0x2``" msgstr "``0x2``" -#: ../../c-api/apiabiversion.rst:108 msgid "``0x0``" -msgstr "" +msgstr "``0x0``" #: ../../c-api/apiabiversion.rst:111 msgid "For example:" @@ -254,37 +238,31 @@ msgstr "例えば:" msgid "Version" msgstr "Version" -#: ../../c-api/apiabiversion.rst:114 msgid "``Py_PACK_FULL_VERSION`` arguments" -msgstr "" +msgstr "``Py_PACK_FULL_VERSION`` の引数" -#: ../../c-api/apiabiversion.rst:114 msgid "Encoded version" -msgstr "" +msgstr "エンコードされたバージョン" -#: ../../c-api/apiabiversion.rst:116 msgid "``(3, 4, 1, 0xA, 2)``" -msgstr "" +msgstr "``(3, 4, 1, 0xA, 2)``" -#: ../../c-api/apiabiversion.rst:116 msgid "``0x030401a2``" -msgstr "" +msgstr "``0x030401a2``" -#: ../../c-api/apiabiversion.rst:118 msgid "``(3, 10, 0, 0xF, 0)``" -msgstr "" +msgstr "``(3, 10, 0, 0xF, 0)``" -#: ../../c-api/apiabiversion.rst:118 msgid "``0x030a00f0``" -msgstr "" +msgstr "``0x030a00f0``" -#: ../../c-api/apiabiversion.rst:121 msgid "" "Out-of range bits in the arguments are ignored. That is, the macro can be " "defined as:" msgstr "" +"引数の範囲外のビットは無視します。\n" +"つまり、このマクロは次のように定義できます。" -#: ../../c-api/apiabiversion.rst:124 msgid "" "#ifndef Py_PACK_FULL_VERSION\n" "#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" @@ -295,16 +273,26 @@ msgid "" " (((SERIAL) & 0xf) << 0))\n" "#endif" msgstr "" +"#ifndef Py_PACK_FULL_VERSION\n" +"#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" +" (((X) & 0xff) << 24) | \\\n" +" (((Y) & 0xff) << 16) | \\\n" +" (((Z) & 0xff) << 8) | \\\n" +" (((LEVEL) & 0xf) << 4) | \\\n" +" (((SERIAL) & 0xf) << 0))\n" +"#endif" -#: ../../c-api/apiabiversion.rst:135 msgid "" "``Py_PACK_FULL_VERSION`` is primarily a macro, intended for use in ``#if`` " "directives, but it is also available as an exported function." msgstr "" +"``Py_PACK_FULL_VERSION`` は主に ``#if`` ディレクティブで使うためのマクロです" +"が、エクスポートされた関数としても利用できます。" -#: ../../c-api/apiabiversion.rst:142 msgid "" "Equivalent to ``Py_PACK_FULL_VERSION(major, minor, 0, 0, 0)``. The result " "does not correspond to any Python release, but is useful in numeric " "comparisons." msgstr "" +"``Py_PACK_FULL_VERSION(major, minor, 0, 0, 0)`` と同等です。\n" +"結果は実際の Python リリースには対応しませんが、数値による比較に便利です。" diff --git a/c-api/arg.po b/c-api/arg.po index 041638a83..edbd1524e 100644 --- a/c-api/arg.po +++ b/c-api/arg.po @@ -18,22 +18,23 @@ msgstr "" "Last-Translator: Maciej Olko, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/arg.rst:6 msgid "Parsing arguments and building values" msgstr "引数の解釈と値の構築" -#: ../../c-api/arg.rst:8 msgid "" "These functions are useful when creating your own extension functions and " "methods. Additional information and examples are available in :ref:" "`extending-index`." msgstr "" +"これらの関数は、独自の拡張関数やメソッドを作成するときに便利です。\n" +"追加の情報や例は :ref:`extending-index` を参照してください。" #: ../../c-api/arg.rst:12 msgid "" @@ -53,7 +54,6 @@ msgstr "" msgid "Parsing arguments" msgstr "引数を解析する" -#: ../../c-api/arg.rst:21 msgid "" "A format string consists of zero or more \"format units.\" A format unit " "describes one Python object; it is usually a single character or a " @@ -64,13 +64,13 @@ msgid "" "Python object type that matches the format unit; and the entry in [square] " "brackets is the type of the C variable(s) whose address should be passed." msgstr "" -"書式文字列は、ゼロ個またはそれ以上の \"書式単位 (format unit)\" から成り立ち" -"ます。 1つの書式単位は1つの Python オブジェクトを表します; 通常は単一の文字" -"か、書式単位からなる文字列を括弧で囲ったものになります。例外として、括弧で囲" -"われていない書式単位文字列が単一のアドレス引数に対応する場合がいくつかありま" -"す。以下の説明では、引用符のついた形式は書式単位です; (丸)括弧で囲った部分は" -"書式単位に対応する Python のオブジェクト型です; [角] 括弧は値をアドレス渡しす" -"る際に使う C の変数型です。" +"書式文字列は、0 個以上の「書式単位 (format unit)」からなります。\n" +"書式単位は一つの Python オブジェクトを記述し、通常は単一の文字か、複数の書式" +"単位を丸括弧で囲んだものです。\n" +"丸括弧で囲まれた並びでない書式単位は、一部の例外を除き、これらの関数に渡す一" +"つのアドレス引数に対応します。\n" +"以下の説明では、引用符で囲んだものが書式単位、丸括弧内が対応する Python オブ" +"ジェクトの型、角括弧内がアドレスを渡す C 変数の型です。" #: ../../c-api/arg.rst:33 msgid "Strings and buffers" @@ -105,7 +105,6 @@ msgstr "特に言及されていない場合、バッファーは NUL 終端さ msgid "There are three ways strings and buffers can be converted to C:" msgstr "文字列とバッファをCに変換する方法は3つあります:" -#: ../../c-api/arg.rst:50 msgid "" "Formats such as ``y*`` and ``s*`` fill a :c:type:`Py_buffer` structure. This " "locks the underlying buffer so that the caller can subsequently use the " @@ -114,24 +113,24 @@ msgid "" "call** :c:func:`PyBuffer_Release` after you have finished processing the " "data (or in any early abort case)." msgstr "" -"形式としては ``y*`` そして ``s*`` 埋める :c:type:`Py_buffer` 構造体。これは" -"ロックします 根底 バッファ これにより、呼び出し元はその後、バッファを内部でも" -"使用できるようになります:c:type:`Py_BEGIN_ALLOW_THREADS` ブロック リスクなし" -"に 可変 データが再サイズ化または破壊される。その結果、**電話をかけなければな" -"らない** :c:func:`PyBuffer_Release` データ処理が完了した後(または早期終了の" -"場合)。" +"``y*`` や ``s*`` などの形式は :c:type:`Py_buffer` 構造体に情報を設定しま" +"す。\n" +"これによって内部バッファがロックされるので、呼び出し側は :c:type:" +"`Py_BEGIN_ALLOW_THREADS` ブロック内でも、可変データのサイズ変更や破棄の危険な" +"しにバッファを使えます。\n" +"そのため、データの処理が完了したときや途中で中止したときは、:c:func:" +"`PyBuffer_Release` を **必ず呼び出す必要があります**。" -#: ../../c-api/arg.rst:57 msgid "" "The ``es``, ``es#``, ``et`` and ``et#`` formats allocate the result buffer. " "**You have to call** :c:func:`PyMem_Free` after you have finished processing " "the data (or in any early abort case)." msgstr "" -"その ``es``, ``es#``, ``et`` そして ``et#`` フォーマットは結果を割り当てます " -"バッファ. **必ず電話をかけてください** :c:func:`PyMem_Free` データ処理が完了" -"した後(または早期終了の場合)。" +"``es``、``es#``、``et``、``et#`` 形式は、結果を格納するバッファを割り当てま" +"す。\n" +"データの処理が完了したときや途中で中止したときは、:c:func:`PyMem_Free` を **" +"必ず呼び出す必要があります**。" -#: ../../c-api/arg.rst:63 msgid "" "Other formats take a :class:`str` or a read-only :term:`bytes-like object`, " "such as :class:`bytes`, and provide a ``const char *`` pointer to its " @@ -139,33 +138,35 @@ msgid "" "corresponding Python object, and shares the lifetime of this object. You " "won't have to release any memory yourself." msgstr "" -"他の形式では :class:`str` または 読み出し専用 :term:`bytes-like オブジェクト" -"`、例えば :class:`bytes`, および提供する ``const char *`` ポインタ その " -"バッファ. この場合 バッファ「借用」されています:これは対応するPythonオブジェ" -"クトによって管理され、このオブジェクトのライフサイクルを共有します。メモリを" -"自分で解放する必要はありません。 " +"ほかの形式は :class:`str` または :class:`bytes` などの読み取り専用の :term:" +"`bytes-like オブジェクト ` を受け取り、そのバッファへの " +"``const char *`` ポインタを提供します。\n" +"この場合、バッファは「借用」されます。\n" +"対応する Python オブジェクトが管理し、そのオブジェクトと寿命を共有します。\n" +"メモリを自分で解放する必要はありません。" -#: ../../c-api/arg.rst:70 msgid "" "To ensure that the underlying buffer may be safely borrowed, the object's :c:" "member:`PyBufferProcs.bf_releasebuffer` field must be ``NULL``. This " "disallows common mutable objects such as :class:`bytearray`, but also some " "read-only objects such as :class:`memoryview` of :class:`bytes`." msgstr "" -"以下のことを確実にするため 根底 バッファ 安全に借りることができます, 対象の :" -"c:member:`PyBufferProcs.bf_releasebuffer` フィールドは必須です。 ``NULL``. こ" -"れは一般的な 可変 次のようなオブジェクト :class:`bytearray`, また、いくつか" -"の 読み出し専用 次のようなオブジェクト :class:`memoryview` の :class:`bytes`." +"内部バッファを安全に借用できるように、オブジェクトの :c:member:" +"`PyBufferProcs.bf_releasebuffer` フィールドは ``NULL`` でなければなりませ" +"ん。\n" +"この条件により、:class:`bytearray` のような一般的な可変オブジェクトだけでな" +"く、:class:`bytes` の :class:`memoryview` のような一部の読み取り専用オブジェ" +"クトも受け付けません。" -#: ../../c-api/arg.rst:76 msgid "" "Besides this ``bf_releasebuffer`` requirement, there is no check to verify " "whether the input object is immutable (e.g. whether it would honor a request " "for a writable buffer, or whether another thread can mutate the data)." msgstr "" -"これに加えて ``bf_releasebuffer`` 要件として、入力が有効かどうかを確認する" -"チェックはありません 対象は 不変 (例:請求に応じるかどうか 書き込み可能 バッ" -"ファ, または、別のスレッドがデータを変更できるかどうか)。" +"この ``bf_releasebuffer`` の要件以外に、入力オブジェクトが不変かどうかを確認" +"するチェックはありません。\n" +"例えば、書き込み可能なバッファの要求に応じるかどうかや、別のスレッドがデータ" +"を変更できるかどうかは確認しません。" #: ../../c-api/arg.rst:80 msgid "``s`` (:class:`str`) [const char \\*]" @@ -234,7 +235,6 @@ msgstr "" "``s#`` (:class:`str`, 読み取り専用の :term:`bytes-like object`) [const char " "\\*, :c:type:`Py_ssize_t`]" -#: ../../c-api/arg.rst:107 msgid "" "Like ``s*``, except that it provides a :ref:`borrowed buffer `. The result is stored into two C variables, the first one a pointer " @@ -242,11 +242,13 @@ msgid "" "null bytes. Unicode objects are converted to C strings using ``'utf-8'`` " "encoding." msgstr "" -"のように ``s*``, ただし、それは :ref:`借用された バッファ `. 結果は2つのC変数に格納されます。最初の変数はC文字列へのポインター、" -"2つ目の変数はその長さです。文字列には埋め込まれたヌルバイトが含まれる可能性が" -"あります。Unicodeオブジェクトは、C文字列に変換されます ``'utf-8'`` エンコー" -"ド。" +"``s*`` と同様ですが、:ref:`借用バッファ ` を提供しま" +"す。\n" +"結果は二つの C 変数に格納され、一つ目は C 文字列へのポインタ、二つ目はその長" +"さです。\n" +"文字列にはヌルバイトが埋め込まれていても構いません。\n" +"Unicode オブジェクトは ``'utf-8'`` エンコーディングで C 文字列に変換されま" +"す。" #: ../../c-api/arg.rst:113 ../../c-api/arg.rst:648 msgid "``z`` (:class:`str` or ``None``) [const char \\*]" @@ -295,17 +297,17 @@ msgstr "" msgid "``y`` (read-only :term:`bytes-like object`) [const char \\*]" msgstr "``y`` (読み出し専用の :term:`bytes-like object`) [const char \\*]" -#: ../../c-api/arg.rst:126 msgid "" "This format converts a bytes-like object to a C pointer to a :ref:`borrowed " "` character string; it does not accept Unicode " "objects. The bytes buffer must not contain embedded null bytes; if it does, " "a :exc:`ValueError` exception is raised." msgstr "" -"この形式は bytes-like Cポインタへのオブジェクトへの参照を拒否する :ref:" -"`borrowed ` 文字列; Unicode オブジェクトは受け付けませ" -"ん。 バイトバッファには埋め込みのヌルバイトを含んではいけません。もし含まれて" -"いる場合 :exc:`ValueError` 例外が発生します。" +"bytes-like オブジェクトを、:ref:`借用した ` 文字列へ" +"の C ポインタに変換します。\n" +"Unicode オブジェクトは受け付けません。\n" +"バイトバッファにはヌルバイトを埋め込めません。\n" +"含まれている場合は :exc:`ValueError` 例外を送出します。" #: ../../c-api/arg.rst:132 msgid "" @@ -393,13 +395,18 @@ msgstr "" msgid "``w*`` (read-write :term:`bytes-like object`) [Py_buffer]" msgstr "``w*`` (読み書き可能な :term:`bytes-like object`) [Py_buffer]" -#: ../../c-api/arg.rst:161 msgid "" "This format accepts any object which implements the read-write buffer " "interface. It fills a :c:type:`Py_buffer` structure provided by the caller. " "The buffer may contain embedded null bytes. The caller has to call :c:func:" "`PyBuffer_Release` when it is done with the buffer." msgstr "" +"この形式は、読み書き可能なバッファインターフェースを実装する任意のオブジェク" +"トを受け付けます。\n" +"呼び出し側が用意した :c:type:`Py_buffer` 構造体に情報を設定します。\n" +"バッファにはヌルバイトが埋め込まれていても構いません。\n" +"呼び出し側は、バッファを使い終わったら :c:func:`PyBuffer_Release` を呼び出す" +"必要があります。" #: ../../c-api/arg.rst:166 msgid "``es`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer]" @@ -469,15 +476,13 @@ msgstr "" "``es#`` (:class:`str`) [const char \\*encoding, char \\*\\*buffer, :c:type:" "`Py_ssize_t` \\*buffer_length]" -#: ../../c-api/arg.rst:189 msgid "" "This variant on ``s#`` is used for encoding Unicode into a character buffer. " "Unlike the ``es`` format, this variant allows input data which contains NUL " "characters." msgstr "" -"``s#`` の変化形で、Unicode をキャラクタ型バッファにエンコードするために用いら" -"れます。``es`` 書式違って、この変化形はバイトが埋め込まれていてもかまいませ" -"ん。" +"``s#`` の変種で、Unicode を文字バッファにエンコードするために使います。\n" +"``es`` 形式と異なり、NUL 文字を含む入力データを受け付けます。" #: ../../c-api/arg.rst:193 msgid "" @@ -558,17 +563,17 @@ msgstr "" "します。その代わり、実装ではバイト文字列オブジェクトがパラメタに渡したエン" "コードを使っているものと仮定します。" -#: ../../c-api/arg.rst:224 msgid "" "``u``, ``u#``, ``Z``, and ``Z#`` are removed because they used a legacy " "``Py_UNICODE*`` representation." msgstr "" +"従来の ``Py_UNICODE*`` 表現を使っていたため、``u``、``u#``、``Z``、``Z#`` を" +"削除しました。" #: ../../c-api/arg.rst:230 msgid "Numbers" msgstr "数" -#: ../../c-api/arg.rst:232 msgid "" "These formats allow representing Python numbers or single characters as C " "numbers. Formats that require :class:`int`, :class:`float` or :class:" @@ -576,6 +581,12 @@ msgid "" "__index__`, :meth:`~object.__float__` or :meth:`~object.__complex__` to " "convert the Python object to the required type." msgstr "" +"これらの形式は、Python の数値や単一の文字を C の数値として表すためのもので" +"す。\n" +":class:`int`、:class:`float`、:class:`complex` を必要とする形式では、対応する" +"特殊メソッド :meth:`~object.__index__`、:meth:`~object.__float__`、:meth:" +"`~object.__complex__` で Python オブジェクトを必要な型に変換することもできま" +"す。" #: ../../c-api/arg.rst:238 msgid "" @@ -591,22 +602,25 @@ msgstr "" msgid "``b`` (:class:`int`) [unsigned char]" msgstr "``b`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:247 msgid "" "Convert a nonnegative Python integer to an unsigned tiny integer, stored in " "a C :c:expr:`unsigned char`." msgstr "" +"負でない Python 整数を小さい符号なし整数に変換し、C の :c:expr:`unsigned " +"char` に格納します。" #: ../../c-api/arg.rst:250 ../../c-api/arg.rst:682 msgid "``B`` (:class:`int`) [unsigned char]" msgstr "``B`` (:class:`int`) [unsigned char]" -#: ../../c-api/arg.rst:251 msgid "" "Convert a Python integer to a tiny integer without overflow checking, stored " "in a C :c:expr:`unsigned char`. Convert a Python integer to a C :c:expr:" "`unsigned char`." msgstr "" +"Python 整数を、オーバーフローチェックなしに小さい整数に変換し、C の :c:expr:" +"`unsigned char` に格納します。\n" +"Python 整数から C の :c:expr:`unsigned char` への変換です。" #: ../../c-api/arg.rst:255 ../../c-api/arg.rst:676 msgid "``h`` (:class:`int`) [short int]" @@ -620,9 +634,8 @@ msgstr "Python の整数を、 C の :c:expr:`short int` 型に変換します msgid "``H`` (:class:`int`) [unsigned short int]" msgstr "``H`` (:class:`int`) [unsigned short int]" -#: ../../c-api/arg.rst:259 msgid "Convert a Python integer to a C :c:expr:`unsigned short int`." -msgstr "" +msgstr "Python 整数を C の :c:expr:`unsigned short int` に変換します。" #: ../../c-api/arg.rst:261 ../../c-api/arg.rst:670 msgid "``i`` (:class:`int`) [int]" @@ -636,9 +649,8 @@ msgstr "Python の整数を、 C の :c:expr:`int` 型に変換します。" msgid "``I`` (:class:`int`) [unsigned int]" msgstr "``I`` (:class:`int`) [unsigned int]" -#: ../../c-api/arg.rst:265 msgid "Convert a Python integer to a C :c:expr:`unsigned int`." -msgstr "" +msgstr "Python 整数を C の :c:expr:`unsigned int` に変換します。" #: ../../c-api/arg.rst:267 ../../c-api/arg.rst:679 msgid "``l`` (:class:`int`) [long int]" @@ -652,9 +664,8 @@ msgstr "Python の整数を、 C の :c:expr:`long int` 型に変換します。 msgid "``k`` (:class:`int`) [unsigned long]" msgstr "``k`` (:class:`int`) [unsigned long]" -#: ../../c-api/arg.rst:271 msgid "Convert a Python integer to a C :c:expr:`unsigned long`." -msgstr "" +msgstr "Python 整数を C の :c:expr:`unsigned long` に変換します。" #: ../../c-api/arg.rst:273 ../../c-api/arg.rst:282 msgid "Use :meth:`~object.__index__` if available." @@ -672,9 +683,8 @@ msgstr "Python の整数を、 C の :c:expr:`long long` 型に変換します msgid "``K`` (:class:`int`) [unsigned long long]" msgstr "``K`` (:class:`int`) [unsigned long long]" -#: ../../c-api/arg.rst:280 msgid "Convert a Python integer to a C :c:expr:`unsigned long long`." -msgstr "" +msgstr "Python 整数を C の :c:expr:`unsigned long long` に変換します。" #: ../../c-api/arg.rst:285 ../../c-api/arg.rst:702 msgid "``n`` (:class:`int`) [:c:type:`Py_ssize_t`]" @@ -716,17 +726,15 @@ msgstr "" msgid "``f`` (:class:`float`) [float]" msgstr "``f`` (:class:`float`) [float]" -#: ../../c-api/arg.rst:300 msgid "Convert a Python floating-point number to a C :c:expr:`float`." -msgstr "" +msgstr "Python の浮動小数点数を C の :c:expr:`float` に変換します。" #: ../../c-api/arg.rst:302 ../../c-api/arg.rst:724 msgid "``d`` (:class:`float`) [double]" msgstr "``d`` (:class:`float`) [double]" -#: ../../c-api/arg.rst:303 msgid "Convert a Python floating-point number to a C :c:expr:`double`." -msgstr "" +msgstr "Python の浮動小数点数を C の :c:expr:`double` に変換します。" #: ../../c-api/arg.rst:305 msgid "``D`` (:class:`complex`) [Py_complex]" @@ -736,13 +744,15 @@ msgstr "``D`` (:class:`complex`) [Py_complex]" msgid "Convert a Python complex number to a C :c:type:`Py_complex` structure." msgstr "Python の複素数型を、 C の :c:type:`Py_complex` 構造体に変換します。" -#: ../../c-api/arg.rst:310 msgid "" "For unsigned integer formats ``B``, ``H``, ``I``, ``k`` and ``K``, :exc:" "`DeprecationWarning` is emitted when the value is larger than the maximal " "value for the C type or less than the minimal value for the corresponding " "signed integer type of the same size." msgstr "" +"符号なし整数の形式 ``B``、``H``、``I``、``k``、``K`` では、値が C の型の最大" +"値を超える場合、または同じサイズの対応する符号付き整数型の最小値より小さい場" +"合に :exc:`DeprecationWarning` を発生させます。" #: ../../c-api/arg.rst:317 msgid "Other objects" @@ -759,10 +769,10 @@ msgid "" "`strong reference` to the object is not created (i.e. its reference count is " "not increased). The pointer stored is not ``NULL``." msgstr "" -"Python オブジェクトを(変換なしで)C オブジェクトのポインターに格納します。 " -"これにより、C プログラムは渡された実際のオブジェクトを受け取ります。新しい :" -"term: 強参照 オブジェクトが作成されていません (すなわち、その参照カウント 増" -"加しません)。その ポインタ 保存されていない ``NULL``." +"Python オブジェクトを変換せずに C オブジェクトのポインタに格納します。これに" +"より、C プログラムは渡されたオブジェクトそのものを受け取ります。オブジェクト" +"への新しい :term:`強参照 ` は作成されません(つまり、参照カ" +"ウントは増加しません)。格納されるポインタは ``NULL`` ではありません。" #: ../../c-api/arg.rst:326 msgid "``O!`` (object) [*typeobject*, PyObject \\*]" @@ -782,9 +792,8 @@ msgstr "" "c:expr:`PyObject*` の) C の変数へのアドレスです。Python オブジェクトが指定し" "た型ではない場合、 :exc:`TypeError` を送出します。" -#: ../../c-api/arg.rst:335 msgid "``O&`` (object) [*converter*, *address*]" -msgstr "" +msgstr "``O&`` (オブジェクト) [*converter*, *address*]" #: ../../c-api/arg.rst:336 msgid "" @@ -798,9 +807,8 @@ msgstr "" "expr:`void *` 型に変換したものです。 *converter* は以下のようにして呼び出され" "ます::" -#: ../../c-api/arg.rst:341 msgid "status = converter(object, address);" -msgstr "" +msgstr "status = converter(object, address);" #: ../../c-api/arg.rst:343 msgid "" @@ -817,7 +825,6 @@ msgstr "" "合、 *converter* 関数は *address* の内容を変更せずに例外を送出しなくてはなり" "ません。" -#: ../../c-api/arg.rst:352 msgid "" "If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get " "called a second time if the argument parsing eventually fails, giving the " @@ -825,16 +832,21 @@ msgid "" "this second call, the *object* parameter will be ``NULL``; *address* will " "have the same value as in the original call." msgstr "" +"``converter`` が :c:macro:`!Py_CLEANUP_SUPPORTED` を返した場合、後で引数の解" +"析に失敗すると、すでに割り当てたメモリを解放できるように再び呼び出されること" +"があります。\n" +"この 2 回目の呼び出しでは、``object`` 引数は ``NULL``、``address`` は最初の呼" +"び出しと同じ値になります。" -#: ../../c-api/arg.rst:358 msgid "" "Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:" "`PyUnicode_FSDecoder`." msgstr "" +"変換関数の例: :c:func:`PyUnicode_FSConverter` と :c:func:" +"`PyUnicode_FSDecoder`。" -#: ../../c-api/arg.rst:361 msgid ":c:macro:`!Py_CLEANUP_SUPPORTED` was added." -msgstr "" +msgstr ":c:macro:`!Py_CLEANUP_SUPPORTED` を追加しました。" #: ../../c-api/arg.rst:364 ../../c-api/arg.rst:705 msgid "``p`` (:class:`bool`) [int]" @@ -855,19 +867,21 @@ msgstr "" "Pythonが値の真偽をどのように判定するかを知りたければ、 :ref:`truth` を参照し" "てください。" -#: ../../c-api/arg.rst:373 msgid "``(items)`` (sequence) [*matching-items*]" -msgstr "" +msgstr "``(items)`` (シーケンス) [*matching-items*]" -#: ../../c-api/arg.rst:374 msgid "" "The object must be a Python sequence (except :class:`str`, :class:`bytes` " "or :class:`bytearray`) whose length is the number of format units in " "*items*. The C arguments must correspond to the individual format units in " "*items*. Format units for sequences may be nested." msgstr "" +"オブジェクトは、長さが ``items`` 内の書式単位の数と等しい Python のシーケンス" +"でなければなりません (:class:`str`、:class:`bytes`、:class:`bytearray` は除き" +"ます)。\n" +"C の引数は ``items`` 内の各書式単位に対応している必要があります。\n" +"シーケンスの書式単位はネストできます。" -#: ../../c-api/arg.rst:379 msgid "" "If *items* contains format units which store a :ref:`borrowed buffer ` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``) or a :" @@ -875,17 +889,25 @@ msgid "" "object must be a Python tuple. The *converter* for the ``O&`` format unit in " "*items* must not store a borrowed buffer or a borrowed reference." msgstr "" +"``items`` に :ref:`借用バッファ ` (``s``、``s#``、" +"``z``、``z#``、``y``、``y#``) または :term:`借用参照 ` " +"(``S``、``Y``、``U``、``O``、``O!``) を格納する書式単位が含まれる場合、オブ" +"ジェクトは Python のタプルでなければなりません。\n" +"``items`` 内の ``O&`` 書式単位の ``converter`` は、借用バッファや借用参照を格" +"納してはいけません。" -#: ../../c-api/arg.rst:386 msgid "" ":class:`str` and :class:`bytearray` objects no longer accepted as a sequence." msgstr "" +":class:`str` と :class:`bytearray` オブジェクトをシーケンスとして受け付けなく" +"なりました。" -#: ../../c-api/arg.rst:389 msgid "" "Non-tuple sequences are deprecated if *items* contains format units which " "store a borrowed buffer or a borrowed reference." msgstr "" +"``items`` に借用バッファまたは借用参照を格納する書式単位が含まれる場合、タプ" +"ル以外のシーケンスは非推奨になりました。" #: ../../c-api/arg.rst:393 msgid "" @@ -899,7 +921,6 @@ msgstr "" msgid "``|``" msgstr "``|``" -#: ../../c-api/arg.rst:397 msgid "" "Indicates that the remaining arguments in the Python argument list are " "optional. The C variables corresponding to optional arguments should be " @@ -908,12 +929,18 @@ msgid "" "corresponding C variable(s). For example, the format string ``\"OO|OO\"`` " "corresponds to the Python signature ``f(a, b, c=None, d=None)``." msgstr "" +"Python の引数リストの残りの引数が省略可能であることを示します。\n" +"省略可能な引数に対応する C 変数は、デフォルト値で初期化しておく必要がありま" +"す。\n" +"引数が省略された場合、:c:func:`PyArg_ParseTuple` は対応する C 変数の内容を変" +"更しません。\n" +"例えば、書式文字列 ``\"OO|OO\"`` は Python のシグネチャ ``f(a, b, c=None, " +"d=None)`` に対応します。" #: ../../c-api/arg.rst:405 msgid "``$``" msgstr "``$``" -#: ../../c-api/arg.rst:406 msgid "" ":c:func:`PyArg_ParseTupleAndKeywords` only: Indicates that the remaining " "arguments in the Python argument list are keyword-only. They are optional if " @@ -922,6 +949,12 @@ msgid "" "corresponds to the Python signature ``f(a, b=None, *, c=None)``, and the " "format string ``\"OO$OO\"`` corresponds to ``f(a, b, *, c, d)``." msgstr "" +":c:func:`PyArg_ParseTupleAndKeywords` のみ: Python の引数リストの残りの引数が" +"キーワード専用であることを示します。\n" +"``$`` より前に ``|`` があれば省略可能で、なければ必須です。\n" +"``$`` より後に ``|`` は指定できません。\n" +"例えば書式文字列 ``\"O|O$O\"`` は Python のシグネチャ ``f(a, b=None, *, " +"c=None)`` に対応し、``\"OO$OO\"`` は ``f(a, b, *, c, d)`` に対応します。" #: ../../c-api/arg.rst:417 msgid "``:``" @@ -1013,7 +1046,6 @@ msgstr "" ":c:func:`PyArg_ParseTuple` と同じですが、可変長の引数ではなく *va_list* を引" "数にとります。" -#: ../../c-api/arg.rst:463 msgid "" "Parse the parameters of a function that takes both positional and keyword " "parameters into local variables. The *keywords* argument is a ``NULL``-" @@ -1022,13 +1054,21 @@ msgid "" "parameters `. Returns true on success; on " "failure, it returns false and raises the appropriate exception." msgstr "" +"位置引数とキーワード引数を受け取る関数の引数を解析し、ローカル変数に格納しま" +"す。\n" +"``keywords`` 引数は、ヌル終端の ASCII または UTF-8 エンコード C 文字列で指定" +"された仮引数名の配列で、``NULL`` で終端する必要があります。\n" +"空の名前は :ref:`位置専用仮引数 ` を表します。\n" +"成功した場合は真を返し、失敗した場合は適切な例外を送出して偽を返します。" -#: ../../c-api/arg.rst:474 msgid "" "The *keywords* parameter declaration is :c:expr:`char * const *` in C and :c:" "expr:`const char * const *` in C++. This can be overridden with the :c:macro:" "`PY_CXX_CONST` macro." msgstr "" +"``keywords`` 引数の宣言は、C では :c:expr:`char * const *`、C++ では :c:expr:" +"`const char * const *` です。\n" +":c:macro:`PY_CXX_CONST` マクロで変更できます。" #: ../../c-api/arg.rst:478 msgid "" @@ -1036,12 +1076,14 @@ msgid "" "only_parameter>`." msgstr ":ref:`位置専用引数 ` を追加した。" -#: ../../c-api/arg.rst:482 msgid "" "The *keywords* parameter has now type :c:expr:`char * const *` in C and :c:" "expr:`const char * const *` in C++, instead of :c:expr:`char **`. Added " "support for non-ASCII keyword parameter names." msgstr "" +"``keywords`` 引数の型は :c:expr:`char **` ではなく、C では :c:expr:`char * " +"const *`、C++ では :c:expr:`const char * const *` になりました。\n" +"非 ASCII のキーワード仮引数名をサポートするようになりました。" #: ../../c-api/arg.rst:491 msgid "" @@ -1061,18 +1103,18 @@ msgstr "" "は :c:func:`PyArg_ParseTupleAndKeywords` を使用しないときにのみ必要で、その理" "由は後者の関数は同様のチェックを実施するためです。" -#: ../../c-api/arg.rst:506 msgid "" "Parse the parameter of a function that takes a single positional parameter " "into a local variable. Returns true on success; on failure, it returns " "false and raises the appropriate exception." msgstr "" +"一つの位置引数を受け取る関数の引数を解析し、ローカル変数に格納します。\n" +"成功した場合は真を返し、失敗した場合は適切な例外を送出して偽を返します。" #: ../../c-api/arg.rst:510 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../c-api/arg.rst:512 msgid "" "// Function using METH_O calling convention\n" "static PyObject*\n" @@ -1085,16 +1127,27 @@ msgid "" " // ... use value ...\n" "}" msgstr "" +"// METH_O 呼び出し規約を使う関数\n" +"static PyObject*\n" +"my_function(PyObject *module, PyObject *arg)\n" +"{\n" +" int value;\n" +" if (!PyArg_Parse(arg, \"i:my_function\", &value)) {\n" +" return NULL;\n" +" }\n" +" // ... value を使う ...\n" +"}" -#: ../../c-api/arg.rst:526 msgid "" "Parse the parameters of a function that takes only array parameters into " "local variables (that is, a function using the :c:macro:`METH_FASTCALL` " "calling convention). Returns true on success; on failure, it returns false " "and raises the appropriate exception." msgstr "" +"配列形式の引数だけを受け取る関数 (つまり :c:macro:`METH_FASTCALL` 呼び出し規" +"約の関数) の引数を解析し、ローカル変数に格納します。\n" +"成功した場合は真を返し、失敗した場合は適切な例外を送出して偽を返します。" -#: ../../c-api/arg.rst:537 msgid "" "Parse the parameters of a function that takes both array and keyword " "parameters into local variables (that is, a function using the :c:macro:" @@ -1102,8 +1155,11 @@ msgid "" "true on success; on failure, it returns false and raises the appropriate " "exception." msgstr "" +"配列形式の引数とキーワード引数を受け取る関数 (つまり :c:macro:" +"`METH_FASTCALL` ``|`` :c:macro:`METH_KEYWORDS` 呼び出し規約の関数) の引数を解" +"析し、ローカル変数に格納します。\n" +"成功した場合は真を返し、失敗した場合は適切な例外を送出して偽を返します。" -#: ../../c-api/arg.rst:548 msgid "" "A simpler form of parameter retrieval which does not use a format string to " "specify the types of the arguments. Functions which use this method to " @@ -1120,28 +1176,30 @@ msgid "" "a tuple or contains the wrong number of elements; an exception will be set " "if there was a failure." msgstr "" -"パラメーターの取得方法のよりシンプルな形式で、使用しないもの a 書式文字列 引" -"数の型を指定する 。関数 これを使用する メソッド 彼らの パラメータ 次のように" -"宣言する必要があります :c:macro:`METH_VARARGS` に 関数 にメソッド テーブル。" -"実際のパラメーターを含むタプルは *args* として渡す必要があります。必ずタプル" -"でなければなりません。タプルの長さは、*min*以上で*max*以下でなければなりませ" -"ん。*min*と*max*は等しい場合もあります。関数には追加の引数を渡す必要があり、" -"各引数はポインターでなければならない ~へ:c:expr:`PyObject*` 変数;これらは" -"*args*の値で埋められる;これらは:term:を含む :term:`借用参照 `。*args* で指定されていないオプションパラメーターに対応する変数は" -"初期化されません。これらの変数は呼び出し元で初期化する必要があります。これ 関" -"数 成功した場合にtrueを返し、*args*がタプルでない場合または要素の数が間違って" -"いる場合にfalseを返します。失敗した場合、例外が設定されます。" - -#: ../../c-api/arg.rst:563 +"引数の型を指定する書式文字列を使わない、より単純な引数の取得方法です。\n" +"この方法で引数を取得する関数は、関数テーブルやメソッドテーブルで :c:macro:" +"`METH_VARARGS` として宣言してください。\n" +"引数を含むタプルを ``args`` として渡します。\n" +"これは必ずタプルでなければなりません。\n" +"タプルの長さは ``min`` 以上 ``max`` 以下で、``min`` と ``max`` は等しくても構" +"いません。\n" +"追加の引数は、それぞれ :c:expr:`PyObject*` 変数へのポインタとして渡す必要があ" +"ります。\n" +"これらの変数には ``args`` からの値が :term:`借用参照 ` と" +"して格納されます。\n" +"省略可能な引数が ``args`` にない場合、対応する変数は変更されないので、呼び出" +"し側で初期化しておいてください。\n" +"成功した場合は真を返します。\n" +"``args`` がタプルでないか、要素数が正しくない場合は、例外を設定して偽を返しま" +"す。" + msgid "" "This is an example of the use of this function, taken from the sources for " "the :mod:`!_weakref` helper module for weak references::" msgstr "" -"これは、この関数の使用例で、ソースコードから抜粋したものです:mod:`!_weakref` " -"弱参照用のヘルパーモジュール::" +"弱参照用の補助モジュール :mod:`!_weakref` のソースから抜粋した、この関数の使" +"用例です。 ::" -#: ../../c-api/arg.rst:566 msgid "" "static PyObject *\n" "weakref_ref(PyObject *self, PyObject *args)\n" @@ -1156,6 +1214,18 @@ msgid "" " return result;\n" "}" msgstr "" +"static PyObject *\n" +"weakref_ref(PyObject *self, PyObject *args)\n" +"{\n" +" PyObject *object;\n" +" PyObject *callback = NULL;\n" +" PyObject *result = NULL;\n" +"\n" +" if (PyArg_UnpackTuple(args, \"ref\", 1, 2, &object, &callback)) {\n" +" result = PyWeakref_NewRef(object, callback);\n" +" }\n" +" return result;\n" +"}" #: ../../c-api/arg.rst:579 msgid "" @@ -1165,11 +1235,9 @@ msgstr "" "この例における :c:func:`PyArg_UnpackTuple` 呼び出しは、 :c:func:" "`PyArg_ParseTuple` を使った以下の呼び出しと全く等価です::" -#: ../../c-api/arg.rst:582 msgid "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -msgstr "" +msgstr "PyArg_ParseTuple(args, \"O|O:ref\", &object, &callback)" -#: ../../c-api/arg.rst:586 msgid "" "The value to be inserted, if any, before :c:expr:`char * const *` in the " "*keywords* parameter declaration of :c:func:`PyArg_ParseTupleAndKeywords` " @@ -1177,6 +1245,13 @@ msgid "" "``const`` for C++ (:c:expr:`const char * const *`). To override, define it " "to the desired value before including :file:`Python.h`." msgstr "" +":c:func:`PyArg_ParseTupleAndKeywords` と :c:func:" +"`PyArg_VaParseTupleAndKeywords` の ``keywords`` 引数の宣言で、:c:expr:`char " +"* const *` の前に挿入する値を指定します。\n" +"デフォルトは C では空、C++ では ``const`` です (:c:expr:`const char * const " +"*`)。\n" +"変更するには :file:`Python.h` をインクルードする前に、必要な値を定義してくだ" +"さい。" #: ../../c-api/arg.rst:600 msgid "Building values" @@ -1403,17 +1478,20 @@ msgstr "C :c:expr:`unsigned long long` をPythonのintオブジェクトへ変 msgid "Convert a C :c:type:`Py_ssize_t` to a Python integer." msgstr "C の :c:type:`Py_ssize_t` を Python の整数オブジェクトに変換します。" -#: ../../c-api/arg.rst:706 msgid "Convert a C :c:expr:`int` to a Python :class:`bool` object." msgstr "" +"C の :c:expr:`int` を Python の :class:`bool` オブジェクトに変換します。" -#: ../../c-api/arg.rst:708 msgid "" "Be aware that this format requires an ``int`` argument. Unlike most other " "contexts in C, variadic arguments are not coerced to a suitable type " "automatically. You can convert another type (for example, a pointer or a " "float) to a suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``." msgstr "" +"この形式には ``int`` 引数が必要です。\n" +"C のほかの多くの場面と異なり、可変長引数は適切な型に自動変換されません。\n" +"ポインタや浮動小数点数など別の型は、``(x) ? 1 : 0`` または ``!!x`` で適切な " +"``int`` 値に変換できます。" #: ../../c-api/arg.rst:716 msgid "``c`` (:class:`bytes` of length 1) [char]" @@ -1435,13 +1513,11 @@ msgstr "" "文字を表す通常の C の :c:expr:`int` を、長さ 1 の Python の :class:`str` オブ" "ジェクトに変換します。" -#: ../../c-api/arg.rst:725 msgid "Convert a C :c:expr:`double` to a Python floating-point number." -msgstr "" +msgstr "C の :c:expr:`double` を Python の浮動小数点数に変換します。" -#: ../../c-api/arg.rst:728 msgid "Convert a C :c:expr:`float` to a Python floating-point number." -msgstr "" +msgstr "C の :c:expr:`float` を Python の浮動小数点数に変換します。" #: ../../c-api/arg.rst:730 msgid "``D`` (:class:`complex`) [Py_complex \\*]" @@ -1451,7 +1527,6 @@ msgstr "``D`` (:class:`complex`) [Py_complex \\*]" msgid "Convert a C :c:type:`Py_complex` structure to a Python complex number." msgstr "C の :c:type:`Py_complex` 構造体を Python の複素数型に変換します。" -#: ../../c-api/arg.rst:734 msgid "" "Pass a Python object untouched but create a new :term:`strong reference` to " "it (i.e. its reference count is incremented by one). If the object passed in " @@ -1460,12 +1535,13 @@ msgid "" "func:`Py_BuildValue` will return ``NULL`` but won't raise an exception. If " "no exception has been raised yet, :exc:`SystemError` is set." msgstr "" -"Python オブジェクトをそのまま渡すものの、それに対する新しい :term:`強参照` を" -"作成する(つまり、その参照カウントが1増加します)。渡されたオブジェクトが " -"``NULL`` ポインタ, この問題は、引数を生成する呼び出しがエラーを検出し、例外を" -"設定したため発生したものと推測されます。したがって、:c:func:`Py_BuildValue` " -"戻ってきます ``NULL`` しかし、そうはならない 送出 例外。 例外がまだ発生してい" -"ない場合、:exc:`SystemError` 設定されています。" +"Python オブジェクトをそのまま渡し、そのオブジェクトへの新しい :term:`強参照 " +"` を作成します (つまり参照カウントを 1 増やします)。\n" +"渡されたオブジェクトが ``NULL`` ポインタなら、引数を生成した呼び出しがエラー" +"を検出して例外を設定したものとみなします。\n" +"この場合、:c:func:`Py_BuildValue` は ``NULL`` を返しますが、新しい例外は送出" +"しません。\n" +"まだ例外が設定されていなければ :exc:`SystemError` を設定します。" #: ../../c-api/arg.rst:743 msgid "``S`` (object) [PyObject \\*]" @@ -1485,9 +1561,9 @@ msgid "" "Useful when the object is created by a call to an object constructor in the " "argument list." msgstr "" -"同じです ``O``, ただし、新しい :term:`強参照` を作成しません。オブジェクトが" -"引数リスト内のオブジェクトコンストラクターの呼び出しによって作成される場合に" -"便利です。" +"同じです ``O``, ただし、新しい :term:`強参照 ` を作成しませ" +"ん。オブジェクトが引数リスト内のオブジェクトコンストラクターの呼び出しによっ" +"て作成される場合に便利です。" #: ../../c-api/arg.rst:751 msgid "``O&`` (object) [*converter*, *anything*]" @@ -1509,34 +1585,31 @@ msgstr "" msgid "``(items)`` (:class:`tuple`) [*matching-items*]" msgstr "``(items)`` (:class:`tuple`) [*matching-items*]" -#: ../../c-api/arg.rst:758 msgid "" "Convert a sequence of C values to a Python tuple with the same number of " "items." -msgstr "C の値からなる配列を、同じ要素数を持つ Python のタプルに変換します。" +msgstr "C の値の並びを、同じ要素数の Python のタプルに変換します。" #: ../../c-api/arg.rst:760 msgid "``[items]`` (:class:`list`) [*matching-items*]" msgstr "``[items]`` (:class:`list`) [*matching-items*]" -#: ../../c-api/arg.rst:761 msgid "" "Convert a sequence of C values to a Python list with the same number of " "items." -msgstr "C の値からなる配列を、同じ要素数を持つ Python のリストに変換します。" +msgstr "C の値の並びを、同じ要素数の Python のリストに変換します。" #: ../../c-api/arg.rst:763 msgid "``{items}`` (:class:`dict`) [*matching-items*]" msgstr "``{items}`` (:class:`dict`) [*matching-items*]" -#: ../../c-api/arg.rst:764 msgid "" "Convert a sequence of C values to a Python dictionary. Each pair of " "consecutive C values adds one item to the dictionary, serving as key and " "value, respectively." msgstr "" -"C の値からなる配列を Python の辞書に変換します。一連のペアからなる C の値が、" -"それぞれキーおよび値となって辞書に追加されます。" +"C の値の並びを Python の辞書に変換します。\n" +"連続する二つの C の値をそれぞれキーと値として、辞書に一つの要素を追加します。" #: ../../c-api/arg.rst:768 msgid "" diff --git a/c-api/bool.po b/c-api/bool.po index 97218c5d6..235949b5e 100644 --- a/c-api/bool.po +++ b/c-api/bool.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/bool.rst:6 diff --git a/c-api/buffer.po b/c-api/buffer.po index 935bbfc2f..d83f2bb93 100644 --- a/c-api/buffer.po +++ b/c-api/buffer.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/buffer.rst:11 @@ -51,26 +51,33 @@ msgstr "" "ファからなるという共通の特徴を共有します。いくつかの状況では仲介するコピーを" "行うことなく直接バッファにアクセスすることが望まれます。" -#: ../../c-api/buffer.rst:24 msgid "" "Python provides such a facility at the C and Python level in the form of " "the :ref:`buffer protocol `. This protocol has two sides:" msgstr "" +"Python は :ref:`バッファプロトコル ` によって、C レベルと " +"Python レベルでこの機能を提供します。\n" +"このプロトコルには二つの側面があります。" -#: ../../c-api/buffer.rst:29 msgid "" "on the producer side, a type can export a \"buffer interface\" which allows " "objects of that type to expose information about their underlying buffer. " "This interface is described in the section :ref:`buffer-structs`; for Python " "see :ref:`python-buffer-protocol`." msgstr "" +"提供する側では、型は「バッファインターフェース」を公開し、その型のオブジェク" +"トが内部バッファの情報を公開できるようにします。\n" +"このインターフェースは :ref:`buffer-structs` で説明します。\n" +"Python 側については :ref:`python-buffer-protocol` を参照してください。" -#: ../../c-api/buffer.rst:34 msgid "" "on the consumer side, several means are available to obtain a pointer to the " "raw underlying data of an object (for example a method parameter). For " "Python see :class:`memoryview`." msgstr "" +"利用する側には、例えばメソッドの引数として受け取ったオブジェクトの内部の生" +"データへのポインタを取得する方法がいくつかあります。\n" +"Python 側については :class:`memoryview` を参照してください。" #: ../../c-api/buffer.rst:38 msgid "" @@ -134,11 +141,12 @@ msgstr "" "呼び出さなければなりません。これを怠ると、リソースリークのような様々な問題に" "つながる恐れがあります。" -#: ../../c-api/buffer.rst:64 msgid "" "The buffer protocol is now accessible in Python, see :ref:`python-buffer-" "protocol` and :class:`memoryview`." msgstr "" +"バッファプロトコルを Python から利用できるようになりました。\n" +":ref:`python-buffer-protocol` と :class:`memoryview` を参照してください。" #: ../../c-api/buffer.rst:70 msgid "Buffer structure" @@ -206,17 +214,16 @@ msgid "" msgstr "" ":term:`連続 ` 配列の場合この値はメモリブロックの先頭を指します。" -#: ../../c-api/buffer.rst:105 msgid "" "A new reference to the exporting object. The reference is owned by the " "consumer and automatically released (i.e. reference count decremented) and " "set to ``NULL`` by :c:func:`PyBuffer_Release`. The field is the equivalent " "of the return value of any standard C-API function." msgstr "" -"エクスポート対象オブジェクトへの新しい参照。この参照は消費者によって所有さ" -"れ、自動的に解放されます(つまり、参照カウントが減少します)し、設定されます " -"``NULL`` by :c:func:`PyBuffer_Release`. このフィールドは、標準のC-API関数の戻" -"り値に相当します。" +"バッファを提供するオブジェクトへの新しい参照です。\n" +"この参照は利用側が所有し、:c:func:`PyBuffer_Release` によって自動的に解放 (参" +"照カウントを減少) され、``NULL`` に設定されます。\n" +"このフィールドは、通常の C API 関数の戻り値に相当します。" #: ../../c-api/buffer.rst:112 msgid "" @@ -270,17 +277,15 @@ msgstr "" ":func:`struct.calcsize` を非 ``NULL`` の :c:member:`~Py_buffer.format` 値に対" "して呼び出した結果と同じです。" -#: ../../c-api/buffer.rst:138 msgid "" "Important exception: If a consumer requests a buffer without the :c:macro:" "`PyBUF_FORMAT` flag, :c:member:`~Py_buffer.format` will be set to " "``NULL``, but :c:member:`~Py_buffer.itemsize` still has the value for the " "original format." msgstr "" -"重要な例外: 消費者が :c:macro:`PyBUF_FORMAT` フラグを設定することなくバッファ" -"を要求した場合、 :c:member:`~Py_Buffer.format` は ``NULL`` に設定されます。\n" -"しかし :c:member:`~Py_buffer.itemsize` は元のフォーマットに従った値を保持しま" -"す。" +"重要な例外: 利用側が :c:macro:`PyBUF_FORMAT` フラグなしでバッファを要求した場" +"合、:c:member:`~Py_buffer.format` は ``NULL`` に設定されますが、:c:member:" +"`~Py_buffer.itemsize` は元の形式に対応する値を保持します。" #: ../../c-api/buffer.rst:143 msgid "" @@ -303,18 +308,19 @@ msgstr "" "`~Py_buffer.itemsize` を無視して ``itemsize == 1`` と見なさなければなりませ" "ん。" -#: ../../c-api/buffer.rst:153 msgid "" "A *NULL* terminated string in :mod:`struct` module style syntax describing " "the contents of a single item. If this is ``NULL``, ``\"B\"`` (unsigned " "bytes) is assumed." msgstr "" +"単一の要素の内容を :mod:`struct` モジュール形式の構文で記述した、ヌル終端文字" +"列です。\n" +"``NULL`` の場合は ``\"B\"`` (符号なしバイト) とみなします。" #: ../../c-api/buffer.rst:157 msgid "This field is controlled by the :c:macro:`PyBUF_FORMAT` flag." msgstr "このフィールドは :c:macro:`PyBUF_FORMAT` フラグによって制御されます。" -#: ../../c-api/buffer.rst:161 msgid "" "The number of dimensions the memory represents as an n-dimensional array. If " "it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing " @@ -322,6 +328,12 @@ msgid "" "strides` and :c:member:`~Py_buffer.suboffsets` MUST be ``NULL``. The maximum " "number of dimensions is given by :c:macro:`PyBUF_MAX_NDIM`." msgstr "" +"メモリを n 次元配列として表すときの次元数です。\n" +"``0`` の場合、:c:member:`~Py_buffer.buf` はスカラを表す単一の要素を指しま" +"す。\n" +"この場合、:c:member:`~Py_buffer.shape`、:c:member:`~Py_buffer.strides`、:c:" +"member:`~Py_buffer.suboffsets` は ``NULL`` でなければなりません。\n" +"次元数の上限は :c:macro:`PyBUF_MAX_NDIM` で定義されています。" #: ../../c-api/buffer.rst:169 msgid "" @@ -344,9 +356,8 @@ msgstr "" "に注意が必要です。\n" "詳細は `complex arrays`_ を参照してください。" -#: ../../c-api/buffer.rst:178 msgid "The shape array is read-only for the consumer." -msgstr "shepe (形状) 配列は利用者からは読み出し専用です。" +msgstr "``shape`` 配列は利用側にとって読み取り専用です。" #: ../../c-api/buffer.rst:182 msgid "" @@ -356,15 +367,15 @@ msgstr "" "各次元において新しい値を得るためにスキップするバイト数を示す、長さ :c:member:" "`~Py_buffer.ndim` の :c:type:`Py_ssize_t` の配列。" -#: ../../c-api/buffer.rst:186 msgid "" "Stride values can be any integer. For regular arrays, strides are usually " "positive, but a consumer MUST be able to handle the case ``strides[n] <= " "0``. See `complex arrays`_ for further information." msgstr "" -"ストライド値は、任意の整数を指定できます。規定の配列では、ストライドは通常で" -"いけば有効です。しかし利用者は、``strides[n] <= 0`` のケースを処理することが" -"できる必要があります。詳細については `complex arrays`_ を参照してください。" +"ストライドの値は任意の整数です。\n" +"通常の配列ではストライドは一般に正ですが、利用側は ``strides[n] <= 0`` の場合" +"も扱えなければなりません。\n" +"詳細は `complex arrays`_ を参照してください。" #: ../../c-api/buffer.rst:190 msgid "The strides array is read-only for the consumer." @@ -421,16 +432,19 @@ msgstr "" "ことができるでしょう。バッファを受け取る側は、この値を決して変更してはなりま" "せん。" -#: ../../c-api/buffer.rst:219 msgid "Constants:" -msgstr "" +msgstr "定数。" -#: ../../c-api/buffer.rst:223 msgid "" "The maximum number of dimensions the memory represents. Exporters MUST " "respect this limit, consumers of multi-dimensional buffers SHOULD be able to " "handle up to :c:macro:`!PyBUF_MAX_NDIM` dimensions. Currently set to 64." msgstr "" +"メモリを表す次元数の上限です。\n" +"バッファの提供側はこの上限を守らなければなりません。\n" +"多次元バッファの利用側は :c:macro:`!PyBUF_MAX_NDIM` 次元まで扱えるべきで" +"す。\n" +"現在は 64 に設定されています。" #: ../../c-api/buffer.rst:232 msgid "Buffer request types" @@ -474,7 +488,6 @@ msgstr "" msgid "readonly, format" msgstr "readonly, format" -#: ../../c-api/buffer.rst:253 msgid "" "Controls the :c:member:`~Py_buffer.readonly` field. If set, the exporter " "MUST provide a writable buffer or else report failure. Otherwise, the " @@ -482,10 +495,16 @@ msgid "" "MUST be consistent for all consumers. For example, :c:expr:`PyBUF_SIMPLE | " "PyBUF_WRITABLE` can be used to request a simple writable buffer." msgstr "" +":c:member:`~Py_buffer.readonly` フィールドを制御します。\n" +"設定されている場合、提供側は書き込み可能なバッファを提供するか、失敗を報告し" +"なければなりません。\n" +"設定されていない場合は、読み取り専用でも書き込み可能でも構いませんが、すべて" +"の利用側に対して一貫した選択をする必要があります。\n" +"例えば :c:expr:`PyBUF_SIMPLE | PyBUF_WRITABLE` で、単純な書き込み可能バッファ" +"を要求できます。" -#: ../../c-api/buffer.rst:261 msgid "This is an alias to :c:macro:`PyBUF_WRITABLE`." -msgstr "" +msgstr ":c:macro:`PyBUF_WRITABLE` の別名です。" #: ../../c-api/buffer.rst:267 msgid "" @@ -509,12 +528,15 @@ msgstr "" "`PyBUF_WRITABLE` は単純な書き込み可能なバッファを要求する単独のフラグとして使" "えます。" -#: ../../c-api/buffer.rst:275 msgid "" ":c:macro:`PyBUF_FORMAT` must be \\|'d to any of the flags except :c:macro:" "`PyBUF_SIMPLE`, because the latter already implies format ``B`` (unsigned " "bytes). :c:macro:`!PyBUF_FORMAT` cannot be used on its own." msgstr "" +":c:macro:`PyBUF_FORMAT` は、:c:macro:`PyBUF_SIMPLE` 以外のいずれかのフラグと" +"ビット OR で組み合わせる必要があります。\n" +"``PyBUF_SIMPLE`` はすでに形式 ``B`` (符号なしバイト) を意味するためです。\n" +":c:macro:`!PyBUF_FORMAT` を単独で使うことはできません。" #: ../../c-api/buffer.rst:281 msgid "shape, strides, suboffsets" @@ -580,15 +602,15 @@ msgstr "NULL" msgid "contiguity requests" msgstr "隣接性のリクエスト" -#: ../../c-api/buffer.rst:307 msgid "" "C or Fortran :term:`contiguity ` can be explicitly requested, " "with and without stride information. Without stride information, the buffer " "must be C-contiguous." msgstr "" -"ストライドの情報があってもなくても、C または Fortran の :term:`連続性 " -"` が明確に要求される可能性があります。\n" -"ストライド情報なしに、バッファーは C と隣接している必要があります。" +"C スタイルまたは Fortran スタイルの :term:`連続性 ` は、ストライ" +"ド情報の有無にかかわらず明示的に要求できます。\n" +"ストライド情報がない場合、バッファは C スタイルで連続していなければなりませ" +"ん。" #: ../../c-api/buffer.rst:314 ../../c-api/buffer.rst:339 msgid "contig" @@ -700,12 +722,14 @@ msgstr "" "そうでない場合は、利用者は次のように n 次元配列にアクセスしなければなりませ" "ん:" -#: ../../c-api/buffer.rst:376 msgid "" "ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " "strides[n-1];\n" "item = *((typeof(item) *)ptr);" msgstr "" +"ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * " +"strides[n-1];\n" +"item = *((typeof(item) *)ptr);" #: ../../c-api/buffer.rst:382 msgid "" @@ -717,7 +741,6 @@ msgstr "" "すことが可能です。エクスポーターはこの関数を使用することによってバッファの妥" "当性を確認出来ます。" -#: ../../c-api/buffer.rst:386 msgid "" "def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" " \"\"\"Verify that the parameters represent a valid array within\n" @@ -745,6 +768,31 @@ msgid "" "\n" " return 0 <= offset+imin and offset+imax+itemsize <= memlen" msgstr "" +"def verify_structure(memlen, itemsize, ndim, shape, strides, offset):\n" +" \"\"\"引数が、割り当てたメモリの範囲内の有効な配列を\n" +" 表しているかどうかを検証する:\n" +" char *mem: 物理メモリブロックの先頭\n" +" memlen: 物理メモリブロックの長さ\n" +" offset: (char *)buf - mem\n" +" \"\"\"\n" +" if offset % itemsize:\n" +" return False\n" +" if offset < 0 or offset+itemsize > memlen:\n" +" return False\n" +" if any(v % itemsize for v in strides):\n" +" return False\n" +"\n" +" if ndim <= 0:\n" +" return ndim == 0 and not shape and not strides\n" +" if 0 in shape:\n" +" return True\n" +"\n" +" imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n" +" if strides[j] <= 0)\n" +" imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)\n" +" if strides[j] > 0)\n" +"\n" +" return 0 <= offset+imin and offset+imax+itemsize <= memlen" #: ../../c-api/buffer.rst:416 msgid "PIL-style: shape, strides and suboffsets" @@ -777,7 +825,6 @@ msgstr "" "次の例は、 strides も suboffsets も ``NULL`` でない場合の、N 次元インデックス" "によって指されている N 次元配列内の要素へのポインタを返す関数です::" -#: ../../c-api/buffer.rst:431 msgid "" "void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" " Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" @@ -792,6 +839,18 @@ msgid "" " return (void*)pointer;\n" "}" msgstr "" +"void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,\n" +" Py_ssize_t *suboffsets, Py_ssize_t *indices) {\n" +" char *pointer = (char*)buf;\n" +" int i;\n" +" for (i = 0; i < ndim; i++) {\n" +" pointer += strides[i] * indices[i];\n" +" if (suboffsets[i] >=0 ) {\n" +" pointer = *((char**)pointer) + suboffsets[i];\n" +" }\n" +" }\n" +" return (void*)pointer;\n" +"}" #: ../../c-api/buffer.rst:446 msgid "Buffer-related functions" @@ -820,18 +879,17 @@ msgstr "" "`BufferError` を送出し、 ``view->obj`` を ``NULL`` に設定した上で、 ``-1`` を" "返さなければなりません。" -#: ../../c-api/buffer.rst:462 msgid "" "On success, fill in *view*, set ``view->obj`` to a new reference to " "*exporter* and return 0. In the case of chained buffer providers that " "redirect requests to a single object, ``view->obj`` MAY refer to this object " "instead of *exporter* (See :ref:`Buffer Object Structures `)." msgstr "" -"成功したときは、 *view* を埋め、 ``view->obj`` に *exporter* への新しい参照を" -"設定し、0を返します。チェイン状のバッファプロバイダがリクエストを単一のオブ" -"ジェクトにリダイレクトするケースでは、 ``view->obj`` は *exporter* の代わりに" -"このオブジェクトを参照します (:ref:`バッファオブジェクト構造体 ` を参照してください)。" +"成功した場合は ``view`` に情報を設定し、``view->obj`` を ``exporter`` への新" +"しい参照にして 0 を返します。\n" +"複数のバッファ提供側が連鎖し、要求を一つのオブジェクトに転送する場合は、" +"``view->obj`` が ``exporter`` の代わりにそのオブジェクトを参照しても構いませ" +"ん (:ref:`バッファオブジェクト構造体 ` を参照)。" #: ../../c-api/buffer.rst:467 msgid "" @@ -846,13 +904,17 @@ msgstr "" "従って、バッファの利用が済んだら :c:func:`PyBuffer_Release` が厳密に1回だけ呼" "び出されなければなりません。" -#: ../../c-api/buffer.rst:475 msgid "" "Release the buffer *view* and release the :term:`strong reference` (i.e. " "decrement the reference count) to the view's supporting object, ``view-" ">obj``. This function MUST be called when the buffer is no longer being " "used, otherwise reference leaks may occur." msgstr "" +"バッファ ``view`` を解放し、ビューを支えるオブジェクト ``view->obj`` への :" +"term:`強参照 ` も解放します (つまり参照カウントを減らしま" +"す)。\n" +"バッファを使わなくなったときは必ず呼び出してください。\n" +"呼び出さないと参照がリークする可能性があります。" #: ../../c-api/buffer.rst:480 msgid "" @@ -862,11 +924,13 @@ msgstr "" ":c:func:`PyObject_GetBuffer` を通して取得していないバッファに対してこの関数を" "呼び出すのは間違いです。" -#: ../../c-api/buffer.rst:486 msgid "" "Return the implied :c:member:`~Py_buffer.itemsize` from :c:member:" "`~Py_buffer.format`. On error, raise an exception and return -1." msgstr "" +":c:member:`~Py_buffer.format` が表す :c:member:`~Py_buffer.itemsize` を返しま" +"す。\n" +"エラーの場合は例外を送出し、-1 を返します。" #: ../../c-api/buffer.rst:494 msgid "" @@ -890,47 +954,49 @@ msgstr "" "*indices* は ``view->ndim`` 個のインデックスからなる配列を指していなければな" "りません。" -#: ../../c-api/buffer.rst:507 msgid "" "Copy contiguous *len* bytes from *buf* to *view*. *order* can be ``'C'`` or " "``'F'`` or ``'A'`` (for C-style or Fortran-style ordering or either one). " "``0`` is returned on success, ``-1`` on error." msgstr "" +"``buf`` の連続した ``len`` バイトを ``view`` にコピーします。\n" +"``order`` は ``'C'``、``'F'``、``'A'`` のいずれかで、それぞれ C スタイル、" +"Fortran スタイル、どちらでもよいことを表します。\n" +"成功した場合は ``0`` を返し、エラーの場合は ``-1`` を返します。" -#: ../../c-api/buffer.rst:515 msgid "" "Copy *len* bytes from *src* to its contiguous representation in *buf*. " "*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style " "ordering or either one). ``0`` is returned on success, ``-1`` on error." msgstr "" -"*src* から *len* バイトを連続表現で *buf* 上にコピーします。\n" -"*order* は ``'C'`` または ``'F'`` または ``'A'`` (C スタイル順序または " -"Fortran スタイル順序またはそれ以外) が指定できます。\n" -"成功したら ``0`` が返り、エラーなら ``-1`` が返ります。" +"``src`` の ``len`` バイトを、``buf`` 内の連続した表現にコピーします。\n" +"``order`` は ``'C'``、``'F'``、``'A'`` のいずれかで、それぞれ C スタイル、" +"Fortran スタイル、どちらでもよいことを表します。\n" +"成功した場合は ``0`` を返し、エラーの場合は ``-1`` を返します。" #: ../../c-api/buffer.rst:519 msgid "This function fails if *len* != *src->len*." msgstr "*len* != *src->len* の場合、この関数は失敗します。" -#: ../../c-api/buffer.rst:524 msgid "" "Copy data from *src* to *dest* buffer. Can convert between C-style and or " "Fortran-style buffers." msgstr "" +"``src`` から ``dest`` バッファにデータをコピーします。\n" +"C スタイルと Fortran スタイルのバッファ間で変換できます。" #: ../../c-api/buffer.rst:527 msgid "``0`` is returned on success, ``-1`` on error." msgstr "成功したら ``0`` が、エラー時には ``-1`` が返されます。" -#: ../../c-api/buffer.rst:531 msgid "" "Fill the *strides* array with byte-strides of a :term:`contiguous` (C-style " "if *order* is ``'C'`` or Fortran-style if *order* is ``'F'``) array of the " "given shape with the given number of bytes per element." msgstr "" -"*strides* 配列を、 *itemsize* の大きさの要素がバイト単位の、 *shape* の形をし" -"た :term:`連続な ` (*order* が ``'C'`` なら C-style 、 ``'F'`` な" -"ら Fortran-style の) 多次元配列として埋める。" +"指定された形状と要素あたりのバイト数を持つ :term:`連続した ` 配列" +"の、バイト単位のストライドを ``strides`` 配列に設定します。\n" +"``order`` が ``'C'`` なら C スタイル、``'F'`` なら Fortran スタイルです。" #: ../../c-api/buffer.rst:538 msgid "" @@ -942,23 +1008,25 @@ msgstr "" "バッファリクエストを処理します。\n" "*buf* は符号無しバイトの列として解釈されます。" -#: ../../c-api/buffer.rst:542 msgid "" "The *flags* argument indicates the request type. This function always fills " "in *view* as specified by flags, unless *buf* has been designated as read-" "only and :c:macro:`PyBUF_WRITABLE` is set in *flags*." msgstr "" -"*flags* 引数はリクエストのタイプを示します。\n" -"この関数は、 *buf* が読み出し専用と指定されていて、 *flags* に :c:macro:" -"`PyBUF_WRITABLE` が設定されていない限り、常にフラグに指定された通りに *view* " -"を埋めます。" +"``flags`` 引数は要求の種類を示します。\n" +"``buf`` が読み取り専用なのに ``flags`` に :c:macro:`PyBUF_WRITABLE` が設定さ" +"れている場合を除き、この関数は常に ``flags`` の指定どおりに ``view`` に情報を" +"設定します。" -#: ../../c-api/buffer.rst:546 msgid "" "On success, set ``view->obj`` to a new reference to *exporter* and return 0. " "Otherwise, raise :exc:`BufferError`, set ``view->obj`` to ``NULL`` and " "return ``-1``;" msgstr "" +"成功した場合は ``view->obj`` を ``exporter`` への新しい参照に設定し、0 を返し" +"ます。\n" +"それ以外の場合は :exc:`BufferError` を送出し、``view->obj`` を ``NULL`` に設" +"定して ``-1`` を返します。" #: ../../c-api/buffer.rst:550 msgid "" @@ -975,30 +1043,24 @@ msgstr "" msgid "buffer protocol" msgstr "buffer protocol" -#: ../../c-api/buffer.rst:3 msgid "buffer interface" -msgstr "" +msgstr "バッファインターフェース" -#: ../../c-api/buffer.rst:3 msgid "(see buffer protocol)" -msgstr "" +msgstr "(バッファプロトコルを参照)" -#: ../../c-api/buffer.rst:3 msgid "buffer object" -msgstr "" +msgstr "バッファオブジェクト" -#: ../../c-api/buffer.rst:27 msgid "PyBufferProcs (C type)" -msgstr "" +msgstr "PyBufferProcs (C の型)" #: ../../c-api/buffer.rst:302 msgid "contiguous" msgstr "contiguous" -#: ../../c-api/buffer.rst:302 msgid "C-contiguous" -msgstr "" +msgstr "C-contiguous" -#: ../../c-api/buffer.rst:302 msgid "Fortran contiguous" -msgstr "" +msgstr "Fortran contiguous" diff --git a/c-api/bytearray.po b/c-api/bytearray.po index 88b1de921..97aa877db 100644 --- a/c-api/bytearray.po +++ b/c-api/bytearray.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/bytearray.rst:6 @@ -33,13 +33,16 @@ msgstr "" "この :c:type:`PyObject` のサブタイプは Python の bytearray オブジェクトを表し" "ます。" -#: ../../c-api/bytearray.rst:17 msgid "" "The internal buffer of :c:type:`PyByteArrayObject` always includes an extra " "trailing null byte for compatibility with null terminated C strings. This " "extra byte is not counted in :c:func:`PyByteArray_Size` nor in the *len* " "arguments of the functions below." msgstr "" +":c:type:`PyByteArrayObject` の内部バッファには、ヌル終端の C 文字列との互換性" +"のため、末尾に余分なヌルバイトが常に含まれます。\n" +"このバイトは :c:func:`PyByteArray_Size` の戻り値にも、以下の関数の ``len`` 引" +"数にも含めません。" #: ../../c-api/bytearray.rst:24 msgid "" @@ -81,20 +84,19 @@ msgstr "" ":ref:`buffer protocol ` を実装した任意のオブジェクト *o* か" "ら、新しいbytearrayオブジェクトを作成し、返します。" -#: ../../c-api/bytearray.rst:51 ../../c-api/bytearray.rst:62 -#: ../../c-api/bytearray.rst:69 msgid "On failure, return ``NULL`` with an exception set." -msgstr "" +msgstr "失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytearray.rst:54 ../../c-api/bytearray.rst:72 msgid "" "If the object implements the buffer protocol, then the buffer must not be " "mutated while the bytearray object is being created." msgstr "" +"オブジェクトがバッファプロトコルを実装している場合、bytearray オブジェクトの" +"作成中にバッファを変更してはいけません。" -#: ../../c-api/bytearray.rst:60 msgid "Create a new bytearray object from *string* and its length, *len*." msgstr "" +"``string`` とその長さ ``len`` から新しい bytearray オブジェクトを作成します。" #: ../../c-api/bytearray.rst:67 msgid "" @@ -114,22 +116,23 @@ msgstr "" "す。\n" "返される配列には、常に余分な null バイトが追加されます。" -#: ../../c-api/bytearray.rst:88 ../../c-api/bytearray.rst:110 msgid "" "It is not thread-safe to mutate the bytearray object while using the " "returned char array." msgstr "" +"返された char 配列の使用中に bytearray オブジェクトを変更する操作はスレッド" +"セーフではありません。" -#: ../../c-api/bytearray.rst:93 msgid "" "Resize the internal buffer of *bytearray* to *len*. Failure is a ``-1`` " "return with an exception set." msgstr "" +"``bytearray`` の内部バッファのサイズを ``len`` に変更します。\n" +"失敗した場合は、例外を設定して ``-1`` を返します。" -#: ../../c-api/bytearray.rst:96 msgid "" "A negative *len* will now result in an exception being set and -1 returned." -msgstr "" +msgstr "``len`` が負の場合は、例外を設定して -1 を返すようになりました。" #: ../../c-api/bytearray.rst:101 msgid "Macros" diff --git a/c-api/bytes.po b/c-api/bytes.po index f4627ff17..4d2901c1d 100644 --- a/c-api/bytes.po +++ b/c-api/bytes.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/bytes.rst:6 @@ -34,13 +34,16 @@ msgstr "" "下記の関数は、バイトオブジェクトを期待している引数にバイトオブジェクトでない" "パラメタを指定して呼び出されると、 :exc:`TypeError` を送出します。" -#: ../../c-api/bytes.rst:13 msgid "" "The internal buffer of :c:type:`PyBytesObject` always includes an extra " "trailing null byte for compatibility with null terminated C strings. This " "extra byte is not counted in :c:func:`PyBytes_Size` nor in the various " "*length* and *size* arguments of the functions below." msgstr "" +":c:type:`PyBytesObject` の内部バッファには、null 終端の C 文字列との互換性の" +"ため、末尾に常に追加の null バイトが含まれます。\n" +"この追加バイトは :c:func:`PyBytes_Size` や、以下の関数の各種 *length* 引数と " +"*size* 引数には数えません。" #: ../../c-api/bytes.rst:23 msgid "This subtype of :c:type:`PyObject` represents a Python bytes object." @@ -91,11 +94,12 @@ msgstr "" "を返し、失敗時に ``NULL`` を返します。\n" "引数 *v* が ``NULL`` の場合、バイトオブジェクトの中身は初期化されていません。" -#: ../../c-api/bytes.rst:57 msgid "" "Use the :c:type:`PyBytesWriter` API instead of " "``PyBytes_FromStringAndSize(NULL, len)``." msgstr "" +"``PyBytes_FromStringAndSize(NULL, len)`` の代わりに :c:type:`PyBytesWriter` " +"API を使ってください。" #: ../../c-api/bytes.rst:64 msgid "" @@ -293,11 +297,12 @@ msgid "" "protocol." msgstr "バッファプロトコルを実装するオブジェクト *o* のバイト表現を返します。" -#: ../../c-api/bytes.rst:138 msgid "" "If the object implements the buffer protocol, then the buffer must not be " "mutated while the bytes object is being created." msgstr "" +"オブジェクトがバッファプロトコルを実装している場合、bytes オブジェクトの作成" +"中にそのバッファを変更してはいけません。" #: ../../c-api/bytes.rst:144 msgid "Return the length of the bytes in bytes object *o*." @@ -307,7 +312,6 @@ msgstr "バイトオブジェクト *o* のバイト単位の長さを返しま msgid "Similar to :c:func:`PyBytes_Size`, but without error checking." msgstr ":c:func:`PyBytes_Size` に似ていますが、エラーチェックを行いません。" -#: ../../c-api/bytes.rst:154 msgid "" "Return a pointer to the contents of *o*. The pointer refers to the internal " "buffer of *o*, which consists of ``len(o) + 1`` bytes. The last byte in the " @@ -317,38 +321,39 @@ msgid "" "deallocated. If *o* is not a bytes object at all, :c:func:" "`PyBytes_AsString` returns ``NULL`` and raises :exc:`TypeError`." msgstr "" -"*o* の中身へのポインタを返します。\n" -"ポインタは、 ``len(o) + 1`` バイトからなる *o* の内部バッファを参照します。\n" -"他に null のバイトがあるかどうかにかかわらず、バッファの最後のバイトは必ず " -"null になります。\n" -"``PyBytes_FromStringAndSize(NULL, size)`` で生成された場合を除いて、データを" -"修正してはなりません。\n" -"またポインタを解放(deallocated)してはなりません。\n" -"もし、 *o* が bytes オブジェクトでなければ、 :c:func:`PyBytes_AsString` は " -"``NULL`` を返し :exc:`TypeError` を送出します。" +"*o* の内容へのポインタを返します。\n" +"このポインタは ``len(o) + 1`` バイトからなる *o* の内部バッファを参照しま" +"す。\n" +"内部に他の null バイトがあるかどうかにかかわらず、バッファの最後のバイトは常" +"に null です。\n" +"``PyBytes_FromStringAndSize(NULL, size)`` で作成したばかりのオブジェクトでな" +"い限り、データを変更してはいけません。\n" +"このバッファを解放してはいけません。\n" +"*o* が bytes オブジェクトでなければ、:c:func:`PyBytes_AsString` は ``NULL`` " +"を返し、:exc:`TypeError` を送出します。" #: ../../c-api/bytes.rst:166 msgid "Similar to :c:func:`PyBytes_AsString`, but without error checking." msgstr "" ":c:func:`PyBytes_AsString` に似ていますが、エラーチェックを行いません。" -#: ../../c-api/bytes.rst:171 msgid "" "Return the null-terminated contents of the object *obj* through the output " "variables *buffer* and *length*. Returns ``0`` on success." msgstr "" +"出力変数 *buffer* と *length* を通じて、オブジェクト *obj* の null 終端された" +"内容を返します。\n" +"成功すると ``0`` を返します。" -#: ../../c-api/bytes.rst:175 msgid "" "If *length* is ``NULL``, the bytes object may not contain embedded null " "bytes; if it does, the function returns ``-1`` and a :exc:`ValueError` is " "raised." msgstr "" -"*length* の値が ``NULL`` の場合、バイトオブジェクトが null バイトを含まない" -"可能性があります。その場合、関数は ``-1`` を返し、 :exc:`ValueError` を送出し" -"ます。" +"*length* が ``NULL`` の場合、bytes オブジェクトの内部に null バイトが含まれて" +"いてはいけません。\n" +"含まれている場合は ``-1`` を返し、:exc:`ValueError` を送出します。" -#: ../../c-api/bytes.rst:179 msgid "" "The buffer refers to an internal buffer of *obj*, which includes an " "additional null byte at the end (not counted in *length*). The data must " @@ -357,13 +362,14 @@ msgid "" "*obj* is not a bytes object at all, :c:func:`PyBytes_AsStringAndSize` " "returns ``-1`` and raises :exc:`TypeError`." msgstr "" -"buffer は *obj* の内部バッファを参照していて、これには末尾の null バイトも含" -"んでいます (これは *length* には数えられません)。\n" -"オブジェクトが ``PyBytes_FromStringAndSize(NULL, size)`` で生成された場合を除" -"いて、何があってもデータを改変してはいけません。\n" -"オブジェクトを解放 (deallocate) してもいけません。\n" -"*obj* が bytes オブジェクトでなかった場合は、 :c:func:" -"`PyBytes_AsStringAndSize` は ``-1`` を返し :exc:`TypeError` を送出します。" +"``buffer`` は *obj* の内部バッファを参照します。\n" +"このバッファには末尾に追加の null バイトが含まれます (*length* には数えませ" +"ん)。\n" +"``PyBytes_FromStringAndSize(NULL, size)`` で作成したばかりのオブジェクトでな" +"い限り、データを変更してはいけません。\n" +"このバッファを解放してはいけません。\n" +"*obj* が bytes オブジェクトでなければ、:c:func:`PyBytes_AsStringAndSize` は " +"``-1`` を返し、:exc:`TypeError` を送出します。" #: ../../c-api/bytes.rst:186 msgid "" @@ -373,7 +379,6 @@ msgstr "" "以前は bytes オブジェクトにヌルバイトが埋め込まれていたときに :exc:" "`TypeError` を送出していました。" -#: ../../c-api/bytes.rst:193 msgid "" "Create a new bytes object in *\\*bytes* containing the contents of *newpart* " "appended to *bytes*; the caller will own the new reference. The reference to " @@ -382,50 +387,64 @@ msgid "" "\"stolen\", the value of *\\*bytes* will be set to ``NULL``, and the " "appropriate exception will be set." msgstr "" +"*bytes* の内容に *newpart* の内容を追加した新しい bytes オブジェクトを " +"*\\*bytes* に作成します。\n" +"呼び出し側はこの新しい参照を所有します。\n" +"*bytes* の元の値への参照は「:term:`盗まれます `」。\n" +"新しいオブジェクトを作成できない場合も、*bytes* の元の参照は「盗まれ」、" +"*\\*bytes* の値は ``NULL`` に設定され、適切な例外が設定されます。" -#: ../../c-api/bytes.rst:201 ../../c-api/bytes.rst:211 msgid "" "If *newpart* implements the buffer protocol, then the buffer must not be " "mutated while the new bytes object is being created." msgstr "" +"*newpart* がバッファプロトコルを実装している場合、新しい bytes オブジェクトの" +"作成中にそのバッファを変更してはいけません。" -#: ../../c-api/bytes.rst:206 msgid "" "Create a new bytes object in *\\*bytes* containing the contents of *newpart* " "appended to *bytes*. This version releases the :term:`strong reference` to " "*newpart* (i.e. decrements its reference count)." msgstr "" +"*bytes* の内容に *newpart* の内容を追加した新しい bytes オブジェクトを " +"*\\*bytes* に作成します。\n" +"この関数は *newpart* への :term:`強参照 ` を解放します (つ" +"まり参照カウントを減らします)。" -#: ../../c-api/bytes.rst:217 msgid "Similar to ``sep.join(iterable)`` in Python." -msgstr "" +msgstr "Python の ``sep.join(iterable)`` と同様です。" -#: ../../c-api/bytes.rst:219 msgid "" "*sep* must be Python :class:`bytes` object. (Note that :c:func:" "`PyUnicode_Join` accepts ``NULL`` separator and treats it as a space, " "whereas :c:func:`PyBytes_Join` doesn't accept ``NULL`` separator.)" msgstr "" +"*sep* は Python の :class:`bytes` オブジェクトでなければなりません。\n" +"(:c:func:`PyUnicode_Join` は区切り文字として ``NULL`` を受け取り、空白として" +"扱いますが、:c:func:`PyBytes_Join` は区切り文字に ``NULL`` を受け付けませ" +"ん。)" -#: ../../c-api/bytes.rst:224 msgid "" "*iterable* must be an iterable object yielding objects that implement the :" "ref:`buffer protocol `." msgstr "" +"*iterable* は :ref:`バッファプロトコル ` を実装するオブジェク" +"トを生成するイテラブルオブジェクトでなければなりません。" -#: ../../c-api/bytes.rst:227 msgid "" "On success, return a new :class:`bytes` object. On error, set an exception " "and return ``NULL``." msgstr "" +"成功すると新しい :class:`bytes` オブジェクトを返します。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytes.rst:233 msgid "" "If *iterable* objects implement the buffer protocol, then the buffers must " "not be mutated while the new bytes object is being created." msgstr "" +"*iterable* のオブジェクトがバッファプロトコルを実装している場合、新しい " +"bytes オブジェクトの作成中にそれらのバッファを変更してはいけません。" -#: ../../c-api/bytes.rst:238 msgid "" "Resize a bytes object. *newsize* will be the new length of the bytes object. " "You can think of it as creating a new bytes object and destroying the old " @@ -436,24 +455,37 @@ msgid "" "the original bytes object at *\\*bytes* is deallocated, *\\*bytes* is set to " "``NULL``, :exc:`MemoryError` is set, and ``-1`` is returned." msgstr "" +"bytes オブジェクトのサイズを変更します。\n" +"*newsize* が bytes オブジェクトの新しい長さになります。\n" +"新しい bytes オブジェクトを作成して古いものを破棄する操作を、より効率よく行う" +"ものと考えることができます。\n" +"既存の bytes オブジェクトのアドレスを左辺値 (書き込みが行われる可能性がありま" +"す) として渡し、希望する新しいサイズを指定します。\n" +"成功すると *\\*bytes* はサイズ変更後の bytes オブジェクトを保持し、``0`` を返" +"します。\n" +"*\\*bytes* のアドレスは入力時の値と異なる場合があります。\n" +"再割り当てに失敗すると、*\\*bytes* の元の bytes オブジェクトを解放し、" +"*\\*bytes* に ``NULL`` を設定し、:exc:`MemoryError` を設定して ``-1`` を返し" +"ます。" -#: ../../c-api/bytes.rst:249 msgid "Use the :c:type:`PyBytesWriter` API instead." -msgstr "" +msgstr "代わりに :c:type:`PyBytesWriter` API を使ってください。" -#: ../../c-api/bytes.rst:255 msgid "" "Get the string representation of *bytes*. This function is currently used to " "implement :meth:`!bytes.__repr__` in Python." msgstr "" +"*bytes* の文字列表現を取得します。\n" +"現在、この関数は Python の :meth:`!bytes.__repr__` の実装に使われています。" -#: ../../c-api/bytes.rst:258 msgid "" "This function does not do type checking; it is undefined behavior to pass " "*bytes* as a non-bytes object or ``NULL``." msgstr "" +"この関数は型チェックを行いません。\n" +"*bytes* に bytes オブジェクト以外のオブジェクトや ``NULL`` を渡すと、動作は未" +"定義です。" -#: ../../c-api/bytes.rst:261 msgid "" "If *smartquotes* is true, the representation will use a double-quoted string " "instead of single-quoted string when single-quotes are present in *bytes*. " @@ -461,245 +493,273 @@ msgid "" "``b\"'Python'\"`` when *smartquotes* is true, or ``b'\\'Python\\''`` when it " "is false." msgstr "" +"*smartquotes* が真の場合、*bytes* にシングルクォートが含まれていれば、その表" +"現にはシングルクォートの代わりにダブルクォートで囲んだ文字列を使います。\n" +"例えば、バイト文字列 ``'Python'`` の表現は、*smartquotes* が真なら " +"``b\"'Python'\"``、偽なら ``b'\\'Python\\''`` となります。" -#: ../../c-api/bytes.rst:267 msgid "" "On success, this function returns a :term:`strong reference` to a :class:" "`str` object containing the representation. On failure, this returns " "``NULL`` with an exception set." msgstr "" +"成功すると、この関数は表現を格納した :class:`str` オブジェクトへの :term:`強" +"参照 ` を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytes.rst:274 msgid "" "Unescape a backslash-escaped string *s*. *s* must not be ``NULL``. *len* " "must be the size of *s*." msgstr "" +"バックスラッシュでエスケープされた文字列 *s* のエスケープを解除します。\n" +"*s* は ``NULL`` であってはなりません。\n" +"*len* は *s* のサイズでなければなりません。" -#: ../../c-api/bytes.rst:277 msgid "" "*errors* must be one of ``\"strict\"``, ``\"replace\"``, or ``\"ignore\"``. " "If *errors* is ``NULL``, then ``\"strict\"`` is used by default." msgstr "" +"*errors* は ``\"strict\"``、``\"replace\"``、``\"ignore\"`` のいずれかでなけ" +"ればなりません。\n" +"*errors* が ``NULL`` の場合、デフォルトで ``\"strict\"`` を使います。" -#: ../../c-api/bytes.rst:280 msgid "" "On success, this function returns a :term:`strong reference` to a Python :" "class:`bytes` object containing the unescaped string. On failure, this " "function returns ``NULL`` with an exception set." msgstr "" +"成功すると、この関数はエスケープを解除した文字列を格納する Python の :class:" +"`bytes` オブジェクトへの :term:`強参照 ` を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytes.rst:284 msgid "*unicode* and *recode_encoding* are now unused." -msgstr "" +msgstr "*unicode* と *recode_encoding* は使われなくなりました。" -#: ../../c-api/bytes.rst:291 msgid "PyBytesWriter" -msgstr "" +msgstr "PyBytesWriter" -#: ../../c-api/bytes.rst:293 msgid "" "The :c:type:`PyBytesWriter` API can be used to create a Python :class:" "`bytes` object." msgstr "" +":c:type:`PyBytesWriter` API を使って Python の :class:`bytes` オブジェクトを" +"作成できます。" -#: ../../c-api/bytes.rst:300 msgid "A bytes writer instance." -msgstr "" +msgstr "bytes ライターのインスタンスです。" -#: ../../c-api/bytes.rst:302 msgid "" "The API is **not thread safe**. To share a writer with multiple threads, a " "critical section or a lock is needed." msgstr "" +"この API は **スレッドセーフではありません**。\n" +"複数のスレッドでライターを共有するには、クリティカルセクションまたはロックが" +"必要です。" -#: ../../c-api/bytes.rst:305 msgid "" "The instance must be destroyed by :c:func:`PyBytesWriter_Finish` on success, " "or :c:func:`PyBytesWriter_Discard` on error." msgstr "" +"成功時には :c:func:`PyBytesWriter_Finish`、エラー時には :c:func:" +"`PyBytesWriter_Discard` でインスタンスを破棄しなければなりません。" -#: ../../c-api/bytes.rst:310 msgid "Create, Finish, Discard" -msgstr "" +msgstr "作成、完了、破棄" -#: ../../c-api/bytes.rst:314 msgid "Create a :c:type:`PyBytesWriter` to write *size* bytes." -msgstr "" +msgstr "*size* バイトを書き込むための :c:type:`PyBytesWriter` を作成します。" -#: ../../c-api/bytes.rst:316 msgid "" "If *size* is greater than zero, allocate *size* bytes, and set the writer " "size to *size*. The caller is responsible to write *size* bytes using :c:" "func:`PyBytesWriter_GetData`. This function does not overallocate." msgstr "" +"*size* がゼロより大きければ *size* バイトを割り当て、ライターのサイズを " +"*size* に設定します。\n" +"呼び出し側は :c:func:`PyBytesWriter_GetData` を使って *size* バイトを書き込む" +"責任があります。\n" +"この関数は余分な領域を割り当てません。" -#: ../../c-api/bytes.rst:321 ../../c-api/bytes.rst:450 msgid "On error, set an exception and return ``NULL``." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytes.rst:323 ../../c-api/bytes.rst:426 msgid "*size* must be positive or zero." -msgstr "" +msgstr "*size* は正の値またはゼロでなければなりません。" -#: ../../c-api/bytes.rst:327 msgid "" "Finish a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`." msgstr "" +":c:func:`PyBytesWriter_Create` で作成した :c:type:`PyBytesWriter` の処理を完" +"了します。" -#: ../../c-api/bytes.rst:330 msgid "" "On success, return a Python :class:`bytes` object. On error, set an " "exception and return ``NULL``." msgstr "" +"成功すると Python の :class:`bytes` オブジェクトを返します。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/bytes.rst:333 msgid "" "The writer instance is invalid after the call in any case. No API can be " "called on the writer after :c:func:`PyBytesWriter_Finish`." msgstr "" +"呼び出し後は、成功したかどうかにかかわらずライターのインスタンスは無効になり" +"ます。\n" +":c:func:`PyBytesWriter_Finish` の後に、そのライターに対して API を呼び出すこ" +"とはできません。" -#: ../../c-api/bytes.rst:338 msgid "" "Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer to *size* " "bytes before creating the :class:`bytes` object." msgstr "" +":c:func:`PyBytesWriter_Finish` と同様ですが、:class:`bytes` オブジェクトを作" +"成する前にライターのサイズを *size* バイトに変更します。" -#: ../../c-api/bytes.rst:343 msgid "" "Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer using *buf* " "pointer before creating the :class:`bytes` object." msgstr "" +":c:func:`PyBytesWriter_Finish` と同様ですが、:class:`bytes` オブジェクトを作" +"成する前に *buf* ポインタを使ってライターのサイズを変更します。" -#: ../../c-api/bytes.rst:346 msgid "" "Set an exception and return ``NULL`` if *buf* pointer is outside the " "internal buffer bounds." msgstr "" +"*buf* ポインタが内部バッファの範囲外であれば、例外を設定して ``NULL`` を返し" +"ます。" -#: ../../c-api/bytes.rst:349 ../../c-api/bytes.rst:454 msgid "Function pseudo-code::" -msgstr "" +msgstr "関数の疑似コードを示します。 ::" -#: ../../c-api/bytes.rst:351 msgid "" "Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" "return PyBytesWriter_FinishWithSize(writer, size);" msgstr "" +"Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"return PyBytesWriter_FinishWithSize(writer, size);" -#: ../../c-api/bytes.rst:356 msgid "" "Discard a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`." msgstr "" +":c:func:`PyBytesWriter_Create` で作成した :c:type:`PyBytesWriter` を破棄しま" +"す。" -#: ../../c-api/bytes.rst:358 msgid "Do nothing if *writer* is ``NULL``." -msgstr "" +msgstr "*writer* が ``NULL`` の場合は何もしません。" -#: ../../c-api/bytes.rst:360 msgid "" "The writer instance is invalid after the call. No API can be called on the " "writer after :c:func:`PyBytesWriter_Discard`." msgstr "" +"呼び出し後はライターのインスタンスは無効になります。\n" +":c:func:`PyBytesWriter_Discard` の後に、そのライターに対して API を呼び出すこ" +"とはできません。" #: ../../c-api/bytes.rst:364 msgid "High-level API" msgstr "高レベルAPI" -#: ../../c-api/bytes.rst:368 msgid "" "Grow the *writer* internal buffer by *size* bytes, write *size* bytes of " "*bytes* at the *writer* end, and add *size* to the *writer* size." msgstr "" +"*writer* の内部バッファを *size* バイト拡張し、*bytes* の *size* バイトを " +"*writer* の末尾に書き込み、*writer* のサイズに *size* を加えます。" -#: ../../c-api/bytes.rst:372 msgid "" "If *size* is equal to ``-1``, call ``strlen(bytes)`` to get the string " "length." msgstr "" +"*size* が ``-1`` の場合は ``strlen(bytes)`` を呼び出して文字列の長さを取得し" +"ます。" -#: ../../c-api/bytes.rst:375 ../../c-api/bytes.rst:384 -#: ../../c-api/bytes.rst:423 ../../c-api/bytes.rst:436 msgid "On success, return ``0``. On error, set an exception and return ``-1``." msgstr "" +"成功すると ``0`` を返します。\n" +"エラー時は例外を設定して ``-1`` を返します。" -#: ../../c-api/bytes.rst:380 msgid "" "Similar to :c:func:`PyBytes_FromFormat`, but write the output directly at " "the writer end. Grow the writer internal buffer on demand. Then add the " "written size to the writer size." msgstr "" +":c:func:`PyBytes_FromFormat` と同様ですが、出力をライターの末尾に直接書き込み" +"ます。\n" +"必要に応じてライターの内部バッファを拡張します。\n" +"その後、書き込んだサイズをライターのサイズに加えます。" -#: ../../c-api/bytes.rst:389 msgid "Getters" -msgstr "" +msgstr "値の取得" -#: ../../c-api/bytes.rst:393 msgid "Get the writer size." -msgstr "" +msgstr "ライターのサイズを取得します。" -#: ../../c-api/bytes.rst:395 msgid "" "The function does not invalidate pointers returned by :c:func:" "`PyBytesWriter_GetData`." msgstr "" +"この関数は :c:func:`PyBytesWriter_GetData` が返したポインタを無効にしません。" -#: ../../c-api/bytes.rst:398 ../../c-api/bytes.rst:408 msgid "The function cannot fail." -msgstr "" +msgstr "この関数は失敗しません。" -#: ../../c-api/bytes.rst:402 msgid "Get the writer data: start of the internal buffer." -msgstr "" +msgstr "ライターのデータ、つまり内部バッファの先頭を取得します。" -#: ../../c-api/bytes.rst:404 msgid "" "The pointer remains valid until a :c:type:`PyBytesWriter` function other " "than :c:func:`PyBytesWriter_GetData` or :c:func:`PyBytesWriter_GetSize` is " "called on *writer*." msgstr "" +"このポインタは、*writer* に対して :c:func:`PyBytesWriter_GetData` と :c:func:" +"`PyBytesWriter_GetSize` 以外の :c:type:`PyBytesWriter` 関数を呼び出すまで有効" +"です。" #: ../../c-api/bytes.rst:412 msgid "Low-level API" msgstr "低レベルAPI" -#: ../../c-api/bytes.rst:416 msgid "" "Resize the writer to *size* bytes. It can be used to enlarge or to shrink " "the writer. This function typically overallocates to achieve amortized " "performance when resizing multiple times." msgstr "" +"ライターのサイズを *size* バイトに変更します。\n" +"ライターの拡張にも縮小にも使えます。\n" +"この関数は通常、サイズ変更を繰り返したときの償却性能をよくするため、余分な領" +"域を割り当てます。" -#: ../../c-api/bytes.rst:421 ../../c-api/bytes.rst:434 msgid "Newly allocated bytes are left uninitialized." -msgstr "" +msgstr "新しく割り当てられたバイトは初期化されません。" -#: ../../c-api/bytes.rst:430 msgid "" "Resize the writer by adding *grow* bytes to the current writer size. This " "function typically overallocates to achieve amortized performance when " "resizing multiple times." msgstr "" +"現在のライターのサイズに *grow* バイトを加えてサイズを変更します。\n" +"この関数は通常、サイズ変更を繰り返したときの償却性能をよくするため、余分な領" +"域を割り当てます。" -#: ../../c-api/bytes.rst:439 msgid "*grow* can be negative to shrink the writer." -msgstr "" +msgstr "*grow* に負の値を指定するとライターを縮小できます。" -#: ../../c-api/bytes.rst:443 msgid "" "Similar to :c:func:`PyBytesWriter_Grow`, but update also the *buf* pointer." msgstr "" +":c:func:`PyBytesWriter_Grow` と同様ですが、*buf* ポインタも更新します。" -#: ../../c-api/bytes.rst:446 msgid "" "The *buf* pointer is moved if the internal buffer is moved in memory. The " "*buf* relative position within the internal buffer is left unchanged." msgstr "" +"内部バッファがメモリ上で移動した場合は、*buf* ポインタも移動します。\n" +"内部バッファ内での *buf* の相対位置は変わりません。" -#: ../../c-api/bytes.rst:452 msgid "*buf* must not be ``NULL``." -msgstr "" +msgstr "*buf* は ``NULL`` であってはなりません。" -#: ../../c-api/bytes.rst:456 msgid "" "Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" "if (PyBytesWriter_Grow(writer, size) < 0) {\n" @@ -707,18 +767,20 @@ msgid "" "}\n" "return (char*)PyBytesWriter_GetData(writer) + pos;" msgstr "" +"Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);\n" +"if (PyBytesWriter_Grow(writer, size) < 0) {\n" +" return NULL;\n" +"}\n" +"return (char*)PyBytesWriter_GetData(writer) + pos;" -#: ../../c-api/bytes.rst:464 msgid "Example creating the string ``b'abc'``" -msgstr "" +msgstr "文字列 ``b'abc'`` を作成する例" -#: ../../c-api/bytes.rst:466 msgid "" "Example creating the bytes string ``b\"abc\"``, with a fixed size of 3 " "bytes::" -msgstr "" +msgstr "3 バイトの固定サイズでバイト文字列 ``b\"abc\"`` を作成する例です。 ::" -#: ../../c-api/bytes.rst:468 msgid "" "PyObject* create_abc(void)\n" "{\n" @@ -732,10 +794,20 @@ msgid "" " return PyBytesWriter_Finish(writer);\n" "}" msgstr "" +"PyObject* create_abc(void)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(3);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +"\n" +" char *str = PyBytesWriter_GetData(writer);\n" +" memcpy(str, \"abc\", 3);\n" +" return PyBytesWriter_Finish(writer);\n" +"}" -#: ../../c-api/bytes.rst:480 msgid "Variant using a pointer to compute the final size::" -msgstr "" +msgstr "ポインタを使って最終的なサイズを計算する別の例です。 ::" #: ../../c-api/bytes.rst:482 msgid "" @@ -753,17 +825,16 @@ msgid "" "}" msgstr "" -#: ../../c-api/bytes.rst:497 msgid "Update ``PyBytes_FromStringAndSize()`` code" -msgstr "" +msgstr "``PyBytes_FromStringAndSize()`` を使うコードの更新" -#: ../../c-api/bytes.rst:499 msgid "" "Example of code using the soft deprecated ``PyBytes_FromStringAndSize(NULL, " "size)`` API::" msgstr "" +"ソフト非推奨の API ``PyBytes_FromStringAndSize(NULL, size)`` を使うコードの例" +"です。 ::" -#: ../../c-api/bytes.rst:502 msgid "" "int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n" "{\n" @@ -782,12 +853,26 @@ msgid "" " return result;\n" "}" msgstr "" +"int copy_bytes(char *dest, const char *src, Py_ssize_t num_bytes)\n" +"{\n" +" ...\n" +"}\n" +"\n" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyObject *result = PyBytes_FromStringAndSize(NULL, num_bytes);\n" +" if (result == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytes_AS_STRING(result), start, num_bytes) < 0) {\n" +" Py_CLEAR(result);\n" +" }\n" +" return result;\n" +"}" -#: ../../c-api/bytes.rst:519 ../../c-api/bytes.rst:556 msgid "It can now be updated to::" -msgstr "" +msgstr "これを次のように更新できます。 ::" -#: ../../c-api/bytes.rst:521 msgid "" "PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" "{\n" @@ -802,14 +887,24 @@ msgid "" " return PyBytesWriter_Finish(writer);\n" "}" msgstr "" +"PyObject* create_string(const char *start, Py_ssize_t num_bytes)\n" +"{\n" +" PyBytesWriter *writer = PyBytesWriter_Create(num_bytes);\n" +" if (writer == NULL) {\n" +" return NULL;\n" +" }\n" +" if (copy_bytes(PyBytesWriter_GetData(writer), start, num_bytes) < 0) {\n" +" PyBytesWriter_Discard(writer);\n" +" return NULL;\n" +" }\n" +" return PyBytesWriter_Finish(writer);\n" +"}" -#: ../../c-api/bytes.rst:536 msgid "Update ``_PyBytes_Resize()`` code" -msgstr "" +msgstr "``_PyBytes_Resize()`` を使うコードの更新" -#: ../../c-api/bytes.rst:538 msgid "Example of code using the soft deprecated ``_PyBytes_Resize()`` API::" -msgstr "" +msgstr "ソフト非推奨の API ``_PyBytes_Resize()`` を使うコードの例です。 ::" #: ../../c-api/bytes.rst:540 msgid "" diff --git a/c-api/call.po b/c-api/call.po index 6d6ef8068..c1bd0b63a 100644 --- a/c-api/call.po +++ b/c-api/call.po @@ -16,67 +16,74 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/call.rst:6 msgid "Call Protocol" msgstr "Call プロトコル" -#: ../../c-api/call.rst:8 msgid "" "CPython supports two different calling protocols: *tp_call* and vectorcall." msgstr "" +"CPython は *tp_call* と vectorcall の二つの呼び出しプロトコルをサポートしてい" +"ます。" -#: ../../c-api/call.rst:12 msgid "The *tp_call* Protocol" -msgstr "" +msgstr "*tp_call* プロトコル" -#: ../../c-api/call.rst:14 msgid "" "Instances of classes that set :c:member:`~PyTypeObject.tp_call` are " "callable. The signature of the slot is::" msgstr "" +":c:member:`~PyTypeObject.tp_call` を設定したクラスのインスタンスは呼び出し可" +"能です。\n" +"このスロットのシグネチャは次のとおりです。 ::" -#: ../../c-api/call.rst:17 msgid "" "PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);" msgstr "" +"PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);" -#: ../../c-api/call.rst:19 msgid "" "A call is made using a tuple for the positional arguments and a dict for the " "keyword arguments, similarly to ``callable(*args, **kwargs)`` in Python " "code. *args* must be non-NULL (use an empty tuple if there are no arguments) " "but *kwargs* may be *NULL* if there are no keyword arguments." msgstr "" +"Python コードの ``callable(*args, **kwargs)`` と同様に、位置引数のタプルと" +"キーワード引数の辞書を使って呼び出します。\n" +"``args`` は NULL であってはいけません (引数がなければ空のタプルを使いま" +"す)。\n" +"ただし、キーワード引数がなければ ``kwargs`` は ``NULL`` で構いません。" -#: ../../c-api/call.rst:25 msgid "" "This convention is not only used by *tp_call*: :c:member:`~PyTypeObject." "tp_new` and :c:member:`~PyTypeObject.tp_init` also pass arguments this way." msgstr "" +"この規約は *tp_call* だけでなく、:c:member:`~PyTypeObject.tp_new` と :c:" +"member:`~PyTypeObject.tp_init` で引数を渡すときにも使います。" -#: ../../c-api/call.rst:29 msgid "" "To call an object, use :c:func:`PyObject_Call` or another :ref:`call API " "`." msgstr "" +"オブジェクトを呼び出すには :c:func:`PyObject_Call` または別の :ref:`呼び出し " +"API ` を使ってください。" -#: ../../c-api/call.rst:36 msgid "The Vectorcall Protocol" -msgstr "" +msgstr "vectorcall プロトコル" -#: ../../c-api/call.rst:40 msgid "" "The vectorcall protocol was introduced in :pep:`590` as an additional " "protocol for making calls more efficient." msgstr "" +"vectorcall プロトコルは、呼び出しを効率化するための追加のプロトコルとして :" +"pep:`590` で導入されました。" -#: ../../c-api/call.rst:43 msgid "" "As rule of thumb, CPython will prefer the vectorcall for internal calls if " "the callable supports it. However, this is not a hard rule. Additionally, " @@ -87,14 +94,25 @@ msgid "" "achieve this is by setting :c:member:`~PyTypeObject.tp_call` to :c:func:" "`PyVectorcall_Call`. This bears repeating:" msgstr "" +"目安として、呼び出し可能オブジェクトが vectorcall をサポートしていれば、" +"CPython は内部の呼び出しでそれを優先します。\n" +"ただし、厳密な規則ではありません。\n" +"また、サードパーティの拡張の中には :c:func:`PyObject_Call` を使わずに " +"*tp_call* を直接使うものもあります。\n" +"そのため、vectorcall をサポートするクラスは :c:member:`~PyTypeObject." +"tp_call` も実装する必要があります。\n" +"さらに、どちらのプロトコルでも同じ動作をしなければなりません。\n" +"これを実現するために推奨される方法は、:c:member:`~PyTypeObject.tp_call` を :" +"c:func:`PyVectorcall_Call` に設定することです。\n" +"繰り返しますが、次の点が重要です。" -#: ../../c-api/call.rst:57 msgid "" "A class supporting vectorcall **must** also implement :c:member:" "`~PyTypeObject.tp_call` with the same semantics." msgstr "" +"vectorcall をサポートするクラスは、同じ意味を持つ :c:member:`~PyTypeObject." +"tp_call` も **必ず** 実装しなければなりません。" -#: ../../c-api/call.rst:62 msgid "" "The :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class " "when the class's :py:meth:`~object.__call__` method is reassigned. (This " @@ -103,16 +121,24 @@ msgid "" "versions, vectorcall should only be used with :c:macro:`immutable " "` or static types." msgstr "" +"クラスの :py:meth:`~object.__call__` メソッドが再代入されると、そのクラスか" +"ら :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` フラグを取り除くようになりました。\n" +"(この再代入は内部で :c:member:`~PyTypeObject.tp_call` だけを設定するため、" +"vectorcall 関数と動作が異なる可能性があります。)\n" +"以前の Python では、vectorcall は :c:macro:`不変な型 " +"` または静的な型でのみ使うべきです。" -#: ../../c-api/call.rst:69 msgid "" "A class should not implement vectorcall if that would be slower than " "*tp_call*. For example, if the callee needs to convert the arguments to an " "args tuple and kwargs dict anyway, then there is no point in implementing " "vectorcall." msgstr "" +"*tp_call* より遅くなる場合、クラスは vectorcall を実装すべきではありませ" +"ん。\n" +"例えば、呼び出される側が結局引数を args タプルと kwargs 辞書に変換する必要が" +"あるなら、vectorcall を実装する意味はありません。" -#: ../../c-api/call.rst:74 msgid "" "Classes can implement the vectorcall protocol by enabling the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag and setting :c:member:`~PyTypeObject." @@ -120,10 +146,14 @@ msgid "" "*vectorcallfunc* appears. This is a pointer to a function with the following " "signature:" msgstr "" +"クラスは :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` フラグを有効にし、:c:member:" +"`~PyTypeObject.tp_vectorcall_offset` をオブジェクト構造体内の " +"*vectorcallfunc* の位置のオフセットに設定することで、vectorcall プロトコルを" +"実装できます。\n" +"これは次のシグネチャを持つ関数へのポインタです。" -#: ../../c-api/call.rst:82 msgid "*callable* is the object being called." -msgstr "" +msgstr "``callable`` は呼び出されるオブジェクトです。" #: ../../c-api/call.rst:83 msgid "" @@ -146,129 +176,157 @@ msgid "" "positional arguments from *nargsf*, use :c:func:`PyVectorcall_NARGS`." msgstr "" -#: ../../c-api/call.rst:90 msgid "*kwnames* is a tuple containing the names of the keyword arguments;" -msgstr "" +msgstr "``kwnames`` はキーワード引数の名前を含むタプルです。" -#: ../../c-api/call.rst:91 msgid "" "in other words, the keys of the kwargs dict. These names must be strings " "(instances of ``str`` or a subclass) and they must be unique. If there are " "no keyword arguments, then *kwnames* can instead be *NULL*." msgstr "" +"言い換えると、kwargs 辞書のキーです。\n" +"名前は文字列 (``str`` またはそのサブクラスのインスタンス) で、重複してはいけ" +"ません。\n" +"キーワード引数がない場合、``kwnames`` は ``NULL`` でも構いません。" -#: ../../c-api/call.rst:98 msgid "" "If this flag is set in a vectorcall *nargsf* argument, the callee is allowed " "to temporarily change ``args[-1]``. In other words, *args* points to " "argument 1 (not 0) in the allocated vector. The callee must restore the " "value of ``args[-1]`` before returning." msgstr "" +"vectorcall の ``nargsf`` 引数にこのフラグが設定されている場合、呼び出される側" +"は一時的に ``args[-1]`` を変更できます。\n" +"つまり、``args`` は割り当てられたベクトル内の引数 0 ではなく引数 1 を指しま" +"す。\n" +"呼び出される側は、戻る前に ``args[-1]`` の値を元に戻す必要があります。" -#: ../../c-api/call.rst:103 msgid "" "For :c:func:`PyObject_VectorcallMethod`, this flag means instead that " "``args[0]`` may be changed." msgstr "" +":c:func:`PyObject_VectorcallMethod` の場合、このフラグは代わりに ``args[0]`` " +"を変更してよいことを意味します。" -#: ../../c-api/call.rst:106 msgid "" "Whenever they can do so cheaply (without additional allocation), callers are " "encouraged to use :c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET`. Doing so will " "allow callables such as bound methods to make their onward calls (which " "include a prepended *self* argument) very efficiently." msgstr "" +"追加の割り当てなしに低コストで設定できる場合、呼び出し側は :c:macro:" +"`PY_VECTORCALL_ARGUMENTS_OFFSET` を使うことが推奨されます。\n" +"これにより、束縛メソッドなどの呼び出し可能オブジェクトは、先頭に ``self`` 引" +"数を追加して次の呼び出しを行う処理を非常に効率的に実行できます。" -#: ../../c-api/call.rst:113 msgid "" "To call an object that implements vectorcall, use a :ref:`call API ` function as with any other callable. :c:func:`PyObject_Vectorcall` " "will usually be most efficient." msgstr "" +"vectorcall を実装するオブジェクトを呼び出すには、ほかの呼び出し可能オブジェク" +"トと同様に :ref:`呼び出し API ` の関数を使ってください。\n" +"通常は :c:func:`PyObject_Vectorcall` が最も効率的です。" #: ../../c-api/call.rst:119 msgid "Recursion Control" msgstr "再帰の管理" -#: ../../c-api/call.rst:121 msgid "" "When using *tp_call*, callees do not need to worry about :ref:`recursion " "`: CPython uses :c:func:`Py_EnterRecursiveCall` and :c:func:" "`Py_LeaveRecursiveCall` for calls made using *tp_call*." msgstr "" +"*tp_call* を使う場合、呼び出される側は :ref:`再帰 ` を管理する必要" +"はありません。\n" +"CPython は *tp_call* による呼び出しで :c:func:`Py_EnterRecursiveCall` と :c:" +"func:`Py_LeaveRecursiveCall` を使います。" -#: ../../c-api/call.rst:126 msgid "" "For efficiency, this is not the case for calls done using vectorcall: the " "callee should use *Py_EnterRecursiveCall* and *Py_LeaveRecursiveCall* if " "needed." msgstr "" +"効率のため、vectorcall による呼び出しではこの管理を行いません。\n" +"必要に応じて、呼び出される側が ``Py_EnterRecursiveCall()`` と " +"``Py_LeaveRecursiveCall()`` を使ってください。" -#: ../../c-api/call.rst:132 msgid "Vectorcall Support API" -msgstr "" +msgstr "vectorcall サポート API" -#: ../../c-api/call.rst:136 msgid "" "Given a vectorcall *nargsf* argument, return the actual number of arguments. " "Currently equivalent to::" msgstr "" +"vectorcall の ``nargsf`` 引数から、実際の引数の数を返します。\n" +"現在は次と同等です。 ::" -#: ../../c-api/call.rst:140 msgid "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)" -msgstr "" +msgstr "(Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)" -#: ../../c-api/call.rst:142 msgid "" "However, the function ``PyVectorcall_NARGS`` should be used to allow for " "future extensions." msgstr "" +"ただし、将来の拡張に対応するため、関数 ``PyVectorcall_NARGS`` を使ってくださ" +"い。" -#: ../../c-api/call.rst:149 msgid "" "If *op* does not support the vectorcall protocol (either because the type " "does not or because the specific instance does not), return *NULL*. " "Otherwise, return the vectorcall function pointer stored in *op*. This " "function never raises an exception." msgstr "" +"``op`` が vectorcall プロトコルをサポートしていなければ (型がサポートしていな" +"い場合も、そのインスタンスがサポートしていない場合も) ``NULL`` を返します。\n" +"それ以外の場合は、``op`` に格納された vectorcall 関数ポインタを返します。\n" +"この関数が例外を送出することはありません。" -#: ../../c-api/call.rst:154 msgid "" "This is mostly useful to check whether or not *op* supports vectorcall, " "which can be done by checking ``PyVectorcall_Function(op) != NULL``." msgstr "" +"主に、``op`` が vectorcall をサポートするかどうかを確認するのに便利です。\n" +"``PyVectorcall_Function(op) != NULL`` で確認できます。" -#: ../../c-api/call.rst:161 msgid "" "Call *callable*'s :c:type:`vectorcallfunc` with positional and keyword " "arguments given in a tuple and dict, respectively." msgstr "" +"それぞれタプルと辞書で与えられた位置引数とキーワード引数を使い、``callable`` " +"の :c:type:`vectorcallfunc` を呼び出します。" -#: ../../c-api/call.rst:164 msgid "" "This is a specialized function, intended to be put in the :c:member:" "`~PyTypeObject.tp_call` slot or be used in an implementation of ``tp_call``. " "It does not check the :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` flag and it does " "not fall back to ``tp_call``." msgstr "" +"この特殊用途の関数は、:c:member:`~PyTypeObject.tp_call` スロットに設定する" +"か、``tp_call`` の実装内で使うためのものです。\n" +":c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` フラグを確認せず、``tp_call`` への" +"フォールバックも行いません。" -#: ../../c-api/call.rst:175 msgid "Object Calling API" -msgstr "" +msgstr "オブジェクト呼び出し API" -#: ../../c-api/call.rst:177 msgid "" "Various functions are available for calling a Python object. Each converts " "its arguments to a convention supported by the called object – either " "*tp_call* or vectorcall. In order to do as little conversion as possible, " "pick one that best fits the format of data you have available." msgstr "" +"Python オブジェクトを呼び出すためのさまざまな関数があります。\n" +"各関数は、呼び出すオブジェクトがサポートする *tp_call* または vectorcall の規" +"約に引数を変換します。\n" +"変換を最小限にするため、手元のデータの形式に最も合う関数を選んでください。" -#: ../../c-api/call.rst:183 msgid "" "The following table summarizes the available functions; please see " "individual documentation for details." msgstr "" +"利用できる関数を以下の表にまとめます。\n" +"詳細は個別の説明を参照してください。" #: ../../c-api/call.rst:187 msgid "Function" @@ -300,9 +358,8 @@ msgstr "``PyObject *``" msgid "tuple" msgstr "tuple" -#: ../../c-api/call.rst:189 ../../c-api/call.rst:211 msgid "dict/``NULL``" -msgstr "" +msgstr "dict/``NULL``" #: ../../c-api/call.rst:191 msgid ":c:func:`PyObject_CallNoArgs`" @@ -318,17 +375,15 @@ msgstr "---" msgid ":c:func:`PyObject_CallOneArg`" msgstr ":c:func:`PyObject_CallOneArg`" -#: ../../c-api/call.rst:193 ../../c-api/call.rst:207 msgid "1 object" -msgstr "" +msgstr "1 個のオブジェクト" #: ../../c-api/call.rst:195 msgid ":c:func:`PyObject_CallObject`" msgstr ":c:func:`PyObject_CallObject`" -#: ../../c-api/call.rst:195 msgid "tuple/``NULL``" -msgstr "" +msgstr "tuple/``NULL``" #: ../../c-api/call.rst:197 msgid ":c:func:`PyObject_CallFunction`" @@ -342,25 +397,22 @@ msgstr "format" msgid ":c:func:`PyObject_CallMethod`" msgstr ":c:func:`PyObject_CallMethod`" -#: ../../c-api/call.rst:199 msgid "obj + ``char*``" -msgstr "" +msgstr "obj + ``char*``" #: ../../c-api/call.rst:201 msgid ":c:func:`PyObject_CallFunctionObjArgs`" msgstr ":c:func:`PyObject_CallFunctionObjArgs`" -#: ../../c-api/call.rst:201 ../../c-api/call.rst:203 msgid "variadic" -msgstr "" +msgstr "可変長引数" #: ../../c-api/call.rst:203 msgid ":c:func:`PyObject_CallMethodObjArgs`" msgstr ":c:func:`PyObject_CallMethodObjArgs`" -#: ../../c-api/call.rst:203 ../../c-api/call.rst:205 ../../c-api/call.rst:207 msgid "obj + name" -msgstr "" +msgstr "obj + 名前" #: ../../c-api/call.rst:205 msgid ":c:func:`PyObject_CallMethodNoArgs`" @@ -374,9 +426,8 @@ msgstr ":c:func:`PyObject_CallMethodOneArg`" msgid ":c:func:`PyObject_Vectorcall`" msgstr ":c:func:`PyObject_Vectorcall`" -#: ../../c-api/call.rst:209 ../../c-api/call.rst:211 ../../c-api/call.rst:213 msgid "vectorcall" -msgstr "" +msgstr "vectorcall" #: ../../c-api/call.rst:211 msgid ":c:func:`PyObject_VectorcallDict`" @@ -386,9 +437,8 @@ msgstr ":c:func:`PyObject_VectorcallDict`" msgid ":c:func:`PyObject_VectorcallMethod`" msgstr ":c:func:`PyObject_VectorcallMethod`" -#: ../../c-api/call.rst:213 msgid "arg + name" -msgstr "" +msgstr "arg + 名前" #: ../../c-api/call.rst:219 msgid "" @@ -398,14 +448,13 @@ msgstr "" "呼び出し可能な Python のオブジェクト *callable* を、タプル *args* として与え" "られる引数と辞書 *kwargs* として与えられる名前付き引数とともに呼び出します。" -#: ../../c-api/call.rst:222 msgid "" "*args* must not be *NULL*; use an empty tuple if no arguments are needed. If " "no named arguments are needed, *kwargs* can be *NULL*." msgstr "" -"*args* は *NULL* であってはならず、引数を必要としない場合は空のタプルを使って" -"ください。\n" -"*kwargs* は *NULL* でも構いません。" +"``args`` は ``NULL`` であってはいけません。\n" +"引数が不要な場合は空のタプルを使ってください。\n" +"キーワード引数が不要な場合は ``kwargs`` を ``NULL`` にできます。" #: ../../c-api/call.rst:225 ../../c-api/call.rst:237 ../../c-api/call.rst:248 #: ../../c-api/call.rst:259 ../../c-api/call.rst:271 ../../c-api/call.rst:291 @@ -423,26 +472,27 @@ msgid "" "**kwargs)``." msgstr "これは次の Python の式と同等です: ``callable(*args, **kwargs)`` 。" -#: ../../c-api/call.rst:234 msgid "" "Call a callable Python object *callable* without any arguments. It is the " "most efficient way to call a callable Python object without any argument." msgstr "" +"呼び出し可能な Python オブジェクト ``callable`` を引数なしで呼び出します。\n" +"引数なしで呼び出すには最も効率的な方法です。" -#: ../../c-api/call.rst:245 msgid "" "Call a callable Python object *callable* with exactly 1 positional argument " "*arg* and no keyword arguments." msgstr "" +"呼び出し可能な Python オブジェクト ``callable`` を、位置引数 ``arg`` だけを渡" +"し、キーワード引数なしで呼び出します。" -#: ../../c-api/call.rst:256 msgid "" "Call a callable Python object *callable*, with arguments given by the tuple " "*args*. If no arguments are needed, then *args* can be *NULL*." msgstr "" -"呼び出し可能な Python のオブジェクト *callable* を、タプル *args* として与え" -"られる引数とともに呼び出します。\n" -"引数が必要な場合は、 *args* は *NULL* で構いません。" +"呼び出し可能な Python オブジェクト ``callable`` を、タプル ``args`` で与えら" +"れた引数で呼び出します。\n" +"引数が不要な場合は ``args`` を ``NULL`` にできます。" #: ../../c-api/call.rst:262 ../../c-api/call.rst:274 msgid "This is the equivalent of the Python expression: ``callable(*args)``." @@ -461,14 +511,13 @@ msgstr "" "す。\n" "*format* は *NULL* かもしれず、与える引数がないことを表します。" -#: ../../c-api/call.rst:276 msgid "" "Note that if you only pass :c:expr:`PyObject *` args, :c:func:" "`PyObject_CallFunctionObjArgs` is a faster alternative." msgstr "" ":c:expr:`PyObject *` args だけを引数に渡す場合は、 :c:func:" "`PyObject_CallFunctionObjArgs` がより速い方法であることを覚えておいてくださ" -"い。 " +"い。" #: ../../c-api/call.rst:279 msgid "The type of *format* was changed from ``char *``." @@ -485,9 +534,8 @@ msgstr "" "C 引数はタプルを生成する :c:func:`Py_BuildValue` 形式のフォーマット文字列で記" "述されています。" -#: ../../c-api/call.rst:289 msgid "The format can be *NULL*, indicating that no arguments are provided." -msgstr "*format* は *NULL* でもよく、引数が与えられないことを表します。 " +msgstr "*format* は *NULL* でもよく、引数が与えられないことを表します。" #: ../../c-api/call.rst:294 msgid "" @@ -495,14 +543,12 @@ msgid "" "arg2, ...)``." msgstr "これは次の Python の式と同等です: ``obj.name(arg1, arg2, ...)`` 。" -#: ../../c-api/call.rst:297 msgid "" "Note that if you only pass :c:expr:`PyObject *` args, :c:func:" "`PyObject_CallMethodObjArgs` is a faster alternative." msgstr "" ":c:expr:`PyObject *` args だけを引数に渡す場合は、 :c:func:" -"`PyObject_CallMethodObjArgs` がより速い方法であることを覚えておいてくださ" -"い。 " +"`PyObject_CallMethodObjArgs` がより速い方法であることを覚えておいてください。" #: ../../c-api/call.rst:300 msgid "The types of *name* and *format* were changed from ``char *``." @@ -536,52 +582,61 @@ msgstr "" "呼び出されます. 引数列は末尾に *NULL* がついた可変数個のパラメタとして与えま" "す。" -#: ../../c-api/call.rst:330 msgid "" "Call a method of the Python object *obj* without arguments, where the name " "of the method is given as a Python string object in *name*." msgstr "" +"Python オブジェクト ``obj`` のメソッドを引数なしで呼び出します。\n" +"メソッド名は Python 文字列オブジェクト ``name`` で指定します。" -#: ../../c-api/call.rst:341 msgid "" "Call a method of the Python object *obj* with a single positional argument " "*arg*, where the name of the method is given as a Python string object in " "*name*." msgstr "" +"Python オブジェクト ``obj`` のメソッドを、一つの位置引数 ``arg`` を渡して呼び" +"出します。\n" +"メソッド名は Python 文字列オブジェクト ``name`` で指定します。" -#: ../../c-api/call.rst:355 msgid "" "Call a callable Python object *callable*. The arguments are the same as for :" "c:type:`vectorcallfunc`. If *callable* supports vectorcall_, this directly " "calls the vectorcall function stored in *callable*." msgstr "" +"呼び出し可能な Python オブジェクト ``callable`` を呼び出します。\n" +"引数は :c:type:`vectorcallfunc` と同じです。\n" +"``callable`` が vectorcall_ をサポートしている場合は、``callable`` に格納され" +"た vectorcall 関数を直接呼び出します。" -#: ../../c-api/call.rst:363 msgid "as ``_PyObject_Vectorcall``" -msgstr "" +msgstr "``_PyObject_Vectorcall`` として追加。" -#: ../../c-api/call.rst:367 msgid "" "Renamed to the current name, without the leading underscore. The old " "provisional name is :term:`soft deprecated`." msgstr "" +"先頭のアンダースコアを除いた現在の名前に変更されました。\n" +"以前の暫定的な名前は :term:`緩やかに非推奨 ` です。" -#: ../../c-api/call.rst:372 msgid "" "Call *callable* with positional arguments passed exactly as in the " "vectorcall_ protocol, but with keyword arguments passed as a dictionary " "*kwdict*. The *args* array contains only the positional arguments." msgstr "" +"位置引数は vectorcall_ プロトコルとまったく同じ方法で渡し、キーワード引数は辞" +"書 ``kwdict`` で渡して ``callable`` を呼び出します。\n" +"``args`` 配列には位置引数だけを含めます。" -#: ../../c-api/call.rst:376 msgid "" "Regardless of which protocol is used internally, a conversion of arguments " "needs to be done. Therefore, this function should only be used if the caller " "already has a dictionary ready to use for the keyword arguments, but not a " "tuple for the positional arguments." msgstr "" +"内部でどちらのプロトコルを使っても、引数の変換が必要です。\n" +"そのため、この関数は呼び出し側がキーワード引数の辞書をすでに用意していて、位" +"置引数のタプルは持っていない場合だけに使ってください。" -#: ../../c-api/call.rst:386 msgid "" "Call a method using the vectorcall calling convention. The name of the " "method is given as a Python string *name*. The object whose method is called " @@ -592,16 +647,24 @@ msgid "" "temporarily be changed. Keyword arguments can be passed just like in :c:func:" "`PyObject_Vectorcall`." msgstr "" +"vectorcall の呼び出し規約でメソッドを呼び出します。\n" +"メソッド名は Python 文字列 ``name`` で指定します。\n" +"メソッドを呼び出す対象のオブジェクトは ``args[0]`` で、``args[1]`` から始ま" +"る ``args`` 配列が呼び出しの引数を表します。\n" +"位置引数は少なくとも一つ必要です。\n" +"``nargsf`` は ``args[0]`` を含む位置引数の数で、``args[0]`` の値を一時的に変" +"更してよい場合は :c:macro:`PY_VECTORCALL_ARGUMENTS_OFFSET` を加えます。\n" +"キーワード引数は :c:func:`PyObject_Vectorcall` と同じ方法で渡せます。" -#: ../../c-api/call.rst:395 msgid "" "If the object has the :c:macro:`Py_TPFLAGS_METHOD_DESCRIPTOR` feature, this " "will call the unbound method object with the full *args* vector as arguments." msgstr "" +"オブジェクトが :c:macro:`Py_TPFLAGS_METHOD_DESCRIPTOR` の機能を持つ場合、" +"``args`` ベクトル全体を引数として非束縛メソッドオブジェクトを呼び出します。" -#: ../../c-api/call.rst:406 msgid "Call Support API" -msgstr "" +msgstr "呼び出しサポート API" #: ../../c-api/call.rst:410 msgid "" diff --git a/c-api/capsule.po b/c-api/capsule.po index 11c9f7f70..77b66234e 100644 --- a/c-api/capsule.po +++ b/c-api/capsule.po @@ -16,24 +16,22 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/capsule.rst:6 msgid "Capsules" msgstr "カプセル" -#: ../../c-api/capsule.rst:10 msgid "" "Refer to :ref:`using-capsules` for more information on using these objects." msgstr "" -"`using-capsules` 以下のオブジェクトを使う方法については :ref:`using-" -"capsules` を参照してください。" +"これらのオブジェクトの使い方については :ref:`using-capsules` を参照してくださ" +"い。" -#: ../../c-api/capsule.rst:17 msgid "" "This subtype of :c:type:`PyObject` represents an opaque value, useful for C " "extension modules which need to pass an opaque value (as a :c:expr:`void*` " @@ -42,20 +40,27 @@ msgid "" "regular import mechanism can be used to access C APIs defined in dynamically " "loaded modules." msgstr "" +":c:type:`PyObject` のこのサブタイプは不透明な値を表します。\n" +"C 拡張モジュールから Python のコードを経由して別の C コードへ、不透明な値を :" +"c:expr:`void*` ポインタとして渡すのに役立ちます。\n" +"あるモジュールで定義した C 関数ポインタを別のモジュールに公開するためによく使" +"われます。\n" +"これにより、通常のインポートの仕組みを使って、動的にロードしたモジュールの C " +"API にアクセスできます。" -#: ../../c-api/capsule.rst:27 msgid "" "The type object corresponding to capsule objects. This is the same object " "as :class:`types.CapsuleType` in the Python layer." msgstr "" +"カプセルオブジェクトに対応する型オブジェクトです。\n" +"Python レイヤの :class:`types.CapsuleType` と同じオブジェクトです。" #: ../../c-api/capsule.rst:33 msgid "The type of a destructor callback for a capsule. Defined as::" msgstr "カプセルに対するデストラクタコールバック型. 次のように定義されます::" -#: ../../c-api/capsule.rst:35 msgid "typedef void (*PyCapsule_Destructor)(PyObject *);" -msgstr "" +msgstr "typedef void (*PyCapsule_Destructor)(PyObject *);" #: ../../c-api/capsule.rst:37 msgid "" @@ -120,13 +125,17 @@ msgstr "" "カプセルに保存されている *pointer* を取り出します。失敗した場合は例外を設定し" "て ``NULL`` を返します。" -#: ../../c-api/capsule.rst:71 msgid "" "The *name* parameter must compare exactly to the name stored in the capsule. " "If the name stored in the capsule is ``NULL``, the *name* passed in must " "also be ``NULL``. Python uses the C function :c:func:`!strcmp` to compare " "capsule names." msgstr "" +"*name* 引数は、カプセルに格納されている名前と完全に一致しなければなりませ" +"ん。\n" +"カプセルに格納されている名前が ``NULL`` なら、渡す *name* も ``NULL`` でなけ" +"ればなりません。\n" +"Python はカプセル名の比較に C 関数 :c:func:`!strcmp` を使います。" #: ../../c-api/capsule.rst:79 msgid "" @@ -182,39 +191,46 @@ msgstr "" "``NULL`` がエラーを指してない可能性があります。 :c:func:`PyCapsule_IsValid` " "か :c:func:`PyErr_Occurred` を利用して確認してください。" -#: ../../c-api/capsule.rst:109 msgid "" "Import a pointer to a C object from a capsule attribute in a module. The " "*name* parameter should specify the full name to the attribute, as in " "``module.attribute``. The *name* stored in the capsule must match this " "string exactly." msgstr "" +"モジュールのカプセル属性から、C オブジェクトへのポインタをインポートしま" +"す。\n" +"*name* 引数には ``module.attribute`` のような属性の完全名を指定してくださ" +"い。\n" +"カプセルに格納されている *name* は、この文字列と完全に一致する必要がありま" +"す。" -#: ../../c-api/capsule.rst:114 msgid "" "This function splits *name* on the ``.`` character, and imports the first " "element. It then processes further elements using attribute lookups." msgstr "" +"この関数は *name* を ``.`` で分割し、最初の要素をインポートします。\n" +"残りの要素は属性の検索でたどります。" -#: ../../c-api/capsule.rst:117 msgid "" "Return the capsule's internal *pointer* on success. On failure, set an " "exception and return ``NULL``." msgstr "" -"成功した場合、カプセルの内部 *ポインタ* を返します。失敗した場合、例外を設定" -"して ``NULL`` を返します。" +"成功すると、カプセル内部の *pointer* を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/capsule.rst:122 msgid "" "If *name* points to an attribute of some submodule or subpackage, this " "submodule or subpackage must be previously imported using other means (for " "example, by using :c:func:`PyImport_ImportModule`) for the attribute lookups " "to succeed." msgstr "" +"*name* がサブモジュールやサブパッケージの属性を指す場合、属性の検索を成功させ" +"るには、\n" +"事前に別の方法 (例えば :c:func:`PyImport_ImportModule`) でそのサブモジュール" +"やサブパッケージをインポートしておく必要があります。" -#: ../../c-api/capsule.rst:127 msgid "*no_block* has no effect anymore." -msgstr "" +msgstr "*no_block* は効果を持たなくなりました。" #: ../../c-api/capsule.rst:133 msgid "" @@ -229,12 +245,13 @@ msgstr "" "ポインタを格納していて、内部の name が引数 *name* とマッチします。 (name の比" "較方法については :c:func:`PyCapsule_GetPointer` を参照)" -#: ../../c-api/capsule.rst:139 msgid "" "In other words, if :c:func:`PyCapsule_IsValid` returns a true value, calls " "to any of the accessors (any function starting with ``PyCapsule_Get``) are " "guaranteed to succeed." msgstr "" +"言い換えると、:c:func:`PyCapsule_IsValid` が真を返した場合、どのアクセサ " +"(``PyCapsule_Get`` で始まる関数) を呼び出しても成功することが保証されます。" #: ../../c-api/capsule.rst:143 msgid "" @@ -278,7 +295,7 @@ msgstr "" #: ../../c-api/capsule.rst:8 msgid "object" -msgstr "オブジェクト" +msgstr "object" #: ../../c-api/capsule.rst:8 msgid "Capsule" diff --git a/c-api/cell.po b/c-api/cell.po index 7c4488bcc..8a335839f 100644 --- a/c-api/cell.po +++ b/c-api/cell.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/cell.rst:6 msgid "Cell Objects" msgstr "セルオブジェクト (cell object)" -#: ../../c-api/cell.rst:8 msgid "" "\"Cell\" objects are used to implement variables referenced by multiple " "scopes. For each such variable, a cell object is created to store the value; " @@ -37,6 +36,17 @@ msgid "" "support from the generated byte-code; these are not automatically de-" "referenced when accessed. Cell objects are not likely to be useful elsewhere." msgstr "" +"「セル」オブジェクトは、複数のスコープから参照される変数を実装するために使わ" +"れます。\n" +"そのような変数ごとに、値を格納するセルオブジェクトを作成します。\n" +"値を参照する各スタックフレームのローカル変数には、その変数を使う外側のスコー" +"プのセルへの参照が含まれます。\n" +"値にアクセスするときは、セルオブジェクト自体ではなく、セルに格納された値を使" +"います。\n" +"このセルの参照をたどる処理には、生成されるバイトコードによるサポートが必要で" +"す。\n" +"セルにアクセスすれば自動的にその中身が得られるわけではありません。\n" +"ほかの用途でセルオブジェクトが役立つことはあまりないでしょう。" #: ../../c-api/cell.rst:20 msgid "The C structure used for cell objects." @@ -62,11 +72,13 @@ msgstr "" "値 *ob* の入った新たなセルオブジェクトを生成して返します。\n" "引数を ``NULL`` にしてもかまいません。" -#: ../../c-api/cell.rst:42 msgid "" "Return the contents of the cell *cell*, which can be ``NULL``. If *cell* is " "not a cell object, returns ``NULL`` with an exception set." msgstr "" +"セル *cell* の内容を返します。\n" +"内容は ``NULL`` の場合もあります。\n" +"*cell* がセルオブジェクトでなければ、例外を設定して ``NULL`` を返します。" #: ../../c-api/cell.rst:48 msgid "" @@ -76,18 +88,22 @@ msgstr "" "*cell* の内容を返しますが、*cell* が非 ``NULL`` かつセルオブジェクトであるか" "どうかはチェックしません。" -#: ../../c-api/cell.rst:54 msgid "" "Set the contents of the cell object *cell* to *value*. This releases the " "reference to any current content of the cell. *value* may be ``NULL``. " "*cell* must be non-``NULL``." msgstr "" +"セルオブジェクト *cell* の内容を *value* に設定します。\n" +"セルに現在格納されている内容への参照は解放します。\n" +"*value* は ``NULL`` でも構いません。\n" +"*cell* は ``NULL`` であってはなりません。" -#: ../../c-api/cell.rst:58 msgid "" "On success, return ``0``. If *cell* is not a cell object, set an exception " "and return ``-1``." msgstr "" +"成功すると ``0`` を返します。\n" +"*cell* がセルオブジェクトでなければ、例外を設定して ``-1`` を返します。" #: ../../c-api/cell.rst:64 msgid "" diff --git a/c-api/code.po b/c-api/code.po index 1a559ed6a..7201d7101 100644 --- a/c-api/code.po +++ b/c-api/code.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/code.rst:8 @@ -43,93 +43,107 @@ msgstr "" "コードオブジェクトを表現するために利用されるC構造体。この型のフィールドは何時" "でも変更され得ます。" -#: ../../c-api/code.rst:22 msgid "" "This is an instance of :c:type:`PyTypeObject` representing the Python :ref:" "`code object `." msgstr "" +"Python の :ref:`コードオブジェクト ` を表す :c:type:" +"`PyTypeObject` のインスタンスです。" -#: ../../c-api/code.rst:28 msgid "" "Return true if *co* is a :ref:`code object `. This function " "always succeeds." msgstr "" +"``co`` が :ref:`コードオブジェクト ` の場合に真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/code.rst:33 msgid "" "Return the number of :term:`free (closure) variables ` in " "a code object." msgstr "" +"コードオブジェクト内の :term:`自由変数 (クロージャ変数) ` " +"の数を返します。" -#: ../../c-api/code.rst:38 msgid "" "Return the position of the first :term:`free (closure) variable ` in a code object." msgstr "" +"コードオブジェクト内の最初の :term:`自由変数 (クロージャ変数) ` の位置を返します。" -#: ../../c-api/code.rst:43 msgid "" "Renamed from ``PyCode_GetFirstFree`` as part of :ref:`unstable-c-api`. The " "old name is deprecated, but will remain available until the signature " "changes again." msgstr "" +":ref:`unstable-c-api` の一部として ``PyCode_GetFirstFree`` から名前を変更しま" +"した。\n" +"古い名前は非推奨ですが、シグネチャが再び変更されるまでは利用できます。" -#: ../../c-api/code.rst:49 msgid "" "Return a new code object. If you need a dummy code object to create a " "frame, use :c:func:`PyCode_NewEmpty` instead." msgstr "" +"新しいコードオブジェクトを返します。\n" +"フレームの作成にダミーのコードオブジェクトが必要な場合は、代わりに :c:func:" +"`PyCode_NewEmpty` を使ってください。" -#: ../../c-api/code.rst:52 msgid "" "Since the definition of the bytecode changes often, calling :c:func:" "`PyUnstable_Code_New` directly can bind you to a precise Python version." msgstr "" +"バイトコードの定義は頻繁に変わるため、:c:func:`PyUnstable_Code_New` を直接呼" +"び出すと、特定の Python バージョンに依存することがあります。" -#: ../../c-api/code.rst:55 msgid "" "The many arguments of this function are inter-dependent in complex ways, " "meaning that subtle changes to values are likely to result in incorrect " "execution or VM crashes. Use this function only with extreme care." msgstr "" +"この関数の多数の引数は複雑に依存し合っているため、値を少し変えるだけで誤った" +"実行や VM のクラッシュにつながりやすくなっています。\n" +"十分に注意して使ってください。" -#: ../../c-api/code.rst:59 msgid "Added ``qualname`` and ``exceptiontable`` parameters." -msgstr "" +msgstr "``qualname`` と ``exceptiontable`` 引数を追加しました。" -#: ../../c-api/code.rst:66 msgid "" "Renamed from ``PyCode_New`` as part of :ref:`unstable-c-api`. The old name " "is deprecated, but will remain available until the signature changes again." msgstr "" +":ref:`unstable-c-api` の一部として ``PyCode_New`` から名前を変更しました。\n" +"古い名前は非推奨ですが、シグネチャが再び変更されるまでは利用できます。" -#: ../../c-api/code.rst:75 msgid "" "Similar to :c:func:`PyUnstable_Code_New`, but with an extra " "\"posonlyargcount\" for positional-only arguments. The same caveats that " "apply to ``PyUnstable_Code_New`` also apply to this function." msgstr "" +":c:func:`PyUnstable_Code_New` と同様ですが、位置専用引数のための " +"``posonlyargcount`` 引数が追加されています。\n" +"``PyUnstable_Code_New`` と同じ注意事項が当てはまります。" -#: ../../c-api/code.rst:78 msgid "as ``PyCode_NewWithPosOnlyArgs``" -msgstr "" +msgstr "``PyCode_NewWithPosOnlyArgs`` として追加。" -#: ../../c-api/code.rst:80 msgid "Added ``qualname`` and ``exceptiontable`` parameters." -msgstr "" +msgstr "``qualname`` と ``exceptiontable`` 引数を追加しました。" -#: ../../c-api/code.rst:85 msgid "" "Renamed to ``PyUnstable_Code_NewWithPosOnlyArgs``. The old name is " "deprecated, but will remain available until the signature changes again." msgstr "" +"``PyUnstable_Code_NewWithPosOnlyArgs`` に名前を変更しました。\n" +"古い名前は非推奨ですが、シグネチャが再び変更されるまでは利用できます。" -#: ../../c-api/code.rst:91 msgid "" "Return a new empty code object with the specified filename, function name, " "and first line number. The resulting code object will raise an ``Exception`` " "if executed." msgstr "" +"指定されたファイル名、関数名、開始行番号を持つ新しい空のコードオブジェクトを" +"返します。\n" +"このコードオブジェクトを実行すると ``Exception`` を送出します。" #: ../../c-api/code.rst:97 msgid "" @@ -144,97 +158,125 @@ msgid "" "`the API described in PEP 626 <0626#out-of-process-debuggers-and-profilers>`." msgstr "" -#: ../../c-api/code.rst:105 msgid "" "Sets the passed ``int`` pointers to the source code line and column numbers " "for the instruction at ``byte_offset``. Sets the value to ``0`` when " "information is not available for any particular element." msgstr "" +"渡された ``int`` ポインタの参照先に、``byte_offset`` にある命令のソースコード" +"上の行番号と列番号を設定します。\n" +"情報がない項目には ``0`` を設定します。" -#: ../../c-api/code.rst:109 msgid "Returns ``1`` if the function succeeds and 0 otherwise." -msgstr "" +msgstr "成功した場合は ``1`` を返し、それ以外の場合は 0 を返します。" -#: ../../c-api/code.rst:115 msgid "" "Equivalent to the Python code ``getattr(co, 'co_code')``. Returns a strong " "reference to a :c:type:`PyBytesObject` representing the bytecode in a code " "object. On error, ``NULL`` is returned and an exception is raised." msgstr "" +"Python コード ``getattr(co, 'co_code')`` と同等です。\n" +"コードオブジェクト内のバイトコードを表す :c:type:`PyBytesObject` への強参照を" +"返します。\n" +"エラーの場合は例外を送出し、``NULL`` を返します。" -#: ../../c-api/code.rst:120 msgid "" "This ``PyBytesObject`` may be created on-demand by the interpreter and does " "not necessarily represent the bytecode actually executed by CPython. The " "primary use case for this function is debuggers and profilers." msgstr "" +"この ``PyBytesObject`` は、インタープリタが必要に応じて作成する場合があり、" +"CPython が実際に実行するバイトコードを表すとは限りません。\n" +"この関数の主な用途はデバッガとプロファイラです。" -#: ../../c-api/code.rst:128 msgid "" "Equivalent to the Python code ``getattr(co, 'co_varnames')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables. On error, ``NULL`` is returned and an exception is raised." msgstr "" +"Python コード ``getattr(co, 'co_varnames')`` と同等です。\n" +"ローカル変数の名前を含む :c:type:`PyTupleObject` への新しい参照を返します。\n" +"エラーの場合は例外を送出し、``NULL`` を返します。" -#: ../../c-api/code.rst:137 msgid "" "Equivalent to the Python code ``getattr(co, 'co_cellvars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the local " "variables that are referenced by nested functions. On error, ``NULL`` is " "returned and an exception is raised." msgstr "" +"Python コード ``getattr(co, 'co_cellvars')`` と同等です。\n" +"ネストした関数から参照されるローカル変数の名前を含む :c:type:`PyTupleObject` " +"への新しい参照を返します。\n" +"エラーの場合は例外を送出し、``NULL`` を返します。" -#: ../../c-api/code.rst:146 msgid "" "Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new " "reference to a :c:type:`PyTupleObject` containing the names of the :term:" "`free (closure) variables `. On error, ``NULL`` is " "returned and an exception is raised." msgstr "" +"Python コード ``getattr(co, 'co_freevars')`` と同等です。\n" +":term:`自由変数 (クロージャ変数) ` の名前を含む :c:type:" +"`PyTupleObject` への新しい参照を返します。\n" +"エラーの場合は例外を送出し、``NULL`` を返します。" -#: ../../c-api/code.rst:155 msgid "" "Register *callback* as a code object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyCode_ClearWatcher`. In case " "of error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" +"現在のインタープリタのコードオブジェクトウォッチャーとして ``callback`` を登" +"録します。\n" +":c:func:`PyCode_ClearWatcher` に渡せる ID を返します。\n" +"エラーの場合 (例えば利用可能なウォッチャー ID がない場合) は、例外を設定して " +"``-1`` を返します。" -#: ../../c-api/code.rst:164 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyCode_AddWatcher` for the current interpreter. Return ``0`` on success, or " "``-1`` and set an exception on error (e.g. if the given *watcher_id* was " "never registered.)" msgstr "" +"現在のインタープリタについて、:c:func:`PyCode_AddWatcher` が以前返した " +"``watcher_id`` で識別されるウォッチャーを解除します。\n" +"成功した場合は ``0`` を返します。\n" +"エラーの場合 (例えば指定した ``watcher_id`` が登録されていない場合) は、例外" +"を設定して ``-1`` を返します。" -#: ../../c-api/code.rst:173 msgid "" "Enumeration of possible code object watcher events: - " "``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" msgstr "" +"コードオブジェクトウォッチャーで発生し得るイベントの列挙型: - " +"``PY_CODE_EVENT_CREATE`` - ``PY_CODE_EVENT_DESTROY``" -#: ../../c-api/code.rst:181 msgid "Type of a code object watcher callback function." -msgstr "" +msgstr "コードオブジェクトウォッチャーのコールバック関数の型。" -#: ../../c-api/code.rst:183 msgid "" "If *event* is ``PY_CODE_EVENT_CREATE``, then the callback is invoked after " "*co* has been fully initialized. Otherwise, the callback is invoked before " "the destruction of *co* takes place, so the prior state of *co* can be " "inspected." msgstr "" +"``event`` が ``PY_CODE_EVENT_CREATE`` の場合、コールバックは ``co`` の初期化" +"がすべて完了した後で呼び出されます。\n" +"それ以外の場合は ``co`` を破棄する前に呼び出されるので、破棄前の状態を調べら" +"れます。" -#: ../../c-api/code.rst:188 msgid "" "If *event* is ``PY_CODE_EVENT_DESTROY``, taking a reference in the callback " "to the about-to-be-destroyed code object will resurrect it and prevent it " "from being freed at this time. When the resurrected object is destroyed " "later, any watcher callbacks active at that time will be called again." msgstr "" +"``event`` が ``PY_CODE_EVENT_DESTROY`` の場合、コールバック内で破棄されようと" +"しているコードオブジェクトへの参照を取得すると、そのオブジェクトが復活し、こ" +"の時点での解放を防ぎます。\n" +"復活したオブジェクトが後で破棄されるときは、その時点で有効なウォッチャーの" +"コールバックが再び呼び出されます。" -#: ../../c-api/code.rst:193 msgid "" "Users of this API should not rely on internal runtime implementation " "details. Such details may include, but are not limited to, the exact order " @@ -243,15 +285,23 @@ msgid "" "whether a callback is invoked or not), it does not change the semantics of " "the Python code being executed." msgstr "" +"この API の利用者は、ランタイム内部の実装の詳細に依存してはいけません。\n" +"例えばコードオブジェクトの作成や破棄の正確な順序とタイミングなどが該当します" +"が、これらに限りません。\n" +"こうした詳細の変更によって、コールバックが呼び出されるかどうかも含めてウォッ" +"チャーから観測できる違いが生じることはありますが、実行される Python コードの" +"意味は変わりません。" -#: ../../c-api/code.rst:200 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" +"コールバックが例外を設定した場合は ``-1`` を返す必要があります。\n" +"その例外は、:c:func:`PyErr_WriteUnraisable` を使って送出できない例外として表" +"示されます。\n" +"それ以外の場合は ``0`` を返してください。" -#: ../../c-api/code.rst:204 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -259,46 +309,58 @@ msgid "" "exception unless it saves and clears the exception state first, and restores " "it before returning." msgstr "" +"コールバックに入る時点で、すでに処理待ちの例外が設定されている場合がありま" +"す。\n" +"その場合、コールバックは同じ例外を設定したまま ``0`` を返すべきです。\n" +"そのため、例外を設定し得る別の API を呼び出す場合は、まず例外の状態を保存して" +"クリアし、戻る前に復元する必要があります。" -#: ../../c-api/code.rst:215 msgid "This is a function that does nothing." -msgstr "" +msgstr "何も行わない関数です。" -#: ../../c-api/code.rst:217 msgid "" "Prior to Python 3.10, this function would perform basic optimizations to a " "code object." msgstr "" +"Python 3.10 より前では、この関数はコードオブジェクトに基本的な最適化を行って" +"いました。" -#: ../../c-api/code.rst:220 msgid "This function now does nothing." -msgstr "" +msgstr "この関数は何も行わなくなりました。" -#: ../../c-api/code.rst:229 msgid "Code Object Flags" -msgstr "" +msgstr "コードオブジェクトのフラグ" -#: ../../c-api/code.rst:231 msgid "" "Code objects contain a bit-field of flags, which can be retrieved as the :" "attr:`~codeobject.co_flags` Python attribute (for example using :c:func:" "`PyObject_GetAttrString`), and set using a *flags* argument to :c:func:" "`PyUnstable_Code_New` and similar functions." msgstr "" +"コードオブジェクトはフラグのビットフィールドを持ちます。\n" +"Python 属性 :attr:`~codeobject.co_flags` として (例えば :c:func:" +"`PyObject_GetAttrString` で) 取得でき、:c:func:`PyUnstable_Code_New` などの関" +"数の ``flags`` 引数で設定できます。" -#: ../../c-api/code.rst:236 msgid "" "Flags whose names start with ``CO_FUTURE_`` correspond to features normally " "selectable by :ref:`future statements `. These flags can be used in :" "c:member:`PyCompilerFlags.cf_flags`. Note that many ``CO_FUTURE_`` flags are " "mandatory in current versions of Python, and setting them has no effect." msgstr "" +"名前が ``CO_FUTURE_`` で始まるフラグは、通常 :ref:`future 文 ` で選択" +"する機能に対応します。\n" +"これらは :c:member:`PyCompilerFlags.cf_flags` で使えます。\n" +"現在の Python では、多くの ``CO_FUTURE_`` フラグに対応する機能が必須となって" +"おり、フラグを設定しても効果はありません。" -#: ../../c-api/code.rst:242 msgid "" "The following flags are available. For their meaning, see the linked " "documentation of their Python equivalents." msgstr "" +"以下のフラグを利用できます。\n" +"意味については、対応する Python 側のフラグのドキュメントへのリンクを参照して" +"ください。" #: ../../c-api/code.rst:250 msgid "Flag" @@ -308,99 +370,84 @@ msgstr "Flag" msgid "Meaning" msgstr "意味" -#: ../../c-api/code.rst:253 msgid ":py:data:`inspect.CO_OPTIMIZED`" -msgstr "" +msgstr ":py:data:`inspect.CO_OPTIMIZED`" -#: ../../c-api/code.rst:255 msgid ":py:data:`inspect.CO_NEWLOCALS`" -msgstr "" +msgstr ":py:data:`inspect.CO_NEWLOCALS`" -#: ../../c-api/code.rst:257 msgid ":py:data:`inspect.CO_VARARGS`" -msgstr "" +msgstr ":py:data:`inspect.CO_VARARGS`" -#: ../../c-api/code.rst:259 msgid ":py:data:`inspect.CO_VARKEYWORDS`" -msgstr "" +msgstr ":py:data:`inspect.CO_VARKEYWORDS`" -#: ../../c-api/code.rst:261 msgid ":py:data:`inspect.CO_NESTED`" -msgstr "" +msgstr ":py:data:`inspect.CO_NESTED`" -#: ../../c-api/code.rst:263 msgid ":py:data:`inspect.CO_GENERATOR`" -msgstr "" +msgstr ":py:data:`inspect.CO_GENERATOR`" -#: ../../c-api/code.rst:265 msgid ":py:data:`inspect.CO_COROUTINE`" -msgstr "" +msgstr ":py:data:`inspect.CO_COROUTINE`" -#: ../../c-api/code.rst:267 msgid ":py:data:`inspect.CO_ITERABLE_COROUTINE`" -msgstr "" +msgstr ":py:data:`inspect.CO_ITERABLE_COROUTINE`" -#: ../../c-api/code.rst:269 msgid ":py:data:`inspect.CO_ASYNC_GENERATOR`" -msgstr "" +msgstr ":py:data:`inspect.CO_ASYNC_GENERATOR`" -#: ../../c-api/code.rst:271 msgid ":py:data:`inspect.CO_HAS_DOCSTRING`" -msgstr "" +msgstr ":py:data:`inspect.CO_HAS_DOCSTRING`" -#: ../../c-api/code.rst:273 msgid ":py:data:`inspect.CO_METHOD`" -msgstr "" +msgstr ":py:data:`inspect.CO_METHOD`" -#: ../../c-api/code.rst:276 msgid "no effect (:py:data:`__future__.division`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.division`)" -#: ../../c-api/code.rst:278 msgid "no effect (:py:data:`__future__.absolute_import`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.absolute_import`)" -#: ../../c-api/code.rst:280 msgid "no effect (:py:data:`__future__.with_statement`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.with_statement`)" -#: ../../c-api/code.rst:282 msgid "no effect (:py:data:`__future__.print_function`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.print_function`)" -#: ../../c-api/code.rst:284 msgid "no effect (:py:data:`__future__.unicode_literals`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.unicode_literals`)" -#: ../../c-api/code.rst:286 msgid "no effect (:py:data:`__future__.generator_stop`)" -msgstr "" +msgstr "効果なし (:py:data:`__future__.generator_stop`)" -#: ../../c-api/code.rst:288 msgid ":py:data:`__future__.annotations`" -msgstr "" +msgstr ":py:data:`__future__.annotations`" -#: ../../c-api/code.rst:292 msgid "Extra information" -msgstr "" +msgstr "追加情報" -#: ../../c-api/code.rst:294 msgid "" "To support low-level extensions to frame evaluation, such as external just-" "in-time compilers, it is possible to attach arbitrary extra data to code " "objects." msgstr "" +"外部の JIT コンパイラなど、フレーム評価の低レベルな拡張をサポートするため、" +"コードオブジェクトには任意の追加データを付加できます。" -#: ../../c-api/code.rst:298 msgid "" "These functions are part of the unstable C API tier: this functionality is a " "CPython implementation detail, and the API may change without deprecation " "warnings." msgstr "" +"これらの関数は不安定な C API の階層に属します。\n" +"この機能は CPython の実装の詳細であり、API は非推奨の警告なしに変更される可能" +"性があります。" -#: ../../c-api/code.rst:307 msgid "Return a new opaque index value used to adding data to code objects." msgstr "" +"コードオブジェクトにデータを追加するための、新しい不透明なインデックス値を返" +"します。" #: ../../c-api/code.rst:309 msgid "" @@ -409,64 +456,72 @@ msgid "" "individual code objects." msgstr "" -#: ../../c-api/code.rst:313 msgid "" "If *free* is not ``NULL``: when a code object is deallocated, *free* will be " "called on non-``NULL`` data stored under the new index. Use :c:func:" "`Py_DecRef` when storing :c:type:`PyObject`." msgstr "" +"``free`` が ``NULL`` でない場合、コードオブジェクトの解放時に、その新しいイン" +"デックスに格納されている非 ``NULL`` のデータに対して ``free`` を呼び出しま" +"す。\n" +":c:type:`PyObject` を格納する場合は :c:func:`Py_DecRef` を使ってください。" -#: ../../c-api/code.rst:317 msgid "as ``_PyEval_RequestCodeExtraIndex``" -msgstr "" +msgstr "``_PyEval_RequestCodeExtraIndex`` として追加。" -#: ../../c-api/code.rst:321 msgid "" "Renamed to ``PyUnstable_Eval_RequestCodeExtraIndex``. The old private name " "is deprecated, but will be available until the API changes." msgstr "" +"``PyUnstable_Eval_RequestCodeExtraIndex`` に名前を変更しました。\n" +"古いプライベートな名前は非推奨ですが、API が変更されるまでは利用できます。" -#: ../../c-api/code.rst:330 msgid "" "Set *extra* to the extra data stored under the given index. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" +"指定されたインデックスに格納された追加データを ``extra`` に設定します。\n" +"成功した場合は 0 を返します。\n" +"失敗した場合は例外を設定して -1 を返します。" -#: ../../c-api/code.rst:333 msgid "" "If no data was set under the index, set *extra* to ``NULL`` and return 0 " "without setting an exception." msgstr "" +"そのインデックスにデータが設定されていない場合は、``extra`` を ``NULL`` に設" +"定し、例外を設定せずに 0 を返します。" -#: ../../c-api/code.rst:336 msgid "as ``_PyCode_GetExtra``" -msgstr "" +msgstr "``_PyCode_GetExtra`` として追加。" -#: ../../c-api/code.rst:340 msgid "" "Renamed to ``PyUnstable_Code_GetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" +"``PyUnstable_Code_GetExtra`` に名前を変更しました。\n" +"古いプライベートな名前は非推奨ですが、API が変更されるまでは利用できます。" -#: ../../c-api/code.rst:349 msgid "" "Set the extra data stored under the given index to *extra*. Return 0 on " "success. Set an exception and return -1 on failure." msgstr "" +"指定されたインデックスに格納する追加データを ``extra`` に設定します。\n" +"成功した場合は 0 を返します。\n" +"失敗した場合は例外を設定して -1 を返します。" -#: ../../c-api/code.rst:352 msgid "as ``_PyCode_SetExtra``" -msgstr "" +msgstr "``_PyCode_SetExtra`` として追加。" -#: ../../c-api/code.rst:356 msgid "" "Renamed to ``PyUnstable_Code_SetExtra``. The old private name is deprecated, " "but will be available until the API changes." msgstr "" +"``PyUnstable_Code_SetExtra`` に名前を変更しました。\n" +"古いプライベートな名前は非推奨ですが、API が変更されるまでは利用できます。" #: ../../c-api/code.rst:3 msgid "object" -msgstr "オブジェクト" +msgstr "object" #: ../../c-api/code.rst:3 msgid "code" diff --git a/c-api/codec.po b/c-api/codec.po index b39a28567..032ec9442 100644 --- a/c-api/codec.po +++ b/c-api/codec.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/codec.rst:4 @@ -30,12 +30,15 @@ msgstr "codec レジストリとサポート関数" msgid "Register a new codec search function." msgstr "新しい codec 検索関数を登録します。" -#: ../../c-api/codec.rst:10 msgid "" "As a side effect, this tries to load the :mod:`!encodings` package, if not " "yet done, to make sure that it is always first in the list of search " "functions." msgstr "" +"副作用として、:mod:`!encodings` パッケージをまだロードしていなければロードを" +"試みます。\n" +"これにより、検索関数のリストでこのパッケージの検索関数が常に先頭になるように" +"します。" #: ../../c-api/codec.rst:15 msgid "" @@ -77,29 +80,32 @@ msgstr "" msgid "Generic codec based decoding API." msgstr "汎用の codec ベースのデコード API." -#: ../../c-api/codec.rst:39 msgid "" "*object* is passed through the decoder function found for the given " "*encoding* using the error handling method defined by *errors*. *errors* " "may be ``NULL`` to use the default method defined for the codec. Raises a :" "exc:`LookupError` if no decoder can be found." msgstr "" +"*encoding* に対応するデコーダ関数に *object* を渡し、*errors* で指定したエ" +"ラー処理方法を使います。\n" +"*errors* は ``NULL`` でも構わず、その場合はコーデックが定めるデフォルトの方法" +"を使います。\n" +"デコーダが見つからなければ :exc:`LookupError` を送出します。" #: ../../c-api/codec.rst:46 msgid "Codec lookup API" msgstr "コーデック検索API" -#: ../../c-api/codec.rst:48 msgid "" "In the following functions, the *encoding* string is looked up converted to " "all lower-case characters, which makes encodings looked up through this " "mechanism effectively case-insensitive. If no codec is found, a :exc:" "`KeyError` is set and ``NULL`` returned." msgstr "" -"次の関数では、文字列 *encoding* は全て小文字に変換することで、効率的に、大文" -"字小文字を無視した検索をします。\n" -"コーデックが見つからない場合、 :exc:`KeyError` を設定して ``NULL`` を返しま" -"す。" +"以下の関数では、文字列 *encoding* をすべて小文字に変換してから検索します。\n" +"このため、この仕組みによるエンコーディングの検索では、実質的に大文字と小文字" +"を区別しません。\n" +"コーデックが見つからなければ :exc:`KeyError` を設定して ``NULL`` を返します。" #: ../../c-api/codec.rst:55 msgid "Get an encoder function for the given *encoding*." @@ -217,12 +223,10 @@ msgstr "" msgid "Replace the unicode encode error with ``\\N{...}`` escapes." msgstr "unicode encode エラーを ``\\N{...}`` で置き換えます。" -#: ../../c-api/codec.rst:135 msgid "Codec utility variables" -msgstr "" +msgstr "コーデックのユーティリティ変数" -#: ../../c-api/codec.rst:139 msgid "" "A string constant containing the lowercase hexadecimal digits: " "``\"0123456789abcdef\"``." -msgstr "" +msgstr "小文字の 16 進数字を含む文字列定数 ``\"0123456789abcdef\"``。" diff --git a/c-api/complex.po b/c-api/complex.po index 96ca06731..7e3ced005 100644 --- a/c-api/complex.po +++ b/c-api/complex.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/complex.rst:6 @@ -31,17 +31,18 @@ msgid "" "This subtype of :c:type:`PyObject` represents a Python complex number object." msgstr "この :c:type:`PyObject` のサブタイプは Python の複素数型を表現します。" -#: ../../c-api/complex.rst:17 msgid "" "The complex number value, using the C :c:type:`Py_complex` representation." -msgstr "" +msgstr "C の :c:type:`Py_complex` 表現による複素数の値。" -#: ../../c-api/complex.rst:19 msgid "" "Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to " "convert a Python complex number to/from the C :c:type:`Py_complex` " "representation." msgstr "" +"Python の複素数と C の :c:type:`Py_complex` 表現を相互に変換するには、:c:" +"func:`PyComplex_AsCComplex` と :c:func:`PyComplex_FromCComplex` を使ってくだ" +"さい。" #: ../../c-api/complex.rst:28 msgid "" @@ -67,39 +68,45 @@ msgstr "" "引数が :c:type:`PyComplexObject` であるが :c:type:`PyComplexObject` のサブタ" "イプでないときに真を返します。この関数は常に成功します。" -#: ../../c-api/complex.rst:46 msgid "" "Return a new :c:type:`PyComplexObject` object from *real* and *imag*. Return " "``NULL`` with an exception set on error." msgstr "" +"*real* と *imag* から新しい :c:type:`PyComplexObject` オブジェクトを作成して" +"返します。\n" +"エラーの場合は例外を設定して ``NULL`` を返します。" #: ../../c-api/complex.rst:52 msgid "Return the real part of *op* as a C :c:expr:`double`." msgstr "*op* の実数部分を C の :c:expr:`double` 型で返します。" -#: ../../c-api/complex.rst:54 msgid "" "If *op* is not a Python complex number object but has a :meth:`~object." "__complex__` method, this method will first be called to convert *op* to a " "Python complex number object. If :meth:`!__complex__` is not defined then " "it falls back to call :c:func:`PyFloat_AsDouble` and returns its result." msgstr "" +"*op* が Python の複素数オブジェクトでなく、:meth:`~object.__complex__` メソッ" +"ドを持つ場合は、まずこのメソッドを呼び出し、*op* を Python の複素数オブジェク" +"トに変換します。\n" +":meth:`!__complex__` が定義されていなければ、代わりに :c:func:" +"`PyFloat_AsDouble` を呼び出し、その結果を返します。" -#: ../../c-api/complex.rst:60 ../../c-api/complex.rst:76 msgid "" "Upon failure, this method returns ``-1.0`` with an exception set, so one " "should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" +"失敗すると、例外を設定して ``-1.0`` を返します。\n" +"そのため、エラーの有無を確認するには :c:func:`PyErr_Occurred` を呼び出してく" +"ださい。" -#: ../../c-api/complex.rst:63 ../../c-api/complex.rst:79 msgid "Use :meth:`~object.__complex__` if available." -msgstr "" +msgstr "利用可能なら :meth:`~object.__complex__` を使うようになりました。" #: ../../c-api/complex.rst:68 msgid "Return the imaginary part of *op* as a C :c:expr:`double`." msgstr "*op* の虚数部分を C の :c:expr:`double` 型で返します。" -#: ../../c-api/complex.rst:70 msgid "" "If *op* is not a Python complex number object but has a :meth:`~object." "__complex__` method, this method will first be called to convert *op* to a " @@ -107,35 +114,43 @@ msgid "" "it falls back to call :c:func:`PyFloat_AsDouble` and returns ``0.0`` on " "success." msgstr "" +"*op* が Python の複素数オブジェクトでなく、:meth:`~object.__complex__` メソッ" +"ドを持つ場合は、まずこのメソッドを呼び出し、*op* を Python の複素数オブジェク" +"トに変換します。\n" +":meth:`!__complex__` が定義されていなければ、代わりに :c:func:" +"`PyFloat_AsDouble` を呼び出し、成功時に ``0.0`` を返します。" -#: ../../c-api/complex.rst:85 msgid "" "This C structure defines an export format for a Python complex number object." msgstr "" +"この C 構造体は、Python の複素数オブジェクトをエクスポートする形式を定義しま" +"す。" -#: ../../c-api/complex.rst:91 msgid "The structure is defined as::" -msgstr "" +msgstr "構造体は次のように定義されています。 ::" -#: ../../c-api/complex.rst:93 msgid "" "typedef struct {\n" " double real;\n" " double imag;\n" "} Py_complex;" msgstr "" +"typedef struct {\n" +" double real;\n" +" double imag;\n" +"} Py_complex;" -#: ../../c-api/complex.rst:101 msgid "" "Create a new Python complex number object from a C :c:type:`Py_complex` " "value. Return ``NULL`` with an exception set on error." msgstr "" +"C の :c:type:`Py_complex` 値から、新しい Python の複素数オブジェクトを作成し" +"ます。\n" +"エラーの場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/complex.rst:107 msgid "Return the :c:type:`Py_complex` value of the complex number *op*." -msgstr "複素数値 *op* から :c:type:`Py_complex` 型を生成します。" +msgstr "複素数 *op* の値を :c:type:`Py_complex` として返します。" -#: ../../c-api/complex.rst:109 msgid "" "If *op* is not a Python complex number object but has a :meth:`~object." "__complex__` method, this method will first be called to convert *op* to a " @@ -143,13 +158,23 @@ msgid "" "it falls back to :meth:`~object.__float__`. If :meth:`!__float__` is not " "defined then it falls back to :meth:`~object.__index__`." msgstr "" +"*op* が Python の複素数オブジェクトでなく、:meth:`~object.__complex__` メソッ" +"ドを持つ場合は、まずこのメソッドを呼び出し、*op* を Python の複素数オブジェク" +"トに変換します。\n" +":meth:`!__complex__` が定義されていなければ、代わりに :meth:`~object." +"__float__` を使います。\n" +":meth:`!__float__` も定義されていなければ、代わりに :meth:`~object." +"__index__` を使います。" -#: ../../c-api/complex.rst:115 msgid "" "Upon failure, this method returns :c:type:`Py_complex` with :c:member:" "`~Py_complex.real` set to ``-1.0`` and with an exception set, so one should " "call :c:func:`PyErr_Occurred` to check for errors." msgstr "" +"失敗すると、例外を設定し、:c:member:`~Py_complex.real` を ``-1.0`` にした :c:" +"type:`Py_complex` を返します。\n" +"そのため、エラーの有無を確認するには :c:func:`PyErr_Occurred` を呼び出してく" +"ださい。" #: ../../c-api/complex.rst:119 msgid "Use :meth:`~object.__index__` if available." @@ -159,21 +184,28 @@ msgstr "可能であれば :meth:`~object.__index__` を使うようになりま msgid "Complex Numbers as C Structures" msgstr "C 構造体としての複素数" -#: ../../c-api/complex.rst:126 msgid "" "The API also provides functions for working with complex numbers, using the :" "c:type:`Py_complex` representation. Note that the functions which accept " "these structures as parameters and return them as results do so *by value* " "rather than dereferencing them through pointers." msgstr "" +"この API は、:c:type:`Py_complex` 表現を使って複素数を扱う関数も提供しま" +"す。\n" +"これらの構造体を引数として受け取り、結果として返す関数は、ポインタを介して参" +"照するのではなく、*値渡し* を行う点に注意してください。" -#: ../../c-api/complex.rst:131 msgid "" "Please note, that these functions are :term:`soft deprecated` since Python " "3.15. Avoid using this API in a new code to do complex arithmetic: either " "use the :ref:`Number Protocol ` API or use native complex types, " "like :c:expr:`double complex`." msgstr "" +"これらの関数は Python 3.15 以降、:term:`ソフト非推奨 ` で" +"す。\n" +"新しいコードでは、複素数演算にこの API を使うのは避けてください。\n" +"代わりに :ref:`数値プロトコル ` の API を使うか、:c:expr:`double " +"complex` などのネイティブな複素数型を使ってください。" #: ../../c-api/complex.rst:139 msgid "" @@ -205,35 +237,31 @@ msgid "" "representation." msgstr "二つの複素数の商を C の :c:type:`Py_complex` 型で返します。" -#: ../../c-api/complex.rst:174 msgid "" "If *divisor* is null, this method returns zero and sets :c:data:`errno` to :" "c:macro:`!EDOM`." msgstr "" -"*divisor* が null の場合は、このメソッドはゼロを返し、 :c:data:`errno` に :c:" -"macro:`!EDOM` をセットします。" +"*divisor* がゼロの場合、この関数はゼロを返し、:c:data:`errno` に :c:macro:`!" +"EDOM` を設定します。" -#: ../../c-api/complex.rst:182 msgid "" "Return the exponentiation of *num* by *exp*, using the C :c:type:" "`Py_complex` representation." -msgstr "指数 *exp* の *num* 乗を C の :c:type:`Py_complex` 型で返します。" +msgstr "*num* の *exp* 乗を、C の :c:type:`Py_complex` 表現で返します。" -#: ../../c-api/complex.rst:185 msgid "" "If *num* is null and *exp* is not a positive real number, this method " "returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`." msgstr "" -"*num* が null で *exp* が正の実数でない場合は、このメソッドはゼロを返し、 :c:" -"data:`errno` に :c:macro:`!EDOM` をセットします。" +"*num* がゼロで、*exp* が正の実数でない場合、この関数はゼロを返し、:c:data:" +"`errno` に :c:macro:`!EDOM` を設定します。" -#: ../../c-api/complex.rst:188 ../../c-api/complex.rst:197 msgid "Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows." msgstr "" +"オーバーフロー時は :c:data:`errno` に :c:macro:`!ERANGE` を設定します。" -#: ../../c-api/complex.rst:195 msgid "Return the absolute value of the complex number *num*." -msgstr "" +msgstr "複素数 *num* の絶対値を返します。" #: ../../c-api/complex.rst:8 msgid "object" diff --git a/c-api/concrete.po b/c-api/concrete.po index 0cbe37d8e..d2135349c 100644 --- a/c-api/concrete.po +++ b/c-api/concrete.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/concrete.rst:8 @@ -43,7 +43,6 @@ msgstr "" "ます。この章は Python のオブジェクト型における \"家計図\" に従って構成されて" "います。" -#: ../../c-api/concrete.rst:19 msgid "" "While the functions described in this chapter carefully check the type of " "the objects which are passed in, many of them do not check for ``NULL`` " @@ -51,11 +50,10 @@ msgid "" "can cause memory access violations and immediate termination of the " "interpreter." msgstr "" -"この章で述べている関数は、渡されたオブジェクトの型を注意深くチェックしはする" -"ものの、多くの関数は渡されたオブジェクトが有効な ``NULL`` なのか有効なオブ" -"ジェクトなのかをチェックしません。これらの関数に ``NULL`` を渡させてしまう" -"と、関数はメモリアクセス違反を起こして、インタプリタを即座に終了させてしまう" -"はずです。" +"この章で説明する関数は、渡されたオブジェクトの型を入念に確認しますが、多くは" +"有効なオブジェクトの代わりに ``NULL`` が渡されたかどうかを確認しません。\n" +"``NULL`` を渡してしまうと、メモリアクセス違反が起きたり、インタープリタが直ち" +"に終了したりする可能性があります。" #: ../../c-api/concrete.rst:28 msgid "Fundamental Objects" @@ -98,9 +96,8 @@ msgstr "Function オブジェクト" msgid "Other Objects" msgstr "その他のオブジェクト" -#: ../../c-api/concrete.rst:124 msgid "C API for extension modules" -msgstr "" +msgstr "拡張モジュール用の C API" #: ../../c-api/concrete.rst:43 ../../c-api/concrete.rst:58 #: ../../c-api/concrete.rst:80 diff --git a/c-api/contextvars.po b/c-api/contextvars.po index fda738ee5..4e70ef8ab 100644 --- a/c-api/contextvars.po +++ b/c-api/contextvars.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/contextvars.rst:6 @@ -36,7 +36,6 @@ msgstr "" "`PyContext`, :c:type:`PyContextVar`, :c:type:`PyContextToken` の代わりに :c:" "type:`PyObject` ポインタを使うように **変更** されました。例えば::" -#: ../../c-api/contextvars.rst:20 msgid "" "// in 3.7.0:\n" "PyContext *PyContext_New(void);\n" @@ -44,6 +43,11 @@ msgid "" "// in 3.7.1+:\n" "PyObject *PyContext_New(void);" msgstr "" +"// 3.7.0 では:\n" +"PyContext *PyContext_New(void);\n" +"\n" +"// 3.7.1 以降では:\n" +"PyObject *PyContext_New(void);" #: ../../c-api/contextvars.rst:26 msgid "See :issue:`34762` for more details." @@ -160,48 +164,63 @@ msgstr "" "ンテキストに復元します。\n" "成功したら ``0`` を、失敗したら ``-1`` を返します。" -#: ../../c-api/contextvars.rst:106 msgid "" "Register *callback* as a context object watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyContext_ClearWatcher`. In " "case of error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" +"*callback* を現在のインタープリタのコンテキストオブジェクトのウォッチャーとし" +"て登録します。\n" +":c:func:`PyContext_ClearWatcher` に渡せる ID を返します。\n" +"利用できるウォッチャー ID が残っていない場合など、エラーの場合は例外を設定し" +"て ``-1`` を返します。" -#: ../../c-api/contextvars.rst:115 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyContext_AddWatcher` for the current interpreter. Return ``0`` on success, " "or ``-1`` and set an exception on error (e.g. if the given *watcher_id* was " "never registered.)" msgstr "" +"現在のインタープリタについて、:c:func:`PyContext_AddWatcher` が以前に返した " +"*watcher_id* で識別されるウォッチャーを解除します。\n" +"成功すると ``0`` を返します。\n" +"指定した *watcher_id* が登録されていない場合など、エラーの場合は例外を設定し" +"て ``-1`` を返します。" -#: ../../c-api/contextvars.rst:124 msgid "Enumeration of possible context object watcher events:" -msgstr "" +msgstr "コンテキストオブジェクトのウォッチャーが受け取るイベントの列挙:" -#: ../../c-api/contextvars.rst:126 msgid "" "``Py_CONTEXT_SWITCHED``: The :term:`current context` has switched to a " "different context. The object passed to the watch callback is the now-" "current :class:`contextvars.Context` object, or None if no context is " "current." msgstr "" +"``Py_CONTEXT_SWITCHED``: :term:`現在のコンテキスト ` が別の" +"コンテキストに切り替わりました。\n" +"ウォッチャーのコールバックに渡されるオブジェクトは、新たに現在のコンテキスト" +"となった :class:`contextvars.Context` オブジェクト、または現在のコンテキスト" +"がなければ ``None`` です。" -#: ../../c-api/contextvars.rst:135 msgid "" "Context object watcher callback function. The object passed to the callback " "is event-specific; see :c:type:`PyContextEvent` for details." msgstr "" +"コンテキストオブジェクトのウォッチャーのコールバック関数です。\n" +"コールバックに渡されるオブジェクトはイベントによって異なります。\n" +"詳しくは :c:type:`PyContextEvent` を参照してください。" -#: ../../c-api/contextvars.rst:138 msgid "" "If the callback returns with an exception set, it must return ``-1``; this " "exception will be printed as an unraisable exception using :c:func:" "`PyErr_FormatUnraisable`. Otherwise it should return ``0``." msgstr "" +"コールバックが例外を設定して戻る場合、``-1`` を返さなければなりません。\n" +"この例外は、送出できない例外として :c:func:`PyErr_FormatUnraisable` で表示さ" +"れます。\n" +"それ以外の場合は ``0`` を返してください。" -#: ../../c-api/contextvars.rst:142 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -209,6 +228,11 @@ msgid "" "exception unless it saves and clears the exception state first, and restores " "it before returning." msgstr "" +"コールバックに入る時点で、すでに処理待ちの例外が設定されている場合がありま" +"す。\n" +"その場合、コールバックは同じ例外を設定したまま ``0`` を返すべきです。\n" +"そのため、例外を設定し得る別の API を呼び出す場合は、まず例外の状態を保存して" +"クリアし、戻る前に復元する必要があります。" #: ../../c-api/contextvars.rst:151 msgid "Context variable functions:" @@ -262,13 +286,12 @@ msgstr "``NULL``" msgid "Except for ``NULL``, the function returns a new reference." msgstr "``NULL`` を除けば、この関数は新しい参照を返します。" -#: ../../c-api/contextvars.rst:177 msgid "" "Set the value of *var* to *value* in the current context. Returns a new " "token object for this change, or ``NULL`` if an error has occurred." msgstr "" "現在のコンテキストにおいて *var* の値を *value* にセットします。この変更によ" -"る新しいトークンオブジェクトか、エラーが起こった場合は``NULL``を返します。" +"る新しいトークンオブジェクトか、エラーが起こった場合は ``NULL`` を返します。" #: ../../c-api/contextvars.rst:182 msgid "" diff --git a/c-api/conversion.po b/c-api/conversion.po index 78a8a43f5..421cf3299 100644 --- a/c-api/conversion.po +++ b/c-api/conversion.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/conversion.rst:6 @@ -60,7 +60,6 @@ msgstr "" "func:`snprintf` と :c:func:`vsnprintf` 関数をラップします。これらの関数の目的" "は、C標準ライブラリが保証していないコーナーケースでの動作を保証することです。" -#: ../../c-api/conversion.rst:28 msgid "" "The wrappers ensure that ``str[size-1]`` is always ``'\\0'`` upon return. " "They never write more than *size* bytes (including the trailing ``'\\0'``) " @@ -69,6 +68,14 @@ msgid "" "equivalent to the C99 ``n = snprintf(NULL, 0, ...)`` which would determine " "the necessary buffer size." msgstr "" +"これらのラッパーは、戻る時点で ``str[size-1]`` が必ず ``'\\0'`` になることを" +"保証します。\n" +"末尾の ``'\\0'`` を含めて、``size`` バイトを超えて ``str`` に書き込むことはあ" +"りません。\n" +"どちらの関数も ``str != NULL``、``size > 0``、``format != NULL``、``size < " +"INT_MAX`` を必要とします。\n" +"このため、必要なバッファサイズを調べる C99 の ``n = snprintf(NULL, 0, ...)`` " +"に相当する操作はできません。" #: ../../c-api/conversion.rst:34 msgid "" @@ -93,12 +100,15 @@ msgstr "" "``rv >= size`` のとき、変換出力は切り詰められており、成功するためには ``rv + " "1`` バイトが必要だったことを示します。``str[size-1]`` は ``'\\0'`` です。" -#: ../../c-api/conversion.rst:44 msgid "" "When ``rv < 0``, the output conversion failed and ``str[size-1]`` is " "``'\\0'`` in this case too, but the rest of *str* is undefined. The exact " "cause of the error depends on the underlying platform." msgstr "" +"``rv < 0`` の場合、出力の変換に失敗しています。\n" +"この場合も ``str[size-1]`` は ``'\\0'`` ですが、``str`` のほかの部分は未定義" +"です。\n" +"エラーの正確な原因は、基盤となるプラットフォームによって異なります。" #: ../../c-api/conversion.rst:49 msgid "" @@ -106,14 +116,16 @@ msgid "" "conversions." msgstr "以下の関数は locale 非依存な文字列から数値への変換を行ないます。" -#: ../../c-api/conversion.rst:53 msgid "" "Convert the initial part of the string in ``str`` to an :c:expr:`unsigned " "long` value according to the given ``base``, which must be between ``2`` and " "``36`` inclusive, or be the special value ``0``." msgstr "" +"文字列 ``str`` の先頭部分を、指定された基数 ``base`` に従って :c:expr:" +"`unsigned long` の値に変換します。\n" +"``base`` は ``2`` 以上 ``36`` 以下、または特別な値 ``0`` でなければなりませ" +"ん。" -#: ../../c-api/conversion.rst:57 msgid "" "Leading white space and case of characters are ignored. If ``base`` is zero " "it looks for a leading ``0b``, ``0o`` or ``0x`` to tell which base. If " @@ -121,35 +133,44 @@ msgid "" "(inclusive). If ``ptr`` is non-``NULL`` it will contain a pointer to the " "end of the scan." msgstr "" +"先頭の空白と文字の大文字・小文字の違いは無視します。\n" +"``base`` がゼロの場合、先頭の ``0b``、``0o``、``0x`` から基数を判定します。\n" +"これらがなければ ``10`` を使います。\n" +"基数は 0、または 2 以上 36 以下でなければなりません。\n" +"``ptr`` が ``NULL`` でなければ、走査が終了した位置へのポインタを格納します。" -#: ../../c-api/conversion.rst:63 msgid "" "If the converted value falls out of range of corresponding return type, " "range error occurs (:c:data:`errno` is set to :c:macro:`!ERANGE`) and :c:" "macro:`!ULONG_MAX` is returned. If no conversion can be performed, ``0`` is " "returned." msgstr "" +"変換した値が戻り値の型の範囲外になった場合、範囲エラーとして :c:data:`errno` " +"を :c:macro:`!ERANGE` に設定し、:c:macro:`!ULONG_MAX` を返します。\n" +"変換できなかった場合は ``0`` を返します。" -#: ../../c-api/conversion.rst:68 msgid "See also the Unix man page :manpage:`strtoul(3)`." -msgstr "" +msgstr "Unix マニュアルページ :manpage:`strtoul(3)` も参照してください。" -#: ../../c-api/conversion.rst:75 msgid "" "Convert the initial part of the string in ``str`` to an :c:expr:`long` value " "according to the given ``base``, which must be between ``2`` and ``36`` " "inclusive, or be the special value ``0``." msgstr "" +"文字列 ``str`` の先頭部分を、指定された基数 ``base`` に従って :c:expr:`long` " +"の値に変換します。\n" +"``base`` は ``2`` 以上 ``36`` 以下、または特別な値 ``0`` でなければなりませ" +"ん。" -#: ../../c-api/conversion.rst:79 msgid "" "Same as :c:func:`PyOS_strtoul`, but return a :c:expr:`long` value instead " "and :c:macro:`LONG_MAX` on overflows." msgstr "" +":c:func:`PyOS_strtoul` と同じですが、戻り値は :c:expr:`long` で、オーバーフ" +"ロー時には :c:macro:`LONG_MAX` を返します。" -#: ../../c-api/conversion.rst:82 msgid "See also the Unix man page :manpage:`strtol(3)`." -msgstr "" +msgstr "Unix マニュアルページ :manpage:`strtol(3)` も参照してください。" #: ../../c-api/conversion.rst:89 msgid "" @@ -187,7 +208,6 @@ msgstr "" "数点数の表現が無かった場合、``*endptr`` を文字列の先頭に設定して、ValueError " "を発生させ、``-1.0`` を返します。" -#: ../../c-api/conversion.rst:106 msgid "" "If ``s`` represents a value that is too large to store in a float (for " "example, ``\"1e500\"`` is such a string on many platforms) then if " @@ -197,6 +217,14 @@ msgid "" "exception and return ``-1.0``. In both cases, set ``*endptr`` to point to " "the first character after the converted value." msgstr "" +"``s`` が float に格納できないほど大きな値を表す場合 (多くのプラットフォームで" +"は例えば ``\"1e500\"``)、``overflow_exception`` が ``NULL`` なら適切な符号" +"の :c:macro:`!INFINITY` を返し、例外は設定しません。\n" +"それ以外の場合、``overflow_exception`` は Python の例外オブジェクトを指す必要" +"があります。\n" +"その例外を送出して ``-1.0`` を返します。\n" +"どちらの場合も、``*endptr`` は変換した値の直後の文字を指すように設定されま" +"す。" #: ../../c-api/conversion.rst:114 msgid "" @@ -225,55 +253,50 @@ msgstr "" "ければならず、無視されます。 ``'r'`` フォーマットコードは標準の :func:`repr` " "フォーマットを指定しています。" -#: ../../c-api/conversion.rst:131 msgid "*flags* can be zero or more of the following values or-ed together:" msgstr "" +"``flags`` には、以下の値のうち 0 個以上をビット OR で組み合わせて指定できま" +"す。" -#: ../../c-api/conversion.rst:137 msgid "" "Always precede the returned string with a sign character, even if *val* is " "non-negative." -msgstr "" +msgstr "``val`` が負でなくても、戻り値の文字列の先頭に常に符号を付けます。" -#: ../../c-api/conversion.rst:142 msgid "Ensure that the returned string will not look like an integer." -msgstr "" +msgstr "戻り値の文字列が整数のように見えないようにします。" -#: ../../c-api/conversion.rst:146 msgid "" "Apply \"alternate\" formatting rules. See the documentation for the :c:func:" "`PyOS_snprintf` ``'#'`` specifier for details." msgstr "" +"「代替形式」の書式規則を適用します。\n" +"詳細は :c:func:`PyOS_snprintf` の ``'#'`` 指定子の説明を参照してください。" -#: ../../c-api/conversion.rst:152 msgid "Negative zero is converted to positive zero." -msgstr "" +msgstr "負のゼロを正のゼロに変換します。" -#: ../../c-api/conversion.rst:156 msgid "" "If *ptype* is non-``NULL``, then the value it points to will be set to one " "of the following constants depending on the type of *val*:" msgstr "" +"``ptype`` が ``NULL`` でなければ、``val`` の種類に応じて参照先を以下の定数の" +"いずれかに設定します。" -#: ../../c-api/conversion.rst:163 msgid "*\\*ptype*" -msgstr "" +msgstr "``*ptype``" -#: ../../c-api/conversion.rst:164 msgid "type of *val*" -msgstr "" +msgstr "``val`` の種類" -#: ../../c-api/conversion.rst:166 msgid "finite number" -msgstr "" +msgstr "有限の数値" -#: ../../c-api/conversion.rst:168 msgid "infinite number" -msgstr "" +msgstr "無限大" -#: ../../c-api/conversion.rst:170 msgid "not a number" -msgstr "" +msgstr "非数" #: ../../c-api/conversion.rst:172 msgid "" @@ -286,96 +309,95 @@ msgstr "" "呼び出し側は、返された文字列を :c:func:`PyMem_Free` を使って解放する責任があ" "ります。" -#: ../../c-api/conversion.rst:182 msgid "" "Case insensitive comparison of strings. These functions work almost " "identically to :c:func:`!strcmp` and :c:func:`!strncmp` (respectively), " "except that they ignore the case of ASCII characters." msgstr "" +"大文字と小文字を区別せずに文字列を比較します。\n" +"それぞれ :c:func:`!strcmp` と :c:func:`!strncmp` とほぼ同じですが、ASCII 文字" +"の大文字と小文字の違いを無視します。" -#: ../../c-api/conversion.rst:186 msgid "" "Return ``0`` if the strings are equal, a negative value if *str1* sorts " "lexicographically before *str2*, or a positive value if it sorts after." msgstr "" +"文字列が等しければ ``0``、辞書順で ``str1`` が ``str2`` より前なら負の値、後" +"なら正の値を返します。" -#: ../../c-api/conversion.rst:189 msgid "" "In the *str1* or *str2* arguments, a NUL byte marks the end of the string. " "For :c:func:`!PyOS_mystrnicmp`, the *size* argument gives the maximum size " "of the string, as if NUL was present at the index given by *size*." msgstr "" +"引数 ``str1`` と ``str2`` では、NUL バイトが文字列の終わりを示します。\n" +":c:func:`!PyOS_mystrnicmp` では、``size`` 引数が文字列の最大サイズを指定し、" +"そのインデックスに NUL があるかのように扱います。" -#: ../../c-api/conversion.rst:193 msgid "These functions do not use the locale." -msgstr "" +msgstr "これらの関数はロケールを使いません。" -#: ../../c-api/conversion.rst:199 msgid "Case insensitive comparison of strings." -msgstr "" +msgstr "大文字と小文字を区別しない文字列の比較。" -#: ../../c-api/conversion.rst:201 msgid "" "On Windows, these are aliases of :c:func:`!stricmp` and :c:func:`!strnicmp`, " "respectively." msgstr "" +"Windows では、それぞれ :c:func:`!stricmp` と :c:func:`!strnicmp` の別名です。" -#: ../../c-api/conversion.rst:204 msgid "" "On other platforms, they are aliases of :c:func:`PyOS_mystricmp` and :c:func:" "`PyOS_mystrnicmp`, respectively." msgstr "" +"ほかのプラットフォームでは、それぞれ :c:func:`PyOS_mystricmp` と :c:func:" +"`PyOS_mystrnicmp` の別名です。" -#: ../../c-api/conversion.rst:209 msgid "Character classification and conversion" -msgstr "" +msgstr "文字の分類と変換" -#: ../../c-api/conversion.rst:211 msgid "" "The following macros provide locale-independent (unlike the C standard " "library ``ctype.h``) character classification and conversion. The argument " "must be a signed or unsigned :c:expr:`char`." msgstr "" +"以下のマクロは、C 標準ライブラリの ``ctype.h`` と異なり、ロケールに依存しない" +"文字の分類と変換を行います。\n" +"引数は符号付きまたは符号なしの :c:expr:`char` でなければなりません。" -#: ../../c-api/conversion.rst:218 msgid "Return true if the character *c* is an alphanumeric character." -msgstr "" +msgstr "文字 ``c`` が英数字の場合に真を返します。" -#: ../../c-api/conversion.rst:223 msgid "" "Return true if the character *c* is an alphabetic character (``a-z`` and ``A-" "Z``)." -msgstr "" +msgstr "文字 ``c`` が英字 (``a-z`` または ``A-Z``) の場合に真を返します。" -#: ../../c-api/conversion.rst:228 msgid "Return true if the character *c* is a decimal digit (``0-9``)." -msgstr "" +msgstr "文字 ``c`` が 10 進数字 (``0-9``) の場合に真を返します。" -#: ../../c-api/conversion.rst:233 msgid "Return true if the character *c* is a lowercase ASCII letter (``a-z``)." -msgstr "" +msgstr "文字 ``c`` が ASCII の英小文字 (``a-z``) の場合に真を返します。" -#: ../../c-api/conversion.rst:238 msgid "" "Return true if the character *c* is an uppercase ASCII letter (``A-Z``)." -msgstr "" +msgstr "文字 ``c`` が ASCII の英大文字 (``A-Z``) の場合に真を返します。" -#: ../../c-api/conversion.rst:243 msgid "" "Return true if the character *c* is a whitespace character (space, tab, " "carriage return, newline, vertical tab, or form feed)." msgstr "" +"文字 ``c`` が空白文字 (スペース、タブ、復帰、改行、垂直タブ、フォームフィー" +"ド) の場合に真を返します。" -#: ../../c-api/conversion.rst:249 msgid "" "Return true if the character *c* is a hexadecimal digit (``0-9``, ``a-f``, " "and ``A-F``)." msgstr "" +"文字 ``c`` が 16 進数字 (``0-9``、``a-f``、``A-F``) の場合に真を返します。" -#: ../../c-api/conversion.rst:255 msgid "Return the lowercase equivalent of the character *c*." -msgstr "" +msgstr "文字 ``c`` に対応する小文字を返します。" -#: ../../c-api/conversion.rst:260 msgid "Return the uppercase equivalent of the character *c*." -msgstr "" +msgstr "文字 ``c`` に対応する大文字を返します。" diff --git a/c-api/coro.po b/c-api/coro.po index 81374e5a5..3e7d15d93 100644 --- a/c-api/coro.po +++ b/c-api/coro.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/coro.rst:6 @@ -42,13 +42,12 @@ msgstr "コルーチンオブジェクトのための C 構造体。" msgid "The type object corresponding to coroutine objects." msgstr "コルーチンオブジェクトに対応する型オブジェクト。" -#: ../../c-api/coro.rst:26 msgid "" "Return true if *ob*'s type is :c:type:`PyCoro_Type`; *ob* must not be " "``NULL``. This function always succeeds." msgstr "" -"*ob* が :c:type:`PyCoro_Type` の場合に真を返します。\n" -"*ob* は ``NULL`` であってはなりません。\n" +"``ob`` の型が :c:type:`PyCoro_Type` の場合に真を返します。\n" +"``ob`` は ``NULL`` であってはいけません。\n" "この関数は常に成功します。" #: ../../c-api/coro.rst:32 diff --git a/c-api/curses.po b/c-api/curses.po index 704e6c64d..934158b3b 100644 --- a/c-api/curses.po +++ b/c-api/curses.po @@ -12,17 +12,15 @@ msgstr "" "PO-Revision-Date: 2025-11-11 14:16+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/curses.rst:4 msgid "Curses C API" -msgstr "" +msgstr "Curses C API" -#: ../../c-api/curses.rst:6 msgid "" ":mod:`curses` exposes a small C interface for extension modules. Consumers " "must include the header file :file:`py_curses.h` (which is not included by " @@ -30,103 +28,118 @@ msgid "" "usually as part of the module initialisation function, to populate :c:var:" "`PyCurses_API`." msgstr "" +":mod:`curses` は拡張モジュール向けに小さな C インターフェースを公開していま" +"す。\n" +"利用する側は :file:`py_curses.h` ヘッダをインクルードする必要があります (この" +"ヘッダは :file:`Python.h` にはデフォルトで含まれません)。\n" +"また、通常はモジュールの初期化関数内で :c:func:`import_curses` を呼び出して :" +"c:var:`PyCurses_API` を設定する必要があります。" -#: ../../c-api/curses.rst:14 msgid "" "Neither the C API nor the pure Python :mod:`curses` module are compatible " "with subinterpreters." msgstr "" +"C API も Python レベルの :mod:`curses` モジュールも、サブインタープリタに対応" +"していません。" -#: ../../c-api/curses.rst:19 msgid "" "Import the curses C API. The macro does not need a semi-colon to be called." msgstr "" +"curses C API をインポートします。\n" +"このマクロの呼び出しにはセミコロンは必要ありません。" -#: ../../c-api/curses.rst:21 msgid "On success, populate the :c:var:`PyCurses_API` pointer." -msgstr "" +msgstr "成功した場合は :c:var:`PyCurses_API` ポインタを設定します。" -#: ../../c-api/curses.rst:23 msgid "" "On failure, set :c:var:`PyCurses_API` to NULL and set an exception. The " "caller must check if an error occurred via :c:func:`PyErr_Occurred`:" msgstr "" +"失敗した場合は :c:var:`PyCurses_API` を NULL に設定し、例外を設定します。\n" +"呼び出し側は :c:func:`PyErr_Occurred` でエラーの有無を確認する必要がありま" +"す。" -#: ../../c-api/curses.rst:26 msgid "" "import_curses(); // semi-colon is optional but recommended\n" "if (PyErr_Occurred()) { /* cleanup */ }" msgstr "" +"import_curses(); // セミコロンは省略可能だが推奨\n" +"if (PyErr_Occurred()) { /* 後片付け */ }" -#: ../../c-api/curses.rst:34 msgid "" "Dynamically allocated object containing the curses C API. This variable is " "only available once :c:macro:`import_curses` succeeds." msgstr "" +"curses C API を格納する、動的に割り当てられたオブジェクトです。\n" +"この変数は :c:macro:`import_curses` が成功した後でのみ利用できます。" -#: ../../c-api/curses.rst:37 msgid "``PyCurses_API[0]`` corresponds to :c:data:`PyCursesWindow_Type`." -msgstr "" +msgstr "``PyCurses_API[0]`` は :c:data:`PyCursesWindow_Type` に対応します。" -#: ../../c-api/curses.rst:39 msgid "" "``PyCurses_API[1]``, ``PyCurses_API[2]``, and ``PyCurses_API[3]`` are " "pointers to predicate functions of type ``int (*)(void)``." msgstr "" +"``PyCurses_API[1]``、``PyCurses_API[2]``、``PyCurses_API[3]`` は、``int (*)" +"(void)`` 型の判定関数へのポインタです。" -#: ../../c-api/curses.rst:42 msgid "" "When called, these predicates return whether :func:`curses.setupterm`, :func:" "`curses.initscr`, and :func:`curses.start_color` have been called " "respectively." msgstr "" +"これらの判定関数は、それぞれ :func:`curses.setupterm`、:func:`curses." +"initscr`、:func:`curses.start_color` が呼び出されたかどうかを返します。" -#: ../../c-api/curses.rst:46 msgid "" "See also the convenience macros :c:macro:`PyCursesSetupTermCalled`, :c:macro:" "`PyCursesInitialised`, and :c:macro:`PyCursesInitialisedColor`." msgstr "" +"便利なマクロ :c:macro:`PyCursesSetupTermCalled`、:c:macro:" +"`PyCursesInitialised`、:c:macro:`PyCursesInitialisedColor` も参照してくださ" +"い。" -#: ../../c-api/curses.rst:51 msgid "" "The number of entries in this structure is subject to changes. Consider " "using :c:macro:`PyCurses_API_pointers` to check if new fields are available " "or not." msgstr "" +"この構造体のエントリー数は変更されることがあります。\n" +"新しいフィールドが利用できるかどうかを確認するには、:c:macro:" +"`PyCurses_API_pointers` の使用を検討してください。" -#: ../../c-api/curses.rst:58 msgid "" "The number of accessible fields (``4``) in :c:var:`PyCurses_API`. This " "number is incremented whenever new fields are added." msgstr "" +":c:var:`PyCurses_API` 内のアクセス可能なフィールドの数 (``4``)。\n" +"新しいフィールドが追加されるたびに増えます。" -#: ../../c-api/curses.rst:64 msgid "" "The :ref:`heap type ` corresponding to :class:`curses.window`." -msgstr "" +msgstr ":class:`curses.window` に対応する :ref:`ヒープ型 `。" -#: ../../c-api/curses.rst:69 msgid "" "Return true if *op* is a :class:`curses.window` instance, false otherwise." msgstr "" +"``op`` が :class:`curses.window` のインスタンスの場合は真を返し、それ以外の場" +"合は偽を返します。" -#: ../../c-api/curses.rst:72 msgid "" "The following macros are convenience macros expanding into C statements. In " "particular, they can only be used as ``macro;`` or ``macro``, but not " "``macro()`` or ``macro();``." msgstr "" +"以下は C の文に展開される便利なマクロです。\n" +"特に、``macro;`` または ``macro`` の形でのみ使え、``macro()`` や ``macro();" +"`` では使えません。" -#: ../../c-api/curses.rst:78 msgid "Macro checking if :func:`curses.setupterm` has been called." -msgstr "" +msgstr ":func:`curses.setupterm` が呼び出されたかどうかを確認するマクロ。" -#: ../../c-api/curses.rst:80 ../../c-api/curses.rst:97 -#: ../../c-api/curses.rst:114 msgid "The macro expansion is roughly equivalent to:" -msgstr "" +msgstr "マクロの展開結果は、おおむね次と同等です。" -#: ../../c-api/curses.rst:82 msgid "" "{\n" " typedef int (*predicate_t)(void);\n" @@ -136,12 +149,17 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_setupterm_called = (predicate_t)PyCurses_API[1];\n" +" if (!was_setupterm_called()) {\n" +" return NULL;\n" +" }\n" +"}" -#: ../../c-api/curses.rst:95 msgid "Macro checking if :func:`curses.initscr` has been called." -msgstr "" +msgstr ":func:`curses.initscr` が呼び出されたかどうかを確認するマクロ。" -#: ../../c-api/curses.rst:99 msgid "" "{\n" " typedef int (*predicate_t)(void);\n" @@ -151,12 +169,17 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_initscr_called = (predicate_t)PyCurses_API[2];\n" +" if (!was_initscr_called()) {\n" +" return NULL;\n" +" }\n" +"}" -#: ../../c-api/curses.rst:112 msgid "Macro checking if :func:`curses.start_color` has been called." -msgstr "" +msgstr ":func:`curses.start_color` が呼び出されたかどうかを確認するマクロ。" -#: ../../c-api/curses.rst:116 msgid "" "{\n" " typedef int (*predicate_t)(void);\n" @@ -166,21 +189,27 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" typedef int (*predicate_t)(void);\n" +" predicate_t was_start_color_called = (predicate_t)PyCurses_API[3];\n" +" if (!was_start_color_called()) {\n" +" return NULL;\n" +" }\n" +"}" -#: ../../c-api/curses.rst:128 msgid "Internal data" -msgstr "" +msgstr "内部データ" -#: ../../c-api/curses.rst:130 msgid "" "The following objects are exposed by the C API but should be considered " "internal-only." msgstr "" +"以下のオブジェクトは C API で公開されていますが、内部専用と考えてください。" -#: ../../c-api/curses.rst:135 msgid "Name of the curses capsule to pass to :c:func:`PyCapsule_Import`." -msgstr "" +msgstr ":c:func:`PyCapsule_Import` に渡す curses カプセルの名前。" -#: ../../c-api/curses.rst:137 msgid "Internal usage only. Use :c:macro:`import_curses` instead." msgstr "" +"内部専用です。\n" +"代わりに :c:macro:`import_curses` を使ってください。" diff --git a/c-api/datetime.po b/c-api/datetime.po index e32d6683f..20513e43c 100644 --- a/c-api/datetime.po +++ b/c-api/datetime.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/datetime.rst:6 @@ -43,57 +43,56 @@ msgstr "" "期化関数から、起動しておく必要があります。このマクロは以下のマクロで使われる" "静的変数 :c:data:`PyDateTimeAPI` に C 構造体へのポインタを入れます。" -#: ../../c-api/datetime.rst:18 msgid "Import the datetime C API." -msgstr "" +msgstr "datetime の C API をインポートします。" -#: ../../c-api/datetime.rst:20 msgid "" "On success, populate the :c:var:`PyDateTimeAPI` pointer. On failure, set :c:" "var:`PyDateTimeAPI` to ``NULL`` and set an exception. The caller must check " "if an error occurred via :c:func:`PyErr_Occurred`:" msgstr "" +"成功すると :c:var:`PyDateTimeAPI` ポインタに値を設定します。\n" +"失敗すると :c:var:`PyDateTimeAPI` を ``NULL`` に設定し、例外を設定します。\n" +"呼び出し側は :c:func:`PyErr_Occurred` でエラーが発生したか確認しなければなり" +"ません:" -#: ../../c-api/datetime.rst:24 msgid "" "PyDateTime_IMPORT;\n" "if (PyErr_Occurred()) { /* cleanup */ }" msgstr "" +"PyDateTime_IMPORT;\n" +"if (PyErr_Occurred()) { /* 後始末 */ }" -#: ../../c-api/datetime.rst:31 msgid "This is not compatible with subinterpreters." -msgstr "" +msgstr "これはサブインタープリタと互換性がありません。" -#: ../../c-api/datetime.rst:35 msgid "This macro is now thread safe." -msgstr "" +msgstr "このマクロがスレッドセーフになりました。" -#: ../../c-api/datetime.rst:39 msgid "Structure containing the fields for the datetime C API." -msgstr "" +msgstr "datetime の C API のフィールドを格納する構造体です。" -#: ../../c-api/datetime.rst:41 msgid "The fields of this structure are private and subject to change." -msgstr "" +msgstr "この構造体のフィールドは非公開であり、変更される可能性があります。" -#: ../../c-api/datetime.rst:43 msgid "Do not use this directly; prefer ``PyDateTime_*`` APIs instead." -msgstr "" +msgstr "これを直接使わず、代わりに ``PyDateTime_*`` API を使ってください。" -#: ../../c-api/datetime.rst:47 msgid "Dynamically allocated object containing the datetime C API." -msgstr "" +msgstr "datetime の C API を格納する、動的に割り当てられたオブジェクトです。" -#: ../../c-api/datetime.rst:49 msgid "" "This variable is only available once :c:macro:`PyDateTime_IMPORT` succeeds." msgstr "" +"この変数は :c:macro:`PyDateTime_IMPORT` が成功した後にのみ利用できます。" -#: ../../c-api/datetime.rst:53 msgid "" "This variable should not be accessed directly as direct access is not thread-" "safe. Use :c:func:`PyDateTime_IMPORT` instead." msgstr "" +"この変数への直接アクセスはスレッドセーフではないため、直接アクセスしないでく" +"ださい。\n" +"代わりに :c:func:`PyDateTime_IMPORT` を使ってください。" #: ../../c-api/datetime.rst:58 msgid "This subtype of :c:type:`PyObject` represents a Python date object." @@ -143,12 +142,14 @@ msgstr "" "この :c:type:`PyTypeObject` のインスタンスは Python の time 型を表します; " "Python レイヤにおける :class:`datetime.time` と同じオブジェクトです。" -#: ../../c-api/datetime.rst:89 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python type for the " "difference between two datetime values; it is the same object as :class:" "`datetime.timedelta` in the Python layer." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは、2 つの datetime の値の差を表す " +"Python の型です。\n" +"Python レイヤの :class:`datetime.timedelta` と同じオブジェクトです。" #: ../../c-api/datetime.rst:95 msgid "" @@ -384,15 +385,11 @@ msgstr "秒を 0 から 59 の間の整数で返します。" msgid "Return the microsecond, as an int from 0 through 999999." msgstr "マイクロ秒を 0 から 999999 の間の整数で返します。" -#: ../../c-api/datetime.rst:281 ../../c-api/datetime.rst:319 msgid "Return the fold, as an int from 0 through 1." -msgstr "" -"フォールド(訳注: サマータイムによる時間のずれのこと)を 0 から 1 までの整数で" -"返します。" +msgstr "``fold`` を 0 または 1 の整数で返します。" -#: ../../c-api/datetime.rst:288 ../../c-api/datetime.rst:326 msgid "Return the tzinfo (which may be ``None``)." -msgstr "" +msgstr "``tzinfo`` を返します (``None`` の場合もあります)。" #: ../../c-api/datetime.rst:293 msgid "" @@ -430,32 +427,33 @@ msgstr "マイクロ秒を 0 から 999999 の間の整数で返します。" msgid "Macros for the convenience of modules implementing the DB API:" msgstr "以下のマクロは DB API を実装する上での便宜用です:" -#: ../../c-api/datetime.rst:360 msgid "" "Create and return a new :class:`datetime.datetime` object given an argument " "tuple suitable for passing to :meth:`datetime.datetime.fromtimestamp`." msgstr "" +":meth:`datetime.datetime.fromtimestamp` に渡せる引数のタプルから、新しい :" +"class:`datetime.datetime` オブジェクトを作成して返します。" -#: ../../c-api/datetime.rst:366 msgid "" "Create and return a new :class:`datetime.date` object given an argument " "tuple suitable for passing to :meth:`datetime.date.fromtimestamp`." msgstr "" +":meth:`datetime.date.fromtimestamp` に渡せる引数のタプルから、新しい :class:" +"`datetime.date` オブジェクトを作成して返します。" -#: ../../c-api/datetime.rst:371 msgid "Internal data" -msgstr "" +msgstr "内部データ" -#: ../../c-api/datetime.rst:373 msgid "" "The following symbols are exposed by the C API but should be considered " "internal-only." msgstr "" +"以下のシンボルは C API で公開されていますが、内部専用として扱ってください。" -#: ../../c-api/datetime.rst:378 msgid "Name of the datetime capsule to pass to :c:func:`PyCapsule_Import`." -msgstr "" +msgstr ":c:func:`PyCapsule_Import` に渡す datetime カプセルの名前です。" -#: ../../c-api/datetime.rst:380 msgid "Internal usage only. Use :c:macro:`PyDateTime_IMPORT` instead." msgstr "" +"内部専用です。\n" +"代わりに :c:macro:`PyDateTime_IMPORT` を使ってください。" diff --git a/c-api/descriptor.po b/c-api/descriptor.po index c708d5645..589fd08b5 100644 --- a/c-api/descriptor.po +++ b/c-api/descriptor.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/descriptor.rst:6 @@ -35,51 +35,62 @@ msgstr "" "述したオブジェクトです。デスクリプタオブジェクトは型オブジェクトの辞書内にあ" "ります。" -#: ../../c-api/descriptor.rst:13 msgid "" "Create a new get-set descriptor for extension type *type* from the :c:type:" "`PyGetSetDef` structure *getset*." msgstr "" +":c:type:`PyGetSetDef` 構造体 *getset* から、拡張型 *type* 用の新しい get-set " +"デスクリプタを作成します。" -#: ../../c-api/descriptor.rst:16 msgid "" "Get-set descriptors expose attributes implemented by C getter and setter " "functions rather than stored directly in the instance. This is the same kind " "of descriptor created for entries in :c:member:`~PyTypeObject.tp_getset`, " "and it appears in Python as a :class:`types.GetSetDescriptorType` object." msgstr "" +"get-set デスクリプタは、インスタンスに直接格納される属性ではなく、C のゲッ" +"ター関数とセッター関数で実装された属性を公開します。\n" +":c:member:`~PyTypeObject.tp_getset` のエントリーに対して作られるものと同じ種" +"類のデスクリプタで、Python では :class:`types.GetSetDescriptorType` オブジェ" +"クトとして扱われます。" -#: ../../c-api/descriptor.rst:21 ../../c-api/descriptor.rst:34 -#: ../../c-api/descriptor.rst:65 ../../c-api/descriptor.rst:96 -#: ../../c-api/descriptor.rst:118 msgid "" "On success, return a :term:`strong reference` to the descriptor. Return " "``NULL`` with an exception set on failure." msgstr "" +"成功するとデスクリプタへの :term:`強参照 ` を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/descriptor.rst:26 msgid "" "Create a new member descriptor for extension type *type* from the :c:type:" "`PyMemberDef` structure *member*." msgstr "" +":c:type:`PyMemberDef` 構造体 *member* から、拡張型 *type* 用の新しいメンバー" +"デスクリプタを作成します。" -#: ../../c-api/descriptor.rst:29 msgid "" "Member descriptors expose fields in the type's C struct as Python " "attributes. This is the same kind of descriptor created for entries in :c:" "member:`~PyTypeObject.tp_members`, and it appears in Python as a :class:" "`types.MemberDescriptorType` object." msgstr "" +"メンバーデスクリプタは、型の C 構造体のフィールドを Python の属性として公開し" +"ます。\n" +":c:member:`~PyTypeObject.tp_members` のエントリーに対して作られるものと同じ種" +"類のデスクリプタで、Python では :class:`types.MemberDescriptorType` オブジェ" +"クトとして扱われます。" -#: ../../c-api/descriptor.rst:39 msgid "" "The type object for member descriptor objects created from :c:type:" "`PyMemberDef` structures. These descriptors expose fields of a C struct as " "attributes on a type, and correspond to :class:`types.MemberDescriptorType` " "objects in Python." msgstr "" +":c:type:`PyMemberDef` 構造体から作成されるメンバーデスクリプタオブジェクトの" +"型オブジェクトです。\n" +"これらのデスクリプタは C 構造体のフィールドを型の属性として公開し、Python " +"の :class:`types.MemberDescriptorType` オブジェクトに対応します。" -#: ../../c-api/descriptor.rst:48 msgid "" "The type object for get/set descriptor objects created from :c:type:" "`PyGetSetDef` structures. These descriptors implement attributes whose value " @@ -87,28 +98,40 @@ msgid "" "type attributes. They correspond to :class:`types.GetSetDescriptorType` " "objects in Python." msgstr "" +":c:type:`PyGetSetDef` 構造体から作成される get/set デスクリプタオブジェクトの" +"型オブジェクトです。\n" +"これらのデスクリプタは、値を C のゲッター関数やセッター関数で計算する属性を実" +"装し、多くの組み込み型の属性に使われています。\n" +"Python の :class:`types.GetSetDescriptorType` オブジェクトに対応します。" -#: ../../c-api/descriptor.rst:57 msgid "" "Create a new method descriptor for extension type *type* from the :c:type:" "`PyMethodDef` structure *meth*." msgstr "" +":c:type:`PyMethodDef` 構造体 *meth* から、拡張型 *type* 用の新しいメソッドデ" +"スクリプタを作成します。" -#: ../../c-api/descriptor.rst:60 msgid "" "Method descriptors expose C functions as methods on a type. This is the same " "kind of descriptor created for entries in :c:member:`~PyTypeObject." "tp_methods`, and it appears in Python as a :class:`types." "MethodDescriptorType` object." msgstr "" +"メソッドデスクリプタは C 関数を型のメソッドとして公開します。\n" +":c:member:`~PyTypeObject.tp_methods` のエントリーに対して作られるものと同じ種" +"類のデスクリプタで、Python では :class:`types.MethodDescriptorType` オブジェ" +"クトとして扱われます。" -#: ../../c-api/descriptor.rst:70 msgid "" "The type object for method descriptor objects created from :c:type:" "`PyMethodDef` structures. These descriptors expose C functions as methods on " "a type, and correspond to :class:`types.MethodDescriptorType` objects in " "Python." msgstr "" +":c:type:`PyMethodDef` 構造体から作成されるメソッドデスクリプタオブジェクトの" +"型オブジェクトです。\n" +"これらのデスクリプタは C 関数を型のメソッドとして公開し、Python の :class:" +"`types.MethodDescriptorType` オブジェクトに対応します。" #: ../../c-api/descriptor.rst:78 msgid "Describes a slot wrapper used by :c:func:`PyDescr_NewWrapper`." @@ -145,80 +168,100 @@ msgid "" "objects." msgstr "" -#: ../../c-api/descriptor.rst:110 msgid "" "Create a new class method descriptor for extension type *type* from the :c:" "type:`PyMethodDef` structure *method*." msgstr "" +":c:type:`PyMethodDef` 構造体 *method* から、拡張型 *type* 用の新しいクラスメ" +"ソッドデスクリプタを作成します。" -#: ../../c-api/descriptor.rst:113 msgid "" "Class method descriptors expose C methods that receive the class rather than " "an instance when accessed. This is the same kind of descriptor created for " "``METH_CLASS`` entries in :c:member:`~PyTypeObject.tp_methods`, and it " "appears in Python as a :class:`types.ClassMethodDescriptorType` object." msgstr "" +"クラスメソッドデスクリプタは、アクセスされた際にインスタンスの代わりにクラス" +"を受け取る C メソッドを公開します。\n" +":c:member:`~PyTypeObject.tp_methods` の ``METH_CLASS`` エントリーに対して作ら" +"れるものと同じ種類のデスクリプタで、Python では :class:`types." +"ClassMethodDescriptorType` オブジェクトとして扱われます。" -#: ../../c-api/descriptor.rst:123 msgid "" "Return non-zero if the descriptor object *descr* describes a data attribute, " "or ``0`` if it describes a method. *descr* must be a descriptor object; " "there is no error checking." msgstr "" +"デスクリプタオブジェクト *descr* がデータ属性を表す場合はゼロ以外、メソッドを" +"表す場合は ``0`` を返します。\n" +"*descr* はデスクリプタオブジェクトでなければなりません。\n" +"エラーチェックは行いません。" -#: ../../c-api/descriptor.rst:130 msgid "" "Create a new bound wrapper object from the wrapper descriptor *d* and the " "instance *self*." msgstr "" +"ラッパーデスクリプタ *d* とインスタンス *self* から、新しい束縛済みラッパーオ" +"ブジェクトを作成します。" -#: ../../c-api/descriptor.rst:133 msgid "" "This is the bound form of a wrapper descriptor created by :c:func:" "`PyDescr_NewWrapper`. CPython creates these objects when a slot wrapper is " "accessed through an instance, and they appear in Python as :class:`types." "MethodWrapperType` objects." msgstr "" +"これは :c:func:`PyDescr_NewWrapper` で作成されるラッパーデスクリプタを束縛し" +"たものです。\n" +"CPython はインスタンスを介してスロットラッパーにアクセスしたときにこのオブ" +"ジェクトを作成し、Python では :class:`types.MethodWrapperType` オブジェクトと" +"して扱われます。" -#: ../../c-api/descriptor.rst:138 msgid "" "On success, return a :term:`strong reference` to the wrapper object. Return " "``NULL`` with an exception set on failure." msgstr "" +"成功するとラッパーオブジェクトへの :term:`強参照 ` を返しま" +"す。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/descriptor.rst:143 msgid "This is a macro including the common fields for a descriptor object." -msgstr "" +msgstr "デスクリプタオブジェクトの共通フィールドを含むマクロです。" -#: ../../c-api/descriptor.rst:146 msgid "" "This was included in Python's C API by mistake; do not use it in extensions. " "For creating custom descriptor objects, create a class implementing the " "descriptor protocol (:c:member:`~PyTypeObject.tp_descr_get` and :c:member:" "`~PyTypeObject.tp_descr_set`)." msgstr "" +"これは誤って Python の C API に含められたものです。\n" +"拡張モジュールでは使わないでください。\n" +"独自のデスクリプタオブジェクトを作成するには、デスクリプタプロトコル (:c:" +"member:`~PyTypeObject.tp_descr_get` と :c:member:`~PyTypeObject." +"tp_descr_set`) を実装するクラスを作成してください。" -#: ../../c-api/descriptor.rst:155 msgid "Built-in descriptors" -msgstr "" +msgstr "組み込みデスクリプタ" -#: ../../c-api/descriptor.rst:159 msgid "" "The type object for property objects. This is the same object as :class:" "`property` in the Python layer." msgstr "" +"プロパティオブジェクトの型オブジェクトです。\n" +"Python レベルの :class:`property` と同じオブジェクトです。" -#: ../../c-api/descriptor.rst:165 msgid "" "The type object for super objects. This is the same object as :class:`super` " "in the Python layer." msgstr "" +"super オブジェクトの型オブジェクトです。\n" +"Python レベルの :class:`super` と同じオブジェクトです。" -#: ../../c-api/descriptor.rst:171 msgid "" "The type of class method objects. This is the same object as :class:" "`classmethod` in the Python layer." msgstr "" +"クラスメソッドオブジェクトの型です。\n" +"Python レベルの :class:`classmethod` と同じオブジェクトです。" #: ../../c-api/descriptor.rst:177 msgid "" @@ -228,34 +271,45 @@ msgid "" "objects in Python." msgstr "" -#: ../../c-api/descriptor.rst:185 msgid "" "Create a new :class:`classmethod` object wrapping *callable*. *callable* " "must be a callable object and must not be ``NULL``." msgstr "" +"*callable* をラップする新しい :class:`classmethod` オブジェクトを作成しま" +"す。\n" +"*callable* は呼び出し可能オブジェクトでなければならず、``NULL`` にはできませ" +"ん。" -#: ../../c-api/descriptor.rst:188 msgid "" "On success, this function returns a :term:`strong reference` to a new class " "method descriptor. On failure, this function returns ``NULL`` with an " "exception set." msgstr "" +"成功すると、新しいクラスメソッドデスクリプタへの :term:`強参照 ` を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/descriptor.rst:195 msgid "" "The type of static method objects. This is the same object as :class:" "`staticmethod` in the Python layer." msgstr "" +"静的メソッドオブジェクトの型です。\n" +"Python レベルの :class:`staticmethod` と同じオブジェクトです。" -#: ../../c-api/descriptor.rst:201 msgid "" "Create a new :class:`staticmethod` object wrapping *callable*. *callable* " "must be a callable object and must not be ``NULL``." msgstr "" +"*callable* をラップする新しい :class:`staticmethod` オブジェクトを作成しま" +"す。\n" +"*callable* は呼び出し可能オブジェクトでなければならず、``NULL`` にはできませ" +"ん。" -#: ../../c-api/descriptor.rst:204 msgid "" "On success, this function returns a :term:`strong reference` to a new static " "method descriptor. On failure, this function returns ``NULL`` with an " "exception set." msgstr "" +"成功すると、新しい静的メソッドデスクリプタへの :term:`強参照 ` を返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" diff --git a/c-api/dict.po b/c-api/dict.po index e69901ff8..1c0bf75db 100644 --- a/c-api/dict.po +++ b/c-api/dict.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/dict.rst:6 msgid "Dictionary objects" -msgstr "" +msgstr "辞書オブジェクト" #: ../../c-api/dict.rst:13 msgid "" @@ -74,21 +73,16 @@ msgstr "" "(non-dynamic class type) のクラス辞書が変更されないようにビューを作成するため" "に使われます。" -#: ../../c-api/dict.rst:45 msgid "" "The first argument can be a :class:`dict`, a :class:`frozendict`, or a " "mapping." msgstr "" +"最初の引数には :class:`dict`、:class:`frozendict`、またはマッピングを指定でき" +"ます。" -#: ../../c-api/dict.rst:48 ../../c-api/dict.rst:84 ../../c-api/dict.rst:98 -#: ../../c-api/dict.rst:165 ../../c-api/dict.rst:196 ../../c-api/dict.rst:214 -#: ../../c-api/dict.rst:239 ../../c-api/dict.rst:251 ../../c-api/dict.rst:337 -#: ../../c-api/dict.rst:347 ../../c-api/dict.rst:358 ../../c-api/dict.rst:371 -#: ../../c-api/dict.rst:379 ../../c-api/dict.rst:453 msgid "Also accept :class:`frozendict`." -msgstr "" +msgstr ":class:`frozendict` も受け付けるようになりました。" -#: ../../c-api/dict.rst:54 msgid "" "The type object for mapping proxy objects created by :c:func:" "`PyDictProxy_New` and for the read-only ``__dict__`` attribute of many built-" @@ -97,63 +91,81 @@ msgid "" "are reflected in the proxy, but the proxy itself does not support mutation " "operations. This corresponds to :class:`types.MappingProxyType` in Python." msgstr "" +":c:func:`PyDictProxy_New` が作成するマッピングプロキシオブジェクトや、多くの" +"組み込み型の読み出し専用の ``__dict__`` 属性に使われる型オブジェクトです。\n" +":c:type:`PyDictProxy_Type` のインスタンスは、元の辞書の動的な読み出し専用" +"ビューを提供します。\n" +"元の辞書の変更はプロキシに反映されますが、プロキシ自体は変更操作をサポートし" +"ません。\n" +"Python の :class:`types.MappingProxyType` に対応します。" #: ../../c-api/dict.rst:65 msgid "Empty an existing dictionary of all key-value pairs." msgstr "現在辞書に入っている全てのキーと値のペアを除去して空にします。" -#: ../../c-api/dict.rst:67 msgid "" "Do nothing if the argument is not a :class:`dict` or a :class:`!dict` " "subclass." msgstr "" +"引数が :class:`dict` または :class:`!dict` のサブクラスでない場合は何もしませ" +"ん。" -#: ../../c-api/dict.rst:73 msgid "" "Determine if dictionary *p* contains *key*. If an item in *p* matches " "*key*, return ``1``, otherwise return ``0``. On error, return ``-1``. This " "is equivalent to the Python expression ``key in p``." msgstr "" +"辞書 *p* に *key* が含まれるか判定します。\n" +"*p* 内に *key* と一致する要素があれば ``1``、なければ ``0`` を返します。\n" +"エラー時には ``-1`` を返します。\n" +"Python の式 ``key in p`` と等価です。" -#: ../../c-api/dict.rst:77 ../../c-api/dict.rst:94 ../../c-api/dict.rst:156 -#: ../../c-api/dict.rst:177 ../../c-api/dict.rst:335 ../../c-api/dict.rst:345 -#: ../../c-api/dict.rst:356 ../../c-api/dict.rst:396 msgid "The first argument can be a :class:`dict` or a :class:`frozendict`." msgstr "" +"最初の引数には :class:`dict` または :class:`frozendict` を指定できます。" -#: ../../c-api/dict.rst:81 ../../c-api/dict.rst:115 ../../c-api/dict.rst:135 -#: ../../c-api/dict.rst:160 ../../c-api/dict.rst:294 ../../c-api/dict.rst:316 msgid "" "The operation is atomic on :term:`free threading ` when " "*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" "`bytes`." msgstr "" +"*key* が :class:`str`、:class:`int`、:class:`float`、:class:`bool`、:class:" +"`bytes` の場合、この操作は :term:`フリースレッドビルド ` でアトミックです。" -#: ../../c-api/dict.rst:90 msgid "" "This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyDict_Contains` と同様ですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定しま" +"す。" #: ../../c-api/dict.rst:104 msgid "Return a new dictionary that contains the same key-value pairs as *p*." msgstr "*p* と同じキーと値のペアが入った新たな辞書を返します。" -#: ../../c-api/dict.rst:108 msgid "" "Insert *val* into the dictionary *p* with a key of *key*. *key* must be :" "term:`hashable`; if it isn't, :exc:`TypeError` will be raised. Return ``0`` " "on success or ``-1`` on failure. This function *does not* \":term:`steal`\" " "a reference to *val*." msgstr "" +"辞書 *p* に、キー *key* で *val* を挿入します。\n" +"*key* は :term:`ハッシュ可能 ` でなければならず、そうでない場合は :" +"exc:`TypeError` を送出します。\n" +"成功すると ``0``、失敗すると ``-1`` を返します。\n" +"この関数は *val* への参照を「:term:`盗みません `」。" -#: ../../c-api/dict.rst:121 msgid "" "This is the same as :c:func:`PyDict_SetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyDict_SetItem` と同様ですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定しま" +"す。" #: ../../c-api/dict.rst:128 msgid "" @@ -167,64 +179,77 @@ msgstr "" "`TypeError` を送出します。*key* が辞書になければ、:exc:`KeyError` を送出しま" "す。成功した場合には ``0`` を、失敗した場合には ``-1`` を返します。" -#: ../../c-api/dict.rst:141 msgid "" "This is the same as :c:func:`PyDict_DelItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyDict_DelItem` と同様ですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定しま" +"す。" -#: ../../c-api/dict.rst:148 msgid "" "Return a new :term:`strong reference` to the object from dictionary *p* " "which has a key *key*:" msgstr "" +"辞書 *p* からキー *key* に対応するオブジェクトへの新しい :term:`強参照 " +"` を返します:" -#: ../../c-api/dict.rst:151 msgid "" "If the key is present, set *\\*result* to a new :term:`strong reference` to " "the value and return ``1``." msgstr "" +"キーがあれば、*\\*result* にその値への新しい :term:`強参照 ` を設定し、``1`` を返します。" -#: ../../c-api/dict.rst:153 msgid "If the key is missing, set *\\*result* to ``NULL`` and return ``0``." -msgstr "" +msgstr "キーがなければ、*\\*result* に ``NULL`` を設定し、``0`` を返します。" -#: ../../c-api/dict.rst:154 msgid "" "On error, raise an exception, set *\\*result* to ``NULL`` and return ``-1``." msgstr "" +"エラー時には例外を送出し、*\\*result* に ``NULL`` を設定して ``-1`` を返しま" +"す。" -#: ../../c-api/dict.rst:168 msgid "See also the :c:func:`PyObject_GetItem` function." -msgstr "" +msgstr ":c:func:`PyObject_GetItem` 関数も参照してください。" -#: ../../c-api/dict.rst:173 msgid "" "Return a :term:`borrowed reference` to the object from dictionary *p* which " "has a key *key*. Return ``NULL`` if the key *key* is missing *without* " "setting an exception." msgstr "" +"辞書 *p* からキー *key* に対応するオブジェクトへの :term:`借用参照 ` を返します。\n" +"キー *key* がなければ、例外を設定 *せずに* ``NULL`` を返します。" -#: ../../c-api/dict.rst:181 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods are silently ignored. Prefer the :c:func:" "`PyDict_GetItemWithError` function instead." msgstr "" +"この関数が :meth:`~object.__hash__` メソッドや :meth:`~object.__eq__` メソッ" +"ドを呼び出す際に発生した例外は、通知せずに無視します。\n" +"代わりに :c:func:`PyDict_GetItemWithError` 関数を使うことを推奨します。" -#: ../../c-api/dict.rst:187 ../../c-api/dict.rst:209 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " "Prefer :c:func:`PyDict_GetItemRef`, which returns a :term:`strong reference`." msgstr "" +":term:`フリースレッドビルド ` では、別のスレッドが同時に" +"辞書を変更すると、返された :term:`借用参照 ` が無効になる" +"可能性があります。\n" +":term:`強参照 ` を返す :c:func:`PyDict_GetItemRef` を使うこ" +"とを推奨します。" -#: ../../c-api/dict.rst:192 msgid "" "Calling this API without an :term:`attached thread state` had been allowed " "for historical reason. It is no longer allowed." msgstr "" +"歴史的な理由により、以前は :term:`アタッチされたスレッド状態 ` なしでこの API を呼び出すことが認められていました。\n" +"現在は認められていません。" #: ../../c-api/dict.rst:202 msgid "" @@ -236,34 +261,46 @@ msgstr "" "例外が発生した場合は、例外をセット **した上で** ``NULL`` を返します。\n" "キーが存在しなかった場合は、例外をセット **せずに** ``NULL`` を返します。" -#: ../../c-api/dict.rst:220 msgid "" "This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyDict_GetItem` と同様ですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定しま" +"す。" -#: ../../c-api/dict.rst:226 msgid "" "Exceptions that occur while this calls :meth:`~object.__hash__` and :meth:" "`~object.__eq__` methods or while creating the temporary :class:`str` object " "are silently ignored. Prefer using the :c:func:`PyDict_GetItemWithError` " "function with your own :c:func:`PyUnicode_FromString` *key* instead." msgstr "" +"この関数が :meth:`~object.__hash__` メソッドや :meth:`~object.__eq__` メソッ" +"ドを呼び出す際、または一時的な :class:`str` オブジェクトを作成する際に発生し" +"た例外は、通知せずに無視します。\n" +"代わりに、自分で :c:func:`PyUnicode_FromString` により *key* を作成し、:c:" +"func:`PyDict_GetItemWithError` 関数を使うことを推奨します。" -#: ../../c-api/dict.rst:234 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " "Prefer :c:func:`PyDict_GetItemStringRef`, which returns a :term:`strong " "reference`." msgstr "" +":term:`フリースレッドビルド ` では、別のスレッドが同時に" +"辞書を変更すると、返された :term:`借用参照 ` が無効になる" +"可能性があります。\n" +":term:`強参照 ` を返す :c:func:`PyDict_GetItemStringRef` を" +"使うことを推奨します。" -#: ../../c-api/dict.rst:245 msgid "" "Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a :c:expr:" "`const char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyDict_GetItemRef` と同様ですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定しま" +"す。" #: ../../c-api/dict.rst:257 msgid "" @@ -280,15 +317,18 @@ msgstr "" "この関数は、 *key* のハッシュ値を検索と挿入ごとに別々に評価するのではなく、一" "度だけしか評価しません。" -#: ../../c-api/dict.rst:267 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the dictionary concurrently. " "Prefer :c:func:`PyDict_SetDefaultRef`, which returns a :term:`strong " "reference`." msgstr "" +":term:`フリースレッドビルド ` では、別のスレッドが同時に" +"辞書を変更すると、返された :term:`借用参照 ` が無効になる" +"可能性があります。\n" +":term:`強参照 ` を返す :c:func:`PyDict_SetDefaultRef` を使" +"うことを推奨します。" -#: ../../c-api/dict.rst:276 msgid "" "Inserts *default_value* into the dictionary *p* with a key of *key* if the " "key is not already present in the dictionary. If *result* is not ``NULL``, " @@ -299,48 +339,67 @@ msgid "" "and *default_value* was inserted. On failure, returns ``-1``, sets an " "exception, and sets ``*result`` to ``NULL``." msgstr "" +"辞書 *p* にキー *key* がまだなければ、そのキーで *default_value* を挿入しま" +"す。\n" +"*result* が ``NULL`` でなければ、*\\*result* には :term:`強参照 ` を設定します。\n" +"キーがなかった場合は *default_value* への参照、*key* がすでにあった場合は既存" +"の値への参照です。\n" +"キーがすでにあり *default_value* を挿入しなかった場合は ``1``、キーがなく " +"*default_value* を挿入した場合は ``0`` を返します。\n" +"失敗すると ``-1`` を返し、例外を設定し、``*result`` に ``NULL`` を設定しま" +"す。" -#: ../../c-api/dict.rst:286 msgid "" "For clarity: if you have a strong reference to *default_value* before " "calling this function, then after it returns, you hold a strong reference to " "both *default_value* and *\\*result* (if it's not ``NULL``). These may refer " "to the same object: in that case you hold two separate references to it." msgstr "" +"明確にすると、この関数を呼び出す前に *default_value* への強参照を持っていた場" +"合、戻った後には *default_value* と *\\*result* (``NULL`` でない場合) の両方" +"への強参照を持つことになります。\n" +"これらが同じオブジェクトを参照している場合もあり、その場合はそのオブジェクト" +"への別々の参照を 2 つ持つことになります。" -#: ../../c-api/dict.rst:302 msgid "" "Remove *key* from dictionary *p* and optionally return the removed value. Do " "not raise :exc:`KeyError` if the key is missing." msgstr "" +"辞書 *p* から *key* を削除し、必要に応じて削除した値を返します。\n" +"キーがなくても :exc:`KeyError` を送出しません。" -#: ../../c-api/dict.rst:305 msgid "" "If the key is present, set *\\*result* to a new reference to the removed " "value if *result* is not ``NULL``, and return ``1``." msgstr "" +"キーがあれば、*result* が ``NULL`` でない場合には *\\*result* に削除した値へ" +"の新しい参照を設定し、``1`` を返します。" -#: ../../c-api/dict.rst:307 msgid "" "If the key is missing, set *\\*result* to ``NULL`` if *result* is not " "``NULL``, and return ``0``." msgstr "" +"キーがなければ、*result* が ``NULL`` でない場合には *\\*result* に ``NULL`` " +"を設定し、``0`` を返します。" #: ../../c-api/dict.rst:309 msgid "On error, raise an exception and return ``-1``." msgstr "エラーの場合例外を送出し ``-1`` を返します。" -#: ../../c-api/dict.rst:311 msgid "" "Similar to :meth:`dict.pop`, but without the default value and not raising :" "exc:`KeyError` if the key is missing." msgstr "" +":meth:`dict.pop` と同様ですが、デフォルト値はなく、キーがない場合も :exc:" +"`KeyError` を送出しません。" -#: ../../c-api/dict.rst:324 msgid "" "Similar to :c:func:`PyDict_Pop`, but *key* is specified as a :c:expr:`const " "char*` UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyDict_Pop` と同様ですが、*key* は :c:expr:`PyObject*` ではなく、" +"UTF-8 でエンコードされた :c:expr:`const char*` のバイト文字列で指定します。" #: ../../c-api/dict.rst:333 msgid "" @@ -365,15 +424,12 @@ msgid "" msgstr "" "辞書内の要素の数を返します。辞書に対して ``len(p)`` を実行するのと同じです。" -#: ../../c-api/dict.rst:369 msgid "The argument can be a :class:`dict` or a :class:`frozendict`." -msgstr "" +msgstr "引数には :class:`dict` または :class:`frozendict` を指定できます。" -#: ../../c-api/dict.rst:377 msgid "Similar to :c:func:`PyDict_Size`, but without error checking." -msgstr "" +msgstr ":c:func:`PyDict_Size` と同様ですが、エラーチェックを行いません。" -#: ../../c-api/dict.rst:385 msgid "" "Iterate over all key-value pairs in the dictionary *p*. The :c:type:" "`Py_ssize_t` referred to by *ppos* must be initialized to ``0`` prior to the " @@ -386,24 +442,22 @@ msgid "" "represents offsets within the internal dictionary structure, and since the " "structure is sparse, the offsets are not consecutive." msgstr "" -"辞書 *p* 内の全てのキー/値のペアにわたる反復処理を行います。\n" -"*ppos* が参照している :c:type:`Py_ssize_t` 型は、この関数で反復処理を開始する" -"際に、最初に関数を呼び出すよりも前に ``0`` に初期化しておかなければなりませ" -"ん。この関数は辞書内の各ペアを取り上げるごとに真を返し、全てのペアを取り上げ" -"たことが分かると偽を返します。\n" -"パラメーター *pkey* および *pvalue* には、それぞれ辞書の各々のキーと値が埋め" -"られた :c:expr:`PyObject*` 変数を指すポインタか、または ``NULL`` が入りま" -"す。\n" -"この関数から返される参照はすべて借用参照になります。\n" -"反復処理中に *ppos* を変更してはなりません。\n" -"この値は内部的な辞書構造体のオフセットを表現しており、構造体はスパースなの" -"で、オフセットの値に一貫性がないためです。" +"辞書 *p* のすべてのキーと値のペアを反復処理します。\n" +"反復処理を開始するには、最初の呼び出しより前に *ppos* が指す :c:type:" +"`Py_ssize_t` を ``0`` に初期化する必要があります。\n" +"この関数は辞書内の各ペアについて真を返し、すべてのペアを返し終わると偽を返し" +"ます。\n" +"引数 *pkey* と *pvalue* は、それぞれキーと値の格納先となる :c:expr:" +"`PyObject*` 変数を指すか、``NULL`` である必要があります。\n" +"これらを通じて返される参照は借用参照です。\n" +"反復処理中に *ppos* を変更してはいけません。\n" +"その値は辞書の内部構造内のオフセットを表しており、この構造は疎であるため、オ" +"フセットは連続しません。" #: ../../c-api/dict.rst:398 msgid "For example::" msgstr "例えば::" -#: ../../c-api/dict.rst:400 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -413,6 +467,13 @@ msgid "" " ...\n" "}" msgstr "" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" /* 値を使って何らかの処理を行う... */\n" +" ...\n" +"}" #: ../../c-api/dict.rst:408 msgid "" @@ -424,7 +485,6 @@ msgstr "" "応する値を変更しても大丈夫になりましたが、キーの集合を変更しないことが前提で" "す。以下に例を示します::" -#: ../../c-api/dict.rst:412 msgid "" "PyObject *key, *value;\n" "Py_ssize_t pos = 0;\n" @@ -444,16 +504,36 @@ msgid "" " Py_DECREF(o);\n" "}" msgstr "" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" long i = PyLong_AsLong(value);\n" +" if (i == -1 && PyErr_Occurred()) {\n" +" return -1;\n" +" }\n" +" PyObject *o = PyLong_FromLong(i + 1);\n" +" if (o == NULL)\n" +" return -1;\n" +" if (PyDict_SetItem(self->dict, key, o) < 0) {\n" +" Py_DECREF(o);\n" +" return -1;\n" +" }\n" +" Py_DECREF(o);\n" +"}" -#: ../../c-api/dict.rst:430 msgid "" "The function is not thread-safe in the :term:`free-threaded ` build without external synchronization for a mutable :class:" "`dict`. You can use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to lock the " "dictionary while iterating over it::" msgstr "" +":term:`フリースレッド ` ビルドでは、外部で同期を行わない限" +"り、ミュータブルな :class:`dict` に対してこの関数はスレッドセーフではありませ" +"ん。\n" +":c:macro:`Py_BEGIN_CRITICAL_SECTION` を使って、反復処理中に辞書をロックできま" +"す。 ::" -#: ../../c-api/dict.rst:435 msgid "" "Py_BEGIN_CRITICAL_SECTION(self->dict);\n" "while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" @@ -461,12 +541,15 @@ msgid "" "}\n" "Py_END_CRITICAL_SECTION();" msgstr "" +"Py_BEGIN_CRITICAL_SECTION(self->dict);\n" +"while (PyDict_Next(self->dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" -#: ../../c-api/dict.rst:441 msgid "The function is thread-safe on a :class:`frozendict`." -msgstr "" +msgstr ":class:`frozendict` に対してこの関数はスレッドセーフです。" -#: ../../c-api/dict.rst:445 msgid "" "On the free-threaded build, this function can be used safely inside a " "critical section. However, the references returned for *pkey* and *pvalue* " @@ -476,8 +559,15 @@ msgid "" "term:`strong reference ` (for example, using :c:func:" "`Py_NewRef`)." msgstr "" +"フリースレッドビルドでは、この関数はクリティカルセクション内で安全に使えま" +"す。\n" +"ただし、*pkey* と *pvalue* に返される参照は :term:`借用参照 ` であり、クリティカルセクションを保持している間だけ有効です。\n" +"クリティカルセクションの外で、またはクリティカルセクションが中断される可能性" +"がある状況でこれらのオブジェクトを使う必要がある場合は、:term:`強参照 " +"` を作成してください (例えば :c:func:`Py_NewRef` を使いま" +"す)。" -#: ../../c-api/dict.rst:458 msgid "" "Iterate over mapping object *b* adding key-value pairs to dictionary *a*. " "*b* may be a dictionary, or any object supporting :c:func:`PyMapping_Keys` " @@ -486,21 +576,26 @@ msgid "" "only be added if there is not a matching key in *a*. Return ``0`` on success " "or ``-1`` if an exception was raised." msgstr "" -"マップ型オブジェクト *b* の全ての要素にわたって、反復的にキー/値のペアを辞書 " -"*a* に追加します。 *b* は辞書か、 :c:func:`PyMapping_Keys` または :c:func:" -"`PyObject_GetItem` をサポートする何らかのオブジェクトにできます。 *override* " -"が真ならば、 *a* のキーと一致するキーが *b* にある際に、既存のペアを置き換え" -"ます。それ以外の場合は、 *b* のキーに一致するキーが *a* にないときのみ追加を" -"行います。成功した場合には ``0`` を返し、例外が送出された場合には ``-1`` を返" -"します。" +"マッピングオブジェクト *b* を反復処理し、キーと値のペアを辞書 *a* に追加しま" +"す。\n" +"*b* は辞書、または :c:func:`PyMapping_Keys` と :c:func:`PyObject_GetItem` の" +"両方をサポートするオブジェクトであれば構いません。\n" +"*override* が真の場合、*b* に一致するキーがあれば *a* の既存のペアを置き換え" +"ます。\n" +"偽の場合は、*a* に一致するキーがないペアだけを追加します。\n" +"成功すると ``0``、例外が送出された場合は ``-1`` を返します。" -#: ../../c-api/dict.rst:467 ../../c-api/dict.rst:483 msgid "" "In the :term:`free-threaded build`, when *b* is a :class:`dict` (with the " "standard iterator), both *a* and *b* are locked for the duration of the " "operation. When *b* is a non-dict mapping, only *a* is locked; *b* may be " "concurrently modified by another thread." msgstr "" +":term:`フリースレッドビルド ` では、*b* が (標準のイテ" +"レータを使う) :class:`dict` の場合、操作中は *a* と *b* の両方をロックしま" +"す。\n" +"*b* が dict 以外のマッピングの場合は *a* だけをロックし、*b* は別のスレッドに" +"よって同時に変更される可能性があります。" #: ../../c-api/dict.rst:475 msgid "" @@ -515,7 +610,6 @@ msgstr "" "性を持たない場合にキー/値ペアのシーケンスを反復することはありません。成功した" "場合には ``0`` を返し、例外が送出された場合には ``-1`` を返します。" -#: ../../c-api/dict.rst:491 msgid "" "Update or merge into dictionary *a*, from the key-value pairs in *seq2*. " "*seq2* must be an iterable object producing iterable objects of length 2, " @@ -523,79 +617,103 @@ msgid "" "*override* is true, else the first wins. Return ``0`` on success or ``-1`` " "if an exception was raised. Equivalent Python (except for the return value)::" msgstr "" -"*seq2* 内のキー/値ペアを使って、辞書 *a* の内容を更新したり統合したりします。" -"*seq2* は、キー/値のペアとみなせる長さ 2 の反復可能オブジェクト(iterable " -"object) を生成する反復可能オブジェクトでなければなりません。重複するキーが存" -"在する場合、*override* が真ならば先に出現したキーを使い、そうでない場合は後に" -"出現したキーを使います。成功した場合には ``0`` を返し、例外が送出された場合に" -"は ``-1`` を返します。(戻り値以外は) 等価な Python コードを書くと、以下のよう" -"になります::" +"*seq2* 内のキーと値のペアを使って、辞書 *a* を更新またはマージします。\n" +"*seq2* は、キーと値のペアとみなせる長さ 2 のイテラブルオブジェクトを生成する" +"イテラブルオブジェクトでなければなりません。\n" +"キーが重複する場合、*override* が真なら最後の値を、偽なら最初の値を使いま" +"す。\n" +"成功すると ``0``、例外が送出された場合は ``-1`` を返します。\n" +"戻り値を除いて等価な Python コードを示します。 ::" -#: ../../c-api/dict.rst:498 msgid "" "def PyDict_MergeFromSeq2(a, seq2, override):\n" " for key, value in seq2:\n" " if override or key not in a:\n" " a[key] = value" msgstr "" +"def PyDict_MergeFromSeq2(a, seq2, override):\n" +" for key, value in seq2:\n" +" if override or key not in a:\n" +" a[key] = value" -#: ../../c-api/dict.rst:505 msgid "" "In the :term:`free-threaded ` build, only *a* is locked. The " "iteration over *seq2* is not synchronized; *seq2* may be concurrently " "modified by another thread." msgstr "" +":term:`フリースレッド ` ビルドでは、*a* だけをロックしま" +"す。\n" +"*seq2* の反復処理は同期されないため、別のスレッドが同時に *seq2* を変更する可" +"能性があります。" -#: ../../c-api/dict.rst:512 msgid "" "Register *callback* as a dictionary watcher. Return a non-negative integer " "id which must be passed to future calls to :c:func:`PyDict_Watch`. In case " "of error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" +"*callback* を辞書ウォッチャーとして登録します。\n" +"非負の整数の ID を返します。この ID は以降の :c:func:`PyDict_Watch` 呼び出し" +"に渡す必要があります。\n" +"エラー時 (例えばウォッチャー ID に空きがない場合) には ``-1`` を返し、例外を" +"設定します。" -#: ../../c-api/dict.rst:519 ../../c-api/dict.rst:534 msgid "" "This function is not internally synchronized. In the :term:`free-threaded " "` build, callers should ensure no concurrent calls to :c:" "func:`PyDict_AddWatcher` or :c:func:`PyDict_ClearWatcher` are in progress." msgstr "" +"この関数は内部で同期を行いません。\n" +":term:`フリースレッド ` ビルドでは、呼び出し側が :c:func:" +"`PyDict_AddWatcher` や :c:func:`PyDict_ClearWatcher` の呼び出しが同時に行われ" +"ないことを保証する必要があります。" -#: ../../c-api/dict.rst:528 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g. if the " "given *watcher_id* was never registered.)" msgstr "" +"以前に :c:func:`PyDict_AddWatcher` が返した *watcher_id* で識別されるウォッ" +"チャーを解除します。\n" +"成功すると ``0``、エラー時 (例えば指定した *watcher_id* が登録されていない場" +"合) には ``-1`` を返します。" -#: ../../c-api/dict.rst:543 msgid "" "Mark dictionary *dict* as watched. The callback granted *watcher_id* by :c:" "func:`PyDict_AddWatcher` will be called when *dict* is modified or " "deallocated. Return ``0`` on success or ``-1`` on error." msgstr "" +"辞書 *dict* を監視対象にします。\n" +"*dict* が変更または解放されると、:c:func:`PyDict_AddWatcher` で *watcher_id* " +"を割り当てられたコールバックを呼び出します。\n" +"成功すると ``0``、エラー時には ``-1`` を返します。" -#: ../../c-api/dict.rst:551 msgid "" "Mark dictionary *dict* as no longer watched. The callback granted " "*watcher_id* by :c:func:`PyDict_AddWatcher` will no longer be called when " "*dict* is modified or deallocated. The dict must previously have been " "watched by this watcher. Return ``0`` on success or ``-1`` on error." msgstr "" +"辞書 *dict* を監視対象から外します。\n" +"*dict* が変更または解放されても、:c:func:`PyDict_AddWatcher` で *watcher_id* " +"を割り当てられたコールバックは呼び出されなくなります。\n" +"この辞書は、それまでこのウォッチャーに監視されている必要があります。\n" +"成功すると ``0``、エラー時には ``-1`` を返します。" -#: ../../c-api/dict.rst:560 msgid "" "Enumeration of possible dictionary watcher events: ``PyDict_EVENT_ADDED``, " "``PyDict_EVENT_MODIFIED``, ``PyDict_EVENT_DELETED``, " "``PyDict_EVENT_CLONED``, ``PyDict_EVENT_CLEARED``, or " "``PyDict_EVENT_DEALLOCATED``." msgstr "" +"辞書ウォッチャーで発生し得るイベントを表す列挙型です: " +"``PyDict_EVENT_ADDED``、``PyDict_EVENT_MODIFIED``、``PyDict_EVENT_DELETED``、" +"``PyDict_EVENT_CLONED``、``PyDict_EVENT_CLEARED``、" +"``PyDict_EVENT_DEALLOCATED``。" -#: ../../c-api/dict.rst:568 msgid "Type of a dict watcher callback function." -msgstr "" +msgstr "辞書ウォッチャーのコールバック関数の型です。" -#: ../../c-api/dict.rst:570 msgid "" "If *event* is ``PyDict_EVENT_CLEARED`` or ``PyDict_EVENT_DEALLOCATED``, both " "*key* and *new_value* will be ``NULL``. If *event* is ``PyDict_EVENT_ADDED`` " @@ -603,23 +721,37 @@ msgid "" "If *event* is ``PyDict_EVENT_DELETED``, *key* is being deleted from the " "dictionary and *new_value* will be ``NULL``." msgstr "" +"*event* が ``PyDict_EVENT_CLEARED`` または ``PyDict_EVENT_DEALLOCATED`` の場" +"合、*key* と *new_value* はどちらも ``NULL`` になります。\n" +"*event* が ``PyDict_EVENT_ADDED`` または ``PyDict_EVENT_MODIFIED`` の場合、" +"*new_value* は *key* に対応する新しい値です。\n" +"*event* が ``PyDict_EVENT_DELETED`` の場合、*key* は辞書から削除されるキーで" +"あり、*new_value* は ``NULL`` になります。" -#: ../../c-api/dict.rst:576 msgid "" "``PyDict_EVENT_CLONED`` occurs when *dict* was previously empty and another " "dict is merged into it. To maintain efficiency of this operation, per-key " "``PyDict_EVENT_ADDED`` events are not issued in this case; instead a single " "``PyDict_EVENT_CLONED`` is issued, and *key* will be the source dictionary." msgstr "" +"``PyDict_EVENT_CLONED`` は、空だった *dict* に別の辞書がマージされるときに発" +"生します。\n" +"この操作の効率を保つため、この場合はキーごとの ``PyDict_EVENT_ADDED`` イベン" +"トは発生しません。\n" +"代わりに ``PyDict_EVENT_CLONED`` が 1 回発生し、*key* はマージ元の辞書になり" +"ます。" -#: ../../c-api/dict.rst:582 msgid "" "The callback may inspect but must not modify *dict*; doing so could have " "unpredictable effects, including infinite recursion. Do not trigger Python " "code execution in the callback, as it could modify the dict as a side effect." msgstr "" +"コールバックは *dict* の内容を調べることはできますが、変更してはいけませ" +"ん。\n" +"変更すると、無限再帰などの予測できない影響が生じる可能性があります。\n" +"副作用で辞書を変更する可能性があるため、コールバック内で Python コードを実行" +"しないでください。" -#: ../../c-api/dict.rst:586 msgid "" "If *event* is ``PyDict_EVENT_DEALLOCATED``, taking a new reference in the " "callback to the about-to-be-destroyed dictionary will resurrect it and " @@ -627,21 +759,29 @@ msgid "" "destroyed later, any watcher callbacks active at that time will be called " "again." msgstr "" +"*event* が ``PyDict_EVENT_DEALLOCATED`` の場合、コールバック内で破棄される直" +"前の辞書への新しい参照を取得すると、その辞書は復活し、その時点では解放されな" +"くなります。\n" +"復活したオブジェクトが後で破棄されると、その時点で有効なウォッチャーのコール" +"バックが再び呼び出されます。" -#: ../../c-api/dict.rst:592 msgid "" "Callbacks occur before the notified modification to *dict* takes place, so " "the prior state of *dict* can be inspected." msgstr "" +"コールバックは、通知対象の *dict* の変更が行われる前に呼び出されるため、変更" +"前の *dict* の状態を調べることができます。" -#: ../../c-api/dict.rst:595 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" +"コールバックが例外を設定した場合は ``-1`` を返す必要があります。\n" +"その例外は、:c:func:`PyErr_WriteUnraisable` を使って送出できない例外として表" +"示されます。\n" +"それ以外の場合は ``0`` を返してください。" -#: ../../c-api/dict.rst:599 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -649,207 +789,229 @@ msgid "" "exception unless it saves and clears the exception state first, and restores " "it before returning." msgstr "" +"コールバックに入る時点で、すでに処理待ちの例外が設定されている場合がありま" +"す。\n" +"その場合、コールバックは同じ例外を設定したまま ``0`` を返すべきです。\n" +"そのため、例外を設定し得る別の API を呼び出す場合は、まず例外の状態を保存して" +"クリアし、戻る前に復元する必要があります。" #: ../../c-api/dict.rst:609 msgid "Dictionary view objects" msgstr "辞書ビューオブジェクト" -#: ../../c-api/dict.rst:613 msgid "" "Return true if *op* is a view of a set inside a dictionary. This is " "currently equivalent to :c:expr:`PyDictKeys_Check(op) || " "PyDictItems_Check(op)`. This function always succeeds." msgstr "" +"*op* が辞書内の集合のビューであれば真を返します。\n" +"現在、これは :c:expr:`PyDictKeys_Check(op) || PyDictItems_Check(op)` と等価で" +"す。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:620 msgid "" "Type object for a view of dictionary keys. In Python, this is the type of " "the object returned by :meth:`dict.keys`." msgstr "" +"辞書のキーのビューの型オブジェクトです。\n" +"Python では :meth:`dict.keys` が返すオブジェクトの型です。" -#: ../../c-api/dict.rst:626 msgid "" "Return true if *op* is an instance of a dictionary keys view. This function " "always succeeds." msgstr "" +"*op* が辞書のキーのビューのインスタンスであれば真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:632 msgid "" "Type object for a view of dictionary values. In Python, this is the type of " "the object returned by :meth:`dict.values`." msgstr "" +"辞書の値のビューの型オブジェクトです。\n" +"Python では :meth:`dict.values` が返すオブジェクトの型です。" -#: ../../c-api/dict.rst:638 msgid "" "Return true if *op* is an instance of a dictionary values view. This " "function always succeeds." msgstr "" +"*op* が辞書の値のビューのインスタンスであれば真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:644 msgid "" "Type object for a view of dictionary items. In Python, this is the type of " "the object returned by :meth:`dict.items`." msgstr "" +"辞書の要素対のビューの型オブジェクトです。\n" +"Python では :meth:`dict.items` が返すオブジェクトの型です。" -#: ../../c-api/dict.rst:650 msgid "" "Return true if *op* is an instance of a dictionary items view. This function " "always succeeds." msgstr "" +"*op* が辞書の要素対のビューのインスタンスであれば真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:655 msgid "Frozen dictionary objects" -msgstr "" +msgstr "凍結された辞書オブジェクト" -#: ../../c-api/dict.rst:662 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python frozen " "dictionary type. This is the same object as :class:`frozendict` in the " "Python layer." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の凍結された辞書の型を表" +"します。\n" +"Python レイヤの :class:`frozendict` と同じオブジェクトです。" -#: ../../c-api/dict.rst:669 msgid "" "Return true if *p* is a :class:`dict` object, a :class:`frozendict` object, " "or an instance of a subtype of the :class:`!dict` or :class:`!frozendict` " "type. This function always succeeds." msgstr "" +"*p* が :class:`dict` オブジェクト、:class:`frozendict` オブジェクト、または :" +"class:`!dict` 型か :class:`!frozendict` 型のサブタイプのインスタンスであれば" +"真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:677 msgid "" "Return true if *p* is a :class:`dict` object or a :class:`frozendict` " "object, but not an instance of a subtype of the :class:`!dict` or :class:`!" "frozendict` type. This function always succeeds." msgstr "" +"*p* が :class:`dict` オブジェクトまたは :class:`frozendict` オブジェクトで、:" +"class:`!dict` 型や :class:`!frozendict` 型のサブタイプのインスタンスではない" +"場合に真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:685 msgid "" "Return true if *p* is a :class:`frozendict` object or an instance of a " "subtype of the :class:`!frozendict` type. This function always succeeds." msgstr "" +"*p* が :class:`frozendict` オブジェクトまたは :class:`!frozendict` 型のサブタ" +"イプのインスタンスであれば真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:692 msgid "" "Return true if *p* is a :class:`frozendict` object, but not an instance of a " "subtype of the :class:`!frozendict` type. This function always succeeds." msgstr "" +"*p* が :class:`frozendict` オブジェクトで、:class:`!frozendict` 型のサブタイ" +"プのインスタンスではない場合に真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:699 msgid "" "Return a new :class:`frozendict` from an iterable, or ``NULL`` on failure " "with an exception set." msgstr "" +"イテラブルから新しい :class:`frozendict` を作成して返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/dict.rst:702 msgid "Create an empty dictionary if *iterable* is ``NULL``." -msgstr "" +msgstr "*iterable* が ``NULL`` の場合は空の辞書を作成します。" -#: ../../c-api/dict.rst:706 msgid "Ordered dictionaries" -msgstr "" +msgstr "順序付き辞書" -#: ../../c-api/dict.rst:708 msgid "" "Python's C API provides interface for :class:`collections.OrderedDict` from " "C. Since Python 3.7, dictionaries are ordered by default, so there is " "usually little need for these functions; prefer ``PyDict*`` where possible." msgstr "" +"Python の C API には、C から :class:`collections.OrderedDict` を扱うためのイ" +"ンターフェースがあります。\n" +"Python 3.7 以降、通常の辞書もデフォルトで順序を保持するため、これらの関数が必" +"要になることはあまりありません。\n" +"可能であれば ``PyDict*`` を使ってください。" -#: ../../c-api/dict.rst:715 msgid "" "Type object for ordered dictionaries. This is the same object as :class:" "`collections.OrderedDict` in the Python layer." msgstr "" +"順序付き辞書の型オブジェクトです。\n" +"Python レイヤの :class:`collections.OrderedDict` と同じオブジェクトです。" -#: ../../c-api/dict.rst:721 msgid "" "Return true if *od* is an ordered dictionary object or an instance of a " "subtype of the :class:`~collections.OrderedDict` type. This function always " "succeeds." msgstr "" +"*od* が順序付き辞書オブジェクト、または :class:`~collections.OrderedDict` 型" +"のサブタイプのインスタンスであれば真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:728 msgid "" "Return true if *od* is an ordered dictionary object, but not an instance of " "a subtype of the :class:`~collections.OrderedDict` type. This function " "always succeeds." msgstr "" +"*od* が順序付き辞書オブジェクトで、:class:`~collections.OrderedDict` 型のサブ" +"タイプのインスタンスではない場合に真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/dict.rst:735 msgid "Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries." -msgstr "" +msgstr ":c:type:`PyDictKeys_Type` に相当する、順序付き辞書用の型です。" -#: ../../c-api/dict.rst:740 msgid "Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries." -msgstr "" +msgstr ":c:type:`PyDictValues_Type` に相当する、順序付き辞書用の型です。" -#: ../../c-api/dict.rst:745 msgid "Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries." -msgstr "" +msgstr ":c:type:`PyDictItems_Type` に相当する、順序付き辞書用の型です。" -#: ../../c-api/dict.rst:750 msgid "Return a new empty ordered dictionary, or ``NULL`` on failure." msgstr "" +"新しい空の順序付き辞書を返します。\n" +"失敗すると ``NULL`` を返します。" -#: ../../c-api/dict.rst:752 msgid "This is analogous to :c:func:`PyDict_New`." -msgstr "" +msgstr ":c:func:`PyDict_New` に相当します。" -#: ../../c-api/dict.rst:757 msgid "" "Insert *value* into the ordered dictionary *od* with a key of *key*. Return " "``0`` on success or ``-1`` with an exception set on failure." msgstr "" +"順序付き辞書 *od* に、キー *key* で *value* を挿入します。\n" +"成功すると ``0``、失敗すると例外を設定して ``-1`` を返します。" -#: ../../c-api/dict.rst:760 msgid "This is analogous to :c:func:`PyDict_SetItem`." -msgstr "" +msgstr ":c:func:`PyDict_SetItem` に相当します。" -#: ../../c-api/dict.rst:765 msgid "" "Remove the entry in the ordered dictionary *od* with key *key*. Return ``0`` " "on success or ``-1`` with an exception set on failure." msgstr "" +"順序付き辞書 *od* から、キー *key* のエントリーを削除します。\n" +"成功すると ``0``、失敗すると例外を設定して ``-1`` を返します。" -#: ../../c-api/dict.rst:768 msgid "This is analogous to :c:func:`PyDict_DelItem`." -msgstr "" +msgstr ":c:func:`PyDict_DelItem` に相当します。" -#: ../../c-api/dict.rst:771 msgid "These are :term:`soft deprecated` aliases to ``PyDict`` APIs:" msgstr "" +"以下は ``PyDict`` API の :term:`ソフト非推奨 ` の別名です:" -#: ../../c-api/dict.rst:778 msgid "``PyODict``" -msgstr "" +msgstr "``PyODict``" -#: ../../c-api/dict.rst:779 msgid "``PyDict``" -msgstr "" +msgstr "``PyDict``" -#: ../../c-api/dict.rst:781 msgid ":c:func:`PyDict_GetItem`" -msgstr "" +msgstr ":c:func:`PyDict_GetItem`" -#: ../../c-api/dict.rst:783 msgid ":c:func:`PyDict_GetItemWithError`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../c-api/dict.rst:785 msgid ":c:func:`PyDict_GetItemString`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemString`" -#: ../../c-api/dict.rst:787 msgid ":c:func:`PyDict_Contains`" -msgstr "" +msgstr ":c:func:`PyDict_Contains`" -#: ../../c-api/dict.rst:789 msgid ":c:func:`PyDict_Size`" -msgstr "" +msgstr ":c:func:`PyDict_Size`" -#: ../../c-api/dict.rst:791 msgid ":c:func:`PyDict_GET_SIZE`" -msgstr "" +msgstr ":c:func:`PyDict_GET_SIZE`" #: ../../c-api/dict.rst:8 msgid "object" diff --git a/c-api/exceptions.po b/c-api/exceptions.po index 93beb25cc..6adc32870 100644 --- a/c-api/exceptions.po +++ b/c-api/exceptions.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/exceptions.rst:8 @@ -62,7 +62,6 @@ msgstr "" "されており、例えば、例外の型が ``NULL`` の場合は、トレースバックは非 " "``NULL`` の値になりません)" -#: ../../c-api/exceptions.rst:26 msgid "" "When a function must fail because some function it called failed, it " "generally doesn't set the error indicator; the function it called already " @@ -74,23 +73,26 @@ msgid "" "error is not handled or carefully propagated, additional calls into the " "Python/C API may not behave as intended and may fail in mysterious ways." msgstr "" -"ある関数が呼び出した関数がいくつか失敗したために、その関数が失敗しなければな" -"らないとき、一般的にエラーインジケータを設定しません。呼び出した関数がすでに" -"設定しています。エラーを処理して例外をクリアするか、あるいは (オブジェクト参" -"照またはメモリ割り当てのような)それが持つどんなリソースも取り除いた後に戻るか" -"のどちらか一方を行う責任があります。エラーを処理する準備をしていなければ、普" -"通に続けるべきでは *ありません*。エラーのために戻る場合は、エラーが設定されて" -"いると呼び出し元に知らせることが大切です。エラーが処理されていない場合または" -"丁寧に伝えられている場合には、Python/C APIのさらなる呼び出しは意図した通りに" -"は動かない可能性があり、不可解な形で失敗するかもしれません。" +"呼び出した関数が失敗したために自分も失敗する必要がある場合、通常はエラーイン" +"ジケータを設定しません。\n" +"呼び出した関数がすでに設定しているためです。\n" +"その関数には、エラーを処理して例外をクリアするか、保持しているリソース (オブ" +"ジェクトへの参照や割り当てたメモリなど) を解放してから戻る責任があります。\n" +"エラーを処理する準備がないなら、通常どおり実行を続けては *いけません*。\n" +"エラーのために戻る場合は、エラーが設定されていることを呼び出し側に通知するこ" +"とが重要です。\n" +"エラーを処理せず、適切に伝播させることもしなければ、その後の Python/C API の" +"呼び出しは意図どおりに動作せず、不可解な形で失敗する可能性があります。" -#: ../../c-api/exceptions.rst:37 msgid "" "The error indicator is **not** the result of :func:`sys.exc_info`. The " "former corresponds to an exception that is not yet caught (and is therefore " "still propagating), while the latter returns an exception after it is caught " "(and has therefore stopped propagating)." msgstr "" +"エラーインジケータは :func:`sys.exc_info` の結果とは **異なります**。\n" +"前者はまだ捕捉されていない例外 (したがって伝播中の例外) に対応し、後者は捕捉" +"された後の例外 (したがって伝播が止まった例外) を返します。" #: ../../c-api/exceptions.rst:44 msgid "Printing and clearing" @@ -126,7 +128,6 @@ msgstr "" "い。\n" "それ以外の場合、致命的なエラーを引き起こすでしょう!" -#: ../../c-api/exceptions.rst:63 msgid "" "If *set_sys_last_vars* is nonzero, the variable :data:`sys.last_exc` is set " "to the printed exception. For backwards compatibility, the deprecated " @@ -134,10 +135,14 @@ msgid "" "last_traceback` are also set to the type, value and traceback of this " "exception, respectively." msgstr "" +"*set_sys_last_vars* がゼロでない場合、表示した例外を変数 :data:`sys." +"last_exc` に設定します。\n" +"後方互換性のため、非推奨の変数 :data:`sys.last_type`、:data:`sys." +"last_value`、:data:`sys.last_traceback` にも、この例外の型、値、トレースバッ" +"クをそれぞれ設定します。" -#: ../../c-api/exceptions.rst:69 msgid "The setting of :data:`sys.last_exc` was added." -msgstr "" +msgstr ":data:`sys.last_exc` の設定が追加されました。" #: ../../c-api/exceptions.rst:75 msgid "Alias for ``PyErr_PrintEx(1)``." @@ -149,35 +154,40 @@ msgid "" "argument." msgstr "現在の例外と *obj* 引数で :func:`sys.unraisablehook` を呼び出します。" -#: ../../c-api/exceptions.rst:83 msgid "" "This utility function prints a warning message to ``sys.stderr`` when an " "exception has been set but it is impossible for the interpreter to actually " "raise the exception. It is used, for example, when an exception occurs in " "an :meth:`~object.__del__` method." msgstr "" +"このユーティリティ関数は、例外が設定されているものの、インタープリタが実際に" +"はその例外を送出できない場合に、``sys.stderr`` に警告メッセージを表示しま" +"す。\n" +"例えば :meth:`~object.__del__` メソッド内で例外が発生した場合に使われます。" -#: ../../c-api/exceptions.rst:88 msgid "" "The function is called with a single argument *obj* that identifies the " "context in which the unraisable exception occurred. If possible, the repr of " "*obj* will be printed in the warning message. If *obj* is ``NULL``, only the " "traceback is printed." msgstr "" +"この関数は、送出できない例外が発生した状況を示す 1 つの引数 *obj* を指定して" +"呼び出します。\n" +"可能であれば、警告メッセージに *obj* の repr を表示します。\n" +"*obj* が ``NULL`` の場合はトレースバックだけを表示します。" #: ../../c-api/exceptions.rst:93 msgid "An exception must be set when calling this function." msgstr "この関数を呼び出すときには、例外がセットされていなければなりません。" -#: ../../c-api/exceptions.rst:95 msgid "Print a traceback. Print only traceback if *obj* is ``NULL``." msgstr "" +"トレースバックを表示するようになりました。\n" +"*obj* が ``NULL`` の場合はトレースバックだけを表示します。" -#: ../../c-api/exceptions.rst:98 msgid "Use :func:`sys.unraisablehook`." -msgstr "" +msgstr ":func:`sys.unraisablehook` を使うようになりました。" -#: ../../c-api/exceptions.rst:104 msgid "" "Similar to :c:func:`PyErr_WriteUnraisable`, but the *format* and subsequent " "parameters help format the warning message; they have the same meaning and " @@ -185,33 +195,43 @@ msgid "" "is roughly equivalent to ``PyErr_FormatUnraisable(\"Exception ignored in: " "%R\", obj)``. If *format* is ``NULL``, only the traceback is printed." msgstr "" +":c:func:`PyErr_WriteUnraisable` と同様ですが、*format* とそれ以降の引数を使っ" +"て警告メッセージを書式化します。\n" +"これらの意味と値は :c:func:`PyUnicode_FromFormat` と同じです。\n" +"``PyErr_WriteUnraisable(obj)`` は、おおよそ " +"``PyErr_FormatUnraisable(\"Exception ignored in: %R\", obj)`` と等価です。\n" +"*format* が ``NULL`` の場合はトレースバックだけを表示します。" -#: ../../c-api/exceptions.rst:116 msgid "" "Print the standard traceback display of ``exc`` to ``sys.stderr``, including " "chained exceptions and notes." msgstr "" +"連鎖した例外と注釈を含め、``exc`` のトレースバックを標準の形式で ``sys." +"stderr`` に表示します。" -#: ../../c-api/exceptions.rst:124 msgid "Legacy variant of :c:func:`PyErr_DisplayException`." -msgstr "" +msgstr ":c:func:`PyErr_DisplayException` の従来の版です。" -#: ../../c-api/exceptions.rst:126 msgid "" "Print the exception *value* with its traceback to :data:`sys.stderr`. If " "*value* has no traceback set, *tb* is used as its traceback. The first " "argument is ignored." msgstr "" +"例外 *value* とそのトレースバックを :data:`sys.stderr` に表示します。\n" +"*value* にトレースバックが設定されていない場合は、*tb* をトレースバックとして" +"使います。\n" +"最初の引数は無視します。" -#: ../../c-api/exceptions.rst:130 msgid "" "If :data:`sys.stderr` is ``None``, nothing is printed. If :data:`sys.stderr` " "is not set, the exception is dumped to the C ``stderr`` stream instead." msgstr "" +":data:`sys.stderr` が ``None`` の場合は何も表示しません。\n" +":data:`sys.stderr` が設定されていない場合は、代わりに C の ``stderr`` スト" +"リームに例外をダンプします。" -#: ../../c-api/exceptions.rst:134 msgid "Use :c:func:`PyErr_DisplayException` instead." -msgstr "" +msgstr "代わりに :c:func:`PyErr_DisplayException` を使ってください。" #: ../../c-api/exceptions.rst:138 msgid "Raising exceptions" @@ -227,7 +247,6 @@ msgstr "" "ため、これらの関数のいくつかは、 ``return`` 文で利用できるように常に " "``NULL`` ポインタを返します。" -#: ../../c-api/exceptions.rst:147 msgid "" "This is the most common way to set the error indicator. The first argument " "specifies the exception type; it is normally one of the standard exceptions, " @@ -235,6 +254,12 @@ msgid "" "reference` to it (e.g. with :c:func:`Py_INCREF`). The second argument is an " "error message; it is decoded from ``'utf-8'``." msgstr "" +"エラーインジケータを設定する最も一般的な方法です。\n" +"最初の引数は例外の型で、通常は :c:data:`PyExc_RuntimeError` などの標準の例外" +"のいずれかです。\n" +"その型への新しい :term:`強参照 ` を作成する必要はありませ" +"ん (例えば :c:func:`Py_INCREF` は不要です)。\n" +"2 番目の引数はエラーメッセージで、``'utf-8'`` からデコードします。" #: ../../c-api/exceptions.rst:156 msgid "" @@ -288,7 +313,6 @@ msgstr "" "ます。したがって、メモリ不足になったとき、オブジェクト割り当て関数は " "``return PyErr_NoMemory();`` と書くことができます。" -#: ../../c-api/exceptions.rst:200 msgid "" "This is a convenience function to raise an exception when a C library " "function has returned an error and set the C variable :c:data:`errno`. It " @@ -301,14 +325,28 @@ msgid "" "returns ``NULL``, so a wrapper function around a system call can write " "``return PyErr_SetFromErrno(type);`` when the system call returns an error." msgstr "" +"C ライブラリ関数がエラーを返し、C の変数 :c:data:`errno` を設定した場合に、例" +"外を送出するための便利関数です。\n" +"最初の要素が :c:data:`errno` の整数値、2 番目の要素が対応するエラーメッセー" +"ジ (:c:func:`!strerror` から取得) であるタプルオブジェクトを作成し、" +"``PyErr_SetObject(type, object)`` を呼び出します。\n" +"Unix で :c:data:`errno` がシステムコールの中断を示す :c:macro:`!EINTR` の場合" +"は、:c:func:`PyErr_CheckSignals` を呼び出します。\n" +"それによってエラーインジケータが設定された場合は、そのままにします。\n" +"この関数は常に ``NULL`` を返すため、システムコールのラッパー関数は、システム" +"コールがエラーを返したときに ``return PyErr_SetFromErrno(type);`` と書けま" +"す。" -#: ../../c-api/exceptions.rst:214 msgid "" "Similar to :c:func:`PyErr_SetFromErrno`, with the additional behavior that " "if *filenameObject* is not ``NULL``, it is passed to the constructor of " "*type* as a third parameter. In the case of :exc:`OSError` exception, this " "is used to define the :attr:`!filename` attribute of the exception instance." msgstr "" +":c:func:`PyErr_SetFromErrno` と同様ですが、*filenameObject* が ``NULL`` でな" +"ければ、*type* のコンストラクタに 3 番目の引数として渡します。\n" +":exc:`OSError` 例外では、これは例外インスタンスの :attr:`!filename` 属性の定" +"義に使われます。" #: ../../c-api/exceptions.rst:223 msgid "" @@ -331,7 +369,6 @@ msgstr "" "*filename* は :term:`ファイルシステムのエンコーディングとエラーハンドラ " "` でデコードされます。" -#: ../../c-api/exceptions.rst:239 msgid "" "This is a convenience function to raise :exc:`OSError`. If called with " "*ierr* of ``0``, the error code returned by a call to :c:func:`!" @@ -344,12 +381,19 @@ msgid "" "``PyErr_SetObject(PyExc_OSError, object)``. This function always returns " "``NULL``." msgstr "" +":exc:`OSError` を送出するための便利関数です。\n" +"*ierr* に ``0`` を指定して呼び出すと、代わりに :c:func:`!GetLastError` の呼び" +"出しで返されたエラーコードを使います。\n" +"Win32 関数 :c:func:`!FormatMessage` を呼び出し、*ierr* または :c:func:`!" +"GetLastError` で指定されたエラーコードの Windows による説明を取得します。\n" +"次に、:attr:`~OSError.winerror` 属性をエラーコード、:attr:`~OSError." +"strerror` 属性を対応するエラーメッセージ (:c:func:`!FormatMessage` から取得) " +"に設定した :exc:`OSError` オブジェクトを作成し、" +"``PyErr_SetObject(PyExc_OSError, object)`` を呼び出します。\n" +"この関数は常に ``NULL`` を返します。" -#: ../../c-api/exceptions.rst:249 ../../c-api/exceptions.rst:257 -#: ../../c-api/exceptions.rst:268 ../../c-api/exceptions.rst:278 -#: ../../c-api/exceptions.rst:286 ../../c-api/exceptions.rst:296 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../c-api/exceptions.rst:254 msgid "" @@ -359,7 +403,6 @@ msgstr "" ":c:func:`PyErr_SetFromWindowsErr` に似ていますが、送出する例外の型を指定する" "引数が追加されています。" -#: ../../c-api/exceptions.rst:262 msgid "" "Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior " "that if *filename* is not ``NULL``, it is decoded from the filesystem " @@ -367,6 +410,10 @@ msgid "" "`OSError` as a third parameter to be used to define the :attr:`!filename` " "attribute of the exception instance." msgstr "" +":c:func:`PyErr_SetFromWindowsErr` と同様ですが、*filename* が ``NULL`` でなけ" +"れば、ファイルシステムのエンコーディング (:func:`os.fsdecode`) でデコード" +"し、:exc:`OSError` のコンストラクタに 3 番目の引数として渡します。\n" +"これは例外インスタンスの :attr:`!filename` 属性の定義に使われます。" #: ../../c-api/exceptions.rst:273 msgid "" @@ -423,11 +470,12 @@ msgstr "" "現在の例外が :exc:`SyntaxError` でない場合は、例外を表示するサブシステムが、" "例外が :exc:`SyntaxError` であると思えるように属性を追加します。" -#: ../../c-api/exceptions.rst:329 msgid "" "Similar to :c:func:`PyErr_SyntaxLocationObject`, but also sets the " "*end_lineno* and *end_col_offset* information for the current exception." msgstr "" +":c:func:`PyErr_SyntaxLocationObject` と同様ですが、現在の例外の *end_lineno* " +"と *end_col_offset* の情報も設定します。" #: ../../c-api/exceptions.rst:337 msgid "" @@ -457,24 +505,29 @@ msgstr "" "*message* は内部操作(例えば、Python/C API関数)が不正な引数とともに呼び出され" "たということを示しています。主に内部で使用するためのものです。" -#: ../../c-api/exceptions.rst:359 msgid "" "Get the source line in *filename* at line *lineno*. *filename* should be a " "Python :class:`str` object." msgstr "" +"*filename* の *lineno* 行目のソース行を取得します。\n" +"*filename* は Python の :class:`str` オブジェクトでなければなりません。" -#: ../../c-api/exceptions.rst:362 msgid "" "On success, this function returns a Python string object with the found " "line. On failure, this function returns ``NULL`` without an exception set." msgstr "" +"成功すると、見つかった行を格納する Python の文字列オブジェクトを返します。\n" +"失敗すると例外を設定せずに ``NULL`` を返します。" -#: ../../c-api/exceptions.rst:368 msgid "" "Similar to :c:func:`PyErr_ProgramTextObject`, but *filename* is a :c:expr:" "`const char *`, which is decoded with the :term:`filesystem encoding and " "error handler`, instead of a Python object reference." msgstr "" +":c:func:`PyErr_ProgramTextObject` と同様ですが、*filename* は Python オブジェ" +"クトへの参照ではなく、:term:`ファイルシステムのエンコーディングとエラーハンド" +"ラ ` でデコードする :c:expr:`const " +"char *` です。" #: ../../c-api/exceptions.rst:375 msgid "Issuing warnings" @@ -509,7 +562,6 @@ msgstr "" "例外が送出された場合、呼び出し元は通常の例外処理を行います (例えば、保持して" "いた参照に対し :c:func:`Py_DECREF` を行い、エラー値を返します)。" -#: ../../c-api/exceptions.rst:392 msgid "" "Issue a warning message. The *category* argument is a warning category (see " "below) or ``NULL``; the *message* argument is a UTF-8 encoded string. " @@ -518,12 +570,13 @@ msgid "" "stack frame. A *stack_level* of 1 is the function calling :c:func:" "`PyErr_WarnEx`, 2 is the function above that, and so forth." msgstr "" -"警告メッセージを発行します。 *category* 引数は警告カテゴリ(以下を参照) かまた" -"は ``NULL`` で、 *message* 引数は UTF-8 エンコードされた文字列です。 " -"*stacklevel* はスタックフレームの数を示す正の整数です; 警告はそのスタックフ" -"レームの中の実行している行から発行されます。 *stacklevel* が 1 だと :c:func:" -"`PyErr_WarnEx` を呼び出している関数が、2 だとその上の関数が Warning の発行元" -"になります。" +"警告メッセージを発行します。\n" +"*category* 引数は警告カテゴリ (後述) または ``NULL``、*message* 引数は UTF-8 " +"でエンコードされた文字列です。\n" +"*stack_level* はスタックフレーム数を指定する正の値で、そのフレームで現在実行" +"中のコードの行を発行元として警告を発行します。\n" +"*stack_level* が 1 なら :c:func:`PyErr_WarnEx` を呼び出す関数、2 ならその 1 " +"つ上の関数、というようになります。" #: ../../c-api/exceptions.rst:399 msgid "" @@ -572,26 +625,32 @@ msgstr "" "イルシステムのエンコーディングとエラーハンドラ ` でデコードされます。" -#: ../../c-api/exceptions.rst:430 msgid "" "Function similar to :c:func:`PyErr_WarnEx`, but uses :c:func:" "`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" "encoded string." msgstr "" +":c:func:`PyErr_WarnEx` と同様の関数ですが、警告メッセージの書式化に :c:func:" +"`PyUnicode_FromFormat` を使います。\n" +"*format* は ASCII でエンコードされた文字列です。" -#: ../../c-api/exceptions.rst:439 msgid "" "Similar to :c:func:`PyErr_WarnExplicit`, but uses :c:func:" "`PyUnicode_FromFormat` to format the warning message. *format* is an ASCII-" "encoded string." msgstr "" +":c:func:`PyErr_WarnExplicit` と同様ですが、警告メッセージの書式化に :c:func:" +"`PyUnicode_FromFormat` を使います。\n" +"*format* は ASCII でエンコードされた文字列です。" -#: ../../c-api/exceptions.rst:448 msgid "" "Function similar to :c:func:`PyErr_WarnFormat`, but *category* is :exc:" "`ResourceWarning` and it passes *source* to :class:`!warnings." "WarningMessage`." msgstr "" +":c:func:`PyErr_WarnFormat` と同様の関数ですが、*category* は :exc:" +"`ResourceWarning` で、*source* を :class:`!warnings.WarningMessage` に渡しま" +"す。" #: ../../c-api/exceptions.rst:455 msgid "Querying the error indicator" @@ -611,9 +670,10 @@ msgstr "" "します。あなたは戻り値への参照を持っていませんので、それに :c:func:" "`Py_DECREF` する必要はありません。" -#: ../../c-api/exceptions.rst:465 msgid "The caller must have an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" #: ../../c-api/exceptions.rst:469 msgid "" @@ -688,30 +748,30 @@ msgstr "" " PyErr_SetRaisedException(exc);\n" "}" -#: ../../c-api/exceptions.rst:508 msgid "" ":c:func:`PyErr_GetHandledException`, to save the exception currently being " "handled." msgstr "" +"現在処理中の例外を保存するには :c:func:`PyErr_GetHandledException` を使いま" +"す。" -#: ../../c-api/exceptions.rst:516 msgid "" "Set *exc* as the exception currently being raised, clearing the existing " "exception if one is set. If *exc* is ``NULL``, just clear the existing " "exception." msgstr "" +"既存の例外が設定されていればクリアし、現在送出中の例外に *exc* を設定しま" +"す。\n" +"*exc* が ``NULL`` の場合は、既存の例外をクリアするだけです。" -#: ../../c-api/exceptions.rst:520 msgid "*exc* must be a valid exception or ``NULL``." -msgstr "" +msgstr "*exc* は有効な例外または ``NULL`` でなければなりません。" -#: ../../c-api/exceptions.rst:522 msgid "This call \":term:`steals `\" a reference to *exc*." -msgstr "" +msgstr "この呼び出しは *exc* への参照を「:term:`盗みます `」。" -#: ../../c-api/exceptions.rst:531 msgid "Use :c:func:`PyErr_GetRaisedException` instead." -msgstr "" +msgstr "代わりに :c:func:`PyErr_GetRaisedException` を使ってください。" #: ../../c-api/exceptions.rst:533 msgid "" @@ -727,13 +787,13 @@ msgstr "" "れのオブジェクトへの参照を持つことになります。型オブジェクトが ``NULL`` でな" "いときでさえ、その値とトレースバックオブジェクトは ``NULL`` かもしれません。" -#: ../../c-api/exceptions.rst:540 msgid "" "This function is normally only used by legacy code that needs to catch " "exceptions or save and restore the error indicator temporarily." msgstr "" +"通常、この関数を使うのは、例外の捕捉やエラーインジケータの一時的な保存と復元" +"が必要な従来のコードだけです。" -#: ../../c-api/exceptions.rst:545 msgid "" "{\n" " PyObject *type, *value, *traceback;\n" @@ -744,12 +804,18 @@ msgid "" " PyErr_Restore(type, value, traceback);\n" "}" msgstr "" +"{\n" +" PyObject *type, *value, *traceback;\n" +" PyErr_Fetch(&type, &value, &traceback);\n" +"\n" +" /* ... 他のエラーを発生させる可能性があるコード ... */\n" +"\n" +" PyErr_Restore(type, value, traceback);\n" +"}" -#: ../../c-api/exceptions.rst:559 msgid "Use :c:func:`PyErr_SetRaisedException` instead." -msgstr "" +msgstr "代わりに :c:func:`PyErr_SetRaisedException` を使ってください。" -#: ../../c-api/exceptions.rst:561 msgid "" "Set the error indicator from the three objects, *type*, *value*, and " "*traceback*, clearing the existing exception if one is set. If the objects " @@ -761,19 +827,36 @@ msgid "" "the call you no longer own these references. (If you don't understand this, " "don't use this function. I warned you.)" msgstr "" +"3 つのオブジェクト *type*、*value*、*traceback* からエラーインジケータを設定" +"し、既存の例外が設定されていればクリアします。\n" +"これらのオブジェクトが ``NULL`` の場合はエラーインジケータをクリアします。\n" +"``NULL`` の型と、``NULL`` でない値やトレースバックを組み合わせて渡してはいけ" +"ません。\n" +"例外の型はクラスでなければなりません。\n" +"無効な例外の型や値を渡してはいけません (これらの規則を破ると、後で気づきにく" +"い問題を引き起こします)。\n" +"この呼び出しは各オブジェクトへの参照を奪います。\n" +"呼び出し前には各オブジェクトへの参照を所有している必要があり、呼び出し後には" +"それらの参照を所有しなくなります。\n" +"(この意味が分からない場合は、この関数を使わないでください。\n" +"十分に注意してください。)" -#: ../../c-api/exceptions.rst:575 msgid "" "This function is normally only used by legacy code that needs to save and " "restore the error indicator temporarily. Use :c:func:`PyErr_Fetch` to save " "the current error indicator." msgstr "" +"通常、この関数を使うのは、エラーインジケータの一時的な保存と復元が必要な従来" +"のコードだけです。\n" +"現在のエラーインジケータを保存するには :c:func:`PyErr_Fetch` を使ってくださ" +"い。" -#: ../../c-api/exceptions.rst:584 msgid "" "Use :c:func:`PyErr_GetRaisedException` instead, to avoid any possible de-" "normalization." msgstr "" +"正規化が失われる可能性を避けるため、代わりに :c:func:" +"`PyErr_GetRaisedException` を使ってください。" #: ../../c-api/exceptions.rst:587 msgid "" @@ -791,27 +874,35 @@ msgstr "" "は何も起きません。遅延正規化はパフォーマンスを改善するために実装されていま" "す。" -#: ../../c-api/exceptions.rst:595 msgid "" "This function *does not* implicitly set the :attr:`~BaseException." "__traceback__` attribute on the exception value. If setting the traceback " "appropriately is desired, the following additional snippet is needed::" msgstr "" +"この関数は、例外の値に :attr:`~BaseException.__traceback__` 属性を暗黙に設定" +"することは *ありません*。\n" +"トレースバックを適切に設定するには、次のコードを追加する必要があります。 ::" -#: ../../c-api/exceptions.rst:600 msgid "" "if (tb != NULL) {\n" " PyException_SetTraceback(val, tb);\n" "}" msgstr "" +"if (tb != NULL) {\n" +" PyException_SetTraceback(val, tb);\n" +"}" -#: ../../c-api/exceptions.rst:607 msgid "" "Retrieve the active exception instance, as would be returned by :func:`sys." "exception`. This refers to an exception that was *already caught*, not to an " "exception that was freshly raised. Returns a new reference to the exception " "or ``NULL``. Does not modify the interpreter's exception state." msgstr "" +":func:`sys.exception` が返すような、現在有効な例外インスタンスを取得しま" +"す。\n" +"これは新たに送出された例外ではなく、*すでに捕捉された* 例外を指します。\n" +"例外への新しい参照、または ``NULL`` を返します。\n" +"インタープリタの例外状態は変更しません。" #: ../../c-api/exceptions.rst:614 msgid "" @@ -825,12 +916,14 @@ msgstr "" "例外の状態を元に戻す、もしくはクリアするには :c:func:" "`PyErr_SetHandledException` を使ってください。" -#: ../../c-api/exceptions.rst:623 msgid "" "Set the active exception, as known from ``sys.exception()``. This refers to " "an exception that was *already caught*, not to an exception that was freshly " "raised. To clear the exception state, pass ``NULL``." msgstr "" +"``sys.exception()`` で得られる、現在有効な例外を設定します。\n" +"これは新たに送出された例外ではなく、*すでに捕捉された* 例外を指します。\n" +"例外状態をクリアするには ``NULL`` を渡してください。" #: ../../c-api/exceptions.rst:630 msgid "" @@ -844,7 +937,6 @@ msgstr "" "例外の状態を取得するには :c:func:`PyErr_GetHandledException` を使ってくださ" "い。" -#: ../../c-api/exceptions.rst:639 msgid "" "Retrieve the old-style representation of the exception info, as known from :" "func:`sys.exc_info`. This refers to an exception that was *already caught*, " @@ -853,6 +945,13 @@ msgid "" "info state. This function is kept for backwards compatibility. Prefer " "using :c:func:`PyErr_GetHandledException`." msgstr "" +":func:`sys.exc_info` で得られる、従来の形式の例外情報を取得します。\n" +"これは新たに送出された例外ではなく、*すでに捕捉された* 例外を指します。\n" +"3 つのオブジェクトへの新しい参照を返しますが、いずれも ``NULL`` の場合があり" +"ます。\n" +"例外情報の状態は変更しません。\n" +"この関数は後方互換性のために残されています。\n" +":c:func:`PyErr_GetHandledException` を使うことを推奨します。" #: ../../c-api/exceptions.rst:648 msgid "" @@ -866,7 +965,6 @@ msgstr "" "例外の状態を元に戻す、もしくはクリアするには :c:func:`PyErr_SetExcInfo` を" "使ってください。" -#: ../../c-api/exceptions.rst:658 msgid "" "Set the exception info, as known from ``sys.exc_info()``. This refers to an " "exception that was *already caught*, not to an exception that was freshly " @@ -875,6 +973,12 @@ msgid "" "arguments. This function is kept for backwards compatibility. Prefer using :" "c:func:`PyErr_SetHandledException`." msgstr "" +"``sys.exc_info()`` で得られる例外情報を設定します。\n" +"これは新たに送出された例外ではなく、*すでに捕捉された* 例外を指します。\n" +"この関数は引数の参照を「:term:`盗みます `」。\n" +"例外状態をクリアするには、3 つの引数すべてに ``NULL`` を渡してください。\n" +"この関数は後方互換性のために残されています。\n" +":c:func:`PyErr_SetHandledException` を使うことを推奨します。" #: ../../c-api/exceptions.rst:668 msgid "" @@ -887,110 +991,125 @@ msgstr "" "外の状態を一時的に保存し、元に戻す必要があるコードで使用することができます。" "例外の状態を取得するには :c:func:`PyErr_GetExcInfo` を使ってください。" -#: ../../c-api/exceptions.rst:675 msgid "" "The ``type`` and ``traceback`` arguments are no longer used and can be NULL. " "The interpreter now derives them from the exception instance (the ``value`` " "argument). The function still \":term:`steals `\" references of all " "three arguments." msgstr "" +"``type`` 引数と ``traceback`` 引数は使われなくなり、``NULL`` にできます。\n" +"インタープリタはこれらを例外インスタンス (``value`` 引数) から取得するように" +"なりました。\n" +"この関数は引き続き 3 つの引数すべての参照を「:term:`盗みます `」。" #: ../../c-api/exceptions.rst:683 msgid "Signal Handling" msgstr "シグナルハンドリング" -#: ../../c-api/exceptions.rst:693 msgid "" "Handle external interruptions, such as signals or activating a debugger, " "whose processing has been delayed until it is safe to run Python code and/or " "raise exceptions." msgstr "" +"シグナルやデバッガの起動など、Python コードの実行や例外の送出が安全になるまで" +"処理を遅らせていた外部からの割り込みを処理します。" -#: ../../c-api/exceptions.rst:697 msgid "" "For example, pressing :kbd:`Ctrl-C` causes a terminal to send the :py:data:" "`signal.SIGINT` signal. This function executes the corresponding Python " "signal handler, which, by default, raises the :exc:`KeyboardInterrupt` " "exception." msgstr "" +"例えば :kbd:`Ctrl-C` を押すと、端末は :py:data:`signal.SIGINT` シグナルを送信" +"します。\n" +"この関数は対応する Python のシグナルハンドラを実行します。\n" +"デフォルトでは :exc:`KeyboardInterrupt` 例外を送出します。" -#: ../../c-api/exceptions.rst:702 msgid "" ":c:func:`!PyErr_CheckSignals` should be called by long-running C code " "frequently enough so that the response appears immediate to humans." msgstr "" +"長時間実行する C コードは、人間にとって即座に応答したように見える程度の頻度" +"で :c:func:`!PyErr_CheckSignals` を呼び出す必要があります。" -#: ../../c-api/exceptions.rst:705 msgid "Handlers invoked by this function currently include:" -msgstr "" +msgstr "現在、この関数が呼び出すハンドラには以下があります:" -#: ../../c-api/exceptions.rst:707 msgid "" "Signal handlers, including Python functions registered using the :mod:" "`signal` module." -msgstr "" +msgstr ":mod:`signal` モジュールで登録した Python 関数などのシグナルハンドラ。" -#: ../../c-api/exceptions.rst:710 msgid "" "Signal handlers are only run in the main thread of the main interpreter." msgstr "" +"シグナルハンドラを実行するのは、メインインタープリタのメインスレッドだけで" +"す。" -#: ../../c-api/exceptions.rst:712 msgid "" "(This is where the function got the name: originally, signals were the only " "way to interrupt the interpreter.)" msgstr "" +"(これが関数名の由来です。\n" +"もともと、インタープリタに割り込む方法はシグナルだけでした。)" -#: ../../c-api/exceptions.rst:715 msgid "Running the garbage collector, if necessary." -msgstr "" +msgstr "必要に応じてガベージコレクタを実行します。" -#: ../../c-api/exceptions.rst:717 msgid "Executing a pending :ref:`remote debugger ` script." msgstr "" +"実行待ちの :ref:`リモートデバッガ ` スクリプトを実行しま" +"す。" -#: ../../c-api/exceptions.rst:719 msgid "Raise the exception set by :c:func:`PyThreadState_SetAsyncExc`." -msgstr "" +msgstr ":c:func:`PyThreadState_SetAsyncExc` で設定された例外を送出します。" -#: ../../c-api/exceptions.rst:721 msgid "" "If any handler raises an exception, immediately return ``-1`` with that " "exception set. Any remaining interruptions are left to be processed on the " "next :c:func:`PyErr_CheckSignals()` invocation, if appropriate." msgstr "" +"いずれかのハンドラが例外を送出すると、その例外を設定して直ちに ``-1`` を返し" +"ます。\n" +"残りの割り込みは、適切であれば次回の :c:func:`PyErr_CheckSignals()` の呼び出" +"しで処理するために残します。" -#: ../../c-api/exceptions.rst:726 msgid "" "If all handlers finish successfully, or there are no handlers to run, return " "``0``." msgstr "" +"すべてのハンドラが正常に終了した場合や、実行するハンドラがない場合は ``0`` を" +"返します。" -#: ../../c-api/exceptions.rst:729 msgid "This function may now invoke the garbage collector." -msgstr "" +msgstr "この関数がガベージコレクタを呼び出す場合があるようになりました。" -#: ../../c-api/exceptions.rst:732 msgid "" "This function may now execute a remote debugger script, if remote debugging " "is enabled." msgstr "" +"リモートデバッグが有効な場合、この関数がリモートデバッガのスクリプトを実行す" +"る場合があるようになりました。" -#: ../../c-api/exceptions.rst:736 msgid "The exception set by :c:func:`PyThreadState_SetAsyncExc` is now raised." msgstr "" +":c:func:`PyThreadState_SetAsyncExc` で設定された例外を送出するようになりまし" +"た。" -#: ../../c-api/exceptions.rst:747 msgid "" "Simulate the effect of a :c:macro:`!SIGINT` signal arriving. This is " "equivalent to ``PyErr_SetInterruptEx(SIGINT)``." msgstr "" +":c:macro:`!SIGINT` シグナルが到達したときの効果をシミュレートします。\n" +"``PyErr_SetInterruptEx(SIGINT)`` と等価です。" -#: ../../c-api/exceptions.rst:751 ../../c-api/exceptions.rst:778 msgid "" "This function is async-signal-safe. It can be called without an :term:" "`attached thread state` and from a C signal handler." msgstr "" +"この関数は非同期シグナルセーフです。\n" +":term:`アタッチされたスレッド状態 ` なしでも、C のシグ" +"ナルハンドラからでも呼び出せます。" #: ../../c-api/exceptions.rst:761 msgid "" @@ -1002,26 +1121,32 @@ msgstr "" "次に :c:func:`PyErr_CheckSignals` が呼ばれたとき、与えられたシグナル番号用の " "Python のシグナルハンドラが呼び出されます。" -#: ../../c-api/exceptions.rst:765 msgid "" "This function can be called by C code that sets up its own signal handling " "and wants Python signal handlers to be invoked as expected when an " "interruption is requested (for example when the user presses Ctrl-C to " "interrupt an operation)." msgstr "" +"この関数は、独自のシグナル処理を設定し、割り込みが要求されたとき (例えばユー" +"ザーが Ctrl-C を押して操作を中断するとき) に、Python のシグナルハンドラを期待" +"どおりに呼び出したい C コードから使えます。" -#: ../../c-api/exceptions.rst:770 msgid "" "If the given signal isn't handled by Python (it was set to :py:const:`signal." "SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored." msgstr "" +"指定されたシグナルを Python が処理しない場合 (:py:const:`signal.SIG_DFL` また" +"は :py:const:`signal.SIG_IGN` が設定されている場合)、そのシグナルは無視しま" +"す。" -#: ../../c-api/exceptions.rst:773 msgid "" "If *signum* is outside of the allowed range of signal numbers, ``-1`` is " "returned. Otherwise, ``0`` is returned. The error indicator is never " "changed by this function." msgstr "" +"*signum* が許されるシグナル番号の範囲外の場合は ``-1`` を返します。\n" +"それ以外の場合は ``0`` を返します。\n" +"この関数がエラーインジケータを変更することはありません。" #: ../../c-api/exceptions.rst:786 msgid "" @@ -1055,7 +1180,6 @@ msgstr "Windowsで、この関数はソケットハンドルをサポートす msgid "Exception Classes" msgstr "例外クラス" -#: ../../c-api/exceptions.rst:804 msgid "" "This utility function creates and returns a new exception class. The *name* " "argument must be the name of the new exception, a C string of the form " @@ -1063,13 +1187,13 @@ msgid "" "``NULL``. This creates a class object derived from :exc:`Exception` " "(accessible in C as :c:data:`PyExc_Exception`)." msgstr "" -"このユーティリティ関数は新しい例外クラスを作成して返します。 *name* 引数は新" -"しい例外の名前、 ``module.classname`` 形式の C文字列でなければならない。 " -"*base* と *dict* 引数は通常 ``NULL`` です。これはすべての例外のためのルート、" -"組み込み名 :exc:`Exception` (Cでは :c:data:`PyExc_Exception` としてアクセス可" -"能)をルートとして派生したクラスオブジェクトを作成します。" +"このユーティリティ関数は、新しい例外クラスを作成して返します。\n" +"*name* 引数は新しい例外の名前で、``module.classname`` 形式の C 文字列でなけれ" +"ばなりません。\n" +"*base* 引数と *dict* 引数は通常 ``NULL`` です。\n" +"これにより :exc:`Exception` (C では :c:data:`PyExc_Exception` としてアクセス" +"できます) から派生したクラスオブジェクトを作成します。" -#: ../../c-api/exceptions.rst:810 msgid "" "The :attr:`~type.__module__` attribute of the new class is set to the first " "part (up to the last dot) of the *name* argument, and the class name is set " @@ -1078,6 +1202,12 @@ msgid "" "of classes. The *dict* argument can be used to specify a dictionary of class " "variables and methods." msgstr "" +"新しいクラスの :attr:`~type.__module__` 属性には *name* 引数の先頭部分 (最後" +"のドットまで) を設定し、クラス名には末尾の部分 (最後のドットの後) を設定しま" +"す。\n" +"*base* 引数を使うと別の基底クラスを指定でき、クラスを 1 つ、またはクラスのタ" +"プルを渡せます。\n" +"*dict* 引数を使うと、クラス変数とメソッドの辞書を指定できます。" #: ../../c-api/exceptions.rst:819 msgid "" @@ -1089,41 +1219,44 @@ msgstr "" "docstring を設定できます。 *doc* が ``NULL`` で無い場合、それが例外クラスの " "docstring になります。" -#: ../../c-api/exceptions.rst:828 msgid "" "Return non-zero if *ob* is an exception class, zero otherwise. This function " "always succeeds." msgstr "" +"*ob* が例外クラスならゼロ以外、それ以外ならゼロを返します。\n" +"この関数は常に成功します。" -#: ../../c-api/exceptions.rst:833 msgid "Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*." -msgstr "" +msgstr "例外クラス *ob* の :c:member:`~PyTypeObject.tp_name` を返します。" -#: ../../c-api/exceptions.rst:838 msgid "This is a macro including the base fields for an exception object." -msgstr "" +msgstr "例外オブジェクトの基本的なフィールドを含むマクロです。" -#: ../../c-api/exceptions.rst:841 msgid "" "This was included in Python's C API by mistake and is not designed for use " "in extensions. For creating custom exception objects, use :c:func:" "`PyErr_NewException` or otherwise create a class inheriting from :c:data:" "`PyExc_BaseException`." msgstr "" +"これは誤って Python の C API に含まれたもので、拡張モジュールで使うための設計" +"にはなっていません。\n" +"独自の例外オブジェクトを作成するには、:c:func:`PyErr_NewException` を使うか、" +"他の方法で :c:data:`PyExc_BaseException` を継承するクラスを作成してください。" #: ../../c-api/exceptions.rst:850 msgid "Exception Objects" msgstr "例外オブジェクト" -#: ../../c-api/exceptions.rst:854 msgid "" "Return true if *op* is an instance of :class:`BaseException`, false " "otherwise. This function always succeeds." msgstr "" +"*op* が :class:`BaseException` のインスタンスなら真、それ以外なら偽を返しま" +"す。\n" +"この関数は常に成功します。" -#: ../../c-api/exceptions.rst:860 msgid "Equivalent to :c:func:`Py_TYPE(op) `." -msgstr "" +msgstr ":c:func:`Py_TYPE(op) ` と等価です。" #: ../../c-api/exceptions.rst:865 msgid "" @@ -1143,20 +1276,27 @@ msgstr "" "その例外に関する traceback に *tb* をセットします。クリアするには " "``Py_None`` を使用してください。" -#: ../../c-api/exceptions.rst:879 msgid "" "Return the context (another exception instance during whose handling *ex* " "was raised) associated with the exception as a new reference, as accessible " "from Python through the :attr:`~BaseException.__context__` attribute. If " "there is no context associated, this returns ``NULL``." msgstr "" +"例外に関連づけられたコンテキスト (*ex* が送出された時点で処理中だった別の例外" +"インスタンス) への新しい参照を返します。\n" +"Python の :attr:`~BaseException.__context__` 属性からアクセスできるものと同じ" +"です。\n" +"関連づけられたコンテキストがなければ ``NULL`` を返します。" -#: ../../c-api/exceptions.rst:887 msgid "" "Set the context associated with the exception to *ctx*. Use ``NULL`` to " "clear it. There is no type check to make sure that *ctx* is an exception " "instance. This \":term:`steals `\" a reference to *ctx*." msgstr "" +"例外に関連づけるコンテキストを *ctx* に設定します。\n" +"クリアするには ``NULL`` を使ってください。\n" +"*ctx* が例外インスタンスかどうかの型チェックは行いません。\n" +"この関数は *ctx* への参照を「:term:`盗みます `」。" #: ../../c-api/exceptions.rst:894 msgid "" @@ -1166,27 +1306,30 @@ msgid "" "attribute." msgstr "" -#: ../../c-api/exceptions.rst:902 msgid "" "Set the cause associated with the exception to *cause*. Use ``NULL`` to " "clear it. There is no type check to make sure that *cause* is either an " "exception instance or ``None``. This \":term:`steals `\" a reference " "to *cause*." msgstr "" +"例外に関連づける原因を *cause* に設定します。\n" +"クリアするには ``NULL`` を使ってください。\n" +"*cause* が例外インスタンスまたは ``None`` かどうかの型チェックは行いませ" +"ん。\n" +"この関数は *cause* への参照を「:term:`盗みます `」。" -#: ../../c-api/exceptions.rst:907 msgid "" "The :attr:`~BaseException.__suppress_context__` attribute is implicitly set " "to ``True`` by this function." msgstr "" +"この関数は :attr:`~BaseException.__suppress_context__` 属性を暗黙に ``True`` " +"に設定します。" -#: ../../c-api/exceptions.rst:913 msgid "Return :attr:`~BaseException.args` of exception *ex*." -msgstr "" +msgstr "例外 *ex* の :attr:`~BaseException.args` を返します。" -#: ../../c-api/exceptions.rst:918 msgid "Set :attr:`~BaseException.args` of exception *ex* to *args*." -msgstr "" +msgstr "例外 *ex* の :attr:`~BaseException.args` を *args* に設定します。" #: ../../c-api/exceptions.rst:922 msgid "" @@ -1239,27 +1382,30 @@ msgstr "" "*start* は ``NULL`` であってはなりません。成功したら ``0`` を、失敗したら " "``-1`` を返します。" -#: ../../c-api/exceptions.rst:965 msgid "" "If the :attr:`UnicodeError.object` is an empty sequence, the resulting " "*start* is ``0``. Otherwise, it is clipped to ``[0, len(object) - 1]``." msgstr "" +":attr:`UnicodeError.object` が空のシーケンスであれば、結果の *start* は " +"``0`` です。\n" +"それ以外の場合は ``[0, len(object) - 1]`` の範囲に収まるように調整します。" -#: ../../c-api/exceptions.rst:968 msgid ":attr:`UnicodeError.start`" -msgstr "" +msgstr ":attr:`UnicodeError.start`" -#: ../../c-api/exceptions.rst:974 msgid "" "Set the *start* attribute of the given exception object to *start*. Return " "``0`` on success, ``-1`` on failure." msgstr "" +"指定された例外オブジェクトの *start* 属性を *start* に設定します。\n" +"成功すると ``0``、失敗すると ``-1`` を返します。" -#: ../../c-api/exceptions.rst:979 msgid "" "While passing a negative *start* does not raise an exception, the " "corresponding getters will not consider it as a relative offset." msgstr "" +"負の *start* を渡しても例外は送出しませんが、対応する取得関数はそれを相対オフ" +"セットとして扱いません。" #: ../../c-api/exceptions.rst:987 msgid "" @@ -1271,11 +1417,13 @@ msgstr "" "*end* は ``NULL`` であってはなりません。成功したら ``0`` を、失敗したら " "``-1`` を返します。" -#: ../../c-api/exceptions.rst:991 msgid "" "If the :attr:`UnicodeError.object` is an empty sequence, the resulting *end* " "is ``0``. Otherwise, it is clipped to ``[1, len(object)]``." msgstr "" +":attr:`UnicodeError.object` が空のシーケンスであれば、結果の *end* は ``0`` " +"です。\n" +"それ以外の場合は ``[1, len(object)]`` の範囲に収まるように調整します。" #: ../../c-api/exceptions.rst:998 msgid "" @@ -1285,9 +1433,8 @@ msgstr "" "渡された例外オブジェクトの *end* 属性を *end* に設定します。成功したら ``0`` " "を、失敗したら ``-1`` を返します。" -#: ../../c-api/exceptions.rst:1001 msgid ":attr:`UnicodeError.end`" -msgstr "" +msgstr ":attr:`UnicodeError.end`" #: ../../c-api/exceptions.rst:1007 msgid "Return the *reason* attribute of the given exception object." @@ -1305,7 +1452,6 @@ msgstr "" msgid "Recursion Control" msgstr "再帰の管理" -#: ../../c-api/exceptions.rst:1022 msgid "" "These two functions provide a way to perform safe recursive calls at the C " "level, both in the core and in extension modules. They are needed if the " @@ -1314,24 +1460,34 @@ msgid "" "implementations because the :ref:`call protocol ` takes care of " "recursion handling." msgstr "" +"次の 2 つの関数は、コアと拡張モジュールの両方で、C レベルの再帰呼び出しを安全" +"に行う方法を提供します。\n" +"再帰するコードが、再帰の深さを自動的に追跡する Python コードを必ずしも呼び出" +"さない場合に必要です。\n" +"また、*tp_call* の実装では :ref:`呼び出しプロトコル ` が再帰を管理する" +"ため、これらの関数は不要です。" #: ../../c-api/exceptions.rst:1031 msgid "Marks a point where a recursive C-level call is about to be performed." msgstr "C レベルの再帰呼び出しをしようとしているところに印を付けます。" -#: ../../c-api/exceptions.rst:1033 msgid "" "The function then checks if the stack limit is reached. If this is the " "case, a :exc:`RecursionError` is set and a nonzero value is returned. " "Otherwise, zero is returned." msgstr "" +"この関数はスタックの上限に達したか確認します。\n" +"達していれば :exc:`RecursionError` を設定し、ゼロ以外の値を返します。\n" +"それ以外の場合はゼロを返します。" -#: ../../c-api/exceptions.rst:1037 msgid "" "The check is based on the remaining C stack space of the current thread, not " "on a count of calls, so it is unaffected by :c:func:`Py_SetRecursionLimit` " "and :func:`sys.setrecursionlimit`." msgstr "" +"この検査は呼び出し回数ではなく、現在のスレッドの C スタックの残り領域に基づく" +"ため、:c:func:`Py_SetRecursionLimit` や :func:`sys.setrecursionlimit` の影響" +"を受けません。" #: ../../c-api/exceptions.rst:1041 msgid "" @@ -1343,21 +1499,22 @@ msgstr "" "して、再帰の深さの限界に達したことで送出される :exc:`RecursionError` のメッ" "セージに連結できるようにすべきです。" -#: ../../c-api/exceptions.rst:1046 msgid "The :c:func:`PyUnstable_ThreadState_SetStackProtection` function." -msgstr "" +msgstr ":c:func:`PyUnstable_ThreadState_SetStackProtection` 関数。" -#: ../../c-api/exceptions.rst:1048 ../../c-api/exceptions.rst:1060 msgid "" "This function is now also available in the :ref:`limited API `." msgstr "" +"この関数が :ref:`制限付き API ` でも利用できるようになりまし" +"た。" -#: ../../c-api/exceptions.rst:1051 msgid "" "The check is based on the remaining C stack space. Previously, a separate " "counter of C-level calls was used." msgstr "" +"この検査は C スタックの残り領域に基づくようになりました。\n" +"以前は C レベルの呼び出し回数を数える別のカウンタを使っていました。" #: ../../c-api/exceptions.rst:1057 msgid "" @@ -1368,7 +1525,6 @@ msgstr "" "`Py_EnterRecursiveCall` の *成功した* 呼び出しに対し 1 回呼ばなければなりませ" "ん。" -#: ../../c-api/exceptions.rst:1063 msgid "" "Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types " "requires special recursion handling. In addition to protecting the stack, :" @@ -1376,6 +1532,12 @@ msgid "" "cycles. The following two functions facilitate this functionality. " "Effectively, these are the C equivalent to :deco:`reprlib.recursive_repr`." msgstr "" +"コンテナ型の :c:member:`~PyTypeObject.tp_repr` を正しく実装するには、特別な再" +"帰処理が必要です。\n" +":c:member:`~PyTypeObject.tp_repr` はスタックを保護するだけでなく、循環を防ぐ" +"ためにオブジェクトも追跡する必要があります。\n" +"次の 2 つの関数はこの機能の実装を助けます。\n" +"実質的に、:deco:`reprlib.recursive_repr` の C 版に相当します。" #: ../../c-api/exceptions.rst:1071 msgid "" @@ -1422,67 +1584,63 @@ msgstr "" ":c:func:`Py_ReprEnter` を終了させます。 0 を返した :c:func:`Py_ReprEnter` の" "呼び出しに対し 1 回呼ばなければなりません。" -#: ../../c-api/exceptions.rst:1094 msgid "" "Get the recursion limit for the current interpreter. It can be set with :c:" "func:`Py_SetRecursionLimit`. The recursion limit prevents the Python " "interpreter stack from growing infinitely." msgstr "" +"現在のインタープリタの再帰の上限を取得します。\n" +"この上限は :c:func:`Py_SetRecursionLimit` で設定できます。\n" +"再帰の上限は、Python インタープリタのスタックが無限に大きくなることを防ぎま" +"す。" -#: ../../c-api/exceptions.rst:1098 ../../c-api/exceptions.rst:1108 msgid "" "This function cannot fail, and the caller must hold an :term:`attached " "thread state`." msgstr "" +"この関数は失敗しません。\n" +"呼び出し側には :term:`アタッチされたスレッド状態 ` が" +"必要です。" -#: ../../c-api/exceptions.rst:1102 msgid ":py:func:`sys.getrecursionlimit`" -msgstr "" +msgstr ":py:func:`sys.getrecursionlimit`" -#: ../../c-api/exceptions.rst:1106 msgid "Set the recursion limit for the current interpreter." -msgstr "" +msgstr "現在のインタープリタの再帰の上限を設定します。" -#: ../../c-api/exceptions.rst:1112 msgid ":py:func:`sys.setrecursionlimit`" -msgstr "" +msgstr ":py:func:`sys.setrecursionlimit`" -#: ../../c-api/exceptions.rst:1117 msgid "Exception and warning types" -msgstr "" +msgstr "例外と警告の型" -#: ../../c-api/exceptions.rst:1119 msgid "" "All standard Python exceptions and warning categories are available as " "global variables whose names are ``PyExc_`` followed by the Python exception " "name. These have the type :c:expr:`PyObject*`; they are all class objects." msgstr "" +"Python のすべての標準の例外と警告カテゴリは、``PyExc_`` に Python の例外名を" +"続けた名前のグローバル変数として利用できます。\n" +"これらの型は :c:expr:`PyObject*` で、すべてクラスオブジェクトです。" -#: ../../c-api/exceptions.rst:1123 msgid "For completeness, here are all the variables:" -msgstr "" +msgstr "すべての変数を以下に示します:" -#: ../../c-api/exceptions.rst:1126 msgid "Exception types" -msgstr "" +msgstr "例外の型" -#: ../../c-api/exceptions.rst:1133 ../../c-api/exceptions.rst:1281 -#: ../../c-api/exceptions.rst:1311 msgid "C name" -msgstr "" +msgstr "C での名前" -#: ../../c-api/exceptions.rst:1134 ../../c-api/exceptions.rst:1282 -#: ../../c-api/exceptions.rst:1312 msgid "Python name" -msgstr "" +msgstr "Python での名前" #: ../../c-api/exceptions.rst:1136 msgid ":exc:`BaseException`" msgstr ":exc:`BaseException`" -#: ../../c-api/exceptions.rst:1138 msgid ":exc:`BaseExceptionGroup`" -msgstr "" +msgstr ":exc:`BaseExceptionGroup`" #: ../../c-api/exceptions.rst:1140 msgid ":exc:`Exception`" @@ -1552,9 +1710,8 @@ msgstr ":exc:`FloatingPointError`" msgid ":exc:`GeneratorExit`" msgstr ":exc:`GeneratorExit`" -#: ../../c-api/exceptions.rst:1174 msgid ":exc:`ImportCycleError`" -msgstr "" +msgstr ":exc:`ImportCycleError`" #: ../../c-api/exceptions.rst:1176 msgid ":exc:`ImportError`" @@ -1730,43 +1887,39 @@ msgstr "" msgid ":c:data:`PyExc_ModuleNotFoundError`." msgstr ":c:data:`PyExc_ModuleNotFoundError`." -#: ../../c-api/exceptions.rst:1264 msgid ":c:data:`PyExc_BaseExceptionGroup`." -msgstr "" +msgstr ":c:data:`PyExc_BaseExceptionGroup`." -#: ../../c-api/exceptions.rst:1269 msgid "OSError aliases" -msgstr "" +msgstr "OSError の別名" -#: ../../c-api/exceptions.rst:1271 msgid "The following are a compatibility aliases to :c:data:`PyExc_OSError`." -msgstr "" +msgstr "以下は互換性のための :c:data:`PyExc_OSError` の別名です。" -#: ../../c-api/exceptions.rst:1273 msgid "These aliases used to be separate exception types." -msgstr "これらのエイリアスは例外の種類を分けるために使われます。" +msgstr "これらの別名は、以前はそれぞれ独立した例外型でした。" #: ../../c-api/exceptions.rst:1283 msgid "Notes" msgstr "注釈" -#: ../../c-api/exceptions.rst:1292 msgid "[win]_" -msgstr "" +msgstr "[win]_" #: ../../c-api/exceptions.rst:1294 msgid "Notes:" msgstr "注釈:" -#: ../../c-api/exceptions.rst:1297 msgid "" ":c:var:`!PyExc_WindowsError` is only defined on Windows; protect code that " "uses this by testing that the preprocessor macro ``MS_WINDOWS`` is defined." msgstr "" +":c:var:`!PyExc_WindowsError` は Windows でのみ定義されます。\n" +"これを使うコードは、プリプロセッサマクロ ``MS_WINDOWS`` が定義されているか検" +"査して保護してください。" -#: ../../c-api/exceptions.rst:1304 msgid "Warning types" -msgstr "" +msgstr "警告の型" #: ../../c-api/exceptions.rst:1314 msgid ":exc:`Warning`" @@ -1780,9 +1933,8 @@ msgstr ":exc:`BytesWarning`" msgid ":exc:`DeprecationWarning`" msgstr ":exc:`DeprecationWarning`" -#: ../../c-api/exceptions.rst:1320 msgid ":exc:`EncodingWarning`" -msgstr "" +msgstr ":exc:`EncodingWarning`" #: ../../c-api/exceptions.rst:1322 msgid ":exc:`FutureWarning`" @@ -1820,53 +1972,51 @@ msgstr ":exc:`UserWarning`" msgid ":c:data:`PyExc_ResourceWarning`." msgstr ":c:data:`PyExc_ResourceWarning`." -#: ../../c-api/exceptions.rst:1341 msgid ":c:data:`PyExc_EncodingWarning`." -msgstr "" +msgstr ":c:data:`PyExc_EncodingWarning`." -#: ../../c-api/exceptions.rst:1346 msgid "Tracebacks" -msgstr "" +msgstr "トレースバック" -#: ../../c-api/exceptions.rst:1350 msgid "" "Type object for traceback objects. This is available as :class:`types." "TracebackType` in the Python layer." msgstr "" +"トレースバックオブジェクトの型オブジェクトです。\n" +"Python レイヤでは :class:`types.TracebackType` として利用できます。" -#: ../../c-api/exceptions.rst:1356 msgid "" "Return true if *op* is a traceback object, false otherwise. This function " "does not account for subtypes." msgstr "" +"*op* がトレースバックオブジェクトなら真、それ以外なら偽を返します。\n" +"この関数はサブタイプを考慮しません。" -#: ../../c-api/exceptions.rst:1362 msgid "" "Replace the :attr:`~BaseException.__traceback__` attribute on the current " "exception with a new traceback prepending *f* to the existing chain." msgstr "" +"現在の例外の :attr:`~BaseException.__traceback__` 属性を、既存の連鎖の先頭に " +"*f* を追加した新しいトレースバックに置き換えます。" -#: ../../c-api/exceptions.rst:1365 msgid "Calling this function without an exception set is undefined behavior." -msgstr "" +msgstr "例外が設定されていない状態でこの関数を呼び出すと、動作は未定義です。" -#: ../../c-api/exceptions.rst:1367 ../../c-api/exceptions.rst:1375 msgid "" "This function returns ``0`` on success, and returns ``-1`` with an exception " "set on failure." -msgstr "" +msgstr "成功時は ``0`` を返し、失敗時は例外を設定して ``-1`` を返します。" -#: ../../c-api/exceptions.rst:1373 msgid "Write the traceback *tb* into the file *f*." -msgstr "" +msgstr "トレースバック *tb* をファイル *f* に書き込みます。" -#: ../../c-api/exceptions.rst:1380 msgid "" "Write a trace of the Python stack in *tstate* into the file *fd*. The " "format looks like::" msgstr "" +"*tstate* の Python スタックのトレースをファイル *fd* に書き込みます。\n" +"形式は次のようになります。 ::" -#: ../../c-api/exceptions.rst:1383 msgid "" "Traceback (most recent call first):\n" " File \"xxx\", line xxx in \n" @@ -1874,46 +2024,61 @@ msgid "" " ...\n" " File \"xxx\", line xxx in " msgstr "" +"Traceback (most recent call first):\n" +" File \"xxx\", line xxx in \n" +" File \"xxx\", line xxx in \n" +" ...\n" +" File \"xxx\", line xxx in " -#: ../../c-api/exceptions.rst:1389 msgid "" "This function is meant to debug situations such as segfaults, fatal errors, " "and similar. The file and function names it outputs are encoded to ASCII " "with backslashreplace and truncated to 500 characters. It writes only the " "first 100 frames; further frames are truncated with the line ``...``." msgstr "" +"この関数は、セグメンテーション違反や致命的なエラーなどの状況をデバッグするた" +"めのものです。\n" +"出力するファイル名と関数名は backslashreplace で ASCII にエンコードし、500 文" +"字で切り詰めます。\n" +"最初の 100 フレームだけを書き込み、それ以降のフレームは ``...`` という行で省" +"略します。" -#: ../../c-api/exceptions.rst:1394 ../../c-api/exceptions.rst:1419 msgid "" "This function will return ``NULL`` on success, or an error message on error." msgstr "" +"この関数は成功すると ``NULL``、エラー時にはエラーメッセージを返します。" -#: ../../c-api/exceptions.rst:1396 ../../c-api/exceptions.rst:1427 msgid "" "This function is intended for use in crash scenarios such as signal handlers " "for SIGSEGV, where the interpreter may be in an inconsistent state. Given " "that it reads interpreter data structures that may be partially modified, " "the function might produce incomplete output or it may even crash itself." msgstr "" +"この関数は、インタープリタが不整合な状態になっている可能性のある、SIGSEGV の" +"シグナルハンドラなどのクラッシュ時の状況で使うことを想定しています。\n" +"変更の途中かもしれないインタープリタのデータ構造を読み取るため、出力が不完全" +"になる可能性があり、関数自体がクラッシュすることもあります。" -#: ../../c-api/exceptions.rst:1401 msgid "" "The caller does not need to hold an :term:`attached thread state`, nor does " "*tstate* need to be attached." msgstr "" +"呼び出し側に :term:`アタッチされたスレッド状態 ` は不" +"要で、*tstate* がアタッチされている必要もありません。" -#: ../../c-api/exceptions.rst:1408 msgid "Write the traces of all Python threads in *interp* into the file *fd*." msgstr "" +"*interp* のすべての Python スレッドのトレースをファイル *fd* に書き込みます。" -#: ../../c-api/exceptions.rst:1410 msgid "" "If *interp* is ``NULL`` then this function will try to identify the current " "interpreter using thread-specific storage. If it cannot, it will return an " "error." msgstr "" +"*interp* が ``NULL`` の場合、この関数はスレッド固有の記憶域を使って現在のイン" +"タープリタの特定を試みます。\n" +"特定できなければエラーを返します。" -#: ../../c-api/exceptions.rst:1414 msgid "" "If *current_tstate* is not ``NULL`` then it will be used to identify what " "the current thread is in the written output. If it is ``NULL`` then this " @@ -1921,8 +2086,11 @@ msgid "" "is not an error if the function is unable to get the current Python thread " "state." msgstr "" +"*current_tstate* が ``NULL`` でなければ、出力内で現在のスレッドを示すために使" +"います。\n" +"``NULL`` の場合は、スレッド固有の記憶域を使って現在のスレッドを特定します。\n" +"現在の Python スレッド状態を取得できなくてもエラーにはなりません。" -#: ../../c-api/exceptions.rst:1421 msgid "" "This function is meant to debug situations such as segfaults, fatal errors, " "and similar. It calls :c:func:`PyUnstable_DumpTraceback` for each thread. It " @@ -1930,23 +2098,32 @@ msgid "" "output is truncated with the line ``...``. If *max_threads* is 0, the " "function will use a default value of 100 for the argument." msgstr "" +"この関数は、セグメンテーション違反や致命的なエラーなどの状況をデバッグするた" +"めのものです。\n" +"各スレッドについて :c:func:`PyUnstable_DumpTraceback` を呼び出します。\n" +"最初の *max_threads* 個のスレッドのトレースバックだけを書き込み、それ以降の出" +"力は ``...`` という行で省略します。\n" +"*max_threads* が 0 の場合は、この引数にデフォルト値の 100 を使います。" -#: ../../c-api/exceptions.rst:1432 msgid "" "The caller does not need to hold an :term:`attached thread state`, nor does " "*current_tstate* need to be attached." msgstr "" +"呼び出し側に :term:`アタッチされたスレッド状態 ` は不" +"要で、*current_tstate* がアタッチされている必要もありません。" -#: ../../c-api/exceptions.rst:1436 msgid "" "On the :term:`free-threaded build`, this function is not thread-safe. If " "another thread deletes its :term:`thread state` while this function is being " "called, the process will likely crash." msgstr "" +":term:`フリースレッドビルド ` では、この関数はスレッド" +"セーフではありません。\n" +"この関数の呼び出し中に別のスレッドが自身の :term:`スレッド状態 ` を削除すると、プロセスがクラッシュする可能性が高くなります。" -#: ../../c-api/exceptions.rst:198 msgid "strerror (C function)" -msgstr "" +msgstr "strerror (C 関数)" #: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 #: ../../c-api/exceptions.rst:757 @@ -1958,9 +2135,8 @@ msgstr "module" msgid "signal" msgstr "signal" -#: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 msgid "SIGINT (C macro)" -msgstr "" +msgstr "SIGINT (C マクロ)" #: ../../c-api/exceptions.rst:688 ../../c-api/exceptions.rst:742 #: ../../c-api/exceptions.rst:757 diff --git a/c-api/extension-modules.po b/c-api/extension-modules.po index c27b237be..72db318bc 100644 --- a/c-api/extension-modules.po +++ b/c-api/extension-modules.po @@ -17,17 +17,16 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/extension-modules.rst:6 msgid "Defining extension modules" msgstr "拡張モジュールの定義" -#: ../../c-api/extension-modules.rst:8 msgid "" "A C extension for CPython is a shared library (for example, a ``.so`` file " "on Linux, ``.pyd`` DLL on Windows), which is loadable into the Python " @@ -35,6 +34,11 @@ msgid "" "which exports an :dfn:`export hook` function (or an old-style :ref:" "`initialization function `)." msgstr "" +"CPython の C 拡張は共有ライブラリです (例えば Linux の ``.so`` ファイルや " +"Windows の ``.pyd`` DLL)。\n" +"Python プロセスにロードできる必要があり (例えば互換性のあるコンパイラ設定でコ" +"ンパイルされていること)、:dfn:`エクスポートフック` 関数 (または旧形式の :ref:" +"`初期化関数 `) をエクスポートします。" #: ../../c-api/extension-modules.rst:14 msgid "" @@ -60,38 +64,47 @@ msgstr "" "あり、ドキュメントは https://setuptools.pypa.io/en/latest/setuptools.html に" "あります。" -#: ../../c-api/extension-modules.rst:30 msgid "Extension export hook" -msgstr "" +msgstr "拡張モジュールのエクスポートフック" -#: ../../c-api/extension-modules.rst:34 msgid "" "Support for the :samp:`PyModExport_{}` export hook was added in Python " "3.15. The older way of defining modules is still available: consult either " "the :ref:`extension-pyinit` section or earlier versions of this " "documentation if you plan to support earlier Python versions." msgstr "" +":samp:`PyModExport_{}` エクスポートフックのサポートは Python 3.15 で追" +"加されました。\n" +"従来のモジュール定義方法も引き続き利用できます。\n" +"以前の Python バージョンに対応する場合は、:ref:`extension-pyinit` の節または" +"以前のバージョンのドキュメントを参照してください。" -#: ../../c-api/extension-modules.rst:39 msgid "" "The export hook must be an exported function with the following signature:" msgstr "" +"エクスポートフックは、次のシグネチャを持つエクスポートされた関数でなければな" +"りません:" -#: ../../c-api/extension-modules.rst:43 msgid "" "For modules with ASCII-only names, the :ref:`export hook ` must be named :samp:`PyModExport_{}`, with ```` replaced " "by the module's name." msgstr "" +"名前が ASCII 文字だけのモジュールでは、:ref:`エクスポートフック ` の名前は :samp:`PyModExport_{}` とし、```` をモ" +"ジュール名に置き換える必要があります。" -#: ../../c-api/extension-modules.rst:47 msgid "" "For non-ASCII module names, the export hook must instead be named :samp:" "`PyModExportU_{}` (note the ``U``), with ```` encoded using " "Python's *punycode* encoding with hyphens replaced by underscores. In Python:" msgstr "" +"モジュール名に非 ASCII 文字が含まれる場合、エクスポートフックの名前は代わり" +"に :samp:`PyModExportU_{}` とします (``U`` に注意してください)。\n" +"```` には、Python の *punycode* エンコーディングでエンコードし、ハイフ" +"ンをアンダースコアに置き換えた名前を使います。\n" +"Python では次のようになります:" -#: ../../c-api/extension-modules.rst:51 msgid "" "def hook_name(name):\n" " try:\n" @@ -100,50 +113,59 @@ msgid "" " suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" " return b'PyModExport' + suffix" msgstr "" +"def hook_name(name):\n" +" try:\n" +" suffix = b'_' + name.encode('ascii')\n" +" except UnicodeEncodeError:\n" +" suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')\n" +" return b'PyModExport' + suffix" -#: ../../c-api/extension-modules.rst:60 msgid "" "The export hook returns an array of :c:type:`PySlot` entries, terminated by " "an entry with a slot ID of ``0``. These slots describe how the module should " "be created and initialized." msgstr "" +"エクスポートフックは :c:type:`PySlot` エントリーの配列を返します。\n" +"この配列はスロット ID が ``0`` のエントリーで終端します。\n" +"これらのスロットで、モジュールの作成方法と初期化方法を記述します。" -#: ../../c-api/extension-modules.rst:64 msgid "" "This array must remain valid and constant until interpreter shutdown. " "Typically, it should use ``static`` storage. Prefer using the :c:macro:" "`Py_mod_create` and :c:macro:`Py_mod_exec` slots for any dynamic behavior." msgstr "" +"この配列はインタープリタの終了まで有効で、変更されない必要があります。\n" +"通常は ``static`` な記憶域を使ってください。\n" +"動的な処理には :c:macro:`Py_mod_create` スロットと :c:macro:`Py_mod_exec` ス" +"ロットを使うことを推奨します。" -#: ../../c-api/extension-modules.rst:69 msgid "" "The export hook may return ``NULL`` with an exception set to signal failure." msgstr "" +"エクスポートフックは、例外を設定して ``NULL`` を返すことで失敗を通知できま" +"す。" -#: ../../c-api/extension-modules.rst:71 msgid "" "It is recommended to define the export hook function using a helper macro:" msgstr "" +"エクスポートフック関数の定義には、次の補助マクロを使うことを推奨します:" -#: ../../c-api/extension-modules.rst:75 msgid "Declare an extension module export hook. This macro:" msgstr "" +"拡張モジュールのエクスポートフックを宣言します。\n" +"このマクロは次の処理を行います:" -#: ../../c-api/extension-modules.rst:78 msgid "specifies the :c:expr:`PySlot*` return type," -msgstr "" +msgstr "戻り値の型として :c:expr:`PySlot*` を指定します。" -#: ../../c-api/extension-modules.rst:79 ../../c-api/extension-modules.rst:248 msgid "adds any special linkage declarations required by the platform, and" -msgstr "" +msgstr "プラットフォームが要求する特別なリンケージ宣言を追加します。" -#: ../../c-api/extension-modules.rst:80 ../../c-api/extension-modules.rst:249 msgid "for C++, declares the function as ``extern \"C\"``." -msgstr "" +msgstr "C++ では、関数を ``extern \"C\"`` として宣言します。" -#: ../../c-api/extension-modules.rst:82 ../../c-api/extension-modules.rst:279 msgid "For example, a module called ``spam`` would be defined like this::" -msgstr "" +msgstr "例えば ``spam`` というモジュールは、次のように定義します。 ::" #: ../../c-api/extension-modules.rst:84 msgid "" @@ -164,44 +186,53 @@ msgid "" "}" msgstr "" -#: ../../c-api/extension-modules.rst:100 msgid "" "The export hook is typically the only non-\\ ``static`` item defined in the " "module's C source." msgstr "" +"通常、モジュールの C ソースで定義する要素のうち、``static`` でないのはエクス" +"ポートフックだけです。" -#: ../../c-api/extension-modules.rst:105 msgid "" "The hook should be kept short. If it does more than ``return`` a static " "array, several caveats apply:" msgstr "" +"フックの処理は短くしてください。\n" +"静的な配列を ``return`` する以外の処理を行う場合は、いくつか注意点があります:" -#: ../../c-api/extension-modules.rst:108 msgid "" "If you need to use any Python C API, it is recommended to call :c:func:" "`PyABIInfo_Check` first to raise an exception, rather than crash, in common " "cases of ABI mismatch." msgstr "" +"Python C API を使う必要がある場合は、最初に :c:func:`PyABIInfo_Check` を呼び" +"出すことを推奨します。\n" +"これにより、よくある ABI の不一致の場合にクラッシュする代わりに例外を送出でき" +"ます。" -#: ../../c-api/extension-modules.rst:111 msgid "" "Code in the export hook must never rely on the :term:`GIL`: :term:`free-" "threaded builds ` of Python can only check the :c:macro:" "`Py_mod_gil` slot (or the lack of it) after the hook returns," msgstr "" +"エクスポートフックのコードは :term:`GIL` に決して依存してはいけません。\n" +"Python の :term:`フリースレッドビルド ` では、フックから" +"戻った後でなければ :c:macro:`Py_mod_gil` スロット (またはその不在) を確認でき" +"ないためです。" -#: ../../c-api/extension-modules.rst:114 msgid "" "Similarly, the hook may be called in any subinterpreter, since the :c:macro:" "`Py_mod_multiple_interpreters` slot (or lack of it) is only checked after " "the hook returns." msgstr "" +"同様に、:c:macro:`Py_mod_multiple_interpreters` スロット (またはその不在) を" +"確認するのはフックから戻った後なので、フックはどのサブインタープリタでも呼び" +"出される可能性があります。" #: ../../c-api/extension-modules.rst:118 msgid "For example::" msgstr "例えば::" -#: ../../c-api/extension-modules.rst:120 msgid "" "PyMODEXPORT_FUNC\n" "PyModExport_modulename(void)\n" @@ -216,8 +247,19 @@ msgid "" " return modulename_slots;\n" "}" msgstr "" +"PyMODEXPORT_FUNC\n" +"PyModExport_modulename(void)\n" +"{\n" +" if (PyABIInfo_Check(&abi_info, \"modulename\") < 0) {\n" +" /* ABI の不一致。送出された例外を調べることは安全ではありません。 */\n" +" return NULL;\n" +" }\n" +"\n" +" /* Python API はできるだけ使わず、GIL に依存しないこと */\n" +"\n" +" return modulename_slots;\n" +"}" -#: ../../c-api/extension-modules.rst:135 msgid "" "It is possible to export multiple modules from a single shared library by " "defining multiple export hooks. However, importing them requires a custom " @@ -227,22 +269,28 @@ msgid "" "pep-0489/#multiple-modules-in-one-library>`__ section in :pep:`489` for " "details." msgstr "" +"複数のエクスポートフックを定義すれば、1 つの共有ライブラリから複数のモジュー" +"ルをエクスポートできます。\n" +"ただし、Python のインポート機構はファイル名に対応する関数だけを探すため、これ" +"らをインポートするには、独自のインポーターか、適切な名前を付けた拡張ファイル" +"のコピーまたはリンクが必要です。\n" +"詳細は :pep:`489` の `Multiple modules in one library `__ の節を参照してください。" #: ../../c-api/extension-modules.rst:147 msgid "Multi-phase initialization" msgstr "多段階初期化" -#: ../../c-api/extension-modules.rst:149 msgid "The process of creating an extension module follows several phases:" -msgstr "" +msgstr "拡張モジュールの作成はいくつかの段階に分かれています:" -#: ../../c-api/extension-modules.rst:151 msgid "" "Python finds and calls the export hook to get information on how to create " "the module." msgstr "" +"Python はエクスポートフックを探して呼び出し、モジュールの作成方法に関する情報" +"を取得します。" -#: ../../c-api/extension-modules.rst:153 msgid "" "Before any substantial code is executed, Python can determine which " "capabilities the module supports, and it can adjust the environment or " @@ -250,36 +298,51 @@ msgid "" "c:data:`Py_mod_gil` and :c:data:`Py_mod_multiple_interpreters` influence " "this step." msgstr "" +"実質的な処理を行うコードが実行される前に、Python はモジュールが対応する機能を" +"確認し、環境を調整したり、互換性のない拡張モジュールのロードを拒否したりでき" +"ます。\n" +":c:data:`Py_mod_abi`、:c:data:`Py_mod_gil`、:c:data:" +"`Py_mod_multiple_interpreters` などのスロットがこの段階に影響します。" -#: ../../c-api/extension-modules.rst:158 msgid "" "By default, Python itself then creates the module object -- that is, it does " "the equivalent of calling :py:meth:`~object.__new__` when creating an " "object. This step can be overridden using the :c:data:`Py_mod_create` slot." msgstr "" +"次に、デフォルトでは Python 自身がモジュールオブジェクトを作成します。\n" +"これは、オブジェクトを作成するときの :py:meth:`~object.__new__` の呼び出しに" +"相当します。\n" +"この段階の処理は :c:data:`Py_mod_create` スロットでオーバーライドできます。" -#: ../../c-api/extension-modules.rst:161 msgid "" "Python sets initial module attributes like :attr:`~module.__package__` and :" "attr:`~module.__loader__`, and inserts the module object into :py:attr:`sys." "modules`." msgstr "" +"Python は :attr:`~module.__package__` や :attr:`~module.__loader__` などのモ" +"ジュール属性の初期値を設定し、モジュールオブジェクトを :py:attr:`sys." +"modules` に挿入します。" -#: ../../c-api/extension-modules.rst:164 msgid "" "Afterwards, the module object is initialized in an extension-specific way -- " "the equivalent of :py:meth:`~object.__init__` when creating an object, or of " "executing top-level code in a Python-language module. The behavior is " "specified using the :c:data:`Py_mod_exec` slot." msgstr "" +"その後、拡張モジュール固有の方法でモジュールオブジェクトを初期化します。\n" +"これはオブジェクト作成時の :py:meth:`~object.__init__` や、Python で書かれた" +"モジュールのトップレベルのコード実行に相当します。\n" +"動作は :c:data:`Py_mod_exec` スロットで指定します。" -#: ../../c-api/extension-modules.rst:169 msgid "" "This is called *multi-phase initialization* to distinguish it from the " "legacy (but still supported) :ref:`single-phase initialization `, where an initialization function returns a fully " "constructed module." msgstr "" +"これを *多段階初期化* と呼び、初期化関数が完全に構築済みのモジュールを返す従" +"来の :ref:`一段階初期化 ` (現在もサポートされて" +"います) と区別します。" #: ../../c-api/extension-modules.rst:175 msgid "Added support for multi-phase initialization (:pep:`489`)." @@ -289,7 +352,6 @@ msgstr "多段階初期化 (:pep:`489`) のサポートを追加しました。" msgid "Multiple module instances" msgstr "複数のモジュールインスタンス" -#: ../../c-api/extension-modules.rst:181 msgid "" "By default, extension modules are not singletons. For example, if the :py:" "attr:`sys.modules` entry is removed and the module is re-imported, a new " @@ -297,8 +359,13 @@ msgid "" "type objects. The old module is subject to normal garbage collection. This " "mirrors the behavior of pure-Python modules." msgstr "" +"デフォルトでは、拡張モジュールはシングルトンではありません。\n" +"例えば :py:attr:`sys.modules` のエントリーを削除してモジュールを再インポート" +"すると、新しいモジュールオブジェクトを作成し、通常は新しいメソッドオブジェク" +"トや型オブジェクトを設定します。\n" +"古いモジュールは通常のガベージコレクションの対象になります。\n" +"これは純粋な Python モジュールと同じ動作です。" -#: ../../c-api/extension-modules.rst:188 msgid "" "Additional module instances may be created in :ref:`sub-interpreters ` or after Python runtime reinitialization (:c:func:" @@ -306,8 +373,12 @@ msgid "" "objects between module instances would likely cause crashes or undefined " "behavior." msgstr "" +":ref:`サブインタープリタ ` 内や、Python ランタイムの" +"再初期化 (:c:func:`Py_Finalize` と :c:func:`Py_Initialize`) 後にも、追加のモ" +"ジュールインスタンスが作成される可能性があります。\n" +"これらの場合、モジュールインスタンス間で Python オブジェクトを共有すると、ク" +"ラッシュや未定義の動作を引き起こしやすくなります。" -#: ../../c-api/extension-modules.rst:195 msgid "" "To avoid such issues, each instance of an extension module should be " "*isolated*: changes to one instance should not implicitly affect the others, " @@ -315,14 +386,20 @@ msgid "" "should be specific to a particular module instance. See :ref:`isolating-" "extensions-howto` for more details and a practical guide." msgstr "" +"このような問題を避けるには、拡張モジュールの各インスタンスを *分離* する必要" +"があります。\n" +"あるインスタンスの変更が暗黙に他のインスタンスに影響してはいけません。\n" +"また、Python オブジェクトへの参照を含む、モジュールが所有するすべての状態は、" +"特定のモジュールインスタンスだけのものでなければなりません。\n" +"詳細と実践的な手引きは :ref:`isolating-extensions-howto` を参照してください。" -#: ../../c-api/extension-modules.rst:201 msgid "" "A simpler way to avoid these issues is :ref:`raising an error on repeated " "initialization `." msgstr "" +"これらの問題を避けるより簡単な方法は、:ref:`初期化を繰り返すとエラーを送出す" +"る ` ことです。" -#: ../../c-api/extension-modules.rst:204 msgid "" "All modules are expected to support :ref:`sub-interpreters `, or otherwise explicitly signal a lack of support. This is usually " @@ -330,90 +407,110 @@ msgid "" "module may also be limited to the main interpreter using the :c:data:" "`Py_mod_multiple_interpreters` slot." msgstr "" +"すべてのモジュールは :ref:`サブインタープリタ ` に対" +"応するか、対応していないことを明示的に通知することが期待されます。\n" +"通常は、上述したように分離を行うか、初期化の繰り返しを禁止します。\n" +":c:data:`Py_mod_multiple_interpreters` スロットで、モジュールをメインインター" +"プリタに限定することもできます。" -#: ../../c-api/extension-modules.rst:216 msgid "``PyInit`` function" -msgstr "" +msgstr "``PyInit`` 関数" -#: ../../c-api/extension-modules.rst:220 msgid "" "This functionality will not get new features, but there are no plans to " "remove it." -msgstr "" +msgstr "この機能に新しい機能は追加されませんが、削除する予定はありません。" -#: ../../c-api/extension-modules.rst:223 msgid "" "Instead of :c:func:`PyModExport_modulename`, an extension module can define " "an older-style :dfn:`initialization function` with the signature:" msgstr "" +"拡張モジュールは :c:func:`PyModExport_modulename` の代わりに、次のシグネチャ" +"を持つ旧形式の :dfn:`初期化関数` を定義できます:" -#: ../../c-api/extension-modules.rst:228 msgid "" "Its name should be :samp:`PyInit_{}`, with ```` replaced by the " "name of the module. For non-ASCII module names, use :samp:`PyInitU_{}` " "instead, with ```` encoded in the same way as for the :ref:`export " "hook ` (that is, using Punycode with underscores)." msgstr "" +"名前は :samp:`PyInit_{}` とし、```` をモジュール名に置き換えま" +"す。\n" +"モジュール名に非 ASCII 文字が含まれる場合は、代わりに :samp:`PyInitU_{}" +"` を使い、```` を :ref:`エクスポートフック ` と" +"同じ方法 (アンダースコアを使う Punycode) でエンコードします。" -#: ../../c-api/extension-modules.rst:235 msgid "" "If a module exports both :samp:`PyInit_{}` and :samp:" "`PyModExport_{}`, the :samp:`PyInit_{}` function is ignored." msgstr "" +"モジュールが :samp:`PyInit_{}` と :samp:`PyModExport_{}` の両方を" +"エクスポートする場合、:samp:`PyInit_{}` 関数は無視されます。" -#: ../../c-api/extension-modules.rst:239 msgid "" "Like with :c:macro:`PyMODEXPORT_FUNC`, it is recommended to define the " "initialization function using a helper macro:" msgstr "" +":c:macro:`PyMODEXPORT_FUNC` と同様に、初期化関数の定義には補助マクロを使うこ" +"とを推奨します:" -#: ../../c-api/extension-modules.rst:244 msgid "Declare an extension module initialization function. This macro:" msgstr "" +"拡張モジュールの初期化関数を宣言します。\n" +"このマクロは次の処理を行います:" -#: ../../c-api/extension-modules.rst:247 msgid "specifies the :c:expr:`PyObject*` return type," -msgstr "" +msgstr "戻り値の型として :c:expr:`PyObject*` を指定します。" -#: ../../c-api/extension-modules.rst:252 msgid "" "Normally, the initialization function (``PyInit_modulename``) returns a :c:" "type:`PyModuleDef` instance with non-``NULL`` :c:member:`~PyModuleDef." "m_slots`. This allows Python to use :ref:`multi-phase initialization `." msgstr "" +"通常、初期化関数 (``PyInit_modulename``) は、:c:member:`~PyModuleDef." +"m_slots` が ``NULL`` でない :c:type:`PyModuleDef` インスタンスを返します。\n" +"これにより Python は :ref:`多段階初期化 ` を利用" +"できます。" -#: ../../c-api/extension-modules.rst:257 msgid "" "Before it is returned, the ``PyModuleDef`` instance must be initialized " "using the following function:" msgstr "" +"返す前に、次の関数を使って ``PyModuleDef`` インスタンスを初期化する必要があり" +"ます:" -#: ../../c-api/extension-modules.rst:262 msgid "" "Ensure a module definition is a properly initialized Python object that " "correctly reports its type and a reference count." msgstr "" +"モジュール定義を、自身の型と参照カウントを正しく示す、適切に初期化された " +"Python オブジェクトにします。" -#: ../../c-api/extension-modules.rst:265 msgid "Return *def* cast to ``PyObject*``, or ``NULL`` if an error occurred." msgstr "" +"*def* を ``PyObject*`` にキャストして返します。\n" +"エラーが発生した場合は ``NULL`` を返します。" -#: ../../c-api/extension-modules.rst:267 msgid "" "Calling this function is required before returning a :c:type:`PyModuleDef` " "from a module initialization function. It should not be used in other " "contexts." msgstr "" +"モジュール初期化関数から :c:type:`PyModuleDef` を返す前に、この関数を呼び出す" +"必要があります。\n" +"他の場面では使わないでください。" -#: ../../c-api/extension-modules.rst:271 msgid "" "Note that Python assumes that ``PyModuleDef`` structures are statically " "allocated. This function may return either a new reference or a borrowed " "one; this reference must not be released." msgstr "" +"Python は ``PyModuleDef`` 構造体が静的に割り当てられていると仮定することに注" +"意してください。\n" +"この関数は新しい参照または借用参照を返しますが、その参照を解放してはいけませ" +"ん。" -#: ../../c-api/extension-modules.rst:281 msgid "" "static struct PyModuleDef spam_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" @@ -427,35 +524,52 @@ msgid "" " return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModuleDef_Init(&spam_module);\n" +"}" #: ../../c-api/extension-modules.rst:297 msgid "Legacy single-phase initialization" msgstr "従来の一段階初期化" -#: ../../c-api/extension-modules.rst:301 msgid "" "Single-phase initialization is a legacy mechanism to initialize extension " "modules, with known drawbacks and design flaws. Extension module authors are " "encouraged to use multi-phase initialization instead." msgstr "" +"一段階初期化は拡張モジュールを初期化する従来の仕組みであり、既知の欠点や設計" +"上の問題があります。\n" +"拡張モジュールの作者には、代わりに多段階初期化を使うことを推奨します。" -#: ../../c-api/extension-modules.rst:305 msgid "However, there are no plans to remove support for it." -msgstr "" +msgstr "ただし、一段階初期化のサポートを削除する予定はありません。" -#: ../../c-api/extension-modules.rst:307 msgid "" "In single-phase initialization, the old-style :ref:`initialization function " "` (``PyInit_modulename``) should create, populate and " "return a module object. This is typically done using :c:func:" "`PyModule_Create` and functions like :c:func:`PyModule_AddObjectRef`." msgstr "" +"一段階初期化では、旧形式の :ref:`初期化関数 ` " +"(``PyInit_modulename``) がモジュールオブジェクトを作成し、内容を設定して返す" +"必要があります。\n" +"通常は :c:func:`PyModule_Create` と :c:func:`PyModule_AddObjectRef` などの関" +"数を使います。" -#: ../../c-api/extension-modules.rst:313 msgid "" "Single-phase initialization differs from the :ref:`default ` in the following ways:" msgstr "" +"一段階初期化は、次の点で :ref:`デフォルトの方式 ` と異なります:" #: ../../c-api/extension-modules.rst:316 msgid "Single-phase modules are, or rather *contain*, “singletons”." @@ -476,7 +590,6 @@ msgid "" "an exception class ``error``:" msgstr "" -#: ../../c-api/extension-modules.rst:330 msgid "" ">>> import sys\n" ">>> import _testsinglephase as one\n" @@ -491,13 +604,23 @@ msgid "" ">>> one.error is two.error\n" "True" msgstr "" +">>> import sys\n" +">>> import _testsinglephase as one\n" +">>> del sys.modules['_testsinglephase']\n" +">>> import _testsinglephase as two\n" +">>> one is two\n" +"False\n" +">>> one.__dict__ is two.__dict__\n" +"False\n" +">>> one.sum is two.sum\n" +"True\n" +">>> one.error is two.error\n" +"True" -#: ../../c-api/extension-modules.rst:345 msgid "" "The exact behavior should be considered a CPython implementation detail." -msgstr "" +msgstr "厳密な動作は CPython の実装の詳細とみなしてください。" -#: ../../c-api/extension-modules.rst:347 msgid "" "To work around the fact that ``PyInit_modulename`` does not take a *spec* " "argument, some state of the import machinery is saved and applied to the " @@ -505,29 +628,40 @@ msgid "" "Specifically, when a sub-module is imported, this mechanism prepends the " "parent package name to the name of the module." msgstr "" +"``PyInit_modulename`` が *spec* 引数を受け取らないことに対処するため、イン" +"ポート機構の状態の一部を保存し、``PyInit_modulename`` の呼び出し中に最初に作" +"成された適切なモジュールに適用します。\n" +"具体的には、サブモジュールをインポートするとき、この仕組みがモジュール名の先" +"頭に親パッケージ名を付加します。" -#: ../../c-api/extension-modules.rst:353 msgid "" "A single-phase ``PyInit_modulename`` function should create “its” module " "object as soon as possible, before any other module objects can be created." msgstr "" +"一段階初期化の ``PyInit_modulename`` 関数は、他のモジュールオブジェクトが作成" +"される前に、できるだけ早く「自身の」モジュールオブジェクトを作成してくださ" +"い。" -#: ../../c-api/extension-modules.rst:356 msgid "Non-ASCII module names (``PyInitU_modulename``) are not supported." msgstr "" +"非 ASCII のモジュール名 (``PyInitU_modulename``) はサポートされません。" -#: ../../c-api/extension-modules.rst:358 msgid "" "Single-phase modules support module lookup functions like :c:func:" "`PyState_FindModule`." msgstr "" +"一段階初期化モジュールは、:c:func:`PyState_FindModule` などのモジュール検索関" +"数をサポートします。" -#: ../../c-api/extension-modules.rst:361 msgid "The module's :c:member:`PyModuleDef.m_slots` must be NULL." msgstr "" +"モジュールの :c:member:`PyModuleDef.m_slots` は ``NULL`` でなければなりませ" +"ん。" -#: ../../c-api/extension-modules.rst:363 msgid "" "``_testsinglephase`` is an internal module used in CPython's self-test " "suite; your installation may or may not include it." msgstr "" +"``_testsinglephase`` は CPython 自身のテストスイートで使う内部モジュールで" +"す。\n" +"利用しているインストール環境には含まれていない場合もあります。" diff --git a/c-api/file.po b/c-api/file.po index a43a8c4e1..ed9c25557 100644 --- a/c-api/file.po +++ b/c-api/file.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/file.rst:6 msgid "File objects" -msgstr "" +msgstr "ファイルオブジェクト" -#: ../../c-api/file.rst:10 msgid "" "These APIs are a minimal emulation of the Python 2 C API for built-in file " "objects, which used to rely on the buffered I/O (:c:expr:`FILE*`) support " @@ -37,14 +35,16 @@ msgid "" "reporting in the interpreter; third-party code is advised to access the :mod:" "`io` APIs instead." msgstr "" -"これらの API は、 Python 2 の組み込みのファイルオブジェクトの C API を最低限" -"エミュレートするためのものです。それらは、標準 C ライブラリでサポートされてい" -"るバッファ付き I/O (:c:expr:`FILE*`) に頼るために使われます。 Python 3 では、" -"ファイルとストリームは新しい :mod:`io` モジュールを使用され、そこに OS の低レ" -"ベルなバッファ付き I/O の上にいくつかの層が定義されています。下で解説されてい" -"る関数は、それらの新しい API の便利な C ラッパーであり、インタプリタでの内部" -"的なエラー通知に向いています; サードパーティーのコードは代わりに :mod:`io` " -"の API を使うことが推奨されます。" +"これらの API は、C 標準ライブラリのバッファ付き I/O (:c:expr:`FILE*`) に依存" +"していた Python 2 の組み込みファイルオブジェクトの C API を、最小限エミュレー" +"トするものです。\n" +"Python 3 のファイルやストリームは新しい :mod:`io` モジュールを使います。\n" +"このモジュールは、OS の低水準なバッファなし I/O の上に複数の層を定義していま" +"す。\n" +"以下の関数は、これらの新しい API を包む便利な C ラッパーで、主にインタープリ" +"タ内部でのエラー報告を目的としています。\n" +"サードパーティのコードでは、代わりに :mod:`io` の API を使うことを推奨しま" +"す。" #: ../../c-api/file.rst:22 msgid "" @@ -65,15 +65,14 @@ msgstr "" "より包括的な引数の解説は、 :func:`io.open` 関数のドキュメントを参照してくださ" "い。" -#: ../../c-api/file.rst:31 msgid "" "Since Python streams have their own buffering layer, mixing them with OS-" "level file descriptors can produce various issues (such as unexpected " "ordering of data)." msgstr "" -"Python ストリームは自身のバッファリング層を持つため、ファイル記述子のOSレベル" -"のバッファリングと併用すると、様々な問題 (予期せぬデータ順) などを引き起こし" -"ます。" +"Python のストリームは独自のバッファリング層を持つため、OS レベルのファイル" +"ディスクリプタと混在させると、データの順序が予想外になるなどの問題が起きる可" +"能性があります。" #: ../../c-api/file.rst:35 msgid "Ignore *name* attribute." @@ -93,7 +92,6 @@ msgstr "" "は、ファイル記述子の値として返される整数でなければなりません。失敗すると例外" "を設定して ``-1`` を返します。" -#: ../../c-api/file.rst:52 msgid "" "Equivalent to ``p.readline([n])``, this function reads one line from the " "object *p*. *p* may be a file object or any object with a :meth:`~io.IOBase." @@ -105,14 +103,15 @@ msgid "" "regardless of length, but :exc:`EOFError` is raised if the end of the file " "is reached immediately." msgstr "" -"``p.readline([n])`` と同じで、この関数はオブジェクト *p* の各行を読み出しま" -"す。 *p* はファイルオブジェクトか、 :meth:`~io.IOBase.readline` メソッドを持" -"つ何らかのオブジェクトでかまいません。 *n* が ``0`` の場合、行の長さに関係な" -"く正確に 1 行だけ読み出します。 *n* が ``0`` より大きければ、 *n* バイト以上" -"のデータは読み出しません; 従って、行の一部だけが返される場合があります。 どち" -"らの場合でも、読み出し後すぐにファイルの終端に到達した場合には空文字列を 返し" -"ます。 *n* が ``0`` より小さければ、長さに関わらず 1 行だけを 読み出します" -"が、すぐにファイルの終端に到達した場合には :exc:`EOFError` を送出します。" +"``p.readline([n])`` に相当し、オブジェクト *p* から一行を読み込みます。\n" +"*p* はファイルオブジェクトでも、:meth:`~io.IOBase.readline` メソッドを持つ任" +"意のオブジェクトでも構いません。\n" +"*n* が ``0`` なら、長さにかかわらず一行を読み込みます。\n" +"*n* が ``0`` より大きければ、ファイルから読み込むのは最大 *n* バイトで、行の" +"一部だけを返す場合があります。\n" +"いずれの場合も、最初からファイルの終端に達していれば空文字列を返します。\n" +"一方、*n* が ``0`` より小さければ、長さにかかわらず一行を読み込みますが、最初" +"からファイルの終端に達している場合は :exc:`EOFError` を送出します。" #: ../../c-api/file.rst:65 msgid "" @@ -155,68 +154,72 @@ msgstr "" "ことが分かっている場合を除いては、フック関数の実行中に新しいモジュールをイン" "ポートするのは避けてください。" -#: ../../c-api/file.rst:85 msgid "" "Once a hook has been set, it cannot be removed or replaced, and later calls " "to :c:func:`PyFile_SetOpenCodeHook` will fail. On failure, the function " "returns -1 and sets an exception if the interpreter has been initialized." msgstr "" -"いったんフック関数が設定されたら、削除や置き換えもできず、後からの :c:func:" +"いったんフックを設定すると、削除も置き換えもできず、その後の :c:func:" "`PyFile_SetOpenCodeHook` の呼び出しは失敗します。\n" -"この関数が失敗したときは、インタープリタが初期化されていた場合、 -1 を返して" -"例外をセットします。" +"失敗すると -1 を返し、インタープリタが初期化済みの場合は例外も設定します。" #: ../../c-api/file.rst:89 msgid "This function is safe to call before :c:func:`Py_Initialize`." msgstr "この関数は :c:func:`Py_Initialize` より前に呼び出しても安全です。" -#: ../../c-api/file.rst:91 msgid "" "Raises an :ref:`auditing event ` ``setopencodehook`` with no " "arguments." msgstr "" -"引数無しで :ref:`監査イベント ` ``setopencodehook`` を送出します。 " +"引数無しで :ref:`監査イベント ` ``setopencodehook`` を送出します。" -#: ../../c-api/file.rst:98 msgid "" "Open *path* with the mode ``'rb'``. *path* must be a Python :class:`str` " "object. The behavior of this function may be overridden by :c:func:" "`PyFile_SetOpenCodeHook` to allow for some preprocessing of the text." msgstr "" +"*path* を ``'rb'`` モードで開きます。\n" +"*path* は Python の :class:`str` オブジェクトでなければなりません。\n" +":c:func:`PyFile_SetOpenCodeHook` でこの関数の動作を変更すると、テキストに前処" +"理を加えられます。" -#: ../../c-api/file.rst:103 msgid "This is analogous to :func:`io.open_code` in Python." -msgstr "" +msgstr "Python の :func:`io.open_code` に相当します。" -#: ../../c-api/file.rst:105 msgid "" "On success, this function returns a :term:`strong reference` to a Python " "file object. On failure, this function returns ``NULL`` with an exception " "set." msgstr "" +"成功すると、Python のファイルオブジェクトへの :term:`強参照 ` を返します。\n" +"失敗すると、例外を設定して ``NULL`` を返します。" -#: ../../c-api/file.rst:114 msgid "" "Similar to :c:func:`PyFile_OpenCodeObject`, but *path* is a UTF-8 encoded :c:" "expr:`const char*`." msgstr "" +":c:func:`PyFile_OpenCodeObject` と似ていますが、*path* は UTF-8 でエンコード" +"された :c:expr:`const char*` です。" -#: ../../c-api/file.rst:124 msgid "" "Write object *obj* to file object *p*. The only supported flag for *flags* " "is :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is " "written instead of the :func:`repr`." msgstr "" +"オブジェクト *obj* をファイルオブジェクト *p* に書き出します。\n" +"*flags* でサポートするフラグは :c:macro:`Py_PRINT_RAW` だけです。\n" +"指定した場合、オブジェクトの :func:`repr` ではなく :func:`str` の結果を書き出" +"します。" -#: ../../c-api/file.rst:128 msgid "If *obj* is ``NULL``, write the string ``\"\"``." -msgstr "" +msgstr "*obj* が ``NULL`` の場合、文字列 ``\"\"`` を書き出します。" -#: ../../c-api/file.rst:130 msgid "" "Return ``0`` on success or ``-1`` on failure; the appropriate exception will " "be set." msgstr "" +"成功すると ``0`` を返し、失敗すると適切な例外を設定して ``-1`` を返します。" #: ../../c-api/file.rst:135 msgid "" @@ -226,28 +229,33 @@ msgstr "" "文字列 *s* をファイルオブジェクト *p* に書き出します。成功した場合には ``0`` " "を返し、失敗すると ``-1`` を返して適切な例外をセットします。" -#: ../../c-api/file.rst:140 msgid "Soft-deprecated API" -msgstr "" +msgstr "緩やかに非推奨となった API" -#: ../../c-api/file.rst:144 msgid "" "These are APIs that were included in Python's C API by mistake. They are " "documented solely for completeness; use other ``PyFile*`` APIs instead." msgstr "" +"これらは誤って Python の C API に含めてしまった API です。\n" +"網羅性のためだけに記載しており、代わりに他の ``PyFile*`` API を使ってくださ" +"い。" -#: ../../c-api/file.rst:150 msgid "" "Use :c:func:`PyFile_FromFd` with defaults (``fd, NULL, \"w\", -1, NULL, " "NULL, NULL, 0``) instead." msgstr "" +"代わりに、デフォルト値 (``fd, NULL, \"w\", -1, NULL, NULL, NULL, 0``) で :c:" +"func:`PyFile_FromFd` を使ってください。" -#: ../../c-api/file.rst:154 msgid "" "Type of file-like objects used internally at Python startup when :py:mod:" "`io` is not yet available. Use Python :py:func:`open` or :c:func:" "`PyFile_FromFd` to create file objects instead." msgstr "" +"Python の起動時に :py:mod:`io` がまだ利用できない間、内部で使うファイルライク" +"オブジェクトの型です。\n" +"ファイルオブジェクトの作成には、代わりに Python の :py:func:`open` または :c:" +"func:`PyFile_FromFd` を使ってください。" #: ../../c-api/file.rst:8 msgid "object" diff --git a/c-api/float.po b/c-api/float.po index 7bb5e1bc4..3139ce0e7 100644 --- a/c-api/float.po +++ b/c-api/float.po @@ -16,26 +16,28 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/float.rst:6 msgid "Floating-Point Objects" -msgstr "" +msgstr "浮動小数点オブジェクト" -#: ../../c-api/float.rst:13 msgid "" "This subtype of :c:type:`PyObject` represents a Python floating-point object." msgstr "" +"この :c:type:`PyObject` のサブタイプは Python の浮動小数点オブジェクトを表し" +"ます。" -#: ../../c-api/float.rst:18 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python floating-point " "type. This is the same object as :class:`float` in the Python layer." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の浮動小数点型を表しま" +"す。\n" +"Python レベルの :class:`float` と同じオブジェクトです。" #: ../../c-api/float.rst:24 msgid "" @@ -68,7 +70,6 @@ msgstr "" "*v* から :c:type:`PyFloatObject` オブジェクトを生成して返します。\n" "失敗すると ``NULL`` を返します。" -#: ../../c-api/float.rst:47 msgid "" "Return a C :c:expr:`double` representation of the contents of *pyfloat*. If " "*pyfloat* is not a Python floating-point object but has a :meth:`~object." @@ -77,6 +78,14 @@ msgid "" "meth:`~object.__index__`. This method returns ``-1.0`` upon failure, so one " "should call :c:func:`PyErr_Occurred` to check for errors." msgstr "" +"``pyfloat`` の値を C の :c:expr:`double` で返します。\n" +"``pyfloat`` が Python の浮動小数点オブジェクトでなく、:meth:`~object." +"__float__` メソッドを持つ場合は、まずそのメソッドを呼び出して ``pyfloat`` を " +"float に変換します。\n" +":meth:`!__float__` が定義されていなければ :meth:`~object.__index__` を使いま" +"す。\n" +"失敗した場合は ``-1.0`` を返すので、:c:func:`PyErr_Occurred` を呼び出してエ" +"ラーの有無を確認する必要があります。" #: ../../c-api/float.rst:54 msgid "Use :meth:`~object.__index__` if available." @@ -99,13 +108,12 @@ msgstr "" "float の精度、最小値、最大値に関する情報を含む structseq インスタンスを返しま" "す。これは、 :file:`float.h` ファイルの薄いラッパーです。" -#: ../../c-api/float.rst:73 msgid "" "Return the maximum representable finite float *DBL_MAX* as C :c:expr:" "`double`." msgstr "" -"float の表現できる最大限解値 *DBL_MAX* を C の :c:expr:`double` 型で返しま" -"す。" +"表現できる最大の有限の浮動小数点数 *DBL_MAX* を C の :c:expr:`double` として" +"返します。" #: ../../c-api/float.rst:78 msgid "" @@ -114,119 +122,112 @@ msgstr "" "float の正規化された最小の正の値 *DBL_MIN* を C の :c:expr:`double` 型で返し" "ます。" -#: ../../c-api/float.rst:83 msgid "" "This macro expands to a constant expression of type :c:expr:`double`, that " "represents the positive infinity." -msgstr "" +msgstr "正の無限大を表す :c:expr:`double` 型の定数式に展開されるマクロです。" -#: ../../c-api/float.rst:86 msgid "" "It is equivalent to the :c:macro:`!INFINITY` macro from the C11 standard " "```` header." msgstr "" +"C11 標準の ```` ヘッダの :c:macro:`!INFINITY` マクロと同等です。" -#: ../../c-api/float.rst:94 msgid "" "This macro expands to a constant expression of type :c:expr:`double`, that " "represents a quiet not-a-number (qNaN) value." msgstr "" +"静かな非数 (qNaN) を表す :c:expr:`double` 型の定数式に展開されるマクロです。" -#: ../../c-api/float.rst:97 msgid "" "On most platforms, this is equivalent to the :c:macro:`!NAN` macro from the " "C11 standard ```` header." msgstr "" +"ほとんどのプラットフォームでは、C11 標準の ```` ヘッダの :c:macro:`!" +"NAN` マクロと同等です。" -#: ../../c-api/float.rst:103 msgid "Equivalent to :c:macro:`!INFINITY`." -msgstr "" +msgstr ":c:macro:`!INFINITY` と同等です。" -#: ../../c-api/float.rst:110 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math.e` " "constant." -msgstr "" +msgstr ":data:`math.e` 定数の定義です (:c:expr:`double` 型の精度)。" -#: ../../c-api/float.rst:115 msgid "High precision (long double) definition of :data:`~math.e` constant." -msgstr "" +msgstr ":data:`~math.e` 定数の高精度 (long double) の定義です。" -#: ../../c-api/float.rst:122 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math.pi` " "constant." -msgstr "" +msgstr ":data:`math.pi` 定数の定義です (:c:expr:`double` 型の精度)。" -#: ../../c-api/float.rst:127 msgid "High precision (long double) definition of :data:`~math.pi` constant." -msgstr "" +msgstr ":data:`~math.pi` 定数の高精度 (long double) の定義です。" -#: ../../c-api/float.rst:134 msgid "" "The definition (accurate for a :c:expr:`double` type) of the :data:`math." "tau` constant." -msgstr "" +msgstr ":data:`math.tau` 定数の定義です (:c:expr:`double` 型の精度)。" -#: ../../c-api/float.rst:141 msgid "Return :data:`math.nan` from a function." -msgstr "" +msgstr "関数から :data:`math.nan` を返します。" -#: ../../c-api/float.rst:143 msgid "" "On most platforms, this is equivalent to ``return PyFloat_FromDouble(NAN)``." msgstr "" +"ほとんどのプラットフォームでは、``return PyFloat_FromDouble(NAN)`` と同等で" +"す。" -#: ../../c-api/float.rst:148 msgid "" "Return :data:`math.inf` or :data:`-math.inf ` from a function, " "depending on the sign of *sign*." msgstr "" +"``sign`` の符号に応じて、関数から :data:`math.inf` または :data:`-math.inf " +"` を返します。" -#: ../../c-api/float.rst:151 msgid "On most platforms, this is equivalent to the following::" -msgstr "" +msgstr "ほとんどのプラットフォームでは、次と同等です。 ::" -#: ../../c-api/float.rst:153 msgid "return PyFloat_FromDouble(copysign(INFINITY, sign));" -msgstr "" +msgstr "return PyFloat_FromDouble(copysign(INFINITY, sign));" -#: ../../c-api/float.rst:158 msgid "" "Return ``1`` if the given floating-point number *X* is finite, that is, it " "is normal, subnormal or zero, but not infinite or NaN. Return ``0`` " "otherwise." msgstr "" +"指定された浮動小数点数 ``X`` が有限、つまり正規化数、非正規化数、ゼロのいずれ" +"かであり、無限大や NaN でなければ ``1`` を返します。\n" +"それ以外の場合は ``0`` を返します。" -#: ../../c-api/float.rst:162 msgid "Use :c:macro:`!isfinite` instead." -msgstr "" +msgstr "代わりに :c:macro:`!isfinite` を使ってください。" -#: ../../c-api/float.rst:168 msgid "" "Return ``1`` if the given floating-point number *X* is positive or negative " "infinity. Return ``0`` otherwise." msgstr "" +"指定された浮動小数点数 ``X`` が正または負の無限大の場合に ``1`` を返しま" +"す。\n" +"それ以外の場合は ``0`` を返します。" -#: ../../c-api/float.rst:171 msgid "Use :c:macro:`!isinf` instead." -msgstr "" +msgstr "代わりに :c:macro:`!isinf` を使ってください。" -#: ../../c-api/float.rst:177 msgid "" "Return ``1`` if the given floating-point number *X* is a not-a-number (NaN) " "value. Return ``0`` otherwise." msgstr "" +"指定された浮動小数点数 ``X`` が非数 (NaN) の場合に ``1`` を返します。\n" +"それ以外の場合は ``0`` を返します。" -#: ../../c-api/float.rst:180 msgid "Use :c:macro:`!isnan` instead." -msgstr "" +msgstr "代わりに :c:macro:`!isnan` を使ってください。" -#: ../../c-api/float.rst:185 msgid "Pack and Unpack functions" -msgstr "" +msgstr "パック関数とアンパック関数" -#: ../../c-api/float.rst:187 msgid "" "The pack and unpack functions provide an efficient platform-independent way " "to store floating-point values as byte strings. The Pack routines produce a " @@ -234,27 +235,30 @@ msgid "" "c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies " "the number of bytes in the bytes string:" msgstr "" +"パック関数とアンパック関数は、浮動小数点数をバイト列として格納するための、効" +"率的でプラットフォームに依存しない方法を提供します。\n" +"パック関数は C の :c:expr:`double` からバイト列を作成し、アンパック関数はその" +"バイト列から C の :c:expr:`double` を作成します。\n" +"接尾辞 (2、4、8) はバイト列のバイト数を表します。" -#: ../../c-api/float.rst:193 msgid "The 2-byte format is the IEEE 754 binary16 half-precision format." -msgstr "" +msgstr "2 バイト形式は IEEE 754 binary16 半精度形式です。" -#: ../../c-api/float.rst:194 msgid "The 4-byte format is the IEEE 754 binary32 single-precision format." -msgstr "" +msgstr "4 バイト形式は IEEE 754 binary32 単精度形式です。" -#: ../../c-api/float.rst:195 msgid "The 8-byte format is the IEEE 754 binary64 double-precision format." -msgstr "" +msgstr "8 バイト形式は IEEE 754 binary64 倍精度形式です。" -#: ../../c-api/float.rst:197 msgid "" "The NaN type may not be preserved on some platforms while unpacking " "(signaling NaNs become quiet NaNs), for example on x86 systems in 32-bit " "mode." msgstr "" +"32 ビットモードの x86 システムなど、一部のプラットフォームでは、アンパック時" +"に NaN の種類が保持されないことがあります (シグナリング NaN が静かな NaN にな" +"ります)。" -#: ../../c-api/float.rst:200 msgid "" "It's assumed that the :c:expr:`double` type has the IEEE 754 binary64 double " "precision format. What happens if it's not true is partly accidental " @@ -265,10 +269,19 @@ msgid "" "exist on the platform) may not be handled correctly, and attempting to " "unpack a bytes string containing an IEEE INF or NaN may raise an exception." msgstr "" +":c:expr:`double` 型は IEEE 754 binary64 倍精度形式であると仮定しています。\n" +"そうでない場合の動作は、残念ながら一部が偶然に左右されます。\n" +"IEEE 形式でなく、IEEE 754 よりも精度やダイナミックレンジが大きいプラット" +"フォームでは、パックできない値があります。\n" +"逆に精度やダイナミックレンジが小さいプラットフォームでは、アンパックできない" +"値があります。\n" +"INF や NaN のような特殊な数値 (そのプラットフォームに存在する場合) のパック" +"は、正しく処理されないことがあります。\n" +"また、IEEE の INF や NaN を含むバイト列をアンパックしようとすると例外が発生す" +"ることがあります。" -#: ../../c-api/float.rst:212 msgid "Pack functions" -msgstr "" +msgstr "パック関数" #: ../../c-api/float.rst:214 msgid "" @@ -280,27 +293,24 @@ msgid "" "on big endian processor, or ``1`` on little endian processor." msgstr "" -#: ../../c-api/float.rst:221 msgid "" "Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set, " "most likely :exc:`OverflowError`)." msgstr "" +"戻り値は、成功した場合は ``0``、エラーの場合は ``-1`` です (例外も設定され、" +"通常は :exc:`OverflowError` です)。" -#: ../../c-api/float.rst:226 msgid "Pack a C double as the IEEE 754 binary16 half-precision format." -msgstr "" +msgstr "C の double を IEEE 754 binary16 半精度形式にパックします。" -#: ../../c-api/float.rst:230 msgid "Pack a C double as the IEEE 754 binary32 single precision format." -msgstr "" +msgstr "C の double を IEEE 754 binary32 単精度形式にパックします。" -#: ../../c-api/float.rst:234 msgid "Pack a C double as the IEEE 754 binary64 double precision format." -msgstr "" +msgstr "C の double を IEEE 754 binary64 倍精度形式にパックします。" -#: ../../c-api/float.rst:238 msgid "Unpack functions" -msgstr "" +msgstr "アンパック関数" #: ../../c-api/float.rst:240 msgid "" @@ -312,24 +322,23 @@ msgid "" "processor, or ``1`` on little endian processor." msgstr "" -#: ../../c-api/float.rst:247 msgid "" "Return value: The unpacked double. On error, this is ``-1.0`` and :c:func:" "`PyErr_Occurred` is true (and an exception is set, most likely :exc:" "`OverflowError`)." msgstr "" +"戻り値は、アンパックした double です。\n" +"エラーの場合は ``-1.0`` を返し、:c:func:`PyErr_Occurred` が真になります (例外" +"も設定され、通常は :exc:`OverflowError` です)。" -#: ../../c-api/float.rst:253 msgid "Unpack the IEEE 754 binary16 half-precision format as a C double." -msgstr "" +msgstr "IEEE 754 binary16 半精度形式を C の double にアンパックします。" -#: ../../c-api/float.rst:257 msgid "Unpack the IEEE 754 binary32 single precision format as a C double." -msgstr "" +msgstr "IEEE 754 binary32 単精度形式を C の double にアンパックします。" -#: ../../c-api/float.rst:261 msgid "Unpack the IEEE 754 binary64 double precision format as a C double." -msgstr "" +msgstr "IEEE 754 binary64 倍精度形式を C の double にアンパックします。" #: ../../c-api/float.rst:8 msgid "object" diff --git a/c-api/frame.po b/c-api/frame.po index 68f4a1f90..b75469f92 100644 --- a/c-api/frame.po +++ b/c-api/frame.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/frame.rst:4 @@ -32,57 +32,61 @@ msgstr "" "フレームオブジェクトを記述する際に用いられる、オブジェクトを表す C 構造体で" "す。" -#: ../../c-api/frame.rst:10 msgid "There are no public members in this structure." -msgstr "" +msgstr "この構造体には公開メンバはありません。" -#: ../../c-api/frame.rst:12 msgid "" "The members of this structure were removed from the public C API. Refer to " "the :ref:`What's New entry ` for details." msgstr "" +"この構造体のメンバは公開 C API から削除されました。\n" +"詳細は :ref:`What's New の該当項目 ` を参照してく" +"ださい。" -#: ../../c-api/frame.rst:17 msgid "" "The :c:func:`PyEval_GetFrame` and :c:func:`PyThreadState_GetFrame` functions " "can be used to get a frame object." msgstr "" +"フレームオブジェクトは :c:func:`PyEval_GetFrame` と :c:func:" +"`PyThreadState_GetFrame` 関数で取得できます。" -#: ../../c-api/frame.rst:20 msgid "See also :ref:`Reflection `." -msgstr "" +msgstr ":ref:`リフレクション ` も参照してください。" -#: ../../c-api/frame.rst:24 msgid "" "The type of frame objects. It is the same object as :py:class:`types." "FrameType` in the Python layer." msgstr "" +"フレームオブジェクトの型です。\n" +"Python レベルの :py:class:`types.FrameType` と同じオブジェクトです。" -#: ../../c-api/frame.rst:29 msgid "" "Previously, this type was only available after including ````." msgstr "" +"以前は、この型を使うには ```` をインクルードする必要がありまし" +"た。" -#: ../../c-api/frame.rst:34 msgid "" "Create a new frame object. This function returns a :term:`strong reference` " "to the new frame object on success, and returns ``NULL`` with an exception " "set on failure." msgstr "" +"新しいフレームオブジェクトを作成します。\n" +"成功した場合は新しいフレームオブジェクトへの :term:`強参照 ` を返し、失敗した場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/frame.rst:40 msgid "Return non-zero if *obj* is a frame object." -msgstr "" +msgstr "``obj`` がフレームオブジェクトの場合に非ゼロを返します。" -#: ../../c-api/frame.rst:44 msgid "" "Previously, this function was only available after including ````." msgstr "" +"以前は、この関数を使うには ```` をインクルードする必要がありま" +"した。" -#: ../../c-api/frame.rst:49 msgid "Get the *frame* next outer frame." -msgstr "" +msgstr "``frame`` の一つ外側のフレームを取得します。" #: ../../c-api/frame.rst:51 msgid "" @@ -90,77 +94,71 @@ msgid "" "frame. This raises no exceptions." msgstr "" -#: ../../c-api/frame.rst:60 msgid "Get the *frame*'s :attr:`~frame.f_builtins` attribute." -msgstr "" +msgstr "``frame`` の :attr:`~frame.f_builtins` 属性を取得します。" -#: ../../c-api/frame.rst:62 ../../c-api/frame.rst:93 msgid "Return a :term:`strong reference`. The result cannot be ``NULL``." msgstr "" +":term:`強参照 ` を返します。\n" +"結果が ``NULL`` になることはありません。" -#: ../../c-api/frame.rst:69 msgid "Get the *frame* code." -msgstr "" +msgstr "``frame`` のコードを取得します。" -#: ../../c-api/frame.rst:71 ../../c-api/frame.rst:137 msgid "Return a :term:`strong reference`." -msgstr "" +msgstr ":term:`強参照 ` を返します。" -#: ../../c-api/frame.rst:73 msgid "The result (frame code) cannot be ``NULL``." -msgstr "" +msgstr "結果 (フレームのコード) が ``NULL`` になることはありません。" -#: ../../c-api/frame.rst:80 msgid "" "Get the generator, coroutine, or async generator that owns this frame, or " "``NULL`` if this frame is not owned by a generator. Does not raise an " "exception, even if the return value is ``NULL``." msgstr "" +"このフレームを所有するジェネレータ、コルーチン、非同期ジェネレータを取得しま" +"す。\n" +"ジェネレータに所有されていない場合は ``NULL`` を返します。\n" +"戻り値が ``NULL`` であっても例外は送出しません。" -#: ../../c-api/frame.rst:84 msgid "Return a :term:`strong reference`, or ``NULL``." -msgstr "" +msgstr ":term:`強参照 ` または ``NULL`` を返します。" -#: ../../c-api/frame.rst:91 msgid "Get the *frame*'s :attr:`~frame.f_globals` attribute." -msgstr "" +msgstr "``frame`` の :attr:`~frame.f_globals` 属性を取得します。" -#: ../../c-api/frame.rst:100 msgid "Get the *frame*'s :attr:`~frame.f_lasti` attribute." -msgstr "" +msgstr "``frame`` の :attr:`~frame.f_lasti` 属性を取得します。" #: ../../c-api/frame.rst:102 msgid "Returns -1 if ``frame.f_lasti`` is ``None``." msgstr "" -#: ../../c-api/frame.rst:109 msgid "Get the variable *name* of *frame*." -msgstr "" +msgstr "``frame`` の変数 ``name`` を取得します。" -#: ../../c-api/frame.rst:111 msgid "Return a :term:`strong reference` to the variable value on success." msgstr "" +"成功した場合は、変数の値への :term:`強参照 ` を返します。" -#: ../../c-api/frame.rst:112 msgid "" "Raise :exc:`NameError` and return ``NULL`` if the variable does not exist." msgstr "" +"変数が存在しない場合は :exc:`NameError` を送出し、``NULL`` を返します。" -#: ../../c-api/frame.rst:113 msgid "Raise an exception and return ``NULL`` on error." -msgstr "" +msgstr "エラーの場合は例外を送出し、``NULL`` を返します。" -#: ../../c-api/frame.rst:115 msgid "*name* type must be a :class:`str`." -msgstr "" +msgstr "``name`` の型は :class:`str` でなければなりません。" -#: ../../c-api/frame.rst:122 msgid "" "Similar to :c:func:`PyFrame_GetVar`, but the variable name is a C string " "encoded in UTF-8." msgstr "" +":c:func:`PyFrame_GetVar` と同様ですが、変数名は UTF-8 でエンコードした C 文字" +"列です。" -#: ../../c-api/frame.rst:130 msgid "" "Get the *frame*'s :attr:`~frame.f_locals` attribute. If the frame refers to " "an :term:`optimized scope`, this returns a write-through proxy object that " @@ -168,6 +166,12 @@ msgid "" "`exec`, :func:`eval`) it returns the mapping representing the frame locals " "directly (as described for :func:`locals`)." msgstr "" +"``frame`` の :attr:`~frame.f_locals` 属性を取得します。\n" +"フレームが :term:`最適化されたスコープ ` を参照する場合、" +"ローカル変数の変更を可能にする、書き込みを反映するプロキシオブジェクトを返し" +"ます。\n" +"それ以外の場合 (クラス、モジュール、:func:`exec`、:func:`eval`) は、フレーム" +"のローカル変数を表すマッピングを直接返します (:func:`locals` の説明を参照)。" #: ../../c-api/frame.rst:141 msgid "" @@ -179,9 +183,8 @@ msgstr "" msgid "Return the line number that *frame* is currently executing." msgstr "*frame* が現在実行している行番号を返します。" -#: ../../c-api/frame.rst:151 msgid "Frame locals proxies" -msgstr "" +msgstr "フレームのローカル変数のプロキシ" #: ../../c-api/frame.rst:155 msgid "" @@ -192,29 +195,25 @@ msgid "" "to date with the live local variables in the frame itself." msgstr "" -#: ../../c-api/frame.rst:161 msgid "See :pep:`667` for more information." -msgstr "" +msgstr "詳細は :pep:`667` を参照してください。" -#: ../../c-api/frame.rst:165 msgid "The type of frame :func:`locals` proxy objects." -msgstr "" +msgstr "フレームの :func:`locals` プロキシオブジェクトの型。" -#: ../../c-api/frame.rst:169 msgid "Return non-zero if *obj* is a frame :func:`locals` proxy." -msgstr "" +msgstr "``obj`` がフレームの :func:`locals` プロキシの場合に非ゼロを返します。" -#: ../../c-api/frame.rst:173 msgid "Legacy local variable APIs" -msgstr "" +msgstr "従来のローカル変数 API" -#: ../../c-api/frame.rst:175 msgid "" "These APIs are :term:`soft deprecated`. As of Python 3.13, they do nothing. " "They exist solely for backwards compatibility." msgstr "" +"これらの API は :term:`緩やかに非推奨 ` です。\n" +"Python 3.13 以降では何も行わず、後方互換性のためだけに存在します。" -#: ../../c-api/frame.rst:181 msgid "" "Prior to Python 3.13, this function would copy the :attr:`~frame.f_locals` " "attribute of *f* to the internal \"fast\" array of local variables, allowing " @@ -222,68 +221,75 @@ msgid "" "true, this function would process variables that were unset in the locals " "dictionary." msgstr "" +"Python 3.13 より前では、この関数は ``f`` の :attr:`~frame.f_locals` 属性を" +"ローカル変数の内部の \"fast\" 配列にコピーし、フレームオブジェクトへの変更を" +"インタープリタから見えるようにしていました。\n" +"``clear`` が真の場合は、ローカル変数の辞書で値が設定されていない変数も処理し" +"ていました。" -#: ../../c-api/frame.rst:187 ../../c-api/frame.rst:198 -#: ../../c-api/frame.rst:208 msgid "This function now does nothing." -msgstr "" +msgstr "この関数は何も行わなくなりました。" -#: ../../c-api/frame.rst:193 msgid "" "Prior to Python 3.13, this function would copy the internal \"fast\" array " "of local variables (which is used by the interpreter) to the :attr:`~frame." "f_locals` attribute of *f*, allowing changes in local variables to be " "visible to frame objects." msgstr "" +"Python 3.13 より前では、この関数はインタープリタが使うローカル変数の内部の " +"\"fast\" 配列を ``f`` の :attr:`~frame.f_locals` 属性にコピーし、ローカル変数" +"への変更をフレームオブジェクトから見えるようにしていました。" -#: ../../c-api/frame.rst:204 msgid "" "Prior to Python 3.13, this function was similar to :c:func:" "`PyFrame_FastToLocals`, but would return ``0`` on success, and ``-1`` with " "an exception set on failure." msgstr "" +"Python 3.13 より前では、この関数は :c:func:`PyFrame_FastToLocals` と同様でし" +"たが、成功した場合は ``0`` を返し、失敗した場合は例外を設定して ``-1`` を返し" +"ていました。" -#: ../../c-api/frame.rst:213 msgid ":pep:`667`" -msgstr "" +msgstr ":pep:`667`" -#: ../../c-api/frame.rst:217 msgid "Internal frames" -msgstr "" +msgstr "内部フレーム" -#: ../../c-api/frame.rst:219 msgid "Unless using :pep:`523`, you will not need this." -msgstr "" +msgstr ":pep:`523` を使わない限り、これは必要ありません。" -#: ../../c-api/frame.rst:223 msgid "The interpreter's internal frame representation." -msgstr "" +msgstr "インタープリタ内部でのフレーム表現。" -#: ../../c-api/frame.rst:229 msgid "Return a :term:`strong reference` to the code object for the frame." msgstr "" +"フレームのコードオブジェクトへの :term:`強参照 ` を返しま" +"す。" -#: ../../c-api/frame.rst:236 msgid "Return the byte offset into the last executed instruction." -msgstr "" +msgstr "最後に実行した命令のバイトオフセットを返します。" -#: ../../c-api/frame.rst:243 msgid "" "Return the currently executing line number, or -1 if there is no line number." msgstr "" +"現在実行している行の番号を返します。\n" +"行番号がない場合は -1 を返します。" -#: ../../c-api/frame.rst:250 msgid "" "An array of executable kinds (executor types) for frames, used for internal " "debugging and tracing." msgstr "" +"内部のデバッグやトレースに使う、フレームの実行対象の種類 (executor の型) の配" +"列。" -#: ../../c-api/frame.rst:253 msgid "" "Tools like debuggers and profilers can use this to identify the type of " "execution context associated with a frame (such as to filter out internal " "frames). The entries are indexed by the following constants:" msgstr "" +"デバッガやプロファイラなどのツールは、これを使ってフレームに関連付けられた実" +"行コンテキストの種類を識別できます (例えば、内部フレームを除外するため)。\n" +"各エントリーのインデックスは以下の定数で指定します。" #: ../../c-api/frame.rst:261 msgid "Constant" @@ -293,29 +299,27 @@ msgstr "定数" msgid "Description" msgstr "説明" -#: ../../c-api/frame.rst:264 msgid "" "The frame is internal (For example: inlined) and should be skipped by tools." msgstr "" +"内部フレーム (例えばインライン化されたフレーム) であり、ツールではスキップす" +"べきです。" -#: ../../c-api/frame.rst:266 msgid "The frame corresponds to a standard Python function." -msgstr "" +msgstr "通常の Python 関数に対応するフレーム。" -#: ../../c-api/frame.rst:268 msgid "The frame corresponds to a function defined in native code." -msgstr "" +msgstr "ネイティブコードで定義された関数に対応するフレーム。" -#: ../../c-api/frame.rst:270 msgid "The frame corresponds to a method on a class instance." -msgstr "" +msgstr "クラスインスタンスのメソッドに対応するフレーム。" -#: ../../c-api/frame.rst:272 msgid "" "Note that reading the executable kind from a frame is currently only " "possible with undocumented internal APIs." msgstr "" +"現在、フレームから実行対象の種類を読み取れるのは、文書化されていない内部 API " +"だけです。" -#: ../../c-api/frame.rst:280 msgid "The number of entries in :c:data:`PyUnstable_ExecutableKinds`." -msgstr "" +msgstr ":c:data:`PyUnstable_ExecutableKinds` のエントリー数。" diff --git a/c-api/function.po b/c-api/function.po index 4178d85cb..dfad07703 100644 --- a/c-api/function.po +++ b/c-api/function.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/function.rst:6 @@ -97,18 +97,21 @@ msgstr "関数オブジェクト *op* に関連付けられたコードオブジ msgid "Return the globals dictionary associated with the function object *op*." msgstr "関数オブジェクト *op* に関連付けられたglobals辞書を返します。" -#: ../../c-api/function.rst:67 msgid "" "Return a :term:`borrowed reference` to the :attr:`~function.__module__` " "attribute of the :ref:`function object ` *op*. It can be " "*NULL*." msgstr "" +":ref:`関数オブジェクト ` ``op`` の :attr:`~function." +"__module__` 属性への :term:`借用参照 ` を返します。\n" +"``NULL`` の場合もあります。" -#: ../../c-api/function.rst:71 msgid "" "This is normally a :class:`string ` containing the module name, but can " "be set to any other object by Python code." msgstr "" +"通常はモジュール名を含む :class:`文字列 ` ですが、Python コードで任意の" +"別のオブジェクトに設定できます。" #: ../../c-api/function.rst:77 msgid "" @@ -131,33 +134,36 @@ msgstr "" msgid "Raises :exc:`SystemError` and returns ``-1`` on failure." msgstr "失敗した時は、 :exc:`SystemError` を発生させ、 ``-1`` を返します。" -#: ../../c-api/function.rst:91 msgid "Set the vectorcall field of a given function object *func*." msgstr "" +"指定された関数オブジェクト ``func`` の vectorcall フィールドを設定します。" -#: ../../c-api/function.rst:93 msgid "" "Warning: extensions using this API must preserve the behavior of the " "unaltered (default) vectorcall function!" msgstr "" +"警告: この API を使う拡張は、変更前の (デフォルトの) vectorcall 関数の動作を" +"維持しなければなりません。" -#: ../../c-api/function.rst:101 msgid "" "Return the keyword-only argument default values of the function object *op*. " "This can be a dictionary of arguments or ``NULL``." msgstr "" +"関数オブジェクト ``op`` のキーワード専用引数のデフォルト値を返します。\n" +"引数の辞書、または ``NULL`` です。" -#: ../../c-api/function.rst:107 msgid "" "Set the keyword-only argument default values of the function object *op*. " "*defaults* must be a dictionary of keyword-only arguments or ``Py_None``." msgstr "" +"関数オブジェクト ``op`` のキーワード専用引数のデフォルト値を設定します。\n" +"``defaults`` はキーワード専用引数の辞書、または ``Py_None`` でなければなりま" +"せん。" -#: ../../c-api/function.rst:110 msgid "" "This function returns ``0`` on success, and returns ``-1`` with an exception " "set on failure." -msgstr "" +msgstr "成功時は ``0`` を返し、失敗時は例外を設定して ``-1`` を返します。" #: ../../c-api/function.rst:116 msgid "" @@ -192,76 +198,81 @@ msgstr "" "関数オブジェクト *op* のアノテーションを設定します。\n" "*annotations* は辞書か、``Py_None`` でなければなりません。" -#: ../../c-api/function.rst:150 msgid "" "These functions are similar to their ``PyFunction_Get*`` counterparts, but " "do not do type checking. Passing anything other than an instance of :c:data:" "`PyFunction_Type` is undefined behavior." msgstr "" +"これらの関数は、対応する ``PyFunction_Get*`` 関数と同様ですが、型のチェックを" +"行いません。\n" +":c:data:`PyFunction_Type` のインスタンス以外を渡すと、動作は未定義です。" -#: ../../c-api/function.rst:157 msgid "" "Register *callback* as a function watcher for the current interpreter. " "Return an ID which may be passed to :c:func:`PyFunction_ClearWatcher`. In " "case of error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" +"現在のインタープリタの関数ウォッチャーとして ``callback`` を登録します。\n" +":c:func:`PyFunction_ClearWatcher` に渡せる ID を返します。\n" +"エラーの場合 (例えば利用可能なウォッチャー ID がない場合) は、例外を設定して " +"``-1`` を返します。" -#: ../../c-api/function.rst:167 msgid "" "Clear watcher identified by *watcher_id* previously returned from :c:func:" "`PyFunction_AddWatcher` for the current interpreter. Return ``0`` on " "success, or ``-1`` and set an exception on error (e.g. if the given " "*watcher_id* was never registered.)" msgstr "" +"現在のインタープリタについて、:c:func:`PyFunction_AddWatcher` が以前返した " +"``watcher_id`` で識別されるウォッチャーを解除します。\n" +"成功した場合は ``0`` を返します。\n" +"エラーの場合 (例えば指定した ``watcher_id`` が登録されていない場合) は、例外" +"を設定して ``-1`` を返します。" -#: ../../c-api/function.rst:177 msgid "Enumeration of possible function watcher events:" -msgstr "" +msgstr "関数ウォッチャーで発生し得るイベントの列挙型。" -#: ../../c-api/function.rst:179 msgid "``PyFunction_EVENT_CREATE``" -msgstr "" +msgstr "``PyFunction_EVENT_CREATE``" -#: ../../c-api/function.rst:180 msgid "``PyFunction_EVENT_DESTROY``" -msgstr "" +msgstr "``PyFunction_EVENT_DESTROY``" -#: ../../c-api/function.rst:181 msgid "``PyFunction_EVENT_MODIFY_CODE``" -msgstr "" +msgstr "``PyFunction_EVENT_MODIFY_CODE``" -#: ../../c-api/function.rst:182 msgid "``PyFunction_EVENT_MODIFY_DEFAULTS``" -msgstr "" +msgstr "``PyFunction_EVENT_MODIFY_DEFAULTS``" -#: ../../c-api/function.rst:183 msgid "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" -msgstr "" +msgstr "``PyFunction_EVENT_MODIFY_KWDEFAULTS``" #: ../../c-api/function.rst:187 msgid "``PyFunction_PYFUNC_EVENT_MODIFY_QUALNAME``" msgstr "" -#: ../../c-api/function.rst:193 msgid "Type of a function watcher callback function." -msgstr "" +msgstr "関数ウォッチャーのコールバック関数の型。" -#: ../../c-api/function.rst:195 msgid "" "If *event* is ``PyFunction_EVENT_CREATE`` or ``PyFunction_EVENT_DESTROY`` " "then *new_value* will be ``NULL``. Otherwise, *new_value* will hold a :term:" "`borrowed reference` to the new value that is about to be stored in *func* " "for the attribute that is being modified." msgstr "" +"``event`` が ``PyFunction_EVENT_CREATE`` または ``PyFunction_EVENT_DESTROY`` " +"の場合、``new_value`` は ``NULL`` です。\n" +"それ以外の場合、``new_value`` は ``func`` の変更対象の属性に格納しようとして" +"いる新しい値への :term:`借用参照 ` です。" -#: ../../c-api/function.rst:200 msgid "" "The callback may inspect but must not modify *func*; doing so could have " "unpredictable effects, including infinite recursion." msgstr "" +"コールバックは ``func`` を調べても構いませんが、変更してはいけません。\n" +"変更すると、無限再帰など予測できない結果を招く可能性があります。" -#: ../../c-api/function.rst:203 msgid "" "If *event* is ``PyFunction_EVENT_CREATE``, then the callback is invoked " "after *func* has been fully initialized. Otherwise, the callback is invoked " @@ -272,23 +283,38 @@ msgid "" "behavior depending on optimization decisions, it does not change the " "semantics of the Python code being executed." msgstr "" +"``event`` が ``PyFunction_EVENT_CREATE`` の場合、コールバックは ``func`` の初" +"期化がすべて完了した後で呼び出されます。\n" +"それ以外の場合は ``func`` を変更する前に呼び出されるので、変更前の状態を調べ" +"られます。\n" +"ランタイムは、可能であれば最適化によって関数オブジェクトの作成を省略しても構" +"いません。\n" +"その場合、イベントは発生しません。\n" +"このため、最適化の判断によって観測できる実行時の動作に違いが生じる可能性はあ" +"りますが、実行される Python コードの意味は変わりません。" -#: ../../c-api/function.rst:212 msgid "" "If *event* is ``PyFunction_EVENT_DESTROY``, taking a reference in the " "callback to the about-to-be-destroyed function will resurrect it, preventing " "it from being freed at this time. When the resurrected object is destroyed " "later, any watcher callbacks active at that time will be called again." msgstr "" +"``event`` が ``PyFunction_EVENT_DESTROY`` の場合、コールバック内で破棄されよ" +"うとしている関数への参照を取得すると、その関数が復活し、この時点での解放を防" +"ぎます。\n" +"復活したオブジェクトが後で破棄されるときは、その時点で有効なウォッチャーの" +"コールバックが再び呼び出されます。" -#: ../../c-api/function.rst:217 msgid "" "If the callback sets an exception, it must return ``-1``; this exception " "will be printed as an unraisable exception using :c:func:" "`PyErr_WriteUnraisable`. Otherwise it should return ``0``." msgstr "" +"コールバックが例外を設定した場合は ``-1`` を返す必要があります。\n" +"その例外は、:c:func:`PyErr_WriteUnraisable` を使って送出できない例外として表" +"示されます。\n" +"それ以外の場合は ``0`` を返してください。" -#: ../../c-api/function.rst:221 msgid "" "There may already be a pending exception set on entry to the callback. In " "this case, the callback should return ``0`` with the same exception still " @@ -296,6 +322,11 @@ msgid "" "exception unless it saves and clears the exception state first, and restores " "it before returning." msgstr "" +"コールバックに入る時点で、すでに処理待ちの例外が設定されている場合がありま" +"す。\n" +"その場合、コールバックは同じ例外を設定したまま ``0`` を返すべきです。\n" +"そのため、例外を設定し得る別の API を呼び出す場合は、まず例外の状態を保存して" +"クリアし、戻る前に復元する必要があります。" #: ../../c-api/function.rst:8 msgid "object" diff --git a/c-api/gcsupport.po b/c-api/gcsupport.po index c1f4cef09..9f39cedb4 100644 --- a/c-api/gcsupport.po +++ b/c-api/gcsupport.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/gcsupport.rst:6 @@ -42,7 +42,6 @@ msgstr "" "参照だけを記憶するような型では、ガベージコレクションに際して特別これといった" "サポートを提供する必要はありません。" -#: ../../c-api/gcsupport.rst:15 msgid "" "To create a container type, the :c:member:`~PyTypeObject.tp_flags` field of " "the type object must include the :c:macro:`Py_TPFLAGS_HAVE_GC` and provide " @@ -50,10 +49,14 @@ msgid "" "instances of the type are mutable, a :c:member:`~PyTypeObject.tp_clear` " "implementation must also be provided." msgstr "" +"コンテナ型を作成するには、型オブジェクトの :c:member:`~PyTypeObject." +"tp_flags` フィールドに :c:macro:`Py_TPFLAGS_HAVE_GC` を含め、:c:member:" +"`~PyTypeObject.tp_traverse` ハンドラを実装する必要があります。\n" +"型のインスタンスが変更可能な場合は、:c:member:`~PyTypeObject.tp_clear` も実装" +"する必要があります。" -#: ../../c-api/gcsupport.rst:21 msgid ":c:macro:`Py_TPFLAGS_HAVE_GC`" -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_HAVE_GC`" #: ../../c-api/gcsupport.rst:22 msgid "" @@ -70,11 +73,12 @@ msgid "Constructors for container types must conform to two rules:" msgstr "" "コンテナ型のコンストラクタは以下の二つの規則に適合しなければなりません:" -#: ../../c-api/gcsupport.rst:28 msgid "" "The memory for the object must be allocated using :c:macro:`PyObject_GC_New` " "or :c:macro:`PyObject_GC_NewVar`." msgstr "" +"オブジェクトのメモリは :c:macro:`PyObject_GC_New` または :c:macro:" +"`PyObject_GC_NewVar` で割り当てなければなりません。" #: ../../c-api/gcsupport.rst:31 msgid "" @@ -113,7 +117,6 @@ msgid "" "subclass or subclasses." msgstr "" -#: ../../c-api/gcsupport.rst:47 msgid "" "When calling :c:func:`PyType_Ready` or some of the APIs that indirectly call " "it like :c:func:`PyType_FromSpecWithBases` or :c:func:`PyType_FromSpec` the " @@ -123,87 +126,106 @@ msgid "" "implements the garbage collector protocol and the child class does *not* " "include the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" +":c:func:`PyType_Ready`、または :c:func:`PyType_FromSpecWithBases` や :c:func:" +"`PyType_FromSpec` など間接的にこの関数を呼び出す API を使った際、\n" +"ガベージコレクタのプロトコルを実装するクラスを継承しており、派生クラスに :c:" +"macro:`Py_TPFLAGS_HAVE_GC` フラグが含まれて *いない* 場合は、\n" +"インタープリタが :c:member:`~PyTypeObject.tp_flags`、:c:member:" +"`~PyTypeObject.tp_traverse`、:c:member:`~PyTypeObject.tp_clear` フィールドを" +"自動的に設定します。" -#: ../../c-api/gcsupport.rst:57 msgid "" "Analogous to :c:macro:`PyObject_New` but for container objects with the :c:" "macro:`Py_TPFLAGS_HAVE_GC` flag set." msgstr "" +":c:macro:`PyObject_New` と同様ですが、:c:macro:`Py_TPFLAGS_HAVE_GC` フラグが" +"設定されたコンテナオブジェクト用です。" -#: ../../c-api/gcsupport.rst:60 ../../c-api/gcsupport.rst:84 msgid "" "Do not call this directly to allocate memory for an object; call the type's :" "c:member:`~PyTypeObject.tp_alloc` slot instead." msgstr "" +"オブジェクトのメモリを割り当てるためにこれを直接呼び出してはいけません。\n" +"代わりに型の :c:member:`~PyTypeObject.tp_alloc` スロットを呼び出してくださ" +"い。" -#: ../../c-api/gcsupport.rst:63 ../../c-api/gcsupport.rst:87 msgid "" "When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot, :c:func:" "`PyType_GenericAlloc` is preferred over a custom function that simply calls " "this macro." msgstr "" +"型の :c:member:`~PyTypeObject.tp_alloc` スロットには、このマクロを呼び出すだ" +"けの独自の関数よりも :c:func:`PyType_GenericAlloc` を設定することが推奨されま" +"す。" -#: ../../c-api/gcsupport.rst:67 ../../c-api/gcsupport.rst:91 msgid "" "Memory allocated by this macro must be freed with :c:func:`PyObject_GC_Del` " "(usually called via the object's :c:member:`~PyTypeObject.tp_free` slot)." msgstr "" +"このマクロで割り当てたメモリは :c:func:`PyObject_GC_Del` で解放しなければなり" +"ません (通常はオブジェクトの :c:member:`~PyTypeObject.tp_free` スロットを介し" +"て呼び出します)。" -#: ../../c-api/gcsupport.rst:73 ../../c-api/gcsupport.rst:97 msgid ":c:func:`PyObject_GC_Del`" -msgstr "" +msgstr ":c:func:`PyObject_GC_Del`" -#: ../../c-api/gcsupport.rst:74 msgid ":c:macro:`PyObject_New`" -msgstr "" +msgstr ":c:macro:`PyObject_New`" -#: ../../c-api/gcsupport.rst:75 ../../c-api/gcsupport.rst:99 -#: ../../c-api/gcsupport.rst:193 msgid ":c:func:`PyType_GenericAlloc`" -msgstr "" +msgstr ":c:func:`PyType_GenericAlloc`" #: ../../c-api/gcsupport.rst:76 ../../c-api/gcsupport.rst:100 msgid ":c:member:`~PyTypeObject.tp_alloc`" msgstr ":c:member:`~PyTypeObject.tp_alloc`" -#: ../../c-api/gcsupport.rst:81 msgid "" "Analogous to :c:macro:`PyObject_NewVar` but for container objects with the :" "c:macro:`Py_TPFLAGS_HAVE_GC` flag set." msgstr "" +":c:macro:`PyObject_NewVar` と同様ですが、:c:macro:`Py_TPFLAGS_HAVE_GC` フラグ" +"が設定されたコンテナオブジェクト用です。" -#: ../../c-api/gcsupport.rst:98 msgid ":c:macro:`PyObject_NewVar`" -msgstr "" +msgstr ":c:macro:`PyObject_NewVar`" -#: ../../c-api/gcsupport.rst:105 msgid "" "Analogous to :c:macro:`PyObject_GC_New` but allocates *extra_size* bytes at " "the end of the object (at offset :c:member:`~PyTypeObject.tp_basicsize`). " "The allocated memory is initialized to zeros, except for the :c:type:`Python " "object header `." msgstr "" +":c:macro:`PyObject_GC_New` と同様ですが、オブジェクトの末尾 (オフセット :c:" +"member:`~PyTypeObject.tp_basicsize`) に *extra_size* バイトを割り当てます。\n" +"割り当てたメモリは :c:type:`Python オブジェクトのヘッダー ` を除い" +"てゼロで初期化されます。" -#: ../../c-api/gcsupport.rst:111 msgid "" "The extra data will be deallocated with the object, but otherwise it is not " "managed by Python." msgstr "" +"追加データはオブジェクトとともに解放されますが、それ以外の管理は Python では" +"行いません。" -#: ../../c-api/gcsupport.rst:114 msgid "" "Memory allocated by this function must be freed with :c:func:" "`PyObject_GC_Del` (usually called via the object's :c:member:`~PyTypeObject." "tp_free` slot)." msgstr "" +"この関数で割り当てたメモリは :c:func:`PyObject_GC_Del` で解放しなければなりま" +"せん (通常はオブジェクトの :c:member:`~PyTypeObject.tp_free` スロットを介して" +"呼び出します)。" -#: ../../c-api/gcsupport.rst:119 msgid "" "The function is marked as unstable because the final mechanism for reserving " "extra data after an instance is not yet decided. For allocating a variable " "number of fields, prefer using :c:type:`PyVarObject` and :c:member:" "`~PyTypeObject.tp_itemsize` instead." msgstr "" +"インスタンスの後ろに追加データを確保する最終的な仕組みが未定のため、この関数" +"は不安定とされています。\n" +"可変個数のフィールドを割り当てるには、代わりに :c:type:`PyVarObject` と :c:" +"member:`~PyTypeObject.tp_itemsize` を使うことが推奨されます。" #: ../../c-api/gcsupport.rst:130 msgid "" @@ -212,13 +234,14 @@ msgid "" "failure." msgstr "" -#: ../../c-api/gcsupport.rst:134 msgid "" "*op* must be of type :c:expr:`PyVarObject *` and must not be tracked by the " "collector yet. *newsize* must be of type :c:type:`Py_ssize_t`." msgstr "" +"*op* の型は :c:expr:`PyVarObject *` でなければならず、まだコレクタの追跡対象" +"になっていてはいけません。\n" +"*newsize* の型は :c:type:`Py_ssize_t` でなければなりません。" -#: ../../c-api/gcsupport.rst:141 msgid "" "Adds the object *op* to the set of container objects tracked by the " "collector. The collector can run at unexpected times so objects must be " @@ -226,74 +249,78 @@ msgid "" "followed by the :c:member:`~PyTypeObject.tp_traverse` handler become valid, " "usually near the end of the constructor." msgstr "" -"オブジェクト *op* を、コレクタによって追跡されるオブジェクトの集合に追加しま" -"す。コレクタは何回動くのかは予想できないので、追跡されている間はオブジェクト" -"は正しい状態でいなければなりません。 :c:member:`~PyTypeObject.tp_traverse` の" -"対象となる全てのフィールドが正しい状態になってすぐに、たいていはコンストラク" -"タの末尾付近で、呼び出すべきです。" +"オブジェクト *op* を、コレクタが追跡するコンテナオブジェクトの集合に追加しま" +"す。\n" +"コレクタは予期しないタイミングで実行される可能性があるため、追跡中のオブジェ" +"クトは有効な状態でなければなりません。\n" +":c:member:`~PyTypeObject.tp_traverse` ハンドラがたどるすべてのフィールドが有" +"効になった時点で、通常はコンストラクタの終わり近くで呼び出してください。" -#: ../../c-api/gcsupport.rst:150 msgid "" "Returns non-zero if the object implements the garbage collector protocol, " "otherwise returns 0." msgstr "" +"オブジェクトがガベージコレクタのプロトコルを実装している場合はゼロ以外、そう" +"でなければ 0 を返します。" -#: ../../c-api/gcsupport.rst:153 msgid "" "The object cannot be tracked by the garbage collector if this function " "returns 0." msgstr "" +"この関数が 0 を返す場合、そのオブジェクトをガベージコレクタの追跡対象にはでき" +"ません。" -#: ../../c-api/gcsupport.rst:158 msgid "" "Returns 1 if the object type of *op* implements the GC protocol and *op* is " "being currently tracked by the garbage collector and 0 otherwise." msgstr "" +"*op* の型が GC プロトコルを実装しており、*op* が現在ガベージコレクタに追跡さ" +"れている場合は 1 を、それ以外の場合は 0 を返します。" -#: ../../c-api/gcsupport.rst:161 msgid "This is analogous to the Python function :func:`gc.is_tracked`." -msgstr "" +msgstr "Python の :func:`gc.is_tracked` 関数に相当します。" -#: ../../c-api/gcsupport.rst:168 msgid "" "Returns 1 if the object type of *op* implements the GC protocol and *op* has " "been already finalized by the garbage collector and 0 otherwise." msgstr "" +"*op* の型が GC プロトコルを実装しており、*op* がガベージコレクタによってすで" +"にファイナライズされている場合は 1 を、それ以外の場合は 0 を返します。" -#: ../../c-api/gcsupport.rst:171 msgid "This is analogous to the Python function :func:`gc.is_finalized`." -msgstr "" +msgstr "Python の :func:`gc.is_finalized` 関数に相当します。" -#: ../../c-api/gcsupport.rst:178 msgid "" "Releases memory allocated to an object using :c:macro:`PyObject_GC_New` or :" "c:macro:`PyObject_GC_NewVar`." msgstr "" +":c:macro:`PyObject_GC_New` または :c:macro:`PyObject_GC_NewVar` でオブジェク" +"トに割り当てたメモリを解放します。" -#: ../../c-api/gcsupport.rst:181 msgid "" "Do not call this directly to free an object's memory; call the type's :c:" "member:`~PyTypeObject.tp_free` slot instead." msgstr "" +"オブジェクトのメモリを解放するために直接呼び出さず、代わりに型の :c:member:" +"`~PyTypeObject.tp_free` スロットを呼び出してください。" -#: ../../c-api/gcsupport.rst:184 msgid "" "Do not use this for memory allocated by :c:macro:`PyObject_New`, :c:macro:" "`PyObject_NewVar`, or related allocation functions; use :c:func:" "`PyObject_Free` instead." msgstr "" +":c:macro:`PyObject_New`、:c:macro:`PyObject_NewVar`、または関連する割り当て関" +"数で割り当てたメモリには使わないでください。\n" +"代わりに :c:func:`PyObject_Free` を使ってください。" -#: ../../c-api/gcsupport.rst:190 msgid ":c:func:`PyObject_Free` is the non-GC equivalent of this function." -msgstr "" +msgstr ":c:func:`PyObject_Free` はこの関数の非 GC 版です。" -#: ../../c-api/gcsupport.rst:191 msgid ":c:macro:`PyObject_GC_New`" -msgstr "" +msgstr ":c:macro:`PyObject_GC_New`" -#: ../../c-api/gcsupport.rst:192 msgid ":c:macro:`PyObject_GC_NewVar`" -msgstr "" +msgstr ":c:macro:`PyObject_GC_NewVar`" #: ../../c-api/gcsupport.rst:194 msgid ":c:member:`~PyTypeObject.tp_free`" @@ -315,11 +342,12 @@ msgstr "" "ケータ (:c:member:`~PyTypeObject.tp_dealloc` ハンドラ) はオブジェクトに対し" "て、この関数を呼び出すべきです。" -#: ../../c-api/gcsupport.rst:208 msgid "" "The :c:func:`!_PyObject_GC_TRACK` and :c:func:`!_PyObject_GC_UNTRACK` macros " "have been removed from the public C API." msgstr "" +":c:func:`!_PyObject_GC_TRACK` マクロと :c:func:`!_PyObject_GC_UNTRACK` マクロ" +"は、公開 C API から削除されました。" #: ../../c-api/gcsupport.rst:211 msgid "" @@ -369,9 +397,8 @@ msgstr "" "ください)。ガベージコレクタは、オブジェクトが循環参照を形成していることを検出" "した際にこのメソッドを呼び出します。" -#: ../../c-api/gcsupport.rst:240 msgid "Traversal" -msgstr "" +msgstr "巡回" #: ../../c-api/gcsupport.rst:242 msgid "" @@ -381,7 +408,6 @@ msgstr "" ":c:member:`~PyTypeObject.tp_traverse` ハンドラは次の型を持っていなければなり" "ません:" -#: ../../c-api/gcsupport.rst:246 msgid "" "Traversal function for a garbage-collected object, used by the garbage " "collector to detect reference cycles. Implementations must call the *visit* " @@ -391,16 +417,26 @@ msgid "" "argument. If *visit* returns a non-zero value, that value should be " "returned immediately." msgstr "" +"ガベージコレクタが循環参照を検出するために使う、ガベージコレクション対象オブ" +"ジェクトの巡回関数です。\n" +"実装では、*self* が直接保持するオブジェクトごとに *visit* 関数を呼び出し、そ" +"のオブジェクトとハンドラに渡された *arg* を引数として渡さなければなりませ" +"ん。\n" +"オブジェクト引数を ``NULL`` にして *visit* 関数を呼び出してはいけません。\n" +"*visit* がゼロ以外の値を返した場合は、その値を直ちに返す必要があります。" -#: ../../c-api/gcsupport.rst:255 msgid "" "A typical :c:member:`!tp_traverse` function calls the :c:func:`Py_VISIT` " "convenience macro on each of the instance's members that are Python objects " "that the instance owns. For example, this is a (slightly outdated) traversal " "function for the :py:class:`threading.local` class::" msgstr "" +"典型的な :c:member:`!tp_traverse` 関数は、インスタンスが所有する Python オブ" +"ジェクトのメンバーそれぞれに対して、便利なマクロ :c:func:`Py_VISIT` を呼び出" +"します。\n" +"例えば、次は :py:class:`threading.local` クラスの巡回関数です (やや古い実装で" +"す)。 ::" -#: ../../c-api/gcsupport.rst:261 msgid "" "static int\n" "local_traverse(PyObject *op, visitproc visit, void *arg)\n" @@ -413,45 +449,67 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"local_traverse(PyObject *op, visitproc visit, void *arg)\n" +"{\n" +" localobject *self = (localobject *) op;\n" +" Py_VISIT(Py_TYPE(self));\n" +" Py_VISIT(self->args);\n" +" Py_VISIT(self->kw);\n" +" Py_VISIT(self->dict);\n" +" return 0;\n" +"}" -#: ../../c-api/gcsupport.rst:273 msgid "" ":c:func:`Py_VISIT` requires the *visit* and *arg* parameters to :c:func:`!" "local_traverse` to have these specific names; don't name them just anything." msgstr "" +":c:func:`Py_VISIT` を使うには、:c:func:`!local_traverse` の *visit* 引数と " +"*arg* 引数を正確にこの名前にする必要があります。\n" +"任意の名前を付けてはいけません。" -#: ../../c-api/gcsupport.rst:277 msgid "" "Instances of :ref:`heap-allocated types ` hold a reference to " "their type. Their traversal function must therefore visit the type::" msgstr "" +":ref:`ヒープに割り当てられた型 ` のインスタンスは、自分の型への参" +"照を保持します。\n" +"したがって、その巡回関数では型も巡回する必要があります。 ::" -#: ../../c-api/gcsupport.rst:280 msgid "Py_VISIT(Py_TYPE(self));" -msgstr "" +msgstr "Py_VISIT(Py_TYPE(self));" -#: ../../c-api/gcsupport.rst:282 msgid "" "Alternately, the type may delegate this responsibility by calling " "``tp_traverse`` of a heap-allocated superclass (or another heap-allocated " "type, if applicable). If they do not, the type object may not be garbage-" "collected." msgstr "" +"代わりに、ヒープに割り当てられた基底クラス (または適切であれば他のヒープに割" +"り当てられた型) の ``tp_traverse`` を呼び出して、この処理を委譲することもでき" +"ます。\n" +"どちらも行わない場合、型オブジェクトがガベージコレクションで回収されない可能" +"性があります。" -#: ../../c-api/gcsupport.rst:287 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, the traverse function must call :c:func:" "`PyObject_VisitManagedDict` like this::" msgstr "" +":c:member:`~PyTypeObject.tp_flags` フィールドに :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` ビットが設定されている場合、巡回関数は次のように :" +"c:func:`PyObject_VisitManagedDict` を呼び出す必要があります。 ::" -#: ../../c-api/gcsupport.rst:291 msgid "" "int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg);\n" "if (err) {\n" " return err;\n" "}" msgstr "" +"int err = PyObject_VisitManagedDict((PyObject*)self, visit, arg);\n" +"if (err) {\n" +" return err;\n" +"}" #: ../../c-api/gcsupport.rst:296 msgid "" @@ -463,18 +521,18 @@ msgid "" "directly own the weak references to itself." msgstr "" -#: ../../c-api/gcsupport.rst:303 msgid "The traversal function has a limitation:" -msgstr "" +msgstr "巡回関数には次の制約があります。" -#: ../../c-api/gcsupport.rst:307 msgid "" "The traversal function must not have any side effects. Implementations may " "not modify the reference counts of any Python objects nor create or destroy " "any Python objects, directly or indirectly." msgstr "" +"巡回関数は副作用を起こしてはいけません。\n" +"実装では、直接的にも間接的にも、Python オブジェクトの参照カウントを変更した" +"り、Python オブジェクトを作成または破棄したりしてはいけません。" -#: ../../c-api/gcsupport.rst:311 msgid "" "This means that *most* Python C API functions may not be used, since they " "can raise a new exception, return a new reference to a result object, have " @@ -482,69 +540,90 @@ msgid "" "functions that happen to not have side effects may start having them in " "future versions, without warning." msgstr "" +"つまり、Python C API の *ほとんど* の関数は使用できません。\n" +"新しい例外を送出したり、結果のオブジェクトへの新しい参照を返したり、内部処理" +"で副作用を起こしたりするためです。\n" +"また、特に明記されていない限り、たまたま副作用がない関数でも、将来のバージョ" +"ンで予告なく副作用を起こすようになる可能性があります。" -#: ../../c-api/gcsupport.rst:317 msgid "" "For a list of safe functions, see a :ref:`separate section ` below." msgstr "" +"安全に使える関数の一覧は、後述の :ref:`専用の節 ` を参照" +"してください。" -#: ../../c-api/gcsupport.rst:322 msgid "" "The :c:func:`Py_VISIT` call may be skipped for those members that provably " "cannot participate in reference cycles. In the ``local_traverse`` example " "above, there is also a ``self->key`` member, but it can only be ``NULL`` or " "a Python string and therefore cannot be part of a reference cycle." msgstr "" +"循環参照に関与しないことを証明できるメンバーについては、:c:func:`Py_VISIT` の" +"呼び出しを省略できます。\n" +"上の ``local_traverse`` の例には ``self->key`` メンバーもありますが、この値" +"は ``NULL`` または Python の文字列に限られるので、循環参照の一部にはなりませ" +"ん。" -#: ../../c-api/gcsupport.rst:328 msgid "" "On the other hand, even if you know a member can never be part of a cycle, " "as a debugging aid you may want to visit it anyway just so the :mod:`gc` " "module's :func:`~gc.get_referents` function will include it." msgstr "" -"一方、メンバが循環参照の一部になり得ないと判っていても、デバッグ目的で巡回し" -"たい場合があるかもしれないので、 :mod:`gc` モジュールの :func:`~gc." -"get_referents` 関数は循環参照になり得ないメンバも返します。" +"一方、メンバーが循環参照の一部にならないと分かっていても、デバッグのために巡" +"回しておくと、:mod:`gc` モジュールの :func:`~gc.get_referents` 関数の結果にそ" +"のメンバーを含められます。" -#: ../../c-api/gcsupport.rst:334 msgid "" "The :c:member:`~PyTypeObject.tp_traverse` function can be called from any " "thread." msgstr "" +":c:member:`~PyTypeObject.tp_traverse` 関数は、どのスレッドからも呼び出される" +"可能性があります。" -#: ../../c-api/gcsupport.rst:339 msgid "" "Garbage collection is a \"stop-the-world\" operation: even in :term:`free " "threading` builds, only one thread state is :term:`attached ` when :c:member:`!tp_traverse` handlers run." msgstr "" +"ガベージコレクションは「stop-the-world」の操作です。\n" +":term:`フリースレッド ` ビルドでも、:c:member:`!tp_traverse` " +"ハンドラの実行中に :term:`アタッチされている ` スレッ" +"ド状態は 1 つだけです。" -#: ../../c-api/gcsupport.rst:346 msgid "" "Heap-allocated types are expected to visit ``Py_TYPE(self)`` in " "``tp_traverse``. In earlier versions of Python, due to `bug 40217 `_, doing this may lead to crashes in subclasses." msgstr "" +"ヒープに割り当てられた型は、``tp_traverse`` で ``Py_TYPE(self)`` を巡回するこ" +"とが期待されます。\n" +"以前のバージョンの Python では、`バグ 40217 `_ によって、この処理がサブクラスのクラッシュを引き起こす場合があ" +"ります。" -#: ../../c-api/gcsupport.rst:351 msgid "" "To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:" "func:`Py_VISIT` macro is provided. In order to use this macro, the :c:member:" "`~PyTypeObject.tp_traverse` implementation must name its arguments exactly " "*visit* and *arg*:" msgstr "" +":c:member:`~PyTypeObject.tp_traverse` ハンドラを簡単に記述できるように、:c:" +"func:`Py_VISIT` マクロが用意されています。\n" +"このマクロを使うには、:c:member:`~PyTypeObject.tp_traverse` の実装で引数の名" +"前を正確に *visit* と *arg* にする必要があります。" -#: ../../c-api/gcsupport.rst:358 msgid "" "If the :c:expr:`PyObject *` *o* is not ``NULL``, call the *visit* callback, " "with arguments *o* and *arg*. If *visit* returns a non-zero value, then " "return it." msgstr "" +":c:expr:`PyObject *` 型の *o* が ``NULL`` でなければ、*o* と *arg* を引数とし" +"て *visit* コールバックを呼び出します。\n" +"*visit* がゼロ以外の値を返した場合は、その値を返します。" -#: ../../c-api/gcsupport.rst:362 msgid "This corresponds roughly to::" -msgstr "" +msgstr "おおむね次のコードに相当します。 ::" #: ../../c-api/gcsupport.rst:364 msgid "" @@ -557,185 +636,206 @@ msgid "" " }" msgstr "" -#: ../../c-api/gcsupport.rst:374 msgid "Traversal-safe functions" -msgstr "" +msgstr "巡回中に安全に使える関数" -#: ../../c-api/gcsupport.rst:376 msgid "" "The following functions and macros are safe to use in a :c:member:" "`~PyTypeObject.tp_traverse` handler:" msgstr "" +"次の関数とマクロは :c:member:`~PyTypeObject.tp_traverse` ハンドラ内で安全に使" +"えます。" -#: ../../c-api/gcsupport.rst:379 msgid "the *visit* function passed to ``tp_traverse``" -msgstr "" +msgstr "``tp_traverse`` に渡された *visit* 関数" -#: ../../c-api/gcsupport.rst:380 msgid ":c:func:`Py_VISIT`" -msgstr "" +msgstr ":c:func:`Py_VISIT`" -#: ../../c-api/gcsupport.rst:381 msgid ":c:func:`Py_SIZE`" -msgstr "" +msgstr ":c:func:`Py_SIZE`" -#: ../../c-api/gcsupport.rst:382 msgid "" ":c:func:`Py_TYPE`: if called from a :c:member:`!tp_traverse` handler, :c:" "func:`!Py_TYPE`'s result will be valid for the duration of the handler call" msgstr "" +":c:func:`Py_TYPE`: :c:member:`!tp_traverse` ハンドラから呼び出した場合、:c:" +"func:`!Py_TYPE` の結果はそのハンドラの呼び出し中ずっと有効です" -#: ../../c-api/gcsupport.rst:384 msgid ":c:func:`PyObject_VisitManagedDict`" -msgstr "" +msgstr ":c:func:`PyObject_VisitManagedDict`" -#: ../../c-api/gcsupport.rst:385 msgid "" ":c:func:`PyObject_TypeCheck`, :c:func:`PyType_IsSubtype`, :c:func:" "`PyType_HasFeature`" msgstr "" +":c:func:`PyObject_TypeCheck`, :c:func:`PyType_IsSubtype`, :c:func:" +"`PyType_HasFeature`" -#: ../../c-api/gcsupport.rst:387 msgid "" ":samp:`Py{}_Check` and :samp:`Py{}_CheckExact` -- for example, :" "c:func:`PyTuple_Check`" msgstr "" +":samp:`Py{}_Check` と :samp:`Py{}_CheckExact`。\n" +"例えば :c:func:`PyTuple_Check`" -#: ../../c-api/gcsupport.rst:389 msgid ":ref:`duringgc-functions`" -msgstr "" +msgstr ":ref:`duringgc-functions`" -#: ../../c-api/gcsupport.rst:394 msgid "\"DuringGC\" functions" -msgstr "" +msgstr "「DuringGC」関数" -#: ../../c-api/gcsupport.rst:396 msgid "" "The following functions should *only* be used in a :c:member:`~PyTypeObject." "tp_traverse` handler; calling them in other contexts may have unintended " "consequences." msgstr "" +"次の関数は :c:member:`~PyTypeObject.tp_traverse` ハンドラ内で *のみ* 使うべき" +"です。\n" +"他の文脈で呼び出すと、意図しない結果を招く可能性があります。" -#: ../../c-api/gcsupport.rst:400 msgid "" "These functions act like their counterparts without the ``_DuringGC`` " "suffix, but they are guaranteed to not have side effects, they do not set an " "exception on failure, and they return/set :term:`borrowed references " "` as detailed in the individual documentation." msgstr "" +"これらの関数は ``_DuringGC`` サフィックスのない対応する関数と同様に動作します" +"が、副作用を起こさないことが保証され、失敗しても例外を設定せず、個別の説明に" +"記載されているとおり :term:`借用参照 ` を返す、または設定" +"します。" -#: ../../c-api/gcsupport.rst:405 msgid "" "Note that these functions may fail (return ``NULL`` or ``-1``), but as they " "do not set an exception, no error information is available. In some cases, " "failure is not distinguishable from a successful ``NULL`` result." msgstr "" +"これらの関数は失敗する (``NULL`` または ``-1`` を返す) ことがありますが、例外" +"を設定しないのでエラー情報は得られません。\n" +"場合によっては、失敗と成功時の ``NULL`` の結果を区別できません。" -#: ../../c-api/gcsupport.rst:415 ../../c-api/gcsupport.rst:430 -#: ../../c-api/gcsupport.rst:443 msgid "See :ref:`duringgc-functions` for common information." -msgstr "" +msgstr "共通の情報は :ref:`duringgc-functions` を参照してください。" -#: ../../c-api/gcsupport.rst:421 msgid "" ":c:func:`PyObject_GetTypeData`, :c:func:`PyObject_GetItemData`, :c:func:" "`PyType_GetModuleState`, :c:func:`PyModule_GetState`, :c:func:" "`PyModule_GetToken`, :c:func:`PyType_GetBaseByToken`" msgstr "" +":c:func:`PyObject_GetTypeData`, :c:func:`PyObject_GetItemData`, :c:func:" +"`PyType_GetModuleState`, :c:func:`PyModule_GetState`, :c:func:" +"`PyModule_GetToken`, :c:func:`PyType_GetBaseByToken`" -#: ../../c-api/gcsupport.rst:432 msgid "" "Sets *\\*result* to a :term:`borrowed reference` rather than a strong one. " "The reference is valid for the duration of the :c:member:`!tp_traverse` " "handler call." msgstr "" +"*\\*result* には強参照ではなく :term:`借用参照 ` を設定し" +"ます。\n" +"この参照は :c:member:`!tp_traverse` ハンドラの呼び出し中ずっと有効です。" -#: ../../c-api/gcsupport.rst:438 msgid ":c:func:`PyType_GetBaseByToken`" -msgstr "" +msgstr ":c:func:`PyType_GetBaseByToken`" -#: ../../c-api/gcsupport.rst:445 msgid "" "These functions return a :term:`borrowed reference`, which is valid for the " "duration of the :c:member:`!tp_traverse` handler call." msgstr "" +"これらの関数は :term:`借用参照 ` を返します。\n" +"この参照は :c:member:`!tp_traverse` ハンドラの呼び出し中ずっと有効です。" -#: ../../c-api/gcsupport.rst:452 msgid ":c:func:`PyType_GetModule`, :c:func:`PyType_GetModuleByToken`" -msgstr "" +msgstr ":c:func:`PyType_GetModule`, :c:func:`PyType_GetModuleByToken`" -#: ../../c-api/gcsupport.rst:457 msgid "Controlling the Garbage Collector State" -msgstr "" +msgstr "ガベージコレクタの状態を制御する" -#: ../../c-api/gcsupport.rst:459 msgid "" "The C-API provides the following functions for controlling garbage " "collection runs." msgstr "" +"C API は、ガベージコレクションの実行を制御するために次の関数を提供します。" -#: ../../c-api/gcsupport.rst:464 msgid "" "Perform a full garbage collection, if the garbage collector is enabled. " "(Note that :func:`gc.collect` runs it unconditionally.)" msgstr "" +"ガベージコレクタが有効な場合に、完全なガベージコレクションを実行します (:" +"func:`gc.collect` は無条件に実行する点に注意してください)。" -#: ../../c-api/gcsupport.rst:467 msgid "" "Returns the number of collected + unreachable objects which cannot be " "collected. If the garbage collector is disabled or already collecting, " "returns ``0`` immediately. Errors during garbage collection are passed to :" "data:`sys.unraisablehook`. This function does not raise exceptions." msgstr "" +"回収したオブジェクト数と、到達不能なのに回収できないオブジェクト数の合計を返" +"します。\n" +"ガベージコレクタが無効か、すでに回収を実行している場合は、直ちに ``0`` を返し" +"ます。\n" +"ガベージコレクション中のエラーは :data:`sys.unraisablehook` に渡されます。\n" +"この関数は例外を送出しません。" -#: ../../c-api/gcsupport.rst:477 msgid "" "Enable the garbage collector: similar to :func:`gc.enable`. Returns the " "previous state, 0 for disabled and 1 for enabled." msgstr "" +"ガベージコレクタを有効にします。\n" +":func:`gc.enable` に相当します。\n" +"以前の状態を返し、無効だった場合は 0、有効だった場合は 1 です。" -#: ../../c-api/gcsupport.rst:485 msgid "" "Disable the garbage collector: similar to :func:`gc.disable`. Returns the " "previous state, 0 for disabled and 1 for enabled." msgstr "" +"ガベージコレクタを無効にします。\n" +":func:`gc.disable` に相当します。\n" +"以前の状態を返し、無効だった場合は 0、有効だった場合は 1 です。" -#: ../../c-api/gcsupport.rst:493 msgid "" "Query the state of the garbage collector: similar to :func:`gc.isenabled`. " "Returns the current state, 0 for disabled and 1 for enabled." msgstr "" +"ガベージコレクタの状態を問い合わせます。\n" +":func:`gc.isenabled` に相当します。\n" +"現在の状態を返し、無効の場合は 0、有効の場合は 1 です。" -#: ../../c-api/gcsupport.rst:500 msgid "Querying Garbage Collector State" -msgstr "" +msgstr "ガベージコレクタの状態を問い合わせる" -#: ../../c-api/gcsupport.rst:502 msgid "" "The C-API provides the following interface for querying information about " "the garbage collector." msgstr "" +"C API は、ガベージコレクタの情報を問い合わせるために次のインターフェースを提" +"供します。" -#: ../../c-api/gcsupport.rst:507 msgid "" "Run supplied *callback* on all live GC-capable objects. *arg* is passed " "through to all invocations of *callback*." msgstr "" +"生存しているすべての GC 対応オブジェクトに対して、指定された *callback* を実" +"行します。\n" +"*callback* を呼び出すたびに *arg* をそのまま渡します。" -#: ../../c-api/gcsupport.rst:511 msgid "" "If new objects are (de)allocated by the callback it is undefined if they " "will be visited." msgstr "" +"コールバックがオブジェクトを割り当てたり解放したりした場合、それらのオブジェ" +"クトが巡回されるかどうかは未定義です。" -#: ../../c-api/gcsupport.rst:514 msgid "" "Garbage collection is disabled during operation. Explicitly running a " "collection in the callback may lead to undefined behaviour e.g. visiting the " "same objects multiple times or not at all." msgstr "" +"処理中はガベージコレクションが無効になります。\n" +"コールバック内で明示的にコレクションを実行すると、同じオブジェクトを複数回巡" +"回したり、まったく巡回しなかったりするなど、未定義の動作を引き起こす可能性が" +"あります。" -#: ../../c-api/gcsupport.rst:522 msgid "" "Type of the visitor function to be passed to :c:func:" "`PyUnstable_GC_VisitObjects`. *arg* is the same as the *arg* passed to " @@ -743,3 +843,8 @@ msgid "" "``0`` to stop iteration. Other return values are reserved for now so " "behavior on returning anything else is undefined." msgstr "" +":c:func:`PyUnstable_GC_VisitObjects` に渡すビジター関数の型です。\n" +"*arg* は ``PyUnstable_GC_VisitObjects`` に渡された *arg* と同じです。\n" +"反復処理を続けるには ``1``、停止するには ``0`` を返してください。\n" +"その他の戻り値は現在予約されており、これら以外の値を返した場合の動作は未定義" +"です。" diff --git a/c-api/gen.po b/c-api/gen.po index 2153b6256..57a2e5bae 100644 --- a/c-api/gen.po +++ b/c-api/gen.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/gen.rst:6 @@ -54,78 +54,90 @@ msgstr "" "*ob* がジェネレータオブジェクトの場合に真を返ます、 *ob* は ``NULL`` であって" "はなりません。この関数は常に成功します。" -#: ../../c-api/gen.rst:31 msgid "" "Return true if *ob*'s type is :c:type:`PyGen_Type`; *ob* must not be " "``NULL``. This function always succeeds." msgstr "" -"*ob* が :c:type:`PyGen_Type` の場合に真を返します。\n" -"*o* は ``NULL`` であってはなりません。\n" +"*ob* の型が :c:type:`PyGen_Type` なら真を返します。\n" +"*ob* は ``NULL`` であってはなりません。\n" "この関数は常に成功します。" -#: ../../c-api/gen.rst:37 msgid "" "Create and return a new generator object based on the *frame* object. A " "reference to *frame* is \":term:`stolen `\" by this function (even on " "error). The argument must not be ``NULL``." msgstr "" +"*frame* オブジェクトに基づく新しいジェネレータオブジェクトを作成して返しま" +"す。\n" +"この関数は、エラー時も含めて *frame* への参照を :term:`盗みます `。\n" +"引数は ``NULL`` であってはなりません。" -#: ../../c-api/gen.rst:43 msgid "" "Create and return a new generator object based on the *frame* object, with " "``__name__`` and ``__qualname__`` set to *name* and *qualname*. A reference " "to *frame* is \":term:`stolen `\" by this function (even on error). " "The *frame* argument must not be ``NULL``." msgstr "" +"*frame* オブジェクトに基づく新しいジェネレータオブジェクトを作成し、" +"``__name__`` と ``__qualname__`` をそれぞれ *name* と *qualname* に設定して返" +"します。\n" +"この関数は、エラー時も含めて *frame* への参照を :term:`盗みます `。\n" +"*frame* 引数は ``NULL`` であってはなりません。" -#: ../../c-api/gen.rst:51 msgid "" "Return a new :term:`strong reference` to the code object wrapped by *gen*. " "This function always succeeds." msgstr "" +"*gen* がラップするコードオブジェクトへの新しい :term:`強参照 ` を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/gen.rst:56 msgid "Asynchronous Generator Objects" -msgstr "" +msgstr "非同期ジェネレータオブジェクト" -#: ../../c-api/gen.rst:59 msgid ":pep:`525`" -msgstr "" +msgstr ":pep:`525`" -#: ../../c-api/gen.rst:63 msgid "" "The type object corresponding to asynchronous generator objects. This is " "available as :class:`types.AsyncGeneratorType` in the Python layer." msgstr "" +"非同期ジェネレータオブジェクトに対応する型オブジェクトです。\n" +"Python レイヤでは :class:`types.AsyncGeneratorType` として利用できます。" -#: ../../c-api/gen.rst:70 msgid "" "Create a new asynchronous generator wrapping *frame*, with ``__name__`` and " "``__qualname__`` set to *name* and *qualname*. *frame* is \":term:`stolen " "`\" by this function (even on error) and must not be ``NULL``." msgstr "" +"*frame* をラップする新しい非同期ジェネレータを作成し、``__name__`` と " +"``__qualname__`` をそれぞれ *name* と *qualname* に設定します。\n" +"この関数は、エラー時も含めて *frame* への参照を :term:`盗みます `。\n" +"*frame* は ``NULL`` であってはなりません。" -#: ../../c-api/gen.rst:75 msgid "" "On success, this function returns a :term:`strong reference` to the new " "asynchronous generator. On failure, this function returns ``NULL`` with an " "exception set." msgstr "" +"成功すると、新しい非同期ジェネレータへの :term:`強参照 ` を" +"返します。\n" +"失敗すると、例外を設定して ``NULL`` を返します。" -#: ../../c-api/gen.rst:83 msgid "" "Return true if *op* is an asynchronous generator object, false otherwise. " "This function always succeeds." msgstr "" +"*op* が非同期ジェネレータオブジェクトなら真を、それ以外なら偽を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/gen.rst:90 msgid "Deprecated API" -msgstr "" +msgstr "非推奨の API" -#: ../../c-api/gen.rst:94 msgid "This is an API that was included in Python's C API by mistake." -msgstr "" +msgstr "この API は誤って Python の C API に含められたものです。" -#: ../../c-api/gen.rst:97 msgid "It is solely here for completeness; do not use this API." msgstr "" +"網羅性のためだけにここに記載しています。\n" +"この API は使わないでください。" diff --git a/c-api/hash.po b/c-api/hash.po index 581bd12ea..06a9f7475 100644 --- a/c-api/hash.po +++ b/c-api/hash.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/hash.rst:4 @@ -42,13 +42,12 @@ msgstr "ハッシュ値型: 符号付き整数。" msgid "Hash value type: unsigned integer." msgstr "ハッシュ値型: 符号なし整数。" -#: ../../c-api/hash.rst:24 msgid "" "A numerical value indicating the algorithm for hashing of :class:`str`, :" "class:`bytes`, and :class:`memoryview`." msgstr "" -":class:`str` 、 :class:`bytes` や :class:`memoryview` のハッシュ用アルゴリズ" -"ムを示す数値型。" +":class:`str`、:class:`bytes`、:class:`memoryview` のハッシュに使うアルゴリズ" +"ムを示す数値です。" #: ../../c-api/hash.rst:27 msgid "The algorithm name is exposed by :data:`sys.hash_info.algorithm`." @@ -65,148 +64,139 @@ msgstr "" msgid "Add :c:macro:`!Py_HASH_FNV` and :c:macro:`!Py_HASH_SIPHASH24`." msgstr "" -#: ../../c-api/hash.rst:43 msgid "Add :c:macro:`!Py_HASH_SIPHASH13`." -msgstr "" +msgstr ":c:macro:`!Py_HASH_SIPHASH13` を追加しました。" -#: ../../c-api/hash.rst:49 msgid "" "Buffers of length in range ``[1, Py_HASH_CUTOFF)`` are hashed using DJBX33A " "instead of the algorithm described by :c:macro:`Py_HASH_ALGORITHM`." msgstr "" +"長さが ``[1, Py_HASH_CUTOFF)`` の範囲にあるバッファのハッシュには、:c:macro:" +"`Py_HASH_ALGORITHM` が示すアルゴリズムの代わりに DJBX33A を使います。" -#: ../../c-api/hash.rst:52 msgid "A :c:macro:`!Py_HASH_CUTOFF` of 0 disables the optimization." -msgstr "" +msgstr ":c:macro:`!Py_HASH_CUTOFF` を 0 にすると、この最適化は無効になります。" -#: ../../c-api/hash.rst:53 msgid "" ":c:macro:`!Py_HASH_CUTOFF` must be non-negative and less or equal than 7." -msgstr "" +msgstr ":c:macro:`!Py_HASH_CUTOFF` は 0 以上 7 以下でなければなりません。" -#: ../../c-api/hash.rst:55 msgid "" "32-bit platforms should use a cutoff smaller than 64-bit platforms because " "it is easier to create colliding strings. A cutoff of 7 on 64-bit platforms " "and 5 on 32-bit platforms should provide a decent safety margin." msgstr "" +"32 ビットのプラットフォームでは衝突する文字列を作成しやすいため、64 ビットの" +"プラットフォームよりも小さい閾値を使うべきです。\n" +"64 ビットでは 7、32 ビットでは 5 を閾値にすると、十分な安全の余裕が得られるは" +"ずです。" -#: ../../c-api/hash.rst:59 msgid "This corresponds to the :data:`sys.hash_info.cutoff` constant." -msgstr "" +msgstr ":data:`sys.hash_info.cutoff` 定数に対応します。" -#: ../../c-api/hash.rst:66 msgid "" "The `Mersenne prime `_ ``P = " "2**n -1``, used for numeric hash scheme." msgstr "" +"数値のハッシュ方式で使う `メルセンヌ素数 `_ ``P = 2**n -1``。" -#: ../../c-api/hash.rst:69 msgid "This corresponds to the :data:`sys.hash_info.modulus` constant." -msgstr "" +msgstr ":data:`sys.hash_info.modulus` 定数に対応します。" -#: ../../c-api/hash.rst:76 msgid "The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`." -msgstr "" +msgstr ":c:macro:`PyHASH_MODULUS` の ``P`` の指数 ``n``。" -#: ../../c-api/hash.rst:83 msgid "Prime multiplier used in string and various other hashes." -msgstr "" +msgstr "文字列などさまざまなハッシュで乗数として使う素数。" -#: ../../c-api/hash.rst:90 msgid "The hash value returned for a positive infinity." -msgstr "" +msgstr "正の無限大に対して返すハッシュ値。" -#: ../../c-api/hash.rst:92 msgid "This corresponds to the :data:`sys.hash_info.inf` constant." -msgstr "" +msgstr ":data:`sys.hash_info.inf` 定数に対応します。" -#: ../../c-api/hash.rst:99 msgid "The multiplier used for the imaginary part of a complex number." -msgstr "" +msgstr "複素数の虚部に使う乗数。" -#: ../../c-api/hash.rst:101 msgid "This corresponds to the :data:`sys.hash_info.imag` constant." -msgstr "" +msgstr ":data:`sys.hash_info.imag` 定数に対応します。" -#: ../../c-api/hash.rst:108 msgid "Hash function definition used by :c:func:`PyHash_GetFuncDef`." -msgstr "" +msgstr ":c:func:`PyHash_GetFuncDef` が使うハッシュ関数の定義。" -#: ../../c-api/hash.rst:112 msgid "Hash function." -msgstr "" +msgstr "ハッシュ関数。" -#: ../../c-api/hash.rst:116 msgid "Hash function name (UTF-8 encoded string)." -msgstr "" +msgstr "ハッシュ関数の名前 (UTF-8 エンコードの文字列)。" -#: ../../c-api/hash.rst:118 msgid "This corresponds to the :data:`sys.hash_info.algorithm` constant." -msgstr "" +msgstr ":data:`sys.hash_info.algorithm` 定数に対応します。" -#: ../../c-api/hash.rst:122 msgid "Internal size of the hash value in bits." -msgstr "" +msgstr "ハッシュ値の内部でのサイズ (ビット単位)。" -#: ../../c-api/hash.rst:124 msgid "This corresponds to the :data:`sys.hash_info.hash_bits` constant." -msgstr "" +msgstr ":data:`sys.hash_info.hash_bits` 定数に対応します。" -#: ../../c-api/hash.rst:128 msgid "Size of seed input in bits." -msgstr "" +msgstr "シード入力のサイズ (ビット単位)。" -#: ../../c-api/hash.rst:130 msgid "This corresponds to the :data:`sys.hash_info.seed_bits` constant." -msgstr "" +msgstr ":data:`sys.hash_info.seed_bits` 定数に対応します。" -#: ../../c-api/hash.rst:137 msgid "Get the hash function definition." -msgstr "" +msgstr "ハッシュ関数の定義を取得します。" -#: ../../c-api/hash.rst:140 msgid ":pep:`456` \"Secure and interchangeable hash algorithm\"." -msgstr "" +msgstr ":pep:`456` 「安全で交換可能なハッシュアルゴリズム」。" -#: ../../c-api/hash.rst:147 msgid "" "Hash a pointer value: process the pointer value as an integer (cast it to " "``uintptr_t`` internally). The pointer is not dereferenced." msgstr "" +"ポインタ値のハッシュを計算します。\n" +"ポインタ値を整数として処理します (内部では ``uintptr_t`` にキャストしま" +"す)。\n" +"ポインタの参照先にはアクセスしません。" -#: ../../c-api/hash.rst:150 msgid "The function cannot fail: it cannot return ``-1``." msgstr "" +"この関数は失敗しません。\n" +"``-1`` を返すことはありません。" -#: ../../c-api/hash.rst:157 msgid "" "Compute and return the hash value of a buffer of *len* bytes starting at " "address *ptr*. The hash is guaranteed to match that of :class:`bytes`, :" "class:`memoryview`, and other built-in objects that implement the :ref:" "`buffer protocol `." msgstr "" +"アドレス ``ptr`` を先頭とする長さ ``len`` バイトのバッファのハッシュ値を計算" +"して返します。\n" +"このハッシュ値は、:class:`bytes`、:class:`memoryview` など :ref:`バッファプロ" +"トコル ` を実装する組み込みオブジェクトのハッシュ値と一致する" +"ことが保証されています。" -#: ../../c-api/hash.rst:162 msgid "" "Use this function to implement hashing for immutable objects whose :c:member:" "`~PyTypeObject.tp_richcompare` function compares to another object's buffer." msgstr "" +":c:member:`~PyTypeObject.tp_richcompare` 関数でほかのオブジェクトのバッファと" +"比較する不変オブジェクトに、ハッシュ計算を実装する場合に使ってください。" -#: ../../c-api/hash.rst:166 msgid "*len* must be greater than or equal to ``0``." -msgstr "" +msgstr "``len`` は ``0`` 以上でなければなりません。" -#: ../../c-api/hash.rst:168 msgid "This function always succeeds." -msgstr "" +msgstr "この関数は常に成功します。" -#: ../../c-api/hash.rst:175 msgid "" "Generic hashing function that is meant to be put into a type object's " "``tp_hash`` slot. Its result only depends on the object's identity." msgstr "" +"型オブジェクトの ``tp_hash`` スロットに設定するための汎用ハッシュ関数です。\n" +"結果はオブジェクトの同一性だけで決まります。" -#: ../../c-api/hash.rst:180 msgid "In CPython, it is equivalent to :c:func:`Py_HashPointer`." -msgstr "" +msgstr "CPython では :c:func:`Py_HashPointer` と同等です。" diff --git a/c-api/import.po b/c-api/import.po index 622edb9f7..5198eee02 100644 --- a/c-api/import.po +++ b/c-api/import.po @@ -16,21 +16,22 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/import.rst:6 msgid "Importing Modules" msgstr "モジュールのインポート" -#: ../../c-api/import.rst:16 msgid "" "This is a wrapper around :c:func:`PyImport_Import()` which takes a :c:expr:" "`const char *` as an argument instead of a :c:expr:`PyObject *`." msgstr "" +":c:func:`PyImport_Import()` のラッパーで、引数として :c:expr:`PyObject *` の" +"代わりに :c:expr:`const char *` を受け取ります。" #: ../../c-api/import.rst:24 msgid "" @@ -83,7 +84,6 @@ msgstr "" msgid "Negative values for *level* are no longer accepted." msgstr "*level* にはもはや負の値は使用できません。" -#: ../../c-api/import.rst:61 msgid "" "This is a higher-level interface that calls the current \"import hook " "function\" (with an explicit *level* of 0, meaning absolute import). It " @@ -91,48 +91,48 @@ msgid "" "current globals. This means that the import is done using whatever import " "hooks are installed in the current environment." msgstr "" -"現在の \"インポートフック関数\" を呼び出すための高水準のインターフェースです " -"(*level* に 0 を明示すると、絶対インポートを意味します)。 この関数は現在のグ" -"ローバル変数辞書内の ``__builtins__`` から :func:`__import__` 関数を呼び出し" -"ます。すなわち、現在の環境にインストールされているインポートフック使ってイン" -"ポートを行います。" +"現在の「インポートフック関数」を呼び出す高水準のインターフェースです " +"(``level`` は明示的に 0、つまり絶対インポートに設定されます)。\n" +"現在のグローバル名前空間の ``__builtins__`` から :func:`__import__` 関数を呼" +"び出します。\n" +"したがって、現在の環境にインストールされたインポートフックを使ってインポート" +"します。" #: ../../c-api/import.rst:67 msgid "This function always uses absolute imports." msgstr "この関数は常に絶対インポートを使用します。" -#: ../../c-api/import.rst:72 msgid "" "Reload a module. Return a new reference to the reloaded module, or ``NULL`` " "with an exception set on failure (the module still exists in this case)." msgstr "" -"モジュールを再ロード (reload) します。戻り値は再ロードしたモジュールかトップ" -"レベルパッケージへの新たな参照になります。\n" -"失敗した場合には例外をセットし、``NULL`` を返します (その場合でも、モジュール" -"は生成されている場合があります)。" +"モジュールを再読み込みします。\n" +"再読み込みしたモジュールへの新しい参照を返します。\n" +"失敗した場合は例外を設定して ``NULL`` を返します (この場合もモジュールは存在" +"します)。" -#: ../../c-api/import.rst:78 msgid "Return the module object corresponding to a module name." -msgstr "" +msgstr "モジュール名に対応するモジュールオブジェクトを返します。" -#: ../../c-api/import.rst:80 msgid "" "The *name* argument may be of the form ``package.module``. First check the " "modules dictionary if there's one there, and if not, create a new one and " "insert it in the modules dictionary." msgstr "" +"``name`` 引数は ``package.module`` という形式でも構いません。\n" +"まずモジュール辞書内を確認し、該当するモジュールがなければ新しく作成してモ" +"ジュール辞書に挿入します。" -#: ../../c-api/import.rst:84 msgid "" "Return a :term:`strong reference` to the module on success. Return ``NULL`` " "with an exception set on failure." msgstr "" +"成功した場合はモジュールへの :term:`強参照 ` を返します。\n" +"失敗した場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/import.rst:87 msgid "The module name *name* is decoded from UTF-8." -msgstr "" +msgstr "モジュール名 ``name`` は UTF-8 からデコードされます。" -#: ../../c-api/import.rst:89 msgid "" "This function does not load or import the module; if the module wasn't " "already loaded, you will get an empty module object. Use :c:func:" @@ -140,20 +140,28 @@ msgid "" "structures implied by a dotted name for *name* are not created if not " "already present." msgstr "" +"この関数はモジュールを読み込んだりインポートしたりしません。\n" +"モジュールがまだ読み込まれていない場合は、空のモジュールオブジェクトが返され" +"ます。\n" +"モジュールをインポートするには :c:func:`PyImport_ImportModule` またはその変種" +"を使ってください。\n" +"``name`` がドットで区切られた名前であっても、まだ存在しないパッケージ構造は作" +"成されません。" -#: ../../c-api/import.rst:100 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference` and *name* is a Python :class:`str` object." msgstr "" +":c:func:`PyImport_AddModuleRef` と同様ですが、:term:`借用参照 ` を返し、``name`` は Python の :class:`str` オブジェクトです。" -#: ../../c-api/import.rst:108 msgid "" "Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed " "reference`." msgstr "" +":c:func:`PyImport_AddModuleRef` と同様ですが、:term:`借用参照 ` を返します。" -#: ../../c-api/import.rst:116 msgid "" "Given a module name (possibly of the form ``package.module``) and a code " "object read from a Python bytecode file or obtained from the built-in " @@ -166,20 +174,36 @@ msgid "" "know that the module object is an unknown (and probably damaged with respect " "to the module author's intents) state." msgstr "" +"モジュール名 (``package.module`` 形式でも可) と、Python バイトコードファイル" +"から読み込んだか組み込み関数 :func:`compile` で取得したコードオブジェクトを" +"使って、モジュールを読み込みます。\n" +"モジュールオブジェクトへの新しい参照を返し、エラーの場合は例外を設定して " +"``NULL`` を返します。\n" +"エラーの場合、:c:func:`PyImport_ExecCodeModule` の呼び出し時に ``name`` がす" +"でに :data:`sys.modules` に存在していたとしても、:data:`sys.modules` から " +"``name`` を削除します。\n" +"不完全に初期化されたモジュールを :data:`sys.modules` に残すのは危険です。\n" +"そのモジュールをインポートする側には、モジュールオブジェクトが不明な状態 (お" +"そらく作者の意図からすれば壊れた状態) にあると知る手段がないためです。" -#: ../../c-api/import.rst:126 msgid "" "The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be " "set, if not set already, with the appropriate values. The spec's loader " "will be set to the module's :attr:`!__loader__` (if set) and to an instance " "of :class:`~importlib.machinery.SourceFileLoader` otherwise." msgstr "" +"モジュールの :attr:`~module.__spec__` と :attr:`~module.__loader__` がまだ設" +"定されていなければ、適切な値を設定します。\n" +"spec のローダーには、モジュールの :attr:`!__loader__` が設定されていればそれ" +"を使い、そうでなければ :class:`~importlib.machinery.SourceFileLoader` のイン" +"スタンスを設定します。" -#: ../../c-api/import.rst:131 msgid "" "The module's :attr:`~module.__file__` attribute will be set to the code " "object's :attr:`~codeobject.co_filename`." msgstr "" +"モジュールの :attr:`~module.__file__` 属性には、コードオブジェクトの :attr:" +"`~codeobject.co_filename` を設定します。" #: ../../c-api/import.rst:134 msgid "" @@ -206,42 +230,46 @@ msgstr "" ":c:func:`PyImport_ExecCodeModuleEx` と :c:func:" "`PyImport_ExecCodeModuleWithPathnames` も参照してください。" -#: ../../c-api/import.rst:143 msgid "" "The setting of ``__cached__`` and :attr:`~module.__loader__` is deprecated. " "See :class:`~importlib.machinery.ModuleSpec` for alternatives." msgstr "" +"``__cached__`` と :attr:`~module.__loader__` の設定は非推奨になりました。\n" +"代替については :class:`~importlib.machinery.ModuleSpec` を参照してください。" -#: ../../c-api/import.rst:148 msgid "The ``__cached__`` attribute is no longer set." -msgstr "" +msgstr "``__cached__`` 属性を設定しなくなりました。" -#: ../../c-api/import.rst:154 msgid "" "Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__` " "attribute of the module object is set to *pathname* if it is non-``NULL``." msgstr "" +":c:func:`PyImport_ExecCodeModule` と同様ですが、``pathname`` が ``NULL`` でな" +"ければモジュールオブジェクトの :attr:`~module.__file__` 属性をその値に設定し" +"ます。" #: ../../c-api/import.rst:157 msgid "See also :c:func:`PyImport_ExecCodeModuleWithPathnames`." msgstr ":c:func:`PyImport_ExecCodeModuleWithPathnames` も参照してください。" -#: ../../c-api/import.rst:162 msgid "" "Like :c:func:`PyImport_ExecCodeModuleEx`, but the path to any compiled file " "via *cpathname* is used appropriately when non-``NULL``. Of the three " "functions, this is the preferred one to use." msgstr "" +":c:func:`PyImport_ExecCodeModuleEx` と同様ですが、``cpathname`` が ``NULL`` " +"でなければ、そこで指定されたコンパイル済みファイルのパスを適切に使います。\n" +"三つの関数の中では、この関数の使用を推奨します。" -#: ../../c-api/import.rst:168 msgid "" "Setting ``__cached__`` is deprecated. See :class:`~importlib.machinery." "ModuleSpec` for alternatives." msgstr "" +"``__cached__`` の設定は非推奨になりました。\n" +"代替については :class:`~importlib.machinery.ModuleSpec` を参照してください。" -#: ../../c-api/import.rst:172 msgid "The ``__cached__`` attribute no longer set." -msgstr "" +msgstr "``__cached__`` 属性を設定しなくなりました。" #: ../../c-api/import.rst:178 msgid "" @@ -255,15 +283,15 @@ msgstr "" "す。もし *pathname* が ``NULL`` の場合、*cpathname* から、*pathname* どのよう" "な値になるべきかを知る試みもなされます。" -#: ../../c-api/import.rst:184 msgid "" "Uses :func:`!imp.source_from_cache` in calculating the source path if only " "the bytecode path is provided." msgstr "" +"バイトコードのパスだけが指定された場合、ソースのパスの計算に :func:`!imp." +"source_from_cache` を使います。" -#: ../../c-api/import.rst:187 msgid "No longer uses the removed :mod:`!imp` module." -msgstr "" +msgstr "削除された :mod:`!imp` モジュールを使わなくなりました。" #: ../../c-api/import.rst:193 msgid "" @@ -308,7 +336,6 @@ msgstr "" "はセットしません。\n" "モジュールの検索に失敗した場合は、 ``NULL`` を返し、エラーをセットします。" -#: ../../c-api/import.rst:224 msgid "" "Return a finder object for a :data:`sys.path`/:attr:`!pkg.__path__` item " "*path*, possibly by fetching it from the :data:`sys.path_importer_cache` " @@ -318,6 +345,16 @@ msgid "" "finder for this path item. Cache the result in :data:`sys." "path_importer_cache`. Return a new reference to the finder object." msgstr "" +":data:`sys.path` または :attr:`!pkg.__path__` の要素 ``path`` に対応するファ" +"インダーオブジェクトを返します。\n" +":data:`sys.path_importer_cache` 辞書から取得する場合もあります。\n" +"まだキャッシュされていなければ、そのパス要素を扱えるフックが見つかるまで :" +"data:`sys.path_hooks` を順に調べます。\n" +"どのフックも扱えない場合は ``None`` を返し、:term:`パスベースのファインダー " +"` がこのパス要素のファインダーを見つけられなかったことを呼" +"び出し側に伝えます。\n" +"結果は :data:`sys.path_importer_cache` にキャッシュします。\n" +"ファインダーオブジェクトへの新しい参照を返します。" #: ../../c-api/import.rst:235 msgid "" @@ -338,14 +375,12 @@ msgstr "" msgid "The ``__file__`` attribute is no longer set on the module." msgstr "``__file__`` 属性はもうモジュールにセットされません。" -#: ../../c-api/import.rst:249 msgid "" "Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a " "UTF-8 encoded string instead of a Unicode object." msgstr "" -":c:func:`PyImport_ImportFrozenModuleObject` と似ていますが、name は UTF-8 で" -"エンコードされた文字列の代わりに、 Unicode オブジェクトを使用する点が異なりま" -"す。" +":c:func:`PyImport_ImportFrozenModuleObject` と同様ですが、名前は Unicode オブ" +"ジェクトではなく UTF-8 エンコードの文字列です。" #: ../../c-api/import.rst:257 msgid "" @@ -369,11 +404,13 @@ msgid "" "};" msgstr "" -#: ../../c-api/import.rst:269 msgid "" "The new ``is_package`` field indicates whether the module is a package or " "not. This replaces setting the ``size`` field to a negative value." msgstr "" +"新しい ``is_package`` フィールドは、モジュールがパッケージかどうかを示しま" +"す。\n" +"``size`` フィールドを負の値に設定する方法に代わるものです。" #: ../../c-api/import.rst:275 msgid "" @@ -404,30 +441,34 @@ msgstr "" "ポートでき、最初にインポートを試みた際に呼び出される関数として *initfunc* を" "使います。 :c:func:`Py_Initialize` よりも前に呼び出さなければなりません。" -#: ../../c-api/import.rst:293 msgid "" "Structure describing a single entry in the list of built-in modules. " "Programs which embed Python may use an array of these structures in " "conjunction with :c:func:`PyImport_ExtendInittab` to provide additional " "built-in modules. The structure consists of two members:" msgstr "" +"組み込みモジュールの一覧の一つのエントリーを記述する構造体です。\n" +"Python を組み込むプログラムは、この構造体の配列を :c:func:" +"`PyImport_ExtendInittab` と併用して、追加の組み込みモジュールを提供できま" +"す。\n" +"構造体は二つのメンバからなります。" -#: ../../c-api/import.rst:301 msgid "The module name, as an ASCII encoded string." -msgstr "" +msgstr "ASCII エンコードの文字列で表したモジュール名。" -#: ../../c-api/import.rst:305 msgid "Initialization function for a module built into the interpreter." -msgstr "" +msgstr "インタープリタに組み込まれたモジュールの初期化関数。" -#: ../../c-api/import.rst:307 msgid "" "Note that the inittab uses \"``PyInit``\" :ref:`initialization functions " "`; there is currently no way to include " "\"``PyModExport_``\" :ref:`export hooks `." msgstr "" +"inittab は「``PyInit``」の :ref:`初期化関数 ` を使いま" +"す。\n" +"現在、「``PyModExport_``」の :ref:`エクスポートフック ` を含める方法はありません。" -#: ../../c-api/import.rst:315 msgid "" "Add a collection of modules to the table of built-in modules. The *newtab* " "array must end with a sentinel entry which contains ``NULL`` for the :c:" @@ -437,6 +478,14 @@ msgid "" "failure, no modules are added to the internal table. This must be called " "before :c:func:`Py_Initialize`." msgstr "" +"組み込みモジュールのテーブルに、複数のモジュールを追加します。\n" +"``newtab`` 配列は、:c:member:`~_inittab.name` フィールドが ``NULL`` の番兵エ" +"ントリーで終わる必要があります。\n" +"番兵がないとメモリアクセス違反を引き起こす可能性があります。\n" +"成功した場合は ``0`` を返し、内部テーブルを拡張するためのメモリを十分に割り当" +"てられなければ ``-1`` を返します。\n" +"失敗した場合、内部テーブルにモジュールは一つも追加されません。\n" +":c:func:`Py_Initialize` より前に呼び出す必要があります。" #: ../../c-api/import.rst:322 msgid "" @@ -448,50 +497,55 @@ msgstr "" "func:`PyImport_ExtendInittab` は、それぞれの初期化の前に呼び出される必要があ" "ります。" -#: ../../c-api/import.rst:329 msgid "" "The table of built-in modules used by Python initialization. Do not use this " "directly; use :c:func:`PyImport_AppendInittab` and :c:func:" "`PyImport_ExtendInittab` instead." msgstr "" +"Python の初期化で使う組み込みモジュールのテーブルです。\n" +"直接使わず、代わりに :c:func:`PyImport_AppendInittab` と :c:func:" +"`PyImport_ExtendInittab` を使ってください。" -#: ../../c-api/import.rst:336 msgid "Import the module *mod_name* and get its attribute *attr_name*." msgstr "" +"モジュール ``mod_name`` をインポートし、その属性 ``attr_name`` を取得します。" -#: ../../c-api/import.rst:338 msgid "Names must be Python :class:`str` objects." -msgstr "" +msgstr "名前は Python の :class:`str` オブジェクトでなければなりません。" -#: ../../c-api/import.rst:340 msgid "" "Helper function combining :c:func:`PyImport_Import` and :c:func:" "`PyObject_GetAttr`. For example, it can raise :exc:`ImportError` if the " "module is not found, and :exc:`AttributeError` if the attribute doesn't " "exist." msgstr "" +":c:func:`PyImport_Import` と :c:func:`PyObject_GetAttr` を組み合わせた補助関" +"数です。\n" +"例えば、モジュールが見つからなければ :exc:`ImportError`、属性が存在しなけれ" +"ば :exc:`AttributeError` を送出することがあります。" -#: ../../c-api/import.rst:349 ../../c-api/import.rst:369 msgid "" "Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded " "strings instead of Python :class:`str` objects." msgstr "" +":c:func:`PyImport_ImportModuleAttr` と同様ですが、名前は Python の :class:" +"`str` オブジェクトではなく UTF-8 エンコードの文字列です。" -#: ../../c-api/import.rst:356 msgid "Gets the current lazy imports mode." -msgstr "" +msgstr "現在の遅延インポートモードを取得します。" -#: ../../c-api/import.rst:362 msgid "" "Return a :term:`strong reference` to the current lazy imports filter, or " "``NULL`` if none exists. This function always succeeds." msgstr "" +"現在の遅延インポートフィルタへの :term:`強参照 ` を返しま" +"す。\n" +"フィルタがなければ ``NULL`` を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/import.rst:372 msgid "This function always returns ``0``." -msgstr "" +msgstr "この関数は常に ``0`` を返します。" -#: ../../c-api/import.rst:378 msgid "" "Sets the current lazy imports filter. The *filter* should be a callable that " "will receive ``(importing_module_name, imported_module_name, [fromlist])`` " @@ -500,33 +554,44 @@ msgid "" "``package.spam``. The callable must return ``True`` if the import should be " "lazy and ``False`` otherwise." msgstr "" +"現在の遅延インポートフィルタを設定します。\n" +"``filter`` には、インポートを遅延できる可能性があるときに " +"``(importing_module_name, imported_module_name, [fromlist])`` を受け取る呼び" +"出し可能オブジェクトを指定してください。\n" +"``imported_module_name`` は解決済みのモジュール名なので、``lazy from .spam " +"import eggs`` の場合は ``package.spam`` が渡されます。\n" +"この呼び出し可能オブジェクトは、インポートを遅延すべきなら ``True``、そうでな" +"ければ ``False`` を返す必要があります。" -#: ../../c-api/import.rst:385 msgid "Return ``0`` on success and ``-1`` with an exception set otherwise." msgstr "" +"成功した場合は ``0`` を返し、それ以外の場合は例外を設定して ``-1`` を返しま" +"す。" -#: ../../c-api/import.rst:391 msgid "Enumeration of possible lazy import modes." -msgstr "" +msgstr "遅延インポートモードの列挙型。" -#: ../../c-api/import.rst:395 msgid "Respect the ``lazy`` keyword in source code. This is the default mode." msgstr "" +"ソースコード内の ``lazy`` キーワードに従います。\n" +"デフォルトのモードです。" -#: ../../c-api/import.rst:399 msgid "Make all imports lazy by default." -msgstr "" +msgstr "デフォルトですべてのインポートを遅延させます。" -#: ../../c-api/import.rst:405 msgid "" "This function is a building block that enables embedders to implement the :" "py:meth:`~importlib.abc.Loader.create_module` step of custom static " "extension importers (e.g. of statically-linked extensions)." msgstr "" +"この関数は、Python を組み込む側が、静的拡張 (例えば静的リンクされた拡張) 用の" +"カスタムインポータの :py:meth:`~importlib.abc.Loader.create_module` ステップ" +"を実装するための構成要素です。" -#: ../../c-api/import.rst:409 msgid "*spec* must be a :class:`~importlib.machinery.ModuleSpec` object." msgstr "" +"``spec`` は :class:`~importlib.machinery.ModuleSpec` オブジェクトでなければな" +"りません。" #: ../../c-api/import.rst:411 msgid "" @@ -534,13 +599,17 @@ msgid "" "hook>`, the same as for :c:func:`PyImport_AppendInittab`." msgstr "" -#: ../../c-api/import.rst:414 msgid "" "On success, create and return a module object. This module will not be " "initialized; call :c:func:`PyModule_Exec` to initialize it. (Custom " "importers should do this in their :py:meth:`~importlib.abc.Loader." "exec_module` method.)" msgstr "" +"成功した場合は、モジュールオブジェクトを作成して返します。\n" +"このモジュールはまだ初期化されていないので、:c:func:`PyModule_Exec` を呼び出" +"して初期化してください。\n" +"(カスタムインポータでは :py:meth:`~importlib.abc.Loader.exec_module` メソッド" +"内で行ってください。)" #: ../../c-api/import.rst:420 msgid "" @@ -549,21 +618,18 @@ msgid "" "to the full name from the spec." msgstr "" -#: ../../c-api/import.rst:424 msgid "On error, return NULL with an exception set." -msgstr "" +msgstr "エラーの場合は例外を設定して NULL を返します。" -#: ../../c-api/import.rst:11 msgid "package variable" -msgstr "" +msgstr "パッケージ変数" #: ../../c-api/import.rst:11 msgid "__all__" msgstr "__all__" -#: ../../c-api/import.rst:11 msgid "__all__ (package variable)" -msgstr "" +msgstr "__all__ (パッケージ変数)" #: ../../c-api/import.rst:11 msgid "modules (in module sys)" diff --git a/c-api/index.po b/c-api/index.po index fdd58b2be..5d064698e 100644 --- a/c-api/index.po +++ b/c-api/index.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/index.rst:5 msgid "Python/C API reference manual" -msgstr "" +msgstr "Python/C API リファレンスマニュアル" #: ../../c-api/index.rst:7 msgid "" diff --git a/c-api/init.po b/c-api/init.po index b7a8a2730..35b813500 100644 --- a/c-api/init.po +++ b/c-api/init.po @@ -12,40 +12,32 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/init.rst:4 msgid "Initialization, finalization, and threads" -msgstr "" +msgstr "初期化、終了処理、スレッド" -#: ../../c-api/init.rst:6 msgid "This page has been split up into the following:" -msgstr "" +msgstr "このページは次のページに分割されました。" -#: ../../c-api/init.rst:8 msgid ":ref:`initialization`" -msgstr "" +msgstr ":ref:`initialization`" -#: ../../c-api/init.rst:9 msgid ":ref:`threads`" -msgstr "" +msgstr ":ref:`threads`" -#: ../../c-api/init.rst:10 msgid ":ref:`synchronization`" -msgstr "" +msgstr ":ref:`synchronization`" -#: ../../c-api/init.rst:11 msgid ":ref:`thread-local-storage`" -msgstr "" +msgstr ":ref:`thread-local-storage`" -#: ../../c-api/init.rst:12 msgid ":ref:`sub-interpreter-support`" -msgstr "" +msgstr ":ref:`sub-interpreter-support`" -#: ../../c-api/init.rst:13 msgid ":ref:`profiling`" -msgstr "" +msgstr ":ref:`profiling`" diff --git a/c-api/init_config.po b/c-api/init_config.po index 8dbed2d98..6a3a3b061 100644 --- a/c-api/init_config.po +++ b/c-api/init_config.po @@ -18,15 +18,14 @@ msgstr "" "Last-Translator: Cheesecake, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/init_config.rst:7 msgid "Python Initialization Configuration" -msgstr "Python 初期化設定 " +msgstr "Python 初期化設定" #: ../../c-api/init_config.rst:13 msgid "PyInitConfig C API" @@ -146,240 +145,235 @@ msgstr "設定の作成" msgid "Opaque structure to configure the Python initialization." msgstr "Python の初期化を構成するための不透明な構造体です。" -#: ../../c-api/init_config.rst:80 msgid "" "Create a new initialization configuration using :ref:`Isolated Configuration " "` default values." msgstr "" +":ref:`隔離設定 ` のデフォルト値を使って、新しい初期化設定" +"を作成します。" -#: ../../c-api/init_config.rst:83 msgid "It must be freed by :c:func:`PyInitConfig_Free`." -msgstr "" +msgstr ":c:func:`PyInitConfig_Free` で解放しなければなりません。" -#: ../../c-api/init_config.rst:85 msgid "Return ``NULL`` on memory allocation failure." -msgstr "" +msgstr "メモリの確保に失敗した場合は ``NULL`` を返します。" -#: ../../c-api/init_config.rst:90 msgid "Free memory of the initialization configuration *config*." -msgstr "" +msgstr "初期化設定 *config* のメモリを解放します。" -#: ../../c-api/init_config.rst:92 msgid "If *config* is ``NULL``, no operation is performed." -msgstr "" +msgstr "*config* が ``NULL`` の場合は、何も行いません。" #: ../../c-api/init_config.rst:96 msgid "Error Handling" msgstr "エラー処理" -#: ../../c-api/init_config.rst:100 msgid "Get the *config* error message." -msgstr "" +msgstr "*config* のエラーメッセージを取得します。" -#: ../../c-api/init_config.rst:102 msgid "Set *\\*err_msg* and return ``1`` if an error is set." -msgstr "" +msgstr "エラーが設定されていれば、*\\*err_msg* を設定して ``1`` を返します。" -#: ../../c-api/init_config.rst:103 msgid "Set *\\*err_msg* to ``NULL`` and return ``0`` otherwise." msgstr "" +"それ以外の場合は、*\\*err_msg* を ``NULL`` に設定して ``0`` を返します。" -#: ../../c-api/init_config.rst:105 msgid "An error message is a UTF-8 encoded string." -msgstr "" +msgstr "エラーメッセージは、UTF-8 でエンコードされた文字列です。" -#: ../../c-api/init_config.rst:107 msgid "If *config* has an exit code, format the exit code as an error message." msgstr "" +"*config* に終了コードがある場合は、その終了コードをエラーメッセージの形式にし" +"ます。" -#: ../../c-api/init_config.rst:110 msgid "" "The error message remains valid until another ``PyInitConfig`` function is " "called with *config*. The caller doesn't have to free the error message." msgstr "" +"エラーメッセージは、*config* を使って別の ``PyInitConfig`` 関数を呼び出すまで" +"有効です。\n" +"呼び出し元がエラーメッセージを解放する必要はありません。" -#: ../../c-api/init_config.rst:117 msgid "Get the *config* exit code." -msgstr "" +msgstr "*config* の終了コードを取得します。" -#: ../../c-api/init_config.rst:119 msgid "Set *\\*exitcode* and return ``1`` if *config* has an exit code set." msgstr "" +"*config* に終了コードが設定されていれば、*\\*exitcode* を設定して ``1`` を返" +"します。" -#: ../../c-api/init_config.rst:120 msgid "Return ``0`` if *config* has no exit code set." -msgstr "" +msgstr "*config* に終了コードが設定されていなければ ``0`` を返します。" -#: ../../c-api/init_config.rst:122 msgid "" "Only the ``Py_InitializeFromInitConfig()`` function can set an exit code if " "the ``parse_argv`` option is non-zero." msgstr "" +"終了コードを設定できるのは、``parse_argv`` オプションがゼロ以外の場合の " +"``Py_InitializeFromInitConfig()`` 関数だけです。" -#: ../../c-api/init_config.rst:125 msgid "" "An exit code can be set when parsing the command line failed (exit code " "``2``) or when a command line option asks to display the command line help " "(exit code ``0``)." msgstr "" +"コマンドラインの解析に失敗した場合 (終了コード ``2``) や、コマンドラインオプ" +"ションでヘルプの表示が要求された場合 (終了コード ``0``) に、終了コードが設定" +"されることがあります。" -#: ../../c-api/init_config.rst:131 msgid "Get Options" -msgstr "" +msgstr "オプションの取得" -#: ../../c-api/init_config.rst:133 ../../c-api/init_config.rst:187 -#: ../../c-api/init_config.rst:559 msgid "" "The configuration option *name* parameter must be a non-NULL null-terminated " "UTF-8 encoded string. See :ref:`Configuration Options `." msgstr "" +"設定オプションの *name* 引数は、``NULL`` でない、null 終端の UTF-8 エンコード" +"文字列でなければなりません。\n" +":ref:`設定オプション ` を参照してください。" -#: ../../c-api/init_config.rst:138 msgid "Test if the configuration has an option called *name*." -msgstr "" +msgstr "設定に *name* というオプションがあるかを調べます。" -#: ../../c-api/init_config.rst:140 msgid "Return ``1`` if the option exists, or return ``0`` otherwise." -msgstr "" +msgstr "オプションがあれば ``1``、なければ ``0`` を返します。" -#: ../../c-api/init_config.rst:145 msgid "Get an integer configuration option." -msgstr "" +msgstr "整数の設定オプションを取得します。" -#: ../../c-api/init_config.rst:147 ../../c-api/init_config.rst:156 msgid "Set *\\*value*, and return ``0`` on success." -msgstr "" +msgstr "成功時は *\\*value* を設定し、``0`` を返します。" -#: ../../c-api/init_config.rst:148 ../../c-api/init_config.rst:157 -#: ../../c-api/init_config.rst:172 ../../c-api/init_config.rst:200 -#: ../../c-api/init_config.rst:209 ../../c-api/init_config.rst:218 -#: ../../c-api/init_config.rst:233 ../../c-api/init_config.rst:249 msgid "Set an error in *config* and return ``-1`` on error." -msgstr "" +msgstr "エラー時は *config* にエラーを設定し、``-1`` を返します。" -#: ../../c-api/init_config.rst:153 msgid "" "Get a string configuration option as a null-terminated UTF-8 encoded string." msgstr "" +"文字列の設定オプションを、null 終端の UTF-8 エンコード文字列として取得しま" +"す。" -#: ../../c-api/init_config.rst:159 msgid "" "*\\*value* can be set to ``NULL`` if the option is an optional string and " "the option is unset." msgstr "" +"オプションが省略可能な文字列で、設定されていない場合は、*\\*value* が " +"``NULL`` に設定されることがあります。" -#: ../../c-api/init_config.rst:162 msgid "" "On success, the string must be released with ``free(value)`` if it's not " "``NULL``." msgstr "" +"成功時に取得した文字列が ``NULL`` でなければ、呼び出し元で ``free(value)`` を" +"使って解放しなければなりません。" -#: ../../c-api/init_config.rst:168 msgid "" "Get a string list configuration option as an array of null-terminated UTF-8 " "encoded strings." msgstr "" +"文字列リストの設定オプションを、null 終端の UTF-8 エンコード文字列の配列とし" +"て取得します。" #: ../../c-api/init_config.rst:171 msgid "Set *\\*length* and *\\*value*, and return ``0`` on success." msgstr "" -#: ../../c-api/init_config.rst:174 msgid "" "On success, the string list must be released with " "``PyInitConfig_FreeStrList(length, items)``." msgstr "" +"成功時は、``PyInitConfig_FreeStrList(length, items)`` で文字列リストを解放し" +"なければなりません。" -#: ../../c-api/init_config.rst:180 msgid "Free memory of a string list created by ``PyInitConfig_GetStrList()``." msgstr "" +"``PyInitConfig_GetStrList()`` で作成した文字列リストのメモリを解放します。" -#: ../../c-api/init_config.rst:185 msgid "Set Options" -msgstr "" +msgstr "オプションの設定" -#: ../../c-api/init_config.rst:190 msgid "" "Some configuration options have side effects on other options. This logic is " "only implemented when ``Py_InitializeFromInitConfig()`` is called, not by " "the \"Set\" functions below. For example, setting ``dev_mode`` to ``1`` does " "not set ``faulthandler`` to ``1``." msgstr "" +"一部の設定オプションは、ほかのオプションに影響します。\n" +"この処理は ``Py_InitializeFromInitConfig()`` の呼び出し時にのみ行われ、以下の" +"設定関数では行われません。\n" +"例えば、``dev_mode`` を ``1`` に設定しても、``faulthandler`` は ``1`` になり" +"ません。" -#: ../../c-api/init_config.rst:197 msgid "Set an integer configuration option." -msgstr "" +msgstr "整数の設定オプションを設定します。" -#: ../../c-api/init_config.rst:199 ../../c-api/init_config.rst:208 -#: ../../c-api/init_config.rst:217 ../../c-api/init_config.rst:232 -#: ../../c-api/init_config.rst:248 ../../c-api/init_config.rst:591 msgid "Return ``0`` on success." -msgstr "" +msgstr "成功時は ``0`` を返します。" -#: ../../c-api/init_config.rst:205 msgid "" "Set a string configuration option from a null-terminated UTF-8 encoded " "string. The string is copied." msgstr "" +"文字列の設定オプションを、null 終端の UTF-8 エンコード文字列で設定します。\n" +"文字列はコピーされます。" -#: ../../c-api/init_config.rst:214 msgid "" "Set a string list configuration option from an array of null-terminated " "UTF-8 encoded strings. The string list is copied." msgstr "" +"文字列リストの設定オプションを、null 終端の UTF-8 エンコード文字列の配列で設" +"定します。\n" +"文字列リストはコピーされます。" -#: ../../c-api/init_config.rst:222 msgid "Module" -msgstr "" +msgstr "モジュール" -#: ../../c-api/init_config.rst:226 msgid "Add a built-in extension module to the table of built-in modules." -msgstr "" +msgstr "組み込みモジュールのテーブルに、組み込みの拡張モジュールを追加します。" -#: ../../c-api/init_config.rst:228 msgid "" "The new module can be imported by the name *name*, and uses the function " "*initfunc* as the initialization function called on the first attempted " "import." msgstr "" +"新しいモジュールは *name* という名前でインポートでき、最初のインポートの試行" +"時に呼び出す初期化関数として *initfunc* を使います。" -#: ../../c-api/init_config.rst:235 msgid "" "If Python is initialized multiple times, ``PyInitConfig_AddModule()`` must " "be called at each Python initialization." msgstr "" +"Python を複数回初期化する場合は、初期化のたびに ``PyInitConfig_AddModule()`` " +"を呼び出さなければなりません。" -#: ../../c-api/init_config.rst:238 msgid "Similar to the :c:func:`PyImport_AppendInittab` function." -msgstr "" +msgstr ":c:func:`PyImport_AppendInittab` 関数と同様です。" -#: ../../c-api/init_config.rst:242 msgid "Initialize Python" -msgstr "" +msgstr "Python の初期化" -#: ../../c-api/init_config.rst:246 msgid "Initialize Python from the initialization configuration." -msgstr "" +msgstr "初期化設定から Python を初期化します。" -#: ../../c-api/init_config.rst:250 msgid "Set an exit code in *config* and return ``-1`` if Python wants to exit." msgstr "" +"Python が終了を要求する場合は、*config* に終了コードを設定して ``-1`` を返し" +"ます。" -#: ../../c-api/init_config.rst:253 msgid "See ``PyInitConfig_GetExitcode()`` for the exit code case." msgstr "" +"終了コードが設定された場合については、``PyInitConfig_GetExitcode()`` を参照し" +"てください。" -#: ../../c-api/init_config.rst:259 msgid "Configuration Options" -msgstr "" +msgstr "設定オプション" #: ../../c-api/init_config.rst:264 msgid "Option" msgstr "オプション" -#: ../../c-api/init_config.rst:265 msgid "PyConfig/PyPreConfig member" -msgstr "" +msgstr "PyConfig/PyPreConfig のメンバー" #: ../../c-api/init_config.rst:266 msgid "Type" @@ -389,13 +383,11 @@ msgstr "型" msgid "Visibility" msgstr "可視性" -#: ../../c-api/init_config.rst:268 msgid "``\"allocator\"``" -msgstr "" +msgstr "``\"allocator\"``" -#: ../../c-api/init_config.rst:269 msgid ":c:member:`allocator `" -msgstr "" +msgstr ":c:member:`allocator `" #: ../../c-api/init_config.rst:270 ../../c-api/init_config.rst:294 #: ../../c-api/init_config.rst:322 ../../c-api/init_config.rst:358 @@ -431,42 +423,23 @@ msgstr "``int``" msgid "Read-only" msgstr "読み出し専用" -#: ../../c-api/init_config.rst:272 msgid "``\"argv\"``" -msgstr "" +msgstr "``\"argv\"``" -#: ../../c-api/init_config.rst:273 msgid ":c:member:`argv `" -msgstr "" +msgstr ":c:member:`argv `" -#: ../../c-api/init_config.rst:274 ../../c-api/init_config.rst:402 -#: ../../c-api/init_config.rst:410 ../../c-api/init_config.rst:530 -#: ../../c-api/init_config.rst:578 msgid "``list[str]``" -msgstr "" +msgstr "``list[str]``" -#: ../../c-api/init_config.rst:275 ../../c-api/init_config.rst:279 -#: ../../c-api/init_config.rst:283 ../../c-api/init_config.rst:287 -#: ../../c-api/init_config.rst:295 ../../c-api/init_config.rst:323 -#: ../../c-api/init_config.rst:339 ../../c-api/init_config.rst:343 -#: ../../c-api/init_config.rst:371 ../../c-api/init_config.rst:379 -#: ../../c-api/init_config.rst:383 ../../c-api/init_config.rst:403 -#: ../../c-api/init_config.rst:407 ../../c-api/init_config.rst:419 -#: ../../c-api/init_config.rst:431 ../../c-api/init_config.rst:435 -#: ../../c-api/init_config.rst:443 ../../c-api/init_config.rst:447 -#: ../../c-api/init_config.rst:491 ../../c-api/init_config.rst:499 -#: ../../c-api/init_config.rst:523 ../../c-api/init_config.rst:531 -#: ../../c-api/init_config.rst:535 ../../c-api/init_config.rst:539 msgid "Public" -msgstr "" +msgstr "公開" -#: ../../c-api/init_config.rst:276 msgid "``\"base_exec_prefix\"``" -msgstr "" +msgstr "``\"base_exec_prefix\"``" -#: ../../c-api/init_config.rst:277 msgid ":c:member:`base_exec_prefix `" -msgstr "" +msgstr ":c:member:`base_exec_prefix `" #: ../../c-api/init_config.rst:278 ../../c-api/init_config.rst:282 #: ../../c-api/init_config.rst:286 ../../c-api/init_config.rst:298 @@ -482,29 +455,23 @@ msgstr "" msgid "``str``" msgstr "``str``" -#: ../../c-api/init_config.rst:280 msgid "``\"base_executable\"``" -msgstr "" +msgstr "``\"base_executable\"``" -#: ../../c-api/init_config.rst:281 msgid ":c:member:`base_executable `" -msgstr "" +msgstr ":c:member:`base_executable `" -#: ../../c-api/init_config.rst:284 msgid "``\"base_prefix\"``" -msgstr "" +msgstr "``\"base_prefix\"``" -#: ../../c-api/init_config.rst:285 msgid ":c:member:`base_prefix `" -msgstr "" +msgstr ":c:member:`base_prefix `" -#: ../../c-api/init_config.rst:288 msgid "``\"buffered_stdio\"``" -msgstr "" +msgstr "``\"buffered_stdio\"``" -#: ../../c-api/init_config.rst:289 msgid ":c:member:`buffered_stdio `" -msgstr "" +msgstr ":c:member:`buffered_stdio `" #: ../../c-api/init_config.rst:290 ../../c-api/init_config.rst:302 #: ../../c-api/init_config.rst:306 ../../c-api/init_config.rst:310 @@ -527,619 +494,490 @@ msgstr "" msgid "``bool``" msgstr "``bool``" -#: ../../c-api/init_config.rst:292 msgid "``\"bytes_warning\"``" -msgstr "" +msgstr "``\"bytes_warning\"``" -#: ../../c-api/init_config.rst:293 msgid ":c:member:`bytes_warning `" -msgstr "" +msgstr ":c:member:`bytes_warning `" -#: ../../c-api/init_config.rst:296 msgid "``\"check_hash_pycs_mode\"``" -msgstr "" +msgstr "``\"check_hash_pycs_mode\"``" -#: ../../c-api/init_config.rst:297 msgid ":c:member:`check_hash_pycs_mode `" -msgstr "" +msgstr ":c:member:`check_hash_pycs_mode `" -#: ../../c-api/init_config.rst:300 msgid "``\"code_debug_ranges\"``" -msgstr "" +msgstr "``\"code_debug_ranges\"``" -#: ../../c-api/init_config.rst:301 msgid ":c:member:`code_debug_ranges `" -msgstr "" +msgstr ":c:member:`code_debug_ranges `" -#: ../../c-api/init_config.rst:304 msgid "``\"coerce_c_locale\"``" -msgstr "" +msgstr "``\"coerce_c_locale\"``" -#: ../../c-api/init_config.rst:305 msgid ":c:member:`coerce_c_locale `" -msgstr "" +msgstr ":c:member:`coerce_c_locale `" -#: ../../c-api/init_config.rst:308 msgid "``\"coerce_c_locale_warn\"``" -msgstr "" +msgstr "``\"coerce_c_locale_warn\"``" -#: ../../c-api/init_config.rst:309 msgid ":c:member:`coerce_c_locale_warn `" -msgstr "" +msgstr ":c:member:`coerce_c_locale_warn `" -#: ../../c-api/init_config.rst:312 msgid "``\"configure_c_stdio\"``" -msgstr "" +msgstr "``\"configure_c_stdio\"``" -#: ../../c-api/init_config.rst:313 msgid ":c:member:`configure_c_stdio `" -msgstr "" +msgstr ":c:member:`configure_c_stdio `" -#: ../../c-api/init_config.rst:316 msgid "``\"configure_locale\"``" -msgstr "" +msgstr "``\"configure_locale\"``" -#: ../../c-api/init_config.rst:317 msgid ":c:member:`configure_locale `" -msgstr "" +msgstr ":c:member:`configure_locale `" -#: ../../c-api/init_config.rst:320 msgid "``\"cpu_count\"``" -msgstr "" +msgstr "``\"cpu_count\"``" -#: ../../c-api/init_config.rst:321 msgid ":c:member:`cpu_count `" -msgstr "" +msgstr ":c:member:`cpu_count `" -#: ../../c-api/init_config.rst:324 msgid "``\"dev_mode\"``" -msgstr "" +msgstr "``\"dev_mode\"``" -#: ../../c-api/init_config.rst:325 msgid ":c:member:`dev_mode `" -msgstr "" +msgstr ":c:member:`dev_mode `" -#: ../../c-api/init_config.rst:328 msgid "``\"dump_refs\"``" -msgstr "" +msgstr "``\"dump_refs\"``" -#: ../../c-api/init_config.rst:329 msgid ":c:member:`dump_refs `" -msgstr "" +msgstr ":c:member:`dump_refs `" -#: ../../c-api/init_config.rst:332 msgid "``\"dump_refs_file\"``" -msgstr "" +msgstr "``\"dump_refs_file\"``" -#: ../../c-api/init_config.rst:333 msgid ":c:member:`dump_refs_file `" -msgstr "" +msgstr ":c:member:`dump_refs_file `" -#: ../../c-api/init_config.rst:336 msgid "``\"exec_prefix\"``" -msgstr "" +msgstr "``\"exec_prefix\"``" -#: ../../c-api/init_config.rst:337 msgid ":c:member:`exec_prefix `" -msgstr "" +msgstr ":c:member:`exec_prefix `" -#: ../../c-api/init_config.rst:340 msgid "``\"executable\"``" -msgstr "" +msgstr "``\"executable\"``" -#: ../../c-api/init_config.rst:341 msgid ":c:member:`executable `" -msgstr "" +msgstr ":c:member:`executable `" -#: ../../c-api/init_config.rst:344 msgid "``\"faulthandler\"``" -msgstr "" +msgstr "``\"faulthandler\"``" -#: ../../c-api/init_config.rst:345 msgid ":c:member:`faulthandler `" -msgstr "" +msgstr ":c:member:`faulthandler `" -#: ../../c-api/init_config.rst:348 msgid "``\"filesystem_encoding\"``" -msgstr "" +msgstr "``\"filesystem_encoding\"``" -#: ../../c-api/init_config.rst:349 msgid ":c:member:`filesystem_encoding `" -msgstr "" +msgstr ":c:member:`filesystem_encoding `" -#: ../../c-api/init_config.rst:352 msgid "``\"filesystem_errors\"``" -msgstr "" +msgstr "``\"filesystem_errors\"``" -#: ../../c-api/init_config.rst:353 msgid ":c:member:`filesystem_errors `" -msgstr "" +msgstr ":c:member:`filesystem_errors `" -#: ../../c-api/init_config.rst:356 msgid "``\"hash_seed\"``" -msgstr "" +msgstr "``\"hash_seed\"``" -#: ../../c-api/init_config.rst:357 msgid ":c:member:`hash_seed `" -msgstr "" +msgstr ":c:member:`hash_seed `" -#: ../../c-api/init_config.rst:360 msgid "``\"home\"``" -msgstr "" +msgstr "``\"home\"``" -#: ../../c-api/init_config.rst:361 msgid ":c:member:`home `" -msgstr "" +msgstr ":c:member:`home `" -#: ../../c-api/init_config.rst:364 msgid "``\"import_time\"``" -msgstr "" +msgstr "``\"import_time\"``" -#: ../../c-api/init_config.rst:365 msgid ":c:member:`import_time `" -msgstr "" +msgstr ":c:member:`import_time `" -#: ../../c-api/init_config.rst:368 msgid "``\"inspect\"``" -msgstr "" +msgstr "``\"inspect\"``" -#: ../../c-api/init_config.rst:369 msgid ":c:member:`inspect `" -msgstr "" +msgstr ":c:member:`inspect `" -#: ../../c-api/init_config.rst:372 msgid "``\"install_signal_handlers\"``" -msgstr "" +msgstr "``\"install_signal_handlers\"``" -#: ../../c-api/init_config.rst:373 msgid ":c:member:`install_signal_handlers `" -msgstr "" +msgstr ":c:member:`install_signal_handlers `" -#: ../../c-api/init_config.rst:376 msgid "``\"int_max_str_digits\"``" -msgstr "" +msgstr "``\"int_max_str_digits\"``" -#: ../../c-api/init_config.rst:377 msgid ":c:member:`int_max_str_digits `" -msgstr "" +msgstr ":c:member:`int_max_str_digits `" -#: ../../c-api/init_config.rst:380 msgid "``\"interactive\"``" -msgstr "" +msgstr "``\"interactive\"``" -#: ../../c-api/init_config.rst:381 msgid ":c:member:`interactive `" -msgstr "" +msgstr ":c:member:`interactive `" -#: ../../c-api/init_config.rst:384 msgid "``\"isolated\"``" -msgstr "" +msgstr "``\"isolated\"``" -#: ../../c-api/init_config.rst:385 msgid ":c:member:`isolated `" -msgstr "" +msgstr ":c:member:`isolated `" -#: ../../c-api/init_config.rst:388 msgid "``\"legacy_windows_fs_encoding\"``" -msgstr "" +msgstr "``\"legacy_windows_fs_encoding\"``" -#: ../../c-api/init_config.rst:389 msgid "" ":c:member:`legacy_windows_fs_encoding `" msgstr "" +":c:member:`legacy_windows_fs_encoding `" -#: ../../c-api/init_config.rst:392 msgid "``\"legacy_windows_stdio\"``" -msgstr "" +msgstr "``\"legacy_windows_stdio\"``" -#: ../../c-api/init_config.rst:393 msgid ":c:member:`legacy_windows_stdio `" -msgstr "" +msgstr ":c:member:`legacy_windows_stdio `" -#: ../../c-api/init_config.rst:396 msgid "``\"malloc_stats\"``" -msgstr "" +msgstr "``\"malloc_stats\"``" -#: ../../c-api/init_config.rst:397 msgid ":c:member:`malloc_stats `" -msgstr "" +msgstr ":c:member:`malloc_stats `" -#: ../../c-api/init_config.rst:400 msgid "``\"module_search_paths\"``" -msgstr "" +msgstr "``\"module_search_paths\"``" -#: ../../c-api/init_config.rst:401 msgid ":c:member:`module_search_paths `" -msgstr "" +msgstr ":c:member:`module_search_paths `" -#: ../../c-api/init_config.rst:404 msgid "``\"optimization_level\"``" -msgstr "" +msgstr "``\"optimization_level\"``" -#: ../../c-api/init_config.rst:405 msgid ":c:member:`optimization_level `" -msgstr "" +msgstr ":c:member:`optimization_level `" -#: ../../c-api/init_config.rst:408 msgid "``\"orig_argv\"``" -msgstr "" +msgstr "``\"orig_argv\"``" -#: ../../c-api/init_config.rst:409 msgid ":c:member:`orig_argv `" -msgstr "" +msgstr ":c:member:`orig_argv `" -#: ../../c-api/init_config.rst:412 msgid "``\"parse_argv\"``" -msgstr "" +msgstr "``\"parse_argv\"``" -#: ../../c-api/init_config.rst:413 msgid ":c:member:`parse_argv `" -msgstr "" +msgstr ":c:member:`parse_argv `" -#: ../../c-api/init_config.rst:416 msgid "``\"parser_debug\"``" -msgstr "" +msgstr "``\"parser_debug\"``" -#: ../../c-api/init_config.rst:417 msgid ":c:member:`parser_debug `" -msgstr "" +msgstr ":c:member:`parser_debug `" -#: ../../c-api/init_config.rst:420 msgid "``\"pathconfig_warnings\"``" -msgstr "" +msgstr "``\"pathconfig_warnings\"``" -#: ../../c-api/init_config.rst:421 msgid ":c:member:`pathconfig_warnings `" -msgstr "" +msgstr ":c:member:`pathconfig_warnings `" -#: ../../c-api/init_config.rst:424 msgid "``\"perf_profiling\"``" -msgstr "" +msgstr "``\"perf_profiling\"``" -#: ../../c-api/init_config.rst:425 msgid ":c:member:`perf_profiling `" -msgstr "" +msgstr ":c:member:`perf_profiling `" -#: ../../c-api/init_config.rst:428 msgid "``\"platlibdir\"``" -msgstr "" +msgstr "``\"platlibdir\"``" -#: ../../c-api/init_config.rst:429 msgid ":c:member:`platlibdir `" -msgstr "" +msgstr ":c:member:`platlibdir `" -#: ../../c-api/init_config.rst:432 msgid "``\"prefix\"``" -msgstr "" +msgstr "``\"prefix\"``" -#: ../../c-api/init_config.rst:433 msgid ":c:member:`prefix `" -msgstr "" +msgstr ":c:member:`prefix `" -#: ../../c-api/init_config.rst:436 msgid "``\"program_name\"``" -msgstr "" +msgstr "``\"program_name\"``" -#: ../../c-api/init_config.rst:437 msgid ":c:member:`program_name `" -msgstr "" +msgstr ":c:member:`program_name `" -#: ../../c-api/init_config.rst:440 msgid "``\"pycache_prefix\"``" -msgstr "" +msgstr "``\"pycache_prefix\"``" -#: ../../c-api/init_config.rst:441 msgid ":c:member:`pycache_prefix `" -msgstr "" +msgstr ":c:member:`pycache_prefix `" -#: ../../c-api/init_config.rst:444 msgid "``\"quiet\"``" -msgstr "" +msgstr "``\"quiet\"``" -#: ../../c-api/init_config.rst:445 msgid ":c:member:`quiet `" -msgstr "" +msgstr ":c:member:`quiet `" -#: ../../c-api/init_config.rst:448 msgid "``\"run_command\"``" -msgstr "" +msgstr "``\"run_command\"``" -#: ../../c-api/init_config.rst:449 msgid ":c:member:`run_command `" -msgstr "" +msgstr ":c:member:`run_command `" -#: ../../c-api/init_config.rst:452 msgid "``\"run_filename\"``" -msgstr "" +msgstr "``\"run_filename\"``" -#: ../../c-api/init_config.rst:453 msgid ":c:member:`run_filename `" -msgstr "" +msgstr ":c:member:`run_filename `" -#: ../../c-api/init_config.rst:456 msgid "``\"run_module\"``" -msgstr "" +msgstr "``\"run_module\"``" -#: ../../c-api/init_config.rst:457 msgid ":c:member:`run_module `" -msgstr "" +msgstr ":c:member:`run_module `" -#: ../../c-api/init_config.rst:460 msgid "``\"run_presite\"``" -msgstr "" +msgstr "``\"run_presite\"``" -#: ../../c-api/init_config.rst:461 msgid ":c:member:`run_presite `" -msgstr "" +msgstr ":c:member:`run_presite `" -#: ../../c-api/init_config.rst:464 msgid "``\"safe_path\"``" -msgstr "" +msgstr "``\"safe_path\"``" -#: ../../c-api/init_config.rst:465 msgid ":c:member:`safe_path `" -msgstr "" +msgstr ":c:member:`safe_path `" -#: ../../c-api/init_config.rst:468 msgid "``\"show_ref_count\"``" -msgstr "" +msgstr "``\"show_ref_count\"``" -#: ../../c-api/init_config.rst:469 msgid ":c:member:`show_ref_count `" -msgstr "" +msgstr ":c:member:`show_ref_count `" -#: ../../c-api/init_config.rst:472 msgid "``\"site_import\"``" -msgstr "" +msgstr "``\"site_import\"``" -#: ../../c-api/init_config.rst:473 msgid ":c:member:`site_import `" -msgstr "" +msgstr ":c:member:`site_import `" -#: ../../c-api/init_config.rst:476 msgid "``\"skip_source_first_line\"``" -msgstr "" +msgstr "``\"skip_source_first_line\"``" -#: ../../c-api/init_config.rst:477 msgid ":c:member:`skip_source_first_line `" -msgstr "" +msgstr ":c:member:`skip_source_first_line `" -#: ../../c-api/init_config.rst:480 msgid "``\"stdio_encoding\"``" -msgstr "" +msgstr "``\"stdio_encoding\"``" -#: ../../c-api/init_config.rst:481 msgid ":c:member:`stdio_encoding `" -msgstr "" +msgstr ":c:member:`stdio_encoding `" -#: ../../c-api/init_config.rst:484 msgid "``\"stdio_errors\"``" -msgstr "" +msgstr "``\"stdio_errors\"``" -#: ../../c-api/init_config.rst:485 msgid ":c:member:`stdio_errors `" -msgstr "" +msgstr ":c:member:`stdio_errors `" -#: ../../c-api/init_config.rst:488 msgid "``\"stdlib_dir\"``" -msgstr "" +msgstr "``\"stdlib_dir\"``" -#: ../../c-api/init_config.rst:489 msgid ":c:member:`stdlib_dir `" -msgstr "" +msgstr ":c:member:`stdlib_dir `" -#: ../../c-api/init_config.rst:492 msgid "``\"tracemalloc\"``" -msgstr "" +msgstr "``\"tracemalloc\"``" -#: ../../c-api/init_config.rst:493 msgid ":c:member:`tracemalloc `" -msgstr "" +msgstr ":c:member:`tracemalloc `" -#: ../../c-api/init_config.rst:496 msgid "``\"use_environment\"``" -msgstr "" +msgstr "``\"use_environment\"``" -#: ../../c-api/init_config.rst:497 msgid ":c:member:`use_environment `" -msgstr "" +msgstr ":c:member:`use_environment `" -#: ../../c-api/init_config.rst:500 msgid "``\"use_frozen_modules\"``" -msgstr "" +msgstr "``\"use_frozen_modules\"``" -#: ../../c-api/init_config.rst:501 msgid ":c:member:`use_frozen_modules `" -msgstr "" +msgstr ":c:member:`use_frozen_modules `" -#: ../../c-api/init_config.rst:504 msgid "``\"use_hash_seed\"``" -msgstr "" +msgstr "``\"use_hash_seed\"``" -#: ../../c-api/init_config.rst:505 msgid ":c:member:`use_hash_seed `" -msgstr "" +msgstr ":c:member:`use_hash_seed `" -#: ../../c-api/init_config.rst:508 msgid "``\"use_system_logger\"``" -msgstr "" +msgstr "``\"use_system_logger\"``" -#: ../../c-api/init_config.rst:509 msgid ":c:member:`use_system_logger `" -msgstr "" +msgstr ":c:member:`use_system_logger `" -#: ../../c-api/init_config.rst:512 msgid "``\"user_site_directory\"``" -msgstr "" +msgstr "``\"user_site_directory\"``" -#: ../../c-api/init_config.rst:513 msgid ":c:member:`user_site_directory `" -msgstr "" +msgstr ":c:member:`user_site_directory `" -#: ../../c-api/init_config.rst:516 msgid "``\"utf8_mode\"``" -msgstr "" +msgstr "``\"utf8_mode\"``" -#: ../../c-api/init_config.rst:517 msgid ":c:member:`utf8_mode `" -msgstr "" +msgstr ":c:member:`utf8_mode `" -#: ../../c-api/init_config.rst:520 msgid "``\"verbose\"``" -msgstr "" +msgstr "``\"verbose\"``" -#: ../../c-api/init_config.rst:521 msgid ":c:member:`verbose `" -msgstr "" +msgstr ":c:member:`verbose `" -#: ../../c-api/init_config.rst:524 msgid "``\"warn_default_encoding\"``" -msgstr "" +msgstr "``\"warn_default_encoding\"``" -#: ../../c-api/init_config.rst:525 msgid ":c:member:`warn_default_encoding `" -msgstr "" +msgstr ":c:member:`warn_default_encoding `" -#: ../../c-api/init_config.rst:528 msgid "``\"warnoptions\"``" -msgstr "" +msgstr "``\"warnoptions\"``" -#: ../../c-api/init_config.rst:529 msgid ":c:member:`warnoptions `" -msgstr "" +msgstr ":c:member:`warnoptions `" -#: ../../c-api/init_config.rst:532 msgid "``\"write_bytecode\"``" -msgstr "" +msgstr "``\"write_bytecode\"``" -#: ../../c-api/init_config.rst:533 msgid ":c:member:`write_bytecode `" -msgstr "" +msgstr ":c:member:`write_bytecode `" -#: ../../c-api/init_config.rst:536 msgid "``\"xoptions\"``" -msgstr "" +msgstr "``\"xoptions\"``" -#: ../../c-api/init_config.rst:537 msgid ":c:member:`xoptions `" -msgstr "" +msgstr ":c:member:`xoptions `" -#: ../../c-api/init_config.rst:538 ../../c-api/init_config.rst:579 msgid "``dict[str, str]``" -msgstr "" +msgstr "``dict[str, str]``" -#: ../../c-api/init_config.rst:540 msgid "``\"_pystats\"``" -msgstr "" +msgstr "``\"_pystats\"``" -#: ../../c-api/init_config.rst:541 msgid ":c:member:`_pystats `" -msgstr "" +msgstr ":c:member:`_pystats `" -#: ../../c-api/init_config.rst:545 msgid "Visibility:" -msgstr "" +msgstr "可視性:" -#: ../../c-api/init_config.rst:547 msgid "" "Public: Can be retrieved by :c:func:`PyConfig_Get` and set by :c:func:" "`PyConfig_Set`." msgstr "" +"公開: :c:func:`PyConfig_Get` で取得でき、:c:func:`PyConfig_Set` で設定できま" +"す。" -#: ../../c-api/init_config.rst:549 msgid "" "Read-only: Can be retrieved by :c:func:`PyConfig_Get`, but cannot be set by :" "c:func:`PyConfig_Set`." msgstr "" +"読み取り専用: :c:func:`PyConfig_Get` で取得できますが、:c:func:" +"`PyConfig_Set` では設定できません。" -#: ../../c-api/init_config.rst:554 msgid "Runtime Python configuration API" -msgstr "" +msgstr "実行時の Python 設定 API" -#: ../../c-api/init_config.rst:556 msgid "" "At runtime, it's possible to get and set configuration options using :c:func:" "`PyConfig_Get` and :c:func:`PyConfig_Set` functions." msgstr "" +"実行時には、:c:func:`PyConfig_Get` と :c:func:`PyConfig_Set` を使って設定オプ" +"ションを取得・設定できます。" -#: ../../c-api/init_config.rst:562 msgid "" "Some options are read from the :mod:`sys` attributes. For example, the " "option ``\"argv\"`` is read from :data:`sys.argv`." msgstr "" +"一部のオプションは :mod:`sys` の属性から読み取ります。\n" +"例えば、``\"argv\"`` オプションは :data:`sys.argv` から読み取ります。" -#: ../../c-api/init_config.rst:568 msgid "" "Get the current runtime value of a configuration option as a Python object." msgstr "" +"設定オプションの現在の実行時の値を、Python オブジェクトとして取得します。" -#: ../../c-api/init_config.rst:570 ../../c-api/init_config.rst:601 msgid "Return a new reference on success." -msgstr "" +msgstr "成功時は新しい参照を返します。" -#: ../../c-api/init_config.rst:571 ../../c-api/init_config.rst:602 msgid "Set an exception and return ``NULL`` on error." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/init_config.rst:573 msgid "The object type depends on the configuration option. It can be:" msgstr "" +"オブジェクトの型は設定オプションによって異なり、次のいずれかになります。" -#: ../../c-api/init_config.rst:581 ../../c-api/init_config.rst:604 -#: ../../c-api/init_config.rst:619 msgid "" "The caller must have an :term:`attached thread state`. The function cannot " "be called before Python initialization nor after Python finalization." msgstr "" +"呼び出し元には :term:`スレッド状態がアタッチされていなければなりません " +"`。\n" +"Python の初期化前や終了処理後には呼び出せません。" -#: ../../c-api/init_config.rst:589 msgid "Similar to :c:func:`PyConfig_Get`, but get the value as a C int." msgstr "" +":c:func:`PyConfig_Get` と同様ですが、値を C の ``int`` として取得します。" -#: ../../c-api/init_config.rst:592 msgid "Set an exception and return ``-1`` on error." -msgstr "" +msgstr "エラー時は例外を設定して ``-1`` を返します。" -#: ../../c-api/init_config.rst:599 msgid "Get all configuration option names as a ``frozenset``." -msgstr "" +msgstr "すべての設定オプションの名前を ``frozenset`` として取得します。" -#: ../../c-api/init_config.rst:612 msgid "Set the current runtime value of a configuration option." -msgstr "" +msgstr "設定オプションの現在の実行時の値を設定します。" -#: ../../c-api/init_config.rst:614 msgid "Raise a :exc:`ValueError` if there is no option *name*." -msgstr "" +msgstr "*name* というオプションがなければ :exc:`ValueError` を送出します。" -#: ../../c-api/init_config.rst:615 msgid "Raise a :exc:`ValueError` if *value* is an invalid value." -msgstr "" +msgstr "*value* が無効な値の場合は :exc:`ValueError` を送出します。" -#: ../../c-api/init_config.rst:616 msgid "Raise a :exc:`ValueError` if the option is read-only (cannot be set)." msgstr "" +"オプションが読み取り専用で設定できない場合は :exc:`ValueError` を送出します。" -#: ../../c-api/init_config.rst:617 msgid "Raise a :exc:`TypeError` if *value* has not the proper type." -msgstr "" +msgstr "*value* の型が正しくない場合は :exc:`TypeError` を送出します。" -#: ../../c-api/init_config.rst:622 msgid "" "Raises an :ref:`auditing event ` ``cpython.PyConfig_Set`` with " "arguments ``name``, ``value``." msgstr "" +"引数 ``name``、``value`` を指定して、:ref:`監査イベント ` " +"``cpython.PyConfig_Set`` を送出します。" -#: ../../c-api/init_config.rst:626 msgid "" "The function now replaces :data:`sys.flags` (create a new object), instead " "of modifying :data:`sys.flags` in-place." msgstr "" +":data:`sys.flags` をその場で変更するのではなく、新しいオブジェクトを作成し" +"て :data:`sys.flags` を置き換えるようになりました。" -#: ../../c-api/init_config.rst:634 msgid "PyConfig C API" -msgstr "" +msgstr "PyConfig C API" #: ../../c-api/init_config.rst:638 msgid "" @@ -1166,23 +1004,25 @@ msgstr "" "舞いをするカスタマイズされた Python を構築するために使用されます。例えば、環" "境変数やコマンドライン引数がPythonを設定するために使用されます。" -#: ../../c-api/init_config.rst:649 msgid "" "The :ref:`Isolated Configuration ` can be used to embed " "Python into an application. It isolates Python from the system. For example, " "environment variables are ignored, the LC_CTYPE locale is left unchanged and " "no signal handler is registered." msgstr "" +":ref:`隔離設定 ` は、Python をアプリケーションに組み込む" +"ために使えます。\n" +"Python をシステムから隔離します。\n" +"例えば、環境変数を無視し、LC_CTYPE ロケールを変更せず、シグナルハンドラーを登" +"録しません。" #: ../../c-api/init_config.rst:660 msgid ":pep:`587` \"Python Initialization Configuration\"." msgstr ":pep:`587` \"Python 初期化設定\"" -#: ../../c-api/init_config.rst:666 msgid "Example of customized Python always running in isolated mode::" -msgstr "" +msgstr "常に隔離モードで実行するようカスタマイズした Python の例です。 ::" -#: ../../c-api/init_config.rst:668 msgid "" "int main(int argc, char **argv)\n" "{\n" @@ -1217,6 +1057,38 @@ msgid "" " Py_ExitStatusException(status);\n" "}" msgstr "" +"int main(int argc, char **argv)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config.isolated = 1;\n" +"\n" +" /* コマンドライン引数をデコードする。\n" +" Python を暗黙に事前初期化する (隔離モード)。 */\n" +" status = PyConfig_SetBytesArgv(&config, argc, argv);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" return Py_RunMain();\n" +"\n" +"exception:\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_IsExit(status)) {\n" +" return status.exitcode;\n" +" }\n" +" /* エラーメッセージを表示し、ゼロ以外の終了コードで\n" +" プロセスを終了する */\n" +" Py_ExitStatusException(status);\n" +"}" #: ../../c-api/init_config.rst:703 msgid "PyWideStringList" @@ -1242,9 +1114,8 @@ msgstr "メソッド:" msgid "Append *item* to *list*." msgstr "*item* を *list* に追加します。" -#: ../../c-api/init_config.rst:720 ../../c-api/init_config.rst:731 msgid "Python must be preinitialized to call this function." -msgstr "" +msgstr "呼び出す前に、Python を事前初期化しておく必要があります。" #: ../../c-api/init_config.rst:724 msgid "Insert *item* into *list* at *index*." @@ -1257,9 +1128,8 @@ msgid "" msgstr "" "*index* が *list* の長さ以上の場合、*item* を *list* の末尾に追加します。" -#: ../../c-api/init_config.rst:729 msgid "*index* must be greater than or equal to ``0``." -msgstr "" +msgstr "*index* は ``0`` 以上でなければなりません。" #: ../../c-api/init_config.rst:735 ../../c-api/init_config.rst:755 #: ../../c-api/init_config.rst:862 ../../c-api/init_config.rst:1179 @@ -1307,13 +1177,11 @@ msgstr "ステータスを生成する関数:" msgid "Success." msgstr "成功。" -#: ../../c-api/init_config.rst:779 msgid "Initialization error with a message." -msgstr "メッセージとともにエラーを初期化します。" +msgstr "メッセージを伴う初期化エラー。" -#: ../../c-api/init_config.rst:781 msgid "*err_msg* must not be ``NULL``." -msgstr "" +msgstr "*err_msg* は ``NULL`` であってはなりません。" #: ../../c-api/init_config.rst:785 msgid "Memory allocation failure (out of memory)." @@ -1327,32 +1195,37 @@ msgstr "指定した終了コードでPythonを終了します。" msgid "Functions to handle a status:" msgstr "ステータスを扱う関数:" -#: ../../c-api/init_config.rst:795 msgid "" "Is the status an error or an exit? If true, the exception must be handled; " "by calling :c:func:`Py_ExitStatusException` for example." msgstr "" +"状態がエラーまたは終了を表すかどうかを調べます。\n" +"真の場合は、:c:func:`Py_ExitStatusException` を呼び出すなどして対処しなければ" +"なりません。" -#: ../../c-api/init_config.rst:800 msgid "Is the result an error?" -msgstr "" +msgstr "結果がエラーかどうかを調べます。" -#: ../../c-api/init_config.rst:804 msgid "Is the result an exit?" -msgstr "" +msgstr "結果が終了かどうかを調べます。" -#: ../../c-api/init_config.rst:808 msgid "" "Call ``exit(exitcode)`` if *status* is an exit. Print the error message and " "exit with a non-zero exit code if *status* is an error. Must only be called " "if ``PyStatus_Exception(status)`` is non-zero." msgstr "" +"*status* が終了を表す場合は、``exit(exitcode)`` を呼び出します。\n" +"*status* がエラーを表す場合は、エラーメッセージを表示し、ゼロ以外の終了コード" +"で終了します。\n" +"``PyStatus_Exception(status)`` がゼロ以外の場合にのみ呼び出さなければなりませ" +"ん。" -#: ../../c-api/init_config.rst:813 msgid "" "Internally, Python uses macros which set ``PyStatus.func``, whereas " "functions to create a status set ``func`` to ``NULL``." msgstr "" +"Python 内部では ``PyStatus.func`` を設定するマクロを使いますが、状態を作成す" +"る関数は ``func`` を ``NULL`` に設定します。" #: ../../c-api/init_config.rst:816 msgid "Example::" @@ -1385,69 +1258,72 @@ msgstr "" msgid "PyPreConfig" msgstr "PyPreConfig" -#: ../../c-api/init_config.rst:844 msgid "Structure used to preinitialize Python." -msgstr "" +msgstr "Python の事前初期化に使う構造体です。" -#: ../../c-api/init_config.rst:848 msgid "Function to initialize a preconfiguration:" -msgstr "" +msgstr "事前設定を初期化する関数:" -#: ../../c-api/init_config.rst:852 msgid "" "Initialize the preconfiguration with :ref:`Python Configuration `." -msgstr "" +msgstr ":ref:`Python 設定 ` で事前設定を初期化します。" -#: ../../c-api/init_config.rst:857 msgid "" "Initialize the preconfiguration with :ref:`Isolated Configuration `." -msgstr "" +msgstr ":ref:`隔離設定 ` で事前設定を初期化します。" -#: ../../c-api/init_config.rst:866 msgid "Name of the Python memory allocators:" -msgstr "" +msgstr "Python のメモリアロケーターの名前:" -#: ../../c-api/init_config.rst:868 msgid "" "``PYMEM_ALLOCATOR_NOT_SET`` (``0``): don't change memory allocators (use " "defaults)." msgstr "" +"``PYMEM_ALLOCATOR_NOT_SET`` (``0``): メモリアロケーターを変更せず、デフォルト" +"を使います。" -#: ../../c-api/init_config.rst:870 msgid "" "``PYMEM_ALLOCATOR_DEFAULT`` (``1``): :ref:`default memory allocators " "`." msgstr "" +"``PYMEM_ALLOCATOR_DEFAULT`` (``1``): :ref:`デフォルトのメモリアロケーター " +"`。" -#: ../../c-api/init_config.rst:872 msgid "" "``PYMEM_ALLOCATOR_DEBUG`` (``2``): :ref:`default memory allocators ` with :ref:`debug hooks `." msgstr "" +"``PYMEM_ALLOCATOR_DEBUG`` (``2``): :ref:`デフォルトのメモリアロケーター " +"` に :ref:`デバッグフック ` を" +"付けます。" -#: ../../c-api/init_config.rst:875 msgid "``PYMEM_ALLOCATOR_MALLOC`` (``3``): use ``malloc()`` of the C library." msgstr "" +"``PYMEM_ALLOCATOR_MALLOC`` (``3``): C ライブラリの ``malloc()`` を使います。" -#: ../../c-api/init_config.rst:876 msgid "" "``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): force usage of ``malloc()`` with :" "ref:`debug hooks `." msgstr "" +"``PYMEM_ALLOCATOR_MALLOC_DEBUG`` (``4``): :ref:`デバッグフック ` 付きの ``malloc()`` の使用を強制します。" -#: ../../c-api/init_config.rst:878 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` (``5``): :ref:`Python pymalloc memory allocator " "`." msgstr "" +"``PYMEM_ALLOCATOR_PYMALLOC`` (``5``): :ref:`Python の pymalloc メモリアロケー" +"ター `。" -#: ../../c-api/init_config.rst:880 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc memory " "allocator ` with :ref:`debug hooks `." msgstr "" +"``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python の pymalloc メモリア" +"ロケーター ` に :ref:`デバッグフック ` を付けま" +"す。" #: ../../c-api/init_config.rst:883 msgid "" @@ -1461,217 +1337,204 @@ msgid "" "replacement with :ref:`debug hooks `." msgstr "" -#: ../../c-api/init_config.rst:889 msgid "" "``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-pymalloc <--" "without-pymalloc>`." msgstr "" +"Python を :option:`--without-pymalloc で構成した <--without-pymalloc>` 場合、" +"``PYMEM_ALLOCATOR_PYMALLOC`` と ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` はサポート" +"されません。" -#: ../../c-api/init_config.rst:893 msgid "" "``PYMEM_ALLOCATOR_MIMALLOC`` and ``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` are not " "supported if Python is :option:`configured using --without-mimalloc <--" "without-mimalloc>` or if the underlying atomic support isn't available." msgstr "" +"Python を :option:`--without-mimalloc で構成した <--without-mimalloc>` 場合" +"や、必要なアトミック操作を利用できない場合、``PYMEM_ALLOCATOR_MIMALLOC`` と " +"``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` はサポートされません。" -#: ../../c-api/init_config.rst:898 msgid "See :ref:`Memory Management `." -msgstr "" +msgstr ":ref:`メモリ管理 ` を参照してください。" -#: ../../c-api/init_config.rst:900 msgid "Default: ``PYMEM_ALLOCATOR_NOT_SET``." -msgstr "" +msgstr "デフォルト: ``PYMEM_ALLOCATOR_NOT_SET``。" -#: ../../c-api/init_config.rst:904 msgid "Set the LC_CTYPE locale to the user preferred locale." -msgstr "" +msgstr "LC_CTYPE ロケールを、ユーザーが選択したロケールに設定します。" -#: ../../c-api/init_config.rst:906 msgid "" "If equals to ``0``, set :c:member:`~PyPreConfig.coerce_c_locale` and :c:" "member:`~PyPreConfig.coerce_c_locale_warn` members to ``0``." msgstr "" +"``0`` の場合、:c:member:`~PyPreConfig.coerce_c_locale` と :c:member:" +"`~PyPreConfig.coerce_c_locale_warn` メンバーを ``0`` に設定します。" -#: ../../c-api/init_config.rst:909 ../../c-api/init_config.rst:920 msgid "See the :term:`locale encoding`." msgstr "" +":term:`ロケールエンコーディング ` を参照してください。" -#: ../../c-api/init_config.rst:911 ../../c-api/init_config.rst:966 -#: ../../c-api/init_config.rst:1340 msgid "Default: ``1`` in Python config, ``0`` in isolated config." -msgstr "" +msgstr "デフォルト: Python 設定では ``1``、隔離設定では ``0``。" -#: ../../c-api/init_config.rst:915 msgid "If equals to ``2``, coerce the C locale." -msgstr "" +msgstr "``2`` の場合、C ロケールを置き換えます。" -#: ../../c-api/init_config.rst:917 msgid "" "If equals to ``1``, read the LC_CTYPE locale to decide if it should be " "coerced." msgstr "" +"``1`` の場合、LC_CTYPE ロケールを調べ、置き換える必要があるかを判断します。" -#: ../../c-api/init_config.rst:922 ../../c-api/init_config.rst:928 msgid "Default: ``-1`` in Python config, ``0`` in isolated config." -msgstr "" +msgstr "デフォルト: Python 設定では ``-1``、隔離設定では ``0``。" -#: ../../c-api/init_config.rst:926 msgid "If non-zero, emit a warning if the C locale is coerced." -msgstr "" +msgstr "ゼロ以外の場合、C ロケールを置き換えたときに警告を出します。" -#: ../../c-api/init_config.rst:932 msgid "" ":ref:`Python Development Mode `: see :c:member:`PyConfig.dev_mode`." msgstr "" +":ref:`Python 開発モード `。\n" +":c:member:`PyConfig.dev_mode` を参照してください。" -#: ../../c-api/init_config.rst:935 ../../c-api/init_config.rst:1349 -#: ../../c-api/init_config.rst:1405 ../../c-api/init_config.rst:1899 msgid "Default: ``-1`` in Python mode, ``0`` in isolated mode." -msgstr "" +msgstr "デフォルト: Python モードでは ``-1``、隔離モードでは ``0``。" -#: ../../c-api/init_config.rst:939 msgid "Isolated mode: see :c:member:`PyConfig.isolated`." msgstr "" +"隔離モード。\n" +":c:member:`PyConfig.isolated` を参照してください。" -#: ../../c-api/init_config.rst:941 ../../c-api/init_config.rst:1576 msgid "Default: ``0`` in Python mode, ``1`` in isolated mode." -msgstr "" +msgstr "デフォルト: Python モードでは ``0``、隔離モードでは ``1``。" -#: ../../c-api/init_config.rst:945 msgid "If non-zero:" -msgstr "" +msgstr "ゼロ以外の場合:" -#: ../../c-api/init_config.rst:947 msgid "Set :c:member:`PyPreConfig.utf8_mode` to ``0``," -msgstr "" +msgstr ":c:member:`PyPreConfig.utf8_mode` を ``0`` に設定します。" -#: ../../c-api/init_config.rst:948 msgid "Set :c:member:`PyConfig.filesystem_encoding` to ``\"mbcs\"``," msgstr "" +":c:member:`PyConfig.filesystem_encoding` を ``\"mbcs\"`` に設定します。" -#: ../../c-api/init_config.rst:949 msgid "Set :c:member:`PyConfig.filesystem_errors` to ``\"replace\"``." msgstr "" +":c:member:`PyConfig.filesystem_errors` を ``\"replace\"`` に設定します。" -#: ../../c-api/init_config.rst:951 msgid "" "Initialized from the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment " "variable value." msgstr "" +":envvar:`PYTHONLEGACYWINDOWSFSENCODING` 環境変数の値から初期化されます。" -#: ../../c-api/init_config.rst:954 ../../c-api/init_config.rst:1590 msgid "" "Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for " "Windows specific code." msgstr "" +"Windows でのみ利用できます。\n" +"Windows 固有のコードには、``#ifdef MS_WINDOWS`` マクロを使えます。" -#: ../../c-api/init_config.rst:957 ../../c-api/init_config.rst:1283 -#: ../../c-api/init_config.rst:1295 ../../c-api/init_config.rst:1362 -#: ../../c-api/init_config.rst:1494 ../../c-api/init_config.rst:1512 -#: ../../c-api/init_config.rst:1526 ../../c-api/init_config.rst:1593 -#: ../../c-api/init_config.rst:1607 ../../c-api/init_config.rst:1667 -#: ../../c-api/init_config.rst:1719 ../../c-api/init_config.rst:1781 -#: ../../c-api/init_config.rst:1835 ../../c-api/init_config.rst:1864 -#: ../../c-api/init_config.rst:1978 ../../c-api/init_config.rst:2024 msgid "Default: ``0``." -msgstr "" +msgstr "デフォルト: ``0``。" -#: ../../c-api/init_config.rst:961 msgid "" "If non-zero, :c:func:`Py_PreInitializeFromArgs` and :c:func:" "`Py_PreInitializeFromBytesArgs` parse their ``argv`` argument the same way " "the regular Python parses command line arguments: see :ref:`Command Line " "Arguments `." msgstr "" +"ゼロ以外の場合、:c:func:`Py_PreInitializeFromArgs` と :c:func:" +"`Py_PreInitializeFromBytesArgs` は、通常の Python がコマンドライン引数を解析" +"するのと同じように ``argv`` 引数を解析します。\n" +":ref:`コマンドライン引数 ` を参照してください。" -#: ../../c-api/init_config.rst:970 msgid "" "Use :ref:`environment variables `? See :c:member:`PyConfig." "use_environment`." msgstr "" +":ref:`環境変数 ` を使うかどうか。\n" +":c:member:`PyConfig.use_environment` を参照してください。" -#: ../../c-api/init_config.rst:973 ../../c-api/init_config.rst:1940 msgid "Default: ``1`` in Python config and ``0`` in isolated config." -msgstr "" +msgstr "デフォルト: Python 設定では ``1``、隔離設定では ``0``。" -#: ../../c-api/init_config.rst:977 msgid "If non-zero, enable the :ref:`Python UTF-8 Mode `." msgstr "" +"ゼロ以外の場合、:ref:`Python UTF-8 モード ` を有効にします。" -#: ../../c-api/init_config.rst:979 msgid "" "Set to ``0`` or ``1`` by the :option:`-X utf8 <-X>` command line option and " "the :envvar:`PYTHONUTF8` environment variable." msgstr "" +":option:`-X utf8 <-X>` コマンドラインオプションと :envvar:`PYTHONUTF8` 環境変" +"数によって、``0`` または ``1`` に設定されます。" -#: ../../c-api/init_config.rst:982 ../../c-api/init_config.rst:1270 -#: ../../c-api/init_config.rst:1308 ../../c-api/init_config.rst:1852 -#: ../../c-api/init_config.rst:2009 msgid "Default: ``1``." -msgstr "" +msgstr "デフォルト: ``1``。" -#: ../../c-api/init_config.rst:988 msgid "Preinitialize Python with PyPreConfig" -msgstr "" +msgstr "PyPreConfig による Python の事前初期化" -#: ../../c-api/init_config.rst:990 msgid "The preinitialization of Python:" -msgstr "" +msgstr "Python の事前初期化では、次の処理を行います。" -#: ../../c-api/init_config.rst:992 msgid "Set the Python memory allocators (:c:member:`PyPreConfig.allocator`)" msgstr "" +"Python のメモリアロケーターを設定する (:c:member:`PyPreConfig.allocator`)" -#: ../../c-api/init_config.rst:993 msgid "Configure the LC_CTYPE locale (:term:`locale encoding`)" msgstr "" +"LC_CTYPE ロケールを設定する (:term:`ロケールエンコーディング `)" -#: ../../c-api/init_config.rst:994 msgid "" "Set the :ref:`Python UTF-8 Mode ` (:c:member:`PyPreConfig." "utf8_mode`)" msgstr "" +":ref:`Python UTF-8 モード ` を設定する (:c:member:`PyPreConfig." +"utf8_mode`)" -#: ../../c-api/init_config.rst:997 msgid "" "The current preconfiguration (``PyPreConfig`` type) is stored in " "``_PyRuntime.preconfig``." msgstr "" +"現在の事前設定 (``PyPreConfig`` 型) は、``_PyRuntime.preconfig`` に保存されて" +"います。" -#: ../../c-api/init_config.rst:1000 msgid "Functions to preinitialize Python:" -msgstr "" +msgstr "Python を事前初期化する関数:" -#: ../../c-api/init_config.rst:1004 ../../c-api/init_config.rst:1010 -#: ../../c-api/init_config.rst:1019 msgid "Preinitialize Python from *preconfig* preconfiguration." -msgstr "" +msgstr "事前設定 *preconfig* から Python を事前初期化します。" -#: ../../c-api/init_config.rst:1006 ../../c-api/init_config.rst:1015 -#: ../../c-api/init_config.rst:1024 msgid "*preconfig* must not be ``NULL``." -msgstr "" +msgstr "*preconfig* は ``NULL`` であってはなりません。" -#: ../../c-api/init_config.rst:1012 msgid "" "Parse *argv* command line arguments (bytes strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" +"*preconfig* の :c:member:`~PyPreConfig.parse_argv` がゼロ以外の場合、コマンド" +"ライン引数 *argv* (バイト文字列) を解析します。" -#: ../../c-api/init_config.rst:1021 msgid "" "Parse *argv* command line arguments (wide strings) if :c:member:" "`~PyPreConfig.parse_argv` of *preconfig* is non-zero." msgstr "" +"*preconfig* の :c:member:`~PyPreConfig.parse_argv` がゼロ以外の場合、コマンド" +"ライン引数 *argv* (ワイド文字列) を解析します。" -#: ../../c-api/init_config.rst:1026 ../../c-api/init_config.rst:2047 msgid "" "The caller is responsible to handle exceptions (error or exit) using :c:func:" "`PyStatus_Exception` and :c:func:`Py_ExitStatusException`." msgstr "" +"呼び出し元は、:c:func:`PyStatus_Exception` と :c:func:" +"`Py_ExitStatusException` を使って、エラーまたは終了の状態を処理する責任があり" +"ます。" -#: ../../c-api/init_config.rst:1029 msgid "" "For :ref:`Python Configuration ` (:c:func:" "`PyPreConfig_InitPythonConfig`), if Python is initialized with command line " @@ -1680,30 +1543,45 @@ msgid "" "For example, the :option:`-X utf8 <-X>` command line option enables the :ref:" "`Python UTF-8 Mode `." msgstr "" +":ref:`Python 設定 ` (:c:func:" +"`PyPreConfig_InitPythonConfig`) で、コマンドライン引数を使って Python を初期" +"化する場合は、事前初期化にもそのコマンドライン引数を渡さなければなりませ" +"ん。\n" +"エンコーディングなどの事前設定に影響するためです。\n" +"例えば、:option:`-X utf8 <-X>` コマンドラインオプションは :ref:`Python UTF-8 " +"モード ` を有効にします。" -#: ../../c-api/init_config.rst:1036 msgid "" "``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and " "before :c:func:`Py_InitializeFromConfig` to install a custom memory " "allocator. It can be called before :c:func:`Py_PreInitialize` if :c:member:" "`PyPreConfig.allocator` is set to ``PYMEM_ALLOCATOR_NOT_SET``." msgstr "" +"カスタムのメモリアロケーターを設定するには、:c:func:`Py_PreInitialize` の" +"後、:c:func:`Py_InitializeFromConfig` の前に ``PyMem_SetAllocator()`` を呼び" +"出せます。\n" +":c:member:`PyPreConfig.allocator` が ``PYMEM_ALLOCATOR_NOT_SET`` に設定されて" +"いる場合は、:c:func:`Py_PreInitialize` より前にも呼び出せます。" -#: ../../c-api/init_config.rst:1041 msgid "" "Python memory allocation functions like :c:func:`PyMem_RawMalloc` must not " "be used before the Python preinitialization, whereas calling directly " "``malloc()`` and ``free()`` is always safe. :c:func:`Py_DecodeLocale` must " "not be called before the Python preinitialization." msgstr "" +"Python の事前初期化より前に、:c:func:`PyMem_RawMalloc` などの Python のメモリ" +"確保関数を使ってはなりません。\n" +"一方、``malloc()`` と ``free()`` を直接呼び出すのは常に安全です。\n" +":c:func:`Py_DecodeLocale` も、Python の事前初期化より前に呼び出してはなりませ" +"ん。" -#: ../../c-api/init_config.rst:1046 msgid "" "Example using the preinitialization to enable the :ref:`Python UTF-8 Mode " "`::" msgstr "" +"事前初期化を使って :ref:`Python UTF-8 モード ` を有効にする例で" +"す。 ::" -#: ../../c-api/init_config.rst:1049 msgid "" "PyStatus status;\n" "PyPreConfig preconfig;\n" @@ -1722,85 +1600,94 @@ msgid "" "/* ... use Python API here ... */\n" "Py_Finalize();" msgstr "" +"PyStatus status;\n" +"PyPreConfig preconfig;\n" +"PyPreConfig_InitPythonConfig(&preconfig);\n" +"\n" +"preconfig.utf8_mode = 1;\n" +"\n" +"status = Py_PreInitialize(&preconfig);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}\n" +"\n" +"/* この時点で Python は UTF-8 を使う */\n" +"\n" +"Py_Initialize();\n" +"/* ... ここで Python API を使う ... */\n" +"Py_Finalize();" -#: ../../c-api/init_config.rst:1068 msgid "PyConfig" -msgstr "" +msgstr "PyConfig" -#: ../../c-api/init_config.rst:1072 msgid "Structure containing most parameters to configure Python." -msgstr "" +msgstr "Python の設定に使うパラメーターの大部分を含む構造体です。" -#: ../../c-api/init_config.rst:1074 msgid "" "When done, the :c:func:`PyConfig_Clear` function must be used to release the " "configuration memory." msgstr "" +"使い終わったら、:c:func:`PyConfig_Clear` で設定のメモリを解放しなければなりま" +"せん。" -#: ../../c-api/init_config.rst:1079 msgid "Structure methods:" -msgstr "" +msgstr "構造体のメソッド:" -#: ../../c-api/init_config.rst:1083 msgid "" "Initialize configuration with the :ref:`Python Configuration `." -msgstr "" +msgstr ":ref:`Python 設定 ` で設定を初期化します。" -#: ../../c-api/init_config.rst:1088 msgid "" "Initialize configuration with the :ref:`Isolated Configuration `." -msgstr "" +msgstr ":ref:`隔離設定 ` で設定を初期化します。" -#: ../../c-api/init_config.rst:1093 msgid "Copy the wide character string *str* into ``*config_str``." -msgstr "" +msgstr "ワイド文字列 *str* を ``*config_str`` にコピーします。" -#: ../../c-api/init_config.rst:1095 ../../c-api/init_config.rst:1102 -#: ../../c-api/init_config.rst:1109 ../../c-api/init_config.rst:1117 -#: ../../c-api/init_config.rst:1123 ../../c-api/init_config.rst:1140 msgid ":ref:`Preinitialize Python ` if needed." -msgstr "" +msgstr "必要なら :ref:`Python を事前初期化 ` します。" -#: ../../c-api/init_config.rst:1099 msgid "" "Decode *str* using :c:func:`Py_DecodeLocale` and set the result into " "``*config_str``." msgstr "" +"*str* を :c:func:`Py_DecodeLocale` でデコードし、結果を ``*config_str`` に設" +"定します。" -#: ../../c-api/init_config.rst:1106 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of wide character strings." msgstr "" +"ワイド文字列のリスト *argv* から、コマンドライン引数 (*config* の :c:member:" +"`~PyConfig.argv` メンバー) を設定します。" -#: ../../c-api/init_config.rst:1113 msgid "" "Set command line arguments (:c:member:`~PyConfig.argv` member of *config*) " "from the *argv* list of bytes strings. Decode bytes using :c:func:" "`Py_DecodeLocale`." msgstr "" +"バイト文字列のリスト *argv* から、コマンドライン引数 (*config* の :c:member:" +"`~PyConfig.argv` メンバー) を設定します。\n" +"バイト列は :c:func:`Py_DecodeLocale` でデコードします。" -#: ../../c-api/init_config.rst:1121 msgid "Set the list of wide strings *list* to *length* and *items*." -msgstr "" +msgstr "ワイド文字列のリスト *list* を、*length* と *items* から設定します。" -#: ../../c-api/init_config.rst:1127 msgid "Read all Python configuration." -msgstr "" +msgstr "Python の設定をすべて読み込みます。" -#: ../../c-api/init_config.rst:1129 msgid "Fields which are already initialized are left unchanged." -msgstr "" +msgstr "すでに初期化されているフィールドは変更しません。" -#: ../../c-api/init_config.rst:1131 msgid "" "Fields for :ref:`path configuration ` are no longer " "calculated or modified when calling this function, as of Python 3.11." msgstr "" +"Python 3.11 以降、この関数を呼び出しても :ref:`パス設定 ` " +"のフィールドは計算・変更されません。" -#: ../../c-api/init_config.rst:1134 ../../c-api/init_config.rst:1696 msgid "" "The :c:func:`PyConfig_Read` function only parses :c:member:`PyConfig.argv` " "arguments once: :c:member:`PyConfig.parse_argv` is set to ``2`` after " @@ -1808,26 +1695,35 @@ msgid "" "`PyConfig.argv`, parsing arguments twice would parse the application options " "as Python options." msgstr "" +":c:func:`PyConfig_Read` は :c:member:`PyConfig.argv` の引数を一度しか解析しま" +"せん。\n" +"解析後には :c:member:`PyConfig.parse_argv` を ``2`` に設定します。\n" +"Python 自体への引数は :c:member:`PyConfig.argv` から取り除かれるため、二度解" +"析するとアプリケーションのオプションを Python のオプションとして解析してしま" +"います。" -#: ../../c-api/init_config.rst:1142 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed once, :c:member:" "`PyConfig.parse_argv` is set to ``2`` after arguments are parsed, and " "arguments are only parsed if :c:member:`PyConfig.parse_argv` equals ``1``." msgstr "" +":c:member:`PyConfig.argv` の引数は一度だけ解析され、解析後は :c:member:" +"`PyConfig.parse_argv` が ``2`` に設定されるようになりました。\n" +"また、:c:member:`PyConfig.parse_argv` が ``1`` の場合にのみ引数を解析するよう" +"になりました。" -#: ../../c-api/init_config.rst:1148 msgid "" ":c:func:`PyConfig_Read` no longer calculates all paths, and so fields listed " "under :ref:`Python Path Configuration ` may no longer be " "updated until :c:func:`Py_InitializeFromConfig` is called." msgstr "" +":c:func:`PyConfig_Read` は、すべてのパスを計算しなくなりました。\n" +"そのため、:ref:`Python のパス設定 ` に挙げたフィールドは、:" +"c:func:`Py_InitializeFromConfig` を呼び出すまで更新されない場合があります。" -#: ../../c-api/init_config.rst:1156 msgid "Release configuration memory." -msgstr "" +msgstr "設定のメモリを解放します。" -#: ../../c-api/init_config.rst:1158 msgid "" "Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. " "In that case, the Python preinitialization configuration (:c:type:" @@ -1835,6 +1731,12 @@ msgid "" "which are in common with :c:type:`PyPreConfig` are tuned, they must be set " "before calling a :c:type:`PyConfig` method:" msgstr "" +"``PyConfig`` のメソッドの多くは、必要に応じて :ref:`Python を事前初期化 ` します。\n" +"この場合、Python の事前初期化設定 (:c:type:`PyPreConfig`) は :c:type:" +"`PyConfig` に基づいて作成されます。\n" +":c:type:`PyPreConfig` と共通の以下のフィールドを調整する場合は、:c:type:" +"`PyConfig` のメソッドを呼び出す前に設定しなければなりません。" #: ../../c-api/init_config.rst:1164 msgid ":c:member:`PyConfig.dev_mode`" @@ -1852,21 +1754,25 @@ msgstr ":c:member:`PyConfig.parse_argv`" msgid ":c:member:`PyConfig.use_environment`" msgstr ":c:member:`PyConfig.use_environment`" -#: ../../c-api/init_config.rst:1169 msgid "" "Moreover, if :c:func:`PyConfig_SetArgv` or :c:func:`PyConfig_SetBytesArgv` " "is used, this method must be called before other methods, since the " "preinitialization configuration depends on command line arguments (if :c:" "member:`~PyConfig.parse_argv` is non-zero)." msgstr "" +"さらに、:c:func:`PyConfig_SetArgv` または :c:func:`PyConfig_SetBytesArgv` を" +"使う場合は、ほかのメソッドより先に呼び出さなければなりません。\n" +":c:member:`~PyConfig.parse_argv` がゼロ以外の場合、事前初期化設定がコマンドラ" +"イン引数に依存するためです。" -#: ../../c-api/init_config.rst:1174 msgid "" "The caller of these methods is responsible to handle exceptions (error or " "exit) using ``PyStatus_Exception()`` and ``Py_ExitStatusException()``." msgstr "" +"これらのメソッドの呼び出し元は、``PyStatus_Exception()`` と " +"``Py_ExitStatusException()`` を使って、エラーまたは終了の状態を処理する責任が" +"あります。" -#: ../../c-api/init_config.rst:1187 msgid "" "Set :data:`sys.argv` command line arguments based on :c:member:`~PyConfig." "argv`. These parameters are similar to those passed to the program's :c:" @@ -1875,363 +1781,370 @@ msgid "" "Python interpreter. If there isn't a script that will be run, the first " "entry in :c:member:`~PyConfig.argv` can be an empty string." msgstr "" +":c:member:`~PyConfig.argv` に基づいて、:data:`sys.argv` のコマンドライン引数" +"を設定します。\n" +"これらはプログラムの :c:func:`main` 関数に渡す引数と似ていますが、最初の要素" +"は Python インタープリタを組み込む実行ファイルではなく、実行するスクリプト" +"ファイルを指す点が異なります。\n" +"実行するスクリプトがなければ、:c:member:`~PyConfig.argv` の最初の要素は空文字" +"列でも構いません。" -#: ../../c-api/init_config.rst:1195 msgid "" "Set :c:member:`~PyConfig.parse_argv` to ``1`` to parse :c:member:`~PyConfig." "argv` the same way the regular Python parses Python command line arguments " "and then to strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" +":c:member:`~PyConfig.parse_argv` を ``1`` に設定すると、通常の Python がコマ" +"ンドライン引数を解析するのと同じように :c:member:`~PyConfig.argv` を解析し、" +"Python 自体への引数を :c:member:`~PyConfig.argv` から取り除きます。" -#: ../../c-api/init_config.rst:1200 msgid "" "If :c:member:`~PyConfig.argv` is empty, an empty string is added to ensure " "that :data:`sys.argv` always exists and is never empty." msgstr "" +":c:member:`~PyConfig.argv` が空の場合は、:data:`sys.argv` が常に存在し、空に" +"ならないよう、空文字列を 1 つ追加します。" -#: ../../c-api/init_config.rst:1203 ../../c-api/init_config.rst:1230 -#: ../../c-api/init_config.rst:1244 ../../c-api/init_config.rst:1254 -#: ../../c-api/init_config.rst:1370 ../../c-api/init_config.rst:1379 -#: ../../c-api/init_config.rst:1390 ../../c-api/init_config.rst:1481 -#: ../../c-api/init_config.rst:1637 ../../c-api/init_config.rst:1738 -#: ../../c-api/init_config.rst:1757 ../../c-api/init_config.rst:1772 -#: ../../c-api/init_config.rst:1789 ../../c-api/init_config.rst:1802 -#: ../../c-api/init_config.rst:1810 ../../c-api/init_config.rst:1824 -#: ../../c-api/init_config.rst:1927 msgid "Default: ``NULL``." -msgstr "" +msgstr "デフォルト: ``NULL``。" -#: ../../c-api/init_config.rst:1205 msgid "See also the :c:member:`~PyConfig.orig_argv` member." -msgstr "" +msgstr ":c:member:`~PyConfig.orig_argv` メンバーも参照してください。" -#: ../../c-api/init_config.rst:1209 msgid "" "If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to :" "data:`sys.path` at startup:" msgstr "" +"ゼロの場合、``Py_RunMain()`` は起動時に、安全でない可能性があるパスを :data:" +"`sys.path` の先頭に追加します。" -#: ../../c-api/init_config.rst:1212 msgid "" "If :c:member:`argv[0] ` is equal to ``L\"-m\"`` (``python -m " "module``), prepend the current working directory." msgstr "" +":c:member:`argv[0] ` が ``L\"-m\"`` の場合 (``python -m " +"module``)、現在の作業ディレクトリを先頭に追加します。" -#: ../../c-api/init_config.rst:1214 msgid "" "If running a script (``python script.py``), prepend the script's directory. " "If it's a symbolic link, resolve symbolic links." msgstr "" +"スクリプトを実行する場合 (``python script.py``)、スクリプトのディレクトリを先" +"頭に追加します。\n" +"シンボリックリンクの場合は、リンクを解決します。" -#: ../../c-api/init_config.rst:1216 msgid "" "Otherwise (``python -c code`` and ``python``), prepend an empty string, " "which means the current working directory." msgstr "" +"それ以外の場合 (``python -c code`` と ``python``)、現在の作業ディレクトリを意" +"味する空文字列を先頭に追加します。" -#: ../../c-api/init_config.rst:1219 msgid "" "Set to ``1`` by the :option:`-P` command line option and the :envvar:" "`PYTHONSAFEPATH` environment variable." msgstr "" +":option:`-P` コマンドラインオプションと :envvar:`PYTHONSAFEPATH` 環境変数に" +"よって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1222 msgid "Default: ``0`` in Python config, ``1`` in isolated config." -msgstr "" +msgstr "デフォルト: Python 設定では ``0``、隔離設定では ``1``。" #: ../../c-api/init_config.rst:1228 msgid ":data:`sys.base_exec_prefix`." msgstr ":data:`sys.base_exec_prefix`." -#: ../../c-api/init_config.rst:1232 ../../c-api/init_config.rst:1246 -#: ../../c-api/init_config.rst:1256 ../../c-api/init_config.rst:1381 -#: ../../c-api/init_config.rst:1392 ../../c-api/init_config.rst:1654 -#: ../../c-api/init_config.rst:1740 msgid "Part of the :ref:`Python Path Configuration ` output." -msgstr "" +msgstr ":ref:`Python のパス設定 ` の出力の一部です。" -#: ../../c-api/init_config.rst:1234 msgid "See also :c:member:`PyConfig.exec_prefix`." -msgstr "" +msgstr ":c:member:`PyConfig.exec_prefix` も参照してください。" -#: ../../c-api/init_config.rst:1238 msgid "Python base executable: ``sys._base_executable``." -msgstr "" +msgstr "Python の基となる実行ファイル: ``sys._base_executable``。" -#: ../../c-api/init_config.rst:1240 msgid "Set by the ``__PYVENV_LAUNCHER__`` environment variable." -msgstr "" +msgstr "``__PYVENV_LAUNCHER__`` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1242 msgid "Set from :c:member:`PyConfig.executable` if ``NULL``." -msgstr "" +msgstr "``NULL`` の場合は :c:member:`PyConfig.executable` から設定されます。" -#: ../../c-api/init_config.rst:1248 msgid "See also :c:member:`PyConfig.executable`." -msgstr "" +msgstr ":c:member:`PyConfig.executable` も参照してください。" #: ../../c-api/init_config.rst:1252 msgid ":data:`sys.base_prefix`." msgstr ":data:`sys.base_prefix`." -#: ../../c-api/init_config.rst:1258 msgid "See also :c:member:`PyConfig.prefix`." -msgstr "" +msgstr ":c:member:`PyConfig.prefix` も参照してください。" -#: ../../c-api/init_config.rst:1262 msgid "" "If equals to ``0`` and :c:member:`~PyConfig.configure_c_stdio` is non-zero, " "disable buffering on the C streams stdout and stderr." msgstr "" +"``0`` で、:c:member:`~PyConfig.configure_c_stdio` がゼロ以外の場合、C のスト" +"リーム ``stdout`` と ``stderr`` のバッファリングを無効にします。" -#: ../../c-api/init_config.rst:1265 msgid "" "Set to ``0`` by the :option:`-u` command line option and the :envvar:" "`PYTHONUNBUFFERED` environment variable." msgstr "" +":option:`-u` コマンドラインオプションと :envvar:`PYTHONUNBUFFERED` 環境変数に" +"よって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:1268 msgid "stdin is always opened in buffered mode." -msgstr "" +msgstr "``stdin`` は常にバッファリングモードで開かれます。" -#: ../../c-api/init_config.rst:1274 msgid "" "If equals to ``1``, issue a warning when comparing :class:`bytes` or :class:" "`bytearray` with :class:`str`, or comparing :class:`bytes` with :class:`int`." msgstr "" +"``1`` の場合、:class:`bytes` または :class:`bytearray` と :class:`str` の比" +"較、および :class:`bytes` と :class:`int` の比較で警告を出します。" -#: ../../c-api/init_config.rst:1278 msgid "" "If equal or greater to ``2``, raise a :exc:`BytesWarning` exception in these " "cases." msgstr "" +"``2`` 以上の場合、これらの場合に :exc:`BytesWarning` 例外を送出します。" -#: ../../c-api/init_config.rst:1281 msgid "Incremented by the :option:`-b` command line option." -msgstr "" +msgstr ":option:`-b` コマンドラインオプションで値が増加します。" -#: ../../c-api/init_config.rst:1287 msgid "" "The :option:`-b` and :option:`!-bb` options will become no-op in 3.17. :c:" "member:`~PyConfig.bytes_warning` member will be removed in 3.17." msgstr "" +":option:`-b` と :option:`!-bb` オプションは、3.17 で何も行わなくなります。\n" +":c:member:`~PyConfig.bytes_warning` メンバーは、3.17 で削除されます。" -#: ../../c-api/init_config.rst:1292 msgid "" "If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io." "TextIOWrapper` uses its default encoding. See :ref:`io-encoding-warning` for " "details." msgstr "" +"ゼロ以外の場合、:class:`io.TextIOWrapper` がデフォルトのエンコーディングを使" +"うときに :exc:`EncodingWarning` を出します。\n" +"詳しくは :ref:`io-encoding-warning` を参照してください。" -#: ../../c-api/init_config.rst:1301 msgid "" "If equals to ``0``, disables the inclusion of the end line and column " "mappings in code objects. Also disables traceback printing carets to " "specific error locations." msgstr "" +"``0`` の場合、コードオブジェクトに終了行と列の対応情報を含めません。\n" +"トレースバックで、エラーの詳しい位置をキャレットで示す表示も無効にします。" -#: ../../c-api/init_config.rst:1305 msgid "" "Set to ``0`` by the :envvar:`PYTHONNODEBUGRANGES` environment variable and " "by the :option:`-X no_debug_ranges <-X>` command line option." msgstr "" +":envvar:`PYTHONNODEBUGRANGES` 環境変数と :option:`-X no_debug_ranges <-X>` コ" +"マンドラインオプションによって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:1314 msgid "" "Control the validation behavior of hash-based ``.pyc`` files: value of the :" "option:`--check-hash-based-pycs` command line option." msgstr "" +"ハッシュベースの ``.pyc`` ファイルの検証方法を制御します。\n" +":option:`--check-hash-based-pycs` コマンドラインオプションの値です。" -#: ../../c-api/init_config.rst:1317 msgid "Valid values:" -msgstr "" +msgstr "有効な値:" -#: ../../c-api/init_config.rst:1319 msgid "" "``L\"always\"``: Hash the source file for invalidation regardless of value " "of the 'check_source' flag." msgstr "" +"``L\"always\"``: ``check_source`` フラグの値にかかわらず、ソースファイルの" +"ハッシュを計算してキャッシュの有効性を確認します。" -#: ../../c-api/init_config.rst:1321 msgid "``L\"never\"``: Assume that hash-based pycs always are valid." -msgstr "" +msgstr "``L\"never\"``: ハッシュベースの pyc は常に有効と見なします。" -#: ../../c-api/init_config.rst:1322 msgid "" "``L\"default\"``: The 'check_source' flag in hash-based pycs determines " "invalidation." msgstr "" +"``L\"default\"``: ハッシュベースの pyc の ``check_source`` フラグに従って、" +"キャッシュの有効性を確認します。" -#: ../../c-api/init_config.rst:1325 msgid "Default: ``L\"default\"``." -msgstr "" +msgstr "デフォルト: ``L\"default\"``。" -#: ../../c-api/init_config.rst:1327 msgid "See also :pep:`552` \"Deterministic pycs\"." -msgstr "" +msgstr ":pep:`552` 「Deterministic pycs」も参照してください。" -#: ../../c-api/init_config.rst:1331 msgid "If non-zero, configure C standard streams:" -msgstr "" +msgstr "ゼロ以外の場合、C の標準ストリームを設定します。" -#: ../../c-api/init_config.rst:1333 msgid "" "On Windows, set the binary mode (``O_BINARY``) on stdin, stdout and stderr." msgstr "" +"Windows では、``stdin``、``stdout``、``stderr`` をバイナリモード " +"(``O_BINARY``) に設定します。" -#: ../../c-api/init_config.rst:1335 msgid "" "If :c:member:`~PyConfig.buffered_stdio` equals zero, disable buffering of " "stdin, stdout and stderr streams." msgstr "" +":c:member:`~PyConfig.buffered_stdio` がゼロの場合、``stdin``、``stdout``、" +"``stderr`` のバッファリングを無効にします。" -#: ../../c-api/init_config.rst:1337 msgid "" "If :c:member:`~PyConfig.interactive` is non-zero, enable stream buffering on " "stdin and stdout (only stdout on Windows)." msgstr "" +":c:member:`~PyConfig.interactive` がゼロ以外の場合、``stdin`` と ``stdout`` " +"(Windows では ``stdout`` のみ) のバッファリングを有効にします。" -#: ../../c-api/init_config.rst:1344 msgid "If non-zero, enable the :ref:`Python Development Mode `." -msgstr "" +msgstr "ゼロ以外の場合、:ref:`Python 開発モード ` を有効にします。" -#: ../../c-api/init_config.rst:1346 msgid "" "Set to ``1`` by the :option:`-X dev <-X>` option and the :envvar:" "`PYTHONDEVMODE` environment variable." msgstr "" +":option:`-X dev <-X>` オプションと :envvar:`PYTHONDEVMODE` 環境変数によって " +"``1`` に設定されます。" -#: ../../c-api/init_config.rst:1353 msgid "Dump Python references?" -msgstr "" +msgstr "Python の参照をダンプするかどうか。" -#: ../../c-api/init_config.rst:1355 msgid "If non-zero, dump all objects which are still alive at exit." msgstr "" +"ゼロ以外の場合、終了時にまだ生存しているすべてのオブジェクトをダンプします。" -#: ../../c-api/init_config.rst:1357 msgid "Set to ``1`` by the :envvar:`PYTHONDUMPREFS` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONDUMPREFS` 環境変数によって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1359 msgid "" "Needs a special build of Python with the ``Py_TRACE_REFS`` macro defined: " "see the :option:`configure --with-trace-refs option <--with-trace-refs>`." msgstr "" +"``Py_TRACE_REFS`` マクロを定義した特別な Python ビルドが必要です。\n" +":option:`configure の --with-trace-refs オプション <--with-trace-refs>` を参" +"照してください。" -#: ../../c-api/init_config.rst:1366 msgid "Filename where to dump Python references." -msgstr "" +msgstr "Python の参照をダンプする先のファイル名。" -#: ../../c-api/init_config.rst:1368 msgid "Set by the :envvar:`PYTHONDUMPREFSFILE` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONDUMPREFSFILE` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1376 msgid "" "The site-specific directory prefix where the platform-dependent Python files " "are installed: :data:`sys.exec_prefix`." msgstr "" +"プラットフォームに依存する Python のファイルをインストールする、サイト固有の" +"ディレクトリのプレフィックス。\n" +":data:`sys.exec_prefix` に対応します。" -#: ../../c-api/init_config.rst:1383 msgid "See also :c:member:`PyConfig.base_exec_prefix`." -msgstr "" +msgstr ":c:member:`PyConfig.base_exec_prefix` も参照してください。" -#: ../../c-api/init_config.rst:1387 msgid "" "The absolute path of the executable binary for the Python interpreter: :data:" "`sys.executable`." msgstr "" +"Python インタープリタの実行ファイルの絶対パス。\n" +":data:`sys.executable` に対応します。" -#: ../../c-api/init_config.rst:1394 msgid "See also :c:member:`PyConfig.base_executable`." -msgstr "" +msgstr ":c:member:`PyConfig.base_executable` も参照してください。" -#: ../../c-api/init_config.rst:1398 msgid "Enable faulthandler?" -msgstr "" +msgstr "faulthandler を有効にするかどうか。" -#: ../../c-api/init_config.rst:1400 msgid "If non-zero, call :func:`faulthandler.enable` at startup." -msgstr "" +msgstr "ゼロ以外の場合、起動時に :func:`faulthandler.enable` を呼び出します。" -#: ../../c-api/init_config.rst:1402 msgid "" "Set to ``1`` by :option:`-X faulthandler <-X>` and the :envvar:" "`PYTHONFAULTHANDLER` environment variable." msgstr "" +":option:`-X faulthandler <-X>` と :envvar:`PYTHONFAULTHANDLER` 環境変数によっ" +"て ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1409 msgid "" ":term:`Filesystem encoding `: :func:" "`sys.getfilesystemencoding`." msgstr "" +":term:`ファイルシステムエンコーディング `。\n" +":func:`sys.getfilesystemencoding` に対応します。" -#: ../../c-api/init_config.rst:1412 msgid "On macOS, Android and VxWorks: use ``\"utf-8\"`` by default." -msgstr "" +msgstr "macOS、Android、VxWorks: デフォルトで ``\"utf-8\"`` を使います。" -#: ../../c-api/init_config.rst:1414 msgid "" "On Windows: use ``\"utf-8\"`` by default, or ``\"mbcs\"`` if :c:member:" "`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is non-" "zero." msgstr "" +"Windows: デフォルトで ``\"utf-8\"`` を使います。\n" +":c:type:`PyPreConfig` の :c:member:`~PyPreConfig.legacy_windows_fs_encoding` " +"がゼロ以外の場合は、``\"mbcs\"`` を使います。" -#: ../../c-api/init_config.rst:1418 msgid "Default encoding on other platforms:" -msgstr "" +msgstr "ほかのプラットフォームでのデフォルトのエンコーディング:" -#: ../../c-api/init_config.rst:1420 msgid "``\"utf-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." -msgstr "" +msgstr ":c:member:`PyPreConfig.utf8_mode` がゼロ以外の場合は ``\"utf-8\"``。" -#: ../../c-api/init_config.rst:1421 msgid "" "``\"ascii\"`` if Python detects that ``nl_langinfo(CODESET)`` announces the " "ASCII encoding, whereas the ``mbstowcs()`` function decodes from a different " "encoding (usually Latin1)." msgstr "" +"``nl_langinfo(CODESET)`` が ASCII エンコーディングを返すのに、``mbstowcs()`` " +"が別のエンコーディング (通常は Latin1) からデコードすると Python が検出した場" +"合は ``\"ascii\"``。" -#: ../../c-api/init_config.rst:1424 msgid "``\"utf-8\"`` if ``nl_langinfo(CODESET)`` returns an empty string." -msgstr "" +msgstr "``nl_langinfo(CODESET)`` が空文字列を返す場合は ``\"utf-8\"``。" -#: ../../c-api/init_config.rst:1425 msgid "" "Otherwise, use the :term:`locale encoding`: ``nl_langinfo(CODESET)`` result." msgstr "" +"それ以外の場合は、``nl_langinfo(CODESET)`` の結果である :term:`ロケールエン" +"コーディング ` を使います。" -#: ../../c-api/init_config.rst:1428 msgid "" "At Python startup, the encoding name is normalized to the Python codec name. " "For example, ``\"ANSI_X3.4-1968\"`` is replaced with ``\"ascii\"``." msgstr "" +"Python の起動時に、エンコーディング名は Python のコーデック名に正規化されま" +"す。\n" +"例えば、``\"ANSI_X3.4-1968\"`` は ``\"ascii\"`` に置き換えられます。" -#: ../../c-api/init_config.rst:1431 msgid "See also the :c:member:`~PyConfig.filesystem_errors` member." -msgstr "" +msgstr ":c:member:`~PyConfig.filesystem_errors` メンバーも参照してください。" -#: ../../c-api/init_config.rst:1435 msgid "" ":term:`Filesystem error handler `: :" "func:`sys.getfilesystemencodeerrors`." msgstr "" +":term:`ファイルシステムのエラーハンドラー `。\n" +":func:`sys.getfilesystemencodeerrors` に対応します。" -#: ../../c-api/init_config.rst:1438 msgid "" "On Windows: use ``\"surrogatepass\"`` by default, or ``\"replace\"`` if :c:" "member:`~PyPreConfig.legacy_windows_fs_encoding` of :c:type:`PyPreConfig` is " "non-zero." msgstr "" +"Windows: デフォルトで ``\"surrogatepass\"`` を使います。\n" +":c:type:`PyPreConfig` の :c:member:`~PyPreConfig.legacy_windows_fs_encoding` " +"がゼロ以外の場合は、``\"replace\"`` を使います。" -#: ../../c-api/init_config.rst:1442 msgid "On other platforms: use ``\"surrogateescape\"`` by default." msgstr "" +"ほかのプラットフォーム: デフォルトで ``\"surrogateescape\"`` を使います。" -#: ../../c-api/init_config.rst:1444 msgid "Supported error handlers:" -msgstr "" +msgstr "サポートするエラーハンドラー:" #: ../../c-api/init_config.rst:1446 msgid "``\"strict\"``" @@ -2241,115 +2154,108 @@ msgstr "``\"strict\"``" msgid "``\"surrogateescape\"``" msgstr "``\"surrogateescape\"``" -#: ../../c-api/init_config.rst:1448 msgid "``\"surrogatepass\"`` (only supported with the UTF-8 encoding)" -msgstr "" +msgstr "``\"surrogatepass\"`` (UTF-8 エンコーディングでのみサポート)" -#: ../../c-api/init_config.rst:1450 msgid "See also the :c:member:`~PyConfig.filesystem_encoding` member." -msgstr "" +msgstr ":c:member:`~PyConfig.filesystem_encoding` メンバーも参照してください。" -#: ../../c-api/init_config.rst:1454 msgid "If non-zero, use frozen modules." -msgstr "" +msgstr "ゼロ以外の場合、凍結モジュールを使います。" -#: ../../c-api/init_config.rst:1456 msgid "Set by the :envvar:`PYTHON_FROZEN_MODULES` environment variable." -msgstr "" +msgstr ":envvar:`PYTHON_FROZEN_MODULES` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1458 msgid "" "Default: ``1`` in a release build, or ``0`` in a :ref:`debug build `." msgstr "" +"デフォルト: リリースビルドでは ``1``、:ref:`デバッグビルド ` で" +"は ``0``。" -#: ../../c-api/init_config.rst:1464 msgid "Randomized hash function seed." -msgstr "" +msgstr "ハッシュ関数のランダム化に使うシード。" -#: ../../c-api/init_config.rst:1466 msgid "" "If :c:member:`~PyConfig.use_hash_seed` is zero, a seed is chosen randomly at " "Python startup, and :c:member:`~PyConfig.hash_seed` is ignored." msgstr "" +":c:member:`~PyConfig.use_hash_seed` がゼロの場合、Python の起動時にシードをラ" +"ンダムに選び、:c:member:`~PyConfig.hash_seed` は無視します。" -#: ../../c-api/init_config.rst:1469 msgid "Set by the :envvar:`PYTHONHASHSEED` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONHASHSEED` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1471 msgid "" "Default *use_hash_seed* value: ``-1`` in Python mode, ``0`` in isolated mode." msgstr "" +"*use_hash_seed* のデフォルト値: Python モードでは ``-1``、隔離モードでは " +"``0``。" -#: ../../c-api/init_config.rst:1476 msgid "" "Set the default Python \"home\" directory, that is, the location of the " "standard Python libraries (see :envvar:`PYTHONHOME`)." msgstr "" +"Python の標準ライブラリの場所である、デフォルトの Python「home」ディレクトリ" +"を設定します (:envvar:`PYTHONHOME` を参照)。" -#: ../../c-api/init_config.rst:1479 msgid "Set by the :envvar:`PYTHONHOME` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONHOME` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1483 ../../c-api/init_config.rst:1619 -#: ../../c-api/init_config.rst:1639 ../../c-api/init_config.rst:1728 -#: ../../c-api/init_config.rst:1759 msgid "Part of the :ref:`Python Path Configuration ` input." -msgstr "" +msgstr ":ref:`Python のパス設定 ` の入力の一部です。" -#: ../../c-api/init_config.rst:1487 msgid "" "If ``1``, profile import time. If ``2``, include additional output that " "indicates when an imported module has already been loaded." msgstr "" +"``1`` の場合、インポート時間を計測します。\n" +"``2`` の場合、インポートするモジュールがすでにロードされていることを示す出力" +"も含めます。" -#: ../../c-api/init_config.rst:1491 msgid "" "Set by the :option:`-X importtime <-X>` option and the :envvar:" "`PYTHONPROFILEIMPORTTIME` environment variable." msgstr "" +":option:`-X importtime <-X>` オプションと :envvar:`PYTHONPROFILEIMPORTTIME` " +"環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1498 msgid "Added support for ``import_time = 2``" -msgstr "" +msgstr "``import_time = 2`` をサポートするようになりました。" -#: ../../c-api/init_config.rst:1502 msgid "Enter interactive mode after executing a script or a command." -msgstr "" +msgstr "スクリプトまたはコマンドの実行後に、対話モードに入ります。" -#: ../../c-api/init_config.rst:1504 msgid "" "If greater than ``0``, enable inspect: when a script is passed as first " "argument or the -c option is used, enter interactive mode after executing " "the script or the command, even when :data:`sys.stdin` does not appear to be " "a terminal." msgstr "" +"``0`` より大きい場合、実行後の対話モードを有効にします。\n" +"最初の引数にスクリプトを指定した場合や ``-c`` オプションを使った場合、:data:" +"`sys.stdin` が端末でなくても、スクリプトやコマンドの実行後に対話モードに入り" +"ます。" -#: ../../c-api/init_config.rst:1509 msgid "" "Incremented by the :option:`-i` command line option. Set to ``1`` if the :" "envvar:`PYTHONINSPECT` environment variable is non-empty." msgstr "" +":option:`-i` コマンドラインオプションで値が増加します。\n" +":envvar:`PYTHONINSPECT` 環境変数が空でなければ ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1516 msgid "Install Python signal handlers?" -msgstr "" +msgstr "Python のシグナルハンドラーを登録するかどうか。" -#: ../../c-api/init_config.rst:1518 ../../c-api/init_config.rst:1702 -#: ../../c-api/init_config.rst:1726 ../../c-api/init_config.rst:1962 msgid "Default: ``1`` in Python mode, ``0`` in isolated mode." -msgstr "" +msgstr "デフォルト: Python モードでは ``1``、隔離モードでは ``0``。" -#: ../../c-api/init_config.rst:1522 msgid "If greater than ``0``, enable the interactive mode (REPL)." -msgstr "" +msgstr "``0`` より大きい場合、対話モード (REPL) を有効にします。" -#: ../../c-api/init_config.rst:1524 msgid "Incremented by the :option:`-i` command line option." -msgstr "" +msgstr ":option:`-i` コマンドラインオプションで値が増加します。" -#: ../../c-api/init_config.rst:1530 msgid "" "Configures the :ref:`integer string conversion length limitation " "`. An initial value of ``-1`` means the value will be " @@ -2358,81 +2264,98 @@ msgid "" "limitation. Values greater than zero but less than 640 (:data:`sys.int_info." "str_digits_check_threshold`) are unsupported and will produce an error." msgstr "" +":ref:`整数と文字列の変換の長さ制限 ` を設定します。\n" +"初期値が ``-1`` の場合、コマンドラインや環境変数の値を使い、それらの指定がな" +"ければデフォルトの 4300 (:data:`sys.int_info.default_max_str_digits`) を使い" +"ます。\n" +"``0`` は制限を無効にします。\n" +"ゼロより大きく 640 (:data:`sys.int_info.str_digits_check_threshold`) 未満の値" +"はサポートされず、エラーになります。" -#: ../../c-api/init_config.rst:1538 msgid "" "Configured by the :option:`-X int_max_str_digits <-X>` command line flag or " "the :envvar:`PYTHONINTMAXSTRDIGITS` environment variable." msgstr "" +":option:`-X int_max_str_digits <-X>` コマンドラインフラグまたは :envvar:" +"`PYTHONINTMAXSTRDIGITS` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1541 msgid "" "Default: ``-1`` in Python mode. 4300 (:data:`sys.int_info." "default_max_str_digits`) in isolated mode." msgstr "" +"デフォルト: Python モードでは ``-1``。\n" +"隔離モードでは 4300 (:data:`sys.int_info.default_max_str_digits`)。" -#: ../../c-api/init_config.rst:1548 msgid "" "If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will " "override the return values of :func:`os.cpu_count`, :func:`os." "process_cpu_count`, and :func:`multiprocessing.cpu_count`." msgstr "" +":c:member:`~PyConfig.cpu_count` が ``-1`` でなければ、:func:`os.cpu_count`、:" +"func:`os.process_cpu_count`、:func:`multiprocessing.cpu_count` の戻り値を上書" +"きします。" -#: ../../c-api/init_config.rst:1552 msgid "" "Configured by the :samp:`-X cpu_count={n|default}` command line flag or the :" "envvar:`PYTHON_CPU_COUNT` environment variable." msgstr "" +":samp:`-X cpu_count={n|default}` コマンドラインフラグまたは :envvar:" +"`PYTHON_CPU_COUNT` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1555 ../../c-api/init_config.rst:1916 msgid "Default: ``-1``." -msgstr "" +msgstr "デフォルト: ``-1``。" -#: ../../c-api/init_config.rst:1561 msgid "If greater than ``0``, enable isolated mode:" -msgstr "" +msgstr "``0`` より大きい場合、隔離モードを有効にします。" -#: ../../c-api/init_config.rst:1563 msgid "" "Set :c:member:`~PyConfig.safe_path` to ``1``: don't prepend a potentially " "unsafe path to :data:`sys.path` at Python startup, such as the current " "directory, the script's directory or an empty string." msgstr "" +":c:member:`~PyConfig.safe_path` を ``1`` に設定します。\n" +"これにより、Python の起動時に、現在のディレクトリ、スクリプトのディレクトリ、" +"空文字列など、安全でない可能性のあるパスを :data:`sys.path` の先頭に追加しま" +"せん。" -#: ../../c-api/init_config.rst:1567 msgid "" "Set :c:member:`~PyConfig.use_environment` to ``0``: ignore ``PYTHON`` " "environment variables." msgstr "" +":c:member:`~PyConfig.use_environment` を ``0`` に設定し、``PYTHON`` 環境変数" +"を無視します。" -#: ../../c-api/init_config.rst:1569 msgid "" "Set :c:member:`~PyConfig.user_site_directory` to ``0``: don't add the user " "site directory to :data:`sys.path`." msgstr "" +":c:member:`~PyConfig.user_site_directory` を ``0`` に設定し、ユーザーのサイト" +"ディレクトリを :data:`sys.path` に追加しません。" -#: ../../c-api/init_config.rst:1571 msgid "" "Python REPL doesn't import :mod:`readline` nor enable default readline " "configuration on interactive prompts." msgstr "" +"Python の REPL は :mod:`readline` をインポートせず、対話プロンプトのデフォル" +"トの readline 設定も有効にしません。" -#: ../../c-api/init_config.rst:1574 msgid "Set to ``1`` by the :option:`-I` command line option." -msgstr "" +msgstr ":option:`-I` コマンドラインオプションによって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1578 msgid "" "See also the :ref:`Isolated Configuration ` and :c:" "member:`PyPreConfig.isolated`." msgstr "" +":ref:`隔離設定 ` と :c:member:`PyPreConfig.isolated` も参" +"照してください。" -#: ../../c-api/init_config.rst:1583 msgid "" "If non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys." "stderr`." msgstr "" +"ゼロ以外の場合、:data:`sys.stdin`、:data:`sys.stdout`、:data:`sys.stderr` " +"に :class:`!io._WindowsConsoleIO` の代わりに :class:`io.FileIO` を使います。" #: ../../c-api/init_config.rst:1587 msgid "" @@ -2442,106 +2365,116 @@ msgstr "" ":envvar:`PYTHONLEGACYWINDOWSSTDIO` 環境変数が空でない文字列に設定された場合" "に、 ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1595 msgid "See also the :pep:`528` (Change Windows console encoding to UTF-8)." msgstr "" +":pep:`528` (Change Windows console encoding to UTF-8) も参照してください。" -#: ../../c-api/init_config.rst:1599 msgid "" "If non-zero, dump statistics on :ref:`Python pymalloc memory allocator " "` at exit." msgstr "" +"ゼロ以外の場合、終了時に :ref:`Python の pymalloc メモリアロケーター " +"` の統計をダンプします。" -#: ../../c-api/init_config.rst:1602 msgid "Set to ``1`` by the :envvar:`PYTHONMALLOCSTATS` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONMALLOCSTATS` 環境変数によって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1604 msgid "" "The option is ignored if Python is :option:`configured using the --without-" "pymalloc option <--without-pymalloc>`." msgstr "" +"Python を :option:`--without-pymalloc オプションで構成した <--without-" +"pymalloc>` 場合、このオプションは無視されます。" -#: ../../c-api/init_config.rst:1611 msgid "Platform library directory name: :data:`sys.platlibdir`." msgstr "" +"プラットフォーム固有のライブラリディレクトリの名前。\n" +":data:`sys.platlibdir` に対応します。" -#: ../../c-api/init_config.rst:1613 msgid "Set by the :envvar:`PYTHONPLATLIBDIR` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONPLATLIBDIR` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1615 msgid "" "Default: value of the ``PLATLIBDIR`` macro which is set by the :option:" "`configure --with-platlibdir option <--with-platlibdir>` (default: " "``\"lib\"``, or ``\"DLLs\"`` on Windows)." msgstr "" +"デフォルト: :option:`configure の --with-platlibdir オプション <--with-" +"platlibdir>` で設定される ``PLATLIBDIR`` マクロの値 (デフォルトは " +"``\"lib\"``、Windows では ``\"DLLs\"``)。" -#: ../../c-api/init_config.rst:1623 msgid "" "This macro is now used on Windows to locate the standard library extension " "modules, typically under ``DLLs``. However, for compatibility, note that " "this value is ignored for any non-standard layouts, including in-tree builds " "and virtual environments." msgstr "" +"このマクロは、Windows で標準ライブラリの拡張モジュールを探すために使われるよ" +"うになりました。\n" +"通常、拡張モジュールは ``DLLs`` にあります。\n" +"ただし、互換性のため、ソースツリー内のビルドや仮想環境など、標準以外のディレ" +"クトリ配置ではこの値を無視します。" -#: ../../c-api/init_config.rst:1632 msgid "" "Module search paths (:data:`sys.path`) as a string separated by ``DELIM`` (:" "data:`os.pathsep`)." msgstr "" +"モジュール検索パス (:data:`sys.path`) を、``DELIM`` (:data:`os.pathsep`) で区" +"切った文字列。" -#: ../../c-api/init_config.rst:1635 msgid "Set by the :envvar:`PYTHONPATH` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONPATH` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1644 msgid "Module search paths: :data:`sys.path`." msgstr "" +"モジュール検索パス。\n" +":data:`sys.path` に対応します。" -#: ../../c-api/init_config.rst:1646 msgid "" "If :c:member:`~PyConfig.module_search_paths_set` is equal to ``0``, :c:func:" "`Py_InitializeFromConfig` will replace :c:member:`~PyConfig." "module_search_paths` and sets :c:member:`~PyConfig.module_search_paths_set` " "to ``1``." msgstr "" +":c:member:`~PyConfig.module_search_paths_set` が ``0`` の場合、:c:func:" +"`Py_InitializeFromConfig` は :c:member:`~PyConfig.module_search_paths` を置き" +"換え、:c:member:`~PyConfig.module_search_paths_set` を ``1`` に設定します。" -#: ../../c-api/init_config.rst:1651 msgid "" "Default: empty list (``module_search_paths``) and ``0`` " "(``module_search_paths_set``)." msgstr "" +"デフォルト: ``module_search_paths`` は空のリスト、" +"``module_search_paths_set`` は ``0``。" -#: ../../c-api/init_config.rst:1658 msgid "Compilation optimization level:" -msgstr "" +msgstr "コンパイルの最適化レベル:" -#: ../../c-api/init_config.rst:1660 msgid "``0``: Peephole optimizer, set ``__debug__`` to ``True``." -msgstr "" +msgstr "``0``: のぞき穴最適化を行い、``__debug__`` を ``True`` に設定します。" -#: ../../c-api/init_config.rst:1661 msgid "``1``: Level 0, remove assertions, set ``__debug__`` to ``False``." msgstr "" +"``1``: レベル 0 に加えて、アサーションを削除し、``__debug__`` を ``False`` に" +"設定します。" -#: ../../c-api/init_config.rst:1662 msgid "``2``: Level 1, strip docstrings." -msgstr "" +msgstr "``2``: レベル 1 に加えて、docstring を削除します。" -#: ../../c-api/init_config.rst:1664 msgid "" "Incremented by the :option:`-O` command line option. Set to the :envvar:" "`PYTHONOPTIMIZE` environment variable value." msgstr "" +":option:`-O` コマンドラインオプションで値が増加します。\n" +":envvar:`PYTHONOPTIMIZE` 環境変数の値から設定されます。" -#: ../../c-api/init_config.rst:1671 msgid "" "The list of the original command line arguments passed to the Python " "executable: :data:`sys.orig_argv`." msgstr "" +"Python 実行ファイルに渡された、元のコマンドライン引数のリスト。\n" +":data:`sys.orig_argv` に対応します。" -#: ../../c-api/init_config.rst:1674 msgid "" "If :c:member:`~PyConfig.orig_argv` list is empty and :c:member:`~PyConfig." "argv` is not a list only containing an empty string, :c:func:`PyConfig_Read` " @@ -2549,469 +2482,508 @@ msgid "" "before modifying :c:member:`~PyConfig.argv` (if :c:member:`~PyConfig." "parse_argv` is non-zero)." msgstr "" +":c:member:`~PyConfig.orig_argv` のリストが空で、:c:member:`~PyConfig.argv` が" +"空文字列だけを含むリストでない場合、:c:func:`PyConfig_Read` は :c:member:" +"`~PyConfig.argv` を :c:member:`~PyConfig.orig_argv` にコピーします。\n" +"これは、:c:member:`~PyConfig.parse_argv` がゼロ以外の場合に :c:member:" +"`~PyConfig.argv` を変更する前に行われます。" -#: ../../c-api/init_config.rst:1681 msgid "" "See also the :c:member:`~PyConfig.argv` member and the :c:func:" "`Py_GetArgcArgv` function." msgstr "" +":c:member:`~PyConfig.argv` メンバーと :c:func:`Py_GetArgcArgv` 関数も参照して" +"ください。" -#: ../../c-api/init_config.rst:1684 ../../c-api/init_config.rst:1996 -#: ../../c-api/init_config.rst:2015 msgid "Default: empty list." -msgstr "" +msgstr "デフォルト: 空のリスト。" -#: ../../c-api/init_config.rst:1690 msgid "Parse command line arguments?" -msgstr "" +msgstr "コマンドライン引数を解析するかどうか。" -#: ../../c-api/init_config.rst:1692 msgid "" "If equals to ``1``, parse :c:member:`~PyConfig.argv` the same way the " "regular Python parses :ref:`command line arguments `, and " "strip Python arguments from :c:member:`~PyConfig.argv`." msgstr "" +"``1`` の場合、通常の Python が :ref:`コマンドライン引数 ` " +"を解析するのと同じように :c:member:`~PyConfig.argv` を解析し、Python 自体への" +"引数を :c:member:`~PyConfig.argv` から取り除きます。" -#: ../../c-api/init_config.rst:1704 msgid "" "The :c:member:`PyConfig.argv` arguments are now only parsed if :c:member:" "`PyConfig.parse_argv` equals to ``1``." msgstr "" +":c:member:`PyConfig.argv` の引数は、:c:member:`PyConfig.parse_argv` が ``1`` " +"の場合にのみ解析されるようになりました。" -#: ../../c-api/init_config.rst:1710 msgid "" "Parser debug mode. If greater than ``0``, turn on parser debugging output " "(for expert only, depending on compilation options)." msgstr "" +"パーサーのデバッグモード。\n" +"``0`` より大きい場合、パーサーのデバッグ出力を有効にします (専門家向けで、コ" +"ンパイルオプションに依存します)。" -#: ../../c-api/init_config.rst:1713 msgid "" "Incremented by the :option:`-d` command line option. Set to the :envvar:" "`PYTHONDEBUG` environment variable value." msgstr "" +":option:`-d` コマンドラインオプションで値が増加します。\n" +":envvar:`PYTHONDEBUG` 環境変数の値から設定されます。" -#: ../../c-api/init_config.rst:1716 ../../c-api/init_config.rst:1821 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_DEBUG`` macro " "must be defined)." msgstr "" +":ref:`Python のデバッグビルド ` が必要です (``Py_DEBUG`` マクロ" +"を定義する必要があります)。" -#: ../../c-api/init_config.rst:1723 msgid "" "If non-zero, calculation of path configuration is allowed to log warnings " "into ``stderr``. If equals to ``0``, suppress these warnings." msgstr "" +"ゼロ以外の場合、パス設定の計算中に ``stderr`` に警告を出せます。\n" +"``0`` の場合は、これらの警告を抑制します。" -#: ../../c-api/init_config.rst:1730 msgid "Now also applies on Windows." -msgstr "" +msgstr "Windows にも適用されるようになりました。" -#: ../../c-api/init_config.rst:1735 msgid "" "The site-specific directory prefix where the platform independent Python " "files are installed: :data:`sys.prefix`." msgstr "" +"プラットフォームに依存しない Python のファイルをインストールする、サイト固有" +"のディレクトリのプレフィックス。\n" +":data:`sys.prefix` に対応します。" -#: ../../c-api/init_config.rst:1742 msgid "See also :c:member:`PyConfig.base_prefix`." -msgstr "" +msgstr ":c:member:`PyConfig.base_prefix` も参照してください。" -#: ../../c-api/init_config.rst:1746 msgid "" "Program name used to initialize :c:member:`~PyConfig.executable` and in " "early error messages during Python initialization." msgstr "" +":c:member:`~PyConfig.executable` の初期化と、Python の初期化の初期段階でのエ" +"ラーメッセージに使うプログラム名。" -#: ../../c-api/init_config.rst:1749 msgid "On macOS, use :envvar:`PYTHONEXECUTABLE` environment variable if set." msgstr "" +"macOS では、設定されていれば :envvar:`PYTHONEXECUTABLE` 環境変数を使います。" -#: ../../c-api/init_config.rst:1750 msgid "" "If the ``WITH_NEXT_FRAMEWORK`` macro is defined, use ``__PYVENV_LAUNCHER__`` " "environment variable if set." msgstr "" +"``WITH_NEXT_FRAMEWORK`` マクロが定義されている場合は、設定されていれば " +"``__PYVENV_LAUNCHER__`` 環境変数を使います。" -#: ../../c-api/init_config.rst:1752 msgid "" "Use ``argv[0]`` of :c:member:`~PyConfig.argv` if available and non-empty." msgstr "" +":c:member:`~PyConfig.argv` の ``argv[0]`` が存在し空でなければ、それを使いま" +"す。" -#: ../../c-api/init_config.rst:1754 msgid "" "Otherwise, use ``L\"python\"`` on Windows, or ``L\"python3\"`` on other " "platforms." msgstr "" +"それ以外の場合、Windows では ``L\"python\"``、ほかのプラットフォームでは " +"``L\"python3\"`` を使います。" -#: ../../c-api/init_config.rst:1763 msgid "" "Directory where cached ``.pyc`` files are written: :data:`sys." "pycache_prefix`." msgstr "" +"キャッシュされた ``.pyc`` ファイルを書き込むディレクトリ。\n" +":data:`sys.pycache_prefix` に対応します。" -#: ../../c-api/init_config.rst:1766 msgid "" "Set by the :option:`-X pycache_prefix=PATH <-X>` command line option and " "the :envvar:`PYTHONPYCACHEPREFIX` environment variable. The command-line " "option takes precedence." msgstr "" +":option:`-X pycache_prefix=PATH <-X>` コマンドラインオプションと :envvar:" +"`PYTHONPYCACHEPREFIX` 環境変数によって設定されます。\n" +"コマンドラインオプションが優先されます。" -#: ../../c-api/init_config.rst:1770 msgid "If ``NULL``, :data:`sys.pycache_prefix` is set to ``None``." msgstr "" +"``NULL`` の場合、:data:`sys.pycache_prefix` は ``None`` に設定されます。" -#: ../../c-api/init_config.rst:1776 msgid "" "Quiet mode. If greater than ``0``, don't display the copyright and version " "at Python startup in interactive mode." msgstr "" +"静粛モード。\n" +"``0`` より大きい場合、対話モードでの Python の起動時に著作権とバージョンを表" +"示しません。" -#: ../../c-api/init_config.rst:1779 msgid "Incremented by the :option:`-q` command line option." -msgstr "" +msgstr ":option:`-q` コマンドラインオプションで値が増加します。" -#: ../../c-api/init_config.rst:1785 msgid "Value of the :option:`-c` command line option." -msgstr "" +msgstr ":option:`-c` コマンドラインオプションの値。" -#: ../../c-api/init_config.rst:1787 ../../c-api/init_config.rst:1808 msgid "Used by :c:func:`Py_RunMain`." -msgstr "" +msgstr ":c:func:`Py_RunMain` が使います。" -#: ../../c-api/init_config.rst:1793 msgid "" "Filename passed on the command line: trailing command line argument without :" "option:`-c` or :option:`-m`. It is used by the :c:func:`Py_RunMain` function." msgstr "" +"コマンドラインで渡されたファイル名。\n" +":option:`-c` や :option:`-m` がない場合の、オプションの後のコマンドライン引数" +"です。\n" +":c:func:`Py_RunMain` が使います。" -#: ../../c-api/init_config.rst:1797 msgid "" "For example, it is set to ``script.py`` by the ``python3 script.py arg`` " "command line." msgstr "" +"例えば、``python3 script.py arg`` というコマンドラインでは ``script.py`` に設" +"定されます。" -#: ../../c-api/init_config.rst:1800 msgid "See also the :c:member:`PyConfig.skip_source_first_line` option." msgstr "" +":c:member:`PyConfig.skip_source_first_line` オプションも参照してください。" -#: ../../c-api/init_config.rst:1806 msgid "Value of the :option:`-m` command line option." -msgstr "" +msgstr ":option:`-m` コマンドラインオプションの値。" -#: ../../c-api/init_config.rst:1814 msgid "" "``module`` or ``module:func`` entry point that should be executed before " "the :mod:`site` module is imported." msgstr "" +":mod:`site` モジュールのインポート前に実行する、``module`` または ``module:" +"func`` 形式のエントリーポイント。" -#: ../../c-api/init_config.rst:1817 msgid "" "Set by the :option:`-X presite=module:func <-X>` command-line option and " "the :envvar:`PYTHON_PRESITE` environment variable. The command-line option " "takes precedence." msgstr "" +":option:`-X presite=module:func <-X>` コマンドラインオプションと :envvar:" +"`PYTHON_PRESITE` 環境変数によって設定されます。\n" +"コマンドラインオプションが優先されます。" -#: ../../c-api/init_config.rst:1828 msgid "" "Show total reference count at exit (excluding :term:`immortal` objects)?" msgstr "" +"終了時に参照カウントの合計を表示するかどうか (:term:`不死 ` オブ" +"ジェクトを除く)。" -#: ../../c-api/init_config.rst:1830 msgid "Set to ``1`` by :option:`-X showrefcount <-X>` command line option." msgstr "" +":option:`-X showrefcount <-X>` コマンドラインオプションによって ``1`` に設定" +"されます。" -#: ../../c-api/init_config.rst:1832 msgid "" "Needs a :ref:`debug build of Python ` (the ``Py_REF_DEBUG`` " "macro must be defined)." msgstr "" +":ref:`Python のデバッグビルド ` が必要です (``Py_REF_DEBUG`` マ" +"クロを定義する必要があります)。" -#: ../../c-api/init_config.rst:1839 msgid "Import the :mod:`site` module at startup?" -msgstr "" +msgstr "起動時に :mod:`site` モジュールをインポートするかどうか。" -#: ../../c-api/init_config.rst:1841 msgid "" "If equal to zero, disable the import of the module site and the site-" "dependent manipulations of :data:`sys.path` that it entails." msgstr "" +"ゼロの場合、``site`` モジュールのインポートと、それに伴うサイト固有の :data:" +"`sys.path` の操作を無効にします。" -#: ../../c-api/init_config.rst:1844 msgid "" "Also disable these manipulations if the :mod:`site` module is explicitly " "imported later (call :func:`site.main` if you want them to be triggered)." msgstr "" +"後で :mod:`site` モジュールを明示的にインポートしても、これらの操作は行われま" +"せん。\n" +"行いたい場合は :func:`site.main` を呼び出してください。" -#: ../../c-api/init_config.rst:1847 msgid "Set to ``0`` by the :option:`-S` command line option." -msgstr "" +msgstr ":option:`-S` コマンドラインオプションによって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:1849 msgid "" ":data:`sys.flags.no_site ` is set to the inverted value of :c:" "member:`~PyConfig.site_import`." msgstr "" +":data:`sys.flags.no_site ` は、:c:member:`~PyConfig.site_import` " +"の値を反転した値に設定されます。" -#: ../../c-api/init_config.rst:1856 msgid "" "If non-zero, skip the first line of the :c:member:`PyConfig.run_filename` " "source." msgstr "" +"ゼロ以外の場合、:c:member:`PyConfig.run_filename` のソースの先頭行を読み飛ば" +"します。" -#: ../../c-api/init_config.rst:1859 msgid "" "It allows the usage of non-Unix forms of ``#!cmd``. This is intended for a " "DOS specific hack only." msgstr "" +"Unix 以外の形式の ``#!cmd`` を使えるようにします。\n" +"DOS 固有の回避策だけを想定したものです。" -#: ../../c-api/init_config.rst:1862 msgid "Set to ``1`` by the :option:`-x` command line option." -msgstr "" +msgstr ":option:`-x` コマンドラインオプションによって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1869 msgid "" "Encoding and encoding errors of :data:`sys.stdin`, :data:`sys.stdout` and :" "data:`sys.stderr` (but :data:`sys.stderr` always uses " "``\"backslashreplace\"`` error handler)." msgstr "" +":data:`sys.stdin`、:data:`sys.stdout`、:data:`sys.stderr` のエンコーディング" +"とエラーハンドラー。\n" +"ただし、:data:`sys.stderr` は常に ``\"backslashreplace\"`` エラーハンドラーを" +"使います。" -#: ../../c-api/init_config.rst:1873 msgid "" "Use the :envvar:`PYTHONIOENCODING` environment variable if it is non-empty." -msgstr "" +msgstr ":envvar:`PYTHONIOENCODING` 環境変数が空でなければ、その値を使います。" -#: ../../c-api/init_config.rst:1876 msgid "Default encoding:" -msgstr "" +msgstr "デフォルトのエンコーディング:" -#: ../../c-api/init_config.rst:1878 msgid "``\"UTF-8\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero." -msgstr "" +msgstr ":c:member:`PyPreConfig.utf8_mode` がゼロ以外の場合は ``\"UTF-8\"``。" -#: ../../c-api/init_config.rst:1879 msgid "Otherwise, use the :term:`locale encoding`." msgstr "" +"それ以外の場合は :term:`ロケールエンコーディング ` を使いま" +"す。" -#: ../../c-api/init_config.rst:1881 msgid "Default error handler:" -msgstr "" +msgstr "デフォルトのエラーハンドラー:" -#: ../../c-api/init_config.rst:1883 msgid "On Windows: use ``\"surrogateescape\"``." -msgstr "" +msgstr "Windows: ``\"surrogateescape\"`` を使います。" -#: ../../c-api/init_config.rst:1884 msgid "" "``\"surrogateescape\"`` if :c:member:`PyPreConfig.utf8_mode` is non-zero, or " "if the LC_CTYPE locale is \"C\" or \"POSIX\"." msgstr "" +":c:member:`PyPreConfig.utf8_mode` がゼロ以外の場合、または LC_CTYPE ロケール" +"が \"C\" か \"POSIX\" の場合は ``\"surrogateescape\"``。" -#: ../../c-api/init_config.rst:1886 msgid "``\"strict\"`` otherwise." -msgstr "" +msgstr "それ以外の場合は ``\"strict\"``。" -#: ../../c-api/init_config.rst:1888 msgid "See also :c:member:`PyConfig.legacy_windows_stdio`." -msgstr "" +msgstr ":c:member:`PyConfig.legacy_windows_stdio` も参照してください。" -#: ../../c-api/init_config.rst:1892 msgid "Enable tracemalloc?" -msgstr "" +msgstr "tracemalloc を有効にするかどうか。" -#: ../../c-api/init_config.rst:1894 msgid "If non-zero, call :func:`tracemalloc.start` at startup." -msgstr "" +msgstr "ゼロ以外の場合、起動時に :func:`tracemalloc.start` を呼び出します。" -#: ../../c-api/init_config.rst:1896 msgid "" "Set by :option:`-X tracemalloc=N <-X>` command line option and by the :" "envvar:`PYTHONTRACEMALLOC` environment variable." msgstr "" +":option:`-X tracemalloc=N <-X>` コマンドラインオプションと :envvar:" +"`PYTHONTRACEMALLOC` 環境変数によって設定されます。" -#: ../../c-api/init_config.rst:1903 msgid "Enable the Linux ``perf`` profiler support?" -msgstr "" +msgstr "Linux の ``perf`` プロファイラーへの対応を有効にするかどうか。" -#: ../../c-api/init_config.rst:1905 msgid "If equals to ``1``, enable support for the Linux ``perf`` profiler." -msgstr "" +msgstr "``1`` の場合、Linux の ``perf`` プロファイラーへの対応を有効にします。" -#: ../../c-api/init_config.rst:1907 msgid "" "If equals to ``2``, enable support for the Linux ``perf`` profiler with " "DWARF JIT support." msgstr "" +"``2`` の場合、DWARF JIT に対応する方式で Linux の ``perf`` プロファイラーへの" +"対応を有効にします。" -#: ../../c-api/init_config.rst:1910 msgid "" "Set to ``1`` by :option:`-X perf <-X>` command-line option and the :envvar:" "`PYTHONPERFSUPPORT` environment variable." msgstr "" +":option:`-X perf <-X>` コマンドラインオプションと :envvar:" +"`PYTHONPERFSUPPORT` 環境変数によって ``1`` に設定されます。" -#: ../../c-api/init_config.rst:1913 msgid "" "Set to ``2`` by the :option:`-X perf_jit <-X>` command-line option and the :" "envvar:`PYTHON_PERF_JIT_SUPPORT` environment variable." msgstr "" +":option:`-X perf_jit <-X>` コマンドラインオプションと :envvar:" +"`PYTHON_PERF_JIT_SUPPORT` 環境変数によって ``2`` に設定されます。" -#: ../../c-api/init_config.rst:1919 msgid "See :ref:`perf_profiling` for more information." -msgstr "" +msgstr "詳しくは :ref:`perf_profiling` を参照してください。" -#: ../../c-api/init_config.rst:1925 msgid "Directory of the Python standard library." -msgstr "" +msgstr "Python の標準ライブラリのディレクトリ。" -#: ../../c-api/init_config.rst:1933 msgid "Use :ref:`environment variables `?" -msgstr "" +msgstr ":ref:`環境変数 ` を使うかどうか。" -#: ../../c-api/init_config.rst:1935 msgid "" "If equals to zero, ignore the :ref:`environment variables `." -msgstr "" +msgstr "ゼロの場合、:ref:`環境変数 ` を無視します。" -#: ../../c-api/init_config.rst:1938 msgid "Set to ``0`` by the :option:`-E` environment variable." -msgstr "" +msgstr ":option:`-E` コマンドラインオプションによって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:1944 msgid "" "If non-zero, ``stdout`` and ``stderr`` will be redirected to the system log." msgstr "" +"ゼロ以外の場合、``stdout`` と ``stderr`` をシステムログにリダイレクトします。" -#: ../../c-api/init_config.rst:1947 msgid "Only available on macOS 10.12 and later, and on iOS." -msgstr "" +msgstr "macOS 10.12 以降と iOS でのみ利用できます。" -#: ../../c-api/init_config.rst:1949 msgid "" "Default: ``0`` (don't use the system log) on macOS; ``1`` on iOS (use the " "system log)." msgstr "" +"デフォルト: macOS では ``0`` (システムログを使わない)、iOS では ``1`` (システ" +"ムログを使う)。" -#: ../../c-api/init_config.rst:1956 msgid "If non-zero, add the user site directory to :data:`sys.path`." msgstr "" +"ゼロ以外の場合、ユーザーのサイトディレクトリを :data:`sys.path` に追加しま" +"す。" -#: ../../c-api/init_config.rst:1958 msgid "Set to ``0`` by the :option:`-s` and :option:`-I` command line options." msgstr "" +":option:`-s` と :option:`-I` コマンドラインオプションによって ``0`` に設定さ" +"れます。" -#: ../../c-api/init_config.rst:1960 msgid "Set to ``0`` by the :envvar:`PYTHONNOUSERSITE` environment variable." -msgstr "" +msgstr ":envvar:`PYTHONNOUSERSITE` 環境変数によって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:1966 msgid "" "Verbose mode. If greater than ``0``, print a message each time a module is " "imported, showing the place (filename or built-in module) from which it is " "loaded." msgstr "" +"詳細表示モード。\n" +"``0`` より大きい場合、モジュールをインポートするたびに、ロード元の場所 (ファ" +"イル名または組み込みモジュール) を示すメッセージを表示します。" -#: ../../c-api/init_config.rst:1970 msgid "" "If greater than or equal to ``2``, print a message for each file that is " "checked for when searching for a module. Also provides information on module " "cleanup at exit." msgstr "" +"``2`` 以上の場合、モジュールを探す際に確認するファイルごとにメッセージを表示" +"します。\n" +"終了時のモジュールの後始末に関する情報も表示します。" -#: ../../c-api/init_config.rst:1974 msgid "Incremented by the :option:`-v` command line option." -msgstr "" +msgstr ":option:`-v` コマンドラインオプションで値が増加します。" -#: ../../c-api/init_config.rst:1976 msgid "Set by the :envvar:`PYTHONVERBOSE` environment variable value." -msgstr "" +msgstr ":envvar:`PYTHONVERBOSE` 環境変数の値から設定されます。" -#: ../../c-api/init_config.rst:1982 msgid "" "Options of the :mod:`warnings` module to build warnings filters, lowest to " "highest priority: :data:`sys.warnoptions`." msgstr "" +":mod:`warnings` モジュールが警告フィルターを作成するためのオプションで、優先" +"度の低いものから高いものの順に並びます。\n" +":data:`sys.warnoptions` に対応します。" -#: ../../c-api/init_config.rst:1985 msgid "" "The :mod:`warnings` module adds :data:`sys.warnoptions` in the reverse " "order: the last :c:member:`PyConfig.warnoptions` item becomes the first item " "of ``warnings.filters`` which is checked first (highest priority)." msgstr "" +":mod:`warnings` モジュールは :data:`sys.warnoptions` を逆順に追加します。\n" +"そのため、:c:member:`PyConfig.warnoptions` の最後の要素が ``warnings." +"filters`` の先頭になり、最初に確認されます (最も高い優先度)。" -#: ../../c-api/init_config.rst:1989 msgid "" "The :option:`-W` command line options adds its value to :c:member:`~PyConfig." "warnoptions`, it can be used multiple times." msgstr "" +":option:`-W` コマンドラインオプションは、その値を :c:member:`~PyConfig." +"warnoptions` に追加します。\n" +"複数回指定できます。" -#: ../../c-api/init_config.rst:1992 msgid "" "The :envvar:`PYTHONWARNINGS` environment variable can also be used to add " "warning options. Multiple options can be specified, separated by commas (``," "``)." msgstr "" +":envvar:`PYTHONWARNINGS` 環境変数でも警告オプションを追加できます。\n" +"カンマ (``,``) で区切ることで、複数のオプションを指定できます。" -#: ../../c-api/init_config.rst:2000 msgid "" "If equal to ``0``, Python won't try to write ``.pyc`` files on the import of " "source modules." msgstr "" +"``0`` の場合、Python はソースモジュールのインポート時に ``.pyc`` ファイルを書" +"き込もうとしません。" -#: ../../c-api/init_config.rst:2003 msgid "" "Set to ``0`` by the :option:`-B` command line option and the :envvar:" "`PYTHONDONTWRITEBYTECODE` environment variable." msgstr "" +":option:`-B` コマンドラインオプションと :envvar:`PYTHONDONTWRITEBYTECODE` 環" +"境変数によって ``0`` に設定されます。" -#: ../../c-api/init_config.rst:2006 msgid "" ":data:`sys.dont_write_bytecode` is initialized to the inverted value of :c:" "member:`~PyConfig.write_bytecode`." msgstr "" +":data:`sys.dont_write_bytecode` は、:c:member:`~PyConfig.write_bytecode` の値" +"を反転した値で初期化されます。" -#: ../../c-api/init_config.rst:2013 msgid "Values of the :option:`-X` command line options: :data:`sys._xoptions`." msgstr "" +":option:`-X` コマンドラインオプションの値。\n" +":data:`sys._xoptions` に対応します。" -#: ../../c-api/init_config.rst:2019 msgid "If non-zero, write performance statistics at Python exit." -msgstr "" +msgstr "ゼロ以外の場合、Python の終了時に性能統計を書き出します。" -#: ../../c-api/init_config.rst:2021 msgid "" "Need a special build with the ``Py_STATS`` macro: see :option:`--enable-" "pystats`." msgstr "" +"``Py_STATS`` マクロを定義した特別なビルドが必要です。\n" +":option:`--enable-pystats` を参照してください。" -#: ../../c-api/init_config.rst:2026 msgid "" "If :c:member:`~PyConfig.parse_argv` is non-zero, :c:member:`~PyConfig.argv` " "arguments are parsed the same way the regular Python parses :ref:`command " "line arguments `, and Python arguments are stripped from :" "c:member:`~PyConfig.argv`." msgstr "" +":c:member:`~PyConfig.parse_argv` がゼロ以外の場合、通常の Python が :ref:`コ" +"マンドライン引数 ` を解析するのと同じように :c:member:" +"`~PyConfig.argv` の引数を解析し、Python 自体への引数を :c:member:`~PyConfig." +"argv` から取り除きます。" -#: ../../c-api/init_config.rst:2031 msgid "" "The :c:member:`~PyConfig.xoptions` options are parsed to set other options: " "see the :option:`-X` command line option." msgstr "" +":c:member:`~PyConfig.xoptions` のオプションを解析して、ほかのオプションを設定" +"します。\n" +":option:`-X` コマンドラインオプションを参照してください。" -#: ../../c-api/init_config.rst:2036 msgid "The ``show_alloc_count`` field has been removed." -msgstr "" +msgstr "``show_alloc_count`` フィールドが削除されました。" -#: ../../c-api/init_config.rst:2042 msgid "Initialization with PyConfig" -msgstr "" +msgstr "PyConfig による初期化" -#: ../../c-api/init_config.rst:2044 msgid "" "Initializing the interpreter from a populated configuration struct is " "handled by calling :c:func:`Py_InitializeFromConfig`." msgstr "" +"値を設定した構造体からインタープリタを初期化するには、:c:func:" +"`Py_InitializeFromConfig` を呼び出します。" -#: ../../c-api/init_config.rst:2050 msgid "" "If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or :c:" "func:`PyImport_ExtendInittab` are used, they must be set or called after " @@ -3019,18 +2991,23 @@ msgid "" "initialized multiple times, :c:func:`PyImport_AppendInittab` or :c:func:" "`PyImport_ExtendInittab` must be called before each Python initialization." msgstr "" +":c:func:`PyImport_FrozenModules`、:c:func:`PyImport_AppendInittab`、:c:func:" +"`PyImport_ExtendInittab` を使う場合は、Python の事前初期化の後、本初期化の前" +"に設定または呼び出す必要があります。\n" +"Python を複数回初期化する場合は、初期化のたびに、その前に :c:func:" +"`PyImport_AppendInittab` または :c:func:`PyImport_ExtendInittab` を呼び出さな" +"ければなりません。" -#: ../../c-api/init_config.rst:2057 msgid "" "The current configuration (``PyConfig`` type) is stored in " "``PyInterpreterState.config``." msgstr "" +"現在の設定 (``PyConfig`` 型) は、``PyInterpreterState.config`` に保存されま" +"す。" -#: ../../c-api/init_config.rst:2060 msgid "Example setting the program name::" -msgstr "" +msgstr "プログラム名を設定する例です。 ::" -#: ../../c-api/init_config.rst:2062 msgid "" "void init_python(void)\n" "{\n" @@ -3058,8 +3035,33 @@ msgid "" " Py_ExitStatusException(status);\n" "}" msgstr "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* プログラム名を設定する。\n" +" Python を暗黙に事前初期化する。 */\n" +" status = PyConfig_SetString(&config, &config.program_name,\n" +" L\"/path/to/my_program\");\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +" return;\n" +"\n" +"exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" -#: ../../c-api/init_config.rst:2088 msgid "" "More complete example modifying the default configuration, read the " "configuration, and then override some parameters. Note that since 3.11, many " @@ -3067,6 +3069,11 @@ msgid "" "read from the configuration structure. Any values set before initialize is " "called will be left unchanged by initialization::" msgstr "" +"デフォルトの設定を変更してから設定を読み込み、さらに一部のパラメーターを上書" +"きする、より完全な例です。\n" +"3.11 以降、多くのパラメーターは初期化するまで計算されないため、設定構造体から" +"値を読み取れないことに注意してください。\n" +"初期化関数の呼び出し前に設定された値は、初期化によって変更されません。 ::" #: ../../c-api/init_config.rst:2095 msgid "" @@ -3123,48 +3130,57 @@ msgid "" "}" msgstr "" -#: ../../c-api/init_config.rst:2151 msgid "Isolated Configuration" -msgstr "" +msgstr "隔離設定" -#: ../../c-api/init_config.rst:2153 msgid "" ":c:func:`PyPreConfig_InitIsolatedConfig` and :c:func:" "`PyConfig_InitIsolatedConfig` functions create a configuration to isolate " "Python from the system. For example, to embed Python into an application." msgstr "" +":c:func:`PyPreConfig_InitIsolatedConfig` と :c:func:" +"`PyConfig_InitIsolatedConfig` は、Python をシステムから隔離する設定を作成しま" +"す。\n" +"例えば、Python をアプリケーションに組み込むために使います。" -#: ../../c-api/init_config.rst:2158 msgid "" "This configuration ignores global configuration variables, environment " "variables, command line arguments (:c:member:`PyConfig.argv` is not parsed) " "and user site directory. The C standard streams (ex: ``stdout``) and the " "LC_CTYPE locale are left unchanged. Signal handlers are not installed." msgstr "" +"この設定は、グローバルな設定変数、環境変数、コマンドライン引数、ユーザーのサ" +"イトディレクトリを無視します (:c:member:`PyConfig.argv` は解析しません)。\n" +"``stdout`` などの C の標準ストリームと LC_CTYPE ロケールは変更しません。\n" +"シグナルハンドラーも登録しません。" -#: ../../c-api/init_config.rst:2163 msgid "" "Configuration files are still used with this configuration to determine " "paths that are unspecified. Ensure :c:member:`PyConfig.home` is specified to " "avoid computing the default path configuration." msgstr "" +"この設定でも、指定されていないパスを決めるために設定ファイルを使います。\n" +"デフォルトのパス設定の計算を避けるには、:c:member:`PyConfig.home` を必ず指定" +"してください。" -#: ../../c-api/init_config.rst:2171 msgid "Python Configuration" -msgstr "" +msgstr "Python 設定" -#: ../../c-api/init_config.rst:2173 msgid "" ":c:func:`PyPreConfig_InitPythonConfig` and :c:func:" "`PyConfig_InitPythonConfig` functions create a configuration to build a " "customized Python which behaves as the regular Python." msgstr "" +":c:func:`PyPreConfig_InitPythonConfig` と :c:func:" +"`PyConfig_InitPythonConfig` は、通常の Python と同じように動作する、カスタマ" +"イズされた Python を作るための設定を作成します。" -#: ../../c-api/init_config.rst:2177 msgid "" "Environments variables and command line arguments are used to configure " "Python, whereas global configuration variables are ignored." msgstr "" +"Python の設定には環境変数とコマンドライン引数を使いますが、グローバルな設定変" +"数は無視します。" #: ../../c-api/init_config.rst:2180 msgid "" @@ -3173,17 +3189,14 @@ msgid "" "`PYTHONUTF8` and :envvar:`PYTHONCOERCECLOCALE` environment variables." msgstr "" -#: ../../c-api/init_config.rst:2189 msgid "Python Path Configuration" -msgstr "" +msgstr "Python のパス設定" -#: ../../c-api/init_config.rst:2191 msgid ":c:type:`PyConfig` contains multiple fields for the path configuration:" -msgstr "" +msgstr ":c:type:`PyConfig` には、パス設定のための複数のフィールドがあります。" -#: ../../c-api/init_config.rst:2193 msgid "Path configuration inputs:" -msgstr "" +msgstr "パス設定の入力:" #: ../../c-api/init_config.rst:2195 msgid ":c:member:`PyConfig.home`" @@ -3205,30 +3218,30 @@ msgstr ":c:member:`PyConfig.program_name`" msgid ":c:member:`PyConfig.pythonpath_env`" msgstr ":c:member:`PyConfig.pythonpath_env`" -#: ../../c-api/init_config.rst:2200 msgid "current working directory: to get absolute paths" -msgstr "" +msgstr "現在の作業ディレクトリ: 絶対パスの取得に使います。" -#: ../../c-api/init_config.rst:2201 msgid "" "``PATH`` environment variable to get the program full path (from :c:member:" "`PyConfig.program_name`)" msgstr "" +"``PATH`` 環境変数: :c:member:`PyConfig.program_name` からプログラムの完全なパ" +"スを取得するために使います。" -#: ../../c-api/init_config.rst:2203 msgid "``__PYVENV_LAUNCHER__`` environment variable" -msgstr "" +msgstr "``__PYVENV_LAUNCHER__`` 環境変数" -#: ../../c-api/init_config.rst:2204 msgid "" "(Windows only) Application paths in the registry under " "\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" of HKEY_CURRENT_USER and " "HKEY_LOCAL_MACHINE (where X.Y is the Python version)." msgstr "" +"Windows のみ: レジストリの HKEY_CURRENT_USER と HKEY_LOCAL_MACHINE の " +"\"Software\\Python\\PythonCore\\X.Y\\PythonPath\" にあるアプリケーションのパ" +"ス (X.Y は Python のバージョン)。" -#: ../../c-api/init_config.rst:2208 msgid "Path configuration output fields:" -msgstr "" +msgstr "パス設定の出力フィールド:" #: ../../c-api/init_config.rst:2210 msgid ":c:member:`PyConfig.base_exec_prefix`" @@ -3262,7 +3275,6 @@ msgstr "" msgid ":c:member:`PyConfig.prefix`" msgstr ":c:member:`PyConfig.prefix`" -#: ../../c-api/init_config.rst:2219 msgid "" "If at least one \"output field\" is not set, Python calculates the path " "configuration to fill unset fields. If :c:member:`~PyConfig." @@ -3270,6 +3282,11 @@ msgid "" "module_search_paths` is overridden and :c:member:`~PyConfig." "module_search_paths_set` is set to ``1``." msgstr "" +"「出力フィールド」が 1 つでも未設定なら、Python はパス設定を計算して未設定の" +"フィールドを埋めます。\n" +":c:member:`~PyConfig.module_search_paths_set` が ``0`` の場合は、:c:member:" +"`~PyConfig.module_search_paths` を上書きし、:c:member:`~PyConfig." +"module_search_paths_set` を ``1`` に設定します。" #: ../../c-api/init_config.rst:2225 msgid "" @@ -3288,45 +3305,50 @@ msgid "" "warning)." msgstr "" -#: ../../c-api/init_config.rst:2235 msgid "" "If :c:member:`~PyConfig.base_prefix` or :c:member:`~PyConfig." "base_exec_prefix` fields are not set, they inherit their value from :c:" "member:`~PyConfig.prefix` and :c:member:`~PyConfig.exec_prefix` respectively." msgstr "" +":c:member:`~PyConfig.base_prefix` と :c:member:`~PyConfig.base_exec_prefix` " +"は、それぞれ未設定なら :c:member:`~PyConfig.prefix` と :c:member:`~PyConfig." +"exec_prefix` の値を引き継ぎます。" -#: ../../c-api/init_config.rst:2239 msgid ":c:func:`Py_RunMain` and :c:func:`Py_Main` modify :data:`sys.path`:" msgstr "" +":c:func:`Py_RunMain` と :c:func:`Py_Main` は :data:`sys.path` を変更します。" -#: ../../c-api/init_config.rst:2241 msgid "" "If :c:member:`~PyConfig.run_filename` is set and is a directory which " "contains a ``__main__.py`` script, prepend :c:member:`~PyConfig." "run_filename` to :data:`sys.path`." msgstr "" +":c:member:`~PyConfig.run_filename` が設定されており、``__main__.py`` スクリプ" +"トを含むディレクトリである場合は、:c:member:`~PyConfig.run_filename` を :" +"data:`sys.path` の先頭に追加します。" #: ../../c-api/init_config.rst:2244 msgid "If :c:member:`~PyConfig.isolated` is zero:" msgstr "" -#: ../../c-api/init_config.rst:2246 msgid "" "If :c:member:`~PyConfig.run_module` is set, prepend the current directory " "to :data:`sys.path`. Do nothing if the current directory cannot be read." msgstr "" +":c:member:`~PyConfig.run_module` が設定されている場合は、現在のディレクトリ" +"を :data:`sys.path` の先頭に追加します。\n" +"現在のディレクトリを取得できなければ何もしません。" -#: ../../c-api/init_config.rst:2248 msgid "" "If :c:member:`~PyConfig.run_filename` is set, prepend the directory of the " "filename to :data:`sys.path`." msgstr "" +":c:member:`~PyConfig.run_filename` が設定されている場合は、そのファイル名の" +"ディレクトリを :data:`sys.path` の先頭に追加します。" -#: ../../c-api/init_config.rst:2250 msgid "Otherwise, prepend an empty string to :data:`sys.path`." -msgstr "" +msgstr "それ以外の場合は、空文字列を :data:`sys.path` の先頭に追加します。" -#: ../../c-api/init_config.rst:2252 msgid "" "If :c:member:`~PyConfig.site_import` is non-zero, :data:`sys.path` can be " "modified by the :mod:`site` module. If :c:member:`~PyConfig." @@ -3334,48 +3356,44 @@ msgid "" "exists, the :mod:`site` module appends the user's site-package directory to :" "data:`sys.path`." msgstr "" +":c:member:`~PyConfig.site_import` がゼロ以外の場合、:mod:`site` モジュール" +"が :data:`sys.path` を変更することがあります。\n" +":c:member:`~PyConfig.user_site_directory` がゼロ以外で、ユーザーの site-" +"packages ディレクトリが存在する場合は、:mod:`site` モジュールがそのディレクト" +"リを :data:`sys.path` の末尾に追加します。" -#: ../../c-api/init_config.rst:2258 msgid "The following configuration files are used by the path configuration:" -msgstr "" +msgstr "パス設定では、以下の設定ファイルを使います。" #: ../../c-api/init_config.rst:2260 msgid "``pyvenv.cfg``" msgstr "``pyvenv.cfg``" -#: ../../c-api/init_config.rst:2261 msgid "``._pth`` file (ex: ``python._pth``)" -msgstr "" +msgstr "``._pth`` ファイル (例: ``python._pth``)" -#: ../../c-api/init_config.rst:2262 msgid "``pybuilddir.txt`` (Unix only)" -msgstr "" +msgstr "``pybuilddir.txt`` (Unix のみ)" -#: ../../c-api/init_config.rst:2264 msgid "If a ``._pth`` file is present:" -msgstr "" +msgstr "``._pth`` ファイルが存在する場合:" -#: ../../c-api/init_config.rst:2266 msgid "Set :c:member:`~PyConfig.isolated` to ``1``." -msgstr "" +msgstr ":c:member:`~PyConfig.isolated` を ``1`` に設定します。" -#: ../../c-api/init_config.rst:2267 msgid "Set :c:member:`~PyConfig.use_environment` to ``0``." -msgstr "" +msgstr ":c:member:`~PyConfig.use_environment` を ``0`` に設定します。" -#: ../../c-api/init_config.rst:2268 msgid "Set :c:member:`~PyConfig.site_import` to ``0``." -msgstr "" +msgstr ":c:member:`~PyConfig.site_import` を ``0`` に設定します。" -#: ../../c-api/init_config.rst:2269 msgid "Set :c:member:`~PyConfig.user_site_directory` to ``0`` (since 3.15)." msgstr "" +":c:member:`~PyConfig.user_site_directory` を ``0`` に設定します (3.15 以降)。" -#: ../../c-api/init_config.rst:2270 msgid "Set :c:member:`~PyConfig.safe_path` to ``1``." -msgstr "" +msgstr ":c:member:`~PyConfig.safe_path` を ``1`` に設定します。" -#: ../../c-api/init_config.rst:2272 msgid "" "If :c:member:`~PyConfig.home` is not set and a ``pyvenv.cfg`` file is " "present in the same directory as :c:member:`~PyConfig.executable`, or its " @@ -3385,121 +3403,124 @@ msgid "" "to the base installation. See :ref:`sys-path-init-virtual-environments` for " "more information." msgstr "" +":c:member:`~PyConfig.home` が未設定で、:c:member:`~PyConfig.executable` と同" +"じディレクトリか、その親ディレクトリに ``pyvenv.cfg`` ファイルがある場合、:c:" +"member:`~PyConfig.prefix` と :c:member:`~PyConfig.exec_prefix` はその場所に設" +"定されます。\n" +"この場合も、:c:member:`~PyConfig.base_prefix` と :c:member:`~PyConfig." +"base_exec_prefix` は元の値を保ち、基となるインストール先を指します。\n" +"詳しくは :ref:`sys-path-init-virtual-environments` を参照してください。" -#: ../../c-api/init_config.rst:2280 msgid "" "The ``__PYVENV_LAUNCHER__`` environment variable is used to set :c:member:" "`PyConfig.base_executable`." msgstr "" +"``__PYVENV_LAUNCHER__`` 環境変数は、:c:member:`PyConfig.base_executable` の設" +"定に使います。" -#: ../../c-api/init_config.rst:2285 msgid "" ":c:member:`~PyConfig.prefix`, and :c:member:`~PyConfig.exec_prefix`, are now " "set to the ``pyvenv.cfg`` directory. This was previously done by :mod:" "`site`, therefore affected by :option:`-S`." msgstr "" +":c:member:`~PyConfig.prefix` と :c:member:`~PyConfig.exec_prefix` が、" +"``pyvenv.cfg`` のディレクトリに設定されるようになりました。\n" +"以前は :mod:`site` が設定していたため、:option:`-S` の影響を受けていました。" -#: ../../c-api/init_config.rst:2292 msgid "" ":c:member:`~PyConfig.user_site_directory` is now set to ``0`` when a ``." "_pth`` file is present." msgstr "" +"``._pth`` ファイルが存在する場合、:c:member:`~PyConfig.user_site_directory` " +"が ``0`` に設定されるようになりました。" #: ../../c-api/init_config.rst:2297 msgid "Py_GetArgcArgv()" msgstr "Py_GetArgcArgv()" -#: ../../c-api/init_config.rst:2301 msgid "Get the original command line arguments, before Python modified them." -msgstr "" +msgstr "Python が変更する前の、元のコマンドライン引数を取得します。" -#: ../../c-api/init_config.rst:2303 msgid "See also :c:member:`PyConfig.orig_argv` member." -msgstr "" +msgstr ":c:member:`PyConfig.orig_argv` メンバーも参照してください。" -#: ../../c-api/init_config.rst:2307 msgid "Multi-Phase Initialization Private Provisional API" -msgstr "" +msgstr "多相初期化の非公開の暫定 API" -#: ../../c-api/init_config.rst:2309 msgid "" "This section is a private provisional API introducing multi-phase " "initialization, the core feature of :pep:`432`:" msgstr "" +"この節では、:pep:`432` の中心的な機能である多相初期化を導入する、非公開の暫" +"定 API を説明します。" -#: ../../c-api/init_config.rst:2312 msgid "\"Core\" initialization phase, \"bare minimum Python\":" msgstr "" +"「コア」初期化フェーズ。\n" +"必要最小限の Python:" -#: ../../c-api/init_config.rst:2314 msgid "Builtin types;" -msgstr "" +msgstr "組み込み型。" -#: ../../c-api/init_config.rst:2315 msgid "Builtin exceptions;" -msgstr "" +msgstr "組み込み例外。" -#: ../../c-api/init_config.rst:2316 msgid "Builtin and frozen modules;" -msgstr "" +msgstr "組み込みモジュールと凍結モジュール。" -#: ../../c-api/init_config.rst:2317 msgid "" "The :mod:`sys` module is only partially initialized (ex: :data:`sys.path` " "doesn't exist yet)." msgstr "" +":mod:`sys` モジュールは一部だけ初期化されます (例えば、:data:`sys.path` はま" +"だ存在しません)。" -#: ../../c-api/init_config.rst:2320 msgid "\"Main\" initialization phase, Python is fully initialized:" msgstr "" +"「メイン」初期化フェーズ。\n" +"Python が完全に初期化されます:" -#: ../../c-api/init_config.rst:2322 msgid "Install and configure :mod:`importlib`;" -msgstr "" +msgstr ":mod:`importlib` の組み込みと設定。" -#: ../../c-api/init_config.rst:2323 msgid "Apply the :ref:`Path Configuration `;" -msgstr "" +msgstr ":ref:`パス設定 ` の適用。" -#: ../../c-api/init_config.rst:2324 msgid "Install signal handlers;" -msgstr "" +msgstr "シグナルハンドラーの登録。" -#: ../../c-api/init_config.rst:2325 msgid "" "Finish :mod:`sys` module initialization (ex: create :data:`sys.stdout` and :" "data:`sys.path`);" msgstr "" +":mod:`sys` モジュールの初期化の完了 (例: :data:`sys.stdout` と :data:`sys." +"path` の作成)。" -#: ../../c-api/init_config.rst:2327 msgid "" "Enable optional features like :mod:`faulthandler` and :mod:`tracemalloc`;" msgstr "" +":mod:`faulthandler` と :mod:`tracemalloc` などのオプション機能の有効化。" -#: ../../c-api/init_config.rst:2328 msgid "Import the :mod:`site` module;" -msgstr "" +msgstr ":mod:`site` モジュールのインポート。" -#: ../../c-api/init_config.rst:2329 msgid "etc." -msgstr "" +msgstr "その他。" -#: ../../c-api/init_config.rst:2331 msgid "Private provisional API:" -msgstr "" +msgstr "非公開の暫定 API:" -#: ../../c-api/init_config.rst:2335 msgid "" "If set to ``0``, :c:func:`Py_InitializeFromConfig` stops at the \"Core\" " "initialization phase." msgstr "" +"``0`` に設定すると、:c:func:`Py_InitializeFromConfig` は「コア」初期化フェー" +"ズで停止します。" -#: ../../c-api/init_config.rst:2340 msgid "" "Move to the \"Main\" initialization phase, finish the Python initialization." -msgstr "" +msgstr "「メイン」初期化フェーズに進み、Python の初期化を完了します。" -#: ../../c-api/init_config.rst:2342 msgid "" "No module is imported during the \"Core\" phase and the ``importlib`` module " "is not configured: the :ref:`Path Configuration ` is only " @@ -3507,29 +3528,39 @@ msgid "" "Python to override or tune the :ref:`Path Configuration `, " "maybe install a custom :data:`sys.meta_path` importer or an import hook, etc." msgstr "" +"「コア」フェーズでは、モジュールをインポートせず、``importlib`` モジュールも" +"設定しません。\n" +":ref:`パス設定 ` は「メイン」フェーズでのみ適用されます。\n" +"これにより、Python コードで Python 自体をカスタマイズし、:ref:`パス設定 " +"` の上書きや調整、独自の :data:`sys.meta_path` インポーター" +"やインポートフックの設定などができる可能性があります。" -#: ../../c-api/init_config.rst:2348 msgid "" "It may become possible to calculate the :ref:`Path Configuration ` in Python, after the Core phase and before the Main phase, which is " "one of the :pep:`432` motivation." msgstr "" +"「コア」フェーズの後、「メイン」フェーズの前に、Python で :ref:`パス設定 " +"` を計算できるようになる可能性があります。\n" +"これは :pep:`432` の動機の 1 つです。" -#: ../../c-api/init_config.rst:2352 msgid "" "The \"Core\" phase is not properly defined: what should be and what should " "not be available at this phase is not specified yet. The API is marked as " "private and provisional: the API can be modified or even be removed anytime " "until a proper public API is designed." msgstr "" +"「コア」フェーズはまだ明確に定義されておらず、この段階で何が利用でき、何が利" +"用できないべきかは未指定です。\n" +"API は非公開かつ暫定とされているため、正式な公開 API が設計されるまでは、いつ" +"でも変更または削除される可能性があります。" -#: ../../c-api/init_config.rst:2357 msgid "" "Example running Python code between \"Core\" and \"Main\" initialization " "phases::" msgstr "" +"「コア」と「メイン」の初期化フェーズの間で Python コードを実行する例です。 ::" -#: ../../c-api/init_config.rst:2360 msgid "" "void init_python(void)\n" "{\n" @@ -3565,6 +3596,39 @@ msgid "" " }\n" "}" msgstr "" +"void init_python(void)\n" +"{\n" +" PyStatus status;\n" +"\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +" config._init_main = 0;\n" +"\n" +" /* ... 'config' の設定をカスタマイズする ... */\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" PyConfig_Clear(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"\n" +" /* sys.stdout は _Py_InitializeMain() で初めて作成されるので、\n" +" sys.stderr を使う */\n" +" int res = PyRun_SimpleString(\n" +" \"import sys; \"\n" +" \"print('Run Python code before _Py_InitializeMain', \"\n" +" \"file=sys.stderr)\");\n" +" if (res < 0) {\n" +" exit(1);\n" +" }\n" +"\n" +" /* ... ここに追加の設定コードを書く ... */\n" +"\n" +" status = _Py_InitializeMain();\n" +" if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +" }\n" +"}" #: ../../c-api/init_config.rst:1183 msgid "main()" diff --git a/c-api/interp-lifecycle.po b/c-api/interp-lifecycle.po index a164e237a..85aa5bc57 100644 --- a/c-api/interp-lifecycle.po +++ b/c-api/interp-lifecycle.po @@ -17,50 +17,49 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/interp-lifecycle.rst:6 msgid "Interpreter initialization and finalization" msgstr "インタープリタの初期化と終了処理" -#: ../../c-api/interp-lifecycle.rst:8 msgid "" "See :ref:`Python Initialization Configuration ` for details on " "how to configure the interpreter prior to initialization." msgstr "" +"初期化前にインタープリタを設定する方法の詳細は、:ref:`Python の初期化設定 " +"` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:14 msgid "Before Python initialization" -msgstr "" +msgstr "Python の初期化前" -#: ../../c-api/interp-lifecycle.rst:16 msgid "" "In an application embedding Python, the :c:func:`Py_Initialize` function " "must be called before using any other Python/C API functions; with the " "exception of a few functions and the :ref:`global configuration variables " "`." msgstr "" +"Python を組み込むアプリケーションでは、一部の関数と :ref:`グローバルな設定変" +"数 ` を除き、ほかの Python/C API を使う前に :c:func:" +"`Py_Initialize` を呼び出さなければなりません。" #: ../../c-api/interp-lifecycle.rst:21 msgid "" "The following functions can be safely called before Python is initialized:" msgstr "次の関数は Python の初期化の前でも安全に呼び出せます:" -#: ../../c-api/interp-lifecycle.rst:23 msgid "Functions that initialize the interpreter:" -msgstr "" +msgstr "インタープリタを初期化する関数:" -#: ../../c-api/interp-lifecycle.rst:25 msgid ":c:func:`Py_Initialize`" -msgstr "" +msgstr ":c:func:`Py_Initialize`" -#: ../../c-api/interp-lifecycle.rst:26 msgid ":c:func:`Py_InitializeEx`" -msgstr "" +msgstr ":c:func:`Py_InitializeEx`" #: ../../c-api/interp-lifecycle.rst:27 msgid ":c:func:`Py_InitializeFromConfig`" @@ -70,13 +69,11 @@ msgstr ":c:func:`Py_InitializeFromConfig`" msgid ":c:func:`Py_BytesMain`" msgstr ":c:func:`Py_BytesMain`" -#: ../../c-api/interp-lifecycle.rst:29 msgid ":c:func:`Py_Main`" -msgstr "" +msgstr ":c:func:`Py_Main`" -#: ../../c-api/interp-lifecycle.rst:30 msgid "the runtime pre-initialization functions covered in :ref:`init-config`" -msgstr "" +msgstr ":ref:`init-config` で説明するランタイムの事前初期化関数" #: ../../c-api/interp-lifecycle.rst:32 msgid "Configuration functions:" @@ -90,9 +87,8 @@ msgstr ":c:func:`PyImport_AppendInittab`" msgid ":c:func:`PyImport_ExtendInittab`" msgstr ":c:func:`PyImport_ExtendInittab`" -#: ../../c-api/interp-lifecycle.rst:36 msgid ":c:func:`!PyInitFrozenExtensions`" -msgstr "" +msgstr ":c:func:`!PyInitFrozenExtensions`" #: ../../c-api/interp-lifecycle.rst:37 msgid ":c:func:`PyMem_SetAllocator`" @@ -114,9 +110,8 @@ msgstr ":c:func:`Py_SetProgramName`" msgid ":c:func:`Py_SetPythonHome`" msgstr ":c:func:`Py_SetPythonHome`" -#: ../../c-api/interp-lifecycle.rst:42 msgid "the configuration functions covered in :ref:`init-config`" -msgstr "" +msgstr ":ref:`init-config` で説明する設定関数" #: ../../c-api/interp-lifecycle.rst:44 msgid "Informative functions:" @@ -162,10 +157,9 @@ msgstr "ユーティリティ:" msgid ":c:func:`Py_DecodeLocale`" msgstr ":c:func:`Py_DecodeLocale`" -#: ../../c-api/interp-lifecycle.rst:59 msgid "" "the status reporting and utility functions covered in :ref:`init-config`" -msgstr "" +msgstr ":ref:`init-config` で説明する状態の報告とユーティリティの関数" #: ../../c-api/interp-lifecycle.rst:61 msgid "Memory allocators:" @@ -187,25 +181,24 @@ msgstr ":c:func:`PyMem_RawCalloc`" msgid ":c:func:`PyMem_RawFree`" msgstr ":c:func:`PyMem_RawFree`" -#: ../../c-api/interp-lifecycle.rst:68 msgid "Synchronization:" -msgstr "" +msgstr "同期:" -#: ../../c-api/interp-lifecycle.rst:70 msgid ":c:func:`PyMutex_Lock`" -msgstr "" +msgstr ":c:func:`PyMutex_Lock`" -#: ../../c-api/interp-lifecycle.rst:71 msgid ":c:func:`PyMutex_Unlock`" -msgstr "" +msgstr ":c:func:`PyMutex_Unlock`" -#: ../../c-api/interp-lifecycle.rst:75 msgid "" "Despite their apparent similarity to some of the functions listed above, the " "following functions **should not be called** before the interpreter has been " "initialized: :c:func:`Py_EncodeLocale`, :c:func:`PyEval_InitThreads`, and :c:" "func:`Py_RunMain`." msgstr "" +"上に挙げた関数の一部と似ていても、:c:func:`Py_EncodeLocale`、:c:func:" +"`PyEval_InitThreads`、:c:func:`Py_RunMain` は、インタープリタの初期化前に **" +"呼び出してはなりません**。" #: ../../c-api/interp-lifecycle.rst:84 msgid "Global configuration variables" @@ -234,12 +227,14 @@ msgstr "" "例えば、 ``-b`` では :c:data:`Py_BytesWarningFlag` が 1 に設定され、 ``-bb`` " "では :c:data:`Py_BytesWarningFlag` が 2 に設定されます。" -#: ../../c-api/interp-lifecycle.rst:97 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "bytes_warning` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.bytes_warning` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:101 msgid "" @@ -255,12 +250,14 @@ msgstr "" msgid "Set by the :option:`-b` option." msgstr ":option:`-b` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:112 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "parser_debug` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.parser_debug` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:116 msgid "" @@ -276,12 +273,14 @@ msgid "" "variable." msgstr ":option:`-d` オプションと :envvar:`PYTHONDEBUG` 環境変数で設定します。" -#: ../../c-api/interp-lifecycle.rst:127 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "write_bytecode` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.write_bytecode` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:131 msgid "" @@ -299,12 +298,14 @@ msgstr "" ":option:`-B` オプションと :envvar:`PYTHONDONTWRITEBYTECODE` 環境変数で設定し" "ます。" -#: ../../c-api/interp-lifecycle.rst:142 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "pathconfig_warnings` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.pathconfig_warnings` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:146 msgid "Private flag used by ``_freeze_module`` and ``frozenmain`` programs." @@ -312,12 +313,15 @@ msgstr "" "``_freeze_module`` プログラムと ``frozenmain`` プログラムが使用する非公開フラ" "グです。" -#: ../../c-api/interp-lifecycle.rst:153 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "hash_seed` and :c:member:`PyConfig.use_hash_seed` should be used instead, " "see :ref:`Python Initialization Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.hash_seed` と :c:member:`PyConfig." +"use_hash_seed` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:158 msgid "" @@ -335,39 +339,43 @@ msgstr "" "フラグがゼロでない場合、 :envvar:`PYTHONHASHSEED` 環境変数を読みシークレット" "ハッシュシードを初期化します。" -#: ../../c-api/interp-lifecycle.rst:169 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "use_environment` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.use_environment` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:173 msgid "" "Ignore all :envvar:`!PYTHON*` environment variables, e.g. :envvar:" "`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set." msgstr "" +":envvar:`PYTHONPATH` や :envvar:`PYTHONHOME` など、設定されているすべての :" +"envvar:`!PYTHON*` 環境変数を無視します。" #: ../../c-api/interp-lifecycle.rst:176 msgid "Set by the :option:`-E` and :option:`-I` options." msgstr ":option:`-E` オプションと :option:`-I` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:183 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "inspect` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.inspect` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:187 msgid "" "When a script is passed as first argument or the :option:`-c` option is " "used, enter interactive mode after executing the script or the command, even " "when :data:`sys.stdin` does not appear to be a terminal." msgstr "" -"最初の引数にスクリプトが指定されたときや :option:`-c` オプションが利用された" -"際に、 :data:`sys.stdin` がターミナルに出力されないときであっても、スクリプト" -"かコマンドを実行した後にインタラクティブモードに入ります。" +"最初の引数にスクリプトを指定した場合や :option:`-c` オプションを使った場合" +"は、:data:`sys.stdin` が端末でなくても、スクリプトやコマンドの実行後に対話" +"モードに入ります。" #: ../../c-api/interp-lifecycle.rst:191 msgid "" @@ -376,23 +384,27 @@ msgid "" msgstr "" ":option:`-i` オプションと :envvar:`PYTHONINSPECT` 環境変数で設定します。" -#: ../../c-api/interp-lifecycle.rst:199 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "interactive` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.interactive` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:203 msgid "Set by the :option:`-i` option." msgstr ":option:`-i` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:210 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "isolated` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.isolated` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:214 msgid "" @@ -407,19 +419,25 @@ msgstr "" msgid "Set by the :option:`-I` option." msgstr ":option:`-I` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:226 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyPreConfig." "legacy_windows_fs_encoding` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyPreConfig.legacy_windows_fs_encoding` を設定してくださ" +"い。\n" +":ref:`Python の初期化設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:230 msgid "" "If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error " "handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler, " "for the :term:`filesystem encoding and error handler`." msgstr "" +"フラグがゼロ以外の場合は、:term:`ファイルシステムエンコーディングとエラーハン" +"ドラー ` として、UTF-8 と " +"``surrogatepass`` エラーハンドラーの代わりに、``mbcs`` と ``replace`` エラー" +"ハンドラーを使います。" #: ../../c-api/interp-lifecycle.rst:234 msgid "" @@ -433,22 +451,24 @@ msgstr "" msgid "See :pep:`529` for more details." msgstr "より詳しくは :pep:`529` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:239 ../../c-api/interp-lifecycle.rst:258 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../c-api/interp-lifecycle.rst:246 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "legacy_windows_stdio` should be used instead, see :ref:`Python " "Initialization Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.legacy_windows_stdio` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:250 msgid "" "If the flag is non-zero, use :class:`io.FileIO` instead of :class:`!io." "_WindowsConsoleIO` for :mod:`sys` standard streams." msgstr "" +"フラグがゼロ以外の場合は、:mod:`sys` の標準ストリームに :class:`!io." +"_WindowsConsoleIO` の代わりに :class:`io.FileIO` を使います。" #: ../../c-api/interp-lifecycle.rst:253 msgid "" @@ -462,12 +482,14 @@ msgstr "" msgid "See :pep:`528` for more details." msgstr "より詳しくは :pep:`528` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:265 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "site_import` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.site_import` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:269 msgid "" @@ -485,12 +507,14 @@ msgstr "" msgid "Set by the :option:`-S` option." msgstr ":option:`-S` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:281 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "user_site_directory` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.user_site_directory` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:285 msgid "" @@ -508,12 +532,14 @@ msgstr "" ":option:`-s` オプション、 :option:`-I` 、 :envvar:`PYTHONNOUSERSITE` 環境変数" "で設定します。" -#: ../../c-api/interp-lifecycle.rst:296 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "optimization_level` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.optimization_level` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:300 msgid "" @@ -522,12 +548,14 @@ msgid "" msgstr "" ":option:`-O` オプションと :envvar:`PYTHONOPTIMIZE` 環境変数で設定します。" -#: ../../c-api/interp-lifecycle.rst:308 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "quiet` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.quiet` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:312 msgid "" @@ -539,12 +567,14 @@ msgstr "" msgid "Set by the :option:`-q` option." msgstr ":option:`-q` オプションで設定します。" -#: ../../c-api/interp-lifecycle.rst:323 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "buffered_stdio` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.buffered_stdio` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:327 msgid "Force the stdout and stderr streams to be unbuffered." @@ -557,12 +587,14 @@ msgid "" msgstr "" ":option:`-u` オプションと :envvar:`PYTHONUNBUFFERED` 環境変数で設定します。" -#: ../../c-api/interp-lifecycle.rst:337 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "verbose` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.verbose` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:341 msgid "" @@ -588,12 +620,16 @@ msgstr "" msgid "Initializing and finalizing the interpreter" msgstr "インタープリタの初期化と終了処理" -#: ../../c-api/interp-lifecycle.rst:367 msgid "" "Initialize the Python interpreter. In an application embedding Python, this " "should be called before using any other Python/C API functions; see :ref:" "`Before Python Initialization ` for the few exceptions." msgstr "" +"Python インタープリタを初期化します。\n" +"Python を組み込むアプリケーションでは、ほかの Python/C API 関数を使う前に呼び" +"出す必要があります。\n" +"少数の例外については :ref:`Python の初期化前 ` を参照してくだ" +"さい。" #: ../../c-api/interp-lifecycle.rst:371 msgid "" @@ -606,11 +642,12 @@ msgid "" "it is a fatal error if the initialization fails." msgstr "" -#: ../../c-api/interp-lifecycle.rst:379 ../../c-api/interp-lifecycle.rst:393 msgid "" "Use :c:func:`Py_InitializeFromConfig` to customize the :ref:`Python " "Initialization Configuration `." msgstr "" +":ref:`Python の初期化設定 ` をカスタマイズするには、:c:func:" +"`Py_InitializeFromConfig` を使ってください。" #: ../../c-api/interp-lifecycle.rst:383 msgid "" @@ -621,26 +658,33 @@ msgstr "" "が、これはその C ランタイムを使っているコンソールでの Python 以外の使い勝手に" "も影響を及ぼします。" -#: ../../c-api/interp-lifecycle.rst:389 msgid "" "This function works like :c:func:`Py_Initialize` if *initsigs* is ``1``. If " "*initsigs* is ``0``, it skips initialization registration of signal " "handlers, which may be useful when CPython is embedded as part of a larger " "application." msgstr "" +"*initsigs* が ``1`` の場合は :c:func:`Py_Initialize` と同じように動作しま" +"す。\n" +"*initsigs* が ``0`` の場合は、シグナルハンドラーの初期化と登録を省略しま" +"す。\n" +"これは、CPython をより大きなアプリケーションに組み込む場合に有用なことがあり" +"ます。" -#: ../../c-api/interp-lifecycle.rst:399 msgid "" "Initialize Python from *config* configuration, as described in :ref:`init-" "from-config`." msgstr "" +":ref:`init-from-config` で説明するように、*config* の設定で Python を初期化し" +"ます。" -#: ../../c-api/interp-lifecycle.rst:402 msgid "" "See the :ref:`init-config` section for details on pre-initializing the " "interpreter, populating the runtime configuration structure, and querying " "the returned status structure." msgstr "" +"インタープリタの事前初期化、ランタイム設定構造体への値の設定、返される状態構" +"造体の調べ方については、:ref:`init-config` を参照してください。" #: ../../c-api/interp-lifecycle.rst:409 msgid "" @@ -652,20 +696,23 @@ msgstr "" "します。:c:func:`Py_FinalizeEx` を呼び出した後は、:c:func:`Py_Initialize` を" "再び呼び出すまで、この関数は偽を返します。" -#: ../../c-api/interp-lifecycle.rst:413 msgid "" "This function no longer returns true until initialization has fully " "completed, including import of the :mod:`site` module. Previously it could " "return true while :c:func:`Py_Initialize` was still running." msgstr "" +":mod:`site` モジュールのインポートを含め、初期化が完全に終了するまでは真を返" +"さなくなりました。\n" +"以前は、:c:func:`Py_Initialize` の実行中に真を返す場合がありました。" -#: ../../c-api/interp-lifecycle.rst:421 msgid "" "Return true (non-zero) if the main Python interpreter is :term:`shutting " "down `. Return false (zero) otherwise." msgstr "" +"メインの Python インタープリタが :term:`終了処理中 ` な" +"ら真 (ゼロ以外) を返します。\n" +"それ以外の場合は偽 (ゼロ) を返します。" -#: ../../c-api/interp-lifecycle.rst:429 msgid "" "Undo all initializations made by :c:func:`Py_Initialize` and subsequent use " "of Python/C API functions, and destroy all sub-interpreters (see :c:func:" @@ -673,22 +720,33 @@ msgid "" "last call to :c:func:`Py_Initialize`. This is a no-op when called for a " "second time (without calling :c:func:`Py_Initialize` again first)." msgstr "" +":c:func:`Py_Initialize` と、その後の Python/C API 関数の使用による初期化をす" +"べて元に戻します。\n" +"さらに、最後に :c:func:`Py_Initialize` を呼び出してから作成され、まだ破棄され" +"ていないサブインタープリタをすべて破棄します (以下の :c:func:" +"`Py_NewInterpreter` を参照)。\n" +"再び :c:func:`Py_Initialize` を呼び出さずにもう一度呼び出しても、何も行いませ" +"ん。" -#: ../../c-api/interp-lifecycle.rst:435 msgid "" "Since this is the reverse of :c:func:`Py_Initialize`, it should be called in " "the same thread with the same interpreter active. That means the main " "thread and the main interpreter. This should never be called while :c:func:" "`Py_RunMain` is running." msgstr "" +":c:func:`Py_Initialize` の逆の処理なので、同じスレッドで同じインタープリタが" +"アクティブな状態で呼び出す必要があります。\n" +"つまり、メインスレッドとメインインタープリタです。\n" +":c:func:`Py_RunMain` の実行中には決して呼び出してはなりません。" -#: ../../c-api/interp-lifecycle.rst:440 msgid "" "Normally the return value is ``0``. If there were errors during finalization " "(flushing buffered data), ``-1`` is returned." msgstr "" +"通常の戻り値は ``0`` です。\n" +"終了処理中にバッファー内のデータの書き出しでエラーがあった場合は、``-1`` を返" +"します。" -#: ../../c-api/interp-lifecycle.rst:444 msgid "" "Note that Python will do a best effort at freeing all memory allocated by " "the Python interpreter. Therefore, any C-Extension should make sure to " @@ -696,6 +754,11 @@ msgid "" "them in subsequent calls to :c:func:`Py_Initialize`. Otherwise it could " "introduce vulnerabilities and incorrect behavior." msgstr "" +"Python は、Python インタープリタが確保したメモリをできる限り解放しようとしま" +"す。\n" +"そのため、C 拡張は、以前に確保したすべての PyObject を適切に後始末してから、" +"次の :c:func:`Py_Initialize` の呼び出しで使うようにしなければなりません。\n" +"そうしないと、脆弱性や不正な動作につながる可能性があります。" #: ../../c-api/interp-lifecycle.rst:450 msgid "" @@ -735,13 +798,12 @@ msgid "" "stdout and stderr files." msgstr "" -#: ../../c-api/interp-lifecycle.rst:474 msgid "" "Raises an :ref:`auditing event ` ``cpython." "_PySys_ClearAuditHooks`` with no arguments." msgstr "" "引数無しで :ref:`監査イベント ` ``cpython._PySys_ClearAuditHooks`` " -"を送出します。 " +"を送出します。" #: ../../c-api/interp-lifecycle.rst:481 msgid "" @@ -751,14 +813,15 @@ msgstr "" "この関数は :c:func:`Py_FinalizeEx` の後方互換性バージョンで、戻り値がありませ" "ん。" -#: ../../c-api/interp-lifecycle.rst:487 msgid "" "Similar to :c:func:`Py_Main` but *argv* is an array of bytes strings, " "allowing the calling application to delegate the text decoding step to the " "CPython runtime." msgstr "" +":c:func:`Py_Main` と同様ですが、*argv* はバイト文字列の配列です。\n" +"これにより、呼び出し元のアプリケーションは、テキストのデコードを CPython ラン" +"タイムに任せられます。" -#: ../../c-api/interp-lifecycle.rst:496 msgid "" "The main program for the standard interpreter, encapsulating a full " "initialization/finalization cycle, as well as additional behaviour to " @@ -766,15 +829,20 @@ msgid "" "line, and then executing ``__main__`` in accordance with :ref:`using-on-" "cmdline`." msgstr "" +"標準インタープリタのメインプログラムです。\n" +"初期化から終了処理までの一連の処理に加え、環境変数とコマンドラインから設定を" +"読み取り、:ref:`using-on-cmdline` に従って ``__main__`` を実行する処理をまと" +"めて行います。" -#: ../../c-api/interp-lifecycle.rst:502 msgid "" "This is made available for programs which wish to support the full CPython " "command line interface, rather than just embedding a Python runtime in a " "larger application." msgstr "" +"より大きなアプリケーションに Python ランタイムを組み込むだけでなく、CPython " +"の完全なコマンドラインインターフェースをサポートしたいプログラムのために提供" +"されています。" -#: ../../c-api/interp-lifecycle.rst:506 msgid "" "The *argc* and *argv* parameters are similar to those which are passed to a " "C program's :c:func:`main` function, except that the *argv* entries are " @@ -783,21 +851,29 @@ msgid "" "strings other than those passed in (however, the contents of the strings " "pointed to by the argument list are not modified)." msgstr "" +"*argc* と *argv* 引数は、C プログラムの :c:func:`main` 関数に渡すものに似てい" +"ますが、*argv* の各要素をあらかじめ :c:func:`Py_DecodeLocale` で ``wchar_t`` " +"に変換する点が異なります。\n" +"引数リストの各要素が、渡された文字列とは別の文字列を指すように変更される可能" +"性があることにも注意してください。\n" +"ただし、引数リストが指す文字列の内容は変更されません。" -#: ../../c-api/interp-lifecycle.rst:513 msgid "" "The return value is ``2`` if the argument list does not represent a valid " "Python command line, and otherwise the same as :c:func:`Py_RunMain`." msgstr "" +"引数リストが有効な Python コマンドラインを表していない場合は ``2`` を返し、そ" +"れ以外の場合は :c:func:`Py_RunMain` と同じ値を返します。" -#: ../../c-api/interp-lifecycle.rst:516 msgid "" "In terms of the CPython runtime configuration APIs documented in the :ref:" "`runtime configuration ` section (and without accounting for " "error handling), ``Py_Main`` is approximately equivalent to::" msgstr "" +":ref:`ランタイムの設定 ` の節で説明する CPython ランタイム設定 " +"API を使うと、エラー処理を除いて、``Py_Main`` はおおむね次の処理と等価で" +"す。 ::" -#: ../../c-api/interp-lifecycle.rst:520 msgid "" "PyConfig config;\n" "PyConfig_InitPythonConfig(&config);\n" @@ -807,8 +883,14 @@ msgid "" "\n" "Py_RunMain();" msgstr "" +"PyConfig config;\n" +"PyConfig_InitPythonConfig(&config);\n" +"PyConfig_SetArgv(&config, argc, argv);\n" +"Py_InitializeFromConfig(&config);\n" +"PyConfig_Clear(&config);\n" +"\n" +"Py_RunMain();" -#: ../../c-api/interp-lifecycle.rst:528 msgid "" "In normal usage, an embedding application will call this function *instead* " "of calling :c:func:`Py_Initialize`, :c:func:`Py_InitializeEx` or :c:func:" @@ -820,12 +902,19 @@ msgid "" "being modified after they have already been set once when the runtime was " "first initialized)." msgstr "" +"通常、Python を組み込むアプリケーションは、:c:func:`Py_Initialize`、:c:func:" +"`Py_InitializeEx`、:c:func:`Py_InitializeFromConfig` を直接呼び出す *代わりに" +"* この関数を呼び出します。\n" +"その場合、すべての設定はこのドキュメントのほかの箇所で説明されているとおりに" +"適用されます。\n" +"先にランタイム初期化 API を呼び出した *後で* この関数を呼び出す場合は、環境変" +"数とコマンドラインのどの設定が更新されるかはバージョンに依存します。\n" +"ランタイムの最初の初期化で一度設定した値を、後から正しく変更できるかどうかが" +"設定によって異なるためです。" -#: ../../c-api/interp-lifecycle.rst:541 msgid "Executes the main module in a fully configured CPython runtime." -msgstr "" +msgstr "設定が完了した CPython ランタイムで、メインモジュールを実行します。" -#: ../../c-api/interp-lifecycle.rst:543 msgid "" "Executes the command (:c:member:`PyConfig.run_command`), the script (:c:" "member:`PyConfig.run_filename`) or the module (:c:member:`PyConfig." @@ -833,14 +922,22 @@ msgid "" "of these values are set, runs the interactive Python prompt (REPL) using the " "``__main__`` module's global namespace." msgstr "" +"コマンドラインまたは設定で指定された、コマンド (:c:member:`PyConfig." +"run_command`)、スクリプト (:c:member:`PyConfig.run_filename`)、またはモジュー" +"ル (:c:member:`PyConfig.run_module`) を実行します。\n" +"どの値も設定されていなければ、``__main__`` モジュールのグローバル名前空間を" +"使って、Python の対話プロンプト (REPL) を実行します。" -#: ../../c-api/interp-lifecycle.rst:549 msgid "" "If :c:member:`PyConfig.inspect` is not set (the default), the return value " "will be ``0`` if the interpreter exits normally (that is, without raising an " "exception), the exit status of an unhandled :exc:`SystemExit`, or ``1`` for " "any other unhandled exception." msgstr "" +":c:member:`PyConfig.inspect` が設定されていない場合 (デフォルト)、インタープ" +"リタが例外を送出せず正常終了すれば ``0`` を返します。\n" +"未処理の :exc:`SystemExit` があればその終了ステータスを、それ以外の未処理の例" +"外があれば ``1`` を返します。" #: ../../c-api/interp-lifecycle.rst:554 msgid "" @@ -853,34 +950,35 @@ msgid "" "status of a :exc:`SystemExit`, as specified above." msgstr "" -#: ../../c-api/interp-lifecycle.rst:562 msgid "" "This function always finalizes the Python interpreter before it returns." -msgstr "" +msgstr "この関数は、戻る前に必ず Python インタープリタの終了処理を行います。" -#: ../../c-api/interp-lifecycle.rst:564 msgid "" "See :ref:`Python Configuration ` for an example of a " "customized Python that always runs in isolated mode using :c:func:" "`Py_RunMain`." msgstr "" +":c:func:`Py_RunMain` を使って常に隔離モードで実行するようカスタマイズした " +"Python の例は、:ref:`Python の設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:570 msgid "" "Register an :mod:`atexit` callback for the target interpreter *interp*. This " "is similar to :c:func:`Py_AtExit`, but takes an explicit interpreter and " "data pointer for the callback." msgstr "" +"対象のインタープリタ *interp* に :mod:`atexit` コールバックを登録します。\n" +":c:func:`Py_AtExit` と似ていますが、インタープリタと、コールバックに渡すデー" +"タポインターを明示的に受け取ります。" -#: ../../c-api/interp-lifecycle.rst:574 msgid "There must be an :term:`attached thread state` for *interp*." msgstr "" +"*interp* の :term:`スレッド状態がアタッチされていなければなりません " +"`。" -#: ../../c-api/interp-lifecycle.rst:582 msgid "Cautions regarding interpreter finalization" -msgstr "" +msgstr "インタープリタの終了処理に関する注意" -#: ../../c-api/interp-lifecycle.rst:584 msgid "" "In the late stage of :term:`interpreter shutdown`, after attempting to wait " "for non-daemon threads to exit (though this can be interrupted by :class:" @@ -890,8 +988,16 @@ msgid "" "(the thread that initiated finalization; this is typically the main thread) " "is allowed to :term:`attach ` a thread state." msgstr "" +":term:`インタープリタの終了処理 ` の後半では、非デーモ" +"ンスレッドの終了を待つ処理と :mod:`atexit` 関数の実行を終えた後、ランタイムが" +"終了処理中と記録されます。\n" +"ただし、スレッドの終了を待つ処理は :class:`KeyboardInterrupt` で中断される場" +"合があります。\n" +"終了処理中と記録されると、:c:func:`Py_IsFinalizing` と :func:`sys." +"is_finalizing` が真を返します。\n" +"この時点では、終了処理を開始したスレッド (通常はメインスレッド) だけが、ス" +"レッド状態を :term:`アタッチ ` できます。" -#: ../../c-api/interp-lifecycle.rst:592 msgid "" "Other threads that attempt to attach during finalization, either explicitly " "(such as via :c:func:`PyThreadState_Ensure` or :c:macro:" @@ -901,36 +1007,45 @@ msgid "" "permanently blocked while holding a lock, meaning that the finalization " "thread can never acquire that lock." msgstr "" +"終了処理中にほかのスレッドがアタッチしようとすると、**永久にブロックされた状" +"態** になります。\n" +"これは、:c:func:`PyThreadState_Ensure` や :c:macro:`Py_END_ALLOW_THREADS` な" +"どで明示的にアタッチする場合も、バイトコード命令の間などで暗黙にアタッチする" +"場合も同じです。\n" +"通常は問題ありませんが、デッドロックを引き起こすことがあります。\n" +"例えば、ロックを保持したまま永久にブロックされると、終了処理を行うスレッドが" +"そのロックを取得できなくなります。" -#: ../../c-api/interp-lifecycle.rst:600 msgid "" "Prior to CPython 3.13, the thread would exit instead of hanging, which led " "to other issues (see the warning note at :c:func:`PyThread_exit_thread`)." msgstr "" +"CPython 3.13 より前は、停止したままになる代わりにスレッドが終了していました" +"が、別の問題を引き起こしていました (:c:func:`PyThread_exit_thread` の警告を参" +"照)。" -#: ../../c-api/interp-lifecycle.rst:604 msgid "" "Gross? Yes. Starting in Python 3.15, there are a number of C APIs that make " "it possible to avoid these issues by temporarily preventing finalization:" msgstr "" +"望ましくない動作ですが、Python 3.15 以降では、一時的に終了処理を防ぐことで、" +"これらの問題を避けるための C API がいくつか用意されています。" -#: ../../c-api/interp-lifecycle.rst:611 msgid "" ":pep:`788` explains the design, motivation and rationale for these APIs." -msgstr "" +msgstr "これらの API の設計、動機、根拠は :pep:`788` で説明されています。" -#: ../../c-api/interp-lifecycle.rst:616 msgid "An opaque interpreter guard structure." -msgstr "" +msgstr "インタープリタのガードを表す不透明な構造体です。" -#: ../../c-api/interp-lifecycle.rst:618 msgid "" "By holding an interpreter guard, the caller can ensure that the interpreter " "will not finalize until the guard is closed (through :c:func:" "`PyInterpreterGuard_Close`)." msgstr "" +"インタープリタのガードを保持すると、:c:func:`PyInterpreterGuard_Close` でガー" +"ドを閉じるまで、そのインタープリタの終了処理が行われないことを保証できます。" -#: ../../c-api/interp-lifecycle.rst:622 msgid "" "When a guard is held, a thread attempting to finalize the interpreter will " "block until the guard is closed before starting finalization. After " @@ -938,26 +1053,35 @@ msgid "" "that interpreter. This means that if you forget to close an interpreter " "guard, the process will **permanently hang** during finalization!" msgstr "" +"ガードが保持されている場合、インタープリタの終了処理を行おうとするスレッド" +"は、ガードが閉じられるまでブロックしてから終了処理を開始します。\n" +"終了処理が始まると、スレッドはそのインタープリタのガードを二度と取得できなく" +"なります。\n" +"つまり、インタープリタのガードを閉じ忘れると、プロセスは終了処理で **永久に停" +"止したままになります**。" -#: ../../c-api/interp-lifecycle.rst:629 msgid "" "Holding a guard for an interpreter is similar to holding a :term:`strong " "reference` to a Python object, except finalization does not happen " "automatically after all guards are released: it requires an explicit :c:func:" "`Py_EndInterpreter` call." msgstr "" +"インタープリタのガードを保持することは、Python オブジェクトへの :term:`強参" +"照 ` を保持することに似ています。\n" +"ただし、すべてのガードを解放しても終了処理は自動的には行われず、明示的に :c:" +"func:`Py_EndInterpreter` を呼び出す必要があります。" -#: ../../c-api/interp-lifecycle.rst:639 msgid "" "Create a finalization guard for the current interpreter. This will prevent " "finalization until the guard is closed." msgstr "" +"現在のインタープリタの終了処理を防ぐガードを作成します。\n" +"ガードを閉じるまで終了処理を防ぎます。" #: ../../c-api/interp-lifecycle.rst:642 msgid "For example:" msgstr "例えば:" -#: ../../c-api/interp-lifecycle.rst:644 msgid "" "// Temporarily prevent finalization.\n" "PyInterpreterGuard *guard = PyInterpreterGuard_FromCurrent();\n" @@ -975,131 +1099,167 @@ msgid "" "// allowed to finalize again.\n" "PyInterpreterGuard_Close(guard);" msgstr "" +"// 一時的に終了処理を防ぐ。\n" +"PyInterpreterGuard *guard = PyInterpreterGuard_FromCurrent();\n" +"if (guard == NULL) {\n" +" // 終了処理がすでに始まっているか、メモリが不足している。\n" +" return NULL;\n" +"}\n" +"\n" +"Py_BEGIN_ALLOW_THREADS;\n" +"// ここで重要な処理を行う。\n" +"// 例えば、終了処理を行うスレッドも取得しうるロックを安全に取得できる。\n" +"Py_END_ALLOW_THREADS;\n" +"\n" +"// 重要な処理が終わったので、インタープリタの終了処理を再び許可する。\n" +"PyInterpreterGuard_Close(guard);" -#: ../../c-api/interp-lifecycle.rst:662 msgid "" "On success, this function returns a guard for the current interpreter; on " "failure, it returns ``NULL`` with an exception set." msgstr "" +"成功時は現在のインタープリタのガードを返します。\n" +"失敗時は例外を設定して ``NULL`` を返します。" -#: ../../c-api/interp-lifecycle.rst:665 msgid "" "This function will fail only if the current interpreter has already started " "finalizing, or if the process is out of memory." msgstr "" +"失敗するのは、現在のインタープリタがすでに終了処理を開始している場合と、プロ" +"セスのメモリが不足している場合だけです。" -#: ../../c-api/interp-lifecycle.rst:668 msgid "" "The guard pointer returned by this function must be eventually closed with :" "c:func:`PyInterpreterGuard_Close`; failing to do so will result in the " "Python process infinitely hanging." msgstr "" +"この関数が返したガードのポインターは、必ず :c:func:" +"`PyInterpreterGuard_Close` で閉じなければなりません。\n" +"閉じないと、Python プロセスが無期限に停止したままになります。" -#: ../../c-api/interp-lifecycle.rst:672 ../../c-api/interp-lifecycle.rst:739 msgid "The caller must hold an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`スレッド状態がアタッチされていなければなりません " +"`。" -#: ../../c-api/interp-lifecycle.rst:679 msgid "Create a finalization guard for an interpreter through a view." -msgstr "" +msgstr "ビューを通じて、インタープリタの終了処理を防ぐガードを作成します。" -#: ../../c-api/interp-lifecycle.rst:681 msgid "" "On success, this function returns a guard to the interpreter represented by " "*view*. The view is still valid after calling this function. The guard must " "eventually be closed with :c:func:`PyInterpreterGuard_Close`." msgstr "" +"成功時は、*view* が表すインタープリタのガードを返します。\n" +"呼び出し後もビューは有効です。\n" +"ガードは必ず :c:func:`PyInterpreterGuard_Close` で閉じなければなりません。" -#: ../../c-api/interp-lifecycle.rst:686 msgid "" "If the interpreter no longer exists, is already finalizing, or out of " "memory, then this function returns ``NULL`` without setting an exception." msgstr "" +"インタープリタがすでに存在しない場合、終了処理中の場合、またはメモリが不足し" +"ている場合は、例外を設定せずに ``NULL`` を返します。" -#: ../../c-api/interp-lifecycle.rst:689 ../../c-api/interp-lifecycle.rst:775 msgid "The caller does not need to hold an :term:`attached thread state`." msgstr "" +"呼び出し元に :term:`スレッド状態がアタッチされている ` 必要はありません。" -#: ../../c-api/interp-lifecycle.rst:696 msgid "" "Close an interpreter guard, allowing the interpreter to start finalization " "if no other guards remain. If an interpreter guard is never closed, the " "interpreter will infinitely wait when trying to enter finalization!" msgstr "" +"インタープリタのガードを閉じます。\n" +"ほかのガードが残っていなければ、インタープリタが終了処理を開始できるようにな" +"ります。\n" +"ガードを閉じないままにすると、インタープリタは終了処理を開始しようとしたとき" +"に無期限に待ち続けます。" -#: ../../c-api/interp-lifecycle.rst:701 msgid "" "After an interpreter guard is closed, it may not be used in :c:func:" "`PyThreadState_Ensure`. Doing so will result in undefined behavior." msgstr "" +"インタープリタのガードを閉じた後は、:c:func:`PyThreadState_Ensure` に使っては" +"なりません。\n" +"使った場合の動作は未定義です。" -#: ../../c-api/interp-lifecycle.rst:705 ../../c-api/interp-lifecycle.rst:752 msgid "" "This function cannot fail, and the caller doesn't need to hold an :term:" "`attached thread state`." msgstr "" +"この関数は失敗せず、呼び出し元に :term:`スレッド状態がアタッチされている " +"` 必要もありません。" -#: ../../c-api/interp-lifecycle.rst:714 msgid "Interpreter views" -msgstr "" +msgstr "インタープリタのビュー" -#: ../../c-api/interp-lifecycle.rst:716 msgid "" "In some cases, it may be necessary to access an interpreter that may have " "been deleted. This can be done using interpreter views." msgstr "" +"すでに削除されている可能性のあるインタープリタにアクセスする必要がある場合が" +"あります。\n" +"インタープリタのビューを使うことで、これを行えます。" -#: ../../c-api/interp-lifecycle.rst:721 msgid "An opaque view of an interpreter." -msgstr "" +msgstr "インタープリタの不透明なビューです。" -#: ../../c-api/interp-lifecycle.rst:723 msgid "" "This is a thread-safe way to access an interpreter that may have be " "finalizing or already destroyed." msgstr "" +"終了処理中、またはすでに破棄されている可能性があるインタープリタに、スレッド" +"セーフにアクセスする手段です。" -#: ../../c-api/interp-lifecycle.rst:731 msgid "Create a view to the current interpreter." -msgstr "" +msgstr "現在のインタープリタのビューを作成します。" -#: ../../c-api/interp-lifecycle.rst:733 msgid "" "This function is generally meant to be used alongside :c:func:" "`PyInterpreterGuard_FromView` or :c:func:`PyThreadState_EnsureFromView`." msgstr "" +"通常、:c:func:`PyInterpreterGuard_FromView` または :c:func:" +"`PyThreadState_EnsureFromView` と組み合わせて使うための関数です。" -#: ../../c-api/interp-lifecycle.rst:736 msgid "" "On success, this function returns a view to the current interpreter; on " "failure, it returns ``NULL`` with an exception set." msgstr "" +"成功時は現在のインタープリタのビューを返します。\n" +"失敗時は例外を設定して ``NULL`` を返します。" -#: ../../c-api/interp-lifecycle.rst:746 msgid "Close an interpreter view." -msgstr "" +msgstr "インタープリタのビューを閉じます。" -#: ../../c-api/interp-lifecycle.rst:748 msgid "" "If an interpreter view is never closed, the view's memory will never be " "freed, but there are no other consequences. (In contrast, forgetting to " "close a guard will infinitely hang the main thread during finalization.)" msgstr "" +"インタープリタのビューを閉じないままにすると、ビューのメモリが解放されなくな" +"りますが、それ以外の影響はありません。\n" +"一方、ガードを閉じ忘れると、終了処理中にメインスレッドが無期限に停止したまま" +"になります。" -#: ../../c-api/interp-lifecycle.rst:760 msgid "" "Create a view for the main interpreter (the first and default interpreter in " "a Python process; see :c:func:`PyInterpreterState_Main`)." msgstr "" +"メインインタープリタのビューを作成します。\n" +"メインインタープリタは Python プロセスで最初に作成される、デフォルトのイン" +"タープリタです (:c:func:`PyInterpreterState_Main` を参照)。" -#: ../../c-api/interp-lifecycle.rst:764 msgid "" "On success, this function returns a view to the main interpreter; on " "failure, it returns ``NULL`` without an exception set. Failure indicates " "that the process is out of memory." msgstr "" +"成功時はメインインタープリタのビューを返します。\n" +"失敗時は例外を設定せずに ``NULL`` を返します。\n" +"失敗は、プロセスのメモリ不足を示します。" -#: ../../c-api/interp-lifecycle.rst:768 msgid "" "Use this function when an interpreter pointer or view cannot be supplied by " "the caller, such as when a native threading library does not provide a " @@ -1108,19 +1268,26 @@ msgid "" "func:`PyInterpreterView_FromCurrent` so the guard tracks the calling " "interpreter rather than the main one." msgstr "" +"ネイティブのスレッドライブラリに、:c:type:`PyInterpreterGuard` や :c:type:" +"`PyInterpreterView` を渡せる ``void *arg`` 引数がない場合など、呼び出し元がイ" +"ンタープリタのポインターやビューを渡せないときに使ってください。\n" +"サブインタープリタに対応するコードでは、メインインタープリタではなく呼び出し" +"元のインタープリタをガードで追跡できるよう、:c:func:" +"`PyInterpreterView_FromCurrent` を優先してください。" #: ../../c-api/interp-lifecycle.rst:781 msgid "Process-wide parameters" msgstr "プロセスワイドのパラメータ" -#: ../../c-api/interp-lifecycle.rst:789 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "program_name` should be used instead, see :ref:`Python Initialization " "Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.program_name` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" -#: ../../c-api/interp-lifecycle.rst:793 msgid "" "This function should be called before :c:func:`Py_Initialize` is called for " "the first time, if it is called at all. It tells the interpreter the value " @@ -1132,13 +1299,25 @@ msgid "" "will not change for the duration of the program's execution. No code in the " "Python interpreter will change the contents of this storage." msgstr "" +"この関数を使う場合は、最初の :c:func:`Py_Initialize` の呼び出しより前に呼び出" +"してください。\n" +"プログラムの :c:func:`main` 関数に渡された ``argv[0]`` 引数をワイド文字に変換" +"した値を、インタープリタに知らせます。\n" +"以下に示す一部の関数は、これを使ってインタープリタの実行ファイルからの相対位" +"置にある Python ランタイムライブラリを探します。\n" +"デフォルト値は ``'python'`` です。\n" +"引数は、静的な記憶領域に置かれた、ゼロ終端のワイド文字列を指す必要がありま" +"す。\n" +"その内容は、プログラムの実行中に変わってはなりません。\n" +"Python インタープリタのコードが、この記憶領域の内容を変更することはありませ" +"ん。" -#: ../../c-api/interp-lifecycle.rst:804 ../../c-api/interp-lifecycle.rst:912 -#: ../../c-api/interp-lifecycle.rst:945 ../../c-api/interp-lifecycle.rst:971 msgid "" "Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:" "`wchar_t*` string." msgstr "" +"バイト文字列をデコードして :c:expr:`wchar_t*` 文字列を取得するには、:c:func:" +"`Py_DecodeLocale` を使ってください。" #: ../../c-api/interp-lifecycle.rst:812 msgid "" @@ -1148,9 +1327,8 @@ msgstr "" "Python インタプリタのバージョンを返します。バージョンは、次のような形式の文字" "列です ::" -#: ../../c-api/interp-lifecycle.rst:815 msgid "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" -msgstr "" +msgstr "\"3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \\n[GCC 4.2.3]\"" #: ../../c-api/interp-lifecycle.rst:819 msgid "" @@ -1166,9 +1344,8 @@ msgstr "" "変更できません。この値は Python コードからは :data:`sys.version` として利用で" "きます。" -#: ../../c-api/interp-lifecycle.rst:824 msgid "See also the :c:var:`Py_Version` constant." -msgstr "" +msgstr ":c:var:`Py_Version` 定数も参照してください。" #: ../../c-api/interp-lifecycle.rst:831 msgid "" @@ -1216,9 +1393,8 @@ msgstr "" "現在使っているバージョンの Python をビルドする際に用いたコンパイラを示す文字" "列を、角括弧で囲った文字列を返します。例えば::" -#: ../../c-api/interp-lifecycle.rst:857 msgid "\"[GCC 2.7.2.2]\"" -msgstr "" +msgstr "\"[GCC 2.7.2.2]\"" #: ../../c-api/interp-lifecycle.rst:861 ../../c-api/interp-lifecycle.rst:875 msgid "" @@ -1230,23 +1406,27 @@ msgstr "" "を変更できません。この値は Python コードからは ``sys.version`` の一部として取" "り出せます。" -#: ../../c-api/interp-lifecycle.rst:868 msgid "" "Return information about the sequence number and build date and time of the " "current Python interpreter instance, for example ::" msgstr "" +"現在の Python インタープリタのビルド番号と、ビルドした日時の情報を返しま" +"す。\n" +"例えば次のような値です。 ::" -#: ../../c-api/interp-lifecycle.rst:871 msgid "\"#67, Aug 1 1997, 22:34:28\"" -msgstr "" +msgstr "\"#67, Aug 1 1997, 22:34:28\"" -#: ../../c-api/interp-lifecycle.rst:887 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv`, :c:member:`PyConfig.parse_argv` and :c:member:`PyConfig.safe_path` " "should be used instead, see :ref:`Python Initialization Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.argv` と :c:member:`PyConfig.parse_argv` と :c:" +"member:`PyConfig.safe_path` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:892 msgid "" @@ -1294,18 +1474,22 @@ msgstr "" "指していない場合)、 :data:`sys.path` の先頭に空の文字列を追加します。\n" "これは現在の作業ディレクトリ (``\".\"``) を先頭に追加するのと同じです。" -#: ../../c-api/interp-lifecycle.rst:915 ../../c-api/interp-lifecycle.rst:948 msgid "" "See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` " "members of the :ref:`Python Initialization Configuration `." msgstr "" +":ref:`Python の初期化設定 ` の :c:member:`PyConfig.orig_argv` " +"と :c:member:`PyConfig.argv` メンバーも参照してください。" -#: ../../c-api/interp-lifecycle.rst:919 msgid "" "It is recommended that applications embedding the Python interpreter for " "purposes other than executing a single script pass ``0`` as *updatepath*, " "and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`." msgstr "" +"単一のスクリプトを実行する以外の目的で Python インタープリタを組み込むアプリ" +"ケーションでは、*updatepath* に ``0`` を渡し、必要なら :data:`sys.path` を自" +"分で更新することを推奨します。\n" +":cve:`2008-5983` を参照してください。" #: ../../c-api/interp-lifecycle.rst:924 msgid "" @@ -1317,16 +1501,18 @@ msgstr "" "に :data:`sys.path` の先頭の要素を取り出すことで、同じ効果が得られます。例え" "ばこのように使います::" -#: ../../c-api/interp-lifecycle.rst:928 msgid "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -msgstr "" +msgstr "PyRun_SimpleString(\"import sys; sys.path.pop(0)\\n\");" -#: ../../c-api/interp-lifecycle.rst:937 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "argv` and :c:member:`PyConfig.parse_argv` should be used instead, see :ref:" "`Python Initialization Configuration `." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.argv` と :c:member:`PyConfig.parse_argv` を設定" +"してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:941 msgid "" @@ -1342,12 +1528,14 @@ msgstr "" msgid "The *updatepath* value depends on :option:`-I`." msgstr "*updatepath* の値は :option:`-I` オプションに依存します。" -#: ../../c-api/interp-lifecycle.rst:958 msgid "" "This API is kept for backward compatibility: setting :c:member:`PyConfig." "home` should be used instead, see :ref:`Python Initialization Configuration " "`." msgstr "" +"この API は後方互換性のために残されています。\n" +"代わりに :c:member:`PyConfig.home` を設定してください。\n" +":ref:`Python の初期化設定 ` を参照してください。" #: ../../c-api/interp-lifecycle.rst:962 msgid "" @@ -1405,9 +1593,8 @@ msgstr "検索" msgid "path" msgstr "パス" -#: ../../c-api/interp-lifecycle.rst:357 msgid "Py_FinalizeEx (C function)" -msgstr "" +msgstr "Py_FinalizeEx (C 関数)" #: ../../c-api/interp-lifecycle.rst:785 msgid "Py_Initialize()" diff --git a/c-api/intro.po b/c-api/intro.po index 4dc31d1cb..9a7eaf7fa 100644 --- a/c-api/intro.po +++ b/c-api/intro.po @@ -17,17 +17,16 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/intro.rst:8 msgid "Introduction" msgstr "はじめに" -#: ../../c-api/intro.rst:10 msgid "" "The Application Programmer's Interface to Python gives C and C++ programmers " "access to the Python interpreter at a variety of levels. The API is equally " @@ -39,16 +38,18 @@ msgid "" "larger application; this technique is generally referred to as :dfn:" "`embedding` Python in an application." msgstr "" -"Python のアプリケーションプログラマ用インタフェース (Application " -"Programmer's Interface, API) は、 Python インタプリタに対する様々なレベルでの" -"アクセス手段を C や C++ のプログラマに提供しています。この API は通常 C++ か" -"らも全く同じように利用できるのですが、簡潔な呼び名にするために Python/C API " -"と名づけられています。根本的に異なる二つの目的から、 Python/C API が用いられ" -"ます。第一は、特定用途の *拡張モジュール (extension module)* 、すなわち " -"Python インタプリタを拡張する C で書かれたモジュールを記述する、という目的で" -"す。第二は、より大規模なアプリケーション内で Python を構成要素 (component) と" -"して利用するという目的です; このテクニックは、一般的にはアプリケーションへの " -"Python の埋め込み (:dfn:`embedding`) と呼びます。" +"Python のアプリケーションプログラマー向けインターフェース (API) は、C と C++ " +"のプログラマーに、Python インタープリタへのさまざまなレベルのアクセスを提供し" +"ます。\n" +"C++ からも同様に使えますが、簡潔に Python/C API と呼びます。\n" +"Python/C API を使う主な理由は、根本的に異なる 2 つです。\n" +"1 つは、特定の目的のために *拡張モジュール* を書くことです。\n" +"これは Python インタープリタを拡張する C のモジュールで、おそらく最も一般的な" +"用途です。\n" +"もう 1 つは、より大きなアプリケーションの構成要素として Python を使うことで" +"す。\n" +"この技法は一般に、アプリケーションへの Python の 埋め込み (:dfn:`embedding`) " +"と呼ばれます。" #: ../../c-api/intro.rst:20 msgid "" @@ -87,11 +88,13 @@ msgid "Python's C API is compatible with C11 and C++11 versions of C and C++." msgstr "" "Pythonの C API は C11 や C++11 バージョンの C と C++ に互換性があります。" -#: ../../c-api/intro.rst:38 msgid "" "This is a lower limit: the C API does not require features from later C/C++ " "versions. You do *not* need to enable your compiler's \"c11 mode\"." msgstr "" +"これは最低限のバージョンであり、C API はこれより新しい C/C++ の機能を必要とし" +"ません。\n" +"コンパイラの「c11 モード」を有効にする必要は *ありません*。" #: ../../c-api/intro.rst:44 msgid "Coding standards" @@ -224,131 +227,131 @@ msgstr "" "ラットフォーム依存のヘッダをインクルードしているので、このような操作を行うと" "複数のプラットフォームでのビルドができなくなります。" -#: ../../c-api/intro.rst:105 msgid "" "C++ users should note that although the API is defined entirely using C, the " "header files properly declare the entry points to be ``extern \"C\"``. As a " "result, there is no need to do anything special to use the API from C++." msgstr "" +"C++ の利用者は、API がすべて C で定義されていても、ヘッダーファイルではエント" +"リーポイントが適切に ``extern \"C\"`` として宣言されていることに注意してくだ" +"さい。\n" +"そのため、C++ から API を使うのに特別な対応は必要ありません。" -#: ../../c-api/intro.rst:113 msgid "System includes" -msgstr "" +msgstr "システムヘッダーのインクルード" -#: ../../c-api/intro.rst:115 msgid "" ":file:`Python.h` includes several standard header files. C extensions should " "include the standard headers that they use, and should not rely on these " "implicit includes. The implicit includes are:" msgstr "" +":file:`Python.h` は、いくつかの標準ヘッダーファイルをインクルードします。\n" +"C 拡張では、この暗黙のインクルードに依存せず、使う標準ヘッダーを自分でインク" +"ルードするべきです。\n" +"暗黙にインクルードされるのは次のヘッダーです。" -#: ../../c-api/intro.rst:120 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:121 msgid "```` (on Windows)" -msgstr "" +msgstr "```` (Windows)" -#: ../../c-api/intro.rst:122 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:123 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:124 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:125 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:126 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:127 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:128 msgid "```` (if present)" -msgstr "" +msgstr "```` (存在する場合)" -#: ../../c-api/intro.rst:130 msgid "" "The following are included for backwards compatibility, unless using :ref:" "`Limited API ` 3.13 or newer:" msgstr "" +"次のヘッダーは、3.13 以降の :ref:`Limited API ` を使う場合を除" +"き、後方互換性のためにインクルードされます。" -#: ../../c-api/intro.rst:133 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:134 msgid "```` (on POSIX)" -msgstr "" +msgstr "```` (POSIX)" -#: ../../c-api/intro.rst:136 msgid "" "The following are included for backwards compatibility, unless using :ref:" "`Limited API ` 3.11 or newer:" msgstr "" +"次のヘッダーは、3.11 以降の :ref:`Limited API ` を使う場合を除" +"き、後方互換性のためにインクルードされます。" -#: ../../c-api/intro.rst:139 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:140 msgid "````" -msgstr "" +msgstr "````" -#: ../../c-api/intro.rst:141 msgid "````" -msgstr "" +msgstr "````" #: ../../c-api/intro.rst:151 msgid "Useful macros" msgstr "便利なマクロ" -#: ../../c-api/intro.rst:153 msgid "" "Several useful macros are defined in the Python header files. Many are " "defined closer to where they are useful (for example, :c:macro:" "`Py_RETURN_NONE`, :c:macro:`PyMODINIT_FUNC`). Others of a more general " "utility are defined here. This is not necessarily a complete listing." msgstr "" +"Python のヘッダーファイルでは、いくつかの便利なマクロが定義されています。\n" +"多くは、:c:macro:`Py_RETURN_NONE` や :c:macro:`PyMODINIT_FUNC` のように、用途" +"に関連する箇所で定義されています。\n" +"ここでは、より汎用的なマクロを説明します。\n" +"すべてを網羅した一覧ではありません。" -#: ../../c-api/intro.rst:161 msgid "" "If this macro is defined, then the current system is able to start threads." msgstr "" +"このマクロが定義されていれば、現在のシステムではスレッドを開始できます。" -#: ../../c-api/intro.rst:163 msgid "" "Currently, all systems supported by CPython (per :pep:`11`), with the " "exception of some WebAssembly platforms, support starting threads." msgstr "" +"現在、CPython がサポートするすべてのシステム (:pep:`11` を参照) は、一部の " +"WebAssembly プラットフォームを除き、スレッドを開始できます。" -#: ../../c-api/intro.rst:170 msgid "" "Like :samp:`getenv({s})`, but returns ``NULL`` if :option:`-E` was passed on " "the command line (see :c:member:`PyConfig.use_environment`)." msgstr "" +":samp:`getenv({s})` と同様ですが、コマンドラインで :option:`-E` が指定された" +"場合は ``NULL`` を返します (:c:member:`PyConfig.use_environment` を参照)。" -#: ../../c-api/intro.rst:175 msgid "Docstring macros" -msgstr "" +msgstr "docstring のマクロ" -#: ../../c-api/intro.rst:179 msgid "" "Creates a variable with name *name* that can be used in docstrings. If " "Python is built without docstrings (:option:`--without-doc-strings`), the " "value will be an empty string." msgstr "" +"docstring に使える、名前が *name* の変数を作成します。\n" +"Python を docstring なしでビルドした場合 (:option:`--without-doc-strings`)、" +"値は空文字列になります。" #: ../../c-api/intro.rst:183 ../../c-api/intro.rst:200 #: ../../c-api/intro.rst:468 @@ -373,15 +376,16 @@ msgstr "" " // ...\n" "}" -#: ../../c-api/intro.rst:193 msgid "Expands to :samp:`PyDoc_VAR({name}) = PyDoc_STR({str})`." -msgstr "" +msgstr ":samp:`PyDoc_VAR({name}) = PyDoc_STR({str})` に展開されます。" -#: ../../c-api/intro.rst:197 msgid "" "Expands to the given input string, or an empty string if docstrings are " "disabled (:option:`--without-doc-strings`)." msgstr "" +"指定された文字列に展開されます。\n" +"docstring が無効な場合 (:option:`--without-doc-strings`) は空文字列に展開され" +"ます。" #: ../../c-api/intro.rst:202 msgid "" @@ -397,31 +401,32 @@ msgstr "" " {NULL, NULL}\n" "};" -#: ../../c-api/intro.rst:210 msgid "" "Declares a static character array variable with the given *name*. Expands " "to :samp:`static const char {name}[]`" msgstr "" +"指定された *name* を名前とする、静的な文字配列変数を宣言します。\n" +":samp:`static const char {name}[]` に展開されます。" #: ../../c-api/intro.rst:213 ../../c-api/intro.rst:354 #: ../../c-api/intro.rst:365 msgid "For example::" msgstr "例えば::" -#: ../../c-api/intro.rst:215 msgid "" "PyDoc_VAR(python_doc) = PyDoc_STR(\n" " \"A genus of constricting snakes in the Pythonidae family native \"\n" " \"to the tropics and subtropics of the Eastern Hemisphere.\");" msgstr "" +"PyDoc_VAR(python_doc) = PyDoc_STR(\n" +" \"東半球の熱帯・亜熱帯に生息するニシキヘビ科の属。\"\n" +" \"獲物に巻き付いて締め付ける。\");" -#: ../../c-api/intro.rst:221 msgid "General utility macros" -msgstr "" +msgstr "汎用ユーティリティマクロ" -#: ../../c-api/intro.rst:223 msgid "The following macros are for common tasks not specific to Python." -msgstr "" +msgstr "以下は、Python に固有ではない一般的な処理のためのマクロです。" #: ../../c-api/intro.rst:227 msgid "" @@ -431,132 +436,150 @@ msgstr "" "コンパイラ警告を抑えるために関数定義の使用されない引数に使用してください。例" "えば: ``int func(int a, int Py_UNUSED(b)) { return a; }`` 。" -#: ../../c-api/intro.rst:234 msgid "" "Use a GCC attribute *name*, hiding it from compilers that don't support GCC " "attributes (such as MSVC)." msgstr "" +"GCC の属性 *name* を使います。\n" +"MSVC など、GCC の属性をサポートしないコンパイラには属性を見せません。" -#: ../../c-api/intro.rst:237 msgid "" "This expands to :samp:`__attribute__(({name)})` on a GCC compiler, and " "expands to nothing on compilers that don't support GCC attributes." msgstr "" +"GCC では :samp:`__attribute__(({name)})` に展開され、GCC の属性をサポートしな" +"いコンパイラでは何も展開されません。" -#: ../../c-api/intro.rst:242 msgid "Numeric utilities" -msgstr "" +msgstr "数値ユーティリティ" #: ../../c-api/intro.rst:246 msgid "Return the absolute value of ``x``." msgstr "``x`` の絶対値を返します。" -#: ../../c-api/intro.rst:248 msgid "" "The argument may be evaluated more than once. Consequently, do not pass an " "expression with side-effects directly to this macro." msgstr "" +"引数は複数回評価される可能性があります。\n" +"そのため、副作用のある式をこのマクロに直接渡さないでください。" -#: ../../c-api/intro.rst:252 msgid "" "If the result cannot be represented (for example, if ``x`` has :c:macro:`!" "INT_MIN` value for :c:expr:`int` type), the behavior is undefined." msgstr "" +"例えば ``x`` が :c:expr:`int` 型の :c:macro:`!INT_MIN` である場合など、結果を" +"表現できない場合の動作は未定義です。" -#: ../../c-api/intro.rst:256 msgid "Corresponds roughly to :samp:`(({x}) < 0 ? -({x}) : ({x}))`" -msgstr "" +msgstr "おおむね :samp:`(({x}) < 0 ? -({x}) : ({x}))` に相当します。" -#: ../../c-api/intro.rst:263 msgid "Return the larger or smaller of the arguments, respectively." -msgstr "" +msgstr "それぞれ、引数のうち大きい方、小さい方を返します。" -#: ../../c-api/intro.rst:265 msgid "" "Any arguments may be evaluated more than once. Consequently, do not pass an " "expression with side-effects directly to this macro." msgstr "" +"どの引数も複数回評価される可能性があります。\n" +"そのため、副作用のある式をこのマクロに直接渡さないでください。" -#: ../../c-api/intro.rst:269 msgid "" ":c:macro:`!Py_MAX` corresponds roughly to :samp:`((({x}) > ({y})) ? ({x}) : " "({y}))`." msgstr "" +":c:macro:`!Py_MAX` は、おおむね :samp:`((({x}) > ({y})) ? ({x}) : ({y}))` に" +"相当します。" -#: ../../c-api/intro.rst:276 msgid "" "Similar to :samp:`{integer} >> {positions}`, but forces sign extension, as " "the C standard does not define whether a right-shift of a signed integer " "will perform sign extension or a zero-fill." msgstr "" +":samp:`{integer} >> {positions}` と似ていますが、必ず符号拡張を行います。\n" +"C の規格では、符号付き整数の右シフトで符号拡張を行うか、ゼロで埋めるかが定め" +"られていないためです。" -#: ../../c-api/intro.rst:280 msgid "" "*integer* should be any signed integer type. *positions* is the number of " "positions to shift to the right." msgstr "" +"*integer* は任意の符号付き整数型の値を指定します。\n" +"*positions* は右にシフトするビット数です。" -#: ../../c-api/intro.rst:283 msgid "" "Both *integer* and *positions* can be evaluated more than once; " "consequently, avoid directly passing a function call or some other operation " "with side-effects to this macro. Instead, store the result as a variable and " "then pass it." msgstr "" +"*integer* と *positions* は、どちらも複数回評価される可能性があります。\n" +"そのため、関数呼び出しやその他の副作用がある操作を、このマクロに直接渡さない" +"でください。\n" +"代わりに、結果を変数に保存してから渡してください。" -#: ../../c-api/intro.rst:288 msgid "" "*type* is unused and only kept for backwards compatibility. Historically, " "*type* was used to cast *integer*." msgstr "" +"*type* は使われず、後方互換性のためだけに残されています。\n" +"以前は、*integer* のキャストに使っていました。" -#: ../../c-api/intro.rst:293 msgid "" "This macro is now valid for all signed integer types, not just those for " "which ``unsigned type`` is legal. As a result, *type* is no longer used." msgstr "" +"``unsigned type`` が有効な型だけでなく、すべての符号付き整数型で使えるように" +"なりました。\n" +"そのため、*type* は使われなくなりました。" -#: ../../c-api/intro.rst:299 msgid "" "Argument must be a character or an integer in the range [-128, 127] or [0, " "255]. This macro returns ``c`` cast to an ``unsigned char``." msgstr "" -"引数は文字か、[-128, 127] あるいは [0, 255] の範囲の整数でなければなりませ" +"引数は、文字か、[-128, 127] または [0, 255] の範囲の整数でなければなりませ" "ん。\n" -"このマクロは ``符号なし文字`` にキャストした ``c`` を返します。" +"このマクロは ``c`` を ``unsigned char`` にキャストして返します。" -#: ../../c-api/intro.rst:304 msgid "Assertion utilities" -msgstr "" +msgstr "アサーションのユーティリティ" -#: ../../c-api/intro.rst:308 msgid "" "Use this when you have a code path that cannot be reached by design. For " "example, in the ``default:`` clause in a ``switch`` statement for which all " "possible values are covered in ``case`` statements. Use this in places " "where you might be tempted to put an ``assert(0)`` or ``abort()`` call." msgstr "" +"設計上、到達することのないコードパスで使ってください。\n" +"例えば、可能な値をすべて ``case`` で網羅した ``switch`` 文の ``default:`` 節" +"で使います。\n" +"``assert(0)`` や ``abort()`` の呼び出しを置きたくなるような箇所で使ってくださ" +"い。" -#: ../../c-api/intro.rst:313 msgid "" "In release mode, the macro helps the compiler to optimize the code, and " "avoids a warning about unreachable code. For example, the macro is " "implemented with ``__builtin_unreachable()`` on GCC in release mode." msgstr "" +"リリースモードでは、このマクロはコンパイラによるコードの最適化を助け、到達不" +"能コードに関する警告を防ぎます。\n" +"例えば、GCC のリリースモードでは ``__builtin_unreachable()`` で実装されていま" +"す。" -#: ../../c-api/intro.rst:317 msgid "" "In debug mode, and on unsupported compilers, the macro expands to a call to :" "c:func:`Py_FatalError`." msgstr "" +"デバッグモードと、対応していないコンパイラでは、:c:func:`Py_FatalError` の呼" +"び出しに展開されます。" -#: ../../c-api/intro.rst:320 msgid "" "A use for ``Py_UNREACHABLE()`` is following a call to a function that never " "returns but that is not declared ``_Noreturn``." msgstr "" +"``Py_UNREACHABLE()`` の用途の 1 つは、決して戻らないものの ``_Noreturn`` と宣" +"言されていない関数の呼び出しの直後に置くことです。" -#: ../../c-api/intro.rst:323 msgid "" "If a code path is very unlikely code but can be reached under exceptional " "case, this macro must not be used. For example, under low memory condition " @@ -564,53 +587,64 @@ msgid "" "case, it's better to report the error to the caller. If the error cannot be " "reported to caller, :c:func:`Py_FatalError` can be used." msgstr "" +"発生する可能性が非常に低くても、例外的な状況で到達しうるコードパスには、この" +"マクロを使ってはなりません。\n" +"例えば、メモリ不足の場合や、システムコールが想定範囲外の値を返した場合で" +"す。\n" +"そのような場合は、呼び出し元にエラーを報告する方が適切です。\n" +"呼び出し元に報告できない場合は、:c:func:`Py_FatalError` を使えます。" -#: ../../c-api/intro.rst:333 msgid "" "Cast *value* to type *smaller* from type *larger*, validating that no " "information was lost." msgstr "" +"*value* を *larger* 型から *smaller* 型にキャストし、情報が失われなかったこと" +"を検証します。" -#: ../../c-api/intro.rst:336 msgid "" "On release builds of Python, this is roughly equivalent to :samp:" "`(({smaller}) {value})` (in C++, :samp:`static_cast<{smaller}>({value})` " "will be used instead)." msgstr "" +"Python のリリースビルドでは、おおむね :samp:`(({smaller}) {value})` と等価で" +"す (C++ では代わりに :samp:`static_cast<{smaller}>({value})` を使います)。" -#: ../../c-api/intro.rst:340 msgid "" "On debug builds (implying that :c:macro:`Py_DEBUG` is defined), this asserts " "that no information was lost with the cast from *larger* to *smaller*." msgstr "" +"デバッグビルド (:c:macro:`Py_DEBUG` が定義されている場合) では、*larger* か" +"ら *smaller* へのキャストで情報が失われていないことをアサートします。" -#: ../../c-api/intro.rst:343 msgid "" "*value*, *larger*, and *smaller* may all be evaluated more than once in the " "expression; consequently, do not pass an expression with side-effects " "directly to this macro." msgstr "" +"*value*、*larger*、*smaller* は、式の中で複数回評価される可能性があります。\n" +"そのため、副作用のある式をこのマクロに直接渡さないでください。" -#: ../../c-api/intro.rst:349 msgid "" "Asserts a compile-time condition *cond*, as a statement. The build will fail " "if the condition is false or cannot be evaluated at compile time." msgstr "" +"コンパイル時の条件 *cond* をアサートする文です。\n" +"条件が偽の場合や、コンパイル時に評価できない場合は、ビルドに失敗します。" -#: ../../c-api/intro.rst:352 msgid "Corresponds roughly to :samp:`static_assert({cond})` on C23 and above." -msgstr "" +msgstr "C23 以降では、おおむね :samp:`static_assert({cond})` に相当します。" #: ../../c-api/intro.rst:356 msgid "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" msgstr "Py_BUILD_ASSERT(sizeof(PyTime_t) == sizeof(int64_t));" -#: ../../c-api/intro.rst:362 msgid "" "Asserts a compile-time condition *cond*, as an expression that evaluates to " "``0``. The build will fail if the condition is false or cannot be evaluated " "at compile time." msgstr "" +"コンパイル時の条件 *cond* をアサートする式で、評価結果は ``0`` です。\n" +"条件が偽の場合や、コンパイル時に評価できない場合は、ビルドに失敗します。" #: ../../c-api/intro.rst:367 msgid "" @@ -620,78 +654,78 @@ msgstr "" "#define foo_to_char(foo) \\\n" " ((char *)(foo) + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))" -#: ../../c-api/intro.rst:374 msgid "Type size utilities" -msgstr "" +msgstr "型のサイズのユーティリティ" -#: ../../c-api/intro.rst:378 msgid "Compute the length of a statically allocated C array at compile time." -msgstr "" +msgstr "静的に確保された C の配列の長さを、コンパイル時に計算します。" -#: ../../c-api/intro.rst:380 msgid "" "The *array* argument must be a C array with a size known at compile time. " "Passing an array with an unknown size, such as a heap-allocated array, will " "result in a compilation error on some compilers, or otherwise produce " "incorrect results." msgstr "" +"*array* 引数は、コンパイル時にサイズが分かる C の配列でなければなりません。\n" +"ヒープに確保した配列など、サイズが不明な配列を渡すと、一部のコンパイラではコ" +"ンパイルエラーになり、それ以外では誤った結果になります。" -#: ../../c-api/intro.rst:385 msgid "This is roughly equivalent to::" -msgstr "" +msgstr "おおむね次の式と等価です。 ::" -#: ../../c-api/intro.rst:387 msgid "sizeof(array) / sizeof((array)[0])" -msgstr "" +msgstr "sizeof(array) / sizeof((array)[0])" -#: ../../c-api/intro.rst:391 msgid "Return the size of a structure (*type*) *member* in bytes." -msgstr "" +msgstr "構造体 *type* のメンバー *member* のサイズをバイト数で返します。" -#: ../../c-api/intro.rst:393 msgid "Corresponds roughly to :samp:`sizeof((({type} *)NULL)->{member})`." -msgstr "" +msgstr "おおむね :samp:`sizeof((({type} *)NULL)->{member})` に相当します。" -#: ../../c-api/intro.rst:399 msgid "Macro definition utilities" -msgstr "" +msgstr "マクロ定義のユーティリティ" -#: ../../c-api/intro.rst:403 msgid "" "This is equivalent to :samp:`{X}`, which is useful for token-pasting in " "macros, as macro expansions in *X* are forcefully evaluated by the " "preprocessor." msgstr "" +":samp:`{X}` と等価ですが、プリプロセッサーが *X* 内のマクロを強制的に展開する" +"ため、マクロでのトークンの連結に役立ちます。" -#: ../../c-api/intro.rst:409 msgid "" "Convert ``x`` to a C string. For example, ``Py_STRINGIFY(123)`` returns " "``\"123\"``." msgstr "" +"``x`` を C の文字列に変換します。\n" +"例えば ``Py_STRINGIFY(123)`` は ``\"123\"`` を返します。" -#: ../../c-api/intro.rst:416 msgid "Declaration utilities" -msgstr "" +msgstr "宣言のユーティリティ" -#: ../../c-api/intro.rst:418 msgid "" "The following macros can be used in declarations. They are most useful for " "defining the C API itself, and have limited use for extension authors. Most " "of them expand to compiler-specific spellings of common extensions to the C " "language." msgstr "" +"以下のマクロは宣言で使えます。\n" +"主に C API 自体を定義するためのもので、拡張の作者にとっての用途は限られま" +"す。\n" +"ほとんどは、C 言語で一般的な拡張機能の、コンパイラ固有の記法に展開されます。" -#: ../../c-api/intro.rst:426 msgid "" "Ask the compiler to always inline a static inline function. The compiler can " "ignore it and decide to not inline the function." msgstr "" +"static inline 関数を常にインライン化するよう、コンパイラに要求します。\n" +"コンパイラはこれを無視して、インライン化しないと判断する場合もあります。" -#: ../../c-api/intro.rst:429 msgid "" "Corresponds to ``always_inline`` attribute in GCC and ``__forceinline`` in " "MSVC." msgstr "" +"GCC の ``always_inline`` 属性と、MSVC の ``__forceinline`` に相当します。" #: ../../c-api/intro.rst:432 msgid "" @@ -700,39 +734,45 @@ msgid "" "MSC disables function inlining when building in debug mode." msgstr "" -#: ../../c-api/intro.rst:436 msgid "" "Marking blindly a static inline function with Py_ALWAYS_INLINE can result in " "worse performances (due to increased code size for example). The compiler is " "usually smarter than the developer for the cost/benefit analysis." msgstr "" +"static inline 関数に無条件に ``Py_ALWAYS_INLINE`` を付けると、コードサイズの" +"増加などによって、性能が悪化する場合があります。\n" +"通常、コストと利点の分析は、開発者よりもコンパイラの方が得意です。" -#: ../../c-api/intro.rst:440 msgid "" "If Python is :ref:`built in debug mode ` (if the :c:macro:" "`Py_DEBUG` macro is defined), the :c:macro:`Py_ALWAYS_INLINE` macro does " "nothing." msgstr "" +"Python が :ref:`デバッグモードでビルドされている ` 場合 (:c:" +"macro:`Py_DEBUG` マクロが定義されている場合)、:c:macro:`Py_ALWAYS_INLINE` マ" +"クロは何も行いません。" -#: ../../c-api/intro.rst:443 msgid "It must be specified before the function return type. Usage::" msgstr "" +"関数の戻り値の型の前に指定しなければなりません。\n" +"使用例を示します。 ::" #: ../../c-api/intro.rst:445 msgid "static inline Py_ALWAYS_INLINE int random(void) { return 4; }" msgstr "static inline Py_ALWAYS_INLINE int random(void) { return 4; }" -#: ../../c-api/intro.rst:451 msgid "" "Disable inlining on a function. For example, it reduces the C stack " "consumption: useful on LTO+PGO builds which heavily inline code (see :issue:" "`33720`)." msgstr "" +"関数のインライン化を無効にします。\n" +"例えば、C のスタックの消費量を減らせるため、コードを大幅にインライン化する " +"LTO+PGO ビルドで有用です (:issue:`33720` を参照)。" -#: ../../c-api/intro.rst:455 msgid "" "Corresponds to the ``noinline`` attribute/specification on GCC and MSVC." -msgstr "" +msgstr "GCC と MSVC の ``noinline`` 属性や指定に相当します。" #: ../../c-api/intro.rst:457 msgid "Usage::" @@ -742,11 +782,13 @@ msgstr "使い方::" msgid "Py_NO_INLINE static int random(void) { return 4; }" msgstr "Py_NO_INLINE static int random(void) { return 4; }" -#: ../../c-api/intro.rst:465 msgid "" "Use this to declare APIs that were deprecated in a specific CPython version. " "The macro must be placed before the symbol name." msgstr "" +"特定の CPython バージョンで非推奨になった API を宣言するときに使ってくださ" +"い。\n" +"シンボル名の前に置かなければなりません。" #: ../../c-api/intro.rst:470 msgid "Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);" @@ -756,169 +798,190 @@ msgstr "Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);" msgid "MSVC support was added." msgstr "MSVC サポートが追加されました。" -#: ../../c-api/intro.rst:477 msgid "" "Declare a function returning the specified *type* using a fast-calling " "qualifier for functions that are local to the current file. Semantically, " "this is equivalent to :samp:`static {type}`." msgstr "" +"現在のファイル内でのみ使う関数に対し、高速な呼び出し規約を指定して、*type* を" +"返す関数を宣言します。\n" +"意味上は :samp:`static {type}` と等価です。" -#: ../../c-api/intro.rst:483 msgid "" "Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function be " "inlined." msgstr "" +":c:macro:`Py_LOCAL` と等価ですが、さらに関数のインライン化を要求します。" -#: ../../c-api/intro.rst:488 msgid "" "Macro used to declare a symbol as local to the shared library (hidden). On " "supported platforms, it ensures the symbol is not exported." msgstr "" +"シンボルを共有ライブラリ内に限定して、非公開として宣言するマクロです。\n" +"対応するプラットフォームでは、シンボルがエクスポートされないようにします。" -#: ../../c-api/intro.rst:491 msgid "" "On compatible versions of GCC/Clang, it expands to " "``__attribute__((visibility(\"hidden\")))``." msgstr "" +"対応するバージョンの GCC/Clang では、" +"``__attribute__((visibility(\"hidden\")))`` に展開されます。" -#: ../../c-api/intro.rst:496 msgid "" "Macro used to declare a symbol (function or data) as exported. On Windows, " "this expands to ``__declspec(dllexport)``. On compatible versions of GCC/" "Clang, it expands to ``__attribute__((visibility(\"default\")))``. This " "macro is for defining the C API itself; extension modules should not use it." msgstr "" +"シンボル (関数やデータ) をエクスポートすると宣言するマクロです。\n" +"Windows では ``__declspec(dllexport)`` に、対応するバージョンの GCC/Clang で" +"は ``__attribute__((visibility(\"default\")))`` に展開されます。\n" +"C API 自体の定義に使うものであり、拡張モジュールでは使うべきではありません。" -#: ../../c-api/intro.rst:505 msgid "" "Macro used to declare a symbol as imported. On Windows, this expands to " "``__declspec(dllimport)``. This macro is for defining the C API itself; " "extension modules should not use it." msgstr "" +"シンボルをインポートすると宣言するマクロです。\n" +"Windows では ``__declspec(dllimport)`` に展開されます。\n" +"C API 自体の定義に使うものであり、拡張モジュールでは使うべきではありません。" -#: ../../c-api/intro.rst:512 msgid "" "Macro used by CPython to declare a function as part of the C API. Its " "expansion depends on the platform and build configuration. This macro is " "intended for defining CPython's C API itself; extension modules should not " "use it for their own symbols." msgstr "" +"CPython が、C API の一部となる関数を宣言するために使うマクロです。\n" +"展開結果は、プラットフォームとビルド設定に依存します。\n" +"CPython の C API 自体を定義するためのものであり、拡張モジュールは自身のシンボ" +"ルに使うべきではありません。" -#: ../../c-api/intro.rst:520 msgid "" "Macro used by CPython to declare a public global variable as part of the C " "API. Its expansion depends on the platform and build configuration. This " "macro is intended for defining CPython's C API itself; extension modules " "should not use it for their own symbols." msgstr "" +"CPython が、C API の一部となる公開グローバル変数を宣言するために使うマクロで" +"す。\n" +"展開結果は、プラットフォームとビルド設定に依存します。\n" +"CPython の C API 自体を定義するためのものであり、拡張モジュールは自身のシンボ" +"ルに使うべきではありません。" -#: ../../c-api/intro.rst:527 msgid "Outdated macros" -msgstr "" +msgstr "古いマクロ" -#: ../../c-api/intro.rst:529 msgid "" "The following :term:`soft deprecated` macros have been used to features that " "have been standardized in C11 (or previous standards)." msgstr "" +"以下の :term:`緩やかに非推奨となった ` マクロは、C11 以前の" +"規格で標準化された機能のために使われていました。" -#: ../../c-api/intro.rst:534 msgid "" "On some GCC-like compilers, specify alignment to *num* bytes. This does " "nothing on other compilers." msgstr "" +"一部の GCC 系コンパイラで、*num* バイト境界へのアラインメントを指定します。\n" +"ほかのコンパイラでは何も行いません。" -#: ../../c-api/intro.rst:537 msgid "Use the standard ``alignas`` specifier rather than this macro." -msgstr "" +msgstr "このマクロではなく、標準の ``alignas`` 指定子を使ってください。" -#: ../../c-api/intro.rst:543 msgid "" "The :c:func:`printf` formatting modifier for :c:type:`size_t`. Use ``\"z\"`` " "directly instead." msgstr "" +":c:type:`size_t` 用の :c:func:`printf` 書式修飾子です。\n" +"代わりに ``\"z\"`` を直接使ってください。" -#: ../../c-api/intro.rst:551 msgid "" "Use *number* as a ``long long`` or ``unsigned long long`` integer literal, " "respectively." msgstr "" +"*number* を、それぞれ ``long long`` または ``unsigned long long`` の整数リテ" +"ラルとして使います。" -#: ../../c-api/intro.rst:554 msgid "" "Expands to *number* followed by ``LL`` or ``LLU``, respectively, but will " "expand to some compiler-specific suffixes on some older compilers." msgstr "" +"それぞれ、*number* の後ろに ``LL`` または ``LLU`` を付けたものに展開されま" +"す。\n" +"ただし、一部の古いコンパイラでは、コンパイラ固有の接尾辞に展開されます。" -#: ../../c-api/intro.rst:557 msgid "Consider using the C99 standard suffixes ``LL`` and ``LLU`` directly." -msgstr "" +msgstr "C99 標準の接尾辞 ``LL`` と ``LLU`` を直接使うことを検討してください。" -#: ../../c-api/intro.rst:567 msgid "" "Aliases for the types :c:type:`!long long`, :c:type:`!int32_t`, :c:type:`!" "uint32_t`. :c:type:`!int64_t` and :c:type:`!uint64_t`, respectively. " "Historically, these types needed compiler-specific extensions." msgstr "" +"それぞれ :c:type:`!long long`、:c:type:`!int32_t`、:c:type:`!uint32_t`、:c:" +"type:`!int64_t`、:c:type:`!uint64_t` 型のエイリアスです。\n" +"以前は、これらの型にはコンパイラ固有の拡張が必要でした。" -#: ../../c-api/intro.rst:579 msgid "" "Aliases for the values :c:macro:`!LLONG_MIN`, :c:macro:`!LLONG_MAX`, :c:" "macro:`!ULLONG_MAX`, and :c:macro:`!SIZE_MAX`, respectively. Use these " "standard names instead." msgstr "" +"それぞれ :c:macro:`!LLONG_MIN`、:c:macro:`!LLONG_MAX`、:c:macro:`!" +"ULLONG_MAX`、:c:macro:`!SIZE_MAX` のエイリアスです。\n" +"代わりに、これらの標準の名前を使ってください。" -#: ../../c-api/intro.rst:583 msgid "" "The required header, ````, :ref:`is included ` in ``Python.h``." msgstr "" +"必要なヘッダー ```` は、``Python.h`` で :ref:`インクルードされます " +"`。" -#: ../../c-api/intro.rst:590 msgid "This is an alias to :c:func:`!memcpy`." -msgstr "" +msgstr ":c:func:`!memcpy` のエイリアスです。" -#: ../../c-api/intro.rst:592 msgid "Use :c:func:`!memcpy` directly instead." -msgstr "" +msgstr "代わりに :c:func:`!memcpy` を直接使ってください。" -#: ../../c-api/intro.rst:597 msgid "" "Size of the :c:type:`!wchar_t` type. Use ``sizeof(wchar_t)`` or " "``WCHAR_WIDTH/8`` instead." msgstr "" +":c:type:`!wchar_t` 型のサイズです。\n" +"代わりに ``sizeof(wchar_t)`` または ``WCHAR_WIDTH/8`` を使ってください。" -#: ../../c-api/intro.rst:600 msgid "" "The required header for the latter, ````, :ref:`is included ` in ``Python.h``." msgstr "" +"後者に必要なヘッダー ```` は、``Python.h`` で :ref:`インクルードさ" +"れます `。" -#: ../../c-api/intro.rst:607 msgid "" "Defined if ``wchar_t`` can hold a Unicode character (UCS-4). Use " "``sizeof(wchar_t) >= 4`` instead" msgstr "" +"``wchar_t`` が Unicode 文字 (UCS-4) を保持できる場合に定義されます。\n" +"代わりに ``sizeof(wchar_t) >= 4`` を使ってください。" -#: ../../c-api/intro.rst:614 msgid "This is an alias to the C99-standard ``va_copy`` function." -msgstr "" +msgstr "C99 標準の ``va_copy`` 関数のエイリアスです。" -#: ../../c-api/intro.rst:616 msgid "" "Historically, this would use a compiler-specific method to copy a " "``va_list``." -msgstr "" +msgstr "以前は、``va_list`` のコピーにコンパイラ固有の方法を使っていました。" -#: ../../c-api/intro.rst:618 msgid "This is now an alias to ``va_copy``." -msgstr "" +msgstr "``va_copy`` のエイリアスになりました。" #: ../../c-api/intro.rst:627 msgid "Objects, Types and Reference Counts" msgstr "オブジェクト、型および参照カウント" -#: ../../c-api/intro.rst:631 msgid "" "Most Python/C API functions have one or more arguments as well as a return " "value of type :c:expr:`PyObject*`. This type is a pointer to an opaque data " @@ -932,16 +995,19 @@ msgid "" "never be deallocated, they are typically static :c:type:`PyTypeObject` " "objects." msgstr "" -"Python/C API 関数は、 :c:expr:`PyObject*` 型の一つ以上の引数と戻り値を持ちま" -"す。この型は、任意の Python オブジェクトを表現する不透明 (opaque) なデータ型" -"へのポインタです。 Python 言語は、全ての Python オブジェクト型をほとんどの状" -"況 (例えば代入、スコープ規則 (scope rule)、引数渡し) で同様に扱います。ほとん" -"ど全ての Python オブジェクトはヒープ (heap) 上に置かれます: このため、 :c:" -"type:`PyObject` 型のオブジェクトは、自動記憶 (automatic) としても静的記憶 " -"(static) としても宣言できません。 :c:expr:`PyObject*` 型のポインタ変数のみ宣" -"言できます。唯一の例外は、型オブジェクトです; 型オブジェクトはメモリ解放 " -"(deallocate) してはならないので、通常は静的記憶の :c:type:`PyTypeObject` オブ" -"ジェクトにします。" +"Python/C API 関数の多くは、:c:expr:`PyObject*` 型の引数を 1 つ以上受け取り、" +"同じ型の値を返します。\n" +"この型は、任意の Python オブジェクトを表す不透明なデータ型へのポインターで" +"す。\n" +"Python 言語では、代入、スコープの規則、引数渡しなど、ほとんどの状況ですべて" +"の Python オブジェクト型を同じように扱います。\n" +"したがって、単一の C の型で表すのが適切です。\n" +"ほとんどすべての Python オブジェクトはヒープ上に置かれます。\n" +":c:type:`PyObject` 型の自動変数や静的変数を宣言することはなく、宣言するのは :" +"c:expr:`PyObject*` 型のポインター変数だけです。\n" +"唯一の例外は型オブジェクトです。\n" +"型オブジェクトは解放してはならないため、通常は静的な :c:type:`PyTypeObject` " +"オブジェクトです。" #: ../../c-api/intro.rst:642 msgid "" @@ -999,7 +1065,6 @@ msgid "" "increment is a simple operation." msgstr "" -#: ../../c-api/intro.rst:688 msgid "" "It is not necessary to hold a :term:`strong reference` (i.e. increment the " "reference count) for every local variable that contains a pointer to an " @@ -1016,8 +1081,21 @@ msgid "" "that are called from Python; the call mechanism guarantees to hold a " "reference to every argument for the duration of the call." msgstr "" +"オブジェクトへのポインターを格納するローカル変数すべてについて、:term:`強参" +"照 ` を保持する (参照カウントを増やす) 必要はありません。\n" +"理論上は、変数がオブジェクトを指すようになったときに参照カウントを 1 増やし、" +"変数がスコープを外れたときに 1 減らします。\n" +"しかし、この 2 つは相殺されるので、最終的な参照カウントは変わりません。\n" +"参照カウントを使う本当の理由は、変数がオブジェクトを指している間に、オブジェ" +"クトが解放されるのを防ぐことだけです。\n" +"少なくともその変数と同じ期間存続する別の参照があると分かっていれば、一時的に" +"新しい :term:`強参照 ` を取得する (参照カウントを増やす) 必" +"要はありません。\n" +"重要な例は、Python から呼び出す拡張モジュールの C 関数に、引数として渡される" +"オブジェクトです。\n" +"呼び出しの仕組みによって、呼び出し中は各引数への参照が保持されることが保証さ" +"れます。" -#: ../../c-api/intro.rst:704 msgid "" "However, a common pitfall is to extract an object from a list and hold on to " "it for a while without taking a new reference. Some other operation might " @@ -1027,8 +1105,15 @@ msgid "" "code path which allows control to flow back to the user from a :c:func:" "`Py_DECREF`, so almost any operation is potentially dangerous." msgstr "" +"ただし、よくある落とし穴として、リストから取り出したオブジェクトを、新しい参" +"照を取得せずにしばらく保持することがあります。\n" +"別の操作がそのオブジェクトをリストから取り除いて参照を解放し、オブジェクト自" +"体も解放してしまう可能性があります。\n" +"本当の危険は、無害に見える操作でも任意の Python コードを呼び出し、そのコード" +"がこのような操作を行いうることです。\n" +":c:func:`Py_DECREF` からユーザーのコードに制御が戻る経路があるため、ほとんど" +"どの操作にも危険が潜んでいます。" -#: ../../c-api/intro.rst:712 msgid "" "A safe approach is to always use the generic operations (functions whose " "name begins with ``PyObject_``, ``PyNumber_``, ``PySequence_`` or " @@ -1037,12 +1122,17 @@ msgid "" "This leaves the caller with the responsibility to call :c:func:`Py_DECREF` " "when they are done with the result; this soon becomes second nature." msgstr "" +"安全な方法は、常に汎用の操作 (名前が ``PyObject_``、``PyNumber_``、" +"``PySequence_``、``PyMapping_`` で始まる関数) を使うことです。\n" +"これらの操作は、返すオブジェクトへの新しい :term:`強参照 ` " +"を必ず作成します (つまり、参照カウントを増やします)。\n" +"そのため、呼び出し元には、結果を使い終えたときに :c:func:`Py_DECREF` を呼び出" +"す責任がありますが、これはすぐに習慣になります。" #: ../../c-api/intro.rst:723 msgid "Reference Count Details" msgstr "参照カウントの詳細" -#: ../../c-api/intro.rst:725 msgid "" "The reference count behavior of functions in the Python/C API is best " "explained in terms of *ownership of references*. Ownership pertains to " @@ -1058,21 +1148,39 @@ msgid "" "said to *borrow* the reference. Nothing needs to be done for a :term:" "`borrowed reference`." msgstr "" +"Python/C API の関数による参照カウントの扱いは、*参照の所有権* で考えると最も" +"よく説明できます。\n" +"所有権は参照に対するものであり、オブジェクトに対するものではありません (オブ" +"ジェクトは所有されず、常に共有されます)。\n" +"「参照を所有する」とは、その参照が不要になったときに ``Py_DECREF`` を呼び出す" +"責任を持つという意味です。\n" +"所有権は移すこともできます。\n" +"所有権を受け取ったコードには、不要になった参照を :c:func:`Py_DECREF` または :" +"c:func:`Py_XDECREF` で解放する責任、あるいはその責任を通常は呼び出し元に引き" +"継ぐ責任が生じます。\n" +"関数が呼び出し元に参照の所有権を渡すとき、呼び出し元は *新しい* 参照を受け取" +"るといいます。\n" +"所有権を移さない場合は、参照を *借用する* といいます。\n" +":term:`借用参照 ` に対しては、何もする必要はありません。" -#: ../../c-api/intro.rst:738 msgid "" "Conversely, when a calling function passes in a reference to an object, " "there are two possibilities: the function *steals* a reference to the " "object, or it does not." msgstr "" +"逆に、呼び出し元の関数がオブジェクトへの参照を渡す場合、呼び出される関数が参" +"照を *盗む* 場合と、盗まない場合の 2 通りがあります。" -#: ../../c-api/intro.rst:742 msgid "" "*Stealing a reference* means that when you pass a reference to a function, " "that function assumes that it now owns that reference. Since the new owner " "can use :c:func:`!Py_DECREF` at its discretion, you (the caller) must not " "use that reference after the call." msgstr "" +"*参照を盗む* とは、関数に参照を渡したとき、その関数が参照を所有するようになる" +"ことです。\n" +"新しい所有者は自身の判断で :c:func:`!Py_DECREF` を使えるため、呼び出し元は呼" +"び出し後にその参照を使ってはなりません。" #: ../../c-api/intro.rst:751 msgid "" @@ -1094,7 +1202,6 @@ msgstr "" "コードは以下のようになります (とりあえず例外処理のことは忘れておきます; もっ" "とよい書き方を後で示します)::" -#: ../../c-api/intro.rst:759 msgid "" "PyObject *t;\n" "\n" @@ -1103,6 +1210,12 @@ msgid "" "PyTuple_SetItem(t, 1, PyLong_FromLong(2L));\n" "PyTuple_SetItem(t, 2, PyUnicode_FromString(\"three\"));" msgstr "" +"PyObject *t;\n" +"\n" +"t = PyTuple_New(3);\n" +"PyTuple_SetItem(t, 0, PyLong_FromLong(1L));\n" +"PyTuple_SetItem(t, 1, PyLong_FromLong(2L));\n" +"PyTuple_SetItem(t, 2, PyUnicode_FromString(\"three\"));" #: ../../c-api/intro.rst:766 msgid "" @@ -1116,18 +1229,17 @@ msgstr "" "い場合は、参照盗む関数を呼び出す前に、 :c:func:`Py_INCREF` を利用してもう一つ" "の参照を取得してください。" -#: ../../c-api/intro.rst:771 msgid "" "Incidentally, :c:func:`PyTuple_SetItem` is the *only* way to set tuple " "items; :c:func:`PySequence_SetItem` and :c:func:`PyObject_SetItem` refuse to " "do this since tuples are an immutable data type. You should only use :c:" "func:`PyTuple_SetItem` for tuples that you are creating yourself." msgstr "" -"ちなみに、 :c:func:`PyTuple_SetItem` はタプルに値をセットするための *唯一の* " -"方法です; タプルは変更不能なデータ型なので、 :c:func:`PySequence_SetItem` " -"や :c:func:`PyObject_SetItem` を使うと上の操作は拒否されてしまいます。自分で" -"タプルの値を入れていくつもりなら、 :c:func:`PyTuple_SetItem` だけしか使えませ" -"ん。" +"ちなみに、:c:func:`PyTuple_SetItem` はタプルの要素を設定する *唯一の* 方法で" +"す。\n" +"タプルは不変のデータ型なので、:c:func:`PySequence_SetItem` と :c:func:" +"`PyObject_SetItem` はこの操作を拒否します。\n" +":c:func:`PyTuple_SetItem` は、自分で作成中のタプルに対してだけ使うべきです。" #: ../../c-api/intro.rst:776 msgid "" @@ -1163,7 +1275,6 @@ msgstr "" "tuple = Py_BuildValue(\"(iis)\", 1, 2, \"three\");\n" "list = Py_BuildValue(\"[iis]\", 1, 2, \"three\");" -#: ../../c-api/intro.rst:790 msgid "" "It is much more common to use :c:func:`PyObject_SetItem` and friends with " "items whose references you are only borrowing, like arguments that were " @@ -1173,8 +1284,13 @@ msgid "" "For example, this function sets all items of a list (actually, any mutable " "sequence) to a given item::" msgstr "" +"実際には、自分の関数に渡された引数のように、参照を借用しているだけの要素に対" +"して、:c:func:`PyObject_SetItem` などを使う方がはるかに一般的です。\n" +"その場合、渡すだけのために新しい参照を取得してから「盗ませる」必要がないた" +"め、参照の扱いがずっと自然になります。\n" +"例えば、次の関数は、リスト (実際には任意の可変シーケンス) のすべての要素を指" +"定した要素に設定します。 ::" -#: ../../c-api/intro.rst:797 msgid "" "int\n" "set_all(PyObject *target, PyObject *item)\n" @@ -1197,6 +1313,26 @@ msgid "" " return 0;\n" "}" msgstr "" +"int\n" +"set_all(PyObject *target, PyObject *item)\n" +"{\n" +" Py_ssize_t i, n;\n" +"\n" +" n = PyObject_Length(target);\n" +" if (n < 0)\n" +" return -1;\n" +" for (i = 0; i < n; i++) {\n" +" PyObject *index = PyLong_FromSsize_t(i);\n" +" if (!index)\n" +" return -1;\n" +" if (PyObject_SetItem(target, index, item) < 0) {\n" +" Py_DECREF(index);\n" +" return -1;\n" +" }\n" +" Py_DECREF(index);\n" +" }\n" +" return 0;\n" +"}" #: ../../c-api/intro.rst:820 msgid "" @@ -1247,7 +1383,6 @@ msgstr "" "書けるかを示した例です; 一つは :c:func:`PyList_GetItem` を使っていて、もう一" "つは :c:func:`PySequence_GetItem` を使っています。 ::" -#: ../../c-api/intro.rst:845 msgid "" "long\n" "sum_list(PyObject *list)\n" @@ -1271,8 +1406,28 @@ msgid "" " return total;\n" "}" msgstr "" +"long\n" +"sum_list(PyObject *list)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +"\n" +" n = PyList_Size(list);\n" +" if (n < 0)\n" +" return -1; /* リストではない */\n" +" for (i = 0; i < n; i++) {\n" +" item = PyList_GetItem(list, i); /* 失敗しない */\n" +" if (!PyLong_Check(item)) continue; /* 整数でないものを飛ばす */\n" +" value = PyLong_AsLong(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* 整数が C の long に収まらないので終了する */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" return total;\n" +"}" -#: ../../c-api/intro.rst:871 msgid "" "long\n" "sum_sequence(PyObject *sequence)\n" @@ -1302,6 +1457,33 @@ msgid "" " return total;\n" "}" msgstr "" +"long\n" +"sum_sequence(PyObject *sequence)\n" +"{\n" +" Py_ssize_t i, n;\n" +" long total = 0, value;\n" +" PyObject *item;\n" +" n = PySequence_Length(sequence);\n" +" if (n < 0)\n" +" return -1; /* 長さを持たない */\n" +" for (i = 0; i < n; i++) {\n" +" item = PySequence_GetItem(sequence, i);\n" +" if (item == NULL)\n" +" return -1; /* シーケンスでないか、別のエラー */\n" +" if (PyLong_Check(item)) {\n" +" value = PyLong_AsLong(item);\n" +" Py_DECREF(item);\n" +" if (value == -1 && PyErr_Occurred())\n" +" /* 整数が C の long に収まらないので終了する */\n" +" return -1;\n" +" total += value;\n" +" }\n" +" else {\n" +" Py_DECREF(item); /* 所有する参照を解放する */\n" +" }\n" +" }\n" +" return total;\n" +"}" #: ../../c-api/intro.rst:905 msgid "Types" @@ -1374,7 +1556,6 @@ msgstr "" "で、 :c:func:`PyErr_Occurred` で明示的にエラーテストを行う必要があります。こ" "れらの例外は常に明示的にドキュメント化されます。" -#: ../../c-api/intro.rst:951 msgid "" "Exception state is maintained in per-thread storage (this is equivalent to " "using global storage in an unthreaded application). A thread can be in one " @@ -1386,18 +1567,18 @@ msgid "" "general) function to set the exception state, and :c:func:`PyErr_Clear` " "clears the exception state." msgstr "" -"例外時の状態情報 (exception state)は、スレッド単位に用意された記憶領域 (per-" -"thread storage) 内で管理されます (この記憶領域は、スレッドを使わないアプリ" -"ケーションではグローバルな記憶領域と同じです)。一つのスレッドは二つの状態のど" -"ちらか: 例外が発生したか、まだ発生していないか、をとります。関数 :c:func:" -"`PyErr_Occurred` を使うと、この状態を調べられます: この関数は例外が発生した際" -"にはその例外型オブジェクトに対する借用参照 (borrowed reference) を返し、そう" -"でないときには ``NULL`` を返します。例外状態を設定する関数は数多くあります: :" -"c:func:`PyErr_SetString` はもっともよく知られている (が、もっとも汎用性のな" -"い) 例外を設定するための関数で、 :c:func:`PyErr_Clear` は例外状態情報を消し去" -"る関数です。" +"例外状態は、スレッドごとの記憶領域で管理されます。\n" +"スレッドを使わないアプリケーションでは、グローバルな記憶領域を使うことに相当" +"します。\n" +"スレッドは、例外が発生しているか、していないかの 2 つの状態のいずれかを取りま" +"す。\n" +":c:func:`PyErr_Occurred` でこれを調べられます。\n" +"例外が発生していれば、その例外の型オブジェクトへの借用参照を返し、それ以外の" +"場合は ``NULL`` を返します。\n" +"例外状態を設定する関数はいくつかあり、:c:func:`PyErr_SetString` が最もよく使" +"われますが、最も汎用的な関数というわけではありません。\n" +":c:func:`PyErr_Clear` は例外状態を消去します。" -#: ../../c-api/intro.rst:961 msgid "" "The full exception state consists of three objects (all of which can be " "``NULL``): the exception type, the corresponding exception value, and the " @@ -1409,17 +1590,16 @@ msgid "" "bytecode interpreter's main loop, which takes care of transferring it to " "``sys.exc_info()`` and friends." msgstr "" -"完全な例外状態情報は、3 つのオブジェクト: 例外の型、例外の値、そしてトレース" -"バック、からなります (どのオブジェクトも ``NULL`` を取り得ます)。これらの情" -"報は、 Python の ``sys.exc_info()`` の結果と同じ意味を持ちます; とはいえ、 C " -"と Python の例外状態情報は全く同じではありません: Python における例外オブジェ" -"クトは、Python の :keyword:`try` ... :keyword:`except` 文で最近処理したオブ" -"ジェクトを表す一方、 C レベルの例外状態情報が存続するのは、渡された例外情報" -"を ``sys.exc_info()`` その他に転送するよう取り計らう Python のバイトコードイ" -"ンタプリタのメインループに到達するまで、例外が関数の間で受け渡しされている間" -"だけです。" +"完全な例外状態は、例外の型、対応する例外の値、トレースバックの 3 つのオブジェ" +"クトからなり、いずれも ``NULL`` になりえます。\n" +"これらは Python の ``sys.exc_info()`` の結果と同じ意味を持ちますが、同じもの" +"ではありません。\n" +"Python 側のオブジェクトは、Python の :keyword:`try` ... :keyword:`except` 文" +"で現在処理している最後の例外を表します。\n" +"一方、C レベルの例外状態が存在するのは、例外が C 関数の間で受け渡され、" +"Python バイトコードインタープリタのメインループに到達するまでの間だけです。\n" +"メインループが、例外を ``sys.exc_info()`` などに移す処理を行います。" -#: ../../c-api/intro.rst:973 msgid "" "Note that starting with Python 1.5, the preferred, thread-safe way to access " "the exception state from Python code is to call the function :func:`sys." @@ -1432,18 +1612,17 @@ msgid "" "reduces the often unwanted lifetime extension for objects that are " "referenced by the stack frames in the traceback." msgstr "" -"Python 1.5 からは、Python で書かれたコードから例外状態情報にアクセスする方法" -"として、推奨されていてスレッドセーフな方法は :func:`sys.exc_info` になってい" -"るので注意してください。この関数は Python コードの実行されているスレッドにお" -"ける例外状態情報を返します。また、これらの例外状態情報に対するアクセス手段" -"は、両方とも意味づけ (semantics) が変更され、ある関数が例外を捕捉すると、その" -"関数を実行しているスレッドの例外状態情報を保存して、呼び出し側の例外状態情報" -"を維持するようになりました。この変更によって、無害そうに見える関数が現在扱っ" -"ている例外を上書きすることで引き起こされる、例外処理コードでよくおきていたバ" -"グを抑止しています; また、トレースバック内のスタックフレームで参照されている" -"オブジェクトがしばしば不必要に寿命を永らえていたのをなくしています。" +"Python 1.5 以降、Python コードから例外状態にアクセスするには、スレッドセーフ" +"な :func:`sys.exc_info` の呼び出しを推奨します。\n" +"この関数は、Python コードから使う、スレッドごとの例外状態を返します。\n" +"また、両方の例外状態へのアクセス方法の意味が変更され、例外を捕捉する関数が、" +"呼び出し元の例外状態を保つためにスレッドの例外状態を保存・復元するようになり" +"ました。\n" +"これにより、無害に見える関数が処理中の例外を上書きすることで生じる、例外処理" +"コードのよくあるバグを防ぎます。\n" +"トレースバック内のスタックフレームが参照するオブジェクトの寿命が、不必要に延" +"びることも減らします。" -#: ../../c-api/intro.rst:984 msgid "" "As a general principle, a function that calls another function to perform " "some task should check whether the called function raised an exception, and " @@ -1453,15 +1632,13 @@ msgid "" "that was just raised, and lose important information about the exact cause " "of the error." msgstr "" -"一般的な原理として、ある関数が別の関数を呼び出して何らかの作業をさせるとき、" -"呼び出し先の関数が例外を送出していないか調べなくてはならず、もし送出していれ" -"ば、その例外状態情報は呼び出し側に渡されなければなりません。呼び出し元の関数" -"はオブジェクト参照の所有権をすべて放棄し、エラー指標を返さなくてはなりません" -"が、余計に例外を設定する必要は *ありません* --- そんなことをすれば、たった今" -"送出されたばかりの例外を上書きしてしまい、エラーの原因そのものに関する重要な" -"情報を失うことになります。" +"一般に、何らかの処理を別の関数に任せる関数は、呼び出し先が例外を送出したかを" +"調べ、送出していれば、その例外状態を自身の呼び出し元に伝えるべきです。\n" +"所有しているオブジェクトへの参照を解放し、エラーを示す値を返します。\n" +"ただし、別の例外を設定しては *なりません*。\n" +"そうすると、直前に送出された例外を上書きし、エラーの正確な原因に関する重要な" +"情報を失ってしまいます。" -#: ../../c-api/intro.rst:993 msgid "" "A simple example of detecting exceptions and passing them on is shown in " "the :c:func:`!sum_sequence` example above. It so happens that this example " @@ -1469,8 +1646,14 @@ msgid "" "following example function shows some error cleanup. First, to remind you " "why you like Python, we show the equivalent Python code::" msgstr "" +"例外を検出して呼び出し元に伝える単純な例は、上の :c:func:`!sum_sequence` に示" +"されています。\n" +"この例では、エラーを検出したときに所有する参照の後始末をする必要がありませ" +"ん。\n" +"次の関数では、エラー時の後始末の例を示します。\n" +"まず、Python の良さを思い出せるように、同じ処理を Python で書いたコードを示し" +"ます。 ::" -#: ../../c-api/intro.rst:999 msgid "" "def incr_item(dict, key):\n" " try:\n" @@ -1479,12 +1662,17 @@ msgid "" " item = 0\n" " dict[key] = item + 1" msgstr "" +"def incr_item(dict, key):\n" +" try:\n" +" item = dict[key]\n" +" except KeyError:\n" +" item = 0\n" +" dict[key] = item + 1" #: ../../c-api/intro.rst:1008 msgid "Here is the corresponding C code, in all its glory::" msgstr "以下は対応するコードを C で完璧に書いたものです::" -#: ../../c-api/intro.rst:1010 msgid "" "int\n" "incr_item(PyObject *dict, PyObject *key)\n" @@ -1529,6 +1717,48 @@ msgid "" " return rv; /* -1 for error, 0 for success */\n" "}" msgstr "" +"int\n" +"incr_item(PyObject *dict, PyObject *key)\n" +"{\n" +" /* Py_XDECREF のため、すべてのオブジェクトを NULL で初期化する */\n" +" PyObject *item = NULL, *const_one = NULL, *incremented_item = NULL;\n" +" int rv = -1; /* 戻り値を -1 (失敗) で初期化する */\n" +"\n" +" item = PyObject_GetItem(dict, key);\n" +" if (item == NULL) {\n" +" /* KeyError のみ処理する: */\n" +" if (!PyErr_ExceptionMatches(PyExc_KeyError))\n" +" goto error;\n" +"\n" +" /* エラーを消去してゼロを使う: */\n" +" PyErr_Clear();\n" +" item = PyLong_FromLong(0L);\n" +" if (item == NULL)\n" +" goto error;\n" +" }\n" +" const_one = PyLong_FromLong(1L);\n" +" if (const_one == NULL)\n" +" goto error;\n" +"\n" +" incremented_item = PyNumber_Add(item, const_one);\n" +" if (incremented_item == NULL)\n" +" goto error;\n" +"\n" +" if (PyObject_SetItem(dict, key, incremented_item) < 0)\n" +" goto error;\n" +" rv = 0; /* 成功 */\n" +" /* 続いて後始末のコードを実行する */\n" +"\n" +" error:\n" +" /* 成功と失敗の両方で使う後始末のコード */\n" +"\n" +" /* NULL 参照を無視するため Py_XDECREF() を使う */\n" +" Py_XDECREF(item);\n" +" Py_XDECREF(const_one);\n" +" Py_XDECREF(incremented_item);\n" +"\n" +" return rv; /* エラーなら -1、成功なら 0 */\n" +"}" #: ../../c-api/intro.rst:1060 msgid "" @@ -1627,13 +1857,17 @@ msgstr "" "`PYTHONPATH` を設定して追加のディレクトリを標準モジュール検索パスの前に挿入し" "たりできます。" -#: ../../c-api/intro.rst:1116 msgid "" "The embedding application can steer the search by setting :c:member:" "`PyConfig.program_name` *before* calling :c:func:`Py_InitializeFromConfig`. " "Note that :envvar:`PYTHONHOME` still overrides this and :envvar:`PYTHONPATH` " "is still inserted in front of the standard path." msgstr "" +"Python を組み込むアプリケーションは、:c:func:`Py_InitializeFromConfig` を呼び" +"出す *前に* :c:member:`PyConfig.program_name` を設定することで、検索先を指定" +"できます。\n" +"この場合も :envvar:`PYTHONHOME` の指定が優先され、:envvar:`PYTHONPATH` は標準" +"のパスの前に挿入されます。" #: ../../c-api/intro.rst:1124 msgid "" @@ -1689,21 +1923,23 @@ msgstr "" "ロファイリングが利用可能です。よく使われるビルドについてのみ、この節の残りの" "部分で説明します。" -#: ../../c-api/intro.rst:1152 msgid "" "Compiling the interpreter with the :c:macro:`!Py_DEBUG` macro defined " "produces what is generally meant by :ref:`a debug build of Python `." msgstr "" +":c:macro:`!Py_DEBUG` マクロを定義してインタープリタをコンパイルすると、一般" +"に :ref:`Python のデバッグビルド ` と呼ばれるものができます。" -#: ../../c-api/intro.rst:1155 msgid "" "On Unix, :c:macro:`!Py_DEBUG` can be enabled by adding :option:`--with-" "pydebug` to the :file:`./configure` command. This will also disable compiler " "optimization." msgstr "" +"Unix では、:file:`./configure` コマンドに :option:`--with-pydebug` を追加し" +"て :c:macro:`!Py_DEBUG` を有効にできます。\n" +"これにより、コンパイラの最適化も無効になります。" -#: ../../c-api/intro.rst:1158 msgid "" "On Windows, selecting a debug build (e.g., by passing the :option:`-d` " "option to :file:`PCbuild/build.bat`) automatically enables :c:macro:`!" @@ -1711,12 +1947,17 @@ msgid "" "_DEBUG` macro, when defined by the compiler, will also implicitly enable :c:" "macro:`!Py_DEBUG`." msgstr "" +"Windows では、例えば :file:`PCbuild/build.bat` に :option:`-d` を渡すなどして" +"デバッグビルドを選ぶと、:c:macro:`!Py_DEBUG` が自動的に有効になります。\n" +"さらに、Python 固有ではない :c:macro:`!_DEBUG` マクロがコンパイラによって定義" +"されている場合も、:c:macro:`!Py_DEBUG` が暗黙に有効になります。" -#: ../../c-api/intro.rst:1163 msgid "" "In addition to the reference count debugging described below, extra checks " "are performed. See :ref:`Python Debug Build ` for more details." msgstr "" +"以下で説明する参照カウントのデバッグに加え、追加の検査を行います。\n" +"詳しくは :ref:`Python のデバッグビルド ` を参照してください。" #: ../../c-api/intro.rst:1166 msgid "" @@ -1740,45 +1981,37 @@ msgstr "" msgid "Recommended third party tools" msgstr "おすすめのサードパーティツール" -#: ../../c-api/intro.rst:1182 msgid "" "The following third party tools offer both simpler and more sophisticated " "approaches to creating C, C++ and Rust extensions for Python:" msgstr "" +"以下のサードパーティーツールは、Python 用の C、C++、Rust 拡張を、より簡単かつ" +"高度な方法で作成できるようにします。" -#: ../../c-api/intro.rst:1185 msgid "`Cython `_" -msgstr "" +msgstr "`Cython `_" -#: ../../c-api/intro.rst:1186 msgid "`cffi `_" -msgstr "" +msgstr "`cffi `_" -#: ../../c-api/intro.rst:1187 msgid "`HPy `_" -msgstr "" +msgstr "`HPy `_" -#: ../../c-api/intro.rst:1188 msgid "`nanobind `_ (C++)" -msgstr "" +msgstr "`nanobind `_ (C++)" -#: ../../c-api/intro.rst:1189 msgid "`Numba `_" -msgstr "" +msgstr "`Numba `_" -#: ../../c-api/intro.rst:1190 msgid "`pybind11 `_ (C++)" -msgstr "" +msgstr "`pybind11 `_ (C++)" -#: ../../c-api/intro.rst:1191 msgid "`PyO3 `_ (Rust)" -msgstr "" +msgstr "`PyO3 `_ (Rust)" -#: ../../c-api/intro.rst:1192 msgid "`SWIG `_" -msgstr "" +msgstr "`SWIG `_" -#: ../../c-api/intro.rst:1194 msgid "" "Using tools such as these can help avoid writing code that is tightly bound " "to a particular version of CPython, avoid reference counting errors, and " @@ -1788,14 +2021,23 @@ msgid "" "support compiling for other implementations of Python from a single set of " "sources." msgstr "" +"これらのツールを使うと、特定の CPython バージョンに強く依存したコードや、参照" +"カウントの誤りを避けられ、CPython API の扱いよりも自分のコードに集中できま" +"す。\n" +"一般に、ツールを更新することで Python の新しいバージョンに対応でき、より新し" +"く効率的な API が自動的に使われることもよくあります。\n" +"1 つのソースから、Python のほかの実装向けにコンパイルできるツールもあります。" -#: ../../c-api/intro.rst:1201 msgid "" "These projects are not supported by the same people who maintain Python, and " "issues need to be raised with the projects directly. Remember to check that " "the project is still maintained and supported, as the list above may become " "outdated." msgstr "" +"これらのプロジェクトのサポートは Python の保守担当者とは別の人々が行っている" +"ため、問題は各プロジェクトに直接報告する必要があります。\n" +"上の一覧は古くなる可能性があるので、そのプロジェクトの保守とサポートが続いて" +"いることを確認してください。" #: ../../c-api/intro.rst:1208 msgid "" @@ -1823,33 +2065,27 @@ msgstr "object" msgid "type" msgstr "type" -#: ../../c-api/intro.rst:668 msgid "Py_INCREF (C function)" -msgstr "" +msgstr "Py_INCREF (C の関数)" -#: ../../c-api/intro.rst:668 msgid "Py_DECREF (C function)" -msgstr "" +msgstr "Py_DECREF (C の関数)" -#: ../../c-api/intro.rst:747 msgid "PyList_SetItem (C function)" -msgstr "" +msgstr "PyList_SetItem (C の関数)" -#: ../../c-api/intro.rst:747 msgid "PyTuple_SetItem (C function)" -msgstr "" +msgstr "PyTuple_SetItem (C の関数)" #: ../../c-api/intro.rst:818 msgid "set_all()" msgstr "set_all()" -#: ../../c-api/intro.rst:837 msgid "PyList_GetItem (C function)" -msgstr "" +msgstr "PyList_GetItem (C の関数)" -#: ../../c-api/intro.rst:837 msgid "PySequence_GetItem (C function)" -msgstr "" +msgstr "PySequence_GetItem (C の関数)" #: ../../c-api/intro.rst:867 msgid "sum_list()" @@ -1859,17 +2095,14 @@ msgstr "sum_list()" msgid "sum_sequence()" msgstr "sum_sequence()" -#: ../../c-api/intro.rst:934 msgid "PyErr_Occurred (C function)" -msgstr "" +msgstr "PyErr_Occurred (C の関数)" -#: ../../c-api/intro.rst:947 msgid "PyErr_SetString (C function)" -msgstr "" +msgstr "PyErr_SetString (C の関数)" -#: ../../c-api/intro.rst:947 ../../c-api/intro.rst:1055 msgid "PyErr_Clear (C function)" -msgstr "" +msgstr "PyErr_Clear (C の関数)" #: ../../c-api/intro.rst:971 msgid "exc_info (in module sys)" @@ -1879,17 +2112,14 @@ msgstr "exc_info (sys モジュール)" msgid "incr_item()" msgstr "incr_item()" -#: ../../c-api/intro.rst:1055 msgid "PyErr_ExceptionMatches (C function)" -msgstr "" +msgstr "PyErr_ExceptionMatches (C の関数)" -#: ../../c-api/intro.rst:1055 msgid "Py_XDECREF (C function)" -msgstr "" +msgstr "Py_XDECREF (C の関数)" -#: ../../c-api/intro.rst:1081 msgid "Py_Initialize (C function)" -msgstr "" +msgstr "Py_Initialize (C の関数)" #: ../../c-api/intro.rst:1081 msgid "module" @@ -1919,6 +2149,5 @@ msgstr "パス" msgid "path (in module sys)" msgstr "path (sys モジュール)" -#: ../../c-api/intro.rst:1122 msgid "Py_IsInitialized (C function)" -msgstr "" +msgstr "Py_IsInitialized (C の関数)" diff --git a/c-api/iter.po b/c-api/iter.po index bffbf7283..5a230457f 100644 --- a/c-api/iter.po +++ b/c-api/iter.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/iter.rst:6 @@ -30,33 +30,42 @@ msgstr "イテレータプロトコル (iterator protocol)" msgid "There are two functions specifically for working with iterators." msgstr "イテレータを扱うための固有の関数は二つあります。" -#: ../../c-api/iter.rst:12 msgid "" "Return non-zero if the object *o* can be safely passed to :c:func:" "`PyIter_NextItem` and ``0`` otherwise. This function always succeeds." msgstr "" +"オブジェクト *o* を :c:func:`PyIter_NextItem` に安全に渡せる場合はゼロ以外" +"を、そうでなければ ``0`` を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/iter.rst:18 msgid "" "Return non-zero if the object *o* provides the :class:`AsyncIterator` " "protocol, and ``0`` otherwise. This function always succeeds." msgstr "" +"オブジェクト *o* が :class:`AsyncIterator` プロトコルを提供する場合はゼロ以外" +"を、そうでなければ ``0`` を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/iter.rst:25 msgid "" "Return ``1`` and set *item* to a :term:`strong reference` of the next value " "of the iterator *iter* on success. Return ``0`` and set *item* to ``NULL`` " "if there are no remaining values. Return ``-1``, set *item* to ``NULL`` and " "set an exception on error." msgstr "" +"成功すると、*item* にイテレータ *iter* の次の値への :term:`強参照 ` を設定し、``1`` を返します。\n" +"残りの値がなければ、*item* に ``NULL`` を設定し、``0`` を返します。\n" +"エラーの場合は、*item* に ``NULL`` を設定し、例外を設定して ``-1`` を返しま" +"す。" -#: ../../c-api/iter.rst:34 msgid "" "This is an older version of :c:func:`!PyIter_NextItem`, which is retained " "for backwards compatibility. Prefer :c:func:`PyIter_NextItem`." msgstr "" +"これは :c:func:`!PyIter_NextItem` の古い版で、後方互換性のために残されていま" +"す。\n" +":c:func:`PyIter_NextItem` を使ってください。" -#: ../../c-api/iter.rst:38 msgid "" "Return the next value from the iterator *o*. The object must be an iterator " "according to :c:func:`PyIter_Check` (it is up to the caller to check this). " @@ -64,28 +73,36 @@ msgid "" "an error occurs while retrieving the item, returns ``NULL`` and passes along " "the exception." msgstr "" +"イテレータ *o* から次の値を返します。\n" +"このオブジェクトは :c:func:`PyIter_Check` で判定されるイテレータでなければな" +"りません (確認は呼び出し側の責任です)。\n" +"残りの値がなければ、例外を設定せずに ``NULL`` を返します。\n" +"要素の取得中にエラーが起きると、``NULL`` を返して例外を引き継ぎます。" -#: ../../c-api/iter.rst:46 msgid "" "The enum value used to represent different results of :c:func:`PyIter_Send`." -msgstr "" +msgstr ":c:func:`PyIter_Send` の各種の結果を表す列挙値です。" -#: ../../c-api/iter.rst:53 msgid "Sends the *arg* value into the iterator *iter*. Returns:" msgstr "" +"値 *arg* をイテレータ *iter* に送ります。\n" +"戻り値は次のとおりです:" -#: ../../c-api/iter.rst:55 msgid "" "``PYGEN_RETURN`` if iterator returns. Return value is returned via *presult*." msgstr "" +"イテレータが return した場合は ``PYGEN_RETURN``。\n" +"戻り値は *presult* を通じて返します。" -#: ../../c-api/iter.rst:56 msgid "" "``PYGEN_NEXT`` if iterator yields. Yielded value is returned via *presult*." msgstr "" +"イテレータが yield した場合は ``PYGEN_NEXT``。\n" +"yield した値は *presult* を通じて返します。" -#: ../../c-api/iter.rst:57 msgid "" "``PYGEN_ERROR`` if iterator has raised an exception. *presult* is set to " "``NULL``." msgstr "" +"イテレータが例外を送出した場合は ``PYGEN_ERROR``。\n" +"*presult* は ``NULL`` になります。" diff --git a/c-api/iterator.po b/c-api/iterator.po index fc456648c..b2f0254d4 100644 --- a/c-api/iterator.po +++ b/c-api/iterator.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/iterator.rst:6 @@ -50,13 +50,12 @@ msgstr "" "関数 :func:`iter` を呼び出したときに返される、イテレータオブジェクトの型オブ" "ジェクトです。" -#: ../../c-api/iterator.rst:24 msgid "" "Return true if the type of *op* is :c:data:`PySeqIter_Type`. This function " "always succeeds." msgstr "" -"*op* の型が :c:data:`PySeqlter_Type` 型の場合に真を返します。この関数は常に成" -"功します。" +"``op`` の型が :c:data:`PySeqIter_Type` の場合に真を返します。\n" +"この関数は常に成功します。" #: ../../c-api/iterator.rst:30 msgid "" @@ -96,29 +95,29 @@ msgstr "" "れたイテレータは、*callable* が *sentinel* に等しい値を返すと反復処理を終了し" "ます。" -#: ../../c-api/iterator.rst:56 msgid "Range Objects" -msgstr "" +msgstr "range オブジェクト" -#: ../../c-api/iterator.rst:60 msgid "The type object for :class:`range` objects." -msgstr "" +msgstr ":class:`range` オブジェクトの型オブジェクト。" -#: ../../c-api/iterator.rst:65 msgid "" "Return true if the object *o* is an instance of a :class:`range` object. " "This function always succeeds." msgstr "" +"オブジェクト ``o`` が :class:`range` のインスタンスの場合に真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/iterator.rst:70 msgid "Builtin Iterator Types" -msgstr "" +msgstr "組み込みのイテレータ型" -#: ../../c-api/iterator.rst:72 msgid "" "These are built-in iteration types that are included in Python's C API, but " "provide no additional functions. They are here for completeness." msgstr "" +"以下は Python の C API に含まれる組み込みのイテレータ型で、追加の関数はありま" +"せん。\n" +"網羅性のために記載しています。" #: ../../c-api/iterator.rst:80 msgid "C type" @@ -128,44 +127,41 @@ msgstr "C の型" msgid "Python type" msgstr "Python の型" -#: ../../c-api/iterator.rst:83 msgid ":py:class:`enumerate`" -msgstr "" +msgstr ":py:class:`enumerate`" -#: ../../c-api/iterator.rst:85 msgid ":py:class:`filter`" -msgstr "" +msgstr ":py:class:`filter`" -#: ../../c-api/iterator.rst:87 msgid ":py:class:`map`" -msgstr "" +msgstr ":py:class:`map`" -#: ../../c-api/iterator.rst:89 msgid ":py:class:`reversed`" -msgstr "" +msgstr ":py:class:`reversed`" -#: ../../c-api/iterator.rst:91 msgid ":py:class:`zip`" -msgstr "" +msgstr ":py:class:`zip`" -#: ../../c-api/iterator.rst:95 msgid "Other Iterator Objects" -msgstr "" +msgstr "その他のイテレータオブジェクト" -#: ../../c-api/iterator.rst:113 msgid "Type objects for iterators of various built-in objects." -msgstr "" +msgstr "さまざまな組み込みオブジェクトのイテレータの型オブジェクト。" -#: ../../c-api/iterator.rst:115 msgid "" "Do not create instances of these directly; prefer calling :c:func:" "`PyObject_GetIter` instead." msgstr "" +"これらのインスタンスを直接作成せず、代わりに :c:func:`PyObject_GetIter` を呼" +"び出してください。" -#: ../../c-api/iterator.rst:118 msgid "" "Note that there is no guarantee that a given built-in type uses a given " "iterator type. For example, iterating over :class:`range` will use one of " "two iterator types depending on the size of the range. Other types may start " "using a similar scheme in the future, without warning." msgstr "" +"ある組み込み型が特定のイテレータ型を使う保証はありません。\n" +"例えば :class:`range` の反復では、範囲の大きさに応じて二つのイテレータ型のど" +"ちらかを使います。\n" +"ほかの型も、将来予告なく同様の方式を使うようになる可能性があります。" diff --git a/c-api/lifecycle.po b/c-api/lifecycle.po index 901ed40d0..67028b14a 100644 --- a/c-api/lifecycle.po +++ b/c-api/lifecycle.po @@ -16,75 +16,84 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/lifecycle.rst:6 msgid "Object Life Cycle" -msgstr "" +msgstr "オブジェクトのライフサイクル" -#: ../../c-api/lifecycle.rst:8 msgid "" "This section explains how a type's slots relate to each other throughout the " "life of an object. It is not intended to be a complete canonical reference " "for the slots; instead, refer to the slot-specific documentation in :ref:" "`type-structs` for details about a particular slot." msgstr "" +"この節では、オブジェクトの生存期間を通じて型の各スロットがどのように関係する" +"かを説明します。\n" +"各スロットの完全なリファレンスを意図したものではありません。\n" +"個々のスロットの詳細は :ref:`type-structs` の該当する説明を参照してください。" -#: ../../c-api/lifecycle.rst:15 msgid "Life Events" -msgstr "" +msgstr "生存期間中のイベント" -#: ../../c-api/lifecycle.rst:17 msgid "" "The figure below illustrates the order of events that can occur throughout " "an object's life. An arrow from *A* to *B* indicates that event *B* can " "occur after event *A* has occurred, with the arrow's label indicating the " "condition that must be true for *B* to occur after *A*." msgstr "" +"次の図は、オブジェクトの生存期間中に起こり得るイベントの順序を示していま" +"す。\n" +"*A* から *B* への矢印は、イベント *A* の後にイベント *B* が起こり得ることを示" +"します。\n" +"矢印のラベルは、*A* の後に *B* が起こるために必要な条件を表します。" -#: ../../c-api/lifecycle.rst:55 msgid "Diagram showing events in an object's life. Explained in detail below." msgstr "" +"オブジェクトの生存期間中のイベントを示す図。\n" +"詳細は後述します。" -#: ../../c-api/lifecycle.rst:63 msgid "Explanation:" -msgstr "" +msgstr "説明:" -#: ../../c-api/lifecycle.rst:65 msgid "When a new object is constructed by calling its type:" -msgstr "" +msgstr "型を呼び出して新しいオブジェクトを構築するとき:" -#: ../../c-api/lifecycle.rst:67 msgid ":c:member:`~PyTypeObject.tp_new` is called to create a new object." msgstr "" +"新しいオブジェクトを作成するために :c:member:`~PyTypeObject.tp_new` が呼び出" +"されます。" -#: ../../c-api/lifecycle.rst:68 msgid "" ":c:member:`~PyTypeObject.tp_alloc` is directly called by :c:member:" "`~PyTypeObject.tp_new` to allocate the memory for the new object." msgstr "" +":c:member:`~PyTypeObject.tp_new` が :c:member:`~PyTypeObject.tp_alloc` を直接" +"呼び出し、新しいオブジェクトのメモリを割り当てます。" -#: ../../c-api/lifecycle.rst:71 msgid "" ":c:member:`~PyTypeObject.tp_init` initializes the newly created object. :c:" "member:`!tp_init` can be called again to re-initialize an object, if " "desired. The :c:member:`!tp_init` call can also be skipped entirely, for " "example by Python code calling :py:meth:`~object.__new__`." msgstr "" +":c:member:`~PyTypeObject.tp_init` が新しく作成されたオブジェクトを初期化しま" +"す。\n" +"必要であれば :c:member:`!tp_init` を再度呼び出してオブジェクトを再初期化でき" +"ます。\n" +"また、例えば Python コードから :py:meth:`~object.__new__` を呼び出す場合な" +"ど、:c:member:`!tp_init` の呼び出しを完全に省くこともできます。" -#: ../../c-api/lifecycle.rst:76 msgid "After :c:member:`!tp_init` completes, the object is ready to use." msgstr "" +":c:member:`!tp_init` が完了すると、オブジェクトを使えるようになります。" -#: ../../c-api/lifecycle.rst:77 msgid "Some time after the last reference to an object is removed:" -msgstr "" +msgstr "オブジェクトへの最後の参照が取り除かれてからしばらく後:" -#: ../../c-api/lifecycle.rst:79 msgid "" "If an object is not marked as *finalized*, it might be finalized by marking " "it as *finalized* and calling its :c:member:`~PyTypeObject.tp_finalize` " @@ -92,30 +101,46 @@ msgid "" "it is deleted; use :c:func:`PyObject_CallFinalizerFromDealloc` to ensure " "that :c:member:`~PyTypeObject.tp_finalize` is always called." msgstr "" +"オブジェクトに *ファイナライズ済み* の印が付いていない場合、*ファイナライズ済" +"み* として印を付けて :c:member:`~PyTypeObject.tp_finalize` 関数を呼び出すこと" +"により、ファイナライズされる可能性があります。\n" +"Python は最後の参照が削除されたときにオブジェクトをファイナライズするわけで" +"は *ありません*。\n" +":c:member:`~PyTypeObject.tp_finalize` が必ず呼び出されるようにするには、:c:" +"func:`PyObject_CallFinalizerFromDealloc` を使ってください。" -#: ../../c-api/lifecycle.rst:85 msgid "" "If the object is marked as finalized, :c:member:`~PyTypeObject.tp_clear` " "might be called by the garbage collector to clear references held by the " "object. It is *not* called when the object's reference count reaches zero." msgstr "" +"オブジェクトにファイナライズ済みの印が付いている場合、ガベージコレクタが :c:" +"member:`~PyTypeObject.tp_clear` を呼び出して、オブジェクトの保持する参照をク" +"リアする可能性があります。\n" +"オブジェクトの参照カウントがゼロになったときに呼び出されるわけでは *ありませ" +"ん*。" -#: ../../c-api/lifecycle.rst:89 msgid "" ":c:member:`~PyTypeObject.tp_dealloc` is called to destroy the object. To " "avoid code duplication, :c:member:`~PyTypeObject.tp_dealloc` typically calls " "into :c:member:`~PyTypeObject.tp_clear` to free up the object's references." msgstr "" +"オブジェクトを破棄するために :c:member:`~PyTypeObject.tp_dealloc` が呼び出さ" +"れます。\n" +"コードの重複を避けるため、:c:member:`~PyTypeObject.tp_dealloc` は通常 :c:" +"member:`~PyTypeObject.tp_clear` を呼び出してオブジェクトの参照を解放します。" -#: ../../c-api/lifecycle.rst:93 msgid "" "When :c:member:`~PyTypeObject.tp_dealloc` finishes object destruction, it " "directly calls :c:member:`~PyTypeObject.tp_free` (usually set to :c:func:" "`PyObject_Free` or :c:func:`PyObject_GC_Del` automatically as appropriate " "for the type) to deallocate the memory." msgstr "" +":c:member:`~PyTypeObject.tp_dealloc` はオブジェクトの破棄を終えると、:c:" +"member:`~PyTypeObject.tp_free` を直接呼び出してメモリを解放します。\n" +"このスロットには通常、型に応じて :c:func:`PyObject_Free` または :c:func:" +"`PyObject_GC_Del` が自動的に設定されます。" -#: ../../c-api/lifecycle.rst:98 msgid "" "The :c:member:`~PyTypeObject.tp_finalize` function is permitted to add a " "reference to the object if desired. If it does, the object is " @@ -129,8 +154,20 @@ msgid "" "remove the mark if the object does not support garbage collection; either or " "both of these behaviors may change in the future." msgstr "" +":c:member:`~PyTypeObject.tp_finalize` 関数は、必要に応じてオブジェクトへの参" +"照を追加できます。\n" +"参照を追加するとオブジェクトが *復活* し、予定されていた破棄が阻止されま" +"す。\n" +"オブジェクトを復活させられるのは :c:member:`!tp_finalize` だけです。\n" +":c:member:`~PyTypeObject.tp_clear` と :c:member:`~PyTypeObject.tp_dealloc` " +"は、:c:member:`!tp_finalize` を呼び出さずに復活させることはできません。\n" +"復活したオブジェクトの *ファイナライズ済み* の印は、取り除かれる場合も残る場" +"合もあります。\n" +"現在の Python は、ガベージコレクションをサポートするオブジェクト (:c:macro:" +"`Py_TPFLAGS_HAVE_GC` フラグが設定されているもの) が復活した場合は *ファイナラ" +"イズ済み* の印を残し、サポートしない場合は印を取り除きます。\n" +"これらの動作の一方または両方は、将来変更される可能性があります。" -#: ../../c-api/lifecycle.rst:111 msgid "" ":c:member:`~PyTypeObject.tp_dealloc` can optionally call :c:member:" "`~PyTypeObject.tp_finalize` via :c:func:`PyObject_CallFinalizerFromDealloc` " @@ -139,8 +176,13 @@ msgid "" "called before destruction. See the :c:member:`~PyTypeObject.tp_dealloc` " "documentation for example code." msgstr "" +":c:member:`~PyTypeObject.tp_dealloc` は、オブジェクトの破棄処理にコードを再利" +"用したい場合、:c:func:`PyObject_CallFinalizerFromDealloc` を介して :c:member:" +"`~PyTypeObject.tp_finalize` を呼び出すことができます。\n" +"これによって破棄前に必ず :c:member:`!tp_finalize` が呼び出されるので、この方" +"法を推奨します。\n" +"コード例は :c:member:`~PyTypeObject.tp_dealloc` の説明を参照してください。" -#: ../../c-api/lifecycle.rst:118 msgid "" "If the object is a member of a :term:`cyclic isolate` and either :c:member:" "`~PyTypeObject.tp_clear` fails to break the reference cycle or the cyclic " @@ -149,21 +191,31 @@ msgid "" "involved types), the objects remain indefinitely uncollectable (they " "\"leak\"). See :data:`gc.garbage`." msgstr "" +"オブジェクトが :term:`孤立した循環参照群 ` の一部であり、:c:" +"member:`~PyTypeObject.tp_clear` が循環参照を解消できないか、その循環参照群が" +"検出されない場合、オブジェクトはいつまでも回収できずに残ります (「リーク」し" +"ます)。\n" +"検出されない原因としては、:func:`gc.disable` が呼び出された場合や、関連する型" +"のいずれかで誤って :c:macro:`Py_TPFLAGS_HAVE_GC` フラグが省かれた場合などが考" +"えられます。\n" +":data:`gc.garbage` を参照してください。" -#: ../../c-api/lifecycle.rst:125 msgid "" "If the object is marked as supporting garbage collection (the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag is set in :c:member:`~PyTypeObject.tp_flags`), the " "following events are also possible:" msgstr "" +"オブジェクトがガベージコレクションをサポートすると示されている場合 (:c:" +"member:`~PyTypeObject.tp_flags` に :c:macro:`Py_TPFLAGS_HAVE_GC` フラグが設定" +"されている場合)、次のイベントも起こり得ます。" -#: ../../c-api/lifecycle.rst:129 msgid "" "The garbage collector occasionally calls :c:member:`~PyTypeObject." "tp_traverse` to identify :term:`cyclic isolates `." msgstr "" +"ガベージコレクタは、ときどき :c:member:`~PyTypeObject.tp_traverse` を呼び出し" +"て :term:`孤立した循環参照群 ` を特定します。" -#: ../../c-api/lifecycle.rst:132 msgid "" "When the garbage collector discovers a :term:`cyclic isolate`, it finalizes " "one of the objects in the group by marking it as *finalized* and calling " @@ -171,8 +223,12 @@ msgid "" "repeats until the cyclic isolate doesn't exist or all of the objects have " "been finalized." msgstr "" +"ガベージコレクタは :term:`孤立した循環参照群 ` を発見すると、" +"その群のオブジェクトの 1 つに *ファイナライズ済み* の印を付け、:c:member:" +"`~PyTypeObject.tp_finalize` 関数があれば呼び出して、ファイナライズします。\n" +"これを、孤立した循環参照群がなくなるか、すべてのオブジェクトがファイナライズ" +"されるまで繰り返します。" -#: ../../c-api/lifecycle.rst:137 msgid "" ":c:member:`~PyTypeObject.tp_finalize` is permitted to resurrect the object " "by adding a reference from outside the :term:`cyclic isolate`. The new " @@ -180,8 +236,11 @@ msgid "" "(the reference cycle may still exist, but if it does the objects are no " "longer isolated)." msgstr "" +":c:member:`~PyTypeObject.tp_finalize` は、:term:`孤立した循環参照群 ` の外から参照を追加することで、オブジェクトを復活させられます。\n" +"新しい参照が加わると、その群は孤立した循環参照群ではなくなります (循環参照が" +"残っていても、オブジェクトはもはや孤立していません)。" -#: ../../c-api/lifecycle.rst:142 msgid "" "When the garbage collector discovers a :term:`cyclic isolate` and all of the " "objects in the group have already been marked as *finalized*, the garbage " @@ -190,12 +249,17 @@ msgid "" "function. This repeats as long as the cyclic isolate still exists and not " "all of the objects have been cleared." msgstr "" +"ガベージコレクタが :term:`孤立した循環参照群 ` を発見し、その" +"群のすべてのオブジェクトに *ファイナライズ済み* の印が付いている場合、\n" +"まだクリアされていないオブジェクトのうち 1 つ以上について、それぞれの :c:" +"member:`~PyTypeObject.tp_clear` 関数を呼び出してクリアします (並行して行われ" +"る場合もあります)。\n" +"孤立した循環参照群が残っており、まだすべてのオブジェクトがクリアされていない" +"間、この処理を繰り返します。" -#: ../../c-api/lifecycle.rst:151 msgid "Cyclic Isolate Destruction" -msgstr "" +msgstr "孤立した循環参照群の破棄" -#: ../../c-api/lifecycle.rst:153 msgid "" "Listed below are the stages of life of a hypothetical :term:`cyclic isolate` " "that continues to exist after each member object is finalized or cleared. " @@ -205,15 +269,24 @@ msgid "" "because the objects are no longer isolated due to finalizer resurrection " "(see :c:member:`~PyTypeObject.tp_finalize`)." msgstr "" +"以下では、各オブジェクトをファイナライズまたはクリアした後も残り続けると仮定" +"した :term:`孤立した循環参照群 ` の段階を示します。\n" +"孤立した循環参照群がすべての段階を通過するなら、それはメモリリークです。\n" +"遅くともすべてのオブジェクトをクリアした時点で、孤立した循環参照群はなくなる" +"べきです。\n" +"循環参照が解消されるか、ファイナライザによる復活によってオブジェクトが孤立し" +"なくなると、孤立した循環参照群はなくなります (:c:member:`~PyTypeObject." +"tp_finalize` を参照)。" -#: ../../c-api/lifecycle.rst:161 msgid "" "**Reachable** (not yet a cyclic isolate): All objects are in their normal, " "reachable state. A reference cycle could exist, but an external reference " "means the objects are not yet isolated." msgstr "" +"**到達可能** (まだ孤立した循環参照群ではありません): すべてのオブジェクトが通" +"常の到達可能な状態にあります。\n" +"循環参照があっても、外部からの参照があるのでまだ孤立していません。" -#: ../../c-api/lifecycle.rst:164 msgid "" "**Unreachable but consistent:** The final reference from outside the cyclic " "group of objects has been removed, causing the objects to become isolated " @@ -222,8 +295,14 @@ msgid "" "some future run of the garbage collector (not necessarily the next run " "because the next run might not scan every object)." msgstr "" +"**到達不能だが整合性は保たれている:** 循環参照しているオブジェクト群への外部" +"からの最後の参照が取り除かれ、オブジェクトが孤立した状態です (これによって孤" +"立した循環参照群が生じます)。\n" +"群のどのオブジェクトも、まだファイナライズもクリアもされていません。\n" +"孤立した循環参照群は、将来ガベージコレクタが実行されるまでこの段階にとどまり" +"ます (次の実行で全オブジェクトを調べるとは限らないため、必ずしも次回とは限り" +"ません)。" -#: ../../c-api/lifecycle.rst:170 msgid "" "**Mix of finalized and not finalized:** Objects in a cyclic isolate are " "finalized one at a time, which means that there is a period of time when the " @@ -233,22 +312,35 @@ msgid "" "it, and a non-finalized object must be able to tolerate the finalization of " "an arbitrary subset of its referents." msgstr "" +"**ファイナライズ済みと未ファイナライズが混在:** 孤立した循環参照群のオブジェ" +"クトは 1 つずつファイナライズされるため、ファイナライズ済みとそうでないオブ" +"ジェクトが混在する期間があります。\n" +"ファイナライズの順序は規定されていないため、無作為に見えることがあります。\n" +"ファイナライズ済みオブジェクトは、未ファイナライズのオブジェクトから操作され" +"ても適切に動作しなければなりません。\n" +"また、未ファイナライズのオブジェクトは、自分の参照先の任意の一部がファイナラ" +"イズされても問題なく扱える必要があります。" -#: ../../c-api/lifecycle.rst:177 msgid "" "**All finalized:** All objects in a cyclic isolate are finalized before any " "of them are cleared." msgstr "" +"**すべてファイナライズ済み:** 孤立した循環参照群では、どのオブジェクトもクリ" +"アされる前に、すべてのオブジェクトがファイナライズされます。" -#: ../../c-api/lifecycle.rst:179 msgid "" "**Mix of finalized and cleared:** The objects can be cleared serially or " "concurrently (but with the :term:`GIL` held); either way, some will finish " "before others. A finalized object must be able to tolerate the clearing of " "a subset of its referents. :pep:`442` calls this stage \"cyclic trash\"." msgstr "" +"**ファイナライズ済みとクリア済みが混在:** オブジェクトは逐次的にも並行的にも" +"クリアされ得ますが、:term:`GIL` を保持して行われます。\n" +"いずれの場合も、他のオブジェクトより先にクリアが完了するものがあります。\n" +"ファイナライズ済みオブジェクトは、自分の参照先の一部がクリアされても問題なく" +"扱える必要があります。\n" +":pep:`442` ではこの段階を「cyclic trash」と呼んでいます。" -#: ../../c-api/lifecycle.rst:183 msgid "" "**Leaked:** If a cyclic isolate still exists after all objects in the group " "have been finalized and cleared, then the objects remain indefinitely " @@ -257,8 +349,13 @@ msgid "" "of the participating objects have failed to break the reference cycle as " "required." msgstr "" +"**リーク:** 群のすべてのオブジェクトをファイナライズし、クリアした後も孤立し" +"た循環参照群が残る場合、それらのオブジェクトはいつまでも回収できずに残ります " +"(:data:`gc.garbage` を参照)。\n" +"孤立した循環参照群がこの段階に達するのはバグです。\n" +"関与するオブジェクトの :c:member:`~PyTypeObject.tp_clear` メソッドが、必要な" +"循環参照の解消に失敗したことを意味します。" -#: ../../c-api/lifecycle.rst:190 msgid "" "If :c:member:`~PyTypeObject.tp_clear` did not exist, then Python would have " "no way to safely break a reference cycle. Simply destroying an object in a " @@ -269,8 +366,17 @@ msgid "" "objects enough to detangle them from each other, then :c:member:" "`~PyTypeObject.tp_dealloc` is called to complete the destruction." msgstr "" +":c:member:`~PyTypeObject.tp_clear` がなければ、Python には循環参照を安全に解" +"消する方法がありません。\n" +"孤立した循環参照群のオブジェクトを単に破棄すると、ダングリングポインタが生じ" +"ます。\n" +"破棄済みのオブジェクトを参照するオブジェクトが破棄される際に、未定義の動作を" +"引き起こします。\n" +"クリアの段階を設けることで、オブジェクトの破棄は 2 段階になります。\n" +"まず :c:member:`~PyTypeObject.tp_clear` を呼び出し、オブジェクト同士の結び付" +"きを解くのに十分なだけ部分的に破棄します。\n" +"次に :c:member:`~PyTypeObject.tp_dealloc` を呼び出し、破棄を完了します。" -#: ../../c-api/lifecycle.rst:199 msgid "" "Unlike clearing, finalization is not a phase of destruction. A finalized " "object must still behave properly by continuing to fulfill its design " @@ -281,8 +387,16 @@ msgid "" "`~PyTypeObject.tp_clear` (if called) and concludes with :c:member:" "`~PyTypeObject.tp_dealloc`." msgstr "" +"クリアとは異なり、ファイナライズは破棄の一段階ではありません。\n" +"ファイナライズ済みのオブジェクトも、設計上の契約を引き続き満たし、正しく動作" +"しなければなりません。\n" +"オブジェクトのファイナライザは任意の Python コードを実行でき、参照を追加し" +"て、間近に迫った破棄を防ぐことさえできます。\n" +"ファイナライザと破棄が関係するのは呼び出し順序だけです。\n" +"ファイナライザが実行されるなら、それは破棄より前です。\n" +"破棄は :c:member:`~PyTypeObject.tp_clear` (呼び出す場合) から始まり、:c:" +"member:`~PyTypeObject.tp_dealloc` で完了します。" -#: ../../c-api/lifecycle.rst:207 msgid "" "The finalization step is not necessary to safely reclaim the objects in a " "cyclic isolate, but its existence makes it easier to design types that " @@ -293,30 +407,45 @@ msgid "" "with cleared objects; non-finalized objects are guaranteed to interact with " "only non-cleared (but potentially finalized) objects." msgstr "" +"孤立した循環参照群のオブジェクトを安全に回収するために、ファイナライズの段階" +"は必須ではありません。\n" +"ただし、この段階があることで、オブジェクトがクリアされても適切に動作する型を" +"設計しやすくなります。\n" +"オブジェクトのクリアでは、部分的に破棄された壊れた状態を避けられない場合があ" +"ります。\n" +"クリア済みのオブジェクトのメソッド呼び出しや属性へのアクセスは、どれも安全で" +"ないかもしれません。\n" +"ファイナライズの段階があれば、クリア済みのオブジェクトとやり取りする可能性が" +"あるのはファイナライズ済みのオブジェクトだけです。\n" +"未ファイナライズのオブジェクトがやり取りする相手は、未クリア (ただしファイナ" +"ライズ済みの場合もあります) のオブジェクトだけであると保証されます。" -#: ../../c-api/lifecycle.rst:216 msgid "To summarize the possible interactions:" -msgstr "" +msgstr "起こり得る参照関係をまとめると、次のようになります。" -#: ../../c-api/lifecycle.rst:218 msgid "" "A non-finalized object might have references to or from non-finalized and " "finalized objects, but not to or from cleared objects." msgstr "" +"未ファイナライズのオブジェクトは、未ファイナライズまたはファイナライズ済みの" +"オブジェクトへの参照や、それらからの参照を持つことがあります。\n" +"クリア済みオブジェクトとの間には、そのような参照はありません。" -#: ../../c-api/lifecycle.rst:220 msgid "" "A finalized object might have references to or from non-finalized, " "finalized, and cleared objects." msgstr "" +"ファイナライズ済みのオブジェクトは、未ファイナライズ、ファイナライズ済み、ク" +"リア済みのいずれのオブジェクトへの参照や、それらからの参照も持ち得ます。" -#: ../../c-api/lifecycle.rst:222 msgid "" "A cleared object might have references to or from finalized and cleared " "objects, but not to or from non-finalized objects." msgstr "" +"クリア済みのオブジェクトは、ファイナライズ済みまたはクリア済みのオブジェクト" +"への参照や、それらからの参照を持つことがあります。\n" +"未ファイナライズのオブジェクトとの間には、そのような参照はありません。" -#: ../../c-api/lifecycle.rst:225 msgid "" "Without any reference cycles, an object can be simply destroyed once its " "last reference is deleted; the finalization and clearing steps are not " @@ -329,16 +458,28 @@ msgid "" "`~PyTypeObject.tp_clear` as needed to destroy a cyclic isolate; this may " "change in a future version." msgstr "" +"循環参照がなければ、最後の参照が削除された時点でオブジェクトを単に破棄できま" +"す。\n" +"使われなくなったオブジェクトを安全に回収するために、ファイナライズやクリアの" +"段階は必要ありません。\n" +"それでも、破棄前に :c:member:`~PyTypeObject.tp_finalize` と :c:member:" +"`~PyTypeObject.tp_clear` を自動的に呼び出すことには利点があります。\n" +"孤立した循環参照群に属していたかどうかにかかわらず、すべてのオブジェクトが常" +"に同じ一連のイベントを経るようにすると、型の設計が簡単になるためです。\n" +"現在の Python は、孤立した循環参照群の破棄に必要な場合にだけ :c:member:" +"`~PyTypeObject.tp_finalize` と :c:member:`~PyTypeObject.tp_clear` を呼び出し" +"ます。\n" +"これは将来のバージョンで変更される可能性があります。" #: ../../c-api/lifecycle.rst:237 msgid "Functions" msgstr "関数" -#: ../../c-api/lifecycle.rst:239 msgid "To allocate and free memory, see :ref:`allocating-objects`." msgstr "" +"メモリの割り当てと解放については :ref:`allocating-objects` を参照してくださ" +"い。" -#: ../../c-api/lifecycle.rst:244 msgid "" "Finalizes the object as described in :c:member:`~PyTypeObject.tp_finalize`. " "Call this function (or :c:func:`PyObject_CallFinalizerFromDealloc`) instead " @@ -348,8 +489,16 @@ msgid "" "collection (i.e., the :c:macro:`Py_TPFLAGS_HAVE_GC` flag is set); this may " "change in the future." msgstr "" +":c:member:`~PyTypeObject.tp_finalize` の説明に従ってオブジェクトをファイナラ" +"イズします。\n" +":c:member:`~PyTypeObject.tp_finalize` を直接呼び出すのではなく、この関数か :" +"c:func:`PyObject_CallFinalizerFromDealloc` を呼び出してください。\n" +"この関数は :c:member:`!tp_finalize` の重複する呼び出しを省く場合があるためで" +"す。\n" +"現在は、型がガベージコレクションをサポートする場合 (:c:macro:" +"`Py_TPFLAGS_HAVE_GC` フラグが設定されている場合) にだけ重複を省きますが、将来" +"変更される可能性があります。" -#: ../../c-api/lifecycle.rst:257 msgid "" "Same as :c:func:`PyObject_CallFinalizer` but meant to be called at the " "beginning of the object's destructor (:c:member:`~PyTypeObject.tp_dealloc`). " @@ -358,7 +507,12 @@ msgid "" "should happen. Otherwise, this function returns 0 and destruction can " "continue normally." msgstr "" +":c:func:`PyObject_CallFinalizer` と同じですが、オブジェクトのデストラクタ (:" +"c:member:`~PyTypeObject.tp_dealloc`) の冒頭で呼び出すための関数です。\n" +"オブジェクトへの参照が残っていてはいけません。\n" +"ファイナライザがオブジェクトを復活させた場合は -1 を返します。\n" +"この場合、これ以上破棄を進めてはいけません。\n" +"それ以外の場合は 0 を返し、通常どおり破棄を続行できます。" -#: ../../c-api/lifecycle.rst:268 msgid ":c:member:`~PyTypeObject.tp_dealloc` for example code." -msgstr "" +msgstr "コード例は :c:member:`~PyTypeObject.tp_dealloc` を参照してください。" diff --git a/c-api/list.po b/c-api/list.po index 2a1134d9b..eb2feb812 100644 --- a/c-api/list.po +++ b/c-api/list.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/list.rst:6 @@ -62,7 +62,6 @@ msgstr "" "サイズが *len* 新たなリストオブジェクトを返します。\n" "失敗すると ``NULL`` を返します。" -#: ../../c-api/list.rst:40 msgid "" "If *len* is greater than zero, the returned list object's items are set to " "``NULL``. Thus you cannot use abstract API functions such as :c:func:" @@ -72,6 +71,14 @@ msgid "" "fully initialized: :c:func:`PyList_SetItem()` and :c:func:" "`PyList_SET_ITEM()`." msgstr "" +"*len* がゼロより大きい場合、返されたリストの要素は ``NULL`` に設定されていま" +"す。\n" +"そのため、:c:func:`PyList_SetItem` や :c:func:`PyList_SET_ITEM()` ですべての" +"要素に実際のオブジェクトを設定するまでは、:c:func:`PySequence_SetItem` などの" +"抽象 API 関数を使ったり、このオブジェクトを Python コードに公開したりしてはな" +"りません。\n" +"リストを完全に初期化する前でも安全に使える API は :c:func:`PyList_SetItem()` " +"と :c:func:`PyList_SET_ITEM()` です。" #: ../../c-api/list.rst:53 msgid "" @@ -85,48 +92,57 @@ msgstr "" msgid "Similar to :c:func:`PyList_Size`, but without error checking." msgstr ":c:func:`PyList_Size` に似ていますが、エラーチェックを行いません。" -#: ../../c-api/list.rst:64 msgid "" "Return the object at position *index* in the list pointed to by *list*. The " "position must be non-negative; indexing from the end of the list is not " "supported. If *index* is out of bounds (:code:`<0 or >=len(list)`), return " "``NULL`` and set an :exc:`IndexError` exception." msgstr "" +"*list* が指すリストの位置 *index* にあるオブジェクトを返します。\n" +"位置は非負でなければならず、リストの末尾からのインデックス指定はサポートしま" +"せん。\n" +"*index* が範囲外 (:code:`<0 or >=len(list)`) の場合、:exc:`IndexError` を設定" +"して ``NULL`` を返します。" -#: ../../c-api/list.rst:74 msgid "" "Like :c:func:`PyList_GetItemRef`, but returns a :term:`borrowed reference` " "instead of a :term:`strong reference`." msgstr "" +":c:func:`PyList_GetItemRef` と似ていますが、:term:`強参照 ` ではなく :term:`借用参照 ` を返します。" -#: ../../c-api/list.rst:79 ../../c-api/list.rst:91 msgid "" "In the :term:`free-threaded build`, the returned :term:`borrowed reference` " "may become invalid if another thread modifies the list concurrently. Prefer :" "c:func:`PyList_GetItemRef`, which returns a :term:`strong reference`." msgstr "" +":term:`フリースレッドビルド ` では、別のスレッドが同時に" +"リストを変更すると、返された :term:`借用参照 ` が無効にな" +"る可能性があります。\n" +":term:`強参照 ` を返す :c:func:`PyList_GetItemRef` を使って" +"ください。" #: ../../c-api/list.rst:87 msgid "Similar to :c:func:`PyList_GetItem`, but without error checking." msgstr ":c:func:`PyList_GetItem` に似ていますが、エラーチェックを行いません。" -#: ../../c-api/list.rst:99 msgid "" "Set the item at index *index* in list to *item*. Return ``0`` on success. " "If *index* is out of bounds, return ``-1`` and set an :exc:`IndexError` " "exception." msgstr "" -"リストオブジェクト内の位置 *index* に、オブジェクト *item* を挿入します。\n" -"成功した場合には ``0`` を返します。\n" -"*index* が範囲を越えている場合、 ``-1`` を返して :exc:`IndexError` をセットし" -"ます。" +"リストのインデックス *index* にある要素を *item* に設定します。\n" +"成功すると ``0`` を返します。\n" +"*index* が範囲外の場合は、:exc:`IndexError` を設定して ``-1`` を返します。" -#: ../../c-api/list.rst:105 msgid "" "This function \":term:`steals `\" a reference to *item*, even on " "error. On success, it discards a reference to an item already in the list at " "the affected position (unless it was ``NULL``)." msgstr "" +"この関数は、エラーの場合も *item* への参照を「:term:`盗みます `」。\n" +"成功すると、リストの指定位置にすでにあった要素が ``NULL`` でない限り、その要" +"素への参照を破棄します。" #: ../../c-api/list.rst:113 msgid "" @@ -137,26 +153,36 @@ msgstr "" "のマクロは、新たなリストのまだ要素を入れたことのない位置に要素を入れるときに" "のみ使います。" -#: ../../c-api/list.rst:116 msgid "" "Bounds checking is performed as an assertion if Python is built in :ref:" "`debug mode ` or :option:`with assertions <--with-assertions>`." msgstr "" +"Python を :ref:`デバッグモード ` または :option:`アサーションを" +"有効にして <--with-assertions>` ビルドした場合、アサーションによる境界チェッ" +"クが行われます。" -#: ../../c-api/list.rst:122 msgid "" "This macro \":term:`steals `\" a reference to *item*, and, unlike :c:" "func:`PyList_SetItem`, does *not* discard a reference to any item that is " "being replaced; any reference in *list* at position *i* will be leaked." msgstr "" +"このマクロは *item* への参照を「:term:`盗みます `」。\n" +":c:func:`PyList_SetItem` とは異なり、置き換える要素への参照は破棄 *しません" +"*。\n" +"*list* の位置 *i* にある参照はリークします。" -#: ../../c-api/list.rst:129 msgid "" "In the :term:`free-threaded build`, this macro has no internal " "synchronization. It is normally only used to fill in new lists where no " "other thread has a reference to the list. If the list may be shared, use :c:" "func:`PyList_SetItem` instead, which uses a :term:`per-object lock`." msgstr "" +":term:`フリースレッドビルド ` では、このマクロは内部で同" +"期しません。\n" +"通常は、他のスレッドが参照を持っていない新しいリストに要素を設定するためにだ" +"け使います。\n" +"リストが共有される可能性がある場合は、代わりに :term:`オブジェクトごとのロッ" +"ク ` を使う :c:func:`PyList_SetItem` を使ってください。" #: ../../c-api/list.rst:138 msgid "" @@ -206,27 +232,32 @@ msgstr "" "成功した場合には ``0`` を、失敗した場合には ``-1`` を返します。\n" "ただし、リストの末尾からのインデックスはサポートされていません。" -#: ../../c-api/list.rst:167 msgid "" "In the :term:`free-threaded build`, when *itemlist* is a :class:`list`, both " "*list* and *itemlist* are locked for the duration of the operation. For " "other iterables (or ``NULL``), only *list* is locked." msgstr "" +":term:`フリースレッドビルド ` では、*itemlist* が :" +"class:`list` の場合、操作中は *list* と *itemlist* の両方をロックします。\n" +"他のイテラブル (または ``NULL``) の場合は、*list* だけをロックします。" -#: ../../c-api/list.rst:174 msgid "" "Extend *list* with the contents of *iterable*. This is the same as " "``PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable)`` and " "analogous to ``list.extend(iterable)`` or ``list += iterable``." msgstr "" +"*iterable* の内容を *list* の末尾に追加します。\n" +"``PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable)`` と同じ" +"で、``list.extend(iterable)`` や ``list += iterable`` に相当します。" -#: ../../c-api/list.rst:178 msgid "" "Raise an exception and return ``-1`` if *list* is not a :class:`list` " "object. Return 0 on success." msgstr "" +"*list* が :class:`list` オブジェクトでなければ、例外を送出して ``-1`` を返し" +"ます。\n" +"成功すると 0 を返します。" -#: ../../c-api/list.rst:185 msgid "" "In the :term:`free-threaded build`, when *iterable* is a :class:`list`, :" "class:`set`, :class:`dict`, or dict view, both *list* and *iterable* (or its " @@ -234,19 +265,29 @@ msgid "" "iterables, only *list* is locked; *iterable* may be concurrently modified by " "another thread." msgstr "" +":term:`フリースレッドビルド ` では、*iterable* が :" +"class:`list`、:class:`set`、:class:`dict`、または辞書ビューの場合、操作中は " +"*list* と *iterable* (辞書ビューの場合はその元の辞書) の両方をロックしま" +"す。\n" +"他のイテラブルの場合は *list* だけをロックするため、別のスレッドが同時に " +"*iterable* を変更する可能性があります。" -#: ../../c-api/list.rst:194 msgid "" "Remove all items from *list*. This is the same as ``PyList_SetSlice(list, " "0, PY_SSIZE_T_MAX, NULL)`` and analogous to ``list.clear()`` or ``del " "list[:]``." msgstr "" +"*list* のすべての要素を削除します。\n" +"``PyList_SetSlice(list, 0, PY_SSIZE_T_MAX, NULL)`` と同じで、``list." +"clear()`` や ``del list[:]`` に相当します。" -#: ../../c-api/list.rst:198 msgid "" "Raise an exception and return ``-1`` if *list* is not a :class:`list` " "object. Return 0 on success." msgstr "" +"*list* が :class:`list` オブジェクトでなければ、例外を送出して ``-1`` を返し" +"ます。\n" +"成功すると 0 を返します。" #: ../../c-api/list.rst:206 msgid "" @@ -256,13 +297,18 @@ msgstr "" "*list* の内容をインプレースでソートします。成功した場合には ``0`` を、失敗し" "た場合には ``-1`` を返します。``list.sort()`` と同じです。" -#: ../../c-api/list.rst:211 msgid "" "In the :term:`free-threaded build`, element comparison via :meth:`~object." "__lt__` can execute arbitrary Python code, during which the :term:`per-" "object lock` may be temporarily released. For built-in types (:class:`str`, :" "class:`int`, :class:`float`), the lock is not released during comparison." msgstr "" +":term:`フリースレッドビルド ` では、:meth:`~object." +"__lt__` による要素の比較で任意の Python コードが実行されることがあり、その間" +"は :term:`オブジェクトごとのロック ` が一時的に解放される場" +"合があります。\n" +"組み込み型 (:class:`str`、:class:`int`、:class:`float`) の比較中は、ロックを" +"解放しません。" #: ../../c-api/list.rst:220 msgid "" diff --git a/c-api/long.po b/c-api/long.po index cdd4cc12f..ba9f07ceb 100644 --- a/c-api/long.po +++ b/c-api/long.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/long.rst:6 @@ -41,9 +41,9 @@ msgstr "" "ますが、これは数値と見分けが付きません。\n" "見分けを付けるためには :c:func:`PyErr_Occurred` を使ってください。" -#: ../../c-api/long.rst:18 msgid "This subtype of :c:type:`PyObject` represents a Python integer object." -msgstr "この :c:type:`PyObject` のサブタイプは整数型を表現します。" +msgstr "" +"この :c:type:`PyObject` のサブタイプは Python の整数オブジェクトを表します。" #: ../../c-api/long.rst:23 msgid "" @@ -76,12 +76,14 @@ msgstr "" "*v* から新たな :c:type:`PyLongObject` オブジェクトを生成して返します。失敗の" "ときには ``NULL`` を返します。" -#: ../../c-api/long.rst:45 msgid "" "CPython keeps an array of integer objects for all integers between ``-5`` " "and ``1024``. When you create an int in that range you actually just get " "back a reference to the existing object." msgstr "" +"CPython は ``-5`` から ``1024`` までのすべての整数について、整数オブジェクト" +"の配列を保持しています。\n" +"この範囲の int を作成すると、実際には既存のオブジェクトへの参照が返されます。" #: ../../c-api/long.rst:52 msgid "" @@ -123,18 +125,22 @@ msgstr "" "C の :c:expr:`unsigned long long` 型から新たな :c:type:`PyLongObject` オブ" "ジェクトを生成して返します。失敗のときには ``NULL`` を返します。" -#: ../../c-api/long.rst:83 msgid "" "Return a new :c:type:`PyLongObject` object from a signed C :c:expr:`int32_t` " "or :c:expr:`int64_t`, or ``NULL`` with an exception set on failure." msgstr "" +"符号付きの C の :c:expr:`int32_t` または :c:expr:`int64_t` から、新しい :c:" +"type:`PyLongObject` オブジェクトを作成して返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/long.rst:93 msgid "" "Return a new :c:type:`PyLongObject` object from an unsigned C :c:expr:" "`uint32_t` or :c:expr:`uint64_t`, or ``NULL`` with an exception set on " "failure." msgstr "" +"符号なしの C の :c:expr:`uint32_t` または :c:expr:`uint64_t` から、新しい :c:" +"type:`PyLongObject` オブジェクトを作成して返します。\n" +"失敗すると例外を設定して ``NULL`` を返します。" #: ../../c-api/long.rst:102 msgid "" @@ -144,7 +150,6 @@ msgstr "" "*v* の整数部から新たな :c:type:`PyLongObject` オブジェクトを生成して返しま" "す。失敗のときには ``NULL`` を返します。" -#: ../../c-api/long.rst:108 msgid "" "Return a new :c:type:`PyLongObject` based on the string value in *str*, " "which is interpreted according to the radix in *base*, or ``NULL`` on " @@ -158,19 +163,32 @@ msgid "" "digits or *str* is not NULL-terminated following the digits and trailing " "whitespace, :exc:`ValueError` will be raised." msgstr "" +"*str* 内の文字列を *base* の基数で解釈し、新しい :c:type:`PyLongObject` を作" +"成して返します。\n" +"失敗すると ``NULL`` を返します。\n" +"*pend* が ``NULL`` でなければ、成功時には *\\*pend* が *str* の末尾を、エラー" +"時には処理できなかった最初の文字を指します。\n" +"*base* が ``0`` の場合、*str* は :ref:`integers` の定義に従って解釈します。\n" +"この場合、ゼロでない 10 進数の先頭にゼロがあると :exc:`ValueError` を送出しま" +"す。\n" +"*base* が ``0`` でない場合は、``2`` 以上 ``36`` 以下でなければなりません。\n" +"先頭と末尾の空白、および基数指定子の後や数字の間にある単独のアンダースコアは" +"無視します。\n" +"数字がない場合や、数字と末尾の空白の後で *str* が NULL 終端されていない場合" +"は、:exc:`ValueError` を送出します。" -#: ../../c-api/long.rst:119 msgid "" ":c:func:`PyLong_AsNativeBytes()` and :c:func:`PyLong_FromNativeBytes()` " "functions can be used to convert a :c:type:`PyLongObject` to/from an array " "of bytes in base ``256``." msgstr "" +":c:func:`PyLong_AsNativeBytes()` と :c:func:`PyLong_FromNativeBytes()` を使う" +"と、:c:type:`PyLongObject` と基数 ``256`` のバイト配列を相互に変換できます。" -#: ../../c-api/long.rst:126 msgid "" "Convert a sequence of Unicode digits in the string *u* to a Python integer " "value." -msgstr "" +msgstr "文字列 *u* 内の Unicode 数字の列を Python の整数値に変換します。" #: ../../c-api/long.rst:134 msgid "" @@ -180,13 +198,13 @@ msgstr "" "ポインタ *p* から Python 整数値を生成します。ポインタの値は :c:func:" "`PyLong_AsVoidPtr` を適用した結果から取得されます。" -#: ../../c-api/long.rst:140 msgid "" "Create a Python integer from the value contained in the first *n_bytes* of " "*buffer*, interpreted as a two's-complement signed number." msgstr "" +"*buffer* の先頭 *n_bytes* バイトに格納された値を、2 の補数表現の符号付き数値" +"として解釈し、Python の整数を作成します。" -#: ../../c-api/long.rst:143 msgid "" "*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " "select the native endian that CPython was compiled with and assume that the " @@ -194,36 +212,49 @@ msgid "" "``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` will produce the same result as " "calling :c:func:`PyLong_FromUnsignedNativeBytes`. Other flags are ignored." msgstr "" +"*flags* は :c:func:`PyLong_AsNativeBytes` と同じです。\n" +"``-1`` を渡すと、CPython のコンパイル時のネイティブなエンディアンを選び、最上" +"位ビットを符号ビットとみなします。\n" +"``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` を渡すと、:c:func:" +"`PyLong_FromUnsignedNativeBytes` の呼び出しと同じ結果になります。\n" +"他のフラグは無視します。" -#: ../../c-api/long.rst:154 msgid "" "Create a Python integer from the value contained in the first *n_bytes* of " "*buffer*, interpreted as an unsigned number." msgstr "" +"*buffer* の先頭 *n_bytes* バイトに格納された値を符号なし数値として解釈し、" +"Python の整数を作成します。" -#: ../../c-api/long.rst:157 msgid "" "*flags* are as for :c:func:`PyLong_AsNativeBytes`. Passing ``-1`` will " "select the native endian that CPython was compiled with and assume that the " "most-significant bit is not a sign bit. Flags other than endian are ignored." msgstr "" +"*flags* は :c:func:`PyLong_AsNativeBytes` と同じです。\n" +"``-1`` を渡すと、CPython のコンパイル時のネイティブなエンディアンを選び、最上" +"位ビットを符号ビットではないとみなします。\n" +"エンディアン以外のフラグは無視します。" -#: ../../c-api/long.rst:166 msgid "Macro for creating a Python integer from a process identifier." -msgstr "" +msgstr "プロセス識別子から Python の整数を作成するマクロです。" -#: ../../c-api/long.rst:168 msgid "" "This can be defined as an alias to :c:func:`PyLong_FromLong` or :c:func:" "`PyLong_FromLongLong`, depending on the size of the system's PID type." msgstr "" +"システムの PID 型のサイズに応じて、:c:func:`PyLong_FromLong` または :c:func:" +"`PyLong_FromLongLong` の別名として定義されることがあります。" -#: ../../c-api/long.rst:181 ../../c-api/long.rst:215 msgid "" "Return a C :c:expr:`long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" +"*obj* を表す C の :c:expr:`long` を返します。\n" +"*obj* が :c:type:`PyLongObject` のインスタンスでない場合、まず :meth:" +"`~object.__index__` メソッド (存在する場合) を呼び出して :c:type:" +"`PyLongObject` に変換します。" #: ../../c-api/long.rst:185 msgid "" @@ -245,37 +276,44 @@ msgstr "" msgid "Use :meth:`~object.__index__` if available." msgstr "可能であれば :meth:`~object.__index__` を使うようになりました。" -#: ../../c-api/long.rst:193 ../../c-api/long.rst:229 ../../c-api/long.rst:250 -#: ../../c-api/long.rst:272 ../../c-api/long.rst:356 ../../c-api/long.rst:376 msgid "This function will no longer use :meth:`~object.__int__`." -msgstr "" +msgstr "この関数は :meth:`~object.__int__` を使わなくなりました。" -#: ../../c-api/long.rst:200 msgid "" "Exactly equivalent to the preferred ``PyLong_AsLong``. In particular, it can " "fail with :exc:`OverflowError` or another exception." msgstr "" +"推奨される ``PyLong_AsLong`` と完全に等価です。\n" +"特に、:exc:`OverflowError` や他の例外で失敗する場合があります。" -#: ../../c-api/long.rst:207 msgid "" "Similar to :c:func:`PyLong_AsLong`, but store the result in a C :c:expr:" "`int` instead of a C :c:expr:`long`." msgstr "" +":c:func:`PyLong_AsLong` と同様ですが、結果を C の :c:expr:`long` ではなく :c:" +"expr:`int` に格納します。" -#: ../../c-api/long.rst:219 msgid "" "If the value of *obj* is greater than :c:macro:`LONG_MAX` or less than :c:" "macro:`LONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " "return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other " "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" +"*obj* の値が :c:macro:`LONG_MAX` より大きい場合は *\\*overflow* に ``1``、:c:" +"macro:`LONG_MIN` より小さい場合は ``-1`` を設定し、``-1`` を返します。\n" +"それ以外の場合は *\\*overflow* に ``0`` を設定します。\n" +"他の例外が発生した場合は、*\\*overflow* に ``0`` を設定し、通常どおり ``-1`` " +"を返します。" -#: ../../c-api/long.rst:238 ../../c-api/long.rst:256 msgid "" "Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an " "instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` " "method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" +"*obj* を表す C の :c:expr:`long long` を返します。\n" +"*obj* が :c:type:`PyLongObject` のインスタンスでない場合、まず :meth:" +"`~object.__index__` メソッド (存在する場合) を呼び出して :c:type:" +"`PyLongObject` に変換します。" #: ../../c-api/long.rst:242 msgid "" @@ -285,13 +323,17 @@ msgstr "" "もし *obj* の値が :c:expr:`long long` の範囲外であれば、 :exc:" "`OverflowError` を送出します。" -#: ../../c-api/long.rst:260 msgid "" "If the value of *obj* is greater than :c:macro:`LLONG_MAX` or less than :c:" "macro:`LLONG_MIN`, set *\\*overflow* to ``1`` or ``-1``, respectively, and " "return ``-1``; otherwise, set *\\*overflow* to ``0``. If any other " "exception occurs set *\\*overflow* to ``0`` and return ``-1`` as usual." msgstr "" +"*obj* の値が :c:macro:`LLONG_MAX` より大きい場合は *\\*overflow* に ``1``、:" +"c:macro:`LLONG_MIN` より小さい場合は ``-1`` を設定し、``-1`` を返します。\n" +"それ以外の場合は *\\*overflow* に ``0`` を設定します。\n" +"他の例外が発生した場合は、*\\*overflow* に ``0`` を設定し、通常どおり ``-1`` " +"を返します。" #: ../../c-api/long.rst:282 msgid "" @@ -388,12 +430,15 @@ msgstr "" "負 *pylong* を指定した際に :exc:`TypeError` ではなく、 :exc:`OverflowError` " "を送出するようになりました。" -#: ../../c-api/long.rst:343 msgid "" "Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not " "an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" +"*obj* を表す C の :c:expr:`unsigned long` を返します。\n" +"*obj* が :c:type:`PyLongObject` のインスタンスでない場合、まず :meth:" +"`~object.__index__` メソッド (存在する場合) を呼び出して :c:type:" +"`PyLongObject` に変換します。" #: ../../c-api/long.rst:347 msgid "" @@ -411,12 +456,15 @@ msgstr "" "エラーが起きたときに ``(unsigned long)-1`` を返します。\n" "見分けを付けるためには :c:func:`PyErr_Occurred` を使ってください。" -#: ../../c-api/long.rst:362 msgid "" "Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj* " "is not an instance of :c:type:`PyLongObject`, first call its :meth:`~object." "__index__` method (if present) to convert it to a :c:type:`PyLongObject`." msgstr "" +"*obj* を表す C の :c:expr:`unsigned long long` を返します。\n" +"*obj* が :c:type:`PyLongObject` のインスタンスでない場合、まず :meth:" +"`~object.__index__` メソッド (存在する場合) を呼び出して :c:type:" +"`PyLongObject` に変換します。" #: ../../c-api/long.rst:367 msgid "" @@ -434,42 +482,44 @@ msgstr "" "エラーが起きたときに ``(unsigned long long)-1`` を返します。\n" "見分けを付けるためには :c:func:`PyErr_Occurred` を使ってください。" -#: ../../c-api/long.rst:383 msgid "" "Set *\\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t` " "representation of *obj*." msgstr "" +"*\\*value* に、*obj* を表す符号付きの C の :c:expr:`int32_t` または :c:expr:" +"`int64_t` の値を設定します。" -#: ../../c-api/long.rst:386 ../../c-api/long.rst:406 msgid "" "If *obj* is not an instance of :c:type:`PyLongObject`, first call its :meth:" "`~object.__index__` method (if present) to convert it to a :c:type:" "`PyLongObject`." msgstr "" +"*obj* が :c:type:`PyLongObject` のインスタンスでない場合、まず :meth:" +"`~object.__index__` メソッド (存在する場合) を呼び出して :c:type:" +"`PyLongObject` に変換します。" -#: ../../c-api/long.rst:390 ../../c-api/long.rst:411 msgid "If the *obj* value is out of range, raise an :exc:`OverflowError`." -msgstr "" +msgstr "*obj* の値が範囲外の場合は :exc:`OverflowError` を送出します。" -#: ../../c-api/long.rst:392 ../../c-api/long.rst:413 msgid "" "Set *\\*value* and return ``0`` on success. Set an exception and return " "``-1`` on error." msgstr "" +"成功すると *\\*value* を設定して ``0`` を返します。\n" +"エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/long.rst:395 ../../c-api/long.rst:416 msgid "*value* must not be ``NULL``." -msgstr "" +msgstr "*value* は ``NULL`` であってはなりません。" -#: ../../c-api/long.rst:403 msgid "" "Set *\\*value* to an unsigned C :c:expr:`uint32_t` or :c:expr:`uint64_t` " "representation of *obj*." msgstr "" +"*\\*value* に、*obj* を表す符号なしの C の :c:expr:`uint32_t` または :c:expr:" +"`uint64_t` の値を設定します。" -#: ../../c-api/long.rst:410 msgid "If *obj* is negative, raise a :exc:`ValueError`." -msgstr "" +msgstr "*obj* が負の場合は :exc:`ValueError` を送出します。" #: ../../c-api/long.rst:423 msgid "" @@ -494,17 +544,16 @@ msgstr "" "エラーが起きたときに ``-1.0`` を返します。\n" "見分けを付けるためには :c:func:`PyErr_Occurred` を使ってください。" -#: ../../c-api/long.rst:434 msgid "" "Convert a Python integer *pylong* to a C :c:expr:`void` pointer. If *pylong* " "cannot be converted, an :exc:`OverflowError` will be raised. This is only " "assured to produce a usable :c:expr:`void` pointer for values created with :" "c:func:`PyLong_FromVoidPtr`." msgstr "" -"Python の整数型を指す *pylong* を、 C の :c:expr:`void` ポインタに変換しま" -"す。 *pylong* を変換できなければ、 :exc:`OverflowError` を送出します。この関" -"数は :c:func:`PyLong_FromVoidPtr` で値を生成するときに使うような :c:expr:" -"`void` ポインタ型を生成できるだけです。" +"Python の整数 *pylong* を C の :c:expr:`void` ポインタに変換します。\n" +"*pylong* を変換できない場合は :exc:`OverflowError` を送出します。\n" +"利用可能な :c:expr:`void` ポインタが得られることを保証するのは、:c:func:" +"`PyLong_FromVoidPtr` で作成した値に対してだけです。" #: ../../c-api/long.rst:439 msgid "" @@ -513,55 +562,63 @@ msgstr "" "エラーが起きたときに ``NULL`` を返します。\n" "見分けを付けるためには :c:func:`PyErr_Occurred` を使ってください。" -#: ../../c-api/long.rst:444 msgid "" "Copy the Python integer value *pylong* to a native *buffer* of size " "*n_bytes*. The *flags* can be set to ``-1`` to behave similarly to a C cast, " "or to values documented below to control the behavior." msgstr "" +"Python の整数値 *pylong* を、サイズ *n_bytes* のネイティブな *buffer* にコ" +"ピーします。\n" +"*flags* に ``-1`` を指定すると C のキャストと同様に動作し、後述する値を指定す" +"ると動作を制御できます。" -#: ../../c-api/long.rst:448 msgid "" "Returns ``-1`` with an exception raised on error. This may happen if " "*pylong* cannot be interpreted as an integer, or if *pylong* was negative " "and the ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` flag was set." msgstr "" +"エラー時には例外を送出して ``-1`` を返します。\n" +"*pylong* を整数として解釈できない場合や、" +"``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` フラグが設定されているときに *pylong* が" +"負である場合に、エラーが発生する可能性があります。" -#: ../../c-api/long.rst:452 msgid "" "Otherwise, returns the number of bytes required to store the value. If this " "is equal to or less than *n_bytes*, the entire value was copied. All " "*n_bytes* of the buffer are written: remaining bytes filled by copies of the " "sign bit." msgstr "" +"それ以外の場合は、値を格納するのに必要なバイト数を返します。\n" +"その値が *n_bytes* 以下であれば、値全体がコピーされています。\n" +"バッファの *n_bytes* バイトすべてに書き込み、余ったバイトは符号ビットを繰り返" +"して埋めます。" -#: ../../c-api/long.rst:457 msgid "" "If the returned value is greater than *n_bytes*, the value was truncated: as " "many of the lowest bits of the value as could fit are written, and the " "higher bits are ignored. This matches the typical behavior of a C-style " "downcast." msgstr "" +"戻り値が *n_bytes* より大きい場合は、値が切り詰められています。\n" +"収まるだけの下位ビットを書き込み、上位ビットは無視します。\n" +"これは C 形式のダウンキャストの典型的な動作と同じです。" -#: ../../c-api/long.rst:464 msgid "" "Overflow is not considered an error. If the returned value is larger than " "*n_bytes*, most significant bits were discarded." msgstr "" +"オーバーフローはエラーとはみなしません。\n" +"戻り値が *n_bytes* より大きい場合、上位ビットは破棄されています。" -#: ../../c-api/long.rst:467 msgid "``0`` will never be returned." -msgstr "" +msgstr "``0`` を返すことはありません。" -#: ../../c-api/long.rst:469 msgid "Values are always copied as two's-complement." -msgstr "" +msgstr "値は常に 2 の補数表現でコピーします。" -#: ../../c-api/long.rst:471 msgid "Usage example::" -msgstr "" +msgstr "使用例です。 ::" -#: ../../c-api/long.rst:473 msgid "" "int32_t value;\n" "Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);\n" @@ -577,27 +634,43 @@ msgid "" " // lowest bits of pylong.\n" "}" msgstr "" +"int32_t value;\n" +"Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);\n" +"if (bytes < 0) {\n" +" // 失敗。理由を示す Python の例外が設定されています。\n" +" return NULL;\n" +"}\n" +"else if (bytes <= (Py_ssize_t)sizeof(value)) {\n" +" // 成功。\n" +"}\n" +"else {\n" +" // オーバーフローしましたが、'value' には切り詰めた\n" +" // pylong の下位ビットが格納されています。\n" +"}" -#: ../../c-api/long.rst:487 msgid "" "Passing zero to *n_bytes* will return the size of a buffer that would be " "large enough to hold the value. This may be larger than technically " "necessary, but not unreasonably so. If *n_bytes=0*, *buffer* may be ``NULL``." msgstr "" +"*n_bytes* にゼロを渡すと、値を格納するのに十分なバッファサイズを返します。\n" +"厳密に必要なサイズより大きい場合がありますが、不合理に大きくなることはありま" +"せん。\n" +"*n_bytes=0* の場合、*buffer* は ``NULL`` でも構いません。" -#: ../../c-api/long.rst:494 msgid "" "Passing *n_bytes=0* to this function is not an accurate way to determine the " "bit length of the value." msgstr "" +"この関数に *n_bytes=0* を渡しても、値の正確なビット長は求められません。" -#: ../../c-api/long.rst:497 msgid "" "To get at the entire Python value of an unknown size, the function can be " "called twice: first to determine the buffer size, then to fill it::" msgstr "" +"サイズが不明な Python の値全体を取得するには、この関数を 2 回呼び出せます。\n" +"最初にバッファサイズを調べ、次にバッファを埋めます。 ::" -#: ../../c-api/long.rst:500 msgid "" "// Ask how much space we need.\n" "Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n" @@ -627,19 +700,50 @@ msgid "" "// ... use bignum ...\n" "free(bignum);" msgstr "" +"// 必要な領域のサイズを調べます。\n" +"Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);\n" +"if (expected < 0) {\n" +" // 失敗。理由を示す Python の例外が設定されています。\n" +" return NULL;\n" +"}\n" +"assert(expected != 0); // API の定義上、ゼロにはなりません。\n" +"uint8_t *bignum = malloc(expected);\n" +"if (!bignum) {\n" +" PyErr_SetString(PyExc_MemoryError, \"bignum malloc failed.\");\n" +" return NULL;\n" +"}\n" +"// 値全体を安全に取得します。\n" +"Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);\n" +"if (bytes < 0) { // 例外が設定されています。\n" +" free(bignum);\n" +" return NULL;\n" +"}\n" +"else if (bytes > expected) { // この状況は起きないはずです。\n" +" PyErr_SetString(PyExc_RuntimeError,\n" +" \"Unexpected bignum truncation after a size check.\");\n" +" free(bignum);\n" +" return NULL;\n" +"}\n" +"// 上の事前チェックから期待される成功です。\n" +"// ... bignum を使います ...\n" +"free(bignum);" -#: ../../c-api/long.rst:528 msgid "" "*flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults " "that behave most like a C cast, or a combination of the other flags in the " "table below. Note that ``-1`` cannot be combined with other flags." msgstr "" +"*flags* には、C のキャストに最も近い動作をするデフォルトを選ぶ ``-1`` " +"(``Py_ASNATIVEBYTES_DEFAULTS``)、または以下の表にある他のフラグの組み合わせを" +"指定します。\n" +"``-1`` は他のフラグと組み合わせられないことに注意してください。" -#: ../../c-api/long.rst:533 msgid "" "Currently, ``-1`` corresponds to ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | " "Py_ASNATIVEBYTES_UNSIGNED_BUFFER``." msgstr "" +"現在、``-1`` は ``Py_ASNATIVEBYTES_NATIVE_ENDIAN | " +"Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` に相当します。" #: ../../c-api/long.rst:539 msgid "Flag" @@ -649,9 +753,8 @@ msgstr "Flag" msgid "Value" msgstr "値" -#: ../../c-api/long.rst:541 msgid "``-1``" -msgstr "" +msgstr "``-1``" #: ../../c-api/long.rst:542 msgid "``0``" @@ -673,15 +776,16 @@ msgstr "``4``" msgid "``8``" msgstr "``8``" -#: ../../c-api/long.rst:547 msgid "``16``" -msgstr "" +msgstr "``16``" -#: ../../c-api/long.rst:550 msgid "" "Specifying ``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` will override any other endian " "flags. Passing ``2`` is reserved." msgstr "" +"``Py_ASNATIVEBYTES_NATIVE_ENDIAN`` を指定すると、他のエンディアンのフラグより" +"優先されます。\n" +"値 ``2`` は予約されています。" #: ../../c-api/long.rst:553 msgid "" @@ -690,7 +794,6 @@ msgid "" "(or more) in order to store a zero sign bit." msgstr "" -#: ../../c-api/long.rst:557 msgid "" "If ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` is specified, a zero sign bit will " "be omitted from size calculations. This allows, for example, 128 to fit in a " @@ -699,16 +802,26 @@ msgid "" "handling of negative values: for those, space for a sign bit is always " "requested." msgstr "" +"``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` を指定すると、サイズの計算からゼロの符号" +"ビットを除外します。\n" +"これにより、例えば 128 を 1 バイトのバッファに収めることができます。\n" +"コピー先のバッファを後で符号付きとして扱うと、正の入力値が負になる場合があり" +"ます。\n" +"このフラグは負の値の扱いには影響せず、負の値には常に符号ビットのための領域が" +"要求されることに注意してください。" -#: ../../c-api/long.rst:564 msgid "" "Specifying ``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` causes an exception to be " "set if *pylong* is negative. Without this flag, negative values will be " "copied provided there is enough space for at least one sign bit, regardless " "of whether ``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` was specified." msgstr "" +"``Py_ASNATIVEBYTES_REJECT_NEGATIVE`` を指定すると、*pylong* が負の場合に例外" +"を設定します。\n" +"このフラグを指定しない場合は、``Py_ASNATIVEBYTES_UNSIGNED_BUFFER`` の指定の有" +"無にかかわらず、少なくとも符号ビット 1 つ分の領域があれば負の値をコピーしま" +"す。" -#: ../../c-api/long.rst:569 msgid "" "If ``Py_ASNATIVEBYTES_ALLOW_INDEX`` is specified and a non-integer value is " "passed, its :meth:`~object.__index__` method will be called first. This may " @@ -717,18 +830,28 @@ msgid "" "``-1``, this option is not set, and non-integer values will raise :exc:" "`TypeError`." msgstr "" +"``Py_ASNATIVEBYTES_ALLOW_INDEX`` を指定して整数以外の値を渡すと、最初にその値" +"の :meth:`~object.__index__` メソッドを呼び出します。\n" +"その結果 Python コードが実行され、他のスレッドも実行できるようになる場合があ" +"り、使用中の他のオブジェクトや値が変化する可能性があります。\n" +"*flags* が ``-1`` の場合、このオプションは設定されず、整数以外の値は :exc:" +"`TypeError` を引き起こします。" -#: ../../c-api/long.rst:578 msgid "" "With the default *flags* (``-1``, or *UNSIGNED_BUFFER* without " "*REJECT_NEGATIVE*), multiple Python integers can map to a single value " "without overflow. For example, both ``255`` and ``-1`` fit a single-byte " "buffer and set all its bits. This matches typical C cast behavior." msgstr "" +"デフォルトの *flags* (``-1``、または *REJECT_NEGATIVE* を指定しない " +"*UNSIGNED_BUFFER*) では、複数の Python の整数が、オーバーフローせずに同じ 1 " +"つの値に対応することがあります。\n" +"例えば ``255`` と ``-1`` はどちらも 1 バイトのバッファに収まり、すべてのビッ" +"トを立てます。\n" +"これは C のキャストの典型的な動作と同じです。" -#: ../../c-api/long.rst:589 msgid "Macro for converting a Python integer into a process identifier." -msgstr "" +msgstr "Python の整数をプロセス識別子に変換するマクロです。" #: ../../c-api/long.rst:591 msgid "" @@ -737,375 +860,400 @@ msgid "" "the system's PID type." msgstr "" -#: ../../c-api/long.rst:600 msgid "Get the sign of the integer object *obj*." -msgstr "" +msgstr "整数オブジェクト *obj* の符号を取得します。" -#: ../../c-api/long.rst:602 msgid "" "On success, set *\\*sign* to the integer sign (0, -1 or +1 for zero, " "negative or positive integer, respectively) and return 0." msgstr "" +"成功すると *\\*sign* に整数の符号 (ゼロ、負、正の整数に対してそれぞれ " +"0、-1、+1) を設定し、0 を返します。" -#: ../../c-api/long.rst:605 msgid "" "On failure, return -1 with an exception set. This function always succeeds " "if *obj* is a :c:type:`PyLongObject` or its subtype." msgstr "" +"失敗すると例外を設定して -1 を返します。\n" +"*obj* が :c:type:`PyLongObject` またはそのサブタイプであれば、この関数は常に" +"成功します。" -#: ../../c-api/long.rst:613 msgid "Check if the integer object *obj* is positive (``obj > 0``)." -msgstr "" +msgstr "整数オブジェクト *obj* が正かどうか (``obj > 0``) を調べます。" -#: ../../c-api/long.rst:615 msgid "" "If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " "``1`` when it's positive and ``0`` otherwise. Else set an exception and " "return ``-1``." msgstr "" +"*obj* が :c:type:`PyLongObject` またはそのサブタイプのインスタンスである場" +"合、正なら ``1``、それ以外なら ``0`` を返します。\n" +"それらのインスタンスでない場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/long.rst:624 msgid "Check if the integer object *obj* is negative (``obj < 0``)." -msgstr "" +msgstr "整数オブジェクト *obj* が負かどうか (``obj < 0``) を調べます。" -#: ../../c-api/long.rst:626 msgid "" "If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " "``1`` when it's negative and ``0`` otherwise. Else set an exception and " "return ``-1``." msgstr "" +"*obj* が :c:type:`PyLongObject` またはそのサブタイプのインスタンスである場" +"合、負なら ``1``、それ以外なら ``0`` を返します。\n" +"それらのインスタンスでない場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/long.rst:635 msgid "Check if the integer object *obj* is zero." -msgstr "" +msgstr "整数オブジェクト *obj* がゼロかどうかを調べます。" -#: ../../c-api/long.rst:637 msgid "" "If *obj* is an instance of :c:type:`PyLongObject` or its subtype, return " "``1`` when it's zero and ``0`` otherwise. Else set an exception and return " "``-1``." msgstr "" +"*obj* が :c:type:`PyLongObject` またはそのサブタイプのインスタンスである場" +"合、ゼロなら ``1``、それ以外なら ``0`` を返します。\n" +"それらのインスタンスでない場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/long.rst:646 msgid "" "On success, return a read only :term:`named tuple`, that holds information " "about Python's internal representation of integers. See :data:`sys.int_info` " "for description of individual fields." msgstr "" +"成功すると、Python の整数の内部表現に関する情報を格納した、読み出し専用の :" +"term:`名前付きタプル ` を返します。\n" +"各フィールドの説明は :data:`sys.int_info` を参照してください。" -#: ../../c-api/long.rst:650 msgid "On failure, return ``NULL`` with an exception set." -msgstr "" +msgstr "失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/long.rst:657 msgid "Return 1 if *op* is compact, 0 otherwise." -msgstr "" +msgstr "*op* がコンパクトであれば 1、それ以外なら 0 を返します。" -#: ../../c-api/long.rst:659 msgid "" "This function makes it possible for performance-critical code to implement a " "“fast path” for small integers. For compact values use :c:func:" "`PyUnstable_Long_CompactValue`; for others fall back to a :c:func:" "`PyLong_As* ` function or :c:func:`PyLong_AsNativeBytes`." msgstr "" +"この関数を使うと、性能が重要なコードで小さい整数向けの「高速な処理経路」を実" +"装できます。\n" +"コンパクトな値には :c:func:`PyUnstable_Long_CompactValue` を使い、それ以外の" +"値には :c:func:`PyLong_As* ` 関数または :c:func:" +"`PyLong_AsNativeBytes` にフォールバックしてください。" -#: ../../c-api/long.rst:665 msgid "The speedup is expected to be negligible for most users." -msgstr "" +msgstr "ほとんどの利用者にとって、速度の向上はごくわずかと考えられます。" -#: ../../c-api/long.rst:667 msgid "" "Exactly what values are considered compact is an implementation detail and " "is subject to change." msgstr "" +"どの値をコンパクトとみなすかは実装の詳細であり、変更される可能性があります。" -#: ../../c-api/long.rst:675 msgid "" "If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`, " "return its value." msgstr "" +":c:func:`PyUnstable_Long_IsCompact` で判定して *op* がコンパクトであれば、そ" +"の値を返します。" -#: ../../c-api/long.rst:678 msgid "Otherwise, the return value is undefined." -msgstr "" +msgstr "それ以外の場合、戻り値は未定義です。" -#: ../../c-api/long.rst:684 msgid "Export API" -msgstr "" +msgstr "エクスポート API" -#: ../../c-api/long.rst:690 msgid "" "Layout of an array of \"digits\" (\"limbs\" in the GMP terminology), used to " "represent absolute value for arbitrary precision integers." msgstr "" +"任意精度の整数の絶対値を表す「桁」(GMP の用語では「limb」) の配列のレイアウト" +"です。" -#: ../../c-api/long.rst:693 msgid "" "Use :c:func:`PyLong_GetNativeLayout` to get the native layout of Python :" "class:`int` objects, used internally for integers with \"big enough\" " "absolute value." msgstr "" +":c:func:`PyLong_GetNativeLayout` を使うと、Python の :class:`int` オブジェク" +"トのネイティブなレイアウトを取得できます。\n" +"これは、絶対値が「十分に大きい」整数に内部で使われるレイアウトです。" -#: ../../c-api/long.rst:697 msgid "" "See also :data:`sys.int_info` which exposes similar information in Python." msgstr "" +"Python で同様の情報を提供する :data:`sys.int_info` も参照してください。" -#: ../../c-api/long.rst:701 msgid "" "Bits per digit. For example, a 15 bit digit means that bits 0-14 contain " "meaningful information." msgstr "" +"1 桁あたりのビット数です。\n" +"例えば 15 ビットの桁では、ビット 0–14 が意味のある情報を持ちます。" -#: ../../c-api/long.rst:706 msgid "" "Digit size in bytes. For example, a 15 bit digit will require at least 2 " "bytes." msgstr "" +"バイト単位の桁のサイズです。\n" +"例えば 15 ビットの桁には少なくとも 2 バイトが必要です。" -#: ../../c-api/long.rst:711 msgid "Digits order:" -msgstr "" +msgstr "桁の順序:" -#: ../../c-api/long.rst:713 msgid "``1`` for most significant digit first" -msgstr "" +msgstr "最上位の桁が先なら ``1``" -#: ../../c-api/long.rst:714 msgid "``-1`` for least significant digit first" -msgstr "" +msgstr "最下位の桁が先なら ``-1``" -#: ../../c-api/long.rst:718 msgid "Digit endianness:" -msgstr "" +msgstr "桁のエンディアン:" -#: ../../c-api/long.rst:720 msgid "``1`` for most significant byte first (big endian)" -msgstr "" +msgstr "最上位バイトが先 (ビッグエンディアン) なら ``1``" -#: ../../c-api/long.rst:721 msgid "``-1`` for least significant byte first (little endian)" -msgstr "" +msgstr "最下位バイトが先 (リトルエンディアン) なら ``-1``" -#: ../../c-api/long.rst:726 msgid "Get the native layout of Python :class:`int` objects." msgstr "" +"Python の :class:`int` オブジェクトのネイティブなレイアウトを取得します。" -#: ../../c-api/long.rst:728 msgid "See the :c:type:`PyLongLayout` structure." -msgstr "" +msgstr ":c:type:`PyLongLayout` 構造体を参照してください。" -#: ../../c-api/long.rst:730 msgid "" "The function must not be called before Python initialization nor after " "Python finalization. The returned layout is valid until Python is finalized. " "The layout is the same for all Python sub-interpreters in a process, and so " "it can be cached." msgstr "" +"Python の初期化前や終了処理後にこの関数を呼び出してはいけません。\n" +"返されたレイアウトは Python の終了処理まで有効です。\n" +"レイアウトはプロセス内のすべての Python サブインタープリタで同じなので、" +"キャッシュできます。" -#: ../../c-api/long.rst:738 msgid "Export of a Python :class:`int` object." -msgstr "" +msgstr "Python の :class:`int` オブジェクトのエクスポートです。" -#: ../../c-api/long.rst:740 msgid "There are two cases:" -msgstr "" +msgstr "次の 2 つの場合があります:" -#: ../../c-api/long.rst:742 msgid "" "If :c:member:`digits` is ``NULL``, only use the :c:member:`value` member." msgstr "" +":c:member:`digits` が ``NULL`` の場合は、:c:member:`value` メンバーだけを使っ" +"てください。" -#: ../../c-api/long.rst:743 msgid "" "If :c:member:`digits` is not ``NULL``, use :c:member:`negative`, :c:member:" "`ndigits` and :c:member:`digits` members." msgstr "" +":c:member:`digits` が ``NULL`` でない場合は、:c:member:`negative`、:c:member:" +"`ndigits`、:c:member:`digits` メンバーを使ってください。" -#: ../../c-api/long.rst:748 msgid "" "The native integer value of the exported :class:`int` object. Only valid if :" "c:member:`digits` is ``NULL``." msgstr "" +"エクスポートした :class:`int` オブジェクトのネイティブな整数値です。\n" +":c:member:`digits` が ``NULL`` の場合だけ有効です。" -#: ../../c-api/long.rst:753 msgid "" "``1`` if the number is negative, ``0`` otherwise. Only valid if :c:member:" "`digits` is not ``NULL``." msgstr "" +"負の数なら ``1``、それ以外なら ``0`` です。\n" +":c:member:`digits` が ``NULL`` でない場合だけ有効です。" -#: ../../c-api/long.rst:758 msgid "" "Number of digits in :c:member:`digits` array. Only valid if :c:member:" "`digits` is not ``NULL``." msgstr "" +":c:member:`digits` 配列の桁数です。\n" +":c:member:`digits` が ``NULL`` でない場合だけ有効です。" -#: ../../c-api/long.rst:763 msgid "Read-only array of unsigned digits. Can be ``NULL``." msgstr "" +"符号なしの桁を格納する読み出し専用の配列です。\n" +"``NULL`` の場合もあります。" -#: ../../c-api/long.rst:768 msgid "Export a Python :class:`int` object." -msgstr "" +msgstr "Python の :class:`int` オブジェクトをエクスポートします。" -#: ../../c-api/long.rst:770 msgid "" "*export_long* must point to a :c:type:`PyLongExport` structure allocated by " "the caller. It must not be ``NULL``." msgstr "" +"*export_long* は、呼び出し側が割り当てた :c:type:`PyLongExport` 構造体を指す" +"必要があります。\n" +"``NULL`` であってはなりません。" -#: ../../c-api/long.rst:773 msgid "" "On success, fill in *\\*export_long* and return ``0``. On error, set an " "exception and return ``-1``." msgstr "" +"成功すると *\\*export_long* を埋め、``0`` を返します。\n" +"エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/long.rst:776 msgid "" ":c:func:`PyLong_FreeExport` must be called when the export is no longer " "needed." msgstr "" +"エクスポートが不要になったら :c:func:`PyLong_FreeExport` を呼び出す必要があり" +"ます。" -#: ../../c-api/long.rst:780 msgid "" "This function always succeeds if *obj* is a Python :class:`int` object or a " "subclass." msgstr "" +"*obj* が Python の :class:`int` オブジェクトまたはそのサブクラスであれば、こ" +"の関数は常に成功します。" -#: ../../c-api/long.rst:786 msgid "Release the export *export_long* created by :c:func:`PyLong_Export`." msgstr "" +":c:func:`PyLong_Export` が作成したエクスポート *export_long* を解放します。" -#: ../../c-api/long.rst:789 msgid "" "Calling :c:func:`PyLong_FreeExport` is optional if *export_long->digits* is " "``NULL``." msgstr "" +"*export_long->digits* が ``NULL`` の場合、:c:func:`PyLong_FreeExport` の呼び" +"出しは省略できます。" -#: ../../c-api/long.rst:794 msgid "PyLongWriter API" -msgstr "" +msgstr "PyLongWriter API" -#: ../../c-api/long.rst:796 msgid "The :c:type:`PyLongWriter` API can be used to import an integer." -msgstr "" +msgstr ":c:type:`PyLongWriter` API を使って整数をインポートできます。" -#: ../../c-api/long.rst:802 msgid "A Python :class:`int` writer instance." -msgstr "" +msgstr "Python の :class:`int` ライターのインスタンスです。" -#: ../../c-api/long.rst:804 msgid "" "The instance must be destroyed by :c:func:`PyLongWriter_Finish` or :c:func:" "`PyLongWriter_Discard`." msgstr "" +"インスタンスは :c:func:`PyLongWriter_Finish` または :c:func:" +"`PyLongWriter_Discard` で破棄する必要があります。" -#: ../../c-api/long.rst:810 msgid "Create a :c:type:`PyLongWriter`." -msgstr "" +msgstr ":c:type:`PyLongWriter` を作成します。" -#: ../../c-api/long.rst:812 msgid "" "On success, allocate *\\*digits* and return a writer. On error, set an " "exception and return ``NULL``." msgstr "" +"成功すると *\\*digits* を割り当て、ライターを返します。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/long.rst:815 msgid "*negative* is ``1`` if the number is negative, or ``0`` otherwise." -msgstr "" +msgstr "*negative* は、負の数なら ``1``、それ以外なら ``0`` とします。" -#: ../../c-api/long.rst:817 msgid "" "*ndigits* is the number of digits in the *digits* array. It must be greater " "than 0." msgstr "" +"*ndigits* は *digits* 配列の桁数です。\n" +"0 より大きくなければなりません。" -#: ../../c-api/long.rst:820 msgid "*digits* must not be NULL." -msgstr "" +msgstr "*digits* は ``NULL`` であってはなりません。" -#: ../../c-api/long.rst:822 msgid "" "After a successful call to this function, the caller should fill in the " "array of digits *digits* and then call :c:func:`PyLongWriter_Finish` to get " "a Python :class:`int`. The layout of *digits* is described by :c:func:" "`PyLong_GetNativeLayout`." msgstr "" +"この関数の呼び出しが成功したら、呼び出し側は桁の配列 *digits* を埋め、:c:" +"func:`PyLongWriter_Finish` を呼び出して Python の :class:`int` を取得する必要" +"があります。\n" +"*digits* のレイアウトは :c:func:`PyLong_GetNativeLayout` で記述されます。" -#: ../../c-api/long.rst:827 msgid "" "Digits must be in the range [``0``; ``(1 << bits_per_digit) - 1``] (where " "the :c:type:`~PyLongLayout.bits_per_digit` is the number of bits per digit). " "Any unused most significant digits must be set to ``0``." msgstr "" +"各桁の値は [``0``; ``(1 << bits_per_digit) - 1``] の範囲内でなければなりませ" +"ん (:c:type:`~PyLongLayout.bits_per_digit` は 1 桁あたりのビット数です)。\n" +"使わない上位の桁はすべて ``0`` に設定する必要があります。" -#: ../../c-api/long.rst:832 msgid "" "Alternately, call :c:func:`PyLongWriter_Discard` to destroy the writer " "instance without creating an :class:`~int` object." msgstr "" +"または、:c:func:`PyLongWriter_Discard` を呼び出して、:class:`~int` オブジェク" +"トを作成せずにライターのインスタンスを破棄します。" -#: ../../c-api/long.rst:838 msgid "" "Finish a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`." msgstr "" +":c:func:`PyLongWriter_Create` で作成した :c:type:`PyLongWriter` の処理を完了" +"します。" -#: ../../c-api/long.rst:840 msgid "" "On success, return a Python :class:`int` object. On error, set an exception " "and return ``NULL``." msgstr "" +"成功すると Python の :class:`int` オブジェクトを返します。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/long.rst:843 msgid "" "The function takes care of normalizing the digits and converts the object to " "a compact integer if needed." msgstr "" +"この関数は桁の正規化を行い、必要に応じてオブジェクトをコンパクトな整数に変換" +"します。" -#: ../../c-api/long.rst:846 ../../c-api/long.rst:855 msgid "The writer instance and the *digits* array are invalid after the call." -msgstr "" +msgstr "呼び出し後は、ライターのインスタンスと *digits* 配列は無効になります。" -#: ../../c-api/long.rst:851 msgid "" "Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`." msgstr "" +":c:func:`PyLongWriter_Create` で作成した :c:type:`PyLongWriter` を破棄しま" +"す。" -#: ../../c-api/long.rst:853 msgid "If *writer* is ``NULL``, no operation is performed." -msgstr "" +msgstr "*writer* が ``NULL`` の場合は何もしません。" -#: ../../c-api/long.rst:859 msgid "Deprecated API" -msgstr "" +msgstr "非推奨の API" -#: ../../c-api/long.rst:861 msgid "" "These macros are :term:`soft deprecated`. They describe parameters of the " "internal representation of :c:type:`PyLongObject` instances." msgstr "" +"これらのマクロは :term:`ソフト非推奨 ` です。\n" +":c:type:`PyLongObject` インスタンスの内部表現のパラメーターを記述します。" -#: ../../c-api/long.rst:864 msgid "" "Use :c:func:`PyLong_GetNativeLayout` instead, along with :c:func:" "`PyLong_Export` to read integer data or :c:type:`PyLongWriter` to write it. " "These currently use the same layout, but are designed to continue working " "correctly even if CPython's internal integer representation changes." msgstr "" +"代わりに :c:func:`PyLong_GetNativeLayout` と、整数データを読み取るための :c:" +"func:`PyLong_Export`、または書き込むための :c:type:`PyLongWriter` を使ってく" +"ださい。\n" +"これらは現在は同じレイアウトを使っていますが、CPython の整数の内部表現が変" +"わっても正しく動作し続けるように設計されています。" -#: ../../c-api/long.rst:872 msgid "" "This is equivalent to :c:member:`~PyLongLayout.bits_per_digit` in the output " "of :c:func:`PyLong_GetNativeLayout`." msgstr "" +":c:func:`PyLong_GetNativeLayout` の出力の :c:member:`~PyLongLayout." +"bits_per_digit` と等価です。" -#: ../../c-api/long.rst:878 msgid "This is currently equivalent to :c:expr:`1 << PyLong_SHIFT`." -msgstr "" +msgstr "現在は :c:expr:`1 << PyLong_SHIFT` と等価です。" -#: ../../c-api/long.rst:883 msgid "This is currently equivalent to :c:expr:`(1 << PyLong_SHIFT) - 1`" -msgstr "" +msgstr "現在は :c:expr:`(1 << PyLong_SHIFT) - 1` と等価です。" #: ../../c-api/long.rst:8 msgid "object" @@ -1119,23 +1267,19 @@ msgstr "long integer" msgid "integer" msgstr "整数" -#: ../../c-api/long.rst:177 msgid "LONG_MAX (C macro)" -msgstr "" +msgstr "LONG_MAX (C マクロ)" #: ../../c-api/long.rst:177 ../../c-api/long.rst:235 ../../c-api/long.rst:278 #: ../../c-api/long.rst:293 ../../c-api/long.rst:309 ../../c-api/long.rst:325 msgid "OverflowError (built-in exception)" msgstr "OverflowError (組み込み例外)" -#: ../../c-api/long.rst:278 msgid "PY_SSIZE_T_MAX (C macro)" -msgstr "" +msgstr "PY_SSIZE_T_MAX (C マクロ)" -#: ../../c-api/long.rst:293 msgid "ULONG_MAX (C macro)" -msgstr "" +msgstr "ULONG_MAX (C マクロ)" -#: ../../c-api/long.rst:309 msgid "SIZE_MAX (C macro)" -msgstr "" +msgstr "SIZE_MAX (C マクロ)" diff --git a/c-api/mapping.po b/c-api/mapping.po index a4995c333..a3fefcb39 100644 --- a/c-api/mapping.po +++ b/c-api/mapping.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/mapping.rst:6 @@ -34,7 +34,6 @@ msgstr "" ":c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem` も参照してください。" -#: ../../c-api/mapping.rst:14 msgid "" "Return ``1`` if the object provides the mapping protocol or supports " "slicing, and ``0`` otherwise. Note that it returns ``1`` for Python classes " @@ -42,6 +41,12 @@ msgid "" "to determine what type of keys the class supports. This function always " "succeeds." msgstr "" +"オブジェクトがマッピングプロトコルを提供するかスライスをサポートする場合は " +"``1`` を返し、それ以外の場合は ``0`` を返します。\n" +"クラスがサポートするキーの型を判定することは一般には不可能なため、:meth:" +"`~object.__getitem__` メソッドを持つ Python クラスのオブジェクトに対しても " +"``1`` を返します。\n" +"この関数は常に成功します。" #: ../../c-api/mapping.rst:25 msgid "" @@ -51,20 +56,21 @@ msgstr "" "成功するとオブジェクト *o* 中のキーの数を返し、失敗すると ``-1`` を返します。" "これは、Python の式 ``len(o)`` と同じになります。" -#: ../../c-api/mapping.rst:31 msgid "" "This is the same as :c:func:`PyObject_GetItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_GetItem` と同じですが、``key`` は :c:expr:`PyObject*` では" +"なく、UTF-8 でエンコードした :c:expr:`const char*` のバイト列で指定します。" -#: ../../c-api/mapping.rst:38 msgid "" "Variant of :c:func:`PyObject_GetItem` which doesn't raise :exc:`KeyError` if " "the key is not found." msgstr "" +"キーが見つからない場合に :exc:`KeyError` を送出しない :c:func:" +"`PyObject_GetItem` の変種です。" -#: ../../c-api/mapping.rst:41 msgid "" "If the key is found, return ``1`` and set *\\*result* to a new :term:`strong " "reference` to the corresponding value. If the key is not found, return ``0`` " @@ -72,45 +78,60 @@ msgid "" "error other than :exc:`KeyError` is raised, return ``-1`` and set " "*\\*result* to ``NULL``." msgstr "" +"キーが見つかった場合は ``1`` を返し、対応する値への新しい :term:`強参照 " +"` を ``*result`` に設定します。\n" +"キーが見つからない場合は ``0`` を返し、``*result`` を ``NULL`` に設定して :" +"exc:`KeyError` を抑制します。\n" +":exc:`KeyError` 以外のエラーが発生した場合は ``-1`` を返し、``*result`` を " +"``NULL`` に設定します。" -#: ../../c-api/mapping.rst:53 msgid "" "This is the same as :c:func:`PyMapping_GetOptionalItem`, but *key* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyMapping_GetOptionalItem` と同じですが、``key`` は :c:expr:" +"`PyObject*` ではなく、UTF-8 でエンコードした :c:expr:`const char*` のバイト列" +"で指定します。" -#: ../../c-api/mapping.rst:62 msgid "" "This is the same as :c:func:`PyObject_SetItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_SetItem` と同じですが、``key`` は :c:expr:`PyObject*` では" +"なく、UTF-8 でエンコードした :c:expr:`const char*` のバイト列で指定します。" -#: ../../c-api/mapping.rst:69 msgid "This is an alias of :c:func:`PyObject_DelItem`." -msgstr "" +msgstr ":c:func:`PyObject_DelItem` の別名です。" -#: ../../c-api/mapping.rst:74 msgid "" "This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_DelItem` と同じですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で指定し" +"ます。" -#: ../../c-api/mapping.rst:81 msgid "" "Return ``1`` if the mapping object has the key *key* and ``0`` otherwise. " "This is equivalent to the Python expression ``key in o``. On failure, return " "``-1``." msgstr "" +"マッピングオブジェクトがキー ``key`` を持つ場合は ``1`` を返し、それ以外の場" +"合は ``0`` を返します。\n" +"Python の式 ``key in o`` と同等です。\n" +"失敗した場合は ``-1`` を返します。" -#: ../../c-api/mapping.rst:90 msgid "" "This is the same as :c:func:`PyMapping_HasKeyWithError`, but *key* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyMapping_HasKeyWithError` と同じですが、``key`` は :c:expr:" +"`PyObject*` ではなく、UTF-8 でエンコードした :c:expr:`const char*` のバイト列" +"で指定します。" #: ../../c-api/mapping.rst:99 msgid "" @@ -122,22 +143,26 @@ msgstr "" "は ``0`` を返します。これは、Python の式 ``key in o`` と等価です。この関数呼" "び出しは常に成功します。" -#: ../../c-api/mapping.rst:105 msgid "" "Exceptions which occur when this calls the :meth:`~object.__getitem__` " "method are silently ignored. For proper error handling, use :c:func:" "`PyMapping_HasKeyWithError`, :c:func:`PyMapping_GetOptionalItem` or :c:func:" "`PyObject_GetItem()` instead." msgstr "" +":meth:`~object.__getitem__` メソッドの呼び出し中に発生した例外は、通知せずに" +"無視します。\n" +"エラーを適切に処理するには、代わりに :c:func:`PyMapping_HasKeyWithError`、:c:" +"func:`PyMapping_GetOptionalItem`、:c:func:`PyObject_GetItem()` を使ってくださ" +"い。" -#: ../../c-api/mapping.rst:113 msgid "" "This is the same as :c:func:`PyMapping_HasKey`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyMapping_HasKey` と同じですが、``key`` は :c:expr:`PyObject*` では" +"なく、UTF-8 でエンコードした :c:expr:`const char*` のバイト列で指定します。" -#: ../../c-api/mapping.rst:119 msgid "" "Exceptions that occur when this calls the :meth:`~object.__getitem__` method " "or while creating the temporary :class:`str` object are silently ignored. " @@ -145,6 +170,12 @@ msgid "" "func:`PyMapping_GetOptionalItemString` or :c:func:`PyMapping_GetItemString` " "instead." msgstr "" +":meth:`~object.__getitem__` メソッドの呼び出し中や、一時的な :class:`str` オ" +"ブジェクトの作成中に発生した例外は、通知せずに無視します。\n" +"エラーを適切に処理するには、代わりに :c:func:" +"`PyMapping_HasKeyStringWithError`、:c:func:" +"`PyMapping_GetOptionalItemString`、:c:func:`PyMapping_GetItemString` を使って" +"ください。" #: ../../c-api/mapping.rst:129 msgid "" diff --git a/c-api/marshal.po b/c-api/marshal.po index 0f44b5be4..076c59b04 100644 --- a/c-api/marshal.po +++ b/c-api/marshal.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/marshal.rst:6 @@ -39,19 +39,21 @@ msgstr "" "加えて、データを読み戻す関数もあります。整列化されたデータを記録するファイル" "はバイナリモードで開かれていなければなりません。" -#: ../../c-api/marshal.rst:14 msgid "Numeric values are stored with the least significant byte first." -msgstr "数値は最小桁が先にくるように記録されます。" +msgstr "数値は最下位バイトから順に格納されます。" -#: ../../c-api/marshal.rst:16 msgid "" "The module supports several versions of the data format; see the :py:mod:" "`Python module documentation ` for details." msgstr "" +"このモジュールは複数のデータ形式のバージョンをサポートしています。\n" +"詳細は :py:mod:`Python モジュールのドキュメント ` を参照してくださ" +"い。" -#: ../../c-api/marshal.rst:21 msgid "The current format version. See :py:data:`marshal.version`." msgstr "" +"現在の形式のバージョン。\n" +":py:data:`marshal.version` を参照してください。" #: ../../c-api/marshal.rst:25 msgid "" @@ -71,12 +73,14 @@ msgstr "" "この関数は失敗することがあり、その場合はエラー指示子を設定します。それを確認" "するために :c:func:`PyErr_Occurred` を使います。" -#: ../../c-api/marshal.rst:34 msgid "" "In Python 3.15 and earlier, this function does not set the error indicator " "if writing to *file* fails. The same caveat applies as for :c:func:" "`PyMarshal_WriteObjectToFile`." msgstr "" +"Python 3.15 以前では、``file`` への書き込みに失敗しても、この関数はエラー指示" +"子を設定しません。\n" +":c:func:`PyMarshal_WriteObjectToFile` と同じ注意事項が当てはまります。" #: ../../c-api/marshal.rst:40 msgid "" @@ -86,7 +90,6 @@ msgstr "" "Python オブジェクト *value* を *file* へ整列化します。*version* はファイル" "フォーマットを示します。" -#: ../../c-api/marshal.rst:48 msgid "" "In Python 3.15 and earlier, this function can write only part of the data to " "*file* and return without setting the error indicator, for example if " @@ -96,6 +99,14 @@ msgid "" "written. It can use :c:func:`PyMarshal_WriteObjectToString` and write the " "result itself, or validate what was written." msgstr "" +"Python 3.15 以前では、``file`` にデータの一部だけを書き込んで、エラー指示子を" +"設定せずに戻る場合があります。\n" +"例えば、``value`` に整列化できないオブジェクトが含まれる場合や、``file`` への" +"書き込みに失敗した場合です (:gh:`155907` を参照)。\n" +"これらのバージョンをサポートするコードでは、:c:func:`PyErr_Occurred` だけを" +"使ってデータ全体が書き込まれたかどうかを判断することはできません。\n" +":c:func:`PyMarshal_WriteObjectToString` を使ってその結果を自分で書き込むか、" +"書き込まれた内容を検証してください。" #: ../../c-api/marshal.rst:59 msgid "" @@ -153,7 +164,6 @@ msgstr "" "エラーの場合、適切な例外 (:exc:`EOFError`, :exc:`ValueError`, :exc:" "`TypeError`) を設定し ``NULL`` を返します。" -#: ../../c-api/marshal.rst:97 msgid "" "Return a Python object from the data stream in a :c:expr:`FILE*` opened for " "reading. Unlike :c:func:`PyMarshal_ReadObjectFromFile`, this function " @@ -163,6 +173,13 @@ msgid "" "file. Only use this variant if you are certain that you won't be reading " "anything else from the file." msgstr "" +"読み取り用に開かれた :c:expr:`FILE*` のデータストリームから Python オブジェク" +"トを読み取って返します。\n" +":c:func:`PyMarshal_ReadObjectFromFile` と異なり、この関数はファイルからこれ以" +"上オブジェクトを読み取らないことを前提とします。\n" +"そのため、ファイルのデータをまとめてメモリに読み込み、ファイルから 1 バイトず" +"つ読み取る代わりにメモリ上のデータから復元できます。\n" +"そのファイルからほかに何も読み取らないと確信できる場合だけ使ってください。" #: ../../c-api/marshal.rst:111 msgid "" diff --git a/c-api/memory.po b/c-api/memory.po index 42db0cdf9..fd2493ea4 100644 --- a/c-api/memory.po +++ b/c-api/memory.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/memory.rst:8 @@ -108,7 +108,6 @@ msgstr "" "メモリ操作関数を使って安全にメモリを確保したり解放したりできます。例えば、以" "下がそのような例です::" -#: ../../c-api/memory.rst:54 msgid "" "PyObject *res;\n" "char *buf = (char *) malloc(BUFSIZ); /* for I/O */\n" @@ -120,6 +119,15 @@ msgid "" "free(buf); /* malloc'ed */\n" "return res;" msgstr "" +"PyObject *res;\n" +"char *buf = (char *) malloc(BUFSIZ); /* I/O 用 */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"...buf を使って何らかの I/O 操作を行う...\n" +"res = PyBytes_FromString(buf);\n" +"free(buf); /* malloc で割り当て済み */\n" +"return res;" #: ../../c-api/memory.rst:64 msgid "" @@ -167,11 +175,9 @@ msgstr "" "生成される時と、シャットダウン時に :ref:`pymalloc メモリアロケータ " "` の統計情報を表示できます。" -#: ../../c-api/memory.rst:92 msgid "Allocator Domains" -msgstr "" +msgstr "アロケータドメイン" -#: ../../c-api/memory.rst:96 msgid "" "All allocating functions belong to one of three different \"domains\" (see " "also :c:type:`PyMemAllocatorDomain`). These domains represent different " @@ -183,12 +189,19 @@ msgid "" "from the same domain. For example, :c:func:`PyMem_Free` must be used to free " "memory allocated using :c:func:`PyMem_Malloc`." msgstr "" +"すべてのメモリ割り当て関数は、三つの「ドメイン」のいずれかに属します (:c:" +"type:`PyMemAllocatorDomain` も参照)。\n" +"各ドメインは異なる割り当て方針を表し、異なる用途に最適化されています。\n" +"各ドメインがどうメモリを割り当て、内部でどの関数を呼ぶかは実装の詳細ですが、" +"デバッグ用の簡略化した表を :ref:`default-memory-allocators` に示します。\n" +"あるメモリブロックの割り当てと解放に使う API は、同じドメインに属している必要" +"があります。\n" +"例えば :c:func:`PyMem_Malloc` で割り当てたメモリは :c:func:`PyMem_Free` で解" +"放しなければなりません。" -#: ../../c-api/memory.rst:105 msgid "The three allocation domains are:" -msgstr "" +msgstr "三つの割り当てドメインは次のとおりです。" -#: ../../c-api/memory.rst:107 msgid "" "Raw domain: intended for allocating memory for general-purpose memory " "buffers where the allocation *must* go to the system allocator or where the " @@ -196,59 +209,80 @@ msgid "" "is requested directly from the system. See :ref:`Raw Memory Interface `." msgstr "" +"Raw ドメイン: システムアロケータによる割り当てが *必要* な場合や、:term:`ア" +"タッチされたスレッド状態 ` なしで動作できるアロケータ" +"が必要な場合に、汎用メモリバッファを割り当てるためのものです。\n" +"メモリはシステムに直接要求します。\n" +":ref:`生メモリインターフェース ` を参照してください。" -#: ../../c-api/memory.rst:112 msgid "" "\"Mem\" domain: intended for allocating memory for Python buffers and " "general-purpose memory buffers where the allocation must be performed with " "an :term:`attached thread state`. The memory is taken from the Python " "private heap. See :ref:`Memory Interface `." msgstr "" +"Mem ドメイン: :term:`スレッド状態がアタッチされた ` 状" +"態で、Python のバッファや汎用メモリバッファを割り当てるためのものです。\n" +"メモリは Python のプライベートヒープから取得します。\n" +":ref:`メモリインターフェース ` を参照してください。" -#: ../../c-api/memory.rst:117 msgid "" "Object domain: intended for allocating memory for Python objects. The memory " "is taken from the Python private heap. See :ref:`Object allocators " "`." msgstr "" +"Object ドメイン: Python オブジェクト用のメモリを割り当てるためのものです。\n" +"メモリは Python のプライベートヒープから取得します。\n" +":ref:`オブジェクトアロケータ ` を参照してください。" -#: ../../c-api/memory.rst:122 msgid "" "The :term:`free-threaded ` build requires that only Python " "objects are allocated using the \"object\" domain and that all Python " "objects are allocated using that domain. This differs from the prior Python " "versions, where this was only a best practice and not a hard requirement." msgstr "" +":term:`フリースレッド ` ビルドでは、object ドメインで割り当て" +"るのは Python オブジェクトだけとし、すべての Python オブジェクトをそのドメイ" +"ンで割り当てる必要があります。\n" +"以前の Python では推奨事項にすぎませんでしたが、フリースレッドビルドでは必須" +"の要件です。" -#: ../../c-api/memory.rst:126 msgid "" "For example, buffers (non-Python objects) should be allocated using :c:func:" "`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`, but not :c:" "func:`PyObject_Malloc`." msgstr "" +"例えば、Python オブジェクトではないバッファは :c:func:`PyObject_Malloc` では" +"なく、:c:func:`PyMem_Malloc`、:c:func:`PyMem_RawMalloc`、:c:func:`malloc` で" +"割り当ててください。" -#: ../../c-api/memory.rst:129 msgid "See :ref:`Memory Allocation APIs `." msgstr "" +":ref:`メモリ割り当て API ` を参照してくださ" +"い。" #: ../../c-api/memory.rst:135 msgid "Raw Memory Interface" msgstr "生メモリインターフェース" -#: ../../c-api/memory.rst:137 msgid "" "The following function sets are wrappers to the system allocator. These " "functions are thread-safe, so a :term:`thread state` does not need to be :" "term:`attached `." msgstr "" +"以下の関数群は、システムアロケータのラッパーです。\n" +"これらはスレッドセーフなので、:term:`スレッド状態 ` が :term:`" +"アタッチされている ` 必要はありません。" -#: ../../c-api/memory.rst:141 msgid "" "The :ref:`default raw memory allocator ` uses the " "following functions: :c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` " "and :c:func:`!free`; call ``malloc(1)`` (or ``calloc(1, 1)``) when " "requesting zero bytes." msgstr "" +":ref:`デフォルトの生メモリアロケータ ` は :c:func:" +"`malloc`、:c:func:`calloc`、:c:func:`realloc`、:c:func:`!free` を使います。\n" +"0 バイトの要求には ``malloc(1)`` または ``calloc(1, 1)`` を呼び出します。" #: ../../c-api/memory.rst:150 ../../c-api/memory.rst:228 #: ../../c-api/memory.rst:361 @@ -269,13 +303,15 @@ msgstr "" "なら ``NULL`` でないユニークなポインタを返します。確保されたメモリーにはいか" "なる初期化も行われません。" -#: ../../c-api/memory.rst:160 ../../c-api/memory.rst:238 -#: ../../c-api/memory.rst:371 msgid "" "Allocates *nelem* elements each of size *elsize* bytes and returns a pointer " "of type :c:expr:`void*` to the allocated memory, or ``NULL`` if the request " "fails. The memory is initialized to zeros." msgstr "" +"サイズ ``elsize`` バイトの要素 ``nelem`` 個分のメモリを割り当て、その領域へ" +"の :c:expr:`void*` ポインタを返します。\n" +"要求が失敗した場合は ``NULL`` を返します。\n" +"メモリはゼロで初期化されます。" #: ../../c-api/memory.rst:164 msgid "" @@ -354,18 +390,23 @@ msgstr "" "ます。これらの関数は ANSI C 標準に従ってモデル化されていますが、0 バイトを要" "求した際の動作についても定義しています:" -#: ../../c-api/memory.rst:207 msgid "" "In the GIL-enabled build (default build) the :ref:`default memory allocator " "` uses the :ref:`pymalloc memory allocator " "`, whereas in the :term:`free-threaded build`, the default is the :" "ref:`mimalloc memory allocator ` instead." msgstr "" +"GIL が有効なビルド (デフォルトのビルド) では、:ref:`デフォルトのメモリアロ" +"ケータ ` は :ref:`pymalloc メモリアロケータ " +"` を使います。\n" +":term:`フリースレッドビルド ` では、代わりに :ref:" +"`mimalloc メモリアロケータ ` がデフォルトです。" -#: ../../c-api/memory.rst:215 ../../c-api/memory.rst:357 msgid "" "There must be an :term:`attached thread state` when using these functions." msgstr "" +"これらの関数を使うときは :term:`スレッド状態がアタッチされている ` 必要があります。" #: ../../c-api/memory.rst:219 msgid "" @@ -374,11 +415,12 @@ msgstr "" "デフォルトのアロケータがシステムの :c:func:`malloc` から pymalloc になりまし" "た。" -#: ../../c-api/memory.rst:223 msgid "" "In the :term:`free-threaded ` build, the default allocator " "is now :ref:`mimalloc `." msgstr "" +":term:`フリースレッド ` ビルドでは、デフォルトのアロケータ" +"が :ref:`mimalloc ` になりました。" #: ../../c-api/memory.rst:231 msgid "" @@ -446,20 +488,26 @@ msgstr "" "以下に挙げる型対象のマクロは利便性のために提供されているものです。*TYPE* は任" "意の C の型を表します。" -#: ../../c-api/memory.rst:280 msgid "" "Same as :c:func:`PyMem_Malloc`, but allocates ``(n * sizeof(TYPE))`` bytes " "of memory. Returns a pointer cast to ``TYPE*``. The memory will not have " "been initialized in any way." msgstr "" +":c:func:`PyMem_Malloc` と同じですが、``(n * sizeof(TYPE))`` バイトのメモリを" +"割り当て、``TYPE*`` にキャストしたポインタを返します。\n" +"メモリはいかなる方法でも初期化されません。" -#: ../../c-api/memory.rst:287 msgid "" "Same as :c:func:`PyMem_Realloc`, but the memory block is resized to ``(n * " "sizeof(TYPE))`` bytes. Returns a pointer cast to ``TYPE*``. On return, *p* " "will be a pointer to the new memory area, or ``NULL`` in the event of " "failure." msgstr "" +":c:func:`PyMem_Realloc` と同じですが、メモリブロックを ``(n * " +"sizeof(TYPE))`` バイトにリサイズし、``TYPE*`` にキャストしたポインタを返しま" +"す。\n" +"戻ったときの ``p`` は、新しいメモリ領域へのポインタ、または失敗した場合は " +"``NULL`` です。" #: ../../c-api/memory.rst:292 msgid "" @@ -477,67 +525,72 @@ msgstr ":c:func:`PyMem_Free` と同じです。" msgid "Deprecated aliases" msgstr "非推奨のエイリアス" -#: ../../c-api/memory.rst:304 msgid "" "These are :term:`soft deprecated` aliases to existing functions and macros. " "They exist solely for backwards compatibility." msgstr "" +"これらは既存の関数やマクロの :term:`緩やかに非推奨 ` な別名" +"です。\n" +"後方互換性のためだけに存在します。" #: ../../c-api/memory.rst:311 msgid "Deprecated alias" msgstr "非推奨のエイリアス" -#: ../../c-api/memory.rst:312 msgid "Corresponding function or macro" -msgstr "" +msgstr "対応する関数またはマクロ" -#: ../../c-api/memory.rst:314 msgid ":c:func:`PyMem_Malloc`" -msgstr "" +msgstr ":c:func:`PyMem_Malloc`" -#: ../../c-api/memory.rst:316 msgid ":c:macro:`PyMem_New`" -msgstr "" +msgstr ":c:macro:`PyMem_New`" #: ../../c-api/memory.rst:318 ../../c-api/memory.rst:507 msgid ":c:func:`PyMem_Realloc`" msgstr ":c:func:`PyMem_Realloc`" -#: ../../c-api/memory.rst:320 msgid ":c:macro:`PyMem_Resize`" -msgstr "" +msgstr ":c:macro:`PyMem_Resize`" #: ../../c-api/memory.rst:322 ../../c-api/memory.rst:324 #: ../../c-api/memory.rst:509 msgid ":c:func:`PyMem_Free`" msgstr ":c:func:`PyMem_Free`" -#: ../../c-api/memory.rst:328 msgid "" "The macros are now aliases of the corresponding functions and macros. " "Previously, their behavior was the same, but their use did not necessarily " "preserve binary compatibility across Python versions." msgstr "" +"これらのマクロは、対応する関数やマクロの別名になりました。\n" +"以前も動作は同じでしたが、使うと Python バージョン間のバイナリ互換性が保たれ" +"るとは限りませんでした。" #: ../../c-api/memory.rst:338 msgid "Object allocators" msgstr "オブジェクトアロケータ" -#: ../../c-api/memory.rst:345 msgid "" "There is no guarantee that the memory returned by these allocators can be " "successfully cast to a Python object when intercepting the allocating " "functions in this domain by the methods described in the :ref:`Customize " "Memory Allocators ` section." msgstr "" +":ref:`メモリアロケータのカスタマイズ ` で説明す" +"る方法でこのドメインの割り当て関数を差し替えて処理を挟む場合、返されるメモリ" +"を Python オブジェクトへ安全にキャストできる保証はありません。" -#: ../../c-api/memory.rst:350 msgid "" "The :ref:`default object allocator ` uses the :" "ref:`pymalloc memory allocator `. In the :term:`free-threaded " "` build, the default is the :ref:`mimalloc memory allocator " "` instead." msgstr "" +":ref:`デフォルトのオブジェクトアロケータ ` は :" +"ref:`pymalloc メモリアロケータ ` を使います。\n" +":term:`フリースレッド ` ビルドでは、代わりに :ref:`mimalloc " +"メモリアロケータ ` がデフォルトです。" #: ../../c-api/memory.rst:364 msgid "" @@ -598,23 +651,27 @@ msgstr "" "`PyObject_Calloc` の返した値でなければなりません。それ以外の場合や " "``PyObject_Free(p)`` を呼び出した後だった場合、未定義の動作になります。" -#: ../../c-api/memory.rst:407 msgid "" "Do not call this directly to free an object's memory; call the type's :c:" "member:`~PyTypeObject.tp_free` slot instead." msgstr "" +"オブジェクトのメモリを解放するために直接呼び出さず、代わりに型の :c:member:" +"`~PyTypeObject.tp_free` スロットを呼び出してください。" -#: ../../c-api/memory.rst:410 msgid "" "Do not use this for memory allocated by :c:macro:`PyObject_GC_New` or :c:" "macro:`PyObject_GC_NewVar`; use :c:func:`PyObject_GC_Del` instead." msgstr "" +":c:macro:`PyObject_GC_New` または :c:macro:`PyObject_GC_NewVar` で割り当てた" +"メモリには使わないでください。\n" +"代わりに :c:func:`PyObject_GC_Del` を使ってください。" -#: ../../c-api/memory.rst:415 msgid "" ":c:func:`PyObject_GC_Del` is the equivalent of this function for memory " "allocated by types that support garbage collection." msgstr "" +"ガベージコレクションをサポートする型が割り当てたメモリに対しては、:c:func:" +"`PyObject_GC_Del` がこの関数に相当します。" #: ../../c-api/memory.rst:417 ../../c-api/memory.rst:515 msgid ":c:func:`PyObject_Malloc`" @@ -628,33 +685,27 @@ msgstr ":c:func:`PyObject_Realloc`" msgid ":c:func:`PyObject_Calloc`" msgstr ":c:func:`PyObject_Calloc`" -#: ../../c-api/memory.rst:420 msgid ":c:macro:`PyObject_New`" -msgstr "" +msgstr ":c:macro:`PyObject_New`" -#: ../../c-api/memory.rst:421 msgid ":c:macro:`PyObject_NewVar`" -msgstr "" +msgstr ":c:macro:`PyObject_NewVar`" -#: ../../c-api/memory.rst:422 msgid ":c:func:`PyType_GenericAlloc`" -msgstr "" +msgstr ":c:func:`PyType_GenericAlloc`" #: ../../c-api/memory.rst:423 msgid ":c:member:`~PyTypeObject.tp_free`" msgstr ":c:member:`~PyTypeObject.tp_free`" -#: ../../c-api/memory.rst:429 msgid "Default Memory Allocators" -msgstr "" +msgstr "デフォルトのメモリアロケータ" -#: ../../c-api/memory.rst:431 msgid "Default memory allocators:" -msgstr "" +msgstr "デフォルトのメモリアロケータは次のとおりです。" -#: ../../c-api/memory.rst:434 msgid "Configuration" -msgstr "Configuration" +msgstr "設定" #: ../../c-api/memory.rst:434 msgid "Name" @@ -720,71 +771,66 @@ msgstr "pymalloc 無しのデバッグビルド" msgid "``\"malloc_debug\"``" msgstr "``\"malloc_debug\"``" -#: ../../c-api/memory.rst:440 msgid "Free-threaded build" -msgstr "" +msgstr "フリースレッドビルド" -#: ../../c-api/memory.rst:440 msgid "``\"mimalloc\"``" -msgstr "" +msgstr "``\"mimalloc\"``" -#: ../../c-api/memory.rst:440 msgid "``mimalloc``" -msgstr "" +msgstr "``mimalloc``" -#: ../../c-api/memory.rst:441 msgid "Free-threaded debug build" -msgstr "" +msgstr "フリースレッドのデバッグビルド" -#: ../../c-api/memory.rst:441 msgid "``\"mimalloc_debug\"``" -msgstr "" +msgstr "``\"mimalloc_debug\"``" -#: ../../c-api/memory.rst:441 msgid "``mimalloc`` + debug" -msgstr "" +msgstr "``mimalloc`` + debug" #: ../../c-api/memory.rst:444 msgid "Legend:" msgstr "説明:" -#: ../../c-api/memory.rst:446 msgid "Name: value for :envvar:`PYTHONMALLOC` environment variable." -msgstr "" +msgstr "名前: 環境変数 :envvar:`PYTHONMALLOC` に指定する値。" -#: ../../c-api/memory.rst:447 msgid "" "``malloc``: system allocators from the standard C library, C functions: :c:" "func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`." msgstr "" +"``malloc``: 標準 C ライブラリのシステムアロケータ。\n" +"C 関数 :c:func:`malloc`、:c:func:`calloc`、:c:func:`realloc`、:c:func:`free` " +"です。" -#: ../../c-api/memory.rst:449 msgid "``pymalloc``: :ref:`pymalloc memory allocator `." -msgstr "" +msgstr "``pymalloc``: :ref:`pymalloc メモリアロケータ `。" -#: ../../c-api/memory.rst:450 msgid "``mimalloc``: :ref:`mimalloc memory allocator `." -msgstr "" +msgstr "``mimalloc``: :ref:`mimalloc メモリアロケータ `。" -#: ../../c-api/memory.rst:451 msgid "" "\"+ debug\": with :ref:`debug hooks on the Python memory allocators `." msgstr "" +"\"+ debug\": :ref:`Python メモリアロケータのデバッグフック ` 付き。" -#: ../../c-api/memory.rst:453 msgid "\"Debug build\": :ref:`Python build in debug mode `." msgstr "" +"「デバッグビルド」: :ref:`デバッグモードでの Python ビルド `。" #: ../../c-api/memory.rst:458 msgid "Customize Memory Allocators" msgstr "メモリアロケータをカスタマイズする" -#: ../../c-api/memory.rst:464 msgid "" "Structure used to describe a memory block allocator. The structure has the " "following fields:" msgstr "" +"メモリブロックのアロケータを記述する構造体です。\n" +"以下のフィールドを持ちます。" #: ../../c-api/memory.rst:468 ../../c-api/memory.rst:723 msgid "Field" @@ -834,11 +880,12 @@ msgstr "``void free(void *ctx, void *ptr)``" msgid "free a memory block" msgstr "メモリブロックを解放する" -#: ../../c-api/memory.rst:482 msgid "" "The :c:type:`!PyMemAllocator` structure was renamed to :c:type:" "`PyMemAllocatorEx` and a new ``calloc`` field was added." msgstr "" +":c:type:`!PyMemAllocator` 構造体を :c:type:`PyMemAllocatorEx` に改名し、新し" +"い ``calloc`` フィールドを追加しました。" #: ../../c-api/memory.rst:489 msgid "Enum used to identify an allocator domain. Domains:" @@ -893,19 +940,22 @@ msgstr "" "新しいアロケータは、0バイトを要求されたときユニークな ``NULL`` でないポインタ" "を返さなければなりません。" -#: ../../c-api/memory.rst:532 msgid "" "For the :c:macro:`PYMEM_DOMAIN_RAW` domain, the allocator must be thread-" "safe: a :term:`thread state` is not :term:`attached ` " "when the allocator is called." msgstr "" +":c:macro:`PYMEM_DOMAIN_RAW` ドメインでは、:term:`スレッド状態 ` が :term:`アタッチされていない ` 状態で呼び出" +"されるため、アロケータはスレッドセーフでなければなりません。" -#: ../../c-api/memory.rst:536 msgid "" "For the remaining domains, the allocator must also be thread-safe: the " "allocator may be called in different interpreters that do not share a :term:" "`GIL`." msgstr "" +"ほかのドメインでも、:term:`GIL` を共有しない異なるインタープリタから呼び出さ" +"れる場合があるため、アロケータはスレッドセーフでなければなりません。" #: ../../c-api/memory.rst:540 msgid "" @@ -917,17 +967,16 @@ msgstr "" "func:`PyMem_SetupDebugHooks` 関数を呼び出して、新しいアロケータの上にデバッグ" "フックを再度設置しなければなりません。" -#: ../../c-api/memory.rst:544 msgid "" "See also :c:member:`PyPreConfig.allocator` and :ref:`Preinitialize Python " "with PyPreConfig `." msgstr "" +":c:member:`PyPreConfig.allocator` と :ref:`PyPreConfig による Python の事前初" +"期化 ` も参照してください。" -#: ../../c-api/memory.rst:549 msgid ":c:func:`PyMem_SetAllocator` does have the following contract:" -msgstr "" +msgstr ":c:func:`PyMem_SetAllocator` には次の規約があります。" -#: ../../c-api/memory.rst:551 msgid "" "It can be called after :c:func:`Py_PreInitialize` and before :c:func:" "`Py_InitializeFromConfig` to install a custom memory allocator. There are no " @@ -936,50 +985,62 @@ msgid "" "without an :term:`attached thread state`). See :ref:`the section on " "allocator domains ` for more information." msgstr "" +":c:func:`Py_PreInitialize` の後、:c:func:`Py_InitializeFromConfig` の前に呼び" +"出すと、カスタムのメモリアロケータを設定できます。\n" +"設定するアロケータに対しては、ドメインの要件以外の制約はありません。\n" +"例えば Raw ドメインでは、:term:`アタッチされたスレッド状態 ` がなくてもアロケータを呼び出せます。\n" +"詳細は :ref:`アロケータドメインの節 ` を参照してください。" -#: ../../c-api/memory.rst:559 msgid "" "If called after Python has finish initializing (after :c:func:" "`Py_InitializeFromConfig` has been called) the allocator **must** wrap the " "existing allocator. Substituting the current allocator for some other " "arbitrary one is **not supported**." msgstr "" +"Python の初期化完了後 (:c:func:`Py_InitializeFromConfig` の呼び出し後) に呼び" +"出す場合、アロケータは既存のアロケータを **必ず** ラップしなければなりませ" +"ん。\n" +"現在のアロケータを別の任意のアロケータで置き換えることは **サポートされていま" +"せん**。" -#: ../../c-api/memory.rst:564 msgid "All allocators must be thread-safe." -msgstr "" +msgstr "すべてのアロケータがスレッドセーフである必要があります。" -#: ../../c-api/memory.rst:570 msgid "" "Setup :ref:`debug hooks in the Python memory allocators ` " "to detect memory errors." msgstr "" +"メモリエラーを検出するために :ref:`Python メモリアロケータのデバッグフック " +"` を設定します。" -#: ../../c-api/memory.rst:577 msgid "Debug hooks on the Python memory allocators" -msgstr "" +msgstr "Python メモリアロケータのデバッグフック" -#: ../../c-api/memory.rst:579 msgid "" "When :ref:`Python is built in debug mode `, the :c:func:" "`PyMem_SetupDebugHooks` function is called at the :ref:`Python " "preinitialization ` to setup debug hooks on Python memory " "allocators to detect memory errors." msgstr "" +":ref:`デバッグモードで Python をビルドした ` 場合、:ref:`Python " +"の事前初期化 ` で :c:func:`PyMem_SetupDebugHooks` を呼び出し、メモ" +"リエラーを検出するデバッグフックをメモリアロケータに設定します。" -#: ../../c-api/memory.rst:584 msgid "" "The :envvar:`PYTHONMALLOC` environment variable can be used to install debug " "hooks on a Python compiled in release mode (ex: ``PYTHONMALLOC=debug``)." msgstr "" +"リリースモードでコンパイルした Python でも、環境変数 :envvar:`PYTHONMALLOC` " +"でデバッグフックを設定できます (例: ``PYTHONMALLOC=debug``)。" -#: ../../c-api/memory.rst:587 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function can be used to set debug hooks " "after calling :c:func:`PyMem_SetAllocator`." msgstr "" +":c:func:`PyMem_SetAllocator` を呼び出した後で、:c:func:" +"`PyMem_SetupDebugHooks` によってデバッグフックを設定できます。" -#: ../../c-api/memory.rst:590 msgid "" "These debug hooks fill dynamically allocated memory blocks with special, " "recognizable bit patterns. Newly allocated memory is filled with the byte " @@ -988,40 +1049,56 @@ msgid "" "bytes\" filled with the byte ``0xFD`` (``PYMEM_FORBIDDENBYTE``). Strings of " "these bytes are unlikely to be valid addresses, floats, or ASCII strings." msgstr "" +"これらのデバッグフックは、動的に割り当てられたメモリブロックを識別しやすい特" +"別なビットパターンで埋めます。\n" +"新しく割り当てたメモリはバイト ``0xCD`` (``PYMEM_CLEANBYTE``)、解放したメモリ" +"はバイト ``0xDD`` (``PYMEM_DEADBYTE``) で埋めます。\n" +"メモリブロックの前後には、バイト ``0xFD`` (``PYMEM_FORBIDDENBYTE``) で埋めた" +"「禁止バイト」を置きます。\n" +"これらのバイトの並びは、有効なアドレス、浮動小数点数、ASCII 文字列にはなりに" +"くいものです。" #: ../../c-api/memory.rst:597 msgid "Runtime checks:" msgstr "実行時チェック:" -#: ../../c-api/memory.rst:599 msgid "" "Detect API violations. For example, detect if :c:func:`PyObject_Free` is " "called on a memory block allocated by :c:func:`PyMem_Malloc`." msgstr "" +"API の誤用を検出します。\n" +"例えば、:c:func:`PyMem_Malloc` で割り当てたメモリブロックに :c:func:" +"`PyObject_Free` を呼び出した場合を検出します。" -#: ../../c-api/memory.rst:601 msgid "Detect write before the start of the buffer (buffer underflow)." msgstr "" +"バッファの先頭より前への書き込み (バッファアンダーフロー) を検出します。" -#: ../../c-api/memory.rst:602 msgid "Detect write after the end of the buffer (buffer overflow)." msgstr "" +"バッファの末尾より後への書き込み (バッファオーバーフロー) を検出します。" -#: ../../c-api/memory.rst:603 msgid "" "Check that there is an :term:`attached thread state` when allocator " "functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex: :c:func:`PyObject_Malloc`) " "and :c:macro:`PYMEM_DOMAIN_MEM` (ex: :c:func:`PyMem_Malloc`) domains are " "called." msgstr "" +":c:macro:`PYMEM_DOMAIN_OBJ` (例: :c:func:`PyObject_Malloc`) と :c:macro:" +"`PYMEM_DOMAIN_MEM` (例: :c:func:`PyMem_Malloc`) のアロケータ関数を呼び出すと" +"きに、:term:`スレッド状態がアタッチされている ` ことを" +"確認します。" -#: ../../c-api/memory.rst:608 msgid "" "On error, the debug hooks use the :mod:`tracemalloc` module to get the " "traceback where a memory block was allocated. The traceback is only " "displayed if :mod:`tracemalloc` is tracing Python memory allocations and the " "memory block was traced." msgstr "" +"エラーの場合、デバッグフックは :mod:`tracemalloc` を使って、メモリブロックを" +"割り当てた箇所のトレースバックを取得します。\n" +"表示されるのは、:mod:`tracemalloc` が Python のメモリ割り当てを追跡しており、" +"そのブロックが追跡対象だった場合だけです。" #: ../../c-api/memory.rst:613 msgid "" @@ -1037,45 +1114,42 @@ msgstr "" msgid "``p[-2*S:-S]``" msgstr "``p[-2*S:-S]``" -#: ../../c-api/memory.rst:620 msgid "" "Number of bytes originally asked for. This is a size_t, big-endian (easier " "to read in a memory dump)." msgstr "" +"元の要求バイト数です。\n" +"メモリダンプで読みやすいように、ビッグエンディアンの size_t で格納します。" #: ../../c-api/memory.rst:622 msgid "``p[-S]``" msgstr "``p[-S]``" -#: ../../c-api/memory.rst:623 msgid "API identifier (ASCII character):" -msgstr "" +msgstr "API 識別子 (ASCII 文字)。" -#: ../../c-api/memory.rst:625 msgid "``'r'`` for :c:macro:`PYMEM_DOMAIN_RAW`." -msgstr "" +msgstr ":c:macro:`PYMEM_DOMAIN_RAW` は ``'r'``。" -#: ../../c-api/memory.rst:626 msgid "``'m'`` for :c:macro:`PYMEM_DOMAIN_MEM`." -msgstr "" +msgstr ":c:macro:`PYMEM_DOMAIN_MEM` は ``'m'``。" -#: ../../c-api/memory.rst:627 msgid "``'o'`` for :c:macro:`PYMEM_DOMAIN_OBJ`." -msgstr "" +msgstr ":c:macro:`PYMEM_DOMAIN_OBJ` は ``'o'``。" #: ../../c-api/memory.rst:629 msgid "``p[-S+1:0]``" msgstr "``p[-S+1:0]``" -#: ../../c-api/memory.rst:630 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and reads." msgstr "" +"PYMEM_FORBIDDENBYTE の繰り返しです。\n" +"領域の手前への書き込みや読み取りを検出するために使います。" #: ../../c-api/memory.rst:632 msgid "``p[0:N]``" msgstr "``p[0:N]``" -#: ../../c-api/memory.rst:633 msgid "" "The requested memory, filled with copies of PYMEM_CLEANBYTE, used to catch " "reference to uninitialized memory. When a realloc-like function is called " @@ -1085,26 +1159,35 @@ msgid "" "like function is called requesting a smaller memory block, the excess old " "bytes are also filled with PYMEM_DEADBYTE." msgstr "" +"要求されたメモリ領域は、未初期化メモリへのアクセスを検出するために " +"PYMEM_CLEANBYTE で埋めます。\n" +"realloc 系の関数で領域を拡大した場合、追加部分も PYMEM_CLEANBYTE で埋めま" +"す。\n" +"free 系の関数を呼び出すと、解放済みメモリへのアクセスを検出するために " +"PYMEM_DEADBYTE で上書きします。\n" +"realloc 系の関数で領域を縮小した場合も、不要になった元の領域を " +"PYMEM_DEADBYTE で埋めます。" #: ../../c-api/memory.rst:641 msgid "``p[N:N+S]``" msgstr "``p[N:N+S]``" -#: ../../c-api/memory.rst:642 msgid "Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and reads." msgstr "" +"PYMEM_FORBIDDENBYTE の繰り返しです。\n" +"領域の後ろへの書き込みや読み取りを検出するために使います。" #: ../../c-api/memory.rst:644 msgid "``p[N+S:N+2*S]``" msgstr "``p[N+S:N+2*S]``" -#: ../../c-api/memory.rst:645 msgid "" "Only used if the ``PYMEM_DEBUG_SERIALNO`` macro is defined (not defined by " "default)." msgstr "" +"``PYMEM_DEBUG_SERIALNO`` マクロが定義されている場合だけ使います (デフォルトで" +"は未定義)。" -#: ../../c-api/memory.rst:648 msgid "" "A serial number, incremented by 1 on each call to a malloc-like or realloc-" "like function. Big-endian :c:type:`size_t`. If \"bad memory\" is detected " @@ -1113,8 +1196,13 @@ msgid "" "static function bumpserialno() in obmalloc.c is the only place the serial " "number is incremented, and exists so you can set such a breakpoint easily." msgstr "" +"malloc 系または realloc 系の関数の呼び出しごとに 1 増える通し番号です。\n" +"ビッグエンディアンの :c:type:`size_t` で格納します。\n" +"後で「不正なメモリ」を検出した場合、この番号を使って次回の実行でブレークポイ" +"ントを設定すると、そのブロックを渡した瞬間を捉えられます。\n" +"obmalloc.c の静的関数 bumpserialno() だけがこの番号を増やし、そのようなブレー" +"クポイントを簡単に設定できるようになっています。" -#: ../../c-api/memory.rst:655 msgid "" "A realloc-like or free-like function first checks that the " "PYMEM_FORBIDDENBYTE bytes at each end are intact. If they've been altered, " @@ -1126,8 +1214,16 @@ msgid "" "memory is getting used) or PYMEM_CLEANBYTE (meaning uninitialized memory is " "getting used)." msgstr "" +"realloc 系や free 系の関数は、まず領域の前後の PYMEM_FORBIDDENBYTE が変わって" +"いないことを確認します。\n" +"変更されていれば stderr に診断情報を出力し、Py_FatalError() でプログラムを中" +"止します。\n" +"もう一つの主な失敗の形は、プログラムが特別なビットパターンを読み取り、アドレ" +"スとして使おうとしてメモリエラーになることです。\n" +"その時点でデバッガからオブジェクトを調べると、全体が PYMEM_DEADBYTE (解放済み" +"メモリを使用) または PYMEM_CLEANBYTE (未初期化メモリを使用) で埋まっている可" +"能性が高いです。" -#: ../../c-api/memory.rst:664 msgid "" "The :c:func:`PyMem_SetupDebugHooks` function now also works on Python " "compiled in release mode. On error, the debug hooks now use :mod:" @@ -1136,20 +1232,29 @@ msgid "" "functions of :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` " "domains are called." msgstr "" +":c:func:`PyMem_SetupDebugHooks` はリリースモードでコンパイルした Python でも" +"動作するようになりました。\n" +"エラーの場合、デバッグフックは :mod:`tracemalloc` を使って割り当て箇所のト" +"レースバックを取得するようになりました。\n" +"また、:c:macro:`PYMEM_DOMAIN_OBJ` と :c:macro:`PYMEM_DOMAIN_MEM` の関数を呼び" +"出すときに、:term:`スレッド状態がアタッチされている ` " +"ことも確認するようになりました。" -#: ../../c-api/memory.rst:672 msgid "" "Byte patterns ``0xCB`` (``PYMEM_CLEANBYTE``), ``0xDB`` (``PYMEM_DEADBYTE``) " "and ``0xFB`` (``PYMEM_FORBIDDENBYTE``) have been replaced with ``0xCD``, " "``0xDD`` and ``0xFD`` to use the same values than Windows CRT debug " "``malloc()`` and ``free()``." msgstr "" +"Windows CRT のデバッグ版 ``malloc()`` と ``free()`` と同じ値を使うため、バイ" +"トパターン ``0xCB`` (``PYMEM_CLEANBYTE``)、``0xDB`` (``PYMEM_DEADBYTE``)、" +"``0xFB`` (``PYMEM_FORBIDDENBYTE``) を、それぞれ ``0xCD``、``0xDD``、``0xFD`` " +"に変更しました。" #: ../../c-api/memory.rst:682 msgid "The pymalloc allocator" msgstr "pymalloc アロケータ" -#: ../../c-api/memory.rst:684 msgid "" "Python has a *pymalloc* allocator optimized for small objects (smaller or " "equal to 512 bytes) with a short lifetime. It uses memory mappings called " @@ -1162,6 +1267,17 @@ msgid "" "`PyMem_RawMalloc` and :c:func:`PyMem_RawRealloc` for allocations larger than " "512 bytes." msgstr "" +"Python には、寿命の短い小さなオブジェクト (512 バイト以下) に最適化された " +"*pymalloc* アロケータがあります。\n" +"「アリーナ」と呼ぶメモリマッピングを使い、その固定サイズは 32 ビットのプラッ" +"トフォームでは 256 KiB、64 ビットでは 1 MiB です。\n" +":option:`--with-pymalloc-hugepages` で Python を構成すると、64 ビットでのア" +"リーナサイズはヒュージページに合わせて 2 MiB に増えます。\n" +"アリーナの割り当てにはヒュージページ (Linux では ``MAP_HUGETLB``、Windows で" +"は ``MEM_LARGE_PAGES``) の使用を試み、使えなければ自動的に通常のページに切り" +"替えます。\n" +"512 バイトを超える割り当てには :c:func:`PyMem_RawMalloc` と :c:func:" +"`PyMem_RawRealloc` を使います。" #: ../../c-api/memory.rst:694 msgid "" @@ -1174,31 +1290,34 @@ msgstr "" msgid "The arena allocator uses the following functions:" msgstr "アリーナアロケータは、次の関数を使います:" -#: ../../c-api/memory.rst:700 msgid ":c:func:`!VirtualAlloc` and :c:func:`!VirtualFree` on Windows," -msgstr "" +msgstr "Windows では :c:func:`!VirtualAlloc` と :c:func:`!VirtualFree`。" -#: ../../c-api/memory.rst:701 msgid ":c:func:`!mmap` and :c:func:`!munmap` if available," -msgstr "" +msgstr "利用可能なら :c:func:`!mmap` と :c:func:`!munmap`。" #: ../../c-api/memory.rst:702 msgid ":c:func:`malloc` and :c:func:`free` otherwise." msgstr "それ以外の場合は :c:func:`malloc` と :c:func:`free`。" -#: ../../c-api/memory.rst:704 msgid "" "This allocator is disabled if Python is configured with the :option:`--" "without-pymalloc` option. It can also be disabled at runtime using the :" "envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``)." msgstr "" +":option:`--without-pymalloc` オプションで Python を構成した場合、このアロケー" +"タは無効になります。\n" +"環境変数 :envvar:`PYTHONMALLOC` で実行時に無効にすることもできます (例: " +"``PYTHONMALLOC=malloc``)。" -#: ../../c-api/memory.rst:708 msgid "" "Typically, it makes sense to disable the pymalloc allocator when building " "Python with AddressSanitizer (:option:`--with-address-sanitizer`) which " "helps uncover low level bugs within the C code." msgstr "" +"C コード内の低レベルのバグ検出に役立つ AddressSanitizer (:option:`--with-" +"address-sanitizer`) を使って Python をビルドする場合、通常は pymalloc アロ" +"ケータを無効にするのが適切です。" #: ../../c-api/memory.rst:713 msgid "Customize pymalloc Arena Allocator" @@ -1219,9 +1338,8 @@ msgstr "``void* alloc(void *ctx, size_t size)``" msgid "allocate an arena of size bytes" msgstr "size バイトのアリーナを割り当てます" -#: ../../c-api/memory.rst:729 msgid "``void free(void *ctx, void *ptr, size_t size)``" -msgstr "" +msgstr "``void free(void *ctx, void *ptr, size_t size)``" #: ../../c-api/memory.rst:729 msgid "free an arena" @@ -1235,11 +1353,9 @@ msgstr "アリーナアロケータを取得します。" msgid "Set the arena allocator." msgstr "アリーナアロケータを設定します。" -#: ../../c-api/memory.rst:743 msgid "The mimalloc allocator" -msgstr "" +msgstr "mimalloc アロケータ" -#: ../../c-api/memory.rst:747 msgid "" "Python supports the `mimalloc `__ " "allocator when the underlying platform support is available. mimalloc is a " @@ -1247,14 +1363,18 @@ msgid "" "initially developed by Daan Leijen for the runtime systems of the Koka and " "Lean languages." msgstr "" +"Python は、基盤となるプラットフォームが対応していれば `mimalloc `__ アロケータをサポートします。\n" +"mimalloc は優れた性能特性を持つ汎用アロケータで、当初は Daan Leijen が Koka " +"言語と Lean 言語のランタイムシステム向けに開発しました。" -#: ../../c-api/memory.rst:753 msgid "" "Unlike :ref:`pymalloc `, which is optimized for small objects (512 " "bytes or fewer), mimalloc handles allocations of any size." msgstr "" +"小さなオブジェクト (512 バイト以下) に最適化された :ref:`pymalloc " +"` と異なり、mimalloc は任意のサイズの割り当てを扱います。" -#: ../../c-api/memory.rst:756 msgid "" "In the :term:`free-threaded ` build, mimalloc is the default " "and **required** allocator for the :c:macro:`PYMEM_DOMAIN_MEM` and :c:macro:" @@ -1262,8 +1382,13 @@ msgid "" "The free-threaded build uses per-thread mimalloc heaps, which allows " "allocation and deallocation to proceed without locking in most cases." msgstr "" +":term:`フリースレッド ` ビルドでは、mimalloc は :c:macro:" +"`PYMEM_DOMAIN_MEM` と :c:macro:`PYMEM_DOMAIN_OBJ` ドメインのデフォルトかつ **" +"必須** のアロケータです。\n" +"フリースレッドビルドでは無効にできません。\n" +"スレッドごとの mimalloc ヒープを使うため、ほとんどの場合にロックなしで割り当" +"てと解放を行えます。" -#: ../../c-api/memory.rst:762 msgid "" "In the default (non-free-threaded) build, mimalloc is available but not the " "default allocator. It can be selected at runtime using :envvar:" @@ -1272,34 +1397,43 @@ msgid "" "option:`--without-mimalloc` configure option, but this option cannot be " "combined with :option:`--disable-gil`." msgstr "" +"デフォルトの (フリースレッドでない) ビルドでも mimalloc は利用できますが、デ" +"フォルトのアロケータではありません。\n" +"実行時に :envvar:`PYTHONMALLOC`\\ ``=mimalloc`` で選択できます (:ref:`デバッ" +"グフック ` を含める場合は ``mimalloc_debug``)。\n" +"ビルド時には configure オプション :option:`--without-mimalloc` で無効にできま" +"すが、このオプションは :option:`--disable-gil` と併用できません。" #: ../../c-api/memory.rst:770 msgid "tracemalloc C API" msgstr "tracemalloc C API" -#: ../../c-api/memory.rst:776 msgid "Track an allocated memory block in the :mod:`tracemalloc` module." msgstr "" +"割り当てられたメモリブロックを :mod:`tracemalloc` モジュールで追跡します。" -#: ../../c-api/memory.rst:778 msgid "" "Return ``0`` on success, return ``-1`` on error (failed to allocate memory " "to store the trace). Return ``-2`` if tracemalloc is disabled." msgstr "" +"成功した場合は ``0`` を返し、エラーの場合 (トレースを格納するメモリを割り当て" +"られなかった場合) は ``-1`` を返します。\n" +"tracemalloc が無効なら ``-2`` を返します。" -#: ../../c-api/memory.rst:781 msgid "If memory block is already tracked, update the existing trace." msgstr "" +"そのメモリブロックがすでに追跡されていれば、既存のトレースを更新します。" -#: ../../c-api/memory.rst:785 msgid "" "Untrack an allocated memory block in the :mod:`tracemalloc` module. Do " "nothing if the block was not tracked." msgstr "" +"割り当てられたメモリブロックを :mod:`tracemalloc` モジュールの追跡対象から外" +"します。\n" +"追跡されていなければ何もしません。" -#: ../../c-api/memory.rst:788 msgid "Return ``-2`` if tracemalloc is disabled, otherwise return ``0``." -msgstr "" +msgstr "tracemalloc が無効なら ``-2``、それ以外の場合は ``0`` を返します。" #: ../../c-api/memory.rst:794 msgid "Examples" @@ -1314,7 +1448,6 @@ msgstr "" "最初に述べた関数セットを使って、 :ref:`memoryoverview` 節の例を Python ヒープ" "に I/O バッファをメモリ確保するように書き換えたものを以下に示します::" -#: ../../c-api/memory.rst:799 msgid "" "PyObject *res;\n" "char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */\n" @@ -1326,12 +1459,20 @@ msgid "" "PyMem_Free(buf); /* allocated with PyMem_Malloc */\n" "return res;" msgstr "" +"PyObject *res;\n" +"char *buf = (char *) PyMem_Malloc(BUFSIZ); /* I/O 用 */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"/* ...buf を使って何らかの I/O 操作を行う... */\n" +"res = PyBytes_FromString(buf);\n" +"PyMem_Free(buf); /* PyMem_Malloc で割り当て済み */\n" +"return res;" #: ../../c-api/memory.rst:809 msgid "The same code using the type-oriented function set::" msgstr "同じコードを型対象の関数セットで書いたものを以下に示します::" -#: ../../c-api/memory.rst:811 msgid "" "PyObject *res;\n" "char *buf = PyMem_New(char, BUFSIZ); /* for I/O */\n" @@ -1343,6 +1484,15 @@ msgid "" "PyMem_Free(buf); /* allocated with PyMem_New */\n" "return res;" msgstr "" +"PyObject *res;\n" +"char *buf = PyMem_New(char, BUFSIZ); /* I/O 用 */\n" +"\n" +"if (buf == NULL)\n" +" return PyErr_NoMemory();\n" +"/* ...buf を使って何らかの I/O 操作を行う... */\n" +"res = PyBytes_FromString(buf);\n" +"PyMem_Free(buf); /* PyMem_New で割り当て済み */\n" +"return res;" #: ../../c-api/memory.rst:821 msgid "" @@ -1371,12 +1521,14 @@ msgid "" "free(buf1); /* Fatal -- should be PyMem_Free() */" msgstr "" -#: ../../c-api/memory.rst:836 msgid "" "In addition to the functions aimed at handling raw memory blocks from the " "Python heap, objects in Python are allocated and released with :c:macro:" "`PyObject_New`, :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Free`." msgstr "" +"Python ヒープの生メモリブロックを扱う関数に加えて、Python オブジェクトの割り" +"当てと解放には :c:macro:`PyObject_New`、:c:macro:`PyObject_NewVar`、:c:func:" +"`PyObject_Free` を使います。" #: ../../c-api/memory.rst:840 msgid "" @@ -1386,18 +1538,14 @@ msgstr "" "これらの関数については、次章の C による新しいオブジェクト型の定義や実装に関す" "る記述の中で説明します。" -#: ../../c-api/memory.rst:39 msgid "malloc (C function)" -msgstr "" +msgstr "malloc (C 関数)" -#: ../../c-api/memory.rst:39 msgid "calloc (C function)" -msgstr "" +msgstr "calloc (C 関数)" -#: ../../c-api/memory.rst:39 msgid "realloc (C function)" -msgstr "" +msgstr "realloc (C 関数)" -#: ../../c-api/memory.rst:39 msgid "free (C function)" -msgstr "" +msgstr "free (C 関数)" diff --git a/c-api/memoryview.po b/c-api/memoryview.po index 26ba78447..bb164bf6b 100644 --- a/c-api/memoryview.po +++ b/c-api/memoryview.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/memoryview.rst:9 @@ -36,11 +36,13 @@ msgstr "" "Python オブジェクトの形をした C 言語レベルの :ref:`バッファのインターフェー" "ス ` です。" -#: ../../c-api/memoryview.rst:18 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python memoryview " "type. This is the same object as :class:`memoryview` in the Python layer." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の memoryview 型を表しま" +"す。\n" +"Python レベルの :class:`memoryview` と同じオブジェクトです。" #: ../../c-api/memoryview.rst:24 msgid "" @@ -54,13 +56,11 @@ msgstr "" "ら、その memoryview オブジェクトは読み書き可能です。そうでなければ読出しのみ" "になるか、エクスポーターの分別にもとづいて読み書きが可能となります。" -#: ../../c-api/memoryview.rst:32 msgid "Flag to request a readonly buffer." -msgstr "" +msgstr "読み取り専用のバッファを要求するフラグ。" -#: ../../c-api/memoryview.rst:37 msgid "Flag to request a writable buffer." -msgstr "" +msgstr "書き込み可能なバッファを要求するフラグ。" #: ../../c-api/memoryview.rst:42 msgid "" @@ -94,10 +94,11 @@ msgstr "" "メモリを参照します。それ以外の場合、メモリはコピーされて、 memoryview オブ" "ジェクトは新しい bytes オブジェクトを参照します。" -#: ../../c-api/memoryview.rst:61 msgid "" "*buffertype* can be one of :c:macro:`PyBUF_READ` or :c:macro:`PyBUF_WRITE`." msgstr "" +"*buffertype* には :c:macro:`PyBUF_READ` または :c:macro:`PyBUF_WRITE` を指定" +"できます。" #: ../../c-api/memoryview.rst:66 msgid "" @@ -109,29 +110,28 @@ msgstr "" "`memoryview` のサブクラスの作成は許可されていません。この関数は常に成功しま" "す。" -#: ../../c-api/memoryview.rst:73 msgid "" "Return a pointer to the memoryview's private copy of the exporter's buffer. " "*mview* **must** be a memoryview instance; this macro doesn't check its " "type, you must do it yourself or you will risk crashes." msgstr "" -"書きだされたバッファーの memoryview のプライベート コピーに、ポインターを返し" -"ます。\n" -"*mview* は memoryview インスタンスでなければなりません;\n" -"このマクロは型をチェックしないので自前で型チェックしなければならず、それを怠" -"るとクラッシュする恐れがあります。" +"memoryview が内部に保持する、エクスポーターのバッファ情報のコピーへのポインタ" +"を返します。\n" +"*mview* は memoryview インスタンスで **なければなりません**。\n" +"このマクロは型を確認しないため、自分で確認しなければクラッシュするおそれがあ" +"ります。" -#: ../../c-api/memoryview.rst:79 msgid "" "Return either a pointer to the exporting object that the memoryview is based " "on or ``NULL`` if the memoryview has been created by one of the functions :c:" "func:`PyMemoryView_FromMemory` or :c:func:`PyMemoryView_FromBuffer`. *mview* " "**must** be a memoryview instance." msgstr "" -"memoryview をエクスポートしているオブジェクトへのポインタを返します。\n" -"memoryview が :c:func:`PyMemoryView_FromMemory` か :c:func:" -"`PyMemoryView_FromBuffer` のどちらかで作成されていた場合、 ``NULL`` を返しま" -"す。" +"memoryview の元になるバッファをエクスポートしているオブジェクトへのポインタを" +"返します。\n" +"memoryview を :c:func:`PyMemoryView_FromMemory` または :c:func:" +"`PyMemoryView_FromBuffer` で作成した場合は、``NULL`` を返します。\n" +"*mview* は memoryview インスタンスで **なければなりません**。" #: ../../c-api/memoryview.rst:5 msgid "object" diff --git a/c-api/method.po b/c-api/method.po index 7feb6ef56..570d21538 100644 --- a/c-api/method.po +++ b/c-api/method.po @@ -16,22 +16,24 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/method.rst:6 msgid "Instance Method Objects" msgstr "インスタンスメソッドオブジェクト(Instance Method Objects)" -#: ../../c-api/method.rst:10 msgid "" "An instance method is a wrapper for a :c:type:`PyCFunction` and the new way " "to bind a :c:type:`PyCFunction` to a class object. It replaces the former " "call ``PyMethod_New(func, NULL, class)``." msgstr "" +"インスタンスメソッドは :c:type:`PyCFunction` のラッパーであり、:c:type:" +"`PyCFunction` をクラスオブジェクトに束縛する新しい方法です。\n" +"以前の ``PyMethod_New(func, NULL, class)`` 呼び出しに代わるものです。" #: ../../c-api/method.rst:17 msgid "" @@ -77,15 +79,15 @@ msgstr "" msgid "Method Objects" msgstr "メソッドオブジェクト" -#: ../../c-api/method.rst:52 msgid "" "Methods are bound function objects. Methods are always bound to an instance " "of a user-defined class. Unbound methods (methods bound to a class object) " "are no longer available." msgstr "" -"メソッドは関数オブジェクトに束縛されています。メソッドは常にあるユーザー定義" -"のクラスに束縛されているのです。束縛されていないメソッド(クラスオブジェクトに" -"束縛されたメソッド)は利用することができません。" +"メソッドは、束縛された関数オブジェクトです。\n" +"メソッドは常にユーザー定義クラスのインスタンスに束縛されます。\n" +"非束縛メソッド (クラスオブジェクトに束縛されたメソッド) は、もはや利用できま" +"せん。" #: ../../c-api/method.rst:61 msgid "" diff --git a/c-api/module.po b/c-api/module.po index 977e79d86..8580e10eb 100644 --- a/c-api/module.po +++ b/c-api/module.po @@ -17,21 +17,23 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/module.rst:6 msgid "Module Objects" msgstr "モジュールオブジェクト (module object)" -#: ../../c-api/module.rst:14 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python module type. " "This is exposed to Python programs as :py:class:`types.ModuleType`." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python のモジュール型を表しま" +"す。\n" +"Python プログラムには :py:class:`types.ModuleType` として公開されています。" #: ../../c-api/module.rst:20 msgid "" @@ -49,7 +51,6 @@ msgstr "" "*p* がモジュールオブジェクトで、かつ :c:data:`PyModule_Type` のサブタイプでな" "いときに真を返します。この関数は常に成功します。" -#: ../../c-api/module.rst:39 msgid "" "Return a new module object with :attr:`module.__name__` set to *name*. The " "module's :attr:`!__name__`, :attr:`~module.__doc__`, :attr:`~module." @@ -57,17 +58,22 @@ msgid "" "but :attr:`!__name__` are set to ``None``). The caller is responsible for " "setting a :attr:`~module.__file__` attribute." msgstr "" +":attr:`module.__name__` に *name* を設定した新しいモジュールオブジェクトを返" +"します。\n" +"モジュールの :attr:`!__name__`、:attr:`~module.__doc__`、:attr:`~module." +"__package__`、:attr:`~module.__loader__` 属性を設定します (:attr:`!__name__` " +"以外はすべて ``None`` に設定します)。\n" +":attr:`~module.__file__` 属性の設定は呼び出し側の責任です。" -#: ../../c-api/module.rst:45 ../../c-api/module.rst:836 -#: ../../c-api/module.rst:867 msgid "Return ``NULL`` with an exception set on error." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/module.rst:49 msgid "" ":attr:`~module.__package__` and :attr:`~module.__loader__` are now set to " "``None``." msgstr "" +":attr:`~module.__package__` と :attr:`~module.__loader__` を ``None`` に設定" +"するようになりました。" #: ../../c-api/module.rst:56 msgid "" @@ -99,18 +105,21 @@ msgstr "" "拡張モジュールでは、モジュールの :attr:`~object.__dict__` を直接操作するより" "も、 ``PyModule_*`` および ``PyObject_*`` 関数を使う方が推奨されます。" -#: ../../c-api/module.rst:73 msgid "" "The returned reference is borrowed from the module; it is valid until the " "module is destroyed." msgstr "" +"返す参照はモジュールからの借用参照であり、モジュールが破棄されるまで有効で" +"す。" -#: ../../c-api/module.rst:83 msgid "" "Return *module*'s :attr:`~module.__name__` value. If the module does not " "provide one, or if it is not a string, :exc:`SystemError` is raised and " "``NULL`` is returned." msgstr "" +"*module* の :attr:`~module.__name__` の値を返します。\n" +"この属性がない場合や文字列でない場合は、:exc:`SystemError` を送出して " +"``NULL`` を返します。" #: ../../c-api/module.rst:92 msgid "" @@ -120,12 +129,15 @@ msgstr "" ":c:func:`PyModule_GetNameObject` に似ていますが、 ``'utf-8'`` でエンコードさ" "れた name を返します。" -#: ../../c-api/module.rst:95 msgid "" "The returned buffer is only valid until the module is renamed or destroyed. " "Note that Python code may rename a module by setting its :py:attr:`~module." "__name__` attribute." msgstr "" +"返されたバッファは、モジュールの名前が変更されるかモジュールが破棄されるまで" +"有効です。\n" +"Python コードから :py:attr:`~module.__name__` 属性を設定してモジュール名を変" +"更できることに注意してください。" #: ../../c-api/module.rst:101 msgid "" @@ -136,20 +148,26 @@ msgstr "" "ます。\n" "モジュールが定義によって作られていなかった場合は ``NULL`` を返します。" -#: ../../c-api/module.rst:104 msgid "" "On error, return ``NULL`` with an exception set. Use :c:func:" "`PyErr_Occurred` to tell this case apart from a missing :c:type:`!" "PyModuleDef`." msgstr "" +"エラー時には例外を設定して ``NULL`` を返します。\n" +":c:func:`PyErr_Occurred` を使って、:c:type:`!PyModuleDef` がない場合と区別し" +"てください。" -#: ../../c-api/module.rst:115 msgid "" "Return the name of the file from which *module* was loaded using *module*'s :" "attr:`~module.__file__` attribute. If this is not defined, or if it is not " "a string, raise :exc:`SystemError` and return ``NULL``; otherwise return a " "reference to a Unicode object." msgstr "" +"*module* の :attr:`~module.__file__` 属性を使って、*module* をロードしたファ" +"イルの名前を返します。\n" +"この属性が定義されていない場合や文字列でない場合は、:exc:`SystemError` を送出" +"して ``NULL`` を返します。\n" +"それ以外の場合は Unicode オブジェクトへの参照を返します。" #: ../../c-api/module.rst:125 msgid "" @@ -159,11 +177,12 @@ msgstr "" ":c:func:`PyModule_GetFilenameObject` と似ていますが、 'utf-8' でエンコードさ" "れたファイル名を返します。" -#: ../../c-api/module.rst:128 msgid "" "The returned buffer is only valid until the module's :py:attr:`~module." "__file__` attribute is reassigned or the module is destroyed." msgstr "" +"返されたバッファは、モジュールの :py:attr:`~module.__file__` 属性に別の値が代" +"入されるか、モジュールが破棄されるまで有効です。" #: ../../c-api/module.rst:131 msgid "" @@ -174,93 +193,109 @@ msgstr "" "`UnicodeEncodeError` を送出します。これの代わりに :c:func:" "`PyModule_GetFilenameObject` を使用してください。" -#: ../../c-api/module.rst:140 msgid "Module definition" -msgstr "" +msgstr "モジュールの定義" -#: ../../c-api/module.rst:142 msgid "" "Modules created using the C API are typically defined using an array of :c:" "type:`PySlot` structs, which provides a \"description\" of how a module " "should be created. See :ref:`capi-slots` for more information on slots in " "general." msgstr "" +"C API で作成するモジュールは通常、:c:type:`PySlot` 構造体の配列を使って定義し" +"ます。\n" +"この配列はモジュールの作成方法を「記述」します。\n" +"スロット全般については :ref:`capi-slots` を参照してください。" -#: ../../c-api/module.rst:149 msgid "" "Previously, a :c:type:`PyModuleDef` struct was necessary to define modules. " "The older way of defining modules is still available: consult either the :" "ref:`pymoduledef` section or earlier versions of this documentation if you " "plan to support earlier Python versions." msgstr "" +"以前はモジュールの定義に :c:type:`PyModuleDef` 構造体が必要でした。\n" +"従来のモジュール定義方法も引き続き利用できます。\n" +"以前の Python バージョンに対応する場合は、:ref:`pymoduledef` の節または以前の" +"バージョンのドキュメントを参照してください。" -#: ../../c-api/module.rst:154 msgid "" "The slots array is usually used to define an extension module's “main” " "module object (see :ref:`extension-modules` for details). It can also be " "used to :ref:`create extension modules dynamically `." msgstr "" +"スロット配列は通常、拡張モジュールの「メイン」のモジュールオブジェクトの定義" +"に使います (詳細は :ref:`extension-modules` を参照)。\n" +":ref:`拡張モジュールを動的に作成する ` こともできます。" -#: ../../c-api/module.rst:159 msgid "" "Unless specified otherwise, the same slot ID may not be repeated in an array " "of slots." msgstr "" +"特に指定がない限り、スロット配列内で同じスロット ID を繰り返し使ってはいけま" +"せん。" -#: ../../c-api/module.rst:164 msgid "Metadata slots" -msgstr "" +msgstr "メタデータのスロット" -#: ../../c-api/module.rst:168 msgid "" ":c:member:`Slot ID ` for the name of the new module, as a NUL-" "terminated UTF8-encoded ``const char *``." msgstr "" +"新しいモジュールの名前を指定する :c:member:`スロット ID ` で" +"す。\n" +"値は UTF-8 でエンコードされた NUL 終端の ``const char *`` です。" -#: ../../c-api/module.rst:171 msgid "" "Note that modules are typically created using a :py:class:`~importlib." "machinery.ModuleSpec`, and when they are, the name from the spec will be " "used instead of :c:data:`!Py_mod_name`. However, it is still recommended to " "include this slot for introspection and debugging purposes." msgstr "" +"モジュールは通常 :py:class:`~importlib.machinery.ModuleSpec` を使って作成さ" +"れ、その場合は :c:data:`!Py_mod_name` ではなく spec の名前を使うことに注意し" +"てください。\n" +"ただし、イントロスペクションやデバッグのため、このスロットを含めることを推奨" +"します。" -#: ../../c-api/module.rst:179 msgid "" "Use :c:member:`PyModuleDef.m_name` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_name` を" +"使ってください。" -#: ../../c-api/module.rst:183 msgid "" ":c:type:`Slot ID ` for the docstring of the new module, as a " "NUL-terminated UTF8-encoded ``const char *``." msgstr "" +"新しいモジュールの docstring を指定する :c:type:`スロット ID ` " +"です。\n" +"値は UTF-8 でエンコードされた NUL 終端の ``const char *`` です。" -#: ../../c-api/module.rst:186 msgid "Usually it is set to a variable created with :c:macro:`PyDoc_STRVAR`." -msgstr "" +msgstr "通常は :c:macro:`PyDoc_STRVAR` で作成した変数を設定します。" -#: ../../c-api/module.rst:190 msgid "Use :c:member:`PyModuleDef.m_doc` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_doc` を使っ" +"てください。" -#: ../../c-api/module.rst:194 msgid "Feature slots" -msgstr "" +msgstr "対応機能のスロット" -#: ../../c-api/module.rst:198 msgid "" ":c:member:`Slot ID ` whose value points to a :c:struct:" "`PyABIInfo` structure describing the ABI that the extension is using." msgstr "" +"拡張モジュールが使う ABI を記述する :c:struct:`PyABIInfo` 構造体へのポインタ" +"を値とする :c:member:`スロット ID ` です。" -#: ../../c-api/module.rst:202 msgid "" "A suitable :c:struct:`!PyABIInfo` variable can be defined using the :c:macro:" "`PyABIInfo_VAR` macro, as in:" msgstr "" +":c:macro:`PyABIInfo_VAR` マクロを使うと、適切な :c:struct:`!PyABIInfo` 変数を" +"次のように定義できます:" -#: ../../c-api/module.rst:205 msgid "" "PyABIInfo_VAR(abi_info);\n" "\n" @@ -269,140 +304,164 @@ msgid "" " ...\n" "};" msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PySlot mymodule_slots[] = {\n" +" PySlot_DATA(Py_mod_abi, &abi_info),\n" +" ...\n" +"};" -#: ../../c-api/module.rst:214 msgid "" "When creating a module, Python checks the value of this slot using :c:func:" "`PyABIInfo_Check`." msgstr "" +"モジュールの作成時に、Python は :c:func:`PyABIInfo_Check` でこのスロットの値" +"を検査します。" -#: ../../c-api/module.rst:217 msgid "" "This slot is required, except for modules created from :c:struct:" "`PyModuleDef`." msgstr "" +":c:struct:`PyModuleDef` から作成するモジュールを除き、このスロットは必須で" +"す。" -#: ../../c-api/module.rst:224 ../../c-api/module.rst:263 msgid ":c:member:`Slot ID ` whose value is one of:" -msgstr "" +msgstr "次のいずれかを値とする :c:member:`スロット ID ` です:" -#: ../../c-api/module.rst:230 msgid "The module does not support being imported in subinterpreters." -msgstr "" +msgstr "モジュールはサブインタープリタでのインポートに対応していません。" -#: ../../c-api/module.rst:234 msgid "" "The module supports being imported in subinterpreters, but only when they " "share the main interpreter's GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" +"モジュールはサブインタープリタでのインポートに対応していますが、メインイン" +"タープリタの GIL を共有している場合に限ります (:ref:`isolating-extensions-" +"howto` を参照)。" -#: ../../c-api/module.rst:240 msgid "" "The module supports being imported in subinterpreters, even when they have " "their own GIL. (See :ref:`isolating-extensions-howto`.)" msgstr "" +"モジュールは、サブインタープリタが独自の GIL を持つ場合も、サブインタープリタ" +"でのインポートに対応しています (:ref:`isolating-extensions-howto` を参照)。" -#: ../../c-api/module.rst:244 msgid "" "This slot determines whether or not importing this module in a " "subinterpreter will fail." msgstr "" +"このスロットは、このモジュールをサブインタープリタでインポートすると失敗する" +"かどうかを決めます。" -#: ../../c-api/module.rst:247 msgid "" "If ``Py_mod_multiple_interpreters`` is not specified, the import machinery " "defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED``." msgstr "" +"``Py_mod_multiple_interpreters`` を指定しない場合、インポート機構はデフォルト" +"で ``Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED`` を使います。" -#: ../../c-api/module.rst:250 msgid "" "For historical reasons, the values are declared as pointers (``void *``). " "When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for :c:macro:" "`!Py_mod_multiple_interpreters`:" msgstr "" +"歴史的な理由により、値はポインタ (``void *``) として宣言されています。\n" +":c:type:`PySlot` 配列を使う場合、:c:macro:`!Py_mod_multiple_interpreters` に" +"は :c:macro:`PySlot_DATA` を使ってください:" -#: ../../c-api/module.rst:254 msgid "" "PySlot_DATA(Py_mod_multiple_interpreters,\n" " Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)" msgstr "" +"PySlot_DATA(Py_mod_multiple_interpreters,\n" +" Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)" -#: ../../c-api/module.rst:269 msgid "" "The module depends on the presence of the global interpreter lock (GIL), and " "may access global state without synchronization." msgstr "" +"モジュールはグローバルインタープリタロック (GIL) の存在に依存し、同期せずにグ" +"ローバルな状態にアクセスする場合があります。" -#: ../../c-api/module.rst:274 msgid "The module is safe to run without an active GIL." -msgstr "" +msgstr "モジュールは GIL が有効でなくても安全に実行できます。" -#: ../../c-api/module.rst:276 msgid "" "This slot is ignored by Python builds not configured with :option:`--disable-" "gil`. Otherwise, it determines whether or not importing this module will " "cause the GIL to be automatically enabled. See :ref:`whatsnew313-free-" "threaded-cpython` for more detail." msgstr "" +":option:`--disable-gil` を指定せずに構成した Python ビルドでは、このスロット" +"は無視されます。\n" +"それ以外のビルドでは、このモジュールのインポートによって GIL が自動的に有効に" +"なるかどうかを決めます。\n" +"詳細は :ref:`whatsnew313-free-threaded-cpython` を参照してください。" -#: ../../c-api/module.rst:281 msgid "" "If ``Py_mod_gil`` is not specified, the import machinery defaults to " "``Py_MOD_GIL_USED``." msgstr "" +"``Py_mod_gil`` を指定しない場合、インポート機構はデフォルトで " +"``Py_MOD_GIL_USED`` を使います。" -#: ../../c-api/module.rst:284 msgid "" "For historical reasons, the values are declared as pointers (``void *``). " "When using :c:type:`PySlot` arrays, use :c:macro:`PySlot_DATA` for :c:macro:" "`!Py_mod_gil`:" msgstr "" +"歴史的な理由により、値はポインタ (``void *``) として宣言されています。\n" +":c:type:`PySlot` 配列を使う場合、:c:macro:`!Py_mod_gil` には :c:macro:" +"`PySlot_DATA` を使ってください:" -#: ../../c-api/module.rst:288 msgid "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)" -msgstr "" +msgstr "PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED)" -#: ../../c-api/module.rst:296 msgid "Creation and initialization slots" -msgstr "" +msgstr "作成と初期化のスロット" -#: ../../c-api/module.rst:300 msgid "" ":c:member:`Slot ID ` for a function that creates the module " "object itself. The function must have the signature:" msgstr "" +"モジュールオブジェクト自体を作成する関数を指定する :c:member:`スロット ID " +"` です。\n" +"関数は次のシグネチャを持つ必要があります:" -#: ../../c-api/module.rst:308 msgid "The function will be called with:" -msgstr "" +msgstr "関数には次の引数を渡します:" -#: ../../c-api/module.rst:310 msgid "" "*spec*: a ``ModuleSpec``-like object, meaning that any attributes defined " "for :py:class:`importlib.machinery.ModuleSpec` have matching semantics. " "However, any of the attributes may be missing." msgstr "" +"*spec*: ``ModuleSpec`` に似たオブジェクトです。\n" +"つまり、:py:class:`importlib.machinery.ModuleSpec` で定義される属性はそれぞれ" +"同じ意味を持ちます。\n" +"ただし、どの属性も存在しない場合があります。" -#: ../../c-api/module.rst:313 msgid "" "*def*: ``NULL``, or the module definition if the module is created from one." msgstr "" +"*def*: ``NULL``、またはモジュールをモジュール定義から作成する場合はその定義で" +"す。" -#: ../../c-api/module.rst:315 msgid "" "The function should return a new module object, or set an error and return " "``NULL``." msgstr "" +"この関数は、新しいモジュールオブジェクトを返すか、エラーを設定して ``NULL`` " +"を返す必要があります。" -#: ../../c-api/module.rst:318 msgid "" "This function should be kept minimal. In particular, it should not call " "arbitrary Python code, as trying to import the same module again may result " "in an infinite loop." msgstr "" -"この関数は最小限に留めておくべきです。\n" -"特に任意のPythonコードを呼び出すべきではなく、同じモジュールをインポートしよ" -"うとすると無限ループに陥るでしょう。" +"この関数の処理は最小限に留めてください。\n" +"特に、同じモジュールを再びインポートしようとすると無限ループに陥る可能性があ" +"るため、任意の Python コードを呼び出してはいけません。" #: ../../c-api/module.rst:322 msgid "" @@ -418,25 +477,28 @@ msgstr "" "ルが動的にモジュール階層における位置を調整できたり、シンボリックリンクを通し" "て同一のモジュール定義を共有しつつ別の名前でインポートできたりします。" -#: ../../c-api/module.rst:328 msgid "" "There is no requirement for the returned object to be an instance of :c:type:" "`PyModule_Type`. However, some slots may only be used with :c:type:`!" "PyModule_Type` instances; in particular:" msgstr "" +"返すオブジェクトは :c:type:`PyModule_Type` のインスタンスである必要はありませ" +"ん。\n" +"ただし、一部のスロットは :c:type:`!PyModule_Type` のインスタンスでしか使えま" +"せん。\n" +"特に以下のスロットが該当します:" -#: ../../c-api/module.rst:333 msgid ":c:macro:`Py_mod_exec`," -msgstr "" +msgstr ":c:macro:`Py_mod_exec`、" -#: ../../c-api/module.rst:334 msgid "" ":ref:`module state slots ` (``Py_mod_state_*``)," msgstr "" +":ref:`モジュール状態のスロット ` " +"(``Py_mod_state_*``)、" -#: ../../c-api/module.rst:335 msgid ":c:macro:`Py_mod_token`." -msgstr "" +msgstr ":c:macro:`Py_mod_token`。" #: ../../c-api/module.rst:341 msgid "" @@ -445,27 +507,32 @@ msgid "" "previous versions of CPython did not enforce this." msgstr "" -#: ../../c-api/module.rst:345 msgid "" "The *def* argument may now be ``NULL``, since modules are not necessarily " "made from definitions." msgstr "" +"モジュールは必ずしもモジュール定義から作成されるとは限らないため、*def* 引数" +"に ``NULL`` を指定できるようになりました。" -#: ../../c-api/module.rst:350 msgid "" ":c:member:`Slot ID ` for a function that will :dfn:`execute`, " "or initialize, the module. This function does the equivalent to executing " "the code of a Python module: typically, it adds classes and constants to the " "module. The signature of the function is:" msgstr "" +"モジュールを :dfn:`実行`、つまり初期化する関数を指定する :c:member:`スロット " +"ID ` です。\n" +"この関数は Python モジュールのコード実行に相当する処理を行います。\n" +"通常はモジュールにクラスや定数を追加します。\n" +"関数のシグネチャは次のとおりです:" -#: ../../c-api/module.rst:360 msgid "" "See the :ref:`capi-module-support-functions` section for some useful " "functions to call." msgstr "" +"この関数から呼び出すと便利な関数については、:ref:`capi-module-support-" +"functions` の節を参照してください。" -#: ../../c-api/module.rst:363 msgid "" "For backwards compatibility, the :c:type:`PyModuleDef.m_slots` array may " "contain multiple :c:macro:`!Py_mod_exec` slots; these are processed in the " @@ -473,156 +540,187 @@ msgid "" "`PyModule_FromSlotsAndSpec` and in return values of :samp:" "`PyModExport_{}`), repeating the slot is not allowed." msgstr "" +"後方互換性のため、:c:type:`PyModuleDef.m_slots` 配列には複数の :c:macro:`!" +"Py_mod_exec` スロットを含めることができ、配列内の順序で処理します。\n" +"それ以外 (つまり :c:func:`PyModule_FromSlotsAndSpec` の引数や :samp:" +"`PyModExport_{}` の戻り値) では、このスロットを繰り返してはいけません。" -#: ../../c-api/module.rst:374 msgid "" "Repeated ``Py_mod_exec`` slots are disallowed, except in :c:type:" "`PyModuleDef.m_slots`." msgstr "" +":c:type:`PyModuleDef.m_slots` を除き、``Py_mod_exec`` スロットの重複が禁止さ" +"れました。" -#: ../../c-api/module.rst:379 msgid "" ":c:member:`Slot ID ` for a table of module-level functions, as " "an array of :c:type:`PyMethodDef` values suitable as the *functions* " "argument to :c:func:`PyModule_AddFunctions`." msgstr "" +"モジュールレベルの関数のテーブルを指定する :c:member:`スロット ID ` です。\n" +"値は :c:func:`PyModule_AddFunctions` の *functions* 引数に渡せる :c:type:" +"`PyMethodDef` 値の配列です。" -#: ../../c-api/module.rst:383 msgid "" "Like other slot IDs, a slots array may only contain one :c:macro:`!" "Py_mod_methods` entry. To add functions from multiple :c:type:`PyMethodDef` " "arrays, call :c:func:`PyModule_AddFunctions` in the :c:macro:`Py_mod_exec` " "function." msgstr "" +"他のスロット ID と同様に、スロット配列に含められる :c:macro:`!" +"Py_mod_methods` エントリーは 1 つだけです。\n" +"複数の :c:type:`PyMethodDef` 配列から関数を追加するには、:c:macro:" +"`Py_mod_exec` 関数内で :c:func:`PyModule_AddFunctions` を呼び出してください。" -#: ../../c-api/module.rst:388 msgid "" "The table must be statically allocated (or otherwise guaranteed to outlive " "the module object)." msgstr "" +"テーブルは静的に割り当てる必要があります (または、モジュールオブジェクトより" +"長く存続することを別の方法で保証する必要があります)。" -#: ../../c-api/module.rst:393 msgid "" "Use :c:member:`PyModuleDef.m_methods` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_methods` を" +"使ってください。" -#: ../../c-api/module.rst:398 msgid "Module state" -msgstr "" +msgstr "モジュール状態" -#: ../../c-api/module.rst:400 msgid "" "Extension modules can have *module state* -- a piece of memory that is " "allocated on module creation, and freed when the module object is " "deallocated. The module state is specified using :ref:`dedicated slots `." msgstr "" +"拡張モジュールは *モジュール状態* を持つことができます。\n" +"これはモジュール作成時に割り当てられ、モジュールオブジェクトの解放時に解放さ" +"れるメモリ領域です。\n" +"モジュール状態は :ref:`専用のスロット ` で指定しま" +"す。" -#: ../../c-api/module.rst:405 msgid "" "A typical use of module state is storing an exception type -- or indeed " "*any* type object defined by the module --" msgstr "" +"モジュール状態の典型的な用途は、例外型や、モジュールで定義する *あらゆる* 型" +"オブジェクトの保持です。" -#: ../../c-api/module.rst:408 msgid "" "Unlike the module's Python attributes, Python code cannot replace or delete " "data stored in module state." msgstr "" +"モジュールの Python 属性とは異なり、モジュール状態に保持したデータを Python " +"コードから置き換えたり削除したりすることはできません。" -#: ../../c-api/module.rst:411 msgid "" "Keeping per-module information in attributes and module state, rather than " "in static globals, makes module objects *isolated* and safer for use in " "multiple sub-interpreters. It also helps Python do an orderly clean-up when " "it shuts down." msgstr "" +"モジュールごとの情報を静的なグローバル変数ではなく属性とモジュール状態に保持" +"すると、モジュールオブジェクトが *分離* され、複数のサブインタープリタでより" +"安全に使えます。\n" +"また、Python が終了時に適切な順序で後始末を行う助けにもなります。" -#: ../../c-api/module.rst:416 msgid "" "Extensions that keep references to Python objects as part of module state " "must implement :c:macro:`Py_mod_state_traverse` and :c:macro:" "`Py_mod_state_clear` functions to avoid reference leaks." msgstr "" +"モジュール状態の一部として Python オブジェクトへの参照を保持する拡張モジュー" +"ルは、参照のリークを防ぐため、:c:macro:`Py_mod_state_traverse` 関数と :c:" +"macro:`Py_mod_state_clear` 関数を実装する必要があります。" -#: ../../c-api/module.rst:420 msgid "To retrieve the state from a given module, use the following functions:" -msgstr "" +msgstr "指定されたモジュールから状態を取得するには、次の関数を使います:" -#: ../../c-api/module.rst:424 msgid "" "Return the \"state\" of the module, that is, a pointer to the block of " "memory allocated at module creation time, or ``NULL``. See :c:macro:" "`Py_mod_state_size`." msgstr "" +"モジュールの「状態」、つまりモジュールの作成時に割り当てられたメモリ領域への" +"ポインタ、または ``NULL`` を返します。\n" +":c:macro:`Py_mod_state_size` を参照してください。" -#: ../../c-api/module.rst:428 msgid "" "On error, return ``NULL`` with an exception set. Use :c:func:" "`PyErr_Occurred` to tell this case apart from missing module state." msgstr "" +"エラー時には例外を設定して ``NULL`` を返します。\n" +":c:func:`PyErr_Occurred` を使って、モジュール状態がない場合と区別してくださ" +"い。" -#: ../../c-api/module.rst:435 msgid "" "Set *\\*result* to the size of *module*'s state, as specified using :c:macro:" "`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`), and return 0." msgstr "" +"*\\*result* に、:c:macro:`Py_mod_state_size` (または :c:member:`PyModuleDef." +"m_size`) で指定された *module* の状態のサイズを設定し、0 を返します。" -#: ../../c-api/module.rst:439 msgid "On error, set *\\*result* to -1, and return -1 with an exception set." msgstr "" +"エラー時には *\\*result* に -1 を設定し、例外を設定して -1 を返します。" -#: ../../c-api/module.rst:448 msgid "Slots for defining module state" -msgstr "" +msgstr "モジュール状態を定義するスロット" -#: ../../c-api/module.rst:450 msgid "" "The following :c:member:`slot IDs ` are available for " "defining the module state." msgstr "" +"モジュール状態の定義には、次の :c:member:`スロット ID ` を使え" +"ます。" -#: ../../c-api/module.rst:455 msgid "" ":c:member:`Slot ID ` for the size of the module state, in " "bytes." msgstr "" +"モジュール状態のバイト単位のサイズを指定する :c:member:`スロット ID ` です。" -#: ../../c-api/module.rst:458 msgid "" "Setting the value to a non-negative value means that the module can be re-" "initialized and specifies the additional amount of memory it requires for " "its state." msgstr "" +"非負の値を設定すると、モジュールを再初期化できることを示すとともに、その状態" +"のために必要な追加メモリの量を指定します。" #: ../../c-api/module.rst:462 msgid "See :PEP:`3121` for more details." msgstr "詳細は :PEP:`3121` を参照。" -#: ../../c-api/module.rst:464 msgid "" "Use :c:func:`PyModule_GetStateSize` to retrieve the size of a given module." msgstr "" +"指定したモジュールの状態のサイズを取得するには、:c:func:" +"`PyModule_GetStateSize` を使ってください。" -#: ../../c-api/module.rst:468 msgid "" "Use :c:member:`PyModuleDef.m_size` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_size` を" +"使ってください。" -#: ../../c-api/module.rst:472 msgid "" ":c:member:`Slot ID ` for a traversal function to call during " "GC traversal of the module object." msgstr "" +"GC がモジュールオブジェクトの参照をたどる際に呼び出す走査関数を指定する :c:" +"member:`スロット ID ` です。" -#: ../../c-api/module.rst:475 msgid "" "The signature of the function, and meanings of the arguments, is similar as " "for :c:member:`PyTypeObject.tp_traverse`:" msgstr "" +"関数のシグネチャと引数の意味は、:c:member:`PyTypeObject.tp_traverse` と同様で" +"す:" -#: ../../c-api/module.rst:482 ../../c-api/module.rst:504 -#: ../../c-api/module.rst:532 msgid "" "This function is not called if the module state was requested but is not " "allocated yet. This is the case immediately after the module is created and " @@ -631,23 +729,30 @@ msgid "" "`Py_mod_state_size`) is greater than 0 and the module state (as returned by :" "c:func:`PyModule_GetState`) is ``NULL``." msgstr "" +"モジュール状態が要求されていても、まだ割り当てられていなければ、この関数は呼" +"び出されません。\n" +"モジュールの作成直後で、モジュールの実行 (:c:data:`Py_mod_exec` 関数) の前が" +"これに該当します。\n" +"より正確には、状態のサイズ (:c:data:`Py_mod_state_size`) が 0 より大きく、モ" +"ジュール状態 (:c:func:`PyModule_GetState` の戻り値) が ``NULL`` の場合、この" +"関数は呼び出されません。" -#: ../../c-api/module.rst:491 msgid "" "Use :c:member:`PyModuleDef.m_traverse` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_traverse` " +"を使ってください。" -#: ../../c-api/module.rst:495 msgid "" ":c:member:`Slot ID ` for a clear function to call during GC " "clearing of the module object." msgstr "" +"GC がモジュールオブジェクトをクリアする際に呼び出すクリア関数を指定する :c:" +"member:`スロット ID ` です。" -#: ../../c-api/module.rst:498 ../../c-api/module.rst:526 msgid "The signature of the function is:" -msgstr "" +msgstr "関数のシグネチャは次のとおりです:" -#: ../../c-api/module.rst:511 msgid "" "Like :c:member:`PyTypeObject.tp_clear`, this function is not *always* called " "before a module is deallocated. For example, when reference counting is " @@ -655,34 +760,45 @@ msgid "" "collector is not involved and the :c:macro:`Py_mod_state_free` function is " "called directly." msgstr "" +":c:member:`PyTypeObject.tp_clear` と同様に、この関数はモジュールの解放前に *" +"必ず* 呼び出されるわけではありません。\n" +"例えば、参照カウントだけでオブジェクトが使われなくなったと判断できる場合、循" +"環ガベージコレクタは関与せず、:c:macro:`Py_mod_state_free` 関数が直接呼び出さ" +"れます。" -#: ../../c-api/module.rst:519 msgid "" "Use :c:member:`PyModuleDef.m_clear` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_clear` を" +"使ってください。" -#: ../../c-api/module.rst:523 msgid "" ":c:member:`Slot ID ` for a function to call during " "deallocation of the module object." msgstr "" +"モジュールオブジェクトの解放時に呼び出す関数を指定する :c:member:`スロット " +"ID ` です。" -#: ../../c-api/module.rst:541 msgid "" "Use :c:member:`PyModuleDef.m_free` instead to support previous versions." msgstr "" +"以前のバージョンに対応するには、代わりに :c:member:`PyModuleDef.m_free` を" +"使ってください。" -#: ../../c-api/module.rst:547 msgid "Module token" -msgstr "" +msgstr "モジュールトークン" -#: ../../c-api/module.rst:549 msgid "" "Each module may have an associated *token*: a pointer-sized value intended " "to identify of the module state's memory layout. This means that if you have " "a module object, but you are not sure if it “belongs” to your extension, you " "can check using code like this:" msgstr "" +"各モジュールには、*トークン* を関連づけることができます。\n" +"これはモジュール状態のメモリレイアウトを識別するための、ポインタサイズの値で" +"す。\n" +"つまり、手元のモジュールオブジェクトが自分の拡張モジュールに「属する」かどう" +"か不明な場合は、次のようなコードで確認できます:" #: ../../c-api/module.rst:554 msgid "" @@ -701,145 +817,167 @@ msgid "" "struct my_state state = (struct my_state*)PyModule_GetState(module)" msgstr "" -#: ../../c-api/module.rst:570 msgid "" "A module's token -- and the *your_token* value to use in the above code -- " "is:" msgstr "" +"モジュールのトークン、つまり上のコードの *your_token* に使う値は次のとおりで" +"す:" -#: ../../c-api/module.rst:572 msgid "" "For modules created with :c:type:`PyModuleDef`: the address of that :c:type:" "`PyModuleDef`;" msgstr "" +":c:type:`PyModuleDef` を使って作成したモジュールでは、その :c:type:" +"`PyModuleDef` のアドレスです。" -#: ../../c-api/module.rst:574 msgid "" "For modules defined with the :c:macro:`Py_mod_token` slot: the value of that " "slot;" msgstr "" +":c:macro:`Py_mod_token` スロットを使って定義したモジュールでは、そのスロット" +"の値です。" -#: ../../c-api/module.rst:576 msgid "" "For modules created from an ``PyModExport_*`` :ref:`export hook `: the slots array that the export hook returned (unless " "overridden with :c:macro:`Py_mod_token`)." msgstr "" +"``PyModExport_*`` :ref:`エクスポートフック ` から作成" +"したモジュールでは、エクスポートフックが返したスロット配列です (:c:macro:" +"`Py_mod_token` でオーバーライドした場合を除きます)。" -#: ../../c-api/module.rst:582 msgid ":c:member:`Slot ID ` for the module token." msgstr "" +"モジュールトークンを指定する :c:member:`スロット ID ` です。" -#: ../../c-api/module.rst:584 msgid "" "If you use this slot to set the module token (rather than rely on the " "default), you must ensure that:" msgstr "" +"デフォルトに任せず、このスロットでモジュールトークンを設定する場合は、以下を" +"保証する必要があります:" -#: ../../c-api/module.rst:587 msgid "" "The pointer outlives the class, so it's not reused for something else while " "the class exists." msgstr "" +"クラスが存在する間にポインタが他の用途に再利用されないよう、その参照先がクラ" +"スより長く存続すること。" -#: ../../c-api/module.rst:589 msgid "" "It \"belongs\" to the extension module where the class lives, so it will not " "clash with other extensions." msgstr "" +"他の拡張モジュールと競合しないよう、クラスが属する拡張モジュールにそのポイン" +"タが「属する」こと。" -#: ../../c-api/module.rst:591 msgid "" "If the token points to a :c:type:`PyModuleDef` struct, the module should " "behave as if it was created from that :c:type:`PyModuleDef`. In particular, " "the module state must have matching layout and semantics." msgstr "" +"トークンが :c:type:`PyModuleDef` 構造体を指している場合、モジュールはその :c:" +"type:`PyModuleDef` から作成した場合と同じように動作する必要があります。\n" +"特に、モジュール状態のレイアウトと意味が一致していなければなりません。" -#: ../../c-api/module.rst:595 msgid "" "Modules created from :c:type:`PyModuleDef` always use the address of the :c:" "type:`PyModuleDef` as the token. This means that :c:macro:`!Py_mod_token` " "cannot be used in :c:member:`PyModuleDef.m_slots`." msgstr "" +":c:type:`PyModuleDef` から作成したモジュールは、常にその :c:type:" +"`PyModuleDef` のアドレスをトークンに使います。\n" +"そのため、:c:macro:`!Py_mod_token` を :c:member:`PyModuleDef.m_slots` で使う" +"ことはできません。" -#: ../../c-api/module.rst:604 msgid "Set *\\*result* to the module token for *module* and return 0." -msgstr "" +msgstr "*\\*result* に *module* のモジュールトークンを設定し、0 を返します。" -#: ../../c-api/module.rst:606 msgid "On error, set *\\*result* to NULL, and return -1 with an exception set." msgstr "" +"エラー時には *\\*result* に ``NULL`` を設定し、例外を設定して -1 を返します。" -#: ../../c-api/module.rst:610 msgid "See also :c:func:`PyType_GetModuleByToken`." -msgstr "" +msgstr ":c:func:`PyType_GetModuleByToken` も参照してください。" -#: ../../c-api/module.rst:616 msgid "Creating extension modules dynamically" -msgstr "" +msgstr "拡張モジュールの動的な作成" -#: ../../c-api/module.rst:618 msgid "" "The following functions may be used to create an extension module " "dynamically, rather than from an extension's :ref:`export hook `." msgstr "" +"次の関数を使うと、拡張モジュールの :ref:`エクスポートフック ` を使わず、動的に拡張モジュールを作成できます。" -#: ../../c-api/module.rst:623 msgid "" "Create a new module object, given an array of :ref:`slots " "` and the :py:class:`~importlib.machinery.ModuleSpec` " "*spec*." msgstr "" +":ref:`スロット ` の配列と :py:class:`~importlib.machinery." +"ModuleSpec` *spec* から、新しいモジュールオブジェクトを作成します。" -#: ../../c-api/module.rst:626 msgid "" "The *slots* argument must point to an array of :c:type:`PySlot` structures, " "terminated by an entry with slot ID of 0 (typically written as :c:macro:" "`PySlot_END`). The array must include a :c:data:`Py_mod_abi` entry." msgstr "" +"*slots* 引数は、スロット ID が 0 のエントリー (通常は :c:macro:`PySlot_END` " +"と記述します) で終端された :c:type:`PySlot` 構造体の配列を指す必要がありま" +"す。\n" +"配列には :c:data:`Py_mod_abi` エントリーを含める必要があります。" -#: ../../c-api/module.rst:631 msgid "" "The *spec* argument may be any ``ModuleSpec``-like object, as described in :" "c:macro:`Py_mod_create` documentation. Currently, the *spec* must have a " "``name`` attribute." msgstr "" +"*spec* 引数には、:c:macro:`Py_mod_create` のドキュメントで説明する " +"``ModuleSpec`` に似たオブジェクトを使えます。\n" +"現在、*spec* には ``name`` 属性が必要です。" -#: ../../c-api/module.rst:635 msgid "" "On success, return the new module. On error, return ``NULL`` with an " "exception set." msgstr "" +"成功すると新しいモジュールを返します。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/module.rst:638 msgid "" "Note that this does not process the module's execution slot (:c:data:" "`Py_mod_exec`). Both :c:func:`!PyModule_FromSlotsAndSpec` and :c:func:" "`PyModule_Exec` must be called to fully initialize a module. (See also :ref:" "`multi-phase-initialization`.)" msgstr "" +"この関数はモジュールの実行スロット (:c:data:`Py_mod_exec`) を処理しないことに" +"注意してください。\n" +"モジュールを完全に初期化するには、:c:func:`!PyModule_FromSlotsAndSpec` と :c:" +"func:`PyModule_Exec` の両方を呼び出す必要があります (:ref:`multi-phase-" +"initialization` も参照)。" -#: ../../c-api/module.rst:648 msgid "Execute the :c:data:`Py_mod_exec` slot(s) of *module*." -msgstr "" +msgstr "*module* の :c:data:`Py_mod_exec` スロットを実行します。" -#: ../../c-api/module.rst:650 msgid "On success, return 0. On error, return -1 with an exception set." msgstr "" +"成功すると 0 を返します。\n" +"エラー時には例外を設定して -1 を返します。" -#: ../../c-api/module.rst:653 msgid "" "For clarity: If *module* has no slots, for example if it uses :ref:`legacy " "single-phase initialization `, this function " "does nothing and returns 0." msgstr "" +"明確にすると、例えば :ref:`従来の一段階初期化 ` " +"を使っていて *module* にスロットがない場合、この関数は何もせずに 0 を返しま" +"す。" -#: ../../c-api/module.rst:664 msgid "Module definition struct" -msgstr "" +msgstr "モジュール定義構造体" -#: ../../c-api/module.rst:666 msgid "" "Traditionally, extension modules were defined using a *module definition* as " "the “description\" of how a module should be created. Rather than using an " @@ -847,70 +985,83 @@ msgid "" "dedicated members for most common functionality, and allows additional slots " "as an extension mechanism." msgstr "" +"従来、拡張モジュールは、その作成方法を「記述」する *モジュール定義* を使って" +"定義していました。\n" +"この定義は :ref:`スロット ` の配列を直接使う代わりに、よく" +"使う機能専用のメンバーを持ち、拡張の仕組みとして追加のスロットを指定できま" +"す。" -#: ../../c-api/module.rst:672 msgid "" "This way of defining modules is still available and there are no plans to " "remove it." -msgstr "" +msgstr "このモジュール定義方法も引き続き利用でき、削除する予定はありません。" -#: ../../c-api/module.rst:677 msgid "" "The module definition struct, which holds information needed to create a " "module object." msgstr "" +"モジュールオブジェクトを作成するのに必要な情報を保持する、モジュール定義構造" +"体です。" -#: ../../c-api/module.rst:680 msgid "" "This structure must be statically allocated (or be otherwise guaranteed to " "be valid while any modules created from it exist). Usually, there is only " "one variable of this type for each extension module defined this way." msgstr "" +"この構造体は静的に割り当てる必要があります (または、この構造体から作成したモ" +"ジュールが存在する間は有効であることを、別の方法で保証する必要があります)。\n" +"通常、この方法で定義する拡張モジュールごとに、この型の変数を 1 つだけ用意しま" +"す。" -#: ../../c-api/module.rst:685 msgid "" "The struct, including all members, is part of the :ref:`Stable ABI ` for non-free-threaded builds (``abi3``). In the Stable ABI for free-" "threaded builds (``abi3t``), this struct is opaque, and unusable in " "practice; see :ref:`pymoduledef_slot` for a replacement." msgstr "" +"この構造体は、すべてのメンバーを含め、フリースレッドでないビルドの :ref:`安" +"定 ABI ` (``abi3``) の一部です。\n" +"フリースレッドビルドの安定 ABI (``abi3t``) では、この構造体は不透明で実際には" +"利用できません。\n" +"代替手段は :ref:`pymoduledef_slot` を参照してください。" -#: ../../c-api/module.rst:693 msgid "Always initialize this member to :c:macro:`PyModuleDef_HEAD_INIT`:" msgstr "" +"このメンバーは必ず :c:macro:`PyModuleDef_HEAD_INIT` で初期化してください:" -#: ../../c-api/module.rst:699 msgid "The type of :c:member:`!PyModuleDef.m_base`." -msgstr "" +msgstr ":c:member:`!PyModuleDef.m_base` の型です。" -#: ../../c-api/module.rst:701 msgid "" "The struct is part of the :ref:`Stable ABI ` for non-free-" "threaded builds (``abi3``). In the Stable ABI for Free-Threaded Builds " "(``abi3t``), this struct is opaque, and unusable in practice." msgstr "" +"この構造体は、フリースレッドでないビルドの :ref:`安定 ABI ` " +"(``abi3``) の一部です。\n" +"フリースレッドビルドの安定 ABI (``abi3t``) では、この構造体は不透明で実際には" +"利用できません。" -#: ../../c-api/module.rst:708 msgid "The required initial value for :c:member:`!PyModuleDef.m_base`." -msgstr "" +msgstr ":c:member:`!PyModuleDef.m_base` に必要な初期値です。" -#: ../../c-api/module.rst:712 msgid "Corresponds to the :c:macro:`Py_mod_name` slot." -msgstr "" +msgstr ":c:macro:`Py_mod_name` スロットに対応します。" -#: ../../c-api/module.rst:716 msgid "" "These members correspond to the :c:macro:`Py_mod_doc` slot. Setting this to " "NULL is equivalent to omitting the slot." msgstr "" +"これらのメンバーは :c:macro:`Py_mod_doc` スロットに対応します。\n" +"``NULL`` を設定することは、スロットを省略することと等価です。" -#: ../../c-api/module.rst:721 msgid "" "Corresponds to the :c:macro:`Py_mod_state_size` slot. Setting this to zero " "is equivalent to omitting the slot." msgstr "" +":c:macro:`Py_mod_state_size` スロットに対応します。\n" +"ゼロを設定することは、スロットを省略することと等価です。" -#: ../../c-api/module.rst:724 msgid "" "When using :ref:`legacy single-phase initialization ` or when creating modules dynamically using :c:func:" @@ -918,27 +1069,39 @@ msgid "" "set to -1. This indicates that the module does not support sub-interpreters, " "because it has global state." msgstr "" +":ref:`従来の一段階初期化 ` を使う場合や、:c:" +"func:`PyModule_Create` または :c:func:`PyModule_Create2` でモジュールを動的に" +"作成する場合は、:c:member:`!m_size` に -1 を設定できます。\n" +"これはモジュールがグローバルな状態を持つため、サブインタープリタに対応してい" +"ないことを示します。" -#: ../../c-api/module.rst:732 msgid "" "Corresponds to the :c:macro:`Py_mod_methods` slot. Setting this to NULL is " "equivalent to omitting the slot." msgstr "" +":c:macro:`Py_mod_methods` スロットに対応します。\n" +"``NULL`` を設定することは、スロットを省略することと等価です。" -#: ../../c-api/module.rst:737 msgid "" "An array of additional slots, terminated by a ``{0, NULL}`` entry. Note that " "the entries use the older :c:type:`PyModuleDef_Slot` structure, rather than :" "c:type:`PySlot`." msgstr "" +"``{0, NULL}`` エントリーで終端された、追加のスロットの配列です。\n" +"エントリーには :c:type:`PySlot` ではなく、従来の :c:type:`PyModuleDef_Slot` " +"構造体を使うことに注意してください。" -#: ../../c-api/module.rst:741 msgid "" "If the array contains slots corresponding to :c:type:`PyModuleDef` members, " "the values must match. For example, if you use :c:macro:`Py_mod_name` in :c:" "member:`!m_slots`, :c:member:`PyModuleDef.m_name` must be set to the same " "pointer (not just an equal string)." msgstr "" +"配列に :c:type:`PyModuleDef` のメンバーに対応するスロットが含まれる場合、値は" +"一致している必要があります。\n" +"例えば :c:member:`!m_slots` で :c:macro:`Py_mod_name` を使う場合、:c:member:" +"`PyModuleDef.m_name` には同じポインタを設定する必要があります (等しい文字列と" +"いうだけでは不十分です)。" #: ../../c-api/module.rst:749 msgid "" @@ -948,24 +1111,25 @@ msgstr "" "バージョン 3.5 より前は、このメンバは常に ``NULL`` に設定されていて、次のもの" "として定義されていました:" -#: ../../c-api/module.rst:758 msgid "Older structure defining additional slots of a module." -msgstr "" +msgstr "モジュールの追加のスロットを定義する従来の構造体です。" -#: ../../c-api/module.rst:760 msgid "" "Note that a :c:type:`!PyModuleDef_Slot` array may be included in a :c:type:`!" "PySlot` array using :c:macro:`Py_mod_slots`, and vice versa using :c:macro:" "`Py_slot_subslots`." msgstr "" +":c:macro:`Py_mod_slots` を使うと :c:type:`!PySlot` 配列に :c:type:`!" +"PyModuleDef_Slot` 配列を含めることができ、逆方向は :c:macro:" +"`Py_slot_subslots` で行えることに注意してください。" -#: ../../c-api/module.rst:764 msgid "" "Each :c:type:`!PyModuleDef_Slot` structure ``modslot`` is interpreted as the " "following :c:type:`PySlot` structure::" msgstr "" +"各 :c:type:`!PyModuleDef_Slot` 構造体 ``modslot`` は、次の :c:type:`PySlot` " +"構造体として解釈されます。 ::" -#: ../../c-api/module.rst:767 msgid "" "(PySlot){\n" " .sl_id=modslot.slot,\n" @@ -973,64 +1137,76 @@ msgid "" " .sl_ptr=modslot.value\n" "}" msgstr "" +"(PySlot){\n" +" .sl_id=modslot.slot,\n" +" .sl_flags=PySlot_INTPTR | sub_static,\n" +" .sl_ptr=modslot.value\n" +"}" -#: ../../c-api/module.rst:773 msgid "" "where ``sub_static`` is ``PySlot_STATIC`` if the slot requires the flag " "(such as for :c:macro:`Py_mod_methods`), or if this flag is present on the " "\"parent\" :c:macro:`!Py_mod_slots` slot (if any)." msgstr "" +"ここで ``sub_static`` は、そのスロットがフラグを必要とする場合 (:c:macro:" +"`Py_mod_methods` など)、または「親」の :c:macro:`!Py_mod_slots` スロット (存" +"在する場合) にこのフラグがある場合は、``PySlot_STATIC`` です。" -#: ../../c-api/module.rst:779 msgid "Corresponds to :c:member:`PySlot.sl_id`." -msgstr "" +msgstr ":c:member:`PySlot.sl_id` に対応します。" -#: ../../c-api/module.rst:783 msgid "Corresponds to :c:member:`PySlot.sl_ptr`." -msgstr "" +msgstr ":c:member:`PySlot.sl_ptr` に対応します。" -#: ../../c-api/module.rst:791 msgid "" "These members correspond to the :c:macro:`Py_mod_state_traverse`, :c:macro:" "`Py_mod_state_clear`, and :c:macro:`Py_mod_state_free` slots, respectively." msgstr "" +"これらのメンバーは、それぞれ :c:macro:`Py_mod_state_traverse`、:c:macro:" +"`Py_mod_state_clear`、:c:macro:`Py_mod_state_free` スロットに対応します。" -#: ../../c-api/module.rst:795 msgid "" "Setting these members to NULL is equivalent to omitting the corresponding " "slots." msgstr "" +"これらのメンバーに ``NULL`` を設定することは、対応するスロットを省略すること" +"と等価です。" -#: ../../c-api/module.rst:800 msgid "" ":c:member:`m_traverse`, :c:member:`m_clear` and :c:member:`m_free` functions " "are no longer called before the module state is allocated." msgstr "" +"モジュール状態の割り当て前には、:c:member:`m_traverse`、:c:member:" +"`m_clear`、:c:member:`m_free` 関数を呼び出さなくなりました。" -#: ../../c-api/module.rst:806 msgid "The type of ``PyModuleDef`` objects." -msgstr "" +msgstr "``PyModuleDef`` オブジェクトの型です。" -#: ../../c-api/module.rst:811 msgid "" ":c:member:`Slot ID ` that works like :c:macro:" "`Py_slot_subslots`, except it specifies an array of :c:type:" "`PyModuleDef_Slot` structures." msgstr "" +":c:macro:`Py_slot_subslots` と同様に動作しますが、:c:type:`PyModuleDef_Slot` " +"構造体の配列を指定する :c:member:`スロット ID ` です。" -#: ../../c-api/module.rst:819 msgid "" "The following API can be used to create modules from a :c:type:`!" "PyModuleDef` struct:" msgstr "" +"次の API を使うと、:c:type:`!PyModuleDef` 構造体からモジュールを作成できます:" -#: ../../c-api/module.rst:824 msgid "" "Create a new module object, given the definition in *def*. This is a macro " "that calls :c:func:`PyModule_Create2` with *module_api_version* set to :c:" "macro:`PYTHON_API_VERSION`, or to :c:macro:`PYTHON_ABI_VERSION` if using " "the :ref:`limited API `." msgstr "" +"*def* の定義から、新しいモジュールオブジェクトを作成します。\n" +"このマクロは *module_api_version* に :c:macro:`PYTHON_API_VERSION` を設定し" +"て :c:func:`PyModule_Create2` を呼び出します。\n" +":ref:`制限付き API ` を使う場合は、代わりに :c:macro:" +"`PYTHON_ABI_VERSION` を設定します。" #: ../../c-api/module.rst:832 msgid "" @@ -1043,11 +1219,13 @@ msgstr "" "もし指定されたバージョンが実行しているインタープリターのバージョンと異なる場" "合は、 :exc:`RuntimeWarning` を発生させます。" -#: ../../c-api/module.rst:838 msgid "" "This function does not support slots. The :c:member:`~PyModuleDef.m_slots` " "member of *def* must be ``NULL``." msgstr "" +"この関数はスロットをサポートしません。\n" +"*def* の :c:member:`~PyModuleDef.m_slots` メンバーは ``NULL`` でなければなり" +"ません。" #: ../../c-api/module.rst:844 msgid "" @@ -1057,16 +1235,19 @@ msgstr "" "ほとんどの場合、この関数ではなく :c:func:`PyModule_Create` を利用するべきで" "す。この関数は、この関数の必要性を理解しているときにだけ利用してください。" -#: ../../c-api/module.rst:849 msgid "" "This macro calls :c:func:`PyModule_FromDefAndSpec2` with " "*module_api_version* set to :c:macro:`PYTHON_API_VERSION`, or to :c:macro:" "`PYTHON_ABI_VERSION` if using the :ref:`limited API `." msgstr "" +"このマクロは *module_api_version* に :c:macro:`PYTHON_API_VERSION` を設定し" +"て :c:func:`PyModule_FromDefAndSpec2` を呼び出します。\n" +":ref:`制限付き API ` を使う場合は、代わりに :c:macro:" +"`PYTHON_ABI_VERSION` を設定します。" -#: ../../c-api/module.rst:858 ../../c-api/module.rst:882 msgid "Prefer :c:func:`PyModule_FromSlotsAndSpec` in new code." msgstr "" +"新しいコードでは :c:func:`PyModule_FromSlotsAndSpec` を使うことを推奨します。" #: ../../c-api/module.rst:862 msgid "" @@ -1080,12 +1261,15 @@ msgstr "" "もし指定されたバージョンが実行しているインタープリターのバージョンと異なる場" "合は、 :exc:`RuntimeWarning` を発生させます。" -#: ../../c-api/module.rst:869 msgid "" "Note that this does not process execution slots (:c:data:`Py_mod_exec`). " "Both ``PyModule_FromDefAndSpec`` and ``PyModule_ExecDef`` must be called to " "fully initialize a module." msgstr "" +"この関数は実行スロット (:c:data:`Py_mod_exec`) を処理しないことに注意してくだ" +"さい。\n" +"モジュールを完全に初期化するには、``PyModule_FromDefAndSpec`` と " +"``PyModule_ExecDef`` の両方を呼び出す必要があります。" #: ../../c-api/module.rst:875 msgid "" @@ -1101,41 +1285,51 @@ msgid "Process any execution slots (:c:data:`Py_mod_exec`) given in *def*." msgstr "" "*def* で与えられた任意の実行スロット (:c:data:`Py_mod_exec`) を実行します。" -#: ../../c-api/module.rst:892 msgid "" "To run a module's own execution slots, prefer :c:func:`PyModule_Exec`, which " "works on modules that were not created from a :c:type:`PyModuleDef` " "structure." msgstr "" +"モジュール自身の実行スロットを実行するには、:c:func:`PyModule_Exec` を使うこ" +"とを推奨します。\n" +"この関数は :c:type:`PyModuleDef` 構造体から作成していないモジュールにも使えま" +"す。" -#: ../../c-api/module.rst:899 msgid "" "The C API version, as an integer (``1013``) and string (``\"1013\"``), " "respectively. Defined for backwards compatibility." msgstr "" +"C API のバージョンを、それぞれ整数 (``1013``) と文字列 (``\"1013\"``) で表し" +"たものです。\n" +"後方互換性のために定義されています。" -#: ../../c-api/module.rst:902 ../../c-api/module.rst:910 msgid "" "Currently, this constant is not updated in new Python versions, and is not " "useful for versioning. This may change in the future." msgstr "" +"現在、この定数は新しい Python バージョンでも更新されないため、バージョンの判" +"別には役立ちません。\n" +"将来は変更される可能性があります。" -#: ../../c-api/module.rst:908 msgid "" "Defined as ``3`` and ``\"3\"``, respectively, for backwards compatibility." -msgstr "" +msgstr "後方互換性のため、それぞれ ``3`` と ``\"3\"`` として定義されています。" #: ../../c-api/module.rst:917 msgid "Support functions" msgstr "サポート関数" -#: ../../c-api/module.rst:919 msgid "" "The following functions are provided to help initialize a module object. " "They are intended for a module's execution slot (:c:data:`Py_mod_exec`), the " "initialization function for legacy :ref:`single-phase initialization `, or code that creates modules dynamically." msgstr "" +"以下の関数は、モジュールオブジェクトの初期化を補助するために用意されていま" +"す。\n" +"モジュールの実行スロット (:c:data:`Py_mod_exec`)、従来の :ref:`一段階初期化 " +"` の初期化関数、またはモジュールを動的に作成する" +"コードで使うことを想定しています。" #: ../../c-api/module.rst:926 msgid "" @@ -1182,12 +1376,14 @@ msgstr "" " return res;\n" " }" -#: ../../c-api/module.rst:945 msgid "" "To be convenient, the function accepts ``NULL`` *value* with an exception " "set. In this case, return ``-1`` and just leave the raised exception " "unchanged." msgstr "" +"使いやすいように、例外が設定されていれば *value* に ``NULL`` を受け付けま" +"す。\n" +"この場合は ``-1`` を返し、送出された例外はそのままにします。" #: ../../c-api/module.rst:949 msgid "" @@ -1225,7 +1421,6 @@ msgstr "" "この場合は、 *obj* が ``NULL`` でありうるため、 ``Py_DECREF()`` の代わりに " "``Py_XDECREF()`` を呼び出す必要があることに注意してください。" -#: ../../c-api/module.rst:964 msgid "" "The number of different *name* strings passed to this function should be " "kept small, usually by only using statically allocated strings as *name*. " @@ -1234,48 +1429,63 @@ msgid "" "details, see :c:func:`PyUnicode_InternFromString`, which may be used " "internally to create a key object." msgstr "" +"この関数に渡す *name* 文字列の種類は少数に抑える必要があります。\n" +"通常は *name* に静的に割り当てた文字列だけを使います。\n" +"コンパイル時に分からない名前には、:c:func:`PyUnicode_FromString` と :c:func:" +"`PyObject_SetAttr` を直接呼び出すことを推奨します。\n" +"詳細は、キーオブジェクトの作成に内部で使われることがある :c:func:" +"`PyUnicode_InternFromString` を参照してください。" -#: ../../c-api/module.rst:977 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but \":term:`steals `\" a " "reference to *value* (even on error). It can be called with a result of " "function that returns a new reference without bothering to check its result " "or even saving it to a variable." msgstr "" +":c:func:`PyModule_AddObjectRef` と同様ですが、*value* への参照を (エラー時も)" +"「:term:`盗みます `」。\n" +"新しい参照を返す関数の結果を、確認したり変数に保存したりすることなく、そのま" +"ま渡して呼び出せます。" -#: ../../c-api/module.rst:984 msgid "" "if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" " goto error;\n" "}" msgstr "" +"if (PyModule_Add(module, \"spam\", PyBytes_FromString(value)) < 0) {\n" +" goto error;\n" +"}" -#: ../../c-api/module.rst:993 msgid "" "Similar to :c:func:`PyModule_AddObjectRef`, but :term:`steals ` a " "reference to *value* on success (if it returns ``0``)." msgstr "" +":c:func:`PyModule_AddObjectRef` と同様ですが、成功時 (``0`` を返した場合) に " +"*value* への参照を :term:`盗みます `。" -#: ../../c-api/module.rst:996 msgid "" "The new :c:func:`PyModule_Add` or :c:func:`PyModule_AddObjectRef` functions " "are recommended, since it is easy to introduce reference leaks by misusing " "the :c:func:`PyModule_AddObject` function." msgstr "" +":c:func:`PyModule_AddObject` 関数は誤用により参照のリークを起こしやすいため、" +"新しい :c:func:`PyModule_Add` または :c:func:`PyModule_AddObjectRef` 関数を推" +"奨します。" -#: ../../c-api/module.rst:1003 msgid "" "Unlike other functions that steal references, ``PyModule_AddObject()`` only " "releases the reference to *value* **on success**." msgstr "" +"参照を盗む他の関数とは異なり、``PyModule_AddObject()`` が *value* への参照を" +"解放するのは **成功時だけ** です。" -#: ../../c-api/module.rst:1006 msgid "" "This means that its return value must be checked, and calling code must :c:" "func:`Py_XDECREF` *value* manually on error." msgstr "" +"そのため、戻り値を確認する必要があり、エラー時には呼び出し側のコードが " +"*value* に対して明示的に :c:func:`Py_XDECREF` を行わなければなりません。" -#: ../../c-api/module.rst:1011 msgid "" "PyObject *obj = PyBytes_FromString(value);\n" "if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" @@ -1288,56 +1498,83 @@ msgid "" "// PyModule_AddObject() stole a reference to obj:\n" "// Py_XDECREF(obj) is not needed here." msgstr "" +"PyObject *obj = PyBytes_FromString(value);\n" +"if (PyModule_AddObject(module, \"spam\", obj) < 0) {\n" +" // 'obj' が NULL でなく、PyModule_AddObject() が失敗した場合は、\n" +" // Py_XDECREF() で 'obj' への強参照を解放する必要があります。\n" +" // 'obj' が NULL の場合、Py_XDECREF() は何もしません。\n" +" Py_XDECREF(obj);\n" +" goto error;\n" +"}\n" +"// PyModule_AddObject() が obj への参照を盗んだため、\n" +"// ここで Py_XDECREF(obj) は不要です。" -#: ../../c-api/module.rst:1027 msgid "" "Add an integer constant to *module* as *name*. This convenience function " "can be used from the module's initialization function. Return ``-1`` with an " "exception set on error, ``0`` on success." msgstr "" +"整数定数を *name* として *module* に追加します。\n" +"この便利関数はモジュールの初期化関数から使えます。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" -#: ../../c-api/module.rst:1031 msgid "" "This is a convenience function that calls :c:func:`PyLong_FromLong` and :c:" "func:`PyModule_AddObjectRef`; see their documentation for details." msgstr "" +"この便利関数は :c:func:`PyLong_FromLong` と :c:func:`PyModule_AddObjectRef` " +"を呼び出します。\n" +"詳細はそれぞれのドキュメントを参照してください。" -#: ../../c-api/module.rst:1037 msgid "" "Add a string constant to *module* as *name*. This convenience function can " "be used from the module's initialization function. The string *value* must " "be ``NULL``-terminated. Return ``-1`` with an exception set on error, ``0`` " "on success." msgstr "" +"文字列定数を *name* として *module* に追加します。\n" +"この便利関数はモジュールの初期化関数から使えます。\n" +"文字列 *value* は ``NULL`` 終端されている必要があります。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" -#: ../../c-api/module.rst:1042 msgid "" "This is a convenience function that calls :c:func:" "`PyUnicode_InternFromString` and :c:func:`PyModule_AddObjectRef`; see their " "documentation for details." msgstr "" +"この便利関数は :c:func:`PyUnicode_InternFromString` と :c:func:" +"`PyModule_AddObjectRef` を呼び出します。\n" +"詳細はそれぞれのドキュメントを参照してください。" -#: ../../c-api/module.rst:1049 msgid "" "Add an int constant to *module*. The name and the value are taken from " "*macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int " "constant *AF_INET* with the value of *AF_INET* to *module*. Return ``-1`` " "with an exception set on error, ``0`` on success." msgstr "" +"整数定数を *module* に追加します。\n" +"名前と値は *macro* から取得します。\n" +"例えば ``PyModule_AddIntMacro(module, AF_INET)`` は、値が *AF_INET* の整数定" +"数 *AF_INET* を *module* に追加します。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" #: ../../c-api/module.rst:1057 msgid "Add a string constant to *module*." msgstr "文字列定数を *module* に追加します。" -#: ../../c-api/module.rst:1061 msgid "" "Add a type object to *module*. The type object is finalized by calling " "internally :c:func:`PyType_Ready`. The name of the type object is taken from " "the last component of :c:member:`~PyTypeObject.tp_name` after dot. Return " "``-1`` with an exception set on error, ``0`` on success." msgstr "" +"型オブジェクトを *module* に追加します。\n" +"内部で :c:func:`PyType_Ready` を呼び出して型オブジェクトの準備を完了しま" +"す。\n" +"型オブジェクトの名前には、:c:member:`~PyTypeObject.tp_name` の最後のドットの" +"後の部分を使います。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" -#: ../../c-api/module.rst:1071 msgid "" "Add the functions from the ``NULL`` terminated *functions* array to " "*module*. Refer to the :c:type:`PyMethodDef` documentation for details on " @@ -1345,8 +1582,13 @@ msgid "" "level \"functions\" implemented in C typically receive the module as their " "first parameter, making them similar to instance methods on Python classes)." msgstr "" +"``NULL`` で終端された *functions* 配列の関数を *module* に追加します。\n" +"各エントリーの詳細は :c:type:`PyMethodDef` のドキュメントを参照してくださ" +"い。\n" +"(C で実装するモジュールレベルの「関数」は、共有されるモジュール名前空間がない" +"ため、通常は最初の引数にモジュールを受け取ります。\n" +"そのため Python クラスのインスタンスメソッドに似ています。)" -#: ../../c-api/module.rst:1077 msgid "" "This function is called automatically when creating a module from " "``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`, " @@ -1354,26 +1596,35 @@ msgid "" "may prefer defining functions in multiple :c:type:`PyMethodDef` arrays; in " "that case they should call this function directly." msgstr "" +"この関数は ``PyModuleDef`` からモジュールを作成するとき (例えば :ref:`multi-" +"phase-initialization`、``PyModule_Create``、``PyModule_FromDefAndSpec`` を使" +"うとき) に自動的に呼び出されます。\n" +"複数の :c:type:`PyMethodDef` 配列に関数を定義したい場合は、この関数を直接呼び" +"出してください。" -#: ../../c-api/module.rst:1084 msgid "" "The *functions* array must be statically allocated (or otherwise guaranteed " "to outlive the module object)." msgstr "" +"*functions* 配列は静的に割り当てる必要があります (または、モジュールオブジェ" +"クトより長く存続することを別の方法で保証する必要があります)。" -#: ../../c-api/module.rst:1091 msgid "" "Set the docstring for *module* to *docstring*. This function is called " "automatically when creating a module from ``PyModuleDef`` (such as when " "using :ref:`multi-phase-initialization`, ``PyModule_Create``, or " "``PyModule_FromDefAndSpec``)." msgstr "" +"*module* の docstring を *docstring* に設定します。\n" +"この関数は ``PyModuleDef`` からモジュールを作成するとき (例えば :ref:`multi-" +"phase-initialization`、``PyModule_Create``、``PyModule_FromDefAndSpec`` を使" +"うとき) に自動的に呼び出されます。" -#: ../../c-api/module.rst:1096 msgid "Return ``0`` on success. Return ``-1`` with an exception set on error." msgstr "" +"成功すると ``0`` を返します。\n" +"エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/module.rst:1103 msgid "" "Indicate that *module* does or does not support running without the global " "interpreter lock (GIL), using one of the values from :c:macro:`Py_mod_gil`. " @@ -1384,18 +1635,29 @@ msgid "" "configured with :option:`--disable-gil`. Return ``-1`` with an exception set " "on error, ``0`` on success." msgstr "" +":c:macro:`Py_mod_gil` の値のいずれかを使って、*module* がグローバルインタープ" +"リタロック (GIL) なしでの実行に対応するかどうかを示します。\n" +":ref:`single-phase-initialization` を使う場合、*module* の初期化関数の中で呼" +"び出す必要があります。\n" +"モジュール初期化中にこの関数を呼び出さなければ、インポート機構はモジュールが " +"GIL なしでの実行に対応していないとみなします。\n" +"この関数は :option:`--disable-gil` を指定して構成した Python ビルドでのみ利用" +"できます。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" -#: ../../c-api/module.rst:1117 msgid "Module lookup (single-phase initialization)" -msgstr "" +msgstr "モジュールの検索 (一段階初期化)" -#: ../../c-api/module.rst:1119 msgid "" "The legacy :ref:`single-phase initialization ` " "initialization scheme creates singleton modules that can be looked up in the " "context of the current interpreter. This allows the module object to be " "retrieved later with only a reference to the module definition." msgstr "" +"従来の :ref:`一段階初期化 ` 方式は、現在のイン" +"タープリタのコンテキストで検索できるシングルトンのモジュールを作成します。\n" +"そのため、モジュール定義への参照だけで、後からモジュールオブジェクトを取得で" +"きます。" #: ../../c-api/module.rst:1124 msgid "" @@ -1434,7 +1696,6 @@ msgstr "" msgid "Only effective on modules created using single-phase initialization." msgstr "一段階初期化を使って作成されたモジュールにのみ有効です。" -#: ../../c-api/module.rst:1141 msgid "" "Python calls ``PyState_AddModule`` automatically after importing a module " "that uses :ref:`single-phase initialization `, " @@ -1445,26 +1706,38 @@ msgid "" "directly, or by referring to its implementation for details of the required " "state updates)." msgstr "" +"Python は :ref:`一段階初期化 ` を使うモジュール" +"のインポート後に、自動的に ``PyState_AddModule`` を呼び出します。\n" +"そのため、モジュール初期化コードから呼び出す必要はありません (呼び出しても問" +"題はありません)。\n" +"明示的な呼び出しが必要なのは、モジュール自身の初期化コードが、その後で " +"``PyState_FindModule`` を呼び出す場合だけです。\n" +"この関数は主に、別のインポート機構の実装を想定しています (直接呼び出すこと" +"も、必要な状態更新の詳細を知るために実装を参照することもできます)。" -#: ../../c-api/module.rst:1150 msgid "" "If a module was attached previously using the same *def*, it is replaced by " "the new *module*." msgstr "" +"同じ *def* を使ってモジュールがすでに関連づけられていた場合は、新しい " +"*module* に置き換えます。" -#: ../../c-api/module.rst:1153 ../../c-api/module.rst:1164 msgid "The caller must have an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" -#: ../../c-api/module.rst:1155 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" +"エラーの場合は例外を設定して ``-1`` を返し、成功した場合は ``0`` を返します。" -#: ../../c-api/module.rst:1161 msgid "" "Removes the module object created from *def* from the interpreter state. " "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" +"*def* から作成されたモジュールオブジェクトを、インタープリタの状態から削除し" +"ます。\n" +"エラー時には例外を設定して ``-1``、成功すると ``0`` を返します。" #: ../../c-api/module.rst:8 msgid "object" @@ -1490,13 +1763,11 @@ msgstr "__doc__ (モジュール属性)" msgid "__file__ (module attribute)" msgstr "__file__ (モジュール属性)" -#: ../../c-api/module.rst:32 msgid "__package__ (module attribute)" -msgstr "" +msgstr "__package__ (モジュール属性)" -#: ../../c-api/module.rst:32 msgid "__loader__ (module attribute)" -msgstr "" +msgstr "__loader__ (モジュール属性)" #: ../../c-api/module.rst:62 msgid "__dict__ (module attribute)" diff --git a/c-api/monitoring.po b/c-api/monitoring.po index 61e8e3844..2eb439d78 100644 --- a/c-api/monitoring.po +++ b/c-api/monitoring.po @@ -16,32 +16,31 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/monitoring.rst:6 msgid "Monitoring C API" -msgstr "" +msgstr "モニタリング C API" -#: ../../c-api/monitoring.rst:8 msgid "Added in version 3.13." -msgstr "" +msgstr "バージョン 3.13 で追加。" -#: ../../c-api/monitoring.rst:10 msgid "" "An extension may need to interact with the event monitoring system. " "Subscribing to events and registering callbacks can be done via the Python " "API exposed in :mod:`sys.monitoring`." msgstr "" +"拡張モジュールがイベントモニタリングシステムと連携する必要がある場合がありま" +"す。\n" +"イベントの購読やコールバックの登録は、:mod:`sys.monitoring` が公開する " +"Python API で行えます。" -#: ../../c-api/monitoring.rst:15 msgid "Generating Execution Events" -msgstr "" +msgstr "実行イベントの発生" -#: ../../c-api/monitoring.rst:17 msgid "" "The functions below make it possible for an extension to fire monitoring " "events as it emulates the execution of Python code. Each of these functions " @@ -53,130 +52,140 @@ msgid "" "callbacks). The ``codelike`` argument should be an instance of :class:`types." "CodeType` or of a type that emulates it." msgstr "" +"以下の関数を使うと、拡張モジュールが Python コードの実行をエミュレートすると" +"きにモニタリングイベントを発生させられます。\n" +"各関数は、イベントの有効化状態を簡潔に保持する ``PyMonitoringState`` 構造体" +"と、イベントの引数を受け取ります。\n" +"イベントの引数には、コードオブジェクトを表す ``PyObject*``、命令オフセット、" +"場合によってはイベント固有の追加引数が含まれます (各イベントのコールバックの" +"シグネチャは :mod:`sys.monitoring` を参照してください)。\n" +"``codelike`` 引数には、:class:`types.CodeType` またはそれをエミュレートする型" +"のインスタンスを指定してください。" -#: ../../c-api/monitoring.rst:27 msgid "" "The VM disables tracing when firing an event, so there is no need for user " "code to do that." msgstr "" +"VM はイベントを発生させるときにトレースを無効にするため、利用者のコードで無効" +"にする必要はありません。" -#: ../../c-api/monitoring.rst:30 msgid "" "Monitoring functions should not be called with an exception set, except " "those listed below as working with the current exception." msgstr "" +"以下で現在の例外を扱うと記載された関数を除き、例外が設定された状態でモニタリ" +"ング関数を呼び出してはいけません。" -#: ../../c-api/monitoring.rst:35 msgid "" "Representation of the state of an event type. It is allocated by the user " "while its contents are maintained by the monitoring API functions described " "below." msgstr "" +"イベント種別の状態を表します。\n" +"利用者が領域を割り当て、内容は以下のモニタリング API 関数が管理します。" -#: ../../c-api/monitoring.rst:39 msgid "" "All of the functions below return 0 on success and -1 (with an exception " "set) on error." msgstr "" +"以下の関数はすべて、成功した場合は 0 を返し、エラーの場合は例外を設定して -1 " +"を返します。" -#: ../../c-api/monitoring.rst:41 msgid "See :mod:`sys.monitoring` for descriptions of the events." -msgstr "" +msgstr "イベントの説明は :mod:`sys.monitoring` を参照してください。" -#: ../../c-api/monitoring.rst:45 msgid "Fire a ``PY_START`` event." -msgstr "" +msgstr "``PY_START`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:50 msgid "Fire a ``PY_RESUME`` event." -msgstr "" +msgstr "``PY_RESUME`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:55 msgid "Fire a ``PY_RETURN`` event." -msgstr "" +msgstr "``PY_RETURN`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:60 msgid "Fire a ``PY_YIELD`` event." -msgstr "" +msgstr "``PY_YIELD`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:65 msgid "Fire a ``CALL`` event." -msgstr "" +msgstr "``CALL`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:70 msgid "Fire a ``LINE`` event." -msgstr "" +msgstr "``LINE`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:75 msgid "Fire a ``JUMP`` event." -msgstr "" +msgstr "``JUMP`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:80 msgid "Fire a ``BRANCH_LEFT`` event." -msgstr "" +msgstr "``BRANCH_LEFT`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:85 msgid "Fire a ``BRANCH_RIGHT`` event." -msgstr "" +msgstr "``BRANCH_RIGHT`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:90 msgid "Fire a ``C_RETURN`` event." -msgstr "" +msgstr "``C_RETURN`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:95 msgid "" "Fire a ``PY_THROW`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``PY_THROW`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:101 msgid "" "Fire a ``RAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``RAISE`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:107 msgid "" "Fire a ``C_RAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``C_RAISE`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:113 msgid "" "Fire a ``RERAISE`` event with the current exception (as returned by :c:func:" "`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``RERAISE`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:119 msgid "" "Fire an ``EXCEPTION_HANDLED`` event with the current exception (as returned " "by :c:func:`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``EXCEPTION_HANDLED`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:125 msgid "" "Fire a ``PY_UNWIND`` event with the current exception (as returned by :c:" "func:`PyErr_GetRaisedException`)." msgstr "" +"現在の例外 (:c:func:`PyErr_GetRaisedException` が返すもの) を使って " +"``PY_UNWIND`` イベントを発生させます。" -#: ../../c-api/monitoring.rst:131 msgid "" "Fire a ``STOP_ITERATION`` event. If ``value`` is an instance of :exc:" "`StopIteration`, it is used. Otherwise, a new :exc:`StopIteration` instance " "is created with ``value`` as its argument." msgstr "" +"``STOP_ITERATION`` イベントを発生させます。\n" +"``value`` が :exc:`StopIteration` のインスタンスなら、それを使います。\n" +"それ以外の場合は、``value`` を引数として新しい :exc:`StopIteration` インスタ" +"ンスを作成します。" -#: ../../c-api/monitoring.rst:136 msgid "Managing the Monitoring State" -msgstr "" +msgstr "モニタリング状態の管理" -#: ../../c-api/monitoring.rst:138 msgid "" "Monitoring states can be managed with the help of monitoring scopes. A scope " "would typically correspond to a Python function." msgstr "" +"モニタリング状態は、モニタリングスコープを使って管理できます。\n" +"通常、一つのスコープが一つの Python 関数に対応します。" -#: ../../c-api/monitoring.rst:143 msgid "" "Enter a monitored scope. ``event_types`` is an array of the event IDs for " "events that may be fired from the scope. For example, the ID of a " @@ -188,8 +197,18 @@ msgid "" "state of the event. The size of ``event_types`` (and hence also of " "``state_array``) is given in ``length``." msgstr "" +"モニタリング対象のスコープに入ります。\n" +"``event_types`` は、そのスコープから発生し得るイベントの ID の配列です。\n" +"例えば ``PY_START`` イベントの ID は ``PY_MONITORING_EVENT_PY_START`` で、こ" +"の値は ``sys.monitoring.events.PY_START`` の 2 を底とする対数に等しくなりま" +"す。\n" +"``state_array`` は、``event_types`` 内の各イベントに対応するモニタリング状態" +"の配列です。\n" +"領域は利用者が割り当て、イベントの有効化状態は :c:func:`!" +"PyMonitoring_EnterScope` が設定します。\n" +"``event_types`` (したがって ``state_array`` も) のサイズは ``length`` で指定" +"します。" -#: ../../c-api/monitoring.rst:153 msgid "" "The ``version`` argument is a pointer to a value which should be allocated " "by the user together with ``state_array`` and initialized to 0, and then set " @@ -197,8 +216,13 @@ msgid "" "to determine whether event states have changed since the previous call, and " "to return quickly if they have not." msgstr "" +"``version`` 引数は、利用者が ``state_array`` と一緒に領域を割り当て、0 に初期" +"化しておく値へのポインタです。\n" +"その後は :c:func:`!PyMonitoring_EnterScope` 自身だけが値を設定するようにして" +"ください。\n" +"この値によって、前回の呼び出し以降にイベントの状態が変化したかどうかを判断" +"し、変化していなければ速やかに戻ることができます。" -#: ../../c-api/monitoring.rst:159 msgid "" "The scopes referred to here are lexical scopes: a function, class or " "method. :c:func:`!PyMonitoring_EnterScope` should be called whenever the " @@ -207,98 +231,85 @@ msgid "" "Python function. When a code-like's execution is paused, such as when " "emulating a generator, the scope needs to be exited and re-entered." msgstr "" +"ここでいうスコープは、関数、クラス、メソッドといった字句スコープです。\n" +"字句スコープに入るたびに :c:func:`!PyMonitoring_EnterScope` を呼び出してくだ" +"さい。\n" +"再帰的な Python 関数をエミュレートする場合などは、同じ ``state_array`` と " +"``version`` を再利用してスコープに再び入れます。\n" +"ジェネレータをエミュレートする場合など、コードに相当するオブジェクトの実行を" +"一時停止するときは、スコープを一度出てから再び入る必要があります。" -#: ../../c-api/monitoring.rst:166 msgid "The macros for *event_types* are:" -msgstr "" +msgstr "``event_types`` に使うマクロは次のとおりです。" -#: ../../c-api/monitoring.rst:174 msgid "Macro" -msgstr "" +msgstr "マクロ" #: ../../c-api/monitoring.rst:174 msgid "Event" msgstr "Event" -#: ../../c-api/monitoring.rst:176 msgid ":monitoring-event:`BRANCH_LEFT`" -msgstr "" +msgstr ":monitoring-event:`BRANCH_LEFT`" -#: ../../c-api/monitoring.rst:177 msgid ":monitoring-event:`BRANCH_RIGHT`" -msgstr "" +msgstr ":monitoring-event:`BRANCH_RIGHT`" -#: ../../c-api/monitoring.rst:178 msgid ":monitoring-event:`CALL`" -msgstr "" +msgstr ":monitoring-event:`CALL`" -#: ../../c-api/monitoring.rst:179 msgid ":monitoring-event:`C_RAISE`" -msgstr "" +msgstr ":monitoring-event:`C_RAISE`" -#: ../../c-api/monitoring.rst:180 msgid ":monitoring-event:`C_RETURN`" -msgstr "" +msgstr ":monitoring-event:`C_RETURN`" -#: ../../c-api/monitoring.rst:181 msgid ":monitoring-event:`EXCEPTION_HANDLED`" -msgstr "" +msgstr ":monitoring-event:`EXCEPTION_HANDLED`" -#: ../../c-api/monitoring.rst:182 msgid ":monitoring-event:`INSTRUCTION`" -msgstr "" +msgstr ":monitoring-event:`INSTRUCTION`" -#: ../../c-api/monitoring.rst:183 msgid ":monitoring-event:`JUMP`" -msgstr "" +msgstr ":monitoring-event:`JUMP`" -#: ../../c-api/monitoring.rst:184 msgid ":monitoring-event:`LINE`" -msgstr "" +msgstr ":monitoring-event:`LINE`" -#: ../../c-api/monitoring.rst:185 msgid ":monitoring-event:`PY_RESUME`" -msgstr "" +msgstr ":monitoring-event:`PY_RESUME`" -#: ../../c-api/monitoring.rst:186 msgid ":monitoring-event:`PY_RETURN`" -msgstr "" +msgstr ":monitoring-event:`PY_RETURN`" -#: ../../c-api/monitoring.rst:187 msgid ":monitoring-event:`PY_START`" -msgstr "" +msgstr ":monitoring-event:`PY_START`" -#: ../../c-api/monitoring.rst:188 msgid ":monitoring-event:`PY_THROW`" -msgstr "" +msgstr ":monitoring-event:`PY_THROW`" -#: ../../c-api/monitoring.rst:189 msgid ":monitoring-event:`PY_UNWIND`" -msgstr "" +msgstr ":monitoring-event:`PY_UNWIND`" -#: ../../c-api/monitoring.rst:190 msgid ":monitoring-event:`PY_YIELD`" -msgstr "" +msgstr ":monitoring-event:`PY_YIELD`" -#: ../../c-api/monitoring.rst:191 msgid ":monitoring-event:`RAISE`" -msgstr "" +msgstr ":monitoring-event:`RAISE`" -#: ../../c-api/monitoring.rst:192 msgid ":monitoring-event:`RERAISE`" -msgstr "" +msgstr ":monitoring-event:`RERAISE`" -#: ../../c-api/monitoring.rst:193 msgid ":monitoring-event:`STOP_ITERATION`" -msgstr "" +msgstr ":monitoring-event:`STOP_ITERATION`" -#: ../../c-api/monitoring.rst:198 msgid "" "Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`." -msgstr "" +msgstr ":c:func:`!PyMonitoring_EnterScope` で最後に入ったスコープを出ます。" -#: ../../c-api/monitoring.rst:203 msgid "" "Return true if the event corresponding to the event ID *ev* is a :ref:`local " "event `." msgstr "" +"イベント ID ``ev`` に対応するイベントが :ref:`ローカルイベント ` の場合に真を返します。" diff --git a/c-api/none.po b/c-api/none.po index e5709e3f2..3d46264c6 100644 --- a/c-api/none.po +++ b/c-api/none.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/none.rst:6 @@ -56,7 +56,7 @@ msgstr "関数から :c:data:`Py_None` を返します。" #: ../../c-api/none.rst:8 msgid "object" -msgstr "オブジェクト" +msgstr "object" #: ../../c-api/none.rst:8 msgid "None" diff --git a/c-api/number.po b/c-api/number.po index 0daa04370..859051434 100644 --- a/c-api/number.po +++ b/c-api/number.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/number.rst:6 @@ -71,13 +71,14 @@ msgstr "" "ます。\n" "Python の式 ``o1 @ o2`` と同じです。" -#: ../../c-api/number.rst:46 msgid "" "Return the floor of *o1* divided by *o2*, or ``NULL`` on failure. This is " "the equivalent of the Python expression ``o1 // o2``." msgstr "" +"*o1* を *o2* で割った結果に床関数 (floor) を適用した値を返します。\n" +"失敗すると ``NULL`` を返します。\n" +"Python の式 ``o1 // o2`` と同じです。" -#: ../../c-api/number.rst:52 msgid "" "Return a reasonable approximation for the mathematical value of *o1* divided " "by *o2*, or ``NULL`` on failure. The return value is \"approximate\" " @@ -86,6 +87,12 @@ msgid "" "point value when passed two integers. This is the equivalent of the Python " "expression ``o1 / o2``." msgstr "" +"*o1* を *o2* で割った数学的な値の適切な近似値を返します。\n" +"失敗すると ``NULL`` を返します。\n" +"2 進浮動小数点数ではすべての実数を表せず近似になるため、戻り値も「近似値」で" +"す。\n" +"整数を 2 個渡しても、浮動小数点数を返すことがあります。\n" +"Python の式 ``o1 / o2`` と同じです。" #: ../../c-api/number.rst:61 msgid "" @@ -239,7 +246,6 @@ msgstr "" "ます。*o1* が *in-place* 演算をサポートする場合、in-place 演算を行います。" "Python の文 ``o1 //= o2`` と同じです。" -#: ../../c-api/number.rst:178 msgid "" "Return a reasonable approximation for the mathematical value of *o1* divided " "by *o2*, or ``NULL`` on failure. The return value is \"approximate\" " @@ -249,6 +255,13 @@ msgid "" "*o1* supports it. This is the equivalent of the Python statement ``o1 /= " "o2``." msgstr "" +"*o1* を *o2* で割った数学的な値の適切な近似値を返します。\n" +"失敗すると ``NULL`` を返します。\n" +"2 進浮動小数点数ではすべての実数を表せず近似になるため、戻り値も「近似値」で" +"す。\n" +"整数を 2 個渡しても、浮動小数点数を返すことがあります。\n" +"*o1* がサポートしている場合は、*in-place* で演算します。\n" +"Python の文 ``o1 /= o2`` と同じです。" #: ../../c-api/number.rst:188 msgid "" diff --git a/c-api/object.po b/c-api/object.po index 789fe4f8f..e047d1d97 100644 --- a/c-api/object.po +++ b/c-api/object.po @@ -16,79 +16,69 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/object.rst:6 msgid "Object Protocol" msgstr "オブジェクトプロトコル (object protocol)" -#: ../../c-api/object.rst:11 msgid "Get a :term:`strong reference` to a constant." -msgstr "" +msgstr "定数への :term:`強参照 ` を取得します。" -#: ../../c-api/object.rst:13 msgid "Set an exception and return ``NULL`` if *constant_id* is invalid." -msgstr "" +msgstr "*constant_id* が無効な場合、例外を設定して ``NULL`` を返します。" -#: ../../c-api/object.rst:15 msgid "*constant_id* must be one of these constant identifiers:" -msgstr "" +msgstr "*constant_id* は次の定数識別子のいずれかでなければなりません。" -#: ../../c-api/object.rst:20 msgid "Constant Identifier" -msgstr "" +msgstr "定数識別子" #: ../../c-api/object.rst:20 msgid "Value" msgstr "値" -#: ../../c-api/object.rst:20 msgid "Returned object" -msgstr "" +msgstr "返されるオブジェクト" #: ../../c-api/object.rst:22 ../../c-api/object.rst:27 msgid "``0``" msgstr "``0``" -#: ../../c-api/object.rst:22 msgid ":py:data:`None`" -msgstr "" +msgstr ":py:data:`None`" #: ../../c-api/object.rst:23 ../../c-api/object.rst:28 msgid "``1``" msgstr "``1``" -#: ../../c-api/object.rst:23 msgid ":py:data:`False`" -msgstr "" +msgstr ":py:data:`False`" #: ../../c-api/object.rst:24 msgid "``2``" msgstr "``2``" -#: ../../c-api/object.rst:24 msgid ":py:data:`True`" -msgstr "" +msgstr ":py:data:`True`" #: ../../c-api/object.rst:25 msgid "``3``" msgstr "``3``" -#: ../../c-api/object.rst:25 msgid ":py:data:`Ellipsis`" -msgstr "" +msgstr ":py:data:`Ellipsis`" #: ../../c-api/object.rst:26 msgid "``4``" msgstr "``4``" -#: ../../c-api/object.rst:26 msgid ":py:data:`NotImplemented`" -msgstr "" +msgstr ":py:data:`NotImplemented`" #: ../../c-api/object.rst:27 msgid "``5``" @@ -102,52 +92,50 @@ msgstr "``6``" msgid "``7``" msgstr "``7``" -#: ../../c-api/object.rst:29 msgid "``''``" -msgstr "" +msgstr "``''``" #: ../../c-api/object.rst:30 msgid "``8``" msgstr "``8``" -#: ../../c-api/object.rst:30 msgid "``b''``" -msgstr "" +msgstr "``b''``" #: ../../c-api/object.rst:31 msgid "``9``" msgstr "``9``" -#: ../../c-api/object.rst:31 msgid "``()``" -msgstr "" +msgstr "``()``" -#: ../../c-api/object.rst:34 msgid "" "Numeric values are only given for projects which cannot use the constant " "identifiers." -msgstr "" +msgstr "数値は、定数識別子を使えないプロジェクトのためにのみ示しています。" -#: ../../c-api/object.rst:42 msgid "In CPython, all of these constants are :term:`immortal`." -msgstr "" +msgstr "CPython では、これらの定数はすべて :term:`不死 ` です。" -#: ../../c-api/object.rst:47 msgid "" "Similar to :c:func:`Py_GetConstant`, but return a :term:`borrowed reference`." msgstr "" +":c:func:`Py_GetConstant` と同様ですが、:term:`借用参照 ` " +"を返します。" -#: ../../c-api/object.rst:50 msgid "" "This function is primarily intended for backwards compatibility: using :c:" "func:`Py_GetConstant` is recommended for new code." msgstr "" +"この関数は主に後方互換性を目的としています。\n" +"新しいコードでは :c:func:`Py_GetConstant` を使うことを推奨します。" -#: ../../c-api/object.rst:53 msgid "" "The reference is borrowed from the interpreter, and is valid until the " "interpreter finalization." msgstr "" +"参照はインタープリタから借用され、インタープリタがファイナライズされるまで有" +"効です。" #: ../../c-api/object.rst:61 msgid "" @@ -157,71 +145,84 @@ msgstr "" "与えられたオブジェクトとメソッドの引数の型の組み合わせの処理が未実装である印" "として使われる、 ``未実装 (NotImplemented)`` シングルトン。" -#: ../../c-api/object.rst:67 msgid "" "Properly handle returning :c:data:`Py_NotImplemented` from within a C " "function (that is, create a new :term:`strong reference` to :const:" "`NotImplemented` and return it)." msgstr "" +"C 関数内から :c:data:`Py_NotImplemented` を返す処理を適切に行います (つまり :" +"const:`NotImplemented` への新しい :term:`強参照 ` を作成し" +"て返します)。" -#: ../../c-api/object.rst:74 msgid "" "Flag to be used with multiple functions that print the object (like :c:func:" "`PyObject_Print` and :c:func:`PyFile_WriteObject`). If passed, these " "functions use the :func:`str` of the object instead of the :func:`repr`." msgstr "" +"オブジェクトを出力する複数の関数 (:c:func:`PyObject_Print` や :c:func:" +"`PyFile_WriteObject` など) で使うフラグです。\n" +"このフラグを渡すと、これらの関数はオブジェクトの :func:`repr` 結果の代わり" +"に :func:`str` 結果を使います。" -#: ../../c-api/object.rst:82 msgid "" "Print an object *o*, on file *fp*. Returns ``-1`` on error. The flags " "argument is used to enable certain printing options. The only option " "currently supported is :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of " "the object is written instead of the :func:`repr`." msgstr "" +"オブジェクト *o* をファイル *fp* に出力します。\n" +"エラー時は ``-1`` を返します。\n" +"``flags`` 引数で出力オプションを有効にします。\n" +"現在サポートされるオプションは :c:macro:`Py_PRINT_RAW` のみで、指定するとオブ" +"ジェクトの :func:`repr` 結果の代わりに :func:`str` 結果を書き出します。" -#: ../../c-api/object.rst:90 msgid "" "Dump an object *op* to ``stderr``. This should only be used for debugging." msgstr "" +"オブジェクト *op* を ``stderr`` にダンプします。\n" +"デバッグのためにのみ使ってください。" -#: ../../c-api/object.rst:92 msgid "" "The output is intended to try dumping objects even after memory corruption:" msgstr "" +"メモリが破損した後でもオブジェクトのダンプを試みられるように、次のように出力" +"します。" -#: ../../c-api/object.rst:94 msgid "" "Information is written starting with fields that are the least likely to " "crash when accessed." msgstr "" +"アクセス時にクラッシュする可能性が最も低いフィールドから順に情報を書き出しま" +"す。" -#: ../../c-api/object.rst:96 msgid "" "This function can be called without an :term:`attached thread state`, but " "it's not recommended to do so: it can cause deadlocks." msgstr "" +"この関数は :term:`アタッチされたスレッド状態 ` がなく" +"ても呼び出せますが、デッドロックを引き起こす可能性があるため推奨されません。" -#: ../../c-api/object.rst:98 msgid "" "An object that does not belong to the current interpreter may be dumped, but " "this may also cause crashes or unintended behavior." msgstr "" +"現在のインタープリタに属さないオブジェクトもダンプできますが、クラッシュや意" +"図しない動作を引き起こす可能性があります。" -#: ../../c-api/object.rst:100 msgid "" "Implement a heuristic to detect if the object memory has been freed. Don't " "display the object contents in this case, only its memory address." msgstr "" +"オブジェクトのメモリが解放済みかどうかを検出するヒューリスティックを実装して" +"います。\n" +"解放済みと判断した場合は、内容を表示せず、メモリアドレスだけを表示します。" -#: ../../c-api/object.rst:102 msgid "The output format may change at any time." -msgstr "" +msgstr "出力形式はいつでも変更される可能性があります。" -#: ../../c-api/object.rst:104 msgid "Example of output:" -msgstr "" +msgstr "出力例:" -#: ../../c-api/object.rst:106 msgid "" "object address : 0x7f80124702c0\n" "object refcount : 2\n" @@ -229,28 +230,37 @@ msgid "" "object type name: str\n" "object repr : 'abcdef'" msgstr "" +"object address : 0x7f80124702c0\n" +"object refcount : 2\n" +"object type : 0x9902e0\n" +"object type name: str\n" +"object repr : 'abcdef'" -#: ../../c-api/object.rst:119 msgid "" "Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " "This is equivalent to the Python expression ``hasattr(o, attr_name)``. On " "failure, return ``-1``." msgstr "" +"*o* に *attr_name* 属性があれば ``1``、なければ ``0`` を返します。\n" +"Python の式 ``hasattr(o, attr_name)`` と同等です。\n" +"失敗すると ``-1`` を返します。" -#: ../../c-api/object.rst:128 msgid "" "This is the same as :c:func:`PyObject_HasAttrWithError`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyObject_HasAttrWithError` と同じですが、*attr_name* は :c:expr:" +"`PyObject*` ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:" +"`const char*` で指定します。" -#: ../../c-api/object.rst:137 msgid "" "Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise. " "This function always succeeds." msgstr "" +"*o* に *attr_name* 属性があれば ``1``、なければ ``0`` を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/object.rst:142 msgid "" "Exceptions that occur when this calls :meth:`~object.__getattr__` and :meth:" "`~object.__getattribute__` methods aren't propagated, but instead given to :" @@ -258,13 +268,21 @@ msgid "" "`PyObject_HasAttrWithError`, :c:func:`PyObject_GetOptionalAttr` or :c:func:" "`PyObject_GetAttr` instead." msgstr "" +":meth:`~object.__getattr__` メソッドや :meth:`~object.__getattribute__` メ" +"ソッドの呼び出し中に発生した例外は伝播せず、:func:`sys.unraisablehook` に渡さ" +"れます。\n" +"適切にエラーを処理するには、代わりに :c:func:`PyObject_HasAttrWithError`、:c:" +"func:`PyObject_GetOptionalAttr`、:c:func:`PyObject_GetAttr` を使ってくださ" +"い。" -#: ../../c-api/object.rst:151 msgid "" "This is the same as :c:func:`PyObject_HasAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_HasAttr` と同じですが、*attr_name* は :c:expr:`PyObject*` " +"ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で" +"指定します。" #: ../../c-api/object.rst:157 msgid "" @@ -285,32 +303,36 @@ msgstr "" "を返し失敗すると ``NULL`` を返します。この関数は Python の式 ``o.attr_name`` " "と同じです。" -#: ../../c-api/object.rst:171 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttr` instead." msgstr "" +"属性がない場合を失敗として扱いたくなければ、代わりに :c:func:" +"`PyObject_GetOptionalAttr` を使えます。" -#: ../../c-api/object.rst:177 msgid "" "This is the same as :c:func:`PyObject_GetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_GetAttr` と同じですが、*attr_name* は :c:expr:`PyObject*` " +"ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で" +"指定します。" -#: ../../c-api/object.rst:181 msgid "" "If the missing attribute should not be treated as a failure, you can use :c:" "func:`PyObject_GetOptionalAttrString` instead." msgstr "" +"属性がない場合を失敗として扱いたくなければ、代わりに :c:func:" +"`PyObject_GetOptionalAttrString` を使えます。" -#: ../../c-api/object.rst:187 msgid "" "Variant of :c:func:`PyObject_GetAttr` which doesn't raise :exc:" "`AttributeError` if the attribute is not found." msgstr "" +"属性が見つからなくても :exc:`AttributeError` を送出しない :c:func:" +"`PyObject_GetAttr` の変種です。" -#: ../../c-api/object.rst:190 msgid "" "If the attribute is found, return ``1`` and set *\\*result* to a new :term:" "`strong reference` to the attribute. If the attribute is not found, return " @@ -318,13 +340,21 @@ msgid "" "silenced. If an error other than :exc:`AttributeError` is raised, return " "``-1`` and set *\\*result* to ``NULL``." msgstr "" +"属性が見つかった場合は ``1`` を返し、*\\*result* に属性への新しい :term:`強参" +"照 ` を設定します。\n" +"属性が見つからない場合は ``0`` を返し、*\\*result* に ``NULL`` を設定して、:" +"exc:`AttributeError` を抑制します。\n" +":exc:`AttributeError` 以外のエラーが発生した場合は ``-1`` を返し、" +"*\\*result* に ``NULL`` を設定します。" -#: ../../c-api/object.rst:202 msgid "" "This is the same as :c:func:`PyObject_GetOptionalAttr`, but *attr_name* is " "specified as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than " "a :c:expr:`PyObject*`." msgstr "" +":c:func:`PyObject_GetOptionalAttr` と同じですが、*attr_name* は :c:expr:" +"`PyObject*` ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:" +"`const char*` で指定します。" #: ../../c-api/object.rst:210 msgid "" @@ -362,23 +392,27 @@ msgstr "" "`PyObject_DelAttr` のため、非推奨となっていますが、削除される予定はありませ" "ん。" -#: ../../c-api/object.rst:229 ../../c-api/object.rst:246 msgid "" "The function must not be called with a ``NULL`` *v* and an exception set. " "This case can arise from forgetting ``NULL`` checks and would delete the " "attribute." msgstr "" +"例外が設定されているときに、*v* を ``NULL`` にしてこの関数を呼び出してはいけ" +"ません。\n" +"``NULL`` チェックを忘れるとこの状態になることがあり、属性が削除されてしまいま" +"す。" -#: ../../c-api/object.rst:233 ../../c-api/object.rst:258 msgid "Must not be called with NULL value if an exception is set." -msgstr "" +msgstr "例外が設定されている場合、値を NULL にして呼び出してはいけません。" -#: ../../c-api/object.rst:239 msgid "" "This is the same as :c:func:`PyObject_SetAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_SetAttr` と同じですが、*attr_name* は :c:expr:`PyObject*` " +"ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で" +"指定します。" #: ../../c-api/object.rst:243 msgid "" @@ -388,7 +422,6 @@ msgstr "" "*v* が ``NULL`` の場合は属性が削除されますが、この機能は非推奨であり :c:func:" "`PyObject_DelAttrString` を使うのが望ましいです。" -#: ../../c-api/object.rst:250 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -397,6 +430,12 @@ msgid "" "more details, see :c:func:`PyUnicode_InternFromString`, which may be used " "internally to create a key object." msgstr "" +"この関数に渡す属性名の種類は少数にとどめるべきです。\n" +"通常は、静的に割り当てた文字列を *attr_name* に使うことでそうします。\n" +"コンパイル時に分からない属性名には、:c:func:`PyUnicode_FromString` と :c:" +"func:`PyObject_SetAttr` を直接呼び出すことを推奨します。\n" +"詳細は、キーオブジェクトを作成するために内部で使われる可能性のある :c:func:" +"`PyUnicode_InternFromString` を参照してください。" #: ../../c-api/object.rst:264 msgid "" @@ -426,14 +465,15 @@ msgstr "" "オブジェクト *o* の *attr_name* という名の属性を削除します。失敗すると " "``-1`` を返します。この関数は Python の文 ``del o.attr_name`` と同じです。" -#: ../../c-api/object.rst:282 msgid "" "This is the same as :c:func:`PyObject_DelAttr`, but *attr_name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_DelAttr` と同じですが、*attr_name* は :c:expr:`PyObject*` " +"ではなく、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で" +"指定します。" -#: ../../c-api/object.rst:286 msgid "" "The number of different attribute names passed to this function should be " "kept small, usually by using a statically allocated string as *attr_name*. " @@ -442,6 +482,12 @@ msgid "" "more details, see :c:func:`PyUnicode_InternFromString`, which may be used " "internally to create a key object for lookup." msgstr "" +"この関数に渡す属性名の種類は少数にとどめるべきです。\n" +"通常は、静的に割り当てた文字列を *attr_name* に使うことでそうします。\n" +"コンパイル時に分からない属性名には、:c:func:`PyUnicode_FromString` と :c:" +"func:`PyObject_DelAttr` を直接呼び出すことを推奨します。\n" +"詳細は、検索用のキーオブジェクトを作成するために内部で使われる可能性のある :" +"c:func:`PyUnicode_InternFromString` を参照してください。" #: ../../c-api/object.rst:297 msgid "" @@ -451,7 +497,6 @@ msgstr "" "``__dict__`` デスクリプタの getter の総称的な実装です。必要な場合は、辞書を作" "成します。" -#: ../../c-api/object.rst:300 msgid "" "This function may also be called to get the :py:attr:`~object.__dict__` of " "the object *o*. Pass ``NULL`` for *context* when calling it. Since this " @@ -459,10 +504,15 @@ msgid "" "efficient to call :c:func:`PyObject_GetAttr` when accessing an attribute on " "the object." msgstr "" +"オブジェクト *o* の :py:attr:`~object.__dict__` を取得するためにこの関数を呼" +"び出すこともできます。\n" +"その場合は *context* に ``NULL`` を渡してください。\n" +"この関数は辞書のメモリを割り当てる必要がある場合があるため、オブジェクトの属" +"性にアクセスするなら :c:func:`PyObject_GetAttr` の方が効率的なことがありま" +"す。" -#: ../../c-api/object.rst:306 msgid "On failure, returns ``NULL`` with an exception set." -msgstr "" +msgstr "失敗すると例外を設定して ``NULL`` を返します。" #: ../../c-api/object.rst:313 msgid "" @@ -472,20 +522,22 @@ msgstr "" "``__dict__`` デスクリプタの setter の総称的な実装です。この実装では辞書を削除" "することは許されていません。" -#: ../../c-api/object.rst:321 msgid "" "Return a pointer to :py:attr:`~object.__dict__` of the object *obj*. If " "there is no ``__dict__``, return ``NULL`` without setting an exception." msgstr "" +"オブジェクト *obj* の :py:attr:`~object.__dict__` へのポインタを返します。\n" +"``__dict__`` がない場合は、例外を設定せずに ``NULL`` を返します。" -#: ../../c-api/object.rst:324 msgid "" "This function may need to allocate memory for the dictionary, so it may be " "more efficient to call :c:func:`PyObject_GetAttr` when accessing an " "attribute on the object." msgstr "" +"この関数は辞書のメモリを割り当てる必要がある場合があるため、オブジェクトの属" +"性にアクセスするなら :c:func:`PyObject_GetAttr` の方が効率的なことがありま" +"す。" -#: ../../c-api/object.rst:331 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "which must be one of :c:macro:`Py_LT`, :c:macro:`Py_LE`, :c:macro:`Py_EQ`, :" @@ -495,32 +547,46 @@ msgid "" "operator corresponding to *opid*. Returns the value of the comparison on " "success, or ``NULL`` on failure." msgstr "" +"*opid* で指定された演算を使って *o1* と *o2* の値を比較します。\n" +"*opid* は :c:macro:`Py_LT`、:c:macro:`Py_LE`、:c:macro:`Py_EQ`、:c:macro:" +"`Py_NE`、:c:macro:`Py_GT`、:c:macro:`Py_GE` のいずれかで、それぞれ ``<``、" +"``<=``、``==``、``!=``、``>``、``>=`` に対応します。\n" +"これは、``op`` を *opid* に対応する演算子とした Python の式 ``o1 op o2`` と同" +"等です。\n" +"成功すると比較の結果を返し、失敗すると ``NULL`` を返します。" -#: ../../c-api/object.rst:341 msgid "" "Compare the values of *o1* and *o2* using the operation specified by *opid*, " "like :c:func:`PyObject_RichCompare`, but returns ``-1`` on error, ``0`` if " "the result is false, ``1`` otherwise." msgstr "" +":c:func:`PyObject_RichCompare` と同様に、*opid* で指定された演算を使って " +"*o1* と *o2* の値を比較します。\n" +"ただし、エラー時は ``-1``、結果が偽なら ``0``、それ以外は ``1`` を返します。" -#: ../../c-api/object.rst:346 msgid "" "If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool` " "will always return ``1`` for :c:macro:`Py_EQ` and ``0`` for :c:macro:`Py_NE`." msgstr "" +"*o1* と *o2* が同じオブジェクトの場合、:c:func:`PyObject_RichCompareBool` " +"は :c:macro:`Py_EQ` に対して常に ``1``、:c:macro:`Py_NE` に対して常に ``0`` " +"を返します。" -#: ../../c-api/object.rst:351 msgid "" "Format *obj* using *format_spec*. This is equivalent to the Python " "expression ``format(obj, format_spec)``." msgstr "" +"*format_spec* を使って *obj* を書式化します。\n" +"Python の式 ``format(obj, format_spec)`` と同等です。" -#: ../../c-api/object.rst:354 msgid "" "*format_spec* may be ``NULL``. In this case the call is equivalent to " "``format(obj)``. Returns the formatted string on success, ``NULL`` on " "failure." msgstr "" +"*format_spec* は ``NULL`` にできます。\n" +"その場合は ``format(obj)`` と同等です。\n" +"成功すると書式化された文字列を返し、失敗すると ``NULL`` を返します。" #: ../../c-api/object.rst:362 msgid "" @@ -533,10 +599,8 @@ msgstr "" "ると ``NULL`` を返します。 Python 式 ``repr(o)`` と同じです。この関数は組み込" "み関数 :func:`repr` の処理で呼び出されます。" -#: ../../c-api/object.rst:366 ../../c-api/object.rst:382 -#: ../../c-api/object.rst:394 msgid "If argument is ``NULL``, return the string ``''``." -msgstr "" +msgstr "引数が ``NULL`` の場合は文字列 ``''`` を返します。" #: ../../c-api/object.rst:368 ../../c-api/object.rst:396 msgid "" @@ -584,10 +648,11 @@ msgstr "" "``bytes(o)`` と同じです。 ``bytes(o)`` と違って、 *o* が整数のときには、ゼロ" "で初期化された bytes オブジェクトを返すのではなく TypeError が送出されます。" -#: ../../c-api/object.rst:411 msgid "" "If argument is ``NULL``, return the :class:`bytes` object ``b''``." msgstr "" +"引数が ``NULL`` の場合は :class:`bytes` オブジェクト ``b''`` を返しま" +"す。" #: ../../c-api/object.rst:416 msgid "" @@ -616,12 +681,15 @@ msgid "" "e. contained in :attr:`cls.__mro__ `." msgstr "" -#: ../../c-api/object.rst:428 msgid "" "Normally only class objects, i.e. instances of :class:`type` or a derived " "class, are considered classes. However, objects can override this by having " "a :attr:`~type.__bases__` attribute (which must be a tuple of base classes)." msgstr "" +"通常はクラスオブジェクト、つまり :class:`type` またはその派生クラスのインスタ" +"ンスだけがクラスとみなされます。\n" +"ただし、オブジェクトに :attr:`~type.__bases__` 属性 (基底クラスのタプルでなけ" +"ればなりません) を持たせることで、この判定を変えられます。" #: ../../c-api/object.rst:435 msgid "" @@ -632,25 +700,31 @@ msgstr "" "``1`` を返し、そうでない場合に ``0`` を返します。\n" "エラーが起きると ``-1`` を返し例外を設定します。" -#: ../../c-api/object.rst:442 msgid "" "If *cls* has a :meth:`~type.__instancecheck__` method, it will be called to " "determine the subclass status as described in :pep:`3119`. Otherwise, " "*inst* is an instance of *cls* if its class is a subclass of *cls*." msgstr "" +"*cls* に :meth:`~type.__instancecheck__` メソッドがある場合、:pep:`3119` に" +"従って判定するためにこのメソッドが呼び出されます。\n" +"そうでなければ、*inst* のクラスが *cls* のサブクラスである場合に、*inst* は " +"*cls* のインスタンスとみなされます。" -#: ../../c-api/object.rst:446 msgid "" "An instance *inst* can override what is considered its class by having a :" "attr:`~object.__class__` attribute." msgstr "" +"インスタンス *inst* は :attr:`~object.__class__` 属性を持つことで、自分のクラ" +"スとみなされるものを変更できます。" -#: ../../c-api/object.rst:449 msgid "" "An object *cls* can override if it is considered a class, and what its base " "classes are, by having a :attr:`~type.__bases__` attribute (which must be a " "tuple of base classes)." msgstr "" +"オブジェクト *cls* は :attr:`~type.__bases__` 属性 (基底クラスのタプルでなけ" +"ればなりません) を持つことで、クラスとみなされるかどうか、および基底クラスを" +"変更できます。" #: ../../c-api/object.rst:458 msgid "" @@ -668,13 +742,16 @@ msgstr "" "返り値の型が Py_hash_t になりました。この型は、 :c:type:`Py_ssize_t` と同じサ" "イズをもつ符号付き整数です。" -#: ../../c-api/object.rst:468 msgid "" "Set a :exc:`TypeError` indicating that ``type(o)`` is not :term:`hashable` " "and return ``-1``. This function receives special treatment when stored in a " "``tp_hash`` slot, allowing a type to explicitly indicate to the interpreter " "that it is not hashable." msgstr "" +"``type(o)`` が :term:`ハッシュ可能 ` でないことを示す :exc:" +"`TypeError` を設定し、``-1`` を返します。\n" +"この関数を ``tp_hash`` スロットに設定すると特別に扱われ、ハッシュ可能でないこ" +"とを型からインタープリタに明示できます。" #: ../../c-api/object.rst:476 msgid "" @@ -694,7 +771,6 @@ msgstr "" "*o* が真を表すとみなせる場合には ``0`` を、そうでないときには ``1`` を返しま" "す。 Python の式 ``not o`` と同じです。失敗すると ``-1`` を返します。" -#: ../../c-api/object.rst:492 msgid "" "When *o* is non-``NULL``, returns a type object corresponding to the object " "type of object *o*. On failure, raises :exc:`SystemError` and returns " @@ -704,12 +780,22 @@ msgid "" "function, which returns a pointer of type :c:expr:`PyTypeObject*`, except " "when a new :term:`strong reference` is needed." msgstr "" +"*o* が ``NULL`` でない場合、オブジェクト *o* の型に対応する型オブジェクトを返" +"します。\n" +"失敗すると :exc:`SystemError` を送出して ``NULL`` を返します。\n" +"Python の式 ``type(o)`` と同等です。\n" +"この関数は戻り値への新しい :term:`強参照 ` を作成します。\n" +"新しい :term:`強参照 ` が必要な場合を除き、:c:expr:" +"`PyTypeObject*` 型のポインタを返す :c:func:`Py_TYPE()` 関数の代わりにこの関数" +"を使う理由はありません。" -#: ../../c-api/object.rst:504 msgid "" "Return non-zero if the object *o* is of type *type* or a subtype of *type*, " "and ``0`` otherwise. Both parameters must be non-``NULL``." msgstr "" +"オブジェクト *o* の型が *type* またはそのサブタイプであればゼロ以外、そうでな" +"ければ ``0`` を返します。\n" +"どちらの引数も ``NULL`` であってはいけません。" #: ../../c-api/object.rst:513 msgid "" @@ -722,7 +808,6 @@ msgstr "" "型プロトコルの両方を提供している場合、シーケンスとしての長さを返します。エ" "ラーが生じると ``-1`` を返します。 Python の式 ``len(o)`` と同じです。" -#: ../../c-api/object.rst:520 msgid "" "Return an estimated length for the object *o*. First try to return its " "actual length, then an estimate using :meth:`~object.__length_hint__`, and " @@ -730,10 +815,11 @@ msgid "" "equivalent to the Python expression ``operator.length_hint(o, " "defaultvalue)``." msgstr "" -"オブジェクト *o* の概算の長さを返します。\n" -"最初に実際の長さを、次に :meth:`~object.__length_hint__` を使って概算の長さ" -"を、そして最後にデフォルトの値を返そうとします。\n" -"この関数は Python の式 ``operator.length_hint(o, defaultvalue)`` と同じです。" +"オブジェクト *o* の推定の長さを返します。\n" +"まず実際の長さを返すことを試み、次に :meth:`~object.__length_hint__` による推" +"定値を試み、最後にデフォルト値を返します。\n" +"エラー時は ``-1`` を返します。\n" +"Python の式 ``operator.length_hint(o, defaultvalue)`` と同等です。" #: ../../c-api/object.rst:530 msgid "" @@ -762,14 +848,15 @@ msgstr "" "オブジェクト *o* から *key* に関する対応付けを削除します。失敗すると ``-1`` " "を返します。Python の文 ``del o[key]`` と同じです。" -#: ../../c-api/object.rst:550 msgid "" "This is the same as :c:func:`PyObject_DelItem`, but *key* is specified as a :" "c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PyObject_DelItem` と同じですが、*key* は :c:expr:`PyObject*` ではな" +"く、UTF-8 でエンコードされたバイト文字列を指す :c:expr:`const char*` で指定し" +"ます。" -#: ../../c-api/object.rst:557 msgid "" "This is equivalent to the Python expression ``dir(o)``, returning a " "(possibly empty) list of strings appropriate for the object argument, or " @@ -778,11 +865,13 @@ msgid "" "case, if no execution frame is active then ``NULL`` is returned but :c:func:" "`PyErr_Occurred` will return false." msgstr "" -"この関数は Python の式 ``dir(o)`` と同じで、オブジェクトの変数名に割り当てて" -"いる文字列からなるリスト (空の場合もあります) を返します。エラーの場合には " -"``NULL`` を返します。引数を ``NULL`` にすると、Python における ``dir()`` と同" -"様に、現在のローカルな名前を返します; この場合、アクティブな実行フレームがな" -"ければ ``NULL`` を返しますが、 :c:func:`PyErr_Occurred` は偽を返します。" +"Python の式 ``dir(o)`` と同等で、引数のオブジェクトに応じた名前の文字列のリス" +"ト (空の場合もあります) を返します。\n" +"エラー時は ``NULL`` を返します。\n" +"引数が ``NULL`` の場合は Python の ``dir()`` と同様に、現在のローカルな名前を" +"返します。\n" +"この場合、アクティブな実行フレームがなければ ``NULL`` を返しますが、:c:func:" +"`PyErr_Occurred` は偽を返します。" #: ../../c-api/object.rst:566 msgid "" @@ -796,14 +885,15 @@ msgstr "" "す。オブジェクトが反復処理不可能であった場合には :exc:`TypeError` を送出して " "``NULL`` を返します。" -#: ../../c-api/object.rst:574 msgid "" "This is equivalent to the Python ``__iter__(self): return self`` method. It " "is intended for :term:`iterator` types, to be used in the :c:member:" "`PyTypeObject.tp_iter` slot." msgstr "" +"Python の ``__iter__(self): return self`` メソッドと同等です。\n" +":term:`イテレータ ` 型の :c:member:`PyTypeObject.tp_iter` スロット" +"に使うことを想定しています。" -#: ../../c-api/object.rst:580 msgid "" "This is the equivalent to the Python expression ``aiter(o)``. Takes an :" "class:`AsyncIterable` object and returns an :class:`AsyncIterator` for it. " @@ -811,78 +901,91 @@ msgid "" "`AsyncIterator`, this returns itself. Raises :exc:`TypeError` and returns " "``NULL`` if the object cannot be iterated." msgstr "" +"Python の式 ``aiter(o)`` と同等です。\n" +":class:`AsyncIterable` オブジェクトを受け取り、それに対する :class:" +"`AsyncIterator` を返します。\n" +"通常は新しいイテレータですが、引数が :class:`AsyncIterator` の場合はそれ自身" +"を返します。\n" +"オブジェクトを反復処理できない場合は :exc:`TypeError` を送出して ``NULL`` を" +"返します。" -#: ../../c-api/object.rst:590 msgid "Get a pointer to subclass-specific data reserved for *cls*." -msgstr "" +msgstr "*cls* 用に確保されたサブクラス固有のデータへのポインタを取得します。" -#: ../../c-api/object.rst:592 msgid "" "The object *o* must be an instance of *cls*, and *cls* must have been " "created using negative :c:member:`PyType_Spec.basicsize`. Python does not " "check this." msgstr "" +"オブジェクト *o* は *cls* のインスタンスでなければならず、*cls* は負の :c:" +"member:`PyType_Spec.basicsize` を使って作成されていなければなりません。\n" +"Python はこれを検証しません。" -#: ../../c-api/object.rst:596 msgid "On error, set an exception and return ``NULL``." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/object.rst:602 msgid "" "Return the size of the instance memory space reserved for *cls*, i.e. the " "size of the memory :c:func:`PyObject_GetTypeData` returns." msgstr "" +"*cls* 用に確保されたインスタンスのメモリ領域のサイズ、つまり :c:func:" +"`PyObject_GetTypeData` が返すメモリのサイズを返します。" -#: ../../c-api/object.rst:605 msgid "" "This may be larger than requested using :c:member:`-PyType_Spec.basicsize " "`; it is safe to use this larger size (e.g. with :c:" "func:`!memset`)." msgstr "" +"このサイズは :c:member:`-PyType_Spec.basicsize ` で要" +"求したサイズより大きい場合があります。\n" +"その大きいサイズを使っても安全です (例えば :c:func:`!memset` で使えます)。" -#: ../../c-api/object.rst:608 msgid "" "The type *cls* **must** have been created using negative :c:member:" "`PyType_Spec.basicsize`. Python does not check this." msgstr "" +"型 *cls* は負の :c:member:`PyType_Spec.basicsize` を使って作成されて **いなけ" +"ればなりません**。\n" +"Python はこれを検証しません。" -#: ../../c-api/object.rst:612 msgid "On error, set an exception and return a negative value." -msgstr "" +msgstr "エラー時は例外を設定して負の値を返します。" -#: ../../c-api/object.rst:618 msgid "" "Get a pointer to per-item data for a class with :c:macro:" "`Py_TPFLAGS_ITEMS_AT_END`." msgstr "" +":c:macro:`Py_TPFLAGS_ITEMS_AT_END` が設定されたクラスの、要素ごとのデータへの" +"ポインタを取得します。" -#: ../../c-api/object.rst:621 msgid "" "On error, set an exception and return ``NULL``. :py:exc:`TypeError` is " "raised if *o* does not have :c:macro:`Py_TPFLAGS_ITEMS_AT_END` set." msgstr "" +"エラー時は例外を設定して ``NULL`` を返します。\n" +"*o* に :c:macro:`Py_TPFLAGS_ITEMS_AT_END` が設定されていない場合は :py:exc:" +"`TypeError` を送出します。" -#: ../../c-api/object.rst:629 msgid "Visit the managed dictionary of *obj*." -msgstr "" +msgstr "*obj* のマネージド辞書を巡回します。" -#: ../../c-api/object.rst:631 msgid "" "This function must only be called in a traverse function of the type which " "has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" +"この関数は :c:macro:`Py_TPFLAGS_MANAGED_DICT` フラグが設定された型の巡回関数" +"内でのみ呼び出さなければなりません。" -#: ../../c-api/object.rst:638 msgid "Clear the managed dictionary of *obj*." -msgstr "" +msgstr "*obj* のマネージド辞書をクリアします。" -#: ../../c-api/object.rst:640 msgid "" "This function must only be called in a clear function of the type which has " "the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set." msgstr "" +"この関数は :c:macro:`Py_TPFLAGS_MANAGED_DICT` フラグが設定された型のクリア関" +"数内でのみ呼び出さなければなりません。" -#: ../../c-api/object.rst:647 msgid "" "Enable `deferred reference counting `_ on *obj*, if supported by the runtime. In " @@ -892,8 +995,14 @@ msgid "" "deallocated by the tracing garbage collector, and not when the interpreter " "no longer has any references to it." msgstr "" +"ランタイムが対応していれば、*obj* の `遅延参照カウント `_ を有効にします。\n" +":term:`フリースレッド ` ビルドでは、インタープリタが *obj* の" +"参照カウントの更新を省略できるため、マルチスレッドの性能が向上する可能性があ" +"ります。\n" +"その代わり、*obj* はインタープリタからの参照がなくなった時点では解放されず、" +"トレーシングガベージコレクタによってのみ解放されるようになります。" -#: ../../c-api/object.rst:654 msgid "" "This function returns ``1`` if deferred reference counting is enabled on " "*obj*, and ``0`` if deferred reference counting is not supported or if the " @@ -901,31 +1010,41 @@ msgid "" "counting is already enabled on *obj*. This function is thread-safe, and " "cannot fail." msgstr "" +"*obj* の遅延参照カウントが有効になった場合は ``1`` を返します。\n" +"遅延参照カウントがサポートされていない場合や、すでに *obj* で有効になっている" +"場合など、インタープリタがヒントを無視した場合は ``0`` を返します。\n" +"この関数はスレッドセーフで、失敗しません。" -#: ../../c-api/object.rst:659 msgid "" "This function does nothing on builds with the :term:`GIL` enabled, which do " "not support deferred reference counting. This also does nothing if *obj* is " "not an object tracked by the garbage collector (see :func:`gc.is_tracked` " "and :c:func:`PyObject_GC_IsTracked`)." msgstr "" +":term:`GIL` が有効なビルドは遅延参照カウントをサポートしないため、この関数は" +"何もしません。\n" +"*obj* がガベージコレクタの追跡対象でない場合も何もしません (:func:`gc." +"is_tracked` と :c:func:`PyObject_GC_IsTracked` を参照)。" -#: ../../c-api/object.rst:664 msgid "" "This function is intended to be used soon after *obj* is created, by the " "code that creates it, such as in the object's :c:member:`~PyTypeObject." "tp_new` slot." msgstr "" +"この関数は、オブジェクトを作成するコード (例えば :c:member:`~PyTypeObject." +"tp_new` スロット) から、*obj* を作成した直後に呼び出すことを想定しています。" -#: ../../c-api/object.rst:672 msgid "" "Check if *obj* is a unique temporary object. Returns ``1`` if *obj* is known " "to be a unique temporary object, and ``0`` otherwise. This function cannot " "fail, but the check is conservative, and may return ``0`` in some cases even " "if *obj* is a unique temporary object." msgstr "" +"*obj* が唯一の参照を持つ一時オブジェクトかどうかを調べます。\n" +"そうであると分かる場合は ``1``、それ以外の場合は ``0`` を返します。\n" +"この関数は失敗しませんが、判定は保守的なので、実際に唯一の参照を持つ一時オブ" +"ジェクトでも ``0`` を返すことがあります。" -#: ../../c-api/object.rst:678 msgid "" "If an object is a unique temporary, it is guaranteed that the current code " "has the only reference to the object. For arguments to C functions, this " @@ -936,66 +1055,83 @@ msgid "" "a reference count of ``1`` by itself does not guarantee that a function " "argument uniquely referenced." msgstr "" +"オブジェクトが唯一の参照を持つ一時オブジェクトであれば、現在のコードがそのオ" +"ブジェクトへの唯一の参照を持つことが保証されます。\n" +"C 関数の引数については、参照カウントが ``1`` かどうかを調べる代わりにこの関数" +"を使うべきです。\n" +"Python 3.14 以降、インタープリタはオペランドスタックにオブジェクトを読み込む" +"とき、可能であれば参照を :term:`借用 ` して一部の参照カウ" +"ントの変更を省略します。\n" +"このため、参照カウントが ``1`` というだけでは、関数の引数への参照が唯一である" +"ことは保証されません。" -#: ../../c-api/object.rst:687 msgid "" "In the example below, ``my_func`` is called with a unique temporary object " "as its argument::" msgstr "" +"次の例では、``my_func`` に渡される引数は唯一の参照を持つ一時オブジェクトで" +"す。 ::" -#: ../../c-api/object.rst:690 msgid "my_func([1, 2, 3])" -msgstr "" +msgstr "my_func([1, 2, 3])" -#: ../../c-api/object.rst:692 msgid "" "In the example below, ``my_func`` is **not** called with a unique temporary " "object as its argument, even if its refcount is ``1``::" msgstr "" +"次の例では、参照カウントが ``1`` であっても、``my_func`` に渡される引数は唯一" +"の参照を持つ一時オブジェクトでは **ありません**。 ::" -#: ../../c-api/object.rst:695 msgid "" "my_list = [1, 2, 3]\n" "my_func(my_list)" msgstr "" +"my_list = [1, 2, 3]\n" +"my_func(my_list)" -#: ../../c-api/object.rst:698 msgid "See also the function :c:func:`Py_REFCNT`." -msgstr "" +msgstr ":c:func:`Py_REFCNT` 関数も参照してください。" -#: ../../c-api/object.rst:704 msgid "" "This function returns non-zero if *obj* is :term:`immortal`, and zero " "otherwise. This function cannot fail." msgstr "" +"*obj* が :term:`不死 ` の場合はゼロ以外、そうでなければゼロを返しま" +"す。\n" +"この関数は失敗しません。" -#: ../../c-api/object.rst:709 msgid "" "Objects that are immortal in one CPython version are not guaranteed to be " "immortal in another." msgstr "" +"ある CPython バージョンで不死のオブジェクトが、別のバージョンでも不死であると" +"は限りません。" -#: ../../c-api/object.rst:716 msgid "" "Increments the reference count of *obj* if it is not zero. Returns ``1`` if " "the object's reference count was successfully incremented. Otherwise, this " "function returns ``0``." msgstr "" +"*obj* の参照カウントがゼロでなければ、参照カウントを増やします。\n" +"増やすことに成功した場合は ``1``、それ以外の場合は ``0`` を返します。" -#: ../../c-api/object.rst:720 msgid "" ":c:func:`PyUnstable_EnableTryIncRef` must have been called earlier on *obj* " "or this function may spuriously return ``0`` in the :term:`free-threaded " "build`." msgstr "" +"*obj* に対してあらかじめ :c:func:`PyUnstable_EnableTryIncRef` を呼び出してお" +"く必要があります。\n" +"そうしなければ、:term:`フリースレッドビルド ` では誤っ" +"て ``0`` を返す場合があります。" -#: ../../c-api/object.rst:724 msgid "" "This function is logically equivalent to the following C code, except that " "it behaves atomically in the :term:`free-threaded build`::" msgstr "" +"この関数は論理的には次の C コードと同等ですが、:term:`フリースレッドビルド " +"` ではアトミックに動作します。 ::" -#: ../../c-api/object.rst:727 msgid "" "if (Py_REFCNT(op) > 0) {\n" " Py_INCREF(op);\n" @@ -1003,22 +1139,30 @@ msgid "" "}\n" "return 0;" msgstr "" +"if (Py_REFCNT(op) > 0) {\n" +" Py_INCREF(op);\n" +" return 1;\n" +"}\n" +"return 0;" -#: ../../c-api/object.rst:733 msgid "" "This is intended as a building block for managing weak references without " "the overhead of a Python :ref:`weak reference object `." msgstr "" +"これは、Python の :ref:`弱参照オブジェクト ` のオーバーヘッド" +"なしで弱参照を管理するための基礎として使うことを想定しています。" -#: ../../c-api/object.rst:736 msgid "" "Typically, correct use of this function requires support from *obj*'s " "deallocator (:c:member:`~PyTypeObject.tp_dealloc`). For example, the " "following sketch could be adapted to implement a \"weakmap\" that works like " "a :py:class:`~weakref.WeakValueDictionary` for a specific type:" msgstr "" +"通常、この関数を正しく使うには *obj* の解放関数 (:c:member:`~PyTypeObject." +"tp_dealloc`) によるサポートが必要です。\n" +"例えば、次の概略コードを応用すると、特定の型に対して :py:class:`~weakref." +"WeakValueDictionary` のように動作する「weakmap」を実装できます。" -#: ../../c-api/object.rst:742 msgid "" "PyMutex mutex;\n" "\n" @@ -1062,61 +1206,125 @@ msgid "" " PyMutex_Unlock(&mutex);\n" "}" msgstr "" +"PyMutex mutex;\n" +"\n" +"PyObject *\n" +"add_entry(weakmap_key_type *key, PyObject *value)\n" +"{\n" +" PyUnstable_EnableTryIncRef(value);\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" weakmap_add_entry(weakmap, key, value);\n" +" PyMutex_Unlock(&mutex);\n" +" Py_RETURN_NONE;\n" +"}\n" +"\n" +"PyObject *\n" +"get_value(weakmap_key_type *key)\n" +"{\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" PyObject *result = weakmap_find(weakmap, key);\n" +" if (PyUnstable_TryIncRef(result)) {\n" +" // `result` は安全に使える\n" +" PyMutex_Unlock(&mutex);\n" +" return result;\n" +" }\n" +" // ここに到達した場合、`result` のガベージコレクションが始まっている" +"が、\n" +" // まだ weakmap からは削除されていない\n" +" PyMutex_Unlock(&mutex);\n" +" return NULL;\n" +"}\n" +"\n" +"// weakmap の値の tp_dealloc 関数\n" +"void\n" +"value_dealloc(PyObject *value)\n" +"{\n" +" weakmap_type weakmap = ...;\n" +" PyMutex_Lock(&mutex);\n" +" weakmap_remove_value(weakmap, value);\n" +"\n" +" ...\n" +" PyMutex_Unlock(&mutex);\n" +"}" -#: ../../c-api/object.rst:790 msgid "" "Enables subsequent uses of :c:func:`PyUnstable_TryIncRef` on *obj*. The " "caller must hold a :term:`strong reference` to *obj* when calling this." msgstr "" +"*obj* に対して後で :c:func:`PyUnstable_TryIncRef` を使えるようにします。\n" +"呼び出し時に、呼び出し側は *obj* への :term:`強参照 ` を保" +"持していなければなりません。" -#: ../../c-api/object.rst:797 msgid "Determine if *op* only has one reference." -msgstr "" +msgstr "*op* への参照が 1 つだけかどうかを調べます。" -#: ../../c-api/object.rst:799 msgid "" "On GIL-enabled builds, this function is equivalent to :c:expr:`Py_REFCNT(op) " "== 1`." msgstr "" +"GIL が有効なビルドでは、この関数は :c:expr:`Py_REFCNT(op) == 1` と同等です。" -#: ../../c-api/object.rst:802 msgid "" "On a :term:`free-threaded build`, this checks if *op*'s :term:`reference " "count` is equal to one and additionally checks if *op* is only used by this " "thread. :c:expr:`Py_REFCNT(op) == 1` is **not** thread-safe on free-threaded " "builds; prefer this function." msgstr "" +":term:`フリースレッドビルド ` では、*op* の :term:`参照" +"カウント ` が 1 かどうかに加えて、*op* がこのスレッドだけで" +"使われているかどうかも調べます。\n" +":c:expr:`Py_REFCNT(op) == 1` はフリースレッドビルドではスレッドセーフでは **" +"ありません**。\n" +"代わりにこの関数を使うことを推奨します。" -#: ../../c-api/object.rst:807 msgid "" "The caller must hold an :term:`attached thread state`, despite the fact that " "this function doesn't call into the Python interpreter. This function cannot " "fail." msgstr "" +"この関数は Python インタープリタを呼び出しませんが、呼び出し側は :term:`ア" +"タッチされたスレッド状態 ` を保持していなければなりま" +"せん。\n" +"この関数は失敗しません。" -#: ../../c-api/object.rst:815 msgid "" "Marks the object *op* :term:`immortal`. The argument should be uniquely " "referenced by the calling thread. This is intended to be used for reducing " "reference counting contention in the :term:`free-threaded build` for objects " "which are shared across threads." msgstr "" +"オブジェクト *op* を :term:`不死 ` にします。\n" +"引数のオブジェクトへの参照は、呼び出し元スレッドが唯一の参照として保持してい" +"る必要があります。\n" +"これは :term:`フリースレッドビルド ` で、スレッド間で共" +"有するオブジェクトの参照カウントを巡る競合を減らすために使うことを想定してい" +"ます。" -#: ../../c-api/object.rst:819 msgid "" "This is a one-way process: objects can only be made immortal; they cannot be " "made mortal once again. Immortal objects do not participate in reference " "counting and will never be garbage collected. If the object is GC-tracked, " "it is untracked." msgstr "" +"この処理は一方向です。\n" +"オブジェクトを不死にすることはできますが、再び有限の寿命を持つようには戻せま" +"せん。\n" +"不死のオブジェクトは参照カウントの対象にならず、ガベージコレクションで回収さ" +"れることもありません。\n" +"GC の追跡対象になっている場合は、追跡対象から外されます。" -#: ../../c-api/object.rst:823 msgid "" "This function is intended to be used soon after *op* is created, by the code " "that creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` " "slot. Returns 1 if the object was made immortal and returns 0 if it was not. " "This function cannot fail." msgstr "" +"この関数は、オブジェクトを作成するコード (例えば :c:member:`~PyTypeObject." +"tp_new` スロット) から、*op* を作成した直後に呼び出すことを想定しています。\n" +"オブジェクトが不死になった場合は 1、ならなかった場合は 0 を返します。\n" +"この関数は失敗しません。" #: ../../c-api/object.rst:360 ../../c-api/object.rst:374 #: ../../c-api/object.rst:403 ../../c-api/object.rst:456 diff --git a/c-api/objimpl.po b/c-api/objimpl.po index 6dfd9a221..488e1f0c7 100644 --- a/c-api/objimpl.po +++ b/c-api/objimpl.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/objimpl.rst:7 diff --git a/c-api/perfmaps.po b/c-api/perfmaps.po index 37c1f9e4d..0b8f20095 100644 --- a/c-api/perfmaps.po +++ b/c-api/perfmaps.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/perfmaps.rst:6 msgid "Support for Perf Maps" -msgstr "" +msgstr "perf map のサポート" -#: ../../c-api/perfmaps.rst:8 msgid "" "On supported platforms (Linux and macOS), the runtime can take advantage of " "*perf map files* to make Python functions visible to an external profiling " @@ -38,12 +36,22 @@ msgid "" "kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jit-interface." "txt>`_." msgstr "" +"対応するプラットフォーム (Linux と macOS) では、ランタイムは *perf map ファイ" +"ル* を使って Python 関数を外部のプロファイリングツール (例えば `perf " +"`_ や `samply `_) に認識させることができます。\n" +"実行中のプロセスは ``/tmp`` ディレクトリにファイルを作成でき、そのファイルの" +"エントリーによって実行可能コードの領域と名前を対応づけられます。\n" +"このインターフェースについては `Linux Perf ツールのドキュメント `_ に記載されています。" -#: ../../c-api/perfmaps.rst:17 msgid "" "In Python, these helper APIs can be used by libraries and features that rely " "on generating machine code on the fly." msgstr "" +"Python では、実行中に機械語コードを生成するライブラリや機能が、これらの補助 " +"API を利用できます。" #: ../../c-api/perfmaps.rst:20 msgid "" @@ -51,7 +59,6 @@ msgid "" "APIs." msgstr "" -#: ../../c-api/perfmaps.rst:24 msgid "" "Open the ``/tmp/perf-$pid.map`` file, unless it's already opened, and create " "a lock to ensure thread-safe writes to the file (provided the writes are " @@ -60,46 +67,64 @@ msgid "" "`PyUnstable_WritePerfMapEntry` and it will initialize the state on first " "call." msgstr "" +"``/tmp/perf-$pid.map`` ファイルがまだ開かれていなければ開き、ファイルへの書き" +"込みをスレッドセーフにするためのロックを作成します (:c:func:" +"`PyUnstable_WritePerfMapEntry` を通じて書き込む必要があります)。\n" +"通常、この関数を明示的に呼び出す必要はありません。\n" +":c:func:`PyUnstable_WritePerfMapEntry` を使うだけで、最初の呼び出し時に状態が" +"初期化されます。" -#: ../../c-api/perfmaps.rst:30 msgid "" "Returns ``0`` on success, ``-1`` on failure to create/open the perf map " "file, or ``-2`` on failure to create a lock. Check ``errno`` for more " "information about the cause of a failure." msgstr "" +"成功すると ``0``、perf map ファイルの作成またはオープンに失敗すると ``-1``、" +"ロックの作成に失敗すると ``-2`` を返します。\n" +"失敗の原因の詳細は ``errno`` を確認してください。" -#: ../../c-api/perfmaps.rst:36 msgid "" "Write one single entry to the ``/tmp/perf-$pid.map`` file. This function is " "thread safe. Here is what an example entry looks like::" msgstr "" +"``/tmp/perf-$pid.map`` ファイルにエントリーを 1 つ書き込みます。\n" +"この関数はスレッドセーフです。\n" +"エントリーの例を示します。 ::" -#: ../../c-api/perfmaps.rst:39 msgid "" "# address size name\n" "7f3529fcf759 b py::bar:/run/t.py" msgstr "" +"# アドレス サイズ 名前\n" +"7f3529fcf759 b py::bar:/run/t.py" -#: ../../c-api/perfmaps.rst:42 msgid "" "Will call :c:func:`PyUnstable_PerfMapState_Init` before writing the entry, " "if the perf map file is not already opened. Returns ``0`` on success, or the " "same error codes as :c:func:`PyUnstable_PerfMapState_Init` on failure." msgstr "" +"perf map ファイルがまだ開かれていなければ、エントリーを書き込む前に :c:func:" +"`PyUnstable_PerfMapState_Init` を呼び出します。\n" +"成功すると ``0``、失敗すると :c:func:`PyUnstable_PerfMapState_Init` と同じエ" +"ラーコードを返します。" -#: ../../c-api/perfmaps.rst:48 msgid "" "Close the perf map file opened by :c:func:`PyUnstable_PerfMapState_Init`. " "This is called by the runtime itself during interpreter shut-down. In " "general, there shouldn't be a reason to explicitly call this, except to " "handle specific scenarios such as forking." msgstr "" +":c:func:`PyUnstable_PerfMapState_Init` が開いた perf map ファイルを閉じま" +"す。\n" +"インタープリタの終了時にランタイム自身がこの関数を呼び出します。\n" +"通常、fork などの特定の状況に対処する場合を除き、この関数を明示的に呼び出す必" +"要はありません。" -#: ../../c-api/perfmaps.rst:55 msgid "" "Open the ``/tmp/perf-$pid.map`` file and append the content of " "*parent_filename* to it." msgstr "" +"``/tmp/perf-$pid.map`` ファイルを開き、*parent_filename* の内容を追記します。" #: ../../c-api/perfmaps.rst:58 msgid "" @@ -108,9 +133,10 @@ msgid "" "it does nothing." msgstr "" -#: ../../c-api/perfmaps.rst:65 msgid "Compile the given code object using the current perf trampoline." msgstr "" +"現在の perf トランポリンを使って、指定されたコードオブジェクトをコンパイルし" +"ます。" #: ../../c-api/perfmaps.rst:67 msgid "" @@ -128,9 +154,8 @@ msgstr "" msgid "Parameters" msgstr "パラメーター" -#: ../../c-api/perfmaps.rst:72 msgid "The code object to compile." -msgstr "" +msgstr "コンパイルするコードオブジェクト。" #: ../../c-api/perfmaps.rst:0 msgid "Returns" @@ -140,26 +165,26 @@ msgstr "返り値" msgid "0 on success, -1 on failure." msgstr "" -#: ../../c-api/perfmaps.rst:79 msgid "Set whether the perf trampoline should persist after a fork." -msgstr "" +msgstr "fork 後も perf トランポリンを保持するかどうかを設定します。" -#: ../../c-api/perfmaps.rst:81 msgid "" "If ``enable`` is true (non-zero): perf map file remains open/valid post-" "fork. Child process inherits all existing perf map entries." msgstr "" +"``enable`` が真 (ゼロ以外) の場合、fork 後も perf map ファイルは開かれた有効" +"な状態を保ちます。\n" +"子プロセスは既存のすべての perf map エントリーを引き継ぎます。" -#: ../../c-api/perfmaps.rst:83 msgid "" "If ``enable`` is false (zero): perf map closes post-fork. Child process gets " "empty perf map." msgstr "" +"``enable`` が偽 (ゼロ) の場合、fork 後に perf map を閉じます。\n" +"子プロセスの perf map は空になります。" -#: ../../c-api/perfmaps.rst:86 msgid "Default: false (clears on fork)." -msgstr "" +msgstr "デフォルトは偽です (fork 時に消去します)。" -#: ../../c-api/perfmaps.rst:88 msgid "1 to enable, 0 to disable." -msgstr "" +msgstr "有効にする場合は 1、無効にする場合は 0。" diff --git a/c-api/picklebuffer.po b/c-api/picklebuffer.po index 642997628..994ffb0a1 100644 --- a/c-api/picklebuffer.po +++ b/c-api/picklebuffer.po @@ -16,91 +16,101 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/picklebuffer.rst:9 msgid "Pickle buffer objects" -msgstr "" +msgstr "pickle バッファオブジェクト" -#: ../../c-api/picklebuffer.rst:13 msgid "" "A :class:`pickle.PickleBuffer` object wraps a :ref:`buffer-providing object " "` for out-of-band data transfer with the :mod:`pickle` module." msgstr "" +":class:`pickle.PickleBuffer` オブジェクトは、:mod:`pickle` モジュールで帯域外" +"データ転送を行うために、:ref:`バッファを提供するオブジェクト " +"` を包みます。" -#: ../../c-api/picklebuffer.rst:19 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python pickle buffer " "type. This is the same object as :class:`pickle.PickleBuffer` in the Python " "layer." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の pickle バッファ型を表" +"します。\n" +"Python レベルの :class:`pickle.PickleBuffer` と同じオブジェクトです。" -#: ../../c-api/picklebuffer.rst:25 msgid "" "Return true if *op* is a pickle buffer instance. This function always " "succeeds." msgstr "" +"*op* が pickle バッファのインスタンスなら真を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/picklebuffer.rst:31 msgid "Create a pickle buffer from the object *obj*." -msgstr "" +msgstr "オブジェクト *obj* から pickle バッファを作成します。" -#: ../../c-api/picklebuffer.rst:33 msgid "" "This function will fail if *obj* doesn't support the :ref:`buffer protocol " "`." msgstr "" +"*obj* が :ref:`バッファプロトコル ` をサポートしない場合、この" +"関数は失敗します。" -#: ../../c-api/picklebuffer.rst:35 msgid "" "On success, return a new pickle buffer instance. On failure, set an " "exception and return ``NULL``." msgstr "" +"成功すると、新しい pickle バッファのインスタンスを返します。\n" +"失敗すると、例外を設定して ``NULL`` を返します。" -#: ../../c-api/picklebuffer.rst:38 msgid "Analogous to calling :class:`pickle.PickleBuffer` with *obj* in Python." msgstr "" +"Python で *obj* を引数に :class:`pickle.PickleBuffer` を呼び出すことに相当し" +"ます。" -#: ../../c-api/picklebuffer.rst:43 msgid "" "Get a pointer to the underlying :c:type:`Py_buffer` that the pickle buffer " "wraps." msgstr "" +"pickle バッファが包む、基となる :c:type:`Py_buffer` へのポインタを取得しま" +"す。" -#: ../../c-api/picklebuffer.rst:45 msgid "" "The returned pointer is valid as long as *picklebuf* is alive and has not " "been released. The caller must not modify or free the returned :c:type:" "`Py_buffer`. If the pickle buffer has been released, raise :exc:`ValueError`." msgstr "" +"返されたポインタは、*picklebuf* が生存し、解放されていない限り有効です。\n" +"呼び出し側は、返された :c:type:`Py_buffer` を変更したり解放したりしてはなりま" +"せん。\n" +"pickle バッファが解放済みの場合は :exc:`ValueError` を送出します。" -#: ../../c-api/picklebuffer.rst:49 msgid "" "On success, return a pointer to the buffer view. On failure, set an " "exception and return ``NULL``." msgstr "" +"成功すると、バッファビューへのポインタを返します。\n" +"失敗すると、例外を設定して ``NULL`` を返します。" -#: ../../c-api/picklebuffer.rst:55 msgid "Release the underlying buffer held by the pickle buffer." -msgstr "" +msgstr "pickle バッファが保持する、基となるバッファを解放します。" -#: ../../c-api/picklebuffer.rst:57 msgid "" "Return ``0`` on success. On failure, set an exception and return ``-1``." msgstr "" +"成功すると ``0`` を返します。\n" +"失敗すると、例外を設定して ``-1`` を返します。" -#: ../../c-api/picklebuffer.rst:59 msgid "Analogous to calling :meth:`pickle.PickleBuffer.release` in Python." msgstr "" +"Python で :meth:`pickle.PickleBuffer.release` を呼び出すことに相当します。" #: ../../c-api/picklebuffer.rst:5 msgid "object" msgstr "object" -#: ../../c-api/picklebuffer.rst:5 msgid "PickleBuffer" -msgstr "" +msgstr "PickleBuffer" diff --git a/c-api/profiling.po b/c-api/profiling.po index 9946b2ff3..968d28ba3 100644 --- a/c-api/profiling.po +++ b/c-api/profiling.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/profiling.rst:6 msgid "Profiling and tracing" -msgstr "" +msgstr "プロファイリングとトレース" #: ../../c-api/profiling.rst:8 msgid "" @@ -53,7 +52,6 @@ msgstr "" "ルでき、トレース関数に報告される基本イベント (basic event) は以前のバージョン" "において Python レベルのトレース関数で報告されていたものと同じです。" -#: ../../c-api/profiling.rst:22 msgid "" "The type of the trace function registered using :c:func:`PyEval_SetProfile` " "and :c:func:`PyEval_SetTrace`. The first parameter is the object passed to " @@ -64,6 +62,14 @@ msgid "" "`PyTrace_C_RETURN`, or :c:data:`PyTrace_OPCODE`, and *arg* depends on the " "value of *what*:" msgstr "" +":c:func:`PyEval_SetProfile` と :c:func:`PyEval_SetTrace` で登録するトレース関" +"数の型です。\n" +"第 1 引数は登録関数に ``obj`` として渡したオブジェクト、``frame`` はイベント" +"の対象のフレームオブジェクトです。\n" +"``what`` は定数 :c:data:`PyTrace_CALL`、:c:data:`PyTrace_EXCEPTION`、:c:data:" +"`PyTrace_LINE`、:c:data:`PyTrace_RETURN`、:c:data:`PyTrace_C_CALL`、:c:data:" +"`PyTrace_C_EXCEPTION`、:c:data:`PyTrace_C_RETURN`、:c:data:`PyTrace_OPCODE` " +"のいずれかで、``arg`` は ``what`` の値によって異なります。" #: ../../c-api/profiling.rst:31 msgid "Value of *what*" @@ -73,30 +79,26 @@ msgstr "*what* の値" msgid "Meaning of *arg*" msgstr "*arg* の意味" -#: ../../c-api/profiling.rst:33 msgid ":c:data:`PyTrace_CALL`" -msgstr "" +msgstr ":c:data:`PyTrace_CALL`" #: ../../c-api/profiling.rst:33 ../../c-api/profiling.rst:38 #: ../../c-api/profiling.rst:49 msgid "Always :c:data:`Py_None`." msgstr "常に :c:data:`Py_None` 。" -#: ../../c-api/profiling.rst:35 msgid ":c:data:`PyTrace_EXCEPTION`" -msgstr "" +msgstr ":c:data:`PyTrace_EXCEPTION`" #: ../../c-api/profiling.rst:35 msgid "Exception information as returned by :func:`sys.exc_info`." msgstr ":func:`sys.exc_info` の返す例外情報です。" -#: ../../c-api/profiling.rst:38 msgid ":c:data:`PyTrace_LINE`" -msgstr "" +msgstr ":c:data:`PyTrace_LINE`" -#: ../../c-api/profiling.rst:40 msgid ":c:data:`PyTrace_RETURN`" -msgstr "" +msgstr ":c:data:`PyTrace_RETURN`" #: ../../c-api/profiling.rst:40 msgid "" @@ -105,28 +107,23 @@ msgstr "" "呼び出し側に返される予定の値か、例外によって関数を抜ける場合は ``NULL`` で" "す。" -#: ../../c-api/profiling.rst:43 msgid ":c:data:`PyTrace_C_CALL`" -msgstr "" +msgstr ":c:data:`PyTrace_C_CALL`" #: ../../c-api/profiling.rst:43 ../../c-api/profiling.rst:45 #: ../../c-api/profiling.rst:47 msgid "Function object being called." msgstr "呼び出される関数オブジェクト。" -#: ../../c-api/profiling.rst:45 msgid ":c:data:`PyTrace_C_EXCEPTION`" -msgstr "" +msgstr ":c:data:`PyTrace_C_EXCEPTION`" -#: ../../c-api/profiling.rst:47 msgid ":c:data:`PyTrace_C_RETURN`" -msgstr "" +msgstr ":c:data:`PyTrace_C_RETURN`" -#: ../../c-api/profiling.rst:49 msgid ":c:data:`PyTrace_OPCODE`" -msgstr "" +msgstr ":c:data:`PyTrace_OPCODE`" -#: ../../c-api/profiling.rst:54 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "a new call to a function or method is being reported, or a new entry into a " @@ -134,13 +131,11 @@ msgid "" "is not reported as there is no control transfer to the Python bytecode in " "the corresponding frame." msgstr "" -"関数やメソッドが新たに呼び出されたり、ジェネレータが新たなエントリの処理に" -"入ったことを報告する際の、 :c:type:`Py_tracefunc` の *what* の値です。イテ" -"レータやジェネレータ関数の生成は、対応するフレーム内の Python バイトコードに" -"制御の委譲 (control transfer) が起こらないため報告されないので注意してくださ" -"い。" +"関数やメソッドの新たな呼び出し、またはジェネレータへの新たな進入を報告すると" +"きに、:c:type:`Py_tracefunc` 関数の ``what`` 引数に渡される値です。\n" +"ジェネレータ関数からイテレータを作成する時点では、対応するフレーム内の " +"Python バイトコードに制御が移らないため、このイベントは報告されません。" -#: ../../c-api/profiling.rst:63 msgid "" "The value of the *what* parameter to a :c:type:`Py_tracefunc` function when " "an exception has been raised. The callback function is called with this " @@ -151,14 +146,24 @@ msgid "" "Only trace functions receive these events; they are not needed by the " "profiler." msgstr "" +"例外が送出されたときに :c:type:`Py_tracefunc` 関数の ``what`` 引数に渡される" +"値です。\n" +"バイトコードの処理後に実行中のフレーム内で例外が設定されると、この値を " +"``what`` に指定してコールバックが呼び出されます。\n" +"このため、例外の伝播によって Python のスタックが巻き戻される際には、伝播先の" +"各フレームに戻るたびにコールバックが呼び出されます。\n" +"このイベントを受け取るのはトレース関数だけで、プロファイラには不要です。" -#: ../../c-api/profiling.rst:74 msgid "" "The value passed as the *what* parameter to a :c:type:`Py_tracefunc` " "function (but not a profiling function) when a line-number event is being " "reported. It may be disabled for a frame by setting :attr:`~frame." "f_trace_lines` to *0* on that frame." msgstr "" +"行番号のイベントを報告するときに、:c:type:`Py_tracefunc` 関数 (プロファイリン" +"グ関数を除く) の ``what`` 引数に渡される値です。\n" +"フレームの :attr:`~frame.f_trace_lines` を *0* に設定すると、そのフレームでは" +"無効にできます。" #: ../../c-api/profiling.rst:82 msgid "" @@ -192,15 +197,18 @@ msgstr "" "C関数から戻るときに :c:type:`Py_tracefunc` 関数の *what* 引数として渡す値で" "す。" -#: ../../c-api/profiling.rst:106 msgid "" "The value for the *what* parameter to :c:type:`Py_tracefunc` functions (but " "not profiling functions) when a new opcode is about to be executed. This " "event is not emitted by default: it must be explicitly requested by setting :" "attr:`~frame.f_trace_opcodes` to *1* on the frame." msgstr "" +"新しいオペコードを実行しようとするときに、:c:type:`Py_tracefunc` 関数 (プロ" +"ファイリング関数を除く) の ``what`` 引数に渡される値です。\n" +"このイベントはデフォルトでは発生しません。\n" +"フレームの :attr:`~frame.f_trace_opcodes` を *1* に設定して明示的に要求する必" +"要があります。" -#: ../../c-api/profiling.rst:114 msgid "" "Set the profiler function to *func*. The *obj* parameter is passed to the " "function as its first parameter, and may be any Python object, or ``NULL``. " @@ -209,30 +217,38 @@ msgid "" "it. The profile function is called for all monitored events except :c:data:" "`PyTrace_LINE` :c:data:`PyTrace_OPCODE` and :c:data:`PyTrace_EXCEPTION`." msgstr "" +"プロファイラ関数を ``func`` に設定します。\n" +"``obj`` はその関数の第 1 引数として渡され、任意の Python オブジェクトまたは " +"``NULL`` を指定できます。\n" +"プロファイラ関数が状態を保持する必要がある場合は、スレッドごとに異なる " +"``obj`` を使うと、便利でスレッドセーフな保存先になります。\n" +"プロファイラ関数は :c:data:`PyTrace_LINE`、:c:data:`PyTrace_OPCODE`、:c:data:" +"`PyTrace_EXCEPTION` を除くすべての監視対象イベントについて呼び出されます。" #: ../../c-api/profiling.rst:121 msgid "See also the :func:`sys.setprofile` function." msgstr ":func:`sys.setprofile` 関数も参照してください。" -#: ../../c-api/profiling.rst:123 ../../c-api/profiling.rst:131 -#: ../../c-api/profiling.rst:150 ../../c-api/profiling.rst:158 msgid "The caller must have an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" -#: ../../c-api/profiling.rst:128 msgid "" "Like :c:func:`PyEval_SetProfile` but sets the profile function in all " "running threads belonging to the current interpreter instead of the setting " "it only on the current thread." msgstr "" +":c:func:`PyEval_SetProfile` と同様ですが、現在のスレッドだけでなく、現在のイ" +"ンタープリタに属する実行中のすべてのスレッドにプロファイラ関数を設定します。" -#: ../../c-api/profiling.rst:133 msgid "" "As :c:func:`PyEval_SetProfile`, this function ignores any exceptions raised " "while setting the profile functions in all threads." msgstr "" +":c:func:`PyEval_SetProfile` と同様に、すべてのスレッドにプロファイラ関数を設" +"定する際に発生した例外を無視します。" -#: ../../c-api/profiling.rst:141 msgid "" "Set the tracing function to *func*. This is similar to :c:func:" "`PyEval_SetProfile`, except the tracing function does receive line-number " @@ -242,29 +258,36 @@ msgid "" "`PyTrace_C_EXCEPTION` or :c:data:`PyTrace_C_RETURN` as a value for the " "*what* parameter." msgstr "" +"トレース関数を ``func`` に設定します。\n" +":c:func:`PyEval_SetProfile` と同様ですが、トレース関数は行番号のイベントとオ" +"ペコードごとのイベントを受け取り、C 関数オブジェクトの呼び出しに関連するイベ" +"ントは受け取りません。\n" +":c:func:`PyEval_SetTrace` で登録したトレース関数には、``what`` 引数として :c:" +"data:`PyTrace_C_CALL`、:c:data:`PyTrace_C_EXCEPTION`、:c:data:" +"`PyTrace_C_RETURN` が渡されることはありません。" #: ../../c-api/profiling.rst:148 msgid "See also the :func:`sys.settrace` function." msgstr ":func:`sys.settrace` 関数も参照してください。" -#: ../../c-api/profiling.rst:155 msgid "" "Like :c:func:`PyEval_SetTrace` but sets the tracing function in all running " "threads belonging to the current interpreter instead of the setting it only " "on the current thread." msgstr "" +":c:func:`PyEval_SetTrace` と同様ですが、現在のスレッドだけでなく、現在のイン" +"タープリタに属する実行中のすべてのスレッドにトレース関数を設定します。" -#: ../../c-api/profiling.rst:160 msgid "" "As :c:func:`PyEval_SetTrace`, this function ignores any exceptions raised " "while setting the trace functions in all threads." msgstr "" +":c:func:`PyEval_SetTrace` と同様に、すべてのスレッドにトレース関数を設定する" +"際に発生した例外を無視します。" -#: ../../c-api/profiling.rst:167 msgid "Reference tracing" -msgstr "" +msgstr "参照のトレース" -#: ../../c-api/profiling.rst:174 msgid "" "The type of the trace function registered using :c:func:" "`PyRefTracer_SetTracer`. The first parameter is a Python object that has " @@ -273,20 +296,29 @@ msgid "" "`PyRefTracer_DESTROY`). The **data** argument is the opaque pointer that was " "provided when :c:func:`PyRefTracer_SetTracer` was called." msgstr "" +":c:func:`PyRefTracer_SetTracer` で登録するトレース関数の型です。\n" +"第 1 引数は、作成されたばかりの Python オブジェクト (``event`` が :c:data:" +"`PyRefTracer_CREATE` の場合)、またはこれから破棄されるオブジェクト " +"(``event`` が :c:data:`PyRefTracer_DESTROY` の場合) です。\n" +"``data`` 引数は :c:func:`PyRefTracer_SetTracer` の呼び出し時に渡した不透明な" +"ポインタです。" -#: ../../c-api/profiling.rst:180 msgid "" "If a new tracing function is registered replacing the current one, a call to " "the trace function will be made with the object set to **NULL** and " "**event** set to :c:data:`PyRefTracer_TRACKER_REMOVED`. This will happen " "just before the new function is registered." msgstr "" +"現在のトレース関数を置き換える新しい関数が登録される場合、新しい関数の登録直" +"前に、オブジェクトを ``NULL``、``event`` を :c:data:" +"`PyRefTracer_TRACKER_REMOVED` として現在のトレース関数が呼び出されます。" -#: ../../c-api/profiling.rst:190 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "a Python object has been created." msgstr "" +"Python オブジェクトが作成されたときに、:c:type:`PyRefTracer` 関数の " +"``event`` 引数に渡される値です。" #: ../../c-api/profiling.rst:196 msgid "" @@ -294,13 +326,13 @@ msgid "" "a Python object has been destroyed." msgstr "" -#: ../../c-api/profiling.rst:202 msgid "" "The value for the *event* parameter to :c:type:`PyRefTracer` functions when " "the current tracer is about to be replaced by a new one." msgstr "" +"現在のトレーサが新しいトレーサに置き換えられる直前に、:c:type:`PyRefTracer` " +"関数の ``event`` 引数に渡される値です。" -#: ../../c-api/profiling.rst:210 msgid "" "Register a reference tracer function. The function will be called when a new " "Python object has been created or when an object is going to be destroyed. " @@ -308,31 +340,49 @@ msgid "" "when the tracer function is called. Return ``0`` on success. Set an " "exception and return ``-1`` on error." msgstr "" +"参照トレーサ関数を登録します。\n" +"この関数は、Python オブジェクトが新しく作成されたときと、これから破棄されると" +"きに呼び出されます。\n" +"``data`` を指定する場合は不透明なポインタでなければならず、トレーサ関数の呼び" +"出し時に渡されます。\n" +"成功した場合は ``0`` を返します。\n" +"エラーの場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/profiling.rst:216 msgid "" "Note that tracer functions **must not** create Python objects inside or " "otherwise the call will be re-entrant. The tracer also **must not** clear " "any existing exception or set an exception. A :term:`thread state` will be " "active every time the tracer function is called." msgstr "" +"トレーサ関数の内部では Python オブジェクトを作成しては **いけません**。\n" +"作成すると、トレーサ関数が再入されてしまいます。\n" +"また、既存の例外をクリアしたり、新しい例外を設定したりしては **いけません" +"**。\n" +"トレーサ関数が呼び出されるときは、常に :term:`スレッド状態 ` が" +"有効です。" -#: ../../c-api/profiling.rst:221 ../../c-api/profiling.rst:237 msgid "" "There must be an :term:`attached thread state` when calling this function." msgstr "" +"この関数の呼び出し時には :term:`スレッド状態がアタッチされている ` 必要があります。" -#: ../../c-api/profiling.rst:223 msgid "" "If another tracer function was already registered, the old function will be " "called with **event** set to :c:data:`PyRefTracer_TRACKER_REMOVED` just " "before the new function is registered." msgstr "" +"別のトレーサ関数がすでに登録されている場合、新しい関数の登録直前に、" +"``event`` を :c:data:`PyRefTracer_TRACKER_REMOVED` として古い関数が呼び出され" +"ます。" -#: ../../c-api/profiling.rst:232 msgid "" "Get the registered reference tracer function and the value of the opaque " "data pointer that was registered when :c:func:`PyRefTracer_SetTracer` was " "called. If no tracer was registered this function will return NULL and will " "set the **data** pointer to NULL." msgstr "" +"登録された参照トレーサ関数と、:c:func:`PyRefTracer_SetTracer` の呼び出し時に" +"登録された不透明なデータポインタの値を取得します。\n" +"トレーサが登録されていない場合は NULL を返し、``data`` ポインタを NULL に設定" +"します。" diff --git a/c-api/refcounting.po b/c-api/refcounting.po index 06bbf4f49..d48154e20 100644 --- a/c-api/refcounting.po +++ b/c-api/refcounting.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/refcounting.rst:8 @@ -58,19 +58,24 @@ msgstr "" "オブジェクトの参照カウントを設定するためには、 :c:func:`Py_SET_REFCNT()` 関数" "を使用してください。" -#: ../../c-api/refcounting.rst:28 msgid "" "On :term:`free-threaded builds ` of Python, returning 1 " "isn't sufficient to determine if it's safe to treat *o* as having no access " "by other threads. Use :c:func:`PyUnstable_Object_IsUniquelyReferenced` for " "that instead." msgstr "" +"Python の :term:`フリースレッドビルド ` では、戻り値が " +"1 であるだけでは、ほかのスレッドから ``o`` へのアクセスがないものとして安全に" +"扱えるかどうかを判断できません。\n" +"その判断には :c:func:`PyUnstable_Object_IsUniquelyReferenced` を使ってくださ" +"い。" -#: ../../c-api/refcounting.rst:33 msgid "" "See also the function :c:func:" "`PyUnstable_Object_IsUniqueReferencedTemporary()`." msgstr "" +":c:func:`PyUnstable_Object_IsUniqueReferencedTemporary()` 関数も参照してくだ" +"さい。" #: ../../c-api/refcounting.rst:35 msgid ":c:func:`Py_REFCNT()` is changed to the inline static function." @@ -111,16 +116,20 @@ msgstr "" "オブジェクト *o* への新しい :term:`強参照 ` を取得し、それ" "が使用中で破棄されてはならないことを示します。" -#: ../../c-api/refcounting.rst:64 msgid "" "This function is usually used to convert a :term:`borrowed reference` to a :" "term:`strong reference` in-place. The :c:func:`Py_NewRef` function can be " "used to create a new :term:`strong reference`." msgstr "" +"この関数は通常、:term:`借用参照 ` をその場で :term:`強参" +"照 ` に変換するために使います。\n" +"新しい :term:`強参照 ` の作成には :c:func:`Py_NewRef` 関数" +"を使えます。" -#: ../../c-api/refcounting.rst:68 msgid "When done using the object, release is by calling :c:func:`Py_DECREF`." msgstr "" +"オブジェクトを使い終わったら、:c:func:`Py_DECREF` を呼び出して参照を解放しま" +"す。" #: ../../c-api/refcounting.rst:70 msgid "" @@ -130,88 +139,99 @@ msgstr "" "オブジェクトが ``NULL`` であってはいけません。それが ``NULL`` ではないと確信" "が持てないならば、 :c:func:`Py_XINCREF` を使ってください。" -#: ../../c-api/refcounting.rst:73 msgid "" "Do not expect this function to actually modify *o* in any way. For at least :" "pep:`some objects <0683>`, this function has no effect." msgstr "" +"この関数が実際に ``o`` を変更するとは限りません。\n" +"少なくとも :pep:`一部のオブジェクト <0683>` に対しては、この関数は何もしませ" +"ん。" -#: ../../c-api/refcounting.rst:83 msgid "" "Similar to :c:func:`Py_INCREF`, but the object *o* can be ``NULL``, in which " "case this has no effect." msgstr "" +":c:func:`Py_INCREF` と同様ですが、オブジェクト ``o`` は ``NULL`` でも構いませ" +"ん。\n" +"その場合は何もしません。" -#: ../../c-api/refcounting.rst:86 msgid "See also :c:func:`Py_XNewRef`." -msgstr "" +msgstr ":c:func:`Py_XNewRef` も参照してください。" -#: ../../c-api/refcounting.rst:91 msgid "" "Create a new :term:`strong reference` to an object: call :c:func:`Py_INCREF` " "on *o* and return the object *o*." msgstr "" +"オブジェクトへの新しい :term:`強参照 ` を作成します。\n" +"``o`` に対して :c:func:`Py_INCREF` を呼び出し、オブジェクト ``o`` を返しま" +"す。" -#: ../../c-api/refcounting.rst:94 msgid "" "When the :term:`strong reference` is no longer needed, :c:func:`Py_DECREF` " "should be called on it to release the reference." msgstr "" +":term:`強参照 ` が不要になったら、:c:func:`Py_DECREF` を呼" +"び出して解放してください。" -#: ../../c-api/refcounting.rst:97 msgid "" "The object *o* must not be ``NULL``; use :c:func:`Py_XNewRef` if *o* can be " "``NULL``." msgstr "" +"オブジェクト ``o`` は ``NULL`` であってはいけません。\n" +"``o`` が ``NULL`` になり得る場合は :c:func:`Py_XNewRef` を使ってください。" #: ../../c-api/refcounting.rst:100 msgid "For example::" msgstr "例えば::" -#: ../../c-api/refcounting.rst:102 msgid "" "Py_INCREF(obj);\n" "self->attr = obj;" msgstr "" +"Py_INCREF(obj);\n" +"self->attr = obj;" -#: ../../c-api/refcounting.rst:105 msgid "can be written as::" -msgstr "" +msgstr "は次のように書けます。 ::" -#: ../../c-api/refcounting.rst:107 msgid "self->attr = Py_NewRef(obj);" -msgstr "" +msgstr "self->attr = Py_NewRef(obj);" -#: ../../c-api/refcounting.rst:109 msgid "See also :c:func:`Py_INCREF`." -msgstr "" +msgstr ":c:func:`Py_INCREF` も参照してください。" -#: ../../c-api/refcounting.rst:116 msgid "Similar to :c:func:`Py_NewRef`, but the object *o* can be NULL." msgstr "" +":c:func:`Py_NewRef` と同様ですが、オブジェクト ``o`` は ``NULL`` でも構いませ" +"ん。" -#: ../../c-api/refcounting.rst:118 msgid "If the object *o* is ``NULL``, the function just returns ``NULL``." msgstr "" +"オブジェクト ``o`` が ``NULL`` の場合、この関数は単に ``NULL`` を返します。" -#: ../../c-api/refcounting.rst:125 msgid "" "Release a :term:`strong reference` to object *o*, indicating the reference " "is no longer used." msgstr "" +"オブジェクト ``o`` への :term:`強参照 ` を解放し、その参照" +"をもう使わないことを示します。" -#: ../../c-api/refcounting.rst:130 msgid "" "Once the last :term:`strong reference` is released (i.e. the object's " "reference count reaches 0), the object's type's deallocation function (which " "must not be ``NULL``) is invoked." msgstr "" +"最後の :term:`強参照 ` が解放されると (つまり、オブジェクト" +"の参照カウントが 0 になると)、そのオブジェクトの型の解放関数が呼び出されま" +"す。\n" +"この関数は ``NULL`` であってはいけません。" -#: ../../c-api/refcounting.rst:135 msgid "" "This function is usually used to delete a :term:`strong reference` before " "exiting its scope." msgstr "" +"この関数は通常、スコープを抜ける前に :term:`強参照 ` を削除" +"するために使います。" #: ../../c-api/refcounting.rst:138 msgid "" @@ -221,13 +241,14 @@ msgstr "" "オブジェクトが ``NULL`` であってはいけません。それが ``NULL`` ではないと確信" "が持てないならば、 :c:func:`Py_XDECREF` を使ってください。" -#: ../../c-api/refcounting.rst:141 msgid "" "Do not expect this function to actually modify *o* in any way. For at least :" "pep:`some objects <683>`, this function has no effect." msgstr "" +"この関数が実際に ``o`` を変更するとは限りません。\n" +"少なくとも :pep:`一部のオブジェクト <683>` に対しては、この関数は何もしませ" +"ん。" -#: ../../c-api/refcounting.rst:147 msgid "" "The deallocation function can cause arbitrary Python code to be invoked (e." "g. when a class instance with a :meth:`~object.__del__` method is " @@ -239,15 +260,26 @@ msgid "" "object in a temporary variable, update the list data structure, and then " "call :c:func:`Py_DECREF` for the temporary variable." msgstr "" +"解放関数は任意の Python コードを呼び出すことがあります (例えば :meth:" +"`~object.__del__` メソッドを持つクラスのインスタンスを解放するとき)。\n" +"そのコード内の例外は伝播しませんが、実行されるコードは Python のすべてのグ" +"ローバル変数に自由にアクセスできます。\n" +"このため、グローバル変数から到達できるオブジェクトは、:c:func:`Py_DECREF` を" +"呼び出す前に整合性の取れた状態にしておく必要があります。\n" +"例えば、リストからオブジェクトを削除するコードでは、そのオブジェクトへの参照" +"を一時変数にコピーしてからリストのデータ構造を更新し、その後で一時変数に対し" +"て :c:func:`Py_DECREF` を呼び出すべきです。" -#: ../../c-api/refcounting.rst:162 msgid "" "Similar to :c:func:`Py_DECREF`, but the object *o* can be ``NULL``, in which " "case this has no effect. The same warning from :c:func:`Py_DECREF` applies " "here as well." msgstr "" +":c:func:`Py_DECREF` と同様ですが、オブジェクト ``o`` は ``NULL`` でも構いませ" +"ん。\n" +"その場合は何もしません。\n" +":c:func:`Py_DECREF` と同じ警告がここにも当てはまります。" -#: ../../c-api/refcounting.rst:169 msgid "" "Release a :term:`strong reference` for object *o*. The object may be " "``NULL``, in which case the macro has no effect; otherwise the effect is the " @@ -256,71 +288,91 @@ msgid "" "to the object passed because the macro carefully uses a temporary variable " "and sets the argument to ``NULL`` before releasing the reference." msgstr "" +"オブジェクト ``o`` への :term:`強参照 ` を解放します。\n" +"オブジェクトは ``NULL`` でもよく、その場合は何もしません。\n" +"それ以外の場合は :c:func:`Py_DECREF` と同じ効果がありますが、引数も ``NULL`` " +"に設定します。\n" +"このマクロは一時変数を使い、参照を解放する前に引数を ``NULL`` に設定するた" +"め、渡したオブジェクトについては :c:func:`Py_DECREF` の警告は当てはまりませ" +"ん。" -#: ../../c-api/refcounting.rst:177 msgid "" "It is a good idea to use this macro whenever releasing a reference to an " "object that might be traversed during garbage collection." msgstr "" +"ガベージコレクション中に走査される可能性のあるオブジェクトへの参照を解放する" +"ときは、このマクロを使うとよいでしょう。" -#: ../../c-api/refcounting.rst:180 msgid "" "The macro argument is now only evaluated once. If the argument has side " "effects, these are no longer duplicated." msgstr "" +"マクロの引数を 1 回だけ評価するようになりました。\n" +"引数に副作用がある場合も、それが重複して発生することはなくなりました。" -#: ../../c-api/refcounting.rst:187 msgid "" "Indicate taking a new :term:`strong reference` to object *o*. A function " "version of :c:func:`Py_XINCREF`. It can be used for runtime dynamic " "embedding of Python." msgstr "" +"オブジェクト ``o`` への新しい :term:`強参照 ` を取得するこ" +"とを示します。\n" +":c:func:`Py_XINCREF` の関数版です。\n" +"実行時に Python を動的に組み込むために使えます。" -#: ../../c-api/refcounting.rst:194 msgid "" "Release a :term:`strong reference` to object *o*. A function version of :c:" "func:`Py_XDECREF`. It can be used for runtime dynamic embedding of Python." msgstr "" +"オブジェクト ``o`` への :term:`強参照 ` を解放します。\n" +":c:func:`Py_XDECREF` の関数版です。\n" +"実行時に Python を動的に組み込むために使えます。" -#: ../../c-api/refcounting.rst:201 msgid "" "Macro safely releasing a :term:`strong reference` to object *dst* and " "setting *dst* to *src*." msgstr "" +"オブジェクト ``dst`` への :term:`強参照 ` を安全に解放し、" +"``dst`` を ``src`` に設定するマクロです。" -#: ../../c-api/refcounting.rst:204 msgid "As in case of :c:func:`Py_CLEAR`, \"the obvious\" code can be deadly::" msgstr "" +":c:func:`Py_CLEAR` の場合と同様に、「当然」と思える次のコードは致命的な結果を" +"招くことがあります。 ::" -#: ../../c-api/refcounting.rst:206 msgid "" "Py_DECREF(dst);\n" "dst = src;" msgstr "" +"Py_DECREF(dst);\n" +"dst = src;" -#: ../../c-api/refcounting.rst:209 msgid "The safe way is::" -msgstr "" +msgstr "安全な書き方は次のとおりです。 ::" -#: ../../c-api/refcounting.rst:211 msgid "Py_SETREF(dst, src);" -msgstr "" +msgstr "Py_SETREF(dst, src);" -#: ../../c-api/refcounting.rst:213 msgid "" "That arranges to set *dst* to *src* *before* releasing the reference to the " "old value of *dst*, so that any code triggered as a side-effect of *dst* " "getting torn down no longer believes *dst* points to a valid object." msgstr "" +"これにより、*dst* の古い値への参照を解放する *前に*、*dst* に *src* が設定さ" +"れます。\n" +"そのため、古いオブジェクトの破棄に伴って実行されるコードが、*dst* はそのオブ" +"ジェクトをまだ有効な状態で指していると誤認することを防げます。" -#: ../../c-api/refcounting.rst:220 ../../c-api/refcounting.rst:232 msgid "" "The macro arguments are now only evaluated once. If an argument has side " "effects, these are no longer duplicated." msgstr "" +"マクロの引数をそれぞれ 1 回だけ評価するようになりました。\n" +"引数に副作用がある場合も、それが重複して発生することはなくなりました。" -#: ../../c-api/refcounting.rst:227 msgid "" "Variant of :c:macro:`Py_SETREF` macro that uses :c:func:`Py_XDECREF` instead " "of :c:func:`Py_DECREF`." msgstr "" +":c:func:`Py_DECREF` の代わりに :c:func:`Py_XDECREF` を使う :c:macro:" +"`Py_SETREF` マクロの変種です。" diff --git a/c-api/reflection.po b/c-api/reflection.po index 75f73e5ab..7b5127d7d 100644 --- a/c-api/reflection.po +++ b/c-api/reflection.po @@ -16,19 +16,18 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/reflection.rst:6 msgid "Reflection" msgstr "リフレクション" -#: ../../c-api/reflection.rst:12 msgid "Use :c:func:`PyEval_GetFrameBuiltins` instead." -msgstr "" +msgstr "代わりに :c:func:`PyEval_GetFrameBuiltins` を使ってください。" #: ../../c-api/reflection.rst:14 ../../c-api/reflection.rst:66 msgid "" @@ -38,27 +37,31 @@ msgstr "" "現在の実行フレーム内のビルトインの辞書か、もし実行中のフレームがなければス" "レッド状態のインタプリタのビルトイン辞書を返します。" -#: ../../c-api/reflection.rst:22 msgid "" "Use either :c:func:`PyEval_GetFrameLocals` to obtain the same behaviour as " "calling :func:`locals` in Python code, or else call :c:func:" "`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame` to access " "the :attr:`~frame.f_locals` attribute of the currently executing frame." msgstr "" +"Python コードで :func:`locals` を呼び出すのと同じ動作を得るには :c:func:" +"`PyEval_GetFrameLocals` を使ってください。\n" +"または、現在実行中のフレームの :attr:`~frame.f_locals` 属性にアクセスするに" +"は、:c:func:`PyEval_GetFrame` の戻り値に対して :c:func:`PyFrame_GetLocals` を" +"呼び出してください。" -#: ../../c-api/reflection.rst:27 msgid "" "Return a mapping providing access to the local variables in the current " "execution frame, or ``NULL`` if no frame is currently executing." msgstr "" +"現在の実行フレームのローカル変数にアクセスするためのマッピングを返します。\n" +"現在実行中のフレームがなければ ``NULL`` を返します。" -#: ../../c-api/reflection.rst:30 msgid "" "Refer to :func:`locals` for details of the mapping returned at different " "scopes." msgstr "" +"スコープごとに返されるマッピングの詳細は :func:`locals` を参照してください。" -#: ../../c-api/reflection.rst:32 msgid "" "As this function returns a :term:`borrowed reference`, the dictionary " "returned for :term:`optimized scopes ` is cached on the " @@ -68,18 +71,27 @@ msgid "" "to reflect changes in the state of the local variables rather than returning " "a new snapshot." msgstr "" +"この関数は :term:`借用参照 ` を返すため、:term:`最適化さ" +"れたスコープ ` に対して返される辞書はフレームオブジェクトに" +"キャッシュされ、フレームオブジェクトが生存する限り生存し続けます。\n" +":c:func:`PyEval_GetFrameLocals` や :func:`locals` と異なり、同じフレームでこ" +"の関数を再度呼び出すと、新しいスナップショットを返す代わりに、ローカル変数の" +"状態の変化を反映するようキャッシュした辞書の内容を更新します。" -#: ../../c-api/reflection.rst:39 msgid "" "As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, and :" "attr:`FrameType.f_locals ` no longer make use of the shared " "cache dictionary. Refer to the :ref:`What's New entry ` for additional details." msgstr "" +":pep:`667` の変更の一環として、:c:func:`PyFrame_GetLocals`、:func:`locals`、:" +"attr:`FrameType.f_locals ` は共有キャッシュ辞書を使わなくなり" +"ました。\n" +"詳しくは :ref:`What's New の該当項目 ` を参照し" +"てください。" -#: ../../c-api/reflection.rst:50 msgid "Use :c:func:`PyEval_GetFrameGlobals` instead." -msgstr "" +msgstr "代わりに :c:func:`PyEval_GetFrameGlobals` を使ってください。" #: ../../c-api/reflection.rst:52 msgid "" @@ -89,53 +101,59 @@ msgstr "" "現在の実行フレーム内のグローバル変数の辞書か、実行中のフレームがなければ " "``NULL`` を返します。" -#: ../../c-api/reflection.rst:58 msgid "" "Return the :term:`attached thread state`'s frame, which is ``NULL`` if no " "frame is currently executing." msgstr "" +":term:`アタッチされたスレッド状態 ` のフレームを返しま" +"す。\n" +"現在実行中のフレームがなければ ``NULL`` です。" -#: ../../c-api/reflection.rst:61 msgid "See also :c:func:`PyThreadState_GetFrame`." -msgstr "" +msgstr ":c:func:`PyThreadState_GetFrame` も参照してください。" -#: ../../c-api/reflection.rst:74 msgid "" "Return a dictionary of the local variables in the current execution frame, " "or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" "`locals` in Python code." msgstr "" +"現在の実行フレームのローカル変数の辞書を返します。\n" +"現在実行中のフレームがなければ ``NULL`` を返します。\n" +"Python コードで :func:`locals` を呼び出すことと等価です。" -#: ../../c-api/reflection.rst:78 msgid "" "To access :attr:`~frame.f_locals` on the current frame without making an " "independent snapshot in :term:`optimized scopes `, call :c:" "func:`PyFrame_GetLocals` on the result of :c:func:`PyEval_GetFrame`." msgstr "" +":term:`最適化されたスコープ ` で独立したスナップショットを作" +"らずに、現在のフレームの :attr:`~frame.f_locals` にアクセスするには、:c:func:" +"`PyEval_GetFrame` の戻り値に対して :c:func:`PyFrame_GetLocals` を呼び出してく" +"ださい。" -#: ../../c-api/reflection.rst:87 msgid "" "Return a dictionary of the global variables in the current execution frame, " "or ``NULL`` if no frame is currently executing. Equivalent to calling :func:" "`globals` in Python code." msgstr "" +"現在の実行フレームのグローバル変数の辞書を返します。\n" +"現在実行中のフレームがなければ ``NULL`` を返します。\n" +"Python コードで :func:`globals` を呼び出すことと等価です。" -#: ../../c-api/reflection.rst:96 msgid "" "Return the name of *func* if it is a function, class or instance object, " "else the name of *func*\\s type." msgstr "" -"*func* が関数、クラス、インスタンスオブジェクトであればその名前を、そうでなけ" -"れば *func* の型を返します。" +"*func* が関数、クラス、インスタンスオブジェクトであればその名前を返し、それ以" +"外の場合は *func* の型の名前を返します。" -#: ../../c-api/reflection.rst:102 msgid "" "Return a description string, depending on the type of *func*. Return values " "include \"()\" for functions and methods, \" constructor\", \" instance\", " "and \" object\". Concatenated with the result of :c:func:" "`PyEval_GetFuncName`, the result will be a description of *func*." msgstr "" -"*func* の型に依存する、解説文字列(description string)を返します。戻り値は、関" -"数とメソッドに対しては \"()\", \" constructor\", \" instance\", \" object\" " -"です。 :c:func:`PyEval_GetFuncName` と連結された結果、 *func* の解説になりま" -"す。" +"*func* の型に応じた説明文字列を返します。\n" +"戻り値には、関数とメソッドに対する \"()\" のほか、\" constructor\"、\" " +"instance\"、\" object\" があります。\n" +":c:func:`PyEval_GetFuncName` の戻り値に連結すると、*func* の説明になります。" diff --git a/c-api/sequence.po b/c-api/sequence.po index 2b6415cd6..1de6ca504 100644 --- a/c-api/sequence.po +++ b/c-api/sequence.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/sequence.rst:6 msgid "Sequence Protocol" msgstr "シーケンス型プロトコル (sequence protocol)" -#: ../../c-api/sequence.rst:11 msgid "" "Return ``1`` if the object provides the sequence protocol, and ``0`` " "otherwise. Note that it returns ``1`` for Python classes with a :meth:" @@ -34,6 +33,12 @@ msgid "" "since in general it is impossible to determine what type of keys the class " "supports. This function always succeeds." msgstr "" +"オブジェクトがシーケンス型プロトコルを提供していれば ``1``、それ以外なら " +"``0`` を返します。\n" +"一般に、クラスがどの型のキーをサポートするかは判定できないため、\n" +":meth:`~object.__getitem__` メソッドを持つ Python クラスに対しては、:class:" +"`dict` のサブクラスでない限り ``1`` を返します。\n" +"この関数は常に成功します。" #: ../../c-api/sequence.rst:23 msgid "" @@ -96,21 +101,23 @@ msgstr "" "成功すると *o* の *i1* から *i2* までの間のスライスを返し、失敗すると " "``NULL`` を返します。Python の式 ``o[i1:i2]`` と同じです。" -#: ../../c-api/sequence.rst:67 msgid "" "Assign object *v* to the *i*\\ th element of *o*. Raise an exception and " "return ``-1`` on failure; return ``0`` on success. This is the equivalent " "of the Python statement ``o[i] = v``. This function *does not* \":term:" "`steal`\" a reference to *v*." msgstr "" +"*o* の *i* 番目の要素にオブジェクト *v* を代入します。\n" +"失敗すると例外を設定して ``-1`` を返し、成功すると ``0`` を返します。\n" +"Python の文 ``o[i] = v`` と同じです。\n" +"この関数は *v* への参照を :term:`盗み ` *ません*。" -#: ../../c-api/sequence.rst:72 msgid "" "If *v* is ``NULL``, the element is deleted, but this feature is deprecated " "in favour of using :c:func:`PySequence_DelItem`." msgstr "" -"*v* が ``NULL`` の場合はその要素が削除されますが、この機能は非推奨であり、 :" -"c:func:`PyObject_DelAttr` を使うのが望ましいです。" +"*v* が ``NULL`` の場合は要素を削除しますが、この機能は非推奨です。\n" +"代わりに :c:func:`PySequence_DelItem` を使ってください。" #: ../../c-api/sequence.rst:78 msgid "" @@ -156,13 +163,11 @@ msgstr "" "(equal) ならば ``1`` を返し、それ以外の場合には ``0`` を返します。エラーが発" "生すると ``-1`` を返します。Python の式 ``value in o`` と同じです。" -#: ../../c-api/sequence.rst:110 msgid "Alias for :c:func:`PySequence_Contains`." -msgstr "" +msgstr ":c:func:`PySequence_Contains` の別名です。" -#: ../../c-api/sequence.rst:112 msgid "The function should no longer be used to write new code." -msgstr "" +msgstr "新しいコードを書く際に、この関数を使わないでください。" #: ../../c-api/sequence.rst:118 msgid "" @@ -268,7 +273,6 @@ msgstr "" "ないことに注意してください。そのため、シーケンスの変更が発生しないコンテキス" "トでのみ背後にあるポインタを使ってください。" -#: ../../c-api/sequence.rst:181 msgid "" "Return the *i*\\ th element of *o* or ``NULL`` on failure. Faster form of :c:" "func:`PySequence_GetItem` but without checking that :c:func:" @@ -277,7 +281,7 @@ msgid "" msgstr "" "*o* の *i* 番目の要素を返し、失敗すると ``NULL`` を返します。 :c:func:" "`PySequence_GetItem` の高速版であり、:c:func:`PySequence_Check` で *o* が真を" -"返すかどうかの検証や、負の添え字の調整を行いません。 " +"返すかどうかの検証や、負の添え字の調整を行いません。" #: ../../c-api/sequence.rst:21 ../../c-api/sequence.rst:131 msgid "built-in function" diff --git a/c-api/set.po b/c-api/set.po index 4af9ec6ca..82ee9f0d9 100644 --- a/c-api/set.po +++ b/c-api/set.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/set.rst:6 @@ -156,12 +156,14 @@ msgstr "" "*iterable* がイテレート可能でない場合は、 :exc:`TypeError` を送出します。\n" "このコンストラクタは set をコピーするときにも使えます (``c=set(s)``)。" -#: ../../c-api/set.rst:94 ../../c-api/set.rst:107 msgid "" "The operation is atomic on :term:`free threading ` when " "*iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:" "`frozendict`." msgstr "" +"*iterable* が :class:`set`、:class:`frozenset`、:class:`dict`、:class:" +"`frozendict` の場合、この操作は :term:`フリースレッドビルド ` でアトミックです。" #: ../../c-api/set.rst:100 msgid "" @@ -183,18 +185,20 @@ msgstr "" "以降の関数やマクロは、 :class:`set` と :class:`frozenset` とそのサブタイプの" "インスタンスに対して利用できます。" -#: ../../c-api/set.rst:119 msgid "" "Return the length of a :class:`set` or :class:`frozenset` object. Equivalent " "to ``len(anyset)``. Raises a :exc:`SystemError` if *anyset* is not a :class:" "`set`, :class:`frozenset`, or an instance of a subtype." msgstr "" +":class:`set` または :class:`frozenset` オブジェクトの長さを返します。\n" +"``len(anyset)`` と等価です。\n" +"*anyset* が :class:`set`、:class:`frozenset`、またはそのサブタイプのインスタ" +"ンスでない場合、:exc:`SystemError` を送出します。" #: ../../c-api/set.rst:126 msgid "Macro form of :c:func:`PySet_Size` without error checking." msgstr "エラーチェックを行わない、 :c:func:`PySet_Size` のマクロ形式。" -#: ../../c-api/set.rst:131 msgid "" "Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is " "encountered. Unlike the Python :meth:`~object.__contains__` method, this " @@ -203,13 +207,22 @@ msgid "" "`SystemError` if *anyset* is not a :class:`set`, :class:`frozenset`, or an " "instance of a subtype." msgstr "" +"見付かれば ``1``、見付からなければ ``0``、エラーが起きれば ``-1`` を返しま" +"す。\n" +"Python の :meth:`~object.__contains__` メソッドとは異なり、ハッシュ不可能な集" +"合を一時的な frozenset に自動変換しません。\n" +"*key* がハッシュ不可能な場合、:exc:`TypeError` を送出します。\n" +"*anyset* が :class:`set`、:class:`frozenset`、またはそのサブタイプのインスタ" +"ンスでない場合、:exc:`SystemError` を送出します。" -#: ../../c-api/set.rst:139 ../../c-api/set.rst:154 ../../c-api/set.rst:174 msgid "" "The operation is atomic on :term:`free threading ` when " "*key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:" "`bytes`." msgstr "" +"*key* が :class:`str`、:class:`int`、:class:`float`、:class:`bool`、:class:" +"`bytes` の場合、この操作は :term:`フリースレッドビルド ` でアトミックです。" #: ../../c-api/set.rst:144 msgid "" @@ -238,7 +251,6 @@ msgstr "" "以降の関数は、 :class:`set` とそのサブタイプに対して利用可能です。 :class:" "`frozenset` とそのサブタイプには利用できません。" -#: ../../c-api/set.rst:165 msgid "" "Return ``1`` if found and removed, ``0`` if not found (no action taken), and " "``-1`` if an error is encountered. Does not raise :exc:`KeyError` for " @@ -247,6 +259,14 @@ msgid "" "convert unhashable sets into temporary frozensets. Raise :exc:`SystemError` " "if *set* is not an instance of :class:`set` or its subtype." msgstr "" +"見付かって削除した場合は ``1``、見付からなかった場合は何もせず ``0``、エラー" +"が起きた場合は ``-1`` を返します。\n" +"キーが存在しなくても :exc:`KeyError` は送出しません。\n" +"*key* がハッシュ不可能な場合は :exc:`TypeError` を送出します。\n" +"Python の :meth:`~set.discard` メソッドとは異なり、ハッシュ不可能な集合を一時" +"的な frozenset に自動変換しません。\n" +"*set* が :class:`set` またはそのサブタイプのインスタンスでない場合は、:exc:" +"`SystemError` を送出します。" #: ../../c-api/set.rst:180 msgid "" @@ -262,41 +282,49 @@ msgstr "" "*set* が :class:`set` とそのサブタイプのインスタンスでない場合は、 :exc:" "`SystemError` を送出します。" -#: ../../c-api/set.rst:188 msgid "" "Empty an existing set of all elements. Return ``0`` on success. Return " "``-1`` and raise :exc:`SystemError` if *set* is not an instance of :class:" "`set` or its subtype." msgstr "" +"既存の集合のすべての要素を取り除いて空にします。\n" +"成功すると ``0`` を返します。\n" +"*set* が :class:`set` またはそのサブタイプのインスタンスでない場合、:exc:" +"`SystemError` を送出して ``-1`` を返します。" -#: ../../c-api/set.rst:194 msgid "" "In the :term:`free-threaded build`, the set is emptied before its entries " "are cleared, so other threads will observe an empty set rather than " "intermediate states." msgstr "" +":term:`フリースレッドビルド ` では、エントリーをクリアす" +"る前に集合を空にするため、他のスレッドからは途中の状態ではなく空の集合が見え" +"ます。" -#: ../../c-api/set.rst:200 msgid "Deprecated API" -msgstr "" +msgstr "非推奨の API" -#: ../../c-api/set.rst:204 msgid "" "A constant representing the size of an internal preallocated table inside :c:" "type:`PySetObject` instances." msgstr "" +":c:type:`PySetObject` インスタンスの内部に事前確保されたテーブルのサイズを表" +"す定数。" -#: ../../c-api/set.rst:207 msgid "" "This is documented solely for completeness, as there are no guarantees that " "a given version of CPython uses preallocated tables with a fixed size. In " "code that does not deal with unstable set internals, :c:macro:`!" "PySet_MINSIZE` can be replaced with a small constant like ``8``." msgstr "" +"CPython のどのバージョンでも固定サイズの事前確保テーブルを使うという保証はな" +"いため、網羅性のためだけに記載しています。\n" +"集合の不安定な内部実装を扱わないコードでは、:c:macro:`!PySet_MINSIZE` を " +"``8`` のような小さな定数に置き換えられます。" -#: ../../c-api/set.rst:213 msgid "If looking for the size of a set, use :c:func:`PySet_Size` instead." msgstr "" +"集合のサイズを求める場合は、代わりに :c:func:`PySet_Size` を使ってください。" #: ../../c-api/set.rst:8 msgid "object" diff --git a/c-api/slice.po b/c-api/slice.po index 3e5d9dbff..38f5d9ec0 100644 --- a/c-api/slice.po +++ b/c-api/slice.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/slice.rst:6 @@ -42,19 +42,24 @@ msgstr "" "*ob* がスライスオブジェクトの場合に真を返します; *ob* は ``NULL`` であっては" "なりません。この関数は常に成功します。" -#: ../../c-api/slice.rst:23 msgid "" "Return a new slice object with the given values. The *start*, *stop*, and " "*step* parameters are used as the values of the slice object attributes of " "the same names. Any of the values may be ``NULL``, in which case the " "``None`` will be used for the corresponding attribute." msgstr "" +"指定された値を持つ新しいスライスオブジェクトを返します。\n" +"引数 ``start``、``stop``、``step`` は、スライスオブジェクトの同名の属性の値と" +"して使われます。\n" +"いずれの値も ``NULL`` で構いません。\n" +"その場合、対応する属性には ``None`` が使われます。" -#: ../../c-api/slice.rst:28 msgid "" "Return ``NULL`` with an exception set if the new object could not be " "allocated." msgstr "" +"新しいオブジェクトを割り当てられなかった場合は、例外を設定して ``NULL`` を返" +"します。" #: ../../c-api/slice.rst:34 msgid "" @@ -66,12 +71,15 @@ msgstr "" "クス値を取得します。このときシーケンスの長さを *length* と仮定します。" "*length* よりも大きなインデクスになるとエラーとして扱います。" -#: ../../c-api/slice.rst:38 msgid "" "Returns ``0`` on success and ``-1`` on error with no exception set (unless " "one of the indices was not ``None`` and failed to be converted to an " "integer, in which case ``-1`` is returned with an exception set)." msgstr "" +"成功した場合は ``0`` を返します。\n" +"エラーの場合は例外を設定せずに ``-1`` を返します。\n" +"ただし、いずれかのインデックスが ``None`` ではなく、整数に変換できなかった場" +"合は、例外を設定して ``-1`` を返します。" #: ../../c-api/slice.rst:42 msgid "You probably do not want to use this function." @@ -82,7 +90,6 @@ msgid "" "The parameter type for the *slice* parameter was ``PySliceObject*`` before." msgstr "以前は、*slice* 引数の型は ``PySliceObject*`` でした。" -#: ../../c-api/slice.rst:51 msgid "" "Usable replacement for :c:func:`PySlice_GetIndices`. Retrieve the start, " "stop, and step indices from the slice object *slice* assuming a sequence of " @@ -90,39 +97,53 @@ msgid "" "bounds indices are clipped in a manner consistent with the handling of " "normal slices. *length* must not be negative." msgstr "" +":c:func:`PySlice_GetIndices` の実用的な代替です。\n" +"長さ ``length`` のシーケンスを仮定し、スライスオブジェクト ``slice`` から " +"start、stop、step のインデックスを取得して、スライスの長さを ``slicelength`` " +"に格納します。\n" +"範囲外のインデックスは、通常のスライスの処理と同じ方法で範囲内に収めます。\n" +"``length`` は負であってはいけません。" -#: ../../c-api/slice.rst:58 msgid "Return ``0`` on success and ``-1`` on error with an exception set." msgstr "" +"成功した場合は ``0`` を返し、エラーの場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/slice.rst:61 msgid "" "This function is considered not safe for resizable sequences. Its invocation " "should be replaced by a combination of :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` where ::" msgstr "" +"この関数は、サイズを変更できるシーケンスに対して安全ではないとされていま" +"す。\n" +":c:func:`PySlice_Unpack` と :c:func:`PySlice_AdjustIndices` の組み合わせに置" +"き換えてください。\n" +"次の呼び出しを、 ::" -#: ../../c-api/slice.rst:65 msgid "" "if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) " "< 0) {\n" " // return error\n" "}" msgstr "" +"if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) " +"< 0) {\n" +" // エラーを返す\n" +"}" -#: ../../c-api/slice.rst:69 msgid "is replaced by ::" -msgstr "" +msgstr "次のように置き換えます。 ::" -#: ../../c-api/slice.rst:71 msgid "" "if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {\n" " // return error\n" "}\n" "slicelength = PySlice_AdjustIndices(length, &start, &stop, step);" msgstr "" +"if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {\n" +" // エラーを返す\n" +"}\n" +"slicelength = PySlice_AdjustIndices(length, &start, &stop, step);" -#: ../../c-api/slice.rst:80 msgid "" "If ``Py_LIMITED_API`` is not set or set to the value between ``0x03050400`` " "and ``0x03060000`` (not including) or ``0x03060100`` or higher :c:func:`!" @@ -130,15 +151,21 @@ msgid "" "PySlice_Unpack` and :c:func:`!PySlice_AdjustIndices`. Arguments *start*, " "*stop* and *step* are evaluated more than once." msgstr "" +"``Py_LIMITED_API`` が設定されていない場合、または ``0x03050400`` 以上 " +"``0x03060000`` 未満か ``0x03060100`` 以上に設定されている場合、:c:func:`!" +"PySlice_GetIndicesEx` は :c:func:`!PySlice_Unpack` と :c:func:`!" +"PySlice_AdjustIndices` を使うマクロとして実装されています。\n" +"引数 ``start``、``stop``、``step`` は複数回評価されます。" -#: ../../c-api/slice.rst:87 msgid "" "If ``Py_LIMITED_API`` is set to the value less than ``0x03050400`` or " "between ``0x03060000`` and ``0x03060100`` (not including) :c:func:`!" "PySlice_GetIndicesEx` is a deprecated function." msgstr "" +"``Py_LIMITED_API`` が ``0x03050400`` 未満、または ``0x03060000`` 以上 " +"``0x03060100`` 未満に設定されている場合、:c:func:`!PySlice_GetIndicesEx` は非" +"推奨の関数です。" -#: ../../c-api/slice.rst:95 msgid "" "Extract the start, stop and step data members from a slice object as C " "integers. Silently reduce values larger than ``PY_SSIZE_T_MAX`` to " @@ -146,39 +173,52 @@ msgid "" "``PY_SSIZE_T_MIN`` to ``PY_SSIZE_T_MIN``, and silently boost the step values " "less than ``-PY_SSIZE_T_MAX`` to ``-PY_SSIZE_T_MAX``." msgstr "" +"スライスオブジェクトの start、stop、step データメンバを C の整数として取り出" +"します。\n" +"``PY_SSIZE_T_MAX`` を超える値は ``PY_SSIZE_T_MAX`` に切り下げます。\n" +"``PY_SSIZE_T_MIN`` より小さい start と stop は ``PY_SSIZE_T_MIN`` に切り上" +"げ、``-PY_SSIZE_T_MAX`` より小さい step は ``-PY_SSIZE_T_MAX`` に切り上げま" +"す。\n" +"これらの調整によってエラーにはなりません。" -#: ../../c-api/slice.rst:101 msgid "Return ``-1`` with an exception set on error, ``0`` on success." msgstr "" +"エラーの場合は例外を設定して ``-1`` を返し、成功した場合は ``0`` を返します。" -#: ../../c-api/slice.rst:108 msgid "" "Adjust start/end slice indices assuming a sequence of the specified length. " "Out of bounds indices are clipped in a manner consistent with the handling " "of normal slices." msgstr "" +"指定された長さのシーケンスを仮定し、スライスの開始と終了のインデックスを調整" +"します。\n" +"範囲外のインデックスは、通常のスライスの処理と同じ方法で範囲内に収めます。" -#: ../../c-api/slice.rst:112 msgid "" "*length* must not be negative. *step* must not be zero and must not be less " "than ``-PY_SSIZE_T_MAX``, as guaranteed by :c:func:`PySlice_Unpack`." msgstr "" +"``length`` は負であってはいけません。\n" +"``step`` はゼロでも ``-PY_SSIZE_T_MAX`` 未満でもいけません。\n" +":c:func:`PySlice_Unpack` の結果はこれらの ``step`` の条件を満たします。" -#: ../../c-api/slice.rst:116 msgid "" "Return the length of the slice. Always successful. Doesn't call Python " "code." msgstr "" +"スライスの長さを返します。\n" +"常に成功し、Python コードを呼び出しません。" #: ../../c-api/slice.rst:123 msgid "Ellipsis Object" msgstr "Ellipsis オブジェクト" -#: ../../c-api/slice.rst:128 msgid "" "The type of Python :const:`Ellipsis` object. Same as :class:`types." "EllipsisType` in the Python layer." msgstr "" +"Python の :const:`Ellipsis` オブジェクトの型です。\n" +"Python レベルの :class:`types.EllipsisType` と同じです。" #: ../../c-api/slice.rst:134 msgid "" diff --git a/c-api/stable.po b/c-api/stable.po index 4dcb5c7e6..2cb1470db 100644 --- a/c-api/stable.po +++ b/c-api/stable.po @@ -16,25 +16,28 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/stable.rst:7 msgid "C API and ABI Stability" -msgstr "" +msgstr "C API と ABI の安定性" -#: ../../c-api/stable.rst:9 msgid "" "Unless documented otherwise, Python's C API is covered by the Backwards " "Compatibility Policy, :pep:`387`. Most changes to it are source-compatible " "(typically by only adding new API). Changing existing API or removing API is " "only done after a deprecation period or to fix serious issues." msgstr "" +"特記のない限り、Python の C API には後方互換性ポリシー :pep:`387` が適用され" +"ます。\n" +"変更の大半はソース互換性を保ちます (通常は新しい API の追加だけを行いま" +"す)。\n" +"既存 API の変更や削除は、非推奨の期間を経た後、または重大な問題を修正するため" +"にのみ行います。" -#: ../../c-api/stable.rst:15 msgid "" "CPython's Application Binary Interface (ABI) is forward- and backwards-" "compatible across a minor release (if these are compiled the same way; see :" @@ -42,29 +45,36 @@ msgid "" "work on 3.10.8 and vice versa, but will need to be compiled separately for " "3.9.x and 3.11.x." msgstr "" +"CPython のアプリケーションバイナリインターフェース (ABI) は、同じマイナーリ" +"リース内で前方互換性と後方互換性を持ちます (同じ方法でコンパイルされている場" +"合。下記の :ref:`stable-abi-platform` を参照)。\n" +"したがって、Python 3.10.0 向けにコンパイルしたコードは 3.10.8 で動作し、その" +"逆も同様ですが、3.9.x や 3.11.x 向けには別にコンパイルする必要があります。" -#: ../../c-api/stable.rst:21 msgid "There are two tiers of C API with different stability expectations:" -msgstr "" +msgstr "C API には、期待される安定性が異なる二つの階層があります。" -#: ../../c-api/stable.rst:23 msgid "" ":ref:`Unstable API `, may change in minor versions without a " "deprecation period. It is marked by the ``PyUnstable`` prefix in names." msgstr "" +":ref:`不安定な API ` は、非推奨の期間なしにマイナーバージョン" +"間で変更される可能性があります。\n" +"名前の接頭辞 ``PyUnstable`` で識別できます。" -#: ../../c-api/stable.rst:25 msgid "" ":ref:`Limited API `, is compatible across several minor " "releases. When :c:macro:`Py_LIMITED_API` is defined, only this subset is " "exposed from ``Python.h``." msgstr "" +":ref:`Limited API ` は、複数のマイナーリリースにわたって互換性" +"を持ちます。\n" +":c:macro:`Py_LIMITED_API` を定義すると、``Python.h`` から公開されるのはこの部" +"分集合だけになります。" -#: ../../c-api/stable.rst:29 msgid "These are discussed in more detail below." -msgstr "" +msgstr "以下でそれぞれを詳しく説明します。" -#: ../../c-api/stable.rst:31 msgid "" "Names prefixed by an underscore, such as ``_Py_InternalState``, are private " "API that can change without notice even in patch releases. If you need to " @@ -72,98 +82,119 @@ msgid "" "python.org/c/core-dev/c-api/30>`_ to discuss adding public API for your use " "case." msgstr "" +"``_Py_InternalState`` のようにアンダースコアで始まる名前はプライベート API " +"で、パッチリリースでも予告なく変更される可能性があります。\n" +"この API を使う必要がある場合は、`CPython 開発者 `_ に連絡し、用途に合う公開 API の追加を相談することを検" +"討してください。" -#: ../../c-api/stable.rst:40 msgid "Unstable C API" -msgstr "" +msgstr "不安定な C API" -#: ../../c-api/stable.rst:44 msgid "" "Any API named with the ``PyUnstable`` prefix exposes CPython implementation " "details, and may change in every minor release (e.g. from 3.9 to 3.10) " "without any deprecation warnings. However, it will not change in a bugfix " "release (e.g. from 3.10.0 to 3.10.1)." msgstr "" +"接頭辞 ``PyUnstable`` を持つ API は CPython の実装の詳細を公開しており、マイ" +"ナーリリースごとに (例えば 3.9 から 3.10 で) 非推奨の警告なしに変更される可能" +"性があります。\n" +"ただし、バグ修正リリース (例えば 3.10.0 から 3.10.1) では変更されません。" -#: ../../c-api/stable.rst:49 msgid "" "It is generally intended for specialized, low-level tools like debuggers." -msgstr "" +msgstr "通常はデバッガのような、低レベルの専門的なツールを対象としています。" -#: ../../c-api/stable.rst:51 msgid "" "Projects that use this API are expected to follow CPython development and " "spend extra effort adjusting to changes." msgstr "" +"この API を使うプロジェクトには、CPython の開発を追い、変更への対応に追加の労" +"力をかけることが期待されます。" -#: ../../c-api/stable.rst:58 msgid "Stable Application Binary Interfaces" -msgstr "" +msgstr "安定したアプリケーションバイナリインターフェース" -#: ../../c-api/stable.rst:60 msgid "" "Python's :dfn:`Stable ABI` allows extensions to be compatible with multiple " "versions of Python, without recompilation." msgstr "" +"Python の :dfn:`Stable ABI` を使うと、再コンパイルせずに複数バージョンの " +"Python と互換性を持つ拡張を作成できます。" -#: ../../c-api/stable.rst:65 msgid "" "For simplicity, this document talks about *extensions*, but Stable ABI works " "the same way for all uses of the API – for example, embedding Python." msgstr "" +"説明を簡単にするため、この文書では *拡張* について述べますが、Python の組み込" +"みなど、API のあらゆる用途で Stable ABI は同じように機能します。" -#: ../../c-api/stable.rst:68 msgid "There are two Stable ABIs:" -msgstr "" +msgstr "Stable ABI は二つあります。" -#: ../../c-api/stable.rst:70 msgid "" "``abi3``, introduced in Python 3.2, is compatible with **non**-:term:`free-" "threaded ` builds of CPython." msgstr "" +"Python 3.2 で導入された ``abi3`` は、CPython の :term:`フリースレッドビルド " +"` **ではない** ビルドと互換性を持ちます。" -#: ../../c-api/stable.rst:73 msgid "" "``abi3t``, introduced in Python 3.15, is compatible with :term:`free-" "threaded ` builds of CPython. It has stricter API " "limitations than ``abi3``." msgstr "" +"Python 3.15 で導入された ``abi3t`` は、CPython の :term:`フリースレッドビル" +"ド ` と互換性を持ちます。\n" +"``abi3`` より API の制約が厳しくなっています。" -#: ../../c-api/stable.rst:79 msgid "``abi3t`` was added in :pep:`803`" -msgstr "" +msgstr "``abi3t`` は :pep:`803` で追加されました。" -#: ../../c-api/stable.rst:81 msgid "" "It is possible for an extension to be compiled for *both* ``abi3`` and " "``abi3t`` at the same time; the result will be compatible with both free-" "threaded and non-free-threaded builds of Python. Currently, this has no " "downsides compared to compiling for ``abi3t`` only." msgstr "" +"拡張を ``abi3`` と ``abi3t`` の *両方* 向けに同時にコンパイルすることもできま" +"す。\n" +"その結果は、フリースレッドビルドとそうでないビルドの両方で使えます。\n" +"現在のところ、``abi3t`` だけを対象にコンパイルする場合と比べて不利な点はあり" +"ません。" -#: ../../c-api/stable.rst:86 msgid "" "Each Stable ABI is versioned using the first two numbers of the Python " "version. For example, Stable ABI 3.14 corresponds to Python 3.14. An " "extension compiled for Stable ABI 3.x is ABI-compatible with Python 3.x and " "above." msgstr "" +"各 Stable ABI のバージョンには、Python のバージョンの最初の二つの数値を使いま" +"す。\n" +"例えば Stable ABI 3.14 は Python 3.14 に対応します。\n" +"Stable ABI 3.x 向けにコンパイルした拡張は、Python 3.x 以降と ABI 互換性を持ち" +"ます。" -#: ../../c-api/stable.rst:91 msgid "" "Extensions that target a stable ABI must only use a limited subset of the C " "API. This subset is known as the :dfn:`Limited API`; its contents are :ref:" "`listed below `." msgstr "" +"Stable ABI を対象にする拡張は、C API の限定された部分集合だけを使わなければな" +"りません。\n" +"この部分集合を :dfn:`Limited API` と呼びます。\n" +"内容は :ref:`後述の一覧 ` を参照してください。" -#: ../../c-api/stable.rst:95 msgid "" "On Windows, extensions that use a Stable ABI should be linked against " "``python3.dll`` rather than a version-specific library such as ``python39." "dll``. This library only exposes the relevant symbols." msgstr "" +"Windows では、Stable ABI を使う拡張は ``python39.dll`` のようなバージョン固有" +"のライブラリではなく、``python3.dll`` とリンクしてください。\n" +"このライブラリは、該当するシンボルだけを公開します。" -#: ../../c-api/stable.rst:100 msgid "" "On some platforms, Python will look for and load shared library files named " "with the ``abi3`` or ``abi3t`` tag (for example, ``mymodule.abi3.so``). :" @@ -172,8 +203,15 @@ msgid "" "back to ``abi3t``. Thus, extensions compatible with both ABIs should use the " "``abi3t`` tag." msgstr "" +"一部のプラットフォームでは、Python は名前に ``abi3`` または ``abi3t`` タグを" +"持つ共有ライブラリファイル (例えば ``mymodule.abi3.so``) を探して読み込みま" +"す。\n" +":term:`フリースレッド ` のインタープリタは ``abi3t`` タ" +"グだけを認識し、それ以外のインタープリタは ``abi3`` を優先しますが、なければ " +"``abi3t`` を使います。\n" +"したがって、両方の ABI と互換性のある拡張には ``abi3t`` タグを使ってくださ" +"い。" -#: ../../c-api/stable.rst:107 msgid "" "Python does not necessarily check that extensions it loads have compatible " "ABI. Extension authors are encouraged to add a check using the :c:macro:" @@ -182,53 +220,72 @@ msgid "" "example, extensions built for Stable ABI 3.10 are not installed for lower " "versions of Python." msgstr "" +"Python は、読み込む拡張の ABI に互換性があるかどうかを必ずしも確認しませ" +"ん。\n" +"拡張の作者には :c:macro:`Py_mod_abi` スロットまたは :c:func:" +"`PyABIInfo_Check` 関数による確認を追加することが推奨されます。\n" +"ただし、例えば Stable ABI 3.10 向けの拡張をそれより古い Python にインストール" +"しないようにする最終的な責任は、利用者 (またはパッケージ管理ツール) にありま" +"す。" -#: ../../c-api/stable.rst:115 msgid "" "All functions in Stable ABI are present as functions in Python's shared " "library, not solely as macros. This makes them usable in languages that " "don't use the C preprocessor, including Python's :py:mod:`ctypes`." msgstr "" +"Stable ABI のすべての関数は、マクロだけでなく Python の共有ライブラリ内の関数" +"としても存在します。\n" +"このため、Python の :py:mod:`ctypes` を含め、C プリプロセッサを使わない言語か" +"らも利用できます。" -#: ../../c-api/stable.rst:124 msgid "Compiling for Stable ABI" -msgstr "" +msgstr "Stable ABI 向けのコンパイル" -#: ../../c-api/stable.rst:128 msgid "" "Build tools (such as, for example, meson-python, scikit-build-core, or " "Setuptools) often have a mechanism for setting macros and synchronizing them " "with extension filenames and other metadata. Prefer using such a mechanism, " "if it exists, over defining the macros manually." msgstr "" +"meson-python、scikit-build-core、Setuptools などのビルドツールには、マクロを" +"設定し、拡張のファイル名やほかのメタデータと同期させる仕組みがあることが多い" +"です。\n" +"その仕組みがある場合は、手動でマクロを定義するよりもそちらを使ってください。" -#: ../../c-api/stable.rst:134 msgid "" "The rest of this section is mainly relevant for tool authors, and for people " "who compile extensions manually." msgstr "" +"この節の残りは、主にツールの作者と手動で拡張をコンパイルする人に関係します。" -#: ../../c-api/stable.rst:137 msgid "`list of recommended tools`_ in the Python Packaging User Guide" msgstr "" +"Python Packaging User Guide の `推奨ツールの一覧 `_" -#: ../../c-api/stable.rst:141 msgid "" "To compile for a Stable ABI, define one or both of the following macros to " "the lowest Python version your extension should support, in :c:macro:" "`Py_PACK_VERSION` format. Typically, you should choose a specific value " "rather than the version of the Python headers you are compiling against." msgstr "" +"Stable ABI 向けにコンパイルするには、以下のマクロの一方または両方を、拡張でサ" +"ポートする最も古い Python バージョンに :c:macro:`Py_PACK_VERSION` 形式で定義" +"します。\n" +"通常は、コンパイルに使う Python ヘッダのバージョンではなく、具体的な値を選ん" +"でください。" -#: ../../c-api/stable.rst:147 msgid "" "The macros must be defined before including ``Python.h``. Since :c:macro:" "`Py_PACK_VERSION` is not available at this point, you will need to use the " "numeric value directly. For reference, the values for a few recent Python " "versions are:" msgstr "" +"マクロは ``Python.h`` をインクルードする前に定義する必要があります。\n" +"この時点では :c:macro:`Py_PACK_VERSION` を使えないため、数値を直接使う必要が" +"あります。\n" +"参考として、最近の Python バージョンの値をいくつか示します。" -#: ../../c-api/stable.rst:1 msgid "" "0x30a0000 /* Py_PACK_VERSION(3,10) */\n" "0x30b0000 /* Py_PACK_VERSION(3,11) */\n" @@ -237,8 +294,13 @@ msgid "" "0x30e0000 /* Py_PACK_VERSION(3,14) */\n" "0x30f0000 /* Py_PACK_VERSION(3,15) */" msgstr "" +"0x30a0000 /* Py_PACK_VERSION(3,10) */\n" +"0x30b0000 /* Py_PACK_VERSION(3,11) */\n" +"0x30c0000 /* Py_PACK_VERSION(3,12) */\n" +"0x30d0000 /* Py_PACK_VERSION(3,13) */\n" +"0x30e0000 /* Py_PACK_VERSION(3,14) */\n" +"0x30f0000 /* Py_PACK_VERSION(3,15) */" -#: ../../c-api/stable.rst:154 msgid "" "When one of the macros is defined, ``Python.h`` will only expose API that is " "compatible with the given Stable ABI -- that is, the :ref:`Limited API " @@ -246,95 +308,114 @@ msgid "" "compiler but should not be used directly. When both are defined, ``Python." "h`` will only expose API compatible with both Stable ABIs." msgstr "" +"どちらかのマクロを定義すると、``Python.h`` は指定した Stable ABI と互換性のあ" +"る API だけを公開します。\n" +"つまり :ref:`Limited API ` と、コンパイラから見える必要は" +"あっても直接使うべきでない一部の定義です。\n" +"両方を定義した場合は、両方の Stable ABI と互換性のある API だけを公開します。" -#: ../../c-api/stable.rst:163 msgid "" "Target ``abi3``, that is, non-:term:`free-threaded builds ` of CPython. See :ref:`above ` for common information." msgstr "" +"``abi3``、つまり CPython の :term:`フリースレッドビルド ` ではないビルドを対象にします。\n" +"共通の情報は :ref:`前述の説明 ` を参照してください。" -#: ../../c-api/stable.rst:169 msgid "" "Target ``abi3t``, that is, :term:`free-threaded builds ` of CPython. See :ref:`above ` for common information." msgstr "" +"``abi3t``、つまり CPython の :term:`フリースレッドビルド ` を対象にします。\n" +"共通の情報は :ref:`前述の説明 ` を参照してください。" -#: ../../c-api/stable.rst:175 msgid "" "Both macros specify a target ABI; the different naming style is due to " "backwards compatibility." msgstr "" +"どちらのマクロも対象の ABI を指定します。\n" +"名前の形式が異なるのは、後方互換性のためです。" -#: ../../c-api/stable.rst:178 msgid "Historical note" -msgstr "" +msgstr "歴史的な補足" -#: ../../c-api/stable.rst:180 msgid "" "You can also define ``Py_LIMITED_API`` as ``3``. This works the same as " "``0x03020000`` (Python 3.2, the version that introduced Stable ABI)." msgstr "" +"``Py_LIMITED_API`` を ``3`` と定義することもできます。\n" +"これは ``0x03020000`` (Stable ABI を導入した Python 3.2) と同じように機能しま" +"す。" -#: ../../c-api/stable.rst:183 msgid "" "When both are defined, ``Python.h`` may, or may not, redefine :c:macro:`!" "Py_LIMITED_API` to match :c:macro:`!Py_TARGET_ABI3T`." msgstr "" +"両方が定義されている場合、``Python.h`` は :c:macro:`!Py_LIMITED_API` を :c:" +"macro:`!Py_TARGET_ABI3T` に合わせて再定義する場合としない場合があります。" -#: ../../c-api/stable.rst:186 msgid "" "On a :term:`free-threaded build` -- that is, when :c:macro:`Py_GIL_DISABLED` " "is defined -- :c:macro:`!Py_TARGET_ABI3T` defaults to the value of :c:macro:" "`!Py_LIMITED_API`. This means that there are two ways to build for both " "``abi3`` and ``abi3t``:" msgstr "" +":term:`フリースレッドビルド `、つまり :c:macro:" +"`Py_GIL_DISABLED` が定義されている場合、:c:macro:`!Py_TARGET_ABI3T` のデフォ" +"ルトは :c:macro:`!Py_LIMITED_API` の値です。\n" +"このため、``abi3`` と ``abi3t`` の両方を対象にビルドする方法は二つあります。" -#: ../../c-api/stable.rst:191 msgid "" "define both :c:macro:`!Py_LIMITED_API` and :c:macro:`!Py_TARGET_ABI3T`, or" msgstr "" +":c:macro:`!Py_LIMITED_API` と :c:macro:`!Py_TARGET_ABI3T` の両方を定義する、" +"または" -#: ../../c-api/stable.rst:192 msgid "define only :c:macro:`!Py_LIMITED_API` and:" -msgstr "" +msgstr ":c:macro:`!Py_LIMITED_API` だけを定義し、さらに次を行う。" -#: ../../c-api/stable.rst:194 msgid "on Windows, define :c:macro:`!Py_GIL_DISABLED`;" -msgstr "" +msgstr "Windows では :c:macro:`!Py_GIL_DISABLED` を定義する。" -#: ../../c-api/stable.rst:195 msgid "on other systems, use the headers of free-threaded build of Python." -msgstr "" +msgstr "それ以外のシステムでは、Python のフリースレッドビルドのヘッダを使う。" -#: ../../c-api/stable.rst:201 msgid "Stable ABI Scope and Performance" -msgstr "" +msgstr "Stable ABI の範囲と性能" -#: ../../c-api/stable.rst:203 msgid "" "The goal for Stable ABI is to allow everything that is possible with the " "full C API, but possibly with a performance penalty. Generally, " "compatibility with Stable ABI will require some changes to an extension's " "source code." msgstr "" +"Stable ABI の目標は、性能が低下する可能性はあるものの、完全な C API で可能な" +"ことをすべて可能にすることです。\n" +"一般に Stable ABI に対応するには、拡張のソースコードに多少の変更が必要です。" -#: ../../c-api/stable.rst:208 msgid "" "For example, while :c:func:`PyList_GetItem` is available, its \"unsafe\" " "macro variant :c:func:`PyList_GET_ITEM` is not. The macro can be faster " "because it can rely on version-specific implementation details of the list " "object." msgstr "" +"例えば :c:func:`PyList_GetItem` は利用できますが、「安全でない」マクロ版の :" +"c:func:`PyList_GET_ITEM` は利用できません。\n" +"このマクロは、リストオブジェクトのバージョン固有の実装の詳細に依存できるた" +"め、高速な場合があります。" -#: ../../c-api/stable.rst:213 msgid "" "For another example, when *not* compiling for Stable ABI, some C API " "functions are inlined or replaced by macros. Compiling for Stable ABI " "disables this inlining, allowing stability as Python's data structures are " "improved, but possibly reducing performance." msgstr "" +"また、Stable ABI 向けにコンパイル *しない* 場合、一部の C API 関数はインライ" +"ン展開されたりマクロに置き換えられたりします。\n" +"Stable ABI 向けのコンパイルではこのインライン展開を無効にするため、Python の" +"データ構造が改良されても安定性を保てますが、性能が低下する可能性があります。" -#: ../../c-api/stable.rst:218 msgid "" "By leaving out the :c:macro:`!Py_LIMITED_API` or :c:macro:`!Py_TARGET_ABI3T` " "definition, it is possible to compile Stable-ABI-compatible source for a " @@ -342,12 +423,15 @@ msgid "" "then be distributed alongside a version compiled for Stable ABI -- a slower " "but more compatible fallback." msgstr "" +":c:macro:`!Py_LIMITED_API` または :c:macro:`!Py_TARGET_ABI3T` の定義を省く" +"と、Stable ABI 対応のソースをバージョン固有の ABI 向けにコンパイルできま" +"す。\n" +"その結果、性能が高くなる可能性のあるバージョン固有の拡張と、低速でも互換性の" +"高い代替として Stable ABI 向けにコンパイルした版を、併せて配布できます。" -#: ../../c-api/stable.rst:229 msgid "Stable ABI Caveats" -msgstr "" +msgstr "Stable ABI の注意点" -#: ../../c-api/stable.rst:231 msgid "" "Note that compiling for Stable ABI is *not* a complete guarantee that code " "will be compatible with the expected Python versions. Stable ABI prevents " @@ -355,8 +439,12 @@ msgid "" "due to changes in structure layouts or function signatures. However, other " "changes in Python can change the *behavior* of extensions." msgstr "" +"Stable ABI 向けにコンパイルしても、意図した Python バージョンでコードが動作す" +"る完全な保証には *なりません*。\n" +"Stable ABI は、シンボル不足によるリンクエラーや、構造体のレイアウトや関数シグ" +"ネチャの変更によるデータ破損などの *ABI* の問題を防ぎます。\n" +"ただし、Python のほかの変更によって拡張の *動作* が変わることはあります。" -#: ../../c-api/stable.rst:238 msgid "" "One issue that the :c:macro:`Py_TARGET_ABI3T` and :c:macro:`Py_LIMITED_API` " "macros do not guard against is calling a function with arguments that are " @@ -366,12 +454,21 @@ msgid "" "directly, causing a ``NULL`` dereference and crash. A similar argument works " "for fields of structs." msgstr "" +":c:macro:`Py_TARGET_ABI3T` と :c:macro:`Py_LIMITED_API` で防げない問題の一つ" +"に、古い Python では無効な引数で関数を呼び出すことがあります。\n" +"例えば、ある関数が引数として ``NULL`` を受け取るようになった場合を考えてくだ" +"さい。\n" +"Python 3.9 では ``NULL`` がデフォルトの動作を選択するのに、Python 3.8 では引" +"数をそのまま使ってしまい、``NULL`` の参照先へのアクセスによってクラッシュする" +"かもしれません。\n" +"構造体のフィールドにも同様のことが言えます。" -#: ../../c-api/stable.rst:246 msgid "" "For these reasons, we recommend testing an extension with *all* minor Python " "versions it supports." msgstr "" +"このため、拡張がサポートする *すべて* の Python マイナーバージョンでテストす" +"ることを推奨します。" #: ../../c-api/stable.rst:249 msgid "" @@ -385,7 +482,6 @@ msgstr "" "が定義されていても、技術的な理由で(あるいはバグとして意図せず)いくつかのプラ" "イベート宣言が公開されることがあります。" -#: ../../c-api/stable.rst:254 msgid "" "Also note that while compiling with ``Py_LIMITED_API`` 3.8 means that the " "extension should *load* on Python 3.12, and *compile* with Python 3.12, the " @@ -393,20 +489,28 @@ msgid "" "3.12. In general, parts of the Limited API may be deprecated and removed, " "provided that Stable ABI stays stable." msgstr "" +"また、``Py_LIMITED_API`` を 3.8 にしてコンパイルした拡張は Python 3.12 で *読" +"み込め*、Python 3.12 で *コンパイルできる* はずですが、同じソースが " +"``Py_LIMITED_API`` を 3.12 にしてコンパイルできるとは限りません。\n" +"一般に、Stable ABI の安定性を維持する限り、Limited API の一部は非推奨になった" +"り削除されたりすることがあります。" #: ../../c-api/stable.rst:265 msgid "Platform Considerations" msgstr "プラットフォームで考慮すべき点" -#: ../../c-api/stable.rst:267 msgid "" "ABI stability depends not only on Python, but also on the compiler used, " "lower-level libraries and compiler options. For the purposes of the :ref:" "`Stable ABIs `, these details define a “platform”. They usually " "depend on the OS type and processor architecture" msgstr "" +"ABI の安定性は Python だけでなく、使用するコンパイラ、低レベルのライブラリ、" +"コンパイラオプションにも依存します。\n" +":ref:`Stable ABI ` では、これらの詳細をまとめて「プラットフォー" +"ム」と呼びます。\n" +"通常は OS の種類とプロセッサのアーキテクチャによって決まります。" -#: ../../c-api/stable.rst:272 msgid "" "It is the responsibility of each particular distributor of Python to ensure " "that all Python versions on a particular platform are built in a way that " @@ -414,37 +518,45 @@ msgid "" "case with Windows and macOS releases from ``python.org`` and many third-" "party distributors." msgstr "" +"特定のプラットフォーム上のすべての Python バージョンが、Stable ABI やバージョ" +"ン固有の ABI の互換性を壊さない方法でビルドされるようにするのは、それぞれの " +"Python 配布者の責任です。\n" +"``python.org`` の Windows 版と macOS 版、および多くのサードパーティの配布者は" +"これを行っています。" -#: ../../c-api/stable.rst:280 msgid "ABI Checking" -msgstr "" +msgstr "ABI の確認" -#: ../../c-api/stable.rst:284 msgid "Python includes a rudimentary check for ABI compatibility." -msgstr "" +msgstr "Python は ABI 互換性の基本的な確認機能を備えています。" -#: ../../c-api/stable.rst:286 msgid "" "This check is not comprehensive. It only guards against common cases of " "incompatible modules being installed for the wrong interpreter. It also does " "not take :ref:`platform incompatibilities ` into " "account. It can only be done after an extension is successfully loaded." msgstr "" +"この確認は網羅的ではありません。\n" +"互換性のないモジュールが誤ったインタープリタ向けにインストールされる、よくあ" +"る場合だけを防ぎます。\n" +":ref:`プラットフォームの非互換性 ` も考慮しません。\n" +"確認できるのは、拡張の読み込みに成功した後だけです。" -#: ../../c-api/stable.rst:293 msgid "" "Despite these limitations, it is recommended that extension modules use this " "mechanism, so that detectable incompatibilities raise exceptions rather than " "crash." msgstr "" +"このような制限はありますが、検出できる非互換性によってクラッシュする代わりに" +"例外を送出できるよう、拡張モジュールではこの仕組みを使うことを推奨します。" -#: ../../c-api/stable.rst:297 msgid "" "Most modules can use this check via the :c:data:`Py_mod_abi` slot and the :c:" "macro:`PyABIInfo_VAR` macro, for example like this:" msgstr "" +"ほとんどのモジュールでは、:c:data:`Py_mod_abi` スロットと :c:macro:" +"`PyABIInfo_VAR` マクロを使って、例えば次のように確認できます。" -#: ../../c-api/stable.rst:300 msgid "" "PyABIInfo_VAR(abi_info);\n" "\n" @@ -453,32 +565,39 @@ msgid "" " ...\n" "};" msgstr "" +"PyABIInfo_VAR(abi_info);\n" +"\n" +"static PyModuleDef_Slot mymodule_slots[] = {\n" +" {Py_mod_abi, &abi_info},\n" +" ...\n" +"};" -#: ../../c-api/stable.rst:310 msgid "The full API is described below for advanced use cases." -msgstr "" +msgstr "高度な用途向けに、以下で API 全体を説明します。" -#: ../../c-api/stable.rst:314 msgid "" "Verify that the given *info* is compatible with the currently running " "interpreter." msgstr "" +"指定された ``info`` が、現在実行中のインタープリタと互換性があるかどうかを確" +"認します。" -#: ../../c-api/stable.rst:317 msgid "Return 0 on success. On failure, raise an exception and return -1." msgstr "" +"成功した場合は 0 を返します。\n" +"失敗した場合は例外を送出し、-1 を返します。" -#: ../../c-api/stable.rst:319 msgid "" "If the ABI is incompatible, the raised exception will be :py:exc:" "`ImportError`." -msgstr "" +msgstr "ABI に互換性がない場合、送出する例外は :py:exc:`ImportError` です。" -#: ../../c-api/stable.rst:321 msgid "" "The *module_name* argument can be ``NULL``, or point to a NUL-terminated " "UTF-8-encoded string used for error messages." msgstr "" +"``module_name`` 引数は ``NULL``、またはエラーメッセージに使う NUL 終端の " +"UTF-8 エンコード文字列へのポインタです。" #: ../../c-api/stable.rst:324 msgid "" @@ -488,13 +607,14 @@ msgid "" "exception." msgstr "" -#: ../../c-api/stable.rst:333 msgid "" "Define a static :c:struct:`PyABIInfo` variable with the given *NAME* that " "describes the ABI that the current code will use. This macro expands to:" msgstr "" +"指定された名前 ``NAME`` で、現在のコードが使う ABI を記述する静的な :c:" +"struct:`PyABIInfo` 変数を定義します。\n" +"このマクロは次のように展開されます。" -#: ../../c-api/stable.rst:337 msgid "" "static PyABIInfo NAME = {\n" " 1, 0,\n" @@ -503,128 +623,146 @@ msgid "" " PyABIInfo_DEFAULT_ABI_VERSION\n" "}" msgstr "" +"static PyABIInfo NAME = {\n" +" 1, 0,\n" +" PyABIInfo_DEFAULT_FLAGS,\n" +" PY_VERSION_HEX,\n" +" PyABIInfo_DEFAULT_ABI_VERSION\n" +"}" -#: ../../c-api/stable.rst:352 msgid "The major version of :c:struct:`PyABIInfo`. Can be set to:" msgstr "" +":c:struct:`PyABIInfo` のメジャーバージョン。\n" +"次の値を設定できます。" -#: ../../c-api/stable.rst:354 msgid "``0`` to skip all checking, or" -msgstr "" +msgstr "``0``: すべての確認を省略する、または" -#: ../../c-api/stable.rst:355 msgid "``1`` to specify this version of :c:struct:`!PyABIInfo`." -msgstr "" +msgstr "``1``: このバージョンの :c:struct:`!PyABIInfo` を指定する。" -#: ../../c-api/stable.rst:359 msgid "" "The minor version of :c:struct:`PyABIInfo`. Must be set to ``0``; larger " "values are reserved for backwards-compatible future versions of :c:struct:`!" "PyABIInfo`." msgstr "" +":c:struct:`PyABIInfo` のマイナーバージョン。\n" +"``0`` に設定する必要があります。\n" +"それより大きな値は、将来の後方互換性を持つ :c:struct:`!PyABIInfo` のバージョ" +"ン用に予約されています。" -#: ../../c-api/stable.rst:367 msgid "This field is usually set to the following macro:" -msgstr "" +msgstr "通常、このフィールドには次のマクロを設定します。" -#: ../../c-api/stable.rst:371 msgid "" "Default flags, based on current values of macros such as :c:macro:" "`Py_LIMITED_API` and :c:macro:`Py_GIL_DISABLED`." msgstr "" +":c:macro:`Py_LIMITED_API` や :c:macro:`Py_GIL_DISABLED` などのマクロの現在の" +"値に基づく、デフォルトのフラグです。" -#: ../../c-api/stable.rst:374 msgid "" "Alternately, the field can be set to the following flags, combined by " "bitwise OR. Unused bits must be set to zero." msgstr "" +"または、以下のフラグをビット OR で組み合わせて設定できます。\n" +"未使用のビットはゼロにする必要があります。" -#: ../../c-api/stable.rst:378 msgid "ABI variant -- one of:" -msgstr "" +msgstr "ABI の種類。次のいずれかです。" -#: ../../c-api/stable.rst:382 msgid "Specifies that Stable ABI is used." -msgstr "" +msgstr "Stable ABI を使うことを指定します。" -#: ../../c-api/stable.rst:386 msgid "" "Specifies ABI specific to a particular build of CPython. Internal use only." msgstr "" +"CPython の特定のビルドに固有の ABI を指定します。\n" +"内部専用です。" -#: ../../c-api/stable.rst:389 msgid "Free-threading compatibility -- one of:" -msgstr "" +msgstr "フリースレッド対応。次のいずれかです。" -#: ../../c-api/stable.rst:393 msgid "" "Specifies ABI compatible with :term:`free-threaded builds ` of CPython. (That is, ones compiled with :option:`--disable-gil`; " "with ``t`` in :py:data:`sys.abiflags`)" msgstr "" +"CPython の :term:`フリースレッドビルド ` と互換性のある " +"ABI を指定します。\n" +"つまり :option:`--disable-gil` でコンパイルされ、:py:data:`sys.abiflags` に " +"``t`` があるビルドです。" -#: ../../c-api/stable.rst:400 msgid "" "Specifies ABI compatible with non-free-threaded builds of CPython (ones " "compiled *without* :option:`--disable-gil`)." msgstr "" +"CPython のフリースレッドでないビルド (:option:`--disable-gil` を指定 *せずに" +"* コンパイルしたもの) と互換性のある ABI を指定します。" -#: ../../c-api/stable.rst:405 msgid "" "Specifies ABI compatible with both free-threaded and non-free-threaded " "builds of CPython, that is, both ``abi3`` and ``abi3t``." msgstr "" +"CPython のフリースレッドビルドとそれ以外のビルドの両方、つまり ``abi3`` と " +"``abi3t`` の両方と互換性のある ABI を指定します。" -#: ../../c-api/stable.rst:411 msgid "" "The version of the Python headers used to build the code, in the format used " "by :c:macro:`PY_VERSION_HEX`." msgstr "" +"コードのビルドに使った Python ヘッダのバージョンを、:c:macro:" +"`PY_VERSION_HEX` と同じ形式で指定します。" -#: ../../c-api/stable.rst:414 msgid "" "This can be set to ``0`` to skip any checks related to this field. This " "option is meant mainly for projects that do not use the CPython headers " "directly, and do not emulate a specific version of them." msgstr "" +"``0`` に設定すると、このフィールドに関する確認をすべて省略できます。\n" +"主に、CPython ヘッダを直接使わず、特定バージョンのヘッダをエミュレートもしな" +"いプロジェクト向けの設定です。" -#: ../../c-api/stable.rst:420 msgid "The ABI version." -msgstr "" +msgstr "ABI のバージョン。" -#: ../../c-api/stable.rst:422 msgid "" "For Stable ABI, this field should be the value of :c:macro:`Py_LIMITED_API` " "or :c:macro:`Py_TARGET_ABI3T`. If both are defined, use the smaller value. " "(If :c:macro:`Py_LIMITED_API` is ``3``; use :c:expr:`Py_PACK_VERSION(3, 2)` " "instead of ``3``.)" msgstr "" +"Stable ABI では、このフィールドを :c:macro:`Py_LIMITED_API` または :c:macro:" +"`Py_TARGET_ABI3T` の値に設定します。\n" +"両方が定義されている場合は小さい方を使います。\n" +"(:c:macro:`Py_LIMITED_API` が ``3`` の場合は、``3`` の代わりに :c:expr:" +"`Py_PACK_VERSION(3, 2)` を使ってください。)" -#: ../../c-api/stable.rst:428 msgid "Otherwise, it should be set to :c:macro:`PY_VERSION_HEX`." -msgstr "" +msgstr "それ以外の場合は :c:macro:`PY_VERSION_HEX` に設定します。" -#: ../../c-api/stable.rst:430 msgid "It can also be set to ``0`` to skip any checks related to this field." msgstr "" +"``0`` に設定して、このフィールドに関する確認をすべて省略することもできます。" -#: ../../c-api/stable.rst:436 msgid "" "The value that should be used for this field, based on current values of " "macros such as :c:macro:`Py_LIMITED_API`, :c:macro:`PY_VERSION_HEX` and :c:" "macro:`Py_GIL_DISABLED`." msgstr "" +":c:macro:`Py_LIMITED_API`、:c:macro:`PY_VERSION_HEX`、:c:macro:" +"`Py_GIL_DISABLED` などのマクロの現在の値に基づき、このフィールドに使うべき値" +"を示します。" #: ../../c-api/stable.rst:447 msgid "Contents of Limited API" msgstr "限定版APIの内容" -#: ../../c-api/stable.rst:449 msgid "" "This is the definitive list of :ref:`Limited API ` for Python " "|version|:" msgstr "" +"Python |version| の :ref:`Limited API ` の正式な一覧です。" -#: ../../c-api/stable.rst:42 msgid "PyUnstable" -msgstr "" +msgstr "PyUnstable" diff --git a/c-api/structures.po b/c-api/structures.po index 556cb9a5c..33fb9fdb8 100644 --- a/c-api/structures.po +++ b/c-api/structures.po @@ -16,30 +16,27 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/structures.rst:6 msgid "Common Object Structures" msgstr "共通のオブジェクト構造体 (common object structure)" -#: ../../c-api/structures.rst:8 msgid "" "There are a large number of structures which are used in the definition of " "object types for Python. This section describes these structures and how " "they are used." msgstr "" -"Python では、オブジェクト型を定義する上で数多くの構造体が使われます。この節で" -"は三つの構造体とその利用方法について説明します。" +"Python のオブジェクト型の定義には、多数の構造体が使われます。\n" +"この節では、それらの構造体と使い方を説明します。" -#: ../../c-api/structures.rst:14 msgid "Base object types and macros" -msgstr "" +msgstr "基本のオブジェクト型とマクロ" -#: ../../c-api/structures.rst:16 msgid "" "All Python objects ultimately share a small number of fields at the " "beginning of the object's representation in memory. These are represented " @@ -49,6 +46,13 @@ msgid "" "Additional macros can be found under :ref:`reference counting " "`." msgstr "" +"すべての Python オブジェクトは、メモリ上の表現の先頭に少数の共通フィールドを" +"持ちます。\n" +"これらを表すのが :c:type:`PyObject` 型と :c:type:`PyVarObject` 型です。\n" +"これらの型はマクロの展開によって定義され、そのマクロは他のすべての Python オ" +"ブジェクトの定義でも直接的または間接的に使われます。\n" +"その他のマクロについては :ref:`参照カウント ` を参照してくださ" +"い。" #: ../../c-api/structures.rst:26 msgid "" @@ -60,13 +64,14 @@ msgid "" "to a :c:expr:`PyObject*`." msgstr "" -#: ../../c-api/structures.rst:33 msgid "" "The members must not be accessed directly; instead use macros such as :c:" "macro:`Py_REFCNT` and :c:macro:`Py_TYPE`." msgstr "" +"メンバーに直接アクセスしてはいけません。\n" +"代わりに :c:macro:`Py_REFCNT` や :c:macro:`Py_TYPE` などのマクロを使ってくだ" +"さい。" -#: ../../c-api/structures.rst:36 msgid "" "In the :ref:`Stable ABI ` for Free-Threaded Builds (``abi3t``), " "this struct is opaque; its size and layout may change between Python " @@ -74,34 +79,46 @@ msgid "" "member:`!ob_refcnt` and :c:member:`!ob_type` fields are available, but using " "them directly is discouraged." msgstr "" +"フリースレッドビルド用の :ref:`Stable ABI ` (``abi3t``) では、こ" +"の構造体は不透明で、サイズやレイアウトは Python のバージョン間で変わる可能性" +"があります。\n" +"フリースレッドでないビルド用の Stable ABI (``abi3``) では :c:member:`!" +"ob_refcnt` フィールドと :c:member:`!ob_type` フィールドを利用できますが、直接" +"使うことは推奨されません。" -#: ../../c-api/structures.rst:45 msgid "" "The object's reference count, as returned by :c:macro:`Py_REFCNT`. Do not " "use this field directly; instead use functions and macros such as :c:macro:`!" "Py_REFCNT`, :c:func:`Py_INCREF` and :c:func:`Py_DecRef`." msgstr "" +":c:macro:`Py_REFCNT` が返す、オブジェクトの参照カウントです。\n" +"このフィールドを直接使わず、代わりに :c:macro:`!Py_REFCNT`、:c:func:" +"`Py_INCREF`、:c:func:`Py_DecRef` などの関数やマクロを使ってください。" -#: ../../c-api/structures.rst:49 msgid "" "The field type may be different from ``Py_ssize_t``, depending on build " "configuration and platform." msgstr "" +"ビルド構成やプラットフォームによっては、フィールドの型は ``Py_ssize_t`` と異" +"なる場合があります。" -#: ../../c-api/structures.rst:54 msgid "" "The object's type. Do not use this field directly; use :c:macro:`Py_TYPE` " "and :c:func:`Py_SET_TYPE` instead." msgstr "" +"オブジェクトの型です。\n" +"このフィールドを直接使わず、代わりに :c:macro:`Py_TYPE` と :c:func:" +"`Py_SET_TYPE` を使ってください。" -#: ../../c-api/structures.rst:60 msgid "" "A :ref:`per-object lock `, present only in the :term:`free-" "threaded ` build (when :c:macro:`Py_GIL_DISABLED` is " "defined)." msgstr "" +":term:`フリースレッド ` ビルド (:c:macro:`Py_GIL_DISABLED` が" +"定義されている場合) にだけ存在する、:ref:`オブジェクトごとのロック ` です。" -#: ../../c-api/structures.rst:63 msgid "" "This field is **reserved for use by the critical section API** (:c:macro:" "`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`). Do " @@ -109,22 +126,31 @@ msgid "" "deadlocks. If you need your own lock, add a separate :c:type:`PyMutex` " "field to your object struct." msgstr "" +"このフィールドは **クリティカルセクション API 専用** です (:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`)。\n" +"``PyMutex_Lock`` で直接ロックしては **いけません**。\n" +"デッドロックを引き起こす可能性があります。\n" +"独自のロックが必要なら、オブジェクトの構造体に別の :c:type:`PyMutex` フィール" +"ドを追加してください。" -#: ../../c-api/structures.rst:74 msgid "" "An extension of :c:type:`PyObject` that adds the :c:member:`~PyVarObject." "ob_size` field. This is intended for objects that have some notion of " "*length*." msgstr "" +":c:type:`PyObject` に :c:member:`~PyVarObject.ob_size` フィールドを追加した型" +"です。\n" +"何らかの *長さ* の概念を持つオブジェクトを対象としています。" -#: ../../c-api/structures.rst:78 msgid "" "As with :c:type:`!PyObject`, the members must not be accessed directly; " "instead use macros such as :c:macro:`Py_SIZE`, :c:macro:`Py_REFCNT` and :c:" "macro:`Py_TYPE`." msgstr "" +":c:type:`!PyObject` と同様に、メンバーに直接アクセスしてはいけません。\n" +"代わりに :c:macro:`Py_SIZE`、:c:macro:`Py_REFCNT`、:c:macro:`Py_TYPE` などの" +"マクロを使ってください。" -#: ../../c-api/structures.rst:82 msgid "" "In the :ref:`Stable ABI ` for Free-Threaded Builds (``abi3t``), " "this struct is opaque; its size and layout may change between Python " @@ -132,36 +158,49 @@ msgid "" "member:`!ob_base` and :c:member:`!ob_size` fields are available, but using " "them directly is discouraged." msgstr "" +"フリースレッドビルド用の :ref:`Stable ABI ` (``abi3t``) では、こ" +"の構造体は不透明で、サイズやレイアウトは Python のバージョン間で変わる可能性" +"があります。\n" +"フリースレッドでないビルド用の Stable ABI (``abi3``) では :c:member:`!" +"ob_base` フィールドと :c:member:`!ob_size` フィールドを利用できますが、直接使" +"うことは推奨されません。" -#: ../../c-api/structures.rst:91 msgid "" "Common object header. Typically, this field is not accessed directly; " "instead :c:type:`!PyVarObject` can be cast to :c:type:`PyObject`." msgstr "" +"共通のオブジェクトヘッダーです。\n" +"通常、このフィールドには直接アクセスせず、代わりに :c:type:`!PyVarObject` " +"を :c:type:`PyObject` にキャストします。" -#: ../../c-api/structures.rst:97 msgid "" "A size field, whose contents should be considered an object's internal " "implementation detail." msgstr "" +"サイズを保持するフィールドです。\n" +"その内容はオブジェクト内部の実装詳細として扱うべきです。" -#: ../../c-api/structures.rst:100 msgid "Do not use this field directly; use :c:macro:`Py_SIZE` instead." msgstr "" +"このフィールドを直接使わず、代わりに :c:macro:`Py_SIZE` を使ってください。" -#: ../../c-api/structures.rst:102 msgid "" "Object creation functions such as :c:func:`PyObject_NewVar` will generally " "set this field to the requested size (number of items). After creation, " "arbitrary values can be stored in :c:member:`!ob_size` using :c:macro:" "`Py_SET_SIZE`." msgstr "" +":c:func:`PyObject_NewVar` などのオブジェクト作成関数は、通常、このフィールド" +"に要求されたサイズ (要素数) を設定します。\n" +"作成後は :c:macro:`Py_SET_SIZE` を使って :c:member:`!ob_size` に任意の値を格" +"納できます。" -#: ../../c-api/structures.rst:107 msgid "" "To get an object's publicly exposed length, as returned by the Python " "function :py:func:`len`, use :c:func:`PyObject_Length` instead." msgstr "" +"Python の :py:func:`len` 関数が返す、公開されたオブジェクトの長さを取得するに" +"は、代わりに :c:func:`PyObject_Length` を使ってください。" #: ../../c-api/structures.rst:114 msgid "" @@ -172,9 +211,8 @@ msgstr "" "です。\n" "PyObject_HEAD マクロは次のように展開されます::" -#: ../../c-api/structures.rst:117 msgid "PyObject ob_base;" -msgstr "" +msgstr "PyObject ob_base;" #: ../../c-api/structures.rst:119 msgid "See documentation of :c:type:`PyObject` above." @@ -190,102 +228,113 @@ msgstr "" "きに使うマクロです。\n" "PyObject_VAR_HEAD マクロは次のように展開されます::" -#: ../../c-api/structures.rst:128 msgid "PyVarObject ob_base;" -msgstr "" +msgstr "PyVarObject ob_base;" #: ../../c-api/structures.rst:130 msgid "See documentation of :c:type:`PyVarObject` above." msgstr "上にある :c:type:`PyVarObject` のドキュメントを参照してください。" -#: ../../c-api/structures.rst:135 msgid "" "The base class of all other objects, the same as :class:`object` in Python." msgstr "" +"他のすべてのオブジェクトの基底クラスで、Python の :class:`object` と同じで" +"す。" -#: ../../c-api/structures.rst:140 msgid "" "Test if the *x* object is the *y* object, the same as ``x is y`` in Python." msgstr "" +"オブジェクト *x* がオブジェクト *y* かどうかを調べます。\n" +"Python の ``x is y`` と同じです。" -#: ../../c-api/structures.rst:147 msgid "" "Test if an object is the ``None`` singleton, the same as ``x is None`` in " "Python." msgstr "" +"オブジェクトが ``None`` シングルトンかどうかを調べます。\n" +"Python の ``x is None`` と同じです。" -#: ../../c-api/structures.rst:155 msgid "" "Test if an object is the ``True`` singleton, the same as ``x is True`` in " "Python." msgstr "" +"オブジェクトが ``True`` シングルトンかどうかを調べます。\n" +"Python の ``x is True`` と同じです。" -#: ../../c-api/structures.rst:163 msgid "" "Test if an object is the ``False`` singleton, the same as ``x is False`` in " "Python." msgstr "" +"オブジェクトが ``False`` シングルトンかどうかを調べます。\n" +"Python の ``x is False`` と同じです。" -#: ../../c-api/structures.rst:171 msgid "Get the type of the Python object *o*." -msgstr "" +msgstr "Python オブジェクト *o* の型を取得します。" -#: ../../c-api/structures.rst:173 msgid "" "The returned reference is :term:`borrowed ` from *o*. Do " "not release it with :c:func:`Py_DECREF` or similar." msgstr "" +"返される参照は *o* からの :term:`借用参照 ` です。\n" +":c:func:`Py_DECREF` などで解放しないでください。" -#: ../../c-api/structures.rst:176 msgid "" ":c:func:`Py_TYPE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyObject*`." msgstr "" +":c:func:`Py_TYPE()` が static なインライン関数になりました。\n" +"引数の型は :c:expr:`const PyObject*` ではなくなりました。" -#: ../../c-api/structures.rst:183 msgid "" "Return non-zero if the object *o* type is *type*. Return zero otherwise. " "Equivalent to: ``Py_TYPE(o) == type``." msgstr "" +"オブジェクト *o* の型が *type* ならゼロ以外、それ以外ならゼロを返します。\n" +"``Py_TYPE(o) == type`` と同等です。" -#: ../../c-api/structures.rst:191 msgid "" "Set the type of object *o* to *type*, without any checking or reference " "counting." msgstr "" +"オブジェクト *o* の型を *type* に設定します。\n" +"検証も参照カウントの操作も行いません。" -#: ../../c-api/structures.rst:194 msgid "" "This is a very low-level operation. Consider instead setting the Python " "attribute :attr:`~object.__class__` using :c:func:`PyObject_SetAttrString` " "or similar." msgstr "" +"これは非常に低レベルの操作です。\n" +"代わりに :c:func:`PyObject_SetAttrString` などで Python の属性 :attr:" +"`~object.__class__` を設定することを検討してください。" -#: ../../c-api/structures.rst:198 msgid "" "Note that assigning an incompatible type can lead to undefined behavior." -msgstr "" +msgstr "互換性のない型を代入すると、未定義の動作を引き起こす可能性があります。" -#: ../../c-api/structures.rst:200 msgid "" "If *type* is a :ref:`heap type `, the caller must create a new " "reference to it. Similarly, if the old type of *o* is a heap type, the " "caller must release a reference to that type." msgstr "" +"*type* が :ref:`ヒープ型 ` である場合、呼び出し側はその型への新し" +"い参照を作成する必要があります。\n" +"同様に、*o* の以前の型がヒープ型である場合は、その型への参照を解放する必要が" +"あります。" -#: ../../c-api/structures.rst:210 msgid "Get the :c:member:`~PyVarObject.ob_size` field of *o*." -msgstr "" +msgstr "*o* の :c:member:`~PyVarObject.ob_size` フィールドを取得します。" -#: ../../c-api/structures.rst:212 msgid "" ":c:func:`Py_SIZE()` is changed to an inline static function. The parameter " "type is no longer :c:expr:`const PyVarObject*`." msgstr "" +":c:func:`Py_SIZE()` が static なインライン関数になりました。\n" +"引数の型は :c:expr:`const PyVarObject*` ではなくなりました。" -#: ../../c-api/structures.rst:219 msgid "Set the :c:member:`~PyVarObject.ob_size` field of *o* to *size*." msgstr "" +"*o* の :c:member:`~PyVarObject.ob_size` フィールドを *size* に設定します。" #: ../../c-api/structures.rst:226 msgid "" @@ -301,12 +350,14 @@ msgid "" "1, type," msgstr "" -#: ../../c-api/structures.rst:235 msgid "" "This is a macro which expands to initialization values for a new :c:type:" "`PyVarObject` type, including the :c:member:`~PyVarObject.ob_size` field. " "This macro expands to::" msgstr "" +":c:member:`~PyVarObject.ob_size` フィールドを含む、新しい :c:type:" +"`PyVarObject` 型の初期値に展開されるマクロです。\n" +"次のように展開されます。 ::" #: ../../c-api/structures.rst:239 msgid "" @@ -314,11 +365,9 @@ msgid "" "1, type, size," msgstr "" -#: ../../c-api/structures.rst:244 msgid "Implementing functions and methods" -msgstr "" +msgstr "関数とメソッドの実装" -#: ../../c-api/structures.rst:248 msgid "" "Type of the functions used to implement most Python callables in C. " "Functions of this type take two :c:expr:`PyObject*` parameters and return " @@ -327,67 +376,90 @@ msgid "" "value of the function as exposed in Python. The function must return a new " "reference." msgstr "" +"Python の呼び出し可能オブジェクトの多くを C で実装するための関数の型です。\n" +"この型の関数は 2 つの :c:expr:`PyObject*` 引数を受け取り、同じ型の値を返しま" +"す。\n" +"戻り値が ``NULL`` の場合、例外が設定されていなければなりません。\n" +"``NULL`` でない場合は、Python に公開された関数の戻り値として扱われます。\n" +"この関数は新しい参照を返さなければなりません。" #: ../../c-api/structures.rst:255 msgid "The function signature is::" msgstr "関数のシグネチャは次のとおりです ::" -#: ../../c-api/structures.rst:257 msgid "" "PyObject *PyCFunction(PyObject *self,\n" " PyObject *args);" msgstr "" +"PyObject *PyCFunction(PyObject *self,\n" +" PyObject *args);" -#: ../../c-api/structures.rst:262 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_VARARGS | METH_KEYWORDS `. " "The function signature is::" msgstr "" +":ref:`METH_VARARGS | METH_KEYWORDS ` のシグネチャ" +"を持つ Python の呼び出し可能オブジェクトを C で実装するための関数の型です。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/structures.rst:266 msgid "" "PyObject *PyCFunctionWithKeywords(PyObject *self,\n" " PyObject *args,\n" " PyObject *kwargs);" msgstr "" +"PyObject *PyCFunctionWithKeywords(PyObject *self,\n" +" PyObject *args,\n" +" PyObject *kwargs);" -#: ../../c-api/structures.rst:273 msgid "" "Type of the functions used to implement Python callables in C with " "signature :c:macro:`METH_FASTCALL`. The function signature is::" msgstr "" +":c:macro:`METH_FASTCALL` のシグネチャを持つ Python の呼び出し可能オブジェクト" +"を C で実装するための関数の型です。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/structures.rst:277 msgid "" "PyObject *PyCFunctionFast(PyObject *self,\n" " PyObject *const *args,\n" " Py_ssize_t nargs);" msgstr "" +"PyObject *PyCFunctionFast(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs);" -#: ../../c-api/structures.rst:283 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" +":ref:`METH_FASTCALL | METH_KEYWORDS ` のシグネ" +"チャを持つ Python の呼び出し可能オブジェクトを C で実装するための関数の型で" +"す。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/structures.rst:287 msgid "" "PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" " PyObject *const *args,\n" " Py_ssize_t nargs,\n" " PyObject *kwnames);" msgstr "" +"PyObject *PyCFunctionFastWithKeywords(PyObject *self,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames);" -#: ../../c-api/structures.rst:294 msgid "" "Type of the functions used to implement Python callables in C with " "signature :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `. The function signature is::" msgstr "" +":ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS ` のシグネチャを持つ Python の呼び出し可能オブジェクトを C で実" +"装するための関数の型です。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/structures.rst:298 msgid "" "PyObject *PyCMethod(PyObject *self,\n" " PyTypeObject *defining_class,\n" @@ -395,6 +467,11 @@ msgid "" " Py_ssize_t nargs,\n" " PyObject *kwnames)" msgstr "" +"PyObject *PyCMethod(PyObject *self,\n" +" PyTypeObject *defining_class,\n" +" PyObject *const *args,\n" +" Py_ssize_t nargs,\n" +" PyObject *kwnames)" #: ../../c-api/structures.rst:309 msgid "" @@ -404,27 +481,23 @@ msgstr "" "拡張型のメソッドを記述する際に用いる構造体です。この構造体には 4 つのフィール" "ドがあります:" -#: ../../c-api/structures.rst:314 msgid "Name of the method." -msgstr "" +msgstr "メソッドの名前。" -#: ../../c-api/structures.rst:316 msgid "A ``NULL`` *ml_name* marks the end of a :c:type:`!PyMethodDef` array." msgstr "" +"*ml_name* が ``NULL`` のエントリーは、:c:type:`!PyMethodDef` 配列の終端を示し" +"ます。" -#: ../../c-api/structures.rst:320 msgid "Pointer to the C implementation." -msgstr "" +msgstr "C での実装へのポインタ。" -#: ../../c-api/structures.rst:324 msgid "Flags bits indicating how the call should be constructed." -msgstr "" +msgstr "呼び出しの構成方法を示すフラグビット。" -#: ../../c-api/structures.rst:328 msgid "Points to the contents of the docstring." -msgstr "" +msgstr "ドキュメント文字列の内容へのポインタ。" -#: ../../c-api/structures.rst:330 msgid "" "The :c:member:`~PyMethodDef.ml_meth` is a C function pointer. The functions " "may be of different types, but they always return :c:expr:`PyObject*`. If " @@ -433,17 +506,24 @@ msgid "" "first parameter as :c:expr:`PyObject*`, it is common that the method " "implementation uses the specific C type of the *self* object." msgstr "" +":c:member:`~PyMethodDef.ml_meth` は C の関数ポインタです。\n" +"関数の型はさまざまですが、戻り値は常に :c:expr:`PyObject*` です。\n" +"関数が :c:type:`PyCFunction` 型でない場合、メソッドテーブル内でのキャストがコ" +"ンパイラから要求されます。\n" +":c:type:`PyCFunction` では第 1 引数を :c:expr:`PyObject*` と定義しています" +"が、メソッドの実装では *self* オブジェクト固有の C 型を使うのが一般的です。" -#: ../../c-api/structures.rst:338 msgid "" "The :c:member:`~PyMethodDef.ml_flags` field is a bitfield which can include " "the following flags. The individual flags indicate either a calling " "convention or a binding convention." msgstr "" +":c:member:`~PyMethodDef.ml_flags` フィールドは、次のフラグを含められるビット" +"フィールドです。\n" +"各フラグは呼び出し規約または束縛の規約を示します。" -#: ../../c-api/structures.rst:343 msgid "There are these calling conventions:" -msgstr "" +msgstr "次の呼び出し規約があります。" #: ../../c-api/structures.rst:347 msgid "" @@ -461,7 +541,6 @@ msgstr "" "オブジェクトです。パラメタは通常、 :c:func:`PyArg_ParseTuple` や :c:func:" "`PyArg_UnpackTuple` で処理されます。" -#: ../../c-api/structures.rst:357 msgid "" "Can only be used in certain combinations with other flags: :ref:" "`METH_VARARGS | METH_KEYWORDS `, :ref:" @@ -469,12 +548,15 @@ msgid "" "`METH_METHOD | METH_FASTCALL | METH_KEYWORDS `." msgstr "" +"他のフラグとの特定の組み合わせでのみ使えます。\n" +"使えるのは :ref:`METH_VARARGS | METH_KEYWORDS `、:ref:`METH_FASTCALL | METH_KEYWORDS `、:ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS " +"` です。" -#: ../../c-api/structures.rst:365 msgid ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -msgstr "" +msgstr ":c:expr:`METH_VARARGS | METH_KEYWORDS`" -#: ../../c-api/structures.rst:366 msgid "" "Methods with these flags must be of type :c:type:`PyCFunctionWithKeywords`. " "The function expects three parameters: *self*, *args*, *kwargs* where " @@ -482,8 +564,13 @@ msgid "" "if there are no keyword arguments. The parameters are typically processed " "using :c:func:`PyArg_ParseTupleAndKeywords`." msgstr "" +"これらのフラグを持つメソッドは :c:type:`PyCFunctionWithKeywords` 型でなければ" +"なりません。\n" +"この関数は *self*、*args*、*kwargs* の 3 引数を受け取ります。\n" +"*kwargs* はすべてのキーワード引数を含む辞書で、キーワード引数がなければ " +"``NULL`` の場合もあります。\n" +"通常は :c:func:`PyArg_ParseTupleAndKeywords` で引数を処理します。" -#: ../../c-api/structures.rst:375 msgid "" "Fast calling convention supporting only positional arguments. The methods " "have the type :c:type:`PyCFunctionFast`. The first parameter is *self*, the " @@ -491,16 +578,18 @@ msgid "" "arguments and the third parameter is the number of arguments (the length of " "the array)." msgstr "" +"位置引数のみをサポートする高速な呼び出し規約です。\n" +"メソッドは :c:type:`PyCFunctionFast` 型です。\n" +"第 1 引数は *self*、第 2 引数は引数を表す :c:expr:`PyObject*` 値の C 配列、" +"第 3 引数は引数の個数 (配列の長さ) です。" -#: ../../c-api/structures.rst:385 msgid "``METH_FASTCALL`` is now part of the :ref:`stable ABI `." msgstr "" +"``METH_FASTCALL`` が :ref:`Stable ABI ` の一部になりました。" -#: ../../c-api/structures.rst:390 msgid ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -msgstr "" +msgstr ":c:expr:`METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:391 msgid "" "Extension of :c:macro:`METH_FASTCALL` supporting also keyword arguments, " "with methods of type :c:type:`PyCFunctionFastWithKeywords`. Keyword " @@ -511,33 +600,45 @@ msgid "" "The values of the keyword arguments are stored in the *args* array, after " "the positional arguments." msgstr "" +":c:macro:`METH_FASTCALL` を拡張してキーワード引数もサポートするもので、メソッ" +"ドは :c:type:`PyCFunctionFastWithKeywords` 型です。\n" +"キーワード引数は :ref:`vectorcall プロトコル ` と同じ方法で渡され" +"ます。\n" +":c:expr:`PyObject*` 型の第 4 引数が追加され、キーワード引数の名前 (文字列であ" +"ることが保証されます) のタプルを渡します。\n" +"キーワード引数がなければ ``NULL`` の場合もあります。\n" +"キーワード引数の値は *args* 配列の位置引数の後に格納されます。" -#: ../../c-api/structures.rst:406 msgid "" "Can only be used in the combination with other flags: :ref:`METH_METHOD | " "METH_FASTCALL | METH_KEYWORDS `." msgstr "" +"他のフラグとの組み合わせ :ref:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS " +"` でのみ使えます。" -#: ../../c-api/structures.rst:412 msgid ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -msgstr "" +msgstr ":c:expr:`METH_METHOD | METH_FASTCALL | METH_KEYWORDS`" -#: ../../c-api/structures.rst:413 msgid "" "Extension of :ref:`METH_FASTCALL | METH_KEYWORDS ` supporting the *defining class*, that is, the class that " "contains the method in question. The defining class might be a superclass of " "``Py_TYPE(self)``." msgstr "" +":ref:`METH_FASTCALL | METH_KEYWORDS ` を拡張し、" +"*定義元のクラス*、つまりそのメソッドを含むクラスを扱えるようにしたもので" +"す。\n" +"定義元のクラスは ``Py_TYPE(self)`` の基底クラスである場合もあります。" -#: ../../c-api/structures.rst:418 msgid "" "The method needs to be of type :c:type:`PyCMethod`, the same as for " "``METH_FASTCALL | METH_KEYWORDS`` with ``defining_class`` argument added " "after ``self``." msgstr "" +"メソッドは :c:type:`PyCMethod` 型でなければなりません。\n" +"これは ``METH_FASTCALL | METH_KEYWORDS`` と同じですが、``self`` の後に " +"``defining_class`` 引数が追加されています。" -#: ../../c-api/structures.rst:427 msgid "" "Methods without parameters don't need to check whether arguments are given " "if they are listed with the :c:macro:`METH_NOARGS` flag. They need to be of " @@ -545,14 +646,21 @@ msgid "" "and will hold a reference to the module or object instance. In all cases " "the second parameter will be ``NULL``." msgstr "" +"引数を取らないメソッドに :c:macro:`METH_NOARGS` フラグを指定すると、引数が渡" +"されたかどうかをメソッド内で確認する必要がなくなります。\n" +"このメソッドは :c:type:`PyCFunction` 型でなければなりません。\n" +"第 1 引数は通常 *self* という名前で、モジュールまたはオブジェクトのインスタン" +"スへの参照を保持します。\n" +"第 2 引数は常に ``NULL`` です。" -#: ../../c-api/structures.rst:433 msgid "" "The function must have 2 parameters. Since the second parameter is unused, :" "c:macro:`Py_UNUSED` can be used to prevent a compiler warning." msgstr "" +"関数には 2 つの引数が必要です。\n" +"第 2 引数は使わないので、:c:macro:`Py_UNUSED` でコンパイラの警告を抑制できま" +"す。" -#: ../../c-api/structures.rst:439 msgid "" "Methods with a single object argument can be listed with the :c:macro:" "`METH_O` flag, instead of invoking :c:func:`PyArg_ParseTuple` with a " @@ -560,28 +668,41 @@ msgid "" "*self* parameter, and a :c:expr:`PyObject*` parameter representing the " "single argument." msgstr "" +"オブジェクトを 1 つ引数に取るメソッドには、``\"O\"`` を指定して :c:func:" +"`PyArg_ParseTuple` を呼び出す代わりに、:c:macro:`METH_O` フラグを指定できま" +"す。\n" +"メソッドは :c:type:`PyCFunction` 型で、*self* 引数と、唯一の引数を表す :c:" +"expr:`PyObject*` 引数を受け取ります。" -#: ../../c-api/structures.rst:445 msgid "" "These two constants are not used to indicate the calling convention but the " "binding when used with methods of classes. These may not be used for " "functions defined for modules. At most one of these flags may be set for " "any given method." msgstr "" +"次の 2 つの定数は呼び出し規約ではなく、クラスのメソッドでの束縛を指定しま" +"す。\n" +"モジュールで定義する関数には使えません。\n" +"1 つのメソッドに設定できるのは、どちらか 1 つだけです。" -#: ../../c-api/structures.rst:455 msgid "" "The method will be passed the type object as the first parameter rather than " "an instance of the type. This is used to create *class methods*, similar to " "what is created when using the :deco:`classmethod` built-in decorator." msgstr "" +"メソッドの第 1 引数には、型のインスタンスの代わりに型オブジェクトが渡されま" +"す。\n" +"組み込みデコレータ :deco:`classmethod` で作成されるものと同様の *クラスメソッ" +"ド* を作成するために使います。" -#: ../../c-api/structures.rst:465 msgid "" "The method will be passed ``NULL`` as the first parameter rather than an " "instance of the type. This is used to create *static methods*, similar to " "what is created when using the :deco:`staticmethod` built-in decorator." msgstr "" +"メソッドの第 1 引数には、型のインスタンスの代わりに ``NULL`` が渡されます。\n" +"組み込みデコレータ :deco:`staticmethod` で作成されるものと同様の *静的メソッ" +"ド* を作成するために使います。" #: ../../c-api/structures.rst:469 msgid "" @@ -591,7 +712,6 @@ msgstr "" "もう一つの定数は、あるメソッドを同名の別のメソッド定義と置き換えるかどうかを" "制御します。" -#: ../../c-api/structures.rst:475 msgid "" "The method will be loaded in place of existing definitions. Without " "*METH_COEXIST*, the default is to skip repeated definitions. Since slot " @@ -603,6 +723,16 @@ msgid "" "This is helpful because calls to PyCFunctions are optimized more than " "wrapper object calls." msgstr "" +"既存の定義を置き換えてメソッドを登録します。\n" +"*METH_COEXIST* がない場合、デフォルトでは重複する定義をスキップします。\n" +"スロットラッパーはメソッドテーブルより先に登録されるため、例えば " +"*sq_contains* スロットがあると、:meth:`~object.__contains__` という名前のラッ" +"プされたメソッドが生成され、同じ名前に対応する PyCFunction は登録されませ" +"ん。\n" +"このフラグがある場合、ラッパーオブジェクトの代わりに PyCFunction が登録され、" +"スロットと共存します。\n" +"PyCFunction の呼び出しはラッパーオブジェクトの呼び出しより最適化されているの" +"で、この方法が役立ちます。" #: ../../c-api/structures.rst:488 msgid "" @@ -610,125 +740,143 @@ msgid "" "as :class:`types.BuiltinMethodType` in the Python layer." msgstr "" -#: ../../c-api/structures.rst:494 msgid "" "Return true if *op* is an instance of the :c:type:`PyCMethod_Type` type or a " "subtype of it. This function always succeeds." msgstr "" +"*op* が :c:type:`PyCMethod_Type` 型またはそのサブタイプのインスタンスなら真を" +"返します。\n" +"この関数は常に成功します。" -#: ../../c-api/structures.rst:500 msgid "" "This is the same as :c:func:`PyCMethod_Check`, but does not account for " "subtypes." -msgstr "" +msgstr ":c:func:`PyCMethod_Check` と同じですが、サブタイプは対象にしません。" -#: ../../c-api/structures.rst:506 msgid "" "Turn *ml* into a Python :term:`callable` object. The caller must ensure that " "*ml* outlives the :term:`callable`. Typically, *ml* is defined as a static " "variable." msgstr "" +"*ml* を Python の :term:`呼び出し可能 ` オブジェクトにします。\n" +"呼び出し側は、*ml* がその :term:`呼び出し可能 ` オブジェクトより長" +"く存続するようにしなければなりません。\n" +"通常、*ml* は静的変数として定義します。" -#: ../../c-api/structures.rst:510 msgid "" "The *self* parameter will be passed as the *self* argument to the C function " "in ``ml->ml_meth`` when invoked. *self* can be ``NULL``." msgstr "" +"*self* 引数は、``ml->ml_meth`` の C 関数を呼び出すときに、その関数の *self* " +"引数として渡されます。\n" +"*self* は ``NULL`` にできます。" -#: ../../c-api/structures.rst:514 msgid "" "The :term:`callable` object's ``__module__`` attribute can be set from the " "given *module* argument. *module* should be a Python string, which will be " "used as name of the module the function is defined in. If unavailable, it " "can be set to :const:`None` or ``NULL``." msgstr "" +"渡された *module* 引数から、:term:`呼び出し可能 ` オブジェクトの " +"``__module__`` 属性を設定できます。\n" +"*module* は Python の文字列で、関数の定義元モジュールの名前として使われま" +"す。\n" +"名前が分からない場合は :const:`None` または ``NULL`` にできます。" -#: ../../c-api/structures.rst:520 msgid ":attr:`function.__module__`" -msgstr "" +msgstr ":attr:`function.__module__`" -#: ../../c-api/structures.rst:522 msgid "" "The *cls* parameter will be passed as the *defining_class* argument to the C " "function. Must be set if :c:macro:`METH_METHOD` is set on ``ml->ml_flags``." msgstr "" +"*cls* 引数は C 関数の *defining_class* 引数として渡されます。\n" +"``ml->ml_flags`` に :c:macro:`METH_METHOD` が設定されている場合は、指定する必" +"要があります。" -#: ../../c-api/structures.rst:531 msgid "" "The type object corresponding to Python C function objects. This is " "available as :class:`types.BuiltinFunctionType` in the Python layer." msgstr "" +"Python の C 関数オブジェクトに対応する型オブジェクトです。\n" +"Python レベルでは :class:`types.BuiltinFunctionType` として利用できます。" -#: ../../c-api/structures.rst:537 msgid "" "Return true if *op* is an instance of the :c:type:`PyCFunction_Type` type or " "a subtype of it. This function always succeeds." msgstr "" +"*op* が :c:type:`PyCFunction_Type` 型またはそのサブタイプのインスタンスなら真" +"を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/structures.rst:543 msgid "" "This is the same as :c:func:`PyCFunction_Check`, but does not account for " "subtypes." -msgstr "" +msgstr ":c:func:`PyCFunction_Check` と同じですが、サブタイプは対象にしません。" -#: ../../c-api/structures.rst:549 msgid "Equivalent to ``PyCMethod_New(ml, self, module, NULL)``." -msgstr "" +msgstr "``PyCMethod_New(ml, self, module, NULL)`` と同等です。" -#: ../../c-api/structures.rst:554 msgid "Equivalent to ``PyCMethod_New(ml, self, NULL, NULL)``." -msgstr "" +msgstr "``PyCMethod_New(ml, self, NULL, NULL)`` と同等です。" -#: ../../c-api/structures.rst:559 msgid "" "Get the function's flags on *func* as they were passed to :c:member:" "`~PyMethodDef.ml_flags`." msgstr "" +":c:member:`~PyMethodDef.ml_flags` に渡された、*func* の関数フラグを取得しま" +"す。" -#: ../../c-api/structures.rst:562 ../../c-api/structures.rst:580 -#: ../../c-api/structures.rst:600 msgid "" "If *func* is not a C function object, this fails with an exception. *func* " "must not be ``NULL``." msgstr "" +"*func* が C 関数オブジェクトでない場合、例外を設定して失敗します。\n" +"*func* は ``NULL`` であってはいけません。" -#: ../../c-api/structures.rst:565 msgid "" "This function returns the function's flags on success, and ``-1`` with an " "exception set on failure." msgstr "" +"成功すると関数のフラグを返し、失敗すると例外を設定して ``-1`` を返します。" -#: ../../c-api/structures.rst:571 msgid "" "This is the same as :c:func:`PyCFunction_GetFlags`, but without error or " "type checking." msgstr "" +":c:func:`PyCFunction_GetFlags` と同じですが、エラーや型のチェックを行いませ" +"ん。" -#: ../../c-api/structures.rst:577 msgid "" "Get the function pointer on *func* as it was passed to :c:member:" "`~PyMethodDef.ml_meth`." msgstr "" +":c:member:`~PyMethodDef.ml_meth` に渡された、*func* の関数ポインタを取得しま" +"す。" -#: ../../c-api/structures.rst:583 msgid "" "This function returns the function pointer on success, and ``NULL`` with an " "exception set on failure." msgstr "" +"成功すると関数ポインタを返し、失敗すると例外を設定して ``NULL`` を返します。" -#: ../../c-api/structures.rst:589 msgid "" "This is the same as :c:func:`PyCFunction_GetFunction`, but without error or " "type checking." msgstr "" +":c:func:`PyCFunction_GetFunction` と同じですが、エラーや型のチェックを行いま" +"せん。" -#: ../../c-api/structures.rst:595 msgid "" "Get the \"self\" object on *func*. This is the object that would be passed " "to the first argument of a :c:type:`PyCFunction`. For C function objects " "created through a :c:type:`PyMethodDef` on a :c:type:`PyModuleDef`, this is " "the resulting module object." msgstr "" +"*func* の「self」オブジェクトを取得します。\n" +"これは :c:type:`PyCFunction` の第 1 引数に渡されるオブジェクトです。\n" +":c:type:`PyModuleDef` 上の :c:type:`PyMethodDef` を介して作成した C 関数オブ" +"ジェクトでは、作成されたモジュールオブジェクトになります。" #: ../../c-api/structures.rst:603 msgid "" @@ -736,59 +884,62 @@ msgid "" "success, and ``NULL`` with an exception set on failure." msgstr "" -#: ../../c-api/structures.rst:609 msgid "" "This is the same as :c:func:`PyCFunction_GetSelf`, but without error or type " "checking." msgstr "" +":c:func:`PyCFunction_GetSelf` と同じですが、エラーや型のチェックを行いませ" +"ん。" -#: ../../c-api/structures.rst:614 msgid "Accessing attributes of extension types" -msgstr "" +msgstr "拡張型の属性へのアクセス" -#: ../../c-api/structures.rst:618 msgid "" "Structure which describes an attribute of a type which corresponds to a C " "struct member. When defining a class, put a NULL-terminated array of these " "structures in the :c:member:`~PyTypeObject.tp_members` slot." msgstr "" +"C 構造体のメンバーに対応する、型の属性を記述する構造体です。\n" +"クラスを定義するときは、この構造体の NULL で終端した配列を :c:member:" +"`~PyTypeObject.tp_members` スロットに設定します。" -#: ../../c-api/structures.rst:623 msgid "Its fields are, in order:" -msgstr "" +msgstr "フィールドは順に次のとおりです。" -#: ../../c-api/structures.rst:627 msgid "" "Name of the member. A NULL value marks the end of a ``PyMemberDef[]`` array." msgstr "" +"メンバーの名前。\n" +"NULL 値は ``PyMemberDef[]`` 配列の終端を示します。" -#: ../../c-api/structures.rst:630 msgid "The string should be static, no copy is made of it." msgstr "" +"文字列は静的に割り当てられている必要があります。\n" +"コピーは作成されません。" -#: ../../c-api/structures.rst:634 msgid "" "The type of the member in the C struct. See :ref:`PyMemberDef-types` for the " "possible values." msgstr "" +"C 構造体内のメンバーの型。\n" +"使用できる値は :ref:`PyMemberDef-types` を参照してください。" -#: ../../c-api/structures.rst:639 msgid "" "The offset in bytes that the member is located on the type’s object struct." -msgstr "" +msgstr "その型のオブジェクト構造体内での、メンバーのバイト単位のオフセット。" -#: ../../c-api/structures.rst:643 msgid "" "Zero or more of the :ref:`PyMemberDef-flags`, combined using bitwise OR." -msgstr "" +msgstr ":ref:`PyMemberDef-flags` を 0 個以上、ビット OR で組み合わせた値。" -#: ../../c-api/structures.rst:647 msgid "" "The docstring, or NULL. The string should be static, no copy is made of it. " "Typically, it is defined using :c:macro:`PyDoc_STR`." msgstr "" +"ドキュメント文字列、または NULL。\n" +"文字列は静的に割り当てられている必要があり、コピーは作成されません。\n" +"通常は :c:macro:`PyDoc_STR` を使って定義します。" -#: ../../c-api/structures.rst:651 msgid "" "By default (when :c:member:`~PyMemberDef.flags` is ``0``), members allow " "both read and write access. Use the :c:macro:`Py_READONLY` flag for read-" @@ -796,8 +947,14 @@ msgid "" "`Py_READONLY`. Only :c:macro:`Py_T_OBJECT_EX` (and legacy :c:macro:" "`T_OBJECT`) members can be deleted." msgstr "" +"デフォルト (:c:member:`~PyMemberDef.flags` が ``0`` の場合) では、メンバーは" +"読み書きの両方を許可します。\n" +"読み取り専用にするには :c:macro:`Py_READONLY` フラグを使ってください。\n" +":c:macro:`Py_T_STRING` など、一部の型は :c:macro:`Py_READONLY` を暗黙に指定し" +"ます。\n" +"削除できるのは :c:macro:`Py_T_OBJECT_EX` (および従来の :c:macro:`T_OBJECT`) " +"のメンバーだけです。" -#: ../../c-api/structures.rst:660 msgid "" "For heap-allocated types (created using :c:func:`PyType_FromSpec` or " "similar), ``PyMemberDef`` may contain a definition for the special member " @@ -806,8 +963,14 @@ msgid "" "``Py_T_PYSSIZET``, and either ``Py_READONLY`` or ``Py_READONLY | " "Py_RELATIVE_OFFSET``. For example::" msgstr "" +"ヒープに割り当てられた型 (:c:func:`PyType_FromSpec` などで作成したもの) で" +"は、型オブジェクトの :c:member:`~PyTypeObject.tp_vectorcall_offset` に対応す" +"る特殊メンバー ``\"__vectorcalloffset__\"`` の定義を ``PyMemberDef`` に含めら" +"れます。\n" +"このメンバーは ``Py_T_PYSSIZET`` と、``Py_READONLY`` または ``Py_READONLY | " +"Py_RELATIVE_OFFSET`` のいずれかで定義しなければなりません。\n" +"例えば次のようにします。 ::" -#: ../../c-api/structures.rst:667 msgid "" "static PyMemberDef spam_type_members[] = {\n" " {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" @@ -815,12 +978,17 @@ msgid "" " {NULL} /* Sentinel */\n" "};" msgstr "" +"static PyMemberDef spam_type_members[] = {\n" +" {\"__vectorcalloffset__\", Py_T_PYSSIZET,\n" +" offsetof(Spam_object, vectorcall), Py_READONLY},\n" +" {NULL} /* 終端 */\n" +"};" -#: ../../c-api/structures.rst:673 msgid "(You may need to ``#include `` for :c:func:`!offsetof`.)" msgstr "" +"(:c:func:`!offsetof` を使うには ``#include `` が必要な場合がありま" +"す。)" -#: ../../c-api/structures.rst:675 msgid "" "The legacy offsets :c:member:`~PyTypeObject.tp_dictoffset` and :c:member:" "`~PyTypeObject.tp_weaklistoffset` can be defined similarly using " @@ -828,71 +996,85 @@ msgid "" "extensions are strongly encouraged to use :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "and :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead." msgstr "" +"従来のオフセット :c:member:`~PyTypeObject.tp_dictoffset` と :c:member:" +"`~PyTypeObject.tp_weaklistoffset` も、``\"__dictoffset__\"`` メンバーと " +"``\"__weaklistoffset__\"`` メンバーを使って同様に定義できます。\n" +"ただし、拡張モジュールでは代わりに :c:macro:`Py_TPFLAGS_MANAGED_DICT` と :c:" +"macro:`Py_TPFLAGS_MANAGED_WEAKREF` を使うことを強く推奨します。" -#: ../../c-api/structures.rst:683 msgid "" "``PyMemberDef`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" +"``PyMemberDef`` が常に利用可能になりました。\n" +"以前は ``\"structmember.h\"`` のインクルードが必要でした。" -#: ../../c-api/structures.rst:688 msgid "" ":c:macro:`Py_RELATIVE_OFFSET` is now allowed for " "``\"__vectorcalloffset__\"``, ``\"__dictoffset__\"`` and " "``\"__weaklistoffset__\"``." msgstr "" +"``\"__vectorcalloffset__\"``、``\"__dictoffset__\"``、" +"``\"__weaklistoffset__\"`` で :c:macro:`Py_RELATIVE_OFFSET` を使えるようにな" +"りました。" -#: ../../c-api/structures.rst:694 msgid "" "Get an attribute belonging to the object at address *obj_addr*. The " "attribute is described by ``PyMemberDef`` *m*. Returns ``NULL`` on error." msgstr "" +"アドレス *obj_addr* にあるオブジェクトの属性を取得します。\n" +"属性は ``PyMemberDef`` *m* で記述します。\n" +"エラー時は ``NULL`` を返します。" -#: ../../c-api/structures.rst:700 msgid "" "``PyMember_GetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" +"``PyMember_GetOne`` が常に利用可能になりました。\n" +"以前は ``\"structmember.h\"`` のインクルードが必要でした。" -#: ../../c-api/structures.rst:705 msgid "" "Set an attribute belonging to the object at address *obj_addr* to object " "*o*. The attribute to set is described by ``PyMemberDef`` *m*. Returns " "``0`` if successful and a negative value on failure." msgstr "" +"アドレス *obj_addr* にあるオブジェクトの属性を、オブジェクト *o* に設定しま" +"す。\n" +"設定する属性は ``PyMemberDef`` *m* で記述します。\n" +"成功すると ``0``、失敗すると負の値を返します。" -#: ../../c-api/structures.rst:711 msgid "" "``PyMember_SetOne`` is always available. Previously, it required including " "``\"structmember.h\"``." msgstr "" +"``PyMember_SetOne`` が常に利用可能になりました。\n" +"以前は ``\"structmember.h\"`` のインクルードが必要でした。" -#: ../../c-api/structures.rst:717 msgid "Member flags" -msgstr "" +msgstr "メンバーのフラグ" -#: ../../c-api/structures.rst:719 msgid "The following flags can be used with :c:member:`PyMemberDef.flags`:" -msgstr "" +msgstr ":c:member:`PyMemberDef.flags` には次のフラグを使えます。" -#: ../../c-api/structures.rst:723 msgid "Not writable." -msgstr "" +msgstr "書き込み不可。" -#: ../../c-api/structures.rst:727 msgid "" "Emit an ``object.__getattr__`` :ref:`audit event ` before " "reading." msgstr "" +"読み取り前に ``object.__getattr__`` :ref:`監査イベント ` を発行" +"します。" -#: ../../c-api/structures.rst:732 msgid "" "Indicates that the :c:member:`~PyMemberDef.offset` of this ``PyMemberDef`` " "entry indicates an offset from the subclass-specific data, rather than from " "``PyObject``." msgstr "" +"この ``PyMemberDef`` エントリーの :c:member:`~PyMemberDef.offset` が、" +"``PyObject`` からではなく、サブクラス固有のデータからのオフセットであることを" +"示します。" -#: ../../c-api/structures.rst:736 msgid "" "Can only be used as part of the :c:data:`Py_tp_members` :c:type:`slot " "` when creating a class using negative :c:member:`~PyType_Spec." @@ -901,8 +1083,14 @@ msgid "" "clears the flag and sets :c:member:`PyMemberDef.offset` to the offset from " "the ``PyObject`` struct." msgstr "" +"負の :c:member:`~PyType_Spec.basicsize` を使ってクラスを作成するとき、:c:" +"data:`Py_tp_members` :c:type:`スロット ` の一部としてのみ使えま" +"す。\n" +"この場合は指定が必須です。\n" +"クラスの作成中、スロットから :c:member:`~PyTypeObject.tp_members` を設定する" +"際に、Python はこのフラグをクリアし、:c:member:`PyMemberDef.offset` を " +"``PyObject`` 構造体からのオフセットに設定します。" -#: ../../c-api/structures.rst:751 msgid "" "The :c:macro:`!RESTRICTED`, :c:macro:`!READ_RESTRICTED` and :c:macro:`!" "WRITE_RESTRICTED` macros available with ``#include \"structmember.h\"`` are " @@ -910,6 +1098,10 @@ msgid "" "equivalent to :c:macro:`Py_AUDIT_READ`; :c:macro:`!WRITE_RESTRICTED` does " "nothing." msgstr "" +"``#include \"structmember.h\"`` で利用できる :c:macro:`!RESTRICTED`、:c:" +"macro:`!READ_RESTRICTED`、:c:macro:`!WRITE_RESTRICTED` マクロは非推奨です。\n" +":c:macro:`!READ_RESTRICTED` と :c:macro:`!RESTRICTED` は :c:macro:" +"`Py_AUDIT_READ` と同等で、:c:macro:`!WRITE_RESTRICTED` は何もしません。" #: ../../c-api/structures.rst:762 msgid "" @@ -920,11 +1112,9 @@ msgid "" "names." msgstr "" -#: ../../c-api/structures.rst:771 msgid "Member types" -msgstr "" +msgstr "メンバーの型" -#: ../../c-api/structures.rst:773 msgid "" ":c:member:`PyMemberDef.type` can be one of the following macros " "corresponding to various C types. When the member is accessed in Python, it " @@ -932,12 +1122,19 @@ msgid "" "it will be converted back to the C type. If that is not possible, an " "exception such as :exc:`TypeError` or :exc:`ValueError` is raised." msgstr "" +":c:member:`PyMemberDef.type` には、各種の C の型に対応する以下のマクロのいず" +"れかを指定できます。\n" +"Python からメンバーにアクセスすると、対応する Python の型に変換されます。\n" +"Python から設定するときは、C の型に変換されます。\n" +"変換できない場合は :exc:`TypeError` や :exc:`ValueError` などの例外が送出され" +"ます。" -#: ../../c-api/structures.rst:781 msgid "" "Unless marked (D), attributes defined this way cannot be deleted using e.g. :" "keyword:`del` or :py:func:`delattr`." msgstr "" +"(D) の印がない限り、この方法で定義した属性は :keyword:`del` や :py:func:" +"`delattr` などで削除できません。" #: ../../c-api/structures.rst:785 msgid "Macro name" @@ -955,14 +1152,8 @@ msgstr "Python の型" msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../c-api/structures.rst:787 ../../c-api/structures.rst:788 -#: ../../c-api/structures.rst:789 ../../c-api/structures.rst:790 -#: ../../c-api/structures.rst:791 ../../c-api/structures.rst:792 -#: ../../c-api/structures.rst:793 ../../c-api/structures.rst:794 -#: ../../c-api/structures.rst:795 ../../c-api/structures.rst:796 -#: ../../c-api/structures.rst:797 msgid ":py:class:`int`" -msgstr "" +msgstr ":py:class:`int`" #: ../../c-api/structures.rst:788 msgid ":c:expr:`short`" @@ -976,9 +1167,8 @@ msgstr ":c:expr:`int`" msgid ":c:expr:`long`" msgstr ":c:expr:`long`" -#: ../../c-api/structures.rst:791 msgid ":c:expr:`long long`" -msgstr "" +msgstr ":c:expr:`long long`" #: ../../c-api/structures.rst:792 msgid ":c:expr:`unsigned char`" @@ -996,105 +1186,102 @@ msgstr ":c:expr:`unsigned short`" msgid ":c:expr:`unsigned long`" msgstr ":c:expr:`unsigned long`" -#: ../../c-api/structures.rst:796 msgid ":c:expr:`unsigned long long`" -msgstr "" +msgstr ":c:expr:`unsigned long long`" -#: ../../c-api/structures.rst:797 msgid ":c:expr:`Py_ssize_t`" -msgstr "" +msgstr ":c:expr:`Py_ssize_t`" #: ../../c-api/structures.rst:798 msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../c-api/structures.rst:798 ../../c-api/structures.rst:799 msgid ":py:class:`float`" -msgstr "" +msgstr ":py:class:`float`" #: ../../c-api/structures.rst:799 msgid ":c:expr:`double`" msgstr ":c:expr:`double`" -#: ../../c-api/structures.rst:800 msgid ":c:expr:`char` (written as 0 or 1)" -msgstr "" +msgstr ":c:expr:`char` (書き込まれる値は 0 または 1)" -#: ../../c-api/structures.rst:800 msgid ":py:class:`bool`" -msgstr "" +msgstr ":py:class:`bool`" -#: ../../c-api/structures.rst:802 msgid ":c:expr:`const char *` (*)" -msgstr "" +msgstr ":c:expr:`const char *` (*)" -#: ../../c-api/structures.rst:802 ../../c-api/structures.rst:803 msgid ":py:class:`str` (RO)" -msgstr "" +msgstr ":py:class:`str` (RO)" -#: ../../c-api/structures.rst:803 msgid ":c:expr:`const char[]` (*)" -msgstr "" +msgstr ":c:expr:`const char[]` (*)" -#: ../../c-api/structures.rst:804 msgid ":c:expr:`char` (0-127)" -msgstr "" +msgstr ":c:expr:`char` (0-127)" -#: ../../c-api/structures.rst:804 msgid ":py:class:`str` (**)" -msgstr "" +msgstr ":py:class:`str` (**)" -#: ../../c-api/structures.rst:805 msgid ":c:expr:`PyObject *`" -msgstr "" +msgstr ":c:expr:`PyObject *`" -#: ../../c-api/structures.rst:805 msgid ":py:class:`object` (D)" -msgstr "" +msgstr ":py:class:`object` (D)" -#: ../../c-api/structures.rst:808 msgid "" "(*): Zero-terminated, UTF8-encoded C string. With :c:macro:`!Py_T_STRING` " "the C representation is a pointer; with :c:macro:`!Py_T_STRING_INPLACE` the " "string is stored directly in the structure." msgstr "" +"(*): ゼロで終端された UTF-8 エンコードの C 文字列です。\n" +":c:macro:`!Py_T_STRING` では C 側の表現はポインタで、:c:macro:`!" +"Py_T_STRING_INPLACE` では文字列を構造体に直接格納します。" -#: ../../c-api/structures.rst:813 msgid "(**): String of length 1. Only ASCII is accepted." msgstr "" +"(**): 長さ 1 の文字列です。\n" +"ASCII だけを受け付けます。" -#: ../../c-api/structures.rst:815 msgid "(RO): Implies :c:macro:`Py_READONLY`." -msgstr "" +msgstr "(RO): :c:macro:`Py_READONLY` が暗黙に指定されます。" -#: ../../c-api/structures.rst:817 msgid "" "(D): Can be deleted, in which case the pointer is set to ``NULL``. Reading a " "``NULL`` pointer raises :py:exc:`AttributeError`." msgstr "" +"(D): 削除できます。\n" +"削除するとポインタは ``NULL`` になります。\n" +"``NULL`` ポインタを読み取ると :py:exc:`AttributeError` が送出されます。" -#: ../../c-api/structures.rst:843 msgid "" "In previous versions, the macros were only available with ``#include " "\"structmember.h\"`` and were named without the ``Py_`` prefix (e.g. as " "``T_INT``). The header is still available and contains the old names, along " "with the following deprecated types:" msgstr "" +"以前のバージョンでは、これらのマクロは ``#include \"structmember.h\"`` でのみ" +"利用でき、``Py_`` 接頭辞のない名前 (例えば ``T_INT``) が使われていました。\n" +"このヘッダーは引き続き利用でき、従来の名前に加えて、次の非推奨の型も含みま" +"す。" -#: ../../c-api/structures.rst:851 msgid "" "Like ``Py_T_OBJECT_EX``, but ``NULL`` is converted to ``None``. This results " "in surprising behavior in Python: deleting the attribute effectively sets it " "to ``None``." msgstr "" +"``Py_T_OBJECT_EX`` と似ていますが、``NULL`` は ``None`` に変換されます。\n" +"このため Python では、属性を削除すると実質的に ``None`` を設定することになる" +"という、意外な動作になります。" -#: ../../c-api/structures.rst:857 msgid "Always ``None``. Must be used with :c:macro:`Py_READONLY`." msgstr "" +"常に ``None``。\n" +":c:macro:`Py_READONLY` とともに使わなければなりません。" -#: ../../c-api/structures.rst:860 msgid "Defining Getters and Setters" -msgstr "" +msgstr "ゲッターとセッターの定義" #: ../../c-api/structures.rst:864 msgid "" @@ -1108,51 +1295,53 @@ msgstr "" msgid "attribute name" msgstr "属性名" -#: ../../c-api/structures.rst:873 msgid "C function to get the attribute." -msgstr "" +msgstr "属性を取得する C 関数。" -#: ../../c-api/structures.rst:877 msgid "" "Optional C function to set or delete the attribute. If ``NULL``, the " "attribute is read-only." msgstr "" +"属性を設定または削除する、省略可能な C 関数。\n" +"``NULL`` なら属性は読み取り専用になります。" #: ../../c-api/structures.rst:882 msgid "optional docstring" msgstr "任意のドキュメンテーション文字列" -#: ../../c-api/structures.rst:886 msgid "" "Optional user data pointer, providing additional data for getter and setter." msgstr "" +"ゲッターとセッターに追加データを提供する、省略可能なユーザーデータポインタ。" -#: ../../c-api/structures.rst:890 msgid "" "The ``get`` function takes one :c:expr:`PyObject*` parameter (the instance) " "and a user data pointer (the associated ``closure``):" msgstr "" +"``get`` 関数は、:c:expr:`PyObject*` 引数 (インスタンス) とユーザーデータポイ" +"ンタ (対応する ``closure``) を受け取ります。" -#: ../../c-api/structures.rst:893 msgid "" "It should return a new reference on success or ``NULL`` with a set exception " "on failure." msgstr "" -"成功または失敗時に ``NULL`` と例外の集合にされたときは新しい参照を返します。" +"成功すると新しい参照を返し、失敗すると例外を設定して ``NULL`` を返す必要があ" +"ります。" -#: ../../c-api/structures.rst:898 msgid "" "``set`` functions take two :c:expr:`PyObject*` parameters (the instance and " "the value to be set) and a user data pointer (the associated ``closure``):" msgstr "" +"``set`` 関数は、2 つの :c:expr:`PyObject*` 引数 (インスタンスと設定する値) と" +"ユーザーデータポインタ (対応する ``closure``) を受け取ります。" -#: ../../c-api/structures.rst:901 msgid "" "In case the attribute should be deleted the second parameter is ``NULL``. " "Should return ``0`` on success or ``-1`` with a set exception on failure." msgstr "" -"属性を削除する場合は、2 番目のパラメータに ``NULL`` を指定します。成功した場" -"合は ``0`` を、失敗した場合は ``-1`` を例外として返します。" +"属性を削除する場合、第 2 引数は ``NULL`` です。\n" +"成功すると ``0`` を返し、失敗すると例外を設定して ``-1`` を返す必要がありま" +"す。" #: ../../c-api/structures.rst:453 ../../c-api/structures.rst:463 msgid "built-in function" @@ -1166,94 +1355,71 @@ msgstr "クラスメソッド" msgid "staticmethod" msgstr "静的メソッド" -#: ../../c-api/structures.rst:744 msgid "READ_RESTRICTED (C macro)" -msgstr "" +msgstr "READ_RESTRICTED (C マクロ)" -#: ../../c-api/structures.rst:744 msgid "WRITE_RESTRICTED (C macro)" -msgstr "" +msgstr "WRITE_RESTRICTED (C マクロ)" -#: ../../c-api/structures.rst:744 msgid "RESTRICTED (C macro)" -msgstr "" +msgstr "RESTRICTED (C マクロ)" -#: ../../c-api/structures.rst:757 msgid "READONLY (C macro)" -msgstr "" +msgstr "READONLY (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_BYTE (C macro)" -msgstr "" +msgstr "T_BYTE (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_SHORT (C macro)" -msgstr "" +msgstr "T_SHORT (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_INT (C macro)" -msgstr "" +msgstr "T_INT (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_LONG (C macro)" -msgstr "" +msgstr "T_LONG (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_LONGLONG (C macro)" -msgstr "" +msgstr "T_LONGLONG (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_UBYTE (C macro)" -msgstr "" +msgstr "T_UBYTE (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_USHORT (C macro)" -msgstr "" +msgstr "T_USHORT (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_UINT (C macro)" -msgstr "" +msgstr "T_UINT (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_ULONG (C macro)" -msgstr "" +msgstr "T_ULONG (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_ULONGULONG (C macro)" -msgstr "" +msgstr "T_ULONGULONG (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_PYSSIZET (C macro)" -msgstr "" +msgstr "T_PYSSIZET (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_FLOAT (C macro)" -msgstr "" +msgstr "T_FLOAT (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_DOUBLE (C macro)" -msgstr "" +msgstr "T_DOUBLE (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_BOOL (C macro)" -msgstr "" +msgstr "T_BOOL (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_CHAR (C macro)" -msgstr "" +msgstr "T_CHAR (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_STRING (C macro)" -msgstr "" +msgstr "T_STRING (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_STRING_INPLACE (C macro)" -msgstr "" +msgstr "T_STRING_INPLACE (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "T_OBJECT_EX (C macro)" -msgstr "" +msgstr "T_OBJECT_EX (C マクロ)" -#: ../../c-api/structures.rst:820 msgid "structmember.h" -msgstr "" +msgstr "structmember.h" diff --git a/c-api/subinterpreters.po b/c-api/subinterpreters.po index 9cd1675e6..48a7c5350 100644 --- a/c-api/subinterpreters.po +++ b/c-api/subinterpreters.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/subinterpreters.rst:6 msgid "Multiple interpreters in a Python process" -msgstr "" +msgstr "Python プロセス内の複数のインタープリタ" #: ../../c-api/subinterpreters.rst:8 msgid "" @@ -38,7 +37,6 @@ msgstr "" "る必要があります。\n" "これを可能にするのがサブインタプリタです。" -#: ../../c-api/subinterpreters.rst:13 msgid "" "The \"main\" interpreter is the first one created when the runtime " "initializes. It is usually the only Python interpreter in a process. Unlike " @@ -48,14 +46,14 @@ msgid "" "runtime finalization. The :c:func:`PyInterpreterState_Main` function " "returns a pointer to its state." msgstr "" -"\"メイン\" インタプリタとは、ランタイムが初期化を行ったときに最初に作成された" -"インタプリタのことです。\n" -"サブインタプリタと違い、メインインタプリタにはシグナルハンドリングのような、" -"プロセス全域で唯一な責務があります。\n" -"メインインタプリタにはランタイムの初期化中の処理実行という責務もあり、通常は" -"ランタイムの終了処理中に動いているランタイムでもあります。\n" -":c:func:`PyInterpreterState_Main` 関数は、メインインタプリタの状態へのポイン" -"タを返します。" +"「メイン」インタープリタは、ランタイムの初期化時に最初に作成されるインタープ" +"リタです。\n" +"通常、プロセス内の Python インタープリタはこれだけです。\n" +"サブインタープリタとは異なり、メインインタープリタはシグナル処理などの、プロ" +"セス全体に関わる固有の役割を担います。\n" +"ランタイムの初期化中の実行も担い、通常はランタイムの終了処理中にもアクティブ" +"なインタープリタです。\n" +":c:func:`PyInterpreterState_Main` は、その状態へのポインターを返します。" #: ../../c-api/subinterpreters.rst:20 msgid "" @@ -66,69 +64,83 @@ msgstr "" "サブインタプリタを切り替えが :c:func:`PyThreadState_Swap` 関数でできます。\n" "次の関数を使ってサブインタプリタの作成と削除が行えます:" -#: ../../c-api/subinterpreters.rst:26 msgid "" "Structure containing most parameters to configure a sub-interpreter. Its " "values are used only in :c:func:`Py_NewInterpreterFromConfig` and never " "modified by the runtime." msgstr "" +"サブインタープリタの設定に使うパラメーターの大部分を含む構造体です。\n" +"値は :c:func:`Py_NewInterpreterFromConfig` でのみ使用され、ランタイムによって" +"変更されることはありません。" #: ../../c-api/subinterpreters.rst:32 msgid "Structure fields:" msgstr "構造体フィールド:" -#: ../../c-api/subinterpreters.rst:36 msgid "" "If this is ``0`` then the sub-interpreter will use its own \"object\" " "allocator state. Otherwise it will use (share) the main interpreter's." msgstr "" +"``0`` の場合、サブインタープリタは独自の「オブジェクト」アロケーターの状態を" +"使います。\n" +"それ以外の場合は、メインインタープリタの状態を共有して使います。" -#: ../../c-api/subinterpreters.rst:40 msgid "" "If this is ``0`` then :c:member:`~PyInterpreterConfig." "check_multi_interp_extensions` must be ``1`` (non-zero). If this is ``1`` " "then :c:member:`~PyInterpreterConfig.gil` must not be :c:macro:" "`PyInterpreterConfig_OWN_GIL`." msgstr "" +"``0`` の場合、:c:member:`~PyInterpreterConfig.check_multi_interp_extensions` " +"は ``1`` (ゼロ以外) でなければなりません。\n" +"``1`` の場合、:c:member:`~PyInterpreterConfig.gil` は :c:macro:" +"`PyInterpreterConfig_OWN_GIL` であってはなりません。" -#: ../../c-api/subinterpreters.rst:48 msgid "" "If this is ``0`` then the runtime will not support forking the process in " "any thread where the sub-interpreter is currently active. Otherwise fork is " "unrestricted." msgstr "" +"``0`` の場合、このサブインタープリタが現在アクティブなスレッドでは、ランタイ" +"ムはプロセスの fork を許可しません。\n" +"それ以外の場合、fork に制限はありません。" -#: ../../c-api/subinterpreters.rst:52 msgid "" "Note that the :mod:`subprocess` module still works when fork is disallowed." -msgstr "" +msgstr "fork を許可しなくても、:mod:`subprocess` モジュールは動作します。" -#: ../../c-api/subinterpreters.rst:57 msgid "" "If this is ``0`` then the runtime will not support replacing the current " "process via exec (e.g. :func:`os.execv`) in any thread where the sub-" "interpreter is currently active. Otherwise exec is unrestricted." msgstr "" +"``0`` の場合、このサブインタープリタが現在アクティブなスレッドでは、ランタイ" +"ムは exec (:func:`os.execv` など) による現在のプロセスの置き換えを許可しませ" +"ん。\n" +"それ以外の場合、exec に制限はありません。" -#: ../../c-api/subinterpreters.rst:62 msgid "" "Note that the :mod:`subprocess` module still works when exec is disallowed." -msgstr "" +msgstr "exec を許可しなくても、:mod:`subprocess` モジュールは動作します。" -#: ../../c-api/subinterpreters.rst:67 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create threads. Otherwise threads are allowed." msgstr "" +"``0`` の場合、このサブインタープリタの :mod:`threading` モジュールはスレッド" +"を作成しません。\n" +"それ以外の場合は、スレッドの作成が許可されます。" -#: ../../c-api/subinterpreters.rst:73 msgid "" "If this is ``0`` then the sub-interpreter's :mod:`threading` module won't " "create daemon threads. Otherwise daemon threads are allowed (as long as :c:" "member:`~PyInterpreterConfig.allow_threads` is non-zero)." msgstr "" +"``0`` の場合、このサブインタープリタの :mod:`threading` モジュールはデーモン" +"スレッドを作成しません。\n" +"それ以外の場合は、:c:member:`~PyInterpreterConfig.allow_threads` がゼロでない" +"限り、デーモンスレッドの作成が許可されます。" -#: ../../c-api/subinterpreters.rst:80 msgid "" "If this is ``0`` then all extension modules may be imported, including " "legacy (single-phase init) modules, in any thread where the sub-interpreter " @@ -136,36 +148,42 @@ msgid "" "pep:`489`) may be imported. (Also see :c:macro:" "`Py_mod_multiple_interpreters`.)" msgstr "" +"``0`` の場合、このサブインタープリタが現在アクティブなスレッドでは、従来の単" +"相初期化モジュールを含め、すべての拡張モジュールをインポートできます。\n" +"それ以外の場合は、多相初期化を使う拡張モジュールのみインポートできます (:pep:" +"`489` を参照)。\n" +":c:macro:`Py_mod_multiple_interpreters` も参照してください。" -#: ../../c-api/subinterpreters.rst:87 msgid "" "This must be ``1`` (non-zero) if :c:member:`~PyInterpreterConfig." "use_main_obmalloc` is ``0``." msgstr "" +":c:member:`~PyInterpreterConfig.use_main_obmalloc` が ``0`` の場合は、``1`` " +"(ゼロ以外) でなければなりません。" -#: ../../c-api/subinterpreters.rst:92 msgid "" "This determines the operation of the GIL for the sub-interpreter. It may be " "one of the following:" msgstr "" +"サブインタープリタの GIL の動作を指定します。\n" +"次のいずれかの値を取ります。" -#: ../../c-api/subinterpreters.rst:99 msgid "Use the default selection (:c:macro:`PyInterpreterConfig_SHARED_GIL`)." msgstr "" +"デフォルトの選択 (:c:macro:`PyInterpreterConfig_SHARED_GIL`) を使います。" -#: ../../c-api/subinterpreters.rst:103 msgid "Use (share) the main interpreter's GIL." -msgstr "" +msgstr "メインインタープリタの GIL を共有して使います。" -#: ../../c-api/subinterpreters.rst:107 msgid "Use the sub-interpreter's own GIL." -msgstr "" +msgstr "サブインタープリタ独自の GIL を使います。" -#: ../../c-api/subinterpreters.rst:109 msgid "" "If this is :c:macro:`PyInterpreterConfig_OWN_GIL` then :c:member:" "`PyInterpreterConfig.use_main_obmalloc` must be ``0``." msgstr "" +":c:macro:`PyInterpreterConfig_OWN_GIL` の場合、:c:member:" +"`PyInterpreterConfig.use_main_obmalloc` は ``0`` でなければなりません。" #: ../../c-api/subinterpreters.rst:123 msgid "" @@ -190,13 +208,11 @@ msgstr "" "stdout``, ``sys.stderr`` を持ちます (とはいえ、これらのストリームは根底にある" "同じファイル記述子を参照しています)。" -#: ../../c-api/subinterpreters.rst:133 msgid "" "The given *config* controls the options with which the interpreter is " "initialized." -msgstr "" +msgstr "*config* は、インタープリタの初期化に使うオプションを指定します。" -#: ../../c-api/subinterpreters.rst:136 msgid "" "Upon success, *tstate_p* will be set to the first :term:`thread state` " "created in the new sub-interpreter. This thread state is :term:`attached " @@ -206,8 +222,16 @@ msgid "" "exception state is stored in the :term:`attached thread state`, which might " "not exist." msgstr "" +"成功時は、新しいサブインタープリタで最初に作成した :term:`スレッド状態 " +"` が *tstate_p* に設定されます。\n" +"このスレッド状態は :term:`アタッチされています `。\n" +"実際のスレッドは作成しないことに注意してください。\n" +"以下のスレッド状態についての説明を参照してください。\n" +"新しいインタープリタの作成に失敗すると、*tstate_p* は ``NULL`` に設定されま" +"す。\n" +"例外の状態は :term:`アタッチされたスレッド状態 ` に保" +"存されますが、それが存在しない場合もあるため、例外は設定されません。" -#: ../../c-api/subinterpreters.rst:145 msgid "" "Like all other Python/C API functions, an :term:`attached thread state` must " "be present before calling this function, but it might be detached upon " @@ -219,14 +243,26 @@ msgid "" "current thread and the previous interpreter's :term:`attached thread state` " "will remain detached." msgstr "" +"ほかの Python/C API 関数と同様に、呼び出す前には :term:`アタッチされたスレッ" +"ド状態 ` が必要ですが、戻るときにはデタッチされている" +"場合があります。\n" +"成功時には、返されたスレッド状態が :term:`アタッチされています `。\n" +"独自の :term:`GIL` を持つサブインタープリタを作成した場合は、呼び出し元のイン" +"タープリタの :term:`アタッチされたスレッド状態 ` がデ" +"タッチされます。\n" +"関数が戻るときには、新しいインタープリタの :term:`スレッド状態 ` が現在のスレッドに :term:`アタッチされ `、元の" +"インタープリタの :term:`アタッチされていたスレッド状態 ` はデタッチされたままです。" -#: ../../c-api/subinterpreters.rst:156 msgid "" "Sub-interpreters are most effective when isolated from each other, with " "certain functionality restricted::" msgstr "" +"サブインタープリタは、一部の機能を制限して互いに隔離したときに、最も効果を発" +"揮します。 ::" -#: ../../c-api/subinterpreters.rst:159 msgid "" "PyInterpreterConfig config = {\n" " .use_main_obmalloc = 0,\n" @@ -243,28 +279,49 @@ msgid "" " Py_ExitStatusException(status);\n" "}" msgstr "" +"PyInterpreterConfig config = {\n" +" .use_main_obmalloc = 0,\n" +" .allow_fork = 0,\n" +" .allow_exec = 0,\n" +" .allow_threads = 1,\n" +" .allow_daemon_threads = 0,\n" +" .check_multi_interp_extensions = 1,\n" +" .gil = PyInterpreterConfig_OWN_GIL,\n" +"};\n" +"PyThreadState *tstate = NULL;\n" +"PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);\n" +"if (PyStatus_Exception(status)) {\n" +" Py_ExitStatusException(status);\n" +"}" -#: ../../c-api/subinterpreters.rst:174 msgid "" "Note that the config is used only briefly and does not get modified. During " "initialization the config's values are converted into various :c:type:" "`PyInterpreterState` values. A read-only copy of the config may be stored " "internally on the :c:type:`PyInterpreterState`." msgstr "" +"設定は短時間だけ使われ、変更されることはありません。\n" +"初期化中に、設定の値が :c:type:`PyInterpreterState` の各種の値に変換されま" +"す。\n" +"設定の読み取り専用のコピーが、:c:type:`PyInterpreterState` 内部に保存される場" +"合もあります。" -#: ../../c-api/subinterpreters.rst:183 msgid "Extension modules are shared between (sub-)interpreters as follows:" msgstr "" +"拡張モジュールは、インタープリタ間 (サブインタープリタを含む) で次のように共" +"有されます。" -#: ../../c-api/subinterpreters.rst:185 msgid "" "For modules using multi-phase initialization, e.g. :c:func:" "`PyModule_FromDefAndSpec`, a separate module object is created and " "initialized for each interpreter. Only C-level static and global variables " "are shared between these module objects." msgstr "" +":c:func:`PyModule_FromDefAndSpec` などの多相初期化を使うモジュールでは、イン" +"タープリタごとに別のモジュールオブジェクトを作成して初期化します。\n" +"これらのモジュールオブジェクトが共有するのは、C レベルの静的変数とグローバル" +"変数だけです。" -#: ../../c-api/subinterpreters.rst:191 msgid "" "For modules using legacy :ref:`single-phase initialization `, e.g. :c:func:`PyModule_Create`, the first time a " @@ -276,8 +333,16 @@ msgid "" "up shared across (sub-)interpreters, which might cause unwanted behavior " "(see `Bugs and caveats`_ below)." msgstr "" +":c:func:`PyModule_Create` などの従来の :ref:`単相初期化 ` を使うモジュールでは、ある拡張を最初にインポートするときは通" +"常どおり初期化し、そのモジュールの辞書の浅いコピーを保存します。\n" +"別のインタープリタ (サブインタープリタを含む) が同じ拡張をインポートすると、" +"新しいモジュールを初期化して、保存したコピーの内容を設定します。\n" +"拡張の ``init`` 関数は呼び出しません。\n" +"その結果、モジュールの辞書内のオブジェクトがインタープリタ間で共有され、望ま" +"しくない動作を引き起こす可能性があります (以下の `Bugs and caveats`_ を参" +"照)。" -#: ../../c-api/subinterpreters.rst:203 msgid "" "Note that this is different from what happens when an extension is imported " "after the interpreter has been completely re-initialized by calling :c:func:" @@ -286,8 +351,12 @@ msgid "" "initialization, this means that only C-level static and global variables are " "shared between these modules." msgstr "" +":c:func:`Py_FinalizeEx` と :c:func:`Py_Initialize` を呼び出してインタープリタ" +"を完全に再初期化した後で、拡張をインポートする場合とは異なります。\n" +"その場合は、拡張の ``initmodule`` 関数が再び呼び出され *ます*。\n" +"多相初期化の場合と同様に、これらのモジュール間で共有されるのは、C レベルの静" +"的変数とグローバル変数だけです。" -#: ../../c-api/subinterpreters.rst:223 msgid "" "Create a new sub-interpreter. This is essentially just a wrapper around :c:" "func:`Py_NewInterpreterFromConfig` with a config that preserves the existing " @@ -295,26 +364,36 @@ msgid "" "interpreter's GIL, allows fork/exec, allows daemon threads, and allows " "single-phase init modules." msgstr "" +"新しいサブインタープリタを作成します。\n" +"基本的には、従来の動作を維持する設定で :c:func:`Py_NewInterpreterFromConfig` " +"を呼び出すラッパーです。\n" +"作成されるサブインタープリタは隔離されておらず、メインインタープリタの GIL を" +"共有し、fork/exec、デーモンスレッド、単相初期化モジュールを許可します。" -#: ../../c-api/subinterpreters.rst:235 msgid "" "Destroy the (sub-)interpreter represented by the given :term:`thread state`. " "The given thread state must be :term:`attached `. " "When the call returns, there will be no :term:`attached thread state`. All " "thread states associated with this interpreter are destroyed." msgstr "" +"指定された :term:`スレッド状態 ` が表すインタープリタ (サブイン" +"タープリタを含む) を破棄します。\n" +"指定したスレッド状態は :term:`アタッチされていなければなりません `。\n" +"呼び出しから戻るときには、:term:`アタッチされたスレッド状態 ` はありません。\n" +"このインタープリタに関連付けられたすべてのスレッド状態が破棄されます。" -#: ../../c-api/subinterpreters.rst:240 msgid "" ":c:func:`Py_FinalizeEx` will destroy all sub-interpreters that haven't been " "explicitly destroyed at that point." msgstr "" +":c:func:`Py_FinalizeEx` は、その時点で明示的に破棄されていないサブインタープ" +"リタをすべて破棄します。" -#: ../../c-api/subinterpreters.rst:247 msgid "A per-interpreter GIL" -msgstr "" +msgstr "インタープリタごとの GIL" -#: ../../c-api/subinterpreters.rst:251 msgid "" "Using :c:func:`Py_NewInterpreterFromConfig` you can create a sub-interpreter " "that is completely isolated from other interpreters, including having its " @@ -325,8 +404,15 @@ msgid "" "isolation also encourages a different approach to concurrency than that of " "just using threads. (See :pep:`554` and :pep:`684`.)" msgstr "" +":c:func:`Py_NewInterpreterFromConfig` を使うと、独自の GIL を持つなど、ほかの" +"インタープリタから完全に隔離されたサブインタープリタを作成できます。\n" +"この隔離の最大の利点は、ほかのインタープリタにブロックされたり、ほかのイン" +"タープリタをブロックしたりせずに Python コードを実行できることです。\n" +"そのため、1 つの Python プロセスで Python コードを実行するときに、複数の CPU " +"コアを実際に活用できます。\n" +"また、隔離によって、単にスレッドを使うのとは異なる並行処理の方法も促されます " +"(:pep:`554` と :pep:`684` を参照)。" -#: ../../c-api/subinterpreters.rst:261 msgid "" "Using an isolated interpreter requires vigilance in preserving that " "isolation. That especially means not sharing any objects or mutable state " @@ -339,14 +425,29 @@ msgid "" "been done for the builtin singletons, small integers, and a number of other " "builtin objects." msgstr "" +"隔離されたインタープリタを使うには、隔離を維持するよう注意しなければなりませ" +"ん。\n" +"特に、スレッドセーフである保証なしにオブジェクトや可変の状態を共有してはいけ" +"ません。\n" +"参照カウントがあるため、``None`` や ``(1, 5)`` のように、それ以外の点では不変" +"なオブジェクトであっても、通常は共有できません。\n" +"単純ですが効率の劣る回避策として、ある状態やオブジェクトを使うすべての操作を" +"グローバルなロックで保護する方法があります。\n" +"また、整数や文字列のように実質的に不変なオブジェクトは、:term:`不死 " +"` にすることで、参照カウントがあっても安全にできます。\n" +"実際に、組み込みのシングルトン、小さい整数、その他多くの組み込みオブジェクト" +"にこの方法が使われています。" -#: ../../c-api/subinterpreters.rst:272 msgid "" "If you preserve isolation then you will have access to proper multi-core " "computing without the complications that come with free-threading. Failure " "to preserve isolation will expose you to the full consequences of free-" "threading, including races and hard-to-debug crashes." msgstr "" +"隔離を維持すれば、フリースレッド化に伴う複雑さなしに、複数のコアを使った計算" +"を行えます。\n" +"隔離を維持できなければ、競合状態やデバッグの難しいクラッシュなど、フリース" +"レッド化のあらゆる問題にさらされます。" #: ../../c-api/subinterpreters.rst:277 msgid "" @@ -362,7 +463,6 @@ msgstr "" msgid "Bugs and caveats" msgstr "バグと注意事項" -#: ../../c-api/subinterpreters.rst:288 msgid "" "Because sub-interpreters (and the main interpreter) are part of the same " "process, the insulation between them isn't perfect --- for example, using " @@ -374,8 +474,16 @@ msgid "" "one sub-interpreter into a namespace of another (sub-)interpreter; this " "should be avoided if possible." msgstr "" +"サブインタープリタとメインインタープリタは同じプロセスに属するため、相互の隔" +"離は完全ではありません。\n" +"例えば、:func:`os.close` のような低水準のファイル操作を使うと、誤って、あるい" +"は悪意を持って、ほかのインタープリタが開いたファイルに影響を与えられます。\n" +"また、拡張はインタープリタ間で共有されるため、正しく動作しないものもありま" +"す。\n" +"特に、単相初期化や静的なグローバル変数を使う場合に起こりやすくなります。\n" +"あるサブインタープリタで作成したオブジェクトを、別のインタープリタの名前空間" +"に挿入することもできますが、できるだけ避けるべきです。" -#: ../../c-api/subinterpreters.rst:298 msgid "" "Special care should be taken to avoid sharing user-defined functions, " "methods, instances or classes between sub-interpreters, since import " @@ -383,6 +491,12 @@ msgid "" "dictionary of loaded modules. It is equally important to avoid sharing " "objects from which the above are reachable." msgstr "" +"サブインタープリタ間で、ユーザー定義の関数、メソッド、インスタンス、クラスを" +"共有しないよう、特に注意するべきです。\n" +"それらが実行するインポート操作によって、誤ったインタープリタのロード済みモ" +"ジュールの辞書に影響する可能性があるためです。\n" +"これらのオブジェクトにたどり着けるオブジェクトの共有を避けることも、同様に重" +"要です。" #: ../../c-api/subinterpreters.rst:304 msgid "" @@ -432,21 +546,24 @@ msgstr "" "いません。GILもまた、スレッドがどのインタプリタに属しているかに関わらずすべて" "のスレッドで共有されています。" -#: ../../c-api/subinterpreters.rst:331 msgid "" ":pep:`684` introduced the possibility of a :ref:`per-interpreter GIL `. See :c:func:`Py_NewInterpreterFromConfig`." msgstr "" +":pep:`684` により、:ref:`インタープリタごとの GIL ` を持" +"てるようになりました。\n" +":c:func:`Py_NewInterpreterFromConfig` を参照してください。" -#: ../../c-api/subinterpreters.rst:338 msgid "Get the current interpreter." -msgstr "" +msgstr "現在のインタープリタを取得します。" -#: ../../c-api/subinterpreters.rst:340 msgid "" "Issue a fatal error if there is no :term:`attached thread state`. It cannot " "return NULL." msgstr "" +":term:`アタッチされたスレッド状態 ` がなければ、致命的" +"エラーを発生させます。\n" +"NULL を返すことはありません。" #: ../../c-api/subinterpreters.rst:348 msgid "" @@ -456,9 +573,10 @@ msgstr "" "インタプリタの一意な ID を返します。\n" "処理中に何かエラーが起きたら、 ``-1`` が返され、エラーがセットされます。" -#: ../../c-api/subinterpreters.rst:351 msgid "The caller must have an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" #: ../../c-api/subinterpreters.rst:358 msgid "" @@ -470,58 +588,54 @@ msgstr "" "この関数が ``NULL`` を返した場合は、ここまでで例外は送出されておらず、呼び出" "し側はインタプリタ固有の辞書は利用できないと考えなければなりません。" -#: ../../c-api/subinterpreters.rst:362 msgid "" "This is not a replacement for :c:func:`PyModule_GetState()`, which " "extensions should use to store interpreter-specific state information." msgstr "" -"この関数は :c:func:`PyModule_GetState()` を置き換えるものではなく、拡張モ" -"ジュールがインタプリタ固有の状態情報を格納するのに使うべきものです。" +"これは :c:func:`PyModule_GetState()` の代わりにはなりません。\n" +"拡張がインタープリタ固有の状態情報を保存するには、そちらを使うべきです。" -#: ../../c-api/subinterpreters.rst:365 msgid "" "The returned dictionary is borrowed from the interpreter and is valid until " "interpreter shutdown." msgstr "" +"返される辞書は、インタープリタからの借用参照であり、インタープリタの終了まで" +"有効です。" -#: ../../c-api/subinterpreters.rst:373 msgid "Type of a frame evaluation function." -msgstr "" +msgstr "フレーム評価関数の型。" -#: ../../c-api/subinterpreters.rst:375 msgid "" "The *throwflag* parameter is used by the ``throw()`` method of generators: " "if non-zero, handle the current exception." msgstr "" +"*throwflag* 引数は、ジェネレーターの ``throw()`` メソッドが使います。\n" +"ゼロ以外の場合は、現在の例外を処理します。" -#: ../../c-api/subinterpreters.rst:378 msgid "The function now takes a *tstate* parameter." -msgstr "" +msgstr "*tstate* 引数を受け取るようになりました。" -#: ../../c-api/subinterpreters.rst:381 msgid "" "The *frame* parameter changed from ``PyFrameObject*`` to " "``_PyInterpreterFrame*``." msgstr "" +"*frame* 引数が ``PyFrameObject*`` から ``_PyInterpreterFrame*`` に変わりまし" +"た。" -#: ../../c-api/subinterpreters.rst:387 msgid "Get the frame evaluation function." -msgstr "" +msgstr "フレーム評価関数を取得します。" -#: ../../c-api/subinterpreters.rst:389 ../../c-api/subinterpreters.rst:398 msgid "See the :pep:`523` \"Adding a frame evaluation API to CPython\"." msgstr "" +":pep:`523` 「Adding a frame evaluation API to CPython」を参照してください。" -#: ../../c-api/subinterpreters.rst:396 msgid "Set the frame evaluation function." -msgstr "" +msgstr "フレーム評価関数を設定します。" -#: ../../c-api/subinterpreters.rst:404 msgid "" "Enables or disables specialization why a custom frame evaluator is in place." -msgstr "" +msgstr "カスタムのフレーム評価器を使うときの特殊化を、有効または無効にします。" -#: ../../c-api/subinterpreters.rst:406 msgid "" "If *allow_specialization* is non-zero, the adaptive specializer will " "continue to specialize bytecodes even though a custom eval frame function is " @@ -530,13 +644,23 @@ msgid "" "deopt while a frame evaluation API is in place - the frame evaluation " "function needs to handle the specialized opcodes to take advantage of this." msgstr "" +"*allow_specialization* がゼロ以外の場合、カスタムのフレーム評価関数が設定され" +"ていても、適応的な特殊化によるバイトコードの特殊化を継続します。\n" +"*allow_specialization* がゼロの場合、カスタムのフレーム評価関数を設定すると特" +"殊化が無効になります。\n" +"フレーム評価 API を使用している間、標準のインタープリタループは特殊化を解除し" +"続けます。\n" +"この機能を活用するには、フレーム評価関数が特殊化されたオペコードを処理する必" +"要があります。" -#: ../../c-api/subinterpreters.rst:417 msgid "" "Return non-zero if adaptive specialization is enabled for the interpreter. " "Specialization is enabled when no custom eval frame function is set, or when " "one is set with *allow_specialization* enabled." msgstr "" +"インタープリタで適応的な特殊化が有効なら、ゼロ以外を返します。\n" +"カスタムのフレーム評価関数が設定されていない場合や、設定されていても " +"*allow_specialization* が有効な場合には、特殊化が有効です。" #: ../../c-api/subinterpreters.rst:425 msgid "Low-level APIs" @@ -548,52 +672,58 @@ msgid "" msgstr "" "次の全ての関数は :c:func:`Py_Initialize` の後に呼び出さなければなりません。" -#: ../../c-api/subinterpreters.rst:429 msgid "" ":c:func:`Py_Initialize()` now initializes the :term:`GIL` and sets an :term:" "`attached thread state`." msgstr "" +":c:func:`Py_Initialize()` が :term:`GIL` を初期化し、:term:`スレッド状態をア" +"タッチ ` するようになりました。" -#: ../../c-api/subinterpreters.rst:436 msgid "" "Create a new interpreter state object. An :term:`attached thread state` is " "not needed, but may optionally exist if it is necessary to serialize calls " "to this function." msgstr "" +"新しいインタープリタ状態オブジェクトを作成します。\n" +":term:`アタッチされたスレッド状態 ` は必要ありません" +"が、この関数の呼び出しを直列化する必要があれば、存在しても構いません。" -#: ../../c-api/subinterpreters.rst:440 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_New`` with no arguments." msgstr "" "引数無しで :ref:`監査イベント ` ``cpython.PyInterpreterState_New`` " -"を送出します。 " +"を送出します。" -#: ../../c-api/subinterpreters.rst:445 msgid "" "Reset all information in an interpreter state object. There must be an :" "term:`attached thread state` for the interpreter." msgstr "" +"インタープリタ状態オブジェクトのすべての情報をリセットします。\n" +"そのインタープリタの :term:`スレッド状態がアタッチされていなければなりません " +"`。" -#: ../../c-api/subinterpreters.rst:448 msgid "" "Raises an :ref:`auditing event ` ``cpython." "PyInterpreterState_Clear`` with no arguments." msgstr "" "引数無しで :ref:`監査イベント ` ``cpython." -"PyInterpreterState_Clear`` を送出します。 " +"PyInterpreterState_Clear`` を送出します。" -#: ../../c-api/subinterpreters.rst:453 msgid "" "Destroy an interpreter state object. There **should not** be an :term:" "`attached thread state` for the target interpreter. The interpreter state " "must have been reset with a previous call to :c:func:" "`PyInterpreterState_Clear`." msgstr "" +"インタープリタ状態オブジェクトを破棄します。\n" +"対象のインタープリタの :term:`スレッド状態がアタッチされていてはなりません " +"`。\n" +"インタープリタ状態は、事前に :c:func:`PyInterpreterState_Clear` を呼び出して" +"リセットしておく必要があります。" -#: ../../c-api/subinterpreters.rst:461 msgid "Advanced debugger support" -msgstr "" +msgstr "高度なデバッガーのサポート" #: ../../c-api/subinterpreters.rst:463 msgid "" @@ -663,14 +793,11 @@ msgstr "stderr (sys モジュール)" msgid "stdin (in module sys)" msgstr "stdin (sys モジュール)" -#: ../../c-api/subinterpreters.rst:179 ../../c-api/subinterpreters.rst:233 msgid "Py_FinalizeEx (C function)" -msgstr "" +msgstr "Py_FinalizeEx (C 関数)" -#: ../../c-api/subinterpreters.rst:179 msgid "Py_Initialize (C function)" -msgstr "" +msgstr "Py_Initialize (C の関数)" -#: ../../c-api/subinterpreters.rst:210 msgid "close (in module os)" -msgstr "" +msgstr "close (os モジュール)" diff --git a/c-api/synchronization.po b/c-api/synchronization.po index d1b895748..03c2e2c15 100644 --- a/c-api/synchronization.po +++ b/c-api/synchronization.po @@ -16,82 +16,100 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/synchronization.rst:6 msgid "Synchronization primitives" msgstr "同期プリミティブ" -#: ../../c-api/synchronization.rst:8 msgid "The C-API provides a basic mutual exclusion lock." -msgstr "" +msgstr "C API は基本的な相互排他ロックを提供します。" -#: ../../c-api/synchronization.rst:12 msgid "" "A mutual exclusion lock. The :c:type:`!PyMutex` should be initialized to " "zero to represent the unlocked state. For example::" msgstr "" +"相互排他ロックです。\n" +":c:type:`!PyMutex` は、ロックされていない状態を表すために 0 で初期化する必要" +"があります。\n" +"例えば次のようにします。 ::" -#: ../../c-api/synchronization.rst:15 msgid "PyMutex mutex = {0};" -msgstr "" +msgstr "PyMutex mutex = {0};" -#: ../../c-api/synchronization.rst:17 msgid "" "Instances of :c:type:`!PyMutex` should not be copied or moved. Both the " "contents and address of a :c:type:`!PyMutex` are meaningful, and it must " "remain at a fixed, writable location in memory." msgstr "" +":c:type:`!PyMutex` のインスタンスは、コピーしたり移動したりしてはなりませ" +"ん。\n" +":c:type:`!PyMutex` は内容とアドレスの両方が意味を持つため、書き込み可能なメモ" +"リ上の固定された場所に置き続ける必要があります。" -#: ../../c-api/synchronization.rst:23 msgid "" "A :c:type:`!PyMutex` currently occupies one byte, but the size should be " "considered unstable. The size may change in future Python releases without " "a deprecation period." msgstr "" +":c:type:`!PyMutex` は現在 1 バイトを占めますが、このサイズは安定した仕様では" +"ありません。\n" +"将来の Python リリースでは、非推奨の期間を設けずにサイズを変更する可能性があ" +"ります。" -#: ../../c-api/synchronization.rst:31 msgid "" "Lock mutex *m*. If another thread has already locked it, the calling thread " "will block until the mutex is unlocked. While blocked, the thread will " "temporarily detach the :term:`thread state ` if one " "exists." msgstr "" +"ミューテックス *m* をロックします。\n" +"別のスレッドがすでにロックしている場合、呼び出し元のスレッドはロックが解除さ" +"れるまでブロックします。\n" +"ブロック中は、:term:`スレッド状態 ` があれば一時的にデ" +"タッチします。" -#: ../../c-api/synchronization.rst:39 msgid "" "Unlock mutex *m*. The mutex must be locked --- otherwise, the function will " "issue a fatal error." msgstr "" +"ミューテックス *m* のロックを解除します。\n" +"ミューテックスはロックされていなければなりません。\n" +"ロックされていない場合、この関数は致命的なエラーを発生させます。" -#: ../../c-api/synchronization.rst:46 msgid "Returns non-zero if the mutex *m* is currently locked, zero otherwise." msgstr "" +"ミューテックス *m* が現在ロックされていれば 0 以外を、そうでなければ 0 を返し" +"ます。" -#: ../../c-api/synchronization.rst:50 msgid "" "This function is intended for use in assertions and debugging only and " "should not be used to make concurrency control decisions, as the lock state " "may change immediately after the check." msgstr "" +"この関数はアサーションとデバッグだけを目的としています。\n" +"確認した直後にロックの状態が変わる可能性があるため、並行処理の制御の判断には" +"使わないでください。" -#: ../../c-api/synchronization.rst:59 msgid "Python critical section API" -msgstr "" +msgstr "Python のクリティカルセクション API" -#: ../../c-api/synchronization.rst:61 msgid "" "The critical section API provides a deadlock avoidance layer on top of per-" "object locks for :term:`free-threaded ` CPython. They are " "intended to replace reliance on the :term:`global interpreter lock`, and are " "no-ops in versions of Python with the global interpreter lock." msgstr "" +"クリティカルセクション API は、:term:`フリースレッドの ` " +"CPython のオブジェクトごとのロックに、デッドロックを避ける層を加えます。\n" +":term:`グローバルインタープリタロック ` への依存を置" +"き換えるためのもので、グローバルインタープリタロックを持つバージョンの " +"Python では何もしません。" -#: ../../c-api/synchronization.rst:66 msgid "" "Critical sections are intended to be used for custom types implemented in C-" "API extensions. They should generally not be used with built-in types like :" @@ -99,8 +117,14 @@ msgid "" "critical sections internally, with the notable exception of :c:func:" "`PyDict_Next`, which requires critical section to be acquired externally." msgstr "" +"クリティカルセクションは、C API を使う拡張で実装した独自の型のためのもので" +"す。\n" +":class:`list` や :class:`dict` などの組み込み型の公開 C API は内部でクリティ" +"カルセクションを使っているため、通常はこれらの型に対して使わないでくださ" +"い。\n" +"重要な例外は :c:func:`PyDict_Next` で、外側でクリティカルセクションを開始して" +"おく必要があります。" -#: ../../c-api/synchronization.rst:73 msgid "" "Critical sections avoid deadlocks by implicitly suspending active critical " "sections, hence, they do not provide exclusive access such as provided by " @@ -110,8 +134,16 @@ msgid "" "suspend the critical section thereby releasing the per-object lock, so other " "threads can acquire the per-object lock for the same object." msgstr "" +"クリティカルセクションは、実行中のクリティカルセクションを暗黙的に中断するこ" +"とでデッドロックを避けます。\n" +"そのため、:c:type:`PyMutex` のような従来のロックが提供する排他的アクセスとは" +"異なります。\n" +"クリティカルセクションを開始すると、対象のオブジェクトのロックを取得しま" +"す。\n" +"内部で実行するコードが C API 関数を呼ぶと、クリティカルセクションを中断してそ" +"のロックを解放する場合があります。\n" +"すると、別のスレッドが同じオブジェクトのロックを取得できます。" -#: ../../c-api/synchronization.rst:81 msgid "" "Variants that accept :c:type:`PyMutex` pointers rather than Python objects " "are also available. Use these variants to start a critical section in a " @@ -119,8 +151,13 @@ msgid "" "with a C type that does not extend or wrap :c:type:`PyObject` but still " "needs to call into the C API in a manner that might lead to deadlocks." msgstr "" +"Python オブジェクトの代わりに :c:type:`PyMutex` ポインタを受け取る形式もあり" +"ます。\n" +":c:type:`PyObject` がない状況でクリティカルセクションを開始する場合に使ってく" +"ださい。\n" +"例えば、:c:type:`PyObject` を拡張もラップもしていない C の型を扱うものの、" +"デッドロックを起こす可能性がある形で C API を呼び出す必要がある場合です。" -#: ../../c-api/synchronization.rst:89 msgid "" "Operations that need to lock two objects at once must use :c:macro:" "`Py_BEGIN_CRITICAL_SECTION2`. You *cannot* use nested critical sections to " @@ -128,12 +165,17 @@ msgid "" "suspend the outer critical sections. This API does not provide a way to " "lock more than two objects at once." msgstr "" +"2 個のオブジェクトを同時にロックする操作には、:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION2` を使う必要があります。\n" +"複数のオブジェクトを同時にロックするために、クリティカルセクションを入れ子に" +"することは *できません*。\n" +"内側のクリティカルセクションが外側のものを中断する場合があるためです。\n" +"この API は、3 個以上のオブジェクトを同時にロックする方法を提供しません。" #: ../../c-api/synchronization.rst:95 msgid "Example usage::" msgstr "使用例::" -#: ../../c-api/synchronization.rst:97 msgid "" "static PyObject *\n" "set_field(MyObject *self, PyObject *value)\n" @@ -144,8 +186,15 @@ msgid "" " Py_RETURN_NONE;\n" "}" msgstr "" +"static PyObject *\n" +"set_field(MyObject *self, PyObject *value)\n" +"{\n" +" Py_BEGIN_CRITICAL_SECTION(self);\n" +" Py_SETREF(self->field, Py_XNewRef(value));\n" +" Py_END_CRITICAL_SECTION();\n" +" Py_RETURN_NONE;\n" +"}" -#: ../../c-api/synchronization.rst:106 msgid "" "In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which " "can call arbitrary code through an object's deallocation function. The " @@ -154,253 +203,276 @@ msgid "" "if the code triggered by the finalizer blocks and calls :c:func:" "`PyEval_SaveThread`." msgstr "" +"上の例では、:c:macro:`Py_SETREF` が :c:macro:`Py_DECREF` を呼び出し、オブジェ" +"クトの解放関数を通じて任意のコードが実行される可能性があります。\n" +"ファイナライザが実行するコードがブロックして :c:func:`PyEval_SaveThread` を呼" +"び出した場合、\n" +"クリティカルセクション API はランタイムによるクリティカルセクションの一時的な" +"中断を許すことで、再入やロックの順序に起因するデッドロックを避けます。" -#: ../../c-api/synchronization.rst:116 msgid "" "Acquires the per-object lock for the object *op* and begins a critical " "section." msgstr "" +"オブジェクト *op* のロックを取得し、クリティカルセクションを開始します。" -#: ../../c-api/synchronization.rst:119 ../../c-api/synchronization.rst:151 -#: ../../c-api/synchronization.rst:181 ../../c-api/synchronization.rst:199 msgid "" "In the free-threaded build, and when building for the :ref:`Stable ABI " "`, this macro expands to::" msgstr "" +"フリースレッドビルドや :ref:`Stable ABI ` 向けのビルドでは、この" +"マクロは次のように展開されます。 ::" -#: ../../c-api/synchronization.rst:122 msgid "" "{\n" " PyCriticalSection _py_cs;\n" " PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" msgstr "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))" -#: ../../c-api/synchronization.rst:126 ../../c-api/synchronization.rst:173 msgid "In the default build, this macro expands to ``{``." -msgstr "" +msgstr "デフォルトのビルドでは、このマクロは ``{`` に展開されます。" -#: ../../c-api/synchronization.rst:132 msgid "Locks the mutex *m* and begins a critical section." -msgstr "" +msgstr "ミューテックス *m* をロックし、クリティカルセクションを開始します。" -#: ../../c-api/synchronization.rst:134 ../../c-api/synchronization.rst:167 msgid "In the free-threaded build, this macro expands to::" -msgstr "" +msgstr "フリースレッドビルドでは、このマクロは次のように展開されます。 ::" -#: ../../c-api/synchronization.rst:136 msgid "" "{\n" " PyCriticalSection _py_cs;\n" " PyCriticalSection_BeginMutex(&_py_cs, m)" msgstr "" +"{\n" +" PyCriticalSection _py_cs;\n" +" PyCriticalSection_BeginMutex(&_py_cs, m)" -#: ../../c-api/synchronization.rst:140 msgid "" "Note that unlike :c:macro:`Py_BEGIN_CRITICAL_SECTION`, there is no cast for " "the argument of the macro - it must be a :c:type:`PyMutex` pointer." msgstr "" +":c:macro:`Py_BEGIN_CRITICAL_SECTION` と異なり、このマクロは引数をキャストしま" +"せん。\n" +"引数は :c:type:`PyMutex` ポインタでなければなりません。" -#: ../../c-api/synchronization.rst:143 ../../c-api/synchronization.rst:191 msgid "On the default build, this macro expands to ``{``." -msgstr "" +msgstr "デフォルトのビルドでは、このマクロは ``{`` に展開されます。" -#: ../../c-api/synchronization.rst:149 msgid "Ends the critical section and releases the per-object lock." -msgstr "" +msgstr "クリティカルセクションを終了し、オブジェクトのロックを解放します。" -#: ../../c-api/synchronization.rst:154 msgid "" " PyCriticalSection_End(&_py_cs);\n" "}" msgstr "" +" PyCriticalSection_End(&_py_cs);\n" +"}" -#: ../../c-api/synchronization.rst:157 ../../c-api/synchronization.rst:205 msgid "In the default build, this macro expands to ``}``." -msgstr "" +msgstr "デフォルトのビルドでは、このマクロは ``}`` に展開されます。" -#: ../../c-api/synchronization.rst:163 msgid "" "Acquires the per-object locks for the objects *a* and *b* and begins a " "critical section. The locks are acquired in a consistent order (lowest " "address first) to avoid lock ordering deadlocks." msgstr "" +"オブジェクト *a* と *b* のロックを取得し、クリティカルセクションを開始しま" +"す。\n" +"ロックの順序によるデッドロックを避けるため、常に同じ順序 (アドレスが小さいも" +"のから) でロックを取得します。" -#: ../../c-api/synchronization.rst:169 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" msgstr "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_Begin(&_py_cs2, (PyObject*)(a), (PyObject*)(b))" -#: ../../c-api/synchronization.rst:179 msgid "Locks the mutexes *m1* and *m2* and begins a critical section." msgstr "" +"ミューテックス *m1* と *m2* をロックし、クリティカルセクションを開始します。" -#: ../../c-api/synchronization.rst:184 msgid "" "{\n" " PyCriticalSection2 _py_cs2;\n" " PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2)" msgstr "" +"{\n" +" PyCriticalSection2 _py_cs2;\n" +" PyCriticalSection2_BeginMutex(&_py_cs2, m1, m2)" -#: ../../c-api/synchronization.rst:188 msgid "" "Note that unlike :c:macro:`Py_BEGIN_CRITICAL_SECTION2`, there is no cast for " "the arguments of the macro - they must be :c:type:`PyMutex` pointers." msgstr "" +":c:macro:`Py_BEGIN_CRITICAL_SECTION2` と異なり、このマクロは引数をキャストし" +"ません。\n" +"引数は :c:type:`PyMutex` ポインタでなければなりません。" -#: ../../c-api/synchronization.rst:197 msgid "Ends the critical section and releases the per-object locks." -msgstr "" +msgstr "クリティカルセクションを終了し、オブジェクトのロックを解放します。" -#: ../../c-api/synchronization.rst:202 msgid "" " PyCriticalSection2_End(&_py_cs2);\n" "}" msgstr "" +" PyCriticalSection2_End(&_py_cs2);\n" +"}" -#: ../../c-api/synchronization.rst:210 msgid "Low-level critical section API" -msgstr "" +msgstr "低水準のクリティカルセクション API" -#: ../../c-api/synchronization.rst:212 msgid "" "The following functions and structs are exposed for cases where C macros are " "not available." -msgstr "" +msgstr "C のマクロを使えない場合のために、次の関数と構造体が公開されています。" -#: ../../c-api/synchronization.rst:220 ../../c-api/synchronization.rst:243 msgid "" "To be used only as in the macro expansions listed :ref:`earlier in this " "section `." msgstr "" +":ref:`この節の前半 ` に示したマクロの展開と同じ形で" +"のみ使ってください。" -#: ../../c-api/synchronization.rst:223 ../../c-api/synchronization.rst:246 msgid "" "In non-:term:`free-threaded ` builds of CPython, these " "functions do nothing." msgstr "" +":term:`フリースレッド ` ではない CPython のビルドでは、これら" +"の関数は何もしません。" -#: ../../c-api/synchronization.rst:231 msgid "" "To be used only as in the macro expansions listed :ref:`earlier in this " "section `. Note that the contents of the structures " "are private and their meaning may change in future Python versions." msgstr "" +":ref:`この節の前半 ` に示したマクロの展開と同じ形で" +"のみ使ってください。\n" +"構造体の内容は非公開で、その意味は将来の Python バージョンで変わる可能性があ" +"ります。" -#: ../../c-api/synchronization.rst:253 msgid "Legacy locking APIs" -msgstr "" +msgstr "従来のロック API" -#: ../../c-api/synchronization.rst:255 msgid "" "These APIs are obsolete since Python 3.13 with the introduction of :c:type:" "`PyMutex`." msgstr "" +"これらの API は、Python 3.13 で :c:type:`PyMutex` が導入されたことにより旧式" +"となりました。" -#: ../../c-api/synchronization.rst:258 msgid "These APIs are now a simple wrapper around ``PyMutex``." -msgstr "" +msgstr "これらの API は、``PyMutex`` を単純にラップするものになりました。" -#: ../../c-api/synchronization.rst:264 msgid "A pointer to a mutual exclusion lock." -msgstr "" +msgstr "相互排他ロックへのポインタです。" -#: ../../c-api/synchronization.rst:269 msgid "The result of acquiring a lock with a timeout." -msgstr "" +msgstr "タイムアウト付きでロックを取得した結果です。" -#: ../../c-api/synchronization.rst:275 msgid "Failed to acquire the lock." -msgstr "" +msgstr "ロックを取得できませんでした。" -#: ../../c-api/synchronization.rst:279 msgid "The lock was successfully acquired." -msgstr "" +msgstr "ロックを取得しました。" -#: ../../c-api/synchronization.rst:283 msgid "The lock was interrupted by a signal." -msgstr "" +msgstr "ロックの取得がシグナルで中断されました。" -#: ../../c-api/synchronization.rst:288 msgid "Allocate a new lock." -msgstr "" +msgstr "新しいロックを確保します。" -#: ../../c-api/synchronization.rst:290 msgid "" "On success, this function returns a lock; on failure, this function returns " "``0`` without an exception set." msgstr "" +"成功するとロックを返します。\n" +"失敗すると、例外を設定せずに ``0`` を返します。" -#: ../../c-api/synchronization.rst:293 ../../c-api/synchronization.rst:305 -#: ../../c-api/synchronization.rst:325 ../../c-api/synchronization.rst:343 -#: ../../c-api/synchronization.rst:351 msgid "The caller does not need to hold an :term:`attached thread state`." msgstr "" +"呼び出し元に :term:`スレッド状態がアタッチされている ` 必要はありません。" -#: ../../c-api/synchronization.rst:295 msgid "" "This function now always uses :c:type:`PyMutex`. In prior versions, this " "would use a lock provided by the operating system." msgstr "" +"常に :c:type:`PyMutex` を使うようになりました。\n" +"以前のバージョンでは、オペレーティングシステムが提供するロックを使っていまし" +"た。" -#: ../../c-api/synchronization.rst:302 msgid "" "Destroy *lock*. The lock should not be held by any thread when calling this." msgstr "" +"*lock* を破棄します。\n" +"呼び出す際に、どのスレッドもこのロックを保持していてはなりません。" -#: ../../c-api/synchronization.rst:310 msgid "Acquire *lock* with a timeout." -msgstr "" +msgstr "タイムアウト付きで *lock* を取得します。" -#: ../../c-api/synchronization.rst:312 msgid "" "This will wait for *microseconds* microseconds to acquire the lock. If the " "timeout expires, this function returns :c:enumerator:`PY_LOCK_FAILURE`. If " "*microseconds* is ``-1``, this will wait indefinitely until the lock has " "been released." msgstr "" +"ロックを取得するまで *microseconds* マイクロ秒待ちます。\n" +"タイムアウトすると :c:enumerator:`PY_LOCK_FAILURE` を返します。\n" +"*microseconds* が ``-1`` の場合は、ロックが解放されるまで無期限に待ちます。" -#: ../../c-api/synchronization.rst:317 msgid "" "If *intr_flag* is ``1``, acquiring the lock may be interrupted by a signal, " "in which case this function returns :c:enumerator:`PY_LOCK_INTR`. Upon " "interruption, it's generally expected that the caller makes a call to :c:" "func:`Py_MakePendingCalls` to propagate an exception to Python code." msgstr "" +"*intr_flag* が ``1`` の場合、ロックの取得がシグナルで中断されることがありま" +"す。\n" +"その場合は :c:enumerator:`PY_LOCK_INTR` を返します。\n" +"中断されたときは、通常、呼び出し元が :c:func:`Py_MakePendingCalls` を呼んで " +"Python コードに例外を伝えることが想定されています。" -#: ../../c-api/synchronization.rst:322 msgid "" "If the lock is successfully acquired, this function returns :c:enumerator:" "`PY_LOCK_ACQUIRED`." -msgstr "" +msgstr "ロックの取得に成功すると :c:enumerator:`PY_LOCK_ACQUIRED` を返します。" -#: ../../c-api/synchronization.rst:330 msgid "Acquire *lock*." -msgstr "" +msgstr "*lock* を取得します。" -#: ../../c-api/synchronization.rst:332 msgid "" "If *waitflag* is ``1`` and another thread currently holds the lock, this " "function will wait until the lock can be acquired and will always return " "``1``." msgstr "" +"*waitflag* が ``1`` で、別のスレッドが現在ロックを保持している場合、ロックを" +"取得できるまで待ち、常に ``1`` を返します。" -#: ../../c-api/synchronization.rst:336 msgid "" "If *waitflag* is ``0`` and another thread holds the lock, this function will " "not wait and instead return ``0``. If the lock is not held by any other " "thread, then this function will acquire it and return ``1``." msgstr "" +"*waitflag* が ``0`` で、別のスレッドがロックを保持している場合は、待たずに " +"``0`` を返します。\n" +"他のスレッドがロックを保持していなければ、ロックを取得して ``1`` を返します。" -#: ../../c-api/synchronization.rst:340 msgid "" "Unlike :c:func:`PyThread_acquire_lock_timed`, acquiring the lock cannot be " "interrupted by a signal." msgstr "" +":c:func:`PyThread_acquire_lock_timed` と異なり、ロックの取得がシグナルで中断" +"されることはありません。" -#: ../../c-api/synchronization.rst:348 msgid "" "Release *lock*. If *lock* is not held, then this function issues a fatal " "error." msgstr "" +"*lock* を解放します。\n" +"*lock* が保持されていない場合、この関数は致命的なエラーを発生させます。" diff --git a/c-api/sys.po b/c-api/sys.po index 45e019a1e..c3445167d 100644 --- a/c-api/sys.po +++ b/c-api/sys.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/sys.rst:6 msgid "Operating System Utilities" msgstr "オペレーティングシステム関連のユーティリティ" -#: ../../c-api/sys.rst:11 msgid "" "Return the file system representation for *path*. If the object is a :class:" "`str` or :class:`bytes` object, then a new :term:`strong reference` is " @@ -35,8 +34,14 @@ msgid "" "or :class:`bytes` object. Otherwise :exc:`TypeError` is raised and ``NULL`` " "is returned." msgstr "" +"``path`` のファイルシステム表現を返します。\n" +"オブジェクトが :class:`str` または :class:`bytes` の場合は、新しい :term:`強" +"参照 ` を返します。\n" +":class:`os.PathLike` インターフェースを実装している場合は、:meth:`~os." +"PathLike.__fspath__` の戻り値が :class:`str` または :class:`bytes` ならそれを" +"返します。\n" +"それ以外の場合は :exc:`TypeError` を送出し、``NULL`` を返します。" -#: ../../c-api/sys.rst:24 msgid "" "Return true (nonzero) if the standard I/O file *fp* with name *filename* is " "deemed interactive. This is the case for files for which " @@ -45,10 +50,14 @@ msgid "" "``NULL`` or if the name is equal to one of the strings ``''`` or " "``'???'``." msgstr "" +"名前が ``filename`` の標準 I/O ファイル ``fp`` が対話的と判定される場合に、" +"真 (非ゼロ) を返します。\n" +"``isatty(fileno(fp))`` が真となるファイルが該当します。\n" +":c:member:`PyConfig.interactive` が非ゼロの場合は、``filename`` ポインタが " +"``NULL``、または名前が ``''`` か ``'???'`` の場合にも真を返します。" -#: ../../c-api/sys.rst:30 msgid "This function must not be called before Python is initialized." -msgstr "" +msgstr "Python が初期化される前に呼び出してはいけません。" #: ../../c-api/sys.rst:35 msgid "" @@ -62,12 +71,15 @@ msgstr "" "数を呼びださなければなりません。:c:func:`fork` が定義されているシステムでのみ" "利用できます。" -#: ../../c-api/sys.rst:41 msgid "" "The C :c:func:`fork` call should only be made from the :ref:`\"main\" thread " "` (of the :ref:`\"main\" interpreter `). The same is true for ``PyOS_BeforeFork()``." msgstr "" +"C の :c:func:`fork` は、:ref:`メインインタープリタ ` の :ref:`メインスレッド ` からだけ呼び出してくだ" +"さい。\n" +"``PyOS_BeforeFork()`` も同様です。" #: ../../c-api/sys.rst:51 msgid "" @@ -82,14 +94,16 @@ msgstr "" "製が成功したかどうかにかかわらず、親プロセスからこの関数を呼び出さなければな" "りません。:c:func:`fork` が定義されているシステムでのみ利用できます。" -#: ../../c-api/sys.rst:58 msgid "" "The C :c:func:`fork` call should only be made from the :ref:`\"main\" thread " "` (of the :ref:`\"main\" interpreter `). The same is true for ``PyOS_AfterFork_Parent()``." msgstr "" +"C の :c:func:`fork` は、:ref:`メインインタープリタ ` の :ref:`メインスレッド ` からだけ呼び出してくだ" +"さい。\n" +"``PyOS_AfterFork_Parent()`` も同様です。" -#: ../../c-api/sys.rst:68 msgid "" "Function to update internal interpreter state after a process fork. This " "must be called from the child process after calling :c:func:`fork`, or any " @@ -97,13 +111,21 @@ msgid "" "process will call back into the Python interpreter. Only available on " "systems where :c:func:`fork` is defined." msgstr "" +"プロセスのフォーク後にインタープリタの内部状態を更新する関数です。\n" +":c:func:`fork` や、現在のプロセスを複製する同様の関数を呼び出した後、そのプロ" +"セスから Python インタープリタを再び呼び出す可能性が少しでもあるなら、子プロ" +"セスからこの関数を呼び出す必要があります。\n" +":c:func:`fork` が定義されているシステムでのみ利用できます。" -#: ../../c-api/sys.rst:75 msgid "" "The C :c:func:`fork` call should only be made from the :ref:`\"main\" thread " "` (of the :ref:`\"main\" interpreter `). The same is true for ``PyOS_AfterFork_Child()``." msgstr "" +"C の :c:func:`fork` は、:ref:`メインインタープリタ ` の :ref:`メインスレッド ` からだけ呼び出してくだ" +"さい。\n" +"``PyOS_AfterFork_Child()`` も同様です。" #: ../../c-api/sys.rst:83 msgid "" @@ -132,7 +154,6 @@ msgid "This function is superseded by :c:func:`PyOS_AfterFork_Child()`." msgstr "" "この関数は :c:func:`PyOS_AfterFork_Child()` によって置き換えられました。" -#: ../../c-api/sys.rst:103 msgid "" "Return true when the interpreter runs out of stack space. This is a " "reliable check, but is only available when :c:macro:`!USE_STACKCHECK` is " @@ -140,32 +161,42 @@ msgid "" "C++ compiler). :c:macro:`!USE_STACKCHECK` will be defined automatically; you " "should never change the definition in your own code." msgstr "" +"インタープリタのスタック領域が足りなくなった場合に真を返します。\n" +"これは信頼できるチェックですが、:c:macro:`!USE_STACKCHECK` が定義されている場" +"合 (現在は Microsoft Visual C++ コンパイラを使う一部の Windows バージョン) だ" +"け利用できます。\n" +":c:macro:`!USE_STACKCHECK` は自動的に定義されます。\n" +"自分のコードで定義を変更してはいけません。" -#: ../../c-api/sys.rst:115 msgid "" "Return the current signal handler for signal *i*. This is a thin wrapper " "around either :c:func:`!sigaction` or :c:func:`!signal`. Do not call those " "functions directly!" msgstr "" +"シグナル ``i`` の現在のシグナルハンドラを返します。\n" +":c:func:`!sigaction` または :c:func:`!signal` の薄いラッパーです。\n" +"それらの関数を直接呼び出してはいけません。" -#: ../../c-api/sys.rst:122 msgid "" "Set the signal handler for signal *i* to be *h*; return the old signal " "handler. This is a thin wrapper around either :c:func:`!sigaction` or :c:" "func:`!signal`. Do not call those functions directly!" msgstr "" +"シグナル ``i`` のシグナルハンドラを ``h`` に設定し、以前のハンドラを返しま" +"す。\n" +":c:func:`!sigaction` または :c:func:`!signal` の薄いラッパーです。\n" +"それらの関数を直接呼び出してはいけません。" -#: ../../c-api/sys.rst:129 msgid "Check if a :c:macro:`!SIGINT` signal has been received." -msgstr "" +msgstr ":c:macro:`!SIGINT` シグナルを受信したかどうかを調べます。" -#: ../../c-api/sys.rst:131 msgid "" "Returns ``1`` if a :c:macro:`!SIGINT` has occurred and clears the signal " "flag, or ``0`` otherwise." msgstr "" +":c:macro:`!SIGINT` が発生していればシグナルフラグをクリアして ``1`` を返し、" +"それ以外の場合は ``0`` を返します。" -#: ../../c-api/sys.rst:134 msgid "" "In most cases, you should prefer :c:func:`PyErr_CheckSignals` over this " "function. :c:func:`!PyErr_CheckSignals` invokes the appropriate signal " @@ -173,26 +204,39 @@ msgid "" "properly. This function only detects :c:macro:`!SIGINT` and does not invoke " "any Python signal handlers." msgstr "" +"ほとんどの場合、この関数よりも :c:func:`PyErr_CheckSignals` を使う方が適切で" +"す。\n" +":c:func:`!PyErr_CheckSignals` は、保留中のすべてのシグナルに対応するシグナル" +"ハンドラを呼び出し、Python コードがシグナルを適切に処理できるようにします。\n" +"この関数は :c:macro:`!SIGINT` の検出だけを行い、Python のシグナルハンドラは呼" +"び出しません。" -#: ../../c-api/sys.rst:140 msgid "" "This function is async-signal-safe and this function cannot fail. The caller " "must hold an :term:`attached thread state`." msgstr "" +"この関数は非同期シグナルセーフで、失敗しません。\n" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" -#: ../../c-api/sys.rst:147 msgid "" "This function should not be called directly: use the :c:type:`PyConfig` API " "with the :c:func:`PyConfig_SetBytesString` function which ensures that :ref:" "`Python is preinitialized `." msgstr "" +"この関数は直接呼び出さないでください。\n" +"代わりに :c:type:`PyConfig` API と :c:func:`PyConfig_SetBytesString` 関数を" +"使ってください。\n" +"これにより、:ref:`Python の事前初期化 ` が保証されます。" -#: ../../c-api/sys.rst:151 ../../c-api/sys.rst:218 msgid "" "This function must not be called before :ref:`Python is preinitialized ` and so that the LC_CTYPE locale is properly configured: see the :c:" "func:`Py_PreInitialize` function." msgstr "" +"LC_CTYPE ロケールを適切に設定するため、:ref:`Python が事前初期化される ` 前にこの関数を呼び出してはいけません。\n" +":c:func:`Py_PreInitialize` 関数を参照してください。" #: ../../c-api/sys.rst:155 msgid "" @@ -231,12 +275,15 @@ msgstr "" "*size* が ``NULL`` でない場合は、メモリエラーのときは ``(size_t)-1`` を、デ" "コードでのエラーのときは ``(size_t)-2`` を ``*size`` に設定します。" -#: ../../c-api/sys.rst:170 ../../c-api/sys.rst:210 msgid "" "The :term:`filesystem encoding and error handler` are selected by :c:func:" "`PyConfig_Read`: see :c:member:`~PyConfig.filesystem_encoding` and :c:member:" "`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` は :c:func:`PyConfig_Read` が選択します。\n" +":c:type:`PyConfig` の :c:member:`~PyConfig.filesystem_encoding` と :c:member:" +"`~PyConfig.filesystem_errors` メンバを参照してください。" #: ../../c-api/sys.rst:174 msgid "" @@ -267,11 +314,12 @@ msgstr "" "この関数は、:ref:`Python UTF-8 Mode ` ではUTF-8エンコーディングを" "利用するようになりました。" -#: ../../c-api/sys.rst:191 msgid "" "The function now uses the UTF-8 encoding on Windows if :c:member:" "`PyPreConfig.legacy_windows_fs_encoding` is zero;" msgstr "" +":c:member:`PyPreConfig.legacy_windows_fs_encoding` がゼロの場合、Windows で" +"は UTF-8 エンコーディングを使うようになりました。" #: ../../c-api/sys.rst:198 msgid "" @@ -296,11 +344,13 @@ msgstr "" "このメモリを解放するのには :c:func:`PyMem_Free` を使ってください。\n" "エンコードエラーかメモリ確保エラーのときは ``NULL`` を返します。" -#: ../../c-api/sys.rst:207 msgid "" "If error_pos is not ``NULL``, ``*error_pos`` is set to ``(size_t)-1`` on " "success, or set to the index of the invalid character on encoding error." msgstr "" +"``error_pos`` が ``NULL`` でなければ、成功した場合は ``*error_pos`` を " +"``(size_t)-1`` に、エンコードエラーの場合は無効な文字のインデックスに設定しま" +"す。" #: ../../c-api/sys.rst:214 msgid "" @@ -318,54 +368,61 @@ msgstr "" ":c:func:`PyUnicode_EncodeFSDefault` および :c:func:`PyUnicode_EncodeLocale` " "関数。" -#: ../../c-api/sys.rst:233 msgid "" "The function now uses the UTF-8 encoding on Windows if :c:member:" "`PyPreConfig.legacy_windows_fs_encoding` is zero." msgstr "" +":c:member:`PyPreConfig.legacy_windows_fs_encoding` がゼロの場合、Windows で" +"は UTF-8 エンコーディングを使うようになりました。" -#: ../../c-api/sys.rst:239 msgid "" "Similar to :c:func:`!fopen`, but *path* is a Python object and an exception " "is set on error." msgstr "" +":c:func:`!fopen` と同様ですが、``path`` は Python オブジェクトで、エラーの場" +"合は例外を設定します。" -#: ../../c-api/sys.rst:242 msgid "" "*path* must be a :class:`str` object, a :class:`bytes` object, or a :term:" "`path-like object`." msgstr "" +"``path`` は :class:`str` オブジェクト、:class:`bytes` オブジェクト、または :" +"term:`パス風オブジェクト ` でなければなりません。" -#: ../../c-api/sys.rst:245 msgid "" "On success, return the new file pointer. On error, set an exception and " "return ``NULL``." msgstr "" +"成功した場合は新しいファイルポインタを返します。\n" +"エラーの場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/sys.rst:248 msgid "" "The file must be closed by :c:func:`Py_fclose` rather than calling directly :" "c:func:`!fclose`." msgstr "" +"ファイルを閉じるには :c:func:`!fclose` を直接呼び出さず、:c:func:`Py_fclose` " +"を使う必要があります。" -#: ../../c-api/sys.rst:251 msgid "The file descriptor is created non-inheritable (:pep:`446`)." -msgstr "" +msgstr "ファイル記述子は継承不可として作成されます (:pep:`446`)。" -#: ../../c-api/sys.rst:253 msgid "The caller must have an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`アタッチされたスレッド状態 ` が" +"必要です。" -#: ../../c-api/sys.rst:260 msgid "Close a file that was opened by :c:func:`Py_fopen`." -msgstr "" +msgstr ":c:func:`Py_fopen` で開いたファイルを閉じます。" -#: ../../c-api/sys.rst:262 msgid "" "On success, return ``0``. On error, return ``EOF`` and ``errno`` is set to " "indicate the error. In either case, any further access (including another " "call to :c:func:`Py_fclose`) to the stream results in undefined behavior." msgstr "" +"成功した場合は ``0`` を返します。\n" +"エラーの場合は ``EOF`` を返し、エラーを示す ``errno`` を設定します。\n" +"どちらの場合も、その後ストリームにアクセスすると (:c:func:`Py_fclose` をもう" +"一度呼び出すことも含めて)、動作は未定義です。" #: ../../c-api/sys.rst:273 msgid "System Functions" @@ -382,72 +439,84 @@ msgstr "" "すべての関数は現在のインタプリタスレッドの :mod:`sys` モジュールの辞書に対し" "て動作します。この辞書は内部のスレッド状態構造体に格納されています。" -#: ../../c-api/sys.rst:281 msgid "" "Get the attribute *name* of the :mod:`sys` module. Return a :term:`strong " "reference`. Raise :exc:`RuntimeError` and return ``NULL`` if it does not " "exist or if the :mod:`sys` module cannot be found." msgstr "" +":mod:`sys` モジュールの属性 ``name`` を取得し、:term:`強参照 ` を返します。\n" +"属性が存在しない場合や :mod:`sys` モジュールが見つからない場合は :exc:" +"`RuntimeError` を送出し、``NULL`` を返します。" -#: ../../c-api/sys.rst:286 msgid "" "If the non-existing object should not be treated as a failure, you can use :" "c:func:`PySys_GetOptionalAttr` instead." msgstr "" +"オブジェクトが存在しない場合を失敗として扱う必要がなければ、代わりに :c:func:" +"`PySys_GetOptionalAttr` を使えます。" -#: ../../c-api/sys.rst:293 msgid "" "This is the same as :c:func:`PySys_GetAttr`, but *name* is specified as a :c:" "expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PySys_GetAttr` と同じですが、``name`` は :c:expr:`PyObject*` ではな" +"く、UTF-8 エンコードの :c:expr:`const char*` バイト列で指定します。" -#: ../../c-api/sys.rst:297 msgid "" "If the non-existing object should not be treated as a failure, you can use :" "c:func:`PySys_GetOptionalAttrString` instead." msgstr "" +"オブジェクトが存在しない場合を失敗として扱う必要がなければ、代わりに :c:func:" +"`PySys_GetOptionalAttrString` を使えます。" -#: ../../c-api/sys.rst:304 msgid "" "Variant of :c:func:`PySys_GetAttr` which doesn't raise exception if the " "object does not exist." msgstr "" +"オブジェクトが存在しない場合に例外を送出しない :c:func:`PySys_GetAttr` の変種" +"です。" -#: ../../c-api/sys.rst:307 msgid "" "Set *\\*result* to a new :term:`strong reference` to the object and return " "``1`` if the object exists." msgstr "" +"オブジェクトが存在する場合は、そのオブジェクトへの新しい :term:`強参照 " +"` を ``*result`` に設定し、``1`` を返します。" -#: ../../c-api/sys.rst:309 msgid "" "Set *\\*result* to ``NULL`` and return ``0`` without setting an exception if " "the object does not exist." msgstr "" +"オブジェクトが存在しない場合は、``*result`` を ``NULL`` に設定し、例外を設定" +"せずに ``0`` を返します。" -#: ../../c-api/sys.rst:311 msgid "" "Set an exception, set *\\*result* to ``NULL``, and return ``-1``, if an " "error occurred." msgstr "" +"エラーの場合は、例外を設定し、``*result`` を ``NULL`` にして ``-1`` を返しま" +"す。" -#: ../../c-api/sys.rst:318 msgid "" "This is the same as :c:func:`PySys_GetOptionalAttr`, but *name* is specified " "as a :c:expr:`const char*` UTF-8 encoded bytes string, rather than a :c:expr:" "`PyObject*`." msgstr "" +":c:func:`PySys_GetOptionalAttr` と同じですが、``name`` は :c:expr:" +"`PyObject*` ではなく、UTF-8 エンコードの :c:expr:`const char*` バイト列で指定" +"します。" -#: ../../c-api/sys.rst:326 msgid "" "Similar to :c:func:`PySys_GetAttrString`, but return a :term:`borrowed " "reference` and return ``NULL`` *without* setting exception on failure." msgstr "" +":c:func:`PySys_GetAttrString` と同様ですが、:term:`借用参照 ` を返し、失敗した場合は例外を設定 *せずに* ``NULL`` を返します。" -#: ../../c-api/sys.rst:329 msgid "Preserves exception that was set before the call." -msgstr "" +msgstr "呼び出し前に設定されていた例外を保持します。" #: ../../c-api/sys.rst:333 msgid "" @@ -526,64 +595,76 @@ msgstr "" ":data:`sys._xoptions` と同様、 :option:`-X` オプションの現在の辞書を返しま" "す。エラーが起きると、 ``NULL`` が返され、例外がセットされます。" -#: ../../c-api/sys.rst:384 msgid "" "Raise an auditing event with any active hooks. Return zero for success and " "non-zero with an exception set on failure." msgstr "" +"有効なフックに監査イベントを通知します。\n" +"成功した場合はゼロを返し、失敗した場合は例外を設定して非ゼロを返します。" -#: ../../c-api/sys.rst:387 msgid "The *event* string argument must not be *NULL*." -msgstr "" +msgstr "文字列引数 ``event`` は ``NULL`` であってはいけません。" -#: ../../c-api/sys.rst:389 msgid "" "If any hooks have been added, *format* and other arguments will be used to " "construct a tuple to pass. Apart from ``N``, the same format characters as " "used in :c:func:`Py_BuildValue` are available. If the built value is not a " "tuple, it will be added into a single-element tuple." msgstr "" +"フックが追加されている場合、``format`` とほかの引数を使って、渡すタプルを作成" +"します。\n" +"``N`` を除き、:c:func:`Py_BuildValue` と同じ書式文字を使えます。\n" +"作成した値がタプルでない場合は、1 要素のタプルに格納します。" -#: ../../c-api/sys.rst:394 msgid "" "The ``N`` format option must not be used. It consumes a reference, but since " "there is no way to know whether arguments to this function will be consumed, " "using it may cause reference leaks." msgstr "" +"書式オプション ``N`` を使ってはいけません。\n" +"このオプションは参照を消費しますが、この関数への引数が消費されるかどうかを知" +"る方法がないため、使うと参照がリークする可能性があります。" -#: ../../c-api/sys.rst:398 msgid "" "Note that ``#`` format characters should always be treated as :c:type:" "`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined." msgstr "" +"``#`` 書式文字の引数は、``PY_SSIZE_T_CLEAN`` の定義の有無にかかわらず、常に :" +"c:type:`Py_ssize_t` として扱ってください。" -#: ../../c-api/sys.rst:401 msgid ":func:`sys.audit` performs the same function from Python code." -msgstr "" +msgstr ":func:`sys.audit` は Python コードから同じ機能を提供します。" -#: ../../c-api/sys.rst:403 msgid "See also :c:func:`PySys_AuditTuple`." -msgstr "" +msgstr ":c:func:`PySys_AuditTuple` も参照してください。" -#: ../../c-api/sys.rst:409 msgid "" "Require :c:type:`Py_ssize_t` for ``#`` format characters. Previously, an " "unavoidable deprecation warning was raised." msgstr "" +"``#`` 書式文字で :c:type:`Py_ssize_t` が必須になりました。\n" +"以前は、回避できない非推奨の警告が発生していました。" -#: ../../c-api/sys.rst:415 msgid "" "Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object. " "*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*." msgstr "" +":c:func:`PySys_Audit` と同様ですが、引数を Python オブジェクトとして渡しま" +"す。\n" +"``args`` は :class:`tuple` でなければなりません。\n" +"引数を渡さない場合は ``NULL`` でも構いません。" -#: ../../c-api/sys.rst:423 msgid "" "Append the callable *hook* to the list of active auditing hooks. Return zero " "on success and non-zero on failure. If the runtime has been initialized, " "also set an error on failure. Hooks added through this API are called for " "all interpreters created by the runtime." msgstr "" +"有効な監査フックのリストに、呼び出し可能な ``hook`` を追加します。\n" +"成功した場合はゼロを返し、失敗した場合は非ゼロを返します。\n" +"ランタイムが初期化済みなら、失敗時にはエラーも設定します。\n" +"この API で追加したフックは、ランタイムが作成するすべてのインタープリタで呼び" +"出されます。" #: ../../c-api/sys.rst:429 msgid "" @@ -595,28 +676,34 @@ msgstr "" "フック関数は別なランタイムから呼び出されるかもしれないので、このポインタは直" "接 Python の状態を参照すべきではありません。" -#: ../../c-api/sys.rst:433 msgid "" "This function is safe to call before :c:func:`Py_Initialize`. When called " "after runtime initialization, existing audit hooks are notified and may " "silently abort the operation by raising an error subclassed from :class:" "`Exception` (other errors will not be silenced)." msgstr "" +"この関数は :c:func:`Py_Initialize` より前でも安全に呼び出せます。\n" +"ランタイムの初期化後に呼び出すと、既存の監査フックに通知されます。\n" +"フックは :class:`Exception` のサブクラスのエラーを送出して、通知せずにこの操" +"作を中止させることがあります (それ以外のエラーは抑制されません)。" -#: ../../c-api/sys.rst:438 msgid "" "The hook function is always called with an :term:`attached thread state` by " "the Python interpreter that raised the event." msgstr "" +"フック関数は、イベントを発生させた Python インタープリタによって、常に :term:" +"`スレッド状態がアタッチされた ` 状態で呼び出されます。" -#: ../../c-api/sys.rst:441 msgid "" "See :pep:`578` for a detailed description of auditing. Functions in the " "runtime and standard library that raise events are listed in the :ref:`audit " "events table `. Details are in each function's documentation." msgstr "" +"監査の詳しい説明は :pep:`578` を参照してください。\n" +"イベントを発生させるランタイムと標準ライブラリの関数は :ref:`監査イベントの" +"表 ` に一覧されています。\n" +"詳細は各関数のドキュメントを参照してください。" -#: ../../c-api/sys.rst:446 ../../c-api/sys.rst:448 msgid "" "If the interpreter is initialized, this function raises an auditing event " "``sys.addaudithook`` with no arguments. If any existing hooks raise an " @@ -624,20 +711,29 @@ msgid "" "and the exception is cleared. As a result, callers cannot assume that their " "hook has been added unless they control all existing hooks." msgstr "" +"インタープリタが初期化済みの場合、この関数は引数なしの監査イベント ``sys." +"addaudithook`` を発生させます。\n" +"既存のフックが :class:`Exception` の派生例外を送出した場合、新しいフックは追" +"加されず、例外はクリアされます。\n" +"そのため、既存のフックをすべて制御できない限り、呼び出し側は自分のフックが追" +"加されたと仮定できません。" -#: ../../c-api/sys.rst:457 msgid "" "The type of the hook function. *event* is the C string event argument passed " "to :c:func:`PySys_Audit` or :c:func:`PySys_AuditTuple`. *args* is guaranteed " "to be a :c:type:`PyTupleObject`. *userData* is the argument passed to " "PySys_AddAuditHook()." msgstr "" +"フック関数の型です。\n" +"``event`` は :c:func:`PySys_Audit` または :c:func:`PySys_AuditTuple` に渡され" +"た C 文字列のイベント引数です。\n" +"``args`` は :c:type:`PyTupleObject` であることが保証されます。\n" +"``userData`` は ``PySys_AddAuditHook()`` に渡された引数です。" #: ../../c-api/sys.rst:469 msgid "Process Control" msgstr "プロセス制御" -#: ../../c-api/sys.rst:476 msgid "" "Print a fatal error message and kill the process. No cleanup is performed. " "This function should only be invoked when a condition is detected that would " @@ -646,17 +742,23 @@ msgid "" "library function :c:func:`!abort` is called which will attempt to produce a :" "file:`core` file." msgstr "" +"致命的なエラーメッセージを表示してプロセスを終了します。\n" +"後片付けは一切行いません。\n" +"オブジェクトの管理情報が破損した場合など、Python インタープリタを使い続けると" +"危険な状況を検出したときだけ呼び出してください。\n" +"Unix では標準 C ライブラリ関数 :c:func:`!abort` を呼び出し、:file:`core` ファ" +"イルの生成を試みます。" -#: ../../c-api/sys.rst:483 msgid "" "The ``Py_FatalError()`` function is replaced with a macro which logs " "automatically the name of the current function, unless the " "``Py_LIMITED_API`` macro is defined." msgstr "" +"``Py_LIMITED_API`` マクロが定義されていない限り、``Py_FatalError()`` 関数は現" +"在の関数名を自動的に記録するマクロに置き換えられます。" -#: ../../c-api/sys.rst:487 msgid "Log the function name automatically." -msgstr "" +msgstr "関数名を自動的に記録するようになりました。" #: ../../c-api/sys.rst:497 msgid "" @@ -691,26 +793,22 @@ msgstr "" "ん。 Python の内部的な終了処理は後始末処理関数より以前に完了しているので、 " "*func* からはいかなる Python API も呼び出してはなりません。" -#: ../../c-api/sys.rst:521 msgid ":c:func:`PyUnstable_AtExit` for passing a ``void *data`` argument." msgstr "" +"``void *data`` 引数を渡すには :c:func:`PyUnstable_AtExit` を参照してくださ" +"い。" -#: ../../c-api/sys.rst:101 msgid "USE_STACKCHECK (C macro)" -msgstr "" +msgstr "USE_STACKCHECK (C マクロ)" -#: ../../c-api/sys.rst:474 msgid "abort (C function)" -msgstr "" +msgstr "abort (C 関数)" -#: ../../c-api/sys.rst:493 ../../c-api/sys.rst:507 msgid "Py_FinalizeEx (C function)" -msgstr "" +msgstr "Py_FinalizeEx (C 関数)" -#: ../../c-api/sys.rst:493 msgid "exit (C function)" -msgstr "" +msgstr "exit (C 関数)" -#: ../../c-api/sys.rst:507 msgid "cleanup functions" -msgstr "cleanup functions" +msgstr "後始末関数" diff --git a/c-api/threads.po b/c-api/threads.po index 24f824944..2c2bc708d 100644 --- a/c-api/threads.po +++ b/c-api/threads.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/threads.rst:6 msgid "Thread states and the global interpreter lock" -msgstr "" +msgstr "スレッド状態とグローバルインタープリタロック" -#: ../../c-api/threads.rst:13 msgid "" "Unless on a :term:`free-threaded build` of :term:`CPython`, the Python " "interpreter is generally not thread-safe. In order to support multi-" @@ -37,28 +35,44 @@ msgid "" "threads simultaneously increment the reference count of the same object, the " "reference count could end up being incremented only once instead of twice." msgstr "" +":term:`CPython` の :term:`フリースレッドビルド ` を除" +"き、Python インタープリタは一般にスレッドセーフではありません。\n" +"マルチスレッドの Python プログラムをサポートするため、:term:`グローバルイン" +"タープリタロック `、または :term:`GIL` というグロー" +"バルなロックがあります。\n" +"スレッドは Python オブジェクトにアクセスする前に、このロックを保持していなけ" +"ればなりません。\n" +"ロックがなければ、マルチスレッドのプログラムでは単純な操作でも問題が起こりえ" +"ます。\n" +"例えば、2 つのスレッドが同じオブジェクトの参照カウントを同時に増やすと、2 回" +"ではなく 1 回しか増えない可能性があります。" -#: ../../c-api/threads.rst:22 msgid "" "As such, only a thread that holds the GIL may operate on Python objects or " "invoke Python's C API." msgstr "" +"このため、Python オブジェクトの操作や Python の C API の呼び出しを行えるの" +"は、GIL を保持するスレッドだけです。" -#: ../../c-api/threads.rst:27 msgid "" "In order to emulate concurrency, the interpreter regularly tries to switch " "threads between bytecode instructions (see :func:`sys.setswitchinterval`). " "This is why locks are also necessary for thread-safety in pure-Python code." msgstr "" +"並行実行を模倣するため、インタープリタはバイトコード命令の間で定期的にスレッ" +"ドの切り替えを試みます (:func:`sys.setswitchinterval` を参照)。\n" +"そのため、純粋な Python コードでもスレッドセーフにするにはロックが必要です。" -#: ../../c-api/threads.rst:31 msgid "" "Additionally, the global interpreter lock is released around blocking I/O " "operations, such as reading or writing to a file. From the C API, this is " "done by :ref:`detaching the thread state `." msgstr "" +"また、ファイルの読み書きなどのブロッキング I/O 操作の間は、グローバルインター" +"プリタロックが解放されます。\n" +"C API では :ref:`スレッド状態をデタッチする ` ことで" +"行います。" -#: ../../c-api/threads.rst:39 msgid "" "The Python interpreter keeps some thread-local information inside a data " "structure called :c:type:`PyThreadState`, known as a :term:`thread state`. " @@ -66,8 +80,13 @@ msgid "" "thread state referenced by this pointer is considered to be :term:`attached " "`." msgstr "" +"Python インタープリタは、:term:`スレッド状態 ` と呼ばれる :c:" +"type:`PyThreadState` データ構造に、スレッドごとの情報を保持します。\n" +"各スレッドには :c:type:`PyThreadState` へのスレッドローカルなポインターがあり" +"ます。\n" +"このポインターが参照するスレッド状態は、:term:`アタッチされている ` と見なされます。" -#: ../../c-api/threads.rst:44 msgid "" "A thread can only have one :term:`attached thread state` at a time. An " "attached thread state is typically analogous with holding the GIL, except on " @@ -77,15 +96,27 @@ msgid "" "the interpreter needs to keep track of which threads may access Python " "objects." msgstr "" +"1 つのスレッドが同時に持てる :term:`アタッチされたスレッド状態 ` は 1 つだけです。\n" +"フリースレッドビルドを除けば、スレッド状態がアタッチされていることは通常、" +"GIL を保持していることに相当します。\n" +"GIL が有効なビルドでは、スレッド状態のアタッチは GIL を取得できるまでブロック" +"します。\n" +"ただし、GIL が無効なビルドでも、スレッド状態をアタッチしておく必要がありま" +"す。\n" +"インタープリタが、どのスレッドが Python オブジェクトにアクセスしうるかを把握" +"するためです。" -#: ../../c-api/threads.rst:53 msgid "" "Even on the free-threaded build, attaching a thread state may block, as the " "GIL can be re-enabled or threads might be temporarily suspended (such as " "during a garbage collection)." msgstr "" +"フリースレッドビルドでも、スレッド状態のアタッチがブロックすることがありま" +"す。\n" +"GIL が再び有効になる場合や、ガベージコレクション中などにスレッドが一時停止す" +"る場合があるためです。" -#: ../../c-api/threads.rst:57 msgid "" "Generally, there will always be an attached thread state when using Python's " "C API, including during embedding and when implementing methods, so it's " @@ -94,30 +125,41 @@ msgid "" "thread, will the thread not have an attached thread state. If uncertain, " "check if :c:func:`PyThreadState_GetUnchecked` returns ``NULL``." msgstr "" +"一般に、Python の C API を使うときは、組み込みやメソッドの実装を含め、常にス" +"レッド状態がアタッチされています。\n" +"そのため、自分でスレッド状態を用意する必要はほとんどありません。\n" +"スレッド状態がアタッチされていないのは、:c:macro:`Py_BEGIN_ALLOW_THREADS` ブ" +"ロック内や新しく作られたスレッドなど、特定の場合だけです。\n" +"不確かな場合は、:c:func:`PyThreadState_GetUnchecked` が ``NULL`` を返すかどう" +"かを確認してください。" -#: ../../c-api/threads.rst:64 msgid "" "If it turns out that you do need to create a thread state, it is recommended " "to use :c:func:`PyThreadState_Ensure` or :c:func:" "`PyThreadState_EnsureFromView`, which will manage the thread state for you." msgstr "" +"スレッド状態を作成する必要がある場合は、:c:func:`PyThreadState_Ensure` また" +"は :c:func:`PyThreadState_EnsureFromView` を使うことを推奨します。\n" +"これらの関数がスレッド状態を管理します。" -#: ../../c-api/threads.rst:72 msgid "Detaching the thread state from extension code" -msgstr "" +msgstr "拡張コードからのスレッド状態のデタッチ" -#: ../../c-api/threads.rst:74 msgid "" "Most extension code manipulating the :term:`thread state` has the following " "simple structure::" msgstr "" +":term:`スレッド状態 ` を操作する拡張コードの多くは、次の単純な" +"構造を取ります。 ::" -#: ../../c-api/threads.rst:77 msgid "" "Save the thread state in a local variable.\n" "... Do some blocking I/O operation ...\n" "Restore the thread state from the local variable." msgstr "" +"// スレッド状態をローカル変数に保存する。\n" +"// ... ブロッキング I/O 操作を行う ...\n" +"// ローカル変数からスレッド状態を復元する。" #: ../../c-api/threads.rst:81 msgid "This is so common that a pair of macros exists to simplify it::" @@ -125,12 +167,14 @@ msgstr "" "この構造は非常に一般的なので、作業を単純にするために2つのマクロが用意されてい" "ます::" -#: ../../c-api/threads.rst:83 msgid "" "Py_BEGIN_ALLOW_THREADS\n" "... Do some blocking I/O operation ...\n" "Py_END_ALLOW_THREADS" msgstr "" +"Py_BEGIN_ALLOW_THREADS\n" +"... ブロッキング I/O 操作を行う ...\n" +"Py_END_ALLOW_THREADS" #: ../../c-api/threads.rst:91 msgid "" @@ -145,7 +189,6 @@ msgstr "" msgid "The block above expands to the following code::" msgstr "上のブロックは次のコードに展開されます::" -#: ../../c-api/threads.rst:97 msgid "" "PyThreadState *_save;\n" "\n" @@ -153,19 +196,25 @@ msgid "" "... Do some blocking I/O operation ...\n" "PyEval_RestoreThread(_save);" msgstr "" +"PyThreadState *_save;\n" +"\n" +"_save = PyEval_SaveThread();\n" +"... ブロッキング I/O 操作を行う ...\n" +"PyEval_RestoreThread(_save);" -#: ../../c-api/threads.rst:107 msgid "Here is how these functions work:" -msgstr "" +msgstr "これらの関数は次のように動作します。" -#: ../../c-api/threads.rst:109 msgid "" "The attached thread state implies that the GIL is held for the interpreter. " "To detach it, :c:func:`PyEval_SaveThread` is called and the result is stored " "in a local variable." msgstr "" +"スレッド状態がアタッチされているということは、そのインタープリタの GIL を保持" +"しているということです。\n" +"デタッチするには :c:func:`PyEval_SaveThread` を呼び出し、結果をローカル変数に" +"保存します。" -#: ../../c-api/threads.rst:113 msgid "" "By detaching the thread state, the GIL is released, which allows other " "threads to attach to the interpreter and execute while the current thread " @@ -173,8 +222,13 @@ msgid "" "state is reattached by calling :c:func:`PyEval_RestoreThread`, which will " "wait until the GIL can be acquired." msgstr "" +"スレッド状態をデタッチすると GIL が解放され、現在のスレッドがブロッキング I/" +"O を行っている間に、ほかのスレッドがインタープリタにアタッチして実行できるよ" +"うになります。\n" +"I/O 操作が完了したら、:c:func:`PyEval_RestoreThread` を呼び出して元のスレッド" +"状態を再びアタッチします。\n" +"この呼び出しは GIL を取得できるまで待機します。" -#: ../../c-api/threads.rst:120 msgid "" "Performing blocking I/O is the most common use case for detaching the thread " "state, but it is also useful to call it over long-running native code that " @@ -182,8 +236,12 @@ msgid "" "standard :mod:`zlib` and :mod:`hashlib` modules detach the :term:`thread " "state ` when compressing or hashing data." msgstr "" +"スレッド状態をデタッチする最も一般的な用途はブロッキング I/O ですが、Python " +"オブジェクトや Python の C API にアクセスしない、実行時間の長いネイティブコー" +"ドでも有用です。\n" +"例えば、標準モジュールの :mod:`zlib` と :mod:`hashlib` は、データの圧縮やハッ" +"シュ計算中に :term:`スレッド状態 ` をデタッチします。" -#: ../../c-api/threads.rst:127 msgid "" "On a :term:`free-threaded build`, the :term:`GIL` is usually out of the " "question, but **detaching the thread state is still required**, because the " @@ -192,17 +250,24 @@ msgid "" "currently suspends all threads for a short period of time while running the " "garbage collector." msgstr "" +":term:`フリースレッドビルド ` では通常 :term:`GIL` を考" +"慮する必要はありませんが、**スレッド状態のデタッチは依然として必要です**。\n" +"インタープリタは、競合状態の危険なく Python オブジェクトの整合した状態を把握" +"するため、定期的にすべてのスレッドをブロックする必要があるためです。\n" +"例えば、現在の CPython はガベージコレクターの実行中、すべてのスレッドを短時間" +"停止します。" -#: ../../c-api/threads.rst:136 msgid "" "Detaching the thread state can lead to unexpected behavior during " "interpreter finalization. See :ref:`cautions-regarding-runtime-finalization` " "for more details." msgstr "" +"スレッド状態のデタッチは、インタープリタの終了処理中に予期しない動作を引き起" +"こす可能性があります。\n" +"詳しくは :ref:`cautions-regarding-runtime-finalization` を参照してください。" -#: ../../c-api/threads.rst:142 msgid "APIs" -msgstr "" +msgstr "API" #: ../../c-api/threads.rst:144 msgid "" @@ -212,11 +277,12 @@ msgstr "" "以下のマクロは、通常末尾にセミコロンを付けずに使います; Python ソース配布物内" "の使用例を見てください。" -#: ../../c-api/threads.rst:149 msgid "" "These macros are still necessary on the :term:`free-threaded build` to " "prevent deadlocks." msgstr "" +"これらのマクロは、デッドロックを防ぐために :term:`フリースレッドビルド ` でも必要です。" #: ../../c-api/threads.rst:154 msgid "" @@ -230,17 +296,16 @@ msgstr "" "弧は後で :c:macro:`Py_END_ALLOW_THREADS` マクロと対応させなければなりません。" "マクロについての詳しい議論は上記を参照してください。" -#: ../../c-api/threads.rst:162 msgid "" "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it " "contains a closing brace; it must be matched with an earlier :c:macro:" "`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of this " "macro." msgstr "" -"このマクロを展開すると ``PyEval_RestoreThread(_save); }`` になります。マクロ" -"に開き波括弧が入っていることに注意してください; この波括弧は事前の :c:macro:" -"`Py_BEGIN_ALLOW_THREADS` マクロと対応していなければなりません。マクロについて" -"の詳しい議論は上記を参照してください。" +"このマクロを展開すると ``PyEval_RestoreThread(_save); }`` になります。\n" +"閉じ波括弧を含むため、事前の :c:macro:`Py_BEGIN_ALLOW_THREADS` マクロと対応さ" +"せなければなりません。\n" +"このマクロについては上の説明を参照してください。" #: ../../c-api/threads.rst:170 msgid "" @@ -259,11 +324,9 @@ msgstr "" "このマクロを展開すると ``_save = PyEval_SaveThread();`` になります: 開き波括" "弧のない :c:macro:`Py_BEGIN_ALLOW_THREADS` と同じです。" -#: ../../c-api/threads.rst:186 msgid "Using the C API from foreign threads" -msgstr "" +msgstr "外部スレッドからの C API の使用" -#: ../../c-api/threads.rst:188 msgid "" "When threads are created using the dedicated Python APIs (such as the :mod:" "`threading` module), a thread state is automatically associated with them, " @@ -271,22 +334,30 @@ msgid "" "party library with its own thread management), it doesn't hold an attached " "thread state." msgstr "" +":mod:`threading` モジュールなどの Python の専用 API でスレッドを作成すると、" +"スレッド状態が自動的に関連付けられます。\n" +"一方、独自のスレッド管理を行うサードパーティーライブラリなど、ネイティブコー" +"ドで作成されたスレッドには、アタッチされたスレッド状態がありません。" -#: ../../c-api/threads.rst:194 msgid "" "If you need to call Python code from these threads (often this will be part " "of a callback API provided by the aforementioned third-party library), you " "must first register these threads with the interpreter by creating a new " "thread state and attaching it." msgstr "" +"このようなスレッドから Python コードを呼び出す必要がある場合は、まずスレッド" +"状態を新しく作成してアタッチし、スレッドをインタープリタに登録しなければなり" +"ません。\n" +"このような呼び出しは、前述のサードパーティーライブラリが提供するコールバック " +"API の一部として行われることがよくあります。" -#: ../../c-api/threads.rst:199 msgid "" "The easiest way to do this is through :c:func:`PyThreadState_Ensure` or :c:" "func:`PyThreadState_EnsureFromView`." msgstr "" +"最も簡単な方法は、:c:func:`PyThreadState_Ensure` または :c:func:" +"`PyThreadState_EnsureFromView` を使うことです。" -#: ../../c-api/threads.rst:203 msgid "" "These functions require an argument pointing to the desired interpreter; " "such a pointer can be acquired via a call to :c:func:" @@ -298,12 +369,22 @@ msgid "" "interpreter, but note that this will make the code incompatible with " "subinterpreters." msgstr "" +"これらの関数には、対象のインタープリタを指すポインターを引数として渡す必要が" +"あります。\n" +"このポインターは、スレッドを作成する関数で :c:func:" +"`PyInterpreterGuard_FromCurrent` (``PyThreadState_Ensure`` 用) または :c:" +"func:`PyInterpreterView_FromCurrent` (``PyThreadState_EnsureFromView`` 用) を" +"呼び出すことで取得できます。\n" +"ネイティブスレッドライブラリにデータを渡す引数がない場合など、ポインターを利" +"用できないときは、:c:func:`PyInterpreterView_FromMain` でメインインタープリタ" +"のビューを取得できます。\n" +"ただし、この方法ではコードがサブインタープリタに対応できなくなることに注意し" +"てください。" #: ../../c-api/threads.rst:214 msgid "For example::" msgstr "例えば::" -#: ../../c-api/threads.rst:216 msgid "" "// The return value of PyInterpreterGuard_FromCurrent() from the\n" "// function that created this thread.\n" @@ -325,8 +406,26 @@ msgid "" "PyThreadState_Release(token);\n" "PyInterpreterGuard_Close(guard);" msgstr "" +"// このスレッドを作成した関数での\n" +"// PyInterpreterGuard_FromCurrent() の戻り値。\n" +"PyInterpreterGuard *guard = thread_data->guard;\n" +"\n" +"// インタープリタのスレッド状態を新しく作成する。\n" +"PyThreadStateToken *token = PyThreadState_Ensure(guard);\n" +"if (token == NULL) {\n" +" PyInterpreterGuard_Close(guard);\n" +" return;\n" +"}\n" +"\n" +"// 有効なスレッド状態があるので、ここで Python の操作を行う。\n" +"result = CallSomeFunction();\n" +"// result を評価するか、例外を処理する。\n" +"\n" +"// スレッド状態を解放する。\n" +"// ここから先では C API を呼び出してはならない。\n" +"PyThreadState_Release(token);\n" +"PyInterpreterGuard_Close(guard);" -#: ../../c-api/threads.rst:237 msgid "" "Keep in mind that calling ``PyThreadState_Ensure`` might not always create a " "new thread state, and calling ``PyThreadState_Release`` might not always " @@ -334,16 +433,20 @@ msgid "" "may re-attach a thread state that was previously attached for the current " "thread." msgstr "" +"``PyThreadState_Ensure`` を呼び出しても、必ずしもスレッド状態が新しく作成され" +"るとは限りません。\n" +"また、``PyThreadState_Release`` を呼び出しても、必ずしもデタッチされるとは限" +"りません。\n" +"これらの関数は、すでにアタッチされたスレッド状態を再利用したり、現在のスレッ" +"ドに以前アタッチされていたスレッド状態を再びアタッチしたりする場合がありま" +"す。" -#: ../../c-api/threads.rst:243 msgid ":pep:`788`" -msgstr "" +msgstr ":pep:`788`" -#: ../../c-api/threads.rst:248 msgid "Reusing a thread state across repeated calls" -msgstr "" +msgstr "繰り返しの呼び出しでスレッド状態を再利用する" -#: ../../c-api/threads.rst:250 msgid "" "Creating and destroying a :c:type:`PyThreadState` is not free, and is more " "expensive on a :term:`free-threaded build`. A foreign thread that calls " @@ -353,56 +456,78 @@ msgid "" "thread starts (or lazily on its first call into Python), attach and detach " "it around each call, and tear it down once when the thread exits." msgstr "" +":c:type:`PyThreadState` の作成と破棄にはコストがかかり、:term:`フリースレッド" +"ビルド ` ではさらに高くなります。\n" +"ネイティブのスレッドプールのワーカースレッドなど、インタープリタを何度も呼び" +"出す外部スレッドでは、呼び出しのたびにスレッド状態を作成し、戻るたびに破棄す" +"ることを避けるべきです。\n" +"代わりに、スレッドの開始時、または最初に Python を呼び出したときにスレッド状" +"態を 1 つ用意し、各呼び出しの前後でアタッチとデタッチを行い、スレッドの終了時" +"に一度だけ破棄します。" -#: ../../c-api/threads.rst:258 msgid "" "Manage the thread state explicitly with :c:func:`PyThreadState_New`, " "attaching and detaching it with :c:func:`PyEval_RestoreThread` and :c:func:" "`PyEval_SaveThread`. This happens in three distinct phases, at different " "points in the thread's life." msgstr "" +":c:func:`PyThreadState_New` でスレッド状態を明示的に管理し、:c:func:" +"`PyEval_RestoreThread` と :c:func:`PyEval_SaveThread` でアタッチとデタッチを" +"行います。\n" +"この処理は、スレッドのライフサイクルの異なる時点で行う、3 つの段階に分かれま" +"す。" -#: ../../c-api/threads.rst:263 msgid "" "When the thread starts, create one thread state for it. ``interp`` is the " "target interpreter, captured by the code that created this thread while it " "held an attached thread state (for example via :c:func:" "`PyInterpreterState_Get`)::" msgstr "" +"スレッドの開始時に、そのスレッドのスレッド状態を 1 つ作成します。\n" +"``interp`` は対象のインタープリタです。\n" +"スレッドを作成したコードが、スレッド状態をアタッチした状態で :c:func:" +"`PyInterpreterState_Get` などを呼び出して取得しておきます。 ::" -#: ../../c-api/threads.rst:267 msgid "PyThreadState *tstate = PyThreadState_New(interp);" -msgstr "" +msgstr "PyThreadState *tstate = PyThreadState_New(interp);" -#: ../../c-api/threads.rst:269 msgid "" "Then, on each call into Python -- which may happen many times over the " "thread's life -- attach the thread state, make the Python C API calls that " "require it, and detach again so the thread does not hold the GIL while off " "doing non-Python work::" msgstr "" +"その後、Python を呼び出すたびにスレッド状態をアタッチし、その状態を必要とす" +"る Python C API を呼び出してから、再びデタッチします。\n" +"こうすることで、Python 以外の処理中にスレッドが GIL を保持しないようにしま" +"す。\n" +"Python の呼び出しは、スレッドの存続中に何度も行われる場合があります。 ::" -#: ../../c-api/threads.rst:274 msgid "" "PyEval_RestoreThread(tstate);\n" "result = CallSomeFunction(); /* your Python C API calls go here */\n" "PyEval_SaveThread();" msgstr "" +"PyEval_RestoreThread(tstate);\n" +"result = CallSomeFunction(); /* ここで Python C API を呼び出す */\n" +"PyEval_SaveThread();" -#: ../../c-api/threads.rst:278 msgid "" "When the thread is finished calling into Python, destroy the thread state " "once::" msgstr "" +"スレッドが Python を呼び出す必要がなくなったら、スレッド状態を一度だけ破棄し" +"ます。 ::" -#: ../../c-api/threads.rst:280 msgid "" "PyEval_RestoreThread(tstate);\n" "PyThreadState_Clear(tstate);\n" "PyThreadState_DeleteCurrent();" msgstr "" +"PyEval_RestoreThread(tstate);\n" +"PyThreadState_Clear(tstate);\n" +"PyThreadState_DeleteCurrent();" -#: ../../c-api/threads.rst:284 msgid "" "The general-purpose entry points for calling in from a foreign thread -- :c:" "func:`PyThreadState_Ensure` and the older :c:func:`PyGILState_Ensure` -- do " @@ -412,8 +537,14 @@ msgid "" "`PyThreadState_New`, as shown here, whenever you specifically want to reuse " "one thread state across calls." msgstr "" +"外部スレッドからの呼び出しに使う汎用の関数 :c:func:`PyThreadState_Ensure` " +"と、従来の :c:func:`PyGILState_Ensure` は、スレッド状態が保持されることを保" +"証 *しません*。\n" +"スレッド状態の寿命は意図的に実装に委ねられているため、対応する取得と解放の組" +"ごとにスレッド状態が作成・破棄される場合があります。\n" +"呼び出しをまたいで 1 つのスレッド状態を再利用したい場合は、ここに示したよう" +"に :c:func:`PyThreadState_New` を使ってください。" -#: ../../c-api/threads.rst:292 msgid "" "The code that created the foreign thread must arrange for the shutdown " "sequence to run before the thread exits, and before :c:func:`Py_FinalizeEx` " @@ -423,44 +554,57 @@ msgid "" "running the shutdown sequence, the thread state is leaked for the remainder " "of the process." msgstr "" +"外部スレッドを作成したコードは、スレッドが終了する前、かつ :c:func:" +"`Py_FinalizeEx` が呼び出される前に、後始末の手順が実行されるようにしなければ" +"なりません。\n" +"インタープリタの終了処理が先に始まると、後始末で呼び出す :c:func:" +"`PyEval_RestoreThread` は戻らずにスレッドを停止させます (:ref:`cautions-" +"regarding-runtime-finalization` を参照)。\n" +"後始末を行わずにスレッドが終了すると、スレッド状態はプロセスの終了までリーク" +"したままになります。" -#: ../../c-api/threads.rst:303 msgid "Attaching/detaching thread states" -msgstr "" +msgstr "スレッド状態のアタッチとデタッチ" -#: ../../c-api/threads.rst:307 msgid "" "Ensure that the thread has an attached thread state for the interpreter " "protected by *guard*, and thus can safely invoke that interpreter." msgstr "" +"スレッドに、*guard* が保護するインタープリタのスレッド状態をアタッチし、その" +"インタープリタを安全に呼び出せるようにします。" -#: ../../c-api/threads.rst:311 msgid "" "It is OK to call this function if the thread already has an attached thread " "state, as long as there is a subsequent call to :c:func:" "`PyThreadState_Release` that matches this one (meaning that \"nested\" calls " "to this function are permitted)." msgstr "" +"すでにスレッド状態がアタッチされているスレッドから呼び出しても構いません。\n" +"ただし、この呼び出しに対応する :c:func:`PyThreadState_Release` を後で呼び出す" +"必要があります (つまり、この関数の入れ子の呼び出しは許可されています)。" -#: ../../c-api/threads.rst:316 msgid "" "The function's effect (if any) will be reversed by the matching call to :c:" "func:`PyThreadState_Release`." msgstr "" +"この関数が状態を変更した場合、対応する :c:func:`PyThreadState_Release` の呼び" +"出しによって元に戻ります。" -#: ../../c-api/threads.rst:319 msgid "" "On error, this function returns ``NULL`` *without* an exception set. Do not " "call :c:func:`!PyThreadState_Release` in this case." msgstr "" +"エラー時は、例外を設定 *せずに* ``NULL`` を返します。\n" +"この場合は :c:func:`!PyThreadState_Release` を呼び出さないでください。" -#: ../../c-api/threads.rst:322 msgid "" "On success, this function returns a pointer value that must be passed to the " "matching call to :c:func:`!PyThreadState_Release`." msgstr "" +"成功時はポインター値を返します。\n" +"この値は、対応する :c:func:`!PyThreadState_Release` の呼び出しに渡さなければ" +"なりません。" -#: ../../c-api/threads.rst:325 msgid "" "The conditions in which this function creates a new :term:`thread state` are " "considered unstable and implementation-dependent. If you need to control the " @@ -471,14 +615,24 @@ msgid "" "compatible manner. In particular, the saving of thread-local variables and " "similar state will be retained across Python versions." msgstr "" +"この関数が新しい :term:`スレッド状態 ` を作成する条件は、安定し" +"た仕様ではなく実装に依存します。\n" +"スレッド状態の寿命を厳密に制御する必要がある場合は、:c:func:" +"`PyThreadState_New` の使用を検討してください。\n" +"ただし、バージョンによってスレッド状態の寿命が異なる可能性があるという理由だ" +"けで、この関数の使用を避けないでください。\n" +"この関数の変更は、後方互換性を保ちながら慎重に行われます。\n" +"特に、スレッドローカル変数や同様の状態の保存は、Python のバージョンが変わって" +"も維持されます。" -#: ../../c-api/threads.rst:336 msgid "" "The exact behavior of whether this function creates a new thread state is " "described below, but be aware that this may change in the future." msgstr "" +"この関数が新しいスレッド状態を作成するかどうかの具体的な動作を以下に示しま" +"す。\n" +"ただし、将来変わる可能性があることに注意してください。" -#: ../../c-api/threads.rst:339 msgid "" "First, this function checks if an attached thread state is present. If there " "is, this function then checks if the interpreter of that thread state " @@ -486,8 +640,12 @@ msgid "" "function simply marks the thread state as being used by a " "``PyThreadState_Ensure`` call and returns." msgstr "" +"まず、アタッチされたスレッド状態があるかどうかを調べます。\n" +"ある場合は、そのスレッド状態のインタープリタが *guard* で保護されたインタープ" +"リタと一致するかを調べます。\n" +"一致すれば、スレッド状態に ``PyThreadState_Ensure`` の呼び出しで使用中である" +"ことを記録して戻ります。" -#: ../../c-api/threads.rst:345 msgid "" "If there is no attached thread state, then this function checks if any " "thread state has been used by the current OS thread. (This is returned by :c:" @@ -495,76 +653,96 @@ msgid "" "checks if that thread state's interpreter matches *guard*. If it does, it is " "re-attached and marked as used." msgstr "" +"アタッチされたスレッド状態がない場合は、現在の OS スレッドが使用したスレッド" +"状態があるかどうかを調べます (:c:func:`PyGILState_GetThisThreadState` が返す" +"ものです)。\n" +"ある場合は、そのスレッド状態のインタープリタが *guard* と一致するかを調べま" +"す。\n" +"一致すれば、再びアタッチして使用中であることを記録します。" -#: ../../c-api/threads.rst:351 msgid "" "Otherwise, if both of the above cases fail, a new thread state is created " "for *guard*. It is then attached and marked as owned by " "``PyThreadState_Ensure``." msgstr "" +"上のどちらにも当てはまらない場合は、*guard* 用のスレッド状態を新しく作成しま" +"す。\n" +"その後、そのスレッド状態をアタッチし、``PyThreadState_Ensure`` が所有すること" +"を記録します。" -#: ../../c-api/threads.rst:359 msgid "Get an attached thread state for the interpreter referenced by *view*." msgstr "" +"*view* が参照するインタープリタの、アタッチされたスレッド状態を取得します。" -#: ../../c-api/threads.rst:361 msgid "" "The behavior and return value are the same as for :c:func:" "`PyThreadState_Ensure`; additionally, if the function succeeds, the " "interpreter referenced by *view* will be implicitly guarded. The guard will " "be released upon the corresponding :c:func:`PyThreadState_Release` call." msgstr "" +"動作と戻り値は :c:func:`PyThreadState_Ensure` と同じです。\n" +"さらに、関数が成功した場合は *view* が参照するインタープリタが暗黙に保護され" +"ます。\n" +"この保護は、対応する :c:func:`PyThreadState_Release` の呼び出しで解除されま" +"す。" -#: ../../c-api/threads.rst:371 msgid "" "Undo a :c:func:`PyThreadState_Ensure` or :c:func:" "`PyThreadState_EnsureFromView` call." msgstr "" +":c:func:`PyThreadState_Ensure` または :c:func:`PyThreadState_EnsureFromView` " +"の呼び出しによる変更を元に戻します。" -#: ../../c-api/threads.rst:374 msgid "" "This must be called exactly once for each successful *Ensure* call, with " "*token* set to that call's return value." msgstr "" +"成功した *Ensure* の呼び出しごとに、その戻り値を *token* に指定して、必ず一度" +"だけ呼び出さなければなりません。" -#: ../../c-api/threads.rst:377 msgid "" "The state that was attached before the corresponding *Ensure* call (if any) " "will be attached when :c:func:`PyThreadState_Release` returns." msgstr "" +"対応する *Ensure* の呼び出しの前にスレッド状態がアタッチされていた場合、:c:" +"func:`PyThreadState_Release` が戻るときには、その状態がアタッチされています。" -#: ../../c-api/threads.rst:380 msgid "" "The exact behavior of whether this function deletes a thread state is " "considered unstable and implementation-dependent." msgstr "" +"この関数がスレッド状態を削除するかどうかの具体的な動作は、安定した仕様ではな" +"く実装に依存します。" -#: ../../c-api/threads.rst:385 msgid "" "Currently, this function will decrement an internal counter on the attached " "thread state. If this counter ever reaches below zero, this function emits a " "fatal error (via :c:func:`Py_FatalError`)." msgstr "" +"現在、この関数はアタッチされたスレッド状態の内部カウンターを減らします。\n" +"カウンターがゼロ未満になると、:c:func:`Py_FatalError` によって致命的エラーを" +"発生させます。" -#: ../../c-api/threads.rst:389 msgid "" "If the attached thread state is owned by ``PyThreadState_Ensure``, then the " "attached thread state will be deallocated and deleted upon the internal " "counter reaching zero. Otherwise, nothing happens when the counter reaches " "zero." msgstr "" +"アタッチされたスレッド状態を ``PyThreadState_Ensure`` が所有している場合は、" +"内部カウンターがゼロになるとそのスレッド状態を解放して削除します。\n" +"それ以外の場合は、カウンターがゼロになっても何も起こりません。" -#: ../../c-api/threads.rst:397 msgid "" "An opaque token retrieved from a :c:func:`PyThreadState_Ensure` call and " "passed to a corresponding :c:func:`PyThreadState_Release` call." msgstr "" +":c:func:`PyThreadState_Ensure` の呼び出しで取得し、対応する :c:func:" +"`PyThreadState_Release` の呼び出しに渡す不透明なトークンです。" -#: ../../c-api/threads.rst:405 msgid "GIL-state APIs" -msgstr "" +msgstr "GIL 状態の API" -#: ../../c-api/threads.rst:407 msgid "" "The following APIs are generally not compatible with subinterpreters and " "will hang the process during interpreter finalization (see :ref:`cautions-" @@ -572,22 +750,29 @@ msgid "" "deprecated` in Python 3.15 in favor of the :ref:`new APIs `." msgstr "" +"以下の API は一般にサブインタープリタに対応しておらず、インタープリタの終了処" +"理中にはプロセスが停止したままになります (:ref:`cautions-regarding-runtime-" +"finalization` を参照)。\n" +"そのため、Python 3.15 で :term:`緩やかに非推奨 ` となり、代" +"わりに :ref:`新しい API ` の使用を推奨します。" -#: ../../c-api/threads.rst:416 msgid "" "The type of the value returned by :c:func:`PyGILState_Ensure` and passed to :" "c:func:`PyGILState_Release`." msgstr "" +":c:func:`PyGILState_Ensure` が返し、:c:func:`PyGILState_Release` に渡す値の型" +"です。" -#: ../../c-api/threads.rst:421 msgid "The GIL was already held when :c:func:`PyGILState_Ensure` was called." msgstr "" +":c:func:`PyGILState_Ensure` が呼び出された時点で、すでに GIL を保持していまし" +"た。" -#: ../../c-api/threads.rst:425 msgid "The GIL was not held when :c:func:`PyGILState_Ensure` was called." msgstr "" +":c:func:`PyGILState_Ensure` が呼び出された時点では、GIL を保持していませんで" +"した。" -#: ../../c-api/threads.rst:430 msgid "" "Ensure that the current thread is ready to call the Python C API regardless " "of the current state of Python, or of the :term:`attached thread state`. " @@ -599,8 +784,16 @@ msgid "" "c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros " "is acceptable." msgstr "" +"Python や :term:`アタッチされたスレッド状態 ` の現在の" +"状態にかかわらず、現在のスレッドで Python C API を呼び出せるようにします。\n" +"各呼び出しに対応する :c:func:`PyGILState_Release` を呼び出す限り、スレッドは" +"何度でもこの関数を呼び出せます。\n" +"一般に、:c:func:`PyGILState_Ensure` と :c:func:`PyGILState_Release` の間で" +"は、``Release()`` の前にスレッド状態を元に戻す限り、ほかのスレッド関連の API " +"を使っても構いません。\n" +"例えば、:c:macro:`Py_BEGIN_ALLOW_THREADS` と :c:macro:`Py_END_ALLOW_THREADS` " +"マクロは通常どおり使えます。" -#: ../../c-api/threads.rst:440 msgid "" "The return value is an opaque \"handle\" to the :term:`attached thread " "state` when :c:func:`PyGILState_Ensure` was called, and must be passed to :c:" @@ -609,56 +802,78 @@ msgid "" "unique call to :c:func:`PyGILState_Ensure` must save the handle for its call " "to :c:func:`PyGILState_Release`." msgstr "" +"戻り値は、:c:func:`PyGILState_Ensure` を呼び出したときの :term:`アタッチされ" +"たスレッド状態 ` を表す不透明な「ハンドル」です。\n" +"Python を同じ状態に戻すため、:c:func:`PyGILState_Release` に渡さなければなり" +"ません。\n" +"再帰的な呼び出しは許可されていますが、ハンドルを共有することは *できません" +"*。\n" +":c:func:`PyGILState_Ensure` の呼び出しごとにハンドルを保存し、その呼び出しに" +"対応する :c:func:`PyGILState_Release` に渡す必要があります。" -#: ../../c-api/threads.rst:447 msgid "" "When the function returns, there will be an :term:`attached thread state` " "and the thread will be able to call arbitrary Python code." msgstr "" +"この関数が戻るときには :term:`スレッド状態がアタッチされており `、スレッドは任意の Python コードを呼び出せます。" -#: ../../c-api/threads.rst:450 msgid "" "This function has no way to return an error. As such, errors are either " "fatal (that is, they send ``SIGABRT`` and crash the process; see :c:func:" "`Py_FatalError`), or the thread will be permanently blocked (such as during " "interpreter finalization)." msgstr "" +"この関数にはエラーを返す手段がありません。\n" +"そのため、エラーは致命的エラーとなる (``SIGABRT`` を送信してプロセスを異常終" +"了させる。\n" +":c:func:`Py_FatalError` を参照) か、インタープリタの終了処理中のように、ス" +"レッドが永久にブロックされます。" -#: ../../c-api/threads.rst:456 msgid "" "Calling this function when the interpreter is finalizing will infinitely " "hang the thread, which may cause deadlocks. :ref:`cautions-regarding-runtime-" "finalization` for more details." msgstr "" +"インタープリタの終了処理中に呼び出すと、スレッドが無期限に停止し、デッドロッ" +"クの原因になる可能性があります。\n" +"詳しくは :ref:`cautions-regarding-runtime-finalization` を参照してください。" -#: ../../c-api/threads.rst:460 msgid "" "In addition, this function generally does not work with subinterpreters when " "used from foreign threads, because this function has no way of knowing which " "interpreter created the thread (and as such, will implicitly pick the main " "interpreter)." msgstr "" +"また、外部スレッドから使う場合、この関数は一般にサブインタープリタでは動作し" +"ません。\n" +"どのインタープリタがスレッドを作成したかを知る手段がないため、暗黙にメインイ" +"ンタープリタを選ぶからです。" -#: ../../c-api/threads.rst:465 ../../c-api/threads.rst:625 -#: ../../c-api/threads.rst:819 msgid "" "Hangs the current thread, rather than terminating it, if called while the " "interpreter is finalizing." msgstr "" +"インタープリタの終了処理中に呼び出された場合、現在のスレッドを終了させる代わ" +"りに、停止したままにするようになりました。" -#: ../../c-api/threads.rst:469 msgid "" "Use :c:func:`PyThreadState_Ensure` or :c:func:`PyThreadState_EnsureFromView` " "instead." msgstr "" +"代わりに :c:func:`PyThreadState_Ensure` または :c:func:" +"`PyThreadState_EnsureFromView` を使ってください。" -#: ../../c-api/threads.rst:476 msgid "" "Release any resources previously acquired. After this call, Python's state " "will be the same as it was prior to the corresponding :c:func:" "`PyGILState_Ensure` call (but generally this state will be unknown to the " "caller, hence the use of the GIL-state API)." msgstr "" +"先に取得したリソースを解放します。\n" +"呼び出し後の Python の状態は、対応する :c:func:`PyGILState_Ensure` の呼び出し" +"の前と同じになります (ただし、呼び出し元は通常その状態を把握していないため、" +"GIL 状態の API を使います)。" #: ../../c-api/threads.rst:481 msgid "" @@ -668,65 +883,67 @@ msgstr "" ":c:func:`PyGILState_Ensure` を呼び出す場合は、必ず同一スレッド内で対応する :" "c:func:`PyGILState_Release` を呼び出してください。" -#: ../../c-api/threads.rst:484 msgid "Use :c:func:`PyThreadState_Release` instead." -msgstr "" +msgstr "代わりに :c:func:`PyThreadState_Release` を使ってください。" -#: ../../c-api/threads.rst:490 msgid "" "Get the :term:`thread state` that was most recently :term:`attached " "` for this thread. (If the most recent thread state " "has been deleted, this returns ``NULL``.)" msgstr "" +"このスレッドに最後に :term:`アタッチされた ` :term:`ス" +"レッド状態 ` を取得します。\n" +"最後のスレッド状態が削除されていれば ``NULL`` を返します。" -#: ../../c-api/threads.rst:494 msgid "If the caller has an attached thread state, it is returned." -msgstr "" +msgstr "呼び出し元にアタッチされたスレッド状態があれば、それを返します。" -#: ../../c-api/threads.rst:496 msgid "" "In other terms, this function returns the thread state that will be used by :" "c:func:`PyGILState_Ensure`. If this returns ``NULL``, then " "``PyGILState_Ensure`` will create a new thread state." msgstr "" +"言い換えると、:c:func:`PyGILState_Ensure` が使うスレッド状態を返します。\n" +"``NULL`` を返す場合、``PyGILState_Ensure`` はスレッド状態を新しく作成します。" -#: ../../c-api/threads.rst:500 msgid "This function cannot fail." -msgstr "" +msgstr "この関数は失敗しません。" -#: ../../c-api/threads.rst:502 msgid "" "Use :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked` " "instead." msgstr "" +"代わりに :c:func:`PyThreadState_Get` または :c:func:" +"`PyThreadState_GetUnchecked` を使ってください。" -#: ../../c-api/threads.rst:509 msgid "" "Return ``1`` if the current thread has an :term:`attached thread state` that " "matches the thread state returned by :c:func:" "`PyGILState_GetThisThreadState`. If the caller has no attached thread state " "or it otherwise doesn't match, then this returns ``0``." msgstr "" +"現在のスレッドに :term:`アタッチされたスレッド状態 ` " +"があり、:c:func:`PyGILState_GetThisThreadState` が返すスレッド状態と一致する" +"場合は ``1`` を返します。\n" +"呼び出し元にアタッチされたスレッド状態がない場合や、一致しない場合は ``0`` を" +"返します。" -#: ../../c-api/threads.rst:514 msgid "" "If the current Python process has ever created a subinterpreter, this " "function will *always* return ``1``." msgstr "" +"現在の Python プロセスが一度でもサブインタープリタを作成していれば、この関数" +"は *常に* ``1`` を返します。" -#: ../../c-api/threads.rst:517 msgid "This is mainly a helper/diagnostic function." -msgstr "" +msgstr "主に補助や診断のための関数です。" -#: ../../c-api/threads.rst:521 msgid "Use ``PyThreadState_GetUnchecked() != NULL`` instead." -msgstr "" +msgstr "代わりに ``PyThreadState_GetUnchecked() != NULL`` を使ってください。" -#: ../../c-api/threads.rst:528 msgid "Cautions about fork()" -msgstr "" +msgstr "fork() に関する注意" -#: ../../c-api/threads.rst:530 msgid "" "Another important thing to note about threads is their behaviour in the face " "of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a " @@ -734,8 +951,13 @@ msgid "" "concrete impact both on how locks must be handled and on all stored state in " "CPython's runtime." msgstr "" +"スレッドに関するもう 1 つの重要な注意点は、C の :c:func:`fork` 呼び出し時の動" +"作です。\n" +":c:func:`fork` を備えるほとんどのシステムでは、プロセスを fork した後には、" +"fork を呼び出したスレッドだけが存在します。\n" +"これは、ロックの扱い方と CPython ランタイムに保存されたすべての状態の両方に、" +"具体的な影響を及ぼします。" -#: ../../c-api/threads.rst:536 msgid "" "The fact that only the \"current\" thread remains means any locks held by " "other threads will never be released. Python solves this for :func:`os.fork` " @@ -751,8 +973,23 @@ msgid "" "after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary " "locks, but is not always able to." msgstr "" +"「現在の」スレッドだけが残るため、ほかのスレッドが保持していたロックは解放さ" +"れなくなります。\n" +"Python は :func:`os.fork` で、内部で使うロックを fork の前に取得し、後で解放" +"することで対処します。\n" +"さらに、子プロセスの :ref:`lock-objects` をすべてリセットします。\n" +"Python の拡張や組み込みでは、fork 前の取得や fork 後のリセットが必要な、" +"Python 以外の追加のロックを Python に知らせる方法はありません。\n" +"同じ処理を行うには、:c:func:`!pthread_atfork` などの OS の機能を使う必要があ" +"ります。\n" +"また、Python の拡張や組み込みで :func:`os.fork` を経由せずに :c:func:`fork` " +"を直接呼び出し、その後 Python に戻るか Python を呼び出すと、デッドロックが起" +"こる可能性があります。\n" +"Python 内部のロックを保持していたスレッドが、fork 後には存在しなくなるためで" +"す。\n" +":c:func:`PyOS_AfterFork_Child` は必要なロックのリセットを試みますが、常にでき" +"るとは限りません。" -#: ../../c-api/threads.rst:551 msgid "" "The fact that all other threads go away also means that CPython's runtime " "state there must be cleaned up properly, which :func:`os.fork` does. This " @@ -764,39 +1001,45 @@ msgid "" "originally initialized. The only exception is if :c:func:`exec` will be " "called immediately after." msgstr "" +"ほかのスレッドがすべて消えるため、それらに対応する CPython ランタイムの状態も" +"適切に後始末する必要があります。\n" +":func:`os.fork` はこの処理を行います。\n" +"具体的には、現在のインタープリタに属するほかのすべての :c:type:" +"`PyThreadState` オブジェクトと、ほかのすべての :c:type:`PyInterpreterState` " +"オブジェクトの終了処理を行います。\n" +"このことと :ref:`メインインタープリタ ` の特殊な性質" +"のため、:c:func:`fork` は、CPython のグローバルなランタイムを最初に初期化し" +"た、そのインタープリタの「メイン」スレッドでのみ呼び出すべきです。\n" +"直後に :c:func:`exec` を呼び出す場合だけは例外です。" #: ../../c-api/threads.rst:564 msgid "High-level APIs" msgstr "高水準 API" -#: ../../c-api/threads.rst:566 msgid "" "These are the most commonly used types and functions when writing multi-" "threaded C extensions." -msgstr "" +msgstr "マルチスレッドの C 拡張を書くときに最もよく使われる型と関数です。" -#: ../../c-api/threads.rst:572 msgid "" "This data structure represents the state of a single thread. The only " "public data member is:" msgstr "" +"このデータ構造は、1 つのスレッドの状態を表します。\n" +"公開されているデータメンバーは次のものだけです。" -#: ../../c-api/threads.rst:577 msgid "This thread's interpreter state." -msgstr "" +msgstr "このスレッドのインタープリタ状態。" -#: ../../c-api/threads.rst:588 msgid "Deprecated function which does nothing." -msgstr "" +msgstr "何も行わない非推奨の関数です。" -#: ../../c-api/threads.rst:590 msgid "" "In Python 3.6 and older, this function created the GIL if it didn't exist." -msgstr "" +msgstr "Python 3.6 以前では、GIL が存在しなければ作成していました。" -#: ../../c-api/threads.rst:592 msgid "The function now does nothing." -msgstr "" +msgstr "この関数は何も行わなくなりました。" #: ../../c-api/threads.rst:595 msgid "" @@ -813,181 +1056,215 @@ msgstr "" "この関数は :c:func:`Py_Initialize()` より前に呼び出すことができなくなりまし" "た。" -#: ../../c-api/threads.rst:609 msgid "" "Detach the :term:`attached thread state` and return it. The thread will have " "no :term:`thread state` upon returning." msgstr "" +":term:`アタッチされたスレッド状態 ` をデタッチして返し" +"ます。\n" +"戻るときには、スレッドに :term:`スレッド状態 ` はアタッチされて" +"いません。" -#: ../../c-api/threads.rst:615 msgid "" "Set the :term:`attached thread state` to *tstate*. The passed :term:`thread " "state` **should not** be :term:`attached `, otherwise " "deadlock ensues. *tstate* will be attached upon returning." msgstr "" +":term:`アタッチされたスレッド状態 ` を *tstate* に設定" +"します。\n" +"渡す :term:`スレッド状態 ` は :term:`アタッチされていてはなりま" +"せん `。\n" +"アタッチ済みの場合はデッドロックします。\n" +"戻るときには *tstate* がアタッチされています。" -#: ../../c-api/threads.rst:620 ../../c-api/threads.rst:809 msgid "" "Calling this function from a thread when the runtime is finalizing will hang " "the thread until the program exits, even if the thread was not created by " "Python. Refer to :ref:`cautions-regarding-runtime-finalization` for more " "details." msgstr "" +"ランタイムの終了処理中にスレッドからこの関数を呼び出すと、そのスレッドはプロ" +"グラムが終了するまで停止したままになります。\n" +"これは Python で作成したスレッドでなくても同じです。\n" +"詳しくは :ref:`cautions-regarding-runtime-finalization` を参照してください。" -#: ../../c-api/threads.rst:631 msgid "" "Return the :term:`attached thread state`. If the thread has no attached " "thread state, (such as when inside of :c:macro:`Py_BEGIN_ALLOW_THREADS` " "block), then this issues a fatal error (so that the caller needn't check for " "``NULL``)." msgstr "" +":term:`アタッチされたスレッド状態 ` を返します。\n" +":c:macro:`Py_BEGIN_ALLOW_THREADS` ブロック内など、スレッド状態がアタッチされ" +"ていない場合は致命的エラーを発生させます (そのため、呼び出し元は ``NULL`` か" +"どうかを調べる必要がありません)。" -#: ../../c-api/threads.rst:636 msgid "See also :c:func:`PyThreadState_GetUnchecked`." -msgstr "" +msgstr ":c:func:`PyThreadState_GetUnchecked` も参照してください。" -#: ../../c-api/threads.rst:640 msgid "" "Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a " "fatal error if it is NULL. The caller is responsible to check if the result " "is NULL." msgstr "" +":c:func:`PyThreadState_Get` と同様ですが、スレッド状態が NULL でも致命的エ" +"ラーでプロセスを終了させません。\n" +"結果が NULL かどうかは、呼び出し元が調べる必要があります。" -#: ../../c-api/threads.rst:644 msgid "" "In Python 3.5 to 3.12, the function was private and known as " "``_PyThreadState_UncheckedGet()``." msgstr "" +"Python 3.5 から 3.12 では、この関数は非公開で、" +"``_PyThreadState_UncheckedGet()`` という名前でした。" -#: ../../c-api/threads.rst:651 msgid "" "Set the :term:`attached thread state` to *tstate*, and return the :term:" "`thread state` that was attached prior to calling." msgstr "" +":term:`アタッチされたスレッド状態 ` を *tstate* に設定" +"し、呼び出し前にアタッチされていた :term:`スレッド状態 ` を返し" +"ます。" -#: ../../c-api/threads.rst:654 msgid "" "This function is safe to call without an :term:`attached thread state`; it " "will simply return ``NULL`` indicating that there was no prior thread state." msgstr "" +":term:`アタッチされたスレッド状態 ` がなくても安全に呼" +"び出せます。\n" +"その場合は、以前のスレッド状態がなかったことを示す ``NULL`` を返すだけです。" -#: ../../c-api/threads.rst:658 msgid ":c:func:`PyEval_ReleaseThread`" -msgstr "" +msgstr ":c:func:`PyEval_ReleaseThread`" -#: ../../c-api/threads.rst:661 msgid "" "Similar to :c:func:`PyGILState_Ensure`, this function will hang the thread " "if the runtime is finalizing." msgstr "" +":c:func:`PyGILState_Ensure` と同様に、ランタイムの終了処理中にはスレッドが停" +"止したままになります。" #: ../../c-api/threads.rst:666 msgid "Low-level APIs" msgstr "低水準 API" -#: ../../c-api/threads.rst:670 msgid "" "Create a new thread state object belonging to the given interpreter object. " "An :term:`attached thread state` is not needed." msgstr "" +"指定されたインタープリタオブジェクトに属するスレッド状態オブジェクトを新しく" +"作成します。\n" +":term:`アタッチされたスレッド状態 ` は必要ありません。" -#: ../../c-api/threads.rst:675 msgid "" "Reset all information in a :term:`thread state` object. *tstate* must be :" "term:`attached `" msgstr "" +":term:`スレッド状態 ` オブジェクトのすべての情報をリセットしま" +"す。\n" +"*tstate* は :term:`アタッチされていなければなりません `。" -#: ../../c-api/threads.rst:678 msgid "" "This function now calls the :c:member:`!PyThreadState.on_delete` callback. " "Previously, that happened in :c:func:`PyThreadState_Delete`." msgstr "" +"この関数が :c:member:`!PyThreadState.on_delete` コールバックを呼び出すように" +"なりました。\n" +"以前は :c:func:`PyThreadState_Delete` で呼び出していました。" -#: ../../c-api/threads.rst:682 msgid "The :c:member:`!PyThreadState.on_delete` callback was removed." -msgstr "" +msgstr ":c:member:`!PyThreadState.on_delete` コールバックが削除されました。" -#: ../../c-api/threads.rst:688 msgid "" "Destroy a :term:`thread state` object. *tstate* should not be :term:" "`attached ` to any thread. *tstate* must have been " "reset with a previous call to :c:func:`PyThreadState_Clear`." msgstr "" +":term:`スレッド状態 ` オブジェクトを破棄します。\n" +"*tstate* はどのスレッドにも :term:`アタッチされていてはなりません `。\n" +"事前に :c:func:`PyThreadState_Clear` を呼び出して *tstate* をリセットしておく" +"必要があります。" -#: ../../c-api/threads.rst:696 msgid "" "Detach the :term:`attached thread state` (which must have been reset with a " "previous call to :c:func:`PyThreadState_Clear`) and then destroy it." msgstr "" +":term:`アタッチされたスレッド状態 ` をデタッチし、破棄" +"します。\n" +"このスレッド状態は、事前に :c:func:`PyThreadState_Clear` を呼び出してリセット" +"しておく必要があります。" -#: ../../c-api/threads.rst:699 msgid "" "No :term:`thread state` will be :term:`attached ` " "upon returning." msgstr "" +"戻るときには、:term:`アタッチされた ` :term:`スレッド" +"状態 ` はありません。" -#: ../../c-api/threads.rst:704 msgid "Get the current frame of the Python thread state *tstate*." -msgstr "" +msgstr "Python のスレッド状態 *tstate* の現在のフレームを取得します。" -#: ../../c-api/threads.rst:706 msgid "" "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently " "executing." msgstr "" +":term:`強参照 ` を返します。\n" +"現在実行中のフレームがなければ ``NULL`` を返します。" -#: ../../c-api/threads.rst:709 msgid "See also :c:func:`PyEval_GetFrame`." -msgstr "" +msgstr ":c:func:`PyEval_GetFrame` も参照してください。" -#: ../../c-api/threads.rst:711 ../../c-api/threads.rst:720 -#: ../../c-api/threads.rst:729 msgid "" "*tstate* must not be ``NULL``, and must be :term:`attached `." msgstr "" +"*tstate* は ``NULL`` であってはならず、:term:`アタッチされていなければなりま" +"せん `。" -#: ../../c-api/threads.rst:718 msgid "" "Get the unique :term:`thread state` identifier of the Python thread state " "*tstate*." msgstr "" +"Python のスレッド状態 *tstate* の、一意な :term:`スレッド状態 ` 識別子を取得します。" -#: ../../c-api/threads.rst:727 msgid "Get the interpreter of the Python thread state *tstate*." -msgstr "" +msgstr "Python のスレッド状態 *tstate* のインタープリタを取得します。" -#: ../../c-api/threads.rst:736 msgid "Suspend tracing and profiling in the Python thread state *tstate*." msgstr "" +"Python のスレッド状態 *tstate* でのトレースとプロファイリングを一時停止しま" +"す。" -#: ../../c-api/threads.rst:738 msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function." -msgstr "" +msgstr "再開するには :c:func:`PyThreadState_LeaveTracing` を使います。" -#: ../../c-api/threads.rst:745 msgid "" "Resume tracing and profiling in the Python thread state *tstate* suspended " "by the :c:func:`PyThreadState_EnterTracing` function." msgstr "" +":c:func:`PyThreadState_EnterTracing` によって一時停止した、Python のスレッド" +"状態 *tstate* でのトレースとプロファイリングを再開します。" -#: ../../c-api/threads.rst:748 msgid "" "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions." msgstr "" +":c:func:`PyEval_SetTrace` と :c:func:`PyEval_SetProfile` も参照してください。" -#: ../../c-api/threads.rst:756 msgid "" "Set the stack protection start address and stack protection size of a Python " "thread state." msgstr "" +"Python のスレッド状態の、スタック保護の開始アドレスとサイズを設定します。" -#: ../../c-api/threads.rst:759 msgid "" "On success, return ``0``. On failure, set an exception and return ``-1``." msgstr "" +"成功時は ``0`` を返します。\n" +"失敗時は例外を設定して ``-1`` を返します。" -#: ../../c-api/threads.rst:762 msgid "" "CPython implements :ref:`recursion control ` for C code by " "raising :py:exc:`RecursionError` when it notices that the machine execution " @@ -999,32 +1276,46 @@ msgid "" "func:`~PyUnstable_ThreadState_SetStackProtection` to inform CPython of the " "change." msgstr "" +"CPython は、マシンの実行スタックがオーバーフローに近づいていることを検出する" +"と :py:exc:`RecursionError` を送出することで、C コードの :ref:`再帰を制御 " +"` します。\n" +"例えば :c:func:`Py_EnterRecursiveCall` を参照してください。\n" +"このため、現在のスレッドのスタックの位置を知る必要があり、通常は OS から取得" +"します。\n" +"Boost ライブラリの ``boost::context`` のようなコンテキスト切り替え技法でス" +"タックを変更する場合は、:c:func:`~PyUnstable_ThreadState_SetStackProtection` " +"を呼び出して CPython に変更を知らせなければなりません。" -#: ../../c-api/threads.rst:771 msgid "" "Call :c:func:`~PyUnstable_ThreadState_SetStackProtection` either before or " "after changing the stack. Do not call any other Python C API between the " "call and the stack change." msgstr "" +":c:func:`~PyUnstable_ThreadState_SetStackProtection` は、スタックを変更する前" +"か後に呼び出してください。\n" +"この呼び出しとスタックの変更の間に、ほかの Python C API を呼び出さないでくだ" +"さい。" -#: ../../c-api/threads.rst:776 msgid "" "See :c:func:`PyUnstable_ThreadState_ResetStackProtection` for undoing this " "operation." msgstr "" +"この操作を元に戻すには :c:func:`PyUnstable_ThreadState_ResetStackProtection` " +"を参照してください。" -#: ../../c-api/threads.rst:783 msgid "" "Reset the stack protection start address and stack protection size of a " "Python thread state to the operating system defaults." msgstr "" +"Python のスレッド状態の、スタック保護の開始アドレスとサイズを OS のデフォルト" +"値に戻します。" -#: ../../c-api/threads.rst:786 msgid "" "See :c:func:`PyUnstable_ThreadState_SetStackProtection` for an explanation." msgstr "" +"説明は :c:func:`PyUnstable_ThreadState_SetStackProtection` を参照してくださ" +"い。" -#: ../../c-api/threads.rst:793 msgid "" "Return a dictionary in which extensions can store thread-specific state " "information. Each extension should use a unique key to use to store state " @@ -1033,24 +1324,36 @@ msgid "" "``NULL``, no exception has been raised and the caller should assume no " "thread state is attached." msgstr "" +"拡張がスレッド固有の状態情報を保存するための辞書を返します。\n" +"各拡張は、一意なキーを使って辞書に状態を保存するべきです。\n" +":term:`スレッド状態 ` が :term:`アタッチされていない ` 場合も呼び出せます。\n" +"``NULL`` が返った場合、例外は送出されておらず、呼び出し元はスレッド状態がア" +"タッチされていないと判断するべきです。" -#: ../../c-api/threads.rst:803 msgid "" ":term:`Attach ` *tstate* to the current thread, which " "must not be ``NULL`` or already :term:`attached `." msgstr "" +"*tstate* を現在のスレッドに :term:`アタッチ ` しま" +"す。\n" +"*tstate* は ``NULL`` であってはならず、すでに :term:`アタッチされていてもなり" +"ません `。" -#: ../../c-api/threads.rst:806 msgid "" "The calling thread must not already have an :term:`attached thread state`." msgstr "" +"呼び出し元のスレッドに、すでに :term:`アタッチされたスレッド状態 ` があってはなりません。" -#: ../../c-api/threads.rst:814 msgid "" "Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:" "`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the " "current thread if called while the interpreter is finalizing." msgstr "" +":c:func:`PyEval_RestoreThread`、:c:func:`Py_END_ALLOW_THREADS`、:c:func:" +"`PyGILState_Ensure` と動作を揃え、インタープリタの終了処理中に呼び出された場" +"合は、現在のスレッドを終了させるようになりました。" #: ../../c-api/threads.rst:823 msgid "" @@ -1060,12 +1363,16 @@ msgstr "" ":c:func:`PyEval_RestoreThread` はいつでも (スレッドが初期化されたいないときで" "も) 利用可能な高レベル関数です。" -#: ../../c-api/threads.rst:829 msgid "" "Detach the :term:`attached thread state`. The *tstate* argument, which must " "not be ``NULL``, is only used to check that it represents the :term:" "`attached thread state` --- if it isn't, a fatal error is reported." msgstr "" +":term:`アタッチされたスレッド状態 ` をデタッチしま" +"す。\n" +"*tstate* 引数は ``NULL`` であってはならず、:term:`アタッチされたスレッド状態 " +"` を表しているかどうかの確認にのみ使われます。\n" +"一致しなければ致命的エラーを報告します。" #: ../../c-api/threads.rst:834 msgid "" @@ -1075,9 +1382,8 @@ msgstr "" ":c:func:`PyEval_SaveThread` はより高レベルな関数で常に (スレッドが初期化され" "ていないときでも) 利用できます。" -#: ../../c-api/threads.rst:839 msgid "Asynchronous notifications" -msgstr "" +msgstr "非同期通知" #: ../../c-api/threads.rst:841 msgid "" @@ -1114,19 +1420,24 @@ msgstr "" msgid "on a :term:`bytecode` boundary;" msgstr ":term:`bytecode` 境界上にいるとき、" -#: ../../c-api/threads.rst:858 msgid "" "with the main thread holding an :term:`attached thread state` (*func* can " "therefore use the full C API)." msgstr "" +"メインスレッドに :term:`スレッド状態がアタッチされている ` こと (したがって *func* はすべての C API を使えます)。" -#: ../../c-api/threads.rst:861 msgid "" "*func* must return ``0`` on success, or ``-1`` on failure with an exception " "set. *func* won't be interrupted to perform another asynchronous " "notification recursively, but it can still be interrupted to switch threads " "if the :term:`thread state ` is detached." msgstr "" +"*func* は成功時に ``0`` を返し、失敗時には例外を設定して ``-1`` を返さなけれ" +"ばなりません。\n" +"別の非同期通知を再帰的に処理するために *func* が中断されることはありません" +"が、:term:`スレッド状態 ` がデタッチされると、スレッド" +"の切り替えのために中断されることはあります。" #: ../../c-api/threads.rst:866 msgid "" @@ -1136,7 +1447,6 @@ msgid "" "be called from the wrong interpreter." msgstr "" -#: ../../c-api/threads.rst:871 msgid "" "This is a low-level function, only useful for very special cases. There is " "no guarantee that *func* will be called as quick as possible. If the main " @@ -1145,71 +1455,95 @@ msgid "" "calling Python code from arbitrary C threads. Instead, use :c:func:" "`PyThreadState_EnsureFromView`." msgstr "" +"これは低水準の関数で、ごく特殊な場合にのみ有用です。\n" +"*func* ができるだけ早く呼び出されるという保証はありません。\n" +"メインスレッドがシステムコールを実行中なら、それが戻るまで *func* は呼び出さ" +"れません。\n" +"一般に、任意の C スレッドから Python コードを呼び出すための関数としては **適" +"していません**。\n" +"代わりに :c:func:`PyThreadState_EnsureFromView` を使ってください。" -#: ../../c-api/threads.rst:880 msgid "" "If this function is called in a subinterpreter, the function *func* is now " "scheduled to be called from the subinterpreter, rather than being called " "from the main interpreter. Each subinterpreter now has its own list of " "scheduled calls." msgstr "" +"サブインタープリタでこの関数を呼び出すと、*func* はメインインタープリタではな" +"く、そのサブインタープリタで呼び出されるようになりました。\n" +"サブインタープリタごとに、呼び出しを予定した関数のリストを持つようになりまし" +"た。" -#: ../../c-api/threads.rst:886 msgid "" "This function now always schedules *func* to be run in the main interpreter." -msgstr "" +msgstr "*func* は常にメインインタープリタで実行されるようになりました。" -#: ../../c-api/threads.rst:893 msgid "" "Execute all pending calls. This is usually executed automatically by the " "interpreter." msgstr "" +"保留中の呼び出しをすべて実行します。\n" +"通常、インタープリタが自動的に実行します。" -#: ../../c-api/threads.rst:896 msgid "" "This function returns ``0`` on success, and returns ``-1`` with an exception " "set on failure." -msgstr "" +msgstr "成功時は ``0`` を返し、失敗時は例外を設定して ``-1`` を返します。" -#: ../../c-api/threads.rst:899 msgid "" "If this is not called in the main thread of the main interpreter, this " "function does nothing and returns ``0``. The caller must hold an :term:" "`attached thread state`." msgstr "" +"メインインタープリタのメインスレッドで呼び出されなければ、何もせず ``0`` を返" +"します。\n" +"呼び出し元には :term:`スレッド状態がアタッチされていなければなりません " +"`。" -#: ../../c-api/threads.rst:905 msgid "This function only runs pending calls in the main interpreter." -msgstr "" +msgstr "メインインタープリタの保留中の呼び出しだけを実行するようになりました。" -#: ../../c-api/threads.rst:911 msgid "" "Schedule an exception to be raised asynchronously in a thread. If the thread " "has a previously scheduled exception, it is overwritten." msgstr "" +"スレッドで例外を非同期に送出するように予定します。\n" +"そのスレッドに送出予定の例外がすでにあれば、上書きします。" -#: ../../c-api/threads.rst:914 msgid "" "The *id* argument is the thread id of the target thread, as returned by :c:" "func:`PyThread_get_thread_ident`. *exc* is the class of the exception to be " "raised, or ``NULL`` to clear the pending exception (if any)." msgstr "" +"*id* 引数は対象スレッドの ID で、:c:func:`PyThread_get_thread_ident` が返すも" +"のです。\n" +"*exc* は送出する例外のクラスです。\n" +"``NULL`` を指定すると、保留中の例外があれば取り消します。" -#: ../../c-api/threads.rst:919 msgid "" "Return the number of affected thread states. This is normally ``1`` if *id* " "is found, even when no change was made (the given *exc* was already pending, " "or *exc* is ``NULL`` but no exception is pending). If the thread id isn't " "found, return ``0``. This raises no exceptions." msgstr "" +"対象となったスレッド状態の数を返します。\n" +"*id* が見つかれば通常は ``1`` で、実際には変更されなかった場合でも同じです " +"(指定した *exc* がすでに保留中だった場合や、*exc* が ``NULL`` で保留中の例外" +"もなかった場合)。\n" +"スレッド ID が見つからなければ ``0`` を返します。\n" +"例外は送出しません。" -#: ../../c-api/threads.rst:925 msgid "" "To prevent naive misuse, you must write your own C extension to call this. " "This function must be called with an :term:`attached thread state`. This " "function does not :term:`steal` any references to *exc*. This function does " "not necessarily interrupt system calls such as :py:func:`~time.sleep`." msgstr "" +"安易な誤用を防ぐため、呼び出すには独自の C 拡張を書く必要があります。\n" +":term:`スレッド状態がアタッチされている ` 状態で呼び出" +"さなければなりません。\n" +"この関数は *exc* への参照を :term:`盗みません `。\n" +":py:func:`~time.sleep` などのシステムコールを中断するとは限りません。" #: ../../c-api/threads.rst:931 msgid "" @@ -1219,54 +1553,56 @@ msgstr "" "*id* 引数の型が :c:expr:`long` から :c:expr:`unsigned long` へ変更されまし" "た。" -#: ../../c-api/threads.rst:937 msgid "Operating system thread APIs" -msgstr "" +msgstr "OS スレッドの API" -#: ../../c-api/threads.rst:941 msgid "Sentinel value for an invalid thread ID." -msgstr "" +msgstr "無効なスレッド ID を表す番兵値。" -#: ../../c-api/threads.rst:943 msgid "This is currently equivalent to ``(unsigned long)-1``." -msgstr "" +msgstr "現在は ``(unsigned long)-1`` と等価です。" -#: ../../c-api/threads.rst:948 msgid "" "Start function *func* in a new thread with argument *arg*. The resulting " "thread is not intended to be joined." msgstr "" +"新しいスレッドで関数 *func* を引数 *arg* とともに開始します。\n" +"作成したスレッドは join することを想定していません。" -#: ../../c-api/threads.rst:951 msgid "*func* must not be ``NULL``, but *arg* may be ``NULL``." msgstr "" +"*func* は ``NULL`` であってはなりませんが、*arg* は ``NULL`` でも構いません。" -#: ../../c-api/threads.rst:953 msgid "" "On success, this function returns the identifier of the new thread; on " "failure, this returns :c:macro:`PYTHREAD_INVALID_THREAD_ID`." msgstr "" +"成功時は新しいスレッドの識別子を返し、失敗時は :c:macro:" +"`PYTHREAD_INVALID_THREAD_ID` を返します。" -#: ../../c-api/threads.rst:956 ../../c-api/threads.rst:1041 -#: ../../c-api/threads.rst:1049 msgid "The caller does not need to hold an :term:`attached thread state`." msgstr "" +"呼び出し元に :term:`スレッド状態がアタッチされている ` 必要はありません。" -#: ../../c-api/threads.rst:961 msgid "Return the identifier of the current thread, which will never be zero." msgstr "" +"現在のスレッドの識別子を返します。\n" +"ゼロになることはありません。" -#: ../../c-api/threads.rst:963 ../../c-api/threads.rst:996 msgid "" "This function cannot fail, and the caller does not need to hold an :term:" "`attached thread state`." msgstr "" +"この関数は失敗せず、呼び出し元に :term:`スレッド状態がアタッチされている " +"` 必要もありません。" -#: ../../c-api/threads.rst:967 msgid "" ":py:func:`threading.get_ident` and :py:attr:`threading.Thread.ident` expose " "this identifier to Python." msgstr "" +":py:func:`threading.get_ident` と :py:attr:`threading.Thread.ident` を使っ" +"て、Python からこの識別子にアクセスできます。" #: ../../c-api/threads.rst:973 msgid "" @@ -1275,49 +1611,55 @@ msgid "" "accessible as :py:attr:`sys.thread_info` in Python." msgstr "" -#: ../../c-api/threads.rst:977 msgid "" "On success, this returns a new :term:`strong reference` to the thread " "information; on failure, this returns ``NULL`` with an exception set." msgstr "" +"成功時はスレッド情報への新しい :term:`強参照 ` を返しま" +"す。\n" +"失敗時は例外を設定して ``NULL`` を返します。" -#: ../../c-api/threads.rst:980 msgid "The caller must hold an :term:`attached thread state`." msgstr "" +"呼び出し元には :term:`スレッド状態がアタッチされていなければなりません " +"`。" -#: ../../c-api/threads.rst:985 msgid "This macro is defined when the system supports native thread IDs." msgstr "" +"システムがネイティブスレッド ID をサポートしている場合に定義されるマクロで" +"す。" -#: ../../c-api/threads.rst:990 msgid "" "Get the native identifier of the current thread as it was assigned by the " "operating system's kernel, which will never be less than zero." msgstr "" +"OS のカーネルが割り当てた、現在のスレッドのネイティブ識別子を取得します。\n" +"ゼロ未満になることはありません。" -#: ../../c-api/threads.rst:993 msgid "" "This function is only available when :c:macro:`PY_HAVE_THREAD_NATIVE_ID` is " "defined." msgstr "" +":c:macro:`PY_HAVE_THREAD_NATIVE_ID` が定義されている場合にのみ利用できます。" -#: ../../c-api/threads.rst:1000 msgid ":py:func:`threading.get_native_id`" -msgstr "" +msgstr ":py:func:`threading.get_native_id`" -#: ../../c-api/threads.rst:1005 msgid "" "Terminate the current thread. This function is generally considered unsafe " "and should be avoided. It is kept solely for backwards compatibility." msgstr "" +"現在のスレッドを終了させます。\n" +"一般に安全ではないとされており、使用を避けるべきです。\n" +"後方互換性のためだけに残されています。" -#: ../../c-api/threads.rst:1008 msgid "" "This function is only safe to call if all functions in the full call stack " "are written to safely allow it." msgstr "" +"呼び出しスタックにあるすべての関数が、この呼び出しを安全に許容できるように書" +"かれている場合にのみ、安全に呼び出せます。" -#: ../../c-api/threads.rst:1013 msgid "" "If the current system uses POSIX threads (also known as \"pthreads\"), this " "calls :manpage:`pthread_exit(3)`, which attempts to unwind the stack and " @@ -1325,33 +1667,44 @@ msgid "" "``noexcept`` function is reached, it may terminate the process. Other " "systems, such as macOS, do unwinding." msgstr "" +"POSIX スレッド (pthreads とも呼ばれます) を使うシステムでは、:manpage:" +"`pthread_exit(3)` を呼び出します。\n" +"一部の libc 実装では、この関数はスタックを巻き戻して C++ のデストラクターを呼" +"び出そうとします。\n" +"ただし、``noexcept`` 関数に到達すると、プロセスを終了させる可能性がありま" +"す。\n" +"macOS など、ほかのシステムでは巻き戻しが行われます。" -#: ../../c-api/threads.rst:1019 msgid "" "On Windows, this function calls ``_endthreadex()``, which kills the thread " "without calling C++ destructors." msgstr "" +"Windows では ``_endthreadex()`` を呼び出し、C++ のデストラクターを呼び出さず" +"にスレッドを終了させます。" -#: ../../c-api/threads.rst:1022 msgid "In any case, there is a risk of corruption on the thread's stack." -msgstr "" +msgstr "どの場合も、スレッドのスタックが破損する危険があります。" -#: ../../c-api/threads.rst:1029 msgid "" "Initialize ``PyThread*`` APIs. Python executes this function automatically, " "so there's little need to call it from an extension module." msgstr "" +"``PyThread*`` API を初期化します。\n" +"Python が自動的に実行するため、拡張モジュールから呼び出す必要はほとんどありま" +"せん。" #: ../../c-api/threads.rst:1035 msgid "Set the stack size of the current thread to *size* bytes." msgstr "" -#: ../../c-api/threads.rst:1037 msgid "" "This function returns ``0`` on success, ``-1`` if *size* is invalid, or " "``-2`` if the system does not support changing the stack size. This function " "does not set exceptions." msgstr "" +"成功時は ``0``、*size* が無効な場合は ``-1``、システムがスタックサイズの変更" +"に対応していない場合は ``-2`` を返します。\n" +"例外は設定しません。" #: ../../c-api/threads.rst:1046 msgid "" @@ -1371,29 +1724,23 @@ msgstr "interpreter lock" msgid "lock, interpreter" msgstr "lock, interpreter" -#: ../../c-api/threads.rst:25 msgid "setswitchinterval (in module sys)" -msgstr "" +msgstr "setswitchinterval (sys モジュール)" -#: ../../c-api/threads.rst:36 msgid "PyThreadState (C type)" -msgstr "" +msgstr "PyThreadState (C の型)" -#: ../../c-api/threads.rst:87 msgid "Py_BEGIN_ALLOW_THREADS (C macro)" -msgstr "" +msgstr "Py_BEGIN_ALLOW_THREADS (C のマクロ)" -#: ../../c-api/threads.rst:87 msgid "Py_END_ALLOW_THREADS (C macro)" -msgstr "" +msgstr "Py_END_ALLOW_THREADS (C のマクロ)" -#: ../../c-api/threads.rst:103 msgid "PyEval_RestoreThread (C function)" -msgstr "" +msgstr "PyEval_RestoreThread (C の関数)" -#: ../../c-api/threads.rst:103 msgid "PyEval_SaveThread (C function)" -msgstr "" +msgstr "PyEval_SaveThread (C の関数)" #: ../../c-api/threads.rst:582 msgid "PyEval_AcquireThread()" diff --git a/c-api/time.po b/c-api/time.po index e29d6d9d5..817bd2358 100644 --- a/c-api/time.po +++ b/c-api/time.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/time.rst:6 @@ -46,97 +46,108 @@ msgstr "" msgid "Types" msgstr "型" -#: ../../c-api/time.rst:21 msgid "" "A timestamp or duration in nanoseconds, represented as a signed 64-bit " "integer." msgstr "" +"符号付き 64 ビット整数で表す、ナノ秒単位のタイムスタンプまたは時間間隔です。" -#: ../../c-api/time.rst:24 msgid "" "The reference point for timestamps depends on the clock used. For example, :" "c:func:`PyTime_Time` returns timestamps relative to the UNIX epoch." msgstr "" +"タイムスタンプの基準時点は、使用するクロックによって異なります。\n" +"例えば :c:func:`PyTime_Time` は UNIX エポックを基準としたタイムスタンプを返し" +"ます。" -#: ../../c-api/time.rst:27 msgid "" "The supported range is around [-292.3 years; +292.3 years]. Using the Unix " "epoch (January 1st, 1970) as reference, the supported date range is around " "[1677-09-21; 2262-04-11]. The exact limits are exposed as constants:" msgstr "" +"サポートする範囲はおよそ [-292.3 年; +292.3 年] です。\n" +"Unix エポック (1970 年 1 月 1 日) を基準とした日付の範囲は、およそ " +"[1677-09-21; 2262-04-11] です。\n" +"正確な限界値は定数として公開されています。" -#: ../../c-api/time.rst:34 msgid "Minimum value of :c:type:`PyTime_t`." -msgstr "" +msgstr ":c:type:`PyTime_t` の最小値。" -#: ../../c-api/time.rst:38 msgid "Maximum value of :c:type:`PyTime_t`." -msgstr "" +msgstr ":c:type:`PyTime_t` の最大値。" -#: ../../c-api/time.rst:42 msgid "Clock Functions" -msgstr "" +msgstr "クロック関数" -#: ../../c-api/time.rst:44 msgid "" "The following functions take a pointer to a :c:expr:`PyTime_t` that they set " "to the value of a particular clock. Details of each clock are given in the " "documentation of the corresponding Python function." msgstr "" +"以下の関数は :c:expr:`PyTime_t` へのポインタを受け取り、特定のクロックの値を" +"その参照先に設定します。\n" +"各クロックの詳細は、対応する Python 関数のドキュメントを参照してください。" -#: ../../c-api/time.rst:49 msgid "" "The functions return ``0`` on success, or ``-1`` (with an exception set) on " "failure." msgstr "" +"成功した場合は ``0`` を返し、失敗した場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/time.rst:52 msgid "" "On integer overflow, they set the :c:data:`PyExc_OverflowError` exception " "and set ``*result`` to the value clamped to the ``[PyTime_MIN; PyTime_MAX]`` " "range. (On current systems, integer overflows are likely caused by " "misconfigured system time.)" msgstr "" +"整数オーバーフローが発生した場合は :c:data:`PyExc_OverflowError` 例外を設定" +"し、``*result`` に ``[PyTime_MIN; PyTime_MAX]`` の範囲内に制限した値を設定し" +"ます。\n" +"(現在のシステムでは、整数オーバーフローはシステム時刻の誤設定によって発生する" +"可能性が高いです。)" -#: ../../c-api/time.rst:58 msgid "" "As any other C API (unless otherwise specified), the functions must be " "called with an :term:`attached thread state`." msgstr "" +"ほかの C API と同様に (特記のない限り)、これらの関数を呼び出すには :term:`ス" +"レッド状態がアタッチされている ` 必要があります。" -#: ../../c-api/time.rst:63 msgid "" "Read the monotonic clock. See :func:`time.monotonic` for important details " "on this clock." msgstr "" +"単調クロックを読み取ります。\n" +"このクロックに関する重要な詳細は :func:`time.monotonic` を参照してください。" -#: ../../c-api/time.rst:68 msgid "" "Read the performance counter. See :func:`time.perf_counter` for important " "details on this clock." msgstr "" +"パフォーマンスカウンタを読み取ります。\n" +"このクロックに関する重要な詳細は :func:`time.perf_counter` を参照してくださ" +"い。" -#: ../../c-api/time.rst:73 msgid "" "Read the “wall clock” time. See :func:`time.time` for details important on " "this clock." msgstr "" +"実時間 (wall clock time) を読み取ります。\n" +"このクロックに関する重要な詳細は :func:`time.time` を参照してください。" -#: ../../c-api/time.rst:78 msgid "Raw Clock Functions" -msgstr "" +msgstr "Raw クロック関数" -#: ../../c-api/time.rst:80 msgid "" "Similar to clock functions, but don't set an exception on error and don't " "require the caller to have an :term:`attached thread state`." msgstr "" +"クロック関数と同様ですが、エラー時に例外を設定せず、呼び出し元に :term:`ア" +"タッチされたスレッド状態 ` がなくても使えます。" -#: ../../c-api/time.rst:83 msgid "On success, the functions return ``0``." -msgstr "" +msgstr "成功した場合は ``0`` を返します。" -#: ../../c-api/time.rst:85 msgid "" "On failure, they set ``*result`` to ``0`` and return ``-1``, *without* " "setting an exception. To get the cause of the error, :term:`attach ` を :term:`ア" +"タッチ ` して、通常の (``Raw`` でない) 関数を呼び出し" +"てください。\n" +"``Raw`` 関数が失敗した後で、通常の関数が成功することもあります。" -#: ../../c-api/time.rst:92 msgid "" "Similar to :c:func:`PyTime_Monotonic`, but don't set an exception on error " "and don't require an :term:`attached thread state`." msgstr "" +":c:func:`PyTime_Monotonic` と同様ですが、エラー時に例外を設定せず、:term:`ア" +"タッチされたスレッド状態 ` も必要としません。" -#: ../../c-api/time.rst:97 msgid "" "Similar to :c:func:`PyTime_PerfCounter`, but don't set an exception on error " "and don't require an :term:`attached thread state`." msgstr "" +":c:func:`PyTime_PerfCounter` と同様ですが、エラー時に例外を設定せず、:term:`" +"アタッチされたスレッド状態 ` も必要としません。" -#: ../../c-api/time.rst:102 msgid "" "Similar to :c:func:`PyTime_Time`, but don't set an exception on error and " "don't require an :term:`attached thread state`." msgstr "" +":c:func:`PyTime_Time` と同様ですが、エラー時に例外を設定せず、:term:`アタッチ" +"されたスレッド状態 ` も必要としません。" -#: ../../c-api/time.rst:107 msgid "Conversion functions" -msgstr "" +msgstr "変換関数" -#: ../../c-api/time.rst:111 msgid "Convert a timestamp to a number of seconds as a C :c:expr:`double`." -msgstr "" +msgstr "タイムスタンプを、C の :c:expr:`double` 型の秒数に変換します。" -#: ../../c-api/time.rst:113 msgid "" "The function cannot fail, but note that :c:expr:`double` has limited " "accuracy for large values." msgstr "" +"この関数は失敗しませんが、大きな値に対する :c:expr:`double` の精度には限りが" +"あることに注意してください。" diff --git a/c-api/tls.po b/c-api/tls.po index a15ecb232..a9b586fc8 100644 --- a/c-api/tls.po +++ b/c-api/tls.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/tls.rst:6 msgid "Thread-local storage support" -msgstr "" +msgstr "スレッドローカルストレージのサポート" -#: ../../c-api/tls.rst:8 msgid "" "The Python interpreter provides low-level support for thread-local storage " "(TLS) which wraps the underlying native TLS implementation to support the " @@ -35,12 +33,20 @@ msgid "" "use a thread key and functions to associate a :c:expr:`void*` value per " "thread." msgstr "" +"Python インタープリタは、基盤となるネイティブの TLS 実装をラップした低水準の" +"スレッドローカルストレージ (TLS) を提供し、\n" +"Python レベルのスレッドローカルストレージ API (:class:`threading.local`) を支" +"えます。\n" +"CPython の C レベルの API は pthreads や Windows が提供するものと似ており、ス" +"レッドキーと関数を使って、スレッドごとに :c:expr:`void*` 値を関連付けます。" -#: ../../c-api/tls.rst:15 msgid "" "A :term:`thread state` does *not* need to be :term:`attached ` when calling these functions; they supply their own locking." msgstr "" +"これらの関数は独自にロックを行うため、呼び出す際に :term:`スレッド状態 " +"` が :term:`アタッチされている ` 必要は " +"*ありません*。" #: ../../c-api/tls.rst:18 msgid "" @@ -64,16 +70,18 @@ msgstr "" ":c:expr:`void*` 値がたまたま :c:expr:`PyObject*` だった場合は、 API 関数はそ" "れぞれの値の参照カウントの操作は行いません。" -#: ../../c-api/tls.rst:30 msgid "Thread-specific storage API" -msgstr "" +msgstr "スレッド固有ストレージ API" -#: ../../c-api/tls.rst:32 msgid "" "The thread-specific storage (TSS) API was introduced to supersede the use of " "the existing TLS API within the CPython interpreter. This API uses a new " "type :c:type:`Py_tss_t` instead of :c:expr:`int` to represent thread keys." msgstr "" +"スレッド固有ストレージ (TSS) API は、CPython インタープリタ内で使われていた " +"TLS API を置き換えるために導入されました。\n" +"スレッドキーの表現には :c:expr:`int` ではなく、新しい型 :c:type:`Py_tss_t` を" +"使います。" #: ../../c-api/tls.rst:38 msgid "\"A New C-API for Thread-Local Storage in CPython\" (:pep:`539`)" @@ -107,9 +115,8 @@ msgstr "" "このマクロは :c:type:`Py_tss_t` 変数の初期化子に展開されます。\n" "このマクロは :ref:`Py_LIMITED_API ` があるときは定義されません。" -#: ../../c-api/tls.rst:59 msgid "Dynamic allocation" -msgstr "" +msgstr "動的なメモリ確保" #: ../../c-api/tls.rst:61 msgid "" @@ -121,43 +128,51 @@ msgstr "" "ルドされた拡張モジュールで必要になりますが、その実装がビルド時に不透明なため" "に、この型の静的なメモリ確保は不可能です。" -#: ../../c-api/tls.rst:68 msgid "" "Return a value which is the same state as a value initialized with :c:macro:" "`Py_tss_NEEDS_INIT`, or ``NULL`` in the case of dynamic allocation failure." msgstr "" +":c:macro:`Py_tss_NEEDS_INIT` で初期化した値と同じ状態の値を返します。\n" +"動的なメモリ確保に失敗した場合は ``NULL`` を返します。" -#: ../../c-api/tls.rst:75 msgid "" "Free the given *key* allocated by :c:func:`PyThread_tss_alloc`, after first " "calling :c:func:`PyThread_tss_delete` to ensure any associated thread locals " "have been unassigned. This is a no-op if the *key* argument is ``NULL``." msgstr "" +"まず :c:func:`PyThread_tss_delete` を呼んで、関連付けられたスレッドローカルな" +"値との対応を解除してから、\n" +":c:func:`PyThread_tss_alloc` で確保した *key* を解放します。\n" +"*key* 引数が ``NULL`` の場合は何もしません。" -#: ../../c-api/tls.rst:81 msgid "" "A freed key becomes a dangling pointer. You should reset the key to ``NULL``." msgstr "" +"解放したキーはダングリングポインタになります。\n" +"キーを ``NULL`` に設定し直してください。" #: ../../c-api/tls.rst:86 msgid "Methods" msgstr "メソッド" -#: ../../c-api/tls.rst:88 msgid "" "The parameter *key* of these functions must not be ``NULL``. Moreover, the " "behaviors of :c:func:`PyThread_tss_set` and :c:func:`PyThread_tss_get` are " "undefined if the given :c:type:`Py_tss_t` has not been initialized by :c:" "func:`PyThread_tss_create`." msgstr "" +"これらの関数の引数 *key* は ``NULL`` であってはなりません。\n" +"また、指定された :c:type:`Py_tss_t` を :c:func:`PyThread_tss_create` で初期化" +"していなければ、\n" +":c:func:`PyThread_tss_set` と :c:func:`PyThread_tss_get` の動作は未定義です。" -#: ../../c-api/tls.rst:96 msgid "" "Return a non-zero value if the given :c:type:`Py_tss_t` has been initialized " "by :c:func:`PyThread_tss_create`." msgstr "" +"指定された :c:type:`Py_tss_t` が :c:func:`PyThread_tss_create` で初期化されて" +"いれば、0 以外の値を返します。" -#: ../../c-api/tls.rst:102 msgid "" "Return a zero value on successful initialization of a TSS key. The behavior " "is undefined if the value pointed to by the *key* argument is not " @@ -165,8 +180,12 @@ msgid "" "repeatedly on the same key -- calling it on an already initialized key is a " "no-op and immediately returns success." msgstr "" +"TSS キーの初期化に成功すると 0 を返します。\n" +"*key* 引数が指す値を :c:macro:`Py_tss_NEEDS_INIT` で初期化していなければ、動" +"作は未定義です。\n" +"同じキーに対して繰り返し呼び出せます。\n" +"初期化済みのキーに対しては何もせず、即座に成功を返します。" -#: ../../c-api/tls.rst:111 msgid "" "Destroy a TSS key to forget the values associated with the key across all " "threads, and change the key's initialization state to uninitialized. A " @@ -174,32 +193,40 @@ msgid "" "`PyThread_tss_create`. This function can be called repeatedly on the same " "key -- calling it on an already destroyed key is a no-op." msgstr "" +"TSS キーを破棄し、すべてのスレッドでそのキーに関連付けられた値との対応を解除" +"して、キーを未初期化の状態にします。\n" +"破棄したキーは :c:func:`PyThread_tss_create` で再び初期化できます。\n" +"同じキーに対して繰り返し呼び出せます。\n" +"破棄済みのキーに対しては何もしません。" -#: ../../c-api/tls.rst:120 msgid "" "Return a zero value to indicate successfully associating a :c:expr:`void*` " "value with a TSS key in the current thread. Each thread has a distinct " "mapping of the key to a :c:expr:`void*` value." msgstr "" +"現在のスレッドで :c:expr:`void*` 値を TSS キーに関連付けることに成功すると、" +"0 を返します。\n" +"キーから :c:expr:`void*` 値への対応付けは、スレッドごとに独立しています。" -#: ../../c-api/tls.rst:127 msgid "" "Return the :c:expr:`void*` value associated with a TSS key in the current " "thread. This returns ``NULL`` if no value is associated with the key in the " "current thread." msgstr "" +"現在のスレッドで TSS キーに関連付けられている :c:expr:`void*` 値を返しま" +"す。\n" +"現在のスレッドでそのキーに値が関連付けられていなければ、``NULL`` を返します。" -#: ../../c-api/tls.rst:135 msgid "Legacy APIs" -msgstr "" +msgstr "従来の API" -#: ../../c-api/tls.rst:137 msgid "" "This API is superseded by the :ref:`thread-specific storage (TSS) API " "`." msgstr "" +"この API は :ref:`スレッド固有ストレージ (TSS) API ` に置き換えられました。" -#: ../../c-api/tls.rst:142 msgid "" "This version of the API does not support platforms where the native TLS key " "is defined in a way that cannot be safely cast to ``int``. On such " @@ -207,6 +234,10 @@ msgid "" "failure status, and the other TLS functions will all be no-ops on such " "platforms." msgstr "" +"このバージョンの API は、ネイティブの TLS キーを安全に ``int`` へキャストでき" +"ないプラットフォームをサポートしません。\n" +"そのようなプラットフォームでは、:c:func:`PyThread_create_key` は即座に失敗を" +"示す値を返し、その他の TLS 関数はすべて何もしません。" #: ../../c-api/tls.rst:147 msgid "" diff --git a/c-api/tuple.po b/c-api/tuple.po index d10640264..790ea9482 100644 --- a/c-api/tuple.po +++ b/c-api/tuple.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/tuple.rst:6 @@ -56,45 +56,51 @@ msgstr "" "*p* がタプルオブジェクトだがタプル型のサブタイプのインスタンスでない場合に真" "を返します。この関数は常に成功します。" -#: ../../c-api/tuple.rst:36 msgid "" "Return a new tuple object of size *len*, or ``NULL`` with an exception set " "on failure." msgstr "" +"サイズ ``len`` の新しいタプルオブジェクトを返します。\n" +"失敗した場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/tuple.rst:42 msgid "" "Create a tuple of *size* items and copy references from *array* to the new " "tuple." msgstr "" +"要素数 ``size`` のタプルを作成し、``array`` から新しいタプルに参照をコピーし" +"ます。" -#: ../../c-api/tuple.rst:45 msgid "*array* can be NULL if *size* is ``0``." -msgstr "" +msgstr "``size`` が ``0`` の場合、``array`` は ``NULL`` でも構いません。" -#: ../../c-api/tuple.rst:47 msgid "" "On success, return a new reference. On error, set an exception and return " "``NULL``." msgstr "" +"成功した場合は新しい参照を返します。\n" +"エラーの場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/tuple.rst:55 msgid "" "Return a new tuple object of size *n*, or ``NULL`` with an exception set on " "failure. The tuple values are initialized to the subsequent *n* C arguments " "pointing to Python objects. ``PyTuple_Pack(2, a, b)`` is equivalent to " "``Py_BuildValue(\"(OO)\", a, b)``." msgstr "" +"サイズ ``n`` の新しいタプルオブジェクトを返します。\n" +"失敗した場合は例外を設定して ``NULL`` を返します。\n" +"タプルの各値は、続く ``n`` 個の C 引数が指す Python オブジェクトで初期化され" +"ます。\n" +"``PyTuple_Pack(2, a, b)`` は ``Py_BuildValue(\"(OO)\", a, b)`` と同等です。" -#: ../../c-api/tuple.rst:63 msgid "" "Take a pointer to a tuple object, and return the size of that tuple. On " "error, return ``-1`` with an exception set." msgstr "" +"タプルオブジェクトへのポインタを受け取り、そのタプルのサイズを返します。\n" +"エラーの場合は例外を設定して ``-1`` を返します。" -#: ../../c-api/tuple.rst:69 msgid "Like :c:func:`PyTuple_Size`, but without error checking." -msgstr "" +msgstr ":c:func:`PyTuple_Size` と同様ですが、エラーチェックを行いません。" #: ../../c-api/tuple.rst:74 msgid "" @@ -106,13 +112,17 @@ msgstr "" "*pos* が負であるか範囲を超えている場合、 ``NULL`` を返して :exc:`IndexError` " "例外をセットします。" -#: ../../c-api/tuple.rst:77 msgid "" "The returned reference is borrowed from the tuple *p* (that is: it is only " "valid as long as you hold a reference to *p*). To get a :term:`strong " "reference`, use :c:func:`Py_NewRef(PyTuple_GetItem(...)) ` or :c:" "func:`PySequence_GetItem`." msgstr "" +"返される参照はタプル ``p`` からの借用参照です (つまり、``p`` への参照を保持し" +"ている間だけ有効です)。\n" +":term:`強参照 ` を取得するには、:c:func:" +"`Py_NewRef(PyTuple_GetItem(...)) ` または :c:func:" +"`PySequence_GetItem` を使ってください。" #: ../../c-api/tuple.rst:86 msgid "Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments." @@ -120,62 +130,78 @@ msgstr "" ":c:func:`PyTuple_GetItem` に似ていますが、引数に対するエラーチェックを行いま" "せん。" -#: ../../c-api/tuple.rst:91 msgid "" "Return the slice of the tuple pointed to by *p* between *low* and *high*, or " "``NULL`` with an exception set on failure." msgstr "" +"``p`` が指すタプルの ``low`` から ``high`` までのスライスを返します。\n" +"失敗した場合は例外を設定して ``NULL`` を返します。" -#: ../../c-api/tuple.rst:94 msgid "" "This is the equivalent of the Python expression ``p[low:high]``. Indexing " "from the end of the tuple is not supported." msgstr "" +"Python の式 ``p[low:high]`` と同等です。\n" +"タプルの末尾からのインデックス指定はサポートしていません。" -#: ../../c-api/tuple.rst:100 msgid "" "Insert a reference to object *o* at position *pos* of the tuple pointed to " "by *p*. Return ``0`` on success. If *pos* is out of bounds, return ``-1`` " "and set an :exc:`IndexError` exception. This function should only be used to " "fill in brand new tuples; using it on an existing tuple is thread-unsafe." msgstr "" +"``p`` が指すタプルの位置 ``pos`` に、オブジェクト ``o`` への参照を挿入しま" +"す。\n" +"成功した場合は ``0`` を返します。\n" +"``pos`` が範囲外の場合は、:exc:`IndexError` 例外を設定して ``-1`` を返しま" +"す。\n" +"この関数は、作成したばかりのタプルに値を設定するためだけに使ってください。\n" +"既存のタプルに使うとスレッドセーフではありません。" -#: ../../c-api/tuple.rst:107 msgid "" "This function \":term:`steals `\" a reference to *o* and discards a " "reference to an item already in the tuple at the affected position (unless " "it was NULL)." msgstr "" +"この関数は ``o`` への参照を「:term:`盗み `」、タプルのその位置にすでに" +"あった要素への参照を破棄します (``NULL`` だった場合を除きます)。" -#: ../../c-api/tuple.rst:114 msgid "" "Like :c:func:`PyTuple_SetItem`, but does no error checking, and should " "*only* be used to fill in brand new tuples, using it on an existing tuple is " "thread-unsafe." msgstr "" +":c:func:`PyTuple_SetItem` と同様ですが、エラーチェックを行いません。\n" +"作成したばかりのタプルに値を設定するため *だけ* に使ってください。\n" +"既存のタプルに使うとスレッドセーフではありません。" -#: ../../c-api/tuple.rst:117 ../../c-api/tuple.rst:244 -#: ../../c-api/tuple.rst:262 msgid "" "Bounds checking is performed as an assertion if Python is built in :ref:" "`debug mode ` or :option:`with assertions <--with-assertions>`." msgstr "" +"Python を :ref:`デバッグモード ` または :option:`アサーションを" +"有効にして <--with-assertions>` ビルドした場合、アサーションによる境界チェッ" +"クが行われます。" -#: ../../c-api/tuple.rst:122 msgid "" "This function \":term:`steals `\" a reference to *o*, and, unlike :c:" "func:`PyTuple_SetItem`, does *not* discard a reference to any item that is " "being replaced; any reference in the tuple at position *pos* will be leaked." msgstr "" +"この関数は ``o`` への参照を「:term:`盗みます `」。\n" +":c:func:`PyTuple_SetItem` と異なり、置き換えられる要素への参照は破棄 *しませ" +"ん*。\n" +"タプルの位置 ``pos`` にすでに参照があれば、その参照はリークします。" -#: ../../c-api/tuple.rst:129 msgid "" "This macro should *only* be used on tuples that are newly created. Using " "this macro on a tuple that is already in use (or in other words, has a " "refcount > 1) could lead to undefined behavior." msgstr "" +"このマクロは、新しく作成したタプルに *だけ* 使ってください。\n" +"すでに使われているタプル (つまり参照カウントが 1 より大きいタプル) に使うと、" +"未定義の動作を引き起こす可能性があります。" -#: ../../c-api/tuple.rst:136 msgid "" "Can be used to resize a tuple. *newsize* will be the new length of the " "tuple. Because tuples are *supposed* to be immutable, this should only be " @@ -189,32 +215,42 @@ msgid "" "and sets ``*p`` to ``NULL``, and raises :exc:`MemoryError` or :exc:" "`SystemError`." msgstr "" -"タプルをリサイズする際に使えます。 *newsize* はタプルの新たな長さです。タプル" -"は変更不能なオブジェクト *ということになっている* ので、この関数はこのオブ" -"ジェクトに対してただ一つしか参照がない時以外には使ってはなりません。タプルが" -"コード中の他の部分ですでに参照されている場合には、この関数を *使ってはなりま" -"せん* 。タプルは常に指定サイズの末尾まで伸縮します。成功した場合には ``0`` を" -"返します。クライアントコードは、 ``*p`` の値が呼び出し前と同じになると期待し" -"てはなりません。 ``*p`` が置き換えられた場合、オリジナルの ``*p`` は破壊され" -"ます。失敗すると ``-1`` を返し、 ``*p`` を ``NULL`` に設定して、 :exc:" +"タプルのサイズ変更に使えます。\n" +"``newsize`` はタプルの新しい長さです。\n" +"タプルは *本来* 不変なので、この関数はオブジェクトへの参照が一つだけの場合に" +"限って使ってください。\n" +"ほかのコードがそのタプルをすでに知っている可能性がある場合は、使っては *いけ" +"ません*。\n" +"タプルは常に末尾で伸縮します。\n" +"古いタプルを破棄して新しいタプルを作成する操作を、より効率的に行うものと考え" +"てください。\n" +"成功した場合は ``0`` を返します。\n" +"呼び出し後の ``*p`` が呼び出し前と同じ値であると仮定してはいけません。\n" +"``*p`` が参照するオブジェクトが置き換えられる場合、元の ``*p`` は破棄されま" +"す。\n" +"失敗した場合は ``-1`` を返し、``*p`` を ``NULL`` に設定して :exc:" "`MemoryError` または :exc:`SystemError` を送出します。" #: ../../c-api/tuple.rst:151 msgid "Struct Sequence Objects" msgstr "Struct Sequence オブジェクト" -#: ../../c-api/tuple.rst:153 msgid "" "A struct sequence object is a :term:`named tuple`, that is, a sequence whose " "items can also be accessed through attributes. It is similar to :func:" "`collections.namedtuple`, but provides a slightly different interface." msgstr "" +"struct sequence オブジェクトは :term:`名前付きタプル `、つまり属" +"性を通じても要素にアクセスできるシーケンスです。\n" +":func:`collections.namedtuple` に似ていますが、インターフェースは多少異なりま" +"す。" -#: ../../c-api/tuple.rst:158 msgid "" "To create a struct sequence, you first have to create a specific struct " "sequence type." msgstr "" +"struct sequence を作成するには、まず専用の struct sequence 型を作成する必要が" +"あります。" #: ../../c-api/tuple.rst:163 msgid "" @@ -225,44 +261,44 @@ msgstr "" "後述の *desc* 中のデータから新しい struct sequence 型を生成します。返される型" "のインスタンスは :c:func:`PyStructSequence_New` で生成できます。" -#: ../../c-api/tuple.rst:166 ../../c-api/tuple.rst:235 msgid "Return ``NULL`` with an exception set on failure." -msgstr "" +msgstr "失敗した場合は例外を設定して ``NULL`` を返します。" #: ../../c-api/tuple.rst:171 msgid "Initializes a struct sequence type *type* from *desc* in place." msgstr "" "struct sequence 型である *type* を *desc* をもとにその場で初期化します。" -#: ../../c-api/tuple.rst:176 msgid "" "Like :c:func:`PyStructSequence_InitType`, but returns ``0`` on success and " "``-1`` with an exception set on failure." msgstr "" +":c:func:`PyStructSequence_InitType` と同様ですが、成功した場合は ``0`` を返" +"し、失敗した場合は例外を設定して ``-1`` を返します。" #: ../../c-api/tuple.rst:184 msgid "Contains the meta information of a struct sequence type to create." msgstr "生成するstruct sequence 型のメタデータを保持します。" -#: ../../c-api/tuple.rst:188 msgid "" "Fully qualified name of the type; null-terminated UTF-8 encoded. The name " "must contain the module name." msgstr "" +"型の完全修飾名。\n" +"ヌル終端された UTF-8 エンコードの文字列です。\n" +"モジュール名を含む必要があります。" -#: ../../c-api/tuple.rst:193 msgid "Pointer to docstring for the type or ``NULL`` to omit." msgstr "" +"型の docstring へのポインタ。\n" +"省略する場合は ``NULL``。" -#: ../../c-api/tuple.rst:197 msgid "Pointer to ``NULL``-terminated array with field names of the new type." -msgstr "" +msgstr "新しい型のフィールド名を持つ、``NULL`` 終端の配列へのポインタ。" -#: ../../c-api/tuple.rst:201 msgid "Number of fields visible to the Python side (if used as tuple)." -msgstr "" +msgstr "タプルとして使う場合に Python 側から見えるフィールドの数。" -#: ../../c-api/tuple.rst:206 msgid "" "Describes a field of a struct sequence. As a struct sequence is modeled as a " "tuple, all fields are typed as :c:expr:`PyObject*`. The index in the :c:" @@ -270,16 +306,25 @@ msgid "" "`PyStructSequence_Desc` determines which field of the struct sequence is " "described." msgstr "" +"struct sequence のフィールドを記述します。\n" +"struct sequence はタプルをモデルとしているので、すべてのフィールドは :c:expr:" +"`PyObject*` 型です。\n" +":c:type:`PyStructSequence_Desc` の :c:member:`~PyStructSequence_Desc.fields` " +"配列内のインデックスによって、struct sequence のどのフィールドを記述するかが" +"決まります。" -#: ../../c-api/tuple.rst:214 msgid "" "Name for the field or ``NULL`` to end the list of named fields, set to :c:" "data:`PyStructSequence_UnnamedField` to leave unnamed." msgstr "" +"フィールド名。\n" +"名前付きフィールドの一覧を終了するには ``NULL``、名前を付けないフィールドに" +"は :c:data:`PyStructSequence_UnnamedField` を指定します。" -#: ../../c-api/tuple.rst:219 msgid "Field docstring or ``NULL`` to omit." msgstr "" +"フィールドの docstring。\n" +"省略する場合は ``NULL``。" #: ../../c-api/tuple.rst:224 msgid "Special value for a field name to leave it unnamed." @@ -297,20 +342,21 @@ msgstr "" "*type* のインスタンスを生成します。 *type* は :c:func:" "`PyStructSequence_NewType` によって事前に生成していなければなりません。" -#: ../../c-api/tuple.rst:240 msgid "" "Return the object at position *pos* in the struct sequence pointed to by " "*p*. The returned reference is borrowed from the struct sequence *p* (that " "is: it is only valid as long as you hold a reference to *p*)." msgstr "" +"``p`` が指す struct sequence の位置 ``pos`` にあるオブジェクトを返します。\n" +"返される参照は struct sequence ``p`` からの借用参照です (つまり、``p`` への参" +"照を保持している間だけ有効です)。" -#: ../../c-api/tuple.rst:250 msgid "Alias to :c:func:`PyStructSequence_GetItem`." -msgstr "" +msgstr ":c:func:`PyStructSequence_GetItem` の別名です。" -#: ../../c-api/tuple.rst:252 msgid "Now implemented as an alias to :c:func:`PyStructSequence_GetItem`." msgstr "" +":c:func:`PyStructSequence_GetItem` の別名として実装されるようになりました。" #: ../../c-api/tuple.rst:258 msgid "" @@ -322,17 +368,15 @@ msgstr "" "func:`PyTuple_SET_ITEM` のように、生成したてのインスタンスに対してのみ使用す" "べきです。" -#: ../../c-api/tuple.rst:267 msgid "This function \":term:`steals `\" a reference to *o*." -msgstr "" +msgstr "この関数は ``o`` への参照を「:term:`盗みます `」。" -#: ../../c-api/tuple.rst:272 msgid "Alias to :c:func:`PyStructSequence_SetItem`." -msgstr "" +msgstr ":c:func:`PyStructSequence_SetItem` の別名です。" -#: ../../c-api/tuple.rst:274 msgid "Now implemented as an alias to :c:func:`PyStructSequence_SetItem`." msgstr "" +":c:func:`PyStructSequence_SetItem` の別名として実装されるようになりました。" #: ../../c-api/tuple.rst:8 msgid "object" diff --git a/c-api/type.po b/c-api/type.po index 3363f9655..a2010a648 100644 --- a/c-api/type.po +++ b/c-api/type.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/type.rst:6 @@ -38,25 +38,30 @@ msgstr "" "型オブジェクト自身の型オブジェクトです。Python レイヤにおける :class:`type` " "と同じオブジェクトです。" -#: ../../c-api/type.rst:24 msgid "" "Return non-zero if the object *o* is a type object, including instances of " "types derived from the standard type object. Return 0 in all other cases. " "This function always succeeds." msgstr "" +"オブジェクト *o* が型オブジェクトであれば、標準の型オブジェクトから派生した型" +"のインスタンスも含めてゼロ以外を返します。\n" +"それ以外の場合は 0 を返します。\n" +"この関数は常に成功します。" -#: ../../c-api/type.rst:31 msgid "" "Return non-zero if the object *o* is a type object, but not a subtype of the " "standard type object. Return 0 in all other cases. This function always " "succeeds." msgstr "" +"オブジェクト *o* が標準の型オブジェクトのインスタンスであり、そのサブタイプの" +"インスタンスではない場合にゼロ以外を返します。\n" +"それ以外の場合は 0 を返します。\n" +"この関数は常に成功します。" #: ../../c-api/type.rst:38 msgid "Clear the internal lookup cache. Return the current version tag." msgstr "内部の検索キャッシュをクリアします。現在のバージョンタグを返します。" -#: ../../c-api/type.rst:42 msgid "" "Return the :c:member:`~PyTypeObject.tp_flags` member of *type*. This " "function is primarily meant for use with ``Py_LIMITED_API``; the individual " @@ -64,31 +69,43 @@ msgid "" "c:member:`~PyTypeObject.tp_flags` itself is not part of the :ref:`limited " "API `." msgstr "" +"*type* の :c:member:`~PyTypeObject.tp_flags` メンバーを返します。\n" +"この関数は主に ``Py_LIMITED_API`` で使うことを想定しています。\n" +"個々のフラグビットは Python のリリース間で安定していることが保証されますが、:" +"c:member:`~PyTypeObject.tp_flags` 自体へのアクセスは :ref:`Limited API " +"` の一部ではありません。" #: ../../c-api/type.rst:49 msgid "The return type is now ``unsigned long`` rather than ``long``." msgstr "返り値の型が ``long`` ではなく ``unsigned long`` になりました。" -#: ../../c-api/type.rst:55 msgid "" "Return the type object's internal namespace, which is otherwise only exposed " "via a read-only proxy (:attr:`cls.__dict__ `). This is a " "replacement for accessing :c:member:`~PyTypeObject.tp_dict` directly. The " "returned dictionary must be treated as read-only." msgstr "" +"型オブジェクトの内部の名前空間を返します。\n" +"通常は読み取り専用のプロキシ (:attr:`cls.__dict__ `) を通じて" +"のみ公開されるものです。\n" +":c:member:`~PyTypeObject.tp_dict` に直接アクセスする代わりに使えます。\n" +"返された辞書は読み取り専用として扱わなければなりません。" -#: ../../c-api/type.rst:61 msgid "" "This function is meant for specific embedding and language-binding cases, " "where direct access to the dict is necessary and indirect access (e.g. via " "the proxy or :c:func:`PyObject_GetAttr`) isn't adequate." msgstr "" +"この関数は、辞書への直接アクセスが必要で、プロキシや :c:func:" +"`PyObject_GetAttr` などによる間接アクセスでは不十分な、特定の埋め込みや言語バ" +"インディングの用途を想定しています。" -#: ../../c-api/type.rst:65 msgid "" "Extension modules should continue to use ``tp_dict``, directly or " "indirectly, when setting up their own types." msgstr "" +"拡張モジュールで独自の型を設定するときは、引き続き直接または間接的に " +"``tp_dict`` を使ってください。" #: ../../c-api/type.rst:73 msgid "" @@ -100,35 +117,45 @@ msgstr "" "この関数は type の属性や基底クラス列を変更したあとに手動で呼び出さなければな" "りません。" -#: ../../c-api/type.rst:80 msgid "" "Register *callback* as a type watcher. Return a non-negative integer ID " "which must be passed to future calls to :c:func:`PyType_Watch`. In case of " "error (e.g. no more watcher IDs available), return ``-1`` and set an " "exception." msgstr "" +"*callback* を型ウォッチャーとして登録します。\n" +"ゼロ以上の整数 ID を返します。\n" +"以後 :c:func:`PyType_Watch` を呼び出すときには、この ID を渡す必要がありま" +"す。\n" +"エラー時 (例えば利用可能なウォッチャー ID が残っていない場合) は、例外を設定" +"して ``-1`` を返します。" -#: ../../c-api/type.rst:85 msgid "" "In free-threaded builds, :c:func:`PyType_AddWatcher` is not thread-safe, so " "it must be called at start up (before spawning the first thread)." msgstr "" +"フリースレッドビルドでは :c:func:`PyType_AddWatcher` はスレッドセーフではない" +"ため、起動時 (最初のスレッドを作成する前) に呼び出さなければなりません。" -#: ../../c-api/type.rst:93 msgid "" "Clear watcher identified by *watcher_id* (previously returned from :c:func:" "`PyType_AddWatcher`). Return ``0`` on success, ``-1`` on error (e.g. if " "*watcher_id* was never registered.)" msgstr "" +"*watcher_id* (:c:func:`PyType_AddWatcher` が以前返した値) で指定したウォッ" +"チャーを解除します。\n" +"成功すると ``0``、エラー時 (例えば *watcher_id* が一度も登録されていない場" +"合) は ``-1`` を返します。" -#: ../../c-api/type.rst:97 msgid "" "An extension should never call ``PyType_ClearWatcher`` with a *watcher_id* " "that was not returned to it by a previous call to :c:func:" "`PyType_AddWatcher`." msgstr "" +"拡張モジュールは、以前 :c:func:`PyType_AddWatcher` の呼び出しで受け取ったもの" +"でない *watcher_id* を渡して ``PyType_ClearWatcher`` を呼び出してはいけませ" +"ん。" -#: ../../c-api/type.rst:106 msgid "" "Mark *type* as watched. The callback granted *watcher_id* by :c:func:" "`PyType_AddWatcher` will be called whenever :c:func:`PyType_Modified` " @@ -137,52 +164,64 @@ msgid "" "is not called on *type* between the modifications; this is an implementation " "detail and subject to change.)" msgstr "" +"*type* を監視対象にします。\n" +":c:func:`PyType_Modified` が *type* の変更を報告するたびに、:c:func:" +"`PyType_AddWatcher` から *watcher_id* を割り当てられたコールバックが呼び出さ" +"れます。\n" +"ただし、*type* に対する一連の変更の間に :c:func:`!_PyType_Lookup` が呼び出さ" +"れなければ、コールバックは 1 度だけ呼び出されることがあります。\n" +"これは実装詳細であり、変更される可能性があります。" -#: ../../c-api/type.rst:113 msgid "The callback is also invoked when a watched heap type is deallocated." -msgstr "" +msgstr "監視対象のヒープ型が解放されるときにも、コールバックが呼び出されます。" -#: ../../c-api/type.rst:115 msgid "" "An extension should never call ``PyType_Watch`` with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" +"拡張モジュールは、以前 :c:func:`PyType_AddWatcher` の呼び出しで受け取ったもの" +"でない *watcher_id* を渡して ``PyType_Watch`` を呼び出してはいけません。" -#: ../../c-api/type.rst:120 msgid "" "The callback is now also invoked when a watched heap type is deallocated." msgstr "" +"監視対象のヒープ型が解放されるときにも、コールバックが呼び出されるようになり" +"ました。" -#: ../../c-api/type.rst:126 msgid "" "Mark *type* as not watched. This undoes a previous call to :c:func:" "`PyType_Watch`. *type* must not be ``NULL``." msgstr "" +"*type* を監視対象から外します。\n" +"以前の :c:func:`PyType_Watch` の呼び出しを取り消します。\n" +"*type* は ``NULL`` であってはいけません。" -#: ../../c-api/type.rst:129 msgid "" "An extension should never call this function with a *watcher_id* that was " "not returned to it by a previous call to :c:func:`PyType_AddWatcher`." msgstr "" +"拡張モジュールは、以前 :c:func:`PyType_AddWatcher` の呼び出しで受け取ったもの" +"でない *watcher_id* を渡して、この関数を呼び出してはいけません。" -#: ../../c-api/type.rst:132 msgid "" "On success, this function returns ``0``. On failure, this function returns " "``-1`` with an exception set." msgstr "" +"成功すると ``0`` を返します。\n" +"失敗すると例外を設定して ``-1`` を返します。" -#: ../../c-api/type.rst:140 msgid "Type of a type-watcher callback function." -msgstr "" +msgstr "型ウォッチャーのコールバック関数の型。" -#: ../../c-api/type.rst:142 msgid "" "The callback must not modify *type* or cause :c:func:`PyType_Modified` to be " "called on *type* or any type in its MRO; violating this rule could cause " "infinite recursion." msgstr "" +"コールバックは *type* を変更したり、*type* またはその MRO 内の型に対して :c:" +"func:`PyType_Modified` が呼び出されるようにしたりしてはいけません。\n" +"この規則に違反すると、無限再帰を引き起こす可能性があります。" -#: ../../c-api/type.rst:146 msgid "" "The callback may be called during type deallocation. In this case, the type " "object is temporarily resurrected (its reference count is at least 1) and " @@ -190,64 +229,86 @@ msgid "" "new strong references to the type, as this would resurrect the object and " "prevent its deallocation." msgstr "" +"コールバックは型の解放中に呼び出されることがあります。\n" +"その場合、型オブジェクトは一時的に復活しており (参照カウントは 1 以上)、すべ" +"ての属性がまだ有効です。\n" +"ただし、型への新しい強参照をコールバックで保存してはいけません。\n" +"オブジェクトを復活させ、解放を妨げてしまうためです。" -#: ../../c-api/type.rst:154 msgid "" "The callback may now be called during deallocation of a watched heap type." msgstr "" +"監視対象のヒープ型の解放中にも、コールバックが呼び出される可能性があるように" +"なりました。" -#: ../../c-api/type.rst:160 msgid "" "Return non-zero if the type object *o* sets the feature *feature*. Type " "features are denoted by single bit flags." msgstr "" +"型オブジェクト *o* に機能 *feature* が設定されていれば、ゼロ以外を返しま" +"す。\n" +"型の機能は、それぞれ 1 ビットのフラグで表します。" -#: ../../c-api/type.rst:166 msgid "" "Return non-zero if the type object *type* sets the subclass flag *flag*. " "Subclass flags are denoted by :c:macro:`Py_TPFLAGS_*_SUBCLASS " "`. This function is used by many ``_Check`` " "functions for common types." msgstr "" +"型オブジェクト *type* にサブクラスフラグ *flag* が設定されていれば、ゼロ以外" +"を返します。\n" +"サブクラスフラグは :c:macro:`Py_TPFLAGS_*_SUBCLASS " +"` で表します。\n" +"この関数は、一般的な型の多くの ``_Check`` 関数で使われています。" -#: ../../c-api/type.rst:172 msgid "" ":c:func:`PyObject_TypeCheck`, which is used as a slower alternative in " "``_Check`` functions for types that don't come with subclass flags." msgstr "" +":c:func:`PyObject_TypeCheck` は、サブクラスフラグのない型の ``_Check`` 関数" +"で、より低速な代替として使われます。" -#: ../../c-api/type.rst:178 msgid "" "Return true if the type object includes support for the cycle detector; this " "tests the type flag :c:macro:`Py_TPFLAGS_HAVE_GC`." msgstr "" +"型オブジェクトが循環参照の検出をサポートしている場合に真を返します。\n" +"型のフラグ :c:macro:`Py_TPFLAGS_HAVE_GC` を調べます。" #: ../../c-api/type.rst:184 msgid "Return true if *a* is a subtype of *b*." msgstr "*a* が *b* のサブタイプの場合に真を返します。" -#: ../../c-api/type.rst:186 msgid "" "This function only checks for actual subtypes, which means that :meth:`~type." "__subclasscheck__` is not called on *b*. Call :c:func:`PyObject_IsSubclass` " "to do the same check that :func:`issubclass` would do." msgstr "" +"この関数が調べるのは実際のサブタイプ関係だけで、*b* の :meth:`~type." +"__subclasscheck__` は呼び出しません。\n" +":func:`issubclass` と同じ検査を行うには :c:func:`PyObject_IsSubclass` を呼び" +"出してください。" -#: ../../c-api/type.rst:194 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_alloc` slot of a type " "object. Uses Python's default memory allocation mechanism to allocate " "memory for a new instance, zeros the memory, then initializes the memory as " "if by calling :c:func:`PyObject_Init` or :c:func:`PyObject_InitVar`." msgstr "" +"型オブジェクトの :c:member:`~PyTypeObject.tp_alloc` スロット用の汎用ハンドラ" +"です。\n" +"Python のデフォルトのメモリ割り当て機構を使って新しいインスタンスのメモリを割" +"り当て、ゼロで埋めてから、:c:func:`PyObject_Init` または :c:func:" +"`PyObject_InitVar` を呼び出すのと同じように初期化します。" -#: ../../c-api/type.rst:199 msgid "" "Do not call this directly to allocate memory for an object; call the type's :" "c:member:`~PyTypeObject.tp_alloc` slot instead." msgstr "" +"オブジェクトのメモリを割り当てるためにこれを直接呼び出してはいけません。\n" +"代わりに型の :c:member:`~PyTypeObject.tp_alloc` スロットを呼び出してくださ" +"い。" -#: ../../c-api/type.rst:202 msgid "" "For types that support garbage collection (i.e., the :c:macro:" "`Py_TPFLAGS_HAVE_GC` flag is set), this function behaves like :c:macro:" @@ -258,27 +319,38 @@ msgid "" "the memory is guaranteed to be zeroed before initialization) and should be " "paired with :c:func:`PyObject_Free` in :c:member:`~PyTypeObject.tp_free`." msgstr "" +"ガベージコレクションをサポートする型 (:c:macro:`Py_TPFLAGS_HAVE_GC` フラグが" +"設定されているもの) では、:c:macro:`PyObject_GC_New` または :c:macro:" +"`PyObject_GC_NewVar` と同様に動作し、:c:member:`~PyTypeObject.tp_free` に設定" +"した :c:func:`PyObject_GC_Del` と組み合わせて使う必要があります。\n" +"それ以外の型では、:c:macro:`PyObject_New` または :c:macro:`PyObject_NewVar` " +"と同様に動作し、:c:member:`~PyTypeObject.tp_free` に設定した :c:func:" +"`PyObject_Free` と組み合わせて使う必要があります。\n" +"いずれの場合も、初期化前にメモリがゼロで埋められることが保証される点が異なり" +"ます。" -#: ../../c-api/type.rst:215 msgid "" "Generic handler for the :c:member:`~PyTypeObject.tp_new` slot of a type " "object. Creates a new instance using the type's :c:member:`~PyTypeObject." "tp_alloc` slot and returns the resulting object." msgstr "" +"型オブジェクトの :c:member:`~PyTypeObject.tp_new` スロット用の汎用ハンドラで" +"す。\n" +"型の :c:member:`~PyTypeObject.tp_alloc` スロットを使って新しいインスタンスを" +"作成し、作成したオブジェクトを返します。" -#: ../../c-api/type.rst:222 msgid "" "Finalize a type object. This should be called on all type objects to finish " "their initialization. This function is responsible for adding inherited " "slots from a type's base class. Return ``0`` on success, or return ``-1`` " "and sets an exception on error." msgstr "" -"型オブジェクトのファイナライズを行います。この関数は全てのオブジェクトで初期" -"化を完了するために呼び出されなくてはなりません。この関数は、基底クラス型から" -"継承したスロットを型オブジェクトに追加する役割があります。成功した場合には " -"``0`` を返し、エラーの場合には ``-1`` を返して例外情報を設定します。" +"型オブジェクトの初期化を完了します。\n" +"すべての型オブジェクトについて、初期化を仕上げるために呼び出す必要がありま" +"す。\n" +"この関数は、型の基底クラスから継承するスロットを追加します。\n" +"成功すると ``0`` を返し、エラー時は例外を設定して ``-1`` を返します。" -#: ../../c-api/type.rst:228 msgid "" "If some of the base classes implements the GC protocol and the provided type " "does not include the :c:macro:`Py_TPFLAGS_HAVE_GC` in its flags, then the GC " @@ -288,31 +360,43 @@ msgid "" "itself by at least implementing the :c:member:`~PyTypeObject.tp_traverse` " "handle." msgstr "" +"基底クラスのいずれかが GC プロトコルを実装しており、指定した型のフラグに :c:" +"macro:`Py_TPFLAGS_HAVE_GC` が含まれていなければ、GC プロトコルの実装が基底ク" +"ラスから自動的に継承されます。\n" +"一方、作成する型のフラグに :c:macro:`Py_TPFLAGS_HAVE_GC` が含まれている場合" +"は、少なくとも :c:member:`~PyTypeObject.tp_traverse` ハンドラを実装して、自分" +"で GC プロトコルを実装 **しなければなりません**。" -#: ../../c-api/type.rst:239 msgid "" "Return the type's name. Equivalent to getting the type's :attr:`~type." "__name__` attribute." msgstr "" +"型の名前を返します。\n" +"型の :attr:`~type.__name__` 属性の取得と同等です。" -#: ../../c-api/type.rst:247 msgid "" "Return the type's qualified name. Equivalent to getting the type's :attr:" "`~type.__qualname__` attribute." msgstr "" +"型の修飾名を返します。\n" +"型の :attr:`~type.__qualname__` 属性の取得と同等です。" -#: ../../c-api/type.rst:254 msgid "" "Return the type's fully qualified name. Equivalent to ``f\"{type.__module__}." "{type.__qualname__}\"``, or :attr:`type.__qualname__` if :attr:`type." "__module__` is not a string or is equal to ``\"builtins\"``." msgstr "" +"型の完全修飾名を返します。\n" +"``f\"{type.__module__}.{type.__qualname__}\"`` と同等ですが、:attr:`type." +"__module__` が文字列でないか ``\"builtins\"`` の場合は :attr:`type." +"__qualname__` と同等です。" -#: ../../c-api/type.rst:263 msgid "" "Return the type's module name. Equivalent to getting the :attr:`type." "__module__` attribute." msgstr "" +"型のモジュール名を返します。\n" +":attr:`type.__module__` 属性の取得と同等です。" #: ../../c-api/type.rst:271 msgid "" @@ -325,37 +409,41 @@ msgstr "" "の場合は、スロットが ``NULL`` か、関数が不正な引数で呼ばれたことを示します。" "通常、呼び出し側は返り値のポインタを適切な関数型にキャストします。" -#: ../../c-api/type.rst:277 msgid "" "See :c:member:`PyType_Slot.slot` for possible values of the *slot* argument." msgstr "" +"*slot* 引数に指定できる値は :c:member:`PyType_Slot.slot` を参照してください。" -#: ../../c-api/type.rst:281 msgid "" ":c:func:`PyType_GetSlot` can now accept all types. Previously, it was " "limited to :ref:`heap types `." msgstr "" +":c:func:`PyType_GetSlot` がすべての型を受け付けるようになりました。\n" +"以前は :ref:`ヒープ型 ` に限られていました。" -#: ../../c-api/type.rst:288 msgid "" "Return the module object associated with the given type when the type was " "created using :c:func:`PyType_FromModuleAndSpec`." msgstr "" +":c:func:`PyType_FromModuleAndSpec` で型を作成したときに、その型に関連付けたモ" +"ジュールオブジェクトを返します。" -#: ../../c-api/type.rst:291 ../../c-api/type.rst:355 msgid "" "The returned reference is :term:`borrowed ` from *type*, " "and will be valid as long as you hold a reference to *type*. Do not release " "it with :c:func:`Py_DECREF` or similar." msgstr "" +"返される参照は *type* からの :term:`借用参照 ` で、" +"*type* への参照を保持している間は有効です。\n" +":c:func:`Py_DECREF` などで解放しないでください。" -#: ../../c-api/type.rst:295 ../../c-api/type.rst:316 msgid "" "If no module is associated with the given type, sets :py:class:`TypeError` " "and returns ``NULL``." msgstr "" +"指定された型にモジュールが関連付けられていない場合は、:py:class:`TypeError` " +"を設定して ``NULL`` を返します。" -#: ../../c-api/type.rst:298 msgid "" "This function is usually used to get the module in which a method is " "defined. Note that in such a method, ``PyType_GetModule(Py_TYPE(self))`` may " @@ -365,32 +453,45 @@ msgid "" "defines the method. See :c:func:`PyType_GetModuleByToken` for cases when :c:" "type:`!PyCMethod` cannot be used." msgstr "" +"この関数は通常、メソッドの定義元のモジュールを取得するために使います。\n" +"そのようなメソッド内で ``PyType_GetModule(Py_TYPE(self))`` を呼び出しても、意" +"図した結果にならない場合がある点に注意してください。\n" +"``Py_TYPE(self)`` は意図したクラスの *サブクラス* である可能性があり、サブク" +"ラスは基底クラスと同じモジュールで定義されているとは限りません。\n" +"メソッドを定義しているクラスを取得する方法は :c:type:`PyCMethod` を参照してく" +"ださい。\n" +":c:type:`!PyCMethod` を使えない場合は :c:func:`PyType_GetModuleByToken` を参" +"照してください。" -#: ../../c-api/type.rst:312 msgid "" "Return the state of the module object associated with the given type. This " "is a shortcut for calling :c:func:`PyModule_GetState()` on the result of :c:" "func:`PyType_GetModule`." msgstr "" +"指定された型に関連付けられたモジュールオブジェクトの状態を返します。\n" +":c:func:`PyType_GetModule` の結果に対して :c:func:`PyModule_GetState()` を呼" +"び出す処理の短縮形です。" -#: ../../c-api/type.rst:319 msgid "" "If the *type* has an associated module but its state is ``NULL``, returns " "``NULL`` without setting an exception." msgstr "" +"*type* にモジュールが関連付けられていても、その状態が ``NULL`` の場合は、例外" +"を設定せずに ``NULL`` を返します。" -#: ../../c-api/type.rst:327 msgid "" "Find the first superclass whose module has the given :ref:`module token `, and return that module." msgstr "" +"モジュールが指定された :ref:`モジュールトークン ` を持つ最" +"初の基底クラスを探し、そのモジュールを返します。" -#: ../../c-api/type.rst:330 msgid "" "If no module is found, raises a :py:class:`TypeError` and returns ``NULL``." msgstr "" +"モジュールが見つからない場合は、:py:class:`TypeError` を送出して ``NULL`` を" +"返します。" -#: ../../c-api/type.rst:332 msgid "" "This function is intended to be used together with :c:func:" "`PyModule_GetState()` to get module state from slot methods (such as :c:" @@ -398,107 +499,121 @@ msgid "" "other places where a method's defining class cannot be passed using the :c:" "type:`PyCMethod` calling convention." msgstr "" +"この関数は、:c:member:`~PyTypeObject.tp_init` や :c:member:`~PyNumberMethods." +"nb_add` などのスロットメソッドや、:c:type:`PyCMethod` 呼び出し規約でメソッド" +"の定義元クラスを渡せない場所で、\n" +":c:func:`PyModule_GetState()` と組み合わせてモジュール状態を取得するために使" +"うことを想定しています。" -#: ../../c-api/type.rst:343 msgid "" "Find the first superclass whose module was created from the given :c:type:" "`PyModuleDef` *def*, or whose :ref:`module token ` is " "equal to *def*, and return that module." msgstr "" +"モジュールが指定された :c:type:`PyModuleDef` *def* から作成されたか、:ref:`モ" +"ジュールトークン ` が *def* と等しい最初の基底クラスを探" +"し、そのモジュールを返します。" -#: ../../c-api/type.rst:347 msgid "" "Note that modules created from a :c:type:`PyModuleDef` always have their " "token set to the :c:type:`PyModuleDef`'s address. In other words, this " "function is equivalent to :c:func:`PyType_GetModuleByToken`, except that it:" msgstr "" +":c:type:`PyModuleDef` から作成されたモジュールでは、トークンは常にその :c:" +"type:`PyModuleDef` のアドレスに設定されます。\n" +"つまり、この関数は次の点を除いて :c:func:`PyType_GetModuleByToken` と同等で" +"す。" -#: ../../c-api/type.rst:352 msgid "returns a borrowed reference, and" -msgstr "" +msgstr "借用参照を返します。" -#: ../../c-api/type.rst:353 msgid "" "has a non-``void*`` argument type (which is a cosmetic difference in C)." -msgstr "" +msgstr "引数の型が ``void*`` ではありません (C では表面的な違いです)。" -#: ../../c-api/type.rst:364 msgid "" "Find the first superclass in *type*'s :term:`method resolution order` whose :" "c:macro:`Py_tp_token` token is equal to *tp_token*." msgstr "" +"*type* の :term:`メソッド解決順序 ` の中で、:c:" +"macro:`Py_tp_token` トークンが *tp_token* と等しい最初の基底クラスを探しま" +"す。" -#: ../../c-api/type.rst:367 msgid "" "If found, set *\\*result* to a new :term:`strong reference` to it and return " "``1``." msgstr "" +"見つかった場合は、*\\*result* にその型への新しい :term:`強参照 ` を設定して ``1`` を返します。" -#: ../../c-api/type.rst:369 msgid "If not found, set *\\*result* to ``NULL`` and return ``0``." msgstr "" +"見つからない場合は、*\\*result* に ``NULL`` を設定して ``0`` を返します。" -#: ../../c-api/type.rst:370 msgid "" "On error, set *\\*result* to ``NULL`` and return ``-1`` with an exception " "set." msgstr "" +"エラー時は *\\*result* に ``NULL`` を設定し、例外を設定して ``-1`` を返しま" +"す。" -#: ../../c-api/type.rst:373 msgid "" "The *result* argument may be ``NULL``, in which case *\\*result* is not set. " "Use this if you need only the return value." msgstr "" +"*result* 引数は ``NULL`` にできます。\n" +"その場合、*\\*result* は設定されません。\n" +"戻り値だけが必要な場合に使ってください。" -#: ../../c-api/type.rst:376 msgid "The *tp_token* argument may not be ``NULL``." -msgstr "" +msgstr "*tp_token* 引数は ``NULL`` にできません。" -#: ../../c-api/type.rst:383 msgid "Attempt to assign a version tag to the given type." -msgstr "" +msgstr "指定された型へのバージョンタグの割り当てを試みます。" -#: ../../c-api/type.rst:385 msgid "" "Returns 1 if the type already had a valid version tag or a new one was " "assigned, or 0 if a new tag could not be assigned." msgstr "" +"型がすでに有効なバージョンタグを持っていたか、新しいタグを割り当てられた場合" +"は 1 を返します。\n" +"新しいタグを割り当てられなかった場合は 0 を返します。" -#: ../../c-api/type.rst:393 msgid "" "Return true if instances of *type* support creating weak references, false " "otherwise. This function always succeeds. *type* must not be ``NULL``." msgstr "" +"*type* のインスタンスが弱参照の作成をサポートする場合は真、それ以外の場合は偽" +"を返します。\n" +"この関数は常に成功します。\n" +"*type* は ``NULL`` であってはいけません。" -#: ../../c-api/type.rst:397 msgid ":ref:`weakrefobjects`" -msgstr "" +msgstr ":ref:`weakrefobjects`" -#: ../../c-api/type.rst:398 msgid ":py:mod:`weakref`" -msgstr "" +msgstr ":py:mod:`weakref`" -#: ../../c-api/type.rst:404 msgid "Creating Heap-Allocated Types" -msgstr "" +msgstr "ヒープに割り当てられる型の作成" -#: ../../c-api/type.rst:406 msgid "" "The following function is used to create :ref:`heap types `:" -msgstr "" +msgstr "次の関数で :ref:`ヒープ型 ` を作成します。" -#: ../../c-api/type.rst:410 msgid "" "Create and return a :ref:`heap type ` from a :c:type:`!PySlot` " "array. See :ref:`capi-slots` for general information on slots, and :ref:" "`pyslot_type_slot_ids` for slots specific to type creation." msgstr "" +":c:type:`!PySlot` 配列から :ref:`ヒープ型 ` を作成して返しま" +"す。\n" +"スロット全般については :ref:`capi-slots`、型の作成に固有のスロットについて" +"は :ref:`pyslot_type_slot_ids` を参照してください。" -#: ../../c-api/type.rst:415 ../../c-api/type.rst:819 msgid "This function calls :c:func:`PyType_Ready` on the new type." -msgstr "" +msgstr "この関数は新しい型に対して :c:func:`PyType_Ready` を呼び出します。" -#: ../../c-api/type.rst:417 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. With user-" @@ -506,6 +621,12 @@ msgid "" "class:`type` (or the metaclass) over ``PyType_From*`` functions. " "Specifically:" msgstr "" +"この関数の動作は、:py:class:`type() ` の呼び出しや :keyword:`class` 文" +"の使用と完全には一致 **しない** 点に注意してください。\n" +"利用者が指定した基底型やメタクラスを使う場合は、``PyType_From*`` 関数よりも :" +"py:class:`type` (またはメタクラス) を :ref:`呼び出す ` 方法を推奨" +"します。\n" +"具体的には、次の違いがあります。" #: ../../c-api/type.rst:424 msgid "" @@ -513,19 +634,17 @@ msgid "" "set to ``type.__new__``)." msgstr "" -#: ../../c-api/type.rst:426 msgid ":py:meth:`~object.__init__` is not called on the new class." -msgstr "" +msgstr "新しいクラスの :py:meth:`~object.__init__` は呼び出されません。" -#: ../../c-api/type.rst:427 msgid ":py:meth:`~object.__init_subclass__` is not called on any bases." msgstr "" +"どの基底クラスの :py:meth:`~object.__init_subclass__` も呼び出されません。" -#: ../../c-api/type.rst:428 msgid ":py:meth:`~object.__set_name__` is not called on new descriptors." msgstr "" +"新しいデスクリプタの :py:meth:`~object.__set_name__` は呼び出されません。" -#: ../../c-api/type.rst:430 msgid "" "Slots are typically defined as a global static constant arrays. However, " "sometimes slot values are not statically known at compile time. For example, " @@ -534,8 +653,14 @@ msgid "" "to put such slots on the stack, and use :c:macro:`Py_slot_subslots` to refer " "to an array of static slots. For example::" msgstr "" +"スロットは通常、グローバルな static const 配列として定義します。\n" +"ただし、スロットの値をコンパイル時に静的に決められない場合もあります。\n" +"例えば :c:data:`Py_tp_bases`、:c:data:`Py_tp_metaclass`、:c:data:" +"`Py_tp_module` などのスロットには、生存する Python オブジェクトが必要です。\n" +"この場合は、そうしたスロットをスタック上に置き、:c:macro:`Py_slot_subslots` " +"で静的なスロット配列を参照することを推奨します。\n" +"例えば次のようにします。 ::" -#: ../../c-api/type.rst:438 msgid "" "static const PySlot my_slots[] = {\n" " PySlot_STATIC_DATA(Py_tp_name, \"MyClass\"),\n" @@ -553,8 +678,22 @@ msgid "" " return PyType_FromSlots(all_slots);\n" "}" msgstr "" +"static const PySlot my_slots[] = {\n" +" PySlot_STATIC_DATA(Py_tp_name, \"MyClass\"),\n" +" PySlot_FUNC(Py_tp_repr, my_repr_func),\n" +" ...\n" +" PySlot_END\n" +"};\n" +"\n" +"PyObject *make_my_class(PyObject *module) {\n" +" PySlot all_slots[] = {\n" +" PySlot_STATIC_DATA(Py_slot_subslots, my_slots),\n" +" PySlot_DATA(Py_tp_module, module),\n" +" PySlot_END\n" +" };\n" +" return PyType_FromSlots(all_slots);\n" +"}" -#: ../../c-api/type.rst:454 msgid "" "Heap types created without the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag may " "be modified, for example by setting attributes on them, as with classes " @@ -562,281 +701,318 @@ msgid "" "initialize a type, but you may wish to prevent users from changing the type " "after the initialization is done:" msgstr "" +":c:macro:`Py_TPFLAGS_IMMUTABLETYPE` フラグを付けずに作成したヒープ型は、" +"Python コードで定義したクラスと同様に、属性の設定などによって変更できます。\n" +"型を完全に初期化するために、そうした変更が必要な場合もありますが、初期化が終" +"わった後は利用者による変更を禁止したいかもしれません。" -#: ../../c-api/type.rst:463 msgid "" "Make a type immutable: set the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag." msgstr "" +":c:macro:`Py_TPFLAGS_IMMUTABLETYPE` フラグを設定して、型を変更不能にします。" -#: ../../c-api/type.rst:465 msgid "All base classes of *type* must be immutable." -msgstr "" +msgstr "*type* のすべての基底クラスが変更不能でなければなりません。" -#: ../../c-api/type.rst:467 msgid "On success, return ``0``. On error, set an exception and return ``-1``." msgstr "" +"成功すると ``0`` を返します。\n" +"エラー時は例外を設定して ``-1`` を返します。" -#: ../../c-api/type.rst:470 msgid "" "The type must not be used before it's made immutable. For example, type " "instances must not be created before the type is made immutable." msgstr "" +"変更不能にする前に型を使ってはいけません。\n" +"例えば、変更不能にする前にその型のインスタンスを作成してはいけません。" -#: ../../c-api/type.rst:479 msgid "Type slot IDs" -msgstr "" +msgstr "型のスロット ID" -#: ../../c-api/type.rst:481 msgid "" "Most type slot IDs are named like the field names of the structures :c:type:" "`PyTypeObject`, :c:type:`PyNumberMethods`, :c:type:`PySequenceMethods`, :c:" "type:`PyMappingMethods` and :c:type:`PyAsyncMethods` with an added ``Py_`` " "prefix. For example, use:" msgstr "" +"型のスロット ID の大半は、:c:type:`PyTypeObject`、:c:type:" +"`PyNumberMethods`、:c:type:`PySequenceMethods`、:c:type:`PyMappingMethods`、:" +"c:type:`PyAsyncMethods` 構造体のフィールド名に ``Py_`` 接頭辞を付けた名前で" +"す。\n" +"例えば、次のように使います。" -#: ../../c-api/type.rst:487 msgid ":c:data:`Py_tp_dealloc` to set :c:member:`PyTypeObject.tp_dealloc`" -msgstr "" +msgstr ":c:member:`PyTypeObject.tp_dealloc` の設定には :c:data:`Py_tp_dealloc`" -#: ../../c-api/type.rst:488 msgid ":c:data:`Py_nb_add` to set :c:member:`PyNumberMethods.nb_add`" -msgstr "" +msgstr ":c:member:`PyNumberMethods.nb_add` の設定には :c:data:`Py_nb_add`" -#: ../../c-api/type.rst:489 msgid ":c:data:`Py_sq_length` to set :c:member:`PySequenceMethods.sq_length`" msgstr "" +":c:member:`PySequenceMethods.sq_length` の設定には :c:data:`Py_sq_length`" -#: ../../c-api/type.rst:491 msgid "" "The following slots need additional considerations when specified as slots:" -msgstr "" +msgstr "次のものをスロットとして指定するときには、追加の注意事項があります。" -#: ../../c-api/type.rst:493 msgid ":c:data:`Py_tp_name`" -msgstr "" +msgstr ":c:data:`Py_tp_name`" -#: ../../c-api/type.rst:494 msgid ":c:data:`Py_tp_basicsize` and :c:data:`Py_tp_extra_basicsize`" -msgstr "" +msgstr ":c:data:`Py_tp_basicsize` と :c:data:`Py_tp_extra_basicsize`" -#: ../../c-api/type.rst:495 msgid ":c:data:`Py_tp_itemsize`" -msgstr "" +msgstr ":c:data:`Py_tp_itemsize`" -#: ../../c-api/type.rst:496 msgid ":c:data:`Py_tp_flags`" -msgstr "" +msgstr ":c:data:`Py_tp_flags`" -#: ../../c-api/type.rst:498 msgid "" "Additional slots do not directly correspond to a :c:type:`!PyTypeObject` " "struct field:" msgstr "" +"次の追加スロットは、:c:type:`!PyTypeObject` 構造体のフィールドに直接対応する" +"ものではありません。" -#: ../../c-api/type.rst:501 msgid ":c:data:`Py_tp_token`" -msgstr "" +msgstr ":c:data:`Py_tp_token`" -#: ../../c-api/type.rst:502 msgid ":c:data:`Py_tp_metaclass`" -msgstr "" +msgstr ":c:data:`Py_tp_metaclass`" -#: ../../c-api/type.rst:503 msgid ":c:data:`Py_tp_module`" -msgstr "" +msgstr ":c:data:`Py_tp_module`" -#: ../../c-api/type.rst:505 msgid "" "The following “offset” fields cannot be set using :c:type:`PyType_Slot`:" msgstr "" +"次の「オフセット」フィールドは :c:type:`PyType_Slot` では設定できません。" -#: ../../c-api/type.rst:507 msgid "" ":c:member:`~PyTypeObject.tp_weaklistoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)" msgstr "" +":c:member:`~PyTypeObject.tp_weaklistoffset` (可能なら代わりに :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` を使ってください)" -#: ../../c-api/type.rst:509 msgid "" ":c:member:`~PyTypeObject.tp_dictoffset` (use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT` instead if possible)" msgstr "" +":c:member:`~PyTypeObject.tp_dictoffset` (可能なら代わりに :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` を使ってください)" -#: ../../c-api/type.rst:511 msgid "" ":c:member:`~PyTypeObject.tp_vectorcall_offset` (use " "``\"__vectorcalloffset__\"`` in :ref:`PyMemberDef `)" msgstr "" +":c:member:`~PyTypeObject.tp_vectorcall_offset` (:ref:`PyMemberDef " +"` で ``\"__vectorcalloffset__\"`` を使ってください)" -#: ../../c-api/type.rst:514 msgid "" "If it is not possible to switch to a ``MANAGED`` flag (for example, for " "vectorcall or to support Python older than 3.12), specify the offset in :c:" "data:`Py_tp_members`. See :ref:`PyMemberDef documentation ` for details." msgstr "" +"``MANAGED`` フラグに切り替えられない場合 (例えば vectorcall を使う場合や " +"Python 3.12 より前をサポートする場合) は、:c:data:`Py_tp_members` でオフセッ" +"トを指定してください。\n" +"詳細は :ref:`PyMemberDef のドキュメント ` を参照してくだ" +"さい。" -#: ../../c-api/type.rst:520 msgid "" "The following internal fields cannot be set at all when creating a heap type:" -msgstr "" +msgstr "次の内部フィールドは、ヒープ型の作成時には一切設定できません。" -#: ../../c-api/type.rst:523 msgid "" ":c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_mro`, :c:" "member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, " "and :c:member:`~PyTypeObject.tp_weaklist`." msgstr "" +":c:member:`~PyTypeObject.tp_dict`, :c:member:`~PyTypeObject.tp_mro`, :c:" +"member:`~PyTypeObject.tp_cache`, :c:member:`~PyTypeObject.tp_subclasses`, " +"and :c:member:`~PyTypeObject.tp_weaklist`." -#: ../../c-api/type.rst:529 msgid "" "The :c:data:`Py_tp_base` slot is equivalent to :c:data:`Py_tp_bases`; both " "may be set either to a type or a tuple of types. If both are specified, the " "value of :c:data:`Py_tp_bases` is used." msgstr "" +":c:data:`Py_tp_base` スロットは :c:data:`Py_tp_bases` と同等で、どちらにも型" +"または型のタプルを設定できます。\n" +"両方を指定した場合は :c:data:`Py_tp_bases` の値が使われます。" -#: ../../c-api/type.rst:534 msgid "Slot values may not be ``NULL``, except for the following:" -msgstr "" +msgstr "次のものを除き、スロットの値を ``NULL`` にはできません。" -#: ../../c-api/type.rst:536 msgid ":c:data:`Py_tp_doc`" -msgstr "" +msgstr ":c:data:`Py_tp_doc`" -#: ../../c-api/type.rst:537 msgid "" ":c:data:`Py_tp_token` (for clarity, prefer :c:data:`Py_TP_USE_SPEC` rather " "than ``NULL``)" msgstr "" +":c:data:`Py_tp_token` (明確にするため、``NULL`` より :c:data:" +"`Py_TP_USE_SPEC` を使うことを推奨します)" -#: ../../c-api/type.rst:540 msgid "Slots in :c:type:`PyBufferProcs` may be set in the unlimited API." msgstr "" +":c:type:`PyBufferProcs` のスロットは、制限のない API では設定できます。" -#: ../../c-api/type.rst:543 msgid "" ":c:member:`~PyBufferProcs.bf_getbuffer` and :c:member:`~PyBufferProcs." "bf_releasebuffer` are now available under the :ref:`limited API `." msgstr "" +":c:member:`~PyBufferProcs.bf_getbuffer` と :c:member:`~PyBufferProcs." +"bf_releasebuffer` が :ref:`Limited API ` でも利用できるように" +"なりました。" -#: ../../c-api/type.rst:548 msgid "" "The field :c:member:`~PyTypeObject.tp_vectorcall` can now be set using :c:" "data:`Py_tp_vectorcall`. See the field's documentation for details." msgstr "" +":c:data:`Py_tp_vectorcall` で :c:member:`~PyTypeObject.tp_vectorcall` フィー" +"ルドを設定できるようになりました。\n" +"詳細はフィールドの説明を参照してください。" -#: ../../c-api/type.rst:553 msgid "" "The :c:data:`Py_tp_bases` slot may be set to a single type object, making it " "equivalent to the :c:data:`Py_tp_base` slot. Previously, a tuple of types " "was required." msgstr "" +":c:data:`Py_tp_bases` スロットに単一の型オブジェクトを設定して、:c:data:" +"`Py_tp_base` スロットと同じように使えるようになりました。\n" +"以前は型のタプルが必要でした。" -#: ../../c-api/type.rst:558 msgid "" "The following slots correspond to fields in the underlying type structure, " "but need extra remarks for use as slots:" msgstr "" +"次のスロットは基になる型の構造体のフィールドに対応しますが、スロットとして使" +"う際には追加の注意事項があります。" -#: ../../c-api/type.rst:563 msgid "" ":c:member:`Slot ID ` for the name of the type, used to set :c:" "member:`PyTypeObject.tp_name`." msgstr "" +"型の名前を指定する :c:member:`スロット ID ` で、:c:member:" +"`PyTypeObject.tp_name` の設定に使います。" -#: ../../c-api/type.rst:566 msgid "" "This slot (or :c:member:`PyType_Spec.name`) is required to create a type." msgstr "" +"型を作成するには、このスロット (または :c:member:`PyType_Spec.name`) が必要で" +"す。" -#: ../../c-api/type.rst:568 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" "`PyType_Spec.name` instead." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +"代わりに :c:member:`PyType_Spec.name` を使ってください。" -#: ../../c-api/type.rst:573 msgid "" "CPython processes slots in order. It is recommended to put ``Py_tp_name`` at " "the beginning of the slots array, so that if processing of a later slots " "fails, error messages can include the name." msgstr "" +"CPython はスロットを順番に処理します。\n" +"後のスロットの処理に失敗したときにエラーメッセージに名前を含められるように、" +"``Py_tp_name`` をスロット配列の先頭に置くことを推奨します。" -#: ../../c-api/type.rst:582 msgid "" ":c:member:`Slot ID ` for the size of the instance in bytes. It " "is used to set :c:member:`PyTypeObject.tp_basicsize`." msgstr "" +"インスタンスのサイズをバイト単位で指定する :c:member:`スロット ID ` です。\n" +":c:member:`PyTypeObject.tp_basicsize` の設定に使います。" -#: ../../c-api/type.rst:585 ../../c-api/type.rst:632 msgid "The value must be positive." -msgstr "" +msgstr "値は正でなければなりません。" -#: ../../c-api/type.rst:587 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" "`PyType_Spec.basicsize` instead." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +"代わりに :c:member:`PyType_Spec.basicsize` を使ってください。" -#: ../../c-api/type.rst:590 msgid "" "This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:member:" "`PyTypeObject.tp_basicsize` instead if needed, but be aware that a type's " "size is often considered an implementation detail." msgstr "" +"このスロットは :c:func:`PyType_GetSlot` では使えません。\n" +"必要であれば代わりに :c:member:`PyTypeObject.tp_basicsize` を使ってくださ" +"い。\n" +"ただし、型のサイズは実装詳細とみなされることが多い点に注意してください。" -#: ../../c-api/type.rst:598 msgid "" ":c:member:`Slot ID ` for type data size in bytes, that is, how " "much space instances of the class need *in addition* to space needed for " "superclasses." msgstr "" +"型のデータサイズをバイト単位で指定する :c:member:`スロット ID ` です。\n" +"基底クラスに必要な領域に *加えて*、このクラスのインスタンスに必要な領域の大き" +"さを指定します。" -#: ../../c-api/type.rst:602 msgid "" "The value is used, together with the size of superclasses, to set :c:member:" "`PyTypeObject.tp_basicsize`. Python will insert padding as needed to meet :c:" "member:`!tp_basicsize`'s alignment requirements." msgstr "" +"この値は、基底クラスのサイズと合わせて :c:member:`PyTypeObject.tp_basicsize` " +"の設定に使われます。\n" +"Python は :c:member:`!tp_basicsize` のアラインメント要件を満たすように、必要" +"に応じてパディングを挿入します。" -#: ../../c-api/type.rst:607 msgid "" "Use :c:func:`PyObject_GetTypeData` to get a pointer to subclass-specific " "memory reserved this way." msgstr "" +"この方法で確保したサブクラス固有のメモリへのポインタは、:c:func:" +"`PyObject_GetTypeData` で取得してください。" -#: ../../c-api/type.rst:610 msgid "" "The value must be positive. To specify that instances need no additional " "size (that is, size should be inherited), omit the :c:macro:`!" "Py_tp_extra_basicsize` slot rather than set it to zero." msgstr "" +"値は正でなければなりません。\n" +"インスタンスに追加のサイズが不要である (サイズを継承する) 場合は、:c:macro:`!" +"Py_tp_extra_basicsize` スロットをゼロに設定するのではなく、省略してください。" -#: ../../c-api/type.rst:615 msgid "" "Specifying both :c:macro:`Py_tp_basicsize` and :c:macro:`!" "Py_tp_extra_basicsize` is an error." msgstr "" +":c:macro:`Py_tp_basicsize` と :c:macro:`!Py_tp_extra_basicsize` の両方を指定" +"するとエラーになります。" -#: ../../c-api/type.rst:618 ../../c-api/type.rst:665 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use negative :c:" "member:`PyType_Spec.basicsize` instead." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +"代わりに負の :c:member:`PyType_Spec.basicsize` を使ってください。" -#: ../../c-api/type.rst:621 ../../c-api/type.rst:653 msgid "This slot may not be used with :c:func:`PyType_GetSlot`." -msgstr "" +msgstr "このスロットは :c:func:`PyType_GetSlot` では使えません。" -#: ../../c-api/type.rst:627 msgid "" ":c:member:`Slot ID ` for the size of one element of a variable-" "size type, in bytes. Used to set :c:member:`PyTypeObject.tp_itemsize`. See :" "c:member:`!tp_itemsize` documentation for caveats." msgstr "" +"可変サイズの型の 1 要素のサイズをバイト単位で指定する :c:member:`スロット ID " +"` です。\n" +":c:member:`PyTypeObject.tp_itemsize` の設定に使います。\n" +"注意事項は :c:member:`!tp_itemsize` の説明を参照してください。" -#: ../../c-api/type.rst:634 msgid "" "If this slot is missing, :c:member:`~PyTypeObject.tp_itemsize` is inherited. " "Extending arbitrary variable-sized classes is dangerous, since some types " @@ -844,52 +1020,64 @@ msgid "" "sized memory used by a subclass. To help prevent mistakes, inheriting " "``itemsize`` is only possible in the following situations:" msgstr "" +"このスロットがない場合は :c:member:`~PyTypeObject.tp_itemsize` を継承しま" +"す。\n" +"任意の可変サイズのクラスを拡張するのは危険です。\n" +"可変サイズのメモリに固定のオフセットを使う型があり、サブクラスの固定サイズの" +"メモリと重なる可能性があるためです。\n" +"誤りを防ぐため、``itemsize`` を継承できるのは次の場合だけです。" -#: ../../c-api/type.rst:641 msgid "" "The base is not variable-sized (its :c:member:`~PyTypeObject.tp_itemsize` is " "zero)." msgstr "" +"基底クラスが可変サイズではない (:c:member:`~PyTypeObject.tp_itemsize` がゼロ" +"である) 場合。" -#: ../../c-api/type.rst:643 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is positive, suggesting that " "the memory layout of the base class is known." msgstr "" +"要求された :c:member:`PyType_Spec.basicsize` が正で、基底クラスのメモリレイア" +"ウトを把握していると考えられる場合。" -#: ../../c-api/type.rst:645 msgid "" "The requested :c:member:`PyType_Spec.basicsize` is zero, suggesting that the " "subclass does not access the instance's memory directly." msgstr "" +"要求された :c:member:`PyType_Spec.basicsize` がゼロで、サブクラスがインスタン" +"スのメモリに直接アクセスしないと考えられる場合。" -#: ../../c-api/type.rst:648 msgid "With the :c:macro:`Py_TPFLAGS_ITEMS_AT_END` flag." -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_ITEMS_AT_END` フラグがある場合。" -#: ../../c-api/type.rst:650 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use :c:member:" "`PyType_Spec.itemsize` instead." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +"代わりに :c:member:`PyType_Spec.itemsize` を使ってください。" -#: ../../c-api/type.rst:659 msgid "" ":c:member:`Slot ID ` for type flags, used to set :c:member:" "`PyTypeObject.tp_flags`." msgstr "" +"型のフラグを指定する :c:member:`スロット ID ` で、:c:member:" +"`PyTypeObject.tp_flags` の設定に使います。" -#: ../../c-api/type.rst:662 msgid "" "The ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:" "`PyType_FromSpecWithBases` sets it automatically." msgstr "" +"``Py_TPFLAGS_HEAPTYPE`` フラグは設定しません。\n" +":c:func:`PyType_FromSpecWithBases` が自動的に設定します。" -#: ../../c-api/type.rst:668 msgid "" "This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" "`PyType_GetFlags` instead." msgstr "" +"このスロットは :c:func:`PyType_GetSlot` では使えません。\n" +"代わりに :c:func:`PyType_GetFlags` を使ってください。" #: ../../c-api/type.rst:675 msgid "" @@ -897,183 +1085,215 @@ msgid "" "`PyTypeObject.tp_bases`." msgstr "" -#: ../../c-api/type.rst:678 msgid "" "The slot can be set to a tuple of type objects which the newly created type " "should inherit from, like the \"positional arguments\" of a Python :ref:" "`class definition `." msgstr "" +"新しい型が継承する型オブジェクトのタプルを設定できます。\n" +"Python の :ref:`クラス定義 ` の「位置引数」に相当します。" -#: ../../c-api/type.rst:682 msgid "" "Alternately, the slot can be set to a single type object to specify a single " "base. The effect is the same as specifying a one-element tuple." msgstr "" +"また、単一の型オブジェクトを設定して基底クラスを 1 つ指定することもできま" +"す。\n" +"要素が 1 つのタプルを指定した場合と同じ効果があります。" -#: ../../c-api/type.rst:688 msgid "Previously, :c:macro:`!Py_tp_bases` required a tuple of types." -msgstr "" +msgstr "以前の :c:macro:`!Py_tp_bases` には型のタプルが必要でした。" -#: ../../c-api/type.rst:692 msgid "" "Equivalent to :c:macro:`Py_tp_bases` (with ``s`` at the end). If both are " "specified, :c:macro:`!Py_tp_bases` takes priority and this slot is ignored." msgstr "" +":c:macro:`Py_tp_bases` (末尾に ``s`` がある方) と同等です。\n" +"両方を指定した場合は :c:macro:`!Py_tp_bases` が優先され、このスロットは無視さ" +"れます。" -#: ../../c-api/type.rst:698 msgid "Previously, :c:macro:`!Py_tp_base` required a single type, not a tuple." -msgstr "" +msgstr "以前の :c:macro:`!Py_tp_base` にはタプルではなく単一の型が必要でした。" -#: ../../c-api/type.rst:702 msgid "" "When not targeting older Python versions, prefer :c:macro:`!Py_tp_bases`." msgstr "" +"古い Python バージョンを対象としない場合は、:c:macro:`!Py_tp_bases` を使うこ" +"とを推奨します。" -#: ../../c-api/type.rst:704 msgid "" "The following slots do not correspond to public fields in the underlying " "structures:" -msgstr "" +msgstr "次のスロットは、基になる構造体の公開フィールドには対応しません。" -#: ../../c-api/type.rst:709 msgid "" ":c:member:`Slot ID ` for the metaclass used to construct the " "resulting type object. When omitted the metaclass is derived from bases (:c:" "macro:`Py_tp_bases` or the *bases* argument of :c:func:" "`PyType_FromMetaclass`)." msgstr "" +"作成される型オブジェクトの構築に使うメタクラスを指定する :c:member:`スロット " +"ID ` です。\n" +"省略すると、基底クラス (:c:macro:`Py_tp_bases` または :c:func:" +"`PyType_FromMetaclass` の *bases* 引数) からメタクラスが決まります。" -#: ../../c-api/type.rst:715 msgid "" "Metaclasses that override :c:member:`~PyTypeObject.tp_new` are not " "supported, except if ``tp_new`` is ``NULL``." msgstr "" +":c:member:`~PyTypeObject.tp_new` をオーバーライドするメタクラスは、" +"``tp_new`` が ``NULL`` の場合を除いてサポートされません。" -#: ../../c-api/type.rst:718 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use :c:func:" "`PyType_FromMetaclass` to specify a metaclass with :c:type:`!PyType_Spec`." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +":c:type:`!PyType_Spec` でメタクラスを指定するには :c:func:" +"`PyType_FromMetaclass` を使ってください。" -#: ../../c-api/type.rst:722 msgid "" "This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" "`Py_TYPE` on the type object instead." msgstr "" +"このスロットは :c:func:`PyType_GetSlot` では使えません。\n" +"代わりに型オブジェクトに対して :c:func:`Py_TYPE` を使ってください。" -#: ../../c-api/type.rst:729 msgid "" ":c:member:`Slot ID ` for recording the module in which the new " "class is defined." msgstr "" +"新しいクラスの定義元モジュールを記録する :c:member:`スロット ID ` です。" -#: ../../c-api/type.rst:732 msgid "" "The value must be a module object. The module is associated with the new " "type and can later be retrieved with :c:func:`PyType_GetModule`. The " "associated module is not inherited by subclasses; it must be specified for " "each class individually." msgstr "" +"値はモジュールオブジェクトでなければなりません。\n" +"モジュールは新しい型に関連付けられ、後で :c:func:`PyType_GetModule` を使って" +"取得できます。\n" +"関連付けられたモジュールはサブクラスに継承されないため、クラスごとに指定する" +"必要があります。" -#: ../../c-api/type.rst:738 msgid "" "This may not be used in :c:member:`PyType_Spec.slots`. Use :c:func:" "`PyType_FromMetaclass` to specify a module with :c:type:`!PyType_Spec`." msgstr "" +":c:member:`PyType_Spec.slots` では使えません。\n" +":c:type:`!PyType_Spec` でモジュールを指定するには :c:func:" +"`PyType_FromMetaclass` を使ってください。" -#: ../../c-api/type.rst:742 msgid "" "This slot may not be used with :c:func:`PyType_GetSlot`. Use :c:func:" "`PyType_GetModule` instead." msgstr "" +"このスロットは :c:func:`PyType_GetSlot` では使えません。\n" +"代わりに :c:func:`PyType_GetModule` を使ってください。" -#: ../../c-api/type.rst:749 msgid "" ":c:member:`Slot ID ` for recording a static memory layout ID " "for a class." msgstr "" +"クラスの静的なメモリレイアウト ID を記録する :c:member:`スロット ID ` です。" -#: ../../c-api/type.rst:752 msgid "" "If the class is defined using a :c:type:`PyType_Spec`, and that spec is " "statically allocated, the token can be set to the spec using the special " "value :c:data:`Py_TP_USE_SPEC`:" msgstr "" +"クラスを :c:type:`PyType_Spec` で定義し、その spec が静的に割り当てられている" +"場合、特殊な値 :c:data:`Py_TP_USE_SPEC` を使って spec をトークンとして設定で" +"きます。" -#: ../../c-api/type.rst:756 msgid "" "static PyType_Slot foo_slots[] = {\n" " {Py_tp_token, Py_TP_USE_SPEC}," msgstr "" +"static PyType_Slot foo_slots[] = {\n" +" {Py_tp_token, Py_TP_USE_SPEC}," -#: ../../c-api/type.rst:761 msgid "It can also be set to an arbitrary pointer, but you must ensure that:" msgstr "" +"任意のポインタを設定することもできますが、次の条件を満たす必要があります。" -#: ../../c-api/type.rst:763 msgid "" "The pointer outlives the class, so it's not reused for something else while " "the class exists." msgstr "" +"クラスが存在する間にポインタが他の用途に再利用されないよう、その参照先がクラ" +"スより長く存続すること。" -#: ../../c-api/type.rst:765 msgid "" "It \"belongs\" to the extension module where the class lives, so it will not " "clash with other extensions." msgstr "" +"他の拡張モジュールと競合しないよう、クラスが属する拡張モジュールにそのポイン" +"タが「属する」こと。" -#: ../../c-api/type.rst:768 msgid "" "Use :c:func:`PyType_GetBaseByToken` to check if a class's superclass has a " "given token -- that is, check whether the memory layout is compatible." msgstr "" +"クラスの基底クラスが指定したトークンを持つかどうか、つまりメモリレイアウトに" +"互換性があるかどうかを調べるには :c:func:`PyType_GetBaseByToken` を使ってくだ" +"さい。" -#: ../../c-api/type.rst:771 msgid "" "To get the token for a given class (without considering superclasses), use :" "c:func:`PyType_GetSlot` with ``Py_tp_token``." msgstr "" +"基底クラスを考慮せず、指定したクラスのトークンを取得するには、" +"``Py_tp_token`` を指定して :c:func:`PyType_GetSlot` を使ってください。" -#: ../../c-api/type.rst:780 msgid "" "Used as a value with :c:data:`Py_tp_token` to set the token to the class's :" "c:type:`PyType_Spec`. May only be used for classes defined using :c:type:`!" "PyType_Spec`." msgstr "" +":c:data:`Py_tp_token` の値として使い、クラスの :c:type:`PyType_Spec` をトーク" +"ンに設定します。\n" +":c:type:`!PyType_Spec` で定義されたクラスでのみ使えます。" -#: ../../c-api/type.rst:784 msgid "Expands to ``NULL``." -msgstr "" +msgstr "``NULL`` に展開されます。" -#: ../../c-api/type.rst:790 msgid "" ":c:member:`Slot ID ` that works like :c:macro:" "`Py_slot_subslots`, except it specifies an array of :c:type:`PyType_Slot` " "structures." msgstr "" +":c:macro:`Py_slot_subslots` と同じように動作する :c:member:`スロット ID " +"` ですが、:c:type:`PyType_Slot` 構造体の配列を指定します。" -#: ../../c-api/type.rst:798 msgid "Soft-deprecated API" -msgstr "" +msgstr "緩やかに非推奨となった API" -#: ../../c-api/type.rst:800 msgid "" "The following functions are :term:`soft deprecated`. They will continue to " "work, but new features will be added as slots for :c:func:" "`PyType_FromSlots`, not as arguments to new ``PyType_From*`` functions." msgstr "" +"次の関数は :term:`緩やかに非推奨 ` となっています。\n" +"引き続き動作しますが、新機能は新しい ``PyType_From*`` 関数の引数としてではな" +"く、:c:func:`PyType_FromSlots` のスロットとして追加されます。" -#: ../../c-api/type.rst:806 msgid "" "Create and return a :ref:`heap type ` from the *spec* (see :c:" "macro:`Py_TPFLAGS_HEAPTYPE`)." msgstr "" +"*spec* から :ref:`ヒープ型 ` を作成して返します (:c:macro:" +"`Py_TPFLAGS_HEAPTYPE` を参照)。" -#: ../../c-api/type.rst:809 msgid "" "A non-``NULL`` *metaclass* argument corresponds to the :c:macro:" "`Py_tp_metaclass` slot." msgstr "" +"``NULL`` でない *metaclass* 引数は :c:macro:`Py_tp_metaclass` スロットに対応" +"します。" #: ../../c-api/type.rst:812 msgid "" @@ -1082,135 +1302,143 @@ msgid "" "`Py_tp_bases` slots." msgstr "" -#: ../../c-api/type.rst:816 msgid "" "A non-``NULL`` *module* argument corresponds to the :c:macro:`Py_tp_module` " "slot." msgstr "" +"``NULL`` でない *module* 引数は :c:macro:`Py_tp_module` スロットに対応しま" +"す。" -#: ../../c-api/type.rst:821 msgid "" "Note that this function does *not* fully match the behavior of calling :py:" "class:`type() ` or using the :keyword:`class` statement. See the note " "in :c:func:`PyType_FromSlots` documentation for details." msgstr "" +"この関数の動作は、:py:class:`type() ` の呼び出しや :keyword:`class` 文" +"の使用と完全には一致 **しない** 点に注意してください。\n" +"詳細は :c:func:`PyType_FromSlots` の説明の注記を参照してください。" -#: ../../c-api/type.rst:829 ../../c-api/type.rst:860 ../../c-api/type.rst:886 -#: ../../c-api/type.rst:911 msgid "Prefer :c:func:`PyType_FromSlots` in new code." -msgstr "" +msgstr "新しいコードでは :c:func:`PyType_FromSlots` を使うことを推奨します。" -#: ../../c-api/type.rst:834 msgid "Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases)``." -msgstr "" +msgstr "``PyType_FromMetaclass(NULL, module, spec, bases)`` と同等です。" -#: ../../c-api/type.rst:840 msgid "" "The function now accepts a single class as the *bases* argument and ``NULL`` " "as the ``tp_doc`` slot." msgstr "" +"*bases* 引数に単一のクラスを、``tp_doc`` スロットに ``NULL`` を指定できるよう" +"になりました。" -#: ../../c-api/type.rst:845 ../../c-api/type.rst:871 msgid "" "The function now finds and uses a metaclass corresponding to the provided " "base classes. Previously, only :class:`type` instances were returned." msgstr "" +"指定された基底クラスに対応するメタクラスを探して使うようになりました。\n" +"以前は :class:`type` のインスタンスだけを返していました。" -#: ../../c-api/type.rst:848 ../../c-api/type.rst:874 ../../c-api/type.rst:899 msgid "" "The :c:member:`~PyTypeObject.tp_new` of the metaclass is *ignored*. which " "may result in incomplete initialization. Creating classes whose metaclass " "overrides :c:member:`~PyTypeObject.tp_new` is deprecated." msgstr "" +"メタクラスの :c:member:`~PyTypeObject.tp_new` は *無視* されるため、初期化が" +"不完全になる可能性があります。\n" +"メタクラスが :c:member:`~PyTypeObject.tp_new` をオーバーライドしているクラス" +"の作成は非推奨です。" -#: ../../c-api/type.rst:855 ../../c-api/type.rst:881 ../../c-api/type.rst:906 msgid "" "Creating classes whose metaclass overrides :c:member:`~PyTypeObject.tp_new` " "is no longer allowed." msgstr "" +"メタクラスが :c:member:`~PyTypeObject.tp_new` をオーバーライドしているクラス" +"は、作成できなくなりました。" -#: ../../c-api/type.rst:865 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases)``." -msgstr "" +msgstr "``PyType_FromMetaclass(NULL, NULL, spec, bases)`` と同等です。" -#: ../../c-api/type.rst:891 msgid "Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL)``." -msgstr "" +msgstr "``PyType_FromMetaclass(NULL, NULL, spec, NULL)`` と同等です。" -#: ../../c-api/type.rst:895 msgid "" "The function now finds and uses a metaclass corresponding to the base " "classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` " "instances were returned." msgstr "" +"*Py_tp_base[s]* スロットに指定された基底クラスに対応するメタクラスを探して使" +"うようになりました。\n" +"以前は :class:`type` のインスタンスだけを返していました。" -#: ../../c-api/type.rst:924 msgid "" "Structure defining a type's behavior, used for soft-deprecated functions " "like :c:func:`PyType_FromMetaclass`." msgstr "" +"型の動作を定義する構造体で、:c:func:`PyType_FromMetaclass` などの緩やかに非推" +"奨となった関数で使います。" -#: ../../c-api/type.rst:927 msgid "" "This structure contains several members that can instead be specified as :" "ref:`slots ` for :c:func:`PyType_FromSlots`, and an " "array of slot entries with a simpler structure." msgstr "" +"この構造体には、:c:func:`PyType_FromSlots` の :ref:`スロット " +"` としても指定できるメンバーがいくつかあり、それらに加" +"えて、より単純な構造体のスロットエントリーの配列を含みます。" -#: ../../c-api/type.rst:933 msgid "Corresponds to :c:macro:`Py_tp_name`." -msgstr "" +msgstr ":c:macro:`Py_tp_name` に対応します。" -#: ../../c-api/type.rst:937 msgid "If positive, corresponds to :c:macro:`Py_tp_basicsize`." -msgstr "" +msgstr "正の場合、:c:macro:`Py_tp_basicsize` に対応します。" -#: ../../c-api/type.rst:939 msgid "" "If negative, corresponds to :c:macro:`Py_tp_extra_basicsize` set to the " "absolute value." msgstr "" +"負の場合、絶対値を設定した :c:macro:`Py_tp_extra_basicsize` に対応します。" -#: ../../c-api/type.rst:944 msgid "Previously, this field could not be negative." -msgstr "" +msgstr "以前はこのフィールドを負にできませんでした。" -#: ../../c-api/type.rst:948 msgid "Corresponds to :c:macro:`Py_tp_itemsize`." -msgstr "" +msgstr ":c:macro:`Py_tp_itemsize` に対応します。" -#: ../../c-api/type.rst:952 msgid "Corresponds to :c:macro:`Py_tp_flags`." -msgstr "" +msgstr ":c:macro:`Py_tp_flags` に対応します。" -#: ../../c-api/type.rst:956 msgid "Array of :c:type:`PyType_Slot` (not :c:type:`PySlot`) structures." msgstr "" +":c:type:`PyType_Slot` 構造体の配列です (:c:type:`PySlot` ではありません)。" -#: ../../c-api/type.rst:958 msgid "" "Terminated by the special slot value ``{0, NULL}``. Each slot ID should be " "specified at most once." msgstr "" +"特殊なスロット値 ``{0, NULL}`` で終端します。\n" +"各スロット ID は最大 1 回だけ指定する必要があります。" -#: ../../c-api/type.rst:971 msgid "" "Structure defining optional functionality of a type, used for soft-" "deprecated functions like :c:func:`PyType_FromMetaclass`." msgstr "" +"型の任意の機能を定義する構造体で、:c:func:`PyType_FromMetaclass` などの緩やか" +"に非推奨となった関数で使います。" -#: ../../c-api/type.rst:974 msgid "" "Note that a :c:type:`!PyType_Slot` array may be included in a :c:type:`!" "PySlot` array using :c:macro:`Py_tp_slots`, and vice versa using :c:macro:" "`Py_slot_subslots`." msgstr "" +":c:macro:`Py_tp_slots` を使うと :c:type:`!PyType_Slot` 配列を :c:type:`!" +"PySlot` 配列に含められ、逆方向には :c:macro:`Py_slot_subslots` を使えます。" -#: ../../c-api/type.rst:978 msgid "" "Each :c:type:`!PyType_Slot` structure ``tpslot`` is interpreted as the " "following :c:type:`PySlot` structure::" msgstr "" +"各 :c:type:`!PyType_Slot` 構造体 ``tpslot`` は、次の :c:type:`PySlot` 構造体" +"として解釈されます。 ::" #: ../../c-api/type.rst:981 msgid "" @@ -1221,20 +1449,20 @@ msgid "" "}" msgstr "" -#: ../../c-api/type.rst:987 msgid "" "where ``sub_static`` is ``PySlot_STATIC`` if the slot requires the flag " "(such as for :c:macro:`Py_tp_methods`), or if this flag is present on the " "\"parent\" :c:macro:`!Py_tp_slots` slot (if any)." msgstr "" +"ここで ``sub_static`` は、スロットがそのフラグを必要とする場合 (例えば :c:" +"macro:`Py_tp_methods`) または「親」の :c:macro:`!Py_tp_slots` スロット (存在" +"する場合) にこのフラグがある場合に、``PySlot_STATIC`` になります。" -#: ../../c-api/type.rst:993 msgid "Corresponds to :c:member:`PySlot.sl_id`." -msgstr "" +msgstr ":c:member:`PySlot.sl_id` に対応します。" -#: ../../c-api/type.rst:997 msgid "Corresponds to :c:member:`PySlot.sl_ptr`." -msgstr "" +msgstr ":c:member:`PySlot.sl_ptr` に対応します。" #: ../../c-api/type.rst:8 msgid "object" diff --git a/c-api/typehints.po b/c-api/typehints.po index 99d4fd1d6..e2bc69923 100644 --- a/c-api/typehints.po +++ b/c-api/typehints.po @@ -16,22 +16,25 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/typehints.rst:6 msgid "Objects for Type Hinting" msgstr "型ヒントのためのオブジェクト" -#: ../../c-api/typehints.rst:8 msgid "" "Various built-in types for type hinting are provided. Currently, two types " "exist -- :ref:`GenericAlias ` and :ref:`Union `. Only ``GenericAlias`` is exposed to C." msgstr "" +"型ヒント用の組み込み型を提供しています。\n" +"現在は :ref:`GenericAlias ` と :ref:`Union ` の二つがあり、このうち C に公開されているのは ``GenericAlias`` だけで" +"す。" #: ../../c-api/typehints.rst:14 msgid "" @@ -58,11 +61,9 @@ msgstr "" "性は ``__args__`` から必要に応じて遅延生成されます。失敗した場合、例外が送出" "されて ``NULL`` を返します。" -#: ../../c-api/typehints.rst:28 msgid "Here's an example of how to make an extension type generic::" -msgstr "以下は拡張の型をジェネリックにする例です。" +msgstr "拡張型をジェネリックにする例を示します。 ::" -#: ../../c-api/typehints.rst:30 msgid "" "...\n" "static PyMethodDef my_obj_methods[] = {\n" @@ -73,10 +74,17 @@ msgid "" " ...\n" "}" msgstr "" +"...\n" +"static PyMethodDef my_obj_methods[] = {\n" +" // ほかのメソッド。\n" +" ...\n" +" {\"__class_getitem__\", Py_GenericAlias, METH_O|METH_CLASS, \"my_obj は格" +"納する要素の型をパラメータとするジェネリック型\"}\n" +" ...\n" +"}" -#: ../../c-api/typehints.rst:38 msgid "The data model method :meth:`~object.__class_getitem__`." -msgstr "" +msgstr "データモデルのメソッド :meth:`~object.__class_getitem__`。" #: ../../c-api/typehints.rst:44 msgid "" diff --git a/c-api/typeobj.po b/c-api/typeobj.po index 25f37e9c9..161b8c3b9 100644 --- a/c-api/typeobj.po +++ b/c-api/typeobj.po @@ -17,17 +17,15 @@ msgstr "" "Last-Translator: Cheesecake, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../c-api/typeobj.rst:6 msgid "Type Object Structures" -msgstr "" +msgstr "型オブジェクトの構造体" -#: ../../c-api/typeobj.rst:8 msgid "" "Perhaps one of the most important structures of the Python object system is " "the structure that defines a new type: the :c:type:`PyTypeObject` " @@ -37,12 +35,12 @@ msgid "" "they are very important to the interpreter itself and to any extension " "module that implements new types." msgstr "" -"新スタイルの型を定義する構造体: :c:type:`PyTypeObject` 構造体は、おそらく " -"Python オブジェクトシステムの中で最も重要な構造体の1つでしょう。型オブジェク" -"トは ``PyObject_*`` 系や ``PyType_*`` 系の関数で扱えますが、ほとんどの " -"Python アプリケーションにとって、さして面白みのある機能を提供しません。型オブ" -"ジェクトはオブジェクトがどのように振舞うかを決める基盤ですから、インタプリタ" -"自体や新たな型を定義する拡張モジュールでは非常に重要な存在です。" +"新しい型を定義する :c:type:`PyTypeObject` 構造体は、Python のオブジェクトシス" +"テムで特に重要な構造体の 1 つです。\n" +"型オブジェクトは ``PyObject_*`` 関数や ``PyType_*`` 関数で扱えますが、ほとん" +"どの Python アプリケーションにとって関心のある機能はあまり提供しません。\n" +"これらのオブジェクトはオブジェクトの動作を決める基盤なので、インタープリタ自" +"体や新しい型を実装する拡張モジュールにとっては非常に重要です。" #: ../../c-api/typeobj.rst:16 msgid "" @@ -365,9 +363,8 @@ msgstr ":c:type:`richcmpfunc`" msgid "__lt__, __le__, __eq__, __ne__, __gt__, __ge__" msgstr "__lt__, __le__, __eq__, __ne__, __gt__, __ge__" -#: ../../c-api/typeobj.rst:99 msgid "(:c:member:`~PyTypeObject.tp_weaklistoffset`)" -msgstr "" +msgstr "(:c:member:`~PyTypeObject.tp_weaklistoffset`)" #: ../../c-api/typeobj.rst:101 msgid ":c:member:`~PyTypeObject.tp_iter`" @@ -476,9 +473,8 @@ msgstr ":c:type:`descrsetfunc`" msgid "__set__, __delete__" msgstr "__set__, __delete__" -#: ../../c-api/typeobj.rst:120 msgid "(:c:member:`~PyTypeObject.tp_dictoffset`)" -msgstr "" +msgstr "(:c:member:`~PyTypeObject.tp_dictoffset`)" #: ../../c-api/typeobj.rst:122 msgid ":c:member:`~PyTypeObject.tp_init`" @@ -593,51 +589,48 @@ msgstr ":c:member:`~PyTypeObject.tp_vectorcall`" msgid ":c:type:`vectorcallfunc`" msgstr ":c:type:`vectorcallfunc`" -#: ../../c-api/typeobj.rst:150 msgid "[:c:member:`~PyTypeObject.tp_watched`]" -msgstr "" +msgstr "[:c:member:`~PyTypeObject.tp_watched`]" #: ../../c-api/typeobj.rst:150 msgid "unsigned char" msgstr "unsigned char" -#: ../../c-api/typeobj.rst:155 msgid "" "**()**: A slot name in parentheses indicates it is (effectively) deprecated." msgstr "" +"**()**: 丸括弧で囲まれたスロット名は、そのスロットが (事実上) 非推奨であるこ" +"とを示します。" -#: ../../c-api/typeobj.rst:157 msgid "" "**<>**: Names in angle brackets should be initially set to ``NULL`` and " "treated as read-only." msgstr "" +"**<>**: 山括弧で囲まれた名前は、最初に ``NULL`` に設定し、読み取り専用として" +"扱うべきものです。" -#: ../../c-api/typeobj.rst:160 msgid "**[]**: Names in square brackets are for internal use only." -msgstr "" +msgstr "**[]**: 角括弧で囲まれた名前は内部使用専用です。" -#: ../../c-api/typeobj.rst:162 msgid "" "**** (as a prefix) means the field is required (must be non-``NULL``)." msgstr "" +"**** (接頭辞) は、そのフィールドが必須 (``NULL`` 不可) であることを示しま" +"す。" #: ../../c-api/typeobj.rst:164 msgid "Columns:" msgstr "列:" -#: ../../c-api/typeobj.rst:166 msgid "**\"O\"**: set on :c:data:`PyBaseObject_Type`" -msgstr "" +msgstr "**\"O\"**: :c:data:`PyBaseObject_Type` に設定されている" -#: ../../c-api/typeobj.rst:168 msgid "**\"T\"**: set on :c:data:`PyType_Type`" -msgstr "" +msgstr "**\"T\"**: :c:data:`PyType_Type` に設定されている" -#: ../../c-api/typeobj.rst:170 msgid "**\"D\"**: default (if slot is set to ``NULL``)" -msgstr "" +msgstr "**\"D\"**: デフォルト (スロットを ``NULL`` に設定した場合)" -#: ../../c-api/typeobj.rst:172 msgid "" "X - PyType_Ready sets this value if it is NULL\n" "~ - PyType_Ready always sets this value (it should be NULL)\n" @@ -645,12 +638,15 @@ msgid "" "\n" "Also see the inheritance column (\"I\")." msgstr "" +"X - NULL の場合、PyType_Ready がこの値を設定する\n" +"~ - PyType_Ready が常にこの値を設定する (NULL にしておくべき)\n" +"? - 他のスロットに応じて PyType_Ready がこの値を設定する場合がある\n" +"\n" +"継承の列 (\"I\") も参照してください。" -#: ../../c-api/typeobj.rst:180 msgid "**\"I\"**: inheritance" -msgstr "" +msgstr "**\"I\"**: 継承" -#: ../../c-api/typeobj.rst:182 msgid "" "X - type slot is inherited via *PyType_Ready* if defined with a *NULL* " "value\n" @@ -659,12 +655,15 @@ msgid "" "description\n" "? - it's complicated; see the slot's description" msgstr "" +"X - *NULL* 値で定義された型のスロットは *PyType_Ready* によって継承される\n" +"% - 下位構造体のスロットが個別に継承される\n" +"G - 他のスロットとの組み合わせでのみ継承される (スロットの説明を参照)\n" +"? - 複雑な規則がある (スロットの説明を参照)" -#: ../../c-api/typeobj.rst:189 msgid "" "Note that some slots are effectively inherited through the normal attribute " "lookup chain." -msgstr "" +msgstr "通常の属性検索の経路を通じて、実質的に継承されるスロットもあります。" #: ../../c-api/typeobj.rst:195 msgid "sub-slots" @@ -765,9 +764,8 @@ msgstr "__sub__ __rsub__" msgid ":c:member:`~PyNumberMethods.nb_inplace_subtract`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_subtract`" -#: ../../c-api/typeobj.rst:222 msgid "__isub__" -msgstr "" +msgstr "__isub__" #: ../../c-api/typeobj.rst:224 msgid ":c:member:`~PyNumberMethods.nb_multiply`" @@ -797,9 +795,8 @@ msgstr "__mod__ __rmod__" msgid ":c:member:`~PyNumberMethods.nb_inplace_remainder`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_remainder`" -#: ../../c-api/typeobj.rst:232 msgid "__imod__" -msgstr "" +msgstr "__imod__" #: ../../c-api/typeobj.rst:234 msgid ":c:member:`~PyNumberMethods.nb_divmod`" @@ -821,9 +818,8 @@ msgstr "__pow__ __rpow__" msgid ":c:member:`~PyNumberMethods.nb_inplace_power`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_power`" -#: ../../c-api/typeobj.rst:240 msgid "__ipow__" -msgstr "" +msgstr "__ipow__" #: ../../c-api/typeobj.rst:242 msgid ":c:member:`~PyNumberMethods.nb_negative`" @@ -877,9 +873,8 @@ msgstr "__lshift__ __rlshift__" msgid ":c:member:`~PyNumberMethods.nb_inplace_lshift`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_lshift`" -#: ../../c-api/typeobj.rst:255 msgid "__ilshift__" -msgstr "" +msgstr "__ilshift__" #: ../../c-api/typeobj.rst:257 msgid ":c:member:`~PyNumberMethods.nb_rshift`" @@ -893,9 +888,8 @@ msgstr "__rshift__ __rrshift__" msgid ":c:member:`~PyNumberMethods.nb_inplace_rshift`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_rshift`" -#: ../../c-api/typeobj.rst:260 msgid "__irshift__" -msgstr "" +msgstr "__irshift__" #: ../../c-api/typeobj.rst:262 msgid ":c:member:`~PyNumberMethods.nb_and`" @@ -909,9 +903,8 @@ msgstr "__and__ __rand__" msgid ":c:member:`~PyNumberMethods.nb_inplace_and`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_and`" -#: ../../c-api/typeobj.rst:265 msgid "__iand__" -msgstr "" +msgstr "__iand__" #: ../../c-api/typeobj.rst:267 msgid ":c:member:`~PyNumberMethods.nb_xor`" @@ -925,9 +918,8 @@ msgstr "__xor__ __rxor__" msgid ":c:member:`~PyNumberMethods.nb_inplace_xor`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_xor`" -#: ../../c-api/typeobj.rst:270 msgid "__ixor__" -msgstr "" +msgstr "__ixor__" #: ../../c-api/typeobj.rst:272 msgid ":c:member:`~PyNumberMethods.nb_or`" @@ -941,9 +933,8 @@ msgstr "__or__ __ror__" msgid ":c:member:`~PyNumberMethods.nb_inplace_or`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_or`" -#: ../../c-api/typeobj.rst:275 msgid "__ior__" -msgstr "" +msgstr "__ior__" #: ../../c-api/typeobj.rst:277 msgid ":c:member:`~PyNumberMethods.nb_int`" @@ -977,9 +968,8 @@ msgstr "__floordiv__" msgid ":c:member:`~PyNumberMethods.nb_inplace_floor_divide`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_floor_divide`" -#: ../../c-api/typeobj.rst:285 msgid "__ifloordiv__" -msgstr "" +msgstr "__ifloordiv__" #: ../../c-api/typeobj.rst:287 msgid ":c:member:`~PyNumberMethods.nb_true_divide`" @@ -993,9 +983,8 @@ msgstr "__truediv__" msgid ":c:member:`~PyNumberMethods.nb_inplace_true_divide`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_true_divide`" -#: ../../c-api/typeobj.rst:289 msgid "__itruediv__" -msgstr "" +msgstr "__itruediv__" #: ../../c-api/typeobj.rst:291 msgid ":c:member:`~PyNumberMethods.nb_index`" @@ -1017,9 +1006,8 @@ msgstr "__matmul__ __rmatmul__" msgid ":c:member:`~PyNumberMethods.nb_inplace_matrix_multiply`" msgstr ":c:member:`~PyNumberMethods.nb_inplace_matrix_multiply`" -#: ../../c-api/typeobj.rst:296 msgid "__imatmul__" -msgstr "" +msgstr "__imatmul__" #: ../../c-api/typeobj.rst:300 msgid ":c:member:`~PyMappingMethods.mp_length`" @@ -1123,9 +1111,8 @@ msgstr ":c:member:`~PyBufferProcs.bf_getbuffer`" msgid ":c:func:`getbufferproc`" msgstr ":c:func:`getbufferproc`" -#: ../../c-api/typeobj.rst:328 msgid "__buffer__" -msgstr "" +msgstr "__buffer__" #: ../../c-api/typeobj.rst:330 msgid ":c:member:`~PyBufferProcs.bf_releasebuffer`" @@ -1135,9 +1122,8 @@ msgstr ":c:member:`~PyBufferProcs.bf_releasebuffer`" msgid ":c:func:`releasebufferproc`" msgstr ":c:func:`releasebufferproc`" -#: ../../c-api/typeobj.rst:330 msgid "__release_\\ buffer\\__" -msgstr "" +msgstr "__release_\\ buffer\\__" #: ../../c-api/typeobj.rst:337 msgid "slot typedefs" @@ -1189,22 +1175,22 @@ msgstr ":c:type:`Py_buffer` *" msgid ":c:type:`releasebufferproc`" msgstr ":c:type:`releasebufferproc`" -#: ../../c-api/typeobj.rst:470 msgid "See :ref:`slot-typedefs` below for more detail." -msgstr "" +msgstr "詳細は後述の :ref:`slot-typedefs` を参照してください。" #: ../../c-api/typeobj.rst:474 msgid "PyTypeObject Definition" msgstr "PyTypeObject 定義" -#: ../../c-api/typeobj.rst:476 msgid "" "The structure definition for :c:type:`PyTypeObject` can be found in :file:" "`Include/cpython/object.h`. For convenience of reference, this repeats the " "definition found there:" msgstr "" +":c:type:`PyTypeObject` の構造体定義は :file:`Include/cpython/object.h` にあり" +"ます。\n" +"参照しやすいように、その定義を以下に再掲します。" -#: ../../c-api/typeobj.rst:482 msgid "" "typedef struct _typeobject {\n" " PyObject_VAR_HEAD\n" @@ -1302,12 +1288,106 @@ msgid "" " uint16_t tp_versions_used;\n" "} PyTypeObject;\n" msgstr "" +"typedef struct _typeobject {\n" +" PyObject_VAR_HEAD\n" +" const char *tp_name; /* 表示用。形式は \".\" */\n" +" Py_ssize_t tp_basicsize, tp_itemsize; /* 割り当て用 */\n" +"\n" +" /* 標準の操作を実装するメソッド */\n" +"\n" +" destructor tp_dealloc;\n" +" Py_ssize_t tp_vectorcall_offset;\n" +" getattrfunc tp_getattr;\n" +" setattrfunc tp_setattr;\n" +" PyAsyncMethods *tp_as_async; /* 以前の名前は tp_compare (Python 2)\n" +" または tp_reserved (Python 3) */\n" +" reprfunc tp_repr;\n" +"\n" +" /* 標準クラス用のメソッド群 */\n" +"\n" +" PyNumberMethods *tp_as_number;\n" +" PySequenceMethods *tp_as_sequence;\n" +" PyMappingMethods *tp_as_mapping;\n" +"\n" +" /* その他の標準の操作 (バイナリ互換性のためこの位置に配置) */\n" +"\n" +" hashfunc tp_hash;\n" +" ternaryfunc tp_call;\n" +" reprfunc tp_str;\n" +" getattrofunc tp_getattro;\n" +" setattrofunc tp_setattro;\n" +"\n" +" /* オブジェクトを入出力バッファとして扱う関数 */\n" +" PyBufferProcs *tp_as_buffer;\n" +"\n" +" /* 任意機能や拡張機能の有無を定義するフラグ */\n" +" unsigned long tp_flags;\n" +"\n" +" const char *tp_doc; /* ドキュメント文字列 */\n" +"\n" +" /* リリース 2.0 で意味を割り当て */\n" +" /* アクセス可能な全オブジェクトについて関数を呼び出す */\n" +" traverseproc tp_traverse;\n" +"\n" +" /* 保持するオブジェクトへの参照を削除する */\n" +" inquiry tp_clear;\n" +"\n" +" /* リリース 2.1 で意味を割り当て */\n" +" /* 拡張比較 */\n" +" richcmpfunc tp_richcompare;\n" +"\n" +" /* 弱参照を有効にする */\n" +" Py_ssize_t tp_weaklistoffset;\n" +"\n" +" /* イテレータ */\n" +" getiterfunc tp_iter;\n" +" iternextfunc tp_iternext;\n" +"\n" +" /* 属性デスクリプタとサブクラス化に関するもの */\n" +" PyMethodDef *tp_methods;\n" +" PyMemberDef *tp_members;\n" +" PyGetSetDef *tp_getset;\n" +" // ヒープ型では強参照、静的な型では借用参照\n" +" PyTypeObject *tp_base;\n" +" PyObject *tp_dict;\n" +" descrgetfunc tp_descr_get;\n" +" descrsetfunc tp_descr_set;\n" +" Py_ssize_t tp_dictoffset;\n" +" initproc tp_init;\n" +" allocfunc tp_alloc;\n" +" newfunc tp_new;\n" +" freefunc tp_free; /* 低レベルのメモリ解放ルーチン */\n" +" inquiry tp_is_gc; /* PyObject_IS_GC 用 */\n" +" PyObject *tp_bases;\n" +" PyObject *tp_mro; /* メソッド解決順序 */\n" +" PyObject *tp_cache; /* 現在は未使用 */\n" +" void *tp_subclasses; /* 静的な組み込み型ではインデックス */\n" +" PyObject *tp_weaklist; /* 静的な組み込み型では未使用 */\n" +" destructor tp_del;\n" +"\n" +" /* 型の属性キャッシュのバージョンタグ。バージョン 2.6 で追加。\n" +" * ゼロならキャッシュは無効であり、初期化が必要。\n" +" */\n" +" unsigned int tp_version_tag;\n" +"\n" +" destructor tp_finalize;\n" +" vectorcallfunc tp_vectorcall;\n" +"\n" +" /* この型に関心を持つ型ウォッチャーを表すビット集合 */\n" +" unsigned char tp_watched;\n" +"\n" +" /* 使用された tp_version_tag 値の数。\n" +" * 属性キャッシュがこの型で無効な場合は、\n" +" * _Py_ATTR_CACHE_UNUSED に設定する (独自の MRO エントリーなどによる)。\n" +" * それ以外の場合は MAX_VERSIONS_PER_CLASS (別の場所で定義) 以下。\n" +" */\n" +" uint16_t tp_versions_used;\n" +"} PyTypeObject;\n" #: ../../c-api/typeobj.rst:486 msgid "PyObject Slots" msgstr "PyObject スロット" -#: ../../c-api/typeobj.rst:488 msgid "" "The type object structure extends the :c:type:`PyVarObject` structure. The :" "c:member:`~PyVarObject.ob_size` field is used for dynamic types (created by :" @@ -1316,10 +1396,15 @@ msgid "" "tp_itemsize`, which means that its instances (i.e. type objects) *must* have " "the :c:member:`~PyVarObject.ob_size` field." msgstr "" +"型オブジェクトの構造体は :c:type:`PyVarObject` 構造体を拡張しています。\n" +":c:member:`~PyVarObject.ob_size` フィールドは動的な型 (:c:func:`!type_new` で" +"作成され、通常はクラス文から呼び出されるもの) に使われます。\n" +":c:data:`PyType_Type` (メタタイプ) は :c:member:`~PyTypeObject.tp_itemsize` " +"を初期化するため、そのインスタンス (型オブジェクト) には :c:member:" +"`~PyVarObject.ob_size` フィールドが **必要です**。" -#: ../../c-api/typeobj.rst:495 msgid ":c:member:`PyObject.ob_refcnt`" -msgstr "" +msgstr ":c:member:`PyObject.ob_refcnt`" #: ../../c-api/typeobj.rst:497 msgid "" @@ -1372,9 +1457,8 @@ msgstr "**継承:**" msgid "This field is not inherited by subtypes." msgstr "サブタイプはこのフィールドを継承しません。" -#: ../../c-api/typeobj.rst:509 msgid ":c:member:`PyObject.ob_type`" -msgstr "" +msgstr ":c:member:`PyObject.ob_type`" #: ../../c-api/typeobj.rst:511 msgid "" @@ -1399,13 +1483,17 @@ msgstr "" msgid "Foo_Type.ob_type = &PyType_Type;" msgstr "" -#: ../../c-api/typeobj.rst:522 msgid "" "This should be done before any instances of the type are created. :c:func:" "`PyType_Ready` checks if :c:member:`~PyObject.ob_type` is ``NULL``, and if " "so, initializes it to the :c:member:`~PyObject.ob_type` field of the base " "class. :c:func:`PyType_Ready` will not change this field if it is non-zero." msgstr "" +"これは型のインスタンスを作成する前に行うべきです。\n" +":c:func:`PyType_Ready` は :c:member:`~PyObject.ob_type` が ``NULL`` かどうか" +"を調べ、``NULL`` なら基底クラスの :c:member:`~PyObject.ob_type` フィールドの" +"値で初期化します。\n" +"ゼロでない場合、:c:func:`PyType_Ready` はこのフィールドを変更しません。" #: ../../c-api/typeobj.rst:529 ../../c-api/typeobj.rst:818 #: ../../c-api/typeobj.rst:945 ../../c-api/typeobj.rst:1045 @@ -1420,9 +1508,8 @@ msgstr "サブタイプはこのフィールドを継承します。" msgid "PyVarObject Slots" msgstr "PyVarObject スロット" -#: ../../c-api/typeobj.rst:535 msgid ":c:member:`PyVarObject.ob_size`" -msgstr "" +msgstr ":c:member:`PyVarObject.ob_size`" #: ../../c-api/typeobj.rst:537 msgid "" @@ -1435,29 +1522,32 @@ msgstr "" "クト ` の場合、このフィールドは内部使用される特殊な意味を持ちま" "す。" -#: ../../c-api/typeobj.rst:541 msgid "This field should be accessed using the :c:func:`Py_SIZE()` macro." -msgstr "" +msgstr "このフィールドには :c:func:`Py_SIZE()` マクロでアクセスするべきです。" #: ../../c-api/typeobj.rst:549 msgid "PyTypeObject Slots" msgstr "PyTypeObject スロット" -#: ../../c-api/typeobj.rst:551 msgid "" "Each slot has a section describing inheritance. If :c:func:`PyType_Ready` " "may set a value when the field is set to ``NULL`` then there will also be a " "\"Default\" section. (Note that many fields set on :c:data:" "`PyBaseObject_Type` and :c:data:`PyType_Type` effectively act as defaults.)" msgstr "" +"各スロットには継承についての説明があります。\n" +"フィールドが ``NULL`` のときに :c:func:`PyType_Ready` が値を設定する可能性が" +"ある場合は、「デフォルト」の説明もあります。\n" +":c:data:`PyBaseObject_Type` や :c:data:`PyType_Type` に設定された多くのフィー" +"ルドも、実質的にデフォルトとして働きます。" -#: ../../c-api/typeobj.rst:558 msgid "" "See :c:macro:`Py_tp_name` for the corresponding :c:member:`Slot ID `." msgstr "" +"対応する :c:member:`スロット ID ` は :c:macro:`Py_tp_name` を参" +"照してください。" -#: ../../c-api/typeobj.rst:561 msgid "" "Pointer to a NUL-terminated string containing the name of the type. For " "types that are accessible as module globals, the string should be the full " @@ -1468,6 +1558,15 @@ msgid "" "mod:`!Q` in package :mod:`!P` should have the :c:member:`~PyTypeObject." "tp_name` initializer ``\"P.Q.M.T\"``." msgstr "" +"型の名前を含む NUL 終端文字列へのポインタです。\n" +"モジュールのグローバル変数としてアクセスできる型では、完全なモジュール名、" +"ドット、型名の順で構成するべきです。\n" +"組み込み型では型名だけにします。\n" +"モジュールがパッケージのサブモジュールである場合、完全なモジュール名にはパッ" +"ケージの完全な名前も含まれます。\n" +"例えば、パッケージ :mod:`!P` のサブパッケージ :mod:`!Q` のモジュール :mod:`!" +"M` で定義された :class:`!T` という型では、:c:member:`~PyTypeObject.tp_name` " +"の初期値は ``\"P.Q.M.T\"`` にするべきです。" #: ../../c-api/typeobj.rst:569 msgid "" @@ -1479,13 +1578,16 @@ msgstr "" "ドは単に型の名前になり、モジュール名は型の辞書内でキー ``'__module__'`` に対" "する値として明示的に保存されます。" -#: ../../c-api/typeobj.rst:574 msgid "" "For :ref:`statically allocated type objects `, the *tp_name* " "field should contain a dot. Everything before the last dot is made " "accessible as the :attr:`~type.__module__` attribute, and everything after " "the last dot is made accessible as the :attr:`~type.__name__` attribute." msgstr "" +":ref:`静的に割り当てられた型オブジェクト ` では、*tp_name* " +"フィールドにドットを含めるべきです。\n" +"最後のドットより前の部分が :attr:`~type.__module__` 属性、後の部分が :attr:" +"`~type.__name__` 属性としてアクセス可能になります。" #: ../../c-api/typeobj.rst:580 msgid "" @@ -1497,12 +1599,14 @@ msgid "" "created with pydoc." msgstr "" -#: ../../c-api/typeobj.rst:586 msgid "" "This field must not be ``NULL``. It is the only required field in :c:func:" "`PyTypeObject` (other than potentially :c:member:`~PyTypeObject." "tp_itemsize`)." msgstr "" +"このフィールドは ``NULL`` にできません。\n" +":c:func:`PyTypeObject` で唯一必須のフィールドです (場合によっては :c:member:" +"`~PyTypeObject.tp_itemsize` も必要です)。" #: ../../c-api/typeobj.rst:598 msgid "" @@ -1510,14 +1614,15 @@ msgid "" msgstr "" "これらのフィールドは、型インスタンスのバイトサイズを計算できるようにします。" -#: ../../c-api/typeobj.rst:600 msgid "" "See :c:macro:`Py_tp_basicsize`, :c:macro:`Py_tp_extra_basicsize` and :c:" "macro:`Py_tp_itemsize` for the corresponding :c:member:`Slot IDs `." msgstr "" +"対応する :c:member:`スロット ID ` は :c:macro:" +"`Py_tp_basicsize`、:c:macro:`Py_tp_extra_basicsize`、:c:macro:" +"`Py_tp_itemsize` を参照してください。" -#: ../../c-api/typeobj.rst:604 msgid "" "There are two kinds of types: types with fixed-length instances have a zero :" "c:member:`!tp_itemsize` field, types with variable-length instances have a " @@ -1526,14 +1631,24 @@ msgid "" "tp_basicsize`. (Exceptions to this rule can be made using :c:func:" "`PyUnstable_Object_GC_NewWithExtraData`.)" msgstr "" +"型には 2 種類あります。\n" +"インスタンスが固定長の型では :c:member:`!tp_itemsize` フィールドがゼロで、可" +"変長の型では :c:member:`!tp_itemsize` フィールドがゼロ以外です。\n" +"固定長の型では、すべてのインスタンスのサイズは :c:member:`!tp_basicsize` で指" +"定された同じ値になります。\n" +":c:func:`PyUnstable_Object_GC_NewWithExtraData` を使うと、この規則の例外を作" +"れます。" -#: ../../c-api/typeobj.rst:611 msgid "" "For a type with variable-length instances, the instances must have an :c:" "member:`~PyVarObject.ob_size` field, and the instance size is :c:member:`!" "tp_basicsize` plus N times :c:member:`!tp_itemsize`, where N is the " "\"length\" of the object." msgstr "" +"可変長の型のインスタンスには :c:member:`~PyVarObject.ob_size` フィールドが必" +"要です。\n" +"インスタンスのサイズは :c:member:`!tp_basicsize` に :c:member:`!tp_itemsize` " +"の N 倍を加えた値で、N はオブジェクトの「長さ」です。" #: ../../c-api/typeobj.rst:616 msgid "" @@ -1546,13 +1661,13 @@ msgid "" "`PyLong_Export`." msgstr "" -#: ../../c-api/typeobj.rst:626 msgid "" "The :c:member:`~PyVarObject.ob_size` field should be accessed using the :c:" "func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros." msgstr "" +":c:member:`~PyVarObject.ob_size` フィールドには :c:func:`Py_SIZE()` マクロ" +"と :c:func:`Py_SET_SIZE()` マクロでアクセスするべきです。" -#: ../../c-api/typeobj.rst:629 msgid "" "Also, the presence of an :c:member:`~PyVarObject.ob_size` field in the " "instance layout doesn't mean that the instance structure is variable-length. " @@ -1561,14 +1676,20 @@ msgid "" "`int`, avoid reading lists' :c:member:`!ob_size` directly. Call :c:func:" "`PyList_Size` instead.)" msgstr "" +"また、インスタンスのレイアウトに :c:member:`~PyVarObject.ob_size` フィールド" +"があっても、その構造体が可変長であるとは限りません。\n" +"例えば :py:type:`list` 型のインスタンスは固定長ですが、:c:member:" +"`~PyVarObject.ob_size` フィールドを持ちます。\n" +":py:type:`int` と同様に、リストの :c:member:`!ob_size` を直接読むのは避け、代" +"わりに :c:func:`PyList_Size` を呼び出してください。" -#: ../../c-api/typeobj.rst:636 msgid "" "The :c:member:`!tp_basicsize` includes size needed for data of the type's :c:" "member:`~PyTypeObject.tp_base`, plus any extra data needed by each instance." msgstr "" +":c:member:`!tp_basicsize` には、その型の :c:member:`~PyTypeObject.tp_base` の" +"データに必要なサイズと、各インスタンスに必要な追加データのサイズを含めます。" -#: ../../c-api/typeobj.rst:640 msgid "" "The correct way to set :c:member:`!tp_basicsize` is to use the ``sizeof`` " "operator on the struct used to declare the instance layout. This struct must " @@ -1576,8 +1697,12 @@ msgid "" "`!tp_basicsize` must be greater than or equal to the base's :c:member:`!" "tp_basicsize`." msgstr "" +":c:member:`!tp_basicsize` を正しく設定するには、インスタンスのレイアウトを宣" +"言する構造体に ``sizeof`` 演算子を使います。\n" +"この構造体は、基底型を宣言する構造体を含んでいなければなりません。\n" +"つまり :c:member:`!tp_basicsize` は、基底型の :c:member:`!tp_basicsize` 以上" +"でなければなりません。" -#: ../../c-api/typeobj.rst:646 msgid "" "Since every type is a subtype of :py:type:`object`, this struct must " "include :c:type:`PyObject` or :c:type:`PyVarObject` (depending on whether :c:" @@ -1585,24 +1710,29 @@ msgid "" "by the macro :c:macro:`PyObject_HEAD` or :c:macro:`PyObject_VAR_HEAD`, " "respectively." msgstr "" +"すべての型は :py:type:`object` のサブタイプなので、この構造体には :c:type:" +"`PyObject` または :c:type:`PyVarObject` を含める必要があります (:c:member:" +"`~PyVarObject.ob_size` を含めるかどうかによります)。\n" +"通常はそれぞれ :c:macro:`PyObject_HEAD` マクロまたは :c:macro:" +"`PyObject_VAR_HEAD` マクロで定義します。" -#: ../../c-api/typeobj.rst:652 msgid "" "The basic size does not include the GC header size, as that header is not " "part of :c:macro:`PyObject_HEAD`." msgstr "" +"GC ヘッダーは :c:macro:`PyObject_HEAD` の一部ではないため、そのサイズは基本サ" +"イズに含めません。" -#: ../../c-api/typeobj.rst:655 msgid "" "For cases where struct used to declare the base type is unknown, see :c:" "member:`PyType_Spec.basicsize` and :c:func:`PyType_FromMetaclass`." msgstr "" +"基底型を宣言する構造体が不明な場合は、:c:member:`PyType_Spec.basicsize` と :" +"c:func:`PyType_FromMetaclass` を参照してください。" -#: ../../c-api/typeobj.rst:658 msgid "Notes about alignment:" -msgstr "" +msgstr "アラインメントに関する注意事項:" -#: ../../c-api/typeobj.rst:660 msgid "" ":c:member:`!tp_basicsize` must be a multiple of ``_Alignof(PyObject)``. When " "using ``sizeof`` on a ``struct`` that includes :c:macro:`PyObject_HEAD`, as " @@ -1610,56 +1740,75 @@ msgid "" "when using compiler extensions like ``__attribute__((packed))``, it is up to " "you." msgstr "" +":c:member:`!tp_basicsize` は ``_Alignof(PyObject)`` の倍数でなければなりませ" +"ん。\n" +"推奨どおり :c:macro:`PyObject_HEAD` を含む ``struct`` に ``sizeof`` を使え" +"ば、コンパイラがこれを保証します。\n" +"C の ``struct`` を使わない場合や、``__attribute__((packed))`` などのコンパイ" +"ラ拡張を使う場合は、自分で保証する必要があります。" -#: ../../c-api/typeobj.rst:665 msgid "" "If the variable items require a particular alignment, :c:member:`!" "tp_basicsize` and :c:member:`!tp_itemsize` must each be a multiple of that " "alignment. For example, if a type's variable part stores a ``double``, it is " "your responsibility that both fields are a multiple of ``_Alignof(double)``." msgstr "" +"可変部分の要素に特定のアラインメントが必要な場合、:c:member:`!tp_basicsize` " +"と :c:member:`!tp_itemsize` はそれぞれそのアラインメントの倍数でなければなり" +"ません。\n" +"例えば可変部分に ``double`` を格納する型では、両フィールドが " +"``_Alignof(double)`` の倍数になるようにする責任があります。" -#: ../../c-api/typeobj.rst:674 msgid "" "These fields are inherited separately by subtypes. (That is, if the field is " "set to zero, :c:func:`PyType_Ready` will copy the value from the base type, " "indicating that the instances do not need additional storage.)" msgstr "" +"これらのフィールドはサブタイプに個別に継承されます。\n" +"フィールドがゼロに設定されている場合、:c:func:`PyType_Ready` は基底型から値を" +"コピーし、インスタンスに追加の格納領域が不要であることを表します。" -#: ../../c-api/typeobj.rst:679 msgid "" "If the base type has a non-zero :c:member:`~PyTypeObject.tp_itemsize`, it is " "generally not safe to set :c:member:`~PyTypeObject.tp_itemsize` to a " "different non-zero value in a subtype (though this depends on the " "implementation of the base type)." msgstr "" +"基底型の :c:member:`~PyTypeObject.tp_itemsize` がゼロ以外の場合、サブタイプ" +"の :c:member:`~PyTypeObject.tp_itemsize` を別のゼロ以外の値に設定するのは、一" +"般に安全ではありません (ただし、基底型の実装によります)。" -#: ../../c-api/typeobj.rst:688 msgid "" "A pointer to the instance destructor function. The function signature is::" msgstr "" +"インスタンスのデストラクタ関数へのポインタです。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/typeobj.rst:690 msgid "void tp_dealloc(PyObject *self);" -msgstr "" +msgstr "void tp_dealloc(PyObject *self);" -#: ../../c-api/typeobj.rst:692 msgid "" "The destructor function should remove all references which the instance owns " "(e.g., call :c:func:`Py_CLEAR`), free all memory buffers owned by the " "instance, and call the type's :c:member:`~PyTypeObject.tp_free` function to " "free the object itself." msgstr "" +"デストラクタ関数は、インスタンスが所有するすべての参照を取り除き (例えば :c:" +"func:`Py_CLEAR` を呼び出します)、インスタンスが所有するすべてのメモリバッファ" +"を解放し、型の :c:member:`~PyTypeObject.tp_free` 関数を呼び出してオブジェクト" +"自体を解放する必要があります。" -#: ../../c-api/typeobj.rst:697 msgid "" "If you may call functions that may set the error indicator, you must use :c:" "func:`PyErr_GetRaisedException` and :c:func:`PyErr_SetRaisedException` to " "ensure you don't clobber a preexisting error indicator (the deallocation " "could have occurred while processing a different error):" msgstr "" +"エラーインジケータを設定する可能性のある関数を呼び出す場合は、:c:func:" +"`PyErr_GetRaisedException` と :c:func:`PyErr_SetRaisedException` を使い、既存" +"のエラーインジケータを上書きしないようにしなければなりません。\n" +"別のエラーの処理中に解放が起きた可能性があるためです。" -#: ../../c-api/typeobj.rst:702 msgid "" "static void\n" "foo_dealloc(foo_object *self)\n" @@ -1670,70 +1819,97 @@ msgid "" " PyErr_SetRaisedException(exc);\n" "}" msgstr "" +"static void\n" +"foo_dealloc(foo_object *self)\n" +"{\n" +" PyObject *et, *ev, *etb;\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +" ...\n" +" PyErr_SetRaisedException(exc);\n" +"}" -#: ../../c-api/typeobj.rst:713 msgid "" "The dealloc handler itself must not raise an exception; if it hits an error " "case it should call :c:func:`PyErr_FormatUnraisable` to log (and clear) an " "unraisable exception." msgstr "" +"解放ハンドラ自体が例外を送出してはいけません。\n" +"エラーが起きた場合は、:c:func:`PyErr_FormatUnraisable` を呼び出して伝播できな" +"い例外を記録し、クリアするべきです。" -#: ../../c-api/typeobj.rst:717 msgid "No guarantees are made about when an object is destroyed, except:" msgstr "" +"オブジェクトが破棄される時点については、次の事項を除いて保証はありません。" -#: ../../c-api/typeobj.rst:719 msgid "" "Python will destroy an object immediately or some time after the final " "reference to the object is deleted, unless its finalizer (:c:member:" "`~PyTypeObject.tp_finalize`) subsequently resurrects the object." msgstr "" +"Python は、オブジェクトへの最後の参照が削除された直後か、その後のどこかの時点" +"でオブジェクトを破棄します。\n" +"ただし、ファイナライザ (:c:member:`~PyTypeObject.tp_finalize`) がその後オブ" +"ジェクトを復活させる場合は除きます。" -#: ../../c-api/typeobj.rst:723 msgid "" "An object will not be destroyed while it is being automatically finalized (:" "c:member:`~PyTypeObject.tp_finalize`) or automatically cleared (:c:member:" "`~PyTypeObject.tp_clear`)." msgstr "" +"オブジェクトが自動的にファイナライズ (:c:member:`~PyTypeObject.tp_finalize`) " +"またはクリア (:c:member:`~PyTypeObject.tp_clear`) されている間は、そのオブ" +"ジェクトは破棄されません。" -#: ../../c-api/typeobj.rst:727 msgid "" "CPython currently destroys an object immediately from :c:func:`Py_DECREF` " "when the new reference count is zero, but this may change in a future " "version." msgstr "" +"現在の CPython は、:c:func:`Py_DECREF` によって参照カウントがゼロになると、そ" +"の呼び出しから直ちにオブジェクトを破棄します。\n" +"ただし、将来のバージョンでは変更される可能性があります。" -#: ../../c-api/typeobj.rst:731 msgid "" "It is recommended to call :c:func:`PyObject_CallFinalizerFromDealloc` at the " "beginning of :c:member:`!tp_dealloc` to guarantee that the object is always " "finalized before destruction." msgstr "" +"オブジェクトが破棄前に必ずファイナライズされるように、:c:member:`!" +"tp_dealloc` の冒頭で :c:func:`PyObject_CallFinalizerFromDealloc` を呼び出すこ" +"とを推奨します。" -#: ../../c-api/typeobj.rst:735 msgid "" "If the type supports garbage collection (the :c:macro:`Py_TPFLAGS_HAVE_GC` " "flag is set), the destructor should call :c:func:`PyObject_GC_UnTrack` " "before clearing any member fields." msgstr "" +"型がガベージコレクションをサポートする場合 (:c:macro:`Py_TPFLAGS_HAVE_GC` フ" +"ラグが設定されている場合)、デストラクタはメンバーフィールドをクリアする前に :" +"c:func:`PyObject_GC_UnTrack` を呼び出すべきです。" -#: ../../c-api/typeobj.rst:739 msgid "" "It is permissible to call :c:member:`~PyTypeObject.tp_clear` from :c:member:" "`!tp_dealloc` to reduce code duplication and to guarantee that the object is " "always cleared before destruction. Beware that :c:member:`!tp_clear` might " "have already been called." msgstr "" +"コードの重複を減らし、破棄前にオブジェクトが必ずクリアされるようにするため、:" +"c:member:`!tp_dealloc` から :c:member:`~PyTypeObject.tp_clear` を呼び出しても" +"構いません。\n" +":c:member:`!tp_clear` はすでに呼び出されている可能性がある点に注意してくださ" +"い。" -#: ../../c-api/typeobj.rst:744 msgid "" "If the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the " "deallocator should release the owned reference to its type object (via :c:" "func:`Py_DECREF`) after calling the type deallocator. See the example code " "below.::" msgstr "" +"型がヒープに割り当てられている場合 (:c:macro:`Py_TPFLAGS_HEAPTYPE`)、解放関数" +"は型の解放関数を呼び出した後、型オブジェクトへの所有する参照を :c:func:" +"`Py_DECREF` で解放するべきです。\n" +"以下のコード例を参照してください。 ::" -#: ../../c-api/typeobj.rst:749 msgid "" "static void\n" "foo_dealloc(PyObject *op)\n" @@ -1744,20 +1920,30 @@ msgid "" " Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" +"static void\n" +"foo_dealloc(PyObject *op)\n" +"{\n" +" foo_object *self = (foo_object *) op;\n" +" PyObject_GC_UnTrack(self);\n" +" Py_CLEAR(self->ref);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" -#: ../../c-api/typeobj.rst:758 msgid "" ":c:member:`!tp_dealloc` must leave the exception status unchanged. If it " "needs to call something that might raise an exception, the exception state " "must be backed up first and restored later (after logging any exceptions " "with :c:func:`PyErr_WriteUnraisable`)." msgstr "" +":c:member:`!tp_dealloc` は例外の状態を変えてはいけません。\n" +"例外を送出する可能性のある処理を呼び出す必要がある場合は、先に例外の状態を保" +"存し、発生した例外を :c:func:`PyErr_WriteUnraisable` で記録した後に復元しなけ" +"ればなりません。" #: ../../c-api/typeobj.rst:763 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../c-api/typeobj.rst:765 msgid "" "static void\n" "foo_dealloc(PyObject *self)\n" @@ -1798,8 +1984,45 @@ msgid "" " PyErr_SetRaisedException(exc);\n" "}" msgstr "" +"static void\n" +"foo_dealloc(PyObject *self)\n" +"{\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +"\n" +" if (PyObject_CallFinalizerFromDealloc(self) < 0) {\n" +" // self が復活した。\n" +" goto done;\n" +" }\n" +"\n" +" PyTypeObject *tp = Py_TYPE(self);\n" +"\n" +" if (tp->tp_flags & Py_TPFLAGS_HAVE_GC) {\n" +" PyObject_GC_UnTrack(self);\n" +" }\n" +"\n" +" // 任意だが、コードの重複を避けるのに便利。\n" +" if (tp->tp_clear && tp->tp_clear(self) < 0) {\n" +" PyErr_WriteUnraisable(self);\n" +" }\n" +"\n" +" // 追加の破棄処理をここで行う。\n" +"\n" +" tp->tp_free(self);\n" +" self = NULL; // 後で PyErr_WriteUnraisable() が呼ばれる場合に備える。\n" +"\n" +" if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" +" Py_CLEAR(tp);\n" +" }\n" +"\n" +"done:\n" +" // 例外を送出する可能性のある処理を呼び出した場合に、\n" +" // 必要に応じて行う。\n" +" if (PyErr_Occurred()) {\n" +" PyErr_WriteUnraisable(self);\n" +" }\n" +" PyErr_SetRaisedException(exc);\n" +"}" -#: ../../c-api/typeobj.rst:804 msgid "" ":c:member:`!tp_dealloc` may be called from any Python thread, not just the " "thread which created the object (if the object becomes part of a refcount " @@ -1811,49 +2034,71 @@ msgid "" "those objects on the thread which called :c:member:`!tp_dealloc` will not " "violate any assumptions of the library." msgstr "" +":c:member:`!tp_dealloc` は、オブジェクトを作成したスレッドに限らず、どの " +"Python スレッドからも呼び出される可能性があります。\n" +"例えば、オブジェクトが循環参照の一部になった場合、その循環参照はどのスレッド" +"のガベージコレクションでも回収され得ます。\n" +":c:member:`!tp_dealloc` を呼び出すスレッドには :term:`アタッチされたスレッド" +"状態 ` があるため、Python API の呼び出しには問題ありま" +"せん。\n" +"ただし、破棄するオブジェクトが別の C ライブラリのオブジェクトも破棄する場合" +"は、:c:member:`!tp_dealloc` を呼び出したスレッドでの破棄が、そのライブラリの" +"前提を破らないよう注意が必要です。" -#: ../../c-api/typeobj.rst:822 ../../c-api/typeobj.rst:1739 -#: ../../c-api/typeobj.rst:2502 msgid "" ":ref:`life-cycle` for details about how this slot relates to other slots." msgstr "" +"このスロットと他のスロットの関係の詳細は :ref:`life-cycle` を参照してくださ" +"い。" -#: ../../c-api/typeobj.rst:827 msgid "" "An optional offset to a per-instance function that implements calling the " "object using the :ref:`vectorcall protocol `, a more efficient " "alternative of the simpler :c:member:`~PyTypeObject.tp_call`." msgstr "" +"より単純な :c:member:`~PyTypeObject.tp_call` より効率的な :ref:`vectorcall プ" +"ロトコル ` を使ってオブジェクトの呼び出しを実装する、インスタンス" +"ごとの関数への省略可能なオフセットです。" -#: ../../c-api/typeobj.rst:832 msgid "" "This field is only used if the flag :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` is " "set. If so, this must be a positive integer containing the offset in the " "instance of a :c:type:`vectorcallfunc` pointer." msgstr "" +"このフィールドは :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` フラグが設定されている" +"場合にのみ使われます。\n" +"その場合、インスタンス内の :c:type:`vectorcallfunc` ポインタのオフセットを表" +"す正の整数でなければなりません。" -#: ../../c-api/typeobj.rst:836 msgid "" "The *vectorcallfunc* pointer may be ``NULL``, in which case the instance " "behaves as if :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` was not set: calling the " "instance falls back to :c:member:`~PyTypeObject.tp_call`." msgstr "" +"*vectorcallfunc* ポインタは ``NULL`` にできます。\n" +"その場合、インスタンスは :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` が設定されてい" +"ないかのように動作し、呼び出しは :c:member:`~PyTypeObject.tp_call` にフォール" +"バックします。" -#: ../../c-api/typeobj.rst:840 msgid "" "Any class that sets ``Py_TPFLAGS_HAVE_VECTORCALL`` must also set :c:member:" "`~PyTypeObject.tp_call` and make sure its behaviour is consistent with the " "*vectorcallfunc* function. This can be done by setting *tp_call* to :c:func:" "`PyVectorcall_Call`." msgstr "" +"``Py_TPFLAGS_HAVE_VECTORCALL`` を設定するクラスでは、:c:member:" +"`~PyTypeObject.tp_call` も設定し、その動作が *vectorcallfunc* 関数と一致する" +"ようにしなければなりません。\n" +"*tp_call* を :c:func:`PyVectorcall_Call` に設定すれば実現できます。" -#: ../../c-api/typeobj.rst:847 msgid "" "Before version 3.8, this slot was named ``tp_print``. In Python 2.x, it was " "used for printing to a file. In Python 3.0 to 3.7, it was unused." msgstr "" +"バージョン 3.8 より前では、このスロットの名前は ``tp_print`` でした。\n" +"Python 2.x ではファイルへの出力に使われ、Python 3.0 から 3.7 では使われていま" +"せんでした。" -#: ../../c-api/typeobj.rst:853 msgid "" "Before version 3.12, it was not recommended for :ref:`mutable heap types " "` to implement the vectorcall protocol. When a user sets :attr:" @@ -1862,14 +2107,24 @@ msgid "" "``__call__`` will disable vectorcall optimization by clearing the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag." msgstr "" +"バージョン 3.12 より前では、:ref:`変更可能なヒープ型 ` による " +"vectorcall プロトコルの実装は推奨されていませんでした。\n" +"利用者が Python コードで :attr:`~object.__call__` を設定すると *tp_call* だけ" +"が更新され、vectorcall 関数と不整合になる可能性が高いためです。\n" +"3.12 以降は、``__call__`` を設定すると :c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` " +"フラグがクリアされ、vectorcall による最適化が無効になります。" -#: ../../c-api/typeobj.rst:863 msgid "" "This field is always inherited. However, the :c:macro:" "`Py_TPFLAGS_HAVE_VECTORCALL` flag is not always inherited. If it's not set, " "then the subclass won't use :ref:`vectorcall `, except when :c:" "func:`PyVectorcall_Call` is explicitly called." msgstr "" +"このフィールドは常に継承されます。\n" +"ただし、:c:macro:`Py_TPFLAGS_HAVE_VECTORCALL` フラグが常に継承されるとは限り" +"ません。\n" +"そのフラグがなければ、:c:func:`PyVectorcall_Call` を明示的に呼び出す場合を除" +"いて、サブクラスは :ref:`vectorcall ` を使いません。" #: ../../c-api/typeobj.rst:874 msgid "An optional pointer to the get-attribute-string function." @@ -1887,11 +2142,12 @@ msgstr "" "同じように動作し、属性名は Python 文字列 オブジェクトではなく C 文字列で指定" "するような関数を指すようにしなければなりません。" -#: ../../c-api/typeobj.rst:882 ../../c-api/typeobj.rst:1090 msgid "" "Group: :c:member:`~PyTypeObject.tp_getattr`, :c:member:`~PyTypeObject." "tp_getattro`" msgstr "" +"グループ: :c:member:`~PyTypeObject.tp_getattr`、:c:member:`~PyTypeObject." +"tp_getattro`" #: ../../c-api/typeobj.rst:884 msgid "" @@ -1924,11 +2180,12 @@ msgstr "" "同じように動作し、属性名は Python 文字列 オブジェクトではなく C 文字列で指定" "するような関数を指すようにしなければなりません。" -#: ../../c-api/typeobj.rst:901 ../../c-api/typeobj.rst:1118 msgid "" "Group: :c:member:`~PyTypeObject.tp_setattr`, :c:member:`~PyTypeObject." "tp_setattro`" msgstr "" +"グループ: :c:member:`~PyTypeObject.tp_setattr`、:c:member:`~PyTypeObject." +"tp_setattro`" #: ../../c-api/typeobj.rst:903 msgid "" @@ -1976,15 +2233,12 @@ msgstr "" "オプションのポインタで、組み込み関数 :func:`repr` を実装している関数を指しま" "す。" -#: ../../c-api/typeobj.rst:932 msgid "The signature is the same as for :c:func:`PyObject_Repr`::" -msgstr "" +msgstr "シグネチャは :c:func:`PyObject_Repr` と同じです。 ::" -#: ../../c-api/typeobj.rst:934 msgid "PyObject *tp_repr(PyObject *self);" -msgstr "" +msgstr "PyObject *tp_repr(PyObject *self);" -#: ../../c-api/typeobj.rst:936 msgid "" "The function must return a string or a Unicode object. Ideally, this " "function should return a string that, when passed to :func:`eval`, given a " @@ -1992,11 +2246,12 @@ msgid "" "feasible, it should return a string starting with ``'<'`` and ending with " "``'>'`` from which both the type and the value of the object can be deduced." msgstr "" -"この関数は文字列オブジェクトか Unicode オブジェクトを返さなければなりません。" -"理想的には、この関数が返す文字列は、適切な環境で :func:`eval` に渡した場合、" -"同じ値を持つオブジェクトになるような文字列でなければなりません。不可能な場合" -"には、オブジェクトの型と値から導出した内容の入った ``'<'`` から始まって " -"``'>'`` で終わる文字列を返さなければなりません。" +"この関数は文字列オブジェクトか Unicode オブジェクトを返さなければなりませ" +"ん。\n" +"理想的には、適切な環境で :func:`eval` に渡すと同じ値のオブジェクトが得られる" +"文字列を返すべきです。\n" +"それが難しい場合は、型と値を読み取れる、``'<'`` で始まり ``'>'`` で終わる文字" +"列を返すべきです。" #: ../../c-api/typeobj.rst:947 ../../c-api/typeobj.rst:1028 #: ../../c-api/typeobj.rst:1069 ../../c-api/typeobj.rst:1096 @@ -2078,13 +2333,11 @@ msgstr "" "オプションのポインタで、組み込み関数 :func:`hash` を実装している関数を指しま" "す。" -#: ../../c-api/typeobj.rst:999 msgid "The signature is the same as for :c:func:`PyObject_Hash`::" -msgstr "" +msgstr "シグネチャは :c:func:`PyObject_Hash` と同じです。 ::" -#: ../../c-api/typeobj.rst:1001 msgid "Py_hash_t tp_hash(PyObject *);" -msgstr "" +msgstr "Py_hash_t tp_hash(PyObject *);" #: ../../c-api/typeobj.rst:1003 msgid "" @@ -2095,13 +2348,16 @@ msgstr "" "通常時には ``-1`` を戻り値にしてはなりません; ハッシュ値の計算中にエラーが生" "じた場合、関数は例外をセットして ``-1`` を返さねばなりません。" -#: ../../c-api/typeobj.rst:1007 msgid "" "When this field is not set (*and* :c:member:`~PyTypeObject.tp_richcompare` " "is not set), an attempt to take the hash of the object raises :exc:" "`TypeError`. This is the same as setting it to :c:func:" "`PyObject_HashNotImplemented`." msgstr "" +"このフィールドが設定されておらず、:c:member:`~PyTypeObject.tp_richcompare` *" +"も* 設定されていない場合、オブジェクトのハッシュを求めると :exc:`TypeError` " +"が送出されます。\n" +":c:func:`PyObject_HashNotImplemented` を設定した場合と同じです。" #: ../../c-api/typeobj.rst:1011 msgid "" @@ -2121,11 +2377,12 @@ msgstr "" "ことで ``tp_hash`` スロットは :c:func:`PyObject_HashNotImplemented` に設定さ" "れます。" -#: ../../c-api/typeobj.rst:1021 ../../c-api/typeobj.rst:1797 msgid "" "Group: :c:member:`~PyTypeObject.tp_hash`, :c:member:`~PyTypeObject." "tp_richcompare`" msgstr "" +"グループ: :c:member:`~PyTypeObject.tp_hash`、:c:member:`~PyTypeObject." +"tp_richcompare`" #: ../../c-api/typeobj.rst:1023 msgid "" @@ -2141,23 +2398,22 @@ msgstr "" "のとき、サブタイプは基底タイプから :c:member:`~PyTypeObject.tp_richcompare` " "と :c:member:`~PyTypeObject.tp_hash` を両方とも継承します。" -#: ../../c-api/typeobj.rst:1030 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericHash`." msgstr "" +":c:data:`PyBaseObject_Type` は :c:func:`PyObject_GenericHash` を使います。" -#: ../../c-api/typeobj.rst:1037 msgid "" "An optional pointer to a function that implements calling the object. This " "should be ``NULL`` if the object is not callable. The signature is the same " "as for :c:func:`PyObject_Call`::" msgstr "" -"オプションのポインタで、オブジェクトの呼び出しを実装している関数を指します。" -"オブジェクトが呼び出し可能でない場合には ``NULL`` にしなければなりません。シ" -"グネチャは :c:func:`PyObject_Call` と同じです。" +"オプションのポインタで、オブジェクトの呼び出しを実装している関数を指しま" +"す。\n" +"オブジェクトが呼び出し可能でない場合には ``NULL`` にしなければなりません。\n" +"シグネチャは :c:func:`PyObject_Call` と同じです。 ::" -#: ../../c-api/typeobj.rst:1041 msgid "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" -msgstr "" +msgstr "PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);" #: ../../c-api/typeobj.rst:1052 msgid "" @@ -2168,18 +2424,16 @@ msgid "" "this handler.)" msgstr "" "オプションのポインタで、組み込みの演算 :func:`str` を実装している関数を指しま" -"す。(:class:`str` が型の一つになったため、 :func:`str` は :class:`str` のコン" -"ストラクタを呼び出すことに注意してください。このコンストラクタは実際の処理を" -"行う上で :c:func:`PyObject_Str` を呼び出し、さらに :c:func:`PyObject_Str` が" -"このハンドラを呼び出すことになります。)" +"す。(:class:`str` が型の一つになったため、 :func:`str` は ``str`` のコンスト" +"ラクタを呼び出すことに注意してください。このコンストラクタは実際の処理を行う" +"上で :c:func:`PyObject_Str` を呼び出し、さらに :c:func:`PyObject_Str` がこの" +"ハンドラを呼び出すことになります。)" -#: ../../c-api/typeobj.rst:1057 msgid "The signature is the same as for :c:func:`PyObject_Str`::" -msgstr "" +msgstr "シグネチャは :c:func:`PyObject_Str` と同じです。 ::" -#: ../../c-api/typeobj.rst:1059 msgid "PyObject *tp_str(PyObject *self);" -msgstr "" +msgstr "PyObject *tp_str(PyObject *self);" #: ../../c-api/typeobj.rst:1061 msgid "" @@ -2205,13 +2459,11 @@ msgstr "" msgid "An optional pointer to the get-attribute function." msgstr "オプションのポインタで、get-attribute を実装している関数を指します。" -#: ../../c-api/typeobj.rst:1081 msgid "The signature is the same as for :c:func:`PyObject_GetAttr`::" -msgstr "" +msgstr "シグネチャは :c:func:`PyObject_GetAttr` と同じです。 ::" -#: ../../c-api/typeobj.rst:1083 msgid "PyObject *tp_getattro(PyObject *self, PyObject *attr);" -msgstr "" +msgstr "PyObject *tp_getattro(PyObject *self, PyObject *attr);" #: ../../c-api/typeobj.rst:1085 msgid "" @@ -2236,17 +2488,15 @@ msgstr "" "基底タイプから :c:member:`~PyTypeObject.tp_getattr` と :c:member:" "`~PyTypeObject.tp_getattro` を両方とも継承します。" -#: ../../c-api/typeobj.rst:1098 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericGetAttr`." msgstr "" +":c:data:`PyBaseObject_Type` は :c:func:`PyObject_GenericGetAttr` を使います。" -#: ../../c-api/typeobj.rst:1107 msgid "The signature is the same as for :c:func:`PyObject_SetAttr`::" -msgstr "" +msgstr "シグネチャは :c:func:`PyObject_SetAttr` と同じです。 ::" -#: ../../c-api/typeobj.rst:1109 msgid "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" -msgstr "" +msgstr "int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);" #: ../../c-api/typeobj.rst:1111 msgid "" @@ -2274,9 +2524,9 @@ msgstr "" "基底タイプから :c:member:`~PyTypeObject.tp_setattr` と :c:member:" "`~PyTypeObject.tp_setattro` を両方とも継承します。" -#: ../../c-api/typeobj.rst:1126 msgid ":c:data:`PyBaseObject_Type` uses :c:func:`PyObject_GenericSetAttr`." msgstr "" +":c:data:`PyBaseObject_Type` は :c:func:`PyObject_GenericSetAttr` を使います。" #: ../../c-api/typeobj.rst:1131 msgid "" @@ -2296,11 +2546,12 @@ msgstr "" ":c:member:`~PyTypeObject.tp_as_buffer` フィールド自体は継承されませんが、これ" "に含まれるフィールドは個別に継承されます。" -#: ../../c-api/typeobj.rst:1143 msgid "" "See :c:macro:`Py_tp_flags` for the corresponding :c:member:`Slot ID `." msgstr "" +"対応する :c:member:`スロット ID ` は :c:macro:`Py_tp_flags` を" +"参照してください。" #: ../../c-api/typeobj.rst:1146 msgid "" @@ -2323,7 +2574,6 @@ msgstr "" "がクリアされていれば、フラグが保護しているフィールドにはアクセスしない代わり" "に、その値はゼロか ``NULL`` になっているとみなさなければなりません。" -#: ../../c-api/typeobj.rst:1156 msgid "" "Inheritance of this field is complicated. Most flag bits are inherited " "individually, i.e. if the base type has a flag bit set, the subtype inherits " @@ -2337,16 +2587,29 @@ msgid "" "`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` fields in " "the subtype exist and have ``NULL`` values." msgstr "" +"このフィールドの継承規則は複雑です。\n" +"ほとんどのフラグビットは個別に継承されます。\n" +"つまり基底型にフラグビットが設定されていれば、サブタイプにも継承されます。\n" +"拡張構造体に関するフラグビットは、その構造体が継承される場合に限って継承され" +"ます。\n" +"基底型のフラグビットの値が、拡張構造体へのポインタとともにサブタイプにコピー" +"されます。\n" +":c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットは :c:member:`~PyTypeObject." +"tp_traverse` フィールドおよび :c:member:`~PyTypeObject.tp_clear` フィールドと" +"まとめて継承されます。\n" +"これは、サブタイプの :c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットがクリアされて" +"おり、:c:member:`~PyTypeObject.tp_traverse` と :c:member:`~PyTypeObject." +"tp_clear` が存在して、どちらも ``NULL`` の場合です。" -#: ../../c-api/typeobj.rst:1171 msgid "" ":c:data:`PyBaseObject_Type` uses ``Py_TPFLAGS_DEFAULT | " "Py_TPFLAGS_BASETYPE``." msgstr "" +":c:data:`PyBaseObject_Type` は ``Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE`` " +"を使います。" -#: ../../c-api/typeobj.rst:1174 msgid "**Bit Masks:**" -msgstr "" +msgstr "**ビットマスク:**" #: ../../c-api/typeobj.rst:1178 msgid "" @@ -2361,7 +2624,6 @@ msgstr "" "す。 :c:func:`PyType_HasFeature` マクロは型とフラグ値、 *tp* および *f* をと" "り、 ``tp->tp_flags & f`` が非ゼロかどうか調べます。" -#: ../../c-api/typeobj.rst:1185 msgid "" "This bit is set when the type object itself is allocated on the heap, for " "example, types created dynamically using :c:func:`PyType_FromSpec`. In this " @@ -2373,6 +2635,17 @@ msgid "" "`support garbage collection ` as they can form a " "reference cycle with their own module object." msgstr "" +"型オブジェクト自体がヒープに割り当てられた場合に設定されるビットです。\n" +"例えば :c:func:`PyType_FromSpec` で動的に作成された型が該当します。\n" +"この場合、インスタンスの :c:member:`~PyObject.ob_type` フィールドは型への参照" +"とみなされ、新しいインスタンスの作成時に型オブジェクトが INCREF され、インス" +"タンスの破棄時に DECREF されます。\n" +"これはサブタイプのインスタンスには適用されません。\n" +"INCREF や DECREF の対象になるのは、インスタンスの ``ob_type`` が参照する型だ" +"けです。\n" +"ヒープ型は自身のモジュールオブジェクトと循環参照を形成する可能性があるため、:" +"ref:`ガベージコレクションをサポート ` するべきで" +"す。" #: ../../c-api/typeobj.rst:1196 ../../c-api/typeobj.rst:1207 #: ../../c-api/typeobj.rst:1217 ../../c-api/typeobj.rst:1227 @@ -2406,7 +2679,6 @@ msgstr "" ":c:func:`PyType_Ready` による型オブジェクトの初期化処理中にセットされるビット" "です。" -#: ../../c-api/typeobj.rst:1232 msgid "" "This bit is set when the object supports garbage collection. If this bit is " "set, memory for new instances (see :c:member:`~PyTypeObject.tp_alloc`) must " @@ -2415,15 +2687,22 @@ msgid "" "tp_free`) using :c:func:`PyObject_GC_Del`. More information in section :ref:" "`supporting-cycle-detection`." msgstr "" +"オブジェクトがガベージコレクションをサポートする場合に設定されるビットで" +"す。\n" +"設定する場合、新しいインスタンスのメモリ (:c:member:`~PyTypeObject.tp_alloc` " +"を参照) は :c:macro:`PyObject_GC_New` または :c:func:`PyType_GenericAlloc` で" +"割り当て、\n" +":c:func:`PyObject_GC_Del` で解放しなければなりません (:c:member:" +"`~PyTypeObject.tp_free` を参照)。\n" +"詳細は :ref:`supporting-cycle-detection` を参照してください。" -#: ../../c-api/typeobj.rst:1241 ../../c-api/typeobj.rst:1584 -#: ../../c-api/typeobj.rst:1730 msgid "" "Group: :c:macro:`Py_TPFLAGS_HAVE_GC`, :c:member:`~PyTypeObject." "tp_traverse`, :c:member:`~PyTypeObject.tp_clear`" msgstr "" +"グループ: :c:macro:`Py_TPFLAGS_HAVE_GC`、:c:member:`~PyTypeObject." +"tp_traverse`、:c:member:`~PyTypeObject.tp_clear`" -#: ../../c-api/typeobj.rst:1243 msgid "" "The :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is inherited together with the :c:" "member:`~PyTypeObject.tp_traverse` and :c:member:`~PyTypeObject.tp_clear` " @@ -2432,121 +2711,151 @@ msgid "" "`~PyTypeObject.tp_clear` fields in the subtype exist and have ``NULL`` " "values." msgstr "" +":c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットは :c:member:`~PyTypeObject." +"tp_traverse` フィールドおよび :c:member:`~PyTypeObject.tp_clear` フィールドと" +"まとめて継承されます。\n" +"これは、サブタイプの :c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットがクリアされて" +"おり、:c:member:`~PyTypeObject.tp_traverse` と :c:member:`~PyTypeObject." +"tp_clear` が存在して、どちらも ``NULL`` の場合です。" -#: ../../c-api/typeobj.rst:1253 msgid "" "This is a bitmask of all the bits that pertain to the existence of certain " "fields in the type object and its extension structures. Currently, it " "includes the following bits: :c:macro:`Py_TPFLAGS_HAVE_STACKLESS_EXTENSION`." msgstr "" +"型オブジェクトとその拡張構造体に特定のフィールドが存在するかどうかに関する、" +"すべてのビットをまとめたビットマスクです。\n" +"現在は :c:macro:`Py_TPFLAGS_HAVE_STACKLESS_EXTENSION` ビットを含みます。" -#: ../../c-api/typeobj.rst:1264 msgid "This bit indicates that objects behave like unbound methods." msgstr "" +"このビットは、オブジェクトが未束縛のメソッドとして動作することを示します。" -#: ../../c-api/typeobj.rst:1266 msgid "If this flag is set for ``type(meth)``, then:" msgstr "" +"``type(meth)`` にこのフラグが設定されている場合、次の条件を満たす必要がありま" +"す。" -#: ../../c-api/typeobj.rst:1268 msgid "" "``meth.__get__(obj, cls)(*args, **kwds)`` (with ``obj`` not None) must be " "equivalent to ``meth(obj, *args, **kwds)``." msgstr "" +"``meth.__get__(obj, cls)(*args, **kwds)`` (``obj`` が None でない場合) は " +"``meth(obj, *args, **kwds)`` と同等でなければなりません。" -#: ../../c-api/typeobj.rst:1271 msgid "" "``meth.__get__(None, cls)(*args, **kwds)`` must be equivalent to " "``meth(*args, **kwds)``." msgstr "" +"``meth.__get__(None, cls)(*args, **kwds)`` は ``meth(*args, **kwds)`` と同等" +"でなければなりません。" -#: ../../c-api/typeobj.rst:1274 msgid "" "This flag enables an optimization for typical method calls like ``obj." "meth()``: it avoids creating a temporary \"bound method\" object for ``obj." "meth``." msgstr "" +"このフラグは、``obj.meth()`` のような一般的なメソッド呼び出しで、``obj." +"meth`` の一時的な「束縛済みメソッド」オブジェクトを作成せずに済ませる最適化を" +"有効にします。" -#: ../../c-api/typeobj.rst:1282 msgid "" "This flag is never inherited by types without the :c:macro:" "`Py_TPFLAGS_IMMUTABLETYPE` flag set. For extension types, it is inherited " "whenever :c:member:`~PyTypeObject.tp_descr_get` is inherited." msgstr "" +"このフラグは、:c:macro:`Py_TPFLAGS_IMMUTABLETYPE` フラグが設定されていない型" +"には継承されません。\n" +"拡張型では、:c:member:`~PyTypeObject.tp_descr_get` が継承されるときに継承され" +"ます。" -#: ../../c-api/typeobj.rst:1288 msgid "" "This bit indicates that instances of the class have a :attr:`~object." "__dict__` attribute, and that the space for the dictionary is managed by the " "VM." msgstr "" +"このビットは、クラスのインスタンスが :attr:`~object.__dict__` 属性を持ち、そ" +"の辞書用の領域を VM が管理することを示します。" -#: ../../c-api/typeobj.rst:1291 ../../c-api/typeobj.rst:1309 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` must also be set." msgstr "" +"このフラグを設定する場合は、:c:macro:`Py_TPFLAGS_HAVE_GC` も設定しなければな" +"りません。" -#: ../../c-api/typeobj.rst:1293 msgid "" "The type traverse function must call :c:func:`PyObject_VisitManagedDict` and " "its clear function must call :c:func:`PyObject_ClearManagedDict`." msgstr "" +"型の巡回関数は :c:func:`PyObject_VisitManagedDict` を、クリア関数は :c:func:" +"`PyObject_ClearManagedDict` を呼び出さなければなりません。" -#: ../../c-api/typeobj.rst:1300 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject.tp_dictoffset` " "field is set in a superclass." msgstr "" +"このフラグは、基底クラスに :c:member:`~PyTypeObject.tp_dictoffset` フィールド" +"が設定されていない限り継承されます。" -#: ../../c-api/typeobj.rst:1306 msgid "" "This bit indicates that instances of the class should be weakly " "referenceable." msgstr "" +"このビットは、クラスのインスタンスに弱参照を作成できるようにすることを示しま" +"す。" -#: ../../c-api/typeobj.rst:1315 msgid "" "This flag is inherited unless the :c:member:`~PyTypeObject." "tp_weaklistoffset` field is set in a superclass." msgstr "" +"このフラグは、基底クラスに :c:member:`~PyTypeObject.tp_weaklistoffset` フィー" +"ルドが設定されていない限り継承されます。" -#: ../../c-api/typeobj.rst:1321 msgid "" "These bits indicate that the VM will manage some fields by storing them " "before the object. Currently, this macro is equivalent to :c:expr:" "`Py_TPFLAGS_MANAGED_DICT | Py_TPFLAGS_MANAGED_WEAKREF`." msgstr "" +"これらのビットは、一部のフィールドをオブジェクトの前に格納して VM が管理する" +"ことを示します。\n" +"現在、このマクロは :c:expr:`Py_TPFLAGS_MANAGED_DICT | " +"Py_TPFLAGS_MANAGED_WEAKREF` と同等です。" -#: ../../c-api/typeobj.rst:1325 msgid "" "This macro value relies on the implementation of the VM, so its value is not " "stable and may change in a future version. Prefer using individual flags " "instead." msgstr "" +"このマクロの値は VM の実装に依存するため安定しておらず、将来のバージョンで変" +"わる可能性があります。\n" +"代わりに個々のフラグを使うことを推奨します。" -#: ../../c-api/typeobj.rst:1334 msgid "" "Only usable with variable-size types, i.e. ones with non-zero :c:member:" "`~PyTypeObject.tp_itemsize`." msgstr "" +"可変サイズの型、つまり :c:member:`~PyTypeObject.tp_itemsize` がゼロでない型で" +"のみ使えます。" -#: ../../c-api/typeobj.rst:1337 msgid "" "Indicates that the variable-sized portion of an instance of this type is at " "the end of the instance's memory area, at an offset of ``Py_TYPE(obj)-" ">tp_basicsize`` (which may be different in each subclass)." msgstr "" +"この型のインスタンスの可変サイズ部分が、インスタンスのメモリ領域の末尾、オフ" +"セット ``Py_TYPE(obj)->tp_basicsize`` にあることを示します。\n" +"このオフセットはサブクラスごとに異なる場合があります。" -#: ../../c-api/typeobj.rst:1342 msgid "" "When setting this flag, be sure that all superclasses either use this memory " "layout, or are not variable-sized. Python does not check this." msgstr "" +"このフラグを設定する場合、すべての基底クラスがこのメモリレイアウトを使ってい" +"るか、可変サイズでないことを確認してください。\n" +"Python はこれを検証しません。" -#: ../../c-api/typeobj.rst:1350 msgid "This flag is inherited." -msgstr "" +msgstr "このフラグは継承されます。" -#: ../../c-api/typeobj.rst:1364 msgid "" "Functions such as :c:func:`PyLong_Check` will call :c:func:" "`PyType_FastSubclass` with one of these flags to quickly determine if a type " @@ -2556,6 +2865,15 @@ msgid "" "appropriately, or the code that interacts with such types will behave " "differently depending on what kind of check is used." msgstr "" +":c:func:`PyLong_Check` などの関数は、これらのフラグのいずれかを指定して :c:" +"func:`PyType_FastSubclass` を呼び出し、型が組み込み型のサブクラスかどうかを高" +"速に調べます。\n" +"こうした個別の検査は :c:func:`PyObject_IsInstance` などの汎用的な検査より高速" +"です。\n" +"組み込み型を継承する独自の型では、:c:member:`~PyTypeObject.tp_flags` を適切に" +"設定する必要があります。\n" +"そうしなければ、その型を扱うコードの動作が、使う検査の種類によって変わってし" +"まいます。" #: ../../c-api/typeobj.rst:1375 msgid "" @@ -2565,229 +2883,271 @@ msgstr "" "型構造体に :c:member:`~PyTypeObject.tp_finalize` スロットが存在しているときに" "セットされるビットです。" -#: ../../c-api/typeobj.rst:1380 msgid "" "This flag isn't necessary anymore, as the interpreter assumes the :c:member:" "`~PyTypeObject.tp_finalize` slot is always present in the type structure." msgstr "" +"インタープリタは型構造体に :c:member:`~PyTypeObject.tp_finalize` スロットが常" +"に存在すると仮定するため、このフラグはもはや必要ありません。" -#: ../../c-api/typeobj.rst:1391 msgid "" "This bit is set when the class implements the :ref:`vectorcall protocol " "`. See :c:member:`~PyTypeObject.tp_vectorcall_offset` for " "details." msgstr "" +"クラスが :ref:`vectorcall プロトコル ` を実装する場合に設定される" +"ビットです。\n" +"詳細は :c:member:`~PyTypeObject.tp_vectorcall_offset` を参照してください。" -#: ../../c-api/typeobj.rst:1397 msgid "" "This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also inherited." msgstr "" +"このビットは :c:member:`~PyTypeObject.tp_call` も継承される場合に継承されま" +"す。" -#: ../../c-api/typeobj.rst:1400 msgid "as ``_Py_TPFLAGS_HAVE_VECTORCALL``" -msgstr "" +msgstr "``_Py_TPFLAGS_HAVE_VECTORCALL`` という名前で追加。" -#: ../../c-api/typeobj.rst:1404 msgid "" "Renamed to the current name, without the leading underscore. The old " "provisional name is :term:`soft deprecated`." msgstr "" +"先頭のアンダースコアを除いた現在の名前に変更されました。\n" +"以前の暫定的な名前は :term:`緩やかに非推奨 ` です。" -#: ../../c-api/typeobj.rst:1409 msgid "" "This flag is now removed from a class when the class's :py:meth:`~object." "__call__` method is reassigned." msgstr "" +"クラスの :py:meth:`~object.__call__` メソッドが再代入されると、このフラグがク" +"リアされるようになりました。" -#: ../../c-api/typeobj.rst:1412 msgid "This flag can now be inherited by mutable classes." -msgstr "" +msgstr "変更可能なクラスもこのフラグを継承できるようになりました。" -#: ../../c-api/typeobj.rst:1416 msgid "" "This bit is set for type objects that are immutable: type attributes cannot " "be set nor deleted." msgstr "" +"変更不能な型オブジェクトに設定されるビットです。\n" +"型の属性を設定したり削除したりできなくなります。" -#: ../../c-api/typeobj.rst:1418 msgid "" ":c:func:`PyType_Ready` automatically applies this flag to :ref:`static types " "`." msgstr "" +":c:func:`PyType_Ready` は :ref:`静的な型 ` にこのフラグを自動的" +"に設定します。" -#: ../../c-api/typeobj.rst:1423 ../../c-api/typeobj.rst:1532 -#: ../../c-api/typeobj.rst:1544 msgid "This flag is not inherited." -msgstr "" +msgstr "このフラグは継承されません。" -#: ../../c-api/typeobj.rst:1429 msgid "" "Disallow creating instances of the type: set :c:member:`~PyTypeObject." "tp_new` to NULL and don't create the ``__new__`` key in the type dictionary." msgstr "" +"この型のインスタンスの作成を禁止します。\n" +":c:member:`~PyTypeObject.tp_new` を NULL に設定し、型の辞書に ``__new__`` " +"キーを作成しません。" -#: ../../c-api/typeobj.rst:1433 msgid "" "The flag must be set before creating the type, not after. For example, it " "must be set before :c:func:`PyType_Ready` is called on the type." msgstr "" +"このフラグは型の作成後ではなく、作成前に設定しなければなりません。\n" +"例えば、型に対して :c:func:`PyType_Ready` を呼び出す前に設定する必要がありま" +"す。" -#: ../../c-api/typeobj.rst:1436 msgid "" "The flag is set automatically on :ref:`static types ` if :c:" "member:`~PyTypeObject.tp_base` is NULL or ``&PyBaseObject_Type`` and :c:" "member:`~PyTypeObject.tp_new` is NULL." msgstr "" +":c:member:`~PyTypeObject.tp_base` が NULL または ``&PyBaseObject_Type`` で、:" +"c:member:`~PyTypeObject.tp_new` が NULL の :ref:`静的な型 ` に" +"は、このフラグが自動的に設定されます。" -#: ../../c-api/typeobj.rst:1442 msgid "" "This flag is not inherited. However, subclasses will not be instantiable " "unless they provide a non-NULL :c:member:`~PyTypeObject.tp_new` (which is " "only possible via the C API)." msgstr "" +"このフラグは継承されません。\n" +"ただし、サブクラスも NULL でない :c:member:`~PyTypeObject.tp_new` を提供しな" +"い限りインスタンス化できません (提供できるのは C API を使う場合だけです)。" -#: ../../c-api/typeobj.rst:1449 msgid "" "To disallow instantiating a class directly but allow instantiating its " "subclasses (e.g. for an :term:`abstract base class`), do not use this flag. " "Instead, make :c:member:`~PyTypeObject.tp_new` only succeed for subclasses." msgstr "" +"クラス自体のインスタンス化は禁止しても、サブクラスのインスタンス化は許可した" +"い場合 (例えば :term:`抽象基底クラス `)、このフラグを" +"使ってはいけません。\n" +"代わりに :c:member:`~PyTypeObject.tp_new` がサブクラスに対してのみ成功するよ" +"うにしてください。" -#: ../../c-api/typeobj.rst:1460 msgid "" "This bit indicates that instances of the class may match mapping patterns " "when used as the subject of a :keyword:`match` block. It is automatically " "set when registering or subclassing :class:`collections.abc.Mapping`, and " "unset when registering :class:`collections.abc.Sequence`." msgstr "" +"このビットは、クラスのインスタンスが :keyword:`match` ブロックの対象となる場" +"合に、マッピングパターンにマッチできることを示します。\n" +":class:`collections.abc.Mapping` に登録するか、そのサブクラスになると自動的に" +"設定され、:class:`collections.abc.Sequence` に登録するとクリアされます。" -#: ../../c-api/typeobj.rst:1467 ../../c-api/typeobj.rst:1489 msgid "" ":c:macro:`Py_TPFLAGS_MAPPING` and :c:macro:`Py_TPFLAGS_SEQUENCE` are " "mutually exclusive; it is an error to enable both flags simultaneously." msgstr "" +":c:macro:`Py_TPFLAGS_MAPPING` と :c:macro:`Py_TPFLAGS_SEQUENCE` は排他的で" +"す。\n" +"両方を同時に有効にするとエラーになります。" -#: ../../c-api/typeobj.rst:1472 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_SEQUENCE`." msgstr "" +"このフラグは、:c:macro:`Py_TPFLAGS_SEQUENCE` がまだ設定されていない型に継承さ" +"れます。" #: ../../c-api/typeobj.rst:1475 ../../c-api/typeobj.rst:1497 msgid ":pep:`634` -- Structural Pattern Matching: Specification" msgstr ":pep:`634` -- 構造的パターンマッチ: 仕様" -#: ../../c-api/typeobj.rst:1482 msgid "" "This bit indicates that instances of the class may match sequence patterns " "when used as the subject of a :keyword:`match` block. It is automatically " "set when registering or subclassing :class:`collections.abc.Sequence`, and " "unset when registering :class:`collections.abc.Mapping`." msgstr "" +"このビットは、クラスのインスタンスが :keyword:`match` ブロックの対象となる場" +"合に、シーケンスパターンにマッチできることを示します。\n" +":class:`collections.abc.Sequence` に登録するか、そのサブクラスになると自動的" +"に設定され、:class:`collections.abc.Mapping` に登録するとクリアされます。" -#: ../../c-api/typeobj.rst:1494 msgid "" "This flag is inherited by types that do not already set :c:macro:" "`Py_TPFLAGS_MAPPING`." msgstr "" +"このフラグは、:c:macro:`Py_TPFLAGS_MAPPING` がまだ設定されていない型に継承さ" +"れます。" -#: ../../c-api/typeobj.rst:1504 msgid "" "Internal. Do not set or unset this flag. To indicate that a class has " "changed call :c:func:`PyType_Modified`" msgstr "" +"内部使用専用です。\n" +"このフラグを設定したりクリアしたりしないでください。\n" +"クラスが変更されたことを示すには :c:func:`PyType_Modified` を呼び出してくださ" +"い。" -#: ../../c-api/typeobj.rst:1508 msgid "" "This flag is present in header files, but is not be used. It will be removed " "in a future version of CPython" msgstr "" +"このフラグはヘッダーファイルに存在しますが、使われていません。\n" +"将来の CPython バージョンで削除される予定です。" -#: ../../c-api/typeobj.rst:1514 msgid "" "This macro does nothing. Historically, this would indicate that the :c:" "member:`~PyTypeObject.tp_version_tag` field was available and initialized." msgstr "" +"このマクロは何もしません。\n" +"以前は :c:member:`~PyTypeObject.tp_version_tag` フィールドが利用可能で、初期" +"化済みであることを示していました。" -#: ../../c-api/typeobj.rst:1524 msgid "" "This bit indicates that instances of this type will have an \"inline " "values\" array (containing the object's attributes) placed directly after " "the end of the object." msgstr "" +"このビットは、この型のインスタンスが、オブジェクトの末尾の直後に「インライン" +"値」の配列 (オブジェクトの属性を含むもの) を持つことを示します。" -#: ../../c-api/typeobj.rst:1528 msgid "This requires that :c:macro:`Py_TPFLAGS_HAVE_GC` is set." -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_HAVE_GC` の設定が必要です。" -#: ../../c-api/typeobj.rst:1539 msgid "" "This bit indicates that this is an abstract type and therefore cannot be " "instantiated." -msgstr "" +msgstr "このビットは、抽象型であるためインスタンス化できないことを示します。" -#: ../../c-api/typeobj.rst:1547 msgid ":mod:`abc`" -msgstr "" +msgstr ":mod:`abc`" -#: ../../c-api/typeobj.rst:1552 msgid "" "Internal. Do not set or unset this flag. Historically, this was a reserved " "flag for use in Stackless Python." msgstr "" +"内部使用専用です。\n" +"このフラグを設定したりクリアしたりしないでください。\n" +"以前は Stackless Python で使うために予約されたフラグでした。" -#: ../../c-api/typeobj.rst:1556 msgid "" "This flag is present in header files, but is not be used. This may be " "removed in a future version of CPython." msgstr "" +"このフラグはヘッダーファイルに存在しますが、使われていません。\n" +"将来の CPython バージョンで削除される可能性があります。" -#: ../../c-api/typeobj.rst:1564 msgid "" "An optional pointer to a NUL-terminated C string giving the docstring for " "this type object. This is exposed as the :attr:`~type.__doc__` attribute on " "the type and instances of the type." msgstr "" +"この型オブジェクトのドキュメント文字列を表す、NUL 終端の C 文字列への省略可能" +"なポインタです。\n" +"型とそのインスタンスの :attr:`~type.__doc__` 属性として公開されます。" #: ../../c-api/typeobj.rst:1570 msgid "This field is *not* inherited by subtypes." msgstr "サブタイプはこのフィールドを継承 *しません* 。" -#: ../../c-api/typeobj.rst:1577 msgid "" "An optional pointer to a traversal function for the garbage collector. This " "is only used if the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit is set." msgstr "" +"ガベージコレクタ用の巡回関数への省略可能なポインタです。\n" +":c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットが設定されている場合にのみ使われま" +"す。" -#: ../../c-api/typeobj.rst:1580 msgid "See :ref:`gc-traversal` for documentation." -msgstr "" +msgstr "説明は :ref:`gc-traversal` を参照してください。" -#: ../../c-api/typeobj.rst:1586 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_clear` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :c:" "member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " "are all inherited from the base type if they are all zero in the subtype." msgstr "" +"このフィールドは、:c:member:`~PyTypeObject.tp_clear` および :c:macro:" +"`Py_TPFLAGS_HAVE_GC` フラグビットとまとめてサブタイプに継承されます。\n" +"サブタイプでフラグビット、:c:member:`~PyTypeObject.tp_traverse`、:c:member:" +"`~PyTypeObject.tp_clear` がすべてゼロの場合に、これらすべてを基底型から継承し" +"ます。" -#: ../../c-api/typeobj.rst:1596 msgid "An optional pointer to a clear function. The signature is::" msgstr "" +"クリア関数への省略可能なポインタです。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/typeobj.rst:1598 msgid "int tp_clear(PyObject *);" -msgstr "" +msgstr "int tp_clear(PyObject *);" -#: ../../c-api/typeobj.rst:1600 msgid "" "The purpose of this function is to break reference cycles that are causing " "a :term:`cyclic isolate` so that the objects can be safely destroyed. A " "cleared object is a partially destroyed object; the object is not obligated " "to satisfy design invariants held during normal use." msgstr "" +"この関数の目的は、:term:`孤立した循環参照群 ` を生じさせてい" +"る循環参照を解消し、オブジェクトを安全に破棄できるようにすることです。\n" +"クリア済みのオブジェクトは部分的に破棄されており、通常の使用時に保たれる設計" +"上の不変条件を満たす義務はありません。" -#: ../../c-api/typeobj.rst:1605 msgid "" ":c:member:`!tp_clear` does not need to delete references to objects that " "can't participate in reference cycles, such as Python strings or Python " @@ -2797,45 +3157,59 @@ msgid "" "might have already been called. Prefer calling idempotent functions like :c:" "func:`Py_CLEAR`.)" msgstr "" +":c:member:`!tp_clear` は、Python の文字列や整数など、循環参照に関与できないオ" +"ブジェクトへの参照を削除する必要はありません。\n" +"ただし、すべての参照をクリアし、型の :c:member:`~PyTypeObject.tp_dealloc` 関" +"数から :c:member:`!tp_clear` を呼ぶようにすると、コードの重複を避けられて便利" +"な場合があります。\n" +":c:member:`!tp_clear` がすでに呼び出されている可能性に注意し、:c:func:" +"`Py_CLEAR` のような冪等な関数を使うことを推奨します。" -#: ../../c-api/typeobj.rst:1613 msgid "" "Any non-trivial cleanup should be performed in :c:member:`~PyTypeObject." "tp_finalize` instead of :c:member:`!tp_clear`." msgstr "" +"複雑な後片付けは :c:member:`!tp_clear` ではなく :c:member:`~PyTypeObject." +"tp_finalize` で行うべきです。" -#: ../../c-api/typeobj.rst:1618 msgid "" "If :c:member:`!tp_clear` fails to break a reference cycle then the objects " "in the :term:`cyclic isolate` may remain indefinitely uncollectable " "(\"leak\"). See :data:`gc.garbage`." msgstr "" +":c:member:`!tp_clear` が循環参照を解消できないと、:term:`孤立した循環参照群 " +"` のオブジェクトがいつまでも回収できずに残る (「リーク」す" +"る) 可能性があります。\n" +":data:`gc.garbage` を参照してください。" -#: ../../c-api/typeobj.rst:1624 msgid "" "Referents (direct and indirect) might have already been cleared; they are " "not guaranteed to be in a consistent state." msgstr "" +"直接または間接の参照先は、すでにクリアされている可能性があります。\n" +"整合性のある状態であるとは限りません。" -#: ../../c-api/typeobj.rst:1629 msgid "" "The :c:member:`~PyTypeObject.tp_clear` function can be called from any " "thread." msgstr "" +":c:member:`~PyTypeObject.tp_clear` 関数は、どのスレッドからも呼び出される可能" +"性があります。" -#: ../../c-api/typeobj.rst:1634 msgid "" "An object is not guaranteed to be automatically cleared before its " "destructor (:c:member:`~PyTypeObject.tp_dealloc`) is called." msgstr "" +"デストラクタ (:c:member:`~PyTypeObject.tp_dealloc`) が呼び出される前に、オブ" +"ジェクトが自動的にクリアされるとは限りません。" -#: ../../c-api/typeobj.rst:1637 msgid "" "This function differs from the destructor (:c:member:`~PyTypeObject." "tp_dealloc`) in the following ways:" msgstr "" +"この関数はデストラクタ (:c:member:`~PyTypeObject.tp_dealloc`) と次の点が異な" +"ります。" -#: ../../c-api/typeobj.rst:1640 msgid "" "The purpose of clearing an object is to remove references to other objects " "that might participate in a reference cycle. The purpose of the destructor, " @@ -2844,8 +3218,14 @@ msgid "" "(e.g., integers) as well as the object's own memory (by calling :c:member:" "`~PyTypeObject.tp_free`)." msgstr "" +"オブジェクトのクリアの目的は、循環参照に関与する可能性のある他のオブジェクト" +"への参照を取り除くことです。\n" +"一方、デストラクタの目的はさらに広く、所有する *すべて* のリソースを解放しな" +"ければなりません。\n" +"循環参照に関与できないオブジェクト (例えば整数) への参照も、オブジェクト自体" +"のメモリ (:c:member:`~PyTypeObject.tp_free` を呼び出して解放します) も含みま" +"す。" -#: ../../c-api/typeobj.rst:1646 msgid "" "When :c:member:`!tp_clear` is called, other objects might still hold " "references to the object being cleared. Because of this, :c:member:`!" @@ -2854,65 +3234,89 @@ msgid "" "when no (strong) references exist, and as such, must safely destroy the " "object itself by deallocating it." msgstr "" +":c:member:`!tp_clear` の呼び出し時には、他のオブジェクトがクリア対象のオブ" +"ジェクトへの参照をまだ保持している可能性があります。\n" +"このため :c:member:`!tp_clear` は、オブジェクト自体のメモリを解放 (:c:member:" +"`~PyTypeObject.tp_free`) してはいけません。\n" +"一方、デストラクタは強参照がなくなってから呼び出されるので、メモリを解放して" +"オブジェクト自体を安全に破棄しなければなりません。" -#: ../../c-api/typeobj.rst:1652 msgid "" ":c:member:`!tp_clear` might never be automatically called. An object's " "destructor, on the other hand, will be automatically called some time after " "the object becomes unreachable (i.e., either there are no references to the " "object or the object is a member of a :term:`cyclic isolate`)." msgstr "" +":c:member:`!tp_clear` は、自動では一度も呼び出されない場合があります。\n" +"一方、デストラクタは、オブジェクトが到達不能になってからいずれかの時点で自動" +"的に呼び出されます。\n" +"到達不能とは、参照がないか、:term:`孤立した循環参照群 ` の一" +"部である状態です。" -#: ../../c-api/typeobj.rst:1657 msgid "" "No guarantees are made about when, if, or how often Python automatically " "clears an object, except:" msgstr "" +"Python がオブジェクトを自動的にクリアするかどうか、いつ行うか、何回行うかにつ" +"いては、次の事項を除いて保証はありません。" -#: ../../c-api/typeobj.rst:1660 msgid "" "Python will not automatically clear an object if it is reachable, i.e., " "there is a reference to it and it is not a member of a :term:`cyclic " "isolate`." msgstr "" +"Python は到達可能なオブジェクトを自動的にクリアしません。\n" +"つまり、参照があり、:term:`孤立した循環参照群 ` の一部ではな" +"いオブジェクトは対象になりません。" -#: ../../c-api/typeobj.rst:1663 msgid "" "Python will not automatically clear an object if it has not been " "automatically finalized (see :c:member:`~PyTypeObject.tp_finalize`). (If " "the finalizer resurrected the object, the object may or may not be " "automatically finalized again before it is cleared.)" msgstr "" +"Python は、自動的にファイナライズされていないオブジェクトを自動的にクリアしま" +"せん (:c:member:`~PyTypeObject.tp_finalize` を参照)。\n" +"ファイナライザがオブジェクトを復活させた場合、クリアされる前に再び自動的に" +"ファイナライズされるかどうかは決まっていません。" -#: ../../c-api/typeobj.rst:1667 msgid "" "If an object is a member of a :term:`cyclic isolate`, Python will not " "automatically clear it if any member of the cyclic isolate has not yet been " "automatically finalized (:c:member:`~PyTypeObject.tp_finalize`)." msgstr "" +":term:`孤立した循環参照群 ` のいずれかのオブジェクトがまだ自" +"動的にファイナライズ (:c:member:`~PyTypeObject.tp_finalize`) されていない場" +"合、Python はその群のオブジェクトを自動的にクリアしません。" -#: ../../c-api/typeobj.rst:1670 msgid "" "Python will not destroy an object until after any automatic calls to its :c:" "member:`!tp_clear` function have returned. This ensures that the act of " "breaking a reference cycle does not invalidate the ``self`` pointer while :c:" "member:`!tp_clear` is still executing." msgstr "" +"Python は、オブジェクトの :c:member:`!tp_clear` 関数への自動的な呼び出しがす" +"べて戻るまで、そのオブジェクトを破棄しません。\n" +"これにより、循環参照の解消によって :c:member:`!tp_clear` の実行中に ``self`` " +"ポインタが無効になることを防ぎます。" -#: ../../c-api/typeobj.rst:1674 msgid "" "Python will not automatically call :c:member:`!tp_clear` multiple times " "concurrently." msgstr "" +"Python は :c:member:`!tp_clear` を自動的に複数回、並行して呼び出すことはあり" +"ません。" -#: ../../c-api/typeobj.rst:1677 msgid "" "CPython currently only automatically clears objects as needed to break " "reference cycles in a :term:`cyclic isolate`, but future versions might " "clear objects regularly before their destruction." msgstr "" +"現在の CPython は、:term:`孤立した循環参照群 ` の循環参照の解" +"消に必要な場合にだけ、オブジェクトを自動的にクリアします。\n" +"将来のバージョンでは、破棄前に通常の処理としてクリアするようになるかもしれま" +"せん。" -#: ../../c-api/typeobj.rst:1681 msgid "" "Taken together, all :c:member:`~PyTypeObject.tp_clear` functions in the " "system must combine to break all reference cycles. This is subtle, and if " @@ -2924,6 +3328,16 @@ msgid "" "containing a tuple. This isn't immediately obvious, and there's rarely a " "good reason to avoid implementing :c:member:`~PyTypeObject.tp_clear`." msgstr "" +"システム内のすべての :c:member:`~PyTypeObject.tp_clear` 関数は、全体としてす" +"べての循環参照を解消できなければなりません。\n" +"これは微妙な問題なので、少しでも疑わしければ :c:member:`~PyTypeObject." +"tp_clear` 関数を用意してください。\n" +"例えばタプルだけで循環参照を構成することは不可能だと証明できるため、タプル型" +"には :c:member:`~PyTypeObject.tp_clear` 関数がありません。\n" +"したがって、タプルを含む循環参照の解消は、他の型の :c:member:`~PyTypeObject." +"tp_clear` 関数が担います。\n" +"これはすぐには分からないことですし、:c:member:`~PyTypeObject.tp_clear` を実装" +"しない方がよい理由はほとんどありません。" #: ../../c-api/typeobj.rst:1692 msgid "" @@ -2936,7 +3350,6 @@ msgstr "" "スから Python オブジェクトだと思われるメンバへの参照を外し、それらのメンバへ" "のポインタに ``NULL`` をセットすべきです::" -#: ../../c-api/typeobj.rst:1696 msgid "" "static int\n" "local_clear(PyObject *op)\n" @@ -2949,8 +3362,17 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"local_clear(PyObject *op)\n" +"{\n" +" localobject *self = (localobject *) op;\n" +" Py_CLEAR(self->key);\n" +" Py_CLEAR(self->args);\n" +" Py_CLEAR(self->kw);\n" +" Py_CLEAR(self->dict);\n" +" return 0;\n" +"}" -#: ../../c-api/typeobj.rst:1707 msgid "" "The :c:func:`Py_CLEAR` macro should be used, because clearing references is " "delicate: the reference to the contained object must not be released (via :" @@ -2964,17 +3386,29 @@ msgid "" "contained object can no longer be used. The :c:func:`Py_CLEAR` macro " "performs the operations in a safe order." msgstr "" +"参照のクリアは慎重に行う必要があるため、:c:func:`Py_CLEAR` マクロを使うべきで" +"す。\n" +"保持するオブジェクトへのポインタを ``NULL`` に設定するまでは、その参照を :c:" +"func:`Py_DECREF` で解放してはいけません。\n" +"参照を解放すると、参照先が不要になって一連の回収処理が始まり、そのオブジェク" +"トに関連するファイナライザや弱参照コールバックによって任意の Python コードが" +"実行される可能性があるためです。\n" +"そのコードが再び *self* を参照する可能性があるなら、その時点で参照先へのポイ" +"ンタが ``NULL`` になっていることが重要です。\n" +"そうすることで *self* は、その参照先をもう使えないと判断できます。\n" +":c:func:`Py_CLEAR` マクロは、安全な順序でこれらの操作を行います。" -#: ../../c-api/typeobj.rst:1719 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, the clear function must call :c:func:" "`PyObject_ClearManagedDict` like this::" msgstr "" +":c:member:`~PyTypeObject.tp_flags` フィールドに :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` ビットが設定されている場合、クリア関数は次のよう" +"に :c:func:`PyObject_ClearManagedDict` を呼び出さなければなりません。 ::" -#: ../../c-api/typeobj.rst:1723 msgid "PyObject_ClearManagedDict((PyObject*)self);" -msgstr "" +msgstr "PyObject_ClearManagedDict((PyObject*)self);" #: ../../c-api/typeobj.rst:1725 msgid "" @@ -2984,13 +3418,17 @@ msgstr "" "Pythonのガベージコレクションの仕組みについての詳細は、 :ref:`supporting-" "cycle-detection` にあります。" -#: ../../c-api/typeobj.rst:1732 msgid "" "This field is inherited by subtypes together with :c:member:`~PyTypeObject." "tp_traverse` and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag bit: the flag bit, :" "c:member:`~PyTypeObject.tp_traverse`, and :c:member:`~PyTypeObject.tp_clear` " "are all inherited from the base type if they are all zero in the subtype." msgstr "" +"このフィールドは、:c:member:`~PyTypeObject.tp_traverse` および :c:macro:" +"`Py_TPFLAGS_HAVE_GC` フラグビットとまとめてサブタイプに継承されます。\n" +"サブタイプでフラグビット、:c:member:`~PyTypeObject.tp_traverse`、:c:member:" +"`~PyTypeObject.tp_clear` がすべてゼロの場合に、これらすべてを基底型から継承し" +"ます。" #: ../../c-api/typeobj.rst:1746 msgid "" @@ -2998,15 +3436,15 @@ msgid "" msgstr "" "オプションのポインタで、拡張比較関数を指します。シグネチャは次の通りです::" -#: ../../c-api/typeobj.rst:1748 msgid "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -msgstr "" +msgstr "PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);" -#: ../../c-api/typeobj.rst:1750 msgid "" "The first parameter is guaranteed to be an instance of the type that is " "defined by :c:type:`PyTypeObject`." msgstr "" +"第 1 引数は、その :c:type:`PyTypeObject` が定義する型のインスタンスであること" +"が保証されます。" #: ../../c-api/typeobj.rst:1753 msgid "" @@ -3079,9 +3517,8 @@ msgstr "" "ばこれらは C言語の整数か浮動小数点数になるでしょう)。三番目の引数には :c:" "func:`PyObject_RichCompare` と同様に要求された演算を指定します。" -#: ../../c-api/typeobj.rst:1789 msgid "The returned value is a new :term:`strong reference`." -msgstr "" +msgstr "戻り値は新しい :term:`強参照 ` です。" #: ../../c-api/typeobj.rst:1791 msgid "On error, sets an exception and returns ``NULL`` from the function." @@ -3109,11 +3546,12 @@ msgid "" "comparisons." msgstr "" -#: ../../c-api/typeobj.rst:1815 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` " "should be used instead, if at all possible." msgstr "" +"このフィールドは引き続きサポートされていますが、可能であれば代わりに :c:" +"macro:`Py_TPFLAGS_MANAGED_WEAKREF` を使うべきです。" #: ../../c-api/typeobj.rst:1818 msgid "" @@ -3139,11 +3577,12 @@ msgstr "" "このフィールドを :c:member:`~PyTypeObject.tp_weaklist` と混同しないようにして" "ください; これは型オブジェクト自身への弱参照からなるリストの先頭です。" -#: ../../c-api/typeobj.rst:1828 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit " "and :c:member:`~PyTypeObject.tp_weaklistoffset`." msgstr "" +":c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` ビットと :c:member:`~PyTypeObject." +"tp_weaklistoffset` の両方を設定するとエラーになります。" #: ../../c-api/typeobj.rst:1833 msgid "" @@ -3159,13 +3598,16 @@ msgstr "" "に :c:member:`~PyTypeObject.tp_weaklistoffset` で分かるはずなので、このことは" "問題にはならないはずです。" -#: ../../c-api/typeobj.rst:1840 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject." "tp_weaklistoffset` will be set to a negative value, to indicate that it is " "unsafe to use this field." msgstr "" +":c:member:`~PyTypeObject.tp_flags` フィールドに :c:macro:" +"`Py_TPFLAGS_MANAGED_WEAKREF` ビットが設定されている場合、:c:member:" +"`~PyTypeObject.tp_weaklistoffset` は負の値に設定され、このフィールドの使用が" +"安全でないことを示します。" #: ../../c-api/typeobj.rst:1850 msgid "" @@ -3182,9 +3624,8 @@ msgstr "" msgid "This function has the same signature as :c:func:`PyObject_GetIter`::" msgstr "この関数は :c:func:`PyObject_GetIter` と同じシグネチャを持っています::" -#: ../../c-api/typeobj.rst:1856 msgid "PyObject *tp_iter(PyObject *self);" -msgstr "" +msgstr "PyObject *tp_iter(PyObject *self);" #: ../../c-api/typeobj.rst:1867 msgid "" @@ -3194,17 +3635,21 @@ msgstr "" "オプションのポインタで、:term:`イテレーター ` の次の要素を返す関数" "を指します。シグネチャは次の通りです::" -#: ../../c-api/typeobj.rst:1870 msgid "PyObject *tp_iternext(PyObject *self);" -msgstr "" +msgstr "PyObject *tp_iternext(PyObject *self);" -#: ../../c-api/typeobj.rst:1872 msgid "" "When the iterator is :term:`exhausted`, the ``tp_iternext`` function must " "return ``NULL``; a :exc:`StopIteration` exception may or may not be set. " "When another error occurs, it must return ``NULL`` too. The presence of " "``tp_iternext`` signals that the instances of this type are iterators." msgstr "" +"イテレータが :term:`尽きた ` 場合、``tp_iternext`` 関数は " +"``NULL`` を返さなければなりません。\n" +":exc:`StopIteration` 例外は設定しても、しなくても構いません。\n" +"他のエラーが発生した場合も ``NULL`` を返す必要があります。\n" +"``tp_iternext`` が存在することは、この型のインスタンスがイテレータであること" +"を示します。" #: ../../c-api/typeobj.rst:1878 msgid "" @@ -3309,17 +3754,19 @@ msgstr "" "います; 多重継承はメタタイプの呼び出しによる動的な型オブジェクトの生成を必要" "とします。" -#: ../../c-api/typeobj.rst:1944 msgid "For the corresponding slot ID, see :c:macro:`Py_tp_base`." -msgstr "" +msgstr "対応するスロット ID は :c:macro:`Py_tp_base` を参照してください。" -#: ../../c-api/typeobj.rst:1950 msgid "" "Slot initialization is subject to the rules of initializing globals. C99 " "requires the initializers to be \"address constants\". Function designators " "like :c:func:`PyType_GenericNew`, with implicit conversion to a pointer, are " "valid C99 address constants." msgstr "" +"スロットの初期化には、グローバル変数の初期化の規則が適用されます。\n" +"C99 では、初期化子は「アドレス定数」である必要があります。\n" +":c:func:`PyType_GenericNew` などの関数指示子は、暗黙にポインタへ変換され、有" +"効な C99 のアドレス定数になります。" #: ../../c-api/typeobj.rst:1955 msgid "" @@ -3329,11 +3776,12 @@ msgid "" "strictly standard conforming in this particular behavior." msgstr "" -#: ../../c-api/typeobj.rst:1961 msgid "" "Consequently, :c:member:`~PyTypeObject.tp_base` should be set in the " "extension module's init function." msgstr "" +"したがって、:c:member:`~PyTypeObject.tp_base` は拡張モジュールの初期化関数内" +"で設定するべきです。" #: ../../c-api/typeobj.rst:1966 msgid "This field is not inherited by subtypes (obviously)." @@ -3352,7 +3800,6 @@ msgid "The type's dictionary is stored here by :c:func:`PyType_Ready`." msgstr "" "型の辞書は :c:func:`PyType_Ready` によってこのフィールドに収められます。" -#: ../../c-api/typeobj.rst:1978 msgid "" "This field should normally be initialized to ``NULL`` before PyType_Ready is " "called; it may also be initialized to a dictionary containing initial " @@ -3362,19 +3809,27 @@ msgid "" "__add__`). Once initialization for the type has finished, this field should " "be treated as read-only." msgstr "" +"通常、このフィールドは ``PyType_Ready`` を呼び出す前に ``NULL`` に初期化する" +"べきですが、型の初期属性を含む辞書で初期化することもできます。\n" +":c:func:`PyType_Ready` が型を初期化した後は、:meth:`~object.__add__` のような" +"オーバーロードされる演算に対応しない属性だけを、この辞書に追加できます。\n" +"型の初期化が完了した後は、このフィールドを読み取り専用として扱うべきです。" -#: ../../c-api/typeobj.rst:1986 msgid "" "Some types may not store their dictionary in this slot. Use :c:func:" "`PyType_GetDict` to retrieve the dictionary for an arbitrary type." msgstr "" +"このスロットに辞書を格納しない型もあります。\n" +"任意の型の辞書を取得するには :c:func:`PyType_GetDict` を使ってください。" -#: ../../c-api/typeobj.rst:1992 msgid "" "Internals detail: For static builtin types, this is always ``NULL``. " "Instead, the dict for such types is stored on ``PyInterpreterState``. Use :c:" "func:`PyType_GetDict` to get the dict for an arbitrary type." msgstr "" +"実装詳細: 静的な組み込み型では常に ``NULL`` です。\n" +"代わりに、これらの型の辞書は ``PyInterpreterState`` に格納されます。\n" +"任意の型の辞書を取得するには :c:func:`PyType_GetDict` を使ってください。" #: ../../c-api/typeobj.rst:1998 msgid "" @@ -3384,11 +3839,12 @@ msgstr "" "サブタイプはこのフィールドを継承しません (が、この辞書内で定義されている属性" "は異なるメカニズムで継承されます)。" -#: ../../c-api/typeobj.rst:2003 msgid "" "If this field is ``NULL``, :c:func:`PyType_Ready` will assign a new " "dictionary to it." msgstr "" +"このフィールドが ``NULL`` の場合、:c:func:`PyType_Ready` が新しい辞書を割り当" +"てます。" #: ../../c-api/typeobj.rst:2008 msgid "" @@ -3408,9 +3864,9 @@ msgstr "オプションのポインタで、デスクリプタの get 関数を msgid "The function signature is::" msgstr "関数のシグネチャは次のとおりです ::" -#: ../../c-api/typeobj.rst:2020 msgid "PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" msgstr "" +"PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);" #: ../../c-api/typeobj.rst:2033 msgid "" @@ -3419,19 +3875,19 @@ msgid "" msgstr "" "オプションのポインタで、デスクリプタの値の設定と削除を行う関数を指します。" -#: ../../c-api/typeobj.rst:2038 msgid "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" -msgstr "" +msgstr "int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);" #: ../../c-api/typeobj.rst:2040 msgid "The *value* argument is set to ``NULL`` to delete the value." msgstr "値を削除するには、*value* 引数に ``NULL`` を設定します。" -#: ../../c-api/typeobj.rst:2051 msgid "" "While this field is still supported, :c:macro:`Py_TPFLAGS_MANAGED_DICT` " "should be used instead, if at all possible." msgstr "" +"このフィールドは引き続きサポートされていますが、可能であれば代わりに :c:" +"macro:`Py_TPFLAGS_MANAGED_DICT` を使うべきです。" #: ../../c-api/typeobj.rst:2054 msgid "" @@ -3453,13 +3909,11 @@ msgstr "" "このフィールドを :c:member:`~PyTypeObject.tp_dict` と混同しないようにしてくだ" "さい; これは型オブジェクト自身の属性の辞書です。" -#: ../../c-api/typeobj.rst:2062 msgid "" "The value specifies the offset of the dictionary from the start of the " "instance structure." -msgstr "" +msgstr "この値は、インスタンス構造体の先頭からの辞書のオフセットを指定します。" -#: ../../c-api/typeobj.rst:2064 msgid "" "The :c:member:`~PyTypeObject.tp_dictoffset` should be regarded as write-" "only. To get the pointer to the dictionary call :c:func:" @@ -3467,57 +3921,78 @@ msgid "" "need to allocate memory for the dictionary, so it is may be more efficient " "to call :c:func:`PyObject_GetAttr` when accessing an attribute on the object." msgstr "" +":c:member:`~PyTypeObject.tp_dictoffset` は書き込み専用として扱うべきです。\n" +"辞書へのポインタを取得するには :c:func:`PyObject_GenericGetDict` を呼び出して" +"ください。\n" +":c:func:`PyObject_GenericGetDict` は辞書用のメモリを割り当てる必要がある場合" +"があるため、オブジェクトの属性にアクセスするなら :c:func:`PyObject_GetAttr` " +"の方が効率的なことがあります。" -#: ../../c-api/typeobj.rst:2070 msgid "" "It is an error to set both the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit and :c:" "member:`~PyTypeObject.tp_dictoffset`." msgstr "" +":c:macro:`Py_TPFLAGS_MANAGED_DICT` ビットと :c:member:`~PyTypeObject." +"tp_dictoffset` の両方を設定するとエラーになります。" -#: ../../c-api/typeobj.rst:2075 msgid "" "This field is inherited by subtypes. A subtype should not override this " "offset; doing so could be unsafe, if C code tries to access the dictionary " "at the previous offset. To properly support inheritance, use :c:macro:" "`Py_TPFLAGS_MANAGED_DICT`." msgstr "" +"このフィールドはサブタイプに継承されます。\n" +"サブタイプでこのオフセットをオーバーライドするべきではありません。\n" +"C コードが以前のオフセットで辞書にアクセスすると、安全でない可能性がありま" +"す。\n" +"継承を適切にサポートするには :c:macro:`Py_TPFLAGS_MANAGED_DICT` を使ってくだ" +"さい。" -#: ../../c-api/typeobj.rst:2082 msgid "" "This slot has no default. For :ref:`static types `, if the " "field is ``NULL`` then no :attr:`~object.__dict__` gets created for " "instances." msgstr "" +"このスロットにはデフォルト値がありません。\n" +":ref:`静的な型 ` でこのフィールドが ``NULL`` の場合、インスタン" +"スに :attr:`~object.__dict__` は作成されません。" -#: ../../c-api/typeobj.rst:2085 msgid "" "If the :c:macro:`Py_TPFLAGS_MANAGED_DICT` bit is set in the :c:member:" "`~PyTypeObject.tp_flags` field, then :c:member:`~PyTypeObject.tp_dictoffset` " "will be set to ``-1``, to indicate that it is unsafe to use this field." msgstr "" +":c:member:`~PyTypeObject.tp_flags` フィールドに :c:macro:" +"`Py_TPFLAGS_MANAGED_DICT` ビットが設定されている場合、:c:member:" +"`~PyTypeObject.tp_dictoffset` は ``-1`` に設定され、このフィールドの使用が安" +"全でないことを示します。" #: ../../c-api/typeobj.rst:2095 msgid "An optional pointer to an instance initialization function." msgstr "オプションのポインタで、インスタンス初期化関数を指します。" -#: ../../c-api/typeobj.rst:2097 msgid "" "This function corresponds to the :meth:`~object.__init__` method of " "classes. Like :meth:`!__init__`, it is possible to create an instance " "without calling :meth:`!__init__`, and it is possible to reinitialize an " "instance by calling its :meth:`!__init__` method again." msgstr "" +"この関数はクラスの :meth:`~object.__init__` メソッドに対応します。\n" +":meth:`!__init__` と同様に、:meth:`!__init__` を呼び出さずにインスタンスを作" +"成することも、:meth:`!__init__` メソッドを再び呼び出してインスタンスを再初期" +"化することもできます。" -#: ../../c-api/typeobj.rst:2104 msgid "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -msgstr "" +msgstr "int tp_init(PyObject *self, PyObject *args, PyObject *kwds);" -#: ../../c-api/typeobj.rst:2106 msgid "" "The self argument is the instance to be initialized; the *args* and *kwds* " "arguments represent positional and keyword arguments of the call to :meth:" "`~object.__init__`." msgstr "" +"``self`` 引数は初期化するインスタンスです。\n" +"*args* と *kwds* は :meth:`~object.__init__` の呼び出しの位置引数とキーワード" +"引数を表します。" #: ../../c-api/typeobj.rst:2110 msgid "" @@ -3543,46 +4018,46 @@ msgid "Returns ``0`` on success, ``-1`` and sets an exception on error." msgstr "" "成功のときには ``0`` を、エラー時には例外をセットして ``-1`` を返します。" -#: ../../c-api/typeobj.rst:2125 msgid "" "For :ref:`static types ` this field does not have a default." msgstr "" +":ref:`静的な型 ` では、このフィールドにデフォルト値はありませ" +"ん。" #: ../../c-api/typeobj.rst:2132 msgid "An optional pointer to an instance allocation function." msgstr "オプションのポインタで、インスタンスのメモリ確保関数を指します。" -#: ../../c-api/typeobj.rst:2136 msgid "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -msgstr "" +msgstr "PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);" -#: ../../c-api/typeobj.rst:2140 msgid "" "Static subtypes inherit this slot, which will be :c:func:" "`PyType_GenericAlloc` if inherited from :class:`object`." msgstr "" +"静的なサブタイプはこのスロットを継承します。\n" +":class:`object` から継承した場合は :c:func:`PyType_GenericAlloc` になります。" -#: ../../c-api/typeobj.rst:2143 ../../c-api/typeobj.rst:2214 msgid ":ref:`Heap subtypes ` do not inherit this slot." -msgstr "" +msgstr ":ref:`ヒープのサブタイプ ` はこのスロットを継承しません。" -#: ../../c-api/typeobj.rst:2147 msgid "" "For heap subtypes, this field is always set to :c:func:`PyType_GenericAlloc`." msgstr "" +"ヒープのサブタイプでは、このフィールドは常に :c:func:`PyType_GenericAlloc` に" +"設定されます。" -#: ../../c-api/typeobj.rst:2150 ../../c-api/typeobj.rst:2222 msgid "For static subtypes, this slot is inherited (see above)." -msgstr "" +msgstr "静的なサブタイプでは、このスロットは継承されます (前述)。" #: ../../c-api/typeobj.rst:2157 msgid "An optional pointer to an instance creation function." msgstr "オプションのポインタで、インスタンス生成関数を指します。" -#: ../../c-api/typeobj.rst:2161 msgid "" "PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" msgstr "" +"PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);" #: ../../c-api/typeobj.rst:2163 msgid "" @@ -3616,11 +4091,12 @@ msgstr "" "tp_new` で行い、一方、変更可能な型ではほとんどの初期化を :c:member:" "`~PyTypeObject.tp_init` に回すべきです。" -#: ../../c-api/typeobj.rst:2177 msgid "" "Set the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag to disallow " "creating instances of the type in Python." msgstr "" +"Python からこの型のインスタンスを作成することを禁止するには、:c:macro:" +"`Py_TPFLAGS_DISALLOW_INSTANTIATION` フラグを設定してください。" #: ../../c-api/typeobj.rst:2182 msgid "" @@ -3632,13 +4108,18 @@ msgstr "" "`~PyTypeObject.tp_base` が ``NULL`` か ``&PyBaseObject_Type`` になっている :" "ref:`静的な型 ` では継承しません。" -#: ../../c-api/typeobj.rst:2188 msgid "" "For :ref:`static types ` this field has no default. This means " "if the slot is defined as ``NULL``, the type cannot be called to create new " "instances; presumably there is some other way to create instances, like a " "factory function." msgstr "" +":ref:`静的な型 ` では、このフィールドにデフォルト値はありませ" +"ん。\n" +"スロットを ``NULL`` と定義すると、型を呼び出して新しいインスタンスを作成でき" +"なくなります。\n" +"その場合は、ファクトリ関数など別の方法でインスタンスを作成することになりま" +"す。" #: ../../c-api/typeobj.rst:2198 msgid "" @@ -3647,17 +4128,16 @@ msgstr "" "オプションのポインタで、インスタンスのメモリ解放関数を指します。シグネチャは" "以下の通りです::" -#: ../../c-api/typeobj.rst:2200 msgid "void tp_free(void *self);" -msgstr "" +msgstr "void tp_free(void *self);" -#: ../../c-api/typeobj.rst:2202 msgid "" "This function must free the memory allocated by :c:member:`~PyTypeObject." "tp_alloc`." msgstr "" +"この関数は :c:member:`~PyTypeObject.tp_alloc` が割り当てたメモリを解放しなけ" +"ればなりません。" -#: ../../c-api/typeobj.rst:2207 msgid "" "Static subtypes inherit this slot, which will be :c:func:`PyObject_Free` if " "inherited from :class:`object`. Exception: If the type supports garbage " @@ -3665,20 +4145,28 @@ msgid "" "`~PyTypeObject.tp_flags`) and it would inherit :c:func:`PyObject_Free`, then " "this slot is not inherited but instead defaults to :c:func:`PyObject_GC_Del`." msgstr "" +"静的なサブタイプはこのスロットを継承します。\n" +":class:`object` から継承した場合は :c:func:`PyObject_Free` になります。\n" +"ただし、型がガベージコレクションをサポートする (:c:member:`~PyTypeObject." +"tp_flags` に :c:macro:`Py_TPFLAGS_HAVE_GC` フラグが設定されている) 場合は例外" +"です。\n" +":c:func:`PyObject_Free` を継承することになる場合、このスロットは継承されず、" +"代わりに :c:func:`PyObject_GC_Del` がデフォルトになります。" -#: ../../c-api/typeobj.rst:2218 msgid "" "For :ref:`heap subtypes `, this slot defaults to a deallocator " "suitable to match :c:func:`PyType_GenericAlloc` and the value of the :c:" "macro:`Py_TPFLAGS_HAVE_GC` flag." msgstr "" +":ref:`ヒープのサブタイプ ` では、このスロットのデフォルトは :c:" +"func:`PyType_GenericAlloc` と :c:macro:`Py_TPFLAGS_HAVE_GC` フラグの値に対応" +"する適切な解放関数になります。" #: ../../c-api/typeobj.rst:2229 msgid "An optional pointer to a function called by the garbage collector." msgstr "" "オプションのポインタで、ガベージコレクタから呼び出される関数を指します。" -#: ../../c-api/typeobj.rst:2231 msgid "" "The garbage collector needs to know whether a particular object is " "collectible or not. Normally, it is sufficient to look at the object's " @@ -3689,10 +4177,18 @@ msgid "" "return ``1`` for a collectible instance, and ``0`` for a non-collectible " "instance. The signature is::" msgstr "" +"ガベージコレクタは、個々のオブジェクトが回収可能かどうかを知る必要がありま" +"す。\n" +"通常は、オブジェクトの型の :c:member:`~PyTypeObject.tp_flags` フィールドで :" +"c:macro:`Py_TPFLAGS_HAVE_GC` フラグビットを確認すれば十分です。\n" +"ただし、静的に割り当てたインスタンスと動的に割り当てたインスタンスが混在する" +"型もあり、静的なインスタンスは回収できません。\n" +"そうした型ではこの関数を定義し、回収可能なインスタンスなら ``1``、回収不能な" +"ら ``0`` を返すべきです。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/typeobj.rst:2239 msgid "int tp_is_gc(PyObject *self);" -msgstr "" +msgstr "int tp_is_gc(PyObject *self);" #: ../../c-api/typeobj.rst:2241 msgid "" @@ -3704,32 +4200,36 @@ msgstr "" "`PyType_Type` は、型のメモリ確保が静的か :ref:`動的 ` かを区別す" "るためにこの関数を定義しています。)" -#: ../../c-api/typeobj.rst:2251 msgid "" "This slot has no default. If this field is ``NULL``, :c:macro:" "`Py_TPFLAGS_HAVE_GC` is used as the functional equivalent." msgstr "" +"このスロットにはデフォルト値がありません。\n" +"``NULL`` の場合は、代わりに :c:macro:`Py_TPFLAGS_HAVE_GC` が同等の役割を果た" +"します。" #: ../../c-api/typeobj.rst:2257 msgid "Tuple of base types." msgstr "基底型からなるタプルです。" -#: ../../c-api/typeobj.rst:2259 ../../c-api/typeobj.rst:2280 msgid "" "This field should be set to ``NULL`` and treated as read-only. Python will " "fill it in when the type is :c:func:`initialized `." msgstr "" +"このフィールドは ``NULL`` に設定し、読み取り専用として扱うべきです。\n" +"型が :c:func:`初期化 ` されるときに、Python が設定します。" -#: ../../c-api/typeobj.rst:2262 msgid "For the corresponding slot ID, see :c:macro:`Py_tp_bases`." -msgstr "" +msgstr "対応するスロット ID は :c:macro:`Py_tp_bases` を参照してください。" -#: ../../c-api/typeobj.rst:2266 msgid "" "Multiple inheritance does not work well for statically defined types. If you " "set ``tp_bases`` to a tuple, Python will not raise an error, but some slots " "will only be inherited from the first base." msgstr "" +"静的に定義された型では、多重継承はうまく動作しません。\n" +"``tp_bases`` にタプルを設定しても Python はエラーを送出しませんが、一部のス" +"ロットは最初の基底クラスからしか継承されません。" #: ../../c-api/typeobj.rst:2272 ../../c-api/typeobj.rst:2295 #: ../../c-api/typeobj.rst:2312 ../../c-api/typeobj.rst:2329 @@ -3758,43 +4258,52 @@ msgstr "" msgid "Unused. Internal use only." msgstr "未使用のフィールドです。内部でのみ利用されます。" -#: ../../c-api/typeobj.rst:2300 msgid "" "A collection of subclasses. Internal use only. May be an invalid pointer." msgstr "" +"サブクラスのコレクションです。\n" +"内部使用専用です。\n" +"無効なポインタの場合があります。" -#: ../../c-api/typeobj.rst:2302 msgid "" "To get a list of subclasses, call the Python method :py:meth:`~type." "__subclasses__`." msgstr "" +"サブクラスのリストを取得するには、Python の :py:meth:`~type.__subclasses__` " +"メソッドを呼び出してください。" -#: ../../c-api/typeobj.rst:2307 msgid "" "For some types, this field does not hold a valid :c:expr:`PyObject*`. The " "type was changed to :c:expr:`void*` to indicate this." msgstr "" +"一部の型では、このフィールドは有効な :c:expr:`PyObject*` を保持しません。\n" +"そのことを示すために、型が :c:expr:`void*` に変更されました。" -#: ../../c-api/typeobj.rst:2317 msgid "" "Weak reference list head, for weak references to this type object. Not " "inherited. Internal use only." -msgstr "この型オブジェクトに対する弱参照からなるリストの先頭です。" +msgstr "" +"この型オブジェクトへの弱参照リストの先頭です。\n" +"継承されません。\n" +"内部使用専用です。" -#: ../../c-api/typeobj.rst:2322 msgid "" "Internals detail: For the static builtin types this is always ``NULL``, even " "if weakrefs are added. Instead, the weakrefs for each are stored on " "``PyInterpreterState``. Use the public C-API or the internal " "``_PyObject_GET_WEAKREFS_LISTPTR()`` macro to avoid the distinction." msgstr "" +"実装詳細: 静的な組み込み型では、弱参照が追加されていても常に ``NULL`` で" +"す。\n" +"代わりに、それぞれの弱参照は ``PyInterpreterState`` に格納されます。\n" +"この違いを意識せずに扱うには、公開 C API または内部マクロ " +"``_PyObject_GET_WEAKREFS_LISTPTR()`` を使ってください。" -#: ../../c-api/typeobj.rst:2336 msgid "" "This field is deprecated. Use :c:member:`~PyTypeObject.tp_finalize` instead." msgstr "" -"このフィールドは廃止されました。:c:member:`~PyTypeObject.tp_finalize` を代わ" -"りに利用してください。" +"このフィールドは非推奨です。\n" +"代わりに :c:member:`~PyTypeObject.tp_finalize` を使ってください。" #: ../../c-api/typeobj.rst:2341 msgid "Used to index into the method cache. Internal use only." @@ -3802,41 +4311,49 @@ msgstr "" "メソッドキャッシュへのインデックスとして使われます。内部使用だけのための関数" "です。" -#: ../../c-api/typeobj.rst:2352 msgid "" "An optional pointer to an instance finalization function. This is the C " "implementation of the :meth:`~object.__del__` special method. Its signature " "is::" msgstr "" +"インスタンスのファイナライズ関数への省略可能なポインタです。\n" +"特殊メソッド :meth:`~object.__del__` の C 実装に相当します。\n" +"シグネチャは次のとおりです。 ::" -#: ../../c-api/typeobj.rst:2356 msgid "void tp_finalize(PyObject *self);" -msgstr "" +msgstr "void tp_finalize(PyObject *self);" -#: ../../c-api/typeobj.rst:2358 msgid "" "The primary purpose of finalization is to perform any non-trivial cleanup " "that must be performed before the object is destroyed, while the object and " "any other objects it directly or indirectly references are still in a " "consistent state. The finalizer is allowed to execute arbitrary Python code." msgstr "" +"ファイナライズの主な目的は、オブジェクトとその直接または間接の参照先がまだ整" +"合性のある状態にある間に、破棄前に必要な複雑な後片付けを行うことです。\n" +"ファイナライザは任意の Python コードを実行できます。" -#: ../../c-api/typeobj.rst:2364 msgid "" "Before Python automatically finalizes an object, some of the object's direct " "or indirect referents might have themselves been automatically finalized. " "However, none of the referents will have been automatically cleared (:c:" "member:`~PyTypeObject.tp_clear`) yet." msgstr "" +"Python がオブジェクトを自動的にファイナライズする前に、その直接または間接の参" +"照先の一部が、すでに自動的にファイナライズされている可能性があります。\n" +"ただし、参照先はまだどれも自動的にクリア (:c:member:`~PyTypeObject." +"tp_clear`) されていません。" -#: ../../c-api/typeobj.rst:2369 msgid "" "Other non-finalized objects might still be using a finalized object, so the " "finalizer must leave the object in a sane state (e.g., invariants are still " "met)." msgstr "" +"他の未ファイナライズのオブジェクトが、ファイナライズ済みのオブジェクトをまだ" +"使っている可能性があります。\n" +"このため、ファイナライザはオブジェクトを正常な状態 (例えば不変条件を満たす状" +"態) に保たなければなりません。" -#: ../../c-api/typeobj.rst:2375 msgid "" "After Python automatically finalizes an object, Python might start " "automatically clearing (:c:member:`~PyTypeObject.tp_clear`) the object and " @@ -3844,8 +4361,12 @@ msgid "" "be in a consistent state; a finalized object must be able to tolerate " "cleared referents." msgstr "" +"Python がオブジェクトを自動的にファイナライズした後は、そのオブジェクトと直接" +"または間接の参照先の自動的なクリア (:c:member:`~PyTypeObject.tp_clear`) を始" +"める可能性があります。\n" +"クリア済みのオブジェクトは整合性のある状態とは限らないので、ファイナライズ済" +"みのオブジェクトは参照先がクリアされても問題なく扱える必要があります。" -#: ../../c-api/typeobj.rst:2383 msgid "" "An object is not guaranteed to be automatically finalized before its " "destructor (:c:member:`~PyTypeObject.tp_dealloc`) is called. It is " @@ -3853,6 +4374,10 @@ msgid "" "beginning of :c:member:`!tp_dealloc` to guarantee that the object is always " "finalized before destruction." msgstr "" +"デストラクタ (:c:member:`~PyTypeObject.tp_dealloc`) の呼び出し前に、オブジェ" +"クトが自動的にファイナライズされるとは限りません。\n" +"破棄前に必ずファイナライズされるようにするため、:c:member:`!tp_dealloc` の冒" +"頭で :c:func:`PyObject_CallFinalizerFromDealloc` を呼び出すことを推奨します。" #: ../../c-api/typeobj.rst:2391 msgid "" @@ -3860,17 +4385,19 @@ msgid "" "thread, although the :term:`GIL` will be held." msgstr "" -#: ../../c-api/typeobj.rst:2396 msgid "" "The :c:member:`!tp_finalize` function can be called during shutdown, after " "some global variables have been deleted. See the documentation of the :meth:" "`~object.__del__` method for details." msgstr "" +":c:member:`!tp_finalize` 関数は、シャットダウン中に一部のグローバル変数が削除" +"された後で呼び出される可能性があります。\n" +"詳細は :meth:`~object.__del__` メソッドの説明を参照してください。" -#: ../../c-api/typeobj.rst:2400 msgid "" "When Python finalizes an object, it behaves like the following algorithm:" msgstr "" +"Python がオブジェクトをファイナライズするときは、次のような手順で動作します。" #: ../../c-api/typeobj.rst:2402 msgid "" @@ -3886,7 +4413,6 @@ msgid "" "finalizer function is non-``NULL``, the finalizer function is called." msgstr "" -#: ../../c-api/typeobj.rst:2410 msgid "" "If the finalizer function was called and the finalizer made the object " "reachable (i.e., there is a reference to the object and it is not a member " @@ -3895,31 +4421,45 @@ msgid "" "resurrect the object by adding a new reference to the object that does not " "make it reachable, i.e., the object is (still) a member of a cyclic isolate." msgstr "" +"ファイナライザ関数が呼び出され、オブジェクトを到達可能にした場合 (参照があ" +"り、:term:`孤立した循環参照群 ` の一部ではなくなった場合)、そ" +"のオブジェクトを *復活させた* といいます。\n" +"到達可能にしない新しい参照を加えた場合、つまりオブジェクトが引き続き孤立した" +"循環参照群の一部である場合にも、ファイナライザが復活させられるかどうかは規定" +"されていません。" -#: ../../c-api/typeobj.rst:2417 msgid "" "If the finalizer resurrected the object, the object's pending destruction is " "canceled and the object's *finalized* mark might be removed if present. " "Currently, Python never removes the *finalized* mark; this might change in a " "future version." msgstr "" +"ファイナライザがオブジェクトを復活させると、予定されていた破棄は取り消され、*" +"ファイナライズ済み* の印があれば取り除かれる可能性があります。\n" +"現在の Python は *ファイナライズ済み* の印を取り除きませんが、将来のバージョ" +"ンで変更される可能性があります。" -#: ../../c-api/typeobj.rst:2422 msgid "" "*Automatic finalization* refers to any finalization performed by Python " "except via calls to :c:func:`PyObject_CallFinalizer` or :c:func:" "`PyObject_CallFinalizerFromDealloc`. No guarantees are made about when, if, " "or how often an object is automatically finalized, except:" msgstr "" +"*自動的なファイナライズ* とは、:c:func:`PyObject_CallFinalizer` または :c:" +"func:`PyObject_CallFinalizerFromDealloc` の呼び出しを介するものを除き、" +"Python が行うすべてのファイナライズを指します。\n" +"自動的にファイナライズするかどうか、いつ行うか、何回行うかについては、次の事" +"項を除いて保証はありません。" -#: ../../c-api/typeobj.rst:2427 msgid "" "Python will not automatically finalize an object if it is reachable, i.e., " "there is a reference to it and it is not a member of a :term:`cyclic " "isolate`." msgstr "" +"Python は到達可能なオブジェクトを自動的にファイナライズしません。\n" +"つまり、参照があり、:term:`孤立した循環参照群 ` の一部ではな" +"いオブジェクトは対象になりません。" -#: ../../c-api/typeobj.rst:2430 msgid "" "Python will not automatically finalize an object if finalizing it would not " "mark the object as *finalized*. Currently, this applies to objects whose " @@ -3928,54 +4468,73 @@ msgid "" "finalized by calling :c:func:`PyObject_CallFinalizer` or :c:func:" "`PyObject_CallFinalizerFromDealloc`." msgstr "" +"ファイナライズしても *ファイナライズ済み* の印が付かないオブジェクトを、" +"Python は自動的にファイナライズしません。\n" +"現在は、ガベージコレクションをサポートしない型 (:c:macro:" +"`Py_TPFLAGS_HAVE_GC` フラグが設定されていないもの) のオブジェクトが該当しま" +"す。\n" +"そうしたオブジェクトでも、:c:func:`PyObject_CallFinalizer` または :c:func:" +"`PyObject_CallFinalizerFromDealloc` を呼び出して手動でファイナライズできま" +"す。" -#: ../../c-api/typeobj.rst:2436 msgid "" "Python will not automatically finalize any two members of a :term:`cyclic " "isolate` concurrently." msgstr "" +"Python は、同じ :term:`孤立した循環参照群 ` に属する 2 つのオ" +"ブジェクトを、自動的に並行してファイナライズすることはありません。" -#: ../../c-api/typeobj.rst:2438 msgid "" "Python will not automatically finalize an object after it has automatically " "cleared (:c:member:`~PyTypeObject.tp_clear`) the object." msgstr "" +"Python は、自動的にクリア (:c:member:`~PyTypeObject.tp_clear`) したオブジェク" +"トを、その後で自動的にファイナライズすることはありません。" -#: ../../c-api/typeobj.rst:2440 msgid "" "If an object is a member of a :term:`cyclic isolate`, Python will not " "automatically finalize it after automatically clearing (see :c:member:" "`~PyTypeObject.tp_clear`) any other member." msgstr "" +":term:`孤立した循環参照群 ` のいずれかのオブジェクトを自動的" +"にクリア (:c:member:`~PyTypeObject.tp_clear` を参照) した後は、Python はその" +"群のオブジェクトを自動的にファイナライズしません。" -#: ../../c-api/typeobj.rst:2443 msgid "" "Python will automatically finalize every member of a :term:`cyclic isolate` " "before it automatically clears (see :c:member:`~PyTypeObject.tp_clear`) any " "of them." msgstr "" +"Python は、:term:`孤立した循環参照群 ` のどのオブジェクトを自" +"動的にクリア (:c:member:`~PyTypeObject.tp_clear` を参照) するよりも前に、すべ" +"てのオブジェクトを自動的にファイナライズします。" -#: ../../c-api/typeobj.rst:2446 msgid "" "If Python is going to automatically clear an object (:c:member:" "`~PyTypeObject.tp_clear`), it will automatically finalize the object first." msgstr "" +"Python がオブジェクトを自動的にクリア (:c:member:`~PyTypeObject.tp_clear`) す" +"る場合は、先にそのオブジェクトを自動的にファイナライズします。" -#: ../../c-api/typeobj.rst:2450 msgid "" "Python currently only automatically finalizes objects that are members of a :" "term:`cyclic isolate`, but future versions might finalize objects regularly " "before their destruction." msgstr "" +"現在の Python は、:term:`孤立した循環参照群 ` に属するオブ" +"ジェクトだけを自動的にファイナライズします。\n" +"将来のバージョンでは、破棄前に通常の処理としてファイナライズするようになるか" +"もしれません。" -#: ../../c-api/typeobj.rst:2454 msgid "" "To manually finalize an object, do not call this function directly; call :c:" "func:`PyObject_CallFinalizer` or :c:func:`PyObject_CallFinalizerFromDealloc` " "instead." msgstr "" +"手動でファイナライズするには、この関数を直接呼び出さず、代わりに :c:func:" +"`PyObject_CallFinalizer` または :c:func:`PyObject_CallFinalizerFromDealloc` " +"を呼び出してください。" -#: ../../c-api/typeobj.rst:2458 msgid "" ":c:member:`~PyTypeObject.tp_finalize` should leave the current exception " "status unchanged. The recommended way to write a non-trivial finalizer is " @@ -3985,8 +4544,15 @@ msgid "" "middle of the finalizer, log and clear it with :c:func:" "`PyErr_WriteUnraisable` or :c:func:`PyErr_FormatUnraisable`. For example::" msgstr "" +":c:member:`~PyTypeObject.tp_finalize` は、現在の例外の状態を変えるべきではあ" +"りません。\n" +"複雑なファイナライザを記述する場合は、冒頭で :c:func:" +"`PyErr_GetRaisedException` を呼び出して例外を保存し、最後に :c:func:" +"`PyErr_SetRaisedException` を呼び出して復元する方法を推奨します。\n" +"途中で例外が発生した場合は、:c:func:`PyErr_WriteUnraisable` または :c:func:" +"`PyErr_FormatUnraisable` で記録してクリアしてください。\n" +"例えば次のようにします。 ::" -#: ../../c-api/typeobj.rst:2467 msgid "" "static void\n" "foo_finalize(PyObject *self)\n" @@ -4008,47 +4574,72 @@ msgid "" " PyErr_SetRaisedException(exc);\n" "}" msgstr "" +"static void\n" +"foo_finalize(PyObject *self)\n" +"{\n" +" // 現在の例外があれば保存する。\n" +" PyObject *exc = PyErr_GetRaisedException();\n" +"\n" +" // ...\n" +"\n" +" if (do_something_that_might_raise() != success_indicator) {\n" +" PyErr_WriteUnraisable(self);\n" +" goto done;\n" +" }\n" +"\n" +"done:\n" +" // 保存した例外を復元する。上で発生した例外は黙って捨てられるので、\n" +" // 必要であれば先に必ず PyErr_WriteUnraisable を呼び出す。\n" +" //\n" +" PyErr_SetRaisedException(exc);\n" +"}" -#: ../../c-api/typeobj.rst:2495 msgid "" "Before version 3.8 it was necessary to set the :c:macro:" "`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to be used. " "This is no longer required." msgstr "" +"バージョン 3.8 より前は、このフィールドを使うために :c:macro:" +"`Py_TPFLAGS_HAVE_FINALIZE` フラグビットの設定が必要でした。\n" +"現在は不要です。" -#: ../../c-api/typeobj.rst:2501 msgid ":pep:`442`: \"Safe object finalization\"" -msgstr "" +msgstr ":pep:`442`: 「安全なオブジェクトのファイナライズ」" -#: ../../c-api/typeobj.rst:2504 msgid ":c:func:`PyObject_CallFinalizer`" -msgstr "" +msgstr ":c:func:`PyObject_CallFinalizer`" -#: ../../c-api/typeobj.rst:2505 msgid ":c:func:`PyObject_CallFinalizerFromDealloc`" -msgstr "" +msgstr ":c:func:`PyObject_CallFinalizerFromDealloc`" -#: ../../c-api/typeobj.rst:2512 msgid "" "A :ref:`vectorcall function ` to use for calls of this type " "object (rather than instances). In other words, ``tp_vectorcall`` can be " "used to optimize ``type.__call__``, which typically returns a new instance " "of *type*." msgstr "" +"インスタンスではなく、この型オブジェクト自体の呼び出しに使う :ref:" +"`vectorcall 関数 ` です。\n" +"つまり ``tp_vectorcall`` は、通常は *type* の新しいインスタンスを返す ``type." +"__call__`` の最適化に使えます。" -#: ../../c-api/typeobj.rst:2517 msgid "" "As with any vectorcall function, if ``tp_vectorcall`` is ``NULL``, the " "*tp_call* protocol (``Py_TYPE(type)->tp_call``) is used instead." msgstr "" +"他の vectorcall 関数と同様に、``tp_vectorcall`` が ``NULL`` の場合は " +"*tp_call* プロトコル (``Py_TYPE(type)->tp_call``) が代わりに使われます。" -#: ../../c-api/typeobj.rst:2522 msgid "" "The :ref:`vectorcall protocol ` requires that the vectorcall " "function has the same behavior as the corresponding ``tp_call``. This means " "that ``type->tp_vectorcall`` must match the behavior of ``Py_TYPE(type)-" ">tp_call``." msgstr "" +":ref:`vectorcall プロトコル ` では、vectorcall 関数は対応する " +"``tp_call`` と同じように動作しなければなりません。\n" +"つまり ``type->tp_vectorcall`` は ``Py_TYPE(type)->tp_call`` と同じように動作" +"する必要があります。" #: ../../c-api/typeobj.rst:2527 msgid "" @@ -4056,9 +4647,8 @@ msgid "" "must behave the same as :c:expr:`PyType_Type->tp_call`, which:" msgstr "" -#: ../../c-api/typeobj.rst:2531 msgid "calls ``type->tp_new``," -msgstr "" +msgstr "``type->tp_new`` を呼び出します。" #: ../../c-api/typeobj.rst:2533 msgid "" @@ -4066,11 +4656,9 @@ msgid "" "of ``tp_new``, and" msgstr "" -#: ../../c-api/typeobj.rst:2536 msgid "returns the result of ``tp_new``." -msgstr "" +msgstr "``tp_new`` の結果を返します。" -#: ../../c-api/typeobj.rst:2538 msgid "" "Typically, ``tp_vectorcall`` is overridden to optimize this process for " "specific :c:member:`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject." @@ -4078,6 +4666,12 @@ msgid "" "overridden (using :py:func:`~object.__new__` and :py:func:`~object." "__init__`, respectively)." msgstr "" +"通常、特定の :c:member:`~PyTypeObject.tp_new` と :c:member:`~PyTypeObject." +"tp_init` に対してこの処理を最適化するために、``tp_vectorcall`` をオーバーライ" +"ドします。\n" +"利用者がサブクラス化できる型でこれを行う場合、どちらも (それぞれ :py:func:" +"`~object.__new__` と :py:func:`~object.__init__` を使って) オーバーライドされ" +"る可能性があることに注意してください。" #: ../../c-api/typeobj.rst:2549 msgid "This field is never inherited." @@ -4088,70 +4682,80 @@ msgid "(the field exists since 3.8 but it's only used since 3.9)" msgstr "" "(このフィールドは3.8から存在していますが、3.9以降でしか利用できません)" -#: ../../c-api/typeobj.rst:2556 msgid "Internal. Do not use." msgstr "" +"内部使用専用です。\n" +"使わないでください。" -#: ../../c-api/typeobj.rst:2564 msgid "Static Types" -msgstr "" +msgstr "静的な型" -#: ../../c-api/typeobj.rst:2566 msgid "" "Traditionally, types defined in C code are *static*, that is, a static :c:" "type:`PyTypeObject` structure is defined directly in code and initialized " "using :c:func:`PyType_Ready`." msgstr "" +"従来、C コードで定義する型は *静的* なものです。\n" +"つまり、静的な :c:type:`PyTypeObject` 構造体をコード内に直接定義し、:c:func:" +"`PyType_Ready` で初期化します。" -#: ../../c-api/typeobj.rst:2570 msgid "" "This results in types that are limited relative to types defined in Python:" msgstr "" +"この方法で作成される型には、Python で定義する型と比べて次の制約があります。" -#: ../../c-api/typeobj.rst:2572 msgid "" "Static types are limited to one base, i.e. they cannot use multiple " "inheritance." -msgstr "" +msgstr "静的な型の基底クラスは 1 つに限られ、多重継承は使えません。" -#: ../../c-api/typeobj.rst:2574 msgid "" "Static type objects (but not necessarily their instances) are immutable. It " "is not possible to add or modify the type object's attributes from Python." msgstr "" +"静的な型オブジェクトは変更不能です (そのインスタンスが変更不能とは限りませ" +"ん)。\n" +"Python から型オブジェクトの属性を追加したり変更したりすることはできません。" -#: ../../c-api/typeobj.rst:2576 msgid "" "Static type objects are shared across :ref:`sub-interpreters `, so they should not include any subinterpreter-" "specific state." msgstr "" +"静的な型オブジェクトは :ref:`サブインタープリタ ` 間" +"で共有されるため、サブインタープリタ固有の状態を含めるべきではありません。" -#: ../../c-api/typeobj.rst:2580 msgid "" "Also, since :c:type:`PyTypeObject` is only part of the :ref:`Limited API " "` as an opaque struct, any extension modules using static " "types must be compiled for a specific Python minor version." msgstr "" +"また、:c:type:`PyTypeObject` は不透明な構造体としてのみ :ref:`Limited API " +"` に含まれるため、静的な型を使う拡張モジュールは、特定の " +"Python マイナーバージョン向けにコンパイルしなければなりません。" -#: ../../c-api/typeobj.rst:2588 msgid "Heap Types" -msgstr "" +msgstr "ヒープ型" -#: ../../c-api/typeobj.rst:2590 msgid "" "An alternative to :ref:`static types ` is *heap-allocated " "types*, or *heap types* for short, which correspond closely to classes " "created by Python's ``class`` statement. Heap types have the :c:macro:" "`Py_TPFLAGS_HEAPTYPE` flag set." msgstr "" +":ref:`静的な型 ` の代わりに使えるのが、*ヒープに割り当てられた" +"型*、略して *ヒープ型* です。\n" +"Python の ``class`` 文で作成したクラスに近いものです。\n" +"ヒープ型には :c:macro:`Py_TPFLAGS_HEAPTYPE` フラグが設定されます。" -#: ../../c-api/typeobj.rst:2595 msgid "" "This is done by filling a :c:type:`PyType_Spec` structure and calling :c:" "func:`PyType_FromSpec`, :c:func:`PyType_FromSpecWithBases`, :c:func:" "`PyType_FromModuleAndSpec`, or :c:func:`PyType_FromMetaclass`." msgstr "" +":c:type:`PyType_Spec` 構造体に値を設定し、:c:func:`PyType_FromSpec`、:c:func:" +"`PyType_FromSpecWithBases`、:c:func:`PyType_FromModuleAndSpec`、:c:func:" +"`PyType_FromMetaclass` のいずれかを呼び出して作成します。" #: ../../c-api/typeobj.rst:2603 msgid "Number Object Structures" @@ -4172,7 +4776,6 @@ msgstr "" msgid "Here is the structure definition::" msgstr "以下は構造体の定義です::" -#: ../../c-api/typeobj.rst:2615 msgid "" "typedef struct {\n" " binaryfunc nb_add;\n" @@ -4217,6 +4820,48 @@ msgid "" " binaryfunc nb_inplace_matrix_multiply;\n" "} PyNumberMethods;" msgstr "" +"typedef struct {\n" +" binaryfunc nb_add;\n" +" binaryfunc nb_subtract;\n" +" binaryfunc nb_multiply;\n" +" binaryfunc nb_remainder;\n" +" binaryfunc nb_divmod;\n" +" ternaryfunc nb_power;\n" +" unaryfunc nb_negative;\n" +" unaryfunc nb_positive;\n" +" unaryfunc nb_absolute;\n" +" inquiry nb_bool;\n" +" unaryfunc nb_invert;\n" +" binaryfunc nb_lshift;\n" +" binaryfunc nb_rshift;\n" +" binaryfunc nb_and;\n" +" binaryfunc nb_xor;\n" +" binaryfunc nb_or;\n" +" unaryfunc nb_int;\n" +" void *nb_reserved;\n" +" unaryfunc nb_float;\n" +"\n" +" binaryfunc nb_inplace_add;\n" +" binaryfunc nb_inplace_subtract;\n" +" binaryfunc nb_inplace_multiply;\n" +" binaryfunc nb_inplace_remainder;\n" +" ternaryfunc nb_inplace_power;\n" +" binaryfunc nb_inplace_lshift;\n" +" binaryfunc nb_inplace_rshift;\n" +" binaryfunc nb_inplace_and;\n" +" binaryfunc nb_inplace_xor;\n" +" binaryfunc nb_inplace_or;\n" +"\n" +" binaryfunc nb_floor_divide;\n" +" binaryfunc nb_true_divide;\n" +" binaryfunc nb_inplace_floor_divide;\n" +" binaryfunc nb_inplace_true_divide;\n" +"\n" +" unaryfunc nb_index;\n" +"\n" +" binaryfunc nb_matrix_multiply;\n" +" binaryfunc nb_inplace_matrix_multiply;\n" +"} PyNumberMethods;" #: ../../c-api/typeobj.rst:2660 msgid "" @@ -4233,12 +4878,15 @@ msgstr "" "ば、二項関数と三項関数は ``Py_NotImplemented`` を返さなければならず、他のエ" "ラーが起こった場合は、``NULL`` を返して例外を設定しなければなりません。" -#: ../../c-api/typeobj.rst:2669 msgid "" "The :c:member:`~PyNumberMethods.nb_reserved` field should always be " "``NULL``. It was previously called :c:member:`!nb_long`, and was renamed in " "Python 3.0.1." msgstr "" +":c:member:`~PyNumberMethods.nb_reserved` フィールドは常に ``NULL`` にするべき" +"です。\n" +"以前は :c:member:`!nb_long` という名前でしたが、Python 3.0.1 で改名されまし" +"た。" #: ../../c-api/typeobj.rst:2820 msgid "Mapping Object Structures" @@ -4275,7 +4923,6 @@ msgstr "" "スロットは :c:func:`PyMapping_Check` が ``1`` を返すためには必要で、そうでな" "ければ ``NULL`` の場合があります。" -#: ../../c-api/typeobj.rst:2849 msgid "" "This function is used by :c:func:`PyObject_SetItem`, :c:func:" "`PyObject_DelItem`, :c:func:`PySequence_SetSlice` and :c:func:" @@ -4284,6 +4931,12 @@ msgid "" "If this slot is ``NULL``, the object does not support item assignment and " "deletion." msgstr "" +"この関数は :c:func:`PyObject_SetItem`、:c:func:`PyObject_DelItem`、:c:func:" +"`PySequence_SetSlice`、:c:func:`PySequence_DelSlice` で使われます。\n" +"シグネチャは :c:func:`!PyObject_SetItem` と同じですが、要素を削除するために " +"*v* を ``NULL`` にすることもできます。\n" +"このスロットが ``NULL`` の場合、オブジェクトは要素の代入と削除をサポートしま" +"せん。" #: ../../c-api/typeobj.rst:2860 msgid "Sequence Object Structures" @@ -4297,13 +4950,17 @@ msgstr "" "この構造体はシーケンス型プロトコルを実装するために使われる関数群へのポインタ" "を保持しています。" -#: ../../c-api/typeobj.rst:2871 msgid "" "This function is used by :c:func:`PySequence_Size` and :c:func:" "`PyObject_Size`, and has the same signature. It is also used for handling " "negative indices via the :c:member:`~PySequenceMethods.sq_item` and the :c:" "member:`~PySequenceMethods.sq_ass_item` slots." msgstr "" +"この関数は :c:func:`PySequence_Size` と :c:func:`PyObject_Size` で使われ、そ" +"れらと同じシグネチャを持ちます。\n" +":c:member:`~PySequenceMethods.sq_item` スロットや :c:member:" +"`~PySequenceMethods.sq_ass_item` スロットを使う際の、負のインデックスの処理に" +"も使われます。" #: ../../c-api/typeobj.rst:2880 msgid "" @@ -4325,7 +4982,6 @@ msgstr "" "す。また、 ``*`` 演算でも、 :c:member:`~PyNumberMethods.nb_multiply` スロット" "による数値乗算を試したあとに利用されます。" -#: ../../c-api/typeobj.rst:2896 msgid "" "This function is used by :c:func:`PySequence_GetItem` and has the same " "signature. It is also used by :c:func:`PyObject_GetItem`, after trying the " @@ -4333,8 +4989,13 @@ msgid "" "slot must be filled for the :c:func:`PySequence_Check` function to return " "``1``, it can be ``NULL`` otherwise." msgstr "" +"この関数は :c:func:`PySequence_GetItem` で使われ、同じシグネチャを持ちま" +"す。\n" +":c:func:`PyObject_GetItem` でも、:c:member:`~PyMappingMethods.mp_subscript` " +"スロットによる添字指定を試した後で使われます。\n" +":c:func:`PySequence_Check` が ``1`` を返すにはこのスロットの設定が必要です" +"が、それ以外の場合は ``NULL`` にできます。" -#: ../../c-api/typeobj.rst:2902 msgid "" "Negative indexes are handled as follows: if the :c:member:" "`~PySequenceMethods.sq_length` slot is filled, it is called and the sequence " @@ -4342,8 +5003,13 @@ msgid "" "`~PySequenceMethods.sq_item`. If :c:member:`!sq_length` is ``NULL``, the " "index is passed as is to the function." msgstr "" +"負のインデックスは次のように処理されます。\n" +":c:member:`~PySequenceMethods.sq_length` スロットが設定されていれば、それを呼" +"び出してシーケンスの長さを取得し、正のインデックスを計算して :c:member:" +"`~PySequenceMethods.sq_item` に渡します。\n" +":c:member:`!sq_length` が ``NULL`` の場合は、インデックスをそのまま関数に渡し" +"ます。" -#: ../../c-api/typeobj.rst:2911 msgid "" "This function is used by :c:func:`PySequence_SetItem` and has the same " "signature. It is also used by :c:func:`PyObject_SetItem` and :c:func:" @@ -4351,6 +5017,13 @@ msgid "" "member:`~PyMappingMethods.mp_ass_subscript` slot. This slot may be left to " "``NULL`` if the object does not support item assignment and deletion." msgstr "" +"この関数は :c:func:`PySequence_SetItem` で使われ、同じシグネチャを持ちま" +"す。\n" +":c:func:`PyObject_SetItem` と :c:func:`PyObject_DelItem` でも、:c:member:" +"`~PyMappingMethods.mp_ass_subscript` スロットによる要素の代入や削除を試した後" +"で使われます。\n" +"オブジェクトが要素の代入と削除をサポートしない場合、このスロットは ``NULL`` " +"のままにできます。" #: ../../c-api/typeobj.rst:2922 msgid "" @@ -4363,7 +5036,6 @@ msgstr "" "PySequence_Contains` はシンプルにマッチするオブジェクトを見つけるまでシーケン" "スを巡回します。" -#: ../../c-api/typeobj.rst:2931 msgid "" "This function is used by :c:func:`PySequence_InPlaceConcat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -4372,8 +5044,15 @@ msgid "" "augmented assignment ``+=``, after trying numeric in-place addition via the :" "c:member:`~PyNumberMethods.nb_inplace_add` slot." msgstr "" +"この関数は :c:func:`PySequence_InPlaceConcat` で使われ、同じシグネチャを持ち" +"ます。\n" +"第 1 オペランドを変更して返すべきです。\n" +"このスロットは ``NULL`` のままにできます。\n" +"その場合 :c:func:`!PySequence_InPlaceConcat` は :c:func:`PySequence_Concat` " +"にフォールバックします。\n" +"累算代入 ``+=`` でも、:c:member:`~PyNumberMethods.nb_inplace_add` スロットに" +"よる数値のインプレース加算を試した後で使われます。" -#: ../../c-api/typeobj.rst:2942 msgid "" "This function is used by :c:func:`PySequence_InPlaceRepeat` and has the same " "signature. It should modify its first operand, and return it. This slot " @@ -4382,6 +5061,14 @@ msgid "" "augmented assignment ``*=``, after trying numeric in-place multiplication " "via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot." msgstr "" +"この関数は :c:func:`PySequence_InPlaceRepeat` で使われ、同じシグネチャを持ち" +"ます。\n" +"第 1 オペランドを変更して返すべきです。\n" +"このスロットは ``NULL`` のままにできます。\n" +"その場合 :c:func:`!PySequence_InPlaceRepeat` は :c:func:`PySequence_Repeat` " +"にフォールバックします。\n" +"累算代入 ``*=`` でも、:c:member:`~PyNumberMethods.nb_inplace_multiply` スロッ" +"トによる数値のインプレース乗算を試した後で使われます。" #: ../../c-api/typeobj.rst:2953 msgid "Buffer Object Structures" @@ -4404,9 +5091,8 @@ msgstr "" msgid "The signature of this function is::" msgstr "この関数のシグネチャは以下の通りです::" -#: ../../c-api/typeobj.rst:2967 msgid "int (PyObject *exporter, Py_buffer *view, int flags);" -msgstr "" +msgstr "int (PyObject *exporter, Py_buffer *view, int flags);" #: ../../c-api/typeobj.rst:2969 msgid "" @@ -4418,11 +5104,13 @@ msgstr "" "求を処理します。ステップ(3) を除いて、この関数の実装では以下のステップを行わ" "なければなりません:" -#: ../../c-api/typeobj.rst:2973 msgid "" "Check if the request can be met. If not, raise :exc:`BufferError`, set " "``view->obj`` to ``NULL`` and return ``-1``." msgstr "" +"要求を満たせるか確認します。\n" +"満たせない場合は :exc:`BufferError` を送出し、``view->obj`` を ``NULL`` に設" +"定して ``-1`` を返します。" #: ../../c-api/typeobj.rst:2976 msgid "Fill in the requested fields." @@ -4432,48 +5120,51 @@ msgstr "要求されたフィールドを埋めます。" msgid "Increment an internal counter for the number of exports." msgstr "エクスポートした回数を保持する内部カウンタをインクリメントします。" -#: ../../c-api/typeobj.rst:2980 msgid "Set ``view->obj`` to *exporter* and increment ``view->obj``." msgstr "" +"``view->obj`` に *exporter* を設定し、``view->obj`` の参照カウントを増やしま" +"す。" #: ../../c-api/typeobj.rst:2982 msgid "Return ``0``." msgstr "``0`` を返します。" -#: ../../c-api/typeobj.rst:2984 ../../c-api/typeobj.rst:3047 msgid "**Thread safety:**" -msgstr "" +msgstr "**スレッド安全性:**" -#: ../../c-api/typeobj.rst:2986 msgid "In the :term:`free-threaded build`, implementations must ensure:" msgstr "" +":term:`フリースレッドビルド ` では、実装は次を保証しなけ" +"ればなりません。" -#: ../../c-api/typeobj.rst:2988 msgid "The export counter increment in step (3) is atomic." -msgstr "" +msgstr "手順 (3) のエクスポート数カウンタの加算がアトミックであること。" -#: ../../c-api/typeobj.rst:2990 msgid "" "The underlying buffer data remains valid and at a stable memory location for " "the lifetime of all exports." msgstr "" +"すべてのエクスポートの生存期間中、基になるバッファデータが有効で、メモリ上の" +"位置も変わらないこと。" -#: ../../c-api/typeobj.rst:2993 msgid "" "For objects that support resizing or reallocation (such as :class:" "`bytearray`), the export counter is checked atomically before such " "operations, and :exc:`BufferError` is raised if exports exist." msgstr "" +"サイズ変更や再割り当てをサポートするオブジェクト (:class:`bytearray` など) で" +"は、そうした操作の前にエクスポート数カウンタをアトミックに検査し、エクスポー" +"トが存在すれば :exc:`BufferError` を送出すること。" -#: ../../c-api/typeobj.rst:2997 msgid "The function is safe to call concurrently from multiple threads." -msgstr "" +msgstr "複数のスレッドから同時に呼び出しても安全であること。" -#: ../../c-api/typeobj.rst:2999 msgid "" "See also :ref:`thread-safety-memoryview` for the Python-level thread safety " "guarantees of :class:`memoryview` objects." msgstr "" +":class:`memoryview` オブジェクトの Python レベルでのスレッド安全性の保証につ" +"いては、:ref:`thread-safety-memoryview` も参照してください。" #: ../../c-api/typeobj.rst:3002 msgid "" @@ -4483,17 +5174,19 @@ msgstr "" "*exporter* がバッファプロバイダのチェインかツリーの一部であれば、2つの主要な" "方式が使用できます:" -#: ../../c-api/typeobj.rst:3005 msgid "" "Re-export: Each member of the tree acts as the exporting object and sets " "``view->obj`` to a new reference to itself." msgstr "" +"再エクスポート: ツリー内の各オブジェクトがエクスポート元として動作し、``view-" +">obj`` に自分自身への新しい参照を設定します。" -#: ../../c-api/typeobj.rst:3008 msgid "" "Redirect: The buffer request is redirected to the root object of the tree. " "Here, ``view->obj`` will be a new reference to the root object." msgstr "" +"転送: バッファの要求をツリーのルートオブジェクトに転送します。\n" +"この場合、``view->obj`` はルートオブジェクトへの新しい参照になります。" #: ../../c-api/typeobj.rst:3012 msgid "" @@ -4536,9 +5229,8 @@ msgstr "" ":c:func:`PyObject_GetBuffer` は、この関数をラップするコンシューマ向けのイン" "ターフェースです。" -#: ../../c-api/typeobj.rst:3036 msgid "void (PyObject *exporter, Py_buffer *view);" -msgstr "" +msgstr "void (PyObject *exporter, Py_buffer *view);" #: ../../c-api/typeobj.rst:3038 msgid "" @@ -4561,39 +5253,42 @@ msgid "If the counter is ``0``, free all memory associated with *view*." msgstr "" "カウンタが ``0`` の場合は、*view* に関連付けられた全てのメモリを解放します。" -#: ../../c-api/typeobj.rst:3049 msgid "In the :term:`free-threaded build`:" -msgstr "" +msgstr ":term:`フリースレッドビルド ` では:" -#: ../../c-api/typeobj.rst:3051 msgid "The export counter decrement in step (1) must be atomic." msgstr "" +"手順 (1) のエクスポート数カウンタの減算は、アトミックでなければなりません。" -#: ../../c-api/typeobj.rst:3053 msgid "" "Resource cleanup when the counter reaches zero must be done atomically, as " "the final release may race with concurrent releases from other threads and " "deallocation must only happen once." msgstr "" +"カウンタがゼロになったときのリソースの後片付けは、アトミックに行わなければな" +"りません。\n" +"最後の解放が他のスレッドで同時に行われる解放と競合する可能性があり、メモリの" +"解放は 1 度だけ行う必要があるためです。" -#: ../../c-api/typeobj.rst:3057 msgid "" "The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep " "track of buffer-specific resources. This field is guaranteed to remain " "constant, while a consumer MAY pass a copy of the original buffer as the " "*view* argument." msgstr "" -"エクスポータは、バッファ固有のリソースを監視し続けるために :c:member:" -"`~Py_buffer.internal` フィールドを使わなければなりません。このフィールドは、" -"コンシューマが *view* 引数としてオリジナルのバッファのコピーを渡しているであ" -"ろう間、変わらないことが保証されています。" +"エクスポータは、バッファ固有のリソースを管理するために :c:member:`~Py_buffer." +"internal` フィールドを使わなければなりません。\n" +"このフィールドの値は変わらないことが保証されますが、コンシューマは元のバッ" +"ファのコピーを *view* 引数として渡しても構いません。" -#: ../../c-api/typeobj.rst:3063 msgid "" "This function MUST NOT decrement ``view->obj``, since that is done " "automatically in :c:func:`PyBuffer_Release` (this scheme is useful for " "breaking reference cycles)." msgstr "" +"この関数は ``view->obj`` の参照カウントを減らしては **いけません**。\n" +":c:func:`PyBuffer_Release` が自動的に行うためです (この仕組みは循環参照の解消" +"に役立ちます)。" #: ../../c-api/typeobj.rst:3068 msgid "" @@ -4615,7 +5310,6 @@ msgstr "" "この構造体は :term:`awaitable` オブジェクトと :term:`asynchronous iterator` " "オブジェクトを実装するのに必要な関数へのポインタを保持しています。" -#: ../../c-api/typeobj.rst:3087 msgid "" "typedef struct {\n" " unaryfunc am_await;\n" @@ -4624,10 +5318,15 @@ msgid "" " sendfunc am_send;\n" "} PyAsyncMethods;" msgstr "" +"typedef struct {\n" +" unaryfunc am_await;\n" +" unaryfunc am_aiter;\n" +" unaryfunc am_anext;\n" +" sendfunc am_send;\n" +"} PyAsyncMethods;" -#: ../../c-api/typeobj.rst:3100 msgid "PyObject *am_await(PyObject *self);" -msgstr "" +msgstr "PyObject *am_await(PyObject *self);" #: ../../c-api/typeobj.rst:3102 msgid "" @@ -4645,15 +5344,16 @@ msgstr "" "オブジェクトが :term:`awaitable` でない場合、このスロットを ``NULL`` に設定し" "ます。" -#: ../../c-api/typeobj.rst:3113 msgid "PyObject *am_aiter(PyObject *self);" -msgstr "" +msgstr "PyObject *am_aiter(PyObject *self);" -#: ../../c-api/typeobj.rst:3115 msgid "" "Must return an :term:`asynchronous iterator` object. See :meth:`~object." "__anext__` for details." msgstr "" +":term:`非同期イテレータ ` オブジェクトを返さなければな" +"りません。\n" +"詳細は :meth:`~object.__anext__` を参照してください。" #: ../../c-api/typeobj.rst:3118 msgid "" @@ -4663,30 +5363,31 @@ msgstr "" "オブジェクトが非同期反復処理のプロトコルを実装していない場合、このスロットを " "``NULL`` に設定します。" -#: ../../c-api/typeobj.rst:3127 msgid "PyObject *am_anext(PyObject *self);" -msgstr "" +msgstr "PyObject *am_anext(PyObject *self);" -#: ../../c-api/typeobj.rst:3129 msgid "" "Must return an :term:`awaitable` object. See :meth:`~object.__anext__` for " "details. This slot may be set to ``NULL``." msgstr "" +":term:`待機可能 ` オブジェクトを返さなければなりません。\n" +"詳細は :meth:`~object.__anext__` を参照してください。\n" +"このスロットは ``NULL`` にできます。" -#: ../../c-api/typeobj.rst:3139 msgid "PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" msgstr "" +"PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);" -#: ../../c-api/typeobj.rst:3141 msgid "" "See :c:func:`PyIter_Send` for details. This slot may be set to ``NULL``." msgstr "" +"詳細は :c:func:`PyIter_Send` を参照してください。\n" +"このスロットは ``NULL`` にできます。" #: ../../c-api/typeobj.rst:3150 msgid "Slot Type typedefs" msgstr "Slot Type typedefs" -#: ../../c-api/typeobj.rst:3154 msgid "" "The purpose of this function is to separate memory allocation from memory " "initialization. It should return a pointer to a block of memory of adequate " @@ -4699,6 +5400,17 @@ msgid "" "a multiple of ``sizeof(void*)``; otherwise, *nitems* is not used and the " "length of the block should be :c:member:`~PyTypeObject.tp_basicsize`." msgstr "" +"この関数の目的は、メモリの割り当てと初期化を分離することです。\n" +"インスタンスに十分な長さを持ち、適切にアラインメントされ、ゼロで初期化された" +"メモリブロックへのポインタを返すべきです。\n" +"ただし、:c:member:`~PyObject.ob_refcnt` は ``1`` に、:c:member:`~PyObject." +"ob_type` は型引数に設定します。\n" +"型の :c:member:`~PyTypeObject.tp_itemsize` がゼロでなければ、オブジェクトの :" +"c:member:`~PyVarObject.ob_size` フィールドを *nitems* に初期化し、割り当てる" +"メモリブロックの長さは ``tp_basicsize + nitems*tp_itemsize`` を " +"``sizeof(void*)`` の倍数に切り上げた値にするべきです。\n" +"それ以外の場合、*nitems* は使わず、ブロックの長さは :c:member:`~PyTypeObject." +"tp_basicsize` にするべきです。" #: ../../c-api/typeobj.rst:3164 msgid "" @@ -4790,11 +5502,9 @@ msgstr "" "ケースを実演しています。より多くの例や実践的な情報、チュートリアルが必要な" "ら、:ref:`defining-new-types` や :ref:`new-types-topics` を参照してください。" -#: ../../c-api/typeobj.rst:3266 msgid "A basic :ref:`static type `::" -msgstr "" +msgstr "基本的な :ref:`静的な型 `。 ::" -#: ../../c-api/typeobj.rst:3268 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4811,6 +5521,20 @@ msgid "" " .tp_repr = (reprfunc)myobj_repr,\n" "};" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +" const char *data;\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject),\n" +" .tp_doc = PyDoc_STR(\"My オブジェクト\"),\n" +" .tp_new = myobj_new,\n" +" .tp_dealloc = (destructor)myobj_dealloc,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +"};" #: ../../c-api/typeobj.rst:3283 msgid "" @@ -4820,7 +5544,6 @@ msgstr "" "より冗長な初期化子を用いた古いコードを(特にCPythonのコードベース中で)見かけ" "ることがあるかもしれません::" -#: ../../c-api/typeobj.rst:3286 msgid "" "static PyTypeObject MyObject_Type = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -4863,6 +5586,46 @@ msgid "" " myobj_new, /* tp_new */\n" "};" msgstr "" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" \"mymod.MyObject\", /* tp_name */\n" +" sizeof(MyObject), /* tp_basicsize */\n" +" 0, /* tp_itemsize */\n" +" (destructor)myobj_dealloc, /* tp_dealloc */\n" +" 0, /* tp_vectorcall_offset */\n" +" 0, /* tp_getattr */\n" +" 0, /* tp_setattr */\n" +" 0, /* tp_as_async */\n" +" (reprfunc)myobj_repr, /* tp_repr */\n" +" 0, /* tp_as_number */\n" +" 0, /* tp_as_sequence */\n" +" 0, /* tp_as_mapping */\n" +" 0, /* tp_hash */\n" +" 0, /* tp_call */\n" +" 0, /* tp_str */\n" +" 0, /* tp_getattro */\n" +" 0, /* tp_setattro */\n" +" 0, /* tp_as_buffer */\n" +" 0, /* tp_flags */\n" +" PyDoc_STR(\"My オブジェクト\"), /* tp_doc */\n" +" 0, /* tp_traverse */\n" +" 0, /* tp_clear */\n" +" 0, /* tp_richcompare */\n" +" 0, /* tp_weaklistoffset */\n" +" 0, /* tp_iter */\n" +" 0, /* tp_iternext */\n" +" 0, /* tp_methods */\n" +" 0, /* tp_members */\n" +" 0, /* tp_getset */\n" +" 0, /* tp_base */\n" +" 0, /* tp_dict */\n" +" 0, /* tp_descr_get */\n" +" 0, /* tp_descr_set */\n" +" 0, /* tp_dictoffset */\n" +" 0, /* tp_init */\n" +" 0, /* tp_alloc */\n" +" myobj_new, /* tp_new */\n" +"};" #: ../../c-api/typeobj.rst:3327 msgid "A type that supports weakrefs, instance dicts, and hashing::" @@ -4894,14 +5657,15 @@ msgid "" "};" msgstr "" -#: ../../c-api/typeobj.rst:3352 msgid "" "A str subclass that cannot be subclassed and cannot be called to create " "instances (e.g. uses a separate factory func) using :c:macro:" "`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag::" msgstr "" +":c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` フラグを使い、サブクラス化も、呼" +"び出しによるインスタンスの作成もできない ``str`` のサブクラスです (例えば別の" +"ファクトリ関数を使います)。 ::" -#: ../../c-api/typeobj.rst:3356 msgid "" "typedef struct {\n" " PyUnicodeObject raw;\n" @@ -4918,13 +5682,26 @@ msgid "" " .tp_repr = (reprfunc)myobj_repr,\n" "};" msgstr "" +"typedef struct {\n" +" PyUnicodeObject raw;\n" +" char *extra;\n" +"} MyStr;\n" +"\n" +"static PyTypeObject MyStr_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyStr\",\n" +" .tp_basicsize = sizeof(MyStr),\n" +" .tp_base = NULL, // モジュール初期化時に &PyUnicode_Type を設定\n" +" .tp_doc = PyDoc_STR(\"独自の str\"),\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,\n" +" .tp_repr = (reprfunc)myobj_repr,\n" +"};" -#: ../../c-api/typeobj.rst:3371 msgid "" "The simplest :ref:`static type ` with fixed-length instances::" msgstr "" +"固定長のインスタンスを持つ、最も単純な :ref:`静的な型 `。 ::" -#: ../../c-api/typeobj.rst:3373 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -4935,14 +5712,21 @@ msgid "" " .tp_name = \"mymod.MyObject\",\n" "};" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +"};" -#: ../../c-api/typeobj.rst:3382 msgid "" "The simplest :ref:`static type ` with variable-length " "instances::" msgstr "" +"可変長のインスタンスを持つ、最も単純な :ref:`静的な型 `。 ::" -#: ../../c-api/typeobj.rst:3384 msgid "" "typedef struct {\n" " PyObject_VAR_HEAD\n" @@ -4956,6 +5740,17 @@ msgid "" " .tp_itemsize = sizeof(char *),\n" "};" msgstr "" +"typedef struct {\n" +" PyObject_VAR_HEAD\n" +" const char *data[1];\n" +"} MyObject;\n" +"\n" +"static PyTypeObject MyObject_Type = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"mymod.MyObject\",\n" +" .tp_basicsize = sizeof(MyObject) - sizeof(char *),\n" +" .tp_itemsize = sizeof(char *),\n" +"};" #: ../../c-api/typeobj.rst:927 ../../c-api/typeobj.rst:994 msgid "built-in function" diff --git a/c-api/unicode.po b/c-api/unicode.po index 89b86ccea..7d73fc346 100644 --- a/c-api/unicode.po +++ b/c-api/unicode.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/unicode.rst:6 @@ -30,7 +30,6 @@ msgstr "Unicode オブジェクトと codec" msgid "Unicode Objects" msgstr "Unicode オブジェクト" -#: ../../c-api/unicode.rst:11 msgid "" "Since the implementation of :pep:`393` in Python 3.3, Unicode objects " "internally use a variety of representations, in order to allow handling the " @@ -39,30 +38,38 @@ msgid "" "65536; otherwise, code points must be below 1114112 (which is the full " "Unicode range)." msgstr "" -"Python3.3 の :pep:`393` 実装から、メモリ効率を維持しながらUnicode文字の完全な" -"範囲を扱えるように、Unicodeオブジェクトは内部的に多様な表現形式を用いていま" -"す。すべてのコードポイントが128、256または65536以下の文字列に対して特別なケー" -"スが存在しますが、それ以外ではコードポイントは1114112以下 (これはすべての" -"Unicode範囲です) でなければなりません。" +"Python 3.3 で :pep:`393` が実装されて以来、Unicode オブジェクトは内部で複数の" +"表現形式を使っています。\n" +"これにより、メモリ効率を維持しながら Unicode 文字の全範囲を扱えます。\n" +"すべてのコードポイントが 128 未満、256 未満、または 65536 未満の文字列は特別" +"に扱います。\n" +"それ以外のコードポイントは 1114112 未満 (Unicode の全範囲) でなければなりませ" +"ん。" -#: ../../c-api/unicode.rst:17 msgid "" "UTF-8 representation is created on demand and cached in the Unicode object." msgstr "" +"UTF-8 表現は必要に応じて作成され、Unicode オブジェクト内にキャッシュされま" +"す。" -#: ../../c-api/unicode.rst:21 msgid "" "The internal buffer always includes an extra trailing null character for " "compatibility with null terminated C strings. This extra character is not " "counted in :c:func:`PyUnicode_GetLength` nor in the various *size* arguments " "of the functions below." msgstr "" +"内部バッファには、null 終端の C 文字列との互換性のため、末尾に常に追加の " +"null 文字が含まれます。\n" +"この追加文字は :c:func:`PyUnicode_GetLength` や、以下の関数の各種 *size* 引数" +"には数えません。" -#: ../../c-api/unicode.rst:27 msgid "" "The :c:type:`Py_UNICODE` representation has been removed since Python 3.12 " "with deprecated APIs. See :pep:`623` for more information." msgstr "" +":c:type:`Py_UNICODE` 表現は、非推奨の API とともに Python 3.12 で削除されまし" +"た。\n" +"詳細は :pep:`623` を参照してください。" #: ../../c-api/unicode.rst:33 msgid "Unicode Type" @@ -75,17 +82,21 @@ msgid "" msgstr "" "以下は Python の Unicode 実装に用いられている基本 Unicode オブジェクト型です:" -#: ../../c-api/unicode.rst:40 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python Unicode type. " "It is exposed to Python code as :py:class:`str`." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の Unicode 型を表しま" +"す。\n" +"Python コードには :py:class:`str` として公開されています。" -#: ../../c-api/unicode.rst:46 msgid "" "This instance of :c:type:`PyTypeObject` represents the Python Unicode " "iterator type. It is used to iterate over Unicode string objects." msgstr "" +"この :c:type:`PyTypeObject` のインスタンスは Python の Unicode イテレータ型を" +"表します。\n" +"Unicode 文字列オブジェクトの反復処理に使われます。" #: ../../c-api/unicode.rst:54 msgid "" @@ -109,26 +120,27 @@ msgstr "" "受け取って PyObject へのポインタを返すので、ほとんどの場合、これらの型を直接" "使うべきではありません。" -#: ../../c-api/unicode.rst:72 msgid "" "The structure of a particular object can be determined using the following " "macros. The macros cannot fail; their behavior is undefined if their " "argument is not a Python Unicode object." msgstr "" +"特定のオブジェクトの構造は、次のマクロで判定できます。\n" +"これらのマクロは失敗しませんが、引数が Python の Unicode オブジェクトでなけれ" +"ば動作は未定義です。" -#: ../../c-api/unicode.rst:81 msgid "True if *o* uses the :c:struct:`PyCompactUnicodeObject` structure." -msgstr "" +msgstr "*o* が :c:struct:`PyCompactUnicodeObject` 構造体を使っていれば真です。" -#: ../../c-api/unicode.rst:88 msgid "True if *o* uses the :c:struct:`PyASCIIObject` structure." -msgstr "" +msgstr "*o* が :c:struct:`PyASCIIObject` 構造体を使っていれば真です。" -#: ../../c-api/unicode.rst:93 msgid "" "The following APIs are C macros and static inlined functions for fast checks " "and access to internal read-only data of Unicode objects:" msgstr "" +"以下の API は、Unicode オブジェクトの高速な検査や、内部の読み出し専用データへ" +"のアクセスのための C マクロと静的インライン関数です:" #: ../../c-api/unicode.rst:98 msgid "" @@ -196,12 +208,12 @@ msgstr "" "*unicode* は \"正統な\" 表現形式の Unicode オブジェクトでなければなりません " "(ただしチェックはしません)。" -#: ../../c-api/unicode.rst:160 msgid "" "Write the code point *value* to the given zero-based *index* in a string." msgstr "" +"文字列のゼロから始まる *index* の位置に、コードポイント *value* を書き込みま" +"す。" -#: ../../c-api/unicode.rst:162 msgid "" "The *kind* value and *data* pointer must have been obtained from a string " "using :c:func:`PyUnicode_KIND` and :c:func:`PyUnicode_DATA` respectively. " @@ -209,24 +221,33 @@ msgid "" "PyUnicode_WRITE`. All requirements of :c:func:`PyUnicode_WriteChar` also " "apply." msgstr "" +"*kind* の値と *data* ポインタは、文字列からそれぞれ :c:func:`PyUnicode_KIND` " +"と :c:func:`PyUnicode_DATA` で取得したものでなければなりません。\n" +":c:func:`!PyUnicode_WRITE` の呼び出し中は、その文字列への参照を保持する必要が" +"あります。\n" +":c:func:`PyUnicode_WriteChar` のすべての要件も適用されます。" -#: ../../c-api/unicode.rst:168 msgid "" "The function performs no checks for any of its requirements, and is intended " "for usage in loops." msgstr "" +"この関数は要件が満たされているか一切検査せず、ループ内での使用を想定していま" +"す。" -#: ../../c-api/unicode.rst:176 msgid "" "Read a code point from a canonical representation *data* (as obtained with :" "c:func:`PyUnicode_DATA`). No checks are performed." msgstr "" +"正統な表現形式の *data* (:c:func:`PyUnicode_DATA` で取得したもの) からコード" +"ポイントを読み取ります。\n" +"検査は行いません。" -#: ../../c-api/unicode.rst:181 ../../c-api/unicode.rst:195 msgid "" "Accept reading the trailing null character at index :c:func:" "`PyUnicode_GetLength`." msgstr "" +":c:func:`PyUnicode_GetLength` が返すインデックスの位置にある、末尾の null 文" +"字を読み取れます。" #: ../../c-api/unicode.rst:189 msgid "" @@ -258,41 +279,47 @@ msgstr "" "文字列が、 :ref:`identifiers` 節の言語定義における有効な識別子であれば ``1`` " "を返します。それ以外の場合は ``0`` を返します。" -#: ../../c-api/unicode.rst:215 msgid "" "The function does not call :c:func:`Py_FatalError` anymore if the string is " "not ready." msgstr "" +"文字列が使用可能な状態でなくても、:c:func:`Py_FatalError` を呼び出さなくなり" +"ました。" -#: ../../c-api/unicode.rst:222 msgid "" "Return true if the string only contains ASCII characters. Equivalent to :py:" "meth:`str.isascii`." msgstr "" +"文字列に ASCII 文字しか含まれていなければ真を返します。\n" +":py:meth:`str.isascii` と等価です。" -#: ../../c-api/unicode.rst:230 msgid "" "If the hash of *str*, as returned by :c:func:`PyObject_Hash`, has been " "cached and is immediately available, return it. Otherwise, return ``-1`` " "*without* setting an exception." msgstr "" +":c:func:`PyObject_Hash` が返す *str* のハッシュ値がキャッシュ済みですぐに取得" +"できれば、その値を返します。\n" +"それ以外の場合は例外を設定 *せずに* ``-1`` を返します。" -#: ../../c-api/unicode.rst:234 msgid "" "If *str* is not a string (that is, if ``PyUnicode_Check(obj)`` is false), " "the behavior is undefined." msgstr "" +"*str* が文字列でない場合 (つまり ``PyUnicode_Check(obj)`` が偽の場合)、動作は" +"未定義です。" -#: ../../c-api/unicode.rst:237 msgid "This function never fails with an exception." -msgstr "" +msgstr "この関数が例外で失敗することはありません。" -#: ../../c-api/unicode.rst:239 msgid "" "Note that there are no guarantees on when an object's hash is cached, and " "the (non-)existence of a cached hash does not imply that the string has any " "other properties." msgstr "" +"オブジェクトのハッシュ値がいつキャッシュされるかは保証されず、キャッシュされ" +"たハッシュ値の有無が文字列の他の性質を示すわけではないことに注意してくださ" +"い。" #: ../../c-api/unicode.rst:245 msgid "Unicode Character Properties" @@ -359,11 +386,12 @@ msgid "" "Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character." msgstr "*ch* が英数文字かどうかに応じて ``1`` または ``0`` を返します。" -#: ../../c-api/unicode.rst:304 msgid "" "Return ``1`` or ``0`` depending on whether *ch* is a printable character, in " "the sense of :meth:`str.isprintable`." msgstr "" +"*ch* が :meth:`str.isprintable` の意味で表示可能な文字かどうかに応じて、" +"``1`` または ``0`` を返します。" #: ../../c-api/unicode.rst:308 msgid "These APIs can be used for fast direct character conversions:" @@ -387,11 +415,13 @@ msgid "" "``-1`` if this is not possible. This function does not raise exceptions." msgstr "" -#: ../../c-api/unicode.rst:334 msgid "" "Return the character *ch* converted to a single digit integer. Return ``-1`` " "if this is not possible. This function does not raise exceptions." msgstr "" +"文字 *ch* を 1 桁の整数に変換して返します。\n" +"変換できなければ ``-1`` を返します。\n" +"この関数は例外を送出しません。" #: ../../c-api/unicode.rst:340 msgid "" @@ -420,25 +450,31 @@ msgid "Check if *ch* is a low surrogate (``0xDC00 <= ch <= 0xDFFF``)." msgstr "" "*ch* が下位サロゲートかどうか (``0xDC00 <= ch <= 0xDFFF``) をチェックします。" -#: ../../c-api/unicode.rst:360 msgid "" "Return the high UTF-16 surrogate (``0xD800`` to ``0xDBFF``) for a Unicode " "code point in the range ``[0x10000; 0x10FFFF]``." msgstr "" +"``[0x10000; 0x10FFFF]`` の範囲の Unicode コードポイントに対応する、UTF-16 の" +"上位サロゲート (``0xD800`` から ``0xDBFF``) を返します。" -#: ../../c-api/unicode.rst:365 msgid "" "Return the low UTF-16 surrogate (``0xDC00`` to ``0xDFFF``) for a Unicode " "code point in the range ``[0x10000; 0x10FFFF]``." msgstr "" +"``[0x10000; 0x10FFFF]`` の範囲の Unicode コードポイントに対応する、UTF-16 の" +"下位サロゲート (``0xDC00`` から ``0xDFFF``) を返します。" -#: ../../c-api/unicode.rst:370 msgid "" "Join two surrogate code points and return a single :c:type:`Py_UCS4` value. " "*high* and *low* are respectively the leading and trailing surrogates in a " "surrogate pair. *high* must be in the range ``[0xD800; 0xDBFF]`` and *low* " "must be in the range ``[0xDC00; 0xDFFF]``." msgstr "" +"2 つのサロゲートコードポイントを結合し、1 つの :c:type:`Py_UCS4` 値を返しま" +"す。\n" +"*high* と *low* は、サロゲートペアのそれぞれ先頭と末尾のサロゲートです。\n" +"*high* は ``[0xD800; 0xDBFF]``、*low* は ``[0xDC00; 0xDFFF]`` の範囲内でなけ" +"ればなりません。" #: ../../c-api/unicode.rst:377 msgid "Creating and accessing Unicode strings" @@ -463,11 +499,9 @@ msgstr "" "その値は概算値として 127, 255, 65535, 1114111 の一番近い値に切り上げられま" "す。" -#: ../../c-api/unicode.rst:388 msgid "On error, set an exception and return ``NULL``." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/unicode.rst:390 msgid "" "After creation, the string can be filled by :c:func:`PyUnicode_WriteChar`, :" "c:func:`PyUnicode_CopyCharacters`, :c:func:`PyUnicode_Fill`, :c:func:" @@ -475,37 +509,46 @@ msgid "" "take care to not “use” the result while it is being modified. In particular, " "before it's filled with its final contents, a string:" msgstr "" +"作成後の文字列には、:c:func:`PyUnicode_WriteChar`、:c:func:" +"`PyUnicode_CopyCharacters`、:c:func:`PyUnicode_Fill`、:c:func:" +"`PyUnicode_WRITE` などで内容を書き込めます。\n" +"文字列はイミュータブルであることを想定しているため、変更中の結果を「使用」し" +"ないように注意してください。\n" +"特に、最終的な内容を書き込み終える前の文字列に対しては、以下を守る必要があり" +"ます:" -#: ../../c-api/unicode.rst:397 msgid "must not be hashed," -msgstr "" +msgstr "ハッシュ値を計算してはいけません。" -#: ../../c-api/unicode.rst:398 msgid "" "must not be :c:func:`converted to UTF-8 `, or " "another non-\"canonical\" representation," msgstr "" +":c:func:`UTF-8 に変換 ` したり、他の「正統でない」表" +"現形式に変換したりしてはいけません。" -#: ../../c-api/unicode.rst:400 msgid "must not have its reference count changed," -msgstr "" +msgstr "参照カウントを変更してはいけません。" -#: ../../c-api/unicode.rst:401 msgid "must not be shared with code that might do one of the above." -msgstr "" +msgstr "上記のいずれかを行う可能性のあるコードと共有してはいけません。" -#: ../../c-api/unicode.rst:403 msgid "" "This list is not exhaustive. Avoiding these uses is your responsibility; " "Python does not always check these requirements." msgstr "" +"この一覧はすべてを網羅しているわけではありません。\n" +"これらの使用を避けるのは利用側の責任であり、Python が常にこれらの要件を検査す" +"るとは限りません。" -#: ../../c-api/unicode.rst:406 msgid "" "To avoid accidentally exposing a partially-written string object, prefer " "using the :c:type:`PyUnicodeWriter` API, or one of the ``PyUnicode_From*`` " "functions below." msgstr "" +"書き込み途中の文字列オブジェクトを誤って公開しないよう、:c:type:" +"`PyUnicodeWriter` API または以下の ``PyUnicode_From*`` 関数のいずれかを使うこ" +"とを推奨します。" #: ../../c-api/unicode.rst:417 msgid "" @@ -519,44 +562,48 @@ msgstr "" "*buffer* は、与えられた kind に従って1文字あたり 1, 2, 4 バイトのいずれかを単" "位として、長さ *size* の配列へのポインタでなければなりません。" -#: ../../c-api/unicode.rst:422 msgid "" "If necessary, the input *buffer* is copied and transformed into the " "canonical representation. For example, if the *buffer* is a UCS4 string (:c:" "macro:`PyUnicode_4BYTE_KIND`) and it consists only of codepoints in the UCS1 " "range, it will be transformed into UCS1 (:c:macro:`PyUnicode_1BYTE_KIND`)." msgstr "" +"必要に応じて、入力の *buffer* をコピーして正統な表現形式に変換します。\n" +"例えば *buffer* が UCS4 文字列 (:c:macro:`PyUnicode_4BYTE_KIND`) で、UCS1 の" +"範囲内のコードポイントだけで構成されていれば、UCS1 (:c:macro:" +"`PyUnicode_1BYTE_KIND`) に変換します。" -#: ../../c-api/unicode.rst:428 msgid "" "All characters must be in range [U+0000; U+10ffff]. If *kind* is :c:macro:" "`PyUnicode_4BYTE_KIND` and the string contains invalid characters, the " "behavior is undefined." msgstr "" +"すべての文字は [U+0000; U+10ffff] の範囲内でなければなりません。\n" +"*kind* が :c:macro:`PyUnicode_4BYTE_KIND` で、文字列に無効な文字が含まれてい" +"る場合、動作は未定義です。" -#: ../../c-api/unicode.rst:437 msgid "" "Create a Unicode object from the char buffer *str*. The bytes will be " "interpreted as being UTF-8 encoded. The buffer is copied into the new " "object. The return value might be a shared object, i.e. modification of the " "data is not allowed." msgstr "" +"char 型のバッファ *str* から Unicode オブジェクトを作成します。\n" +"バイト列は UTF-8 でエンコードされているものとして解釈します。\n" +"バッファの内容を新しいオブジェクトにコピーします。\n" +"戻り値は共有オブジェクトの場合があるため、データの変更は許されません。" -#: ../../c-api/unicode.rst:443 msgid "This function raises :exc:`SystemError` when:" -msgstr "" +msgstr "次の場合、この関数は :exc:`SystemError` を送出します:" -#: ../../c-api/unicode.rst:445 msgid "*size* < 0," -msgstr "" +msgstr "*size* < 0 の場合。" -#: ../../c-api/unicode.rst:446 msgid "*str* is ``NULL`` and *size* > 0" -msgstr "" +msgstr "*str* が ``NULL`` で、*size* > 0 の場合。" -#: ../../c-api/unicode.rst:448 msgid "*str* == ``NULL`` with *size* > 0 is not allowed anymore." -msgstr "" +msgstr "*size* > 0 のときに *str* == ``NULL`` を指定できなくなりました。" #: ../../c-api/unicode.rst:454 msgid "" @@ -566,7 +613,6 @@ msgstr "" "UTF-8 エンコードされたnull終端のchar 型バッファ *str* から Unicode オブジェク" "トを生成します。" -#: ../../c-api/unicode.rst:460 msgid "" "Take a C :c:func:`printf`\\ -style *format* string and a variable number of " "arguments, calculate the size of the resulting Python Unicode string and " @@ -574,6 +620,11 @@ msgid "" "must be C types and must correspond exactly to the format characters in the " "*format* ASCII-encoded string." msgstr "" +"C の :c:func:`printf` 形式の書式文字列 *format* と可変個数の引数を受け取り、" +"結果の Python Unicode 文字列のサイズを計算し、値を書式化した文字列を返しま" +"す。\n" +"可変個数の引数は C の型でなければならず、ASCII でエンコードされた *format* 文" +"字列の書式指定文字に厳密に対応していなければなりません。" #: ../../c-api/unicode.rst:466 msgid "" @@ -593,25 +644,31 @@ msgid "" "types." msgstr "変換フラグ (オプション)。一部の変換型の結果に影響します。" -#: ../../c-api/unicode.rst:474 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is given in the next argument, which must be of type :c:expr:" "`int`, and the object to convert comes after the minimum field width and " "optional precision." msgstr "" +"最小フィールド幅 (省略可能)。\n" +"``'*'`` (アスタリスク) を指定した場合は、次の引数に実際の幅を :c:expr:`int` " +"型で渡します。\n" +"変換するオブジェクトは、最小フィールド幅と、省略可能な精度の後に渡します。" -#: ../../c-api/unicode.rst:479 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. If " "specified as ``'*'`` (an asterisk), the actual precision is given in the " "next argument, which must be of type :c:expr:`int`, and the value to convert " "comes after the precision." msgstr "" +"精度 (省略可能)。\n" +"``'.'`` (ドット) の後に精度を指定します。\n" +"``'*'`` (アスタリスク) を指定した場合は、次の引数に実際の精度を :c:expr:" +"`int` 型で渡します。\n" +"変換する値は精度の後に渡します。" -#: ../../c-api/unicode.rst:484 msgid "Length modifier (optional)." -msgstr "精度長変換子 (オプション)。" +msgstr "長さ修飾子 (省略可能)。" #: ../../c-api/unicode.rst:486 msgid "Conversion type." @@ -637,22 +694,23 @@ msgstr "``0``" msgid "The conversion will be zero padded for numeric values." msgstr "数値型に対してゼロによるパディングを行います。" -#: ../../c-api/unicode.rst:497 msgid "``-``" -msgstr "" +msgstr "``-``" -#: ../../c-api/unicode.rst:497 msgid "" "The converted value is left adjusted (overrides the ``0`` flag if both are " "given)." msgstr "" +"変換した値を左寄せにします (``0`` フラグも指定されている場合は、こちらが優先" +"されます)。" -#: ../../c-api/unicode.rst:501 msgid "" "The length modifiers for following integer conversions (``d``, ``i``, ``o``, " "``u``, ``x``, or ``X``) specify the type of the argument (:c:expr:`int` by " "default):" msgstr "" +"次の整数変換 (``d``、``i``、``o``、``u``、``x``、``X``) の長さ修飾子は、引数" +"の型 (デフォルトは :c:expr:`int`) を指定します:" #: ../../c-api/unicode.rst:508 msgid "Modifier" @@ -678,21 +736,17 @@ msgstr "``ll``" msgid ":c:expr:`long long` or :c:expr:`unsigned long long`" msgstr ":c:expr:`long long` または :c:expr:`unsigned long long`" -#: ../../c-api/unicode.rst:514 msgid "``j``" -msgstr "" +msgstr "``j``" -#: ../../c-api/unicode.rst:514 msgid ":c:type:`intmax_t` or :c:type:`uintmax_t`" -msgstr "" +msgstr ":c:type:`intmax_t` または :c:type:`uintmax_t`" -#: ../../c-api/unicode.rst:516 msgid "``z``" -msgstr "" +msgstr "``z``" -#: ../../c-api/unicode.rst:516 msgid ":c:type:`size_t` or :c:type:`ssize_t`" -msgstr "" +msgstr ":c:type:`size_t` または :c:type:`ssize_t`" #: ../../c-api/unicode.rst:518 msgid "``t``" @@ -702,19 +756,18 @@ msgstr "``t``" msgid ":c:type:`ptrdiff_t`" msgstr ":c:type:`ptrdiff_t`" -#: ../../c-api/unicode.rst:521 msgid "" "The length modifier ``l`` for following conversions ``s`` or ``V`` specify " "that the type of the argument is :c:expr:`const wchar_t*`." msgstr "" +"変換 ``s`` または ``V`` に付ける長さ修飾子 ``l`` は、引数の型が :c:expr:" +"`const wchar_t*` であることを指定します。" -#: ../../c-api/unicode.rst:524 msgid "The conversion specifiers are:" -msgstr "" +msgstr "変換指定子を以下に示します:" -#: ../../c-api/unicode.rst:530 msgid "Conversion Specifier" -msgstr "" +msgstr "変換指定子" #: ../../c-api/unicode.rst:531 msgid "Type" @@ -732,55 +785,45 @@ msgstr "``%``" msgid "*n/a*" msgstr "*n/a*" -#: ../../c-api/unicode.rst:536 msgid "The literal ``%`` character." -msgstr "" +msgstr "文字 ``%`` そのもの。" -#: ../../c-api/unicode.rst:538 msgid "``d``, ``i``" -msgstr "" +msgstr "``d``, ``i``" -#: ../../c-api/unicode.rst:539 ../../c-api/unicode.rst:543 -#: ../../c-api/unicode.rst:547 ../../c-api/unicode.rst:551 -#: ../../c-api/unicode.rst:555 msgid "Specified by the length modifier" -msgstr "" +msgstr "長さ修飾子で指定" -#: ../../c-api/unicode.rst:540 msgid "The decimal representation of a signed C integer." -msgstr "" +msgstr "符号付き C 整数の 10 進表現。" #: ../../c-api/unicode.rst:542 msgid "``u``" msgstr "``u``" -#: ../../c-api/unicode.rst:544 msgid "The decimal representation of an unsigned C integer." -msgstr "" +msgstr "符号なし C 整数の 10 進表現。" #: ../../c-api/unicode.rst:546 msgid "``o``" msgstr "``o``" -#: ../../c-api/unicode.rst:548 msgid "The octal representation of an unsigned C integer." -msgstr "" +msgstr "符号なし C 整数の 8 進表現。" #: ../../c-api/unicode.rst:550 msgid "``x``" msgstr "``x``" -#: ../../c-api/unicode.rst:552 msgid "The hexadecimal representation of an unsigned C integer (lowercase)." -msgstr "" +msgstr "符号なし C 整数の 16 進表現 (小文字)。" #: ../../c-api/unicode.rst:554 msgid "``X``" msgstr "``X``" -#: ../../c-api/unicode.rst:556 msgid "The hexadecimal representation of an unsigned C integer (uppercase)." -msgstr "" +msgstr "符号なし C 整数の 16 進表現 (大文字)。" #: ../../c-api/unicode.rst:558 msgid "``c``" @@ -790,9 +833,8 @@ msgstr "``c``" msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../c-api/unicode.rst:560 msgid "A single character." -msgstr "" +msgstr "1 文字。" #: ../../c-api/unicode.rst:562 msgid "``s``" @@ -850,78 +892,76 @@ msgstr "Unicode オブジェクト。" msgid "``V``" msgstr "``V``" -#: ../../c-api/unicode.rst:582 msgid ":c:expr:`PyObject*`, :c:expr:`const char*` or :c:expr:`const wchar_t*`" msgstr "" +":c:expr:`PyObject*`、:c:expr:`const char*`、または :c:expr:`const wchar_t*`" -#: ../../c-api/unicode.rst:583 msgid "" "A Unicode object (which may be ``NULL``) and a null-terminated C character " "array as a second parameter (which will be used, if the first parameter is " "``NULL``)." msgstr "" +"Unicode オブジェクト (``NULL`` でも構いません) と、2 番目の引数として null 終" +"端の C 文字配列を渡します (最初の引数が ``NULL`` の場合に使われます)。" -#: ../../c-api/unicode.rst:587 msgid "``S``" -msgstr "" +msgstr "``S``" #: ../../c-api/unicode.rst:589 msgid "The result of calling :c:func:`PyObject_Str`." msgstr ":c:func:`PyObject_Str` の戻り値。" -#: ../../c-api/unicode.rst:591 msgid "``R``" -msgstr "" +msgstr "``R``" #: ../../c-api/unicode.rst:593 msgid "The result of calling :c:func:`PyObject_Repr`." msgstr ":c:func:`PyObject_Repr` の戻り値。" -#: ../../c-api/unicode.rst:595 msgid "``T``" -msgstr "" +msgstr "``T``" -#: ../../c-api/unicode.rst:597 msgid "" "Get the fully qualified name of an object type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" +"オブジェクトの型の完全修飾名を取得します。\n" +":c:func:`PyType_GetFullyQualifiedName` を呼び出します。" -#: ../../c-api/unicode.rst:600 msgid "``#T``" -msgstr "" +msgstr "``#T``" -#: ../../c-api/unicode.rst:602 msgid "" "Similar to ``T`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" +"``T`` 形式と同様ですが、モジュール名と修飾名の区切りにコロン (``:``) を使いま" +"す。" #: ../../c-api/unicode.rst:605 msgid "``N``" msgstr "``N``" -#: ../../c-api/unicode.rst:606 ../../c-api/unicode.rst:611 msgid ":c:expr:`PyTypeObject*`" -msgstr "" +msgstr ":c:expr:`PyTypeObject*`" -#: ../../c-api/unicode.rst:607 msgid "" "Get the fully qualified name of a type; call :c:func:" "`PyType_GetFullyQualifiedName`." msgstr "" +"型の完全修飾名を取得します。\n" +":c:func:`PyType_GetFullyQualifiedName` を呼び出します。" -#: ../../c-api/unicode.rst:610 msgid "``#N``" -msgstr "" +msgstr "``#N``" -#: ../../c-api/unicode.rst:612 msgid "" "Similar to ``N`` format, but use a colon (``:``) as separator between the " "module name and the qualified name." msgstr "" +"``N`` 形式と同様ですが、モジュール名と修飾名の区切りにコロン (``:``) を使いま" +"す。" -#: ../../c-api/unicode.rst:616 msgid "" "The width formatter unit is number of characters rather than bytes. The " "precision formatter unit is number of bytes or :c:type:`wchar_t` items (if " @@ -930,13 +970,20 @@ msgid "" "``\"%A\"``, ``\"%U\"``, ``\"%S\"``, ``\"%R\"`` and ``\"%V\"`` (if the " "``PyObject*`` argument is not ``NULL``)." msgstr "" +"幅の単位はバイト数ではなく文字数です。\n" +"精度の単位は、``\"%s\"`` と ``PyObject*`` 引数が ``NULL`` の場合の " +"``\"%V\"`` では、バイト数または :c:type:`wchar_t` 要素数 (長さ修飾子 ``l`` を" +"使う場合) です。\n" +"``\"%A\"``、``\"%U\"``、``\"%S\"``、``\"%R\"``、および ``PyObject*`` 引数が " +"``NULL`` でない場合の ``\"%V\"`` では、文字数です。" -#: ../../c-api/unicode.rst:624 msgid "" "Unlike to C :c:func:`printf` the ``0`` flag has effect even when a precision " "is given for integer conversions (``d``, ``i``, ``u``, ``o``, ``x``, or " "``X``)." msgstr "" +"C の :c:func:`printf` とは異なり、整数変換 (``d``、``i``、``u``、``o``、" +"``x``、``X``) で精度を指定しても ``0`` フラグは有効です。" #: ../../c-api/unicode.rst:628 msgid "Support for ``\"%lld\"`` and ``\"%llu\"`` added." @@ -954,7 +1001,6 @@ msgstr "" "``\"%s\"``, ``\"%A\"``, ``\"%U\"``, ``\"%V\"``, ``\"%S\"``, ``\"%R\"`` での幅" "フォーマッタおよび精度フォーマッタのサポートが追加されました。" -#: ../../c-api/unicode.rst:638 msgid "" "Support for conversion specifiers ``o`` and ``X``. Support for length " "modifiers ``j`` and ``t``. Length modifiers are now applied to all integer " @@ -962,17 +1008,23 @@ msgid "" "``s`` and ``V``. Support for variable width and precision ``*``. Support for " "flag ``-``." msgstr "" +"変換指定子 ``o`` と ``X``、長さ修飾子 ``j`` と ``t`` に対応しました。\n" +"長さ修飾子をすべての整数変換に適用するようになりました。\n" +"長さ修飾子 ``l`` を変換指定子 ``s`` と ``V`` に適用するようになりました。\n" +"可変の幅と精度 ``*``、フラグ ``-`` に対応しました。" -#: ../../c-api/unicode.rst:646 msgid "" "An unrecognized format character now sets a :exc:`SystemError`. In previous " "versions it caused all the rest of the format string to be copied as-is to " "the result string, and any extra arguments discarded." msgstr "" +"認識できない書式指定文字があると、:exc:`SystemError` を設定するようになりまし" +"た。\n" +"以前のバージョンでは、書式文字列の残りすべてをそのまま結果の文字列にコピー" +"し、余分な引数を無視していました。" -#: ../../c-api/unicode.rst:650 msgid "Support for ``%T``, ``%#T``, ``%N`` and ``%#N`` formats added." -msgstr "" +msgstr "``%T``、``%#T``、``%N``、``%#N`` 形式のサポートが追加されました。" #: ../../c-api/unicode.rst:656 msgid "" @@ -982,12 +1034,15 @@ msgstr "" "ちょうど2つの引数を取ることを除いて、 :c:func:`PyUnicode_FromFormat` と同じ" "です。" -#: ../../c-api/unicode.rst:662 msgid "" "Copy an instance of a Unicode subtype to a new true Unicode object if " "necessary. If *obj* is already a true Unicode object (not a subtype), return " "a new :term:`strong reference` to the object." msgstr "" +"必要に応じて、Unicode のサブタイプのインスタンスを、サブタイプではない新しい " +"Unicode オブジェクトにコピーします。\n" +"*obj* がすでにサブタイプではない Unicode オブジェクトの場合は、そのオブジェク" +"トへの新しい :term:`強参照 ` を返します。" #: ../../c-api/unicode.rst:666 msgid "" @@ -996,15 +1051,17 @@ msgstr "" "Unicode やそのサブタイプ以外のオブジェクトでは :exc:`TypeError` が引き起こさ" "れます。" -#: ../../c-api/unicode.rst:671 msgid "Create a Unicode Object from the given Unicode code point *ordinal*." msgstr "" +"指定された Unicode コードポイント *ordinal* から Unicode オブジェクトを作成し" +"ます。" -#: ../../c-api/unicode.rst:673 msgid "" "The ordinal must be in ``range(0x110000)``. A :exc:`ValueError` is raised in " "the case it is not." msgstr "" +"``ordinal`` は ``range(0x110000)`` の範囲内でなければなりません。\n" +"範囲外の場合は :exc:`ValueError` を送出します。" #: ../../c-api/unicode.rst:680 msgid "Decode an encoded object *obj* to a Unicode object." @@ -1039,26 +1096,29 @@ msgstr "" "この API は、エラーが生じたときには ``NULL`` を返します。呼び出し側は返された" "オブジェクトに対し参照カウンタを 1 つ減らす (decref) する責任があります。" -#: ../../c-api/unicode.rst:697 msgid "" "Append the string *right* to the end of *p_left*. *p_left* must point to a :" "term:`strong reference` to a Unicode object; :c:func:`!PyUnicode_Append` " "releases (\":term:`steals `\") this reference." msgstr "" +"文字列 *right* を *p_left* の末尾に追加します。\n" +"*p_left* は Unicode オブジェクトへの :term:`強参照 ` を指す" +"必要があります。\n" +":c:func:`!PyUnicode_Append` はこの参照を解放します (「:term:`盗みます " +"`」)。" -#: ../../c-api/unicode.rst:702 msgid "On error, set *\\*p_left* to ``NULL`` and set an exception." -msgstr "" +msgstr "エラー時には *\\*p_left* に ``NULL`` を設定し、例外を設定します。" -#: ../../c-api/unicode.rst:704 msgid "On success, set *\\*p_left* to a new strong reference to the result." -msgstr "" +msgstr "成功すると *\\*p_left* に結果への新しい強参照を設定します。" -#: ../../c-api/unicode.rst:709 msgid "" "The function is similar to :c:func:`PyUnicode_Append`, with the only " "difference being that it decrements the reference count of *right* by one." msgstr "" +":c:func:`PyUnicode_Append` と同様ですが、*right* の参照カウントを 1 減らす点" +"だけが異なります。" #: ../../c-api/unicode.rst:715 msgid "" @@ -1069,29 +1129,27 @@ msgid "" "return ``NULL`` on invalid input." msgstr "" -#: ../../c-api/unicode.rst:726 msgid "" "Return the name of the default string encoding, ``\"utf-8\"``. See :func:" "`sys.getdefaultencoding`." msgstr "" +"デフォルトの文字列エンコーディングの名前 ``\"utf-8\"`` を返します。\n" +":func:`sys.getdefaultencoding` を参照してください。" -#: ../../c-api/unicode.rst:729 msgid "" "The returned string does not need to be freed, and is valid until " "interpreter shutdown." -msgstr "" +msgstr "返された文字列を解放する必要はなく、インタープリタの終了まで有効です。" #: ../../c-api/unicode.rst:735 msgid "Return the length of the Unicode object, in code points." msgstr "Unicode オブジェクトの長さをコードポイントで返します。" -#: ../../c-api/unicode.rst:737 msgid "On error, set an exception and return ``-1``." -msgstr "" +msgstr "エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/unicode.rst:741 msgid "The length does not count the trailing null character." -msgstr "" +msgstr "長さには末尾の null 文字を数えません。" #: ../../c-api/unicode.rst:752 msgid "" @@ -1106,36 +1164,41 @@ msgstr "" "失敗のときには ``-1`` を返し、例外を設定します。そうでない場合は、コピーした" "文字数を返します。" -#: ../../c-api/unicode.rst:757 ../../c-api/unicode.rst:787 -#: ../../c-api/unicode.rst:807 msgid "" "The string must not have been “used” yet. See :c:func:`PyUnicode_New` for " "details." msgstr "" +"文字列はまだ「使用」していないものでなければなりません。\n" +"詳細は :c:func:`PyUnicode_New` を参照してください。" -#: ../../c-api/unicode.rst:765 msgid "" "Resize a Unicode object *\\*unicode* to the new *length* in code points." msgstr "" +"Unicode オブジェクト *\\*unicode* のサイズを、コードポイント数で指定した新し" +"い *length* に変更します。" -#: ../../c-api/unicode.rst:767 msgid "" "Try to resize the string in place (which is usually faster than allocating a " "new string and copying characters), or create a new string." msgstr "" +"文字列をその場でサイズ変更しようと試みるか、新しい文字列を作成します。\n" +"その場での変更は通常、新しい文字列を割り当てて文字をコピーするより高速です。" -#: ../../c-api/unicode.rst:770 msgid "" "*\\*unicode* is modified to point to the new (resized) object and ``0`` is " "returned on success. Otherwise, ``-1`` is returned and an exception is set, " "and *\\*unicode* is left untouched." msgstr "" +"成功すると *\\*unicode* が新しい (サイズ変更後の) オブジェクトを指すように変" +"更し、``0`` を返します。\n" +"それ以外の場合は ``-1`` を返して例外を設定し、*\\*unicode* は変更しません。" -#: ../../c-api/unicode.rst:774 msgid "" "The function doesn't check string content, the result may not be a string in " "canonical representation." msgstr "" +"この関数は文字列の内容を検査しないため、結果は正統な表現形式の文字列でない場" +"合があります。" #: ../../c-api/unicode.rst:781 msgid "" @@ -1153,25 +1216,31 @@ msgstr "" "*fill_char* が文字列の最大文字よりも大きい場合や、文字列2つ以上の参照を持って" "た場合は失敗します。" -#: ../../c-api/unicode.rst:790 msgid "" "Return the number of written characters, or return ``-1`` and raise an " "exception on error." msgstr "" +"書き込んだ文字数を返します。\n" +"エラー時には ``-1`` を返して例外を送出します。" -#: ../../c-api/unicode.rst:799 msgid "" "Write a *character* to the string *unicode* at the zero-based *index*. " "Return ``0`` on success, ``-1`` on error with an exception set." msgstr "" +"文字列 *unicode* のゼロから始まる *index* の位置に *character* を書き込みま" +"す。\n" +"成功すると ``0``、エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/unicode.rst:802 msgid "" "This function checks that *unicode* is a Unicode object, that the index is " "not out of bounds, and that the object's reference count is one. See :c:func:" "`PyUnicode_WRITE` for a version that skips these checks, making them your " "responsibility." msgstr "" +"この関数は *unicode* が Unicode オブジェクトであること、インデックスが範囲内" +"であること、オブジェクトの参照カウントが 1 であることを検査します。\n" +"これらの検査を省略し、利用側の責任とする版については :c:func:" +"`PyUnicode_WRITE` を参照してください。" #: ../../c-api/unicode.rst:815 msgid "" @@ -1184,30 +1253,39 @@ msgstr "" "は *unicode* が Unicode オブジェクトであること、インデックスが範囲内であるこ" "とをチェックします。" -#: ../../c-api/unicode.rst:819 msgid "Return character on success, ``-1`` on error with an exception set." msgstr "" +"成功すると文字を返します。\n" +"エラー時には例外を設定して ``-1`` を返します。" -#: ../../c-api/unicode.rst:823 msgid "" "Do not accept reading the trailing null character at index :c:func:" "`PyUnicode_GetLength`." msgstr "" +":c:func:`PyUnicode_GetLength` が返すインデックスの位置にある、末尾の null 文" +"字は読み取れません。" -#: ../../c-api/unicode.rst:832 msgid "" "Return a substring of *unicode*, from character index *start* (included) to " "character index *end* (excluded). Negative indices are not supported. On " "error, set an exception and return ``NULL``." msgstr "" +"文字インデックス *start* (含む) から *end* (含まない) までの *unicode* の部分" +"文字列を返します。\n" +"負のインデックスはサポートしません。\n" +"エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/unicode.rst:842 msgid "" "Copy the string *unicode* into a UCS4 buffer, including a null character, if " "*copy_null* is set. Returns ``NULL`` and sets an exception on error (in " "particular, a :exc:`SystemError` if *buflen* is smaller than the length of " "*unicode*). *buffer* is returned on success." msgstr "" +"文字列 *unicode* を UCS4 バッファにコピーします。\n" +"*copy_null* が設定されている場合は null 文字も含めます。\n" +"エラー時には ``NULL`` を返して例外を設定します (特に *buflen* が *unicode* の" +"長さより小さい場合は :exc:`SystemError` を設定します)。\n" +"成功すると *buffer* を返します。" #: ../../c-api/unicode.rst:852 msgid "" @@ -1233,7 +1311,6 @@ msgstr "" "現在のロケールエンコーディングはオペレーティングシステムのテキストをデコード" "するのに使えます。" -#: ../../c-api/unicode.rst:870 msgid "" "Decode a string from UTF-8 on Android and VxWorks, or from the current " "locale encoding on other platforms. The supported error handlers are " @@ -1241,16 +1318,25 @@ msgid "" "``\"strict\"`` error handler if *errors* is ``NULL``. *str* must end with a " "null character but cannot contain embedded null characters." msgstr "" +"Android と VxWorks では UTF-8、それ以外のプラットフォームでは現在のロケールエ" +"ンコーディングで文字列をデコードします。\n" +"対応するエラーハンドラは ``\"strict\"`` と ``\"surrogateescape\"`` (:pep:" +"`383`) です。\n" +"*errors* が ``NULL`` の場合、デコーダは ``\"strict\"`` エラーハンドラを使いま" +"す。\n" +"*str* は null 文字で終端されている必要がありますが、内部に null 文字を含める" +"ことはできません。" -#: ../../c-api/unicode.rst:877 msgid "" "Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` to decode a string from the :" "term:`filesystem encoding and error handler`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` で文字列をデコードするには、:c:func:" +"`PyUnicode_DecodeFSDefaultAndSize` を使ってください。" -#: ../../c-api/unicode.rst:880 ../../c-api/unicode.rst:915 msgid "This function ignores the :ref:`Python UTF-8 Mode `." -msgstr "" +msgstr "この関数は :ref:`Python UTF-8 モード ` を無視します。" #: ../../c-api/unicode.rst:884 ../../c-api/unicode.rst:1000 msgid "The :c:func:`Py_DecodeLocale` function." @@ -1268,13 +1354,13 @@ msgstr "" "以前は、 :c:func:`Py_DecodeLocale` が ``surrogateescape`` で使われ、現在のロ" "ケールエンコーディングは ``strict`` で使われていました。" -#: ../../c-api/unicode.rst:897 msgid "" "Similar to :c:func:`PyUnicode_DecodeLocaleAndSize`, but compute the string " "length using :c:func:`!strlen`." msgstr "" +":c:func:`PyUnicode_DecodeLocaleAndSize` と同様ですが、文字列の長さを :c:func:" +"`!strlen` で計算します。" -#: ../../c-api/unicode.rst:905 msgid "" "Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current " "locale encoding on other platforms. The supported error handlers are " @@ -1282,12 +1368,22 @@ msgid "" "``\"strict\"`` error handler if *errors* is ``NULL``. Return a :class:" "`bytes` object. *unicode* cannot contain embedded null characters." msgstr "" +"Android と VxWorks では UTF-8、それ以外のプラットフォームでは現在のロケールエ" +"ンコーディングで Unicode オブジェクトをエンコードします。\n" +"対応するエラーハンドラは ``\"strict\"`` と ``\"surrogateescape\"`` (:pep:" +"`383`) です。\n" +"*errors* が ``NULL`` の場合、エンコーダは ``\"strict\"`` エラーハンドラを使い" +"ます。\n" +":class:`bytes` オブジェクトを返します。\n" +"*unicode* の内部に null 文字を含めることはできません。" -#: ../../c-api/unicode.rst:912 msgid "" "Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to the :term:" "`filesystem encoding and error handler`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` で文字列をエンコードするには、:c:func:" +"`PyUnicode_EncodeFSDefault` を使ってください。" #: ../../c-api/unicode.rst:919 ../../c-api/unicode.rst:1031 msgid "The :c:func:`Py_EncodeLocale` function." @@ -1309,20 +1405,23 @@ msgstr "" msgid "File System Encoding" msgstr "ファイルシステムエンコーディング" -#: ../../c-api/unicode.rst:934 msgid "" "Functions encoding to and decoding from the :term:`filesystem encoding and " "error handler` (:pep:`383` and :pep:`529`)." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` でエンコードとデコードを行う関数です (:pep:" +"`383` と :pep:`529`)。" -#: ../../c-api/unicode.rst:937 msgid "" "To encode file names to :class:`bytes` during argument parsing, the " "``\"O&\"`` converter should be used, passing :c:func:`!" "PyUnicode_FSConverter` as the conversion function:" msgstr "" +"引数の解析中にファイル名を :class:`bytes` にエンコードするには、変換関数に :" +"c:func:`!PyUnicode_FSConverter` を渡して ``\"O&\"`` コンバータを使ってくださ" +"い:" -#: ../../c-api/unicode.rst:943 msgid "" ":ref:`PyArg_Parse\\* converter `: encode :class:`str` objects " "-- obtained directly or through the :class:`os.PathLike` interface -- to :" @@ -1334,25 +1433,39 @@ msgid "" "a non-zero value (:c:macro:`Py_CLEANUP_SUPPORTED`). Embedded null bytes are " "not allowed in the result. On failure, return ``0`` with an exception set." msgstr "" +":ref:`PyArg_Parse\\* コンバータ ` です。\n" +"直接、または :class:`os.PathLike` インターフェースを通じて取得した :class:" +"`str` オブジェクトを、:c:func:`PyUnicode_EncodeFSDefault` で :class:`bytes` " +"にエンコードします。\n" +":class:`bytes` オブジェクトはそのまま出力します。\n" +"*result* は :c:expr:`PyObject*` 型 (または :c:expr:`PyBytesObject*` 型) の C " +"変数のアドレスでなければなりません。\n" +"成功すると、その変数に :ref:`bytes オブジェクト ` への新しい :" +"term:`強参照 ` を設定し、ゼロ以外の値 (:c:macro:" +"`Py_CLEANUP_SUPPORTED`) を返します。\n" +"この参照は使わなくなったら解放する必要があります。\n" +"結果の内部に null バイトを含めることはできません。\n" +"失敗すると例外を設定して ``0`` を返します。" -#: ../../c-api/unicode.rst:955 msgid "" "If *obj* is ``NULL``, the function releases a strong reference stored in the " "variable referred by *result* and returns ``1``." msgstr "" +"*obj* が ``NULL`` の場合、*result* が指す変数に格納された強参照を解放し、" +"``1`` を返します。" #: ../../c-api/unicode.rst:960 ../../c-api/unicode.rst:987 msgid "Accepts a :term:`path-like object`." msgstr ":term:`path-like object` を受け入れるようになりました。" -#: ../../c-api/unicode.rst:963 msgid "" "To decode file names to :class:`str` during argument parsing, the ``\"O&\"`` " "converter should be used, passing :c:func:`!PyUnicode_FSDecoder` as the " "conversion function:" msgstr "" +"引数の解析中にファイル名を :class:`str` にデコードするには、変換関数に :c:" +"func:`!PyUnicode_FSDecoder` を渡して ``\"O&\"`` コンバータを使ってください:" -#: ../../c-api/unicode.rst:969 msgid "" ":ref:`PyArg_Parse\\* converter `: decode :class:`bytes` objects " "-- obtained either directly or indirectly through the :class:`os.PathLike` " @@ -1365,54 +1478,77 @@ msgid "" "`Py_CLEANUP_SUPPORTED`). Embedded null characters are not allowed in the " "result. On failure, return ``0`` with an exception set." msgstr "" +":ref:`PyArg_Parse\\* コンバータ ` です。\n" +"直接、または :class:`os.PathLike` インターフェースを通じて間接的に取得した :" +"class:`bytes` オブジェクトを、:c:func:`PyUnicode_DecodeFSDefaultAndSize` で :" +"class:`str` にデコードします。\n" +":class:`str` オブジェクトはそのまま出力します。\n" +"*result* は :c:expr:`PyObject*` 型 (または :c:expr:`PyUnicodeObject*` 型) の " +"C 変数のアドレスでなければなりません。\n" +"成功すると、その変数に :ref:`Unicode オブジェクト ` への新し" +"い :term:`強参照 ` を設定し、ゼロ以外の値 (:c:macro:" +"`Py_CLEANUP_SUPPORTED`) を返します。\n" +"この参照は使わなくなったら解放する必要があります。\n" +"結果の内部に null 文字を含めることはできません。\n" +"失敗すると例外を設定して ``0`` を返します。" -#: ../../c-api/unicode.rst:982 msgid "" "If *obj* is ``NULL``, release the strong reference to the object referred to " "by *result* and return ``1``." msgstr "" +"*obj* が ``NULL`` の場合、*result* が指すオブジェクトへの強参照を解放し、" +"``1`` を返します。" -#: ../../c-api/unicode.rst:993 msgid "Decode a string from the :term:`filesystem encoding and error handler`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` で文字列をデコードします。" -#: ../../c-api/unicode.rst:995 msgid "" "If you need to decode a string from the current locale encoding, use :c:func:" "`PyUnicode_DecodeLocaleAndSize`." msgstr "" +"現在のロケールエンコーディングで文字列をデコードするには、:c:func:" +"`PyUnicode_DecodeLocaleAndSize` を使ってください。" -#: ../../c-api/unicode.rst:1002 ../../c-api/unicode.rst:1015 -#: ../../c-api/unicode.rst:1035 msgid "" "The :term:`filesystem error handler ` " "is now used." msgstr "" +":term:`ファイルシステムのエラーハンドラ ` を使うようになりました。" -#: ../../c-api/unicode.rst:1009 msgid "" "Decode a null-terminated string from the :term:`filesystem encoding and " "error handler`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` で null 終端の文字列をデコードします。" -#: ../../c-api/unicode.rst:1012 msgid "" "If the string length is known, use :c:func:" "`PyUnicode_DecodeFSDefaultAndSize`." msgstr "" +"文字列の長さが分かっている場合は、:c:func:`PyUnicode_DecodeFSDefaultAndSize` " +"を使ってください。" -#: ../../c-api/unicode.rst:1022 msgid "" "Encode a Unicode object to the :term:`filesystem encoding and error " "handler`, and return :class:`bytes`. Note that the resulting :class:`bytes` " "object can contain null bytes." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` で Unicode オブジェクトをエンコードし、:class:" +"`bytes` を返します。\n" +"結果の :class:`bytes` オブジェクトには null バイトが含まれる場合があることに" +"注意してください。" -#: ../../c-api/unicode.rst:1026 msgid "" "If you need to encode a string to the current locale encoding, use :c:func:" "`PyUnicode_EncodeLocale`." msgstr "" +"現在のロケールエンコーディングで文字列をエンコードするには、:c:func:" +"`PyUnicode_EncodeLocale` を使ってください。" #: ../../c-api/unicode.rst:1040 msgid "wchar_t Support" @@ -1422,29 +1558,37 @@ msgstr "wchar_t サポート" msgid ":c:type:`wchar_t` support for platforms which support it:" msgstr ":c:type:`wchar_t` をサポートするプラットフォームでの wchar_t サポート:" -#: ../../c-api/unicode.rst:1046 msgid "" "Create a Unicode object from the :c:type:`wchar_t` buffer *wstr* of the " "given *size*. Passing ``-1`` as the *size* indicates that the function must " "itself compute the length, using :c:func:`!wcslen`. Return ``NULL`` on " "failure." msgstr "" +"指定された *size* の :c:type:`wchar_t` バッファ *wstr* から Unicode オブジェ" +"クトを作成します。\n" +"*size* に ``-1`` を渡すと、この関数自身が :c:func:`!wcslen` を使って長さを計" +"算します。\n" +"失敗すると ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1054 msgid "" "Copy the Unicode object contents into the :c:type:`wchar_t` buffer *wstr*. " "At most *size* :c:type:`wchar_t` characters are copied (excluding a possibly " "trailing null termination character). Return the number of :c:type:" "`wchar_t` characters copied or ``-1`` in case of an error." msgstr "" +"Unicode オブジェクトの内容を :c:type:`wchar_t` バッファ *wstr* にコピーしま" +"す。\n" +"最大で *size* 個の :c:type:`wchar_t` 文字をコピーします (末尾に付く場合がある" +"終端の null 文字を除きます)。\n" +"コピーした :c:type:`wchar_t` 文字の数、またはエラー時には ``-1`` を返します。" -#: ../../c-api/unicode.rst:1059 msgid "" "When *wstr* is ``NULL``, instead return the *size* that would be required to " "store all of *unicode* including a terminating null." msgstr "" +"*wstr* が ``NULL`` の場合は、代わりに終端の null 文字も含めて *unicode* 全体" +"を格納するのに必要な *size* を返します。" -#: ../../c-api/unicode.rst:1062 msgid "" "Note that the resulting :c:expr:`wchar_t*` string may or may not be null-" "terminated. It is the responsibility of the caller to make sure that the :c:" @@ -1453,8 +1597,13 @@ msgid "" "null characters, which would cause the string to be truncated when used with " "most C functions." msgstr "" +"結果の :c:expr:`wchar_t*` 文字列は、null 終端される場合とされない場合があるこ" +"とに注意してください。\n" +"アプリケーションが null 終端を必要とする場合、:c:expr:`wchar_t*` 文字列が " +"null 終端されていることを保証するのは呼び出し側の責任です。\n" +"また、:c:expr:`wchar_t*` 文字列の内部に null 文字が含まれる場合があり、その場" +"合はほとんどの C 関数で文字列が途中で切れてしまうことにも注意してください。" -#: ../../c-api/unicode.rst:1072 msgid "" "Convert the Unicode object to a wide character string. The output string " "always ends with a null character. If *size* is not ``NULL``, write the " @@ -1464,19 +1613,31 @@ msgid "" "when used with most C functions. If *size* is ``NULL`` and the :c:expr:" "`wchar_t*` string contains null characters a :exc:`ValueError` is raised." msgstr "" +"Unicode オブジェクトをワイド文字列に変換します。\n" +"出力文字列は常に null 文字で終わります。\n" +"*size* が ``NULL`` でなければ、ワイド文字の数 (末尾の終端 null 文字を除く) " +"を *\\*size* に書き込みます。\n" +"結果の :c:type:`wchar_t` 文字列の内部に null 文字が含まれる場合があり、その場" +"合はほとんどの C 関数で文字列が途中で切れてしまうことに注意してください。\n" +"*size* が ``NULL`` で、:c:expr:`wchar_t*` 文字列の内部に null 文字が含まれて" +"いる場合は、:exc:`ValueError` を送出します。" -#: ../../c-api/unicode.rst:1080 msgid "" "Returns a buffer allocated by :c:macro:`PyMem_New` (use :c:func:`PyMem_Free` " "to free it) on success. On error, returns ``NULL`` and *\\*size* is " "undefined. Raises a :exc:`MemoryError` if memory allocation is failed." msgstr "" +"成功すると、:c:macro:`PyMem_New` で割り当てたバッファを返します (:c:func:" +"`PyMem_Free` で解放してください)。\n" +"エラー時には ``NULL`` を返し、*\\*size* は未定義です。\n" +"メモリの割り当てに失敗すると :exc:`MemoryError` を送出します。" -#: ../../c-api/unicode.rst:1087 msgid "" "Raises a :exc:`ValueError` if *size* is ``NULL`` and the :c:expr:`wchar_t*` " "string contains null characters." msgstr "" +"*size* が ``NULL`` で、:c:expr:`wchar_t*` 文字列の内部に null 文字が含まれて" +"いる場合は、:exc:`ValueError` を送出するようになりました。" #: ../../c-api/unicode.rst:1095 msgid "Built-in Codecs" @@ -1500,13 +1661,18 @@ msgstr "" "らのパラメータは、組み込みの文字列コンストラクタである :func:`str` における同" "名のパラメータと同じ意味を持ちます。" -#: ../../c-api/unicode.rst:1104 msgid "" "Setting encoding to ``NULL`` causes the default encoding to be used which is " "UTF-8. The file system calls should use :c:func:`PyUnicode_FSConverter` for " "encoding file names. This uses the :term:`filesystem encoding and error " "handler` internally." msgstr "" +"``encoding`` に ``NULL`` を設定すると、デフォルトのエンコーディングである " +"UTF-8 を使います。\n" +"ファイルシステムの呼び出しでファイル名をエンコードするには、:c:func:" +"`PyUnicode_FSConverter` を使ってください。\n" +"これは内部で :term:`ファイルシステムのエンコーディングとエラーハンドラ " +"` を使います。" #: ../../c-api/unicode.rst:1109 msgid "" @@ -1532,25 +1698,23 @@ msgstr "" msgid "Generic Codecs" msgstr "汎用 codec" -#: ../../c-api/unicode.rst:1120 msgid "The following macro is provided:" -msgstr "" +msgstr "次のマクロが用意されています:" -#: ../../c-api/unicode.rst:1125 msgid "The Unicode code point ``U+FFFD`` (replacement character)." -msgstr "" +msgstr "Unicode コードポイント ``U+FFFD`` (置換文字)。" -#: ../../c-api/unicode.rst:1127 msgid "" "This Unicode character is used as the replacement character during decoding " "if the *errors* argument is set to \"replace\"." msgstr "" +"*errors* 引数が \"replace\" の場合、この Unicode 文字をデコード時の置換文字と" +"して使います。" #: ../../c-api/unicode.rst:1131 msgid "These are the generic codec APIs:" msgstr "以下は汎用 codec の API です:" -#: ../../c-api/unicode.rst:1137 msgid "" "Create a Unicode object by decoding *size* bytes of the encoded string " "*str*. *encoding* and *errors* have the same meaning as the parameters of " @@ -1558,6 +1722,12 @@ msgid "" "looked up using the Python codec registry. Return ``NULL`` if an exception " "was raised by the codec." msgstr "" +"エンコードされた文字列 *str* の *size* バイトをデコードし、Unicode オブジェク" +"トを作成します。\n" +"*encoding* と *errors* の意味は、組み込み関数 :func:`str` の同名の引数と同じ" +"です。\n" +"使用する codec は Python の codec レジストリで検索します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1147 msgid "" @@ -1612,11 +1782,12 @@ msgstr "" "トとして返します。エラー処理は \"strict\" です。 codec が例外を送出した場合に" "は ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1181 ../../c-api/unicode.rst:1196 msgid "" "The function fails if the string contains surrogate code points (``U+D800`` " "- ``U+DFFF``)." msgstr "" +"文字列にサロゲートコードポイント (``U+D800`` - ``U+DFFF``) が含まれていると、" +"この関数は失敗します。" #: ../../c-api/unicode.rst:1187 msgid "" @@ -1632,13 +1803,13 @@ msgstr "" "返されるバッファには、 null コードポイントがあるかどうかに関わらず、常に " "null バイトが終端に付加されています (これは *size* には勘定されません)。" -#: ../../c-api/unicode.rst:1193 msgid "" "On error, set an exception, set *size* to ``-1`` (if it's not NULL) and " "return ``NULL``." msgstr "" +"エラー時には例外を設定し、*size* が ``NULL`` でなければ ``-1`` を格納して、" +"``NULL`` を返します。" -#: ../../c-api/unicode.rst:1199 msgid "" "This caches the UTF-8 representation of the string in the Unicode object, " "and subsequent calls will return a pointer to the same buffer. The caller " @@ -1646,21 +1817,23 @@ msgid "" "and pointers to it become invalid when the Unicode object is garbage " "collected." msgstr "" +"この関数は Unicode オブジェクト内に文字列の UTF-8 表現をキャッシュし、それ以" +"降の呼び出しでは同じバッファへのポインタを返します。\n" +"呼び出し側がバッファを解放する必要はありません。\n" +"Unicode オブジェクトがガベージコレクションで回収されるとバッファは解放され、" +"それを指すポインタは無効になります。" -#: ../../c-api/unicode.rst:1206 ../../c-api/unicode.rst:1228 msgid "The return type is now ``const char *`` rather than ``char *``." -msgstr "" +msgstr "戻り値の型が ``char *`` から ``const char *`` に変更されました。" -#: ../../c-api/unicode.rst:1209 msgid "This function is a part of the :ref:`limited API `." -msgstr "" +msgstr "この関数が :ref:`制限付き API ` の一部になりました。" #: ../../c-api/unicode.rst:1215 msgid "As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size." msgstr "" ":c:func:`PyUnicode_AsUTF8AndSize` とほぼ同じですが、サイズを格納しません。" -#: ../../c-api/unicode.rst:1219 msgid "" "This function does not have any special behavior for `null characters " "`_ embedded within *unicode*. " @@ -1669,6 +1842,12 @@ msgid "" "leading to truncation. If truncation is an issue, it is recommended to use :" "c:func:`PyUnicode_AsUTF8AndSize` instead." msgstr "" +"この関数は、*unicode* の内部に含まれる `null 文字 `_ を特別に扱いません。\n" +"そのため、返された文字列にも null 文字が残り、一部の C 関数はそれを文字列の末" +"尾と解釈するため、途中で切れてしまう場合があります。\n" +"これが問題になる場合は、代わりに :c:func:`PyUnicode_AsUTF8AndSize` を使うこと" +"を推奨します。" #: ../../c-api/unicode.rst:1233 msgid "UTF-32 Codecs" @@ -1696,12 +1875,14 @@ msgstr "" "*byteorder* が ``NULL`` でない時、デコーダは与えられたバイトオーダーでデコー" "ドを開始します。 ::" -#: ../../c-api/unicode.rst:1248 ../../c-api/unicode.rst:1298 msgid "" "*byteorder == -1: little endian\n" "*byteorder == 0: native order\n" "*byteorder == 1: big endian" msgstr "" +"*byteorder == -1: リトルエンディアン\n" +"*byteorder == 0: ネイティブのバイト順\n" +"*byteorder == 1: ビッグエンディアン" #: ../../c-api/unicode.rst:1252 msgid "" @@ -1833,11 +2014,13 @@ msgstr "UTF-7 Codecs" msgid "These are the UTF-7 codec APIs:" msgstr "以下は UTF-7 codec の API です:" -#: ../../c-api/unicode.rst:1341 msgid "" "Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" +"UTF-7 でエンコードされた文字列 *str* の *size* バイトをデコードし、Unicode オ" +"ブジェクトを作成します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1348 msgid "" @@ -1859,12 +2042,14 @@ msgstr "Unicode-Escape Codecs" msgid "These are the \"Unicode Escape\" codec APIs:" msgstr "以下は \"Unicode Escape\" codec の API です:" -#: ../../c-api/unicode.rst:1363 msgid "" "Create a Unicode object by decoding *size* bytes of the Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" +"Unicode-Escape でエンコードされた文字列 *str* の *size* バイトをデコードし、" +"Unicode オブジェクトを作成します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1369 msgid "" @@ -1885,12 +2070,14 @@ msgstr "Raw-Unicode-Escape Codecs" msgid "These are the \"Raw Unicode Escape\" codec APIs:" msgstr "以下は \"Raw Unicode Escape\" codec の APIです:" -#: ../../c-api/unicode.rst:1383 msgid "" "Create a Unicode object by decoding *size* bytes of the Raw-Unicode-Escape " "encoded string *str*. Return ``NULL`` if an exception was raised by the " "codec." msgstr "" +"Raw-Unicode-Escape でエンコードされた文字列 *str* の *size* バイトをデコード" +"し、Unicode オブジェクトを作成します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1389 msgid "" @@ -1946,11 +2133,13 @@ msgstr "" "以下は ASCII codec の APIです。 7 ビットの ASCII データだけを受理します。その" "他のコードはエラーになります。" -#: ../../c-api/unicode.rst:1423 msgid "" "Create a Unicode object by decoding *size* bytes of the ASCII encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" +"ASCII でエンコードされた文字列 *str* の *size* バイトをデコードし、Unicode オ" +"ブジェクトを作成します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1429 msgid "" @@ -1998,7 +2187,6 @@ msgstr "" "字列 *str* をデコードして Unicode オブジェクトを作成します。\n" "codec が例外を発生させたときは ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1452 msgid "" "If *mapping* is ``NULL``, Latin-1 decoding will be applied. Else *mapping* " "must map bytes ordinals (integers in the range from 0 to 255) to Unicode " @@ -2007,6 +2195,13 @@ msgid "" "well as ones which get mapped to ``None``, ``0xFFFE`` or ``'\\ufffe'``, are " "treated as undefined mappings and cause an error." msgstr "" +"*mapping* が ``NULL`` の場合は Latin-1 でデコードします。\n" +"それ以外の場合、*mapping* はバイト値 (0 から 255 の範囲の整数) を、Unicode 文" +"字列、整数 (Unicode の序数として解釈)、または ``None`` に対応づける必要があり" +"ます。\n" +"対応のないバイト、つまり :exc:`LookupError` を引き起こすバイトや、``None``、" +"``0xFFFE``、``'\\ufffe'`` に対応づけられたバイトは、未定義の対応として扱い、" +"エラーになります。" #: ../../c-api/unicode.rst:1463 msgid "" @@ -2018,13 +2213,16 @@ msgstr "" "し、結果を bytes オブジェクトとして返します。エラー処理は \"strict\" です。 " "codec が例外を送出した場合には ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1467 msgid "" "The *mapping* object must map Unicode ordinal integers to bytes objects, " "integers in the range from 0 to 255 or ``None``. Unmapped character " "ordinals (ones which cause a :exc:`LookupError`) as well as mapped to " "``None`` are treated as \"undefined mapping\" and cause an error." msgstr "" +"*mapping* オブジェクトは、Unicode の序数を表す整数を、bytes オブジェクト、0 " +"から 255 の範囲の整数、または ``None`` に対応づける必要があります。\n" +"対応のない文字の序数 (:exc:`LookupError` を引き起こすもの) や、``None`` に対" +"応づけられたものは「未定義の対応」として扱い、エラーになります。" #: ../../c-api/unicode.rst:1473 msgid "The following codec API is special in that maps Unicode to Unicode." @@ -2048,12 +2246,15 @@ msgstr "" "対応表は、Unicode 序数を表す整数を Unicode 序数を表す整数または ``None`` (そ" "の文字を削除する) に対応付けなければなりません。" -#: ../../c-api/unicode.rst:1484 msgid "" "Mapping tables need only provide the :meth:`~object.__getitem__` interface; " "dictionaries and sequences work well. Unmapped character ordinals (ones " "which cause a :exc:`LookupError`) are left untouched and are copied as-is." msgstr "" +"対応表には :meth:`~object.__getitem__` インターフェースだけが必要で、辞書や" +"シーケンスを使えます。\n" +"対応のない文字の序数 (:exc:`LookupError` を引き起こすもの) は変更せず、そのま" +"まコピーします。" #: ../../c-api/unicode.rst:1488 msgid "" @@ -2081,11 +2282,13 @@ msgstr "" "式 (target encoding) は、 codec を動作させているマシン上のユーザ設定で定義さ" "れています。" -#: ../../c-api/unicode.rst:1502 msgid "" "Create a Unicode object by decoding *size* bytes of the MBCS encoded string " "*str*. Return ``NULL`` if an exception was raised by the codec." msgstr "" +"MBCS でエンコードされた文字列 *str* の *size* バイトをデコードし、Unicode オ" +"ブジェクトを作成します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。" #: ../../c-api/unicode.rst:1509 msgid "" @@ -2099,11 +2302,12 @@ msgstr "" "`PyUnicode_DecodeMBCSStateful` は文字列の最後にあるマルチバイト文字の前半バイ" "トをデコードせず、 *consumed* にデコードしたバイト数を格納します。" -#: ../../c-api/unicode.rst:1518 msgid "" "Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page " "specified by *code_page*." msgstr "" +":c:func:`PyUnicode_DecodeMBCSStateful` と同様ですが、*code_page* で指定した" +"コードページを使います。" #: ../../c-api/unicode.rst:1524 msgid "" @@ -2115,12 +2319,16 @@ msgstr "" "トとして返します。エラー処理は \"strict\" です。 codec が例外を送出した場合に" "は ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1531 msgid "" "Encode the Unicode object using the specified code page and return a Python " "bytes object. Return ``NULL`` if an exception was raised by the codec. Use :" "c:macro:`!CP_ACP` code page to get the MBCS encoder." msgstr "" +"指定されたコードページで Unicode オブジェクトをエンコードし、Python の bytes " +"オブジェクトを返します。\n" +"codec が例外を送出した場合は ``NULL`` を返します。\n" +"MBCS エンコーダを使うには、コードページに :c:macro:`!CP_ACP` を指定してくださ" +"い。" #: ../../c-api/unicode.rst:1541 msgid "Methods and Slot Functions" @@ -2146,7 +2354,6 @@ msgstr "" msgid "Concat two strings giving a new Unicode string." msgstr "二つの文字列を結合して、新たな Unicode 文字列を生成します。" -#: ../../c-api/unicode.rst:1557 msgid "" "Split a string giving a list of Unicode strings. If *sep* is ``NULL``, " "splitting will be done at all whitespace substrings. Otherwise, splits " @@ -2154,64 +2361,65 @@ msgid "" "negative, no limit is set. Separators are not included in the resulting " "list." msgstr "" -"Unicode 文字列のリストを分割して、 Unicode 文字列からなるリストを返します。 " -"*sep* が ``NULL`` の場合、全ての空白文字を使って分割を行います。それ以外の場" -"合、指定された文字を使って分割を行います。最大で *maxsplit* 個までの分割を行" -"います。 *maxsplit* が負ならば分割数に制限を設けません。分割結果のリスト内に" -"は分割文字は含みません。" +"文字列を分割し、Unicode 文字列のリストを返します。\n" +"*sep* が ``NULL`` の場合は、すべての空白部分で分割します。\n" +"それ以外の場合は、指定された区切り文字列で分割します。\n" +"分割回数は最大で *maxsplit* 回です。\n" +"負の値なら回数に制限はありません。\n" +"結果のリストには区切り文字列を含めません。" -#: ../../c-api/unicode.rst:1562 ../../c-api/unicode.rst:1572 -#: ../../c-api/unicode.rst:1593 ../../c-api/unicode.rst:1606 msgid "On error, return ``NULL`` with an exception set." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1564 msgid "Equivalent to :py:meth:`str.split`." -msgstr "" +msgstr ":py:meth:`str.split` と等価です。" -#: ../../c-api/unicode.rst:1569 msgid "" "Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning " "at the end of the string." -msgstr "" +msgstr ":c:func:`PyUnicode_Split` と同様ですが、文字列の末尾から分割します。" -#: ../../c-api/unicode.rst:1574 msgid "Equivalent to :py:meth:`str.rsplit`." -msgstr "" +msgstr ":py:meth:`str.rsplit` と等価です。" -#: ../../c-api/unicode.rst:1579 msgid "" "Split a Unicode string at line breaks, returning a list of Unicode strings. " "CRLF is considered to be one line break. If *keepends* is ``0``, the Line " "break characters are not included in the resulting strings." msgstr "" +"Unicode 文字列を改行位置で分割し、Unicode 文字列のリストを返します。\n" +"CRLF は 1 つの改行とみなします。\n" +"*keepends* が ``0`` の場合、結果の文字列に改行文字を含めません。" -#: ../../c-api/unicode.rst:1586 msgid "" "Split a Unicode string at the first occurrence of *sep*, and return a 3-" "tuple containing the part before the separator, the separator itself, and " "the part after the separator. If the separator is not found, return a 3-" "tuple containing the string itself, followed by two empty strings." msgstr "" +"Unicode 文字列を *sep* が最初に現れる位置で分割し、区切り文字列より前の部分、" +"区切り文字列自体、その後の部分を含む 3 要素のタプルを返します。\n" +"区切り文字列が見つからなければ、元の文字列と、その後に 2 つの空文字列を含む " +"3 要素のタプルを返します。" -#: ../../c-api/unicode.rst:1591 ../../c-api/unicode.rst:1604 msgid "*sep* must not be empty." -msgstr "" +msgstr "*sep* は空であってはなりません。" -#: ../../c-api/unicode.rst:1595 msgid "Equivalent to :py:meth:`str.partition`." -msgstr "" +msgstr ":py:meth:`str.partition` と等価です。" -#: ../../c-api/unicode.rst:1600 msgid "" "Similar to :c:func:`PyUnicode_Partition`, but split a Unicode string at the " "last occurrence of *sep*. If the separator is not found, return a 3-tuple " "containing two empty strings, followed by the string itself." msgstr "" +":c:func:`PyUnicode_Partition` と同様ですが、Unicode 文字列を *sep* が最後に現" +"れる位置で分割します。\n" +"区切り文字列が見つからなければ、2 つの空文字列と、その後に元の文字列を含む 3 " +"要素のタプルを返します。" -#: ../../c-api/unicode.rst:1608 msgid "Equivalent to :py:meth:`str.rpartition`." -msgstr "" +msgstr ":py:meth:`str.rpartition` と等価です。" #: ../../c-api/unicode.rst:1613 msgid "" @@ -2221,12 +2429,15 @@ msgstr "" "指定した *separator* で文字列からなるシーケンスを連結 (join) し、連結結果を " "Unicode 文字列で返します。" -#: ../../c-api/unicode.rst:1620 msgid "" "Return ``1`` if *substr* matches ``unicode[start:end]`` at the given tail " "end (*direction* == ``-1`` means to do a prefix match, *direction* == ``1`` " "a suffix match), ``0`` otherwise. Return ``-1`` if an error occurred." msgstr "" +"*substr* が ``unicode[start:end]`` の指定された側の端と一致すれば ``1``、それ" +"以外なら ``0`` を返します (*direction* == ``-1`` は前方一致、*direction* == " +"``1`` は後方一致を意味します)。\n" +"エラーが発生した場合は ``-1`` を返します。" #: ../../c-api/unicode.rst:1628 msgid "" @@ -2259,10 +2470,11 @@ msgstr "" "チが見つからなかったことを表し、 ``-2`` はエラーが発生して例外情報が設定され" "ていることを表します。" -#: ../../c-api/unicode.rst:1646 msgid "" "*start* and *end* are now adjusted to behave like ``unicode[start:end]``." msgstr "" +"``unicode[start:end]`` と同じ動作になるよう、*start* と *end* を調整するよう" +"になりました。" #: ../../c-api/unicode.rst:1653 msgid "" @@ -2299,43 +2511,39 @@ msgstr "" "この関数は、失敗したときに ``-1`` を返すので、 :c:func:`PyErr_Occurred` を呼" "び出して、エラーをチェックすべきです。" -#: ../../c-api/unicode.rst:1675 msgid "The :c:func:`PyUnicode_Equal` function." -msgstr "" +msgstr ":c:func:`PyUnicode_Equal` 関数。" -#: ../../c-api/unicode.rst:1680 msgid "Test if two strings are equal:" -msgstr "" +msgstr "2 つの文字列が等しいか調べます:" -#: ../../c-api/unicode.rst:1682 msgid "Return ``1`` if *a* is equal to *b*." -msgstr "" +msgstr "*a* と *b* が等しければ ``1`` を返します。" -#: ../../c-api/unicode.rst:1683 msgid "Return ``0`` if *a* is not equal to *b*." -msgstr "" +msgstr "*a* と *b* が等しくなければ ``0`` を返します。" -#: ../../c-api/unicode.rst:1684 msgid "" "Set a :exc:`TypeError` exception and return ``-1`` if *a* or *b* is not a :" "class:`str` object." msgstr "" +"*a* または *b* が :class:`str` オブジェクトでなければ、:exc:`TypeError` 例外" +"を設定して ``-1`` を返します。" -#: ../../c-api/unicode.rst:1687 msgid "The function always succeeds if *a* and *b* are :class:`str` objects." msgstr "" +"*a* と *b* が :class:`str` オブジェクトであれば、この関数は常に成功します。" -#: ../../c-api/unicode.rst:1689 msgid "" "The function works for :class:`str` subclasses, but does not honor custom " "``__eq__()`` method." msgstr "" +"この関数は :class:`str` のサブクラスにも使えますが、独自の ``__eq__()`` メ" +"ソッドは考慮しません。" -#: ../../c-api/unicode.rst:1694 msgid "The :c:func:`PyUnicode_Compare` function." -msgstr "" +msgstr ":c:func:`PyUnicode_Compare` 関数。" -#: ../../c-api/unicode.rst:1701 msgid "" "Compare a Unicode object with a char buffer which is interpreted as being " "UTF-8 or ASCII encoded and return true (``1``) if they are equal, or false " @@ -2343,17 +2551,25 @@ msgid "" "(``U+D800`` - ``U+DFFF``) or the C string is not valid UTF-8, false (``0``) " "is returned." msgstr "" +"Unicode オブジェクトと、UTF-8 または ASCII でエンコードされていると解釈する " +"char 型バッファを比較し、等しければ真 (``1``)、それ以外なら偽 (``0``) を返し" +"ます。\n" +"Unicode オブジェクトにサロゲートコードポイント (``U+D800`` - ``U+DFFF``) が含" +"まれている場合や、C 文字列が有効な UTF-8 でない場合は、偽 (``0``) を返しま" +"す。" #: ../../c-api/unicode.rst:1708 ../../c-api/unicode.rst:1729 msgid "This function does not raise exceptions." msgstr "この関数は例外を送出しません。" -#: ../../c-api/unicode.rst:1715 msgid "" "Similar to :c:func:`PyUnicode_EqualToUTF8AndSize`, but compute *string* " "length using :c:func:`!strlen`. If the Unicode object contains null " "characters, false (``0``) is returned." msgstr "" +":c:func:`PyUnicode_EqualToUTF8AndSize` と同様ですが、*string* の長さを :c:" +"func:`!strlen` で計算します。\n" +"Unicode オブジェクトに null 文字が含まれている場合は、偽 (``0``) を返します。" #: ../../c-api/unicode.rst:1724 msgid "" @@ -2382,15 +2598,15 @@ msgstr "" ":c:data:`Py_True` もしくは :c:data:`Py_False` を、正しく比較できた時に返しま" "す。" -#: ../../c-api/unicode.rst:1738 msgid ":c:data:`Py_NotImplemented` in case the type combination is unknown" -msgstr "" +msgstr "型の組み合わせが不明な場合は :c:data:`Py_NotImplemented`。" -#: ../../c-api/unicode.rst:1740 msgid "" "Possible values for *op* are :c:macro:`Py_GT`, :c:macro:`Py_GE`, :c:macro:" "`Py_EQ`, :c:macro:`Py_NE`, :c:macro:`Py_LT`, and :c:macro:`Py_LE`." msgstr "" +"*op* に指定できる値は :c:macro:`Py_GT`、:c:macro:`Py_GE`、:c:macro:`Py_EQ`、:" +"c:macro:`Py_NE`、:c:macro:`Py_LT`、:c:macro:`Py_LE` です。" #: ../../c-api/unicode.rst:1746 msgid "" @@ -2415,7 +2631,6 @@ msgstr "" "*substr* は単要素の Unicode 文字に型強制できなければなりません。エラーが生じ" "た場合には ``-1`` を返します。" -#: ../../c-api/unicode.rst:1761 msgid "" "Intern the argument :c:expr:`*p_unicode` in place. The argument must be the " "address of a pointer variable pointing to a Python Unicode string object. " @@ -2425,27 +2640,44 @@ msgid "" "interned string object), otherwise it leaves :c:expr:`*p_unicode` alone and " "interns it." msgstr "" +"引数 :c:expr:`*p_unicode` をその場でインターンします。\n" +"引数は、Python の Unicode 文字列オブジェクトを指すポインタ変数のアドレスでな" +"ければなりません。\n" +":c:expr:`*p_unicode` と同じ文字列がすでにインターンされていれば、:c:expr:" +"`*p_unicode` をその文字列に設定します (元の文字列オブジェクトへの参照を解放" +"し、インターン済み文字列オブジェクトへの新しい :term:`強参照 ` を作成します)。\n" +"それ以外の場合は :c:expr:`*p_unicode` を変更せず、その文字列をインターンしま" +"す。" -#: ../../c-api/unicode.rst:1768 msgid "" "(Clarification: even though there is a lot of talk about references, think " "of this function as reference-neutral. You must own the object you pass in; " "after the call you no longer own the passed-in reference, but you newly own " "the result.)" msgstr "" +"(補足: 参照についての説明が多いですが、この関数は参照の数を変えないと考えてく" +"ださい。\n" +"渡すオブジェクトへの参照を所有している必要があります。\n" +"呼び出し後は渡した参照を所有しなくなり、代わりに結果への参照を新たに所有しま" +"す。)" -#: ../../c-api/unicode.rst:1773 msgid "" "This function never raises an exception. On error, it leaves its argument " "unchanged without interning it." msgstr "" +"この関数は例外を送出しません。\n" +"エラー時には、引数を変更せず、インターンもしません。" -#: ../../c-api/unicode.rst:1776 msgid "" "Instances of subclasses of :py:class:`str` may not be interned, that is, :c:" "expr:`PyUnicode_CheckExact(*p_unicode)` must be true. If it is not, then -- " "as with any other error -- the argument is left unchanged." msgstr "" +":py:class:`str` のサブクラスのインスタンスはインターンできません。\n" +"つまり :c:expr:`PyUnicode_CheckExact(*p_unicode)` が真でなければなりませ" +"ん。\n" +"真でなければ、他のエラーと同様に引数を変更しません。" #: ../../c-api/unicode.rst:1780 msgid "" @@ -2453,20 +2685,22 @@ msgid "" "the result to benefit from interning." msgstr "" -#: ../../c-api/unicode.rst:1786 msgid "" "A combination of :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace`, meant for statically allocated strings." msgstr "" +":c:func:`PyUnicode_FromString` と :c:func:`PyUnicode_InternInPlace` を組み合" +"わせたもので、静的に割り当てられた文字列用です。" -#: ../../c-api/unicode.rst:1789 msgid "" "Return a new (\"owned\") reference to either a new Unicode string object " "that has been interned, or an earlier interned string object with the same " "value." msgstr "" +"新しく作成してインターンした Unicode 文字列オブジェクト、または同じ値を持つ以" +"前にインターン済みの文字列オブジェクトへの、新しい (「所有する」) 参照を返し" +"ます。" -#: ../../c-api/unicode.rst:1793 msgid "" "Python may keep a reference to the result, or make it :term:`immortal`, " "preventing it from being garbage-collected promptly. For interning an " @@ -2474,227 +2708,243 @@ msgid "" "prefer calling :c:func:`PyUnicode_FromString` and :c:func:" "`PyUnicode_InternInPlace` directly." msgstr "" +"Python が結果への参照を保持したり、結果を :term:`不死 ` にしたりす" +"ることで、すぐにはガベージコレクションで回収されない場合があります。\n" +"ユーザー入力など、異なる文字列を上限なくインターンする場合は、:c:func:" +"`PyUnicode_FromString` と :c:func:`PyUnicode_InternInPlace` を直接呼び出すこ" +"とを推奨します。" -#: ../../c-api/unicode.rst:1802 msgid "" "Return a non-zero value if *str* is interned, zero if not. The *str* " "argument must be a string; this is not checked. This function always " "succeeds." msgstr "" +"*str* がインターン済みならゼロ以外の値、そうでなければゼロを返します。\n" +"*str* 引数は文字列でなければなりませんが、検査は行いません。\n" +"この関数は常に成功します。" -#: ../../c-api/unicode.rst:1808 msgid "" "A non-zero return value may carry additional information about *how* the " "string is interned. The meaning of such non-zero values, as well as each " "specific string's intern-related details, may change between CPython " "versions." msgstr "" +"ゼロ以外の戻り値には、文字列が *どのように* インターンされているかについての" +"追加情報が含まれる場合があります。\n" +"これらの値の意味や、各文字列のインターンに関する詳細は、CPython のバージョン" +"によって変わる可能性があります。" -#: ../../c-api/unicode.rst:1815 msgid "PyUnicodeWriter" -msgstr "" +msgstr "PyUnicodeWriter" -#: ../../c-api/unicode.rst:1817 msgid "" "The :c:type:`PyUnicodeWriter` API can be used to create a Python :class:" "`str` object." msgstr "" +":c:type:`PyUnicodeWriter` API を使って Python の :class:`str` オブジェクトを" +"作成できます。" -#: ../../c-api/unicode.rst:1824 msgid "A Unicode writer instance." -msgstr "" +msgstr "Unicode ライターのインスタンスです。" -#: ../../c-api/unicode.rst:1826 msgid "" "The instance must be destroyed by :c:func:`PyUnicodeWriter_Finish` on " "success, or :c:func:`PyUnicodeWriter_Discard` on error." msgstr "" +"成功時には :c:func:`PyUnicodeWriter_Finish`、エラー時には :c:func:" +"`PyUnicodeWriter_Discard` でインスタンスを破棄する必要があります。" -#: ../../c-api/unicode.rst:1829 msgid "" "The API is **not thread safe**. To share a writer with multiple threads, a " "critical section or a lock is needed." msgstr "" +"この API は **スレッドセーフではありません**。\n" +"複数のスレッドでライターを共有するには、クリティカルセクションまたはロックが" +"必要です。" -#: ../../c-api/unicode.rst:1834 msgid "Create a Unicode writer instance." -msgstr "" +msgstr "Unicode ライターのインスタンスを作成します。" -#: ../../c-api/unicode.rst:1836 msgid "*length* must be greater than or equal to ``0``." -msgstr "" +msgstr "*length* は ``0`` 以上でなければなりません。" -#: ../../c-api/unicode.rst:1838 msgid "" "If *length* is greater than ``0``, preallocate an internal buffer of " "*length* characters." msgstr "" +"*length* が ``0`` より大きければ、*length* 文字分の内部バッファを事前に割り当" +"てます。" -#: ../../c-api/unicode.rst:1841 ../../c-api/unicode.rst:1847 msgid "Set an exception and return ``NULL`` on error." -msgstr "" +msgstr "エラー時には例外を設定して ``NULL`` を返します。" -#: ../../c-api/unicode.rst:1845 msgid "" "Return the final Python :class:`str` object and destroy the writer instance." msgstr "" +"最終的な Python の :class:`str` オブジェクトを返し、ライターのインスタンスを" +"破棄します。" -#: ../../c-api/unicode.rst:1849 ../../c-api/unicode.rst:1857 msgid "The writer instance is invalid after this call." -msgstr "" +msgstr "この呼び出しの後、ライターのインスタンスは無効になります。" -#: ../../c-api/unicode.rst:1853 msgid "Discard the internal Unicode buffer and destroy the writer instance." -msgstr "" +msgstr "内部の Unicode バッファを破棄し、ライターのインスタンスを破棄します。" -#: ../../c-api/unicode.rst:1855 msgid "If *writer* is ``NULL``, no operation is performed." -msgstr "" +msgstr "*writer* が ``NULL`` の場合は何もしません。" -#: ../../c-api/unicode.rst:1861 msgid "Write the single Unicode character *ch* into *writer*." -msgstr "" +msgstr "Unicode 文字 *ch* を 1 文字、*writer* に書き込みます。" -#: ../../c-api/unicode.rst:1863 ../../c-api/unicode.rst:1873 -#: ../../c-api/unicode.rst:1888 ../../c-api/unicode.rst:1898 -#: ../../c-api/unicode.rst:1910 ../../c-api/unicode.rst:1917 -#: ../../c-api/unicode.rst:1930 ../../c-api/unicode.rst:1945 -#: ../../c-api/unicode.rst:1952 ../../c-api/unicode.rst:1971 msgid "" "On success, return ``0``. On error, set an exception, leave the writer " "unchanged, and return ``-1``." msgstr "" +"成功すると ``0`` を返します。\n" +"エラー時には例外を設定し、ライターは変更せずに ``-1`` を返します。" -#: ../../c-api/unicode.rst:1868 msgid "" "Decode the string *str* from UTF-8 in strict mode and write the output into " "*writer*." msgstr "" +"文字列 *str* を UTF-8 の strict モードでデコードし、結果を *writer* に書き込" +"みます。" -#: ../../c-api/unicode.rst:1870 ../../c-api/unicode.rst:1882 -#: ../../c-api/unicode.rst:1960 msgid "" "*size* is the string length in bytes. If *size* is equal to ``-1``, call " "``strlen(str)`` to get the string length." msgstr "" +"*size* はバイト単位の文字列の長さです。\n" +"*size* が ``-1`` の場合は ``strlen(str)`` を呼び出して文字列の長さを取得しま" +"す。" -#: ../../c-api/unicode.rst:1876 msgid "See also :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`." -msgstr "" +msgstr ":c:func:`PyUnicodeWriter_DecodeUTF8Stateful` も参照してください。" -#: ../../c-api/unicode.rst:1880 msgid "Write the ASCII string *str* into *writer*." -msgstr "" +msgstr "ASCII 文字列 *str* を *writer* に書き込みます。" -#: ../../c-api/unicode.rst:1885 msgid "" "*str* must only contain ASCII characters. The behavior is undefined if *str* " "contains non-ASCII characters." msgstr "" +"*str* は ASCII 文字だけを含む必要があります。\n" +"非 ASCII 文字が含まれている場合、動作は未定義です。" -#: ../../c-api/unicode.rst:1893 msgid "Write the wide string *str* into *writer*." -msgstr "" +msgstr "ワイド文字列 *str* を *writer* に書き込みます。" -#: ../../c-api/unicode.rst:1895 msgid "" "*size* is a number of wide characters. If *size* is equal to ``-1``, call " "``wcslen(str)`` to get the string length." msgstr "" +"*size* はワイド文字の数です。\n" +"*size* が ``-1`` の場合は ``wcslen(str)`` を呼び出して文字列の長さを取得しま" +"す。" -#: ../../c-api/unicode.rst:1903 msgid "Write the UCS4 string *str* into *writer*." -msgstr "" +msgstr "UCS4 文字列 *str* を *writer* に書き込みます。" -#: ../../c-api/unicode.rst:1905 msgid "*size* is a number of UCS4 characters." -msgstr "" +msgstr "*size* は UCS4 文字の数です。" -#: ../../c-api/unicode.rst:1907 msgid "" "All characters must be in range [U+0000; U+10ffff]. If the string contains " "invalid characters, the behavior is undefined." msgstr "" +"すべての文字は [U+0000; U+10ffff] の範囲内でなければなりません。\n" +"文字列に無効な文字が含まれている場合、動作は未定義です。" -#: ../../c-api/unicode.rst:1915 msgid "" "Call :c:func:`PyObject_Str` on *obj* and write the output into *writer*." msgstr "" +"*obj* に対して :c:func:`PyObject_Str` を呼び出し、結果を *writer* に書き込み" +"ます。" -#: ../../c-api/unicode.rst:1920 msgid "" "To write a :class:`str` subclass which overrides the :meth:`~object.__str__` " "method, :c:func:`PyUnicode_FromObject` can be used to get the original " "string." msgstr "" +":meth:`~object.__str__` メソッドをオーバーライドする :class:`str` サブクラス" +"を書き込むには、:c:func:`PyUnicode_FromObject` を使って元の文字列を取得できま" +"す。" -#: ../../c-api/unicode.rst:1926 msgid "" "Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*." msgstr "" +"*obj* に対して :c:func:`PyObject_Repr` を呼び出し、結果を *writer* に書き込み" +"ます。" -#: ../../c-api/unicode.rst:1928 msgid "If *obj* is ``NULL``, write the string ``\"\"`` into *writer*." msgstr "" +"*obj* が ``NULL`` の場合は、文字列 ``\"\"`` を *writer* に書き込みま" +"す。" -#: ../../c-api/unicode.rst:1935 msgid "Added support for ``NULL``." -msgstr "" +msgstr "``NULL`` のサポートが追加されました。" -#: ../../c-api/unicode.rst:1939 msgid "Write the substring ``str[start:end]`` into *writer*." -msgstr "" +msgstr "部分文字列 ``str[start:end]`` を *writer* に書き込みます。" -#: ../../c-api/unicode.rst:1941 msgid "" "*str* must be Python :class:`str` object. *start* must be greater than or " "equal to 0, and less than or equal to *end*. *end* must be less than or " "equal to *str* length." msgstr "" +"*str* は Python の :class:`str` オブジェクトでなければなりません。\n" +"*start* は 0 以上かつ *end* 以下、*end* は *str* の長さ以下でなければなりませ" +"ん。" -#: ../../c-api/unicode.rst:1950 msgid "" "Similar to :c:func:`PyUnicode_FromFormat`, but write the output directly " "into *writer*." msgstr "" +":c:func:`PyUnicode_FromFormat` と同様ですが、出力を直接 *writer* に書き込みま" +"す。" -#: ../../c-api/unicode.rst:1957 msgid "" "Decode the string *str* from UTF-8 with *errors* error handler and write the " "output into *writer*." msgstr "" +"エラーハンドラ *errors* を使って文字列 *str* を UTF-8 からデコードし、結果を " +"*writer* に書き込みます。" -#: ../../c-api/unicode.rst:1963 msgid "" "*errors* is an :ref:`error handler ` name, such as " "``\"replace\"``. If *errors* is ``NULL``, use the strict error handler." msgstr "" +"*errors* は ``\"replace\"`` などの :ref:`エラーハンドラ ` の" +"名前です。\n" +"*errors* が ``NULL`` の場合は strict エラーハンドラを使います。" -#: ../../c-api/unicode.rst:1966 msgid "" "If *consumed* is not ``NULL``, set *\\*consumed* to the number of decoded " "bytes on success. If *consumed* is ``NULL``, treat trailing incomplete UTF-8 " "byte sequences as an error." msgstr "" +"*consumed* が ``NULL`` でなければ、成功時に *\\*consumed* にデコードしたバイ" +"ト数を設定します。\n" +"*consumed* が ``NULL`` の場合は、末尾の不完全な UTF-8 バイト列をエラーとして" +"扱います。" -#: ../../c-api/unicode.rst:1974 msgid "See also :c:func:`PyUnicodeWriter_WriteUTF8`." -msgstr "" +msgstr ":c:func:`PyUnicodeWriter_WriteUTF8` も参照してください。" -#: ../../c-api/unicode.rst:1977 msgid "Deprecated API" -msgstr "" +msgstr "非推奨の API" -#: ../../c-api/unicode.rst:1979 msgid "The following API is deprecated." -msgstr "" +msgstr "以下の API は非推奨です。" -#: ../../c-api/unicode.rst:1983 msgid "" "This is a typedef of :c:type:`wchar_t`, which is a 16-bit type or 32-bit " "type depending on the platform. Please use :c:type:`wchar_t` directly " "instead." msgstr "" +"これは :c:type:`wchar_t` の typedef であり、プラットフォームに応じて 16 ビッ" +"トまたは 32 ビットの型になります。\n" +"代わりに :c:type:`wchar_t` を直接使ってください。" #: ../../c-api/unicode.rst:1987 msgid "" @@ -2706,27 +2956,33 @@ msgstr "" "Unicode バージョンのどちらを選択したかによって、 16ビットか32ビットのどちらか" "の型になっていました。" -#: ../../c-api/unicode.rst:1997 msgid "" "Do nothing and return ``0``. This API is kept only for backward " "compatibility, but there are no plans to remove it." msgstr "" +"何もせずに ``0`` を返します。\n" +"この API は後方互換性のためだけに残されていますが、削除する予定はありません。" -#: ../../c-api/unicode.rst:2003 msgid "" "This API does nothing since Python 3.12. Previously, this needed to be " "called for each string created using the old API (:c:func:`!" "PyUnicode_FromUnicode` or similar)." msgstr "" +"Python 3.12 以降、この API は何もしません。\n" +"以前は、古い API (:c:func:`!PyUnicode_FromUnicode` など) で作成した文字列ごと" +"に呼び出す必要がありました。" -#: ../../c-api/unicode.rst:2011 msgid "" "Do nothing and return ``1``. This API is kept only for backward " "compatibility, but there are no plans to remove it." msgstr "" +"何もせずに ``1`` を返します。\n" +"この API は後方互換性のためだけに残されていますが、削除する予定はありません。" -#: ../../c-api/unicode.rst:2017 msgid "" "This API does nothing since Python 3.12. Previously, this could be called to " "check if :c:func:`PyUnicode_READY` is necessary." msgstr "" +"Python 3.12 以降、この API は何もしません。\n" +"以前は、:c:func:`PyUnicode_READY` が必要かどうかを調べるために呼び出せまし" +"た。" diff --git a/c-api/utilities.po b/c-api/utilities.po index 67850cdac..9ad008c99 100644 --- a/c-api/utilities.po +++ b/c-api/utilities.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/utilities.rst:7 diff --git a/c-api/veryhigh.po b/c-api/veryhigh.po index 76506249c..0f25a7cac 100644 --- a/c-api/veryhigh.po +++ b/c-api/veryhigh.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/veryhigh.rst:8 @@ -35,7 +35,6 @@ msgstr "" "この章の関数を使うとファイルまたはバッファにある Python ソースコードを実行で" "きますが、より詳細なやり取りをインタプリタとすることはできないでしょう。" -#: ../../c-api/veryhigh.rst:14 msgid "" "Several of these functions accept a start symbol from the grammar as a " "parameter. The available start symbols are :c:data:`Py_eval_input`, :c:data:" @@ -43,8 +42,11 @@ msgid "" "`Py_func_type_input`. These are described following the functions which " "accept them as parameters." msgstr "" +"これらの関数の一部は、文法の開始記号を引数に取ります。\n" +"利用できる開始記号は :c:data:`Py_eval_input`、:c:data:`Py_file_input`、:c:" +"data:`Py_single_input`、:c:data:`Py_func_type_input` です。\n" +"説明は、それらを引数に取る関数の後にあります。" -#: ../../c-api/veryhigh.rst:20 msgid "" "Note also that several of these functions take :c:expr:`FILE*` parameters. " "One particular issue which needs to be handled carefully is that the :c:type:" @@ -55,6 +57,13 @@ msgid "" "it is certain that they were created by the same library that the Python " "runtime is using." msgstr "" +"これらの関数の一部は :c:expr:`FILE*` 引数も受け取ります。\n" +"C ライブラリが異なると :c:type:`FILE` 構造体も異なり、互換性がない場合がある" +"点に特に注意が必要です。\n" +"少なくとも Windows では、動的リンクされた拡張が実際に別のライブラリを使うこと" +"があります。\n" +":c:expr:`FILE*` 引数を渡す場合は、Python ランタイムが使うのと同じライブラリに" +"よって作成されたものだと確実に分かっている必要があります。" #: ../../c-api/veryhigh.rst:31 msgid "" @@ -120,12 +129,13 @@ msgstr "" "します。エラーがあっても、例外情報を得る方法はありません。 *flags* の意味につ" "いては、後述します。" -#: ../../c-api/veryhigh.rst:73 msgid "" "Note that if an otherwise unhandled :exc:`SystemExit` is raised, this " "function will not return ``-1``, but exit the process, as long as :c:member:" "`PyConfig.inspect` is zero." msgstr "" +"処理されない :exc:`SystemExit` が送出されると、:c:member:`PyConfig.inspect` " +"がゼロである限り、この関数は ``-1`` を返さずにプロセスを終了します。" #: ../../c-api/veryhigh.rst:80 msgid "" @@ -168,13 +178,16 @@ msgstr "" "\"rb\")``)。\n" "そうしない場合は、 Python は行末が LF のスクリプトを正しく扱えないでしょう。" -#: ../../c-api/veryhigh.rst:105 msgid "" "Read and execute a single statement from a file associated with an " "interactive device according to the *flags* argument. The user will be " "prompted using ``sys.ps1`` and ``sys.ps2``. *filename* must be a Python :" "class:`str` object." msgstr "" +"対話的なデバイスに関連付けられたファイルから、``flags`` 引数に従って一つの文" +"を読み込み、実行します。\n" +"利用者には ``sys.ps1`` と ``sys.ps2`` を使ってプロンプトを表示します。\n" +"``filename`` は Python の :class:`str` オブジェクトでなければなりません。" #: ../../c-api/veryhigh.rst:110 msgid "" @@ -198,12 +211,14 @@ msgstr "" "下記の :c:func:`PyRun_InteractiveOneFlags` の *flags* を ``NULL`` にして単純" "化したインターフェースです。" -#: ../../c-api/veryhigh.rst:125 msgid "" "Similar to :c:func:`PyRun_InteractiveOneObject`, but *filename* is a :c:expr:" "`const char*`, which is decoded from the :term:`filesystem encoding and " "error handler`." msgstr "" +":c:func:`PyRun_InteractiveOneObject` と同様ですが、``filename`` は :c:expr:" +"`const char*` で、:term:`ファイルシステムのエンコーディングとエラーハンドラ " +"` を使ってデコードされます。" #: ../../c-api/veryhigh.rst:132 msgid "" @@ -227,7 +242,6 @@ msgstr "" "` でデコードされます。\n" "EOFに達すると ``0`` を返すか、失敗したら負の数を返します。" -#: ../../c-api/veryhigh.rst:146 msgid "" "Can be set to point to a function with the prototype ``int func(void)``. " "The function will be called when Python's interpreter prompt is about to " @@ -236,12 +250,19 @@ msgid "" "prompt with other event loops, as done in :file:`Modules/_tkinter.c` in the " "Python source code." msgstr "" +"プロトタイプが ``int func(void)`` の関数へのポインタを設定できます。\n" +"Python インタープリタのプロンプトがアイドル状態になり、端末からの利用者の入力" +"を待とうとするときに呼び出されます。\n" +"戻り値は無視します。\n" +"このフックを置き換えると、Python ソースの :file:`Modules/_tkinter.c` のよう" +"に、インタープリタのプロンプトをほかのイベントループと統合できます。" -#: ../../c-api/veryhigh.rst:154 ../../c-api/veryhigh.rst:178 msgid "" "This function is only called from the :ref:`main interpreter `." msgstr "" +"この関数は :ref:`メインインタープリタ ` からだけ呼び" +"出されます。" #: ../../c-api/veryhigh.rst:161 msgid "" @@ -289,7 +310,6 @@ msgstr "" "下記の :c:func:`PyRun_StringFlags` の *flags* を ``NULL`` にして単純化したイ" "ンターフェースです。" -#: ../../c-api/veryhigh.rst:190 msgid "" "Execute Python source code from *str* in the context specified by the " "objects *globals* and *locals* with the compiler flags specified by " @@ -297,6 +317,13 @@ msgid "" "implements the mapping protocol. The parameter *start* specifies the start " "symbol and must be one of the :ref:`available start symbols `." msgstr "" +"``str`` の Python ソースコードを、オブジェクト ``globals`` と ``locals`` が指" +"定するコンテキストで、``flags`` が指定するコンパイラフラグを使って実行しま" +"す。\n" +"``globals`` は辞書でなければならず、``locals`` はマッピングプロトコルを実装す" +"る任意のオブジェクトを指定できます。\n" +"``start`` 引数は開始記号を指定し、:ref:`利用できる開始記号 ` " +"のいずれかでなければなりません。" #: ../../c-api/veryhigh.rst:196 msgid "" @@ -361,7 +388,6 @@ msgstr "" "下記の :c:func:`Py_CompileStringExFlags` の *optimize* を ``-1`` にして単純化" "したインターフェースです。" -#: ../../c-api/veryhigh.rst:241 msgid "" "Parse and compile the Python source code in *str*, returning the resulting " "code object. The start symbol is given by *start*; this can be used to " @@ -371,6 +397,14 @@ msgid "" "exception messages. This returns ``NULL`` if the code cannot be parsed or " "compiled." msgstr "" +"``str`` 内の Python ソースコードを構文解析してコンパイルし、そのコードオブ" +"ジェクトを返します。\n" +"開始記号は ``start`` で指定し、:ref:`利用できる開始記号 ` のい" +"ずれかでなければなりません。\n" +"これによって、コンパイルできるコードを制限できます。\n" +"``filename`` で指定されたファイル名はコードオブジェクトの作成に使われ、トレー" +"スバックや :exc:`SyntaxError` のメッセージに現れることがあります。\n" +"コードを構文解析またはコンパイルできない場合は ``NULL`` を返します。" #: ../../c-api/veryhigh.rst:249 msgid "" @@ -404,7 +438,6 @@ msgstr "" "トと、グローバル変数とローカル変数だけを受け取ります。\n" "他の引数には ``NULL`` が渡されます。" -#: ../../c-api/veryhigh.rst:274 msgid "" "Evaluate a precompiled code object, given a particular environment for its " "evaluation. This environment consists of a dictionary of global variables, " @@ -412,10 +445,11 @@ msgid "" "defaults, a dictionary of default values for :ref:`keyword-only ` arguments and a closure tuple of cells." msgstr "" -"与えられた特定の環境で、コンパイル済みのコードオブジェクトを評価します。この" -"環境はグローバル変数の辞書と、ローカル変数のマッピングオブジェクト、引数の配" -"列、キーワードとデフォルト値、:ref:`キーワード専用 ` " -"引数のデフォルト値の辞書と、セルのクロージャタプルで構成されます。" +"指定された評価環境で、コンパイル済みのコードオブジェクトを評価します。\n" +"環境は、グローバル変数の辞書、ローカル変数のマッピングオブジェクト、引数・" +"キーワード・デフォルト値それぞれの配列、:ref:`キーワード専用 ` 引数のデフォルト値の辞書、クロージャのセルのタプルからなりま" +"す。" #: ../../c-api/veryhigh.rst:283 msgid "" @@ -468,63 +502,72 @@ msgstr "" "``PyCompilerFlags *flags`` として渡されます。この場合、``from __future__ " "import`` は *flags* の内容を変更できます。" -#: ../../c-api/veryhigh.rst:314 msgid "" "Whenever ``PyCompilerFlags *flags`` is ``NULL``, :c:member:`~PyCompilerFlags." "cf_flags` is treated as equal to ``0``, and any modification due to ``from " "__future__ import`` is discarded." msgstr "" +"``PyCompilerFlags *flags`` が ``NULL`` の場合、:c:member:`~PyCompilerFlags." +"cf_flags` は ``0`` として扱われ、``from __future__ import`` による変更は破棄" +"されます。" #: ../../c-api/veryhigh.rst:320 msgid "Compiler flags." msgstr "コンパイラフラグ。" -#: ../../c-api/veryhigh.rst:324 msgid "" "*cf_feature_version* is the minor Python version. It should be initialized " "to ``PY_MINOR_VERSION``." msgstr "" +"``cf_feature_version`` は Python のマイナーバージョンです。\n" +"``PY_MINOR_VERSION`` に初期化してください。" -#: ../../c-api/veryhigh.rst:327 msgid "" "The field is ignored by default, it is used if and only if ``PyCF_ONLY_AST`` " "flag is set in :c:member:`~PyCompilerFlags.cf_flags`." msgstr "" +"このフィールドはデフォルトでは無視されます。\n" +":c:member:`~PyCompilerFlags.cf_flags` に ``PyCF_ONLY_AST`` フラグが設定されて" +"いる場合に限って使います。" -#: ../../c-api/veryhigh.rst:330 msgid "Added *cf_feature_version* field." -msgstr "" +msgstr "``cf_feature_version`` フィールドを追加しました。" -#: ../../c-api/veryhigh.rst:333 msgid "The available compiler flags are accessible as macros:" -msgstr "" +msgstr "利用できるコンパイラフラグはマクロとして公開されています。" -#: ../../c-api/veryhigh.rst:342 msgid "" "See :ref:`compiler flags ` in documentation of the :py:" "mod:`!ast` Python module, which exports these constants under the same names." msgstr "" +":py:mod:`!ast` Python モジュールのドキュメントの :ref:`コンパイラフラグ ` を参照してください。\n" +"このモジュールは同じ名前で定数をエクスポートしています。" -#: ../../c-api/veryhigh.rst:347 msgid "Low-level flags" -msgstr "" +msgstr "低レベルのフラグ" -#: ../../c-api/veryhigh.rst:348 msgid "" "The following flags and masks serve narrow needs of the standard library and " "interactive interpreters. Code outside the standard library rarely has a " "reason to use them. They are considered implementation details and may " "change at any time." msgstr "" +"以下のフラグとマスクは、標準ライブラリや対話的インタープリタの限られた用途に" +"使います。\n" +"標準ライブラリ以外のコードで必要になることはほとんどありません。\n" +"実装の詳細とみなされ、いつでも変更される可能性があります。" -#: ../../c-api/veryhigh.rst:355 msgid "" "This flag is a private interface between the compiler and the :mod:`codeop` " "module. Do not use it; its behavior is unsupported and may change without " "warning." msgstr "" +"このフラグはコンパイラと :mod:`codeop` モジュールの間のプライベートなインター" +"フェースです。\n" +"使わないでください。\n" +"動作はサポートされておらず、予告なく変更される可能性があります。" -#: ../../c-api/veryhigh.rst:359 msgid "" "With this flag set, when compilation fails because the source text ends " "where more input is expected, for example in the middle of an indented block " @@ -535,8 +578,15 @@ msgid "" "with a real syntax error, so that interactive interpreters know when to " "prompt for another line instead of reporting an error." msgstr "" +"このフラグを設定すると、インデントされたブロックの途中や閉じていない文字列リ" +"テラルなど、さらに入力が必要な位置でソースが終わったためにコンパイルに失敗し" +"た場合、:exc:`SyntaxError` のサブクラスである未公開の " +"``_IncompleteInputError`` を送出します。\n" +":mod:`codeop` モジュールは、このフラグを :c:macro:`PyCF_DONT_IMPLY_DEDENT` と" +"併せて設定し、入力が未完成なのか、実際に構文エラーがあるのかを区別します。\n" +"これにより、対話的インタープリタはエラーを報告せずに次の行の入力を求めるべき" +"場合を判断できます。" -#: ../../c-api/veryhigh.rst:373 msgid "" "By default, when compiling with the :c:var:`Py_single_input` start symbol, " "reaching the end of the source text implicitly closes any open indented " @@ -544,8 +594,11 @@ msgid "" "the source ends with a newline; otherwise, compilation fails with a :exc:" "`SyntaxError`:" msgstr "" +"デフォルトでは、:c:var:`Py_single_input` を開始記号としてコンパイルすると、" +"ソースの末尾で未終了のインデントブロックを暗黙に閉じます。\n" +"このフラグを設定すると、ソースの最終行が改行で終わる場合だけブロックを閉じ、" +"それ以外の場合は :exc:`SyntaxError` でコンパイルが失敗します。" -#: ../../c-api/veryhigh.rst:379 msgid "" "PyCompilerFlags flags = {\n" " .cf_flags = 0,\n" @@ -562,22 +615,39 @@ msgid "" "flags.cf_flags = PyCF_DONT_IMPLY_DEDENT;\n" "Py_CompileStringFlags(source, \"\", Py_single_input, &flags);" msgstr "" +"PyCompilerFlags flags = {\n" +" .cf_flags = 0,\n" +" .cf_feature_version = PY_MINOR_VERSION,\n" +"};\n" +"const char *source = \"if a:\\n pass\";\n" +"\n" +"/* \"if\" ブロックは暗黙に閉じられる。\n" +" コードオブジェクトを返す: */\n" +"Py_CompileStringFlags(source, \"\", Py_single_input, &flags);\n" +"\n" +"/* このフラグを使うと、最終行が改行で終わらないため\n" +" SyntaxError で失敗する: */\n" +"flags.cf_flags = PyCF_DONT_IMPLY_DEDENT;\n" +"Py_CompileStringFlags(source, \"\", Py_single_input, &flags);" -#: ../../c-api/veryhigh.rst:396 msgid "" "The :mod:`codeop` module uses this flag to detect incomplete interactive " "input. While the user is still typing inside an indented block, the source " "does not yet end with a newline, so it fails to compile and the user is " "prompted for another line." msgstr "" +":mod:`codeop` モジュールは、このフラグで対話的入力が未完成かどうかを検出しま" +"す。\n" +"インデントされたブロック内でまだ入力中なら、ソースはまだ改行で終わらないため" +"コンパイルに失敗し、利用者に次の行の入力を求めます。" -#: ../../c-api/veryhigh.rst:403 msgid "" "Read the source text as UTF-8, ignoring its :pep:`263` encoding declaration " "(\"coding cookie\"), if any:" msgstr "" +"ソースに :pep:`263` のエンコーディング宣言 (\"coding cookie\") があっても無視" +"し、UTF-8 として読み取ります。" -#: ../../c-api/veryhigh.rst:406 msgid "" "PyCompilerFlags flags = {\n" " .cf_flags = 0,\n" @@ -594,34 +664,53 @@ msgid "" "flags.cf_flags = PyCF_IGNORE_COOKIE;\n" "Py_CompileStringFlags(source, \"\", Py_file_input, &flags);" msgstr "" +"PyCompilerFlags flags = {\n" +" .cf_flags = 0,\n" +" .cf_feature_version = PY_MINOR_VERSION,\n" +"};\n" +"const char *source = \"# coding: latin-1\\ns = '\\xe9'\\n\";\n" +"\n" +"/* エンコーディング宣言に従い、バイト 0xE9 を Latin-1 として\n" +" デコードする。s を \"é\" に設定するコードオブジェクトを返す: */\n" +"Py_CompileStringFlags(source, \"\", Py_file_input, &flags);\n" +"\n" +"/* このフラグを使うとエンコーディング宣言を無視する。0xE9 は\n" +" 有効な UTF-8 ではないため、コンパイルは SyntaxError で失敗する: */\n" +"flags.cf_flags = PyCF_IGNORE_COOKIE;\n" +"Py_CompileStringFlags(source, \"\", Py_file_input, &flags);" -#: ../../c-api/veryhigh.rst:423 msgid "" "The :func:`compile`, :func:`eval` and :func:`exec` built-in functions set " "this flag when the source is a :class:`str` object, because they pass the " "text to the parser encoded as UTF-8." msgstr "" +"組み込み関数 :func:`compile`、:func:`eval`、:func:`exec` は、ソースが :class:" +"`str` オブジェクトの場合にこのフラグを設定します。\n" +"UTF-8 にエンコードしたテキストをパーサに渡すためです。" -#: ../../c-api/veryhigh.rst:429 msgid "" "Mark the source text as known to be UTF-8 encoded. The :func:`compile`, :" "func:`eval` and :func:`exec` built-in functions set this flag, but it " "currently has no effect." msgstr "" +"ソースが UTF-8 エンコードであると分かっていることを示します。\n" +"組み込み関数 :func:`compile`、:func:`eval`、:func:`exec` はこのフラグを設定し" +"ますが、現在は効果がありません。" -#: ../../c-api/veryhigh.rst:433 msgid "" "The \"``PyCF``\" flags above can be combined with \"``CO_FUTURE``\" flags " "such as :c:macro:`CO_FUTURE_ANNOTATIONS` to enable features normally " "selectable using :ref:`future statements `. See :ref:" "`c_codeobject_flags` for a complete list." msgstr "" +"上記の「``PyCF``」フラグは、:c:macro:`CO_FUTURE_ANNOTATIONS` などの" +"「``CO_FUTURE``」フラグと組み合わせ、通常 :ref:`future 文 ` で選択す" +"る機能を有効にできます。\n" +"全一覧は :ref:`c_codeobject_flags` を参照してください。" -#: ../../c-api/veryhigh.rst:438 msgid "The following masks combine several flags:" -msgstr "" +msgstr "以下のマスクは複数のフラグを組み合わせたものです。" -#: ../../c-api/veryhigh.rst:442 msgid "" "Bitmask of all ``CO_FUTURE`` flags (see :ref:`c_codeobject_flags`), which " "select features normally enabled by :ref:`future statements `. When " @@ -629,28 +718,37 @@ msgid "" "__future__ import`` statement, the flag for the imported feature is added to " "*flags*, so that code executed later in the same context inherits it." msgstr "" +"通常 :ref:`future 文 ` で有効にする機能を選ぶ、すべての " +"``CO_FUTURE`` フラグ (:ref:`c_codeobject_flags` を参照) のビットマスクで" +"す。\n" +"``PyCompilerFlags *flags`` 引数を使ってコンパイルしたコードに ``from " +"__future__ import`` 文が含まれる場合、インポートされた機能のフラグが " +"``flags`` に追加され、同じコンテキストで後から実行するコードに引き継がれま" +"す。" -#: ../../c-api/veryhigh.rst:452 msgid "" "Do not use this mask in new code. It is kept only so that old code passing " "its flags to :func:`compile` keeps working." msgstr "" +"新しいコードでこのマスクを使わないでください。\n" +"フラグを :func:`compile` に渡す古いコードが動作し続けるためだけに残されていま" +"す。" -#: ../../c-api/veryhigh.rst:455 msgid "" "Bitmask of flags for obsolete future features that no longer have any effect." -msgstr "" +msgstr "もはや効果のない、廃止された future 機能のフラグのビットマスクです。" -#: ../../c-api/veryhigh.rst:460 msgid "" "Bitmask of all ``PyCF`` flags that change how the source is compiled, such " "as :c:macro:`PyCF_ONLY_AST`. The :func:`compile` built-in function uses this " "mask to validate its *flags* argument." msgstr "" +":c:macro:`PyCF_ONLY_AST` など、ソースのコンパイル方法を変えるすべての " +"``PyCF`` フラグのビットマスクです。\n" +"組み込み関数 :func:`compile` は、``flags`` 引数の検証にこのマスクを使います。" -#: ../../c-api/veryhigh.rst:469 msgid "Available start symbols" -msgstr "" +msgstr "利用できる開始記号" #: ../../c-api/veryhigh.rst:476 msgid "" @@ -679,56 +777,53 @@ msgstr "" "単一の文に対するPython文法の開始記号で、 :c:func:`Py_CompileString` と一緒に" "使います。これは対話式のインタプリタループのための記号です。" -#: ../../c-api/veryhigh.rst:502 msgid "" "The start symbol from the Python grammar for a function type; for use with :" "c:func:`Py_CompileString`. This is used to parse \"signature type comments\" " "from :pep:`484`." msgstr "" +"関数型に対する Python 文法の開始記号で、:c:func:`Py_CompileString` と一緒に使" +"います。\n" +":pep:`484` の「シグネチャ型コメント」を構文解析するために使います。" -#: ../../c-api/veryhigh.rst:506 msgid "This requires the :c:macro:`PyCF_ONLY_AST` flag to be set." -msgstr "" +msgstr ":c:macro:`PyCF_ONLY_AST` フラグの設定が必要です。" -#: ../../c-api/veryhigh.rst:509 msgid ":py:class:`ast.FunctionType`" -msgstr "" +msgstr ":py:class:`ast.FunctionType`" -#: ../../c-api/veryhigh.rst:510 msgid ":pep:`484`" -msgstr "" +msgstr ":pep:`484`" -#: ../../c-api/veryhigh.rst:516 msgid "Stack Effects" -msgstr "" +msgstr "スタックへの影響" -#: ../../c-api/veryhigh.rst:519 msgid ":py:func:`dis.stack_effect`" -msgstr "" +msgstr ":py:func:`dis.stack_effect`" -#: ../../c-api/veryhigh.rst:524 msgid "Sentinel value representing an invalid stack effect." -msgstr "" +msgstr "無効なスタックへの影響を表す番兵値。" -#: ../../c-api/veryhigh.rst:526 msgid "This is currently equivalent to ``INT_MAX``." -msgstr "" +msgstr "現在は ``INT_MAX`` と同等です。" #: ../../c-api/veryhigh.rst:533 msgid "Compute the stack effect of *opcode* with argument *oparg*." msgstr "*opcode* と引数 *oparg* がスタックに与える影響を計算します。" -#: ../../c-api/veryhigh.rst:535 ../../c-api/veryhigh.rst:549 msgid "" "On success, this function returns the stack effect; on failure, this " "returns :c:macro:`PY_INVALID_STACK_EFFECT`." msgstr "" +"成功した場合はスタックへの影響を返し、失敗した場合は :c:macro:" +"`PY_INVALID_STACK_EFFECT` を返します。" -#: ../../c-api/veryhigh.rst:543 msgid "" "Similar to :c:func:`PyCompile_OpcodeStackEffect`, but don't include the " "stack effect of jumping if *jump* is zero." msgstr "" +":c:func:`PyCompile_OpcodeStackEffect` と同様ですが、``jump`` がゼロの場合は" +"ジャンプしたときのスタックへの影響を含めません。" #: ../../c-api/veryhigh.rst:546 msgid "" @@ -736,7 +831,5 @@ msgid "" "if *jump* is ``1`` or ``-1``, this will include it." msgstr "" -#: ../../c-api/veryhigh.rst:474 ../../c-api/veryhigh.rst:482 -#: ../../c-api/veryhigh.rst:491 ../../c-api/veryhigh.rst:500 msgid "Py_CompileString (C function)" -msgstr "" +msgstr "Py_CompileString (C 関数)" diff --git a/c-api/weakref.po b/c-api/weakref.po index 2d87b69e3..ddb7c26c3 100644 --- a/c-api/weakref.po +++ b/c-api/weakref.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../c-api/weakref.rst:6 @@ -38,30 +38,36 @@ msgstr "" "な参照オブジェクトで、第二はオリジナルのオブジェクトに対して可能な限りプロキ" "シとして振舞うオブジェクトです。" -#: ../../c-api/weakref.rst:16 msgid "" "Return non-zero if *ob* is either a reference or proxy object. This " "function always succeeds." msgstr "" +"``ob`` が弱参照オブジェクトまたはプロキシオブジェクトの場合に非ゼロを返しま" +"す。\n" +"この関数は常に成功します。" -#: ../../c-api/weakref.rst:22 msgid "" "Return non-zero if *ob* is a reference object or a subclass of the reference " "type. This function always succeeds." msgstr "" +"``ob`` が弱参照型またはそのサブクラスのインスタンスの場合に非ゼロを返しま" +"す。\n" +"この関数は常に成功します。" -#: ../../c-api/weakref.rst:28 msgid "" "Return non-zero if *ob* is a reference object, but not a subclass of the " "reference type. This function always succeeds." msgstr "" +"``ob`` が弱参照型のインスタンスであり、サブクラスのインスタンスではない場合に" +"非ゼロを返します。\n" +"この関数は常に成功します。" -#: ../../c-api/weakref.rst:34 msgid "" "Return non-zero if *ob* is a proxy object. This function always succeeds." msgstr "" +"``ob`` がプロキシオブジェクトの場合に非ゼロを返します。\n" +"この関数は常に成功します。" -#: ../../c-api/weakref.rst:39 msgid "" "Return a weak reference object for the object *ob*. This will always return " "a new reference, but is not guaranteed to create a new object; an existing " @@ -72,12 +78,23 @@ msgid "" "weakly referenceable object, this will raise :exc:`TypeError` and return " "``NULL``." msgstr "" +"オブジェクト ``ob`` に対する弱参照オブジェクトを返します。\n" +"常に新しい参照を返しますが、新しいオブジェクトが作成されるとは限りません。\n" +"既存の弱参照オブジェクトを返す場合があります。\n" +"第 2 引数 ``callback`` には、``ob`` がガベージコレクションで回収されたときに" +"通知を受け取る呼び出し可能オブジェクトを指定できます。\n" +"このオブジェクトは、弱参照オブジェクト自身を唯一の引数として受け取る必要があ" +"ります。\n" +"``callback`` は ``None`` または ``NULL`` でも構いません。\n" +"``ob`` が弱参照を作成できるオブジェクトでない場合は :exc:`TypeError` を送出し" +"て ``NULL`` を返します。" -#: ../../c-api/weakref.rst:49 ../../c-api/weakref.rst:65 msgid "" ":c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly " "referenceable." msgstr "" +"``ob`` が弱参照を作成できるオブジェクトかどうかを調べるには :c:func:" +"`PyType_SUPPORTS_WEAKREFS` を参照してください。" #: ../../c-api/weakref.rst:55 msgid "" @@ -91,51 +108,55 @@ msgid "" "return ``NULL``." msgstr "" -#: ../../c-api/weakref.rst:71 msgid "" "Get a :term:`strong reference` to the referenced object from a weak " "reference, *ref*, into *\\*pobj*." msgstr "" +"弱参照 ``ref`` から参照先のオブジェクトへの :term:`強参照 ` を取得し、``*pobj`` に格納します。" -#: ../../c-api/weakref.rst:74 msgid "" "On success, set *\\*pobj* to a new :term:`strong reference` to the " "referenced object and return 1." msgstr "" +"成功した場合は、参照先のオブジェクトへの新しい :term:`強参照 ` を ``*pobj`` に設定し、1 を返します。" -#: ../../c-api/weakref.rst:76 msgid "If the reference is dead, set *\\*pobj* to ``NULL`` and return 0." msgstr "" +"参照先が消滅している場合は、``*pobj`` を ``NULL`` に設定し、0 を返します。" -#: ../../c-api/weakref.rst:77 msgid "On error, raise an exception and return -1." -msgstr "" +msgstr "エラーの場合は例外を送出し、-1 を返します。" -#: ../../c-api/weakref.rst:84 msgid "" "Test if the weak reference *ref* is dead. Returns 1 if the reference is " "dead, 0 if it is alive, and -1 with an error set if *ref* is not a weak " "reference object." msgstr "" +"弱参照 ``ref`` の参照先が消滅しているかどうかを調べます。\n" +"参照先が消滅していれば 1、生存していれば 0 を返します。\n" +"``ref`` が弱参照オブジェクトでなければ、エラーを設定して -1 を返します。" -#: ../../c-api/weakref.rst:93 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "to clear weak references." msgstr "" +"この関数は、弱参照をクリアするために :c:member:`~PyTypeObject.tp_dealloc` ハ" +"ンドラから呼び出されます。" -#: ../../c-api/weakref.rst:96 msgid "" "This iterates through the weak references for *object* and calls callbacks " "for those references which have one. It returns when all callbacks have been " "attempted." msgstr "" +"``object`` への弱参照を順に調べ、コールバックを持つものについてはそのコール" +"バックを呼び出します。\n" +"すべてのコールバックの呼び出しを試みた後で戻ります。" -#: ../../c-api/weakref.rst:103 msgid "Clears the weakrefs for *object* without calling the callbacks." -msgstr "" +msgstr "コールバックを呼び出さずに ``object`` への弱参照をクリアします。" -#: ../../c-api/weakref.rst:105 msgid "" "This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler " "for types with finalizers (i.e., :meth:`~object.__del__`). The handler for " @@ -143,9 +164,16 @@ msgid "" "and call their callbacks, then the finalizer, and finally this function to " "clear any weakrefs that may have been created by the finalizer." msgstr "" +"この関数は、ファイナライザ (つまり :meth:`~object.__del__`) を持つ型の :c:" +"member:`~PyTypeObject.tp_dealloc` ハンドラから呼び出されます。\n" +"このようなオブジェクトのハンドラは、まず :c:func:`PyObject_ClearWeakRefs` を" +"呼び出して弱参照をクリアし、そのコールバックを呼び出します。\n" +"次にファイナライザを呼び出し、最後にこの関数を呼び出してファイナライザが作成" +"した可能性のある弱参照をクリアします。" -#: ../../c-api/weakref.rst:111 msgid "" "In most circumstances, it's more appropriate to use :c:func:" "`PyObject_ClearWeakRefs` to clear weakrefs instead of this function." msgstr "" +"ほとんどの場合、弱参照のクリアにはこの関数よりも :c:func:" +"`PyObject_ClearWeakRefs` を使う方が適切です。" diff --git a/contents.po b/contents.po index 68ea80bb0..9180df324 100644 --- a/contents.po +++ b/contents.po @@ -16,12 +16,11 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../contents.rst:3 msgid "Python Documentation contents" -msgstr "Python Documentation contents" +msgstr "Python ドキュメントの目次" diff --git a/copyright.po b/copyright.po index ca92a964a..d7ed47ada 100644 --- a/copyright.po +++ b/copyright.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: よっちゃん, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../copyright.rst:3 diff --git a/deprecations/c-api-pending-removal-in-3.14.po b/deprecations/c-api-pending-removal-in-3.14.po index 1cb75e174..4ceab7169 100644 --- a/deprecations/c-api-pending-removal-in-3.14.po +++ b/deprecations/c-api-pending-removal-in-3.14.po @@ -12,24 +12,25 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:2 msgid "Pending removal in Python 3.14" -msgstr "" +msgstr "Python 3.14 で削除予定" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:4 msgid "" "The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules " "(:pep:`699`; :gh:`101193`)." msgstr "" +"拡張モジュールで :c:type:`PyDictObject` の ``ma_version_tag`` フィールドを使" +"うこと (:pep:`699`、:gh:`101193`)。" -#: ../../deprecations/c-api-pending-removal-in-3.14.rst:7 msgid "" "Creating :c:data:`immutable types ` with mutable " "bases (:gh:`95388`)." msgstr "" +"ミュータブルな基底型を持つ :c:data:`イミュータブルな型 " +"` を作成すること (:gh:`95388`)。" diff --git a/deprecations/c-api-pending-removal-in-3.15.po b/deprecations/c-api-pending-removal-in-3.15.po index 77391954c..089c3bcdf 100644 --- a/deprecations/c-api-pending-removal-in-3.15.po +++ b/deprecations/c-api-pending-removal-in-3.15.po @@ -12,46 +12,55 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:2 msgid "Pending removal in Python 3.15" -msgstr "" +msgstr "Python 3.15 で削除予定" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" "The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" +":c:func:`!PyImport_ImportModuleNoBlock`:代わりに :c:func:" +"`PyImport_ImportModule` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" ":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" +":c:func:`!PyWeakref_GetObject` と :c:func:`!PyWeakref_GET_OBJECT`:代わりに :" +"c:func:`PyWeakref_GetRef` を使ってください。\n" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.12 以前でも :c:func:`PyWeakref_GetRef` を利用できま" +"す。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" +":c:func:`!PyUnicode_AsDecodedObject`:代わりに :c:func:`PyCodec_Decode` を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " "than :class:`str`, such as :class:`bytes`." msgstr "" +":c:func:`!PyUnicode_AsDecodedUnicode`:代わりに :c:func:`PyCodec_Decode` を" +"使ってください。\n" +"一部のコーデック (例えば \"base64\") は、:class:`bytes` など :class:`str` 以" +"外の型を返す場合があることに注意してください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" +":c:func:`!PyUnicode_AsEncodedObject`:代わりに :c:func:`PyCodec_Encode` を" +"使ってください。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" @@ -60,226 +69,282 @@ msgid "" "than :class:`bytes`, such as :class:`str`." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" -msgstr "" +msgstr "Python 3.13 で非推奨となった Python 初期化関数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" ":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" +":c:func:`!Py_GetPath`:代わりに :c:func:" +"`PyConfig_Get(\"module_search_paths\") ` (:data:`sys.path`) を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" ":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" +":c:func:`!Py_GetPrefix`:代わりに :c:func:`PyConfig_Get(\"base_prefix\") " +"` (:data:`sys.base_prefix`) を使ってください。\n" +":ref:`仮想環境 ` に対応する必要がある場合は、:c:func:" +"`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" ":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" +":c:func:`!Py_GetExecPrefix`:代わりに :c:func:" +"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." +"base_exec_prefix`) を使ってください。\n" +":ref:`仮想環境 ` に対応する必要がある場合は、:c:func:" +"`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" ":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" +":c:func:`!Py_GetProgramFullPath`:代わりに :c:func:" +"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`) を使っ" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" ":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" +":c:func:`!Py_GetProgramName`:代わりに :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" ":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" +":c:func:`!Py_GetPythonHome`:代わりに :c:func:`PyConfig_Get(\"home\") " +"` または環境変数 :envvar:`PYTHONHOME` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." msgstr "" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.13 以前でも :c:func:`PyConfig_Get` を利用できます。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" -msgstr "" +msgstr "Python 3.11 で非推奨となった、Python の初期化を設定する関数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr "" +":c:func:`!PySys_SetArgvEx()`:代わりに :c:member:`PyConfig.argv` を設定してく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr "" +":c:func:`!PySys_SetArgv()`:代わりに :c:member:`PyConfig.argv` を設定してくだ" +"さい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" +":c:func:`!Py_SetProgramName()`:代わりに :c:member:`PyConfig.program_name` を" +"設定してください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr "" +":c:func:`!Py_SetPythonHome()`:代わりに :c:member:`PyConfig.home` を設定して" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" ":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" +":c:func:`!PySys_ResetWarnOptions`:代わりに :data:`sys.warnoptions` と :data:" +"`!warnings.filters` をクリアしてください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" +"代わりに :c:type:`PyConfig` と :c:func:`Py_InitializeFromConfig` API を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" -msgstr "" +msgstr "グローバルな設定変数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." msgstr "" +":c:var:`Py_DebugFlag`:代わりに :c:member:`PyConfig.parser_debug` または :c:" +"func:`PyConfig_Get(\"parser_debug\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." msgstr "" +":c:var:`Py_VerboseFlag`:代わりに :c:member:`PyConfig.verbose` または :c:" +"func:`PyConfig_Get(\"verbose\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." msgstr "" +":c:var:`Py_QuietFlag`:代わりに :c:member:`PyConfig.quiet` または :c:func:" +"`PyConfig_Get(\"quiet\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." msgstr "" +":c:var:`Py_InteractiveFlag`:代わりに :c:member:`PyConfig.interactive` また" +"は :c:func:`PyConfig_Get(\"interactive\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." msgstr "" +":c:var:`Py_InspectFlag`:代わりに :c:member:`PyConfig.inspect` または :c:" +"func:`PyConfig_Get(\"inspect\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." msgstr "" +":c:var:`Py_OptimizeFlag`:代わりに :c:member:`PyConfig.optimization_level` ま" +"たは :c:func:`PyConfig_Get(\"optimization_level\") ` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." msgstr "" +":c:var:`Py_NoSiteFlag`:代わりに :c:member:`PyConfig.site_import` または :c:" +"func:`PyConfig_Get(\"site_import\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." msgstr "" +":c:var:`Py_BytesWarningFlag`:代わりに :c:member:`PyConfig.bytes_warning` ま" +"たは :c:func:`PyConfig_Get(\"bytes_warning\") ` を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." msgstr "" +":c:var:`Py_FrozenFlag`:代わりに :c:member:`PyConfig.pathconfig_warnings` ま" +"たは :c:func:`PyConfig_Get(\"pathconfig_warnings\") ` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." msgstr "" +":c:var:`Py_IgnoreEnvironmentFlag`:代わりに :c:member:`PyConfig." +"use_environment` または :c:func:`PyConfig_Get(\"use_environment\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." msgstr "" +":c:var:`Py_DontWriteBytecodeFlag`:代わりに :c:member:`PyConfig." +"write_bytecode` または :c:func:`PyConfig_Get(\"write_bytecode\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " "` instead." msgstr "" +":c:var:`Py_NoUserSiteDirectory`:代わりに :c:member:`PyConfig." +"user_site_directory` または :c:func:`PyConfig_Get(\"user_site_directory\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." msgstr "" +":c:var:`Py_UnbufferedStdioFlag`:代わりに :c:member:`PyConfig." +"buffered_stdio` または :c:func:`PyConfig_Get(\"buffered_stdio\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " "` instead." msgstr "" +":c:var:`Py_HashRandomizationFlag`:代わりに :c:member:`PyConfig." +"use_hash_seed` と :c:member:`PyConfig.hash_seed` または :c:func:" +"`PyConfig_Get(\"hash_seed\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." msgstr "" +":c:var:`Py_IsolatedFlag`:代わりに :c:member:`PyConfig.isolated` または :c:" +"func:`PyConfig_Get(\"isolated\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") ` instead." msgstr "" +":c:var:`Py_LegacyWindowsFSEncodingFlag`:代わりに :c:member:`PyPreConfig." +"legacy_windows_fs_encoding` または :c:func:" +"`PyConfig_Get(\"legacy_windows_fs_encoding\") ` を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "` instead." msgstr "" +":c:var:`Py_LegacyWindowsStdioFlag`:代わりに :c:member:`PyConfig." +"legacy_windows_stdio` または :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." "filesystem_encoding` or :c:func:`PyConfig_Get(\"filesystem_encoding\") " "` instead." msgstr "" +":c:var:`!Py_FileSystemDefaultEncoding`、:c:var:`!" +"Py_HasFileSystemDefaultEncoding`:代わりに :c:member:`PyConfig." +"filesystem_encoding` または :c:func:`PyConfig_Get(\"filesystem_encoding\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " "` instead." msgstr "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:代わりに :c:member:`PyConfig." +"filesystem_errors` または :c:func:`PyConfig_Get(\"filesystem_errors\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" "`Py_PreInitialize`)" msgstr "" +":c:var:`!Py_UTF8Mode`:代わりに :c:member:`PyPreConfig.utf8_mode` または :c:" +"func:`PyConfig_Get(\"utf8_mode\") ` を使ってください。\n" +"(:c:func:`Py_PreInitialize` を参照)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " "get these options at runtime." msgstr "" +"これらのオプションを設定するには、:c:type:`PyConfig` と :c:func:" +"`Py_InitializeFromConfig` API を使ってください。\n" +"実行時に値を取得するには :c:func:`PyConfig_Get` を使えます。" diff --git a/deprecations/c-api-pending-removal-in-3.16.po b/deprecations/c-api-pending-removal-in-3.16.po index a8d218a1e..42a8dbf90 100644 --- a/deprecations/c-api-pending-removal-in-3.16.po +++ b/deprecations/c-api-pending-removal-in-3.16.po @@ -12,16 +12,14 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 msgid "Pending removal in Python 3.16" -msgstr "" +msgstr "Python 3.16 で削除予定" -#: ../../deprecations/c-api-pending-removal-in-3.16.rst:4 msgid "The bundled copy of ``libmpdec``." -msgstr "" +msgstr "同梱されている ``libmpdec``。" diff --git a/deprecations/c-api-pending-removal-in-3.18.po b/deprecations/c-api-pending-removal-in-3.18.po index 16dda633c..572b0e906 100644 --- a/deprecations/c-api-pending-removal-in-3.18.po +++ b/deprecations/c-api-pending-removal-in-3.18.po @@ -12,97 +12,108 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" -msgstr "" +msgstr "Python 3.18 で削除予定" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:4 msgid "" "The following private functions are deprecated and planned for removal in " "Python 3.18:" -msgstr "" +msgstr "以下の非公開関数は非推奨となり、Python 3.18 で削除予定です:" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:7 msgid ":c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`." -msgstr "" +msgstr ":c:func:`!_PyBytes_Join`::c:func:`PyBytes_Join` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:8 msgid "" ":c:func:`!_PyDict_GetItemStringWithError`: use :c:func:" "`PyDict_GetItemStringRef`." msgstr "" +":c:func:`!_PyDict_GetItemStringWithError`::c:func:`PyDict_GetItemStringRef` " +"を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:9 msgid ":c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`." -msgstr "" +msgstr ":c:func:`!_PyDict_Pop()`::c:func:`PyDict_Pop` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:10 msgid ":c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`." -msgstr "" +msgstr ":c:func:`!_PyLong_Sign()`::c:func:`PyLong_GetSign` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:11 msgid "" ":c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`: use :c:func:" "`PyLongWriter_Create`." msgstr "" +":c:func:`!_PyLong_FromDigits` と :c:func:`!_PyLong_New`::c:func:" +"`PyLongWriter_Create` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:13 msgid "" ":c:func:`!_PyThreadState_UncheckedGet`: use :c:func:" "`PyThreadState_GetUnchecked`." msgstr "" +":c:func:`!_PyThreadState_UncheckedGet`::c:func:`PyThreadState_GetUnchecked` " +"を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:14 msgid ":c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`." msgstr "" +":c:func:`!_PyUnicode_AsString`::c:func:`PyUnicode_AsUTF8` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:15 msgid "" ":c:func:`!_PyUnicodeWriter_Init`: replace ``_PyUnicodeWriter_Init(&writer)`` " "with :c:func:`writer = PyUnicodeWriter_Create(0) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Init`:``_PyUnicodeWriter_Init(&writer)`` を :c:" +"func:`writer = PyUnicodeWriter_Create(0) ` に置き換え" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:18 msgid "" ":c:func:`!_PyUnicodeWriter_Finish`: replace " "``_PyUnicodeWriter_Finish(&writer)`` with :c:func:" "`PyUnicodeWriter_Finish(writer) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Finish`:``_PyUnicodeWriter_Finish(&writer)`` を :" +"c:func:`PyUnicodeWriter_Finish(writer) ` に置き換えて" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:21 msgid "" ":c:func:`!_PyUnicodeWriter_Dealloc`: replace " "``_PyUnicodeWriter_Dealloc(&writer)`` with :c:func:" "`PyUnicodeWriter_Discard(writer) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Dealloc`:``_PyUnicodeWriter_Dealloc(&writer)`` " +"を :c:func:`PyUnicodeWriter_Discard(writer) ` に置き" +"換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:24 msgid "" ":c:func:`!_PyUnicodeWriter_WriteChar`: replace " "``_PyUnicodeWriter_WriteChar(&writer, ch)`` with :c:func:" "`PyUnicodeWriter_WriteChar(writer, ch) `." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteChar`:``_PyUnicodeWriter_WriteChar(&writer, " +"ch)`` を :c:func:`PyUnicodeWriter_WriteChar(writer, ch) " +"` に置き換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:27 msgid "" ":c:func:`!_PyUnicodeWriter_WriteStr`: replace " "``_PyUnicodeWriter_WriteStr(&writer, str)`` with :c:func:" "`PyUnicodeWriter_WriteStr(writer, str) `." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteStr`:``_PyUnicodeWriter_WriteStr(&writer, " +"str)`` を :c:func:`PyUnicodeWriter_WriteStr(writer, str) " +"` に置き換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:30 msgid "" ":c:func:`!_PyUnicodeWriter_WriteSubstring`: replace " "``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:" "`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " "`." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`:" +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` を :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"` に置き換えてください。" #: ../../deprecations/c-api-pending-removal-in-3.18.rst:33 msgid "" @@ -118,25 +129,24 @@ msgid "" "`PyUnicodeWriter_WriteUTF8(writer, str) `." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:39 msgid ":c:func:`!_PyUnicodeWriter_Prepare`: (no replacement)." -msgstr "" +msgstr ":c:func:`!_PyUnicodeWriter_Prepare`:(代替なし)。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:40 msgid ":c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement)." -msgstr "" +msgstr ":c:func:`!_PyUnicodeWriter_PrepareKind`:(代替なし)。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:41 msgid ":c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`." msgstr "" +":c:func:`!_Py_HashPointer`::c:func:`Py_HashPointer` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:42 msgid ":c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`." -msgstr "" +msgstr ":c:func:`!_Py_fopen_obj`::c:func:`Py_fopen` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:44 msgid "" "The `pythoncapi-compat project `__ can be used to get these new public functions on Python 3.13 and older. " "(Contributed by Victor Stinner in :gh:`128863`.)" msgstr "" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.13 以前でもこれらの新しい公開関数を利用できます。\n" +"(Victor Stinner が :gh:`128863` で貢献しました。)" diff --git a/deprecations/c-api-pending-removal-in-future.po b/deprecations/c-api-pending-removal-in-future.po index 367edd985..7bdafa47a 100644 --- a/deprecations/c-api-pending-removal-in-future.po +++ b/deprecations/c-api-pending-removal-in-future.po @@ -12,99 +12,108 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/c-api-pending-removal-in-future.rst:2 msgid "Pending removal in future versions" -msgstr "" +msgstr "将来のバージョンで削除予定" -#: ../../deprecations/c-api-pending-removal-in-future.rst:4 msgid "" "The following APIs are deprecated and will be removed, although there is " "currently no date scheduled for their removal." msgstr "" +"以下の API は非推奨となり、削除される予定ですが、現時点では削除時期は決まって" +"いません。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:7 msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:Python 3.8 以降では不要です。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr "" +":c:func:`PyErr_Fetch`:代わりに :c:func:`PyErr_GetRaisedException` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 msgid "" ":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" +":c:func:`PyErr_NormalizeException`:代わりに :c:func:" +"`PyErr_GetRaisedException` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 msgid "" ":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr "" +":c:func:`PyErr_Restore`:代わりに :c:func:`PyErr_SetRaisedException` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:15 msgid "" ":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" +":c:func:`PyModule_GetFilename`:代わりに :c:func:" +"`PyModule_GetFilenameObject` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:17 msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr "" +":c:func:`PyOS_AfterFork`:代わりに :c:func:`PyOS_AfterFork_Child` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:19 msgid "" ":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` instead." msgstr "" +":c:func:`PySlice_GetIndicesEx`:代わりに :c:func:`PySlice_Unpack` と :c:func:" +"`PySlice_AdjustIndices` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:21 msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" -msgstr "" +msgstr ":c:func:`PyUnicode_READY`:Python 3.12 以降では不要です。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr "" +":c:func:`!PyErr_Display`:代わりに :c:func:`PyErr_DisplayException` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" ":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " "instead." msgstr "" +":c:func:`!_PyErr_ChainExceptions`:代わりに :c:func:`!" +"_PyErr_ChainExceptions1` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." msgstr "" +":c:member:`!PyBytesObject.ob_shash` メンバー:代わりに :c:func:" +"`PyObject_Hash` を呼び出してください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid "Thread Local Storage (TLS) API:" -msgstr "" +msgstr "スレッドローカルストレージ (TLS) API:" #: ../../deprecations/c-api-pending-removal-in-future.rst:31 msgid "" ":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr "" +":c:func:`PyThread_delete_key`:代わりに :c:func:`PyThread_tss_free` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr "" +":c:func:`PyThread_set_key_value`:代わりに :c:func:`PyThread_tss_set` を使っ" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid "" ":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr "" +":c:func:`PyThread_get_key_value`:代わりに :c:func:`PyThread_tss_get` を使っ" +"てください。" #: ../../deprecations/c-api-pending-removal-in-future.rst:39 msgid "" @@ -112,6 +121,5 @@ msgid "" "instead." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-future.rst:41 msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." -msgstr "" +msgstr ":c:func:`PyThread_ReInitTLS`:Python 3.7 以降では不要です。" diff --git a/deprecations/index.po b/deprecations/index.po index 30bf32ccf..82fa273dc 100644 --- a/deprecations/index.po +++ b/deprecations/index.po @@ -18,96 +18,97 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../deprecations/index.rst:2 msgid "Deprecations" msgstr "非推奨" -#: ../../deprecations/c-api-pending-removal-in-3.16.rst:2 -#: ../../deprecations/pending-removal-in-3.16.rst:2 msgid "Pending removal in Python 3.16" -msgstr "" +msgstr "Python 3.16 で削除予定" -#: ../../deprecations/pending-removal-in-3.16.rst:4 msgid "The import system:" -msgstr "" +msgstr "インポートシステム:" -#: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" "Setting :attr:`~module.__loader__` on a module while failing to set :attr:" "`__spec__.loader ` is deprecated. In " "Python 3.16, :attr:`!__loader__` will cease to be set or taken into " "consideration by the import system or the standard library." msgstr "" +"モジュールの :attr:`__spec__.loader ` " +"を設定せずに :attr:`~module.__loader__` を設定することは非推奨です。\n" +"Python 3.16 では、インポートシステムや標準ライブラリは :attr:`!__loader__` を" +"設定しなくなり、その値も参照しなくなります。" -#: ../../deprecations/pending-removal-in-3.16.rst:11 msgid ":mod:`array`:" -msgstr "" +msgstr ":mod:`array`:" -#: ../../deprecations/pending-removal-in-3.16.rst:13 msgid "" "The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " "documentation since Python 3.3 and at runtime since Python 3.13. Use the " "``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." msgstr "" +"書式コード ``'u'`` (:c:type:`wchar_t`) は、Python 3.3 からドキュメントで非推" +"奨とされ、Python 3.13 からは実行時にも非推奨とされています。\n" +"Unicode 文字には、代わりに書式コード ``'w'`` (:c:type:`Py_UCS4`) を使ってくだ" +"さい。" -#: ../../deprecations/pending-removal-in-3.16.rst:19 msgid ":mod:`asyncio`:" -msgstr "" +msgstr ":mod:`asyncio`:" -#: ../../deprecations/pending-removal-in-3.16.rst:21 msgid "" ":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " "Python 3.16; use :func:`inspect.iscoroutinefunction` instead. (Contributed " "by Jiahao Li and Kumar Aditya in :gh:`122875`.)" msgstr "" +":func:`!asyncio.iscoroutinefunction` は非推奨となり、Python 3.16 で削除されま" +"す。\n" +"代わりに :func:`inspect.iscoroutinefunction` を使ってください。\n" +"(Jiahao Li と Kumar Aditya が :gh:`122875` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:26 msgid "" ":mod:`asyncio` policy system is deprecated and will be removed in Python " "3.16. In particular, the following classes and functions are deprecated:" msgstr "" +":mod:`asyncio` のポリシーシステムは非推奨となり、Python 3.16 で削除されま" +"す。\n" +"具体的には、以下のクラスと関数が非推奨です:" -#: ../../deprecations/pending-removal-in-3.16.rst:29 msgid ":class:`asyncio.AbstractEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.AbstractEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:30 msgid ":class:`asyncio.DefaultEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.DefaultEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:31 msgid ":class:`asyncio.WindowsSelectorEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.WindowsSelectorEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:32 msgid ":class:`asyncio.WindowsProactorEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.WindowsProactorEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:33 msgid ":func:`asyncio.get_event_loop_policy`" -msgstr "" +msgstr ":func:`asyncio.get_event_loop_policy`" -#: ../../deprecations/pending-removal-in-3.16.rst:34 msgid ":func:`asyncio.set_event_loop_policy`" -msgstr "" +msgstr ":func:`asyncio.set_event_loop_policy`" -#: ../../deprecations/pending-removal-in-3.16.rst:36 msgid "" "Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with " "*loop_factory* to use the desired event loop implementation." msgstr "" +"使いたいイベントループの実装を指定するには、:func:`asyncio.run` または :" +"class:`asyncio.Runner` の ``loop_factory`` を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:39 msgid "For example, to use :class:`asyncio.SelectorEventLoop` on Windows::" msgstr "" +"例えば、Windows で :class:`asyncio.SelectorEventLoop` を使うには、次のように" +"します。 ::" -#: ../../deprecations/pending-removal-in-3.16.rst:41 msgid "" "import asyncio\n" "\n" @@ -116,17 +117,19 @@ msgid "" "\n" "asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" msgstr "" +"import asyncio\n" +"\n" +"async def main():\n" +" ...\n" +"\n" +"asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" -#: ../../deprecations/pending-removal-in-3.16.rst:48 msgid "(Contributed by Kumar Aditya in :gh:`127949`.)" -msgstr "" +msgstr "(Kumar Aditya が :gh:`127949` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:50 -#: ../../deprecations/pending-removal-in-future.rst:16 msgid ":mod:`builtins`:" -msgstr "" +msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-3.16.rst:52 msgid "" "Bitwise inversion on boolean types, ``~True`` or ``~False`` has been " "deprecated since Python 3.12, as it produces surprising and unintuitive " @@ -134,121 +137,129 @@ msgid "" "of a Boolean. In the rare case that you need the bitwise inversion of the " "underlying integer, convert to ``int`` explicitly (``~int(x)``)." msgstr "" +"真偽値に対するビット単位の反転 ``~True`` や ``~False`` は、直感に反する意外な" +"結果 (``-2`` と ``-1``) になるため、Python 3.12 から非推奨です。\n" +"真偽値の論理否定には、代わりに ``not x`` を使ってください。\n" +"元の整数値のビット単位の反転が必要になるまれな場合には、明示的に ``int`` に変" +"換してください (``~int(x)``)。" -#: ../../deprecations/pending-removal-in-3.16.rst:59 msgid ":mod:`functools`:" -msgstr "" +msgstr ":mod:`functools`:" -#: ../../deprecations/pending-removal-in-3.16.rst:61 msgid "" "Calling the Python implementation of :func:`functools.reduce` with " "*function* or *sequence* as keyword arguments has been deprecated since " "Python 3.14." msgstr "" +":func:`functools.reduce` の Python 実装を、``function`` や ``sequence`` を" +"キーワード引数として指定して呼び出すことは、Python 3.14 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.16.rst:64 msgid ":mod:`logging`:" -msgstr "" +msgstr ":mod:`logging`:" -#: ../../deprecations/pending-removal-in-3.16.rst:66 msgid "" "Support for custom logging handlers with the *strm* argument is deprecated " "and scheduled for removal in Python 3.16. Define handlers with the *stream* " "argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)" msgstr "" +"``strm`` 引数を持つカスタムログハンドラーへの対応は非推奨となり、Python 3.16 " +"で削除予定です。\n" +"代わりに ``stream`` 引数を持つハンドラーを定義してください。\n" +"(Mariusz Felisiak が :gh:`115032` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:70 msgid ":mod:`mimetypes`:" -msgstr "" +msgstr ":mod:`mimetypes`:" -#: ../../deprecations/pending-removal-in-3.16.rst:72 msgid "" "Valid extensions start with a '.' or are empty for :meth:`mimetypes." "MimeTypes.add_type`. Undotted extensions are deprecated and will raise a :" "exc:`ValueError` in Python 3.16. (Contributed by Hugo van Kemenade in :gh:" "`75223`.)" msgstr "" +":meth:`mimetypes.MimeTypes.add_type` で有効な拡張子は、'.' で始まるものか空の" +"ものです。\n" +"ドットのない拡張子は非推奨となり、Python 3.16 では :exc:`ValueError` が発生し" +"ます。\n" +"(Hugo van Kemenade が :gh:`75223` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:78 msgid ":mod:`shutil`:" -msgstr "" +msgstr ":mod:`shutil`:" -#: ../../deprecations/pending-removal-in-3.16.rst:80 msgid "" "The :class:`!ExecError` exception has been deprecated since Python 3.14. It " "has not been used by any function in :mod:`!shutil` since Python 3.4, and is " "now an alias of :exc:`RuntimeError`." msgstr "" +":class:`!ExecError` 例外は Python 3.14 から非推奨です。\n" +"Python 3.4 以降は :mod:`!shutil` のどの関数でも使われておらず、現在は :exc:" +"`RuntimeError` の別名になっています。" -#: ../../deprecations/pending-removal-in-3.16.rst:85 msgid ":mod:`symtable`:" -msgstr "" +msgstr ":mod:`symtable`:" -#: ../../deprecations/pending-removal-in-3.16.rst:87 msgid "" "The :meth:`Class.get_methods ` method has been " "deprecated since Python 3.14." msgstr "" +":meth:`Class.get_methods ` メソッドは Python " +"3.14 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.16.rst:90 msgid ":mod:`sys`:" -msgstr "" +msgstr ":mod:`sys`:" -#: ../../deprecations/pending-removal-in-3.16.rst:92 msgid "" "The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " "since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " "environment variable instead." msgstr "" +":func:`~sys._enablelegacywindowsfsencoding` 関数は Python 3.13 から非推奨で" +"す。\n" +"代わりに環境変数 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:96 msgid ":mod:`sysconfig`:" -msgstr "" +msgstr ":mod:`sysconfig`:" -#: ../../deprecations/pending-removal-in-3.16.rst:98 msgid "" "The :func:`!sysconfig.expand_makefile_vars` function has been deprecated " "since Python 3.14. Use the ``vars`` argument of :func:`sysconfig.get_paths` " "instead." msgstr "" +":func:`!sysconfig.expand_makefile_vars` 関数は Python 3.14 から非推奨です。\n" +"代わりに :func:`sysconfig.get_paths` の ``vars`` 引数を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:102 msgid ":mod:`tarfile`:" -msgstr "" +msgstr ":mod:`tarfile`:" -#: ../../deprecations/pending-removal-in-3.16.rst:104 msgid "" "The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " "deprecated since Python 3.13." msgstr "" +"ドキュメント化されておらず、使われてもいない :attr:`!TarFile.tarfile` 属性は " +"Python 3.13 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.17.rst:2 msgid "Pending removal in Python 3.17" -msgstr "" +msgstr "Python 3.17 で削除予定" -#: ../../deprecations/pending-removal-in-3.17.rst:4 -#: ../../deprecations/pending-removal-in-future.rst:53 msgid ":mod:`datetime`:" -msgstr "" +msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 msgid "" ":meth:`~datetime.datetime.strptime` calls using a format string containing " "``%e`` (day of month) without a year. This has been deprecated since Python " "3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" msgstr "" +"年を含まず ``%e`` (月内の日) を含む書式文字列で :meth:`~datetime.datetime." +"strptime` を呼び出すこと。\n" +"これは Python 3.15 から非推奨です。\n" +"(Stan Ulbrych が :gh:`70647` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" -msgstr "" +msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." -msgstr "" +msgstr ":class:`collections.abc.ByteString` は Python 3.17 で削除予定です。" -#: ../../deprecations/pending-removal-in-3.17.rst:16 -#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -256,9 +267,13 @@ msgid "" "that explicitly specifies the types your code supports (e.g., ``bytes | " "bytearray | memoryview``)." msgstr "" +"実行時に ``obj`` が :ref:`バッファプロトコル ` を実装している" +"か調べるには、``isinstance(obj, collections.abc.Buffer)`` を使ってくださ" +"い。\n" +"型アノテーションには :class:`~collections.abc.Buffer` を使うか、コードが対応" +"する型を明示したユニオン (例えば ``bytes | bytearray | memoryview``) を使って" +"ください。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -268,53 +283,63 @@ msgid "" "also never understood as subtypes of :class:`!ByteString` (either at runtime " "or by static type checkers)." msgstr "" +":class:`!ByteString` は当初、:class:`bytes` と :class:`bytearray` の両方の上" +"位型となる抽象クラスとして意図されていました。\n" +"しかし、この ABC はメソッドを一つも持たないため、あるオブジェクトが :class:`!" +"ByteString` のインスタンスだと分かっても、そのオブジェクトに関する有用な情報" +"は何も得られませんでした。\n" +":class:`memoryview` など、他の一般的なバッファ型も、実行時にも静的型チェッ" +"カーによっても :class:`!ByteString` のサブタイプとして認識されることはありま" +"せんでした。" -#: ../../deprecations/pending-removal-in-3.17.rst:30 -#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" msgstr "" +"詳しくは :pep:`PEP 688 <688#current-options>` を参照してください。\n" +"(Shantanu Jain が :gh:`91896` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:34 msgid ":mod:`encodings`:" -msgstr "" +msgstr ":mod:`encodings`:" -#: ../../deprecations/pending-removal-in-3.17.rst:36 msgid "" "Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " "is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " "Ulbrych in :gh:`136702`.)" msgstr "" +":func:`encodings.normalize_encoding` に非 ASCII の ``encoding`` 名を渡すこと" +"は非推奨となり、Python 3.17 で削除予定です。\n" +"(Stan Ulbrych が :gh:`136702` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:40 msgid ":mod:`profile`:" -msgstr "" +msgstr ":mod:`profile`:" -#: ../../deprecations/pending-removal-in-3.17.rst:42 msgid "" "The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " "Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" "pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " "in :gh:`138122`.)" msgstr "" +":mod:`!profile` モジュールは非推奨となり、Python 3.17 で削除されます。\n" +"代わりに、互換性のある API を提供する :mod:`profiling.tracing` を使ってくださ" +"い。\n" +"詳しくは :pep:`799` を参照してください。\n" +"(Pablo Galindo と László Kiss Kollár が :gh:`138122` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:47 msgid ":mod:`webbrowser`:" -msgstr "" +msgstr ":mod:`webbrowser`:" -#: ../../deprecations/pending-removal-in-3.17.rst:49 msgid "" ":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" "webbrowser.MacOS`. (:gh:`137586`)" msgstr "" +":class:`!webbrowser.MacOSXOSAScript` は非推奨となりました。\n" +"代わりに :class:`!webbrowser.MacOS` を使ってください。\n" +"(:gh:`137586`)" -#: ../../deprecations/pending-removal-in-3.17.rst:52 -#: ../../deprecations/pending-removal-in-3.20.rst:57 msgid ":mod:`typing`:" -msgstr "" +msgstr ":mod:`typing`:" -#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -323,18 +348,24 @@ msgid "" "helpers like :func:`typing.get_origin` and :func:`typing.get_args` instead " "of relying on private implementation details." msgstr "" +"Python 3.14 より前は、従来のユニオンは非公開クラス ``typing." +"_UnionGenericAlias`` を使って実装されていました。\n" +"このクラスは実装上は不要になりましたが、後方互換性のために残されており、" +"Python 3.17 で削除予定です。\n" +"非公開の実装の詳細に依存する代わりに、:func:`typing.get_origin` や :func:" +"`typing.get_args` など、ドキュメント化されたイントロスペクション用の補助関数" +"を使ってください。" -#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." msgstr "" +"Python 3.9 から非推奨となっている :class:`typing.ByteString` は、Python 3.17 " +"で削除予定です。" -#: ../../deprecations/pending-removal-in-3.17.rst:79 msgid ":mod:`tkinter`:" -msgstr "" +msgstr ":mod:`tkinter`:" -#: ../../deprecations/pending-removal-in-3.17.rst:81 msgid "" "The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" "trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" @@ -342,65 +373,66 @@ msgid "" "in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" "trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" msgstr "" +"Python 3.14 から非推奨となっている :class:`!tkinter.Variable` のメソッド :" +"meth:`!trace_variable`、:meth:`!trace` (:meth:`!trace_variable` の別名)、:" +"meth:`!trace_vdelete`、:meth:`!trace_vinfo` は、Python 3.17 で削除予定で" +"す。\n" +"代わりに :meth:`!trace_add`、:meth:`!trace_remove`、:meth:`!trace_info` を" +"使ってください。\n" +"(Serhiy Storchaka が :gh:`120220` で貢献しました。)" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:2 -#: ../../deprecations/pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" -msgstr "" +msgstr "Python 3.18 で削除予定" -#: ../../deprecations/pending-removal-in-3.18.rst:4 msgid "" "No longer accept a boolean value when a file descriptor is expected. " "(Contributed by Serhiy Storchaka in :gh:`82626`.)" msgstr "" +"ファイルディスクリプタが必要なところでは、真偽値を受け付けなくなります。\n" +"(Serhiy Storchaka が :gh:`82626` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" -msgstr "" +msgstr ":mod:`decimal`:" -#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " "implementation, has been deprecated since Python 3.13. (Contributed by " "Serhiy Storchaka in :gh:`89902`.)" msgstr "" +":class:`~decimal.Decimal` の標準外でドキュメント化されていない書式指定子 " +"``'N'`` は、Python 3.13 から非推奨です。\n" +"これは :mod:`!decimal` モジュールの C 実装だけでサポートされています。\n" +"(Serhiy Storchaka が :gh:`89902` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.18.rst:14 -#: ../../deprecations/pending-removal-in-3.20.rst:42 msgid "Deprecations defined by :pep:`829`:" -msgstr "" +msgstr ":pep:`829` で定義された非推奨事項:" -#: ../../deprecations/pending-removal-in-3.18.rst:16 msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." msgstr "" +":file:`{name}.pth` ファイルの ``import`` 行は、警告なしで無視されます。" -#: ../../deprecations/pending-removal-in-3.18.rst:18 -#: ../../deprecations/pending-removal-in-3.20.rst:50 msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" -msgstr "" +msgstr "(Barry Warsaw が :gh:`148641` で貢献しました。)" -#: ../../deprecations/c-api-pending-removal-in-3.19.rst:2 -#: ../../deprecations/pending-removal-in-3.19.rst:2 msgid "Pending removal in Python 3.19" -msgstr "" +msgstr "Python 3.19 で削除予定" -#: ../../deprecations/pending-removal-in-3.19.rst:4 msgid ":mod:`ctypes`:" -msgstr "" +msgstr ":mod:`ctypes`:" -#: ../../deprecations/pending-removal-in-3.19.rst:6 msgid "" "Implicitly switching to the MSVC-compatible struct layout by setting :attr:" "`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_` on non-" "Windows platforms." msgstr "" +"Windows 以外のプラットフォームで、:attr:`~ctypes.Structure._layout_` を設定せ" +"ずに :attr:`~ctypes.Structure._pack_` を設定することで、暗黙的に MSVC 互換の" +"構造体レイアウトに切り替えること。" -#: ../../deprecations/pending-removal-in-3.19.rst:10 msgid ":mod:`hashlib`:" -msgstr "" +msgstr ":mod:`hashlib`:" -#: ../../deprecations/pending-removal-in-3.19.rst:12 msgid "" "In hash function constructors such as :func:`~hashlib.new` or the direct " "hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." @@ -408,123 +440,129 @@ msgid "" "keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " "implementations." msgstr "" +":mod:`!hashlib` のさまざまな実装では、:func:`~hashlib.new` や、:func:" +"`~hashlib.md5`、:func:`~hashlib.sha256` などのハッシュ名を直接使ったコンスト" +"ラクターに、省略可能な初期データを ``data=`` または ``string=`` というキー" +"ワード引数で渡すこともできました。" -#: ../../deprecations/pending-removal-in-3.19.rst:18 msgid "" "Support for the ``string`` keyword argument name is now deprecated and " "slated for removal in Python 3.19." msgstr "" +"キーワード引数名 ``string`` のサポートは非推奨となり、Python 3.19 で削除予定" +"です。" -#: ../../deprecations/pending-removal-in-3.19.rst:21 msgid "" "Before Python 3.13, the ``string`` keyword parameter was not correctly " "supported depending on the backend implementation of hash functions. Prefer " "passing the initial data as a positional argument for maximum backwards " "compatibility." msgstr "" +"Python 3.13 より前は、ハッシュ関数のバックエンド実装によっては、キーワードパ" +"ラメータ ``string`` が正しくサポートされていませんでした。\n" +"後方互換性を最大限に保つには、初期データは位置引数として渡してください。" -#: ../../deprecations/pending-removal-in-3.19.rst:26 msgid ":mod:`http.cookies`:" -msgstr "" +msgstr ":mod:`http.cookies`:" -#: ../../deprecations/pending-removal-in-3.19.rst:28 msgid "" ":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " "Python 3.19." msgstr "" +":meth:`http.cookies.Morsel.js_output` は非推奨となり、Python 3.19 で削除され" +"ます。" -#: ../../deprecations/pending-removal-in-3.19.rst:31 msgid "" ":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " "in Python 3.19." msgstr "" +":meth:`http.cookies.BaseCookie.js_output` は非推奨となり、Python 3.19 で削除" +"されます。" -#: ../../deprecations/pending-removal-in-3.19.rst:34 msgid ":mod:`imaplib`:" -msgstr "" +msgstr ":mod:`imaplib`:" -#: ../../deprecations/pending-removal-in-3.19.rst:36 msgid "" "Altering :attr:`IMAP4.file ` is now deprecated and " "slated for removal in Python 3.19. This property is now unused and changing " "its value does not automatically close the current file." msgstr "" +":attr:`IMAP4.file ` の変更は非推奨となり、Python 3.19 で" +"削除予定です。\n" +"このプロパティは現在使われておらず、値を変更しても現在のファイルは自動的には" +"閉じられません。" -#: ../../deprecations/pending-removal-in-3.19.rst:40 msgid "" "Before Python 3.14, this property was used to implement the corresponding " "``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " "is no longer the case since then." msgstr "" +"Python 3.14 より前は、このプロパティは :class:`~imaplib.IMAP4` の対応する " +"``read()`` メソッドと ``readline()`` メソッドの実装に使われていましたが、それ" +"以降は使われていません。" -#: ../../deprecations/c-api-pending-removal-in-3.20.rst:2 -#: ../../deprecations/pending-removal-in-3.20.rst:2 msgid "Pending removal in Python 3.20" -msgstr "" +msgstr "Python 3.20 で削除予定" -#: ../../deprecations/pending-removal-in-3.20.rst:4 msgid "" "Calling the ``__new__()`` method of :class:`struct.Struct` without the " "*format* argument is deprecated and will be removed in Python 3.20. " "Calling :meth:`~object.__init__` method on initialized :class:`~struct." "Struct` objects is deprecated and will be removed in Python 3.20." msgstr "" +":class:`struct.Struct` の ``__new__()`` メソッドを ``format`` 引数なしで呼び" +"出すことは非推奨となり、Python 3.20 で削除されます。\n" +"初期化済みの :class:`~struct.Struct` オブジェクトで :meth:`~object.__init__` " +"メソッドを呼び出すことも非推奨となり、Python 3.20 で削除されます。" -#: ../../deprecations/pending-removal-in-3.20.rst:9 msgid "" "(Contributed by Sergey B Kirpichev and Serhiy Storchaka in :gh:`143715`.)" msgstr "" +"(Sergey B Kirpichev と Serhiy Storchaka が :gh:`143715` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.20.rst:11 msgid "" "The ``__version__``, ``version`` and ``VERSION`` attributes have been " "deprecated in these standard library modules and will be removed in Python " "3.20. Use :py:data:`sys.version_info` instead." msgstr "" +"以下の標準ライブラリモジュールの ``__version__``、``version``、``VERSION`` 属" +"性は非推奨となり、Python 3.20 で削除されます。\n" +"代わりに :py:data:`sys.version_info` を使ってください。" -#: ../../deprecations/pending-removal-in-3.20.rst:15 msgid ":mod:`argparse`" -msgstr "" +msgstr ":mod:`argparse`" -#: ../../deprecations/pending-removal-in-3.20.rst:16 msgid ":mod:`csv`" -msgstr "" +msgstr ":mod:`csv`" #: ../../deprecations/pending-removal-in-3.20.rst:17 msgid ":mod:`ctypes`" msgstr ":mod:`ctypes`" -#: ../../deprecations/pending-removal-in-3.20.rst:18 msgid ":mod:`!ctypes.macholib`" -msgstr "" +msgstr ":mod:`!ctypes.macholib`" -#: ../../deprecations/pending-removal-in-3.20.rst:19 msgid ":mod:`decimal` (use :data:`decimal.SPEC_VERSION` instead)" msgstr "" +":mod:`decimal` (代わりに :data:`decimal.SPEC_VERSION` を使ってください)" -#: ../../deprecations/pending-removal-in-3.20.rst:20 msgid ":mod:`http.server`" -msgstr "" +msgstr ":mod:`http.server`" -#: ../../deprecations/pending-removal-in-3.20.rst:21 msgid ":mod:`imaplib`" -msgstr "" +msgstr ":mod:`imaplib`" -#: ../../deprecations/pending-removal-in-3.20.rst:22 msgid ":mod:`ipaddress`" -msgstr "" +msgstr ":mod:`ipaddress`" -#: ../../deprecations/pending-removal-in-3.20.rst:23 msgid ":mod:`json`" -msgstr "" +msgstr ":mod:`json`" -#: ../../deprecations/pending-removal-in-3.20.rst:24 msgid ":mod:`logging` (``__date__`` also deprecated)" -msgstr "" +msgstr ":mod:`logging` (``__date__`` も非推奨)" -#: ../../deprecations/pending-removal-in-3.20.rst:25 msgid ":mod:`optparse`" -msgstr "" +msgstr ":mod:`optparse`" #: ../../deprecations/pending-removal-in-3.20.rst:26 msgid ":mod:`pickle`" @@ -534,21 +572,18 @@ msgstr ":mod:`pickle`" msgid ":mod:`platform`" msgstr ":mod:`platform`" -#: ../../deprecations/pending-removal-in-3.20.rst:28 msgid ":mod:`re`" -msgstr "" +msgstr ":mod:`re`" -#: ../../deprecations/pending-removal-in-3.20.rst:29 msgid ":mod:`socketserver`" -msgstr "" +msgstr ":mod:`socketserver`" #: ../../deprecations/pending-removal-in-3.20.rst:30 msgid ":mod:`tabnanny`" msgstr ":mod:`tabnanny`" -#: ../../deprecations/pending-removal-in-3.20.rst:31 msgid ":mod:`tarfile`" -msgstr "" +msgstr ":mod:`tarfile`" #: ../../deprecations/pending-removal-in-3.20.rst:32 msgid ":mod:`tkinter.font`" @@ -558,101 +593,95 @@ msgstr ":mod:`tkinter.font`" msgid ":mod:`tkinter.ttk`" msgstr ":mod:`tkinter.ttk`" -#: ../../deprecations/pending-removal-in-3.20.rst:34 msgid ":mod:`wsgiref.simple_server`" -msgstr "" +msgstr ":mod:`wsgiref.simple_server`" -#: ../../deprecations/pending-removal-in-3.20.rst:35 msgid ":mod:`xml.etree.ElementTree`" -msgstr "" +msgstr ":mod:`xml.etree.ElementTree`" -#: ../../deprecations/pending-removal-in-3.20.rst:36 msgid ":mod:`!xml.sax.expatreader`" -msgstr "" +msgstr ":mod:`!xml.sax.expatreader`" -#: ../../deprecations/pending-removal-in-3.20.rst:37 msgid ":mod:`xml.sax.handler`" -msgstr "" +msgstr ":mod:`xml.sax.handler`" -#: ../../deprecations/pending-removal-in-3.20.rst:38 msgid ":mod:`zlib`" -msgstr "" +msgstr ":mod:`zlib`" -#: ../../deprecations/pending-removal-in-3.20.rst:40 msgid "(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)" -msgstr "" +msgstr "(Hugo van Kemenade と Stan Ulbrych が :gh:`76007` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.20.rst:44 msgid "" "Warnings are produced for ``import`` lines found in :file:`{name}.pth` files." -msgstr "" +msgstr ":file:`{name}.pth` ファイルに ``import`` 行がある場合は警告が出ます。" -#: ../../deprecations/pending-removal-in-3.20.rst:47 msgid "" ":file:`{name}.pth` files are no longer decoded in the locale encoding by " "default. They **MUST** be encoded in ``utf-8-sig``." msgstr "" +":file:`{name}.pth` ファイルは、デフォルトではロケールのエンコーディングでデ" +"コードされなくなります。\n" +"``utf-8-sig`` でエンコードされて **いなければなりません**。" -#: ../../deprecations/pending-removal-in-3.20.rst:52 msgid ":mod:`ast`:" -msgstr "" +msgstr ":mod:`ast`:" -#: ../../deprecations/pending-removal-in-3.20.rst:54 msgid "" "Creating instances of abstract AST nodes (such as :class:`ast.AST` or :class:" "`!ast.expr`) is deprecated and will raise an error in Python 3.20." msgstr "" +"抽象 AST ノード (:class:`ast.AST` や :class:`!ast.expr` など) のインスタンス" +"を作成することは非推奨となり、Python 3.20 ではエラーになります。" -#: ../../deprecations/pending-removal-in-3.20.rst:59 msgid "" "It is deprecated to call :func:`isinstance` and :func:`issubclass` checks on " "protocol classes that were not explicitly decorated with :func:`!" "runtime_checkable` but that inherit from a runtime-checkable protocol class. " "This will raise a :exc:`TypeError` in Python 3.20." msgstr "" +"実行時チェック可能なプロトコルクラスを継承していても、:func:`!" +"runtime_checkable` で明示的にデコレートされていないプロトコルクラスに対し、:" +"func:`isinstance` や :func:`issubclass` でチェックすることは非推奨です。\n" +"Python 3.20 では :exc:`TypeError` が発生します。" -#: ../../deprecations/pending-removal-in-3.20.rst:64 msgid "(Contributed by Bartosz Sławecki in :gh:`132604`.)" -msgstr "" +msgstr "(Bartosz Sławecki が :gh:`132604` で貢献しました。)" -#: ../../deprecations/c-api-pending-removal-in-future.rst:2 -#: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" -msgstr "" +msgstr "将来のバージョンで削除予定" -#: ../../deprecations/pending-removal-in-future.rst:4 msgid "" "The following APIs will be removed in the future, although there is " "currently no date scheduled for their removal." msgstr "" +"以下の API は将来削除されますが、現時点では削除時期は決まっていません。" -#: ../../deprecations/pending-removal-in-future.rst:7 msgid ":mod:`argparse`:" -msgstr "" +msgstr ":mod:`argparse`:" -#: ../../deprecations/pending-removal-in-future.rst:9 msgid "" "Nesting argument groups and nesting mutually exclusive groups are deprecated." -msgstr "" +msgstr "引数グループの入れ子と、相互排他的なグループの入れ子は非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:11 msgid "" "Passing the undocumented keyword argument *prefix_chars* to :meth:`~argparse." "ArgumentParser.add_argument_group` is now deprecated." msgstr "" +":meth:`~argparse.ArgumentParser.add_argument_group` に、ドキュメント化されて" +"いないキーワード引数 ``prefix_chars`` を渡すことは非推奨になりました。" -#: ../../deprecations/pending-removal-in-future.rst:14 msgid "The :class:`argparse.FileType` type converter is deprecated." -msgstr "" +msgstr ":class:`argparse.FileType` 型コンバーターは非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:18 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " "argument signature." msgstr "" +"ジェネレーター:``throw(type, exc, tb)`` と ``athrow(type, exc, tb)`` という" +"シグネチャは非推奨です。\n" +"代わりに、引数が一つの ``throw(exc)`` と ``athrow(exc)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:21 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -663,6 +692,15 @@ msgid "" "keyword:`is` and :keyword:`or`. In a future release it will be changed to a " "syntax error. (:gh:`87999`)" msgstr "" +"現在の Python は、``0in x``、``1or x``、``0if 1else 2`` のように数値リテラル" +"の直後にキーワードが続く記法を受け付けます。\n" +"そのため、``[0x1for x in y]`` のような紛らわしく曖昧な式も書けます (``[0x1 " +"for x in y]`` とも ``[0x1f or x in y]`` とも解釈できます)。\n" +"数値リテラルの直後に :keyword:`and`、:keyword:`else`、:keyword:`for`、:" +"keyword:`if`、:keyword:`in`、:keyword:`is`、:keyword:`or` のいずれかが続く場" +"合は、構文上の警告が発生します。\n" +"将来のリリースでは構文エラーになります。\n" +"(:gh:`87999`)" #: ../../deprecations/pending-removal-in-future.rst:29 msgid "" @@ -671,103 +709,116 @@ msgid "" "of :class:`int`." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:32 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" "`float`." msgstr "" +"``__float__()`` メソッドが :class:`float` の厳密なサブクラスのインスタンスを" +"返すことへの対応:今後は :class:`float` 自体のインスタンスを返すことが必須に" +"なります。" -#: ../../deprecations/pending-removal-in-future.rst:35 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" "`complex`." msgstr "" +"``__complex__()`` メソッドが :class:`complex` の厳密なサブクラスのインスタン" +"スを返すことへの対応:今後は :class:`complex` 自体のインスタンスを返すことが" +"必須になります。" -#: ../../deprecations/pending-removal-in-future.rst:38 msgid "" "Passing a complex number as the *real* or *imag* argument in the :func:" "`complex` constructor is now deprecated; it should only be passed as a " "single positional argument. (Contributed by Serhiy Storchaka in :gh:" "`109218`.)" msgstr "" +":func:`complex` コンストラクターの ``real`` 引数や ``imag`` 引数に複素数を渡" +"すことは非推奨になりました。\n" +"複素数は単独の位置引数としてのみ渡してください。\n" +"(Serhiy Storchaka が :gh:`109218` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:43 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." "FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.)" msgstr "" +":mod:`calendar`:定数 ``calendar.January`` と ``calendar.February`` は非推奨" +"となり、:data:`calendar.JANUARY` と :data:`calendar.FEBRUARY` に置き換えられ" +"ました。\n" +"(Prince Roshan が :gh:`103636` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:48 msgid "" ":mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:" "`133038`)" msgstr "" +":mod:`codecs`::func:`codecs.open` の代わりに :func:`open` を使ってくださ" +"い。\n" +"(:gh:`133038`)" -#: ../../deprecations/pending-removal-in-future.rst:50 msgid "" ":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" +":attr:`!codeobject.co_lnotab`:代わりに :meth:`codeobject.co_lines` メソッド" +"を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:55 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." msgstr "" +":meth:`~datetime.datetime.utcnow`:``datetime.datetime.now(tz=datetime." +"UTC)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:57 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." msgstr "" +":meth:`~datetime.datetime.utcfromtimestamp`:``datetime.datetime." +"fromtimestamp(timestamp, tz=datetime.UTC)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:60 msgid ":mod:`gettext`: Plural value must be an integer." -msgstr "" +msgstr ":mod:`gettext`:複数形を選択するための値は整数でなければなりません。" -#: ../../deprecations/pending-removal-in-future.rst:62 msgid ":mod:`importlib`:" -msgstr "" +msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-future.rst:64 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." msgstr "" +":func:`~importlib.util.cache_from_source` の ``debug_override`` パラメータは" +"非推奨です。\n" +"代わりに ``optimization`` パラメータを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:67 msgid ":mod:`importlib.metadata`:" -msgstr "" +msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:69 msgid "``EntryPoints`` tuple interface." -msgstr "" +msgstr "``EntryPoints`` のタプルインターフェース。" -#: ../../deprecations/pending-removal-in-future.rst:70 msgid "Implicit ``None`` on return values." -msgstr "" +msgstr "戻り値として暗黙的に ``None`` を返すこと。" -#: ../../deprecations/pending-removal-in-future.rst:72 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." msgstr "" +":mod:`logging`:``warn()`` メソッドは Python 3.3 から非推奨です。\n" +"代わりに :meth:`~logging.warning` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:75 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " "BytesIO and binary mode instead." msgstr "" +":mod:`mailbox`:StringIO による入力とテキストモードの使用は非推奨です。\n" +"代わりに BytesIO とバイナリモードを使ってください。" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" ":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:80 msgid "" ":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." "path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " @@ -776,14 +827,24 @@ msgid "" "module about path manipulation, meaning it is easy to accidentally introduce " "path traversal vulnerabilities into Python programs by using this function." msgstr "" +":mod:`os.path`::func:`os.path.commonprefix` は非推奨です。\n" +"パスの共通の先頭部分を求めるには :func:`os.path.commonpath` を使ってくださ" +"い。\n" +":func:`os.path.commonprefix` は、名前と所属するモジュールが誤解を招くため非推" +"奨になります。\n" +"この関数はパス操作用のモジュールに含まれていますが、パスの先頭部分を扱う用途" +"では安全に使えません。\n" +"そのため、この関数を使うと Python プログラムにパストラバーサルの脆弱性を誤っ" +"て持ち込みやすくなります。" -#: ../../deprecations/pending-removal-in-future.rst:88 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" +":class:`!pydoc.ErrorDuringImport`:``exc_info`` パラメータにタプルを渡すこと" +"は非推奨です。\n" +"例外インスタンスを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -791,198 +852,201 @@ msgid "" "replacement strings can now only contain ASCII letters and digits and " "underscore. (Contributed by Serhiy Storchaka in :gh:`91760`.)" msgstr "" +":mod:`re`:正規表現内の番号によるグループ参照とグループ名に、より厳しい規則が" +"適用されるようになりました。\n" +"番号による参照には ASCII の数字の並びだけを使えます。\n" +"bytes パターンと置換文字列のグループ名には、ASCII の英字、数字、アンダースコ" +"アだけを使えます。\n" +"(Serhiy Storchaka が :gh:`91760` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." msgstr "" +":mod:`shutil`::func:`~shutil.rmtree` の ``onerror`` パラメータは Python " +"3.12 で非推奨になりました。\n" +"代わりに ``onexc`` パラメータを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" -msgstr "" +msgstr ":mod:`ssl` のオプションとプロトコル:" -#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "" +"プロトコル引数を指定せずに :class:`ssl.SSLContext` を作成することは非推奨で" +"す。" -#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." msgstr "" +":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` と :meth:" +"`!selected_npn_protocol` は非推奨です。\n" +"代わりに ALPN を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" -msgstr "" +msgstr "``ssl.OP_NO_SSL*`` オプション" -#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" -msgstr "" +msgstr "``ssl.OP_NO_TLS*`` オプション" -#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" -msgstr "" +msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" -msgstr "" +msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" -msgstr "" +msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" -msgstr "" +msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" -msgstr "" +msgstr ":mod:`threading` のメソッド:" -#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." msgstr "" +":meth:`!threading.Condition.notifyAll`::meth:`~threading.Condition." +"notify_all` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr "" +":meth:`!threading.Event.isSet`::meth:`~threading.Event.is_set` を使ってくだ" +"さい。" -#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." msgstr "" +":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`::" +"attr:`threading.Thread.daemon` 属性を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." msgstr "" +":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`::attr:" +"`threading.Thread.name` 属性を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" +":meth:`!threading.currentThread`::meth:`threading.current_thread` を使ってく" +"ださい。" -#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr "" +":meth:`!threading.activeCount`::meth:`threading.active_count` を使ってくださ" +"い。" -#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." -msgstr "" +msgstr ":class:`typing.Text` (:gh:`92332`)." -#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " "this private class, a compatibility shim will be provided until at least " "Python 3.17. (Contributed by Jelle Zijlstra in :gh:`105499`.)" msgstr "" +"内部クラス ``typing._UnionGenericAlias`` は、:class:`typing.Union` の実装には" +"使われなくなりました。\n" +"この非公開クラスを使っているユーザーとの互換性を保つため、少なくとも Python " +"3.17 までは互換性を維持するための実装が提供されます。\n" +"(Jelle Zijlstra が :gh:`105499` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." msgstr "" +":class:`unittest.IsolatedAsyncioTestCase`:テストケースから ``None`` 以外の値" +"を返すことは非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" +":mod:`urllib.parse` の非推奨の関数:代わりに :func:`~urllib.parse.urlparse` " +"を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" -msgstr "" +msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" -msgstr "" +msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" -msgstr "" +msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" -msgstr "" +msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" -msgstr "" +msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" -msgstr "" +msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" -msgstr "" +msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" -msgstr "" +msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" -msgstr "" +msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" -msgstr "" +msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" -msgstr "" +msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr "" +":mod:`wsgiref`:``SimpleHandler.stdout.write()`` は、渡されたデータの一部だけ" +"を書き込んで終了してはいけません。" -#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " "return ``True``. Prefer explicit ``len(elem)`` or ``elem is not None`` tests " "instead." msgstr "" +":mod:`xml.etree.ElementTree`::class:`~xml.etree.ElementTree.Element` の真偽" +"値を調べることは非推奨です。\n" +"将来のリリースでは、常に ``True`` を返すようになります。\n" +"代わりに ``len(elem)`` や ``elem is not None`` を使って明示的に判定してくださ" +"い。" -#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." msgstr "" +":func:`sys._clear_type_cache` は非推奨です。\n" +"代わりに :func:`sys._clear_internal_caches` を使ってください。" -#: ../../deprecations/soft-deprecations.rst:2 msgid "Soft deprecations" -msgstr "" +msgstr "ソフト非推奨" -#: ../../deprecations/soft-deprecations.rst:4 msgid "There are no plans to remove :term:`soft deprecated` APIs." msgstr "" +":term:`ソフト非推奨 ` の API を削除する予定はありません。" -#: ../../deprecations/soft-deprecations.rst:6 msgid "" ":func:`re.match` and :meth:`re.Pattern.match` are now :term:`soft " "deprecated` in favor of the new :func:`re.prefixmatch` and :meth:`re.Pattern." @@ -992,66 +1056,92 @@ msgid "" "implicit\"* mantra. Most other language regular expression libraries use an " "API named *match* to mean what Python has always called *search*." msgstr "" +":func:`re.match` と :meth:`re.Pattern.match` は :term:`ソフト非推奨 ` となり、代わりに新しい API :func:`re.prefixmatch` と :meth:`re." +"Pattern.prefixmatch` を使うことが推奨されます。\n" +"これらは、より明確な別名として追加されました。\n" +"Zen of Python の *「暗黙的であるより明示的であるほうがよい」* という指針に従" +"い、*match* の意味に関する混乱を減らすことを意図しています。\n" +"他の言語の正規表現ライブラリの多くでは、Python が一貫して *search* と呼んでき" +"た操作を *match* という名前の API で提供しています。" -#: ../../deprecations/soft-deprecations.rst:15 msgid "" "We **do not** plan to remove the older :func:`!match` name, as it has been " "used in code for over 30 years. Code supporting older versions of Python " "should continue to use :func:`!match`, while new code should prefer :func:`!" "prefixmatch`. See :ref:`prefixmatch-vs-match`." msgstr "" +"従来の名前 :func:`!match` は30年以上コードで使われているため、削除する予定は " +"**ありません**。\n" +"古いバージョンの Python に対応するコードでは、引き続き :func:`!match` を使っ" +"てください。\n" +"新しいコードでは :func:`!prefixmatch` を使うことを推奨します。\n" +":ref:`prefixmatch-vs-match` を参照してください。" -#: ../../deprecations/soft-deprecations.rst:20 msgid "" "(Contributed by Gregory P. Smith in :gh:`86519` and Hugo van Kemenade in :gh:" "`148100`.)" msgstr "" +"(Gregory P. Smith が :gh:`86519` で、Hugo van Kemenade が :gh:`148100` で貢献" +"しました。)" -#: ../../deprecations/soft-deprecations.rst:23 msgid "" "Using ``'F'`` and ``'D'`` format type codes of the :mod:`struct` module now " "are :term:`soft deprecated` in favor of two-letter forms ``'Zf'`` and " "``'Zd'``. (Contributed by Sergey B Kirpichev in :gh:`121249`.)" msgstr "" +":mod:`struct` モジュールの書式型コード ``'F'`` と ``'D'`` の使用は :term:`ソ" +"フト非推奨 ` となり、代わりに2文字の形式 ``'Zf'`` と " +"``'Zd'`` を使うことが推奨されます。\n" +"(Sergey B Kirpichev が :gh:`121249` で貢献しました。)" #: ../../deprecations/index.rst:19 msgid "C API deprecations" msgstr "" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:2 msgid "Pending removal in Python 3.15" -msgstr "" +msgstr "Python 3.15 で削除予定" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:4 msgid "" "The :c:func:`!PyImport_ImportModuleNoBlock`: Use :c:func:" "`PyImport_ImportModule` instead." msgstr "" +":c:func:`!PyImport_ImportModuleNoBlock`:代わりに :c:func:" +"`PyImport_ImportModule` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:6 msgid "" ":c:func:`!PyWeakref_GetObject` and :c:func:`!PyWeakref_GET_OBJECT`: Use :c:" "func:`PyWeakref_GetRef` instead. The `pythoncapi-compat project `__ can be used to get :c:func:" "`PyWeakref_GetRef` on Python 3.12 and older." msgstr "" +":c:func:`!PyWeakref_GetObject` と :c:func:`!PyWeakref_GET_OBJECT`:代わりに :" +"c:func:`PyWeakref_GetRef` を使ってください。\n" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.12 以前でも :c:func:`PyWeakref_GetRef` を利用できま" +"す。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:10 msgid "" ":c:func:`!PyUnicode_AsDecodedObject`: Use :c:func:`PyCodec_Decode` instead." msgstr "" +":c:func:`!PyUnicode_AsDecodedObject`:代わりに :c:func:`PyCodec_Decode` を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:12 msgid "" ":c:func:`!PyUnicode_AsDecodedUnicode`: Use :c:func:`PyCodec_Decode` instead; " "Note that some codecs (for example, \"base64\") may return a type other " "than :class:`str`, such as :class:`bytes`." msgstr "" +":c:func:`!PyUnicode_AsDecodedUnicode`:代わりに :c:func:`PyCodec_Decode` を" +"使ってください。\n" +"一部のコーデック (例えば \"base64\") は、:class:`bytes` など :class:`str` 以" +"外の型を返す場合があることに注意してください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:15 msgid "" ":c:func:`!PyUnicode_AsEncodedObject`: Use :c:func:`PyCodec_Encode` instead." msgstr "" +":c:func:`!PyUnicode_AsEncodedObject`:代わりに :c:func:`PyCodec_Encode` を" +"使ってください。" #: ../../deprecations/c-api-pending-removal-in-3.15.rst:17 msgid "" @@ -1060,315 +1150,382 @@ msgid "" "than :class:`bytes`, such as :class:`str`." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:20 msgid "Python initialization functions, deprecated in Python 3.13:" -msgstr "" +msgstr "Python 3.13 で非推奨となった Python 初期化関数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:22 msgid "" ":c:func:`!Py_GetPath`: Use :c:func:`PyConfig_Get(\"module_search_paths\") " "` (:data:`sys.path`) instead." msgstr "" +":c:func:`!Py_GetPath`:代わりに :c:func:" +"`PyConfig_Get(\"module_search_paths\") ` (:data:`sys.path`) を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:25 msgid "" ":c:func:`!Py_GetPrefix`: Use :c:func:`PyConfig_Get(\"base_prefix\") " "` (:data:`sys.base_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) if :ref:" "`virtual environments ` need to be handled." msgstr "" +":c:func:`!Py_GetPrefix`:代わりに :c:func:`PyConfig_Get(\"base_prefix\") " +"` (:data:`sys.base_prefix`) を使ってください。\n" +":ref:`仮想環境 ` に対応する必要がある場合は、:c:func:" +"`PyConfig_Get(\"prefix\") ` (:data:`sys.prefix`) を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:30 msgid "" ":c:func:`!Py_GetExecPrefix`: Use :c:func:`PyConfig_Get(\"base_exec_prefix\") " "` (:data:`sys.base_exec_prefix`) instead. Use :c:func:" "`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) if :" "ref:`virtual environments ` need to be handled." msgstr "" +":c:func:`!Py_GetExecPrefix`:代わりに :c:func:" +"`PyConfig_Get(\"base_exec_prefix\") ` (:data:`sys." +"base_exec_prefix`) を使ってください。\n" +":ref:`仮想環境 ` に対応する必要がある場合は、:c:func:" +"`PyConfig_Get(\"exec_prefix\") ` (:data:`sys.exec_prefix`) を" +"使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:36 msgid "" ":c:func:`!Py_GetProgramFullPath`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" +":c:func:`!Py_GetProgramFullPath`:代わりに :c:func:" +"`PyConfig_Get(\"executable\") ` (:data:`sys.executable`) を使っ" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:39 msgid "" ":c:func:`!Py_GetProgramName`: Use :c:func:`PyConfig_Get(\"executable\") " "` (:data:`sys.executable`) instead." msgstr "" +":c:func:`!Py_GetProgramName`:代わりに :c:func:`PyConfig_Get(\"executable\") " +"` (:data:`sys.executable`) を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:42 msgid "" ":c:func:`!Py_GetPythonHome`: Use :c:func:`PyConfig_Get(\"home\") " "` or the :envvar:`PYTHONHOME` environment variable instead." msgstr "" +":c:func:`!Py_GetPythonHome`:代わりに :c:func:`PyConfig_Get(\"home\") " +"` または環境変数 :envvar:`PYTHONHOME` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:46 msgid "" "The `pythoncapi-compat project `__ can be used to get :c:func:`PyConfig_Get` on Python 3.13 and older." msgstr "" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.13 以前でも :c:func:`PyConfig_Get` を利用できます。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:50 msgid "" "Functions to configure Python's initialization, deprecated in Python 3.11:" -msgstr "" +msgstr "Python 3.11 で非推奨となった、Python の初期化を設定する関数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:52 msgid ":c:func:`!PySys_SetArgvEx()`: Set :c:member:`PyConfig.argv` instead." msgstr "" +":c:func:`!PySys_SetArgvEx()`:代わりに :c:member:`PyConfig.argv` を設定してく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:54 msgid ":c:func:`!PySys_SetArgv()`: Set :c:member:`PyConfig.argv` instead." msgstr "" +":c:func:`!PySys_SetArgv()`:代わりに :c:member:`PyConfig.argv` を設定してくだ" +"さい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:56 msgid "" ":c:func:`!Py_SetProgramName()`: Set :c:member:`PyConfig.program_name` " "instead." msgstr "" +":c:func:`!Py_SetProgramName()`:代わりに :c:member:`PyConfig.program_name` を" +"設定してください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:58 msgid ":c:func:`!Py_SetPythonHome()`: Set :c:member:`PyConfig.home` instead." msgstr "" +":c:func:`!Py_SetPythonHome()`:代わりに :c:member:`PyConfig.home` を設定して" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:60 msgid "" ":c:func:`!PySys_ResetWarnOptions`: Clear :data:`sys.warnoptions` and :data:`!" "warnings.filters` instead." msgstr "" +":c:func:`!PySys_ResetWarnOptions`:代わりに :data:`sys.warnoptions` と :data:" +"`!warnings.filters` をクリアしてください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:63 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` instead." msgstr "" +"代わりに :c:type:`PyConfig` と :c:func:`Py_InitializeFromConfig` API を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:66 msgid "Global configuration variables:" -msgstr "" +msgstr "グローバルな設定変数:" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:68 msgid "" ":c:var:`Py_DebugFlag`: Use :c:member:`PyConfig.parser_debug` or :c:func:" "`PyConfig_Get(\"parser_debug\") ` instead." msgstr "" +":c:var:`Py_DebugFlag`:代わりに :c:member:`PyConfig.parser_debug` または :c:" +"func:`PyConfig_Get(\"parser_debug\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:71 msgid "" ":c:var:`Py_VerboseFlag`: Use :c:member:`PyConfig.verbose` or :c:func:" "`PyConfig_Get(\"verbose\") ` instead." msgstr "" +":c:var:`Py_VerboseFlag`:代わりに :c:member:`PyConfig.verbose` または :c:" +"func:`PyConfig_Get(\"verbose\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:74 msgid "" ":c:var:`Py_QuietFlag`: Use :c:member:`PyConfig.quiet` or :c:func:" "`PyConfig_Get(\"quiet\") ` instead." msgstr "" +":c:var:`Py_QuietFlag`:代わりに :c:member:`PyConfig.quiet` または :c:func:" +"`PyConfig_Get(\"quiet\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:77 msgid "" ":c:var:`Py_InteractiveFlag`: Use :c:member:`PyConfig.interactive` or :c:func:" "`PyConfig_Get(\"interactive\") ` instead." msgstr "" +":c:var:`Py_InteractiveFlag`:代わりに :c:member:`PyConfig.interactive` また" +"は :c:func:`PyConfig_Get(\"interactive\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:80 msgid "" ":c:var:`Py_InspectFlag`: Use :c:member:`PyConfig.inspect` or :c:func:" "`PyConfig_Get(\"inspect\") ` instead." msgstr "" +":c:var:`Py_InspectFlag`:代わりに :c:member:`PyConfig.inspect` または :c:" +"func:`PyConfig_Get(\"inspect\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:83 msgid "" ":c:var:`Py_OptimizeFlag`: Use :c:member:`PyConfig.optimization_level` or :c:" "func:`PyConfig_Get(\"optimization_level\") ` instead." msgstr "" +":c:var:`Py_OptimizeFlag`:代わりに :c:member:`PyConfig.optimization_level` ま" +"たは :c:func:`PyConfig_Get(\"optimization_level\") ` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:86 msgid "" ":c:var:`Py_NoSiteFlag`: Use :c:member:`PyConfig.site_import` or :c:func:" "`PyConfig_Get(\"site_import\") ` instead." msgstr "" +":c:var:`Py_NoSiteFlag`:代わりに :c:member:`PyConfig.site_import` または :c:" +"func:`PyConfig_Get(\"site_import\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:89 msgid "" ":c:var:`Py_BytesWarningFlag`: Use :c:member:`PyConfig.bytes_warning` or :c:" "func:`PyConfig_Get(\"bytes_warning\") ` instead." msgstr "" +":c:var:`Py_BytesWarningFlag`:代わりに :c:member:`PyConfig.bytes_warning` ま" +"たは :c:func:`PyConfig_Get(\"bytes_warning\") ` を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:92 msgid "" ":c:var:`Py_FrozenFlag`: Use :c:member:`PyConfig.pathconfig_warnings` or :c:" "func:`PyConfig_Get(\"pathconfig_warnings\") ` instead." msgstr "" +":c:var:`Py_FrozenFlag`:代わりに :c:member:`PyConfig.pathconfig_warnings` ま" +"たは :c:func:`PyConfig_Get(\"pathconfig_warnings\") ` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:95 msgid "" ":c:var:`Py_IgnoreEnvironmentFlag`: Use :c:member:`PyConfig.use_environment` " "or :c:func:`PyConfig_Get(\"use_environment\") ` instead." msgstr "" +":c:var:`Py_IgnoreEnvironmentFlag`:代わりに :c:member:`PyConfig." +"use_environment` または :c:func:`PyConfig_Get(\"use_environment\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:98 msgid "" ":c:var:`Py_DontWriteBytecodeFlag`: Use :c:member:`PyConfig.write_bytecode` " "or :c:func:`PyConfig_Get(\"write_bytecode\") ` instead." msgstr "" +":c:var:`Py_DontWriteBytecodeFlag`:代わりに :c:member:`PyConfig." +"write_bytecode` または :c:func:`PyConfig_Get(\"write_bytecode\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:101 msgid "" ":c:var:`Py_NoUserSiteDirectory`: Use :c:member:`PyConfig." "user_site_directory` or :c:func:`PyConfig_Get(\"user_site_directory\") " "` instead." msgstr "" +":c:var:`Py_NoUserSiteDirectory`:代わりに :c:member:`PyConfig." +"user_site_directory` または :c:func:`PyConfig_Get(\"user_site_directory\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:104 msgid "" ":c:var:`Py_UnbufferedStdioFlag`: Use :c:member:`PyConfig.buffered_stdio` or :" "c:func:`PyConfig_Get(\"buffered_stdio\") ` instead." msgstr "" +":c:var:`Py_UnbufferedStdioFlag`:代わりに :c:member:`PyConfig." +"buffered_stdio` または :c:func:`PyConfig_Get(\"buffered_stdio\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:107 msgid "" ":c:var:`Py_HashRandomizationFlag`: Use :c:member:`PyConfig.use_hash_seed` " "and :c:member:`PyConfig.hash_seed` or :c:func:`PyConfig_Get(\"hash_seed\") " "` instead." msgstr "" +":c:var:`Py_HashRandomizationFlag`:代わりに :c:member:`PyConfig." +"use_hash_seed` と :c:member:`PyConfig.hash_seed` または :c:func:" +"`PyConfig_Get(\"hash_seed\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:111 msgid "" ":c:var:`Py_IsolatedFlag`: Use :c:member:`PyConfig.isolated` or :c:func:" "`PyConfig_Get(\"isolated\") ` instead." msgstr "" +":c:var:`Py_IsolatedFlag`:代わりに :c:member:`PyConfig.isolated` または :c:" +"func:`PyConfig_Get(\"isolated\") ` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:114 msgid "" ":c:var:`Py_LegacyWindowsFSEncodingFlag`: Use :c:member:`PyPreConfig." "legacy_windows_fs_encoding` or :c:func:" "`PyConfig_Get(\"legacy_windows_fs_encoding\") ` instead." msgstr "" +":c:var:`Py_LegacyWindowsFSEncodingFlag`:代わりに :c:member:`PyPreConfig." +"legacy_windows_fs_encoding` または :c:func:" +"`PyConfig_Get(\"legacy_windows_fs_encoding\") ` を使ってくださ" +"い。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:117 msgid "" ":c:var:`Py_LegacyWindowsStdioFlag`: Use :c:member:`PyConfig." "legacy_windows_stdio` or :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " "` instead." msgstr "" +":c:var:`Py_LegacyWindowsStdioFlag`:代わりに :c:member:`PyConfig." +"legacy_windows_stdio` または :c:func:`PyConfig_Get(\"legacy_windows_stdio\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:120 msgid "" ":c:var:`!Py_FileSystemDefaultEncoding`, :c:var:`!" "Py_HasFileSystemDefaultEncoding`: Use :c:member:`PyConfig." "filesystem_encoding` or :c:func:`PyConfig_Get(\"filesystem_encoding\") " "` instead." msgstr "" +":c:var:`!Py_FileSystemDefaultEncoding`、:c:var:`!" +"Py_HasFileSystemDefaultEncoding`:代わりに :c:member:`PyConfig." +"filesystem_encoding` または :c:func:`PyConfig_Get(\"filesystem_encoding\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:123 msgid "" ":c:var:`!Py_FileSystemDefaultEncodeErrors`: Use :c:member:`PyConfig." "filesystem_errors` or :c:func:`PyConfig_Get(\"filesystem_errors\") " "` instead." msgstr "" +":c:var:`!Py_FileSystemDefaultEncodeErrors`:代わりに :c:member:`PyConfig." +"filesystem_errors` または :c:func:`PyConfig_Get(\"filesystem_errors\") " +"` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:126 msgid "" ":c:var:`!Py_UTF8Mode`: Use :c:member:`PyPreConfig.utf8_mode` or :c:func:" "`PyConfig_Get(\"utf8_mode\") ` instead. (see :c:func:" "`Py_PreInitialize`)" msgstr "" +":c:var:`!Py_UTF8Mode`:代わりに :c:member:`PyPreConfig.utf8_mode` または :c:" +"func:`PyConfig_Get(\"utf8_mode\") ` を使ってください。\n" +"(:c:func:`Py_PreInitialize` を参照)" -#: ../../deprecations/c-api-pending-removal-in-3.15.rst:131 msgid "" "The :c:func:`Py_InitializeFromConfig` API should be used with :c:type:" "`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be used to " "get these options at runtime." msgstr "" +"これらのオプションを設定するには、:c:type:`PyConfig` と :c:func:" +"`Py_InitializeFromConfig` API を使ってください。\n" +"実行時に値を取得するには :c:func:`PyConfig_Get` を使えます。" -#: ../../deprecations/c-api-pending-removal-in-3.16.rst:4 msgid "The bundled copy of ``libmpdec``." -msgstr "" +msgstr "同梱されている ``libmpdec``。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:4 msgid "" "The following private functions are deprecated and planned for removal in " "Python 3.18:" -msgstr "" +msgstr "以下の非公開関数は非推奨となり、Python 3.18 で削除予定です:" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:7 msgid ":c:func:`!_PyBytes_Join`: use :c:func:`PyBytes_Join`." -msgstr "" +msgstr ":c:func:`!_PyBytes_Join`::c:func:`PyBytes_Join` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:8 msgid "" ":c:func:`!_PyDict_GetItemStringWithError`: use :c:func:" "`PyDict_GetItemStringRef`." msgstr "" +":c:func:`!_PyDict_GetItemStringWithError`::c:func:`PyDict_GetItemStringRef` " +"を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:9 msgid ":c:func:`!_PyDict_Pop()`: use :c:func:`PyDict_Pop`." -msgstr "" +msgstr ":c:func:`!_PyDict_Pop()`::c:func:`PyDict_Pop` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:10 msgid ":c:func:`!_PyLong_Sign()`: use :c:func:`PyLong_GetSign`." -msgstr "" +msgstr ":c:func:`!_PyLong_Sign()`::c:func:`PyLong_GetSign` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:11 msgid "" ":c:func:`!_PyLong_FromDigits` and :c:func:`!_PyLong_New`: use :c:func:" "`PyLongWriter_Create`." msgstr "" +":c:func:`!_PyLong_FromDigits` と :c:func:`!_PyLong_New`::c:func:" +"`PyLongWriter_Create` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:13 msgid "" ":c:func:`!_PyThreadState_UncheckedGet`: use :c:func:" "`PyThreadState_GetUnchecked`." msgstr "" +":c:func:`!_PyThreadState_UncheckedGet`::c:func:`PyThreadState_GetUnchecked` " +"を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:14 msgid ":c:func:`!_PyUnicode_AsString`: use :c:func:`PyUnicode_AsUTF8`." msgstr "" +":c:func:`!_PyUnicode_AsString`::c:func:`PyUnicode_AsUTF8` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:15 msgid "" ":c:func:`!_PyUnicodeWriter_Init`: replace ``_PyUnicodeWriter_Init(&writer)`` " "with :c:func:`writer = PyUnicodeWriter_Create(0) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Init`:``_PyUnicodeWriter_Init(&writer)`` を :c:" +"func:`writer = PyUnicodeWriter_Create(0) ` に置き換え" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:18 msgid "" ":c:func:`!_PyUnicodeWriter_Finish`: replace " "``_PyUnicodeWriter_Finish(&writer)`` with :c:func:" "`PyUnicodeWriter_Finish(writer) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Finish`:``_PyUnicodeWriter_Finish(&writer)`` を :" +"c:func:`PyUnicodeWriter_Finish(writer) ` に置き換えて" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:21 msgid "" ":c:func:`!_PyUnicodeWriter_Dealloc`: replace " "``_PyUnicodeWriter_Dealloc(&writer)`` with :c:func:" "`PyUnicodeWriter_Discard(writer) `." msgstr "" +":c:func:`!_PyUnicodeWriter_Dealloc`:``_PyUnicodeWriter_Dealloc(&writer)`` " +"を :c:func:`PyUnicodeWriter_Discard(writer) ` に置き" +"換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:24 msgid "" ":c:func:`!_PyUnicodeWriter_WriteChar`: replace " "``_PyUnicodeWriter_WriteChar(&writer, ch)`` with :c:func:" "`PyUnicodeWriter_WriteChar(writer, ch) `." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteChar`:``_PyUnicodeWriter_WriteChar(&writer, " +"ch)`` を :c:func:`PyUnicodeWriter_WriteChar(writer, ch) " +"` に置き換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:27 msgid "" ":c:func:`!_PyUnicodeWriter_WriteStr`: replace " "``_PyUnicodeWriter_WriteStr(&writer, str)`` with :c:func:" "`PyUnicodeWriter_WriteStr(writer, str) `." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteStr`:``_PyUnicodeWriter_WriteStr(&writer, " +"str)`` を :c:func:`PyUnicodeWriter_WriteStr(writer, str) " +"` に置き換えてください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:30 msgid "" ":c:func:`!_PyUnicodeWriter_WriteSubstring`: replace " "``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` with :c:func:" "`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " "`." msgstr "" +":c:func:`!_PyUnicodeWriter_WriteSubstring`:" +"``_PyUnicodeWriter_WriteSubstring(&writer, str, start, end)`` を :c:func:" +"`PyUnicodeWriter_WriteSubstring(writer, str, start, end) " +"` に置き換えてください。" #: ../../deprecations/c-api-pending-removal-in-3.18.rst:33 msgid "" @@ -1384,34 +1541,33 @@ msgid "" "`PyUnicodeWriter_WriteUTF8(writer, str) `." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:39 msgid ":c:func:`!_PyUnicodeWriter_Prepare`: (no replacement)." -msgstr "" +msgstr ":c:func:`!_PyUnicodeWriter_Prepare`:(代替なし)。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:40 msgid ":c:func:`!_PyUnicodeWriter_PrepareKind`: (no replacement)." -msgstr "" +msgstr ":c:func:`!_PyUnicodeWriter_PrepareKind`:(代替なし)。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:41 msgid ":c:func:`!_Py_HashPointer`: use :c:func:`Py_HashPointer`." msgstr "" +":c:func:`!_Py_HashPointer`::c:func:`Py_HashPointer` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:42 msgid ":c:func:`!_Py_fopen_obj`: use :c:func:`Py_fopen`." -msgstr "" +msgstr ":c:func:`!_Py_fopen_obj`::c:func:`Py_fopen` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.18.rst:44 msgid "" "The `pythoncapi-compat project `__ can be used to get these new public functions on Python 3.13 and older. " "(Contributed by Victor Stinner in :gh:`128863`.)" msgstr "" +"`pythoncapi-compat プロジェクト `__ を使うと、Python 3.13 以前でもこれらの新しい公開関数を利用できます。\n" +"(Victor Stinner が :gh:`128863` で貢献しました。)" -#: ../../deprecations/c-api-pending-removal-in-3.19.rst:4 msgid ":pep:`456` embedders support for the string hashing scheme definition." msgstr "" +":pep:`456` の、Python を組み込む側で文字列のハッシュ方式を定義するためのサ" +"ポート。" -#: ../../deprecations/c-api-pending-removal-in-3.20.rst:4 msgid "" ":c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and :c:" "func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in " @@ -1419,101 +1575,118 @@ msgid "" "result in the module state, then call :c:func:`PyObject_CallMethod` or :c:" "func:`PyObject_GetAttr`. (Contributed by Victor Stinner in :gh:`141049`.)" msgstr "" +":c:func:`!_PyObject_CallMethodId`、:c:func:`!_PyObject_GetAttrId`、:c:func:`!" +"_PyUnicode_FromId` は 3.15 から非推奨となり、3.20 で削除されます。\n" +"代わりに :c:func:`PyUnicode_InternFromString()` の結果をモジュール状態に" +"キャッシュしてから、:c:func:`PyObject_CallMethod` または :c:func:" +"`PyObject_GetAttr` を呼び出してください。\n" +"(Victor Stinner が :gh:`141049` で貢献しました。)" -#: ../../deprecations/c-api-pending-removal-in-3.20.rst:11 msgid "" "The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`). Use :c:func:" "`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to convert a " "Python complex number to/from the C :c:type:`Py_complex` representation." msgstr "" +":c:type:`PyComplexObject` の ``cval`` フィールド (:gh:`128813`)。\n" +"Python の複素数と C の :c:type:`Py_complex` 表現の相互変換には、:c:func:" +"`PyComplex_AsCComplex` と :c:func:`PyComplex_FromCComplex` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-3.20.rst:16 msgid "Macros :c:macro:`!Py_MATH_PIl` and :c:macro:`!Py_MATH_El`." -msgstr "" +msgstr "マクロ :c:macro:`!Py_MATH_PIl` と :c:macro:`!Py_MATH_El`。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:4 msgid "" "The following APIs are deprecated and will be removed, although there is " "currently no date scheduled for their removal." msgstr "" +"以下の API は非推奨となり、削除される予定ですが、現時点では削除時期は決まって" +"いません。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:7 msgid ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: Unneeded since Python 3.8." -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_HAVE_FINALIZE`:Python 3.8 以降では不要です。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:9 msgid ":c:func:`PyErr_Fetch`: Use :c:func:`PyErr_GetRaisedException` instead." msgstr "" +":c:func:`PyErr_Fetch`:代わりに :c:func:`PyErr_GetRaisedException` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:11 msgid "" ":c:func:`PyErr_NormalizeException`: Use :c:func:`PyErr_GetRaisedException` " "instead." msgstr "" +":c:func:`PyErr_NormalizeException`:代わりに :c:func:" +"`PyErr_GetRaisedException` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:13 msgid "" ":c:func:`PyErr_Restore`: Use :c:func:`PyErr_SetRaisedException` instead." msgstr "" +":c:func:`PyErr_Restore`:代わりに :c:func:`PyErr_SetRaisedException` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:15 msgid "" ":c:func:`PyModule_GetFilename`: Use :c:func:`PyModule_GetFilenameObject` " "instead." msgstr "" +":c:func:`PyModule_GetFilename`:代わりに :c:func:" +"`PyModule_GetFilenameObject` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:17 msgid ":c:func:`PyOS_AfterFork`: Use :c:func:`PyOS_AfterFork_Child` instead." msgstr "" +":c:func:`PyOS_AfterFork`:代わりに :c:func:`PyOS_AfterFork_Child` を使ってく" +"ださい。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:19 msgid "" ":c:func:`PySlice_GetIndicesEx`: Use :c:func:`PySlice_Unpack` and :c:func:" "`PySlice_AdjustIndices` instead." msgstr "" +":c:func:`PySlice_GetIndicesEx`:代わりに :c:func:`PySlice_Unpack` と :c:func:" +"`PySlice_AdjustIndices` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:21 msgid ":c:func:`PyUnicode_READY`: Unneeded since Python 3.12" -msgstr "" +msgstr ":c:func:`PyUnicode_READY`:Python 3.12 以降では不要です。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:23 msgid ":c:func:`!PyErr_Display`: Use :c:func:`PyErr_DisplayException` instead." msgstr "" +":c:func:`!PyErr_Display`:代わりに :c:func:`PyErr_DisplayException` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:25 msgid "" ":c:func:`!_PyErr_ChainExceptions`: Use :c:func:`!_PyErr_ChainExceptions1` " "instead." msgstr "" +":c:func:`!_PyErr_ChainExceptions`:代わりに :c:func:`!" +"_PyErr_ChainExceptions1` を使ってください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:27 msgid "" ":c:member:`!PyBytesObject.ob_shash` member: call :c:func:`PyObject_Hash` " "instead." msgstr "" +":c:member:`!PyBytesObject.ob_shash` メンバー:代わりに :c:func:" +"`PyObject_Hash` を呼び出してください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:29 msgid "Thread Local Storage (TLS) API:" -msgstr "" +msgstr "スレッドローカルストレージ (TLS) API:" #: ../../deprecations/c-api-pending-removal-in-future.rst:31 msgid "" ":c:func:`PyThread_create_key`: Use :c:func:`PyThread_tss_alloc` instead." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-future.rst:33 msgid ":c:func:`PyThread_delete_key`: Use :c:func:`PyThread_tss_free` instead." msgstr "" +":c:func:`PyThread_delete_key`:代わりに :c:func:`PyThread_tss_free` を使って" +"ください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:35 msgid "" ":c:func:`PyThread_set_key_value`: Use :c:func:`PyThread_tss_set` instead." msgstr "" +":c:func:`PyThread_set_key_value`:代わりに :c:func:`PyThread_tss_set` を使っ" +"てください。" -#: ../../deprecations/c-api-pending-removal-in-future.rst:37 msgid "" ":c:func:`PyThread_get_key_value`: Use :c:func:`PyThread_tss_get` instead." msgstr "" +":c:func:`PyThread_get_key_value`:代わりに :c:func:`PyThread_tss_get` を使っ" +"てください。" #: ../../deprecations/c-api-pending-removal-in-future.rst:39 msgid "" @@ -1521,6 +1694,5 @@ msgid "" "instead." msgstr "" -#: ../../deprecations/c-api-pending-removal-in-future.rst:41 msgid ":c:func:`PyThread_ReInitTLS`: Unneeded since Python 3.7." -msgstr "" +msgstr ":c:func:`PyThread_ReInitTLS`:Python 3.7 以降では不要です。" diff --git a/deprecations/pending-removal-in-3.13.po b/deprecations/pending-removal-in-3.13.po index be7d7baed..7c53aed10 100644 --- a/deprecations/pending-removal-in-3.13.po +++ b/deprecations/pending-removal-in-3.13.po @@ -16,103 +16,82 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.13.rst:2 msgid "Pending removal in Python 3.13" -msgstr "" +msgstr "Python 3.13 で削除予定" #: ../../deprecations/pending-removal-in-3.13.rst:4 msgid "Modules (see :pep:`594`):" msgstr "モジュール(:pep:`594` を参照):" -#: ../../deprecations/pending-removal-in-3.13.rst:6 msgid ":mod:`!aifc`" -msgstr "" +msgstr ":mod:`!aifc`" -#: ../../deprecations/pending-removal-in-3.13.rst:7 msgid ":mod:`!audioop`" -msgstr "" +msgstr ":mod:`!audioop`" -#: ../../deprecations/pending-removal-in-3.13.rst:8 msgid ":mod:`!cgi`" -msgstr "" +msgstr ":mod:`!cgi`" -#: ../../deprecations/pending-removal-in-3.13.rst:9 msgid ":mod:`!cgitb`" -msgstr "" +msgstr ":mod:`!cgitb`" -#: ../../deprecations/pending-removal-in-3.13.rst:10 msgid ":mod:`!chunk`" -msgstr "" +msgstr ":mod:`!chunk`" -#: ../../deprecations/pending-removal-in-3.13.rst:11 msgid ":mod:`!crypt`" -msgstr "" +msgstr ":mod:`!crypt`" -#: ../../deprecations/pending-removal-in-3.13.rst:12 msgid ":mod:`!imghdr`" -msgstr "" +msgstr ":mod:`!imghdr`" -#: ../../deprecations/pending-removal-in-3.13.rst:13 msgid ":mod:`!mailcap`" -msgstr "" +msgstr ":mod:`!mailcap`" -#: ../../deprecations/pending-removal-in-3.13.rst:14 msgid ":mod:`!msilib`" -msgstr "" +msgstr ":mod:`!msilib`" -#: ../../deprecations/pending-removal-in-3.13.rst:15 msgid ":mod:`!nis`" -msgstr "" +msgstr ":mod:`!nis`" -#: ../../deprecations/pending-removal-in-3.13.rst:16 msgid ":mod:`!nntplib`" -msgstr "" +msgstr ":mod:`!nntplib`" -#: ../../deprecations/pending-removal-in-3.13.rst:17 msgid ":mod:`!ossaudiodev`" -msgstr "" +msgstr ":mod:`!ossaudiodev`" -#: ../../deprecations/pending-removal-in-3.13.rst:18 msgid ":mod:`!pipes`" -msgstr "" +msgstr ":mod:`!pipes`" -#: ../../deprecations/pending-removal-in-3.13.rst:19 msgid ":mod:`!sndhdr`" -msgstr "" +msgstr ":mod:`!sndhdr`" -#: ../../deprecations/pending-removal-in-3.13.rst:20 msgid ":mod:`!spwd`" -msgstr "" +msgstr ":mod:`!spwd`" -#: ../../deprecations/pending-removal-in-3.13.rst:21 msgid ":mod:`!sunau`" -msgstr "" +msgstr ":mod:`!sunau`" -#: ../../deprecations/pending-removal-in-3.13.rst:22 msgid ":mod:`!telnetlib`" -msgstr "" +msgstr ":mod:`!telnetlib`" -#: ../../deprecations/pending-removal-in-3.13.rst:23 msgid ":mod:`!uu`" -msgstr "" +msgstr ":mod:`!uu`" -#: ../../deprecations/pending-removal-in-3.13.rst:24 msgid ":mod:`!xdrlib`" -msgstr "" +msgstr ":mod:`!xdrlib`" #: ../../deprecations/pending-removal-in-3.13.rst:26 msgid "Other modules:" msgstr "その他のモジュール:" -#: ../../deprecations/pending-removal-in-3.13.rst:28 msgid ":mod:`!lib2to3`, and the :program:`2to3` program (:gh:`84540`)" -msgstr "" +msgstr ":mod:`!lib2to3` と :program:`2to3` プログラム (:gh:`84540`)" #: ../../deprecations/pending-removal-in-3.13.rst:30 msgid "APIs:" @@ -122,9 +101,8 @@ msgstr "API" msgid ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" msgstr ":class:`!configparser.LegacyInterpolation` (:gh:`90765`)" -#: ../../deprecations/pending-removal-in-3.13.rst:33 msgid "``locale.resetlocale()`` (:gh:`90817`)" -msgstr "" +msgstr "``locale.resetlocale()`` (:gh:`90817`)" #: ../../deprecations/pending-removal-in-3.13.rst:34 msgid ":meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)" @@ -142,14 +120,12 @@ msgstr ":func:`!unittest.getTestCaseNames` (:gh:`50096`)" msgid ":func:`!unittest.makeSuite` (:gh:`50096`)" msgstr ":func:`!unittest.makeSuite` (:gh:`50096`)" -#: ../../deprecations/pending-removal-in-3.13.rst:38 msgid ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" -msgstr "" +msgstr ":meth:`!unittest.TestProgram.usageExit` (:gh:`67048`)" #: ../../deprecations/pending-removal-in-3.13.rst:39 msgid ":class:`!webbrowser.MacOSX` (:gh:`86421`)" msgstr ":class:`!webbrowser.MacOSX` (:gh:`86421`)" -#: ../../deprecations/pending-removal-in-3.13.rst:40 msgid ":class:`classmethod` descriptor chaining (:gh:`89519`)" -msgstr "" +msgstr ":class:`classmethod` のデスクリプタの連鎖 (:gh:`89519`)" diff --git a/deprecations/pending-removal-in-3.14.po b/deprecations/pending-removal-in-3.14.po index efcf11284..9c7639b2e 100644 --- a/deprecations/pending-removal-in-3.14.po +++ b/deprecations/pending-removal-in-3.14.po @@ -16,93 +16,103 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.14.rst:2 msgid "Pending removal in Python 3.14" -msgstr "" +msgstr "Python 3.14 で削除予定" -#: ../../deprecations/pending-removal-in-3.14.rst:4 msgid "" ":mod:`argparse`: The *type*, *choices*, and *metavar* parameters of :class:`!" "argparse.BooleanOptionalAction` are deprecated and will be removed in 3.14. " "(Contributed by Nikita Sobolev in :gh:`92248`.)" msgstr "" +":mod:`argparse`::class:`!argparse.BooleanOptionalAction` の ``type``、" +"``choices``、``metavar`` パラメータは非推奨となり、3.14 で削除されます。\n" +"(Nikita Sobolev が :gh:`92248` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:9 msgid "" ":mod:`ast`: The following features have been deprecated in documentation " "since Python 3.8, now cause a :exc:`DeprecationWarning` to be emitted at " "runtime when they are accessed or used, and will be removed in Python 3.14:" msgstr "" +":mod:`ast`:以下の機能は Python 3.8 からドキュメントで非推奨とされていました" +"が、アクセスや使用をすると実行時に :exc:`DeprecationWarning` が出るようになり" +"ました。\n" +"Python 3.14 で削除されます:" -#: ../../deprecations/pending-removal-in-3.14.rst:13 msgid ":class:`!ast.Num`" -msgstr "" +msgstr ":class:`!ast.Num`" -#: ../../deprecations/pending-removal-in-3.14.rst:14 msgid ":class:`!ast.Str`" -msgstr "" +msgstr ":class:`!ast.Str`" -#: ../../deprecations/pending-removal-in-3.14.rst:15 msgid ":class:`!ast.Bytes`" -msgstr "" +msgstr ":class:`!ast.Bytes`" -#: ../../deprecations/pending-removal-in-3.14.rst:16 msgid ":class:`!ast.NameConstant`" -msgstr "" +msgstr ":class:`!ast.NameConstant`" -#: ../../deprecations/pending-removal-in-3.14.rst:17 msgid ":class:`!ast.Ellipsis`" -msgstr "" +msgstr ":class:`!ast.Ellipsis`" -#: ../../deprecations/pending-removal-in-3.14.rst:19 msgid "" "Use :class:`ast.Constant` instead. (Contributed by Serhiy Storchaka in :gh:" "`90953`.)" msgstr "" +"代わりに :class:`ast.Constant` を使ってください。\n" +"(Serhiy Storchaka が :gh:`90953` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:22 msgid ":mod:`asyncio`:" -msgstr "" +msgstr ":mod:`asyncio`:" -#: ../../deprecations/pending-removal-in-3.14.rst:24 msgid "" "The child watcher classes :class:`!asyncio.MultiLoopChildWatcher`, :class:`!" "asyncio.FastChildWatcher`, :class:`!asyncio.AbstractChildWatcher` and :class:" "`!asyncio.SafeChildWatcher` are deprecated and will be removed in Python " "3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" +"子プロセスを監視するクラス :class:`!asyncio.MultiLoopChildWatcher`、:class:`!" +"asyncio.FastChildWatcher`、:class:`!asyncio.AbstractChildWatcher`、:class:`!" +"asyncio.SafeChildWatcher` は非推奨となり、Python 3.14 で削除されます。\n" +"(Kumar Aditya が :gh:`94597` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:30 msgid "" ":func:`!asyncio.set_child_watcher`, :func:`!asyncio.get_child_watcher`, :" "meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher` and :meth:`!" "asyncio.AbstractEventLoopPolicy.get_child_watcher` are deprecated and will " "be removed in Python 3.14. (Contributed by Kumar Aditya in :gh:`94597`.)" msgstr "" +":func:`!asyncio.set_child_watcher`、:func:`!asyncio.get_child_watcher`、:" +"meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher`、:meth:`!asyncio." +"AbstractEventLoopPolicy.get_child_watcher` は非推奨となり、Python 3.14 で削除" +"されます。\n" +"(Kumar Aditya が :gh:`94597` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:36 msgid "" "The :meth:`~asyncio.get_event_loop` method of the default event loop policy " "now emits a :exc:`DeprecationWarning` if there is no current event loop set " "and it decides to create one. (Contributed by Serhiy Storchaka and Guido van " "Rossum in :gh:`100160`.)" msgstr "" +"デフォルトのイベントループポリシーの :meth:`~asyncio.get_event_loop` メソッド" +"は、現在のイベントループが設定されておらず、新たに作成することにした場合に :" +"exc:`DeprecationWarning` を出すようになりました。\n" +"(Serhiy Storchaka と Guido van Rossum が :gh:`100160` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:41 msgid "" ":mod:`email`: Deprecated the *isdst* parameter in :func:`email.utils." "localtime`. (Contributed by Alan Williams in :gh:`72346`.)" msgstr "" +":mod:`email`::func:`email.utils.localtime` の ``isdst`` パラメータは非推奨に" +"なりました。\n" +"(Alan Williams が :gh:`72346` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:44 msgid ":mod:`importlib.abc` deprecated classes:" -msgstr "" +msgstr ":mod:`importlib.abc` の非推奨のクラス:" #: ../../deprecations/pending-removal-in-3.14.rst:46 msgid ":class:`!importlib.abc.ResourceReader`" @@ -116,9 +126,8 @@ msgstr ":class:`!importlib.abc.Traversable`" msgid ":class:`!importlib.abc.TraversableResources`" msgstr ":class:`!importlib.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:50 msgid "Use :mod:`importlib.resources.abc` classes instead:" -msgstr "" +msgstr "代わりに :mod:`importlib.resources.abc` のクラスを使ってください:" #: ../../deprecations/pending-removal-in-3.14.rst:52 msgid ":class:`importlib.resources.abc.Traversable`" @@ -128,19 +137,23 @@ msgstr ":class:`importlib.resources.abc.Traversable`" msgid ":class:`importlib.resources.abc.TraversableResources`" msgstr ":class:`importlib.resources.abc.TraversableResources`" -#: ../../deprecations/pending-removal-in-3.14.rst:55 msgid "(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)" msgstr "" +"(Jason R. Coombs and Hugo van Kemenade が :gh:`93963` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:57 msgid "" ":mod:`itertools` had undocumented, inefficient, historically buggy, and " "inconsistent support for copy, deepcopy, and pickle operations. This will be " "removed in 3.14 for a significant reduction in code volume and maintenance " "burden. (Contributed by Raymond Hettinger in :gh:`101588`.)" msgstr "" +":mod:`itertools` は copy、deepcopy、pickle の操作をサポートしていましたが、ド" +"キュメント化されておらず、非効率で、以前からバグが多く、一貫性もありませんで" +"した。\n" +"コード量と保守の負担を大幅に減らすため、このサポートは 3.14 で削除されま" +"す。\n" +"(Raymond Hettinger が :gh:`101588` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:63 msgid "" ":mod:`multiprocessing`: The default start method will change to a safer one " "on Linux, BSDs, and other non-macOS POSIX platforms where ``'fork'`` is " @@ -150,50 +163,62 @@ msgid "" "set_start_method` APIs to explicitly specify when your code *requires* " "``'fork'``. See :ref:`multiprocessing-start-methods`." msgstr "" +":mod:`multiprocessing`:Linux、BSD、および現在 ``'fork'`` がデフォルトとなっ" +"ている macOS 以外の POSIX プラットフォームでは、デフォルトの開始方式がより安" +"全なものに変わります (:gh:`84559`)。\n" +"ほとんどのコードでは影響を受けないと考えられるため、この変更について実行時に" +"警告を出すのは混乱が大きすぎると判断されました。\n" +"コードが ``'fork'`` を *必要とする* 場合は、:func:`~multiprocessing." +"get_context` または :func:`~multiprocessing.set_start_method` API で明示的に" +"指定してください。\n" +":ref:`multiprocessing-start-methods` を参照してください。" -#: ../../deprecations/pending-removal-in-3.14.rst:71 msgid "" ":mod:`pathlib`: :meth:`~pathlib.PurePath.is_relative_to` and :meth:`~pathlib." "PurePath.relative_to`: passing additional arguments is deprecated." msgstr "" +":mod:`pathlib`::meth:`~pathlib.PurePath.is_relative_to` と :meth:`~pathlib." +"PurePath.relative_to` に追加の引数を渡すことは非推奨です。" -#: ../../deprecations/pending-removal-in-3.14.rst:75 msgid "" ":mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:`!pkgutil.get_loader` " "now raise :exc:`DeprecationWarning`; use :func:`importlib.util.find_spec` " "instead. (Contributed by Nikita Sobolev in :gh:`97850`.)" msgstr "" +":mod:`pkgutil`::func:`!pkgutil.find_loader` と :func:`!pkgutil.get_loader` " +"は :exc:`DeprecationWarning` を出すようになりました。\n" +"代わりに :func:`importlib.util.find_spec` を使ってください。\n" +"(Nikita Sobolev が :gh:`97850` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.14.rst:80 msgid ":mod:`pty`:" -msgstr "" +msgstr ":mod:`pty`:" -#: ../../deprecations/pending-removal-in-3.14.rst:82 msgid "``master_open()``: use :func:`pty.openpty`." -msgstr "" +msgstr "``master_open()``::func:`pty.openpty` を使ってください。" -#: ../../deprecations/pending-removal-in-3.14.rst:83 msgid "``slave_open()``: use :func:`pty.openpty`." -msgstr "" +msgstr "``slave_open()``::func:`pty.openpty` を使ってください。" -#: ../../deprecations/pending-removal-in-3.14.rst:85 msgid ":mod:`sqlite3`:" -msgstr "" +msgstr ":mod:`sqlite3`:" -#: ../../deprecations/pending-removal-in-3.14.rst:87 msgid ":data:`!version` and :data:`!version_info`." -msgstr "" +msgstr ":data:`!version` と :data:`!version_info`。" -#: ../../deprecations/pending-removal-in-3.14.rst:89 msgid "" ":meth:`~sqlite3.Cursor.execute` and :meth:`~sqlite3.Cursor.executemany` if :" "ref:`named placeholders ` are used and *parameters* is " "a sequence instead of a :class:`dict`." msgstr "" +":meth:`~sqlite3.Cursor.execute` と :meth:`~sqlite3.Cursor.executemany` で、:" +"ref:`名前付きプレースホルダー ` を使い、``parameters`` " +"に :class:`dict` ではなくシーケンスを渡すこと。" -#: ../../deprecations/pending-removal-in-3.14.rst:93 msgid "" ":mod:`urllib`: :class:`!urllib.parse.Quoter` is deprecated: it was not " "intended to be a public API. (Contributed by Gregory P. Smith in :gh:" "`88168`.)" msgstr "" +":mod:`urllib`::class:`!urllib.parse.Quoter` は非推奨です。\n" +"公開 API として意図されたものではありませんでした。\n" +"(Gregory P. Smith が :gh:`88168` で貢献しました。)" diff --git a/deprecations/pending-removal-in-3.15.po b/deprecations/pending-removal-in-3.15.po index 13d0490ad..07f7f215c 100644 --- a/deprecations/pending-removal-in-3.15.po +++ b/deprecations/pending-removal-in-3.15.po @@ -12,139 +12,156 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.15.rst:2 msgid "Pending removal in Python 3.15" -msgstr "" +msgstr "Python 3.15 で削除予定" -#: ../../deprecations/pending-removal-in-3.15.rst:4 msgid "The import system:" -msgstr "" +msgstr "インポートシステム:" -#: ../../deprecations/pending-removal-in-3.15.rst:6 msgid "" "Setting ``__cached__`` on a module while failing to set :attr:`__spec__." "cached ` is deprecated. In Python " "3.15, ``__cached__`` will cease to be set or take into consideration by the " "import system or standard library. (:gh:`97879`)" msgstr "" +"モジュールの :attr:`__spec__.cached ` " +"を設定せずに ``__cached__`` を設定することは非推奨です。\n" +"Python 3.15 では、インポートシステムや標準ライブラリは ``__cached__`` を設定" +"しなくなり、その値も参照しなくなります。\n" +"(:gh:`97879`)" -#: ../../deprecations/pending-removal-in-3.15.rst:11 msgid "" "Setting :attr:`~module.__package__` on a module while failing to set :attr:" "`__spec__.parent ` is deprecated. In " "Python 3.15, :attr:`!__package__` will cease to be set or take into " "consideration by the import system or standard library. (:gh:`97879`)" msgstr "" +"モジュールの :attr:`__spec__.parent ` " +"を設定せずに :attr:`~module.__package__` を設定することは非推奨です。\n" +"Python 3.15 では、インポートシステムや標準ライブラリは :attr:`!__package__` " +"を設定しなくなり、その値も参照しなくなります。\n" +"(:gh:`97879`)" -#: ../../deprecations/pending-removal-in-3.15.rst:16 msgid ":mod:`ctypes`:" -msgstr "" +msgstr ":mod:`ctypes`:" -#: ../../deprecations/pending-removal-in-3.15.rst:18 msgid "" "The undocumented :func:`!ctypes.SetPointerType` function has been deprecated " "since Python 3.13." msgstr "" +"ドキュメント化されていない :func:`!ctypes.SetPointerType` 関数は Python 3.13 " +"から非推奨です。" -#: ../../deprecations/pending-removal-in-3.15.rst:21 msgid ":mod:`http.server`:" -msgstr "" +msgstr ":mod:`http.server`:" -#: ../../deprecations/pending-removal-in-3.15.rst:23 msgid "" "The obsolete and rarely used :class:`!CGIHTTPRequestHandler` has been " "deprecated since Python 3.13. No direct replacement exists. *Anything* is " "better than CGI to interface a web server with a request handler." msgstr "" +"古く、ほとんど使われていない :class:`!CGIHTTPRequestHandler` は Python 3.13 " +"から非推奨です。\n" +"直接の代替はありません。\n" +"Web サーバーとリクエストハンドラーを接続するには、CGI 以外なら *どの方法でも" +"* よりよい選択です。" -#: ../../deprecations/pending-removal-in-3.15.rst:29 msgid "" "The :option:`!--cgi` flag to the :program:`python -m http.server` command-" "line interface has been deprecated since Python 3.13." msgstr "" +":program:`python -m http.server` のコマンドラインインターフェースの :option:" +"`!--cgi` フラグは Python 3.13 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.15.rst:32 msgid ":mod:`importlib`:" -msgstr "" +msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-3.15.rst:34 msgid "``load_module()`` method: use ``exec_module()`` instead." msgstr "" +"``load_module()`` メソッド:代わりに ``exec_module()`` を使ってください。" -#: ../../deprecations/pending-removal-in-3.15.rst:36 msgid ":mod:`pathlib`:" -msgstr "" +msgstr ":mod:`pathlib`:" -#: ../../deprecations/pending-removal-in-3.15.rst:38 msgid "" ":meth:`!.PurePath.is_reserved` has been deprecated since Python 3.13. Use :" "func:`os.path.isreserved` to detect reserved paths on Windows." msgstr "" +":meth:`!.PurePath.is_reserved` は Python 3.13 から非推奨です。\n" +"Windows で予約済みのパスを検出するには :func:`os.path.isreserved` を使ってく" +"ださい。" -#: ../../deprecations/pending-removal-in-3.15.rst:42 msgid ":mod:`platform`:" -msgstr "" +msgstr ":mod:`platform`:" -#: ../../deprecations/pending-removal-in-3.15.rst:44 msgid "" ":func:`!platform.java_ver` has been deprecated since Python 3.13. This " "function is only useful for Jython support, has a confusing API, and is " "largely untested." msgstr "" +":func:`!platform.java_ver` は Python 3.13 から非推奨です。\n" +"この関数が役立つのは Jython への対応だけで、API は分かりにくく、ほとんどテス" +"トされていません。" -#: ../../deprecations/pending-removal-in-3.15.rst:48 msgid ":mod:`sysconfig`:" -msgstr "" +msgstr ":mod:`sysconfig`:" -#: ../../deprecations/pending-removal-in-3.15.rst:50 msgid "" "The *check_home* argument of :func:`sysconfig.is_python_build` has been " "deprecated since Python 3.12." msgstr "" +":func:`sysconfig.is_python_build` の ``check_home`` 引数は Python 3.12 から非" +"推奨です。" -#: ../../deprecations/pending-removal-in-3.15.rst:53 msgid ":mod:`threading`:" -msgstr "" +msgstr ":mod:`threading`:" -#: ../../deprecations/pending-removal-in-3.15.rst:55 msgid "" ":func:`~threading.RLock` will take no arguments in Python 3.15. Passing any " "arguments has been deprecated since Python 3.14, as the Python version does " "not permit any arguments, but the C version allows any number of positional " "or keyword arguments, ignoring every argument." msgstr "" +":func:`~threading.RLock` は Python 3.15 から引数を受け取らなくなります。\n" +"Python 実装は引数を一切受け付けない一方、C 実装は任意の個数の位置引数やキー" +"ワード引数を受け付けてすべて無視するため、Python 3.14 から引数を渡すことは非" +"推奨です。" -#: ../../deprecations/pending-removal-in-3.15.rst:61 msgid ":mod:`types`:" -msgstr "" +msgstr ":mod:`types`:" -#: ../../deprecations/pending-removal-in-3.15.rst:63 msgid "" ":class:`types.CodeType`: Accessing :attr:`!codeobject.co_lnotab` was " "deprecated in :pep:`626` since 3.10 and was planned to be removed in 3.12, " "but it only got a proper :exc:`DeprecationWarning` in 3.12. May be removed " "in 3.15. (Contributed by Nikita Sobolev in :gh:`101866`.)" msgstr "" +":class:`types.CodeType`::attr:`!codeobject.co_lnotab` へのアクセスは、:pep:" +"`626` で 3.10 から非推奨となり、3.12 で削除予定でした。\n" +"しかし、実際に :exc:`DeprecationWarning` が出るようになったのは 3.12 です。\n" +"3.15 で削除される可能性があります。\n" +"(Nikita Sobolev が :gh:`101866` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.15.rst:70 msgid ":mod:`typing`:" -msgstr "" +msgstr ":mod:`typing`:" -#: ../../deprecations/pending-removal-in-3.15.rst:72 msgid "" "The undocumented keyword argument syntax for creating :class:`~typing." "NamedTuple` classes (for example, ``Point = NamedTuple(\"Point\", x=int, " "y=int)``) has been deprecated since Python 3.13. Use the class-based syntax " "or the functional syntax instead." msgstr "" +":class:`~typing.NamedTuple` クラスを作成する、ドキュメント化されていないキー" +"ワード引数による構文 (例えば ``Point = NamedTuple(\"Point\", x=int, " +"y=int)``) は Python 3.13 から非推奨です。\n" +"代わりにクラスベースの構文か関数形式の構文を使ってください。" -#: ../../deprecations/pending-removal-in-3.15.rst:78 msgid "" "When using the functional syntax of :class:`~typing.TypedDict`\\s, failing " "to pass a value to the *fields* parameter (``TD = TypedDict(\"TD\")``) or " @@ -152,36 +169,46 @@ msgid "" "since Python 3.13. Use ``class TD(TypedDict): pass`` or ``TD = " "TypedDict(\"TD\", {})`` to create a TypedDict with zero field." msgstr "" +":class:`~typing.TypedDict` の関数形式の構文で、``fields`` パラメータを省略す" +"ること (``TD = TypedDict(\"TD\")``) や ``None`` を渡すこと (``TD = " +"TypedDict(\"TD\", None)``) は Python 3.13 から非推奨です。\n" +"フィールドがない TypedDict を作成するには、``class TD(TypedDict): pass`` また" +"は ``TD = TypedDict(\"TD\", {})`` を使ってください。" -#: ../../deprecations/pending-removal-in-3.15.rst:85 msgid "" "The :deco:`!typing.no_type_check_decorator` decorator function has been " "deprecated since Python 3.13. After eight years in the :mod:`typing` module, " "it has yet to be supported by any major type checker." msgstr "" +":deco:`!typing.no_type_check_decorator` デコレーター関数は Python 3.13 から非" +"推奨です。\n" +":mod:`typing` モジュールに追加されてから8年が経過しましたが、主要な型チェッ" +"カーではまだサポートされていません。" -#: ../../deprecations/pending-removal-in-3.15.rst:90 msgid "" ":mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules." msgstr "" +":mod:`!sre_compile`、:mod:`!sre_constants`、:mod:`!sre_parse` モジュール。" -#: ../../deprecations/pending-removal-in-3.15.rst:92 msgid ":mod:`wave`:" -msgstr "" +msgstr ":mod:`wave`:" -#: ../../deprecations/pending-removal-in-3.15.rst:94 msgid "" "The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of the :class:" "`~wave.Wave_read` and :class:`~wave.Wave_write` classes have been deprecated " "since Python 3.13." msgstr "" +":class:`~wave.Wave_read` クラスと :class:`~wave.Wave_write` クラスの " +"``getmark()``、``setmark()``、``getmarkers()`` メソッドは Python 3.13 から非" +"推奨です。" -#: ../../deprecations/pending-removal-in-3.15.rst:98 msgid ":mod:`zipimport`:" -msgstr "" +msgstr ":mod:`zipimport`:" -#: ../../deprecations/pending-removal-in-3.15.rst:100 msgid "" ":meth:`!zipimport.zipimporter.load_module` has been deprecated since Python " "3.10. Use :meth:`~zipimport.zipimporter.exec_module` instead. (:gh:`125746`.)" msgstr "" +":meth:`!zipimport.zipimporter.load_module` は Python 3.10 から非推奨です。\n" +"代わりに :meth:`~zipimport.zipimporter.exec_module` を使ってください。\n" +"(:gh:`125746`。)" diff --git a/deprecations/pending-removal-in-3.16.po b/deprecations/pending-removal-in-3.16.po index b06caaa87..ddba9e250 100644 --- a/deprecations/pending-removal-in-3.16.po +++ b/deprecations/pending-removal-in-3.16.po @@ -12,91 +12,93 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.16.rst:2 msgid "Pending removal in Python 3.16" -msgstr "" +msgstr "Python 3.16 で削除予定" -#: ../../deprecations/pending-removal-in-3.16.rst:4 msgid "The import system:" -msgstr "" +msgstr "インポートシステム:" -#: ../../deprecations/pending-removal-in-3.16.rst:6 msgid "" "Setting :attr:`~module.__loader__` on a module while failing to set :attr:" "`__spec__.loader ` is deprecated. In " "Python 3.16, :attr:`!__loader__` will cease to be set or taken into " "consideration by the import system or the standard library." msgstr "" +"モジュールの :attr:`__spec__.loader ` " +"を設定せずに :attr:`~module.__loader__` を設定することは非推奨です。\n" +"Python 3.16 では、インポートシステムや標準ライブラリは :attr:`!__loader__` を" +"設定しなくなり、その値も参照しなくなります。" -#: ../../deprecations/pending-removal-in-3.16.rst:11 msgid ":mod:`array`:" -msgstr "" +msgstr ":mod:`array`:" -#: ../../deprecations/pending-removal-in-3.16.rst:13 msgid "" "The ``'u'`` format code (:c:type:`wchar_t`) has been deprecated in " "documentation since Python 3.3 and at runtime since Python 3.13. Use the " "``'w'`` format code (:c:type:`Py_UCS4`) for Unicode characters instead." msgstr "" +"書式コード ``'u'`` (:c:type:`wchar_t`) は、Python 3.3 からドキュメントで非推" +"奨とされ、Python 3.13 からは実行時にも非推奨とされています。\n" +"Unicode 文字には、代わりに書式コード ``'w'`` (:c:type:`Py_UCS4`) を使ってくだ" +"さい。" -#: ../../deprecations/pending-removal-in-3.16.rst:19 msgid ":mod:`asyncio`:" -msgstr "" +msgstr ":mod:`asyncio`:" -#: ../../deprecations/pending-removal-in-3.16.rst:21 msgid "" ":func:`!asyncio.iscoroutinefunction` is deprecated and will be removed in " "Python 3.16; use :func:`inspect.iscoroutinefunction` instead. (Contributed " "by Jiahao Li and Kumar Aditya in :gh:`122875`.)" msgstr "" +":func:`!asyncio.iscoroutinefunction` は非推奨となり、Python 3.16 で削除されま" +"す。\n" +"代わりに :func:`inspect.iscoroutinefunction` を使ってください。\n" +"(Jiahao Li と Kumar Aditya が :gh:`122875` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:26 msgid "" ":mod:`asyncio` policy system is deprecated and will be removed in Python " "3.16. In particular, the following classes and functions are deprecated:" msgstr "" +":mod:`asyncio` のポリシーシステムは非推奨となり、Python 3.16 で削除されま" +"す。\n" +"具体的には、以下のクラスと関数が非推奨です:" -#: ../../deprecations/pending-removal-in-3.16.rst:29 msgid ":class:`asyncio.AbstractEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.AbstractEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:30 msgid ":class:`asyncio.DefaultEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.DefaultEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:31 msgid ":class:`asyncio.WindowsSelectorEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.WindowsSelectorEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:32 msgid ":class:`asyncio.WindowsProactorEventLoopPolicy`" -msgstr "" +msgstr ":class:`asyncio.WindowsProactorEventLoopPolicy`" -#: ../../deprecations/pending-removal-in-3.16.rst:33 msgid ":func:`asyncio.get_event_loop_policy`" -msgstr "" +msgstr ":func:`asyncio.get_event_loop_policy`" -#: ../../deprecations/pending-removal-in-3.16.rst:34 msgid ":func:`asyncio.set_event_loop_policy`" -msgstr "" +msgstr ":func:`asyncio.set_event_loop_policy`" -#: ../../deprecations/pending-removal-in-3.16.rst:36 msgid "" "Users should use :func:`asyncio.run` or :class:`asyncio.Runner` with " "*loop_factory* to use the desired event loop implementation." msgstr "" +"使いたいイベントループの実装を指定するには、:func:`asyncio.run` または :" +"class:`asyncio.Runner` の ``loop_factory`` を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:39 msgid "For example, to use :class:`asyncio.SelectorEventLoop` on Windows::" msgstr "" +"例えば、Windows で :class:`asyncio.SelectorEventLoop` を使うには、次のように" +"します。 ::" -#: ../../deprecations/pending-removal-in-3.16.rst:41 msgid "" "import asyncio\n" "\n" @@ -105,16 +107,19 @@ msgid "" "\n" "asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" msgstr "" +"import asyncio\n" +"\n" +"async def main():\n" +" ...\n" +"\n" +"asyncio.run(main(), loop_factory=asyncio.SelectorEventLoop)" -#: ../../deprecations/pending-removal-in-3.16.rst:48 msgid "(Contributed by Kumar Aditya in :gh:`127949`.)" -msgstr "" +msgstr "(Kumar Aditya が :gh:`127949` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:50 msgid ":mod:`builtins`:" -msgstr "" +msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-3.16.rst:52 msgid "" "Bitwise inversion on boolean types, ``~True`` or ``~False`` has been " "deprecated since Python 3.12, as it produces surprising and unintuitive " @@ -122,90 +127,102 @@ msgid "" "of a Boolean. In the rare case that you need the bitwise inversion of the " "underlying integer, convert to ``int`` explicitly (``~int(x)``)." msgstr "" +"真偽値に対するビット単位の反転 ``~True`` や ``~False`` は、直感に反する意外な" +"結果 (``-2`` と ``-1``) になるため、Python 3.12 から非推奨です。\n" +"真偽値の論理否定には、代わりに ``not x`` を使ってください。\n" +"元の整数値のビット単位の反転が必要になるまれな場合には、明示的に ``int`` に変" +"換してください (``~int(x)``)。" -#: ../../deprecations/pending-removal-in-3.16.rst:59 msgid ":mod:`functools`:" -msgstr "" +msgstr ":mod:`functools`:" -#: ../../deprecations/pending-removal-in-3.16.rst:61 msgid "" "Calling the Python implementation of :func:`functools.reduce` with " "*function* or *sequence* as keyword arguments has been deprecated since " "Python 3.14." msgstr "" +":func:`functools.reduce` の Python 実装を、``function`` や ``sequence`` を" +"キーワード引数として指定して呼び出すことは、Python 3.14 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.16.rst:64 msgid ":mod:`logging`:" -msgstr "" +msgstr ":mod:`logging`:" -#: ../../deprecations/pending-removal-in-3.16.rst:66 msgid "" "Support for custom logging handlers with the *strm* argument is deprecated " "and scheduled for removal in Python 3.16. Define handlers with the *stream* " "argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)" msgstr "" +"``strm`` 引数を持つカスタムログハンドラーへの対応は非推奨となり、Python 3.16 " +"で削除予定です。\n" +"代わりに ``stream`` 引数を持つハンドラーを定義してください。\n" +"(Mariusz Felisiak が :gh:`115032` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:70 msgid ":mod:`mimetypes`:" -msgstr "" +msgstr ":mod:`mimetypes`:" -#: ../../deprecations/pending-removal-in-3.16.rst:72 msgid "" "Valid extensions start with a '.' or are empty for :meth:`mimetypes." "MimeTypes.add_type`. Undotted extensions are deprecated and will raise a :" "exc:`ValueError` in Python 3.16. (Contributed by Hugo van Kemenade in :gh:" "`75223`.)" msgstr "" +":meth:`mimetypes.MimeTypes.add_type` で有効な拡張子は、'.' で始まるものか空の" +"ものです。\n" +"ドットのない拡張子は非推奨となり、Python 3.16 では :exc:`ValueError` が発生し" +"ます。\n" +"(Hugo van Kemenade が :gh:`75223` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.16.rst:78 msgid ":mod:`shutil`:" -msgstr "" +msgstr ":mod:`shutil`:" -#: ../../deprecations/pending-removal-in-3.16.rst:80 msgid "" "The :class:`!ExecError` exception has been deprecated since Python 3.14. It " "has not been used by any function in :mod:`!shutil` since Python 3.4, and is " "now an alias of :exc:`RuntimeError`." msgstr "" +":class:`!ExecError` 例外は Python 3.14 から非推奨です。\n" +"Python 3.4 以降は :mod:`!shutil` のどの関数でも使われておらず、現在は :exc:" +"`RuntimeError` の別名になっています。" -#: ../../deprecations/pending-removal-in-3.16.rst:85 msgid ":mod:`symtable`:" -msgstr "" +msgstr ":mod:`symtable`:" -#: ../../deprecations/pending-removal-in-3.16.rst:87 msgid "" "The :meth:`Class.get_methods ` method has been " "deprecated since Python 3.14." msgstr "" +":meth:`Class.get_methods ` メソッドは Python " +"3.14 から非推奨です。" -#: ../../deprecations/pending-removal-in-3.16.rst:90 msgid ":mod:`sys`:" -msgstr "" +msgstr ":mod:`sys`:" -#: ../../deprecations/pending-removal-in-3.16.rst:92 msgid "" "The :func:`~sys._enablelegacywindowsfsencoding` function has been deprecated " "since Python 3.13. Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` " "environment variable instead." msgstr "" +":func:`~sys._enablelegacywindowsfsencoding` 関数は Python 3.13 から非推奨で" +"す。\n" +"代わりに環境変数 :envvar:`PYTHONLEGACYWINDOWSFSENCODING` を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:96 msgid ":mod:`sysconfig`:" -msgstr "" +msgstr ":mod:`sysconfig`:" -#: ../../deprecations/pending-removal-in-3.16.rst:98 msgid "" "The :func:`!sysconfig.expand_makefile_vars` function has been deprecated " "since Python 3.14. Use the ``vars`` argument of :func:`sysconfig.get_paths` " "instead." msgstr "" +":func:`!sysconfig.expand_makefile_vars` 関数は Python 3.14 から非推奨です。\n" +"代わりに :func:`sysconfig.get_paths` の ``vars`` 引数を使ってください。" -#: ../../deprecations/pending-removal-in-3.16.rst:102 msgid ":mod:`tarfile`:" -msgstr "" +msgstr ":mod:`tarfile`:" -#: ../../deprecations/pending-removal-in-3.16.rst:104 msgid "" "The undocumented and unused :attr:`!TarFile.tarfile` attribute has been " "deprecated since Python 3.13." msgstr "" +"ドキュメント化されておらず、使われてもいない :attr:`!TarFile.tarfile` 属性は " +"Python 3.13 から非推奨です。" diff --git a/deprecations/pending-removal-in-3.17.po b/deprecations/pending-removal-in-3.17.po index c108c497c..d462d4853 100644 --- a/deprecations/pending-removal-in-3.17.po +++ b/deprecations/pending-removal-in-3.17.po @@ -12,38 +12,35 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.17.rst:2 msgid "Pending removal in Python 3.17" -msgstr "" +msgstr "Python 3.17 で削除予定" -#: ../../deprecations/pending-removal-in-3.17.rst:4 msgid ":mod:`datetime`:" -msgstr "" +msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-3.17.rst:6 msgid "" ":meth:`~datetime.datetime.strptime` calls using a format string containing " "``%e`` (day of month) without a year. This has been deprecated since Python " "3.15. (Contributed by Stan Ulbrych in :gh:`70647`.)" msgstr "" +"年を含まず ``%e`` (月内の日) を含む書式文字列で :meth:`~datetime.datetime." +"strptime` を呼び出すこと。\n" +"これは Python 3.15 から非推奨です。\n" +"(Stan Ulbrych が :gh:`70647` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:12 msgid ":mod:`collections.abc`:" -msgstr "" +msgstr ":mod:`collections.abc`:" -#: ../../deprecations/pending-removal-in-3.17.rst:14 msgid "" ":class:`collections.abc.ByteString` is scheduled for removal in Python 3.17." -msgstr "" +msgstr ":class:`collections.abc.ByteString` は Python 3.17 で削除予定です。" -#: ../../deprecations/pending-removal-in-3.17.rst:16 -#: ../../deprecations/pending-removal-in-3.17.rst:62 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -51,9 +48,13 @@ msgid "" "that explicitly specifies the types your code supports (e.g., ``bytes | " "bytearray | memoryview``)." msgstr "" +"実行時に ``obj`` が :ref:`バッファプロトコル ` を実装している" +"か調べるには、``isinstance(obj, collections.abc.Buffer)`` を使ってくださ" +"い。\n" +"型アノテーションには :class:`~collections.abc.Buffer` を使うか、コードが対応" +"する型を明示したユニオン (例えば ``bytes | bytearray | memoryview``) を使って" +"ください。" -#: ../../deprecations/pending-removal-in-3.17.rst:22 -#: ../../deprecations/pending-removal-in-3.17.rst:68 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -63,52 +64,63 @@ msgid "" "also never understood as subtypes of :class:`!ByteString` (either at runtime " "or by static type checkers)." msgstr "" +":class:`!ByteString` は当初、:class:`bytes` と :class:`bytearray` の両方の上" +"位型となる抽象クラスとして意図されていました。\n" +"しかし、この ABC はメソッドを一つも持たないため、あるオブジェクトが :class:`!" +"ByteString` のインスタンスだと分かっても、そのオブジェクトに関する有用な情報" +"は何も得られませんでした。\n" +":class:`memoryview` など、他の一般的なバッファ型も、実行時にも静的型チェッ" +"カーによっても :class:`!ByteString` のサブタイプとして認識されることはありま" +"せんでした。" -#: ../../deprecations/pending-removal-in-3.17.rst:30 -#: ../../deprecations/pending-removal-in-3.17.rst:76 msgid "" "See :pep:`PEP 688 <688#current-options>` for more details. (Contributed by " "Shantanu Jain in :gh:`91896`.)" msgstr "" +"詳しくは :pep:`PEP 688 <688#current-options>` を参照してください。\n" +"(Shantanu Jain が :gh:`91896` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:34 msgid ":mod:`encodings`:" -msgstr "" +msgstr ":mod:`encodings`:" -#: ../../deprecations/pending-removal-in-3.17.rst:36 msgid "" "Passing non-ascii *encoding* names to :func:`encodings.normalize_encoding` " "is deprecated and scheduled for removal in Python 3.17. (Contributed by Stan " "Ulbrych in :gh:`136702`.)" msgstr "" +":func:`encodings.normalize_encoding` に非 ASCII の ``encoding`` 名を渡すこと" +"は非推奨となり、Python 3.17 で削除予定です。\n" +"(Stan Ulbrych が :gh:`136702` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:40 msgid ":mod:`profile`:" -msgstr "" +msgstr ":mod:`profile`:" -#: ../../deprecations/pending-removal-in-3.17.rst:42 msgid "" "The :mod:`!profile` module is deprecated and will be removed in Python 3.17. " "Use :mod:`profiling.tracing` instead, which provides a compatible API. See :" "pep:`799` for details. (Contributed by Pablo Galindo and László Kiss Kollár " "in :gh:`138122`.)" msgstr "" +":mod:`!profile` モジュールは非推奨となり、Python 3.17 で削除されます。\n" +"代わりに、互換性のある API を提供する :mod:`profiling.tracing` を使ってくださ" +"い。\n" +"詳しくは :pep:`799` を参照してください。\n" +"(Pablo Galindo と László Kiss Kollár が :gh:`138122` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.17.rst:47 msgid ":mod:`webbrowser`:" -msgstr "" +msgstr ":mod:`webbrowser`:" -#: ../../deprecations/pending-removal-in-3.17.rst:49 msgid "" ":class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of :class:`!" "webbrowser.MacOS`. (:gh:`137586`)" msgstr "" +":class:`!webbrowser.MacOSXOSAScript` は非推奨となりました。\n" +"代わりに :class:`!webbrowser.MacOS` を使ってください。\n" +"(:gh:`137586`)" -#: ../../deprecations/pending-removal-in-3.17.rst:52 msgid ":mod:`typing`:" -msgstr "" +msgstr ":mod:`typing`:" -#: ../../deprecations/pending-removal-in-3.17.rst:54 msgid "" "Before Python 3.14, old-style unions were implemented using the private " "class ``typing._UnionGenericAlias``. This class is no longer needed for the " @@ -117,18 +129,24 @@ msgid "" "helpers like :func:`typing.get_origin` and :func:`typing.get_args` instead " "of relying on private implementation details." msgstr "" +"Python 3.14 より前は、従来のユニオンは非公開クラス ``typing." +"_UnionGenericAlias`` を使って実装されていました。\n" +"このクラスは実装上は不要になりましたが、後方互換性のために残されており、" +"Python 3.17 で削除予定です。\n" +"非公開の実装の詳細に依存する代わりに、:func:`typing.get_origin` や :func:" +"`typing.get_args` など、ドキュメント化されたイントロスペクション用の補助関数" +"を使ってください。" -#: ../../deprecations/pending-removal-in-3.17.rst:59 msgid "" ":class:`typing.ByteString`, deprecated since Python 3.9, is scheduled for " "removal in Python 3.17." msgstr "" +"Python 3.9 から非推奨となっている :class:`typing.ByteString` は、Python 3.17 " +"で削除予定です。" -#: ../../deprecations/pending-removal-in-3.17.rst:79 msgid ":mod:`tkinter`:" -msgstr "" +msgstr ":mod:`tkinter`:" -#: ../../deprecations/pending-removal-in-3.17.rst:81 msgid "" "The :class:`!tkinter.Variable` methods :meth:`!trace_variable`, :meth:`!" "trace` (an alias of :meth:`!trace_variable`), :meth:`!trace_vdelete` and :" @@ -136,3 +154,10 @@ msgid "" "in Python 3.17. Use :meth:`!trace_add`, :meth:`!trace_remove` and :meth:`!" "trace_info` instead. (Contributed by Serhiy Storchaka in :gh:`120220`.)" msgstr "" +"Python 3.14 から非推奨となっている :class:`!tkinter.Variable` のメソッド :" +"meth:`!trace_variable`、:meth:`!trace` (:meth:`!trace_variable` の別名)、:" +"meth:`!trace_vdelete`、:meth:`!trace_vinfo` は、Python 3.17 で削除予定で" +"す。\n" +"代わりに :meth:`!trace_add`、:meth:`!trace_remove`、:meth:`!trace_info` を" +"使ってください。\n" +"(Serhiy Storchaka が :gh:`120220` で貢献しました。)" diff --git a/deprecations/pending-removal-in-3.18.po b/deprecations/pending-removal-in-3.18.po index 54c1165b8..aa27c2005 100644 --- a/deprecations/pending-removal-in-3.18.po +++ b/deprecations/pending-removal-in-3.18.po @@ -12,42 +12,42 @@ msgstr "" "PO-Revision-Date: 2026-01-07 14:20+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.18.rst:2 msgid "Pending removal in Python 3.18" -msgstr "" +msgstr "Python 3.18 で削除予定" -#: ../../deprecations/pending-removal-in-3.18.rst:4 msgid "" "No longer accept a boolean value when a file descriptor is expected. " "(Contributed by Serhiy Storchaka in :gh:`82626`.)" msgstr "" +"ファイルディスクリプタが必要なところでは、真偽値を受け付けなくなります。\n" +"(Serhiy Storchaka が :gh:`82626` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.18.rst:7 msgid ":mod:`decimal`:" -msgstr "" +msgstr ":mod:`decimal`:" -#: ../../deprecations/pending-removal-in-3.18.rst:9 msgid "" "The non-standard and undocumented :class:`~decimal.Decimal` format specifier " "``'N'``, which is only supported in the :mod:`!decimal` module's C " "implementation, has been deprecated since Python 3.13. (Contributed by " "Serhiy Storchaka in :gh:`89902`.)" msgstr "" +":class:`~decimal.Decimal` の標準外でドキュメント化されていない書式指定子 " +"``'N'`` は、Python 3.13 から非推奨です。\n" +"これは :mod:`!decimal` モジュールの C 実装だけでサポートされています。\n" +"(Serhiy Storchaka が :gh:`89902` で貢献しました。)" -#: ../../deprecations/pending-removal-in-3.18.rst:14 msgid "Deprecations defined by :pep:`829`:" -msgstr "" +msgstr ":pep:`829` で定義された非推奨事項:" -#: ../../deprecations/pending-removal-in-3.18.rst:16 msgid "``import`` lines in :file:`{name}.pth` files are silently ignored." msgstr "" +":file:`{name}.pth` ファイルの ``import`` 行は、警告なしで無視されます。" -#: ../../deprecations/pending-removal-in-3.18.rst:18 msgid "(Contributed by Barry Warsaw in :gh:`148641`.)" -msgstr "" +msgstr "(Barry Warsaw が :gh:`148641` で貢献しました。)" diff --git a/deprecations/pending-removal-in-3.19.po b/deprecations/pending-removal-in-3.19.po index 53d8a1907..a0d4956fd 100644 --- a/deprecations/pending-removal-in-3.19.po +++ b/deprecations/pending-removal-in-3.19.po @@ -12,32 +12,30 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-3.19.rst:2 msgid "Pending removal in Python 3.19" -msgstr "" +msgstr "Python 3.19 で削除予定" -#: ../../deprecations/pending-removal-in-3.19.rst:4 msgid ":mod:`ctypes`:" -msgstr "" +msgstr ":mod:`ctypes`:" -#: ../../deprecations/pending-removal-in-3.19.rst:6 msgid "" "Implicitly switching to the MSVC-compatible struct layout by setting :attr:" "`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_` on non-" "Windows platforms." msgstr "" +"Windows 以外のプラットフォームで、:attr:`~ctypes.Structure._layout_` を設定せ" +"ずに :attr:`~ctypes.Structure._pack_` を設定することで、暗黙的に MSVC 互換の" +"構造体レイアウトに切り替えること。" -#: ../../deprecations/pending-removal-in-3.19.rst:10 msgid ":mod:`hashlib`:" -msgstr "" +msgstr ":mod:`hashlib`:" -#: ../../deprecations/pending-removal-in-3.19.rst:12 msgid "" "In hash function constructors such as :func:`~hashlib.new` or the direct " "hash-named constructors such as :func:`~hashlib.md5` and :func:`~hashlib." @@ -45,51 +43,63 @@ msgid "" "keyword argument named ``data=`` or ``string=`` in various :mod:`!hashlib` " "implementations." msgstr "" +":mod:`!hashlib` のさまざまな実装では、:func:`~hashlib.new` や、:func:" +"`~hashlib.md5`、:func:`~hashlib.sha256` などのハッシュ名を直接使ったコンスト" +"ラクターに、省略可能な初期データを ``data=`` または ``string=`` というキー" +"ワード引数で渡すこともできました。" -#: ../../deprecations/pending-removal-in-3.19.rst:18 msgid "" "Support for the ``string`` keyword argument name is now deprecated and " "slated for removal in Python 3.19." msgstr "" +"キーワード引数名 ``string`` のサポートは非推奨となり、Python 3.19 で削除予定" +"です。" -#: ../../deprecations/pending-removal-in-3.19.rst:21 msgid "" "Before Python 3.13, the ``string`` keyword parameter was not correctly " "supported depending on the backend implementation of hash functions. Prefer " "passing the initial data as a positional argument for maximum backwards " "compatibility." msgstr "" +"Python 3.13 より前は、ハッシュ関数のバックエンド実装によっては、キーワードパ" +"ラメータ ``string`` が正しくサポートされていませんでした。\n" +"後方互換性を最大限に保つには、初期データは位置引数として渡してください。" -#: ../../deprecations/pending-removal-in-3.19.rst:26 msgid ":mod:`http.cookies`:" -msgstr "" +msgstr ":mod:`http.cookies`:" -#: ../../deprecations/pending-removal-in-3.19.rst:28 msgid "" ":meth:`http.cookies.Morsel.js_output` is deprecated and will be removed in " "Python 3.19." msgstr "" +":meth:`http.cookies.Morsel.js_output` は非推奨となり、Python 3.19 で削除され" +"ます。" -#: ../../deprecations/pending-removal-in-3.19.rst:31 msgid "" ":meth:`http.cookies.BaseCookie.js_output` is deprecated and will be removed " "in Python 3.19." msgstr "" +":meth:`http.cookies.BaseCookie.js_output` は非推奨となり、Python 3.19 で削除" +"されます。" -#: ../../deprecations/pending-removal-in-3.19.rst:34 msgid ":mod:`imaplib`:" -msgstr "" +msgstr ":mod:`imaplib`:" -#: ../../deprecations/pending-removal-in-3.19.rst:36 msgid "" "Altering :attr:`IMAP4.file ` is now deprecated and " "slated for removal in Python 3.19. This property is now unused and changing " "its value does not automatically close the current file." msgstr "" +":attr:`IMAP4.file ` の変更は非推奨となり、Python 3.19 で" +"削除予定です。\n" +"このプロパティは現在使われておらず、値を変更しても現在のファイルは自動的には" +"閉じられません。" -#: ../../deprecations/pending-removal-in-3.19.rst:40 msgid "" "Before Python 3.14, this property was used to implement the corresponding " "``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this " "is no longer the case since then." msgstr "" +"Python 3.14 より前は、このプロパティは :class:`~imaplib.IMAP4` の対応する " +"``read()`` メソッドと ``readline()`` メソッドの実装に使われていましたが、それ" +"以降は使われていません。" diff --git a/deprecations/pending-removal-in-future.po b/deprecations/pending-removal-in-future.po index d7ee86c72..1c908ad75 100644 --- a/deprecations/pending-removal-in-future.po +++ b/deprecations/pending-removal-in-future.po @@ -12,53 +12,50 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../deprecations/pending-removal-in-future.rst:2 msgid "Pending removal in future versions" -msgstr "" +msgstr "将来のバージョンで削除予定" -#: ../../deprecations/pending-removal-in-future.rst:4 msgid "" "The following APIs will be removed in the future, although there is " "currently no date scheduled for their removal." msgstr "" +"以下の API は将来削除されますが、現時点では削除時期は決まっていません。" -#: ../../deprecations/pending-removal-in-future.rst:7 msgid ":mod:`argparse`:" -msgstr "" +msgstr ":mod:`argparse`:" -#: ../../deprecations/pending-removal-in-future.rst:9 msgid "" "Nesting argument groups and nesting mutually exclusive groups are deprecated." -msgstr "" +msgstr "引数グループの入れ子と、相互排他的なグループの入れ子は非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:11 msgid "" "Passing the undocumented keyword argument *prefix_chars* to :meth:`~argparse." "ArgumentParser.add_argument_group` is now deprecated." msgstr "" +":meth:`~argparse.ArgumentParser.add_argument_group` に、ドキュメント化されて" +"いないキーワード引数 ``prefix_chars`` を渡すことは非推奨になりました。" -#: ../../deprecations/pending-removal-in-future.rst:14 msgid "The :class:`argparse.FileType` type converter is deprecated." -msgstr "" +msgstr ":class:`argparse.FileType` 型コンバーターは非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:16 msgid ":mod:`builtins`:" -msgstr "" +msgstr ":mod:`builtins`:" -#: ../../deprecations/pending-removal-in-future.rst:18 msgid "" "Generators: ``throw(type, exc, tb)`` and ``athrow(type, exc, tb)`` signature " "is deprecated: use ``throw(exc)`` and ``athrow(exc)`` instead, the single " "argument signature." msgstr "" +"ジェネレーター:``throw(type, exc, tb)`` と ``athrow(type, exc, tb)`` という" +"シグネチャは非推奨です。\n" +"代わりに、引数が一つの ``throw(exc)`` と ``athrow(exc)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:21 msgid "" "Currently Python accepts numeric literals immediately followed by keywords, " "for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing and " @@ -69,6 +66,15 @@ msgid "" "keyword:`is` and :keyword:`or`. In a future release it will be changed to a " "syntax error. (:gh:`87999`)" msgstr "" +"現在の Python は、``0in x``、``1or x``、``0if 1else 2`` のように数値リテラル" +"の直後にキーワードが続く記法を受け付けます。\n" +"そのため、``[0x1for x in y]`` のような紛らわしく曖昧な式も書けます (``[0x1 " +"for x in y]`` とも ``[0x1f or x in y]`` とも解釈できます)。\n" +"数値リテラルの直後に :keyword:`and`、:keyword:`else`、:keyword:`for`、:" +"keyword:`if`、:keyword:`in`、:keyword:`is`、:keyword:`or` のいずれかが続く場" +"合は、構文上の警告が発生します。\n" +"将来のリリースでは構文エラーになります。\n" +"(:gh:`87999`)" #: ../../deprecations/pending-removal-in-future.rst:29 msgid "" @@ -77,107 +83,119 @@ msgid "" "of :class:`int`." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:32 msgid "" "Support for ``__float__()`` method returning a strict subclass of :class:" "`float`: these methods will be required to return an instance of :class:" "`float`." msgstr "" +"``__float__()`` メソッドが :class:`float` の厳密なサブクラスのインスタンスを" +"返すことへの対応:今後は :class:`float` 自体のインスタンスを返すことが必須に" +"なります。" -#: ../../deprecations/pending-removal-in-future.rst:35 msgid "" "Support for ``__complex__()`` method returning a strict subclass of :class:" "`complex`: these methods will be required to return an instance of :class:" "`complex`." msgstr "" +"``__complex__()`` メソッドが :class:`complex` の厳密なサブクラスのインスタン" +"スを返すことへの対応:今後は :class:`complex` 自体のインスタンスを返すことが" +"必須になります。" -#: ../../deprecations/pending-removal-in-future.rst:38 msgid "" "Passing a complex number as the *real* or *imag* argument in the :func:" "`complex` constructor is now deprecated; it should only be passed as a " "single positional argument. (Contributed by Serhiy Storchaka in :gh:" "`109218`.)" msgstr "" +":func:`complex` コンストラクターの ``real`` 引数や ``imag`` 引数に複素数を渡" +"すことは非推奨になりました。\n" +"複素数は単独の位置引数としてのみ渡してください。\n" +"(Serhiy Storchaka が :gh:`109218` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:43 msgid "" ":mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants " "are deprecated and replaced by :data:`calendar.JANUARY` and :data:`calendar." "FEBRUARY`. (Contributed by Prince Roshan in :gh:`103636`.)" msgstr "" +":mod:`calendar`:定数 ``calendar.January`` と ``calendar.February`` は非推奨" +"となり、:data:`calendar.JANUARY` と :data:`calendar.FEBRUARY` に置き換えられ" +"ました。\n" +"(Prince Roshan が :gh:`103636` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:48 msgid "" ":mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:" "`133038`)" msgstr "" +":mod:`codecs`::func:`codecs.open` の代わりに :func:`open` を使ってくださ" +"い。\n" +"(:gh:`133038`)" -#: ../../deprecations/pending-removal-in-future.rst:50 msgid "" ":attr:`!codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method " "instead." msgstr "" +":attr:`!codeobject.co_lnotab`:代わりに :meth:`codeobject.co_lines` メソッド" +"を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:53 msgid ":mod:`datetime`:" -msgstr "" +msgstr ":mod:`datetime`:" -#: ../../deprecations/pending-removal-in-future.rst:55 msgid "" ":meth:`~datetime.datetime.utcnow`: use ``datetime.datetime.now(tz=datetime." "UTC)``." msgstr "" +":meth:`~datetime.datetime.utcnow`:``datetime.datetime.now(tz=datetime." +"UTC)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:57 msgid "" ":meth:`~datetime.datetime.utcfromtimestamp`: use ``datetime.datetime." "fromtimestamp(timestamp, tz=datetime.UTC)``." msgstr "" +":meth:`~datetime.datetime.utcfromtimestamp`:``datetime.datetime." +"fromtimestamp(timestamp, tz=datetime.UTC)`` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:60 msgid ":mod:`gettext`: Plural value must be an integer." -msgstr "" +msgstr ":mod:`gettext`:複数形を選択するための値は整数でなければなりません。" -#: ../../deprecations/pending-removal-in-future.rst:62 msgid ":mod:`importlib`:" -msgstr "" +msgstr ":mod:`importlib`:" -#: ../../deprecations/pending-removal-in-future.rst:64 msgid "" ":func:`~importlib.util.cache_from_source` *debug_override* parameter is " "deprecated: use the *optimization* parameter instead." msgstr "" +":func:`~importlib.util.cache_from_source` の ``debug_override`` パラメータは" +"非推奨です。\n" +"代わりに ``optimization`` パラメータを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:67 msgid ":mod:`importlib.metadata`:" -msgstr "" +msgstr ":mod:`importlib.metadata`:" -#: ../../deprecations/pending-removal-in-future.rst:69 msgid "``EntryPoints`` tuple interface." -msgstr "" +msgstr "``EntryPoints`` のタプルインターフェース。" -#: ../../deprecations/pending-removal-in-future.rst:70 msgid "Implicit ``None`` on return values." -msgstr "" +msgstr "戻り値として暗黙的に ``None`` を返すこと。" -#: ../../deprecations/pending-removal-in-future.rst:72 msgid "" ":mod:`logging`: the ``warn()`` method has been deprecated since Python 3.3, " "use :meth:`~logging.warning` instead." msgstr "" +":mod:`logging`:``warn()`` メソッドは Python 3.3 から非推奨です。\n" +"代わりに :meth:`~logging.warning` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:75 msgid "" ":mod:`mailbox`: Use of StringIO input and text mode is deprecated, use " "BytesIO and binary mode instead." msgstr "" +":mod:`mailbox`:StringIO による入力とテキストモードの使用は非推奨です。\n" +"代わりに BytesIO とバイナリモードを使ってください。" #: ../../deprecations/pending-removal-in-future.rst:78 msgid "" ":mod:`os`: Calling :func:`os.register_at_fork` in a multi-threaded process." msgstr "" -#: ../../deprecations/pending-removal-in-future.rst:80 msgid "" ":mod:`os.path`: :func:`os.path.commonprefix` is deprecated, use :func:`os." "path.commonpath` for path prefixes. The :func:`os.path.commonprefix` " @@ -186,14 +204,24 @@ msgid "" "module about path manipulation, meaning it is easy to accidentally introduce " "path traversal vulnerabilities into Python programs by using this function." msgstr "" +":mod:`os.path`::func:`os.path.commonprefix` は非推奨です。\n" +"パスの共通の先頭部分を求めるには :func:`os.path.commonpath` を使ってくださ" +"い。\n" +":func:`os.path.commonprefix` は、名前と所属するモジュールが誤解を招くため非推" +"奨になります。\n" +"この関数はパス操作用のモジュールに含まれていますが、パスの先頭部分を扱う用途" +"では安全に使えません。\n" +"そのため、この関数を使うと Python プログラムにパストラバーサルの脆弱性を誤っ" +"て持ち込みやすくなります。" -#: ../../deprecations/pending-removal-in-future.rst:88 msgid "" ":class:`!pydoc.ErrorDuringImport`: A tuple value for *exc_info* parameter is " "deprecated, use an exception instance." msgstr "" +":class:`!pydoc.ErrorDuringImport`:``exc_info`` パラメータにタプルを渡すこと" +"は非推奨です。\n" +"例外インスタンスを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:91 msgid "" ":mod:`re`: More strict rules are now applied for numerical group references " "and group names in regular expressions. Only sequence of ASCII digits is " @@ -201,185 +229,190 @@ msgid "" "replacement strings can now only contain ASCII letters and digits and " "underscore. (Contributed by Serhiy Storchaka in :gh:`91760`.)" msgstr "" +":mod:`re`:正規表現内の番号によるグループ参照とグループ名に、より厳しい規則が" +"適用されるようになりました。\n" +"番号による参照には ASCII の数字の並びだけを使えます。\n" +"bytes パターンと置換文字列のグループ名には、ASCII の英字、数字、アンダースコ" +"アだけを使えます。\n" +"(Serhiy Storchaka が :gh:`91760` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:98 msgid "" ":mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in " "Python 3.12; use the *onexc* parameter instead." msgstr "" +":mod:`shutil`::func:`~shutil.rmtree` の ``onerror`` パラメータは Python " +"3.12 で非推奨になりました。\n" +"代わりに ``onexc`` パラメータを使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:101 msgid ":mod:`ssl` options and protocols:" -msgstr "" +msgstr ":mod:`ssl` のオプションとプロトコル:" -#: ../../deprecations/pending-removal-in-future.rst:103 msgid ":class:`ssl.SSLContext` without protocol argument is deprecated." msgstr "" +"プロトコル引数を指定せずに :class:`ssl.SSLContext` を作成することは非推奨で" +"す。" -#: ../../deprecations/pending-removal-in-future.rst:104 msgid "" ":class:`ssl.SSLContext`: :meth:`~ssl.SSLContext.set_npn_protocols` and :meth:" "`!selected_npn_protocol` are deprecated: use ALPN instead." msgstr "" +":class:`ssl.SSLContext`::meth:`~ssl.SSLContext.set_npn_protocols` と :meth:" +"`!selected_npn_protocol` は非推奨です。\n" +"代わりに ALPN を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:107 msgid "``ssl.OP_NO_SSL*`` options" -msgstr "" +msgstr "``ssl.OP_NO_SSL*`` オプション" -#: ../../deprecations/pending-removal-in-future.rst:108 msgid "``ssl.OP_NO_TLS*`` options" -msgstr "" +msgstr "``ssl.OP_NO_TLS*`` オプション" -#: ../../deprecations/pending-removal-in-future.rst:109 msgid "``ssl.PROTOCOL_SSLv3``" -msgstr "" +msgstr "``ssl.PROTOCOL_SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:110 msgid "``ssl.PROTOCOL_TLS``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLS``" -#: ../../deprecations/pending-removal-in-future.rst:111 msgid "``ssl.PROTOCOL_TLSv1``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:112 msgid "``ssl.PROTOCOL_TLSv1_1``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:113 msgid "``ssl.PROTOCOL_TLSv1_2``" -msgstr "" +msgstr "``ssl.PROTOCOL_TLSv1_2``" -#: ../../deprecations/pending-removal-in-future.rst:114 msgid "``ssl.TLSVersion.SSLv3``" -msgstr "" +msgstr "``ssl.TLSVersion.SSLv3``" -#: ../../deprecations/pending-removal-in-future.rst:115 msgid "``ssl.TLSVersion.TLSv1``" -msgstr "" +msgstr "``ssl.TLSVersion.TLSv1``" -#: ../../deprecations/pending-removal-in-future.rst:116 msgid "``ssl.TLSVersion.TLSv1_1``" -msgstr "" +msgstr "``ssl.TLSVersion.TLSv1_1``" -#: ../../deprecations/pending-removal-in-future.rst:118 msgid ":mod:`threading` methods:" -msgstr "" +msgstr ":mod:`threading` のメソッド:" -#: ../../deprecations/pending-removal-in-future.rst:120 msgid "" ":meth:`!threading.Condition.notifyAll`: use :meth:`~threading.Condition." "notify_all`." msgstr "" +":meth:`!threading.Condition.notifyAll`::meth:`~threading.Condition." +"notify_all` を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:121 msgid ":meth:`!threading.Event.isSet`: use :meth:`~threading.Event.is_set`." msgstr "" +":meth:`!threading.Event.isSet`::meth:`~threading.Event.is_set` を使ってくだ" +"さい。" -#: ../../deprecations/pending-removal-in-future.rst:122 msgid "" ":meth:`!threading.Thread.isDaemon`, :meth:`threading.Thread.setDaemon`: use :" "attr:`threading.Thread.daemon` attribute." msgstr "" +":meth:`!threading.Thread.isDaemon`、:meth:`threading.Thread.setDaemon`::" +"attr:`threading.Thread.daemon` 属性を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:124 msgid "" ":meth:`!threading.Thread.getName`, :meth:`threading.Thread.setName`: use :" "attr:`threading.Thread.name` attribute." msgstr "" +":meth:`!threading.Thread.getName`、:meth:`threading.Thread.setName`::attr:" +"`threading.Thread.name` 属性を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:126 msgid ":meth:`!threading.currentThread`: use :meth:`threading.current_thread`." msgstr "" +":meth:`!threading.currentThread`::meth:`threading.current_thread` を使ってく" +"ださい。" -#: ../../deprecations/pending-removal-in-future.rst:127 msgid ":meth:`!threading.activeCount`: use :meth:`threading.active_count`." msgstr "" +":meth:`!threading.activeCount`::meth:`threading.active_count` を使ってくださ" +"い。" -#: ../../deprecations/pending-removal-in-future.rst:129 msgid ":class:`typing.Text` (:gh:`92332`)." -msgstr "" +msgstr ":class:`typing.Text` (:gh:`92332`)." -#: ../../deprecations/pending-removal-in-future.rst:131 msgid "" "The internal class ``typing._UnionGenericAlias`` is no longer used to " "implement :class:`typing.Union`. To preserve compatibility with users using " "this private class, a compatibility shim will be provided until at least " "Python 3.17. (Contributed by Jelle Zijlstra in :gh:`105499`.)" msgstr "" +"内部クラス ``typing._UnionGenericAlias`` は、:class:`typing.Union` の実装には" +"使われなくなりました。\n" +"この非公開クラスを使っているユーザーとの互換性を保つため、少なくとも Python " +"3.17 までは互換性を維持するための実装が提供されます。\n" +"(Jelle Zijlstra が :gh:`105499` で貢献しました。)" -#: ../../deprecations/pending-removal-in-future.rst:136 msgid "" ":class:`unittest.IsolatedAsyncioTestCase`: it is deprecated to return a " "value that is not ``None`` from a test case." msgstr "" +":class:`unittest.IsolatedAsyncioTestCase`:テストケースから ``None`` 以外の値" +"を返すことは非推奨です。" -#: ../../deprecations/pending-removal-in-future.rst:139 msgid "" ":mod:`urllib.parse` deprecated functions: :func:`~urllib.parse.urlparse` " "instead" msgstr "" +":mod:`urllib.parse` の非推奨の関数:代わりに :func:`~urllib.parse.urlparse` " +"を使ってください。" -#: ../../deprecations/pending-removal-in-future.rst:141 msgid "``splitattr()``" -msgstr "" +msgstr "``splitattr()``" -#: ../../deprecations/pending-removal-in-future.rst:142 msgid "``splithost()``" -msgstr "" +msgstr "``splithost()``" -#: ../../deprecations/pending-removal-in-future.rst:143 msgid "``splitnport()``" -msgstr "" +msgstr "``splitnport()``" -#: ../../deprecations/pending-removal-in-future.rst:144 msgid "``splitpasswd()``" -msgstr "" +msgstr "``splitpasswd()``" -#: ../../deprecations/pending-removal-in-future.rst:145 msgid "``splitport()``" -msgstr "" +msgstr "``splitport()``" -#: ../../deprecations/pending-removal-in-future.rst:146 msgid "``splitquery()``" -msgstr "" +msgstr "``splitquery()``" -#: ../../deprecations/pending-removal-in-future.rst:147 msgid "``splittag()``" -msgstr "" +msgstr "``splittag()``" -#: ../../deprecations/pending-removal-in-future.rst:148 msgid "``splittype()``" -msgstr "" +msgstr "``splittype()``" -#: ../../deprecations/pending-removal-in-future.rst:149 msgid "``splituser()``" -msgstr "" +msgstr "``splituser()``" -#: ../../deprecations/pending-removal-in-future.rst:150 msgid "``splitvalue()``" -msgstr "" +msgstr "``splitvalue()``" -#: ../../deprecations/pending-removal-in-future.rst:151 msgid "``to_bytes()``" -msgstr "" +msgstr "``to_bytes()``" -#: ../../deprecations/pending-removal-in-future.rst:153 msgid "" ":mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial " "writes." msgstr "" +":mod:`wsgiref`:``SimpleHandler.stdout.write()`` は、渡されたデータの一部だけ" +"を書き込んで終了してはいけません。" -#: ../../deprecations/pending-removal-in-future.rst:156 msgid "" ":mod:`xml.etree.ElementTree`: Testing the truth value of an :class:`~xml." "etree.ElementTree.Element` is deprecated. In a future release it will always " "return ``True``. Prefer explicit ``len(elem)`` or ``elem is not None`` tests " "instead." msgstr "" +":mod:`xml.etree.ElementTree`::class:`~xml.etree.ElementTree.Element` の真偽" +"値を調べることは非推奨です。\n" +"将来のリリースでは、常に ``True`` を返すようになります。\n" +"代わりに ``len(elem)`` や ``elem is not None`` を使って明示的に判定してくださ" +"い。" -#: ../../deprecations/pending-removal-in-future.rst:161 msgid "" ":func:`sys._clear_type_cache` is deprecated: use :func:`sys." "_clear_internal_caches` instead." msgstr "" +":func:`sys._clear_type_cache` は非推奨です。\n" +"代わりに :func:`sys._clear_internal_caches` を使ってください。" diff --git a/distributing/index.po b/distributing/index.po index eb264883b..63737da7b 100644 --- a/distributing/index.po +++ b/distributing/index.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../distributing/index.rst:10 diff --git a/distutils/builtdist.po b/distutils/builtdist.po index ca6e6b188..fb6b267d1 100644 --- a/distutils/builtdist.po +++ b/distutils/builtdist.po @@ -566,12 +566,8 @@ msgstr "Packager" msgid "``packager``" msgstr "``packager``" -#: ../../distutils/builtdist.rst:223 ../../distutils/builtdist.rst:225 -#: ../../distutils/builtdist.rst:227 ../../distutils/builtdist.rst:229 -#: ../../distutils/builtdist.rst:231 ../../distutils/builtdist.rst:233 -#: ../../distutils/builtdist.rst:235 ../../distutils/builtdist.rst:237 msgid "(none)" -msgstr "(none)" +msgstr "(なし)" #: ../../distutils/builtdist.rst:225 msgid "Provides" diff --git a/extending/building.po b/extending/building.po index 9ed75d764..a8e3e8e13 100644 --- a/extending/building.po +++ b/extending/building.po @@ -17,25 +17,25 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/building.rst:7 msgid "Building C and C++ Extensions" msgstr "C および C++ 拡張のビルド" -#: ../../extending/building.rst:9 msgid "" "A C extension for CPython is a shared library (for example, a ``.so`` file " "on Linux, ``.pyd`` on Windows), which exports an *initialization function*." msgstr "" +"CPython の C 拡張は、*初期化関数* をエクスポートする共有ライブラリです (例え" +"ば、Linux では ``.so`` ファイル、Windows では ``.pyd`` ファイル)。" -#: ../../extending/building.rst:12 msgid "See :ref:`extension-modules` for details." -msgstr "" +msgstr "詳しくは :ref:`extension-modules` を参照してください。" #: ../../extending/building.rst:21 msgid "Building C and C++ Extensions with setuptools" @@ -53,8 +53,9 @@ msgstr "" "あり、ドキュメントは https://setuptools.pypa.io/en/latest/setuptools.html に" "あります。" -#: ../../extending/building.rst:29 msgid "" "The :mod:`distutils` module, which was included in the standard library " "until Python 3.12, is now maintained as part of Setuptools." msgstr "" +"Python 3.12 より前は標準ライブラリに含まれていた :mod:`distutils` モジュール" +"は、現在は Setuptools の一部として保守されています。" diff --git a/extending/embedding.po b/extending/embedding.po index ee945b8eb..54bf099f0 100644 --- a/extending/embedding.po +++ b/extending/embedding.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/embedding.rst:8 @@ -122,7 +122,6 @@ msgstr "" "トを実行するためのものです。例えばこれは、一つのファイル上で何らかの操作を実" "現するのに利用できます。 ::" -#: ../../extending/embedding.rst:56 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -159,6 +158,40 @@ msgid "" " Py_ExitStatusException(status);\n" "}" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyStatus status;\n" +" PyConfig config;\n" +" PyConfig_InitPythonConfig(&config);\n" +"\n" +" /* 省略可能だが推奨 */\n" +" status = PyConfig_SetBytesString(&config, &config.program_name, " +"argv[0]);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +"\n" +" status = Py_InitializeFromConfig(&config);\n" +" if (PyStatus_Exception(status)) {\n" +" goto exception;\n" +" }\n" +" PyConfig_Clear(&config);\n" +"\n" +" PyRun_SimpleString(\"from time import time,ctime\\n\"\n" +" \"print('Today is', ctime(time()))\\n\");\n" +" if (Py_FinalizeEx() < 0) {\n" +" exit(120);\n" +" }\n" +" return 0;\n" +"\n" +" exception:\n" +" PyConfig_Clear(&config);\n" +" Py_ExitStatusException(status);\n" +"}" #: ../../extending/embedding.rst:92 msgid "" @@ -296,7 +329,6 @@ msgstr "" "Python スクリプト内で定義されている関数を実行するためのコードは以下のようにな" "ります:" -#: ../../extending/embedding.rst:162 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -371,6 +403,78 @@ msgid "" " return 0;\n" "}\n" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"int\n" +"main(int argc, char *argv[])\n" +"{\n" +" PyObject *pName, *pModule, *pFunc;\n" +" PyObject *pArgs, *pValue;\n" +" int i;\n" +"\n" +" if (argc < 3) {\n" +" fprintf(stderr,\"Usage: call pythonfile funcname [args]\\n\");\n" +" return 1;\n" +" }\n" +"\n" +" Py_Initialize();\n" +" pName = PyUnicode_DecodeFSDefault(argv[1]);\n" +" /* pName のエラーチェックは省略 */\n" +"\n" +" pModule = PyImport_Import(pName);\n" +" Py_DECREF(pName);\n" +"\n" +" if (pModule != NULL) {\n" +" pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" +" /* pFunc は新しい参照 */\n" +"\n" +" if (pFunc && PyCallable_Check(pFunc)) {\n" +" pArgs = PyTuple_New(argc - 3);\n" +" for (i = 0; i < argc - 3; ++i) {\n" +" pValue = PyLong_FromLong(atoi(argv[i + 3]));\n" +" if (!pValue) {\n" +" Py_DECREF(pArgs);\n" +" Py_DECREF(pModule);\n" +" fprintf(stderr, \"Cannot convert argument\\n\");\n" +" return 1;\n" +" }\n" +" /* ここで pValue の参照が盗まれる: */\n" +" PyTuple_SetItem(pArgs, i, pValue);\n" +" }\n" +" pValue = PyObject_CallObject(pFunc, pArgs);\n" +" Py_DECREF(pArgs);\n" +" if (pValue != NULL) {\n" +" printf(\"Result of call: %ld\\n\", PyLong_AsLong(pValue));\n" +" Py_DECREF(pValue);\n" +" }\n" +" else {\n" +" Py_DECREF(pFunc);\n" +" Py_DECREF(pModule);\n" +" PyErr_Print();\n" +" fprintf(stderr,\"Call failed\\n\");\n" +" return 1;\n" +" }\n" +" }\n" +" else {\n" +" if (PyErr_Occurred())\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Cannot find function \\\"%s\\\"\\n\", " +"argv[2]);\n" +" }\n" +" Py_XDECREF(pFunc);\n" +" Py_DECREF(pModule);\n" +" }\n" +" else {\n" +" PyErr_Print();\n" +" fprintf(stderr, \"Failed to load \\\"%s\\\"\\n\", argv[1]);\n" +" return 1;\n" +" }\n" +" if (Py_FinalizeEx() < 0) {\n" +" return 120;\n" +" }\n" +" return 0;\n" +"}\n" #: ../../extending/embedding.rst:165 msgid "" @@ -386,7 +490,6 @@ msgstr "" "(できた実行可能形式を :program:`call` と呼びましょう)、以下のような Python ス" "クリプトを実行することにします:" -#: ../../extending/embedding.rst:171 msgid "" "def multiply(a,b):\n" " print(\"Will compute\", a, \"times\", b)\n" @@ -395,45 +498,57 @@ msgid "" " c = c + b\n" " return c" msgstr "" +"def multiply(a,b):\n" +" print(\"Will compute\", a, \"times\", b)\n" +" c = 0\n" +" for i in range(0, a):\n" +" c = c + b\n" +" return c" #: ../../extending/embedding.rst:180 msgid "then the result should be:" msgstr "実行結果は以下のようになるはずです:" -#: ../../extending/embedding.rst:182 msgid "" "$ call multiply multiply 3 2\n" "Will compute 3 times 2\n" "Result of call: 6" msgstr "" +"$ call multiply multiply 3 2\n" +"Will compute 3 times 2\n" +"Result of call: 6" -#: ../../extending/embedding.rst:188 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 " "interesting part with respect to embedding Python starts with ::" msgstr "" -"この程度の機能を実現するにはプログラムがいささか大きすぎますが、ほとんどは " -"Python から C へのデータ変換やエラー報告のためのコードです。Python の埋め込み" -"という観点から最も興味深い部分は以下のコードから始まる部分です::" +"機能の割に大きなプログラムですが、コードの大部分は Python と C の間のデータ変" +"換と、エラーの報告のためのものです。\n" +"Python の埋め込みという観点から重要なのは、次の箇所から始まる処理です。 ::" -#: ../../extending/embedding.rst:192 msgid "" "Py_Initialize();\n" "pName = PyUnicode_DecodeFSDefault(argv[1]);\n" "/* Error checking of pName left out */\n" "pModule = PyImport_Import(pName);" msgstr "" +"Py_Initialize();\n" +"pName = PyUnicode_DecodeFSDefault(argv[1]);\n" +"/* pName のエラーチェックは省略 */\n" +"pModule = PyImport_Import(pName);" -#: ../../extending/embedding.rst:197 msgid "" "After initializing the interpreter, the script is loaded using :c:func:" "`PyImport_Import`. This routine needs a Python string as its argument, " "which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data " "conversion routine. ::" msgstr "" +"インタープリタを初期化した後、:c:func:`PyImport_Import` でスクリプトをロード" +"します。\n" +"この関数には Python の文字列を引数として渡す必要があるため、データ変換関数 :" +"c:func:`PyUnicode_DecodeFSDefault` で作成します。 ::" -#: ../../extending/embedding.rst:202 msgid "" "pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" "/* pFunc is a new reference */\n" @@ -443,6 +558,13 @@ msgid "" "}\n" "Py_XDECREF(pFunc);" msgstr "" +"pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" +"/* pFunc は新しい参照 */\n" +"\n" +"if (pFunc && PyCallable_Check(pFunc)) {\n" +" ...\n" +"}\n" +"Py_XDECREF(pFunc);" #: ../../extending/embedding.rst:210 msgid "" @@ -458,9 +580,8 @@ msgstr "" "支えないでしょう。そこでプログラムは定石どおりに引数のタプル構築に進みます。" "その後、Python 関数を以下のコードで呼び出します::" -#: ../../extending/embedding.rst:216 msgid "pValue = PyObject_CallObject(pFunc, pArgs);" -msgstr "" +msgstr "pValue = PyObject_CallObject(pFunc, pArgs);" #: ../../extending/embedding.rst:218 msgid "" @@ -497,7 +618,6 @@ msgstr "" "クセスできるようにするグルー(glue, 糊) コードを書くと考えてください。例えば以" "下のようにです::" -#: ../../extending/embedding.rst:237 msgid "" "static int numargs=0;\n" "\n" @@ -529,6 +649,35 @@ msgid "" " return PyModuleDef_Init(&emb_module);\n" "}" msgstr "" +"static int numargs=0;\n" +"\n" +"/* アプリケーションのコマンドライン引数の数を返す */\n" +"static PyObject*\n" +"emb_numargs(PyObject *self, PyObject *args)\n" +"{\n" +" if(!PyArg_ParseTuple(args, \":numargs\"))\n" +" return NULL;\n" +" return PyLong_FromLong(numargs);\n" +"}\n" +"\n" +"static PyMethodDef emb_module_methods[] = {\n" +" {\"numargs\", emb_numargs, METH_VARARGS,\n" +" \"プロセスが受け取った引数の数を返します。\"},\n" +" {NULL, NULL, 0, NULL}\n" +"};\n" +"\n" +"static struct PyModuleDef emb_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"emb\",\n" +" .m_size = 0,\n" +" .m_methods = emb_module_methods,\n" +"};\n" +"\n" +"static PyObject*\n" +"PyInit_emb(void)\n" +"{\n" +" return PyModuleDef_Init(&emb_module);\n" +"}" #: ../../extending/embedding.rst:267 msgid "" @@ -538,24 +687,28 @@ msgstr "" "上のコードを :c:func:`main` 関数のすぐ上に挿入します。また、以下の二つの文" "を :c:func:`Py_Initialize` の呼び出しの前に挿入します::" -#: ../../extending/embedding.rst:270 msgid "" "numargs = argc;\n" "PyImport_AppendInittab(\"emb\", &PyInit_emb);" msgstr "" +"numargs = argc;\n" +"PyImport_AppendInittab(\"emb\", &PyInit_emb);" -#: ../../extending/embedding.rst:273 msgid "" "These two lines initialize the ``numargs`` variable, and make the :func:`!" "emb.numargs` function accessible to the embedded Python interpreter. With " "these extensions, the Python script can do things like" msgstr "" +"この 2 行は、``numargs`` 変数を初期化し、埋め込まれた Python インタープリタか" +"ら :func:`!emb.numargs` 関数を利用できるようにします。\n" +"この拡張によって、Python スクリプトで次のような処理ができます。" -#: ../../extending/embedding.rst:277 msgid "" "import emb\n" "print(\"Number of arguments\", emb.numargs())" msgstr "" +"import emb\n" +"print(\"Number of arguments\", emb.numargs())" #: ../../extending/embedding.rst:282 msgid "" @@ -586,17 +739,16 @@ msgstr "" msgid "Compiling and Linking under Unix-like systems" msgstr "Unix 系システムにおけるコンパイルとリンク" -#: ../../extending/embedding.rst:305 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 " "application, particularly because Python needs to load library modules " "implemented as C dynamic extensions (:file:`.so` files) linked against it." msgstr "" -"Python インタプリタをアプリケーションに埋め込むためにコンパイラ (とリンカ) に" -"渡すべき正しいフラグを見出すのは簡単でないかもしれません。これは特に、Python " -"がライブラリモジュールに対してリンクされた C 動的拡張 (:file:`.so` ファイル) " -"として実装されたものをロードする必要があるためです。" +"Python インタープリタをアプリケーションに組み込むために、コンパイラとリンカー" +"に渡す適切なフラグを見つけるのは、必ずしも簡単ではありません。\n" +"特に、Python にリンクされた C の動的拡張 (:file:`.so` ファイル) として実装さ" +"れたライブラリモジュールを、Python がロードする必要があるためです。" #: ../../extending/embedding.rst:311 msgid "" @@ -618,12 +770,14 @@ msgid "" msgstr "" "``pythonX.Y-config --cflags`` は推奨のコンパイルオプションを出力します:" -#: ../../extending/embedding.rst:320 msgid "" "$ /opt/bin/python3.11-config --cflags\n" "-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " "-g -fwrapv -O3 -Wall" msgstr "" +"$ /opt/bin/python3.11-config --cflags\n" +"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " +"-g -fwrapv -O3 -Wall" #: ../../extending/embedding.rst:325 msgid "" @@ -632,12 +786,14 @@ msgid "" msgstr "" "``pythonX.Y-config --ldflags --embed`` は推奨のリンクオプションを出力します:" -#: ../../extending/embedding.rst:328 msgid "" "$ /opt/bin/python3.11-config --ldflags --embed\n" "-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" "lpthread -ldl -lutil -lm" msgstr "" +"$ /opt/bin/python3.11-config --ldflags --embed\n" +"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" +"lpthread -ldl -lutil -lm" #: ../../extending/embedding.rst:334 msgid "" @@ -650,7 +806,6 @@ msgstr "" "た Python)での混乱を避けるために、上での例のように :file:`python{X.Y}-" "config` は絶対パスで起動したほうが良いです。" -#: ../../extending/embedding.rst:339 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 ` は歓迎です)、あなたのシステムのダイナミックリンクについてのドキュメン" -"トを読み、Python の :file:`Makefile` のコンパイルオプションを調べる必要がある" -"でしょう(Makefile の場所を調べるには :func:`sysconfig.get_makefile_filename` " -"を使ってください)。この場合、 :mod:`sysconfig` モジュールが役に立つ道具になり" -"ます。これによってあなたが付け加えたいコンパイル・リンクのオプション構成をプ" -"ログラム的に抽出できます。例えば:" +"この手順でうまくいかない場合は、システムの動的リンクに関するドキュメントを読" +"むか、Python の :file:`Makefile` とコンパイルオプションを調べる、あるいはその" +"両方を行う必要があります。\n" +"すべての Unix 系プラットフォームで動作する保証はありませんが、:ref:`バグ報告 " +"` は歓迎します。\n" +"Makefile の場所は :func:`sysconfig.get_makefile_filename` で調べられます。\n" +"この場合、:mod:`sysconfig` モジュールを使うと、組み合わせたい設定値をプログラ" +"ムで抽出できて便利です。\n" +"例えば、次のように使います。" -#: ../../extending/embedding.rst:348 msgid "" ">>> import sysconfig\n" ">>> sysconfig.get_config_var('LIBS')\n" @@ -678,3 +833,8 @@ msgid "" ">>> sysconfig.get_config_var('LINKFORSHARED')\n" "'-Xlinker -export-dynamic'" msgstr "" +">>> import sysconfig\n" +">>> sysconfig.get_config_var('LIBS')\n" +"'-lpthread -ldl -lutil'\n" +">>> sysconfig.get_config_var('LINKFORSHARED')\n" +"'-Xlinker -export-dynamic'" diff --git a/extending/extending.po b/extending/extending.po index eba104d94..ee531e103 100644 --- a/extending/extending.po +++ b/extending/extending.po @@ -16,23 +16,24 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../extending/extending.rst:8 msgid "Using the C API: Assorted topics" -msgstr "" +msgstr "C API の使用: その他の話題" -#: ../../extending/extending.rst:10 msgid "" "The :ref:`tutorial ` walked you through creating a C " "API extension module, but left many areas unexplained. This document looks " "at several concepts that you'll need to learn in order to write more complex " "extensions." msgstr "" +":ref:`チュートリアル ` では C API 拡張モジュールの作" +"り方を説明しましたが、まだ説明していない領域が数多くあります。\n" +"この文書では、より複雑な拡張を書くために必要な概念をいくつか取り上げます。" #: ../../extending/extending.rst:19 msgid "Errors and Exceptions" @@ -101,7 +102,6 @@ msgstr "" "を判別できるはずなので、 :c:func:`PyErr_Occurred` を呼び出す必要はありませ" "ん。" -#: ../../extending/extending.rst:51 msgid "" "When a function *f* that calls another function *g* detects that the latter " "fails, *f* should itself return an error value (usually ``NULL`` or " @@ -113,17 +113,18 @@ msgid "" "interpreter's main loop, this aborts the currently executing Python code and " "tries to find an exception handler specified by the Python programmer." msgstr "" -"関数 *g* を呼び出す *f* が、前者の関数の呼び出しに失敗したことを検出すると、 " -"*f* 自体はエラー値 (大抵は ``NULL`` や ``-1``) を返さねばなりません。しか" -"し、 ``PyErr_*`` 関数群のいずれかを呼び出す必要は *ありません* --- なぜな" -"ら、 *g* がすでに呼び出しているからです。次いで *f* を呼び出したコードもエ" -"ラーを示す値を *自らを呼び出したコード* に返すことになりますが、同様に " -"``PyErr_*`` は *呼び出しません* 。以下同様に続きます --- エラーの最も詳しい原" -"因は、最初にエラーを検出した関数がすでに報告しているからです。エラーが " -"Python インタプリタのメインループに到達すると、現在実行中の Python コードは一" -"時停止し、 Python プログラマが指定した例外ハンドラを探し出そうとします。" +"別の関数 *g* を呼び出した関数 *f* が、その呼び出しの失敗を検出した場合、*f* " +"自身もエラー値 (通常は ``NULL`` または ``-1``) を返す必要があります。\n" +"このとき ``PyErr_*`` 関数を呼び出しては *いけません*。\n" +"*g* がすでに呼び出しているからです。\n" +"次に *f* の呼び出し元も、``PyErr_*`` を *呼び出さずに*、*その呼び出し元* へエ" +"ラーを示す値を返します。\n" +"以下同様に続きます。\n" +"エラーの最も詳しい原因は、最初にエラーを検出した関数がすでに報告していま" +"す。\n" +"エラーが Python インタープリタのメインループに到達すると、実行中の Python " +"コードの処理を中断し、Python プログラマーが指定した例外ハンドラーを探します。" -#: ../../extending/extending.rst:61 msgid "" "(There are situations where a module can actually give a more detailed error " "message by calling another ``PyErr_*`` function, and in such cases it is " @@ -131,11 +132,11 @@ msgid "" "cause information about the cause of the error to be lost: most operations " "can fail for a variety of reasons.)" msgstr "" -"(モジュールが ``PyErr_*`` 関数をもう一度呼び出して、より詳細なエラーメッセー" -"ジを提供するような状況があります。このような状況ではそうすべきです。とはい" -"え、一般的な規則としては、この関数を何度も呼び出す必要はなく、ともすればエ" -"ラーの原因に関する情報を失う結果になりがちです: これにより、ほとんどの操作が" -"様々な理由から失敗するかもしれません)" +"(別の ``PyErr_*`` 関数を呼び出すことで、モジュールがより詳しいエラーメッセー" +"ジを提供できる場合は、そうしても構いません。\n" +"ただし、一般には不要であり、エラーの原因に関する情報が失われるおそれがありま" +"す。\n" +"ほとんどの操作は様々な理由で失敗し得るためです。)" #: ../../extending/extending.rst:67 msgid "" @@ -162,20 +163,19 @@ msgstr "" ":c:func:`malloc` の呼び出し失敗は、常に例外にしなくてはなりません --- :c:" "func:`malloc` (または :c:func:`realloc`) を直接呼び出しているコードは、 :c:" "func:`PyErr_NoMemory` を呼び出して、失敗を示す値を返さねばなりません。オブ" -"ジェクトを生成する全ての関数 (例えば :c:func:`PyLong_FromLong`) は :c:func:" -"`PyErr_NoMemory` の呼び出しを済ませてしまうので、この規則が関係するのは直接 :" -"c:func:`malloc` を呼び出すコードだけです。" +"ジェクトを生成する全ての関数 (例えば :c:func:`PyLong_FromLong`) は " +"``PyErr_NoMemory()`` の呼び出しを済ませてしまうので、この規則が関係するのは直" +"接 :c:func:`malloc` を呼び出すコードだけです。" -#: ../../extending/extending.rst:79 msgid "" "Also note that, with the important exception of :c:func:`PyArg_ParseTuple` " "and friends, functions that return an integer status usually return a " "positive value or zero for success and ``-1`` for failure, like Unix system " "calls." msgstr "" -"また、 :c:func:`PyArg_ParseTuple` という重要な例外を除いて、整数の状態コード" -"を返す関数はたいてい、Unix のシステムコールと同じく、処理が成功した際にはゼロ" -"または正の値を返し、失敗した場合には ``-1`` を返します。" +"また、:c:func:`PyArg_ParseTuple` などの重要な例外を除き、整数の状態コードを返" +"す関数は通常、Unix のシステムコールと同じく、成功時に正の値またはゼロを返し、" +"失敗時に ``-1`` を返します。" #: ../../extending/extending.rst:83 msgid "" @@ -187,7 +187,6 @@ msgstr "" "ブジェクトに対して :c:func:`Py_XDECREF` や :c:func:`Py_DECREF` を呼び出して) " "ごみ処理を注意深く行ってください!" -#: ../../extending/extending.rst:87 msgid "" "The choice of which exception to raise is entirely yours. There are " "predeclared C objects corresponding to all built-in Python exceptions, such " @@ -199,42 +198,55 @@ msgid "" "you have an argument whose value must be in a particular range or must " "satisfy other conditions, :c:data:`PyExc_ValueError` is appropriate." msgstr "" +"どの例外を送出するかは自由に選べます。\n" +":c:data:`PyExc_ZeroDivisionError` など、Python のすべての組み込み例外に対応す" +"る C オブジェクトが宣言済みで、そのまま利用できます。\n" +"もちろん、例外は適切に選ぶ必要があります。\n" +"例えば、ファイルを開けなかったことを示すために :c:data:`PyExc_TypeError` を使" +"うべきではありません (おそらく :c:data:`PyExc_OSError` が適切です)。\n" +"引数リストに問題がある場合、:c:func:`PyArg_ParseTuple` 関数は通常 :c:data:" +"`PyExc_TypeError` を送出します。\n" +"引数の値が特定の範囲内でなければならない場合や、その他の条件を満たす必要があ" +"る場合は、:c:data:`PyExc_ValueError` が適切です。" -#: ../../extending/extending.rst:97 msgid "" "You can also define a new exception that is unique to your module. The " "simplest way to do this is to declare a static global object variable at the " "beginning of the file::" msgstr "" +"モジュール独自の新しい例外を定義することもできます。\n" +"最も簡単な方法は、ファイルの先頭で静的なグローバルオブジェクト変数を宣言する" +"ことです。 ::" -#: ../../extending/extending.rst:101 msgid "static PyObject *SpamError = NULL;" -msgstr "" +msgstr "static PyObject *SpamError = NULL;" -#: ../../extending/extending.rst:103 msgid "" "and initialize it by calling :c:func:`PyErr_NewException` in the module's :c:" "data:`Py_mod_exec` function (:c:func:`!spam_module_exec`)::" msgstr "" +"そして、モジュールの :c:data:`Py_mod_exec` 関数 (:c:func:`!" +"spam_module_exec`) で :c:func:`PyErr_NewException` を呼び出して初期化しま" +"す。 ::" -#: ../../extending/extending.rst:106 msgid "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" -msgstr "" +msgstr "SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);" -#: ../../extending/extending.rst:108 msgid "" "Since :c:data:`!SpamError` is a global variable, it will be overwritten " "every time the module is reinitialized, when the :c:data:`Py_mod_exec` " "function is called." msgstr "" +":c:data:`!SpamError` はグローバル変数なので、モジュールが再初期化されて :c:" +"data:`Py_mod_exec` 関数が呼び出されるたびに上書きされます。" -#: ../../extending/extending.rst:111 msgid "" "For now, let's avoid the issue: we will block repeated initialization by " "raising an :py:exc:`ImportError`::" msgstr "" +"ひとまず、この問題は回避しましょう。\n" +":py:exc:`ImportError` を送出して、初期化が繰り返されるのを防ぎます。 ::" -#: ../../extending/extending.rst:114 msgid "" "static PyObject *SpamError = NULL;\n" "\n" @@ -272,16 +284,54 @@ msgid "" " return PyModuleDef_Init(&spam_module);\n" "}" msgstr "" +"static PyObject *SpamError = NULL;\n" +"\n" +"static int\n" +"spam_module_exec(PyObject *m)\n" +"{\n" +" if (SpamError != NULL) {\n" +" PyErr_SetString(PyExc_ImportError,\n" +" \"cannot initialize spam module more than once\");\n" +" return -1;\n" +" }\n" +" SpamError = PyErr_NewException(\"spam.error\", NULL, NULL);\n" +" if (PyModule_AddObjectRef(m, \"SpamError\", SpamError) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot spam_module_slots[] = {\n" +" {Py_mod_exec, spam_module_exec},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static struct PyModuleDef spam_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"spam\",\n" +" .m_size = 0, // 非負の値\n" +" .m_slots = spam_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_spam(void)\n" +"{\n" +" return PyModuleDef_Init(&spam_module);\n" +"}" -#: ../../extending/extending.rst:150 msgid "" "Note that the Python name for the exception object is :exc:`!spam.error`. " "The :c:func:`PyErr_NewException` function may create a class with the base " "class being :exc:`Exception` (unless another class is passed in instead of " "``NULL``), described in :ref:`bltin-exceptions`." msgstr "" +"例外オブジェクトの Python での名前は :exc:`!spam.error` であることに注意して" +"ください。\n" +":c:func:`PyErr_NewException` 関数は、``NULL`` の代わりに別のクラスを渡さなけ" +"れば、:ref:`bltin-exceptions` で説明する :exc:`Exception` を基底クラスとする" +"クラスを作成できます。" -#: ../../extending/extending.rst:155 msgid "" "Note also that the :c:data:`!SpamError` variable retains a reference to the " "newly created exception class; this is intentional! Since the exception " @@ -291,14 +341,26 @@ msgid "" "pointer, C code which raises the exception could cause a core dump or other " "unintended side effects." msgstr "" +":c:data:`!SpamError` 変数が新しく作成した例外クラスへの参照を保持している点に" +"も注意してください。\n" +"これは意図的なものです。\n" +"外部のコードがモジュールから例外を削除する可能性があるため、クラスへの参照を" +"所有しておく必要があります。\n" +"そうすることで、クラスが破棄されて :c:data:`!SpamError` がダングリングポイン" +"ターになるのを防ぎます。\n" +"ダングリングポインターになると、その例外を送出する C コードがコアダンプなどの" +"意図しない副作用を引き起こすおそれがあります。" -#: ../../extending/extending.rst:162 msgid "" "For now, the :c:func:`Py_DECREF` call to remove this reference is missing. " "Even when the Python interpreter shuts down, the global :c:data:`!SpamError` " "variable will not be garbage-collected. It will \"leak\". We did, however, " "ensure that this will happen at most once per process." msgstr "" +"現時点では、この参照を解放する :c:func:`Py_DECREF` 呼び出しがありません。\n" +"Python インタープリタが終了しても、グローバル変数 :c:data:`!SpamError` はガ" +"ベージコレクションの対象にならず、「リーク」します。\n" +"ただし、これが起こるのはプロセスあたり最大 1 回となるようにしてあります。" #: ../../extending/extending.rst:167 msgid "" @@ -306,13 +368,13 @@ msgid "" "later in this sample." msgstr "" -#: ../../extending/extending.rst:170 msgid "" "The :exc:`!spam.error` exception can be raised in your extension module " "using a call to :c:func:`PyErr_SetString` as shown below::" msgstr "" +"次のように :c:func:`PyErr_SetString` を呼び出すと、拡張モジュールから :exc:`!" +"spam.error` 例外を送出できます。 ::" -#: ../../extending/extending.rst:173 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -330,12 +392,25 @@ msgid "" " return PyLong_FromLong(sts);\n" "}" msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *args)\n" +"{\n" +" const char *command;\n" +" int sts;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;\n" +" sts = system(command);\n" +" if (sts < 0) {\n" +" PyErr_SetString(SpamError, \"System command failed\");\n" +" return NULL;\n" +" }\n" +" return PyLong_FromLong(sts);\n" +"}" -#: ../../extending/extending.rst:193 msgid "Embedding an extension" -msgstr "" +msgstr "拡張モジュールの組み込み" -#: ../../extending/extending.rst:195 msgid "" "If you want to make your module a permanent part of the Python interpreter, " "you will have to change the configuration setup and rebuild the " @@ -343,10 +418,14 @@ msgid "" "the :file:`Modules/` directory of an unpacked source distribution, add a " "line to the file :file:`Modules/Setup.local` describing your file:" msgstr "" +"モジュールを Python インタープリタの恒久的な構成要素にするには、設定を変更し" +"てインタープリタを再ビルドする必要があります。\n" +"Unix では、ソース配布物を展開した :file:`Modules/` ディレクトリにファイル (例" +"えば :file:`spammodule.c`) を置き、:file:`Modules/Setup.local` にそのファイル" +"を記述する行を追加します。" -#: ../../extending/extending.rst:202 msgid "spam spammodule.o" -msgstr "" +msgstr "spam spammodule.o" #: ../../extending/extending.rst:206 msgid "" @@ -370,15 +449,13 @@ msgstr "" "モジュールが別のライブラリとリンクされている必要がある場合、ライブラリも設定" "ファイルに列挙できます。例えば以下のようにします。" -#: ../../extending/extending.rst:215 msgid "spam spammodule.o -lX11" -msgstr "" +msgstr "spam spammodule.o -lX11" #: ../../extending/extending.rst:223 msgid "Calling Python Functions from C" msgstr "C から Python 関数を呼び出す" -#: ../../extending/extending.rst:225 msgid "" "The tutorial concentrated on making C functions callable from Python. The " "reverse is also useful: calling Python functions from C. This is especially " @@ -388,14 +465,27 @@ msgid "" "will require calling the Python callback functions from a C callback. Other " "uses are also imaginable." msgstr "" +"チュートリアルでは、Python から C 関数を呼び出せるようにする方法に注目しまし" +"た。\n" +"その逆、つまり C から Python 関数を呼び出すことも有用です。\n" +"特に、いわゆる「コールバック」関数をサポートするライブラリでは役立ちます。\n" +"C のインターフェースがコールバックを利用する場合、それに対応する Python のイ" +"ンターフェースでも、Python プログラマーにコールバックの仕組みを提供する必要が" +"あることがよくあります。\n" +"その実装には、C のコールバックから Python のコールバック関数を呼び出す処理が" +"必要です。\n" +"ほかの用途も考えられます。" -#: ../../extending/extending.rst:233 msgid "" "Fortunately, the Python interpreter is easily called recursively, and there " "is a standard interface to call a Python function. (If you're interested in " "how to call the Python parser with a particular string as input, see :ref:" "`veryhigh`.)" msgstr "" +"幸い、Python インタープリタは簡単に再帰的に呼び出せますし、Python 関数を呼び" +"出すための標準インターフェースがあります。\n" +"(特定の文字列を入力として Python のパーサーを呼び出す方法については、:ref:" +"`veryhigh` を参照してください。)" #: ../../extending/extending.rst:237 msgid "" @@ -415,7 +505,6 @@ msgstr "" "`Py_INCREF` するようよく注意してください!)。例えば、以下のような関数がモ" "ジュールの一部になっていることでしょう::" -#: ../../extending/extending.rst:244 msgid "" "static PyObject *my_callback = NULL;\n" "\n" @@ -441,14 +530,41 @@ msgid "" " return result;\n" "}" msgstr "" +"static PyObject *my_callback = NULL;\n" +"\n" +"static PyObject *\n" +"my_set_callback(PyObject *dummy, PyObject *args)\n" +"{\n" +" PyObject *result = NULL;\n" +" PyObject *temp;\n" +"\n" +" if (PyArg_ParseTuple(args, \"O:set_callback\", &temp)) {\n" +" if (!PyCallable_Check(temp)) {\n" +" PyErr_SetString(PyExc_TypeError, \"parameter must be " +"callable\");\n" +" return NULL;\n" +" }\n" +" Py_XINCREF(temp); /* 新しいコールバックへの参照を追加する " +"*/\n" +" Py_XDECREF(my_callback); /* 以前のコールバックを解放する */\n" +" my_callback = temp; /* 新しいコールバックを保存する */\n" +" /* \"None\" を返すための定型処理 */\n" +" Py_INCREF(Py_None);\n" +" result = Py_None;\n" +" }\n" +" return result;\n" +"}" -#: ../../extending/extending.rst:267 msgid "" "This function must be registered with the interpreter using the :c:macro:" "`METH_VARARGS` flag in :c:type:`PyMethodDef.ml_flags`. The :c:func:" "`PyArg_ParseTuple` function and its arguments are documented in section :ref:" "`parsetuple`." msgstr "" +"この関数は、:c:type:`PyMethodDef.ml_flags` に :c:macro:`METH_VARARGS` フラグ" +"を指定してインタープリタに登録する必要があります。\n" +":c:func:`PyArg_ParseTuple` 関数とその引数については :ref:`parsetuple` で説明" +"しています。" #: ../../extending/extending.rst:272 msgid "" @@ -484,7 +600,6 @@ msgstr "" "化コードが入った丸括弧がある場合、この関数はタプルを返します。以下に例を示し" "ます::" -#: ../../extending/extending.rst:288 msgid "" "int arg;\n" "PyObject *arglist;\n" @@ -497,6 +612,16 @@ msgid "" "result = PyObject_CallObject(my_callback, arglist);\n" "Py_DECREF(arglist);" msgstr "" +"int arg;\n" +"PyObject *arglist;\n" +"PyObject *result;\n" +"...\n" +"arg = 123;\n" +"...\n" +"/* コールバックを呼び出す */\n" +"arglist = Py_BuildValue(\"(i)\", arg);\n" +"result = PyObject_CallObject(my_callback, arglist);\n" +"Py_DECREF(arglist);" #: ../../extending/extending.rst:299 msgid "" @@ -512,7 +637,6 @@ msgstr "" "タプルを生成して引数リストとして提供しており、このタプルは :c:func:" "`PyObject_CallObject` の呼び出し直後に :c:func:`Py_DECREF` されています。" -#: ../../extending/extending.rst:306 msgid "" "The return value of :c:func:`PyObject_CallObject` is \"new\": either it is a " "brand new object, or it is an existing object whose reference count has been " @@ -520,13 +644,13 @@ msgid "" "should somehow :c:func:`Py_DECREF` the result, even (especially!) if you are " "not interested in its value." msgstr "" -":c:func:`PyObject_CallObject` は戻り値として \"新しい\" オブジェクト: 新規に" -"作成されたオブジェクトか、既存のオブジェクトの参照カウントをインクリメントし" -"たものを返します。従って、このオブジェクトをグローバル変数に保存したいのでな" -"いかぎり、たとえこの戻り値に興味がなくても (むしろ、そうであればなおさら!) 何" -"がしかの方法で戻り値オブジェクトを :c:func:`Py_DECREF` しなければなりません。" +":c:func:`PyObject_CallObject` の戻り値は「新しい参照」です。\n" +"新しく作成したオブジェクトか、参照カウントを増やした既存のオブジェクトを指し" +"ます。\n" +"そのため、グローバル変数に保存するのでなければ、結果に対してどこかで :c:func:" +"`Py_DECREF` を呼び出す必要があります。\n" +"戻り値を使わない場合も (特にそのような場合こそ) 必要です。" -#: ../../extending/extending.rst:312 msgid "" "Before you do this, however, it is important to check that the return value " "isn't ``NULL``. If it is, the Python function terminated by raising an " @@ -536,25 +660,27 @@ msgid "" "handle the exception. If this is not possible or desirable, the exception " "should be cleared by calling :c:func:`PyErr_Clear`. For example::" msgstr "" -"とはいえ、戻り値を :c:func:`Py_DECREF` する前には、値が ``NULL`` でないか" -"チェックしておくことが重要です。もし ``NULL`` なら、呼び出した Python 関数は" -"例外を送出して終了させられています。 :c:func:`PyObject_CallObject` を呼び出し" -"ているコード自体もまた Python から呼び出されているのであれば、今度は C コード" -"が自分を呼び出している Python コードにエラー標示値を返さねばなりません。それ" -"により、インタプリタはスタックトレースを出力したり、例外を処理するための " -"Python コードを呼び出したりできます。例外の送出が不可能だったり、したくないの" -"なら、 :c:func:`PyErr_Clear` を呼んで例外を消去しておかねばなりません。例えば" -"以下のようにします::" +"ただし、その前に戻り値が ``NULL`` でないことを確認する必要があります。\n" +"``NULL`` なら、Python 関数は例外を送出して終了しています。\n" +":c:func:`PyObject_CallObject` を呼び出した C コード自体が Python から呼び出さ" +"れている場合は、Python の呼び出し元にエラーを示す値を返す必要があります。\n" +"これにより、インタープリタがスタックトレースを表示したり、呼び出し元の " +"Python コードが例外を処理したりできます。\n" +"そうすることが不可能、または望ましくない場合は、:c:func:`PyErr_Clear` を呼び" +"出して例外を消去する必要があります。\n" +"例えば、次のようにします。 ::" -#: ../../extending/extending.rst:320 msgid "" "if (result == NULL)\n" " return NULL; /* Pass error back */\n" "...use result...\n" "Py_DECREF(result);" msgstr "" +"if (result == NULL)\n" +" return NULL; /* 呼び出し元にエラーを返す */\n" +"...use result...\n" +"Py_DECREF(result);" -#: ../../extending/extending.rst:325 msgid "" "Depending on the desired interface to the Python callback function, you may " "also have to provide an argument list to :c:func:`PyObject_CallObject`. In " @@ -565,15 +691,16 @@ msgid "" "simplest way to do this is to call :c:func:`Py_BuildValue`. For example, if " "you want to pass an integral event code, you might use the following code::" msgstr "" -"Python コールバック関数をどんなインターフェースにしたいかによっては、引数リス" -"トを :c:func:`PyObject_CallObject` に与えなければならない場合もあります。ある" -"ケースでは、コールバック関数を指定したのと同じインターフェースを介して、引数" -"リストも渡されているかもしれません。また別のケースでは、新しいタプルを構築し" -"て引数リストを渡さねばならないかもしれません。この場合最も簡単なのは :c:func:" -"`Py_BuildValue` を呼ぶやり方です。例えば、整数のイベントコードを渡したけれ" -"ば、以下のようなコードを使うことになるでしょう::" +"Python のコールバック関数にどのようなインターフェースを用意するかによって" +"は、:c:func:`PyObject_CallObject` に引数リストを渡す必要もあります。\n" +"コールバック関数を指定するインターフェースを通じて、Python プログラムが引数リ" +"ストも渡す場合があります。\n" +"その場合は、関数オブジェクトと同じ方法で保存して使えます。\n" +"一方、引数リストとして渡す新しいタプルを構築しなければならない場合もありま" +"す。\n" +"最も簡単な方法は :c:func:`Py_BuildValue` を呼び出すことです。\n" +"例えば、整数のイベントコードを渡すには、次のように書けます。 ::" -#: ../../extending/extending.rst:334 msgid "" "PyObject *arglist;\n" "...\n" @@ -585,6 +712,15 @@ msgid "" "/* Here maybe use the result */\n" "Py_DECREF(result);" msgstr "" +"PyObject *arglist;\n" +"...\n" +"arglist = Py_BuildValue(\"(l)\", eventcode);\n" +"result = PyObject_CallObject(my_callback, arglist);\n" +"Py_DECREF(arglist);\n" +"if (result == NULL)\n" +" return NULL; /* 呼び出し元にエラーを返す */\n" +"/* 必要ならここで結果を使う */\n" +"Py_DECREF(result);" #: ../../extending/extending.rst:344 msgid "" @@ -598,15 +734,14 @@ msgstr "" "c:func:`Py_BuildValue` はメモリ不足におちいるかもしれず、チェックしておくべき" "です。" -#: ../../extending/extending.rst:348 msgid "" "You may also call a function with keyword arguments by using :c:func:" "`PyObject_Call`, which supports arguments and keyword arguments. As in the " "above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::" msgstr "" -"通常の引数とキーワード引数をサポートする :c:func:`PyObject_Call` を使って、" -"キーワード引数を伴う関数呼び出しをすることができます。上の例と同じように、 :" -"c:func:`Py_BuildValue` を作って辞書を作ります。 ::" +"位置引数とキーワード引数をサポートする :c:func:`PyObject_Call` を使うと、キー" +"ワード引数を指定して関数を呼び出すこともできます。\n" +"上の例と同じように、:c:func:`Py_BuildValue` を使って辞書を構築します。 ::" #: ../../extending/extending.rst:352 msgid "" @@ -625,25 +760,28 @@ msgstr "" msgid "Extracting Parameters in Extension Functions" msgstr "拡張モジュール関数でのパラメタ展開" -#: ../../extending/extending.rst:370 msgid "" "The :ref:`tutorial ` uses a \":c:data:`METH_O`\" " "function, which is limited to a single Python argument. If you want more, " "you can use :c:data:`METH_VARARGS` instead. With this flag, the C function " "will receive a :py:class:`tuple` of arguments instead of a single object." msgstr "" +":ref:`チュートリアル ` では「:c:data:`METH_O`」関数を" +"使いましたが、これは Python の引数を 1 個だけ受け取れます。\n" +"より多くの引数が必要なら、代わりに :c:data:`METH_VARARGS` を使えます。\n" +"このフラグを指定すると、C 関数は単一のオブジェクトではなく、引数の :py:class:" +"`tuple` を受け取ります。" -#: ../../extending/extending.rst:376 msgid "" "For unpacking the tuple, CPython provides the :c:func:`PyArg_ParseTuple` " "function, declared as follows::" msgstr "" +"タプルの要素を取り出すために、CPython は次のように宣言された :c:func:" +"`PyArg_ParseTuple` 関数を提供しています。 ::" -#: ../../extending/extending.rst:379 msgid "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" -msgstr "" +msgstr "int PyArg_ParseTuple(PyObject *arg, const char *format, ...);" -#: ../../extending/extending.rst:381 msgid "" "The *arg* argument must be a tuple object containing an argument list passed " "from Python to a C function. The *format* argument must be a format string, " @@ -651,25 +789,30 @@ msgid "" "Reference Manual. The remaining arguments must be addresses of variables " "whose type is determined by the format string." msgstr "" -"引数 *arg* は C 関数から Python に渡される引数リストが入ったタプルオブジェク" -"トでなければなりません。 *format* 引数は書式文字列で、 Python/C API リファレ" -"ンスマニュアルの :ref:`arg-parsing` で解説されている書法に従わねばなりませ" -"ん。残りの引数は、それぞれの変数のアドレスで、書式化文字列から決まる型になっ" -"ていなければなりません。" +"引数 *arg* は、Python から C 関数に渡された引数リストを含むタプルオブジェクト" +"でなければなりません。\n" +"引数 *format* は書式文字列で、その構文は Python/C API リファレンスマニュアル" +"の :ref:`arg-parsing` で説明しています。\n" +"残りの引数には、書式文字列によって型が決まる変数のアドレスを渡す必要がありま" +"す。" -#: ../../extending/extending.rst:387 msgid "" "For example, to receive a single Python :py:class:`str` object and turn it " "into a C buffer, you would use ``\"s\"`` as the format string::" msgstr "" +"例えば、Python の :py:class:`str` オブジェクトを 1 個受け取って C のバッ" +"ファーに変換するには、書式文字列に ``\"s\"`` を指定します。 ::" -#: ../../extending/extending.rst:390 msgid "" "const char *command;\n" "if (!PyArg_ParseTuple(args, \"s\", &command)) {\n" " return NULL;\n" "}" msgstr "" +"const char *command;\n" +"if (!PyArg_ParseTuple(args, \"s\", &command)) {\n" +" return NULL;\n" +"}" #: ../../extending/extending.rst:395 msgid "" @@ -687,10 +830,10 @@ msgid "" "probably crash or at least overwrite random bits in memory. So be careful!" msgstr "" ":c:func:`PyArg_ParseTuple` は Python 側から与えられた引数が必要な型になってい" -"るか調べるのに対し、 :c:func:`PyArg_ParseTuple` は呼び出しの際に渡された C 変" -"数のアドレスが有効な値を持つか調べられないことに注意してください: ここで間違" -"いを犯すと、コードがクラッシュするかもしれませんし、少なくともでたらめなビッ" -"トをメモリに上書きしてしまいます。慎重に!" +"るか調べるのに対し、 ``PyArg_ParseTuple()`` は呼び出しの際に渡された C 変数の" +"アドレスが有効な値を持つか調べられないことに注意してください: ここで間違いを" +"犯すと、コードがクラッシュするかもしれませんし、少なくともでたらめなビットを" +"メモリに上書きしてしまいます。慎重に!" #: ../../extending/extending.rst:405 msgid "" @@ -705,11 +848,9 @@ msgstr "" msgid "Some example calls::" msgstr "以下にいくつかの呼び出し例を示します::" -#: ../../extending/extending.rst:410 ../../extending/extending.rst:1003 msgid "#include " -msgstr "" +msgstr "#include " -#: ../../extending/extending.rst:414 msgid "" "int ok;\n" "int i, j;\n" @@ -720,28 +861,41 @@ msgid "" "ok = PyArg_ParseTuple(args, \"\"); /* No arguments */\n" " /* Python call: f() */" msgstr "" +"int ok;\n" +"int i, j;\n" +"long k, l;\n" +"const char *s;\n" +"Py_ssize_t size;\n" +"\n" +"ok = PyArg_ParseTuple(args, \"\"); /* 引数なし */\n" +" /* Python での呼び出し: f() */" -#: ../../extending/extending.rst:425 msgid "" "ok = PyArg_ParseTuple(args, \"s\", &s); /* A string */\n" " /* Possible Python call: f('whoops!') */" msgstr "" +"ok = PyArg_ParseTuple(args, \"s\", &s); /* 文字列 */\n" +" /* Python での呼び出し例: f('whoops!') */" -#: ../../extending/extending.rst:430 msgid "" "ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* Two longs and a string " "*/\n" " /* Possible Python call: f(1, 2, 'three') */" msgstr "" +"ok = PyArg_ParseTuple(args, \"lls\", &k, &l, &s); /* long 型の値 2 個と文字" +"列 */\n" +" /* Python での呼び出し例: f(1, 2, 'three') */" -#: ../../extending/extending.rst:435 msgid "" "ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" " /* A pair of ints and a string, whose size is also returned */\n" " /* Possible Python call: f((1, 2), 'three') */" msgstr "" +"ok = PyArg_ParseTuple(args, \"(ii)s#\", &i, &j, &s, &size);\n" +" /* int 型の値のペアと文字列。\n" +" 文字列のサイズも取得する */\n" +" /* Python での呼び出し例: f((1, 2), 'three') */" -#: ../../extending/extending.rst:441 msgid "" "{\n" " const char *file;\n" @@ -755,8 +909,18 @@ msgid "" " f('spam', 'wb', 100000) */\n" "}" msgstr "" +"{\n" +" const char *file;\n" +" const char *mode = \"r\";\n" +" int bufsize = 0;\n" +" ok = PyArg_ParseTuple(args, \"s|si\", &file, &mode, &bufsize);\n" +" /* 文字列と、省略可能な別の文字列および整数 */\n" +" /* Python での呼び出し例:\n" +" f('spam')\n" +" f('spam', 'w')\n" +" f('spam', 'wb', 100000) */\n" +"}" -#: ../../extending/extending.rst:455 msgid "" "{\n" " int left, top, right, bottom, h, v;\n" @@ -767,8 +931,15 @@ msgid "" " f(((0, 0), (400, 300)), (10, 10)) */\n" "}" msgstr "" +"{\n" +" int left, top, right, bottom, h, v;\n" +" ok = PyArg_ParseTuple(args, \"((ii)(ii))(ii)\",\n" +" &left, &top, &right, &bottom, &h, &v);\n" +" /* 長方形と点 */\n" +" /* Python での呼び出し例:\n" +" f(((0, 0), (400, 300)), (10, 10)) */\n" +"}" -#: ../../extending/extending.rst:466 msgid "" "{\n" " Py_complex c;\n" @@ -777,25 +948,39 @@ msgid "" " /* Possible Python call: myfunction(1+2j) */\n" "}" msgstr "" +"{\n" +" Py_complex c;\n" +" ok = PyArg_ParseTuple(args, \"D:myfunction\", &c);\n" +" /* 複素数。\n" +" エラー用の関数名も指定する */\n" +" /* Python での呼び出し例: myfunction(1+2j) */\n" +"}" #: ../../extending/extending.rst:477 msgid "Keyword Parameters for Extension Functions" msgstr "拡張モジュール関数のキーワードパラメタ" -#: ../../extending/extending.rst:479 msgid "" "If you also want your function to accept :term:`keyword arguments `, use the :c:data:`METH_KEYWORDS` flag in combination with :c:data:" "`METH_VARARGS`. (:c:data:`!METH_KEYWORDS` can also be used with other flags; " "see its documentation for the allowed combinations.)" msgstr "" +"関数が :term:`キーワード引数 ` も受け取れるようにするに" +"は、:c:data:`METH_VARARGS` と組み合わせて :c:data:`METH_KEYWORDS` フラグを使" +"います。\n" +"(:c:data:`!METH_KEYWORDS` はほかのフラグとも組み合わせられます。\n" +"使用できる組み合わせについては、そのドキュメントを参照してください。)" -#: ../../extending/extending.rst:485 msgid "" "In this case, the C function should accept a third ``PyObject *`` parameter " "which will be a dictionary of keywords. Use :c:func:" "`PyArg_ParseTupleAndKeywords` to parse the arguments to such a function." msgstr "" +"この場合、C 関数はキーワード引数の辞書を受け取るための 3 番目の引数を " +"``PyObject *`` 型で受け取る必要があります。\n" +"このような関数の引数を解析するには :c:func:`PyArg_ParseTupleAndKeywords` を使" +"います。" #: ../../extending/extending.rst:492 msgid "" @@ -803,12 +988,14 @@ msgid "" msgstr "" ":c:func:`PyArg_ParseTupleAndKeywords` は、以下のように宣言されています::" -#: ../../extending/extending.rst:494 msgid "" "int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" " const char *format, char * const " "*kwlist, ...);" msgstr "" +"int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,\n" +" const char *format, char * const " +"*kwlist, ...);" #: ../../extending/extending.rst:497 msgid "" @@ -847,7 +1034,6 @@ msgstr "" "以下にキーワードを使ったモジュール例を示します。これは Geoff Philbrick " "(philbrick@hks.com) によるプログラム例をもとにしています::" -#: ../../extending/extending.rst:516 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -886,6 +1072,41 @@ msgid "" " {NULL, NULL, 0, NULL} /* sentinel */\n" "};" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"static PyObject *\n" +"keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)\n" +"{\n" +" int voltage;\n" +" const char *state = \"a stiff\";\n" +" const char *action = \"voom\";\n" +" const char *type = \"Norwegian Blue\";\n" +"\n" +" static char *kwlist[] = {\"voltage\", \"state\", \"action\", \"type\", " +"NULL};\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, keywds, \"i|sss\", kwlist,\n" +" &voltage, &state, &action, &type))\n" +" return NULL;\n" +"\n" +" printf(\"-- This parrot wouldn't %s if you put %i Volts through it." +"\\n\",\n" +" action, voltage);\n" +" printf(\"-- Lovely plumage, the %s -- It's %s!\\n\", type, state);\n" +"\n" +" Py_RETURN_NONE;\n" +"}\n" +"\n" +"static PyMethodDef keywdarg_methods[] = {\n" +" /* PyCFunction は PyObject* 引数を 2 個だけ受け取るのに対し、\n" +" * keywdarg_parrot() は 3 個受け取るため、関数のキャストが必要。\n" +" */\n" +" {\"parrot\", (PyCFunction)(void(*)(void))keywdarg_parrot, METH_VARARGS | " +"METH_KEYWORDS,\n" +" \"楽しい寸劇を標準出力に表示します。\"},\n" +" {NULL, NULL, 0, NULL} /* 終端 */\n" +"};" #: ../../extending/extending.rst:554 msgid "Building Arbitrary Values" @@ -896,12 +1117,11 @@ msgid "" "This function is the counterpart to :c:func:`PyArg_ParseTuple`. It is " "declared as follows::" msgstr "" -":c:func:`Py_BuildValue` は :c:func:`PyArg_ParseTuple` の対極に位置するもので" -"す。この関数は以下のように定義されています::" +"``Py_BuildValue()`` は :c:func:`PyArg_ParseTuple` の対極に位置するものです。" +"この関数は以下のように定義されています::" -#: ../../extending/extending.rst:559 msgid "PyObject *Py_BuildValue(const char *format, ...);" -msgstr "" +msgstr "PyObject *Py_BuildValue(const char *format, ...);" #: ../../extending/extending.rst:561 msgid "" @@ -910,10 +1130,10 @@ msgid "" "not output) must not be pointers, just values. It returns a new Python " "object, suitable for returning from a C function called from Python." msgstr "" -":c:func:`Py_BuildValue` は、 :c:func:`PyArg_ParseTuple` の認識する一連の書式" -"単位に似た書式単位を認識します。ただし (関数への出力ではなく、入力に使われ" -"る) 引数はポインタではなく、ただの値でなければなりません。 Python から呼び出" -"された C 関数が返す値として適切な、新たな Python オブジェクトを返します。" +"``Py_BuildValue()`` は、 :c:func:`PyArg_ParseTuple` の認識する一連の書式単位" +"に似た書式単位を認識します。ただし (関数への出力ではなく、入力に使われる) 引" +"数はポインタではなく、ただの値でなければなりません。 Python から呼び出された " +"C 関数が返す値として適切な、新たな Python オブジェクトを返します。" #: ../../extending/extending.rst:566 msgid "" @@ -926,14 +1146,14 @@ msgid "" "that format unit. To force it to return a tuple of size 0 or one, " "parenthesize the format string." msgstr "" -":c:func:`PyArg_ParseTuple` とは一つ違う点があります: :c:func:" -"`PyArg_ParseTuple` は第一引数をタプルにする必要があります (Python の引数リス" -"トは内部的には常にタプルとして表現されるからです) が、 :c:func:" -"`Py_BuildValue` はタプルを生成するとは限りません。 :c:func:`Py_BuildValue` は" -"書式文字列中に書式単位が二つかそれ以上入っている場合にのみタプルを構築しま" -"す。書式文字列が空なら、 ``None`` を返します。きっかり一つの書式単位なら、そ" -"の書式単位が記述している何らかのオブジェクトになります。サイズが 0 や 1 のタ" -"プル返させたいのなら、書式文字列を丸括弧で囲います。" +":c:func:`PyArg_ParseTuple` とは一つ違う点があります: ``PyArg_ParseTuple()`` " +"は第一引数をタプルにする必要があります (Python の引数リストは内部的には常にタ" +"プルとして表現されるからです) が、 :c:func:`Py_BuildValue` はタプルを生成する" +"とは限りません。 ``Py_BuildValue()`` は書式文字列中に書式単位が二つかそれ以上" +"入っている場合にのみタプルを構築します。書式文字列が空なら、 ``None`` を返し" +"ます。きっかり一つの書式単位なら、その書式単位が記述している何らかのオブジェ" +"クトになります。サイズが 0 や 1 のタプル返させたいのなら、書式文字列を丸括弧" +"で囲います。" #: ../../extending/extending.rst:574 msgid "" @@ -941,7 +1161,6 @@ msgid "" msgstr "" "以下に例を示します (左に呼び出し例を、右に構築される Python 値を示します):" -#: ../../extending/extending.rst:576 msgid "" "Py_BuildValue(\"\") None\n" "Py_BuildValue(\"i\", 123) 123\n" @@ -961,6 +1180,23 @@ msgid "" "Py_BuildValue(\"((ii)(ii)) (ii)\",\n" " 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" msgstr "" +"Py_BuildValue(\"\") None\n" +"Py_BuildValue(\"i\", 123) 123\n" +"Py_BuildValue(\"iii\", 123, 456, 789) (123, 456, 789)\n" +"Py_BuildValue(\"s\", \"hello\") 'hello'\n" +"Py_BuildValue(\"y\", \"hello\") b'hello'\n" +"Py_BuildValue(\"ss\", \"hello\", \"world\") ('hello', 'world')\n" +"Py_BuildValue(\"s#\", \"hello\", 4) 'hell'\n" +"Py_BuildValue(\"y#\", \"hello\", 4) b'hell'\n" +"Py_BuildValue(\"()\") ()\n" +"Py_BuildValue(\"(i)\", 123) (123,)\n" +"Py_BuildValue(\"(ii)\", 123, 456) (123, 456)\n" +"Py_BuildValue(\"(i,i)\", 123, 456) (123, 456)\n" +"Py_BuildValue(\"[i,i]\", 123, 456) [123, 456]\n" +"Py_BuildValue(\"{s:i,s:i}\",\n" +" \"abc\", 123, \"def\", 456) {'abc': 123, 'def': 456}\n" +"Py_BuildValue(\"((ii)(ii)) (ii)\",\n" +" 1, 2, 3, 4, 5, 6) (((1, 2), (3, 4)), (5, 6))" #: ../../extending/extending.rst:600 msgid "Reference Counts" @@ -979,7 +1215,6 @@ msgstr "" "func:`free` で行います。C++では本質的に同じ意味で演算子 ``new`` や " "``delete`` が使われます。そこで、以下の議論は C の場合に限定して行います。" -#: ../../extending/extending.rst:608 msgid "" "Every block of memory allocated with :c:func:`malloc` should eventually be " "returned to the pool of available memory by exactly one call to :c:func:" @@ -993,6 +1228,17 @@ msgid "" "as referencing uninitialized data --- core dumps, wrong results, mysterious " "crashes." msgstr "" +":c:func:`malloc` で確保したメモリブロックは、最終的に :c:func:`free` をちょう" +"ど 1 回呼び出して、利用可能なメモリのプールに戻す必要があります。\n" +":c:func:`free` を適切なタイミングで呼び出すことが重要です。\n" +":c:func:`free` を呼び出さないままブロックのアドレスを失うと、そのメモリはプロ" +"グラムが終了するまで再利用できません。\n" +"これをメモリリーク (:dfn:`memory leak`) と呼びます。\n" +"一方、:c:func:`free` を呼び出した後もそのブロックを使い続けると、別の :c:" +"func:`malloc` 呼び出しによるブロックの再利用と競合します。\n" +"これを解放済みメモリの使用 (:dfn:`using freed memory`) と呼びます。\n" +"初期化していないデータへの参照と同様に、コアダンプ、誤った結果、不可解なク" +"ラッシュといった悪影響があります。" #: ../../extending/extending.rst:619 msgid "" @@ -1042,7 +1288,6 @@ msgstr "" "ら、オブジェクトへの最後の参照が削除されたことになり、オブジェクトは解放され" "ます。" -#: ../../extending/extending.rst:640 msgid "" "An alternative strategy is called :dfn:`automatic garbage collection`. " "(Sometimes, reference counting is also referred to as a garbage collection " @@ -1057,8 +1302,21 @@ msgid "" "garbage collector will be available for C. Until then, we'll have to live " "with reference counts." msgstr "" +"別の方法として、自動ガベージコレクション (:dfn:`automatic garbage " +"collection`) があります。\n" +"(参照カウント法もガベージコレクションの方法と呼ばれることがあるため、両者を区" +"別するために「自動」と付けています。)\n" +"自動ガベージコレクションの大きな利点は、利用者が :c:func:`free` を明示的に呼" +"び出す必要がないことです。\n" +"(速度やメモリ使用量の改善も利点として挙げられますが、これは確実な事実ではあり" +"ません。)\n" +"欠点は、C には真に移植性のある自動ガベージコレクターがないことです。\n" +"一方、参照カウント法は移植可能な形で実装できます (:c:func:`malloc` と :c:" +"func:`free` が利用できる限りですが、これは C 規格で保証されています)。\n" +"いつかは C でも十分に移植性のある自動ガベージコレクターが使えるようになるかも" +"しれません。\n" +"それまでは参照カウントを使っていく必要があります。" -#: ../../extending/extending.rst:652 msgid "" "While Python uses the traditional reference counting implementation, it also " "offers a cycle detector that works to detect reference cycles. This allows " @@ -1071,15 +1329,16 @@ msgid "" "in a reference cycle, or referenced from the objects in the cycle, even " "though there are no further references to the cycle itself." msgstr "" -"Python では、伝統的な参照カウント法の実装を行っている一方で、参照の循環を検出" -"するために働く循環参照検出機構 (cycle detector) も提供しています。循環参照検" -"出機構のおかげで、直接、間接にかかわらず循環参照の生成を気にせずにアプリケー" -"ションを構築できます; というのも、参照カウント法だけを使ったガベージコレク" -"ション実装にとって循環参照は弱点だからです。循環参照は、(間接参照の場合も含め" -"て) 相互への参照が入ったオブジェクトから形成されるため、循環内のオブジェクト" -"は各々非ゼロの参照カウントを持ちます。典型的な参照カウント法の実装では、たと" -"え循環参照を形成するオブジェクトに対して他に全く参照がないとしても、循環参照" -"内のどのオブジェクトに属するメモリも再利用できません。" +"Python は従来の参照カウント法に加えて、循環参照を検出する仕組みも備えていま" +"す。\n" +"これにより、アプリケーションは直接または間接的な循環参照ができることを心配せ" +"ずに済みます。\n" +"循環参照は、参照カウント法だけで実装したガベージコレクションの弱点です。\n" +"循環参照は、直接または間接的に自分自身への参照を持つオブジェクトからなり、循" +"環内の各オブジェクトの参照カウントはゼロではありません。\n" +"通常の参照カウント法の実装では、循環そのものへの参照がほかになくなっても、循" +"環内のオブジェクトや、そこから参照されるオブジェクトのメモリを回収できませ" +"ん。" #: ../../extending/extending.rst:663 msgid "" @@ -1098,7 +1357,6 @@ msgstr "" msgid "Reference Counting in Python" msgstr "Python における参照カウント法" -#: ../../extending/extending.rst:674 msgid "" "There are two macros, ``Py_INCREF(x)`` and ``Py_DECREF(x)``, which handle " "the incrementing and decrementing of the reference count. :c:func:" @@ -1108,13 +1366,15 @@ msgid "" "this purpose (and others), every object also contains a pointer to its type " "object." msgstr "" -"Python には、参照カウントのインクリメントやデクリメントを処理する二つのマク" -"ロ、 ``Py_INCREF(x)`` と ``Py_DECREF(x)`` があります。 :c:func:`Py_DECREF` " -"は、参照カウントがゼロに到達した際に、オブジェクトのメモリ解放も行います。柔" -"軟性を持たせるために、 :c:func:`free` を直接呼び出しません --- その代わりにオ" -"ブジェクトの型オブジェクト (:dfn:`type object`) を介します。このために (他の" -"目的もありますが)、全てのオブジェクトには自身の型オブジェクトに対するポインタ" -"が入っています。" +"参照カウントを増減するマクロとして、``Py_INCREF(x)`` と ``Py_DECREF(x)`` があ" +"ります。\n" +":c:func:`Py_DECREF` は、カウントがゼロになるとオブジェクトの解放も行いま" +"す。\n" +"柔軟性を持たせるため、:c:func:`free` を直接呼び出すのではなく、オブジェクトの" +"型オブジェクト (:dfn:`type object`) にある関数ポインターを介して呼び出しま" +"す。\n" +"この目的などのために、すべてのオブジェクトは自身の型オブジェクトへのポイン" +"ターも持っています。" #: ../../extending/extending.rst:681 msgid "" @@ -1139,7 +1399,6 @@ msgstr "" "`Py_DECREF` を呼び出す、という三つの方法があります。所有参照を処理し忘れる" "と、メモリリークを引き起こします。" -#: ../../extending/extending.rst:690 msgid "" "It is also possible to :dfn:`borrow` [#borrow]_ a reference to an object. " "The borrower of a reference should not call :c:func:`Py_DECREF`. The " @@ -1148,6 +1407,11 @@ msgid "" "risks using freed memory and should be avoided completely [#dont-check-" "refcount]_." msgstr "" +"オブジェクトへの参照を借用 (:dfn:`borrow`) [#borrow]_ することもできます。\n" +"参照を借用した側は :c:func:`Py_DECREF` を呼び出してはいけません。\n" +"また、借用元の所有者よりも長くオブジェクトを保持してはいけません。\n" +"所有者が参照を手放した後に借用参照を使うと、解放済みメモリを使うおそれがある" +"ため、絶対に避けてください [#dont-check-refcount]_。" #: ../../extending/extending.rst:696 msgid "" @@ -1175,22 +1439,21 @@ msgid "" "properly, as well as the previous owner)." msgstr "" ":c:func:`Py_INCREF` を呼び出すと、借用参照を所有参照に変更できます。この操作" -"は参照の借用元の状態には影響しません --- :c:func:`Py_INCREF` は新たな所有参照" -"を生成し、参照の所有者が担うべき全ての責任を課します (つまり、新たな参照の所" -"有者は、以前の所有者と同様、参照の放棄を適切に行わねばなりません)。" +"は参照の借用元の状態には影響しません --- ``Py_INCREF()`` は新たな所有参照を生" +"成し、参照の所有者が担うべき全ての責任を課します (つまり、新たな参照の所有者" +"は、以前の所有者と同様、参照の放棄を適切に行わねばなりません)。" #: ../../extending/extending.rst:714 msgid "Ownership Rules" msgstr "所有権にまつわる規則" -#: ../../extending/extending.rst:716 msgid "" "Whenever an object reference is passed into or out of a function, it is part " "of the function's interface specification whether ownership is transferred " "with the reference or not." msgstr "" -"オブジェクトへの参照を関数の内外に渡す場合には、オブジェクトの所有権が参照と" -"共に渡されるか否かが常に関数インターフェース仕様の一部となります。" +"オブジェクトへの参照を関数に渡す場合も、関数から返す場合も、その参照の所有権" +"を一緒に移すかどうかは、関数のインターフェース仕様の一部です。" #: ../../extending/extending.rst:720 msgid "" @@ -1209,7 +1472,6 @@ msgstr "" "ます。例えば、 :c:func:`PyLong_FromLong` はよく使う値をキャッシュしており、" "キャッシュされた値への参照を返すことがあります。" -#: ../../extending/extending.rst:728 msgid "" "Many functions that extract objects from other objects also transfer " "ownership with the reference, for instance :c:func:" @@ -1219,13 +1481,13 @@ msgid "" "`PyDict_GetItemString` all return references that you borrow from the tuple, " "list or dictionary." msgstr "" -":c:func:`PyObject_GetAttrString` のように、あるオブジェクトから別のオブジェク" -"トを抽出するような関数もまた、参照とともに所有権を委譲します。こちらの方はや" -"や理解しにくいかもしれません。というのはよく使われるルーチンのいくつかが例外" -"となっているからです: :c:func:`PyTuple_GetItem` 、 :c:func:" -"`PyList_GetItem` 、 :c:func:`PyDict_GetItem` 、および :c:func:" -"`PyDict_GetItemString` は全て、タプル、リスト、または辞書から借用参照を返しま" -"す。" +"ほかのオブジェクトからオブジェクトを取り出す多くの関数も、参照とともに所有権" +"を移します。\n" +"例えば :c:func:`PyObject_GetAttrString` がそうです。\n" +"ただし、こちらはよく使う関数にも例外があり、少し複雑です。\n" +":c:func:`PyTuple_GetItem`、:c:func:`PyList_GetItem`、:c:func:" +"`PyDict_GetItem`、:c:func:`PyDict_GetItemString` はいずれも、タプル、リスト、" +"辞書から借用した参照を返します。" #: ../../extending/extending.rst:735 msgid "" @@ -1303,7 +1565,6 @@ msgstr "" "参照を借りている際に起きる、関係ないオブジェクトに対する :c:func:`Py_DECREF` " "の使用です。例えば::" -#: ../../extending/extending.rst:770 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1314,6 +1575,14 @@ msgid "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" msgstr "" +"void\n" +"bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +"\n" +" PyList_SetItem(list, 1, PyLong_FromLong(0L));\n" +" PyObject_Print(item, stdout, 0); /* 不具合あり! */\n" +"}" #: ../../extending/extending.rst:779 msgid "" @@ -1325,7 +1594,6 @@ msgstr "" "置き換え、最後にさきほど借用した参照を出力しています。何も問題ないように見え" "ますね? でもそうではないのです!" -#: ../../extending/extending.rst:783 msgid "" "Let's follow the control flow into :c:func:`PyList_SetItem`. The list owns " "references to all its items, so when item 1 is replaced, it has to dispose " @@ -1341,8 +1609,23 @@ msgid "" "`442`). This entire sequence happens synchronously within the :c:func:" "`PyList_SetItem` call." msgstr "" +":c:func:`PyList_SetItem` の中での処理を追ってみましょう。\n" +"リストはすべての要素への参照を所有しているため、インデックス 1 の要素を置き換" +"える際には、元の要素への参照を手放す必要があります。\n" +"元の要素がユーザー定義クラスのインスタンスで、そのクラスに :meth:`!__del__` " +"メソッドが定義されているとします。\n" +"このインスタンスの参照カウントが 1 なら、参照を手放すことで :meth:`!__del__` " +"メソッドが呼び出されます。\n" +"内部では、:c:func:`PyList_SetItem` が置き換えた要素に対して :c:func:" +"`Py_DECREF` を呼び出し、その要素に対応する :c:member:`~PyTypeObject." +"tp_dealloc` 関数が呼び出されます。\n" +"解放処理中に :c:member:`~PyTypeObject.tp_dealloc` は :c:member:" +"`~PyTypeObject.tp_finalize` を呼び出します。\n" +"クラスのインスタンスでは、これは :meth:`!__del__` メソッドに対応します (:pep:" +"`442` を参照)。\n" +"この一連の処理はすべて、:c:func:`PyList_SetItem` の呼び出し内で同期的に行われ" +"ます。" -#: ../../extending/extending.rst:797 msgid "" "Since it is written in Python, the :meth:`!__del__` method can execute " "arbitrary Python code. Could it perhaps do something to invalidate the " @@ -1352,6 +1635,15 @@ msgid "" "this was the last reference to that object, it would free the memory " "associated with it, thereby invalidating ``item``." msgstr "" +":meth:`!__del__` メソッドは Python で書かれているため、任意の Python コードを" +"実行できます。\n" +"では、:c:func:`!bug` 内の ``item`` への参照を無効にすることもできるでしょう" +"か。\n" +"もちろんできます。\n" +":c:func:`!bug` に渡されたリストに :meth:`!__del__` メソッドからアクセスできれ" +"ば、``del list[0]`` に相当する文を実行できます。\n" +"これがそのオブジェクトへの最後の参照であれば、オブジェクトのメモリが解放さ" +"れ、``item`` は無効になります。" #: ../../extending/extending.rst:805 msgid "" @@ -1361,7 +1653,6 @@ msgstr "" "問題の原因が分かれば、解決は簡単です。一時的に参照回数を増やせばよいのです。" "正しく動作するバージョンは以下のようになります::" -#: ../../extending/extending.rst:808 msgid "" "void\n" "no_bug(PyObject *list)\n" @@ -1374,15 +1665,27 @@ msgid "" " Py_DECREF(item);\n" "}" msgstr "" +"void\n" +"no_bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +"\n" +" Py_INCREF(item);\n" +" PyList_SetItem(list, 1, PyLong_FromLong(0L));\n" +" PyObject_Print(item, stdout, 0);\n" +" Py_DECREF(item);\n" +"}" -#: ../../extending/extending.rst:819 msgid "" "This is a true story. An older version of Python contained variants of this " "bug and someone spent a considerable amount of time in a C debugger to " "figure out why his :meth:`!__del__` methods would fail..." msgstr "" +"これは実際にあった話です。\n" +"古いバージョンの Python にはこの種の不具合があり、:meth:`!__del__` メソッドが" +"失敗する理由を突き止めるために、C のデバッガーでかなりの時間を費やした人がい" +"ました。" -#: ../../extending/extending.rst:823 msgid "" "The second case of problems with a borrowed reference is a variant involving " "threads. Normally, multiple threads in the Python interpreter can't get in " @@ -1394,8 +1697,17 @@ msgid "" "other threads use the processor while waiting for the I/O to complete. " "Obviously, the following function has the same problem as the previous one::" msgstr "" +"借用参照で問題になる 2 つ目のケースは、スレッドが関わるものです。\n" +"通常、Python のオブジェクト全体を保護する :term:`グローバルロック ` があるため、インタープリタ内の複数のスレッドが互いに干渉す" +"ることはありません。\n" +"しかし、マクロ :c:macro:`Py_BEGIN_ALLOW_THREADS` でこのロックを一時的に解放" +"し、:c:macro:`Py_END_ALLOW_THREADS` で再取得できます。\n" +"これは、ブロックする I/O 呼び出しの前後でよく使われます。\n" +"I/O の完了を待つ間、ほかのスレッドがプロセッサーを使えるようにするためで" +"す。\n" +"明らかに、次の関数にも先ほどと同じ問題があります。 ::" -#: ../../extending/extending.rst:833 msgid "" "void\n" "bug(PyObject *list)\n" @@ -1407,6 +1719,15 @@ msgid "" " PyObject_Print(item, stdout, 0); /* BUG! */\n" "}" msgstr "" +"void\n" +"bug(PyObject *list)\n" +"{\n" +" PyObject *item = PyList_GetItem(list, 0);\n" +" Py_BEGIN_ALLOW_THREADS\n" +" ...some blocking I/O call...\n" +" Py_END_ALLOW_THREADS\n" +" PyObject_Print(item, stdout, 0); /* 不具合あり! */\n" +"}" #: ../../extending/extending.rst:847 msgid "NULL Pointers" @@ -1465,12 +1786,14 @@ msgstr "" "別に ``NULL`` ポインタのチェックをすると冗長なテストになってしまうのです。型" "を調べるマクロには、 ``NULL`` チェックを行う変化形はありません。" -#: ../../extending/extending.rst:871 msgid "" "The C function calling mechanism guarantees that the argument list passed to " "C functions (``args`` in the examples) is never ``NULL`` --- in fact it " "guarantees that it is always a tuple [#old-calling-convention]_." msgstr "" +"C 関数の呼び出しの仕組みにより、C 関数に渡される引数リスト (例の ``args``) は" +"決して ``NULL`` にならず、常にタプルであることが保証されます [#old-calling-" +"convention]_。" #: ../../extending/extending.rst:875 msgid "" @@ -1484,7 +1807,6 @@ msgstr "" msgid "Writing Extensions in C++" msgstr "C++での拡張モジュール作成" -#: ../../extending/extending.rst:888 msgid "" "It is possible to write extension modules in C++. Some restrictions apply. " "If the main program (the Python interpreter) is compiled and linked by the C " @@ -1496,16 +1818,16 @@ msgid "" "`` --- they use this form already if the symbol ``__cplusplus`` is defined " "(all recent C++ compilers define this symbol)." msgstr "" -"C++でも拡張モジュールは作成できます。ただしいくつか制限があります。メインプロ" -"グラム (Python インタプリタ) は C コンパイラでコンパイルされリンクされている" -"ので、グローバル変数や静的オブジェクトをコンストラクタで作成できません。メイ" -"ンプログラムが C++ コンパイラでリンクされているならこれは問題ではありませ" -"ん。 Python インタプリタから呼び出される関数 (特にモジュール初期化関数) は、 " -"``extern \"C\"`` を使って宣言しなければなりません。また、Python ヘッダファイ" -"ルを ``extern \"C\" {...}`` に入れる必要はありません--- シンボル " -"``__cplusplus`` (最近の C++ コンパイラは全てこのシンボルを定義しています) が" -"定義されているときに ``extern \"C\" {...}`` が行われるように、ヘッダファイル" -"内にすでに書かれているからです。" +"C++ でも拡張モジュールを作成できますが、いくつか制限があります。\n" +"メインプログラム (Python インタープリタ) を C コンパイラでコンパイルしてリン" +"クする場合、コンストラクターを持つグローバルオブジェクトや静的オブジェクトは" +"使えません。\n" +"メインプログラムを C++ コンパイラでリンクする場合は問題ありません。\n" +"Python インタープリタから呼び出される関数 (特にモジュール初期化関数) は、" +"``extern \"C\"`` を使って宣言する必要があります。\n" +"Python のヘッダーファイルを ``extern \"C\" {...}`` で囲む必要はありません。\n" +"シンボル ``__cplusplus`` が定義されていれば、ヘッダーファイル自体がこの形式を" +"使います (最近の C++ コンパイラはすべてこのシンボルを定義します)。" #: ../../extending/extending.rst:902 msgid "Providing a C API for an Extension Module" @@ -1529,7 +1851,6 @@ msgstr "" "たなコレクション型も他の拡張モジュールから直接操作できるようにするには一連の " "C 関数を持っていなければなりません。" -#: ../../extending/extending.rst:912 msgid "" "At first sight this seems easy: just write the functions (without declaring " "them ``static``, of course), provide an appropriate header file, and " @@ -1544,20 +1865,22 @@ msgid "" "if symbols are globally visible, the module whose functions one wishes to " "call might not have been loaded yet!" msgstr "" -"一見するとこれは簡単なこと: 単に関数を (もちろん ``static`` などとは宣言せず" -"に) 書いて、適切なヘッダファイルを提供し、C API を書けばよいだけ、に思えま" -"す。そして実際のところ、全ての拡張モジュールが Python インタプリタに常に静的" -"にリンクされている場合にはうまく動作します。ところがモジュールが共有ライブラ" -"リの場合には、一つのモジュールで定義されているシンボルが他のモジュールから不" -"可視なことがあります。可視性の詳細はオペレーティングシステムによります; ある" -"システムは Python インタプリタと全ての拡張モジュール用に単一のグローバルな名" -"前空間を用意しています (例えば Windows)。別のシステムはモジュールのリンク時に" -"取り込まれるシンボルを明示的に指定する必要があります (AIX がその一例です)、ま" -"た別のシステム (ほとんどの Unix) では、違った戦略を選択肢として提供していま" -"す。そして、たとえシンボルがグローバル変数として可視であっても、呼び出したい" -"関数の入ったモジュールがまだロードされていないことだってあります!" - -#: ../../extending/extending.rst:924 +"一見すると簡単そうです。\n" +"関数を書き (もちろん ``static`` は付けずに)、適切なヘッダーファイルを用意し、" +"C API の使い方を文書化すればよさそうです。\n" +"実際、すべての拡張モジュールを常に Python インタープリタに静的にリンクするの" +"であれば、この方法で動作します。\n" +"しかし、モジュールを共有ライブラリとして使う場合、あるモジュールで定義したシ" +"ンボルが別のモジュールから見えるとは限りません。\n" +"可視性の詳細はオペレーティングシステムによって異なります。\n" +"Python インタープリタとすべての拡張モジュールで単一のグローバルな名前空間を使" +"うシステムもあれば (例えば Windows)、\n" +"モジュールのリンク時にインポートするシンボルを明示的に列挙する必要があるシス" +"テム (例えば AIX) や、\n" +"複数の方式から選べるシステム (ほとんどの Unix) もあります。\n" +"そして、シンボルがどこからでも見える場合でも、呼び出したい関数のあるモジュー" +"ルがまだロードされていないかもしれません。" + msgid "" "Portability therefore requires not to make any assumptions about symbol " "visibility. This means that all symbols in extension modules should be " @@ -1566,8 +1889,13 @@ msgid "" "symbols that *should* be accessible from other extension modules must be " "exported in a different way." msgstr "" +"そのため、移植性を確保するにはシンボルの可視性について何も仮定しないことが必" +"要です。\n" +"つまり、ほかの拡張モジュールとの名前の衝突を避けるため、モジュール初期化関数" +"以外のすべてのシンボルを ``static`` として宣言するべきです。\n" +"また、ほかの拡張モジュールからアクセス *できるようにしたい* シンボルは、別の" +"方法で公開する必要があります。" -#: ../../extending/extending.rst:931 msgid "" "Python provides a special mechanism to pass C-level information (pointers) " "from one extension module to another one: Capsules. A Capsule is a Python " @@ -1578,15 +1906,16 @@ msgid "" "module, retrieve the value of this name, and then retrieve the pointer from " "the Capsule." msgstr "" -"Python はある拡張モジュールの C レベルの情報 (ポインタ) を別のモジュールに渡" -"すための特殊な機構: Capsule (カプセル)を提供しています。 Capsule はポインタ " -"(:c:expr:`void \\*`) を記憶する Python のデータ型です。 Capsule は C API を介" -"してのみ生成したりアクセスしたりできますが、他の Python オブジェクトと同じよ" -"うに受け渡しできます。とりわけ、Capsule は拡張モジュールの名前空間内にある名" -"前に代入できます。他の拡張モジュールはこのモジュールを import でき、次に名前" -"を取得し、最後にCapsule へのポインタを取得します。" +"Python は、拡張モジュール間で C レベルの情報 (ポインター) を渡すための特別な" +"仕組みとして Capsule を提供しています。\n" +"Capsule はポインター (:c:expr:`void \\*`) を格納する Python のデータ型で" +"す。\n" +"作成や内容へのアクセスは C API 経由でしかできませんが、ほかの Python オブジェ" +"クトと同様に受け渡せます。\n" +"特に、拡張モジュールの名前空間にある名前に代入できます。\n" +"ほかの拡張モジュールはそのモジュールをインポートし、その名前に対応する値を取" +"得して、Capsule の中からポインターを取り出せます。" -#: ../../extending/extending.rst:939 msgid "" "There are many ways in which Capsules can be used to export the C API of an " "extension module. Each function could get its own Capsule, or all C API " @@ -1595,11 +1924,11 @@ msgid "" "distributed in different ways between the module providing the code and the " "client modules." msgstr "" -"拡張モジュールの C API を公開するために、様々な方法で Capsule が使われます。" -"各関数を1つのオブジェクトに入れたり、全ての C API のポインタ配列を Capsule に" -"入れることができます。そして、ポインタに対する保存や取得といった様々な作業" -"は、コードを提供しているモジュールとクライアントモジュールとの間では異なる方" -"法で分散できます。" +"Capsule を使って拡張モジュールの C API を公開する方法はいくつもあります。\n" +"関数ごとに専用の Capsule を用意してもよいですし、すべての C API ポインターを" +"配列に格納し、その配列のアドレスを Capsule で公開しても構いません。\n" +"ポインターの保存や取得に関わる処理を、コードを提供するモジュールとクライアン" +"トモジュールにどう分担させるかにも、様々な方法があります。" #: ../../extending/extending.rst:945 msgid "" @@ -1625,9 +1954,8 @@ msgstr "" "特に、 C API を公開するための Capsule には次のルールに従った名前を付けるべき" "です::" -#: ../../extending/extending.rst:955 msgid "modulename.attributename" -msgstr "" +msgstr "modulename.attributename" #: ../../extending/extending.rst:957 msgid "" @@ -1659,7 +1987,6 @@ msgstr "" "を提供します; クライアントモジュールは、C API にアクセスする前にこのマクロを" "呼ぶだけです。" -#: ../../extending/extending.rst:970 msgid "" "The exporting module is a modification of the :mod:`!spam` module from the :" "ref:`tutorial `. The function :func:`!spam.system` " @@ -1669,14 +1996,21 @@ msgid "" "function :c:func:`!PySpam_System` is also exported to other extension " "modules." msgstr "" +"API を公開するモジュールは、:ref:`チュートリアル ` " +"の :mod:`!spam` モジュールを変更したものです。\n" +":func:`!spam.system` は C ライブラリの :c:func:`system` を直接呼ばず、:c:" +"func:`!PySpam_System` を呼び出します。\n" +"実際には、この関数はもっと複雑な処理 (例えばすべてのコマンドに \"spam\" を追" +"加するなど) を行うでしょう。\n" +"この :c:func:`!PySpam_System` 関数を、ほかの拡張モジュールにも公開します。" -#: ../../extending/extending.rst:978 msgid "" "The function :c:func:`!PySpam_System` is a plain C function, declared " "``static`` like everything else::" msgstr "" +":c:func:`!PySpam_System` は普通の C 関数で、ほかと同じく ``static`` として宣" +"言します。 ::" -#: ../../extending/extending.rst:981 msgid "" "static int\n" "PySpam_System(const char *command)\n" @@ -1684,12 +2018,15 @@ msgid "" " return system(command);\n" "}" msgstr "" +"static int\n" +"PySpam_System(const char *command)\n" +"{\n" +" return system(command);\n" +"}" -#: ../../extending/extending.rst:987 msgid "The function :c:func:`!spam_system` is modified in a trivial way::" -msgstr "" +msgstr ":c:func:`!spam_system` には、ごく簡単な変更を加えます。 ::" -#: ../../extending/extending.rst:989 msgid "" "static PyObject *\n" "spam_system(PyObject *self, PyObject *args)\n" @@ -1703,6 +2040,17 @@ msgid "" " return PyLong_FromLong(sts);\n" "}" msgstr "" +"static PyObject *\n" +"spam_system(PyObject *self, PyObject *args)\n" +"{\n" +" const char *command;\n" +" int sts;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"s\", &command))\n" +" return NULL;\n" +" sts = PySpam_System(command);\n" +" return PyLong_FromLong(sts);\n" +"}" #: ../../extending/extending.rst:1001 msgid "In the beginning of the module, right after the line ::" @@ -1712,21 +2060,24 @@ msgstr "モジュールの先頭にある以下の行 ::" msgid "two more lines must be added::" msgstr "の直後に、以下の二行を必ず追加してください::" -#: ../../extending/extending.rst:1007 msgid "" "#define SPAM_MODULE\n" "#include \"spammodule.h\"" msgstr "" +"#define SPAM_MODULE\n" +"#include \"spammodule.h\"" -#: ../../extending/extending.rst:1010 msgid "" "The ``#define`` is used to tell the header file that it is being included in " "the exporting module, not a client module. Finally, the module's :c:data:" "`mod_exec ` function must take care of initializing the C API " "pointer array::" msgstr "" +"この ``#define`` は、ヘッダーファイルがクライアントモジュールではなく API を" +"公開するモジュールからインクルードされていることを伝えます。\n" +"最後に、モジュールの :c:data:`mod_exec ` 関数で C API ポインター" +"配列を初期化する必要があります。 ::" -#: ../../extending/extending.rst:1014 msgid "" "static int\n" "spam_module_exec(PyObject *m)\n" @@ -1748,6 +2099,25 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"spam_module_exec(PyObject *m)\n" +"{\n" +" static void *PySpam_API[PySpam_API_pointers];\n" +" PyObject *c_api_object;\n" +"\n" +" /* C API ポインターの配列を初期化する */\n" +" PySpam_API[PySpam_System_NUM] = (void *)PySpam_System;\n" +"\n" +" /* API ポインター配列のアドレスを格納した Capsule を作成する */\n" +" c_api_object = PyCapsule_New((void *)PySpam_API, \"spam._C_API\", " +"NULL);\n" +"\n" +" if (PyModule_Add(m, \"_C_API\", c_api_object) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}" #: ../../extending/extending.rst:1033 msgid "" @@ -1763,7 +2133,6 @@ msgstr "" "からくりの大部分はヘッダファイル :file:`spammodule.h` 内にあり、以下のように" "なっています::" -#: ../../extending/extending.rst:1039 msgid "" "#ifndef Py_SPAMMODULE_H\n" "#define Py_SPAMMODULE_H\n" @@ -1814,6 +2183,54 @@ msgid "" "\n" "#endif /* !defined(Py_SPAMMODULE_H) */" msgstr "" +"#ifndef Py_SPAMMODULE_H\n" +"#define Py_SPAMMODULE_H\n" +"#ifdef __cplusplus\n" +"extern \"C\" {\n" +"#endif\n" +"\n" +"/* spammodule のヘッダーファイル */\n" +"\n" +"/* C API 関数 */\n" +"#define PySpam_System_NUM 0\n" +"#define PySpam_System_RETURN int\n" +"#define PySpam_System_PROTO (const char *command)\n" +"\n" +"/* C API ポインターの総数 */\n" +"#define PySpam_API_pointers 1\n" +"\n" +"\n" +"#ifdef SPAM_MODULE\n" +"/* この部分は spammodule.c のコンパイル時に使う */\n" +"\n" +"static PySpam_System_RETURN PySpam_System PySpam_System_PROTO;\n" +"\n" +"#else\n" +"/* この部分は spammodule の API を使うモジュールで使う */\n" +"\n" +"static void **PySpam_API;\n" +"\n" +"#define PySpam_System \\\n" +" (*(PySpam_System_RETURN (*)PySpam_System_PROTO) " +"PySpam_API[PySpam_System_NUM])\n" +"\n" +"/* エラー時は -1、成功時は 0 を返す。\n" +" * エラーがあれば PyCapsule_Import が例外を設定する。\n" +" */\n" +"static int\n" +"import_spam(void)\n" +"{\n" +" PySpam_API = (void **)PyCapsule_Import(\"spam._C_API\", 0);\n" +" return (PySpam_API != NULL) ? 0 : -1;\n" +"}\n" +"\n" +"#endif\n" +"\n" +"#ifdef __cplusplus\n" +"}\n" +"#endif\n" +"\n" +"#endif /* !defined(Py_SPAMMODULE_H) */" #: ../../extending/extending.rst:1087 msgid "" @@ -1822,7 +2239,6 @@ msgid "" "import_spam` in its :c:data:`mod_exec ` function::" msgstr "" -#: ../../extending/extending.rst:1091 msgid "" "static int\n" "client_module_exec(PyObject *m)\n" @@ -1834,18 +2250,24 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"client_module_exec(PyObject *m)\n" +"{\n" +" if (import_spam() < 0) {\n" +" return -1;\n" +" }\n" +" /* 必要ならここで追加の初期化を行う */\n" +" return 0;\n" +"}" -#: ../../extending/extending.rst:1101 msgid "" "The main disadvantage of this approach is that the file :file:`spammodule.h` " "is rather complicated. However, the basic structure is the same for each " "function that is exported, so it has to be learned only once." msgstr "" -"このアプローチの主要な欠点は、 :file:`spammodule.h` がやや難解になるというこ" -"とです。とはいえ、各関数の基本的な構成は公開されるものと同じなので、書き方を" -"一度だけ学べばすみます。" +"この方法の主な欠点は、:file:`spammodule.h` がやや複雑になることです。\n" +"ただし、公開するどの関数でも基本構造は同じなので、一度覚えれば済みます。" -#: ../../extending/extending.rst:1105 msgid "" "Finally it should be mentioned that Capsules offer additional functionality, " "which is especially useful for memory allocation and deallocation of the " @@ -1854,6 +2276,11 @@ msgid "" "Capsules (files :file:`Include/pycapsule.h` and :file:`Objects/capsule.c` in " "the Python source code distribution)." msgstr "" +"最後に、Capsule には追加の機能もあり、特に格納するポインターに関わるメモリの" +"確保や解放に役立ちます。\n" +"詳細は、Python/C API リファレンスマニュアルの :ref:`capsules` と、Capsule の" +"実装 (Python のソース配布物にある :file:`Include/pycapsule.h` と :file:" +"`Objects/capsule.c`) を参照してください。" #: ../../extending/extending.rst:1113 msgid "Footnotes" @@ -1885,17 +2312,14 @@ msgstr "" "\"旧式の\" 呼び出し規約を使っている場合には、この保証は適用されません --- 既" "存のコードにはいまだに旧式の呼び出し規約が多々あります。" -#: ../../extending/extending.rst:277 msgid "PyObject_CallObject (C function)" -msgstr "" +msgstr "PyObject_CallObject (C 関数)" -#: ../../extending/extending.rst:363 msgid "PyArg_ParseTuple (C function)" -msgstr "" +msgstr "PyArg_ParseTuple (C 関数)" -#: ../../extending/extending.rst:490 msgid "PyArg_ParseTupleAndKeywords (C function)" -msgstr "" +msgstr "PyArg_ParseTupleAndKeywords (C 関数)" #: ../../extending/extending.rst:511 msgid "Philbrick, Geoff" diff --git a/extending/index.po b/extending/index.po index f843dc404..ed76b1f39 100644 --- a/extending/index.po +++ b/extending/index.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/index.rst:5 msgid "Extending and Embedding the Python Interpreter" msgstr "Python インタプリタの拡張と埋め込み" -#: ../../extending/index.rst:7 msgid "" "This document describes how to write modules in C or C++ to extend the " "Python interpreter with new modules. Those modules can do what Python code " @@ -38,8 +37,16 @@ msgid "" "be loaded dynamically (at run time) into the interpreter, if the underlying " "operating system supports this feature." msgstr "" +"このドキュメントでは、C や C++ で新しいモジュールを書いて Python インタープリ" +"タを拡張する方法を説明します。\n" +"これらのモジュールは、関数、オブジェクト型、メソッドの定義など、Python コード" +"でできることに加え、ネイティブライブラリとの連携や、インタープリタのオーバー" +"ヘッドを避けた高速化も行えます。\n" +"また、Python を拡張言語として使うために、別のアプリケーションに Python イン" +"タープリタを組み込む方法も説明します。\n" +"最後に、OS が実行時の動的ロードをサポートしている場合に、インタープリタにロー" +"ドできるよう拡張モジュールをコンパイル・リンクする方法を示します。" -#: ../../extending/index.rst:17 msgid "" "This document assumes basic knowledge about C and Python. For an informal " "introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index` " @@ -48,6 +55,12 @@ msgid "" "documents the modules (both built-in and written in Python) that give the " "language its wide application range." msgstr "" +"このドキュメントは、C と Python の基礎知識を前提としています。\n" +"Python の入門には :ref:`tutorial-index` を参照してください。\n" +":ref:`reference-index` には、より厳密な言語の定義があります。\n" +":ref:`builtins-index` は組み込み関数とオブジェクト型を説明し、:ref:`library-" +"index` は Python の幅広い用途を支えるモジュール (組み込みモジュールと Python " +"で書かれたモジュールの両方) を説明します。" #: ../../extending/index.rst:24 msgid "" @@ -57,13 +70,17 @@ msgstr "" "Python/C API 全体の詳しい説明は、別のドキュメントである、 :ref:`c-api-index` " "を参照してください。" -#: ../../extending/index.rst:27 msgid "" "To support extensions, Python's C API (Application Programmers Interface) " "defines a set of functions, macros and variables that provide access to most " "aspects of the Python run-time system. The Python API is incorporated in a " "C source file by including the header ``\"Python.h\"``." msgstr "" +"Python の C API (Application Programmers Interface) は、拡張をサポートするた" +"め、Python ランタイムのほとんどの機能にアクセスする関数、マクロ、変数を定義し" +"ています。\n" +"C のソースファイルでは、ヘッダー ``\"Python.h\"`` をインクルードすることで " +"Python API を使えます。" #: ../../extending/index.rst:34 msgid "" @@ -90,40 +107,44 @@ msgstr "" msgid "Recommended third party tools" msgstr "おすすめのサードパーティツール" -#: ../../extending/index.rst:61 msgid "" "This document only covers the basic tools for creating extensions provided " "as part of this version of CPython. Some :ref:`third party tools ` offer both simpler and more sophisticated approaches to creating C " "and C++ extensions for Python." msgstr "" +"このドキュメントでは、このバージョンの CPython に付属する、拡張を作成するため" +"の基本的な手段だけを扱います。\n" +"Python 用の C や C++ の拡張を、より簡単かつ高度な方法で作成できる :ref:`サー" +"ドパーティーツール ` もあります。" -#: ../../extending/index.rst:66 msgid "" "While this document is aimed at extension authors, it should also be helpful " "to the authors of such tools. For example, the tutorial module can serve as " "a simple test case for a build tool or sample expected output of a code " "generator." msgstr "" +"拡張の作者を対象としたドキュメントですが、これらのツールの作者にも役立つで" +"しょう。\n" +"例えば、チュートリアルのモジュールは、ビルドツールの単純なテストケースや、" +"コード生成器に期待する出力の例として使えます。" -#: ../../extending/index.rst:73 msgid "C API Tutorial" -msgstr "" +msgstr "C API チュートリアル" -#: ../../extending/index.rst:75 msgid "" "This tutorial describes how to write a simple module in C or C++, using the " "Python C API -- that is, using the basic tools provided as part of this " "version of CPython." msgstr "" +"このチュートリアルでは、Python C API、つまりこのバージョンの CPython に付属す" +"る基本的な手段を使って、C や C++ で単純なモジュールを書く方法を説明します。" -#: ../../extending/index.rst:80 msgid ":ref:`first-extension-module`" -msgstr "" +msgstr ":ref:`first-extension-module`" -#: ../../extending/index.rst:84 msgid "Guides for intermediate topics" -msgstr "" +msgstr "中級トピックのガイド" #: ../../extending/index.rst:86 msgid "" @@ -137,42 +158,35 @@ msgstr "" "これは自分自身の C 拡張を作成するおすすめの方法というよりも、主にそれらのツー" "ルを作成する人向けのものです。" -#: ../../extending/index.rst:91 msgid ":ref:`extending-intro`" -msgstr "" +msgstr ":ref:`extending-intro`" -#: ../../extending/index.rst:92 msgid ":ref:`defining-new-types`" -msgstr "" +msgstr ":ref:`defining-new-types`" -#: ../../extending/index.rst:93 msgid ":ref:`new-types-topics`" -msgstr "" +msgstr ":ref:`new-types-topics`" -#: ../../extending/index.rst:94 msgid ":ref:`building`" -msgstr "" +msgstr ":ref:`building`" -#: ../../extending/index.rst:95 msgid ":ref:`building-on-windows`" -msgstr "" +msgstr ":ref:`building-on-windows`" #: ../../extending/index.rst:98 msgid "Embedding the CPython runtime in a larger application" msgstr "大規模なアプリケーションへの Python ランタイムの埋め込み" -#: ../../extending/index.rst:100 msgid "" "Sometimes, rather than creating an extension that runs inside the Python " "interpreter as the main application, it is desirable to instead embed the " "CPython runtime inside a larger application. This section covers some of the " "details involved in doing that successfully." msgstr "" -"Python インタープリタの中でメインアプリケーションとして実行される拡張を作るの" -"ではなく、 CPython をより大きなアプリケーションの中に埋め込む方が望ましいこと" -"があります。\n" -"この節ではその上手い埋め込みに関わる詳細について説明します。" +"Python インタープリタをメインアプリケーションとして、その中で実行する拡張を作" +"るよりも、大きなアプリケーションの中に CPython ランタイムを組み込む方が望まし" +"い場合があります。\n" +"この節では、そのために必要な詳細の一部を説明します。" -#: ../../extending/index.rst:105 msgid ":ref:`embedding`" -msgstr "" +msgstr ":ref:`embedding`" diff --git a/extending/newtypes.po b/extending/newtypes.po index 356bfc2b1..3f0022a47 100644 --- a/extending/newtypes.po +++ b/extending/newtypes.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Cheesecake, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/newtypes.rst:7 @@ -43,7 +43,6 @@ msgstr "" "以下は :c:type:`PyTypeObject` の定義です。 :ref:`デバッグビルド ` でしか使われないいくつかのメンバは省いてあります:" -#: ../../extending/newtypes.rst:17 msgid "" "typedef struct _typeobject {\n" " PyObject_VAR_HEAD\n" @@ -141,6 +140,101 @@ msgid "" " uint16_t tp_versions_used;\n" "} PyTypeObject;\n" msgstr "" +"typedef struct _typeobject {\n" +" PyObject_VAR_HEAD\n" +" const char *tp_name; /* 表示用。形式は \".\" */\n" +" Py_ssize_t tp_basicsize, tp_itemsize; /* 割り当て用 */\n" +"\n" +" /* 標準の操作を実装するメソッド */\n" +"\n" +" destructor tp_dealloc;\n" +" Py_ssize_t tp_vectorcall_offset;\n" +" getattrfunc tp_getattr;\n" +" setattrfunc tp_setattr;\n" +" PyAsyncMethods *tp_as_async; /* 以前の名前は tp_compare (Python 2)\n" +" または tp_reserved (Python 3) */\n" +" reprfunc tp_repr;\n" +"\n" +" /* 標準クラス用のメソッド群 */\n" +"\n" +" PyNumberMethods *tp_as_number;\n" +" PySequenceMethods *tp_as_sequence;\n" +" PyMappingMethods *tp_as_mapping;\n" +"\n" +" /* その他の標準の操作 (バイナリ互換性のためこの位置に配置) */\n" +"\n" +" hashfunc tp_hash;\n" +" ternaryfunc tp_call;\n" +" reprfunc tp_str;\n" +" getattrofunc tp_getattro;\n" +" setattrofunc tp_setattro;\n" +"\n" +" /* オブジェクトを入出力バッファとして扱う関数 */\n" +" PyBufferProcs *tp_as_buffer;\n" +"\n" +" /* 任意機能や拡張機能の有無を定義するフラグ */\n" +" unsigned long tp_flags;\n" +"\n" +" const char *tp_doc; /* ドキュメント文字列 */\n" +"\n" +" /* リリース 2.0 で意味を割り当て */\n" +" /* アクセス可能な全オブジェクトについて関数を呼び出す */\n" +" traverseproc tp_traverse;\n" +"\n" +" /* 保持するオブジェクトへの参照を削除する */\n" +" inquiry tp_clear;\n" +"\n" +" /* リリース 2.1 で意味を割り当て */\n" +" /* 拡張比較 */\n" +" richcmpfunc tp_richcompare;\n" +"\n" +" /* 弱参照を有効にする */\n" +" Py_ssize_t tp_weaklistoffset;\n" +"\n" +" /* イテレータ */\n" +" getiterfunc tp_iter;\n" +" iternextfunc tp_iternext;\n" +"\n" +" /* 属性デスクリプタとサブクラス化に関するもの */\n" +" PyMethodDef *tp_methods;\n" +" PyMemberDef *tp_members;\n" +" PyGetSetDef *tp_getset;\n" +" // ヒープ型では強参照、静的な型では借用参照\n" +" PyTypeObject *tp_base;\n" +" PyObject *tp_dict;\n" +" descrgetfunc tp_descr_get;\n" +" descrsetfunc tp_descr_set;\n" +" Py_ssize_t tp_dictoffset;\n" +" initproc tp_init;\n" +" allocfunc tp_alloc;\n" +" newfunc tp_new;\n" +" freefunc tp_free; /* 低レベルのメモリ解放ルーチン */\n" +" inquiry tp_is_gc; /* PyObject_IS_GC 用 */\n" +" PyObject *tp_bases;\n" +" PyObject *tp_mro; /* メソッド解決順序 */\n" +" PyObject *tp_cache; /* 現在は未使用 */\n" +" void *tp_subclasses; /* 静的な組み込み型ではインデックス */\n" +" PyObject *tp_weaklist; /* 静的な組み込み型では未使用 */\n" +" destructor tp_del;\n" +"\n" +" /* 型の属性キャッシュのバージョンタグ。バージョン 2.6 で追加。\n" +" * ゼロならキャッシュは無効であり、初期化が必要。\n" +" */\n" +" unsigned int tp_version_tag;\n" +"\n" +" destructor tp_finalize;\n" +" vectorcallfunc tp_vectorcall;\n" +"\n" +" /* この型に関心を持つ型ウォッチャーを表すビット集合 */\n" +" unsigned char tp_watched;\n" +"\n" +" /* 使用された tp_version_tag 値の数。\n" +" * 属性キャッシュがこの型で無効な場合は、\n" +" * _Py_ATTR_CACHE_UNUSED に設定する (独自の MRO エントリーなどによる)。\n" +" * それ以外の場合は MAX_VERSIONS_PER_CLASS (別の場所で定義) 以下。\n" +" */\n" +" uint16_t tp_versions_used;\n" +"} PyTypeObject;\n" #: ../../extending/newtypes.rst:20 msgid "" @@ -168,9 +262,8 @@ msgstr "" "多くの場合いちばん簡単なのは、必要とするメンバがすべて含まれている例をとって" "きて、新しく作る型に合わせて値を変更することです。 ::" -#: ../../extending/newtypes.rst:31 msgid "const char *tp_name; /* For printing */" -msgstr "" +msgstr "const char *tp_name; /* 表示用 */" #: ../../extending/newtypes.rst:33 msgid "" @@ -182,9 +275,8 @@ msgstr "" "は診断目的で使われるものです。\n" "それなので、そのような場面で役に立つであろう名前を選んでください! ::" -#: ../../extending/newtypes.rst:37 msgid "Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */" -msgstr "" +msgstr "Py_ssize_t tp_basicsize, tp_itemsize; /* 割り当て用 */" #: ../../extending/newtypes.rst:39 msgid "" @@ -200,17 +292,15 @@ msgstr "" "度あり、ここで :c:member:`~PyTypeObject.tp_itemsize` メンバが使われます。これ" "らについてはあとでふれます。 ::" -#: ../../extending/newtypes.rst:44 msgid "const char *tp_doc;" -msgstr "" +msgstr "const char *tp_doc;" -#: ../../extending/newtypes.rst:46 msgid "" "Here you can put a string (or its address) that you want returned when the " "Python script references ``obj.__doc__`` to retrieve the doc string." msgstr "" -"ここには Python スクリプトリファレンス ``obj.__doc__`` が doc string を返すと" -"きの文字列 (あるいはそのアドレス) を入れます。" +"ここには、Python スクリプトが ``obj.__doc__`` を参照してドキュメント文字列を" +"取得するときに返す文字列 (またはそのアドレス) を設定します。" #: ../../extending/newtypes.rst:49 msgid "" @@ -224,9 +314,8 @@ msgstr "" msgid "Finalization and De-allocation" msgstr "ファイナライズとメモリ解放" -#: ../../extending/newtypes.rst:64 msgid "destructor tp_dealloc;" -msgstr "" +msgstr "destructor tp_dealloc;" #: ../../extending/newtypes.rst:66 msgid "" @@ -242,7 +331,6 @@ msgstr "" "す。オブジェクトそれ自体もここで解放される必要があります。この関数の例は、以" "下のようなものです::" -#: ../../extending/newtypes.rst:72 msgid "" "static void\n" "newdatatype_dealloc(PyObject *op)\n" @@ -252,14 +340,22 @@ msgid "" " Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" +"static void\n" +"newdatatype_dealloc(PyObject *op)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" free(self->obj_UnderlyingDatatypePtr);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" -#: ../../extending/newtypes.rst:80 msgid "" "If your type supports garbage collection, the destructor should call :c:func:" "`PyObject_GC_UnTrack` before clearing any member fields::" msgstr "" +"型がガベージコレクションをサポートする場合、デストラクタでは、メンバフィール" +"ドをクリアする前に :c:func:`PyObject_GC_UnTrack` を呼び出す必要がありま" +"す。 ::" -#: ../../extending/newtypes.rst:83 msgid "" "static void\n" "newdatatype_dealloc(PyObject *op)\n" @@ -271,6 +367,15 @@ msgid "" " Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" +"static void\n" +"newdatatype_dealloc(PyObject *op)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" PyObject_GC_UnTrack(op);\n" +" Py_CLEAR(self->other_obj);\n" +" ...\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" #: ../../extending/newtypes.rst:97 msgid "" @@ -297,7 +402,6 @@ msgstr "" "たらそれを元に戻すことです。これは :c:func:`PyErr_Fetch` および :c:func:" "`PyErr_Restore` 関数を使うことによって可能になります::" -#: ../../extending/newtypes.rst:109 msgid "" "static void\n" "my_dealloc(PyObject *obj)\n" @@ -327,8 +431,34 @@ msgid "" " Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" +"static void\n" +"my_dealloc(PyObject *obj)\n" +"{\n" +" MyObject *self = (MyObject *) obj;\n" +" PyObject *cbresult;\n" +"\n" +" if (self->my_callback != NULL) {\n" +" PyObject *err_type, *err_value, *err_traceback;\n" +"\n" +" /* 現在の例外の状態を保存する */\n" +" PyErr_Fetch(&err_type, &err_value, &err_traceback);\n" +"\n" +" cbresult = PyObject_CallNoArgs(self->my_callback);\n" +" if (cbresult == NULL) {\n" +" PyErr_WriteUnraisable(self->my_callback);\n" +" }\n" +" else {\n" +" Py_DECREF(cbresult);\n" +" }\n" +"\n" +" /* 保存した例外の状態を復元する */\n" +" PyErr_Restore(err_type, err_value, err_traceback);\n" +"\n" +" Py_DECREF(self->my_callback);\n" +" }\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" -#: ../../extending/newtypes.rst:138 msgid "" "There are limitations to what you can safely do in a deallocator function. " "First, if your type supports garbage collection (using :c:member:" @@ -340,16 +470,16 @@ msgid "" "(as in the example above) might end up calling :c:member:`~PyTypeObject." "tp_dealloc` again, causing a double free and a crash." msgstr "" -"メモリ解放関数の中で安全に行えることにはいくつか制限があります。\n" -"1つ目は、その型が (:c:member:`~PyTypeObject.tp_traverse` および :c:member:" -"`~PyTypeObject.tp_clear` を使って) ガベージコレクションをサポートしている場" -"合、 :c:member:`~PyTypeObject.tp_dealloc` が呼び出されるまでに、消去されファ" -"イナライズされてしまうオブジェクトのメンバーが有り得ることです。\n" -"2つ目は、 :c:member:`~PyTypeObject.tp_dealloc` の中ではオブジェクトは不安定な" -"状態にあることです: つまり参照カウントが0であるということです。\n" -"(上の例にあるような) 複雑なオブジェクトや API の呼び出しでは、 :c:member:" -"`~PyTypeObject.tp_dealloc` を再度呼び出し、二重解放からクラッシュすることにな" -"るかもしれません。" +"メモリ解放関数で安全に行えることには制限があります。\n" +"まず、型が (:c:member:`~PyTypeObject.tp_traverse`、:c:member:`~PyTypeObject." +"tp_clear` の一方または両方を使って) ガベージコレクションをサポートする場合、:" +"c:member:`~PyTypeObject.tp_dealloc` が呼ばれる時点で、オブジェクトの一部のメ" +"ンバがすでにクリアされているか、ファイナライズされている可能性があります。\n" +"また、:c:member:`~PyTypeObject.tp_dealloc` の中ではオブジェクトの参照カウント" +"がゼロになっており、不安定な状態にあります。\n" +"上の例のような単純でないオブジェクトや API の呼び出しは、:c:member:" +"`~PyTypeObject.tp_dealloc` を再び呼び出し、二重解放によるクラッシュを引き起こ" +"す可能性があります。" #: ../../extending/newtypes.rst:147 msgid "" @@ -380,11 +510,12 @@ msgstr "" "`print` 関数は単に :func:`str` を呼び出します。) これらのハンドラはどちらも省" "略できます。" -#: ../../extending/newtypes.rst:167 msgid "" "reprfunc tp_repr;\n" "reprfunc tp_str;" msgstr "" +"reprfunc tp_repr;\n" +"reprfunc tp_str;" #: ../../extending/newtypes.rst:170 msgid "" @@ -396,7 +527,6 @@ msgstr "" "表現を格納した文字列オブジェクトを返す必要があります。簡単な例は以下のような" "ものです::" -#: ../../extending/newtypes.rst:174 msgid "" "static PyObject *\n" "newdatatype_repr(PyObject *op)\n" @@ -406,13 +536,22 @@ msgid "" " self->obj_UnderlyingDatatypePtr->size);\n" "}" msgstr "" +"static PyObject *\n" +"newdatatype_repr(PyObject *op)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" return PyUnicode_FromFormat(\"Repr-ified_newdatatype{{size:%d}}\",\n" +" self->obj_UnderlyingDatatypePtr->size);\n" +"}" -#: ../../extending/newtypes.rst:182 msgid "" "If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the " "interpreter will supply a representation that uses the type's :c:member:" "`~PyTypeObject.tp_name` and a uniquely identifying value for the object." msgstr "" +":c:member:`~PyTypeObject.tp_repr` ハンドラを指定しない場合、インタープリタは" +"その型の :c:member:`~PyTypeObject.tp_name` とオブジェクトを一意に識別する値を" +"使った表現を生成します。" #: ../../extending/newtypes.rst:186 msgid "" @@ -436,7 +575,6 @@ msgstr "" msgid "Here is a simple example::" msgstr "以下は簡単な例です::" -#: ../../extending/newtypes.rst:195 msgid "" "static PyObject *\n" "newdatatype_str(PyObject *op)\n" @@ -446,12 +584,18 @@ msgid "" " self->obj_UnderlyingDatatypePtr->size);\n" "}" msgstr "" +"static PyObject *\n" +"newdatatype_str(PyObject *op)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" return PyUnicode_FromFormat(\"Stringified_newdatatype{{size:%d}}\",\n" +" self->obj_UnderlyingDatatypePtr->size);\n" +"}" #: ../../extending/newtypes.rst:206 msgid "Attribute Management" msgstr "属性を管理する" -#: ../../extending/newtypes.rst:208 msgid "" "For every object which can support attributes, the corresponding type must " "provide the functions that control how the attributes are resolved. There " @@ -460,8 +604,12 @@ msgid "" "an attribute is a special case, for which the new value passed to the " "handler is ``NULL``." msgstr "" +"属性を持つオブジェクトでは、対応する型が属性の解決方法を制御する関数を提供す" +"る必要があります。\n" +"属性を定義する場合は取得用の関数が、属性の設定を許可する場合は設定用の関数が" +"必要です。\n" +"属性の削除は特別な場合で、ハンドラには新しい値として ``NULL`` を渡します。" -#: ../../extending/newtypes.rst:214 msgid "" "Python supports two pairs of attribute handlers; a type that supports " "attributes only needs to implement the functions for one pair. The " @@ -469,8 +617,12 @@ msgid "" "`char\\*`, while the other accepts a :c:expr:`PyObject*`. Each type can use " "whichever pair makes more sense for the implementation's convenience. ::" msgstr "" +"Python は属性ハンドラの組を二つサポートしています。\n" +"属性をサポートする型は、どちらか一組の関数だけを実装すれば十分です。\n" +"違いは、一方が属性名を :c:expr:`char\\*` で受け取り、もう一方は :c:expr:" +"`PyObject*` で受け取る点です。\n" +"各型は実装に都合のよい方を使えます。 ::" -#: ../../extending/newtypes.rst:220 msgid "" "getattrfunc tp_getattr; /* char * version */\n" "setattrfunc tp_setattr;\n" @@ -478,8 +630,12 @@ msgid "" "getattrofunc tp_getattro; /* PyObject * version */\n" "setattrofunc tp_setattro;" msgstr "" +"getattrfunc tp_getattr; /* char * 版 */\n" +"setattrfunc tp_setattr;\n" +"/* ... */\n" +"getattrofunc tp_getattro; /* PyObject * 版 */\n" +"setattrofunc tp_setattro;" -#: ../../extending/newtypes.rst:226 msgid "" "If accessing attributes of an object is always a simple operation (this will " "be explained shortly), there are generic implementations which can be used " @@ -489,6 +645,11 @@ msgid "" "examples which have not been updated to use some of the new generic " "mechanism that is available." msgstr "" +"オブジェクトの属性へのアクセスが常に単純な操作で済む場合 (この後で説明しま" +"す)、:c:expr:`PyObject*` 版の属性管理関数として使える汎用の実装があります。\n" +"Python 2.2 以降、型固有の属性ハンドラが実際に必要になることはほとんどなくなり" +"ました。\n" +"ただし、新しい汎用の仕組みを使うように更新されていない例も数多くあります。" #: ../../extending/newtypes.rst:237 msgid "Generic Attribute Management" @@ -509,24 +670,20 @@ msgid "" msgstr "" ":c:func:`PyType_Ready` が呼ばれたとき、すでに属性の名前がわかっていること。" -#: ../../extending/newtypes.rst:245 msgid "" "No special processing is needed to record that an attribute was looked up or " "set, nor do actions need to be taken based on the value." msgstr "" -"属性を参照したり設定したりするときに、特別な記録のための処理が必要でなく、ま" -"た参照したり設定した値に対してどんな操作も実行する必要がないこと。" +"属性が取得または設定されたことを記録するための特別な処理も、属性の値に応じた" +"処理も不要であること。" -#: ../../extending/newtypes.rst:248 msgid "" "Note that this list does not place any restrictions on the values of the " "attributes, when the values are computed, or how relevant data is stored." msgstr "" -"これらの条件は、属性の値や、値が計算されるタイミング、または格納されたデータ" -"がどの程度妥当なものであるかといったことになんら制約を課すものではないことに" -"注意してください。" +"これらの条件は、属性の値、値を計算するタイミング、関連するデータの格納方法に" +"は何の制約も課しません。" -#: ../../extending/newtypes.rst:251 msgid "" "When :c:func:`PyType_Ready` is called, it uses three tables referenced by " "the type object to create :term:`descriptor`\\s which are placed in the " @@ -537,26 +694,40 @@ msgid "" "`~PyTypeObject.tp_getattro` and :c:member:`~PyTypeObject.tp_setattro` fields " "``NULL`` as well, allowing the base type to handle attributes." msgstr "" +":c:func:`PyType_Ready` は、型オブジェクトが参照する三つのテーブルを使って :" +"term:`デスクリプタ ` を作成し、型オブジェクトの辞書に格納しま" +"す。\n" +"各デスクリプタは、インスタンスオブジェクトの一つの属性へのアクセスを制御しま" +"す。\n" +"テーブルはいずれも省略可能です。\n" +"三つとも ``NULL`` の場合、その型のインスタンスが持つ属性は基底型から継承した" +"ものだけになります。\n" +"この場合、属性の処理を基底型に任せられるように、:c:member:`~PyTypeObject." +"tp_getattro` と :c:member:`~PyTypeObject.tp_setattro` フィールドも ``NULL`` " +"にしてください。" #: ../../extending/newtypes.rst:259 msgid "The tables are declared as three fields of the type object::" msgstr "テーブルはタイプオブジェクト中の 3つのメンバとして宣言されています::" -#: ../../extending/newtypes.rst:261 msgid "" "struct PyMethodDef *tp_methods;\n" "struct PyMemberDef *tp_members;\n" "struct PyGetSetDef *tp_getset;" msgstr "" +"struct PyMethodDef *tp_methods;\n" +"struct PyMemberDef *tp_members;\n" +"struct PyGetSetDef *tp_getset;" -#: ../../extending/newtypes.rst:265 msgid "" "If :c:member:`~PyTypeObject.tp_methods` is not ``NULL``, it must refer to an " "array of :c:type:`PyMethodDef` structures. Each entry in the table is an " "instance of this structure::" msgstr "" +":c:member:`~PyTypeObject.tp_methods` が ``NULL`` でない場合は、:c:type:" +"`PyMethodDef` 構造体の配列を指す必要があります。\n" +"テーブル内の各エントリーは、次の構造体のインスタンスです。 ::" -#: ../../extending/newtypes.rst:269 msgid "" "typedef struct PyMethodDef {\n" " const char *ml_name; /* method name */\n" @@ -565,14 +736,25 @@ msgid "" " const char *ml_doc; /* docstring */\n" "} PyMethodDef;" msgstr "" +"typedef struct PyMethodDef {\n" +" const char *ml_name; /* メソッド名 */\n" +" PyCFunction ml_meth; /* 実装関数 */\n" +" int ml_flags; /* フラグ */\n" +" const char *ml_doc; /* ドキュメント文字列 */\n" +"} PyMethodDef;" -#: ../../extending/newtypes.rst:276 msgid "" "One entry should be defined for each method provided by the type; no entries " "are needed for methods inherited from a base type. One additional entry is " "needed at the end; it is a sentinel that marks the end of the array. The :c:" "member:`~PyMethodDef.ml_name` field of the sentinel must be ``NULL``." msgstr "" +"型が提供するメソッドごとに一つのエントリーを定義します。\n" +"基底型から継承するメソッドのエントリーは不要です。\n" +"末尾には、配列の終わりを示す番兵となるエントリーをもう一つ追加する必要があり" +"ます。\n" +"番兵の :c:member:`~PyMethodDef.ml_name` フィールドは ``NULL`` にしなければな" +"りません。" #: ../../extending/newtypes.rst:281 msgid "" @@ -597,7 +779,6 @@ msgid "" "} PyMemberDef;" msgstr "" -#: ../../extending/newtypes.rst:293 msgid "" "For each entry in the table, a :term:`descriptor` will be constructed and " "added to the type which will be able to extract a value from the instance " @@ -608,8 +789,16 @@ msgid "" "the attribute can be accessed: you can set it to :c:macro:`Py_READONLY` to " "prevent Python code from setting it." msgstr "" +"テーブルの各エントリーから、インスタンス構造体の値を取り出せる :term:`デスク" +"リプタ ` が作成され、型に追加されます。\n" +":c:member:`~PyMemberDef.type` フィールドには :c:macro:`Py_T_INT` や :c:macro:" +"`Py_T_DOUBLE` のような型コードを設定します。\n" +"この値は、Python の値と C の値を相互に変換する方法を決めるために使います。\n" +":c:member:`~PyMemberDef.flags` フィールドには、属性へのアクセス方法を制御する" +"フラグを格納します。\n" +":c:macro:`Py_READONLY` を設定すると、Python コードからの値の設定を禁止できま" +"す。" -#: ../../extending/newtypes.rst:301 msgid "" "An interesting advantage of using the :c:member:`~PyTypeObject.tp_members` " "table to build descriptors that are used at runtime is that any attribute " @@ -618,6 +807,13 @@ msgid "" "the descriptor from the class object, and get the doc string using its :attr:" "`~type.__doc__` attribute." msgstr "" +":c:member:`~PyTypeObject.tp_members` テーブルから実行時に使うデスクリプタを作" +"成する方法には、興味深い利点があります。\n" +"この方法で定義した属性は、テーブルにテキストを指定するだけでドキュメント文字" +"列を関連付けられます。\n" +"アプリケーションはイントロスペクション API を使ってクラスオブジェクトからデス" +"クリプタを取得し、その :attr:`~type.__doc__` 属性からドキュメント文字列を取得" +"できます。" #: ../../extending/newtypes.rst:307 msgid "" @@ -629,7 +825,6 @@ msgstr "" msgid "Type-specific Attribute Management" msgstr "特定の型に特化した属性の管理" -#: ../../extending/newtypes.rst:323 msgid "" "For simplicity, only the :c:expr:`char\\*` version will be demonstrated " "here; the type of the name parameter is the only difference between the :c:" @@ -639,6 +834,13 @@ msgid "" "handler functions are called, so that if you do need to extend their " "functionality, you'll understand what needs to be done." msgstr "" +"簡単にするため、ここでは :c:expr:`char\\*` 版だけを示します。\n" +"インターフェースの :c:expr:`char\\*` 版と :c:expr:`PyObject*` 版の違いは、名" +"前を渡す引数の型だけです。\n" +"この例は、上の汎用の例と実質的に同じ処理を行いますが、Python 2.2 で追加された" +"汎用の仕組みは使いません。\n" +"ハンドラ関数の呼び出し方を説明するので、機能を拡張する必要がある場合に、何を" +"すべきかが分かるでしょう。" #: ../../extending/newtypes.rst:331 msgid "" @@ -651,7 +853,6 @@ msgstr "" msgid "Here is an example::" msgstr "以下に例を示します。::" -#: ../../extending/newtypes.rst:337 msgid "" "static PyObject *\n" "newdatatype_getattr(PyObject *op, char *name)\n" @@ -667,8 +868,20 @@ msgid "" " return NULL;\n" "}" msgstr "" +"static PyObject *\n" +"newdatatype_getattr(PyObject *op, char *name)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" if (strcmp(name, \"data\") == 0) {\n" +" return PyLong_FromLong(self->data);\n" +" }\n" +"\n" +" PyErr_Format(PyExc_AttributeError,\n" +" \"'%.100s' object has no attribute '%.400s'\",\n" +" Py_TYPE(self)->tp_name, name);\n" +" return NULL;\n" +"}" -#: ../../extending/newtypes.rst:351 msgid "" "The :c:member:`~PyTypeObject.tp_setattr` handler is called when the :meth:" "`~object.__setattr__` or :meth:`~object.__delattr__` method of a class " @@ -677,8 +890,14 @@ msgid "" "exception; if this were really all you wanted, the :c:member:`~PyTypeObject." "tp_setattr` handler should be set to ``NULL``. ::" msgstr "" +":c:member:`~PyTypeObject.tp_setattr` ハンドラは、クラスのインスタンスの :" +"meth:`~object.__setattr__` または :meth:`~object.__delattr__` メソッドが呼ば" +"れる状況で呼び出されます。\n" +"属性を削除する場合、第 3 引数は ``NULL`` になります。\n" +"次は単に例外を送出する例です。\n" +"本当にこれだけを行いたいのであれば、:c:member:`~PyTypeObject.tp_setattr` ハン" +"ドラを ``NULL`` に設定してください。 ::" -#: ../../extending/newtypes.rst:357 msgid "" "static int\n" "newdatatype_setattr(PyObject *op, char *name, PyObject *v)\n" @@ -687,24 +906,32 @@ msgid "" " return -1;\n" "}" msgstr "" +"static int\n" +"newdatatype_setattr(PyObject *op, char *name, PyObject *v)\n" +"{\n" +" PyErr_Format(PyExc_RuntimeError, \"Read-only attribute: %s\", name);\n" +" return -1;\n" +"}" #: ../../extending/newtypes.rst:365 msgid "Object Comparison" msgstr "オブジェクトの比較" -#: ../../extending/newtypes.rst:369 msgid "richcmpfunc tp_richcompare;" -msgstr "" +msgstr "richcmpfunc tp_richcompare;" -#: ../../extending/newtypes.rst:371 msgid "" "The :c:member:`~PyTypeObject.tp_richcompare` handler is called when " "comparisons are needed. It is analogous to the :ref:`rich comparison " "methods `, like :meth:`!__lt__`, and also called by :c:func:" "`PyObject_RichCompare` and :c:func:`PyObject_RichCompareBool`." msgstr "" +":c:member:`~PyTypeObject.tp_richcompare` ハンドラは、比較が必要なときに呼び出" +"されます。\n" +":meth:`!__lt__` などの :ref:`拡張比較メソッド ` に相当し、:c:" +"func:`PyObject_RichCompare` と :c:func:`PyObject_RichCompareBool` からも呼び" +"出されます。" -#: ../../extending/newtypes.rst:376 msgid "" "This function is called with two Python objects and the operator as " "arguments, where the operator is one of ``Py_EQ``, ``Py_NE``, ``Py_LE``, " @@ -714,6 +941,14 @@ msgid "" "comparison is not implemented and the other object's comparison method " "should be tried, or ``NULL`` if an exception was set." msgstr "" +"この関数は、二つの Python オブジェクトと演算子を引数として受け取ります。\n" +"演算子は ``Py_EQ``、``Py_NE``、``Py_LE``、``Py_GE``、``Py_LT``、``Py_GT`` の" +"いずれかです。\n" +"指定された演算子で二つのオブジェクトを比較し、比較が成功した場合は " +"``Py_True`` または ``Py_False`` を返してください。\n" +"比較が実装されておらず、もう一方のオブジェクトの比較メソッドを試すべきことを" +"示すには ``Py_NotImplemented`` を、例外を設定した場合は ``NULL`` を返してくだ" +"さい。" #: ../../extending/newtypes.rst:384 msgid "" @@ -723,7 +958,6 @@ msgstr "" "これは内部ポインタのサイズが等しければ等しいと見なすデータ型のサンプル実装で" "す::" -#: ../../extending/newtypes.rst:387 msgid "" "static PyObject *\n" "newdatatype_richcmp(PyObject *lhs, PyObject *rhs, int op)\n" @@ -751,6 +985,31 @@ msgid "" " return Py_NewRef(result);\n" " }" msgstr "" +"static PyObject *\n" +"newdatatype_richcmp(PyObject *lhs, PyObject *rhs, int op)\n" +"{\n" +" newdatatypeobject *obj1 = (newdatatypeobject *) lhs;\n" +" newdatatypeobject *obj2 = (newdatatypeobject *) rhs;\n" +" PyObject *result;\n" +" int c, size1, size2;\n" +"\n" +" /* 両方の引数が newdatatype 型であることを\n" +" 確認するコードは省略 */\n" +"\n" +" size1 = obj1->obj_UnderlyingDatatypePtr->size;\n" +" size2 = obj2->obj_UnderlyingDatatypePtr->size;\n" +"\n" +" switch (op) {\n" +" case Py_LT: c = size1 < size2; break;\n" +" case Py_LE: c = size1 <= size2; break;\n" +" case Py_EQ: c = size1 == size2; break;\n" +" case Py_NE: c = size1 != size2; break;\n" +" case Py_GT: c = size1 > size2; break;\n" +" case Py_GE: c = size1 >= size2; break;\n" +" }\n" +" result = c ? Py_True : Py_False;\n" +" return Py_NewRef(result);\n" +" }" #: ../../extending/newtypes.rst:415 msgid "Abstract Protocol Support" @@ -779,14 +1038,15 @@ msgid "" "slot, but a slot may still be unfilled.) ::" msgstr "" -#: ../../extending/newtypes.rst:432 msgid "" "PyNumberMethods *tp_as_number;\n" "PySequenceMethods *tp_as_sequence;\n" "PyMappingMethods *tp_as_mapping;" msgstr "" +"PyNumberMethods *tp_as_number;\n" +"PySequenceMethods *tp_as_sequence;\n" +"PyMappingMethods *tp_as_mapping;" -#: ../../extending/newtypes.rst:436 msgid "" "If you wish your object to be able to act like a number, a sequence, or a " "mapping object, then you place the address of a structure that implements " @@ -796,16 +1056,15 @@ msgid "" "of these in the :file:`Objects` directory of the Python source " "distribution. ::" msgstr "" -"お使いのオブジェクトを数値やシーケンス、あるいは辞書のようにふるまうようにし" -"たいならば、それぞれに C の :c:type:`PyNumberMethods` 構造体、 :c:type:" -"`PySequenceMethods` 構造体、または :c:type:`PyMappingMethods` 構造体のアドレ" -"スを入れます。これらに適切な値を入れても入れなくてもかまいません。これらを" -"使った例は Python の配布ソースにある :file:`Objects` でみつけることができるで" -"しょう。 ::" +"オブジェクトを数値、シーケンス、マッピングとして振る舞わせるには、それぞれ C " +"の :c:type:`PyNumberMethods`、:c:type:`PySequenceMethods`、:c:type:" +"`PyMappingMethods` 型の構造体のアドレスを設定します。\n" +"これらの構造体に適切な値を設定するのは、実装する側の責任です。\n" +"それぞれの使用例は、Python の配布ソースの :file:`Objects` ディレクトリで見つ" +"けられます。 ::" -#: ../../extending/newtypes.rst:443 msgid "hashfunc tp_hash;" -msgstr "" +msgstr "hashfunc tp_hash;" #: ../../extending/newtypes.rst:445 msgid "" @@ -815,7 +1074,6 @@ msgstr "" "この関数は、もし使うことにしたならば、データ型のインスタンスのハッシュ番号を" "返すようにします。次のは単純な例です::" -#: ../../extending/newtypes.rst:448 msgid "" "static Py_hash_t\n" "newdatatype_hash(PyObject *op)\n" @@ -829,18 +1087,32 @@ msgid "" " return result;\n" "}" msgstr "" +"static Py_hash_t\n" +"newdatatype_hash(PyObject *op)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" Py_hash_t result;\n" +" result = self->some_size + 32767 * self->some_number;\n" +" if (result == -1) {\n" +" result = -2;\n" +" }\n" +" return result;\n" +"}" -#: ../../extending/newtypes.rst:460 msgid "" ":c:type:`Py_hash_t` is a signed integer type with a platform-varying width. " "Returning ``-1`` from :c:member:`~PyTypeObject.tp_hash` indicates an error, " "which is why you should be careful to avoid returning it when hash " "computation is successful, as seen above." msgstr "" +":c:type:`Py_hash_t` は、幅がプラットフォームによって異なる符号付き整数型で" +"す。\n" +":c:member:`~PyTypeObject.tp_hash` が ``-1`` を返すとエラーを示すため、上の例" +"のように、ハッシュの計算に成功したときはこの値を返さないよう注意してくださ" +"い。" -#: ../../extending/newtypes.rst:467 msgid "ternaryfunc tp_call;" -msgstr "" +msgstr "ternaryfunc tp_call;" #: ../../extending/newtypes.rst:469 msgid "" @@ -874,7 +1146,6 @@ msgstr "" "*args* は呼び出しの引数を格納しているタプルです。ここから引数を取り出すには :" "c:func:`PyArg_ParseTuple` を使います。" -#: ../../extending/newtypes.rst:481 msgid "" "*kwds* is a dictionary of keyword arguments that were passed. If this is non-" "``NULL`` and you support keyword arguments, use :c:func:" @@ -882,12 +1153,17 @@ msgid "" "to support keyword arguments and this is non-``NULL``, raise a :exc:" "`TypeError` with a message saying that keyword arguments are not supported." msgstr "" +"``kwds`` は、渡されたキーワード引数の辞書です。\n" +"これが ``NULL`` でなく、キーワード引数をサポートする場合は、:c:func:" +"`PyArg_ParseTupleAndKeywords` で引数を取り出してください。\n" +"キーワード引数をサポートしない場合にこれが ``NULL`` でなければ、キーワード引" +"数をサポートしていないことを示すメッセージとともに :exc:`TypeError` を送出し" +"てください。" #: ../../extending/newtypes.rst:487 msgid "Here is a toy ``tp_call`` implementation::" msgstr "以下は ``tp_call`` の簡易な実装です::" -#: ../../extending/newtypes.rst:489 msgid "" "static PyObject *\n" "newdatatype_call(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -908,15 +1184,34 @@ msgid "" " return result;\n" "}" msgstr "" +"static PyObject *\n" +"newdatatype_call(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" newdatatypeobject *self = (newdatatypeobject *) op;\n" +" PyObject *result;\n" +" const char *arg1;\n" +" const char *arg2;\n" +" const char *arg3;\n" +"\n" +" if (!PyArg_ParseTuple(args, \"sss:call\", &arg1, &arg2, &arg3)) {\n" +" return NULL;\n" +" }\n" +" result = PyUnicode_FromFormat(\n" +" \"Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\\n\",\n" +" self->obj_UnderlyingDatatypePtr->size,\n" +" arg1, arg2, arg3);\n" +" return result;\n" +"}" -#: ../../extending/newtypes.rst:510 msgid "" "/* Iterators */\n" "getiterfunc tp_iter;\n" "iternextfunc tp_iternext;" msgstr "" +"/* イテレータ */\n" +"getiterfunc tp_iter;\n" +"iternextfunc tp_iternext;" -#: ../../extending/newtypes.rst:514 msgid "" "These functions provide support for the iterator protocol. Both handlers " "take exactly one parameter, the instance for which they are being called, " @@ -926,6 +1221,13 @@ msgid "" "`~PyTypeObject.tp_iternext` corresponds to the Python :meth:`~iterator." "__next__` method." msgstr "" +"これらの関数はイテレータプロトコルをサポートします。\n" +"どちらのハンドラも、呼び出し対象のインスタンスを唯一の引数として受け取り、新" +"しい参照を返します。\n" +"エラーの場合は例外を設定し、``NULL`` を返してください。\n" +":c:member:`~PyTypeObject.tp_iter` は Python の :meth:`~object.__iter__` メ" +"ソッドに、:c:member:`~PyTypeObject.tp_iternext` は Python の :meth:" +"`~iterator.__next__` メソッドに対応します。" #: ../../extending/newtypes.rst:521 msgid "" @@ -934,22 +1236,27 @@ msgid "" "same guidelines apply as for Python classes:" msgstr "" -#: ../../extending/newtypes.rst:525 msgid "" "For collections (such as lists and tuples) which can support multiple " "independent iterators, a new iterator should be created and returned by each " "call to :c:member:`~PyTypeObject.tp_iter`." msgstr "" +"独立した複数のイテレータをサポートできるコレクション (リストやタプルなど) で" +"は、:c:member:`~PyTypeObject.tp_iter` を呼び出すたびに新しいイテレータを作成" +"して返す必要があります。" -#: ../../extending/newtypes.rst:528 msgid "" "Objects which can only be iterated over once (usually due to side effects of " "iteration, such as file objects) can implement :c:member:`~PyTypeObject." "tp_iter` by returning a new reference to themselves -- and should also " "therefore implement the :c:member:`~PyTypeObject.tp_iternext` handler." msgstr "" +"一度しか反復できないオブジェクト (ファイルオブジェクトのように、通常は反復に" +"副作用があるもの) は、自身への新しい参照を返すことで :c:member:" +"`~PyTypeObject.tp_iter` を実装できます。\n" +"その場合は :c:member:`~PyTypeObject.tp_iternext` ハンドラも実装する必要があり" +"ます。" -#: ../../extending/newtypes.rst:533 msgid "" "Any :term:`iterator` object should implement both :c:member:`~PyTypeObject." "tp_iter` and :c:member:`~PyTypeObject.tp_iternext`. An iterator's :c:member:" @@ -963,40 +1270,57 @@ msgid "" "`~PyTypeObject.tp_iternext` should always set an exception and return " "``NULL``." msgstr "" +":term:`イテレータ ` オブジェクトは、:c:member:`~PyTypeObject." +"tp_iter` と :c:member:`~PyTypeObject.tp_iternext` の両方を実装する必要があり" +"ます。\n" +"イテレータの :c:member:`~PyTypeObject.tp_iter` ハンドラは、そのイテレータへの" +"新しい参照を返します。\n" +":c:member:`~PyTypeObject.tp_iternext` ハンドラは、反復する次のオブジェクトが" +"あれば、それへの新しい参照を返します。\n" +"反復の終わりに達した場合、:c:member:`~PyTypeObject.tp_iternext` は例外を設定" +"せずに ``NULL`` を返しても、``NULL`` を返す *とともに* :exc:`StopIteration` " +"を設定しても構いません。\n" +"例外を設定しない方が、パフォーマンスが少しよくなることがあります。\n" +"実際にエラーが発生した場合は、:c:member:`~PyTypeObject.tp_iternext` は必ず例" +"外を設定し、``NULL`` を返してください。" #: ../../extending/newtypes.rst:549 msgid "Weak Reference Support" msgstr "弱参照(Weak Reference)のサポート" -#: ../../extending/newtypes.rst:551 msgid "" "One of the goals of Python's weak reference implementation is to allow any " "type to participate in the weak reference mechanism without incurring the " "overhead on performance-critical objects (such as numbers)." msgstr "" +"Python の弱参照の実装では、数値のようにパフォーマンスが重要なオブジェクトに" +"オーバーヘッドを課さず、どの型でも弱参照の仕組みに参加できるようにすることを" +"目指しています。" -#: ../../extending/newtypes.rst:556 msgid "Documentation for the :mod:`weakref` module." -msgstr "" +msgstr ":mod:`weakref` モジュールのドキュメント。" -#: ../../extending/newtypes.rst:558 msgid "" "For an object to be weakly referenceable, the extension type must set the " "``Py_TPFLAGS_MANAGED_WEAKREF`` bit of the :c:member:`~PyTypeObject.tp_flags` " "field. The legacy :c:member:`~PyTypeObject.tp_weaklistoffset` field should " "be left as zero." msgstr "" +"オブジェクトが弱参照をサポートするには、拡張の型が :c:member:`~PyTypeObject." +"tp_flags` フィールドの ``Py_TPFLAGS_MANAGED_WEAKREF`` ビットを設定する必要が" +"あります。\n" +"従来の :c:member:`~PyTypeObject.tp_weaklistoffset` フィールドはゼロのままにし" +"てください。" -#: ../../extending/newtypes.rst:563 msgid "If this flag is set, :c:macro:`Py_TPFLAGS_HAVE_GC` should also be set." msgstr "" +"このフラグを設定する場合は、:c:macro:`Py_TPFLAGS_HAVE_GC` も設定するべきで" +"す。" -#: ../../extending/newtypes.rst:565 msgid "" "Concretely, here is how the statically declared type object would look::" -msgstr "" +msgstr "具体的には、静的に宣言した型オブジェクトは次のようになります。 ::" -#: ../../extending/newtypes.rst:567 msgid "" "static PyTypeObject TrivialType = {\n" " PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -1004,14 +1328,19 @@ msgid "" " .tp_flags = Py_TPFLAGS_MANAGED_WEAKREF | ...,\n" "};" msgstr "" +"static PyTypeObject TrivialType = {\n" +" PyVarObject_HEAD_INIT(NULL, 0)\n" +" /* ... 簡略化のためほかのメンバは省略 ... */\n" +" .tp_flags = Py_TPFLAGS_MANAGED_WEAKREF | ...,\n" +"};" -#: ../../extending/newtypes.rst:574 msgid "" "The only further addition is that ``tp_dealloc`` needs to clear any weak " "references (by calling :c:func:`PyObject_ClearWeakRefs`)::" msgstr "" +"このほかに必要なのは、``tp_dealloc`` で (:c:func:`PyObject_ClearWeakRefs` を" +"呼び出して) 弱参照をすべてクリアすることだけです。 ::" -#: ../../extending/newtypes.rst:577 msgid "" "static void\n" "Trivial_dealloc(PyObject *op)\n" @@ -1022,12 +1351,19 @@ msgid "" " Py_TYPE(op)->tp_free(op);\n" "}" msgstr "" +"static void\n" +"Trivial_dealloc(PyObject *op)\n" +"{\n" +" /* デストラクタを呼ぶ前に、まず弱参照をクリアする */\n" +" PyObject_ClearWeakRefs(op);\n" +" /* ... 簡略化のため残りの破棄処理は省略 ... */\n" +" Py_TYPE(op)->tp_free(op);\n" +"}" #: ../../extending/newtypes.rst:588 msgid "More Suggestions" msgstr "その他いろいろ" -#: ../../extending/newtypes.rst:590 msgid "" "In order to learn how to implement any specific method for your new data " "type, get the :term:`CPython` source code. Go to the :file:`Objects` " @@ -1035,34 +1371,43 @@ msgid "" "want (for example, ``tp_richcompare``). You will find examples of the " "function you want to implement." msgstr "" +"新しいデータ型の特定のメソッドを実装する方法を知るには、:term:`CPython` の" +"ソースコードを入手してください。\n" +":file:`Objects` ディレクトリで、``tp_`` に目的の関数名を続けた文字列 " +"(``tp_richcompare`` など) を C ソースファイルから検索すると、実装したい関数の" +"例が見つかります。" -#: ../../extending/newtypes.rst:596 msgid "" "When you need to verify that an object is a concrete instance of the type " "you are implementing, use the :c:func:`PyObject_TypeCheck` function. A " "sample of its use might be something like the following::" msgstr "" +"オブジェクトが実装中の型のインスタンスであることを確認するには、:c:func:" +"`PyObject_TypeCheck` 関数を使ってください。\n" +"例えば、次のように使います。 ::" -#: ../../extending/newtypes.rst:600 msgid "" "if (!PyObject_TypeCheck(some_object, &MyType)) {\n" " PyErr_SetString(PyExc_TypeError, \"arg #1 not a mything\");\n" " return NULL;\n" "}" msgstr "" +"if (!PyObject_TypeCheck(some_object, &MyType)) {\n" +" PyErr_SetString(PyExc_TypeError, \"arg #1 not a mything\");\n" +" return NULL;\n" +"}" -#: ../../extending/newtypes.rst:606 msgid "Download CPython source releases." -msgstr "" +msgstr "CPython のソースリリースをダウンロードできます。" #: ../../extending/newtypes.rst:607 msgid "https://www.python.org/downloads/source/" msgstr "https://www.python.org/downloads/source/" -#: ../../extending/newtypes.rst:609 msgid "" "The CPython project on GitHub, where the CPython source code is developed." msgstr "" +"CPython のソースコードが開発されている GitHub 上の CPython プロジェクトです。" #: ../../extending/newtypes.rst:610 msgid "https://github.com/python/cpython" @@ -1088,21 +1433,18 @@ msgstr "finalization" msgid "finalization, of objects" msgstr "finalization, of objects" -#: ../../extending/newtypes.rst:93 msgid "PyErr_Fetch (C function)" -msgstr "" +msgstr "PyErr_Fetch (C 関数)" -#: ../../extending/newtypes.rst:93 msgid "PyErr_Restore (C function)" -msgstr "" +msgstr "PyErr_Restore (C 関数)" #: ../../extending/newtypes.rst:154 msgid "string" msgstr "string" -#: ../../extending/newtypes.rst:154 msgid "object representation" -msgstr "" +msgstr "オブジェクト表現" #: ../../extending/newtypes.rst:154 msgid "built-in function" diff --git a/extending/newtypes_tutorial.po b/extending/newtypes_tutorial.po index 8bf49f133..11c765935 100644 --- a/extending/newtypes_tutorial.po +++ b/extending/newtypes_tutorial.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/newtypes_tutorial.rst:7 @@ -44,7 +44,6 @@ msgstr "" msgid "The Basics" msgstr "基本的なこと" -#: ../../extending/newtypes_tutorial.rst:21 msgid "" "The :term:`CPython` runtime sees all Python objects as variables of type :c:" "expr:`PyObject*`, which serves as a \"base type\" for all Python objects. " @@ -55,14 +54,16 @@ msgid "" "an object, a method called, or it is multiplied by another object. These C " "functions are called \"type methods\"." msgstr "" -":term:`CPython` ランタイムは Python の全てのオブジェクトを、 Python の全ての" -"オブジェクトの \"基底型 (base type)\" である :c:expr:`PyObject*` 型の変数と見" -"なします。 :c:type:`PyObject` 構造体自身は :term:`参照カウント ` と、オブジェクトの \"型オブジェクト\" へのポインタのみを持ちます。こ" -"こには動作が定義されています; 型オブジェクトは、例えば、ある属性があるオブ" -"ジェクトから検索されたり、メソッドが呼ばれたり、他のオブジェクトによって操作" -"されたりしたときに、どの (C) 関数がインタープリターから呼ばれるのかを決定しま" -"す。これらの C 関数は \"型メソッド (type method)\" と呼ばれます。" +":term:`CPython` ランタイムは、すべての Python オブジェクトを :c:expr:" +"`PyObject*` 型の変数として扱います。\n" +"この型はすべての Python オブジェクトの「基底型」の役割を果たします。\n" +":c:type:`PyObject` 構造体自体に含まれるのは、オブジェクトの :term:`参照カウン" +"ト ` と、その「型オブジェクト」へのポインタだけです。\n" +"動作を決めるのは、この型オブジェクトです。\n" +"例えばオブジェクトの属性を検索するとき、メソッドを呼び出すとき、ほかのオブ" +"ジェクトとの乗算を行うときに、インタープリタがどの C 関数を呼び出すかを決定し" +"ます。\n" +"これらの C 関数を「型メソッド」と呼びます。" #: ../../extending/newtypes_tutorial.rst:30 msgid "" @@ -94,7 +95,6 @@ msgstr "" "C API では、 :c:func:`PyType_FromSpec` 関数を使い、ヒープ上に配置された拡張の" "型も定義できますが、これについてはこのチュートリアルでは扱いません。" -#: ../../extending/newtypes_tutorial.rst:43 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -151,14 +151,68 @@ msgid "" " return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" /* 型固有のフィールドをここに記述します。 */\n" +"} CustomObject;\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom オブジェクト\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT,\n" +" .tp_new = PyType_GenericNew,\n" +"};\n" +"\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" // 静的な型を使う間はこの設定を使う\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom\",\n" +" .m_doc = \"拡張型を作成するサンプルモジュール。\",\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom(void)\n" +"{\n" +" return PyModuleDef_Init(&custom_module);\n" +"}\n" -#: ../../extending/newtypes_tutorial.rst:45 msgid "" "Now that's quite a bit to take in at once, but hopefully bits will seem " "familiar from the previous chapter. This file defines three things:" msgstr "" -"一度に把握するにはちょっと量が多いですが、前の章よりはとっつきやすくなってい" -"ることと思います。このファイルでは、3つの要素が定義されています:" +"一度に理解するにはかなりの量ですが、前の章で見たことのある部分もあるでしょ" +"う。\n" +"このファイルでは、次の三つを定義しています。" #: ../../extending/newtypes_tutorial.rst:48 msgid "" @@ -179,26 +233,30 @@ msgstr "" "で、フラグと関数ポインタの集まりを定義しています。特定の操作が要求されたとき" "に、この関数ポインタをインタープリターが見に行きます。" -#: ../../extending/newtypes_tutorial.rst:53 msgid "" "How to define and execute the :mod:`!custom` module: this is the " "``PyInit_custom`` function and the associated ``custom_module`` struct for " "defining the module, and the ``custom_module_exec`` function to set up a " "fresh module object." msgstr "" +":mod:`!custom` モジュールをどう定義し、実行するか。\n" +"モジュールを定義する ``PyInit_custom`` 関数と、それに関連する " +"``custom_module`` 構造体、および新しいモジュールオブジェクトを設定する " +"``custom_module_exec`` 関数がこれに当たります。" #: ../../extending/newtypes_tutorial.rst:58 msgid "The first bit is::" msgstr "まず最初はこれです::" -#: ../../extending/newtypes_tutorial.rst:60 msgid "" "typedef struct {\n" " PyObject_HEAD\n" "} CustomObject;" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +"} CustomObject;" -#: ../../extending/newtypes_tutorial.rst:64 msgid "" "This is what a Custom object will contain. ``PyObject_HEAD`` is mandatory " "at the start of each object struct and defines a field called ``ob_base`` of " @@ -208,13 +266,13 @@ msgid "" "abstract away the layout and to enable additional fields in :ref:`debug " "builds `." msgstr "" -"これが Custom オブジェクトの内容です。 ``PyObject_HEAD`` はそれぞれのオブジェ" -"クト構造体の先頭に必須なもので、 :c:type:`PyObject` 型の ``ob_base`` という名" -"前のフィールドを定義します。 :c:type:`PyObject` 型には (それぞれ :c:macro:" -"`Py_TYPE` マクロおよび :c:macro:`Py_REFCNT` マクロからアクセスできる) 型オブ" -"ジェクトへのポインタと参照カウントが格納されています。このマクロが用意されて" -"いる理由は、構造体のレイアウトを抽象化し、デバッグビルドでフィールドを追加で" -"きるようにするためです。" +"これが Custom オブジェクトの内容です。\n" +"各オブジェクト構造体の先頭には ``PyObject_HEAD`` が必須で、これは :c:type:" +"`PyObject` 型の ``ob_base`` というフィールドを定義します。\n" +"このフィールドには型オブジェクトへのポインタと参照カウントが含まれ、それぞ" +"れ :c:macro:`Py_TYPE` と :c:macro:`Py_REFCNT` マクロでアクセスできます。\n" +"このマクロはレイアウトを抽象化し、:ref:`デバッグビルド ` で" +"フィールドを追加できるようにするためのものです。" #: ../../extending/newtypes_tutorial.rst:73 msgid "" @@ -235,19 +293,21 @@ msgstr "" "の他にもデータを保持しています; 例えば、これは Python 標準の浮動小数点数の定" "義です::" -#: ../../extending/newtypes_tutorial.rst:80 msgid "" "typedef struct {\n" " PyObject_HEAD\n" " double ob_fval;\n" "} PyFloatObject;" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +" double ob_fval;\n" +"} PyFloatObject;" #: ../../extending/newtypes_tutorial.rst:85 msgid "The second bit is the definition of the type object. ::" msgstr "2つ目は型オブジェクトの定義です。 ::" -#: ../../extending/newtypes_tutorial.rst:87 msgid "" "static PyTypeObject CustomType = {\n" " .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" @@ -259,6 +319,15 @@ msgid "" " .tp_new = PyType_GenericNew,\n" "};" msgstr "" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom オブジェクト\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT,\n" +" .tp_new = PyType_GenericNew,\n" +"};" #: ../../extending/newtypes_tutorial.rst:98 msgid "" @@ -286,21 +355,18 @@ msgstr "" msgid "We're going to pick it apart, one field at a time::" msgstr "一度に1つずつフィールドを取り上げていきましょう::" -#: ../../extending/newtypes_tutorial.rst:109 msgid ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" -msgstr "" +msgstr ".ob_base = PyVarObject_HEAD_INIT(NULL, 0)" -#: ../../extending/newtypes_tutorial.rst:111 msgid "" "This line is mandatory boilerplate to initialize the ``ob_base`` field " "mentioned above. ::" msgstr "" -"この行は、上で触れた ``ob_base`` フィールドの初期化に必須のボイラープレートで" -"す。" +"この行は、上で説明した ``ob_base`` フィールドを初期化するために必要な定型的な" +"記述です。 ::" -#: ../../extending/newtypes_tutorial.rst:114 msgid ".tp_name = \"custom.Custom\"," -msgstr "" +msgstr ".tp_name = \"custom.Custom\"," #: ../../extending/newtypes_tutorial.rst:116 msgid "" @@ -311,15 +377,17 @@ msgstr "" "これは、オブジェクトのデフォルトの文字列表現やエラーメッセージに現れます。例" "えば次の通りです:" -#: ../../extending/newtypes_tutorial.rst:119 msgid "" ">>> \"\" + custom.Custom()\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "TypeError: can only concatenate str (not \"custom.Custom\") to str" msgstr "" +">>> \"\" + custom.Custom()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: can only concatenate str (not \"custom.Custom\") to str" -#: ../../extending/newtypes_tutorial.rst:126 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:`!" @@ -327,17 +395,19 @@ msgid "" "`!custom.Custom`. Using the real dotted import path is important to make " "your type compatible with the :mod:`pydoc` and :mod:`pickle` modules. ::" msgstr "" -"型の名前が、モジュール名とモジュールにおける型の名前の両方をドットでつないだ" -"名前になっていることに注意してください。この場合は、モジュールは :mod:`!" -"custom` で型は :class:`!Custom` なので、型の名前を :class:`!custom.Custom` に" -"設定しました。実際のドット付きのインポートパスを使うのは、 :mod:`pydoc` モ" -"ジュールや :mod:`pickle` モジュールと互換性を持たせるために重要なのです。" +"型の名前は、モジュール名とモジュール内の型の名前をドットでつないだ名前で" +"す。\n" +"この場合、モジュールは :mod:`!custom`、型は :class:`!Custom` なので、型の名前" +"を :class:`!custom.Custom` に設定します。\n" +"この型を :mod:`pydoc` や :mod:`pickle` モジュールと互換性のあるものにするに" +"は、実際のドット付きインポートパスを使うことが重要です。 ::" -#: ../../extending/newtypes_tutorial.rst:132 msgid "" ".tp_basicsize = sizeof(CustomObject),\n" ".tp_itemsize = 0," msgstr "" +".tp_basicsize = sizeof(CustomObject),\n" +".tp_itemsize = 0," #: ../../extending/newtypes_tutorial.rst:135 msgid "" @@ -350,7 +420,6 @@ msgstr "" "tp_itemsize` は可変サイズのオブジェクトでのみ使うものなので、サイズが可変でな" "いオブジェクトでは 0 にすべきです。" -#: ../../extending/newtypes_tutorial.rst:141 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 " @@ -363,14 +432,23 @@ msgid "" "type will be :class:`object`, or else you will be adding data members to " "your base type, and therefore increasing its size." msgstr "" +"Python からサブクラスを作成できる型で、その :c:member:`~PyTypeObject." +"tp_basicsize` が基底型と同じ場合は、多重継承で問題が起こる可能性がありま" +"す。\n" +"その型の Python サブクラスでは、:attr:`~type.__bases__` の先頭にその型を指定" +"しないと、その型の :meth:`~object.__new__` メソッドを呼び出す際にエラーが発生" +"します。\n" +"この問題は、型の :c:member:`~PyTypeObject.tp_basicsize` を基底型より大きな値" +"にすることで避けられます。\n" +"たいていの場合、基底型が :class:`object` であるか、基底型にデータメンバを追加" +"してサイズを増やすので、すでにこの条件を満たしています。" #: ../../extending/newtypes_tutorial.rst:151 msgid "We set the class flags to :c:macro:`Py_TPFLAGS_DEFAULT`. ::" msgstr ":c:macro:`Py_TPFLAGS_DEFAULT` にクラスフラグを設定します。 ::" -#: ../../extending/newtypes_tutorial.rst:153 msgid ".tp_flags = Py_TPFLAGS_DEFAULT," -msgstr "" +msgstr ".tp_flags = Py_TPFLAGS_DEFAULT," #: ../../extending/newtypes_tutorial.rst:155 msgid "" @@ -387,9 +465,8 @@ msgid "" "We provide a doc string for the type in :c:member:`~PyTypeObject.tp_doc`. ::" msgstr "この型の docstring は :c:member:`~PyTypeObject.tp_doc` に入れます。 ::" -#: ../../extending/newtypes_tutorial.rst:161 msgid ".tp_doc = PyDoc_STR(\"Custom objects\")," -msgstr "" +msgstr ".tp_doc = PyDoc_STR(\"Custom オブジェクト\")," #: ../../extending/newtypes_tutorial.rst:163 msgid "" @@ -405,22 +482,24 @@ msgstr "" "func:`PyType_GenericNew` として提供されるデフォルトの実装をそのまま使えま" "す。 ::" -#: ../../extending/newtypes_tutorial.rst:168 msgid ".tp_new = PyType_GenericNew," -msgstr "" +msgstr ".tp_new = PyType_GenericNew," -#: ../../extending/newtypes_tutorial.rst:170 msgid "" "Everything else in the file should be familiar, except for some code in :c:" "func:`!custom_module_exec`::" msgstr "" +"ファイル内の残りの部分は、:c:func:`!custom_module_exec` の一部を除いて、すで" +"に見慣れたものでしょう。 ::" -#: ../../extending/newtypes_tutorial.rst:173 msgid "" "if (PyType_Ready(&CustomType) < 0) {\n" " return -1;\n" "}" msgstr "" +"if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +"}" #: ../../extending/newtypes_tutorial.rst:177 msgid "" @@ -432,12 +511,14 @@ msgstr "" "つかのメンバーを適切なデフォルト値で埋めて、 :class:`!Custom` 型を初期化しま" "す。 ::" -#: ../../extending/newtypes_tutorial.rst:181 msgid "" "if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" " return -1;\n" "}" msgstr "" +"if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) {\n" +" return -1;\n" +"}" #: ../../extending/newtypes_tutorial.rst:185 msgid "" @@ -447,11 +528,12 @@ msgstr "" "これは型をモジュールの辞書に追加します。こうすることで :class:`!Custom` クラ" "スの呼び出しで :class:`!Custom` インスタンスが作成できるようになります:" -#: ../../extending/newtypes_tutorial.rst:188 msgid "" ">>> import custom\n" ">>> mycustom = custom.Custom()" msgstr "" +">>> import custom\n" +">>> mycustom = custom.Custom()" #: ../../extending/newtypes_tutorial.rst:193 msgid "" @@ -461,7 +543,6 @@ msgstr "" "以上です!残りの作業はビルドだけです; :file:`custom.c` という名前のファイルに" "ここまでのコードを書き込み、" -#: ../../extending/newtypes_tutorial.rst:196 msgid "" "[build-system]\n" "requires = [\"setuptools\"]\n" @@ -471,16 +552,24 @@ msgid "" "name = \"custom\"\n" "version = \"1\"\n" msgstr "" +"[build-system]\n" +"requires = [\"setuptools\"]\n" +"build-backend = \"setuptools.build_meta\"\n" +"\n" +"[project]\n" +"name = \"custom\"\n" +"version = \"1\"\n" #: ../../extending/newtypes_tutorial.rst:198 msgid "in a file called :file:`pyproject.toml`, and" msgstr ":file:`pyproject.toml` というファイルにこれを書き込み、" -#: ../../extending/newtypes_tutorial.rst:200 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" msgstr "" +"from setuptools import Extension, setup\n" +"setup(ext_modules=[Extension(\"custom\", [\"custom.c\"])])" #: ../../extending/newtypes_tutorial.rst:205 msgid "in a file called :file:`setup.py`; then typing" @@ -488,10 +577,8 @@ msgstr "" "そして :file:`setup.py` というファイルにこのように書き込み、そして、以下のよ" "うに" -#: ../../extending/newtypes_tutorial.rst:207 -#: ../../extending/newtypes_tutorial.rst:545 msgid "$ python -m pip install ." -msgstr "" +msgstr "$ python -m pip install ." #: ../../extending/newtypes_tutorial.rst:211 msgid "" @@ -529,7 +616,6 @@ msgstr "" "基底クラスとしても利用できるようにします。ここでは新しいモジュール :mod:`!" "custom2` をつくり、これらの機能を追加します:" -#: ../../extending/newtypes_tutorial.rst:228 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -675,6 +761,149 @@ msgid "" " return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* offsetof() 用 */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* ファーストネーム */\n" +" PyObject *last; /* ラストネーム */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static void\n" +"Custom_dealloc(PyObject *op)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_XSETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_XSETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" +" \"ファーストネーム\"},\n" +" {\"last\", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,\n" +" \"ラストネーム\"},\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"独自の数値\"},\n" +" {NULL} /* 番兵 */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" if (self->first == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"first\");\n" +" return NULL;\n" +" }\n" +" if (self->last == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"last\");\n" +" return NULL;\n" +" }\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", Custom_name, METH_NOARGS,\n" +" \"ファーストネームとラストネームを連結した名前を返す\"\n" +" },\n" +" {NULL} /* 番兵 */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom2.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom オブジェクト\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_new = Custom_new,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +"};\n" +"\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom2\",\n" +" .m_doc = \"拡張型を作成するサンプルモジュール。\",\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom2(void)\n" +"{\n" +" return PyModuleDef_Init(&custom_module);\n" +"}\n" #: ../../extending/newtypes_tutorial.rst:231 msgid "This version of the module has a number of changes." @@ -696,7 +925,6 @@ msgstr "" msgid "The object structure is updated accordingly::" msgstr "これにしたがうと、オブジェクトの構造体は次のようになります::" -#: ../../extending/newtypes_tutorial.rst:239 msgid "" "typedef struct {\n" " PyObject_HEAD\n" @@ -705,6 +933,12 @@ msgid "" " int number;\n" "} CustomObject;" msgstr "" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* ファーストネーム */\n" +" PyObject *last; /* ラストネーム */\n" +" int number;\n" +"} CustomObject;" #: ../../extending/newtypes_tutorial.rst:246 msgid "" @@ -714,7 +948,6 @@ msgstr "" "いまや管理すべきデータができたので、オブジェクトの割り当てと解放に際してはよ" "り慎重になる必要があります。最低限、オブジェクトの解放メソッドが必要です::" -#: ../../extending/newtypes_tutorial.rst:249 msgid "" "static void\n" "Custom_dealloc(PyObject *op)\n" @@ -725,15 +958,22 @@ msgid "" " Py_TYPE(self)->tp_free(self);\n" "}" msgstr "" +"static void\n" +"Custom_dealloc(PyObject *op)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}" #: ../../extending/newtypes_tutorial.rst:258 msgid "which is assigned to the :c:member:`~PyTypeObject.tp_dealloc` member::" msgstr "" "この関数は :c:member:`~PyTypeObject.tp_dealloc` メンバに代入されます。 ::" -#: ../../extending/newtypes_tutorial.rst:260 msgid ".tp_dealloc = Custom_dealloc," -msgstr "" +msgstr ".tp_dealloc = Custom_dealloc," #: ../../extending/newtypes_tutorial.rst:262 msgid "" @@ -753,7 +993,6 @@ msgstr "" "CustomType` であるとは限らない点に注意してください。なぜなら、オブジェクトは" "サブクラスのインスタンスかもしれないからです。" -#: ../../extending/newtypes_tutorial.rst:272 msgid "" "The explicit cast to ``CustomObject *`` above is needed because we defined " "``Custom_dealloc`` to take a ``PyObject *`` argument, as the ``tp_dealloc`` " @@ -762,15 +1001,23 @@ msgid "" "with instances of our ``CustomObject`` class, so the cast to ``(CustomObject " "*)`` is safe. This is object-oriented polymorphism, in C!" msgstr "" +"``tp_dealloc`` 関数ポインタが ``PyObject *`` 引数を受け取るため、" +"``Custom_dealloc`` も ``PyObject *`` 引数を受け取るように定義しています。\n" +"そのため、上の例では ``CustomObject *`` への明示的なキャストが必要です。\n" +"この関数を型の ``tp_dealloc`` スロットに代入することで、``CustomObject`` クラ" +"スのインスタンスに対してだけ呼び出されることを宣言しているので、" +"``(CustomObject *)`` へのキャストは安全です。\n" +"これが C でのオブジェクト指向のポリモーフィズムです。" -#: ../../extending/newtypes_tutorial.rst:280 msgid "" "In existing code, or in previous versions of this tutorial, you might see " "similar functions take a pointer to the subtype object structure " "(``CustomObject*``) directly, like this::" msgstr "" +"既存のコードやこのチュートリアルの以前のバージョンでは、次のようにサブタイプ" +"のオブジェクト構造体へのポインタ (``CustomObject*``) を直接受け取る関数を見か" +"けるかもしれません。 ::" -#: ../../extending/newtypes_tutorial.rst:284 msgid "" "Custom_dealloc(CustomObject *self)\n" "{\n" @@ -781,12 +1028,21 @@ msgid "" "...\n" ".tp_dealloc = (destructor) Custom_dealloc," msgstr "" +"Custom_dealloc(CustomObject *self)\n" +"{\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free((PyObject *) self);\n" +"}\n" +"...\n" +".tp_dealloc = (destructor) Custom_dealloc," -#: ../../extending/newtypes_tutorial.rst:293 msgid "" "This does the same thing on all architectures that CPython supports, but " "according to the C standard, it invokes undefined behavior." msgstr "" +"CPython がサポートするすべてのアーキテクチャでは同じ動作になりますが、C の規" +"格上は未定義の動作を引き起こします。" #: ../../extending/newtypes_tutorial.rst:297 msgid "" @@ -796,7 +1052,6 @@ msgstr "" "ファーストネームとラストネームを空文字列に初期化しておきたいので、``tp_new`` " "の実装を追加することにしましょう::" -#: ../../extending/newtypes_tutorial.rst:300 msgid "" "static PyObject *\n" "Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" @@ -819,18 +1074,36 @@ msgid "" " return (PyObject *) self;\n" "}" msgstr "" - -#: ../../extending/newtypes_tutorial.rst:321 -msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" -msgstr "" -"そしてこれを :c:member:`~PyTypeObject.tp_new` メンバとしてインストールしま" -"す::" - -#: ../../extending/newtypes_tutorial.rst:323 -msgid ".tp_new = Custom_new," +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = PyUnicode_FromString(\"\");\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = PyUnicode_FromString(\"\");\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}" + +#: ../../extending/newtypes_tutorial.rst:321 +msgid "and install it in the :c:member:`~PyTypeObject.tp_new` member::" msgstr "" +"そしてこれを :c:member:`~PyTypeObject.tp_new` メンバとしてインストールしま" +"す::" + +msgid ".tp_new = Custom_new," +msgstr ".tp_new = Custom_new," -#: ../../extending/newtypes_tutorial.rst:325 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:" @@ -840,8 +1113,15 @@ msgid "" "type above. In this case, we use the ``tp_new`` handler to initialize the " "``first`` and ``last`` attributes to non-``NULL`` default values." msgstr "" +"``tp_new`` ハンドラは、その型のオブジェクトの初期化ではなく、作成を担当しま" +"す。\n" +"Python では :meth:`~object.__new__` メソッドとして公開されます。\n" +"``tp_new`` メンバを独自に定義する必要はなく、実際、多くの拡張型は、上の最初" +"の :class:`!Custom` 型と同じく :c:func:`PyType_GenericNew` をそのまま使いま" +"す。\n" +"今回は ``tp_new`` ハンドラを使って、``first`` と ``last`` 属性を ``NULL`` で" +"ないデフォルト値に初期化します。" -#: ../../extending/newtypes_tutorial.rst:333 msgid "" "``tp_new`` is passed the type being instantiated (not necessarily " "``CustomType``, if a subclass is instantiated) and any arguments passed when " @@ -850,6 +1130,13 @@ msgid "" "often ignore the arguments, leaving the argument handling to initializer (a." "k.a. ``tp_init`` in C or ``__init__`` in Python) methods." msgstr "" +"``tp_new`` にはインスタンス化する型 (サブクラスをインスタンス化する場合は必ず" +"しも ``CustomType`` とは限りません) と、その型の呼び出し時に渡された引数を渡" +"します。\n" +"作成したインスタンスを返す必要があります。\n" +"``tp_new`` ハンドラは常に位置引数とキーワード引数を受け取りますが、それらを無" +"視して、初期化メソッド (C では ``tp_init``、Python では ``__init__``) に引数" +"の処理を任せることもよくあります。" #: ../../extending/newtypes_tutorial.rst:341 msgid "" @@ -867,9 +1154,8 @@ msgstr "" "この ``tp_new`` の実装は、:c:member:`~PyTypeObject.tp_alloc` スロットを呼び出" "してメモリを割り当てます::" -#: ../../extending/newtypes_tutorial.rst:347 msgid "self = (CustomObject *) type->tp_alloc(type, 0);" -msgstr "" +msgstr "self = (CustomObject *) type->tp_alloc(type, 0);" #: ../../extending/newtypes_tutorial.rst:349 msgid "" @@ -880,15 +1166,18 @@ msgstr "" "`~PyTypeObject.tp_alloc` の結果が ``NULL`` でないかチェックしなければなりませ" "ん。" -#: ../../extending/newtypes_tutorial.rst:353 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 " "class, which is :class:`object` by default. Most types use the default " "allocation strategy." msgstr "" +"ここでは :c:member:`~PyTypeObject.tp_alloc` スロットを自分では設定していませ" +"ん。\n" +":c:func:`PyType_Ready` が、デフォルトでは :class:`object` となる基底クラスか" +"ら継承して設定してくれます。\n" +"ほとんどの型は、デフォルトの割り当て方法を使います。" -#: ../../extending/newtypes_tutorial.rst:359 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:`~object." @@ -900,23 +1189,21 @@ msgid "" "correctly. (Specifically, you may not be able to create instances of such " "subclasses without getting a :exc:`TypeError`.)" msgstr "" -"もし協力的な :c:member:`~PyTypeObject.tp_new` (基底タイプの :c:member:" -"`~PyTypeObject.tp_new` または :meth:`~object.__new__` を呼んでいるもの) を作" -"りたいのならば、実行時のメソッド解決順序をつかってどのメソッドを呼びだすかを" -"決定しようとしては *いけません* 。常に呼び出す型を静的に決めておき、直接そ" -"の :c:member:`~PyTypeObject.tp_new` を呼び出すか、あるいは ``type->tp_base-" -">tp_new`` を経由してください。こうしないと、あなたが作成したタイプの Python " -"サブクラスが他の Python で定義されたクラスも継承している場合にうまく動かない" -"場合があります。 (とりわけ、そのようなサブクラスのインスタンスを :exc:" -"`TypeError` を出さずに作ることが不可能になります。)" +"基底型の :c:member:`~PyTypeObject.tp_new` や :meth:`~object.__new__` を呼び出" +"す、協調的な :c:member:`~PyTypeObject.tp_new` を実装する場合、実行時のメソッ" +"ド解決順序を使って呼び出すメソッドを決めようとしては *いけません*。\n" +"呼び出す型を常に静的に決め、その :c:member:`~PyTypeObject.tp_new` を直接、ま" +"たは ``type->tp_base->tp_new`` を通して呼び出してください。\n" +"そうしないと、この型の Python サブクラスが、ほかの Python で定義されたクラス" +"も継承する場合に正しく動作しない可能性があります。\n" +"具体的には、そのようなサブクラスのインスタンスを作ろうとすると :exc:" +"`TypeError` が発生する場合があります。" -#: ../../extending/newtypes_tutorial.rst:369 msgid "" "We also define an initialization function which accepts arguments to provide " "initial values for our instance::" -msgstr "" +msgstr "インスタンスの初期値を引数として受け取る初期化関数も定義し、 ::" -#: ../../extending/newtypes_tutorial.rst:372 msgid "" "static int\n" "Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -945,24 +1232,52 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|OOi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" tmp = self->first;\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +" Py_XDECREF(tmp);\n" +" }\n" +" if (last) {\n" +" tmp = self->last;\n" +" Py_INCREF(last);\n" +" self->last = last;\n" +" Py_XDECREF(tmp);\n" +" }\n" +" return 0;\n" +"}" #: ../../extending/newtypes_tutorial.rst:399 msgid "by filling the :c:member:`~PyTypeObject.tp_init` slot. ::" msgstr "これは :c:member:`~PyTypeObject.tp_init` メンバに代入されます。 ::" -#: ../../extending/newtypes_tutorial.rst:401 msgid ".tp_init = Custom_init," -msgstr "" +msgstr ".tp_init = Custom_init," -#: ../../extending/newtypes_tutorial.rst:403 msgid "" "The :c:member:`~PyTypeObject.tp_init` slot is exposed in Python as the :meth:" "`~object.__init__` method. It is used to initialize an object after it's " "created. Initializers always accept positional and keyword arguments, and " "they should return either ``0`` on success or ``-1`` on error." msgstr "" +":c:member:`~PyTypeObject.tp_init` スロットは、Python では :meth:`~object." +"__init__` メソッドとして公開されます。\n" +"作成後のオブジェクトを初期化するために使います。\n" +"初期化関数は常に位置引数とキーワード引数を受け取り、成功した場合は ``0``、エ" +"ラーの場合は ``-1`` を返す必要があります。" -#: ../../extending/newtypes_tutorial.rst:408 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 " @@ -972,8 +1287,14 @@ msgid "" "new attribute values. We might be tempted, for example to assign the " "``first`` member like this::" msgstr "" +"``tp_new`` ハンドラと異なり、``tp_init`` が呼ばれる保証はありません (例えば :" +"mod:`pickle` モジュールは、デフォルトでは unpickle したインスタンスに対して :" +"meth:`~object.__init__` を呼び出しません)。\n" +"また、複数回呼ばれることもあります。\n" +"誰でもこのオブジェクトの :meth:`!__init__` メソッドを呼び出せるからです。\n" +"そのため、新しい属性値を代入するときは特に注意する必要があります。\n" +"例えば、``first`` メンバを次のように代入したくなるかもしれません。 ::" -#: ../../extending/newtypes_tutorial.rst:416 msgid "" "if (first) {\n" " Py_XDECREF(self->first);\n" @@ -981,8 +1302,12 @@ msgid "" " self->first = first;\n" "}" msgstr "" +"if (first) {\n" +" Py_XDECREF(self->first);\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:422 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 " @@ -991,31 +1316,44 @@ msgid "" "` and let arbitrary code run in other threads that " "accesses and modifies our object." msgstr "" +"しかし、これは危険です。\n" +"この型は ``first`` メンバの型を制限していないので、どのようなオブジェクトでも" +"格納できます。\n" +"そのオブジェクトのデストラクタが、``first`` メンバにアクセスするコードを実行" +"する可能性があります。\n" +"また、デストラクタが :term:`スレッド状態 ` をデタッチ" +"し、別のスレッドで任意のコードが動いて、このオブジェクトにアクセスしたり変更" +"したりする可能性もあります。" -#: ../../extending/newtypes_tutorial.rst:429 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 "" +"この可能性にも十分に注意して対処するため、ほとんどの場合は、参照カウントを減" +"らす前にメンバに新しい値を代入します。\n" +"では、このようにする必要がないのはどのような場合でしょうか。" #: ../../extending/newtypes_tutorial.rst:433 msgid "when we absolutely know that the reference count is greater than 1;" msgstr "その参照カウントが 1 より大きいと確信できる場合" -#: ../../extending/newtypes_tutorial.rst:435 msgid "" "when we know that deallocation of the object [#]_ will neither detach the :" "term:`thread state ` nor cause any calls back into " "our type's code;" msgstr "" +"オブジェクト [#]_ の解放で、:term:`スレッド状態 ` がデ" +"タッチされることも、自分の型のコードが呼び戻されることもないと分かっている場" +"合。" -#: ../../extending/newtypes_tutorial.rst:438 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 "" +"循環ガベージコレクションをサポートしない型の :c:member:`~PyTypeObject." +"tp_dealloc` ハンドラ内で、参照カウントを減らす場合 [#]_。" #: ../../extending/newtypes_tutorial.rst:441 msgid "" @@ -1025,7 +1363,6 @@ msgstr "" "ここではインスタンス変数を属性として見えるようにしたいのですが、これにはいく" "つもの方法があります。もっとも簡単な方法は、メンバの定義を与えることです::" -#: ../../extending/newtypes_tutorial.rst:444 msgid "" "static PyMemberDef Custom_members[] = {\n" " {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" @@ -1037,6 +1374,15 @@ msgid "" " {NULL} /* Sentinel */\n" "};" msgstr "" +"static PyMemberDef Custom_members[] = {\n" +" {\"first\", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,\n" +" \"ファーストネーム\"},\n" +" {\"last\", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,\n" +" \"ラストネーム\"},\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"独自の数値\"},\n" +" {NULL} /* 番兵 */\n" +"};" #: ../../extending/newtypes_tutorial.rst:454 msgid "" @@ -1045,18 +1391,18 @@ msgstr "" "そして、この定義を :c:member:`~PyTypeObject.tp_members` スロットに入れましょ" "う::" -#: ../../extending/newtypes_tutorial.rst:456 msgid ".tp_members = Custom_members," -msgstr "" +msgstr ".tp_members = Custom_members," -#: ../../extending/newtypes_tutorial.rst:458 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 "" +"各メンバ定義には、メンバ名、型、オフセット、アクセスフラグ、ドキュメント文字" +"列があります。\n" +"詳細は後述の :ref:`Generic-Attribute-Management` 節を参照してください。" -#: ../../extending/newtypes_tutorial.rst:462 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 " @@ -1066,14 +1412,21 @@ msgid "" "``NULL`` values, the members can be set to ``NULL`` if the attributes are " "deleted." msgstr "" +"この方法の欠点は、Python の属性に代入できるオブジェクトの型を制限できないこと" +"です。\n" +"ファーストネームとラストネームには文字列を想定していますが、任意の Python オ" +"ブジェクトを代入できてしまいます。\n" +"さらに、属性を削除すると、C のポインタが ``NULL`` になります。\n" +"メンバを ``NULL`` でない値に初期化しても、属性が削除されれば ``NULL`` に設定" +"されます。" -#: ../../extending/newtypes_tutorial.rst:469 msgid "" "We define a single method, :meth:`!Custom.name`, that outputs the objects " "name as the concatenation of the first and last names. ::" msgstr "" +"ファーストネームとラストネームを連結してオブジェクトの名前を返す、:meth:`!" +"Custom.name` というメソッドを一つ定義します。 ::" -#: ../../extending/newtypes_tutorial.rst:472 msgid "" "static PyObject *\n" "Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" @@ -1090,8 +1443,21 @@ msgid "" " return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" "}" msgstr "" +"static PyObject *\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" if (self->first == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"first\");\n" +" return NULL;\n" +" }\n" +" if (self->last == NULL) {\n" +" PyErr_SetString(PyExc_AttributeError, \"last\");\n" +" return NULL;\n" +" }\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}" -#: ../../extending/newtypes_tutorial.rst:487 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 " @@ -1100,14 +1466,21 @@ msgid "" "to accept a positional argument tuple or keyword argument dictionary. This " "method is equivalent to the Python method:" msgstr "" +"このメソッドは、:class:`!Custom` (または :class:`!Custom` のサブクラス) のイ" +"ンスタンスを第 1 引数として受け取る C 関数として実装します。\n" +"メソッドは常に第 1 引数としてインスタンスを受け取ります。\n" +"多くの場合は位置引数やキーワード引数も受け取りますが、ここではどちらも受け取" +"らないため、位置引数のタプルやキーワード引数の辞書を受け取る必要はありませ" +"ん。\n" +"このメソッドは、次の Python メソッドに相当します。" -#: ../../extending/newtypes_tutorial.rst:494 msgid "" "def name(self):\n" " return \"%s %s\" % (self.first, self.last)" msgstr "" +"def name(self):\n" +" return \"%s %s\" % (self.first, self.last)" -#: ../../extending/newtypes_tutorial.rst:499 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 " @@ -1115,6 +1488,11 @@ msgid "" "of these attributes and to restrict the attribute values to be strings. " "We'll see how to do that in the next section." msgstr "" +":attr:`!first` と :attr:`!last` メンバが ``NULL`` である可能性を確認する必要" +"があります。\n" +"これらの属性は削除可能で、削除された場合は ``NULL`` に設定されるためです。\n" +"これらの属性を削除できないようにし、値を文字列に制限するとよいでしょう。\n" +"次の節でその方法を説明します。" #: ../../extending/newtypes_tutorial.rst:505 msgid "" @@ -1124,7 +1502,6 @@ msgstr "" "さて、メソッドを定義したので、ここでメソッド定義用の配列を作成する必要があり" "ます::" -#: ../../extending/newtypes_tutorial.rst:508 msgid "" "static PyMethodDef Custom_methods[] = {\n" " {\"name\", Custom_name, METH_NOARGS,\n" @@ -1133,45 +1510,55 @@ msgid "" " {NULL} /* Sentinel */\n" "};" msgstr "" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", Custom_name, METH_NOARGS,\n" +" \"ファーストネームとラストネームを連結した名前を返す\"\n" +" },\n" +" {NULL} /* 番兵 */\n" +"};" -#: ../../extending/newtypes_tutorial.rst:515 msgid "" "(note that we used the :c:macro:`METH_NOARGS` flag to indicate that the " "method is expecting no arguments other than *self*)" msgstr "" +"(``self`` 以外の引数を受け取らないことを示すために、:c:macro:`METH_NOARGS` フ" +"ラグを使っています。)" -#: ../../extending/newtypes_tutorial.rst:518 msgid "and assign it to the :c:member:`~PyTypeObject.tp_methods` slot::" msgstr "" +"そして、それを :c:member:`~PyTypeObject.tp_methods` スロットに代入します。 ::" -#: ../../extending/newtypes_tutorial.rst:520 msgid ".tp_methods = Custom_methods," -msgstr "" +msgstr ".tp_methods = Custom_methods," -#: ../../extending/newtypes_tutorial.rst:522 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 " "about the type of the object being created or used, so all we need to do is " "to add the :c:macro:`Py_TPFLAGS_BASETYPE` to our class flag definition::" msgstr "" +"最後に、この型をサブクラスの基底クラスとして使えるようにします。\n" +"ここまで、作成するオブジェクトや操作対象のオブジェクトの型を決めつけないよう" +"に注意してメソッドを書いてきました。\n" +"そのため、クラスのフラグ定義に :c:macro:`Py_TPFLAGS_BASETYPE` を追加するだけ" +"で済みます。 ::" -#: ../../extending/newtypes_tutorial.rst:527 msgid ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," -msgstr "" +msgstr ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE," -#: ../../extending/newtypes_tutorial.rst:529 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 "" +":c:func:`!PyInit_custom` を :c:func:`!PyInit_custom2` に改名し、:c:type:" +"`PyModuleDef` 構造体のモジュール名と :c:type:`PyTypeObject` 構造体の完全なク" +"ラス名を更新します。" -#: ../../extending/newtypes_tutorial.rst:533 msgid "Finally, we update our :file:`setup.py` file to include the new module," msgstr "" +"最後に、新しいモジュールを含めるよう :file:`setup.py` ファイルを更新し、" -#: ../../extending/newtypes_tutorial.rst:535 msgid "" "from setuptools import Extension, setup\n" "setup(ext_modules=[\n" @@ -1179,16 +1566,19 @@ msgid "" " Extension(\"custom2\", [\"custom2.c\"]),\n" "])" msgstr "" +"from setuptools import Extension, setup\n" +"setup(ext_modules=[\n" +" Extension(\"custom\", [\"custom.c\"]),\n" +" Extension(\"custom2\", [\"custom2.c\"]),\n" +"])" -#: ../../extending/newtypes_tutorial.rst:543 msgid "and then we re-install so that we can ``import custom2``:" -msgstr "" +msgstr "``import custom2`` ができるように再インストールします。" #: ../../extending/newtypes_tutorial.rst:550 msgid "Providing finer control over data attributes" msgstr "データ属性をこまかく制御する" -#: ../../extending/newtypes_tutorial.rst:552 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 " @@ -1196,8 +1586,12 @@ msgid "" "attr:`!last` could be set to non-string values or even deleted. We want to " "make sure that these attributes always contain strings." msgstr "" +"この節では、:class:`!Custom` の例で :attr:`!first` と :attr:`!last` 属性を設" +"定する方法を、より細かく制御します。\n" +"前のバージョンのモジュールでは、インスタンス変数 :attr:`!first` と :attr:`!" +"last` に文字列以外の値を設定でき、削除することさえできました。\n" +"これらの属性が常に文字列を格納するようにしたいと思います。" -#: ../../extending/newtypes_tutorial.rst:558 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -1390,29 +1784,85 @@ msgid "" " return PyModuleDef_Init(&custom_module);\n" "}\n" msgstr "" - -#: ../../extending/newtypes_tutorial.rst:561 -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 "" - -#: ../../extending/newtypes_tutorial.rst:565 -msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* offsetof() 用 */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* ファーストネーム */\n" +" PyObject *last; /* ラストネーム */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static void\n" +"Custom_dealloc(PyObject *op)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_XDECREF(self->first);\n" +" Py_XDECREF(self->last);\n" +" Py_TYPE(self)->tp_free(self);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_SETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_SETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"独自の数値\"},\n" +" {NULL} /* 番兵 */\n" +"};\n" +"\n" "static PyObject *\n" "Custom_getfirst(PyObject *op, void *closure)\n" "{\n" " CustomObject *self = (CustomObject *) op;\n" -" Py_INCREF(self->first);\n" -" return self->first;\n" +" return Py_NewRef(self->first);\n" "}\n" "\n" "static int\n" "Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" "{\n" " CustomObject *self = (CustomObject *) op;\n" -" PyObject *tmp;\n" " if (value == NULL) {\n" " PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " "attribute\");\n" @@ -1423,95 +1873,279 @@ msgid "" " \"The first attribute value must be a string\");\n" " return -1;\n" " }\n" -" tmp = self->first;\n" -" Py_INCREF(value);\n" -" self->first = value;\n" -" Py_DECREF(tmp);\n" +" Py_SETREF(self->first, Py_NewRef(value));\n" " return 0;\n" -"}" -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:594 -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 " -"closure supports an advanced usage in which definition data is passed to the " -"getter and setter. This could, for example, be used to allow a single set of " -"getter and setter functions that decide the attribute to get or set based on " -"data in the closure.)" -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:600 -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 being deleted. In our setter, we raise an error if the attribute is " -"deleted or if its new value is not a string." -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:605 -msgid "We create an array of :c:type:`PyGetSetDef` structures::" -msgstr "ここでは :c:type:`PyGetSetDef` 構造体の配列をつくります::" - -#: ../../extending/newtypes_tutorial.rst:607 -msgid "" -"static PyGetSetDef Custom_getsetters[] = {\n" -" {\"first\", Custom_getfirst, Custom_setfirst,\n" -" \"first name\", NULL},\n" -" {\"last\", Custom_getlast, Custom_setlast,\n" -" \"last name\", NULL},\n" -" {NULL} /* Sentinel */\n" -"};" -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:615 -msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" -msgstr "" -"そしてこれを :c:member:`~PyTypeObject.tp_getset` スロットに登録します::" - -#: ../../extending/newtypes_tutorial.rst:617 -msgid ".tp_getset = Custom_getsetters," -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:619 -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 "" - -#: ../../extending/newtypes_tutorial.rst:622 -msgid "We also remove the member definitions for these attributes::" -msgstr "また、メンバ定義からはこれらの属性を除いておきましょう::" - -#: ../../extending/newtypes_tutorial.rst:624 -msgid "" -"static PyMemberDef Custom_members[] = {\n" -" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" -" \"custom number\"},\n" -" {NULL} /* Sentinel */\n" -"};" -msgstr "" - -#: ../../extending/newtypes_tutorial.rst:630 -msgid "" -"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " -"allow strings [#]_ to be passed::" -msgstr "" -"また、ここでは :c:member:`~PyTypeObject.tp_init` ハンドラも渡されるものとして" -"文字列のみを許可するように修正する必要があります [#]_::" - -#: ../../extending/newtypes_tutorial.rst:633 -msgid "" -"static int\n" -"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_getlast(PyObject *op, void *closure)\n" "{\n" " CustomObject *self = (CustomObject *) op;\n" -" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" -" PyObject *first = NULL, *last = NULL, *tmp;\n" +" return Py_NewRef(self->last);\n" +"}\n" "\n" -" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" -" &first, &last,\n" +"static int\n" +"Custom_setlast(PyObject *op, PyObject *value, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The last attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_SETREF(self->last, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" +" \"ファーストネーム\", NULL},\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" +" \"ラストネーム\", NULL},\n" +" {NULL} /* 番兵 */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", Custom_name, METH_NOARGS,\n" +" \"ファーストネームとラストネームを連結した名前を返す\"\n" +" },\n" +" {NULL} /* 番兵 */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom3.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom オブジェクト\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_new = Custom_new,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +" .tp_getset = Custom_getsetters,\n" +"};\n" +"\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom3\",\n" +" .m_doc = \"拡張型を作成するサンプルモジュール。\",\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom3(void)\n" +"{\n" +" return PyModuleDef_Init(&custom_module);\n" +"}\n" + +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 "" +":attr:`!first` と :attr:`!last` 属性をもっと細かく制御するため、独自の " +"getter 関数と setter 関数を使います。\n" +":attr:`!first` 属性を取得、設定する関数は次のとおりです。 ::" + +msgid "" +"static PyObject *\n" +"Custom_getfirst(PyObject *op, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_INCREF(self->first);\n" +" return self->first;\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" PyObject *tmp;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" tmp = self->first;\n" +" Py_INCREF(value);\n" +" self->first = value;\n" +" Py_DECREF(tmp);\n" +" return 0;\n" +"}" +msgstr "" +"static PyObject *\n" +"Custom_getfirst(PyObject *op, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_INCREF(self->first);\n" +" return self->first;\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" PyObject *tmp;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" tmp = self->first;\n" +" Py_INCREF(value);\n" +" self->first = value;\n" +" Py_DECREF(tmp);\n" +" return 0;\n" +"}" + +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 " +"closure supports an advanced usage in which definition data is passed to the " +"getter and setter. This could, for example, be used to allow a single set of " +"getter and setter functions that decide the attribute to get or set based on " +"data in the closure.)" +msgstr "" +"getter 関数には、:class:`!Custom` オブジェクトと、void ポインタである「クロー" +"ジャ」を渡します。\n" +"ここではクロージャを無視します。\n" +"(クロージャは、定義に関するデータを getter や setter に渡す高度な使い方をサ" +"ポートします。\n" +"例えば、クロージャ内のデータに応じて取得や設定を行う属性を決める、一組の " +"getter 関数と setter 関数を用意できます。)" + +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 being deleted. In our setter, we raise an error if the attribute is " +"deleted or if its new value is not a string." +msgstr "" +"setter 関数には、:class:`!Custom` オブジェクト、新しい値、クロージャを渡しま" +"す。\n" +"新しい値が ``NULL`` の場合は、属性の削除を意味します。\n" +"今回の setter では、属性を削除しようとした場合や、新しい値が文字列でない場合" +"にエラーを送出します。" + +#: ../../extending/newtypes_tutorial.rst:605 +msgid "We create an array of :c:type:`PyGetSetDef` structures::" +msgstr "ここでは :c:type:`PyGetSetDef` 構造体の配列をつくります::" + +msgid "" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" +" \"first name\", NULL},\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" +" \"last name\", NULL},\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" +" \"ファーストネーム\", NULL},\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" +" \"ラストネーム\", NULL},\n" +" {NULL} /* 番兵 */\n" +"};" + +#: ../../extending/newtypes_tutorial.rst:615 +msgid "and register it in the :c:member:`~PyTypeObject.tp_getset` slot::" +msgstr "" +"そしてこれを :c:member:`~PyTypeObject.tp_getset` スロットに登録します::" + +msgid ".tp_getset = Custom_getsetters," +msgstr ".tp_getset = Custom_getsetters," + +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 "" +":c:type:`PyGetSetDef` 構造体の最後の項目は、先ほど説明した「クロージャ」で" +"す。\n" +"ここではクロージャを使わないので、単に ``NULL`` を渡します。" + +#: ../../extending/newtypes_tutorial.rst:622 +msgid "We also remove the member definitions for these attributes::" +msgstr "また、メンバ定義からはこれらの属性を除いておきましょう::" + +msgid "" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};" +msgstr "" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"独自の数値\"},\n" +" {NULL} /* 番兵 */\n" +"};" + +#: ../../extending/newtypes_tutorial.rst:630 +msgid "" +"We also need to update the :c:member:`~PyTypeObject.tp_init` handler to only " +"allow strings [#]_ to be passed::" +msgstr "" +"また、ここでは :c:member:`~PyTypeObject.tp_init` ハンドラも渡されるものとして" +"文字列のみを許可するように修正する必要があります [#]_::" + +msgid "" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" " &self->number))\n" " return -1;\n" "\n" @@ -1530,8 +2164,33 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL, *tmp;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" tmp = self->first;\n" +" Py_INCREF(first);\n" +" self->first = first;\n" +" Py_DECREF(tmp);\n" +" }\n" +" if (last) {\n" +" tmp = self->last;\n" +" Py_INCREF(last);\n" +" self->last = last;\n" +" Py_DECREF(tmp);\n" +" }\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:660 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 " @@ -1540,6 +2199,12 @@ msgid "" "these calls is in the ``tp_dealloc`` implementation, where there is the " "possibility that the initialization of these members failed in ``tp_new``." msgstr "" +"これらの変更により、``first`` と ``last`` メンバが ``NULL`` にならないことを" +"保証できるため、ほとんどの場合は ``NULL`` のチェックを削除できます。\n" +"つまり、:c:func:`Py_XDECREF` の呼び出しのほとんどを :c:func:`Py_DECREF` に置" +"き換えられます。\n" +"唯一置き換えられないのは ``tp_dealloc`` の実装内です。\n" +"``tp_new`` でこれらのメンバの初期化に失敗した可能性があるためです。" #: ../../extending/newtypes_tutorial.rst:667 msgid "" @@ -1566,12 +2231,14 @@ msgstr "" "ることができます。そのような状況はオブジェクトの参照が循環しているときに起こ" "りえます。たとえば以下の例を考えてください:" -#: ../../extending/newtypes_tutorial.rst:679 msgid "" ">>> l = []\n" ">>> l.append(l)\n" ">>> del l" msgstr "" +">>> l = []\n" +">>> l.append(l)\n" +">>> del l" #: ../../extending/newtypes_tutorial.rst:685 msgid "" @@ -1585,7 +2252,6 @@ msgstr "" "りません。嬉しいことに Python には循環ガベージコレクタは最終的にはこのリスト" "が不要であることを検出し、解放できます。" -#: ../../extending/newtypes_tutorial.rst:690 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 " @@ -1593,8 +2259,14 @@ msgid "" "class:`!Custom`, and subclasses may add arbitrary attributes. For any of " "those two reasons, :class:`!Custom` objects can participate in cycles:" msgstr "" +":class:`!Custom` の例の第 2 版では、:attr:`!first` と :attr:`!last` 属性にど" +"のようなオブジェクトでも格納できるようにしました [#]_。\n" +"さらに、第 2 版と第 3 版では :class:`!Custom` のサブクラス化を許可しまし" +"た。\n" +"サブクラスには任意の属性を追加できます。\n" +"これらのどちらの理由によっても、:class:`!Custom` オブジェクトが参照の循環に加" +"わる可能性があります。" -#: ../../extending/newtypes_tutorial.rst:696 msgid "" ">>> import custom3\n" ">>> class Derived(custom3.Custom): pass\n" @@ -1602,25 +2274,242 @@ msgid "" ">>> n = Derived()\n" ">>> n.some_attribute = n" msgstr "" +">>> import custom3\n" +">>> class Derived(custom3.Custom): pass\n" +"...\n" +">>> n = Derived()\n" +">>> n.some_attribute = n" -#: ../../extending/newtypes_tutorial.rst:704 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 needs to fill two additional slots and to enable a flag that enables " "these slots:" msgstr "" - -#: ../../extending/newtypes_tutorial.rst:708 -msgid "" +"参照の循環に加わった :class:`!Custom` インスタンスを循環 GC が正しく検出して" +"回収できるようにするには、:class:`!Custom` 型でさらに二つのスロットを設定し、" +"それらのスロットを有効にするフラグを設定する必要があります。" + +msgid "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"#include /* for offsetof() */\n" +"\n" +"typedef struct {\n" +" PyObject_HEAD\n" +" PyObject *first; /* first name */\n" +" PyObject *last; /* last name */\n" +" int number;\n" +"} CustomObject;\n" +"\n" +"static int\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_VISIT(self->first);\n" +" Py_VISIT(self->last);\n" +" return 0;\n" +"}\n" +"\n" +"static int\n" +"Custom_clear(PyObject *op)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_CLEAR(self->first);\n" +" Py_CLEAR(self->last);\n" +" return 0;\n" +"}\n" +"\n" +"static void\n" +"Custom_dealloc(PyObject *op)\n" +"{\n" +" PyObject_GC_UnTrack(op);\n" +" (void)Custom_clear(op);\n" +" Py_TYPE(op)->tp_free(op);\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self;\n" +" self = (CustomObject *) type->tp_alloc(type, 0);\n" +" if (self != NULL) {\n" +" self->first = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->first == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->last = Py_GetConstant(Py_CONSTANT_EMPTY_STR);\n" +" if (self->last == NULL) {\n" +" Py_DECREF(self);\n" +" return NULL;\n" +" }\n" +" self->number = 0;\n" +" }\n" +" return (PyObject *) self;\n" +"}\n" +"\n" +"static int\n" +"Custom_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" static char *kwlist[] = {\"first\", \"last\", \"number\", NULL};\n" +" PyObject *first = NULL, *last = NULL;\n" +"\n" +" if (!PyArg_ParseTupleAndKeywords(args, kwds, \"|UUi\", kwlist,\n" +" &first, &last,\n" +" &self->number))\n" +" return -1;\n" +"\n" +" if (first) {\n" +" Py_SETREF(self->first, Py_NewRef(first));\n" +" }\n" +" if (last) {\n" +" Py_SETREF(self->last, Py_NewRef(last));\n" +" }\n" +" return 0;\n" +"}\n" +"\n" +"static PyMemberDef Custom_members[] = {\n" +" {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" +" \"custom number\"},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_getfirst(PyObject *op, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" return Py_NewRef(self->first);\n" +"}\n" +"\n" +"static int\n" +"Custom_setfirst(PyObject *op, PyObject *value, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the first " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The first attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_XSETREF(self->first, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyObject *\n" +"Custom_getlast(PyObject *op, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" return Py_NewRef(self->last);\n" +"}\n" +"\n" +"static int\n" +"Custom_setlast(PyObject *op, PyObject *value, void *closure)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" if (value == NULL) {\n" +" PyErr_SetString(PyExc_TypeError, \"Cannot delete the last " +"attribute\");\n" +" return -1;\n" +" }\n" +" if (!PyUnicode_Check(value)) {\n" +" PyErr_SetString(PyExc_TypeError,\n" +" \"The last attribute value must be a string\");\n" +" return -1;\n" +" }\n" +" Py_XSETREF(self->last, Py_NewRef(value));\n" +" return 0;\n" +"}\n" +"\n" +"static PyGetSetDef Custom_getsetters[] = {\n" +" {\"first\", Custom_getfirst, Custom_setfirst,\n" +" \"first name\", NULL},\n" +" {\"last\", Custom_getlast, Custom_setlast,\n" +" \"last name\", NULL},\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyObject *\n" +"Custom_name(PyObject *op, PyObject *Py_UNUSED(dummy))\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" return PyUnicode_FromFormat(\"%S %S\", self->first, self->last);\n" +"}\n" +"\n" +"static PyMethodDef Custom_methods[] = {\n" +" {\"name\", Custom_name, METH_NOARGS,\n" +" \"Return the name, combining the first and last name\"\n" +" },\n" +" {NULL} /* Sentinel */\n" +"};\n" +"\n" +"static PyTypeObject CustomType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"custom4.Custom\",\n" +" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_basicsize = sizeof(CustomObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | " +"Py_TPFLAGS_HAVE_GC,\n" +" .tp_new = Custom_new,\n" +" .tp_init = Custom_init,\n" +" .tp_dealloc = Custom_dealloc,\n" +" .tp_traverse = Custom_traverse,\n" +" .tp_clear = Custom_clear,\n" +" .tp_members = Custom_members,\n" +" .tp_methods = Custom_methods,\n" +" .tp_getset = Custom_getsetters,\n" +"};\n" +"\n" +"static int\n" +"custom_module_exec(PyObject *m)\n" +"{\n" +" if (PyType_Ready(&CustomType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"Custom\", (PyObject *) &CustomType) < 0) " +"{\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot custom_module_slots[] = {\n" +" {Py_mod_exec, custom_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef custom_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"custom4\",\n" +" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_size = 0,\n" +" .m_slots = custom_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_custom4(void)\n" +"{\n" +" return PyModuleDef_Init(&custom_module);\n" +"}\n" +msgstr "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" -"#include /* for offsetof() */\n" +"#include /* offsetof() 用 */\n" "\n" "typedef struct {\n" " PyObject_HEAD\n" -" PyObject *first; /* first name */\n" -" PyObject *last; /* last name */\n" +" PyObject *first; /* ファーストネーム */\n" +" PyObject *last; /* ラストネーム */\n" " int number;\n" "} CustomObject;\n" "\n" @@ -1694,8 +2583,8 @@ msgid "" "\n" "static PyMemberDef Custom_members[] = {\n" " {\"number\", Py_T_INT, offsetof(CustomObject, number), 0,\n" -" \"custom number\"},\n" -" {NULL} /* Sentinel */\n" +" \"独自の数値\"},\n" +" {NULL} /* 番兵 */\n" "};\n" "\n" "static PyObject *\n" @@ -1750,10 +2639,10 @@ msgid "" "\n" "static PyGetSetDef Custom_getsetters[] = {\n" " {\"first\", Custom_getfirst, Custom_setfirst,\n" -" \"first name\", NULL},\n" +" \"ファーストネーム\", NULL},\n" " {\"last\", Custom_getlast, Custom_setlast,\n" -" \"last name\", NULL},\n" -" {NULL} /* Sentinel */\n" +" \"ラストネーム\", NULL},\n" +" {NULL} /* 番兵 */\n" "};\n" "\n" "static PyObject *\n" @@ -1765,15 +2654,15 @@ msgid "" "\n" "static PyMethodDef Custom_methods[] = {\n" " {\"name\", Custom_name, METH_NOARGS,\n" -" \"Return the name, combining the first and last name\"\n" +" \"ファーストネームとラストネームを連結した名前を返す\"\n" " },\n" -" {NULL} /* Sentinel */\n" +" {NULL} /* 番兵 */\n" "};\n" "\n" "static PyTypeObject CustomType = {\n" " .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" " .tp_name = \"custom4.Custom\",\n" -" .tp_doc = PyDoc_STR(\"Custom objects\"),\n" +" .tp_doc = PyDoc_STR(\"Custom オブジェクト\"),\n" " .tp_basicsize = sizeof(CustomObject),\n" " .tp_itemsize = 0,\n" " .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | " @@ -1813,7 +2702,7 @@ msgid "" "static PyModuleDef custom_module = {\n" " .m_base = PyModuleDef_HEAD_INIT,\n" " .m_name = \"custom4\",\n" -" .m_doc = \"Example module that creates an extension type.\",\n" +" .m_doc = \"拡張型を作成するサンプルモジュール。\",\n" " .m_size = 0,\n" " .m_slots = custom_module_slots,\n" "};\n" @@ -1823,15 +2712,14 @@ msgid "" "{\n" " return PyModuleDef_Init(&custom_module);\n" "}\n" -msgstr "" -#: ../../extending/newtypes_tutorial.rst:711 msgid "" "First, the traversal method lets the cyclic GC know about subobjects that " "could participate in cycles::" msgstr "" +"まず、走査メソッドによって、参照の循環に加わる可能性のある子オブジェクトを循" +"環 GC に知らせます。 ::" -#: ../../extending/newtypes_tutorial.rst:714 msgid "" "static int\n" "Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" @@ -1851,8 +2739,24 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" int vret;\n" +" if (self->first) {\n" +" vret = visit(self->first, arg);\n" +" if (vret != 0)\n" +" return vret;\n" +" }\n" +" if (self->last) {\n" +" vret = visit(self->last, arg);\n" +" if (vret != 0)\n" +" return vret;\n" +" }\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:732 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:" @@ -1860,15 +2764,22 @@ msgid "" "*arg* passed to the traversal method. It returns an integer value that must " "be returned if it is non-zero." msgstr "" +"参照の循環に加わる可能性のある子オブジェクトごとに、走査メソッドに渡された :" +"c:func:`!visit` 関数を呼び出す必要があります。\n" +":c:func:`!visit` 関数は、子オブジェクトと、走査メソッドに渡された追加の引数 " +"``arg`` を受け取ります。\n" +"戻り値は整数で、ゼロでなければその値をそのまま返す必要があります。" -#: ../../extending/newtypes_tutorial.rst:738 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 "" +"Python には、visit 関数の呼び出しを自動化する :c:func:`Py_VISIT` マクロがあり" +"ます。\n" +":c:func:`Py_VISIT` を使うと、``Custom_traverse`` の定型的なコードを最小限にで" +"きます。 ::" -#: ../../extending/newtypes_tutorial.rst:742 msgid "" "static int\n" "Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" @@ -1879,20 +2790,29 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_traverse(PyObject *op, visitproc visit, void *arg)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_VISIT(self->first);\n" +" Py_VISIT(self->last);\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:752 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 "" +":c:func:`Py_VISIT` を使うには、:c:member:`~PyTypeObject.tp_traverse` の実装" +"で、引数の名前を必ず ``visit`` と ``arg`` にする必要があります。" -#: ../../extending/newtypes_tutorial.rst:755 msgid "" "Second, we need to provide a method for clearing any subobjects that can " "participate in cycles::" msgstr "" +"次に、参照の循環に加わる可能性のある子オブジェクトをすべてクリアするメソッド" +"を用意する必要があります。 ::" -#: ../../extending/newtypes_tutorial.rst:758 msgid "" "static int\n" "Custom_clear(PyObject *op)\n" @@ -1903,8 +2823,15 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"Custom_clear(PyObject *op)\n" +"{\n" +" CustomObject *self = (CustomObject *) op;\n" +" Py_CLEAR(self->first);\n" +" Py_CLEAR(self->last);\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:767 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 " @@ -1913,27 +2840,36 @@ msgid "" "attribute's destructor would call back into code that reads the attribute " "again (*especially* if there is a reference cycle)." msgstr "" +":c:func:`Py_CLEAR` マクロを使っていることに注目してください。\n" +"これは、参照カウントを減らしながら任意の型のデータ属性をクリアする、推奨され" +"る安全な方法です。\n" +"属性を ``NULL`` に設定する前に、代わりに :c:func:`Py_XDECREF` を呼び出すと、" +"属性のデストラクタがその属性を再び読み取るコードを呼び出す可能性があります " +"(参照の循環がある場合は *特に* 注意が必要です)。" -#: ../../extending/newtypes_tutorial.rst:775 msgid "You could emulate :c:func:`Py_CLEAR` by writing::" -msgstr "" +msgstr ":c:func:`Py_CLEAR` と同じ処理は、次のようにも書けます。 ::" -#: ../../extending/newtypes_tutorial.rst:777 msgid "" "PyObject *tmp;\n" "tmp = self->first;\n" "self->first = NULL;\n" "Py_XDECREF(tmp);" msgstr "" +"PyObject *tmp;\n" +"tmp = self->first;\n" +"self->first = NULL;\n" +"Py_XDECREF(tmp);" -#: ../../extending/newtypes_tutorial.rst:782 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 "" +"それでも、属性を削除するときは常に :c:func:`Py_CLEAR` を使う方が、はるかに簡" +"単で間違いも少なくなります。\n" +"堅牢性を犠牲にしてまで細かな最適化を試みないでください。" -#: ../../extending/newtypes_tutorial.rst:786 msgid "" "The deallocator ``Custom_dealloc`` may call arbitrary code when clearing " "attributes. It means the circular GC can be triggered inside the function. " @@ -1942,8 +2878,15 @@ msgid "" "members. Here is our reimplemented deallocator using :c:func:" "`PyObject_GC_UnTrack` and ``Custom_clear``::" msgstr "" +"メモリ解放関数 ``Custom_dealloc`` は、属性のクリア時に任意のコードを呼び出す" +"可能性があります。\n" +"つまり、この関数内で循環 GC が実行される可能性があります。\n" +"GC は参照カウントがゼロでないことを前提としているため、メンバをクリアする前" +"に :c:func:`PyObject_GC_UnTrack` を呼び出して、GC の追跡対象からオブジェクト" +"を外す必要があります。\n" +":c:func:`PyObject_GC_UnTrack` と ``Custom_clear`` を使って書き直したメモリ解" +"放関数は次のとおりです。 ::" -#: ../../extending/newtypes_tutorial.rst:793 msgid "" "static void\n" "Custom_dealloc(PyObject *op)\n" @@ -1953,16 +2896,24 @@ msgid "" " Py_TYPE(op)->tp_free(op);\n" "}" msgstr "" +"static void\n" +"Custom_dealloc(PyObject *op)\n" +"{\n" +" PyObject_GC_UnTrack(op);\n" +" (void)Custom_clear(op);\n" +" Py_TYPE(op)->tp_free(op);\n" +"}" -#: ../../extending/newtypes_tutorial.rst:801 msgid "" "Finally, we add the :c:macro:`Py_TPFLAGS_HAVE_GC` flag to the class flags::" msgstr "" +"最後に、クラスのフラグに :c:macro:`Py_TPFLAGS_HAVE_GC` フラグを追加しま" +"す。 ::" -#: ../../extending/newtypes_tutorial.rst:803 msgid "" ".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," msgstr "" +".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC," #: ../../extending/newtypes_tutorial.rst:805 msgid "" @@ -1992,15 +2943,17 @@ msgstr "" "す。それに比べて、 :c:type:`PyTypeObject` 構造体を拡張モジュール間で共有する" "のは難しいです。" -#: ../../extending/newtypes_tutorial.rst:818 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 " "with regular lists, but will have an additional :meth:`!increment` method " "that increases an internal counter:" msgstr "" +"この例では、組み込みの :class:`list` 型を継承した :class:`!SubList` 型を作成" +"します。\n" +"新しい型は通常のリストと完全な互換性を持ち、さらに内部カウンタを増やす :meth:" +"`!increment` メソッドを持ちます。" -#: ../../extending/newtypes_tutorial.rst:823 msgid "" ">>> import sublist\n" ">>> s = sublist.SubList(range(3))\n" @@ -2012,8 +2965,16 @@ msgid "" ">>> print(s.increment())\n" "2" msgstr "" +">>> import sublist\n" +">>> s = sublist.SubList(range(3))\n" +">>> s.extend(s)\n" +">>> print(len(s))\n" +"6\n" +">>> print(s.increment())\n" +"1\n" +">>> print(s.increment())\n" +"2" -#: ../../extending/newtypes_tutorial.rst:835 msgid "" "#define PY_SSIZE_T_CLEAN\n" "#include \n" @@ -2095,37 +3056,124 @@ msgid "" " return PyModuleDef_Init(&sublist_module);\n" "}\n" msgstr "" +"#define PY_SSIZE_T_CLEAN\n" +"#include \n" +"\n" +"typedef struct {\n" +" PyListObject list;\n" +" int state;\n" +"} SubListObject;\n" +"\n" +"static PyObject *\n" +"SubList_increment(PyObject *op, PyObject *Py_UNUSED(dummy))\n" +"{\n" +" SubListObject *self = (SubListObject *) op;\n" +" self->state++;\n" +" return PyLong_FromLong(self->state);\n" +"}\n" +"\n" +"static PyMethodDef SubList_methods[] = {\n" +" {\"increment\", SubList_increment, METH_NOARGS,\n" +" PyDoc_STR(\"状態カウンタを増やす\")},\n" +" {NULL},\n" +"};\n" +"\n" +"static int\n" +"SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" SubListObject *self = (SubListObject *) op;\n" +" if (PyList_Type.tp_init(op, args, kwds) < 0)\n" +" return -1;\n" +" self->state = 0;\n" +" return 0;\n" +"}\n" +"\n" +"static PyTypeObject SubListType = {\n" +" .ob_base = PyVarObject_HEAD_INIT(NULL, 0)\n" +" .tp_name = \"sublist.SubList\",\n" +" .tp_doc = PyDoc_STR(\"SubList オブジェクト\"),\n" +" .tp_basicsize = sizeof(SubListObject),\n" +" .tp_itemsize = 0,\n" +" .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n" +" .tp_init = SubList_init,\n" +" .tp_methods = SubList_methods,\n" +"};\n" +"\n" +"static int\n" +"sublist_module_exec(PyObject *m)\n" +"{\n" +" SubListType.tp_base = &PyList_Type;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " +"0) {\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}\n" +"\n" +"static PyModuleDef_Slot sublist_module_slots[] = {\n" +" {Py_mod_exec, sublist_module_exec},\n" +" {Py_mod_multiple_interpreters, " +"Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},\n" +" {0, NULL}\n" +"};\n" +"\n" +"static PyModuleDef sublist_module = {\n" +" .m_base = PyModuleDef_HEAD_INIT,\n" +" .m_name = \"sublist\",\n" +" .m_doc = \"拡張型を作成するサンプルモジュール。\",\n" +" .m_size = 0,\n" +" .m_slots = sublist_module_slots,\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_sublist(void)\n" +"{\n" +" return PyModuleDef_Init(&sublist_module);\n" +"}\n" -#: ../../extending/newtypes_tutorial.rst:838 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 "" +"見てのとおり、ソースコードは前の節の :class:`!Custom` の例によく似ていま" +"す。\n" +"主な違いを順に見ていきましょう。 ::" -#: ../../extending/newtypes_tutorial.rst:841 msgid "" "typedef struct {\n" " PyListObject list;\n" " int state;\n" "} SubListObject;" msgstr "" +"typedef struct {\n" +" PyListObject list;\n" +" int state;\n" +"} SubListObject;" -#: ../../extending/newtypes_tutorial.rst:846 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 "" +"派生型のオブジェクトで最も大きな違いは、先頭のメンバを基底型のオブジェクト構" +"造体にする必要があることです。\n" +"基底型の構造体には、すでに先頭に :c:func:`PyObject_HEAD` が含まれています。" -#: ../../extending/newtypes_tutorial.rst:850 msgid "" "When a Python object is a :class:`!SubList` instance, its ``PyObject *`` " "pointer can be safely cast to both ``PyListObject *`` and ``SubListObject " "*``::" msgstr "" +"Python オブジェクトが :class:`!SubList` のインスタンスである場合、その " +"``PyObject *`` ポインタは ``PyListObject *`` と ``SubListObject *`` のどちら" +"にも安全にキャストできます。 ::" -#: ../../extending/newtypes_tutorial.rst:853 msgid "" "static int\n" "SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" @@ -2137,14 +3185,23 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"SubList_init(PyObject *op, PyObject *args, PyObject *kwds)\n" +"{\n" +" SubListObject *self = (SubListObject *) op;\n" +" if (PyList_Type.tp_init(op, args, kwds) < 0)\n" +" return -1;\n" +" self->state = 0;\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:863 msgid "" "We see above how to call through to the :meth:`~object.__init__` method of " "the base type." msgstr "" +"上の例は、基底型の :meth:`~object.__init__` メソッドを呼び出す方法を示してい" +"ます。" -#: ../../extending/newtypes_tutorial.rst:866 msgid "" "This pattern is important when writing a type with custom :c:member:" "`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_dealloc` members. " @@ -2152,16 +3209,25 @@ msgid "" "memory for the object with its :c:member:`~PyTypeObject.tp_alloc`, but let " "the base class handle it by calling its own :c:member:`~PyTypeObject.tp_new`." msgstr "" +"この方法は、独自の :c:member:`~PyTypeObject.tp_new` と :c:member:" +"`~PyTypeObject.tp_dealloc` メンバを持つ型を書くときに重要です。\n" +":c:member:`~PyTypeObject.tp_new` ハンドラでは、自身の :c:member:" +"`~PyTypeObject.tp_alloc` でオブジェクトのメモリを割り当てるのではなく、基底ク" +"ラスの :c:member:`~PyTypeObject.tp_new` を呼び出して、基底クラスに処理を任せ" +"るべきです。" -#: ../../extending/newtypes_tutorial.rst:872 msgid "" "The :c:type:`PyTypeObject` struct supports a :c:member:`~PyTypeObject." "tp_base` specifying the type's concrete base class. Due to cross-platform " "compiler issues, you can't fill that field directly with a reference to :c:" "type:`PyList_Type`; it should be done in the :c:data:`Py_mod_exec` function::" msgstr "" +":c:type:`PyTypeObject` 構造体には、型の具体的な基底クラスを指定する :c:" +"member:`~PyTypeObject.tp_base` があります。\n" +"プラットフォーム間のコンパイラの違いによる問題があるため、このフィールドに :" +"c:type:`PyList_Type` への参照を直接設定することはできません。\n" +":c:data:`Py_mod_exec` 関数内で設定してください。 ::" -#: ../../extending/newtypes_tutorial.rst:878 msgid "" "static int\n" "sublist_module_exec(PyObject *m)\n" @@ -2179,8 +3245,22 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int\n" +"sublist_module_exec(PyObject *m)\n" +"{\n" +" SubListType.tp_base = &PyList_Type;\n" +" if (PyType_Ready(&SubListType) < 0) {\n" +" return -1;\n" +" }\n" +"\n" +" if (PyModule_AddObjectRef(m, \"SubList\", (PyObject *) &SubListType) < " +"0) {\n" +" return -1;\n" +" }\n" +"\n" +" return 0;\n" +"}" -#: ../../extending/newtypes_tutorial.rst:893 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 " @@ -2188,17 +3268,18 @@ msgid "" "tp_alloc` slot with :c:func:`PyType_GenericNew` -- the allocation function " "from the base type will be inherited." msgstr "" -":c:func:`PyType_Read` を呼ぶ前に、型の構造体の :c:member:`~PyTypeObject." -"tp_base` スロットは埋められていなければなりません。既存の型を継承する際に" -"は、 :c:member:`~PyTypeObject.tp_alloc` スロットを :c:func:" -"`PyType_GenericNew` で埋める必要はありません。 -- 基底型のアロケーション関数" -"が継承されます。" +":c:func:`PyType_Ready` を呼び出す前に、型の構造体の :c:member:`~PyTypeObject." +"tp_base` スロットを設定しておく必要があります。\n" +"既存の型から派生させる場合、:c:member:`~PyTypeObject.tp_alloc` スロットを :c:" +"func:`PyType_GenericNew` で設定する必要はありません。\n" +"基底型の割り当て関数が継承されます。" -#: ../../extending/newtypes_tutorial.rst:899 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 "" +"その後の :c:func:`PyType_Ready` の呼び出しと型オブジェクトのモジュールへの追" +"加は、基本的な :class:`!Custom` の例と同じです。" #: ../../extending/newtypes_tutorial.rst:904 msgid "Footnotes" @@ -2212,13 +3293,13 @@ msgstr "" "これはそのオブジェクトが文字列や実数などの基本タイプであるような時に成り立ち" "ます。" -#: ../../extending/newtypes_tutorial.rst:908 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 "" +"この例の :c:member:`~PyTypeObject.tp_dealloc` ハンドラでは、型がガベージコレ" +"クションをサポートしていないため、この点を利用しました。" -#: ../../extending/newtypes_tutorial.rst:911 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 " @@ -2227,10 +3308,16 @@ msgid "" "deallocating an instance of a string subclass won't call back into our " "objects." msgstr "" +"``first`` と ``last`` メンバが文字列だと分かったので、参照カウントを減らすと" +"きの注意を少し省けるかもしれません。\n" +"しかし、ここでは文字列のサブクラスのインスタンスも受け付けます。\n" +"通常の文字列の解放が自分のオブジェクトを呼び戻すことはありませんが、文字列の" +"サブクラスのインスタンスを解放するときにもそうならないとは保証できません。" -#: ../../extending/newtypes_tutorial.rst:917 msgid "" "Also, even with our attributes restricted to strings instances, the user " "could pass arbitrary :class:`str` subclasses and therefore still create " "reference cycles." msgstr "" +"また、属性を文字列のインスタンスに制限しても、ユーザーは任意の :class:`str` " +"サブクラスを渡せるので、依然として参照の循環を作れます。" diff --git a/extending/windows.po b/extending/windows.po index a2bee8ed7..65b4015f3 100644 --- a/extending/windows.po +++ b/extending/windows.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../extending/windows.rst:8 @@ -71,7 +71,6 @@ msgstr "" msgid "A Cookbook Approach" msgstr "型どおりのアプローチ" -#: ../../extending/windows.rst:36 msgid "" "There are two approaches to building extension modules on Windows, just as " "there are on Unix: use the ``setuptools`` package to control the build " @@ -82,6 +81,14 @@ msgid "" "project file for the :source:`winsound ` standard " "library module." msgstr "" +"Unix と同様、Windows で拡張モジュールをビルドする方法には、``setuptools`` " +"パッケージでビルドを制御する方法と、手動で行う方法の 2 つがあります。\n" +"ほとんどの拡張では setuptools が適しています。\n" +"``setuptools`` による拡張モジュールのビルドとパッケージ化の説明は、:ref:" +"`setuptools-index` にあります。\n" +"手動で行う必要がある場合は、標準ライブラリの :source:`winsound ` モジュールのプロジェクトファイルを調べると参考になるでしょ" +"う。" #: ../../extending/windows.rst:48 msgid "Differences Between Unix and Windows" @@ -97,7 +104,6 @@ msgstr "" "ます。動的ロードされるようなモジュールをビルドしようとする前に、自分のシステ" "ムがどのように動作するか知っておいてください。" -#: ../../extending/windows.rst:54 msgid "" "In Unix, a shared object (:file:`.so`) file contains code to be used by the " "program, and also the names of functions and data that it expects to find in " @@ -106,11 +112,11 @@ msgid "" "actual locations in the program where the functions and data are placed in " "memory. This is basically a link operation." msgstr "" -"Unix では、共有オブジェクト (:file:`.so`) ファイルにプログラムが使うコード、" -"そしてプログラム内で使う関数名やデータが入っています。ファイルがプログラムに" -"結合されると、これらの関数やデータに対するファイルのコード内の全ての参照は、" -"メモリ内で関数やデータが配置されている、プログラム中の実際の場所を指すように" -"変更されます。これは基本的にはリンク操作にあたります。" +"Unix の共有オブジェクト (:file:`.so`) ファイルには、プログラムが使うコードに" +"加え、プログラム内に存在すると想定する関数やデータの名前が含まれています。\n" +"ファイルをプログラムに組み込むと、ファイル内のコードからそれらの関数やデータ" +"への参照は、メモリ上の実際の配置先を指すように変更されます。\n" +"これは基本的にリンク操作です。" #: ../../extending/windows.rst:61 msgid "" @@ -199,28 +205,31 @@ msgstr "" "作成したりはしません。Unix では、ライブラリとのリンクはむしろ ``from spam " "import *`` に似ています; この操作では個別にコードのコピーを生成します。" -#: ../../extending/windows.rst:98 msgid "" "Turn off the implicit, ``#pragma``-based linkage with the Python library, " "performed inside CPython header files." msgstr "" +"CPython のヘッダーファイル内で行われる、``#pragma`` による Python ライブラリ" +"への暗黙のリンクを無効にします。" #: ../../extending/windows.rst:107 msgid "Using DLLs in Practice" msgstr "DLL 使用の実際" -#: ../../extending/windows.rst:109 msgid "" "Windows Python is built in Microsoft Visual C++; using other compilers may " "or may not work. The rest of this section is MSVC++ specific." msgstr "" +"Windows 版 Python は Microsoft Visual C++ でビルドされています。\n" +"ほかのコンパイラで動作するかどうかは分かりません。\n" +"この節の残りは、MSVC++ 固有の説明です。" -#: ../../extending/windows.rst:112 msgid "" "When creating DLLs in Windows, you can use the CPython library in two ways:" msgstr "" +"Windows で DLL を作成する場合、CPython のライブラリを使う方法は 2 つありま" +"す。" -#: ../../extending/windows.rst:114 msgid "" "By default, inclusion of :file:`PC/pyconfig.h` directly or via :file:`Python." "h` triggers an implicit, configure-aware link with the library. The header " @@ -228,26 +237,37 @@ msgid "" "Release, and :file:`pythonX.lib` for Release with the :ref:`Limited API " "` enabled." msgstr "" +"デフォルトでは、:file:`PC/pyconfig.h` を直接、または :file:`Python.h` を通じ" +"てインクルードすると、設定に応じたライブラリが暗黙にリンクされます。\n" +"ヘッダーファイルは、Debug では :file:`pythonXY_d.lib`、Release では :file:" +"`pythonXY.lib`、:ref:`Limited API ` を有" +"効にした Release では :file:`pythonX.lib` を選びます。" -#: ../../extending/windows.rst:120 ../../extending/windows.rst:138 msgid "" "To build two DLLs, spam and ni (which uses C functions found in spam), you " "could use these commands::" msgstr "" +"spam と、spam 内の C 関数を使う ni という 2 つの DLL をビルドするには、次のコ" +"マンドを使えます。 ::" -#: ../../extending/windows.rst:123 msgid "" "cl /LD /I/python/include spam.c\n" "cl /LD /I/python/include ni.c spam.lib" msgstr "" +"cl /LD /I/python/include spam.c\n" +"cl /LD /I/python/include ni.c spam.lib" -#: ../../extending/windows.rst:126 msgid "" "The first command created three files: :file:`spam.obj`, :file:`spam.dll` " "and :file:`spam.lib`. :file:`Spam.dll` does not contain any Python " "functions (such as :c:func:`PyArg_ParseTuple`), but it does know how to find " "the Python code thanks to the implicitly linked :file:`pythonXY.lib`." msgstr "" +"最初のコマンドは、:file:`spam.obj`、:file:`spam.dll`、:file:`spam.lib` の 3 " +"つのファイルを作成します。\n" +":file:`Spam.dll` には :c:func:`PyArg_ParseTuple` などの Python の関数は含まれ" +"ていませんが、暗黙にリンクされた :file:`pythonXY.lib` によって Python のコー" +"ドを見つけられます。" #: ../../extending/windows.rst:131 ../../extending/windows.rst:149 msgid "" @@ -259,17 +279,20 @@ msgstr "" "ができ、このライブラリは spam と Python 実行形式中の必要な関数をどうやって見" "つければよいか知っています。" -#: ../../extending/windows.rst:135 msgid "" "Manually by defining :c:macro:`Py_NO_LINK_LIB` macro before including :file:" "`Python.h`. You must pass :file:`pythonXY.lib` to the linker." msgstr "" +":file:`Python.h` をインクルードする前に :c:macro:`Py_NO_LINK_LIB` マクロを定" +"義し、手動でリンクします。\n" +"リンカーに :file:`pythonXY.lib` を渡さなければなりません。" -#: ../../extending/windows.rst:141 msgid "" "cl /LD /DPy_NO_LINK_LIB /I/python/include spam.c ../libs/pythonXY.lib\n" "cl /LD /DPy_NO_LINK_LIB /I/python/include ni.c spam.lib ../libs/pythonXY.lib" msgstr "" +"cl /LD /DPy_NO_LINK_LIB /I/python/include spam.c ../libs/pythonXY.lib\n" +"cl /LD /DPy_NO_LINK_LIB /I/python/include ni.c spam.lib ../libs/pythonXY.lib" #: ../../extending/windows.rst:144 msgid "" diff --git a/faq/design.po b/faq/design.po index 29e8a4e55..b2a67796d 100644 --- a/faq/design.po +++ b/faq/design.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/design.rst:3 @@ -293,7 +293,6 @@ msgstr "" "基底クラスにある同じ名前のメソッドを拡張するために、基底クラスのメソッドをど" "うにかして呼び出したい時にも便利です。" -#: ../../faq/design.rst:136 msgid "" "Finally, for instance variables it solves a syntactic problem with " "assignment: since local variables in Python are (by definition!) those " @@ -310,18 +309,20 @@ msgid "" "instance variables live in two different namespaces, and you need to tell " "Python which namespace to use." msgstr "" -"最後に、インスタンス変数に対する、代入の構文の問題を解決できます。Python の" -"ローカル変数は、関数の中で (global が明示的に宣言されることなく) 値が代入され" -"た変数 (と定義されています!) です。なので、ある代入が意図するのが、ローカル" -"変数へではなくインスタンス変数への代入であると、インタプリタが判断する手段が" -"必要です。そしてそれは構文を見るだけで分かる方が (効率が) 良いのです。C++ で" -"はその区別を宣言時に行いますが、Python では宣言がないので、この方法でしか区別" -"できなかったら残念です。 ``self.var`` を明示すればうまく解決できます。同様" -"に、インスタンス変数を使うのにも ``self.var`` と書かなければならないので、メ" -"ソッドの中の self が付いていない名前への参照は、そのインスタンスのディレクト" -"リを検索するまでもなくローカル変数とわかります。別の言い方をすれば、ローカル" -"変数とインスタンス変数は二つの異なる名前空間に存在し、Python にどちらの名前空" -"間を使うかを伝えなくてはならないのです。" +"最後に、インスタンス変数に対する、代入の構文の問題を解決できます。\n" +"Python のローカル変数は、関数の中で (global が明示的に宣言されることなく) 値" +"が代入された変数 (と定義されています!) です。\n" +"なので、ある代入が意図するのが、ローカル変数へではなくインスタンス変数への代" +"入であると、インタプリタが判断する手段が必要です。\n" +"そしてそれは構文を見るだけで分かる方が (効率が) 良いのです。\n" +"C++ ではその区別を宣言時に行いますが、Python には宣言がなく、この目的だけのた" +"めに導入しなければならないのは残念です。\n" +"``self.var`` を明示すればうまく解決できます。\n" +"同様に、インスタンス変数を使うのにも ``self.var`` と書かなければならないの" +"で、メソッド内の修飾のない名前を参照する際に、そのインスタンスの属性を検索す" +"る必要がなくなります。\n" +"別の言い方をすれば、ローカル変数とインスタンス変数は二つの異なる名前空間に存" +"在し、Python にどちらの名前空間を使うかを伝えなくてはならないのです。" #: ../../faq/design.rst:154 msgid "Why can't I use an assignment in an expression?" @@ -447,17 +448,18 @@ msgstr "" "値に過ぎないというのが答えです。文字列に束縛された名前にメソッドが許されるな" "ら、リテラルに使えないようにする論理的な理由はないでしょう。" -#: ../../faq/design.rst:215 msgid "" "The second objection is typically cast as: \"I am really telling a sequence " "to join its members together with a string constant\". Sadly, you aren't. " "For some reason there seems to be much less difficulty with having :meth:" "`~str.split` as a string method, since in that case it is easy to see that ::" msgstr "" -"二つ目の反対理由は、典型的には「私は実際、要素を文字列定数とともに結合させる" -"よう、シーケンスに命じているのだ」というものです。残念ながら、そうではないの" -"です。いくつかの理由から :meth:`~str.split` を文字列のメソッドとしておいた方" -"がはるかに簡単です。これを見ると分かりやすいでしょう ::" +"二つ目の反論は、よく「シーケンスに対して、文字列定数を使って要素を結合するよ" +"うに指示しているのだ」と表現されます。\n" +"残念ながら、そうではありません。\n" +"なぜか :meth:`~str.split` が文字列のメソッドであることには、はるかに抵抗が少" +"ないようです。\n" +"次の例では、何を指示しているかが分かりやすいからでしょう。 ::" #: ../../faq/design.rst:220 msgid "\"1, 2, 4, 8, 16\".split(\", \")" @@ -547,7 +549,6 @@ msgstr "" msgid "Why isn't there a switch or case statement in Python?" msgstr "Python に switch や case 文がないのはなぜですか?" -#: ../../faq/design.rst:262 msgid "" "In general, structured switch statements execute one block of code when an " "expression has a particular value or set of values. Since Python 3.10 one " @@ -557,6 +558,14 @@ msgid "" "statements. An older alternative is a sequence of ``if... elif... elif... " "else``." msgstr "" +"一般に、構造化された switch 文は、式が特定の値または値の集合のいずれかに一致" +"するときに、一つのコードブロックを実行します。\n" +"Python 3.10 以降では ``match ... case`` 文を使い、リテラル値や名前空間内の定" +"数と簡単に照合できます。\n" +":keyword:`match` 文について詳しくは、:ref:`仕様 ` と :ref:`チュートリ" +"アル ` を参照してください。\n" +"以前から使える方法として、``if... elif... elif... else`` を並べる方法もありま" +"す。" #: ../../faq/design.rst:270 msgid "" @@ -692,9 +701,8 @@ msgstr "" "る必要が無いことだけです -- しかし、(ラムダ式が生み出すオブジェクトと厳密に同" "じ型の) 関数オブジェクトが代入される先はただのローカル変数です!" -#: ../../faq/design.rst:330 msgid "Can Python be compiled to machine code, C or some other language?" -msgstr "Python は C やその他の言語のように機械語にコンパイルできますか?" +msgstr "Python を機械語、C、または他の言語にコンパイルできますか?" #: ../../faq/design.rst:332 msgid "" @@ -832,7 +840,6 @@ msgid "Why isn't all memory freed when CPython exits?" msgstr "" "なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか?" -#: ../../faq/design.rst:396 msgid "" "Objects referenced from the global namespaces of Python modules are not " "always deallocated when Python exits. This may happen if there are circular " @@ -841,20 +848,20 @@ msgid "" "about these). Python is, however, aggressive about cleaning up memory on " "exit and does try to destroy every single object." msgstr "" -"Python モジュールのグローバルな名前空間から参照されるオブジェクトは、Python " -"の終了時にメモリの割り当てを解除されるとは限りません。これは、循環参照がある" -"ときに起こりえます。解放できない C ライブラリ (例えば、Purify のようなツール" -"などが当てはまります) によって割り当てられたいくらかのメモリも含まれます。し" -"かし、Python は終了時にメモリをクリーンアップすることには積極的で、全ての単一" -"のオブジェクトを破棄しようとします。" +"Python モジュールのグローバル名前空間から参照されているオブジェクトは、" +"Python の終了時に必ずしも解放されるとは限りません。\n" +"循環参照があると、このようなことが起こる場合があります。\n" +"また、C ライブラリが割り当てたメモリの一部には解放できないものもあります (例" +"えば Purify のようなツールはこれを報告します)。\n" +"それでも Python は終了時のメモリの後始末を積極的に行い、すべてのオブジェクト" +"を破棄しようとします。" -#: ../../faq/design.rst:403 msgid "" "If you want to force Python to delete certain things on deallocation use " "the :mod:`atexit` module to run a function that will force those deletions." msgstr "" -"再割り当て時に Python が特定のものを削除するように強制したいときは、 :mod:" -"`atexit` モジュールを使って削除を強制する関数を実行してください。" +"解放時に特定のものを Python に確実に削除させたい場合は、:mod:`atexit` モ" +"ジュールを使い、それらを削除する関数を実行してください。" #: ../../faq/design.rst:408 msgid "Why are there separate tuple and list data types?" @@ -910,16 +917,15 @@ msgstr "" msgid "How are lists implemented in CPython?" msgstr "CPythonでリストはどのように実装されているのですか?" -#: ../../faq/design.rst:438 msgid "" "CPython's lists are really variable-length arrays, not Lisp-style linked " "lists. The implementation uses a contiguous array of references to other " "objects, and keeps a pointer to this array and the array's length in a list " "head structure." msgstr "" -"CPythonのリストは実際に変数分の長さの配列で、Lispスタイルの連結リストではあり" -"ません。この実装は他のオブジェクトへの参照の連続した配列を使用していて、この" -"配列へのポインタおよび配列長はリストの先頭の構造体に保存されています。" +"CPython のリストは可変長配列で、Lispスタイルの連結リストではありません。\n" +"この実装は他のオブジェクトへの参照の連続した配列を使用していて、この配列への" +"ポインタおよび配列長はリストの先頭の構造体に保存されています。" #: ../../faq/design.rst:442 msgid "" @@ -941,10 +947,11 @@ msgstr "" "くなるとき、次の何回かは実際に大きさを変更する必要がないように、いくらかの追" "加の領域が割り当てられます。" -#: ../../faq/design.rst:450 msgid "" "See :ref:`time-complexity` for the costs of the various list operations." msgstr "" +"リストの各種操作の計算コストについては、:ref:`time-complexity` を参照してくだ" +"さい。" #: ../../faq/design.rst:456 msgid "How are dictionaries implemented in CPython?" @@ -982,17 +989,17 @@ msgstr "" "なるとすれば、一定の時間 − Big-O 記法では *O*\\ (1) − でキーを検索できること" "になります。" -#: ../../faq/design.rst:471 msgid "" "See :ref:`time-complexity` for the costs of the various dictionary " "operations." msgstr "" +"辞書の各種操作の計算コストについては、:ref:`time-complexity` を参照してくださ" +"い。" #: ../../faq/design.rst:475 msgid "Why must dictionary keys be immutable?" msgstr "なぜ辞書のキーはイミュータブルでなくてはならないのですか?" -#: ../../faq/design.rst:477 msgid "" "The hash table implementation of dictionaries uses a hash value calculated " "from the key value to find the key. If the key were a mutable object, its " @@ -1005,13 +1012,15 @@ msgid "" "would be different." msgstr "" "辞書のハッシュテーブルの実装は、キーを見つけるために、キー値から計算された" -"ハッシュ値を使います。もしキーがミュータブルなオブジェクトだったら、その値は" -"変えられ、それによりハッシュ値も変わってしまいます。しかし、キーオブジェクト" -"を変更したのが何者であれ、値が辞書のキーとして使われていたと気付けないので、" -"辞書の中のエントリを適切な場所に動かせません。そして、同じオブジェクトを探そ" -"うとしても、ハッシュ値が違うため見つかりません。古い値を探そうとしても、その" -"ハッシュバイナリから見つかるオブジェクトの値は異なるでしょうから、これも見つ" -"かりません。" +"ハッシュ値を使います。\n" +"もしキーがミュータブルなオブジェクトだったら、その値は変えられ、それにより" +"ハッシュ値も変わってしまいます。\n" +"しかし、キーオブジェクトを変更したのが何者であれ、値が辞書のキーとして使われ" +"ていたと気付けないので、辞書の中のエントリを適切な場所に動かせません。\n" +"そして、同じオブジェクトを探そうとしても、ハッシュ値が違うため見つかりませ" +"ん。\n" +"古い値を探そうとしても、そのハッシュ値に対応する格納場所で見つかるオブジェク" +"トの値は異なるでしょうから、これも見つかりません。" #: ../../faq/design.rst:486 msgid "" @@ -1028,13 +1037,14 @@ msgstr "" msgid "Some unacceptable solutions that have been proposed:" msgstr "いくつかの受け入れられなかった提案:" -#: ../../faq/design.rst:492 msgid "" "Hash lists by their address (object ID). This doesn't work because if you " "construct a new list with the same value it won't be found; e.g.::" msgstr "" -"アドレス (オブジェクト ID) のハッシュリスト。これは、同じ値の新しいリストを" -"作っても見つからないので駄目です。例えば::" +"リストのアドレス (オブジェクト ID) を使ってハッシュ値を計算する。\n" +"同じ値を持つ新しいリストを作っても見つからないため、この方法はうまくいきませ" +"ん。\n" +"例えば次のコードです。 ::" #: ../../faq/design.rst:495 msgid "" @@ -1055,15 +1065,16 @@ msgstr "" "外を送出するでしょう。言い換えれば、辞書のキーは ``==`` を使って比較されるべ" "きであり、 :keyword:`is` ではないということです。" -#: ../../faq/design.rst:502 msgid "" "Make a copy when using a list as a key. This doesn't work because the list, " "being a mutable object, could contain a reference to itself, and then the " "copying code would run into an infinite loop." msgstr "" -"リストをキーとして使うときにコピーを作る。リストはミュータブルなので、自分自" -"身への参照を含むことができ、コードをコピーするときに無限ループにハマる可能性" -"があるので、これは駄目です。" +"リストをキーとして使う際にコピーを作る。\n" +"リストはミュータブルなオブジェクトなので、自分自身への参照を含む場合がありま" +"す。\n" +"その場合、コピーを行うコードが無限ループに陥るため、この方法はうまくいきませ" +"ん。" #: ../../faq/design.rst:506 msgid "" @@ -1217,21 +1228,20 @@ msgstr "" "for key in sorted(mydict):\n" " ... # mydict[key] を使って何でもできる ..." -#: ../../faq/design.rst:576 msgid "How do you specify and enforce an interface spec in Python?" -msgstr "Python ではどのようにインターフェース仕様を特定し適用するのですか?" +msgstr "" +"Python ではインターフェース仕様をどのように定義し、遵守させるのですか?" -#: ../../faq/design.rst:578 msgid "" "An interface specification for a module as provided by languages such as C++ " "and Java describes the prototypes for the methods and functions of the " "module. Many feel that compile-time enforcement of interface specifications " "helps in the construction of large programs." msgstr "" -"C++ や Java のような言語が提供するような、モジュールに対するインターフェース" -"仕様の特定は、モジュールのメソッドや関数の原型を表現します。インターフェース" -"の特定がコンパイル時に適用されることが、大きなプログラムの構成に役立つと、広" -"く感じられています。" +"C++ や Java などの言語が提供するモジュールのインターフェース仕様は、そのモ" +"ジュールのメソッドや関数のプロトタイプを記述します。\n" +"コンパイル時にインターフェース仕様への適合を強制することが、大規模なプログラ" +"ムの構築に役立つと考える人は多くいます。" #: ../../faq/design.rst:583 msgid "" @@ -1460,16 +1470,16 @@ msgstr "" msgid "In Python, such a construct would be ambiguous." msgstr "Python では、このような構造は曖昧になるでしょう。" -#: ../../faq/design.rst:685 msgid "" "Other languages, such as Object Pascal, Delphi, and C++, use static types, " "so it's possible to know, in an unambiguous way, what member is being " "assigned to. This is the main point of static typing -- the compiler " "*always* knows the scope of every variable at compile time." msgstr "" -"Object Pascal、Delphi、C++のような他の言語では、静的な型を使うので、曖昧な方" -"法でも、どのメンバに代入されているのか分かります。これが静的型付けの要点です " -"-- コンパイラは *いつでも* コンパイル時にすべての変数のスコープを知るのです。" +"Object Pascal、Delphi、C++のような他の言語では、静的な型を使うので、どのメン" +"バに代入されているのかを曖昧さなく判断できます。\n" +"これが静的型付けの要点です -- コンパイラは *いつでも* コンパイル時にすべての" +"変数のスコープを知るのです。" #: ../../faq/design.rst:690 msgid "" @@ -1616,14 +1626,15 @@ msgstr "" "if a == b:\n" " print(a)" -#: ../../faq/design.rst:755 msgid "" "Notice how the second one is slightly easier to read. Notice further how a " "colon sets off the example in this FAQ answer; it's a standard usage in " "English." msgstr "" -"を考えれば、後者のほうが少し読みやすいでしょう。さらに言えば、この FAQ の解答" -"例は次のようになるでしょう。これは、英語の標準的な用法です。" +"後者のほうが少し読みやすいことに注目してください。\n" +"この FAQ の回答でも、原文ではコロンを使って例を区切っていることにも注目してく" +"ださい。\n" +"これは英語では標準的な用法です。" #: ../../faq/design.rst:758 msgid "" diff --git a/faq/extending.po b/faq/extending.po index 276c82a0a..0134a5eb5 100644 --- a/faq/extending.po +++ b/faq/extending.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/extending.rst:3 @@ -51,29 +51,32 @@ msgstr "ほとんどの中級から上級の Python 本もこの話題を扱っ msgid "Can I create my own functions in C++?" msgstr "C++ で独自の関数を作ることはできますか?" -#: ../../faq/extending.rst:28 msgid "" "Yes, using the C compatibility features found in C++. Place ``extern " "\"C\" { ... }`` around the Python include files and put ``extern \"C\"`` " "before each function that is going to be called by the Python interpreter. " "Global or static C++ objects with constructors are probably not a good idea." msgstr "" -"はい。C++ 内にある C 互換機能を使ってできます。 ``extern \"C\" { ... }`` で " -"Python のインクルードファイルを囲み、 ``extern \"C\"`` を Python インタプリタ" -"から呼ぶ各関数の前に置いてください。グローバルや静的な C++ オブジェクトの構造" -"体を持つものは良くないでしょう。" +"はい。\n" +"C++ 内にある C 互換機能を使ってできます。\n" +"``extern \"C\" { ... }`` で Python のインクルードファイルを囲み、 ``extern " +"\"C\"`` を Python インタプリタから呼ぶ各関数の前に置いてください。\n" +"コンストラクタを持つグローバルな C++ オブジェクトや静的な C++ オブジェクトを" +"使うのは、おそらく望ましくありません。" #: ../../faq/extending.rst:37 msgid "Writing C is hard; are there any alternatives?" msgstr "C を書くのは大変です。他の方法はありませんか?" -#: ../../faq/extending.rst:39 msgid "" "There are a number of alternatives to writing your own C extensions, " "depending on what you're trying to do. :ref:`Recommended third party tools " "` offer both simpler and more sophisticated approaches to " "creating C and C++ extensions for Python." msgstr "" +"何をしたいかに応じて、C 拡張を自分で書く以外にもいくつかの方法があります。\n" +":ref:`推奨されるサードパーティツール ` には、Python の C/C++ 拡" +"張をより簡単に作るものや、より高度な方法を提供するものがあります。" #: ../../faq/extending.rst:46 msgid "How can I execute arbitrary Python statements from C?" @@ -185,22 +188,23 @@ msgstr "" "す。パラメタは、オブジェクト、呼び出すメソッドの名前、 :c:func:" "`Py_BuildValue` で使われるようなフォーマット文字列、そして引数です::" -#: ../../faq/extending.rst:102 msgid "" "PyObject *\n" "PyObject_CallMethod(PyObject *object, const char *method_name,\n" " const char *arg_format, ...);" msgstr "" +"PyObject *\n" +"PyObject_CallMethod(PyObject *object, const char *method_name,\n" +" const char *arg_format, ...);" -#: ../../faq/extending.rst:106 msgid "" "This works for any object that has methods -- whether built-in or user-" "defined. You are responsible for eventually :c:func:`Py_DECREF`\\ 'ing the " "return value." msgstr "" -"これはメソッドを持ついかなるオブジェクトにも有効で、組み込みかユーザ定義かは" -"関係ありません。返り値に対して :c:func:`Py_DECREF` する必要があることもありま" -"す。" +"これは、組み込みかユーザー定義かを問わず、メソッドを持つ任意のオブジェクトに" +"使えます。\n" +"返り値を使い終わったら、呼び出し側で :c:func:`Py_DECREF` する責任があります。" #: ../../faq/extending.rst:109 msgid "" @@ -210,7 +214,6 @@ msgstr "" "例えば、あるファイルオブジェクトの \"seek\" メソッドを 10, 0 を引数として呼ぶ" "とき (ファイルオブジェクトのポインタを \"f\" とします)::" -#: ../../faq/extending.rst:112 msgid "" "res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" "if (res == NULL) {\n" @@ -220,8 +223,14 @@ msgid "" " Py_DECREF(res);\n" "}" msgstr "" +"res = PyObject_CallMethod(f, \"seek\", \"(ii)\", 10, 0);\n" +"if (res == NULL) {\n" +" ... 例外が発生した場合の処理 ...\n" +"}\n" +"else {\n" +" Py_DECREF(res);\n" +"}" -#: ../../faq/extending.rst:120 msgid "" "Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the " "argument list, to call a function without arguments, pass \"()\" for the " @@ -229,8 +238,9 @@ msgid "" "parentheses, e.g. \"(i)\"." msgstr "" "なお、 :c:func:`PyObject_CallObject` の引数リストには *常に* タプルが必要で" -"す。関数を引数なしで呼び出すには、フォーマットに \"()\" を渡し、関数を一つの" -"引数で呼び出すには、関数を括弧でくくって例えば \"(i)\" としてください。" +"す。\n" +"関数を引数なしで呼び出すには、フォーマットに \"()\" を渡し、関数を一つの引数" +"で呼び出すには、引数の書式を括弧で囲んで例えば \"(i)\" としてください。" #: ../../faq/extending.rst:127 msgid "" @@ -256,7 +266,6 @@ msgstr "" msgid "The easiest way to do this is to use the :class:`io.StringIO` class:" msgstr "最も簡単な方法は、 :class:`io.StringIO` クラスを使うことです:" -#: ../../faq/extending.rst:136 msgid "" ">>> import io, sys\n" ">>> sys.stdout = io.StringIO()\n" @@ -266,12 +275,18 @@ msgid "" "foo\n" "hello world!" msgstr "" +">>> import io, sys\n" +">>> sys.stdout = io.StringIO()\n" +">>> print('foo')\n" +">>> print('hello world!')\n" +">>> sys.stderr.write(sys.stdout.getvalue())\n" +"foo\n" +"hello world!" #: ../../faq/extending.rst:146 msgid "A custom object to do the same would look like this:" msgstr "これと同じことをするカスタムオブジェクトは次のようになるでしょう:" -#: ../../faq/extending.rst:148 msgid "" ">>> import io, sys\n" ">>> class StdoutCatcher(io.TextIOBase):\n" @@ -288,6 +303,20 @@ msgid "" "foo\n" "hello world!" msgstr "" +">>> import io, sys\n" +">>> class StdoutCatcher(io.TextIOBase):\n" +"... def __init__(self):\n" +"... self.data = []\n" +"... def write(self, stuff):\n" +"... self.data.append(stuff)\n" +"...\n" +">>> import sys\n" +">>> sys.stdout = StdoutCatcher()\n" +">>> print('foo')\n" +">>> print('hello world!')\n" +">>> sys.stderr.write(''.join(sys.stdout.data))\n" +"foo\n" +"hello world!" #: ../../faq/extending.rst:167 msgid "How do I access a module written in Python from C?" @@ -297,9 +326,8 @@ msgstr "C から Python で書かれたモジュールにアクセスするに msgid "You can get a pointer to the module object as follows::" msgstr "以下のようにモジュールオブジェクトへのポインタを得られます::" -#: ../../faq/extending.rst:171 msgid "module = PyImport_ImportModule(\"\");" -msgstr "" +msgstr "module = PyImport_ImportModule(\"\");" #: ../../faq/extending.rst:173 msgid "" @@ -323,9 +351,8 @@ msgstr "" "これで、モジュールの属性 (つまり、モジュールで定義された任意の名前) に以下の" "ようにアクセスできるようになります::" -#: ../../faq/extending.rst:182 msgid "attr = PyObject_GetAttrString(module, \"\");" -msgstr "" +msgstr "attr = PyObject_GetAttrString(module, \"\");" #: ../../faq/extending.rst:184 msgid "" @@ -379,13 +406,12 @@ msgstr "" msgid "How do I debug an extension?" msgstr "拡張をデバッグするにはどうしますか?" -#: ../../faq/extending.rst:211 msgid "" "When using GDB with dynamically loaded extensions, you can't set a " "breakpoint in your extension until your extension is loaded." msgstr "" "動的にロードされた拡張に GDB を使うとき、拡張がロードされるまでブレークポイン" -"トを設定してはいけません。" +"トを設定できません。" #: ../../faq/extending.rst:214 msgid "In your ``.gdbinit`` file (or interactively), add the command:" @@ -417,19 +443,20 @@ msgstr "" "Linux システムで Python モジュールをコンパイルしたいのですが、見つからない" "ファイルがあります。なぜですか?" -#: ../../faq/extending.rst:234 msgid "" "Most packaged versions of Python omit some files required for compiling " "Python extensions." msgstr "" +"パッケージとして配布されている Python の多くでは、Python 拡張のコンパイルに必" +"要なファイルの一部が省かれています。" -#: ../../faq/extending.rst:237 msgid "For Red Hat, install the python3-devel RPM to get the necessary files." msgstr "" +"Red Hat では、必要なファイルを入手するために python3-devel RPM をインストール" +"してください。" -#: ../../faq/extending.rst:239 msgid "For Debian, run ``apt-get install python3-dev``." -msgstr "" +msgstr "Debian では ``apt-get install python3-dev`` を実行してください。" #: ../../faq/extending.rst:242 msgid "How do I tell \"incomplete input\" from \"invalid input\"?" diff --git a/faq/general.po b/faq/general.po index 5aeb8d611..4bcac7473 100644 --- a/faq/general.po +++ b/faq/general.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/general.rst:5 @@ -105,7 +105,6 @@ msgstr "" msgid "Are there copyright restrictions on the use of Python?" msgstr "Python を使うのに著作権の制限はありますか?" -#: ../../faq/general.rst:50 msgid "" "You can do anything you want with the source, as long as you leave the " "copyrights in and display those copyrights in any documentation about Python " @@ -115,12 +114,13 @@ msgid "" "some form. We would still like to know about all commercial use of Python, " "of course." msgstr "" -"あなたが作成する Python に関するドキュメントのすべてに著作権を残し、それらの" -"著作権を表示する限り、ソースコードをどのように扱ってもかまいません。この著作" -"権規則を尊重する限り、商用に Python を利用しても、ソースあるいはバイナリ形式" -"で(変更の有無にかかわらず) Python のコピーを販売しても、Python が何らかの形で" -"組み込まれた製品を販売してかまいません。もちろん、Python のあらゆる商業用途に" -"ついても同様です。" +"ソースに著作権表示を残し、作成する Python 関連のドキュメントにもその表示を載" +"せる限り、ソースを自由に扱えます。\n" +"著作権に関する規則を守れば、Python を商用利用したり、ソースやバイナリのコピー" +"を変更の有無にかかわらず販売したり、Python を何らかの形で組み込んだ製品を販売" +"したりしても構いません。\n" +"もちろん、Python がどのように商用利用されているかは、ぜひ知らせていただきたい" +"と思っています。" #: ../../faq/general.rst:57 msgid "" @@ -197,18 +197,17 @@ msgstr "" "理の方法が必要でした。Amoeba のエラー処理の経験から、プログラミング言語の機能" "としての例外の重要さを強く意識するようになりました。" -#: ../../faq/general.rst:93 msgid "" "It occurred to me that a scripting language with a syntax like ABC but with " "access to the Amoeba system calls would fill the need. I realized that it " "would be foolish to write an Amoeba-specific language, so I decided that I " "needed a language that was generally extensible." msgstr "" -"ABC のような構文と Amoeba のようなシステムコールを合わせ持ったスクリプト言語" -"が必要だろうと思いつきました。Amoeba 専用の言語を書くのは愚かであるだろうと気" -"づき、一般に拡張できるような言語を求めることに決めました。" +"ABC のような構文と Amoeba のシステムコールへのアクセスを合わせ持ったスクリプ" +"ト言語が必要だろうと思いつきました。\n" +"Amoeba 専用の言語を書くのは愚かであるだろうと気づき、一般に拡張できるような言" +"語を求めることに決めました。" -#: ../../faq/general.rst:98 msgid "" "During the 1989 Christmas holidays, I had a lot of time on my hand, so I " "decided to give it a try. During the next year, while still mostly working " @@ -216,18 +215,18 @@ msgid "" "success, and the feedback from colleagues made me add many early " "improvements." msgstr "" -"1989 年のクリスマス休暇の間、自由な時間がたくさんできたので、その言語を実際に" -"作ってみることにしました。翌年の間、勤務時間以外はほとんどその開発に費やし、" -"Python は Amoeba プロジェクトのなかで成果を重ね、同僚からのフィードバックは私" -"の開発を大いに加速させてくれました。" +"1989 年のクリスマス休暇には時間がたくさんあったので、試しに作ってみることにし" +"ました。\n" +"翌年も主に自分の時間を使って開発を続ける一方、Python は Amoeba プロジェクトで" +"使われ、ますます成果を上げていました。\n" +"同僚からのフィードバックを受けて、初期の改良を数多く加えました。" -#: ../../faq/general.rst:104 msgid "" "In February 1991, after just over a year of development, I decided to post " "to USENET. The rest is in the ``Misc/HISTORY`` file." msgstr "" -"1991 年 2 月、1 年間と少しの開発を経て、USENET に投稿することにしました。それ" -"は ``Misc/HISTORY`` ファイルに残っています。" +"1991 年 2 月、1 年間と少しの開発を経て、USENET に投稿することにしました。\n" +"その後の歴史は ``Misc/HISTORY`` ファイルに記されています。" #: ../../faq/general.rst:109 msgid "What is Python good for?" @@ -341,7 +340,6 @@ msgstr "" "つまり、 *2.0aN* と付けられたバージョンはすべて *2.0bN* に先立ち、 *2.0bN* " "は *2.0rcN* に先立ち、そして *これら* は 2.0 に先立ちます。" -#: ../../faq/general.rst:155 msgid "" "You may also find version numbers with a \"+dev\" suffix, such as " "\"3.15.0b3+dev\". These are unreleased versions, built directly from the " @@ -349,6 +347,12 @@ msgid "" "version is incremented to the next feature version, which becomes the \"a0\" " "version, such as \"3.16.0a0\"." msgstr "" +"\"3.15.0b3+dev\" のように、\"+dev\" という接尾辞の付いたバージョン番号を見か" +"けることもあります。\n" +"これらは CPython の開発リポジトリから直接ビルドされた未リリースのバージョンで" +"す。\n" +"最初のベータ版をリリースした後、バージョン番号は次の機能リリースに進" +"み、\"3.16.0a0\" のような \"a0\" バージョンになります。" #: ../../faq/general.rst:161 msgid "" @@ -452,7 +456,6 @@ msgstr "" msgid "Is there a newsgroup or mailing list devoted to Python?" msgstr "Python のためのニュースグループやメーリングリストはありますか?" -#: ../../faq/general.rst:211 msgid "" "There is a newsgroup, :newsgroup:`comp.lang.python`, and a mailing list, " "`python-list `_. The " @@ -462,13 +465,13 @@ msgid "" "Usenet readers are often more able to cope with this volume." msgstr "" "ニュースグループ :newsgroup:`comp.lang.python` やメーリングリスト `python-" -"list `_ があります。" +"list `_ があります。\n" "ニュースグループとメーリングリストは互いに接続されていて、ニュースを購読すれ" -"ばメーリングリストに参加する必要はありません。 :newsgroup:`comp.lang.python` " -"は一日に数百のポスティングを受ける高いトラフィックで、USENET 読者は多くの場" -"合、このボリュームに応えることができます。" +"ばメーリングリストに参加する必要はありません。\n" +":newsgroup:`comp.lang.python` は一日に数百のポスティングを受ける高いトラ" +"フィックで、Usenet 閲覧ソフトのほうが、この量の投稿を扱いやすいことがよくあり" +"ます。" -#: ../../faq/general.rst:218 msgid "" "Announcements of new software releases and events can be found in comp.lang." "python.announce, a low-traffic moderated list that receives about five " @@ -476,9 +479,11 @@ msgid "" "`_." msgstr "" "新しいソフトウェアリリースとイベントの告知は comp.lang.python.announce で見つ" -"けられます。これは一日に 5 ポスティング程度を受ける低トラフィックの手頃なメー" -"リングリストです。`the python-announce mailing list `_ から利用可能です。" +"けられます。\n" +"これは一日に 5 ポスティング程度を受ける投稿が承認制になっている低トラフィック" +"のリストです。\n" +"`the python-announce mailing list `_ から利用可能です。" #: ../../faq/general.rst:223 msgid "" @@ -562,13 +567,13 @@ msgstr "" msgid "Are there any books on Python?" msgstr "Python の本はありますか?" -#: ../../faq/general.rst:265 msgid "" "Yes, there are many, and more are being published. See the python.org wiki " "at https://wiki.python.org/moin/PythonBooks for a list." msgstr "" -"はい、たくさんあり、そのほとんどは現在も出版されています。リストは python." -"org wiki https://wiki.python.org/moin/PythonBooks にあります。" +"はい、たくさんあり、さらに新しい本が出版されています。\n" +"リストは python.org wiki https://wiki.python.org/moin/PythonBooks にありま" +"す。" #: ../../faq/general.rst:268 msgid "" @@ -754,7 +759,6 @@ msgstr "" msgid "Is it reasonable to propose incompatible changes to Python?" msgstr "Python の互換性を無くすような提案をしてもいいのですか?" -#: ../../faq/general.rst:363 msgid "" "In general, no. There are already millions of lines of Python code around " "the world, so any change in the language that invalidates more than a very " @@ -763,22 +767,23 @@ msgid "" "documentation; many books have been written about Python, and we don't want " "to invalidate them all at a single stroke." msgstr "" -"一般的には、してはいけません。世界中にすでに何百万行もの Python コードがある" -"ので、既存のプログラムのどんなに僅かな部分でも無効にしてしまうような言語仕様" -"の変更も認められてはなりません。コンバートするプログラムが出来てさえ、すべて" -"のドキュメントをアップデートしなければならないという問題があります。 Python " -"に関する多くの本が出版されているので、それらを一発で不適切にするようなことは" -"したくないです。" +"一般的には、してはいけません。\n" +"世界中にすでに何百万行もの Python コードがあるので、既存プログラムのごく僅か" +"な割合を超えて動かなくしてしまう言語の変更は、好ましくないと考えられます。\n" +"コンバートするプログラムが出来てさえ、すべてのドキュメントをアップデートしな" +"ければならないという問題があります。\n" +"Python に関する多くの本が出版されているので、それらを一発で不適切にするような" +"ことはしたくないです。" -#: ../../faq/general.rst:370 msgid "" "Providing a gradual upgrade path is necessary if a feature has to be " "changed. :pep:`5` describes the procedure followed for introducing backward-" "incompatible changes while minimizing disruption for users." msgstr "" "仕様を変えなければならないのなら、緩やかなアップグレード計画が組まれなくては" -"なりません。 :pep:`5` で、ユーザーの受ける分裂を最小限にしながら後方互換性の" -"ない変更を行うために従うべき手順について説明しています。" +"なりません。\n" +":pep:`5` で、ユーザーに生じる混乱を最小限にしながら後方互換性のない変更を行う" +"ために従うべき手順について説明しています。" #: ../../faq/general.rst:376 msgid "Is Python a good language for beginning programmers?" @@ -827,7 +832,6 @@ msgstr "" "見れば静的型付け言語を学ぶことは重要ですが、それが最初のプログラミングの授業" "で学ぶべき最高の話題とは限りません。" -#: ../../faq/general.rst:398 msgid "" "Many other aspects of Python make it a good first language. Like Java, " "Python has a large standard library so that students can be assigned " @@ -839,16 +843,17 @@ msgid "" "students about code reuse. Third-party modules such as PyGame are also " "helpful in extending the students' reach." msgstr "" -"Python の良いところは他にもたくさんあります。Python には、Java のように大きな" -"標準ライブラリがあり、生徒が何かを *する* 段階で非常に早くプログラミングプロ" -"ジェクトに参加できるようになります。宿題は標準の四則演算機や平均を求めるプロ" -"グラムに限定されません。標準ライブラリを使用することで、生徒はプログラミング" -"の原理を学びながら現実的なアプリケーションに取り組む満足感を得ることができま" -"す。また、標準ライブラリの使用からコードの再利用を学ぶことができます。 " -"PyGame などのサードパーティモジュールもまた手が届く範囲を広げるのに役立ちま" -"す。" +"ほかにも、Python を最初に学ぶ言語として適したものにする特徴は数多くありま" +"す。\n" +"Java と同様に大規模な標準ライブラリを備えているため、授業の早い段階から、実際" +"に何かを *行う* プログラムを課題にできます。\n" +"課題は定番の四則演算電卓や小切手帳の残高確認プログラムに限られません。\n" +"標準ライブラリを使えば、生徒はプログラミングの基礎を学びながら、実用的なアプ" +"リケーションに取り組む満足感を得られます。\n" +"標準ライブラリの利用を通じて、コードの再利用も学べます。\n" +"PyGame などのサードパーティモジュールも、生徒が取り組める範囲を広げるのに役立" +"ちます。" -#: ../../faq/general.rst:407 msgid "" "Python's interactive interpreter enables students to test language features " "while they're programming. They can keep a window with the interpreter " @@ -856,9 +861,10 @@ msgid "" "can't remember the methods for a list, they can do something like this::" msgstr "" "Python のインタラクティブインタプリタによって、プログラミングをしながら、言語" -"機能を確認することができます。別のウィンドウでプログラムのソースに入っている" -"間、ウィンドウでインタプリタを起動させたままにしておくことができます。リスト" -"のメソッドを思い出せないときは、例えばこのようにできます::" +"機能を確認することができます。\n" +"一つのウィンドウでインタープリタを動かしたまま、別のウィンドウでプログラムの" +"ソースを入力できます。\n" +"リストのメソッドを思い出せないときは、例えばこのようにできます::" #: ../../faq/general.rst:412 msgid "" diff --git a/faq/gui.po b/faq/gui.po index d39268708..3109174a0 100644 --- a/faq/gui.po +++ b/faq/gui.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/gui.rst:5 @@ -98,17 +98,15 @@ msgstr "" "envvar:`!TCL_LIBRARY` と :envvar:`!TK_LIBRARY` でランタイムに指定することで" "す。" -#: ../../faq/gui.rst:49 msgid "" "Various third-party freeze libraries such as py2exe and cx_Freeze have " "handling for Tkinter applications built-in." msgstr "" -"py2exe や cx_Freeze など いくつかのサードパーティ製凍結ライブラリは、 " -"Tkinter アプリケーション組み込みの機能を持ちます。" +"py2exe や cx_Freeze など、さまざまなサードパーティの凍結ライブラリには、" +"Tkinter アプリケーションを扱う機能が組み込まれています。" -#: ../../faq/gui.rst:54 msgid "Can I have Tk events handled while waiting for I/O?" -msgstr "I/O を待つ間に扱われる Tk イベントを作れますか?" +msgstr "I/O を待っている間も Tk イベントを処理できますか?" #: ../../faq/gui.rst:56 msgid "" diff --git a/faq/index.po b/faq/index.po index 268f705b6..aa09c303d 100644 --- a/faq/index.po +++ b/faq/index.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/index.rst:5 diff --git a/faq/installed.po b/faq/installed.po index 9f3deb35b..f4f0b6226 100644 --- a/faq/installed.po +++ b/faq/installed.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/installed.rst:3 @@ -114,14 +114,13 @@ msgstr "Python を削除してもいいですか?" msgid "That depends on where Python came from." msgstr "Python をどこから手に入れたかによります。" -#: ../../faq/installed.rst:42 msgid "" "If someone installed it deliberately, you can remove it without hurting " "anything. On Windows, use the Add/Remove Programs icon in the Control Panel." msgstr "" -"誰かが Python を意図してダウンロードしたのであれば、何の問題もなく削除するこ" -"とができます。Windows では、コントロールパネルのプログラムの追加と削除を使っ" -"てください。" +"誰かが Python を意図してインストールしたのであれば、何の問題もなく削除するこ" +"とができます。\n" +"Windows では、コントロールパネルのプログラムの追加と削除を使ってください。" #: ../../faq/installed.rst:45 msgid "" diff --git a/faq/library.po b/faq/library.po index 5fb2330f5..d5c818afe 100644 --- a/faq/library.po +++ b/faq/library.po @@ -19,10 +19,10 @@ msgstr "" "Last-Translator: Maciej Olko, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/library.rst:5 @@ -247,13 +247,12 @@ msgstr "" msgid "Is there an equivalent to C's onexit() in Python?" msgstr "Python には C の onexit() に相当するものはありますか?" -#: ../../faq/library.rst:113 msgid "" "The :mod:`atexit` module provides a register function that is similar to " "C's :c:func:`!onexit`." msgstr "" -":mod:`atexit` モジュールは、 C の :c:func:`!onexit` と同じような関数登録を提" -"供します。" +":mod:`atexit` モジュールには、C の :c:func:`!onexit` に似た ``register()`` 関" +"数があります。" #: ../../faq/library.rst:118 msgid "Why don't my signal handlers work?" @@ -301,13 +300,12 @@ msgstr "" "ルは、モジュールの docstring から使用例を見つけてそれらを実行し、出力を " "docstring によって与えられた望まれる出力と比較します。" -#: ../../faq/library.rst:141 msgid "" "The :mod:`unittest` module is a fancier testing framework modelled on Java " "and Smalltalk testing frameworks." msgstr "" -":mod:`unittest` モジュールは、Java や Smalltalk のテストフレームワークを模し" -"た装飾されたテストフレームワークです。" +":mod:`unittest` モジュールは、Java や Smalltalk のテストフレームワークをモデ" +"ルにした、より高機能なテストフレームワークです。" #: ../../faq/library.rst:144 msgid "" @@ -566,7 +564,6 @@ msgstr "" msgid "Here's a trivial example::" msgstr "ここにちょっとした例があります::" -#: ../../faq/library.rst:304 msgid "" "import threading, queue, time\n" "\n" @@ -627,7 +624,7 @@ msgstr "" "# キュー作成\n" "q = queue.Queue()\n" "\n" -"# 5つのワーカープールをスタート\n" +"# 5 個のワーカーからなるプールを開始\n" "for i in range(5):\n" " t = threading.Thread(target=worker, name='worker %i' % (i+1))\n" " t.start()\n" @@ -1006,15 +1003,15 @@ msgstr "" " s = f.read(8)\n" " x, y, z = struct.unpack(\">hhl\", s)" -#: ../../faq/library.rst:518 msgid "" "The '>' in the format string forces big-endian data; the letter 'h' reads " "one \"short integer\" (2 bytes), and 'l' reads one \"long integer\" (4 " "bytes) from the string." msgstr "" -"フォーマット中の '>' はデータを強制的にビッグエンディアンにします。ファイルか" -"ら、文字 'h' は一つの\"整数\"(2 バイト)を読み込み、文字 'l' は一つの\"long 整" -"数\"を読み込みます。" +"書式文字列の \">\" は、データをビッグエンディアンとして解釈するよう指定しま" +"す。\n" +"\"h\" は文字列から一つの short 整数 (2 バイト) を読み取り、\"l\" は一つの " +"long 整数 (4 バイト) を読み取ります。" #: ../../faq/library.rst:522 msgid "" @@ -1037,11 +1034,10 @@ msgstr "" "read()`` は :class:`bytes` オブジェクトではなく :class:`str` オブジェクトを返" "します。" -#: ../../faq/library.rst:535 msgid "I can't seem to use os.read() on a pipe created with os.popen(); why?" msgstr "" -"os.popen() によって作られたパイプで os.read() が使われていないようです。なぜ" -"ですか?" +"os.popen() で作成したパイプに os.read() を使えないようです。\n" +"なぜですか?" #: ../../faq/library.rst:537 msgid "" @@ -1315,16 +1311,16 @@ msgstr "" "``errno.EISCONN`` は接続されたことを表します -- または、このソケットを :meth:" "`select.select` に渡して書き込み可能か調べることができます。" -#: ../../faq/library.rst:675 msgid "" "The :mod:`asyncio` module provides a general purpose single-threaded and " "concurrent asynchronous library, which can be used for writing non-blocking " "network code. The third-party `Twisted `_ library is a " "popular and feature-rich alternative." msgstr "" -":mod:`asyncio` モジュールは、ノンブロッキングのネットワークコードを書く作業の" -"ためにフレームワークのような方法を提供します。その他の選択肢として、`Twisted " -"`_ は多機能で著名なサードパーティのライブラリです。" +":mod:`asyncio` モジュールは、シングルスレッドで並行処理を行う汎用の非同期ライ" +"ブラリを提供し、ノンブロッキングのネットワークコードを書くのに使えます。\n" +"サードパーティの `Twisted `_ ライブラリも、広く使われて" +"いる多機能な選択肢です。" #: ../../faq/library.rst:683 msgid "Databases" diff --git a/faq/programming.po b/faq/programming.po index c757783e5..ba15f54c1 100644 --- a/faq/programming.po +++ b/faq/programming.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/programming.rst:5 @@ -596,15 +596,14 @@ msgstr "" msgid "locally developed modules" msgstr "自前で開発したモジュール" -#: ../../faq/programming.rst:307 msgid "" "It is sometimes necessary to move imports to a function or class to avoid " "problems with circular imports. Gordon McMillan says:" msgstr "" -"循環参照の問題を避けるために、インポートを関数やクラスに移すことが必要なとき" -"もあります。Gordon McMillan によれば:" +"循環インポートの問題を避けるために、インポートを関数やクラスに移すことが必要" +"なときもあります。\n" +"Gordon McMillan によれば:" -#: ../../faq/programming.rst:310 msgid "" "Circular imports are fine where both modules use the \"import \" " "form of import. They fail when the 2nd module wants to grab a name out of " @@ -612,9 +611,10 @@ msgid "" "That's because names in the 1st are not yet available, because the first " "module is busy importing the 2nd." msgstr "" -"循環参照は両方のモジュールが \"import \" 形式のインポートを使っていれ" -"ば大丈夫です。二つ目のモジュールが最初のモジュールから名前を確保しようとして " -"(\"from module import name\")、そのインポートがトップレベルにあると駄目です。" +"循環インポートは両方のモジュールが \"import \" 形式のインポートを使っ" +"ていれば大丈夫です。\n" +"二つ目のモジュールが最初のモジュールから名前を確保しようとして (\"from " +"module import name\")、そのインポートがトップレベルにあると駄目です。\n" "最初のモジュールが二つ目のモジュールをインポートするのに忙しくて、最初のモ" "ジュールの名前が利用可能になっていないからです。" @@ -643,7 +643,6 @@ msgstr "" "ポートすることさえできないかもしれません。この場合は、対応するプラットフォー" "ムに合わせたコードで正しいモジュールをインポートすることを選ぶと良いです。" -#: ../../faq/programming.rst:326 msgid "" "Only move imports into a local scope, such as inside a function definition, " "if it's necessary to solve a problem such as avoiding a circular import or " @@ -656,15 +655,19 @@ msgid "" "only a couple of dictionary lookups. Even if the module name has gone out " "of scope, the module is probably available in :data:`sys.modules`." msgstr "" -"循環参照の問題を避けたりモジュールの初期化にかかる時間を減らしたりしたいな" -"ら、単にインポートを関数定義の中などのローカルなスコープに移してください。こ" -"の手法は多くのインポートがプログラムがどのように実行されるかに依存しなくてよ" -"いときに特に有効です。ある関数の中でのみモジュールが使われるのなら、インポー" -"トをその関数の中に移すことを考えてもいいでしょう。なお、モジュールを読み込む" -"最初の回はモジュールの初期化の時間のために高価になりえますが、複数回目にモ" -"ジュールを読み込むのは事実上無料、辞書探索の数回のコストだけで済みます。モ" -"ジュール名がスコープから外れてさえ、そのモジュールはおそらく :data:`sys." -"modules` から利用できるでしょう。" +"インポートを関数定義内などのローカルスコープへ移すのは、循環インポートを避け" +"るといった問題の解決に必要な場合や、モジュールの初期化時間を短くしたい場合だ" +"けにしてください。\n" +"この手法は、プログラムの実行のされ方によって多くのインポートが不要になる場合" +"に特に有効です。\n" +"モジュールをある関数の中でしか使わない場合も、インポートをその関数内へ移すと" +"よいでしょう。\n" +"初回の読み込みにはモジュールの初期化が伴うため、時間がかかることがありま" +"す。\n" +"一方、繰り返し読み込むときのコストは辞書を数回検索する程度で、ほぼ無視できま" +"す。\n" +"モジュール名がスコープから外れても、モジュール自体はおそらく :data:`sys." +"modules` に残っています。" #: ../../faq/programming.rst:339 msgid "Why are default values shared between objects?" @@ -713,15 +716,15 @@ msgstr "" "に一度だけ生成されます。この例の辞書のように、そのオブジェクトが変更されたと" "き、その後の関数の呼び出しは変更後のオブジェクトを参照します。" -#: ../../faq/programming.rst:357 msgid "" "By definition, immutable objects such as numbers, strings, tuples, and " "``None``, are safe from change. Changes to mutable objects such as " "dictionaries, lists, and class instances can lead to confusion." msgstr "" -"定義の時に、数、文字列、タプル、``None`` など、イミュータブルなオブジェクトを" -"使うと変更される危険がありません。辞書、リスト、クラスインスタンスなどの" -"ミュータブルなオブジェクトは混乱のもとです。" +"数値、文字列、タプル、``None`` などのイミュータブルなオブジェクトは、定義上、" +"変更されることがありません。\n" +"辞書、リスト、クラスインスタンスなどのミュータブルなオブジェクトを変更する" +"と、混乱を招く場合があります。" #: ../../faq/programming.rst:361 msgid "" @@ -839,7 +842,6 @@ msgstr "" msgid "What is the difference between arguments and parameters?" msgstr "実引数と仮引数の違いは何ですか?" -#: ../../faq/programming.rst:418 msgid "" ":term:`Parameters ` are defined by the names that appear in a " "function definition, whereas :term:`arguments ` are the values " @@ -849,8 +851,10 @@ msgid "" msgstr "" ":term:`仮引数 (parameter) ` は関数定義に表れる名前で定義されるのに" "対し、 :term:`実引数 (argument) ` は関数を呼び出すときに実際に渡す" -"値のことです。仮引数は関数が受け取ることの出来る :term:`実引数の型 " -"` を定義します。例えば、以下のような関数定義があったとして::" +"値のことです。\n" +"仮引数は関数が受け取ることの出来る :term:`実引数の種類 ` を定義し" +"ます。\n" +"例えば、以下のような関数定義があったとして::" #: ../../faq/programming.rst:424 msgid "" @@ -1459,9 +1463,8 @@ msgstr "" "……そして、その猫が沢山の名前で知られていたり、逆に全く名前が無かったりしても" "驚かないでください!" -#: ../../faq/programming.rst:702 msgid "What's up with the comma operator's precedence?" -msgstr "カンマ演算子はなぜ優先されるのですか?" +msgstr "カンマ演算子の優先順位はどうなっていますか?" #: ../../faq/programming.rst:704 msgid "Comma is not an operator in Python. Consider this session::" @@ -1745,14 +1748,14 @@ msgstr "" msgid "i == (i // j) * j + (i % j)" msgstr "i == (i // j) * j + (i % j)" -#: ../../faq/programming.rst:837 msgid "" "then integer division has to return the floor. C also requires that " "identity to hold, and then compilers that truncate ``i // j`` need to make " "``i % j`` have the same sign as ``i``." msgstr "" -"整数除算は床を返すことになります。C にも C の一貫性があって、``i % j`` が " -"``i`` と同じ符号を持つように ``i // j`` を丸めています。" +"整数除算は床、つまり商以下の最大の整数を返す必要があります。\n" +"C でもこの等式を満たす必要があり、商をゼロ方向に切り捨てるコンパイラでは、" +"``i % j`` の符号を ``i`` と同じにする必要があります。" #: ../../faq/programming.rst:841 msgid "" @@ -2091,15 +2094,13 @@ msgstr "" "これは典型的に一度に一行ずつテキストを読みたい時にのみ使われるので、``S." "rstrip()`` をこの方法で使うとうまくいきます。" -#: ../../faq/programming.rst:1010 msgid "Is there a ``scanf()`` or ``sscanf()`` equivalent?" -msgstr "" +msgstr "``scanf()`` や ``sscanf()`` に相当するものはありますか?" #: ../../faq/programming.rst:1012 msgid "Not as such." msgstr "そのようなものはありません。" -#: ../../faq/programming.rst:1014 msgid "" "For simple input parsing, the easiest approach is usually to split the line " "into whitespace-delimited words using the :meth:`~str.split` method of " @@ -2108,6 +2109,11 @@ msgid "" "parameter which is useful if the line uses something other than whitespace " "as a separator." msgstr "" +"単純な入力を解析するには、通常、文字列オブジェクトの :meth:`~str.split` メ" +"ソッドで行を空白区切りの単語に分割し、:func:`int` や :func:`float` で十進数の" +"文字列を数値に変換するのが最も簡単です。\n" +":meth:`!split` には省略可能な ``sep`` 引数があり、空白以外の区切り文字を使っ" +"た行を扱うのに便利です。" #: ../../faq/programming.rst:1020 msgid "" @@ -2117,9 +2123,8 @@ msgstr "" "もっと複雑な入力解析をしたいなら、C の ``sscanf`` よりも正規表現の方が便利で" "すし、この処理に向いています。" -#: ../../faq/programming.rst:1025 msgid "What does ``UnicodeDecodeError`` or ``UnicodeEncodeError`` error mean?" -msgstr "" +msgstr "``UnicodeDecodeError`` や ``UnicodeEncodeError`` は何を意味しますか?" #: ../../faq/programming.rst:1027 msgid "See the :ref:`unicode-howto`." @@ -2137,7 +2142,6 @@ msgstr "" "奇数個のバックスラッシュで終わる raw string は文字列のクォートをエスケープし" "ます::" -#: ../../faq/programming.rst:1037 msgid "" ">>> r'C:\\this\\will\\not\\work\\'\n" " File \"\", line 1\n" @@ -2145,6 +2149,11 @@ msgid "" " ^\n" "SyntaxError: unterminated string literal (detected at line 1)" msgstr "" +">>> r'C:\\this\\will\\not\\work\\'\n" +" File \"\", line 1\n" +" r'C:\\this\\will\\not\\work\\'\n" +" ^\n" +"SyntaxError: unterminated string literal (detected at line 1)" #: ../../faq/programming.rst:1043 msgid "" @@ -2154,11 +2163,12 @@ msgstr "" "これにはいくつかの回避策があります。ひとつは通常文字列と二重バックスラッシュ" "を使うことです::" -#: ../../faq/programming.rst:1046 msgid "" ">>> 'C:\\\\this\\\\will\\\\work\\\\'\n" "'C:\\\\this\\\\will\\\\work\\\\'" msgstr "" +">>> 'C:\\\\this\\\\will\\\\work\\\\'\n" +"'C:\\\\this\\\\will\\\\work\\\\'" #: ../../faq/programming.rst:1049 msgid "" @@ -2168,11 +2178,12 @@ msgstr "" "もうひとつは、エスケープされたバックスラッシュを含む通常の文字列を、 raw " "string に連結します::" -#: ../../faq/programming.rst:1052 msgid "" ">>> r'C:\\this\\will\\work' '\\\\'\n" "'C:\\\\this\\\\will\\\\work\\\\'" msgstr "" +">>> r'C:\\this\\will\\work' '\\\\'\n" +"'C:\\\\this\\\\will\\\\work\\\\'" #: ../../faq/programming.rst:1055 msgid "" @@ -2182,11 +2193,12 @@ msgstr "" "Windowsでは、 :func:`os.path.join` を使ってバックスラッシュを追加することもで" "きます::" -#: ../../faq/programming.rst:1057 msgid "" ">>> os.path.join(r'C:\\this\\will\\work', '')\n" "'C:\\\\this\\\\will\\\\work\\\\'" msgstr "" +">>> os.path.join(r'C:\\this\\will\\work', '')\n" +"'C:\\\\this\\\\will\\\\work\\\\'" #: ../../faq/programming.rst:1060 msgid "" @@ -2199,11 +2211,12 @@ msgstr "" "ますが、 raw string の値を解釈する際にはエスケープが生じません。つまり、バッ" "クスラッシュは raw string 値の中に残ったままになります::" -#: ../../faq/programming.rst:1065 msgid "" ">>> r'backslash\\'preserved'\n" "\"backslash\\\\'preserved\"" msgstr "" +">>> r'backslash\\'preserved'\n" +"\"backslash\\\\'preserved\"" #: ../../faq/programming.rst:1068 msgid "Also see the specification in the :ref:`language reference `." @@ -2217,11 +2230,12 @@ msgstr "性能" msgid "My program is too slow. How do I speed it up?" msgstr "プログラムが遅すぎます。どうしたら速くなりますか?" -#: ../../faq/programming.rst:1077 msgid "" "That's a tough one, in general. First, here is a list of things to remember " "before diving further:" msgstr "" +"一般には難しい問題です。\n" +"詳しく検討する前に、まず次の点を覚えておいてください。" #: ../../faq/programming.rst:1080 msgid "" @@ -2264,14 +2278,13 @@ msgstr "" "洗練された最適化に隠れたリグレッションの可能性を生む前に、(ユニットテストやそ" "の他の技法で) コードカバレッジを上げることを強く推奨します。" -#: ../../faq/programming.rst:1092 msgid "" "That being said, there are many tricks to speed up Python code. Here are " "some general principles which go a long way towards reaching acceptable " "performance levels:" msgstr "" -"とは言っても、Python コードを高速化する技法はたくさんあります。ここでは、満足" -"な性能のレベルにたどり着くまでの長い道のりを進む、一般的な方針を示します:" +"とはいえ、Python コードを高速化する方法はたくさんあります。\n" +"満足できる性能を得るうえで大いに役立つ一般的な方針を紹介します。" #: ../../faq/programming.rst:1096 msgid "" @@ -2307,7 +2320,6 @@ msgstr "" "`sorted` 関数を使ってください (また、中程度に高度な例は、 :ref:" "`sortinghowto` を参照してください)。" -#: ../../faq/programming.rst:1111 msgid "" "Abstractions tend to create indirections and force the interpreter to work " "more. If the levels of indirection outweigh the amount of useful work done, " @@ -2315,12 +2327,11 @@ msgid "" "especially under the form of tiny functions or methods (which are also often " "detrimental to readability)." msgstr "" -"抽象化は、遠回りにしがちで、インタプリタの作業を増やすことになります。この遠" -"回りさが、なされる作業の量より重大になると、プログラムが遅くなってしまいま" -"す。過度な抽象化、特に細かい関数やメソッドの形で現れるもの (これは読みにくさ" -"も落とします) は防ぐべきです。" +"抽象化によって処理が間接的になると、インタープリタの仕事が増えがちです。\n" +"間接的な処理の負担が本来の処理の量を上回ると、プログラムが遅くなります。\n" +"過度な抽象化、特に細かすぎる関数やメソッドは避けるべきです。\n" +"こうした関数やメソッドは、読みやすさを損なうこともよくあります。" -#: ../../faq/programming.rst:1117 msgid "" "If you have reached the limit of what pure Python can allow, there are tools " "to take you further away. For example, `Cython `_ can " @@ -2331,12 +2342,14 @@ msgid "" "skills, you can also :ref:`write a C extension module ` " "yourself." msgstr "" -"pure Python にできる限界に達したなら、更に進むためのツールがあります。例え" -"ば、`Cython `_ は、Python コードのわずかに変形した版を C " -"拡張にコンパイルし、多種のプラットフォームで使えます。Cython は、コンパイル " -"(と任意の型アノテーション) を利用し、コードの解釈を大幅に速くします。C プログ" -"ラミングに自信があるなら、自分で :ref:`write a C extension module ` こともできます。" +"Python だけで書いたコードの限界に達したら、さらに性能を上げるためのツールがあ" +"ります。\n" +"例えば `Cython `_ は、Python コードに少し手を加えたもの" +"を C 拡張にコンパイルでき、多くのプラットフォームで使えます。\n" +"Cython はコンパイルと、省略可能な型アノテーションを活用することで、インタープ" +"リタによる実行よりもコードを大幅に高速化できます。\n" +"C のプログラミングに自信があれば、自分で :ref:`C 拡張モジュールを書く " +"` こともできます。" #: ../../faq/programming.rst:1127 msgid "" @@ -2350,7 +2363,6 @@ msgstr "" msgid "What is the most efficient way to concatenate many strings together?" msgstr "多くの文字列を結合するのに最も効率的な方法は何ですか?" -#: ../../faq/programming.rst:1136 msgid "" ":class:`str` and :class:`bytes` objects are immutable, therefore " "concatenating many strings together is inefficient as each concatenation " @@ -2358,6 +2370,10 @@ msgid "" "quadratic in the total string length. See :ref:`time-complexity` for more " "information." msgstr "" +":class:`str` と :class:`bytes` のオブジェクトはイミュータブルなので、多数の文" +"字列を連結すると、そのたびに新しいオブジェクトが作られて非効率になります。\n" +"一般には、実行時間は文字列の全長の二乗に比例します。\n" +"詳しくは :ref:`time-complexity` を参照してください。" #: ../../faq/programming.rst:1141 msgid "" @@ -2367,17 +2383,19 @@ msgstr "" "多くの :class:`str` オブジェクトを累積するのにおすすめのイディオムは、すべて" "をリストに配置してから最後に :meth:`str.join` を呼び出すことです::" -#: ../../faq/programming.rst:1144 msgid "" "chunks = []\n" "for s in my_strings:\n" " chunks.append(s)\n" "result = ''.join(chunks)" msgstr "" +"chunks = []\n" +"for s in my_strings:\n" +" chunks.append(s)\n" +"result = ''.join(chunks)" -#: ../../faq/programming.rst:1149 msgid "(Another reasonably efficient idiom is to use :class:`io.StringIO`.)" -msgstr "" +msgstr "(:class:`io.StringIO` を使うのも、ある程度効率のよい方法です。)" #: ../../faq/programming.rst:1151 msgid "" @@ -2389,16 +2407,17 @@ msgstr "" "class:`bytearray` オブジェクトをインプレース結合 (``+=`` 演算子) で拡張するこ" "とです::" -#: ../../faq/programming.rst:1154 msgid "" "result = bytearray()\n" "for b in my_bytes_objects:\n" " result += b" msgstr "" +"result = bytearray()\n" +"for b in my_bytes_objects:\n" +" result += b" -#: ../../faq/programming.rst:1160 msgid "Sequences (tuples/lists)" -msgstr "" +msgstr "シーケンス (タプルとリスト)" #: ../../faq/programming.rst:1163 msgid "How do I convert between tuples and lists?" @@ -2470,11 +2489,12 @@ msgstr "シーケンスを逆順にイテレートするにはどうしたらい msgid "Use the :func:`reversed` built-in function::" msgstr "組み込み関数 :func:`reversed` を使ってください。" -#: ../../faq/programming.rst:1197 msgid "" "for x in reversed(sequence):\n" " ... # do something with x ..." msgstr "" +"for x in reversed(sequence):\n" +" ... # x を使った処理 ..." #: ../../faq/programming.rst:1200 msgid "" @@ -2496,15 +2516,13 @@ msgstr "Python Cookbook の長い議論に多くの方法があるので参照 msgid "https://code.activestate.com/recipes/52560/" msgstr "https://code.activestate.com/recipes/52560/" -#: ../../faq/programming.rst:1211 msgid "" "If you don't mind reordering the list, sort it and then scan from the end of " "the list, deleting duplicates as you go::" msgstr "" -"リストを並び替えて構わないのなら、ソートした上でリストの最初から最後までを調" -"べ、次のように重複を削除してください::" +"リストの順序を変えてもよければ、ソートしてから末尾から順に調べ、重複を削除し" +"てください。 ::" -#: ../../faq/programming.rst:1214 msgid "" "if mylist:\n" " mylist.sort()\n" @@ -2515,16 +2533,24 @@ msgid "" " else:\n" " last = mylist[i]" msgstr "" +"if mylist:\n" +" mylist.sort()\n" +" last = mylist[-1]\n" +" for i in range(len(mylist)-2, -1, -1):\n" +" if last == mylist[i]:\n" +" del mylist[i]\n" +" else:\n" +" last = mylist[i]" -#: ../../faq/programming.rst:1223 msgid "" "If all elements of the list may be used as set keys (that is, they are all :" "term:`hashable`) this is often faster::" msgstr "" +"リストのすべての要素を集合に格納できる場合 (つまり、すべてが :term:" +"`hashable` な場合) は、次の方法のほうが速いことがよくあります。 ::" -#: ../../faq/programming.rst:1226 msgid "mylist = list(set(mylist))" -msgstr "" +msgstr "mylist = list(set(mylist))" #: ../../faq/programming.rst:1228 msgid "" @@ -2534,24 +2560,29 @@ msgstr "" "リストを集合に変換するときに重複は取り除かれるので、それをリストに戻せばいい" "のです。" -#: ../../faq/programming.rst:1233 msgid "How do you remove multiple items from a list?" -msgstr "" +msgstr "リストから複数の要素を取り除くにはどうしますか?" -#: ../../faq/programming.rst:1235 msgid "" "As with removing duplicates, explicitly iterating in reverse with a delete " "condition is one possibility. However, it is easier and faster to use slice " "replacement with an implicit or explicit forward iteration. Here are three " "variations::" msgstr "" +"重複を取り除く場合と同じように、逆順にイテレートし、条件に合う要素を削除する" +"方法があります。\n" +"ただし、暗黙的または明示的に順方向へイテレートし、スライスを置き換えるほうが" +"簡単で高速です。\n" +"次の 3 通りの書き方があります。 ::" -#: ../../faq/programming.rst:1240 msgid "" "mylist[:] = filter(keep_function, mylist)\n" "mylist[:] = (x for x in mylist if keep_condition)\n" "mylist[:] = [x for x in mylist if keep_condition]" msgstr "" +"mylist[:] = filter(keep_function, mylist)\n" +"mylist[:] = (x for x in mylist if keep_condition)\n" +"mylist[:] = [x for x in mylist if keep_condition]" #: ../../faq/programming.rst:1244 msgid "The list comprehension may be fastest." @@ -2565,9 +2596,8 @@ msgstr "Python で配列を作るにはどうしますか?" msgid "Use a list::" msgstr "リストを使ってください::" -#: ../../faq/programming.rst:1252 msgid "[\"this\", 1, \"is\", \"an\", \"array\"]" -msgstr "" +msgstr "[\"this\", 1, \"is\", \"an\", \"array\"]" #: ../../faq/programming.rst:1254 msgid "" @@ -2578,13 +2608,16 @@ msgstr "" "リストの時間計算量は C や Pascal の配列と同じです。大きな違いは、Python のリ" "ストは多くの異なる型のオブジェクトを含めることです。" -#: ../../faq/programming.rst:1257 msgid "" "The ``array`` module also provides methods for creating arrays of fixed " "types with compact representations, but they are slower to index than " "lists. Also note that `NumPy `_ and other third-party " "packages define array-like structures with various characteristics as well." msgstr "" +"``array`` モジュールにも、型を固定した配列をコンパクトな表現で作るためのメ" +"ソッドがありますが、インデックスによるアクセスはリストより遅くなります。\n" +"また、`NumPy `_ などのサードパーティーパッケージも、さま" +"ざまな特性を持つ配列に似た構造を定義しています。" #: ../../faq/programming.rst:1263 msgid "" @@ -2593,9 +2626,8 @@ msgstr "" "Lisp 方式の連結リストを得るのに、タプルを使って *cons cells* をエミュレートで" "きます::" -#: ../../faq/programming.rst:1265 msgid "lisp_list = (\"like\", (\"this\", (\"example\", None) ) )" -msgstr "" +msgstr "lisp_list = (\"like\", (\"this\", (\"example\", None) ) )" #: ../../faq/programming.rst:1267 msgid "" @@ -2617,42 +2649,44 @@ msgstr "多次元のリストを作るにはどうしますか?" msgid "You probably tried to make a multidimensional array like this::" msgstr "このようにして多次元の配列を作ろうとしてしまったことがあるでしょう::" -#: ../../faq/programming.rst:1280 msgid ">>> A = [[None] * 2] * 3" -msgstr "" +msgstr ">>> A = [[None] * 2] * 3" #: ../../faq/programming.rst:1282 msgid "This looks correct if you print it:" msgstr "これを表示したときには問題なさそうに見えます:" -#: ../../faq/programming.rst:1288 msgid "" ">>> A\n" "[[None, None], [None, None], [None, None]]" msgstr "" +">>> A\n" +"[[None, None], [None, None], [None, None]]" #: ../../faq/programming.rst:1293 msgid "But when you assign a value, it shows up in multiple places:" msgstr "しかし値を代入すると、その値が複数の場所に現れてしまいます:" -#: ../../faq/programming.rst:1299 msgid "" ">>> A[0][0] = 5\n" ">>> A\n" "[[5, None], [5, None], [5, None]]" msgstr "" +">>> A[0][0] = 5\n" +">>> A\n" +"[[5, None], [5, None], [5, None]]" -#: ../../faq/programming.rst:1305 msgid "" "The reason is that replicating a list with ``*`` doesn't create copies, it " "only creates references to the existing objects. The ``*3`` creates a list " "containing 3 references to the same list of length two. Changes to one row " "will show in all rows, which is almost certainly not what you want." msgstr "" -"これは、``*`` を使ったリストの複製がコピーを作らず、存在するオブジェクトへの" -"参照を作るだけだからです。この ``*3`` は長さ 2 の同じリストへの参照を含むリス" -"トを作ります。一つの列に対する変更はすべての列に現れますが、これが望んだ結果" -"であることはまずないでしょう。" +"``*`` によるリストの繰り返しは、要素のコピーではなく既存のオブジェクトへの参" +"照を作るためです。\n" +"``*3`` は、長さ 2 の同じリストへの参照を 3 つ含むリストを作ります。\n" +"1 つの行を変更するとすべての行に反映されますが、これが意図した結果であること" +"はまずないでしょう。" #: ../../faq/programming.rst:1310 msgid "" @@ -2662,12 +2696,14 @@ msgstr "" "おすすめの方法は、最初に望んだ長さのリストを作り、それから新しく作ったリスト" "でそれぞれの要素を埋めていくことです::" -#: ../../faq/programming.rst:1313 msgid "" "A = [None] * 3\n" "for i in range(3):\n" " A[i] = [None] * 2" msgstr "" +"A = [None] * 3\n" +"for i in range(3):\n" +" A[i] = [None] * 2" #: ../../faq/programming.rst:1317 msgid "" @@ -2677,11 +2713,12 @@ msgstr "" "これは長さ 2 の異なるリスト 3 つを含むリストを生成します。リスト内包表記も使" "えます::" -#: ../../faq/programming.rst:1320 msgid "" "w, h = 2, 3\n" "A = [[None] * w for i in range(h)]" msgstr "" +"w, h = 2, 3\n" +"A = [[None] * w for i in range(h)]" #: ../../faq/programming.rst:1323 msgid "" @@ -2695,18 +2732,21 @@ msgstr "" msgid "How do I apply a method or function to a sequence of objects?" msgstr "オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか?" -#: ../../faq/programming.rst:1330 msgid "" "To call a method or function and accumulate the return values in a list, a :" "term:`list comprehension` is an elegant solution::" msgstr "" +"メソッドや関数を呼び出し、その戻り値をリストにまとめるには、:term:`list " +"comprehension` を使うと簡潔に書けます。 ::" -#: ../../faq/programming.rst:1333 msgid "" "result = [obj.method() for obj in mylist]\n" "\n" "result = [function(obj) for obj in mylist]" msgstr "" +"result = [obj.method() for obj in mylist]\n" +"\n" +"result = [function(obj) for obj in mylist]" #: ../../faq/programming.rst:1337 msgid "" @@ -2716,7 +2756,6 @@ msgstr "" "戻り値を保存せずにメソッドや関数を実行するだけなら、ただの :keyword:`for` " "ループで十分です::" -#: ../../faq/programming.rst:1340 msgid "" "for obj in mylist:\n" " obj.method()\n" @@ -2724,6 +2763,11 @@ msgid "" "for obj in mylist:\n" " function(obj)" msgstr "" +"for obj in mylist:\n" +" obj.method()\n" +"\n" +"for obj in mylist:\n" +" function(obj)" #: ../../faq/programming.rst:1350 msgid "" @@ -2752,7 +2796,6 @@ msgstr "" msgid "If you wrote::" msgstr "次のように書いたとします::" -#: ../../faq/programming.rst:1362 msgid "" ">>> a_tuple = (1, 2)\n" ">>> a_tuple[0] += 1\n" @@ -2760,8 +2803,12 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> a_tuple = (1, 2)\n" +">>> a_tuple[0] += 1\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" -#: ../../faq/programming.rst:1368 msgid "" "The reason for the exception should be immediately clear: ``1`` is added to " "the object ``a_tuple[0]`` points to (``1``), producing the result object, " @@ -2769,10 +2816,12 @@ msgid "" "to element ``0`` of the tuple, we get an error because we can't change what " "an element of a tuple points to." msgstr "" -"例外が送出された理由は明らかです: ``1`` が (``1``) を指すオブジェクト " -"``a_tuple[0]`` に加えられ、結果のオブジェクト ``2`` が生成されますが、計算結" -"果 ``2`` をタプルの第 ``0`` 要素に代入しようとしたときに、エラーが発生しま" -"す。なぜならば、タプルの要素が何を指すかは変えられないからです。" +"例外の理由は明らかでしょう。\n" +"``a_tuple[0]`` が指すオブジェクト (``1``) に ``1`` を加えると、結果のオブジェ" +"クト ``2`` が作られます。\n" +"しかし、計算結果の ``2`` をタプルのインデックス ``0`` の要素に代入しようとす" +"るとエラーになります。\n" +"タプルの要素が指すオブジェクトは変更できないためです。" #: ../../faq/programming.rst:1374 msgid "" @@ -2780,7 +2829,6 @@ msgid "" "approximately this::" msgstr "このような裏事情の元、累算代入文はだいたい次のようなことをしています::" -#: ../../faq/programming.rst:1377 msgid "" ">>> result = a_tuple[0] + 1\n" ">>> a_tuple[0] = result\n" @@ -2788,6 +2836,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> result = a_tuple[0] + 1\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1383 msgid "" @@ -2799,7 +2852,6 @@ msgstr "タプルは不変なので、例外を生み出しているのは操作 msgid "When you write something like::" msgstr "次のように書いたとします::" -#: ../../faq/programming.rst:1388 msgid "" ">>> a_tuple = (['foo'], 'bar')\n" ">>> a_tuple[0] += ['item']\n" @@ -2807,6 +2859,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> a_tuple = (['foo'], 'bar')\n" +">>> a_tuple[0] += ['item']\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1394 msgid "" @@ -2816,13 +2873,13 @@ msgstr "" "この例外にはちょっと驚きますが、もっと驚くべきことは、エラーがあったとしても" "追記はきちんと動いている、という事実です::" -#: ../../faq/programming.rst:1397 msgid "" ">>> a_tuple[0]\n" "['foo', 'item']" msgstr "" +">>> a_tuple[0]\n" +"['foo', 'item']" -#: ../../faq/programming.rst:1400 msgid "" "To see why this happens, you need to know that (a) if an object implements " "an :meth:`~object.__iadd__` magic method, it gets called when the ``+=`` " @@ -2832,24 +2889,35 @@ msgid "" "That's why we say that for lists, ``+=`` is a \"shorthand\" for :meth:`list." "extend`::" msgstr "" +"この理由を理解するには、次の 2 点を知る必要があります。\n" +"(a) オブジェクトに :meth:`~object.__iadd__` 特殊メソッドが実装されていると、" +"``+=`` による累算代入の実行時にそのメソッドが呼ばれ、戻り値が代入に使われま" +"す。\n" +"(b) リストの :meth:`!__iadd__` は、そのリストの :meth:`~sequence.extend` を呼" +"び出してからリストを返すのと同じです。\n" +"このため、リストの ``+=`` は :meth:`list.extend` の「短縮形」といえます。 ::" -#: ../../faq/programming.rst:1408 msgid "" ">>> a_list = []\n" ">>> a_list += [1]\n" ">>> a_list\n" "[1]" msgstr "" +">>> a_list = []\n" +">>> a_list += [1]\n" +">>> a_list\n" +"[1]" #: ../../faq/programming.rst:1413 msgid "This is equivalent to::" msgstr "これは次と等価です::" -#: ../../faq/programming.rst:1415 msgid "" ">>> result = a_list.__iadd__([1])\n" ">>> a_list = result" msgstr "" +">>> result = a_list.__iadd__([1])\n" +">>> a_list = result" #: ../../faq/programming.rst:1418 msgid "" @@ -2867,7 +2935,6 @@ msgstr "" msgid "Thus, in our tuple example what is happening is equivalent to::" msgstr "従って、今のタプルの例では、次のと同じことが起きています::" -#: ../../faq/programming.rst:1425 msgid "" ">>> result = a_tuple[0].__iadd__(['item'])\n" ">>> a_tuple[0] = result\n" @@ -2875,6 +2942,11 @@ msgid "" " ...\n" "TypeError: 'tuple' object does not support item assignment" msgstr "" +">>> result = a_tuple[0].__iadd__(['item'])\n" +">>> a_tuple[0] = result\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: 'tuple' object does not support item assignment" #: ../../faq/programming.rst:1431 msgid "" @@ -2905,21 +2977,23 @@ msgstr "" "ます。Python では、 :meth:`list.sort` メソッドに ``key`` 引数を使ってくださ" "い::" -#: ../../faq/programming.rst:1443 msgid "" "Isorted = L[:]\n" "Isorted.sort(key=lambda s: int(s[10:15]))" msgstr "" +"Isorted = L[:]\n" +"Isorted.sort(key=lambda s: int(s[10:15]))" #: ../../faq/programming.rst:1448 msgid "How can I sort one list by values from another list?" msgstr "リストを別のリストの値によってソートするにはどうしますか?" -#: ../../faq/programming.rst:1450 msgid "" "Merge them into an iterator of tuples, sort the resulting list, and then " "pick out the element you want." msgstr "" +"2 つのリストをタプルのイテレータにまとめ、その結果から得られるリストをソート" +"して、必要な要素を取り出してください。" #: ../../faq/programming.rst:1465 msgid "Objects" @@ -2929,17 +3003,17 @@ msgstr "オブジェクト" msgid "What is a class?" msgstr "クラスとは何ですか?" -#: ../../faq/programming.rst:1470 msgid "" "A class is the particular object type created by executing a class " "statement. Class objects are used as templates to create instance objects, " "which embody both the data (attributes) and code (methods) specific to a " "datatype." msgstr "" -"クラスは、class 文の実行で生成される特殊なオブジェクトです。クラスオブジェク" -"トはインスタンスオブジェクトを生成するためのテンプレートとして使われ、ある" -"データ型に特有のデータ (attribute/属性) とコード (メソッド) の両方を内蔵して" -"います。" +"クラスは class 文の実行によって作られる、特定の種類のオブジェクトです。\n" +"クラスオブジェクトはインスタンスオブジェクトを作るためのテンプレートとして使" +"われます。\n" +"インスタンスオブジェクトは、そのデータ型に固有のデータ (属性) とコード (メ" +"ソッド) の両方を備えています。" #: ../../faq/programming.rst:1474 msgid "" @@ -2970,12 +3044,14 @@ msgstr "" "メソッドは、オブジェクト ``x`` が持つ関数で、通常 ``x.name(arguments...)`` と" "して呼び出されるものです。メソッドはクラス定義の中で関数として定義されます::" -#: ../../faq/programming.rst:1489 msgid "" "class C:\n" " def meth(self, arg):\n" " return arg * 2 + self.attribute" msgstr "" +"class C:\n" +" def meth(self, arg):\n" +" return arg * 2 + self.attribute" #: ../../faq/programming.rst:1495 msgid "What is self?" @@ -3005,7 +3081,6 @@ msgstr "" "あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを" "調べるにはどうしますか?" -#: ../../faq/programming.rst:1508 msgid "" "Use the built-in function :func:`isinstance(obj, cls) `. You " "can check if an object is an instance of any of a number of classes by " @@ -3014,8 +3089,13 @@ msgid "" "Python's built-in types, for example, ``isinstance(obj, str)`` or " "``isinstance(obj, (int, float, complex))``." msgstr "" +"組み込み関数 :func:`isinstance(obj, cls) ` を使ってください。\n" +"``isinstance(obj, (class1, class2, ...))`` のように、クラスを 1 つ渡す代わり" +"にタプルを渡すと、複数のクラスのいずれかのインスタンスであるかを調べられま" +"す。\n" +"また、``isinstance(obj, str)`` や ``isinstance(obj, (int, float, complex))`` " +"のように、Python の組み込み型のインスタンスであるかも調べられます。" -#: ../../faq/programming.rst:1515 msgid "" "Note that :func:`isinstance` also checks for virtual inheritance from an :" "term:`abstract base class`. So, the test will return ``True`` for a " @@ -3023,8 +3103,13 @@ msgid "" "To test for \"true inheritance\", scan the :term:`method resolution order` " "(MRO) of the class:" msgstr "" +":func:`isinstance` は :term:`abstract base class` の仮想的な継承も調べま" +"す。\n" +"そのため、抽象基底クラスに登録されたクラスであれば、直接または間接的に継承し" +"ていなくても ``True`` を返します。\n" +"「実際の継承」を調べるには、そのクラスの :term:`method resolution order` " +"(MRO) を確認します。" -#: ../../faq/programming.rst:1521 msgid "" "from collections.abc import Mapping\n" "\n" @@ -3036,8 +3121,16 @@ msgid "" "\n" "Mapping.register(P)" msgstr "" +"from collections.abc import Mapping\n" +"\n" +"class P:\n" +" pass\n" +"\n" +"class C(P):\n" +" pass\n" +"\n" +"Mapping.register(P)" -#: ../../faq/programming.rst:1533 msgid "" ">>> c = C()\n" ">>> isinstance(c, C) # direct\n" @@ -3055,8 +3148,22 @@ msgid "" ">>> Mapping in type(c).__mro__\n" "False" msgstr "" +">>> c = C()\n" +">>> isinstance(c, C) # 直接\n" +"True\n" +">>> isinstance(c, P) # 間接\n" +"True\n" +">>> isinstance(c, Mapping) # 仮想\n" +"True\n" +"\n" +"# 実際の継承関係\n" +">>> type(c).__mro__\n" +"(, , )\n" +"\n" +"# 「実際の継承」を調べる\n" +">>> Mapping in type(c).__mro__\n" +"False" -#: ../../faq/programming.rst:1551 msgid "" "Note that most programs do not use :func:`isinstance` on user-defined " "classes very often. If you are developing the classes yourself, a more " @@ -3065,13 +3172,13 @@ msgid "" "and doing a different thing based on what class it is. For example, if you " "have a function that does something::" msgstr "" -"なお、大部分のプログラムでは、 :func:`isinstance` をユーザー定義のクラスに何" -"度も使うべきではありません。クラスを自分で開発するときに、適切なオブジェクト" -"指向スタイルは、特定の振る舞いをカプセル化するクラスのメソッドを定義するもの" -"であって、オブジェクトのクラスを調べてそのクラスに応じて違うことをするもので" -"はありません。例えば、何かをする関数があったとして::" +"なお、ほとんどのプログラムでは、ユーザー定義のクラスに対して :func:" +"`isinstance` を頻繁には使いません。\n" +"自分でクラスを開発するなら、オブジェクトのクラスを調べて処理を分岐させるより" +"も、各クラスに特定の振る舞いをカプセル化するメソッドを定義するほうが、オブ" +"ジェクト指向に適した書き方です。\n" +"例えば、次のような関数があるとします。 ::" -#: ../../faq/programming.rst:1558 msgid "" "def search(obj):\n" " if isinstance(obj, Mailbox):\n" @@ -3080,6 +3187,12 @@ msgid "" " ... # code to search a document\n" " elif ..." msgstr "" +"def search(obj):\n" +" if isinstance(obj, Mailbox):\n" +" ... # メールボックスを検索するコード\n" +" elif isinstance(obj, Document):\n" +" ... # 文書を検索するコード\n" +" elif ..." #: ../../faq/programming.rst:1565 msgid "" @@ -3089,7 +3202,6 @@ msgstr "" "よりよいアプローチは、``search()`` メソッドをすべてのクラスに定義して、それを" "ただ呼び出すことです::" -#: ../../faq/programming.rst:1568 msgid "" "class Mailbox:\n" " def search(self):\n" @@ -3101,12 +3213,20 @@ msgid "" "\n" "obj.search()" msgstr "" +"class Mailbox:\n" +" def search(self):\n" +" ... # メールボックスを検索するコード\n" +"\n" +"class Document:\n" +" def search(self):\n" +" ... # 文書を検索するコード\n" +"\n" +"obj.search()" #: ../../faq/programming.rst:1580 msgid "What is delegation?" msgstr "委譲とは何ですか?" -#: ../../faq/programming.rst:1582 msgid "" "Delegation is an object-oriented technique (also called a design pattern). " "Let's say you have an object ``x`` and want to change the behaviour of just " @@ -3114,17 +3234,21 @@ msgid "" "implementation of the method you're interested in changing and delegates all " "other methods to the corresponding method of ``x``." msgstr "" +"委譲はオブジェクト指向の技法 (デザインパターンとも呼ばれます) の 1 つです。\n" +"オブジェクト ``x`` があり、そのメソッドのうち 1 つだけ振る舞いを変えたいとし" +"ます。\n" +"そのメソッドの新しい実装を持ち、ほかのすべてのメソッドの処理を ``x`` の対応す" +"るメソッドに委ねるクラスを作れます。" -#: ../../faq/programming.rst:1588 msgid "" "Python programmers can easily implement delegation. For example, the " "following class implements a class that behaves like a file but converts all " "written data to uppercase::" msgstr "" -"Python プログラマは簡単に委譲を実装できます。例えば、以下のクラスは、ファイル" -"のように振る舞いながらすべての文字を大文字に変換するクラスを実装します::" +"Python では委譲を簡単に実装できます。\n" +"例えば、次のクラスはファイルのように振る舞いますが、書き込まれるデータをすべ" +"て大文字に変換します。 ::" -#: ../../faq/programming.rst:1592 msgid "" "class UpperOut:\n" "\n" @@ -3137,6 +3261,16 @@ msgid "" " def __getattr__(self, name):\n" " return getattr(self._outfile, name)" msgstr "" +"class UpperOut:\n" +"\n" +" def __init__(self, outfile):\n" +" self._outfile = outfile\n" +"\n" +" def write(self, s):\n" +" self._outfile.write(s.upper())\n" +"\n" +" def __getattr__(self, name):\n" +" return getattr(self._outfile, name)" #: ../../faq/programming.rst:1603 msgid "" @@ -3154,7 +3288,6 @@ msgstr "" "されます。属性の制御の詳細は :ref:`言語リファレンス ` を参" "照してください。" -#: ../../faq/programming.rst:1610 msgid "" "Note that for more general cases delegation can get trickier. When " "attributes must be set as well as retrieved, the class must define a :meth:" @@ -3162,12 +3295,11 @@ msgid "" "implementation of :meth:`!__setattr__` is roughly equivalent to the " "following::" msgstr "" -"なお、一般的に委譲はトリッキーになりがちです。属性が設定される時には読み出さ" -"れる時と同様に、そのクラスに :meth:`~object.__setattr__` メソッドを定義する必" -"要があり、それには細心の注意が必要です。 :meth:`!__setattr__` の基本的な実装" -"はおおよそ以下のようになります::" +"より一般的な場合には、委譲が複雑になることがあります。\n" +"属性の取得だけでなく設定も扱うには、クラスに :meth:`~object.__setattr__` メ" +"ソッドも定義する必要があり、その実装には注意が必要です。\n" +":meth:`!__setattr__` の基本的な実装は、おおよそ次と同じです。 ::" -#: ../../faq/programming.rst:1615 msgid "" "class X:\n" " ...\n" @@ -3175,26 +3307,36 @@ msgid "" " self.__dict__[name] = value\n" " ..." msgstr "" +"class X:\n" +" ...\n" +" def __setattr__(self, name, value):\n" +" self.__dict__[name] = value\n" +" ..." -#: ../../faq/programming.rst:1621 msgid "" "Many :meth:`~object.__setattr__` implementations call :meth:`!object." "__setattr__` to set an attribute on self without causing infinite recursion::" msgstr "" +":meth:`~object.__setattr__` の多くの実装では、無限再帰を起こさずに ``self`` " +"の属性を設定するため、:meth:`!object.__setattr__` を呼び出します。 ::" -#: ../../faq/programming.rst:1624 msgid "" "class X:\n" " def __setattr__(self, name, value):\n" " # Custom logic here...\n" " object.__setattr__(self, name, value)" msgstr "" +"class X:\n" +" def __setattr__(self, name, value):\n" +" # ここに独自の処理を書く...\n" +" object.__setattr__(self, name, value)" -#: ../../faq/programming.rst:1629 msgid "" "Alternatively, it is possible to set attributes by inserting entries into :" "attr:`self.__dict__ ` directly." msgstr "" +":attr:`self.__dict__ ` に直接エントリーを追加して属性を設定" +"することもできます。" #: ../../faq/programming.rst:1634 msgid "" @@ -3208,14 +3350,15 @@ msgstr "" msgid "Use the built-in :func:`super` function::" msgstr "組み込みの :func:`super` 関数を使ってください::" -#: ../../faq/programming.rst:1638 msgid "" "class Derived(Base):\n" " def meth(self):\n" " super().meth() # calls Base.meth" msgstr "" +"class Derived(Base):\n" +" def meth(self):\n" +" super().meth() # Base.meth を呼び出す" -#: ../../faq/programming.rst:1642 msgid "" "In the example, :func:`super` will automatically determine the instance from " "which it was called (the ``self`` value), look up the :term:`method " @@ -3224,21 +3367,22 @@ msgid "" msgstr "" "この例では、 :func:`super` は呼ばれたインスタンス (``self`` の値) を自動判断" "し、 ``type(self).__mro__`` で :term:`method resolution order` (MRO メソッド" -"解決順) を検索し、そしてMRO内で ``Derived`` の次行を返します: ``Base`` 。" +"解決順) を検索し、MRO で ``Derived`` の次にある ``Base`` を返します。" -#: ../../faq/programming.rst:1649 msgid "How can I organize my code to make it easier to change the base class?" -msgstr "基底クラスの名前を変えやすいコードを書くにはどうしますか?" +msgstr "基底クラスを変更しやすいようにコードを構成するにはどうしますか?" -#: ../../faq/programming.rst:1651 msgid "" "You could assign the base class to an alias and derive from the alias. Then " "all you have to change is the value assigned to the alias. Incidentally, " "this trick is also handy if you want to decide dynamically (such as " "depending on availability of resources) which base class to use. Example::" msgstr "" +"基底クラスを別名に代入し、その別名を使って継承できます。\n" +"こうすれば、別名に代入する値だけを変更すれば済みます。\n" +"この方法は、例えばリソースが利用できるかどうかに応じて、使う基底クラスを動的" +"に決めたい場合にも便利です。 ::" -#: ../../faq/programming.rst:1656 msgid "" "class Base:\n" " ...\n" @@ -3248,6 +3392,13 @@ msgid "" "class Derived(BaseAlias):\n" " ..." msgstr "" +"class Base:\n" +" ...\n" +"\n" +"BaseAlias = Base\n" +"\n" +"class Derived(BaseAlias):\n" +" ..." #: ../../faq/programming.rst:1666 msgid "How do I create static class data and static class methods?" @@ -3269,7 +3420,6 @@ msgstr "" "静的なデータを作るには、単純にクラス属性を定義してください。その属性に新しい" "値を代入するには、代入するクラス名を明示する必要があります::" -#: ../../faq/programming.rst:1674 msgid "" "class C:\n" " count = 0 # number of times C.__init__ called\n" @@ -3280,6 +3430,14 @@ msgid "" " def getcount(self):\n" " return C.count # or return self.count" msgstr "" +"class C:\n" +" count = 0 # C.__init__ が呼び出された回数\n" +"\n" +" def __init__(self):\n" +" C.count = C.count + 1\n" +"\n" +" def getcount(self):\n" +" return C.count # または return self.count" #: ../../faq/programming.rst:1683 msgid "" @@ -3303,15 +3461,13 @@ msgstr "" "静的なデータの再束縛には、メソッド内であるか否かにかかわらず、いつもクラスを" "指定しなければなりません::" -#: ../../faq/programming.rst:1692 msgid "C.count = 314" -msgstr "" +msgstr "C.count = 314" #: ../../faq/programming.rst:1694 msgid "Static methods are possible::" msgstr "静的メソッドが使えます::" -#: ../../faq/programming.rst:1696 msgid "" "class C:\n" " @staticmethod\n" @@ -3319,6 +3475,11 @@ msgid "" " # No 'self' parameter!\n" " ..." msgstr "" +"class C:\n" +" @staticmethod\n" +" def static(arg1, arg2, arg3):\n" +" # 'self' 仮引数はない!\n" +" ..." #: ../../faq/programming.rst:1702 msgid "" @@ -3328,20 +3489,19 @@ msgstr "" "しかし、静的メソッドの効果を得るもっと簡単な方法は、単にモジュールレベル関数" "を使うことです::" -#: ../../faq/programming.rst:1705 msgid "" "def getcount():\n" " return C.count" msgstr "" +"def getcount():\n" +" return C.count" -#: ../../faq/programming.rst:1708 msgid "" "If your code is structured so as to define one class (or tightly related " "class hierarchy) per module, this supplies the desired encapsulation." msgstr "" -"モジュールあたりに一つのクラスを定義するように (あるいはクラス組織を厳密に関" -"連させるように) コードが構成されているなら、これで必要なカプセル化ができま" -"す。" +"モジュールごとに 1 つのクラス、または密接に関連するクラス階層を定義する構成な" +"ら、この方法で必要なカプセル化を実現できます。" #: ../../faq/programming.rst:1713 msgid "How can I overload constructors (or methods) in Python?" @@ -3349,25 +3509,26 @@ msgstr "" "Python でコンストラクタ(やメソッド)をオーバーロードするにはどうしたらいいです" "か?" -#: ../../faq/programming.rst:1715 msgid "" "This answer actually applies to all methods, but the question usually comes " "up first in the context of constructors." msgstr "" -"この質問の答えはすべてのメソッドについて言えることですが、この質問はだいたい" -"以下の構造の文脈から出てきます。" +"この回答は実際にはすべてのメソッドに当てはまりますが、通常、この疑問が最初に" +"生じるのはコンストラクタについてです。" -#: ../../faq/programming.rst:1718 msgid "In C++ you'd write:" -msgstr "" +msgstr "C++ では次のように書くでしょう。" -#: ../../faq/programming.rst:1720 msgid "" "class C {\n" " C() { cout << \"No arguments\\n\"; }\n" " C(int i) { cout << \"Argument is \" << i << \"\\n\"; }\n" "}" msgstr "" +"class C {\n" +" C() { cout << \"No arguments\\n\"; }\n" +" C(int i) { cout << \"Argument is \" << i << \"\\n\"; }\n" +"}" #: ../../faq/programming.rst:1727 msgid "" @@ -3377,7 +3538,6 @@ msgstr "" "Python では、一つのコンストラクタでデフォルトの引数を使ってすべての場合に対応" "するように書かなければなりません。例えば::" -#: ../../faq/programming.rst:1730 msgid "" "class C:\n" " def __init__(self, i=None):\n" @@ -3386,28 +3546,33 @@ msgid "" " else:\n" " print(\"Argument is\", i)" msgstr "" +"class C:\n" +" def __init__(self, i=None):\n" +" if i is None:\n" +" print(\"No arguments\")\n" +" else:\n" +" print(\"Argument is\", i)" #: ../../faq/programming.rst:1737 msgid "This is not entirely equivalent, but close enough in practice." msgstr "これで完全に等価とは言えませんが、実用上は十分に近いです。" -#: ../../faq/programming.rst:1739 msgid "You could also try a variable-length argument list, for example::" -msgstr "" +msgstr "可変長の引数リストを使う方法もあります。 ::" -#: ../../faq/programming.rst:1741 msgid "" "def __init__(self, *args):\n" " ..." msgstr "" +"def __init__(self, *args):\n" +" ..." #: ../../faq/programming.rst:1744 msgid "The same approach works for all method definitions." msgstr "これと同じやり方がすべてのメソッド定義で使えます。" -#: ../../faq/programming.rst:1748 msgid "I try to use __spam and I get an error about _SomeClassName__spam." -msgstr "__spam を使おうとしたら _SomeClassName__spam からエラーがでました。" +msgstr "__spam を使おうとすると、_SomeClassName__spam に関するエラーが出ます。" #: ../../faq/programming.rst:1750 msgid "" @@ -3424,13 +3589,13 @@ msgstr "" "子は、``classname`` が先頭のアンダースコアをすべて削除した現在のクラス名とす" "れば、``_classname__spam`` のように文字上で置換えられます。" -#: ../../faq/programming.rst:1756 msgid "" "The identifier can be used unchanged within the class, but to access it " "outside the class, the mangled name must be used:" msgstr "" +"クラス内では識別子をそのまま使えますが、クラス外からアクセスするにはマングル" +"化された名前を使う必要があります。" -#: ../../faq/programming.rst:1759 msgid "" "class A:\n" " def __one(self):\n" @@ -3444,13 +3609,26 @@ msgid "" "\n" "four = 4 * A()._A__one()" msgstr "" +"class A:\n" +" def __one(self):\n" +" return 1\n" +" def two(self):\n" +" return 2 * self.__one()\n" +"\n" +"class B(A):\n" +" def three(self):\n" +" return 3 * self._A__one()\n" +"\n" +"four = 4 * A()._A__one()" -#: ../../faq/programming.rst:1773 msgid "" "In particular, this does not guarantee privacy since an outside user can " "still deliberately access the private attribute; many Python programmers " "never bother to use private variable names at all." msgstr "" +"特に、この仕組みはプライバシーを保証するものではありません。\n" +"外部の利用者が意図的にプライベート属性にアクセスすることは可能です。\n" +"Python プログラマの多くは、プライベートな変数名をあえて使うことはしません。" #: ../../faq/programming.rst:1779 msgid "" @@ -3480,7 +3658,6 @@ msgstr "" "-- これは単純にオブジェクトの参照カウントを減らすもので、カウントがゼロになっ" "たときに :meth:`!__del__` が呼び出されます。" -#: ../../faq/programming.rst:1792 msgid "" "If your data structures contain circular links (for example, a tree where " "each child has a parent reference and each parent has a list of children) " @@ -3493,8 +3670,19 @@ msgid "" "You can run :func:`gc.collect` to force a collection, but there *are* " "pathological cases where objects will never be collected." msgstr "" +"データ構造に循環参照があると、参照カウントはゼロに戻りません。\n" +"例えば、各子が親への参照を持ち、各親が子のリストを持つツリーがこれに当たりま" +"す。\n" +"Python はこうした循環を検出するアルゴリズムを時折実行しますが、データ構造への" +"最後の参照がなくなってからガベージコレクタが動くまでには、時間がかかる場合が" +"あります。\n" +"そのため、:meth:`!__del__` メソッドが都合の悪い、予測できないタイミングで呼ば" +"れることがあります。\n" +"これは問題を再現しようとするときに不便です。\n" +"さらに、オブジェクトの :meth:`!__del__` メソッドの実行順序は任意です。\n" +":func:`gc.collect` を実行して回収を強制できますが、オブジェクトが決して回収さ" +"れない特殊な場合も *あります*。" -#: ../../faq/programming.rst:1803 msgid "" "Despite the cycle collector, it's still a good idea to define an explicit " "``close()`` method on objects to be called whenever you're done with them. " @@ -3503,13 +3691,12 @@ msgid "" "``close()`` and ``close()`` should make sure that it can be called more than " "once for the same object." msgstr "" -"循環参照コレクタがあるとはいえ、オブジェクトに ``close()`` メソッドを明示的に" -"定義し、使い終わったらいつでも呼び出せるようにするのはいいことです。\n" -"``close()`` メソッドを使うと、サブオブジェクトを参照している属性を取り除けま" -"す。\n" -":meth:`!__del__` を直接呼び出さないでください -- :meth:`!__del__` は " -"``close()`` を呼び出すでしょうし、 ``close()`` なら同じオブジェクトに対して複" -"数回呼ばれてもいいことが保証されているでしょう。" +"循環参照を回収する仕組みがあっても、オブジェクトには明示的な ``close()`` メ" +"ソッドを定義し、使い終わったときに呼び出すようにするとよいでしょう。\n" +"``close()`` メソッドでは、下位のオブジェクトを参照する属性を削除できます。\n" +":meth:`!__del__` を直接呼び出さないでください。\n" +":meth:`!__del__` から ``close()`` を呼び出し、``close()`` は同じオブジェクト" +"に対して複数回呼び出せるように実装してください。" #: ../../faq/programming.rst:1810 msgid "" @@ -3562,16 +3749,16 @@ msgstr "" "はメモリの同じ場所にメモリ領域を確保されていることが、しばしば起きます。この" "現象を次の例で示しましょう:" -#: ../../faq/programming.rst:1849 msgid "" "The two ids belong to different integer objects that are created before, and " "deleted immediately after execution of the ``id()`` call. To be sure that " "objects whose id you want to examine are still alive, create another " "reference to the object:" msgstr "" -"2 つの同じ値を持つ id は ``id()`` の実行の前に作られてすぐさま削除された異な" -"る整数オブジェクトによるものです。id を調べたいオブジェクトがまだ生きてること" -"を保証したいなら、オブジェクトへの別の参照を作ってください:" +"この 2 つの id は、それぞれ ``id()`` の呼び出し前に作られ、呼び出しの実行直後" +"に削除された、異なる整数オブジェクトのものです。\n" +"id を調べるオブジェクトがまだ生存していることを保証するには、そのオブジェクト" +"への別の参照を作ってください。" #: ../../faq/programming.rst:1864 msgid "When can I rely on identity tests with the *is* operator?" @@ -3607,25 +3794,30 @@ msgstr "" "保証されている場合 *のみ* です。 一般的に、同一性が保証される状況は3つありま" "す:" -#: ../../faq/programming.rst:1878 msgid "" "Assignments create new names but do not change object identity. After the " "assignment ``new = old``, it is guaranteed that ``new is old``." msgstr "" +"代入は新しい名前を作りますが、オブジェクトの同一性は変えません。\n" +"``new = old`` と代入した後は、``new is old`` が保証されます。" -#: ../../faq/programming.rst:1881 msgid "" "Putting an object in a container that stores object references does not " "change object identity. After the list assignment ``s[0] = x``, it is " "guaranteed that ``s[0] is x``." msgstr "" +"オブジェクトへの参照を格納するコンテナにオブジェクトを入れても、その同一性は" +"変わりません。\n" +"リストへの代入 ``s[0] = x`` の後は、``s[0] is x`` が保証されます。" -#: ../../faq/programming.rst:1885 msgid "" "If an object is a singleton, it means that only one instance of that object " "can exist. After the assignments ``a = None`` and ``b = None``, it is " "guaranteed that ``a is b`` because ``None`` is a singleton." msgstr "" +"シングルトンのオブジェクトは、インスタンスが 1 つしか存在できません。\n" +"``None`` はシングルトンなので、``a = None`` と ``b = None`` を代入した後は、" +"``a is b`` が保証されます。" #: ../../faq/programming.rst:1889 msgid "" @@ -3638,7 +3830,6 @@ msgstr "" "特に、シングルトンであることが保証されていない :class:`int` や :class:`str` " "などの定数をチェックするために同一性テストを使わないでください。" -#: ../../faq/programming.rst:1894 msgid "" ">>> a = 10_000_000\n" ">>> b = 5_000_000\n" @@ -3652,19 +3843,33 @@ msgid "" ">>> a is c\n" "False" msgstr "" +">>> a = 10_000_000\n" +">>> b = 5_000_000\n" +">>> c = b + 5_000_000\n" +">>> a is c\n" +"False\n" +"\n" +">>> a = 'Python'\n" +">>> b = 'Py'\n" +">>> c = b + 'thon'\n" +">>> a is c\n" +"False" #: ../../faq/programming.rst:1906 msgid "Likewise, new instances of mutable containers are never identical::" msgstr "" "同様に、ミュータブルなコンテナの新しいインスタンスは同一ではありません::" -#: ../../faq/programming.rst:1908 msgid "" ">>> a = []\n" ">>> b = []\n" ">>> a is b\n" "False" msgstr "" +">>> a = []\n" +">>> b = []\n" +">>> a is b\n" +"False" #: ../../faq/programming.rst:1913 msgid "" @@ -3674,14 +3879,15 @@ msgstr "" "標準ライブラリのコードには、同一性テストを正しく使うための一般的なパターンが" "あります:" -#: ../../faq/programming.rst:1916 msgid "" "As recommended by :pep:`8`, an identity test is the preferred way to check " "for ``None``. This reads like plain English in code and avoids confusion " "with other objects that may have boolean values that evaluate to false." msgstr "" -":pep:`8` で推奨されているとおり、同一性テストは ``None`` をチェックする際に望" -"ましい方法です。これはコードの中で自然な英語に読むことができ、また" +":pep:`8` が推奨するとおり、``None`` かどうかを調べるには同一性テストを使うの" +"が望ましい方法です。\n" +"コードを自然な英語として読めるうえ、真偽値が偽と評価されるほかのオブジェクト" +"との混同も避けられます。" #: ../../faq/programming.rst:1920 msgid "" @@ -3695,7 +3901,6 @@ msgstr "" "オブジェクト( singleton sentinel object )を作ることで対策できます。例え" "ば、 :meth:`dict.pop` のように振る舞うメソッドを実装する方法を示します:" -#: ../../faq/programming.rst:1925 msgid "" "_sentinel = sentinel('_sentinel')\n" "\n" @@ -3708,6 +3913,16 @@ msgid "" " raise KeyError(key)\n" " return default" msgstr "" +"_sentinel = sentinel('_sentinel')\n" +"\n" +"def pop(self, key, default=_sentinel):\n" +" if key in self:\n" +" value = self[key]\n" +" del self[key]\n" +" return value\n" +" if default is _sentinel:\n" +" raise KeyError(key)\n" +" return default" #: ../../faq/programming.rst:1938 msgid "" @@ -3719,14 +3934,13 @@ msgstr "" "ます。これは、 ``float('NaN')`` のような自分自身と等しくないオブジェクトに" "よってコードが混乱するのを防ぎます。" -#: ../../faq/programming.rst:1942 msgid "" "For example, here is the implementation of :meth:`!collections.abc.Sequence." "__contains__`::" msgstr "" -"例えば、これは :meth:`!collections.abc.Sequence.__contains__`: の実装です:" +"例えば、:meth:`!collections.abc.Sequence.__contains__` の実装は次のとおりで" +"す。 ::" -#: ../../faq/programming.rst:1945 msgid "" "def __contains__(self, value):\n" " for v in self:\n" @@ -3734,6 +3948,11 @@ msgid "" " return True\n" " return False" msgstr "" +"def __contains__(self, value):\n" +" for v in self:\n" +" if v is value or v == value:\n" +" return True\n" +" return False" #: ../../faq/programming.rst:1953 msgid "" @@ -3742,17 +3961,16 @@ msgstr "" "どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御で" "きますか?" -#: ../../faq/programming.rst:1955 msgid "" "When subclassing an immutable type, override the :meth:`~object.__new__` " "method instead of the :meth:`~object.__init__` method. The latter only runs " "*after* an instance is created, which is too late to alter data in an " "immutable instance." msgstr "" -"イミュータブル型をサブクラス化する場合、 :meth:`~object.__init__` ではなく :" -"meth:`~object.__new__` メソッドを継承します。 前者はインスタンスが生成され" -"た *後* に動くため、イミュータブルなインスタンスのデータを変えるには遅すぎま" -"す。" +"イミュータブルな型のサブクラスを作る場合は、:meth:`~object.__init__` ではな" +"く :meth:`~object.__new__` メソッドをオーバーライドしてください。\n" +"``__init__()`` が実行されるのはインスタンスが作られた *後* なので、イミュータ" +"ブルなインスタンスのデータを変更するには遅すぎます。" #: ../../faq/programming.rst:1960 msgid "" @@ -3761,7 +3979,6 @@ msgid "" msgstr "" "これらのイミュータブルクラスはすべて、親クラスと異なるシグネチャを持ちます:" -#: ../../faq/programming.rst:1963 msgid "" "import datetime as dt\n" "\n" @@ -3784,12 +4001,31 @@ msgid "" " s = ''.join([c for c in s if c.isalnum() or c == '-'])\n" " return super().__new__(cls, s)" msgstr "" +"import datetime as dt\n" +"\n" +"class FirstOfMonthDate(dt.date):\n" +" \"常にその月の初日を選ぶ\"\n" +" def __new__(cls, year, month, day):\n" +" return super().__new__(cls, year, month, 1)\n" +"\n" +"class NamedInt(int):\n" +" \"一部の数値を文字列の名前で指定できるようにする\"\n" +" xlat = {'zero': 0, 'one': 1, 'ten': 10}\n" +" def __new__(cls, value):\n" +" value = cls.xlat.get(value, value)\n" +" return super().__new__(cls, value)\n" +"\n" +"class TitleStr(str):\n" +" \"文字列を URL パスに適した名前に変換する\"\n" +" def __new__(cls, s):\n" +" s = s.lower().replace(' ', '-')\n" +" s = ''.join([c for c in s if c.isalnum() or c == '-'])\n" +" return super().__new__(cls, s)" #: ../../faq/programming.rst:1986 msgid "The classes can be used like this:" msgstr "クラスはこのように使えます:" -#: ../../faq/programming.rst:1988 msgid "" ">>> FirstOfMonthDate(2012, 2, 14)\n" "FirstOfMonthDate(2012, 2, 1)\n" @@ -3800,24 +4036,37 @@ msgid "" ">>> TitleStr('Blog: Why Python Rocks')\n" "'blog-why-python-rocks'" msgstr "" +">>> FirstOfMonthDate(2012, 2, 14)\n" +"FirstOfMonthDate(2012, 2, 1)\n" +">>> NamedInt('ten')\n" +"10\n" +">>> NamedInt(20)\n" +"20\n" +">>> TitleStr('Blog: Why Python Rocks')\n" +"'blog-why-python-rocks'" #: ../../faq/programming.rst:2003 msgid "How do I cache method calls?" msgstr "メソッド呼び出しをキャッシュするには どうしたらいいですか?" -#: ../../faq/programming.rst:2005 msgid "" "The two principal tools for caching methods are :deco:`functools." "cached_property` and :deco:`functools.lru_cache`. The former stores results " "at the instance level and the latter at the class level." msgstr "" +"メソッドのキャッシュに使う主なツールは :deco:`functools.cached_property` と :" +"deco:`functools.lru_cache` です。\n" +"前者はインスタンス単位で、後者はクラス単位で結果を保存します。" -#: ../../faq/programming.rst:2010 msgid "" "The ``cached_property`` approach only works with methods that do not take " "any arguments. It does not create a reference to the instance. The cached " "method result will be kept only as long as the instance is alive." msgstr "" +"``cached_property`` は、引数を受け取らないメソッドにだけ使えます。\n" +"インスタンスへの参照は作りません。\n" +"キャッシュされたメソッドの結果は、インスタンスが生存している間だけ保持されま" +"す。" #: ../../faq/programming.rst:2014 msgid "" @@ -3830,29 +4079,28 @@ msgstr "" "すぐに解放されることです。欠点は、インスタンスが溜まると、溜められたメソッド" "の結果も増えてしまうことです。それらは際限なく増える恐れがあります。" -#: ../../faq/programming.rst:2019 msgid "" "The ``lru_cache`` approach works with methods that have :term:`hashable` " "arguments. It creates a reference to the instance unless special efforts " "are made to pass in weak references." msgstr "" +"``lru_cache`` は、引数が :term:`hashable` なメソッドに使えます。\n" +"弱参照を渡すように特別な工夫をしない限り、インスタンスへの参照を作ります。" -#: ../../faq/programming.rst:2023 msgid "" "The advantage of the least recently used algorithm is that the cache is " "bounded by the specified *maxsize*. The disadvantage is that instances are " "kept alive until they age out of the cache or until the cache is cleared." msgstr "" -"least recently used アルゴリズム(訳注:LRU 直近に使われたものを残す)の利点" -"は、キャッシュが指定された *maxsize* で制限されることです。欠点は、キャッシュ" -"から期限切れで追い出されるかクリアされるまで、インスタンスが生き続けることで" -"す。" +"LRU (最も長く使われていないものから削除する) アルゴリズムの利点は、指定され" +"た *maxsize* でキャッシュの大きさを制限できることです。\n" +"欠点は、長く使われずにキャッシュから追い出されるか、キャッシュが消去されるま" +"で、インスタンスが生存し続けることです。" #: ../../faq/programming.rst:2028 msgid "This example shows the various techniques::" msgstr "この例は各種テクニックを示します::" -#: ../../faq/programming.rst:2030 msgid "" "class Weather:\n" " \"Lookup weather information on a government website\"\n" @@ -3876,13 +4124,36 @@ msgid "" " \"Rainfall on a given date\"\n" " # Depends on the station_id, date, and units." msgstr "" +"class Weather:\n" +" \"政府のウェブサイトで気象情報を調べる\"\n" +"\n" +" def __init__(self, station_id):\n" +" self._station_id = station_id\n" +" # _station_id はプライベートで変更されない\n" +"\n" +" def current_temperature(self):\n" +" \"1 時間ごとの観測の最新値\"\n" +" # 古い結果は現在の状況を反映しないことがあるので、\n" +" # キャッシュしない。\n" +"\n" +" @cached_property\n" +" def location(self):\n" +" \"観測所の経度・緯度を返す\"\n" +" # 結果は station_id だけに依存する\n" +"\n" +" @lru_cache(maxsize=20)\n" +" def historic_rainfall(self, date, units='mm'):\n" +" \"指定した日の降水量\"\n" +" # station_id、date、units に依存する。" -#: ../../faq/programming.rst:2052 msgid "" "The above example assumes that the *station_id* never changes. If the " "relevant instance attributes are mutable, the ``cached_property`` approach " "can't be made to work because it cannot detect changes to the attributes." msgstr "" +"上の例は *station_id* が変わらないことを前提としています。\n" +"関係するインスタンス属性が変更される場合、``cached_property`` は属性の変更を" +"検出できないため、この方法は使えません。" #: ../../faq/programming.rst:2057 msgid "" @@ -3953,7 +4224,6 @@ msgstr "" "ば、ウェブサーバーでテストを行っているときのような、開発者のユーザと実行者の" "ユーザが別な場合に、起こり得ます。" -#: ../../faq/programming.rst:2101 msgid "" "Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, " "creation of a .pyc file is automatic if you're importing a module and Python " @@ -3961,8 +4231,11 @@ msgid "" "``__pycache__`` subdirectory and write the compiled module to that " "subdirectory." msgstr "" +":envvar:`PYTHONDONTWRITEBYTECODE` 環境変数が設定されておらず、Python が " +"``__pycache__`` サブディレクトリを作成してコンパイル済みモジュールを書き込め" +"るだけの権限や空き容量などを持っていれば、モジュールをインポートすると .pyc " +"ファイルは自動的に作られます。" -#: ../../faq/programming.rst:2106 msgid "" "Running Python on a top-level script is not considered an import and no ``." "pyc`` will be created. For example, if you have a top-level module ``foo." @@ -3971,6 +4244,13 @@ msgid "" "``xyz`` because ``xyz`` is imported, but no ``.pyc`` file will be created " "for ``foo`` since ``foo.py`` isn't being imported." msgstr "" +"Python で最上位のスクリプトを実行することはインポートとはみなされず、``." +"pyc`` は作られません。\n" +"例えば、最上位のモジュール ``foo.py`` が別のモジュール ``xyz.py`` をインポー" +"トするとします。\n" +"シェルで ``python foo.py`` と入力して ``foo`` を実行すると、``xyz`` はイン" +"ポートされるため ``.pyc`` が作られますが、``foo.py`` はインポートされないた" +"め ``foo`` の ``.pyc`` は作られません。" #: ../../faq/programming.rst:2113 msgid "" @@ -3991,18 +4271,21 @@ msgstr "" "り方の一つは、このモジュールの ``compile()`` 関数をインタラクティブに実行する" "ことです::" -#: ../../faq/programming.rst:2120 msgid "" ">>> import py_compile\n" ">>> py_compile.compile('foo.py')" msgstr "" +">>> import py_compile\n" +">>> py_compile.compile('foo.py')" -#: ../../faq/programming.rst:2123 msgid "" "This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same " "location as ``foo.py`` (or you can override that with the optional parameter " "*cfile*)." msgstr "" +"これにより、``foo.py`` と同じ場所にある ``__pycache__`` サブディレクトリに " +"``.pyc`` が書き込まれます。\n" +"保存先は省略可能な引数 *cfile* で変更できます。" #: ../../faq/programming.rst:2127 msgid "" @@ -4015,15 +4298,13 @@ msgstr "" "のファイルをコンパイルできます。シェルプロンプトから ``compileall.py`` を起動" "して、コンパイルしたいファイルを含むディレクトリのパスを指定してください::" -#: ../../faq/programming.rst:2132 msgid "python -m compileall ." -msgstr "" +msgstr "python -m compileall ." #: ../../faq/programming.rst:2136 msgid "How do I find the current module name?" msgstr "現在のモジュール名を知るにはどうしますか?" -#: ../../faq/programming.rst:2138 msgid "" "A module can find out its own module name by looking at the predefined " "global variable ``__name__``. If this has the value ``'__main__'``, the " @@ -4031,13 +4312,14 @@ msgid "" "importing them also provide a command-line interface or a self-test, and " "only execute this code after checking ``__name__``::" msgstr "" -"モジュールは前もって定義されたグローバル変数 ``__name__`` を検索することで自" -"身の名前を決定できます。この値が ``'__main__'`` であるとき、そのプログラムは" -"スクリプトとして実行されています。インポートされることによって使われる大抵の" -"モジュールはコマンドラインインターフェースや自己テストも提供していて、" -"``__name__`` をチェックしてからそのコードだけを実行します::" +"モジュールは、あらかじめ定義されたグローバル変数 ``__name__`` を調べることで" +"自分の名前を知ることができます。\n" +"値が ``'__main__'`` なら、そのプログラムはスクリプトとして実行されていま" +"す。\n" +"通常はインポートして使うモジュールの多くは、コマンドラインインターフェースや" +"自己テストも提供しています。\n" +"そのコードは ``__name__`` を確認した場合にだけ実行します。 ::" -#: ../../faq/programming.rst:2144 msgid "" "def main():\n" " print('Running test...')\n" @@ -4046,6 +4328,12 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"def main():\n" +" print('Running test...')\n" +" ...\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../faq/programming.rst:2153 msgid "How can I have modules that mutually import each other?" @@ -4059,21 +4347,23 @@ msgstr "以下のモジュールがあったとしましょう:" msgid ":file:`foo.py`::" msgstr ":file:`foo.py`::" -#: ../../faq/programming.rst:2159 msgid "" "from bar import bar_var\n" "foo_var = 1" msgstr "" +"from bar import bar_var\n" +"foo_var = 1" #: ../../faq/programming.rst:2162 msgid ":file:`bar.py`::" msgstr ":file:`bar.py`::" -#: ../../faq/programming.rst:2164 msgid "" "from foo import foo_var\n" "bar_var = 2" msgstr "" +"from foo import foo_var\n" +"bar_var = 2" #: ../../faq/programming.rst:2167 msgid "The problem is that the interpreter will perform the following steps:" @@ -4139,7 +4429,6 @@ msgstr "" msgid "There are (at least) three possible workarounds for this problem." msgstr "この問題には (少なくとも) 三つの解決策があります。" -#: ../../faq/programming.rst:2186 msgid "" "Guido van Rossum recommends avoiding all uses of ``from import ..." "``, and placing all code inside functions. Initializations of global " @@ -4147,10 +4436,11 @@ msgid "" "only. This means everything from an imported module is referenced as " "``.``." msgstr "" -"Guido van Rossum は ``from import ...`` を全く使わないで、すべての" -"コードを関数の中に入れることを勧めています。グローバル変数とクラス変数の初期" -"化は定数とビルトイン関数のみで行われるべきです。これでインポートされたすべて" -"のモジュールは ``.`` として参照されることになります。" +"Guido van Rossum は ``from import ...`` を一切使わず、すべてのコード" +"を関数内に置くことを勧めています。\n" +"グローバル変数やクラス変数の初期化には、定数か組み込み関数だけを使います。\n" +"つまり、インポートしたモジュール内のものはすべて ``.`` として参" +"照します。" #: ../../faq/programming.rst:2191 msgid "" @@ -4211,9 +4501,8 @@ msgstr "" ":mod:`importlib` に :func:`~importlib.import_module` という便利な関数があるの" "で、代わりにそちらを使用することを検討してください。" -#: ../../faq/programming.rst:2213 msgid "z = importlib.import_module('x.y.z')" -msgstr "" +msgstr "z = importlib.import_module('x.y.z')" #: ../../faq/programming.rst:2217 msgid "" @@ -4237,22 +4526,24 @@ msgstr "" "その基本モジュールの解析と再解析が繰り返されることになります。変更されさたモ" "ジュールの再読込を強制するには、こうしてください::" -#: ../../faq/programming.rst:2225 msgid "" "import importlib\n" "import modname\n" "importlib.reload(modname)" msgstr "" +"import importlib\n" +"import modname\n" +"importlib.reload(modname)" -#: ../../faq/programming.rst:2229 msgid "" "Warning: this technique is not 100% fool-proof. In particular, modules " "containing statements like::" msgstr "" +"注意: この方法は万全ではありません。\n" +"特に、" -#: ../../faq/programming.rst:2232 msgid "from modname import some_objects" -msgstr "" +msgstr "from modname import some_objects" #: ../../faq/programming.rst:2234 msgid "" @@ -4266,7 +4557,6 @@ msgstr "" "スタンスは新しいクラス定義を使うようにアップデート *されません*。これによって" "以下の矛盾した振舞いがなされえます::" -#: ../../faq/programming.rst:2239 msgid "" ">>> import importlib\n" ">>> import cls\n" @@ -4276,22 +4566,31 @@ msgid "" ">>> isinstance(c, cls.C) # isinstance is false?!?\n" "False" msgstr "" +">>> import importlib\n" +">>> import cls\n" +">>> c = cls.C() # C のインスタンスを作る\n" +">>> importlib.reload(cls)\n" +"\n" +">>> isinstance(c, cls.C) # isinstance が偽になる!\n" +"False" -#: ../../faq/programming.rst:2247 msgid "" "The nature of the problem is made clear if you print out the \"identity\" of " "the class objects::" msgstr "" -"この問題の本質は、クラスオブジェクトの \"固有値\" を印字することで明らかにな" -"ります::" +"クラスオブジェクトの「識別値」を表示すると、この問題の原因がはっきりしま" +"す。 ::" -#: ../../faq/programming.rst:2250 msgid "" ">>> hex(id(c.__class__))\n" "'0x7352a0'\n" ">>> hex(id(cls.C))\n" "'0x4198d0'" msgstr "" +">>> hex(id(c.__class__))\n" +"'0x7352a0'\n" +">>> hex(id(cls.C))\n" +"'0x4198d0'" #: ../../faq/programming.rst:409 msgid "argument" diff --git a/faq/windows.po b/faq/windows.po index 4f8505666..93a4c5d62 100644 --- a/faq/windows.po +++ b/faq/windows.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq/windows.rst:9 @@ -184,7 +184,6 @@ msgstr "" "ドウは閉じます; Windows は 1 つの \"python\" コマンドをウィンドウで実行してい" "て、インタプリタを終了させたときに、そのウィンドウを閉じます。" -#: ../../faq/windows.rst:97 msgid "" "Now that we know the ``py`` command is recognized, you can give your Python " "script to it. You'll have to give either an absolute or a relative path to " @@ -196,8 +195,9 @@ msgstr "" "られるようになりました。\n" "そのためには Python スクリプトの絶対パスあるいは相対パスを与える必要がありま" "す。\n" -"Python スクリプトがデスクトップにあり、 ``hellp.py`` という名前で、ちょうど良" -"いことにコマンドプロンプトがホームディレクトリを開いていると仮定しましょう。" +"Python スクリプトがデスクトップにあり、 ``hello.py`` という名前で、ちょうど良" +"いことにコマンドプロンプトがホームディレクトリを開いていると仮定しましょ" +"う。\n" "そうすると次のような表示が見られます::" #: ../../faq/windows.rst:104 @@ -256,7 +256,6 @@ msgstr "" "トアップに時間がかかるようになったというバグレポートがあります。更に複雑なこ" "とに、Python は同様に設定された他の Windows システムではきちんと動くのです。" -#: ../../faq/windows.rst:131 msgid "" "The problem may be caused by a misconfiguration of virus checking software " "on the problem machine. Some virus scanners have been known to introduce " @@ -266,11 +265,13 @@ msgid "" "configured identically. McAfee, when configured to scan all file system read " "activity, is a particular offender." msgstr "" -"この問題はそのマシンのウイルス対策ソフトウェアの設定ミスによって起こされるこ" -"とがあります。ウイルススキャナの中には、ファイルシステムからの全ての読み込み" -"を監視するように設定した場合に、二桁のスタートアップオーバーヘッドを引き起す" -"ことが知られているものがあります。あなたのシステムのウイルススキャンソフト" -"ウェアの設定を確かめて、本当に同様に設定されていることを確実にしてください。" +"問題が起きるマシンのウイルス対策ソフトウェアの設定が原因かもしれません。\n" +"ファイルシステムからの読み取りをすべて監視するように設定すると、起動時のオー" +"バーヘッドが 100 倍程度になるウイルススキャナがあることが知られています。\n" +"各システムのウイルス対策ソフトウェアが本当に同じ設定になっているか確認してく" +"ださい。\n" +"特に McAfee は、ファイルシステムの読み取りをすべてスキャンする設定にすると、" +"この問題を起こします。" #: ../../faq/windows.rst:141 msgid "How do I make an executable from a Python script?" @@ -288,7 +289,6 @@ msgstr "" msgid "Is a ``*.pyd`` file the same as a DLL?" msgstr "``*.pyd`` ファイルは DLL と同じですか?" -#: ../../faq/windows.rst:150 msgid "" "Yes, .pyd files are dll's, but there are a few differences. If you have a " "DLL named ``foo.pyd``, then it must have a function ``PyInit_foo()``. You " @@ -297,12 +297,12 @@ msgid "" "``PyInit_foo()`` to initialize it. You do not link your .exe with foo.lib, " "as that would cause Windows to require the DLL to be present." msgstr "" -"はい、.pyd ファイルは dll と同じようなものですが、少し違いがあります。``foo." -"pyd`` という名前の DLL があったとしたら、それには関数 ``PyInit_foo()`` が含ま" -"れていなければなりません。そうすれば Python で \"import foo\" を書けて、" -"Python は foo.pyd (や foo.py、foo.pyc) を探して、あれば、``PyInit_foo()`` を" -"呼び出して初期化しようとします。Windows が DLL の存在を必要とするのと違い、." -"exe ファイルを foo.lib にリンクするわけではありません。" +"はい、.pyd ファイルは DLL ですが、いくつか違いがあります。\n" +"``foo.pyd`` という DLL には ``PyInit_foo()`` 関数が必要です。\n" +"Python で ``import foo`` と書くと、Python は foo.py や foo.pyc に加えて foo." +"pyd を探し、見つかれば ``PyInit_foo()`` を呼び出して初期化しようとします。\n" +".exe を foo.lib にリンクする必要はありません。\n" +"リンクすると、Windows がその DLL の存在を必須とするようになるためです。" #: ../../faq/windows.rst:157 msgid "" @@ -361,7 +361,6 @@ msgstr "" "`python{NN}.lib` は :file:`python{NN}.dll` に対するいわゆる \"インポートライ" "ブラリ\" です。これは単にリンカに対するシンボルを定義します。)" -#: ../../faq/windows.rst:182 msgid "" "Run-time linking greatly simplifies link options; everything happens at run " "time. Your code must load :file:`python{NN}.dll` using the Windows " @@ -371,13 +370,15 @@ msgid "" "these pointers transparent to any C code that calls routines in Python's C " "API." msgstr "" -"run-time なリンクは、リンクの選択を大いに単純化します。全ては実行時に行われま" -"す。コードは Windows の ``LoadLibraryEx()`` ルーチンで :file:`python{NN}." -"dll` をロードしなければなりません。コードはまた、Windows の " -"``GetProcAddress()`` ルーチンで得られるポインタで、 :file:`python{NN}.dll` " -"(すなわち、Python の C API)のルーチンとデータへアクセスしていなければなりませ" -"ん。マクロによって、このポインタを Python の C API のルーチンを呼び出す任意" -"の C コードに通して使えます。" +"実行時のリンクではすべての処理が実行時に行われるため、リンクオプションを大幅" +"に簡略化できます。\n" +"コードでは Windows の ``LoadLibraryEx()`` で :file:`python{NN}.dll` を読み込" +"む必要があります。\n" +"また、Windows の ``GetProcAddress()`` で得たポインタを使って、:file:" +"`python{NN}.dll` 内のルーチンやデータ (Python の C API) にアクセスする必要が" +"あります。\n" +"マクロを使えば、Python の C API を呼び出す C コード側でこれらのポインタを意識" +"せずに済むようにできます。" #: ../../faq/windows.rst:191 msgid "" @@ -473,28 +474,29 @@ msgstr "" "_resultobj = Py_None;\n" "return _resultobj;" -#: ../../faq/windows.rst:235 msgid "" "Alas, Py_None is a macro that expands to a reference to a complex data " "structure called _Py_NoneStruct inside pythonNN.dll. Again, this code will " "fail in a mult-compiler environment. Replace such code by:" msgstr "" -"ああ、Py_none は pythonNN.dll 内の _Py_NoneStruct という複雑なデータ構造に展" -"開するマクロです。また、このコードは他コンパイラ環境では失敗します。このコー" -"ドを次のように置き換えてください:" +"ああ、Py_None は pythonNN.dll 内の _Py_NoneStruct という複雑なデータ構造への" +"参照に展開するマクロです。\n" +"また、このコードは他コンパイラ環境では失敗します。\n" +"このコードを次のように置き換えてください:" #: ../../faq/windows.rst:239 msgid "return Py_BuildValue(\"\");" msgstr "return Py_BuildValue(\"\");" -#: ../../faq/windows.rst:243 msgid "" "It may be possible to use SWIG's ``%typemap`` command to make the change " "automatically, though I have not been able to get this to work (I'm a " "complete SWIG newbie)." msgstr "" -"これで、SWIG をまだ仕事に使えない (私は SWIG の完全な初心者です) 私でも、" -"SWIG の ``%typemap`` コマンドを使って自動的に変更できるようになります。" +"SWIG の ``%typemap`` コマンドを使えば、この変更を自動化できるかもしれませ" +"ん。\n" +"ただし、私はこれを動作させられていません (SWIG についてはまったくの初心者で" +"す)。" #: ../../faq/windows.rst:247 msgid "" @@ -560,15 +562,15 @@ msgstr "" msgid "How do I check for a keypress without blocking?" msgstr "ブロックすることなく押鍵を検出するにはどうしますか?" -#: ../../faq/windows.rst:276 msgid "" "Use the :mod:`msvcrt` module. This is a standard Windows-specific extension " "module. It defines a function ``kbhit()`` which checks whether a keyboard " "hit is present, and ``getch()`` which gets one character without echoing it." msgstr "" -":mod:`msvcrt` モジュールを使ってください。これは標準の Windows 専用拡張モ" -"ジュールです。これはキーボードが打たれているかを調べる関数 ``kbhit()`` と、反" -"響することなく一文字を得る ``getch()`` を定義します。" +":mod:`msvcrt` モジュールを使ってください。\n" +"これは Windows 専用の標準拡張モジュールです。\n" +"キー入力があるかを調べる ``kbhit()`` と、入力された文字を表示せずに 1 文字取" +"得する ``getch()`` が定義されています。" #: ../../faq/windows.rst:281 msgid "How do I solve the missing api-ms-win-crt-runtime-l1-1-0.dll error?" diff --git a/glossary.po b/glossary.po index 12cf3d0df..2af7db6e5 100644 --- a/glossary.po +++ b/glossary.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../glossary.rst:5 @@ -59,10 +59,11 @@ msgstr "" "コレーターの後に、コードを入力する際に表示されるデフォルトの Python プロンプ" "トです。" -#: ../../glossary.rst:26 msgid "" "The three dots form of the :ref:`Ellipsis ` object." msgstr "" +":ref:`Ellipsis ` オブジェクトの、3 つのドットを使った" +"表記。" #: ../../glossary.rst:27 msgid "abstract base class" @@ -93,11 +94,9 @@ msgstr "" "インダ及びローダーです。 :mod:`abc` モジュールを利用して独自の ABC を作成でき" "ます。" -#: ../../glossary.rst:40 msgid "annotate function" -msgstr "" +msgstr "annotate function" -#: ../../glossary.rst:42 msgid "" "A callable that can be called to retrieve the :term:`annotations " "` of an object. Annotate functions are usually :term:`functions " @@ -105,6 +104,11 @@ msgid "" "attribute of functions, classes, and modules. Annotate functions are a " "subset of :term:`evaluate functions `." msgstr "" +"(annotate 関数) オブジェクトの :term:`アノテーション ` を取得する" +"ために呼び出せる呼び出し可能オブジェクトです。\n" +"annotate 関数は通常、関数、クラス、モジュールの :attr:`~object.__annotate__` " +"属性として自動生成される :term:`関数 ` です。\n" +"annotate 関数は :term:`評価関数 ` の一種です。" #: ../../glossary.rst:47 msgid "annotation" @@ -119,13 +123,15 @@ msgstr "" "す。\n" "慣例により :term:`type hint` として使われています。" -#: ../../glossary.rst:53 msgid "" "Annotations of local variables cannot be accessed at runtime, but " "annotations of global variables, class attributes, and functions can be " "retrieved by calling :func:`annotationlib.get_annotations` on modules, " "classes, and functions, respectively." msgstr "" +"ローカル変数のアノテーションには実行時にアクセスできませんが、グローバル変" +"数、クラス属性、関数のアノテーションは、それぞれモジュール、クラス、関数に対" +"して :func:`annotationlib.get_annotations` を呼び出すことで取得できます。" #: ../../glossary.rst:58 msgid "" @@ -228,7 +234,6 @@ msgstr "" msgid "asynchronous generator" msgstr "asynchronous generator" -#: ../../glossary.rst:99 msgid "" "Informally used to mean either an :term:`asynchronous generator function` or " "an :term:`asynchronous generator iterator`, depending on context. The " @@ -236,18 +241,29 @@ msgid "" "generator iterator` are uncommon in practice; \"asynchronous generator\" " "alone is almost always sufficient." msgstr "" +"文脈に応じて、:term:`非同期ジェネレータ関数 ` または :term:`非同期ジェネレータイテレータ ` のどちらかを指すために非公式に使われる語です。\n" +"正式な用語である :term:`非同期ジェネレータ関数 ` と :term:`非同期ジェネレータイテレータ ` は、実際にはあまり使われません。\n" +"ほとんどの場合、「非同期ジェネレータ」だけで十分です。" -#: ../../glossary.rst:104 msgid "asynchronous generator function" -msgstr "" +msgstr "asynchronous generator function" -#: ../../glossary.rst:106 msgid "" "A function which returns an :term:`asynchronous generator iterator`. It " "looks like a coroutine function defined with :keyword:`async def` except " "that it contains :keyword:`yield` expressions for producing a series of " "values usable in an :keyword:`async for` loop. See :pep:`525`." msgstr "" +"(非同期ジェネレータ関数) :term:`非同期ジェネレータイテレータ ` を返す関数です。\n" +":keyword:`async def` で定義されたコルーチン関数に似ていますが、:keyword:" +"`async for` ループで使用できる一連の値を生成するための :keyword:`yield` 式を" +"含む点が異なります。\n" +":pep:`525` を参照してください。" #: ../../glossary.rst:111 msgid "" @@ -261,9 +277,10 @@ msgstr "" msgid "asynchronous generator iterator" msgstr "asynchronous generator iterator" -#: ../../glossary.rst:116 msgid "An object created by an :term:`asynchronous generator function`." msgstr "" +":term:`非同期ジェネレータ関数 ` が作成するオ" +"ブジェクトです。" #: ../../glossary.rst:118 msgid "" @@ -277,7 +294,6 @@ msgstr "" "ジェクトは、次の :keyword:`yield` 式まで非同期ジェネレータ関数の本体を実行し" "ます。" -#: ../../glossary.rst:123 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). " @@ -285,10 +301,11 @@ msgid "" "awaitable returned by :meth:`~object.__anext__`, it picks up where it left " "off. See :pep:`492` and :pep:`525`." msgstr "" -"各 :keyword:`yield` では一時的に処理を中断し、その実行状態 (ローカル変数や保" -"留中の try 文を含む) を記憶します。 *非同期ジェネレータイテレータ* が :meth:" -"`~object.__anext__` で返された他の awaitable で実際に再開する時には、その中断" -"箇所が選ばれます。 :pep:`492` および :pep:`525` を参照してください。" +"各 :keyword:`yield` は処理を一時的に中断し、実行状態(ローカル変数や保留中の " +"try 文を含む)を記憶します。\n" +":meth:`~object.__anext__` が返す別の awaitable によって *非同期ジェネレータイ" +"テレータ* の実行が実際に再開すると、中断した箇所から処理を続けます。\n" +":pep:`492` と :pep:`525` を参照してください。" #: ../../glossary.rst:128 msgid "asynchronous iterable" @@ -324,11 +341,9 @@ msgstr "" "例外を送出するまで、非同期イテレータの :meth:`~object.__anext__` メソッドが返" "す awaitable を解決します。 :pep:`492` で導入されました。" -#: ../../glossary.rst:140 msgid "atomic operation" -msgstr "" +msgstr "atomic operation" -#: ../../glossary.rst:142 msgid "" "An operation that appears to execute as a single, indivisible step: no other " "thread can observe it half-done, and its effects become visible all at " @@ -337,22 +352,32 @@ msgid "" "atomic). Atomicity is only guaranteed where explicitly documented. See " "also :term:`race condition` and :term:`data race`." msgstr "" +"(アトミック操作) 分割できない単一のステップとして実行されるように見える操作で" +"す。\n" +"ほかのスレッドから途中の状態は観測できず、その効果は一度に見えるようになりま" +"す。\n" +"Python は、高水準の文がアトミックであることを保証しません(たとえば、``x += " +"1`` は複数のバイトコード操作を実行し、アトミックではありません)。\n" +"アトミック性が保証されるのは、ドキュメントに明記されている場合だけです。\n" +":term:`競合状態 ` と :term:`データ競合 ` も参照し" +"てください。" -#: ../../glossary.rst:148 msgid "attached thread state" -msgstr "" +msgstr "attached thread state" -#: ../../glossary.rst:151 msgid "A :term:`thread state` that is active for the current OS thread." msgstr "" +"(アタッチされたスレッド状態) 現在の OS スレッドで有効な :term:`スレッド状態 " +"` です。" -#: ../../glossary.rst:153 msgid "" "When a :term:`thread state` is attached, the OS thread has access to the " "full Python C API and can safely invoke the bytecode interpreter." msgstr "" +":term:`スレッド状態 ` がアタッチされていると、OS スレッドは " +"Python C API の全機能にアクセスでき、バイトコードインタープリタを安全に呼び出" +"せます。" -#: ../../glossary.rst:157 msgid "" "Unless a function explicitly notes otherwise, attempting to call the C API " "without an attached thread state will result in a fatal error or undefined " @@ -360,8 +385,14 @@ msgid "" "user through the C API, or implicitly by the runtime, including during " "blocking C calls and by the bytecode interpreter in between calls." msgstr "" +"関数の説明に明示的な例外の記載がない限り、スレッド状態がアタッチされていない" +"状態で C API を呼び出そうとすると、致命的エラーまたは未定義の動作を引き起こし" +"ます。\n" +"スレッド状態は、利用者が C API を通じて明示的にアタッチしたりデタッチしたりで" +"きるほか、ランタイムが暗黙に行うこともあります。\n" +"後者には、ブロックする C 関数の呼び出し中に行う場合や、バイトコードインタープ" +"リタが呼び出しと呼び出しの間に行う場合が含まれます。" -#: ../../glossary.rst:164 msgid "" "On most builds of Python, having an attached thread state implies that the " "caller holds the :term:`GIL` for the current interpreter, so only one OS " @@ -370,6 +401,14 @@ msgid "" "hold an attached thread state, allowing for true parallelism of the bytecode " "interpreter." msgstr "" +"ほとんどの Python ビルドでは、スレッド状態がアタッチされていることは、呼び出" +"し元が現在のインタープリタの :term:`GIL ` を保持していることを意味しま" +"す。\n" +"そのため、ある時点でスレッド状態をアタッチできる OS スレッドは一つだけで" +"す。\n" +"Python の :term:`フリースレッドビルド ` では、複数のス" +"レッドがスレッド状態を同時にアタッチでき、バイトコードインタープリタの真の並" +"列実行が可能になります。" #: ../../glossary.rst:170 msgid "attribute" @@ -453,19 +492,21 @@ msgstr "" ":class:`str` オブジェクトの読み書きができるファイルオブジェクトについては、 :" "term:`text file` も参照してください。" -#: ../../glossary.rst:202 msgid "borrowed reference" -msgstr "" +msgstr "borrowed reference" -#: ../../glossary.rst:204 msgid "" "In Python's C API, a borrowed reference is a reference to an object, where " "the code using the object does not own the reference. It becomes a dangling " "pointer if the object is destroyed. For example, a garbage collection can " "remove the last :term:`strong reference` to the object and so destroy it." msgstr "" +"(借用参照) Python の C API で、オブジェクトを使うコードが所有していない、その" +"オブジェクトへの参照です。\n" +"オブジェクトが破棄されると、ダングリングポインタになります。\n" +"たとえば、ガベージコレクションによってオブジェクトへの最後の :term:`強参照 " +"` が取り除かれ、オブジェクトが破棄されることがあります。" -#: ../../glossary.rst:210 msgid "" "Calling :c:func:`Py_INCREF` on the :term:`borrowed reference` is recommended " "to convert it to a :term:`strong reference` in-place, except when the object " @@ -473,6 +514,12 @@ msgid "" "func:`Py_NewRef` function can be used to create a new :term:`strong " "reference`." msgstr "" +":term:`借用参照 ` に対して :c:func:`Py_INCREF` を呼び出" +"し、その場で :term:`強参照 ` に変換することを推奨します。\n" +"ただし、借用参照の最後の使用までオブジェクトが破棄され得ない場合は除きま" +"す。\n" +":c:func:`Py_NewRef` 関数を使うと、新しい :term:`強参照 ` を" +"作成できます。" #: ../../glossary.rst:215 msgid "bytes-like object" @@ -495,7 +542,6 @@ msgstr "" "由した送信など、バイナリデータを要求するいろいろな操作に利用することができま" "す。" -#: ../../glossary.rst:224 msgid "" "Some operations need the binary data to be mutable. The documentation often " "refers to these as \"read-write bytes-like objects\". Example mutable " @@ -504,14 +550,15 @@ msgid "" "immutable objects (\"read-only bytes-like objects\"); examples of these " "include :class:`bytes` and a :class:`memoryview` of a :class:`bytes` object." msgstr "" -"幾つかの操作ではバイナリデータを変更する必要があります。\n" -"その操作のドキュメントではよく \"読み書き可能な bytes-like オブジェクト\" に" -"言及しています。\n" -"変更可能なバッファーオブジェクトには、 :class:`bytearray` と :class:" -"`bytearray` の :class:`memoryview` などが含まれます。\n" -"また、他の幾つかの操作では不変なオブジェクト内のバイナリデータ (\"読み出し専" -"用の bytes-like オブジェクト\") を必要します。それには :class:`bytes` と :" -"class:`bytes` の :class:`memoryview` オブジェクトが含まれます。" +"操作によっては、バイナリデータが変更可能である必要があります。\n" +"ドキュメントでは、そのようなデータを「読み書き可能な bytes-like オブジェク" +"ト」と呼ぶことがよくあります。\n" +"変更可能なバッファオブジェクトには、:class:`bytearray` や :class:`bytearray` " +"の :class:`memoryview` があります。\n" +"一方、別の操作では、バイナリデータが不変なオブジェクト(「読み出し専用の " +"bytes-like オブジェクト」)に格納されている必要があります。\n" +"そのようなオブジェクトには、:class:`bytes` や :class:`bytes` オブジェクトの :" +"class:`memoryview` があります。" #: ../../glossary.rst:232 msgid "bytecode" @@ -549,22 +596,27 @@ msgstr "" msgid "callable" msgstr "callable" -#: ../../glossary.rst:248 msgid "" "A callable is an object that can be called, possibly with a set of arguments " "(see :term:`argument`), with the following syntax::" msgstr "" +"呼び出し可能オブジェクトは、次の構文で呼び出すことができるオブジェクトで" +"す。\n" +"その際、実引数(:term:`実引数 ` を参照)を渡すこともできます。 ::" #: ../../glossary.rst:251 msgid "callable(argument1, argument2, argumentN)" msgstr "callable(argument1, argument2, argumentN)" -#: ../../glossary.rst:253 msgid "" "A :term:`function`, and by extension a :term:`method`, is a callable. An " "instance of a class that implements the :meth:`~object.__call__` method is " "also a callable." msgstr "" +":term:`関数 ` も :term:`メソッド ` も、呼び出し可能オブジェ" +"クトです。\n" +":meth:`~object.__call__` メソッドを実装したクラスのインスタンスも、呼び出し可" +"能オブジェクトです。" #: ../../glossary.rst:256 msgid "callback" @@ -592,19 +644,16 @@ msgstr "" msgid "class variable" msgstr "class variable" -#: ../../glossary.rst:267 msgid "" "A variable defined in a class and intended to be modified only at class " "level (i.e., not in an instance of the class)." msgstr "" -"(クラス変数) クラス上に定義され、クラスレベルで (つまり、クラスのインスタンス" -"上ではなしに) 変更されることを目的としている変数です。" +"(クラス変数) クラス内で定義され、クラスレベルでのみ(つまり、クラスのインスタ" +"ンスではなく)変更することを意図した変数です。" -#: ../../glossary.rst:269 msgid "closure variable" -msgstr "" +msgstr "closure variable" -#: ../../glossary.rst:271 msgid "" "A :term:`free variable` referenced from a :term:`nested scope` that is " "defined in an outer scope rather than being resolved at runtime from the " @@ -612,13 +661,20 @@ msgid "" "`nonlocal` keyword to allow write access, or implicitly defined if the " "variable is only being read." msgstr "" +"(クロージャ変数) :term:`ネストされたスコープ ` から参照される :" +"term:`自由変数 ` のうち、実行時にグローバル名前空間や組み込み" +"名前空間から解決されるのではなく、外側のスコープで定義されているものです。\n" +"書き込みを可能にするために :keyword:`nonlocal` キーワードで明示的に定義する場" +"合と、変数を読み取るだけで暗黙に定義される場合があります。" -#: ../../glossary.rst:276 msgid "" "For example, in the ``inner`` function in the following code, both ``x`` and " "``print`` are :term:`free variables `, but only ``x`` is a " "*closure variable*::" msgstr "" +"たとえば、次のコードの ``inner`` 関数では、``x`` と ``print`` はどちらも :" +"term:`自由変数 ` ですが、*クロージャ変数* は ``x`` だけで" +"す。 ::" #: ../../glossary.rst:279 msgid "" @@ -638,7 +694,6 @@ msgstr "" " print(x)\n" " return inner" -#: ../../glossary.rst:287 msgid "" "Due to the :attr:`codeobject.co_freevars` attribute (which, despite its " "name, only includes the names of closure variables rather than listing all " @@ -646,6 +701,10 @@ msgid "" "sometimes used even when the intended meaning is to refer specifically to " "closure variables." msgstr "" +":attr:`codeobject.co_freevars` 属性には、その名前に反して、参照されるすべての" +"自由変数ではなくクロージャ変数の名前だけが含まれます。\n" +"このため、クロージャ変数だけを指す意図で、より一般的な用語である :term:`自由" +"変数 ` が使われることもあります。" #: ../../glossary.rst:291 msgid "complex number" @@ -671,11 +730,9 @@ msgstr "" "`cmath` を使います。複素数の使用はかなり高度な数学の機能です。必要性を感じな" "ければ、ほぼ間違いなく無視してしまってよいでしょう。" -#: ../../glossary.rst:303 msgid "concurrency" -msgstr "" +msgstr "concurrency" -#: ../../glossary.rst:305 msgid "" "The ability of a computer program to perform multiple tasks at the same " "time. Python provides libraries for writing programs that make use of " @@ -685,85 +742,108 @@ msgid "" "processes. Multi-core processors can execute threads and processes on " "different CPU cores at the same time (see :term:`parallelism`)." msgstr "" +"(並行性) コンピュータプログラムが複数のタスクを同時に実行する能力です。\n" +"Python は、さまざまな形の並行性を利用するプログラムを書くためのライブラリを提" +"供します。\n" +":mod:`asyncio` は非同期タスクやコルーチンを扱うためのライブラリです。\n" +":mod:`threading` はオペレーティングシステムのスレッドへのアクセスを、:mod:" +"`multiprocessing` はオペレーティングシステムのプロセスへのアクセスを提供しま" +"す。\n" +"マルチコアプロセッサは、異なる CPU コアでスレッドやプロセスを同時に実行できま" +"す(:term:`並列性 ` を参照)。" -#: ../../glossary.rst:313 msgid "concurrent modification" -msgstr "" +msgstr "concurrent modification" -#: ../../glossary.rst:315 msgid "" "When multiple threads modify shared data at the same time. Concurrent " "modification without proper synchronization can cause :term:`race conditions " "`, and might also trigger a :term:`data race `, " "data corruption, or both." msgstr "" +"(並行変更) 複数のスレッドが共有データを同時に変更することです。\n" +"適切な同期を行わずに並行変更すると、:term:`競合状態 ` を引き" +"起こすことがあり、さらに :term:`データ競合 `、データの破損、または" +"その両方を引き起こす可能性もあります。" -#: ../../glossary.rst:319 msgid "context" -msgstr "" +msgstr "context" -#: ../../glossary.rst:321 msgid "" "This term has different meanings depending on where and how it is used. Some " "common meanings:" msgstr "" +"(コンテキスト) この語は、使われる場所や使い方によって意味が異なります。\n" +"よく使われる意味には次のものがあります:" -#: ../../glossary.rst:324 msgid "" "The temporary state or environment established by a :term:`context manager` " "via a :keyword:`with` statement." msgstr "" +":term:`コンテキストマネージャ ` が :keyword:`with` 文を通じ" +"て設定する、一時的な状態または環境。" -#: ../../glossary.rst:326 msgid "" "The collection of key­value bindings associated with a particular :class:" "`contextvars.Context` object and accessed via :class:`~contextvars." "ContextVar` objects. Also see :term:`context variable`." msgstr "" +"特定の :class:`contextvars.Context` オブジェクトに関連付けられ、:class:" +"`~contextvars.ContextVar` オブジェクトを通じてアクセスされる、キーと値の束縛" +"の集まり。\n" +":term:`コンテキスト変数 ` も参照してください。" -#: ../../glossary.rst:330 msgid "" "A :class:`contextvars.Context` object. Also see :term:`current context`." msgstr "" +":class:`contextvars.Context` オブジェクト。\n" +":term:`現在のコンテキスト ` も参照してください。" #: ../../glossary.rst:332 msgid "context management protocol" msgstr "コンテキスト管理プロトコル" -#: ../../glossary.rst:334 msgid "" "The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called by " "the :keyword:`with` statement. See :pep:`343`." msgstr "" +":keyword:`with` 文から呼び出される :meth:`~object.__enter__` メソッドと :" +"meth:`~object.__exit__` メソッドです。\n" +":pep:`343` を参照してください。" #: ../../glossary.rst:336 msgid "context manager" msgstr "context manager" -#: ../../glossary.rst:338 msgid "" "An object which implements the :term:`context management protocol` and " "controls the environment seen in a :keyword:`with` statement. See :pep:" "`343`." msgstr "" +":term:`コンテキスト管理プロトコル ` を実装し、:" +"keyword:`with` 文内の環境を管理するオブジェクトです。\n" +":pep:`343` を参照してください。" #: ../../glossary.rst:341 msgid "context variable" msgstr "context variable" -#: ../../glossary.rst:343 msgid "" "A variable whose value depends on which context is the :term:`current " "context`. Values are accessed via :class:`contextvars.ContextVar` objects. " "Context variables are primarily used to isolate state between concurrent " "asynchronous tasks." msgstr "" +"どのコンテキストが :term:`現在のコンテキスト ` であるかに" +"よって値が変わる変数です。\n" +"値には :class:`contextvars.ContextVar` オブジェクトを通じてアクセスします。\n" +"コンテキスト変数は主に、並行する非同期タスク間で状態を分離するために使われま" +"す。" #: ../../glossary.rst:347 msgid "contiguous" msgstr "contiguous" -#: ../../glossary.rst:351 msgid "" "A buffer is considered contiguous exactly if it is either *C-contiguous* or " "*Fortran contiguous*. Zero-dimensional buffers are C and Fortran " @@ -773,13 +853,14 @@ msgid "" "visiting items in order of memory address. However, in Fortran contiguous " "arrays, the first index varies the fastest." msgstr "" -"(隣接、連続) バッファが厳密に *C-連続* または *Fortran 連続* である場合に、そ" -"のバッファは連続しているとみなせます。\n" -"ゼロ次元バッファは C 連続であり Fortran 連続です。\n" -"一次元の配列では、その要素は必ずメモリ上で隣接するように配置され、添字がゼロ" -"から始まり増えていく順序で並びます。\n" -"多次元の C-連続な配列では、メモリアドレス順に要素を巡る際には最後の添え字が最" -"初に変わるのに対し、 Fortran 連続な配列では最初の添え字が最初に動きます。" +"(隣接、連続) バッファが *C-連続* または *Fortran 連続* のいずれかである場合、" +"かつその場合に限り、そのバッファは連続しているとみなされます。\n" +"ゼロ次元バッファは C 連続であり、Fortran 連続でもあります。\n" +"一次元配列では、要素はメモリ上で互いに隣接し、ゼロから始まる添字の昇順で並ん" +"でいなければなりません。\n" +"多次元の C-連続配列では、メモリアドレス順に要素をたどると、最後の添字が最も速" +"く変化します。\n" +"一方、Fortran 連続配列では、最初の添字が最も速く変化します。" #: ../../glossary.rst:359 msgid "coroutine" @@ -831,11 +912,9 @@ msgstr "" "グ言語の標準的な実装です。\"CPython\" という単語は、この実装を Jython や " "IronPython といった他の実装と区別する必要が有る場合に利用されます。" -#: ../../glossary.rst:379 msgid "current context" -msgstr "" +msgstr "current context" -#: ../../glossary.rst:381 msgid "" "The :term:`context` (:class:`contextvars.Context` object) that is currently " "used by :class:`~contextvars.ContextVar` objects to access (get or set) the " @@ -844,12 +923,19 @@ msgid "" "`asyncio`) associate each task with a context which becomes the current " "context whenever the task starts or resumes execution." msgstr "" +"(現在のコンテキスト) :class:`~contextvars.ContextVar` オブジェクトが :term:`" +"コンテキスト変数 ` の値にアクセス(取得や設定)するために現" +"在使っている :term:`コンテキスト `(:class:`contextvars.Context` オ" +"ブジェクト)です。\n" +"各スレッドには、それぞれ現在のコンテキストがあります。\n" +"非同期タスクを実行するフレームワーク(:mod:`asyncio` を参照)は、各タスクにコ" +"ンテキストを関連付けます。\n" +"このコンテキストは、タスクが実行を開始または再開するたびに、現在のコンテキス" +"トになります。" -#: ../../glossary.rst:387 msgid "cyclic isolate" -msgstr "" +msgstr "cyclic isolate" -#: ../../glossary.rst:389 msgid "" "A subgroup of one or more objects that reference each other in a reference " "cycle, but are not referenced by objects outside the group. The goal of " @@ -857,12 +943,14 @@ msgid "" "these groups and break the reference cycles so that the memory can be " "reclaimed." msgstr "" +"(孤立した循環参照群) 循環参照によって互いを参照している一つ以上のオブジェクト" +"からなる集まりで、外部のオブジェクトから参照されていないものです。\n" +":term:`循環ガベージコレクタ ` の目的は、こうした集まりを" +"特定し、循環参照を断ち切ってメモリを回収できるようにすることです。" -#: ../../glossary.rst:393 msgid "data race" -msgstr "" +msgstr "data race" -#: ../../glossary.rst:395 msgid "" "A situation where multiple threads access the same memory location " "concurrently, at least one of the accesses is a write, and the threads do " @@ -873,12 +961,22 @@ msgid "" "only happen in native code, but that :term:`native code` might be exposed in " "a Python API. See also :term:`race condition` and :term:`thread-safe`." msgstr "" +"(データ競合) 複数のスレッドが同じメモリ位置に並行してアクセスし、そのうち少な" +"くとも一つが書き込みであり、どのスレッドもアクセスを制御する同期を使っていな" +"い状況です。\n" +"データ競合は :term:`非決定的な ` 動作につながり、データの" +"破損を引き起こすことがあります。\n" +":term:`ロック ` やその他の :term:`同期プリミティブ ` を適切に使うと、データ競合を防げます。\n" +"データ競合が起こり得るのはネイティブコード内だけですが、その :term:`ネイティ" +"ブコード ` が Python API を通じて公開されている可能性があること" +"に注意してください。\n" +":term:`競合状態 ` と :term:`スレッドセーフ ` も" +"参照してください。" -#: ../../glossary.rst:404 msgid "deadlock" -msgstr "" +msgstr "deadlock" -#: ../../glossary.rst:406 msgid "" "A situation in which two or more tasks (threads, processes, or coroutines) " "wait indefinitely for each other to release resources or complete actions, " @@ -890,17 +988,31 @@ msgid "" "`locks ` in a consistent order. See also :term:`lock` and :term:" "`reentrant`." msgstr "" +"(デッドロック) 二つ以上のタスク(スレッド、プロセス、コルーチン)が、互いにリ" +"ソースを解放したり動作を完了したりするのを無期限に待ち、どのタスクも処理を進" +"められない状況です。\n" +"たとえば、スレッド A がロック 1 を保持したままロック 2 を待ち、スレッド B が" +"ロック 2 を保持したままロック 1 を待つと、両方のスレッドが無期限に待つことに" +"なります。\n" +"Python では、複数のロックを相反する順序で取得したり、join や await の依存関係" +"が循環したりすると、よくこの状況が発生します。\n" +"複数の :term:`ロック ` を常に一貫した順序で取得すると、デッドロックを回" +"避できます。\n" +":term:`ロック ` と :term:`再入可能 ` も参照してください。" #: ../../glossary.rst:415 msgid "decorator" msgstr "decorator" -#: ../../glossary.rst:417 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@wrapper`` syntax. Common examples for " "decorators are :deco:`classmethod` and :deco:`staticmethod`." msgstr "" +"(デコレータ) 別の関数を返す関数で、通常は ``@wrapper`` 構文を使って関数を変換" +"するために適用されます。\n" +"デコレータの代表的な例には、:deco:`classmethod` と :deco:`staticmethod` があ" +"ります。" #: ../../glossary.rst:421 msgid "" @@ -910,7 +1022,6 @@ msgstr "" "デコレータの文法はシンタックスシュガーです。次の2つの関数定義は意味的に同じも" "のです::" -#: ../../glossary.rst:424 msgid "" "def f(arg):\n" " ...\n" @@ -920,6 +1031,13 @@ msgid "" "def f(arg):\n" " ..." msgstr "" +"def f(arg):\n" +" ...\n" +"f = staticmethod(f)\n" +"\n" +"@staticmethod\n" +"def f(arg):\n" +" ..." #: ../../glossary.rst:432 msgid "" @@ -935,7 +1053,6 @@ msgstr "" msgid "descriptor" msgstr "descriptor" -#: ../../glossary.rst:437 msgid "" "Any object which defines the methods :meth:`~object.__get__`, :meth:`~object." "__set__`, or :meth:`~object.__delete__`. When a class attribute is a " @@ -947,6 +1064,16 @@ msgid "" "basis for many features including functions, methods, properties, class " "methods, static methods, and reference to super classes." msgstr "" +"(デスクリプタ) :meth:`~object.__get__`、:meth:`~object.__set__`、:meth:" +"`~object.__delete__` のいずれかのメソッドを定義したオブジェクトです。\n" +"クラス属性がデスクリプタの場合、属性の検索時に、デスクリプタ特有の束縛動作が" +"起動します。\n" +"通常、*a.b* を使って属性を取得、設定、削除すると、*a* のクラス辞書から *b* と" +"いう名前のオブジェクトを検索しますが、*b* がデスクリプタなら、対応するデスク" +"リプタのメソッドが呼び出されます。\n" +"デスクリプタは、関数、メソッド、プロパティ、クラスメソッド、静的メソッド、" +"スーパークラスへの参照など、多くの機能の基盤となっているため、これを理解する" +"ことは Python を深く理解する鍵となります。" #: ../../glossary.rst:448 msgid "" @@ -960,12 +1087,15 @@ msgstr "" msgid "dictionary" msgstr "dictionary" -#: ../../glossary.rst:452 msgid "" "An associative array, where arbitrary keys are mapped to values. The keys " "can be any object with :meth:`~object.__hash__` and :meth:`~object.__eq__` " "methods. Called a hash in Perl." msgstr "" +"(辞書) 任意のキーが値に対応付けられる連想配列です。\n" +"キーには、:meth:`~object.__hash__` メソッドと :meth:`~object.__eq__` メソッド" +"を持つ任意のオブジェクトを使えます。\n" +"Perl ではハッシュと呼ばれます。" #: ../../glossary.rst:456 msgid "dictionary comprehension" @@ -987,7 +1117,6 @@ msgstr "" msgid "dictionary view" msgstr "dictionary view" -#: ../../glossary.rst:464 msgid "" "The objects returned from :meth:`dict.keys`, :meth:`dict.values`, and :meth:" "`dict.items` are called dictionary views. They provide a dynamic view on the " @@ -1001,14 +1130,13 @@ msgstr "" "辞書の項目の動的なビューを提供します。\n" "すなわち、辞書が変更されるとビューはそれを反映します。\n" "辞書ビューを強制的に完全なリストにするには ``list(dictview)`` を使用してくだ" -"さい。 \n" +"さい。\n" ":ref:`dict-views` を参照してください。" #: ../../glossary.rst:470 msgid "docstring" msgstr "docstring" -#: ../../glossary.rst:472 msgid "" "A string literal which appears as the first expression in a class, function " "or module. While ignored when the suite is executed, it is recognized by " @@ -1016,6 +1144,12 @@ msgid "" "enclosing class, function or module. Since it is available via " "introspection, it is the canonical place for documentation of the object." msgstr "" +"(ドキュメンテーション文字列) クラス、関数、モジュールの最初の式として現れる文" +"字列リテラルです。\n" +"スイートの実行時には無視されますが、コンパイラによって認識され、それを囲むク" +"ラス、関数、モジュールの :attr:`~definition.__doc__` 属性に格納されます。\n" +"イントロスペクションを通じて利用できるため、オブジェクトのドキュメントを書く" +"標準的な場所となっています。" #: ../../glossary.rst:478 msgid "duck-typing" @@ -1043,22 +1177,22 @@ msgstr "" "class>` で補完することもできます。) その代わり、典型的に :func:`hasattr` 判定" "や :term:`EAFP` プログラミングを利用します。" -#: ../../glossary.rst:489 msgid "dunder" -msgstr "" +msgstr "dunder" -#: ../../glossary.rst:491 msgid "" "An informal short-hand for \"double underscore\", used when talking about a :" "term:`special method`. For example, ``__init__`` is often pronounced " "\"dunder init\"." msgstr "" +"「double underscore(二重アンダースコア)」を表す非公式な略語で、:term:`特殊" +"メソッド ` について話すときに使います。\n" +"たとえば、``__init__`` はよく「dunder init」と発音されます。" #: ../../glossary.rst:494 msgid "EAFP" msgstr "EAFP" -#: ../../glossary.rst:496 msgid "" "Easier to ask for forgiveness than permission. This common Python coding " "style assumes the existence of valid keys or attributes and catches " @@ -1067,42 +1201,44 @@ msgid "" "statements. The technique contrasts with the :term:`LBYL` style common to " "many other languages such as C." msgstr "" -"「認可をとるより許しを請う方が容易 (easier to ask for forgiveness than " -"permission、マーフィーの法則)」の略です。この Python で広く使われているコー" -"ディングスタイルでは、通常は有効なキーや属性が存在するものと仮定し、その仮定" -"が誤っていた場合に例外を捕捉します。この簡潔で手早く書けるコーディングスタイ" -"ルには、 :keyword:`try` 文および :keyword:`except` 文がたくさんあるのが特徴で" -"す。このテクニックは、C のような言語でよく使われている :term:`LBYL` スタイル" -"と対照的なものです。" +"許可を求めるより、許しを請うほうが容易(Easier to ask for forgiveness than " +"permission)の略です。\n" +"Python で一般的なこのコーディングスタイルでは、有効なキーや属性が存在すると仮" +"定し、その仮定が誤っていた場合に例外を捕捉します。\n" +"この簡潔で高速なスタイルは、:keyword:`try` 文と :keyword:`except` 文を多用す" +"ることを特徴とします。\n" +"この手法は、C などの多くの言語で一般的な :term:`LBYL` スタイルと対照的です。" -#: ../../glossary.rst:502 msgid "evaluate function" -msgstr "" +msgstr "evaluate function" -#: ../../glossary.rst:504 msgid "" "A function that can be called to evaluate a lazily evaluated attribute of an " "object, such as the value of type aliases created with the :keyword:`type` " "statement." msgstr "" +"(評価関数) :keyword:`type` 文で作成された型エイリアスの値など、オブジェクトの" +"遅延評価される属性を評価するために呼び出せる関数です。" -#: ../../glossary.rst:507 msgid "exhausted" -msgstr "" +msgstr "exhausted" -#: ../../glossary.rst:509 msgid "" "An :term:`iterator` that has produced all of its values is said to be :dfn:" "`exhausted`. Further attempts to get the next value (for example, calls to :" "func:`next`) raise :exc:`StopIteration` (or :exc:`StopAsyncIteration` in the " "case of an :term:`asynchronous iterator`)." msgstr "" +"(枯渇した) すべての値を生成し終えた :term:`イテレータ ` を :dfn:`枯" +"渇した` といいます。\n" +"その後に次の値を取得しようとすると(たとえば :func:`next` を呼び出すと)、:" +"exc:`StopIteration`(:term:`非同期イテレータ ` の場合" +"は :exc:`StopAsyncIteration`)が送出されます。" #: ../../glossary.rst:515 msgid "expression" msgstr "expression" -#: ../../glossary.rst:517 msgid "" "A piece of syntax which can be evaluated to some value. In other words, an " "expression is an accumulation of expression elements like literals, names, " @@ -1111,6 +1247,13 @@ msgid "" "`statement`\\s which cannot be used as expressions, such as :keyword:" "`while`. Assignments are also statements, not expressions." msgstr "" +"(式) 評価すると何らかの値になる構文の一部です。\n" +"つまり、式は、リテラル、名前、属性アクセス、演算子、関数呼び出しなど、いずれ" +"も値を返す式の要素を組み合わせたものです。\n" +"言語のすべての構成要素が式というわけではありません。\n" +":keyword:`while` のように、式として使えない :term:`文 ` もありま" +"す。\n" +"代入も式ではなく文です。" #: ../../glossary.rst:524 msgid "extension module" @@ -1128,22 +1271,23 @@ msgstr "" msgid "f-string" msgstr "f-string" -#: ../../glossary.rst:529 msgid "f-strings" -msgstr "" +msgstr "f-strings" -#: ../../glossary.rst:531 msgid "" "String literals prefixed with ``f`` or ``F`` are commonly called \"f-" "strings\" which is short for :ref:`formatted string literals `. " "See also :pep:`498`." msgstr "" +"``f`` または ``F`` を接頭辞に持つ文字列リテラルは、一般に「f-string」と呼ばれ" +"ます。\n" +"これは :ref:`フォーマット済み文字列リテラル ` の略です。\n" +":pep:`498` も参照してください。" #: ../../glossary.rst:534 msgid "file object" msgstr "file object" -#: ../../glossary.rst:536 msgid "" "An object exposing a file-oriented API (with methods such as :meth:`!read` " "or :meth:`!write`) to an underlying resource. Depending on the way it was " @@ -1152,6 +1296,13 @@ msgid "" "output, in-memory buffers, sockets, pipes, etc.). File objects are also " "called :dfn:`file-like objects` or :dfn:`streams`." msgstr "" +"(ファイルオブジェクト) 基になるリソースに対して、ファイル向けの API(:meth:`!" +"read` や :meth:`!write` などのメソッド)を提供するオブジェクトです。\n" +"作成方法に応じて、ディスク上の実際のファイル、または別の種類の記憶装置や通信" +"装置(標準入出力、メモリ内バッファ、ソケット、パイプなど)へのアクセスを仲介" +"できます。\n" +"ファイルオブジェクトは、:dfn:`file-like オブジェクト` や :dfn:`ストリーム` と" +"も呼ばれます。" #: ../../glossary.rst:544 msgid "" @@ -1175,33 +1326,35 @@ msgstr "file-like object" msgid "A synonym for :term:`file object`." msgstr ":term:`file object` と同義です。" -#: ../../glossary.rst:552 msgid "filesystem encoding and error handler" -msgstr "" +msgstr "filesystem encoding and error handler" -#: ../../glossary.rst:554 msgid "" "Encoding and error handler used by Python to decode bytes from the operating " "system and encode Unicode to the operating system." msgstr "" +"(ファイルシステムのエンコーディングとエラーハンドラ) オペレーティングシステム" +"から受け取ったバイト列のデコードと、オペレーティングシステムに渡す Unicode の" +"エンコードに Python が使用する、エンコーディングとエラーハンドラです。" -#: ../../glossary.rst:557 msgid "" "The filesystem encoding must guarantee to successfully decode all bytes " "below 128. If the file system encoding fails to provide this guarantee, API " "functions can raise :exc:`UnicodeError`." msgstr "" -"ファイルシステムのエンコーディングでは、すべてが 128 バイト以下に正常にデコー" -"ドされることが保証されなくてはなりません。ファイルシステムのエンコーディング" -"でこれが保証されなかった場合は、API 関数が :exc:`UnicodeError` を送出すること" -"があります。" +"ファイルシステムのエンコーディングは、128 未満のすべてのバイト値を正常にデ" +"コードできることを保証しなければなりません。\n" +"ファイルシステムのエンコーディングがこれを保証しない場合、API 関数が :exc:" +"`UnicodeError` を送出することがあります。" -#: ../../glossary.rst:561 msgid "" "The :func:`sys.getfilesystemencoding` and :func:`sys." "getfilesystemencodeerrors` functions can be used to get the filesystem " "encoding and error handler." msgstr "" +":func:`sys.getfilesystemencoding` 関数と :func:`sys." +"getfilesystemencodeerrors` 関数を使うと、ファイルシステムのエンコーディングと" +"エラーハンドラを取得できます。" #: ../../glossary.rst:565 msgid "" @@ -1210,15 +1363,15 @@ msgid "" "filesystem_encoding` and :c:member:`~PyConfig.filesystem_errors` members of :" "c:type:`PyConfig`." msgstr "" -"term:`ファイルシステムのエンコーディングとエラーハンドラ ` は、Pythonの開始時に:c:func:`PyConfig_Read` 関数" -"により設定されます。 :c:type:`PyConfig` のメンバー :c:member:`~PyConfig." +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` は、Python の開始時に :c:func:`PyConfig_Read` 関" +"数により設定されます。 :c:type:`PyConfig` のメンバー :c:member:`~PyConfig." "filesystem_encoding` と :c:member:`~PyConfig.filesystem_errors` を参照してく" "ださい。" -#: ../../glossary.rst:570 msgid "See also the :term:`locale encoding`." msgstr "" +":term:`ロケールエンコーディング ` も参照してください。" #: ../../glossary.rst:571 msgid "finder" @@ -1233,17 +1386,19 @@ msgstr "" "インポートされているモジュールの :term:`loader` の発見を試行するオブジェクト" "です。" -#: ../../glossary.rst:576 msgid "" "There are two types of finder: :term:`meta path finders ` " "for use with :data:`sys.meta_path`, and :term:`path entry finders ` for use with :data:`sys.path_hooks`." msgstr "" +"ファインダには、:data:`sys.meta_path` で使用する :term:`メタパスファインダ " +"` と、:data:`sys.path_hooks` で使用する :term:`パスエントリ" +"ファインダ ` の 2 種類があります。" -#: ../../glossary.rst:580 msgid "" "See :ref:`finders-and-loaders` and :mod:`importlib` for much more detail." msgstr "" +"詳しくは、:ref:`finders-and-loaders` と :mod:`importlib` を参照してください。" #: ../../glossary.rst:581 msgid "floor division" @@ -1265,37 +1420,38 @@ msgstr "" "を行う) ので ``-3`` になることに注意してください。\n" ":pep:`238` を参照してください。" -#: ../../glossary.rst:588 msgid "free threading" -msgstr "" +msgstr "free threading" -#: ../../glossary.rst:590 msgid "" "A threading model where multiple threads can run Python bytecode " "simultaneously within the same interpreter. This is in contrast to the :" "term:`global interpreter lock` which allows only one thread to execute " "Python bytecode at a time. See :pep:`703`." msgstr "" +"(フリースレッディング) 同じインタープリタ内で、複数のスレッドが Python バイト" +"コードを同時に実行できるスレッドモデルです。\n" +"一度に一つのスレッドだけが Python バイトコードを実行できる :term:`グローバル" +"インタープリタロック ` とは対照的です。\n" +":pep:`703` を参照してください。" -#: ../../glossary.rst:594 msgid "free-threaded build" -msgstr "" +msgstr "free-threaded build" -#: ../../glossary.rst:597 msgid "" "A build of :term:`CPython` that supports :term:`free threading`, configured " "using the :option:`--disable-gil` option before compilation." msgstr "" +"(フリースレッドビルド) コンパイル前に :option:`--disable-gil` オプションで構" +"成した、:term:`フリースレッディング ` に対応する :term:" +"`CPython` のビルドです。" -#: ../../glossary.rst:600 msgid "See :ref:`freethreading-python-howto`." -msgstr "" +msgstr ":ref:`freethreading-python-howto` を参照してください。" -#: ../../glossary.rst:601 msgid "free variable" -msgstr "" +msgstr "free variable" -#: ../../glossary.rst:603 msgid "" "Formally, as defined in the :ref:`language execution model `, a " "free variable is any variable used in a namespace which is not a local " @@ -1304,6 +1460,12 @@ msgid "" "attribute, the term is also sometimes used as a synonym for :term:`closure " "variable`." msgstr "" +"(自由変数) :ref:`言語の実行モデル ` における正式な定義では、ある" +"名前空間で使われる変数で、その名前空間のローカル変数ではないものを指しま" +"す。\n" +"例については :term:`クロージャ変数 ` を参照してください。\n" +"実際の用法では、:attr:`codeobject.co_freevars` 属性の名前に由来して、:term:`" +"クロージャ変数 ` の同義語として使われることもあります。" #: ../../glossary.rst:608 msgid "function" @@ -1330,21 +1492,21 @@ msgid "An :term:`annotation` of a function parameter or return value." msgstr "" "(関数アノテーション) 関数のパラメータや返り値の :term:`annotation` です。" -#: ../../glossary.rst:618 msgid "" "Function annotations are usually used for :term:`type hints `: " "for example, this function is expected to take two :class:`int` arguments " "and is also expected to have an :class:`int` return value::" msgstr "" -"関数アノテーションは、通常は :term:`型ヒント ` のために使われま" -"す: 例えば、この関数は 2 つの :class:`int` 型の引数を取ると期待され、また :" -"class:`int` 型の返り値を持つと期待されています。" +"関数アノテーションは通常、:term:`型ヒント ` に使用されます。\n" +"たとえば、次の関数は二つの :class:`int` 型の引数を受け取り、:class:`int` 型の" +"値を返すことを想定しています。 ::" -#: ../../glossary.rst:623 msgid "" "def sum_two_numbers(a: int, b: int) -> int:\n" " return a + b" msgstr "" +"def sum_two_numbers(a: int, b: int) -> int:\n" +" return a + b" #: ../../glossary.rst:626 msgid "Function annotation syntax is explained in section :ref:`function`." @@ -1381,12 +1543,14 @@ msgstr "" "し、その変数を評価することで、新機能が最初に言語に追加されたのはいつかや、い" "つデフォルトになるか (またはなったか) を見ることができます::" -#: ../../glossary.rst:642 msgid "" ">>> import __future__\n" ">>> __future__.division\n" "_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" msgstr "" +">>> import __future__\n" +">>> __future__.division\n" +"_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)" #: ../../glossary.rst:645 msgid "garbage collection" @@ -1408,74 +1572,90 @@ msgstr "" msgid "generator" msgstr "ジェネレータ" -#: ../../glossary.rst:655 msgid "" "Informally used to mean either a :term:`generator function` or a :term:" "`generator iterator`, depending on context. The formal terms :term:" "`generator function` and :term:`generator iterator` are uncommon in " "practice; \"generator\" alone is almost always sufficient." msgstr "" +"文脈に応じて、:term:`ジェネレータ関数 ` または :term:`" +"ジェネレータイテレータ ` のどちらかを指すために非公式に使" +"われる語です。\n" +"正式な用語である :term:`ジェネレータ関数 ` と :term:`ジェ" +"ネレータイテレータ ` は、実際にはあまり使われません。\n" +"ほとんどの場合、「ジェネレータ」だけで十分です。" -#: ../../glossary.rst:660 ../../glossary.rst:661 msgid "generator function" -msgstr "" +msgstr "generator function" -#: ../../glossary.rst:663 msgid "" "A function which returns a :term:`generator` object. It looks like a normal " "function except that it contains :keyword:`yield` expressions for producing " "a series of values usable in a :keyword:`for`\\-loop or that can be " "retrieved one at a time with the :func:`next` function. See :ref:`yieldexpr`." msgstr "" +"(ジェネレータ関数) :term:`ジェネレータ ` オブジェクトを返す関数で" +"す。\n" +"通常の関数に似ていますが、:keyword:`for` ループで使用したり、:func:`next` 関" +"数で一つずつ取得したりできる一連の値を生成するための :keyword:`yield` 式を含" +"む点が異なります。\n" +":ref:`yieldexpr` を参照してください。" #: ../../glossary.rst:668 msgid "generator iterator" msgstr "generator iterator" -#: ../../glossary.rst:670 msgid "" "An object created by a :term:`generator function` or a :term:`generator " "expression`." msgstr "" +":term:`ジェネレータ関数 ` または :term:`ジェネレータ式 " +"` によって作成されるオブジェクトです。" -#: ../../glossary.rst:673 msgid "" "Each :keyword:`yield` temporarily suspends processing, remembering the " "execution state (including local variables and pending try-statements). When " "the *generator iterator* resumes, it picks up where it left off (in contrast " "to functions which start fresh on every invocation)." msgstr "" +"各 :keyword:`yield` は処理を一時的に中断し、実行状態(ローカル変数や保留中の " +"try 文を含む)を記憶します。\n" +"*ジェネレータイテレータ* は、実行を再開すると、中断した箇所から処理を続けます" +"(呼び出しのたびに最初から実行する関数とは異なります)。" -#: ../../glossary.rst:678 msgid "" "Generator iterators also implement the :meth:`~generator.send` method to " "send a value into the suspended generator, and the :meth:`~generator.throw` " "method to raise an exception at the point where the generator was paused. " "See :ref:`generator-methods`." msgstr "" +"ジェネレータイテレータは、中断したジェネレータに値を送る :meth:`~generator." +"send` メソッドと、ジェネレータが中断した箇所で例外を送出する :meth:" +"`~generator.throw` メソッドも実装します。\n" +":ref:`generator-methods` を参照してください。" #: ../../glossary.rst:683 ../../glossary.rst:684 msgid "generator expression" msgstr "generator expression" -#: ../../glossary.rst:686 msgid "" "An :term:`expression` that returns an :term:`iterator`. It looks like a " "normal expression followed by a :keyword:`!for` clause defining a loop " "variable, range, and an optional :keyword:`!if` clause. The combined " "expression generates values for an enclosing function::" msgstr "" -"(ジェネレータ式) :term:`iterator <イテレータ>` を返す :term:`式 " -"` です。\n" -"普通の式に、ループ変数を定義する :keyword:`!for` 節、範囲、そして省略可能な :" -"keyword:`!if` 節がつづいているように見えます。\n" -"こうして構成された式は、外側の関数に向けて値を生成します::" +"(ジェネレータ式) :term:`イテレータ ` を返す :term:`式 " +"` です。\n" +"通常の式の後に、ループ変数と範囲を定義する :keyword:`!for` 節、そして省略可能" +"な :keyword:`!if` 節が続く形をしています。\n" +"このように組み合わせた式は、外側の関数に渡す値を生成します。 ::" -#: ../../glossary.rst:691 msgid "" ">>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81\n" "285" msgstr "" +">>> sum(i*i for i in range(10)) # 平方数 0, 1, 4, ... 81 の合計\n" +"285" #: ../../glossary.rst:693 msgid "generic function" @@ -1490,28 +1670,33 @@ msgstr "" "(ジェネリック関数) 異なる型に対し同じ操作をする関数群から構成される関数です。" "呼び出し時にどの実装を用いるかはディスパッチアルゴリズムにより決定されます。" -#: ../../glossary.rst:699 msgid "" "See also the :term:`single dispatch` glossary entry, the :deco:`functools." "singledispatch` decorator, and :pep:`443`." msgstr "" +"用語集の :term:`単一ディスパッチ ` の項目、:deco:`functools." +"singledispatch` デコレータ、および :pep:`443` も参照してください。" -#: ../../glossary.rst:701 msgid "generic type" -msgstr "" +msgstr "generic type" -#: ../../glossary.rst:703 msgid "" "A :term:`type` that can be parameterized; typically a :ref:`container " "class` such as :class:`list` or :class:`dict`. Used for :" "term:`type hints ` and :term:`annotations `." msgstr "" +"(ジェネリック型) パラメータ化できる :term:`型 ` で、通常は :class:" +"`list` や :class:`dict` のような :ref:`コンテナクラス ` で" +"す。\n" +":term:`型ヒント ` や :term:`アノテーション ` に使用さ" +"れます。" -#: ../../glossary.rst:708 msgid "" "For more details, see :ref:`generic alias types`, :pep:" "`483`, :pep:`484`, :pep:`585`, and the :mod:`typing` module." msgstr "" +"詳しくは、:ref:`ジェネリックエイリアス型 `、:pep:`483`、:" +"pep:`484`、:pep:`585`、:mod:`typing` モジュールを参照してください。" #: ../../glossary.rst:710 msgid "GIL" @@ -1525,7 +1710,6 @@ msgstr ":term:`global interpreter lock` を参照してください。" msgid "global interpreter lock" msgstr "global interpreter lock" -#: ../../glossary.rst:715 msgid "" "The mechanism used by the :term:`CPython` interpreter to assure that only " "one thread executes Python :term:`bytecode` at a time. This simplifies the " @@ -1535,13 +1719,14 @@ msgid "" "multi-threaded, at the expense of much of the parallelism afforded by multi-" "processor machines." msgstr "" -"(グローバルインタプリタロック) :term:`CPython` インタプリタが利用している、一" -"度に Python の :term:`バイトコード ` を実行するスレッドは一つだけで" -"あることを保証する仕組みです。これにより (:class:`dict` などの重要な組み込み" -"型を含む) オブジェクトモデルが同時アクセスに対して暗黙的に安全になるので、 " -"CPython の実装がシンプルになります。インタプリタ全体をロックすることで、マル" -"チプロセッサマシンが生じる並列化のコストと引き換えに、インタプリタを簡単にマ" -"ルチスレッド化できるようになります。" +"(グローバルインタプリタロック) :term:`CPython` インタプリタが、一度に一つのス" +"レッドだけが Python の :term:`バイトコード ` を実行することを保証す" +"るために使う仕組みです。\n" +"この仕組みは、:class:`dict` などの重要な組み込み型を含むオブジェクトモデル" +"を、並行アクセスに対して暗黙に安全にすることで、CPython の実装を単純にしま" +"す。\n" +"インタプリタ全体をロックすると、マルチプロセッサマシンが可能にする並列性の多" +"くを犠牲にする代わりに、インタプリタをマルチスレッド化しやすくなります。" #: ../../glossary.rst:724 msgid "" @@ -1554,7 +1739,6 @@ msgstr "" "の計算の重い処理をするときに GIL を解除するように設計されています。また、I/O " "処理をする場合 GIL は常に解除されます。" -#: ../../glossary.rst:729 msgid "" "As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil` " "build configuration. After building Python with this option, code must be " @@ -1563,19 +1747,28 @@ msgid "" "performance for multi-threaded applications and makes it easier to use multi-" "core CPUs efficiently. For more details, see :pep:`703`." msgstr "" +"Python 3.13 以降では、ビルド設定 :option:`--disable-gil` を使って GIL を無効" +"にできます。\n" +"このオプションで Python をビルドした後は、:option:`-X gil=0 <-X>` を指定する" +"か、環境変数 :envvar:`PYTHON_GIL=0 ` を設定してコードを実行する必" +"要があります。\n" +"この機能により、マルチスレッドアプリケーションの性能を改善でき、マルチコア " +"CPU を効率よく利用しやすくなります。\n" +"詳しくは :pep:`703` を参照してください。" -#: ../../glossary.rst:736 msgid "" "In prior versions of Python's C API, a function might declare that it " "requires the GIL to be held in order to use it. This refers to having an :" "term:`attached thread state`." msgstr "" +"以前の Python C API では、関数を使用するには GIL を保持する必要があると宣言さ" +"れていることがありました。\n" +"これは、:term:`スレッド状態がアタッチされている ` こと" +"を指します。" -#: ../../glossary.rst:739 msgid "global state" -msgstr "" +msgstr "global state" -#: ../../glossary.rst:741 msgid "" "Data that is accessible throughout a program, such as module-level " "variables, class variables, or C static variables in :term:`extension " @@ -1583,6 +1776,12 @@ msgid "" "shared between threads typically requires synchronization to avoid :term:" "`race conditions ` and :term:`data races `." msgstr "" +"(グローバル状態) モジュールレベルの変数、クラス変数、:term:`拡張モジュール " +"` 内の C の静的変数など、プログラム全体からアクセスできる" +"データです。\n" +"マルチスレッドプログラムでは、スレッド間で共有されるグローバル状態には通常、:" +"term:`競合状態 ` や :term:`データ競合 ` を避けるた" +"めの同期が必要です。" #: ../../glossary.rst:747 msgid "hash-based pyc" @@ -1602,13 +1801,18 @@ msgstr "" msgid "hashable" msgstr "hashable" -#: ../../glossary.rst:754 msgid "" "An object is *hashable* if it has a hash value which never changes during " "its lifetime (it needs a :meth:`~object.__hash__` method), and can be " "compared to other objects (it needs an :meth:`~object.__eq__` method). " "Hashable objects which compare equal must have the same hash value." msgstr "" +"(ハッシュ可能) オブジェクトの生存期間を通して変わらないハッシュ値を持ち(:" +"meth:`~object.__hash__` メソッドが必要です)、ほかのオブジェクトと比較できる" +"(:meth:`~object.__eq__` メソッドが必要です)場合、そのオブジェクトは *ハッ" +"シュ可能* です。\n" +"比較で等しいと判定されるハッシュ可能オブジェクトは、同じハッシュ値を持たなけ" +"ればなりません。" #: ../../glossary.rst:760 msgid "" @@ -1654,30 +1858,34 @@ msgstr "" msgid "immortal" msgstr "永続オブジェクト (immortal)" -#: ../../glossary.rst:777 msgid "" "*Immortal objects* are a CPython implementation detail introduced in :pep:" "`683`." msgstr "" +"*永続オブジェクト* は、:pep:`683` で導入された CPython の実装の詳細です。" -#: ../../glossary.rst:780 msgid "" "If an object is immortal, its :term:`reference count` is never modified, and " "therefore it is never deallocated while the interpreter is running. For " "example, :const:`True` and :const:`None` are immortal in CPython." msgstr "" +"オブジェクトが永続である場合、その :term:`参照カウント ` は" +"決して変更されず、そのためインタープリタの実行中にメモリが解放されることはあ" +"りません。\n" +"たとえば、CPython では :const:`True` と :const:`None` が永続オブジェクトで" +"す。" -#: ../../glossary.rst:784 msgid "" "Immortal objects can be identified via :func:`sys._is_immortal`, or via :c:" "func:`PyUnstable_IsImmortal` in the C API." msgstr "" +"永続オブジェクトは :func:`sys._is_immortal`、または C API の :c:func:" +"`PyUnstable_IsImmortal` によって識別できます。" #: ../../glossary.rst:786 msgid "immutable" msgstr "immutable" -#: ../../glossary.rst:788 msgid "" "An object with a fixed value. Immutable objects include numbers, strings " "and tuples. Such an object cannot be altered. A new object has to be " @@ -1687,6 +1895,15 @@ msgid "" "their state cannot be modified after creation, eliminating concerns about " "improperly synchronized :term:`concurrent modification`." msgstr "" +"(不変) 値が固定されたオブジェクトです。\n" +"不変オブジェクトには、数値、文字列、タプルがあります。\n" +"このようなオブジェクトは変更できません。\n" +"異なる値を格納するには、新しいオブジェクトを作成する必要があります。\n" +"不変オブジェクトは、辞書のキーなど、ハッシュ値が一定である必要のある場面で重" +"要な役割を果たします。\n" +"作成後に状態を変更できないため、不変オブジェクトは本質的に :term:`スレッド" +"セーフ ` であり、不適切な同期による :term:`並行変更 ` を心配する必要がありません。" #: ../../glossary.rst:795 msgid "import path" @@ -1728,37 +1945,37 @@ msgstr "" "モジュールを探してロードするオブジェクト。 :term:`finder` と :term:`loader` " "のどちらでもあるオブジェクト。" -#: ../../glossary.rst:810 msgid "index" -msgstr "" +msgstr "index" -#: ../../glossary.rst:812 msgid "" "A numeric value that represents the position of an element in a :term:" "`sequence`." msgstr "" +"(インデックス) :term:`シーケンス ` 内の要素の位置を表す数値です。" -#: ../../glossary.rst:815 msgid "" "In Python, indexing starts at zero. For example, ``things[0]`` names the " "*first* element of ``things``; ``things[1]`` names the second one." msgstr "" +"Python のインデックスはゼロから始まります。\n" +"たとえば、``things[0]`` は ``things`` の *最初* の要素を、``things[1]`` は 2 " +"番目の要素を表します。" -#: ../../glossary.rst:819 msgid "" "In some contexts, Python allows negative indexes for counting from the end " "of a sequence, and indexing using :term:`slices `." msgstr "" +"文脈によっては、Python はシーケンスの末尾から数えるための負のインデックス" +"や、:term:`スライス ` を使ったインデックス指定を許可しています。" -#: ../../glossary.rst:822 msgid "See also :term:`subscript`." -msgstr "" +msgstr ":term:`添字 ` も参照してください。" #: ../../glossary.rst:823 msgid "interactive" msgstr "interactive" -#: ../../glossary.rst:825 msgid "" "Python has an interactive interpreter which means you can enter statements " "and expressions at the interpreter prompt, immediately execute them and see " @@ -1767,6 +1984,13 @@ msgid "" "test out new ideas or inspect modules and packages (remember ``help(x)``). " "For more on interactive mode, see :ref:`tut-interac`." msgstr "" +"(対話型) Python には対話型インタープリタがあり、そのプロンプトで文や式を入力" +"して、すぐに実行し、結果を見ることができます。\n" +"``python`` を引数なしで起動するだけで利用できます(コンピュータのメインメ" +"ニューで選択して起動することもできます)。\n" +"新しいアイデアを試したり、モジュールやパッケージを調べたりするための、とても" +"強力な方法です(``help(x)`` を思い出してください)。\n" +"対話モードについて詳しくは、:ref:`tut-interac` を参照してください。" #: ../../glossary.rst:832 msgid "interpreted" @@ -1792,7 +2016,6 @@ msgstr "" msgid "interpreter shutdown" msgstr "interpreter shutdown" -#: ../../glossary.rst:843 msgid "" "When asked to shut down, the Python interpreter enters a special phase where " "it gradually releases all allocated resources, such as modules and various " @@ -1803,16 +2026,15 @@ msgid "" "relies on may not function anymore (common examples are library modules or " "the warnings machinery)." msgstr "" -"Python インタープリターはシャットダウンを要請された時に、モジュールやすべての" -"クリティカルな内部構造をなどの、すべての確保したリソースを段階的に開放する、" -"特別なフェーズに入ります。\n" -"このフェーズは :term:`ガベージコレクタ ` を複数回呼び出し" -"ます。\n" -"これによりユーザー定義のデストラクターや weakref コールバックが呼び出されるこ" -"とがあります。\n" -"シャットダウンフェーズ中に実行されるコードは、それが依存するリソースがすでに" -"機能しない(よくある例はライブラリーモジュールや warning 機構です) ために様々" -"な例外に直面します。" +"Python インタープリタは、シャットダウンを要求されると、モジュールや各種の重要" +"な内部構造など、割り当てられたすべてのリソースを段階的に解放する特別な段階に" +"入ります。\n" +"また、:term:`ガベージコレクタ ` を複数回呼び出します。\n" +"これにより、ユーザー定義のデストラクタや weakref コールバックのコードが実行さ" +"れることがあります。\n" +"シャットダウン段階で実行されるコードでは、依存するリソースがすでに機能しなく" +"なっている場合があるため(よくある例はライブラリモジュールや warnings の仕組" +"みです)、さまざまな例外が発生することがあります。" #: ../../glossary.rst:852 msgid "" @@ -1826,7 +2048,6 @@ msgstr "" msgid "iterable" msgstr "iterable" -#: ../../glossary.rst:856 msgid "" "An object capable of returning its members one at a time. Examples of " "iterables include all sequence types (such as :class:`list`, :class:`str`, " @@ -1835,8 +2056,14 @@ msgid "" "meth:`~object.__iter__` method or with a :meth:`~object.__getitem__` method " "that implements :term:`sequence` semantics." msgstr "" +"(イテラブル) 要素を一つずつ返すことができるオブジェクトです。\n" +"例として、すべてのシーケンス型(:class:`list`、:class:`str`、:class:`tuple` " +"など)や、:class:`dict`、:term:`ファイルオブジェクト ` のような" +"一部のシーケンスでない型があります。\n" +"また、:meth:`~object.__iter__` メソッド、または :term:`シーケンス " +"` の意味論を実装する :meth:`~object.__getitem__` メソッドを定義した" +"任意のクラスのオブジェクトも該当します。" -#: ../../glossary.rst:864 msgid "" "Iterables can be used in a :keyword:`for` loop and in many other places " "where a sequence is needed (:func:`zip`, :func:`map`, ...). When an " @@ -1848,24 +2075,23 @@ msgid "" "temporary unnamed variable to hold the iterator for the duration of the " "loop. See also :term:`iterator`, :term:`sequence`, and :term:`generator`." msgstr "" -"反復可能オブジェクトは :keyword:`for` ループ内やその他多くのシーケンス (訳" -"注: ここでのシーケンスとは、シーケンス型ではなくただの列という意味)が必要とな" -"る状況 (:func:`zip`, :func:`map`, ...) で利用できます。\n" -"反復可能オブジェクトを組み込み関数 :func:`iter` の引数として渡すと、 オブジェ" -"クトに対するイテレータを返します。\n" -"このイテレータは一連の値を引き渡す際に便利です。\n" -"通常は反復可能オブジェクトを使う際には、 :func:`iter` を呼んだりイテレータオ" -"ブジェクトを自分で操作する必要はありません。\n" -":keyword:`for` 文ではこの操作を自動的に行い、一時的な無名の変数を作成してルー" -"プを回している間イテレータを保持します。\n" -":term:`イテレータ ` 、 :term:`シーケンス ` 、 :term:`ジェ" -"ネレータ ` も参照してください。 " +"イテラブルは :keyword:`for` ループや、シーケンスを必要とするほかの多くの場面" +"(:func:`zip`、:func:`map` など)で使えます(訳注: ここでのシーケンスは、シー" +"ケンス型ではなく、単なる列という意味です)。\n" +"組み込み関数 :func:`iter` にイテラブルオブジェクトを引数として渡すと、そのオ" +"ブジェクトのイテレータが返されます。\n" +"このイテレータで、一連の値を一度だけ走査できます。\n" +"イテラブルを使う際には通常、:func:`iter` を呼び出したり、イテレータオブジェク" +"トを自分で扱ったりする必要はありません。\n" +":keyword:`for` 文が自動的にこれを行い、一時的な無名の変数を作成して、ループの" +"実行中にイテレータを保持します。\n" +":term:`イテレータ `、:term:`シーケンス `、:term:`ジェネ" +"レータ ` も参照してください。" #: ../../glossary.rst:874 msgid "iterator" msgstr "iterator" -#: ../../glossary.rst:876 msgid "" "An object representing a stream of data. Repeated calls to the iterator's :" "meth:`~iterator.__next__` method (or passing it to the built-in function :" @@ -1883,28 +2109,49 @@ msgid "" "iterator object used in the previous iteration pass, making it appear like " "an empty container." msgstr "" +"(イテレータ) データのストリームを表すオブジェクトです。\n" +"イテレータの :meth:`~iterator.__next__` メソッドを繰り返し呼び出すと(または" +"組み込み関数 :func:`next` に渡すと)、ストリーム内の要素が順に返されます。\n" +"それ以上データがない場合、代わりに :exc:`StopIteration` 例外が送出されま" +"す。\n" +"この時点でイテレータオブジェクトは :term:`枯渇した ` 状態となり、" +"その後 :meth:`!__next__` メソッドを呼び出しても、再び :exc:`StopIteration` が" +"送出されるだけです。\n" +"イテレータには、自身を返す :meth:`~iterator.__iter__` メソッドが必要です。\n" +"したがって、すべてのイテレータはイテラブルでもあり、ほかのイテラブルを受け付" +"けるほとんどの場面で使えます。\n" +"主な例外は、複数回の反復を試みるコードです。\n" +"コンテナオブジェクト(:class:`list` など)は、:func:`iter` 関数に渡したり、:" +"keyword:`for` ループで使ったりするたびに、新しいイテレータを生成します。\n" +"イテレータでこれを試みても、前の反復で使ったものと同じ枯渇したイテレータオブ" +"ジェクトが返されるだけなので、空のコンテナのように見えます。" #: ../../glossary.rst:891 msgid "More information can be found in :ref:`typeiter`." msgstr "詳細な情報は :ref:`typeiter` にあります。" -#: ../../glossary.rst:895 msgid "" "CPython does not consistently apply the requirement that an iterator define :" "meth:`~iterator.__iter__`. And also please note that :term:`free-threaded " "` CPython does not guarantee :term:`thread-safe` behavior of " "iterator operations." msgstr "" +"CPython は、イテレータが :meth:`~iterator.__iter__` を定義するという要件を、" +"一貫して適用しているわけではありません。\n" +"また、:term:`フリースレッドの ` CPython は、イテレータ操作" +"の :term:`スレッドセーフな ` 動作を保証しない点にも注意してくだ" +"さい。" #: ../../glossary.rst:900 msgid "key" msgstr "キー" -#: ../../glossary.rst:902 msgid "" "A value that identifies an entry in a :term:`mapping`. See also :term:" "`subscript`." msgstr "" +":term:`マッピング ` 内の項目を識別する値です。\n" +":term:`添字 ` も参照してください。" #: ../../glossary.rst:904 msgid "key function" @@ -1933,7 +2180,6 @@ msgstr "" "merge`, :func:`heapq.nsmallest`, :func:`heapq.nlargest`, :func:`itertools." "groupby` 等があります。" -#: ../../glossary.rst:917 msgid "" "There are several ways to create a key function. For example. the :meth:" "`str.casefold` method can serve as a key function for case insensitive " @@ -1943,6 +2189,15 @@ msgid "" "are three key function constructors. See the :ref:`Sorting HOW TO " "` for examples of how to create and use key functions." msgstr "" +"キー関数を作成する方法はいくつかあります。\n" +"たとえば、:meth:`str.casefold` メソッドは、大文字と小文字を区別しないソートの" +"キー関数として使えます。\n" +"また、``lambda r: (r[0], r[2])`` のような :keyword:`lambda` 式からキー関数を" +"作成することもできます。\n" +"さらに、:func:`operator.attrgetter`、:func:`operator.itemgetter`、:func:" +"`operator.methodcaller` という三つのキー関数のコンストラクタがあります。\n" +"キー関数の作成と使用の例については、:ref:`ソート HOWTO ` を参照" +"してください。" #: ../../glossary.rst:924 msgid "keyword argument" @@ -1982,7 +2237,6 @@ msgstr "" "す。 :term:`EAFP` アプローチと対照的で、 :keyword:`if` 文がたくさん使われるの" "が特徴的です。" -#: ../../glossary.rst:939 msgid "" "In a multi-threaded environment, the LBYL approach can risk introducing a :" "term:`race condition` between \"the looking\" and \"the leaping\". For " @@ -1991,25 +2245,36 @@ msgid "" "lookup. This issue can be solved with :term:`locks ` or by using the :" "term:`EAFP` approach. See also :term:`thread-safe`." msgstr "" +"マルチスレッド環境では、LBYL のアプローチは「確認」と「実行」の間に :term:`競" +"合状態 ` を生じさせる危険があります。\n" +"たとえば、``if key in mapping: return mapping[key]`` というコードでは、判定の" +"後、検索する前に、別のスレッドが *mapping* から *key* を削除すると、失敗する" +"ことがあります。\n" +"この問題は、:term:`ロック ` または :term:`EAFP` のアプローチを使うと解" +"決できます。\n" +":term:`スレッドセーフ ` も参照してください。" -#: ../../glossary.rst:945 msgid "lexical analyzer" -msgstr "" +msgstr "lexical analyzer" -#: ../../glossary.rst:948 msgid "Formal name for the *tokenizer*; see :term:`token`." msgstr "" +"(字句解析器) *トークナイザ* の正式な名称です。\n" +":term:`トークン ` を参照してください。" #: ../../glossary.rst:949 msgid "list" msgstr "list" -#: ../../glossary.rst:951 msgid "" "A built-in Python :term:`sequence`. Despite its name it is more akin to an " "array in other languages than to a linked list since access to elements is " "*O*\\ (1). See :ref:`time-complexity`." msgstr "" +"Python の組み込み :term:`シーケンス ` です。\n" +"要素へのアクセスが *O*\\ (1) であるため、名前とは異なり、連結リストよりも、ほ" +"かの言語の配列に似ています。\n" +":ref:`time-complexity` を参照してください。" #: ../../glossary.rst:954 msgid "list comprehension" @@ -2027,14 +2292,11 @@ msgstr "" "なるリストを返す、コンパクトな方法です。 ``result = ['{:#04x}'.format(x) for " "x in range(256) if x % 2 == 0]`` とすると、 0 から 255 までの偶数を 16進数表" "記 (0x..) した文字列からなるリストを生成します。 :keyword:`if` 節はオプション" -"です。 :keyword:`if` 節がない場合、 ``range(256)`` の全ての要素が処理されま" -"す。" +"です。 ``if`` 節がない場合、 ``range(256)`` の全ての要素が処理されます。" -#: ../../glossary.rst:962 msgid "lock" -msgstr "" +msgstr "lock" -#: ../../glossary.rst:964 msgid "" "A :term:`synchronization primitive` that allows only one thread at a time to " "access a shared resource. A thread must acquire a lock before accessing the " @@ -2048,12 +2310,25 @@ msgid "" "patterns, and thread-local state. See also :term:`deadlock`, and :term:" "`reentrant`." msgstr "" +"(ロック) 一度に一つのスレッドだけが共有リソースにアクセスできるようにする :" +"term:`同期プリミティブ ` です。\n" +"スレッドは、保護されたリソースにアクセスする前にロックを取得し、アクセス後に" +"解放しなければなりません。\n" +"ほかのスレッドがすでに保持しているロックを取得しようとすると、ロックが利用可" +"能になるまでブロックします。\n" +"Python の :mod:`threading` モジュールは、:class:`~threading.Lock`(基本的な" +"ロック)と :class:`~threading.RLock`(:term:`再入可能な ` ロック)" +"を提供します。\n" +"ロックは、:term:`競合状態 ` を防ぎ、共有データへの :term:`ス" +"レッドセーフな ` アクセスを保証するために使われます。\n" +"ロックの代わりに使える設計パターンとして、キュー、生産者と消費者のパターン、" +"スレッドローカルな状態などがあります。\n" +":term:`デッドロック ` と :term:`再入可能 ` も参照してく" +"ださい。" -#: ../../glossary.rst:975 msgid "lock-free" -msgstr "" +msgstr "lock-free" -#: ../../glossary.rst:977 msgid "" "An operation that does not acquire any :term:`lock` and uses atomic CPU " "instructions to ensure correctness. Lock-free operations can execute " @@ -2064,26 +2339,38 @@ msgid "" "multi-step modifications even when those modifications hold the :term:`per-" "object lock`." msgstr "" +"(ロックフリー) :term:`ロック ` を取得せず、CPU のアトミック命令を使って" +"正しさを保証する操作です。\n" +"ロックフリーな操作は、互いをブロックせずに並行して実行でき、ロックを保持する" +"操作によってブロックされることもありません。\n" +":term:`フリースレッドの ` Python では、:class:`dict` や :" +"class:`list` のような組み込み型がロックフリーな読み取り操作を提供します。\n" +"そのため、複数のステップからなる変更が :term:`オブジェクトごとのロック ` を保持していても、ほかのスレッドから途中の状態が観測されること" +"があります。" #: ../../glossary.rst:985 msgid "loader" msgstr "loader" -#: ../../glossary.rst:987 msgid "" "An object that loads a module. It must define the :meth:`!exec_module` and :" "meth:`!create_module` methods to implement the :class:`~importlib.abc." "Loader` interface. A loader is typically returned by a :term:`finder`. See " "also:" msgstr "" +"(ローダー) モジュールをロードするオブジェクトです。\n" +":class:`~importlib.abc.Loader` インターフェースを実装するには、:meth:`!" +"exec_module` メソッドと :meth:`!create_module` メソッドを定義しなければなりま" +"せん。\n" +"ローダーは通常、:term:`ファインダ ` から返されます。\n" +"次の項目も参照してください:" -#: ../../glossary.rst:993 msgid ":ref:`finders-and-loaders`" -msgstr "" +msgstr ":ref:`finders-and-loaders`" -#: ../../glossary.rst:994 msgid ":class:`importlib.abc.Loader`" -msgstr "" +msgstr ":class:`importlib.abc.Loader`" #: ../../glossary.rst:995 msgid ":pep:`302`" @@ -2093,28 +2380,31 @@ msgstr ":pep:`302`" msgid "locale encoding" msgstr "ロケールエンコーディング" -#: ../../glossary.rst:998 msgid "" "On Unix, it is the encoding of the LC_CTYPE locale. It can be set with :func:" "`locale.setlocale(locale.LC_CTYPE, new_locale) `." msgstr "" +"Unix では、LC_CTYPE ロケールのエンコーディングです。\n" +":func:`locale.setlocale(locale.LC_CTYPE, new_locale) ` で設" +"定できます。" -#: ../../glossary.rst:1001 msgid "On Windows, it is the ANSI code page (ex: ``\"cp1252\"``)." -msgstr "" +msgstr "Windows では、ANSI コードページ(例: ``\"cp1252\"``)です。" -#: ../../glossary.rst:1003 msgid "" "On Android and VxWorks, Python uses ``\"utf-8\"`` as the locale encoding." msgstr "" +"Android と VxWorks では、Python はロケールエンコーディングとして " +"``\"utf-8\"`` を使用します。" -#: ../../glossary.rst:1005 msgid ":func:`locale.getencoding` can be used to get the locale encoding." msgstr "" +":func:`locale.getencoding` を使うと、ロケールエンコーディングを取得できます。" -#: ../../glossary.rst:1007 msgid "See also the :term:`filesystem encoding and error handler`." msgstr "" +":term:`ファイルシステムのエンコーディングとエラーハンドラ ` も参照してください。" #: ../../glossary.rst:1008 msgid "magic method" @@ -2216,12 +2506,14 @@ msgstr "" msgid "method resolution order" msgstr "method resolution order" -#: ../../glossary.rst:1050 msgid "" "Method Resolution Order is the order in which base classes are searched for " "a member during lookup. See :ref:`python_2.3_mro` for details of the " "algorithm used by the Python interpreter since the 2.3 release." msgstr "" +"(メソッド解決順序) メンバーの検索時に基底クラスを調べる順序です。\n" +"Python インタープリタがリリース 2.3 以降で使っているアルゴリズムの詳細につい" +"ては、:ref:`python_2.3_mro` を参照してください。" #: ../../glossary.rst:1053 msgid "module" @@ -2253,9 +2545,8 @@ msgstr "" "モジュールをロードするのに使われるインポート関連の情報を含む名前空間です。\n" ":class:`importlib.machinery.ModuleSpec` のインスタンスです。" -#: ../../glossary.rst:1065 msgid "See also :ref:`module-specs`." -msgstr "" +msgstr ":ref:`module-specs` も参照してください。" #: ../../glossary.rst:1066 msgid "MRO" @@ -2269,7 +2560,6 @@ msgstr ":term:`method resolution order` を参照してください。" msgid "mutable" msgstr "mutable" -#: ../../glossary.rst:1071 msgid "" "An :term:`object` with state that is allowed to change during the course of " "the program. In multi-threaded programs, mutable objects that are shared " @@ -2277,6 +2567,12 @@ msgid "" "conditions `. See also :term:`immutable`, :term:`thread-" "safe`, and :term:`concurrent modification`." msgstr "" +"(可変) プログラムの実行中に状態を変更できる :term:`オブジェクト ` で" +"す。\n" +"マルチスレッドプログラムでは、スレッド間で共有する可変オブジェクトには、:" +"term:`競合状態 ` を避けるための慎重な同期が必要です。\n" +":term:`不変 `、:term:`スレッドセーフ `、:term:`並行変" +"更 ` も参照してください。" #: ../../glossary.rst:1076 msgid "named tuple" @@ -2302,7 +2598,6 @@ msgstr "" "は名前付きタプルです。\n" "他の例は :data:`sys.float_info` です::" -#: ../../glossary.rst:1086 msgid "" ">>> sys.float_info[1] # indexed access\n" "1024\n" @@ -2311,8 +2606,13 @@ msgid "" ">>> isinstance(sys.float_info, tuple) # kind of tuple\n" "True" msgstr "" +">>> sys.float_info[1] # インデックスによるアクセス\n" +"1024\n" +">>> sys.float_info.max_exp # 名前付きフィールドによるアクセス\n" +"1024\n" +">>> isinstance(sys.float_info, tuple) # タプルの一種\n" +"True" -#: ../../glossary.rst:1093 msgid "" "Some named tuples are built-in types (such as the above examples). " "Alternatively, a named tuple can be created from a regular class definition " @@ -2322,6 +2622,14 @@ msgid "" "namedtuple`. The latter techniques also add some extra methods that may not " "be found in hand-written or built-in named tuples." msgstr "" +"名前付きタプルの一部は、上の例のような組み込み型です。\n" +"また、:class:`tuple` を継承して名前付きフィールドを定義する、通常のクラス定義" +"からも名前付きタプルを作成できます。\n" +"このようなクラスは手作業で書くことも、:class:`typing.NamedTuple` を継承した" +"り、ファクトリ関数 :func:`collections.namedtuple` を使ったりして作成すること" +"もできます。\n" +"後者の方法では、手書きの名前付きタプルや組み込みの名前付きタプルにはない場合" +"がある、いくつかの追加メソッドも用意されます。" #: ../../glossary.rst:1101 msgid "namespace" @@ -2353,34 +2661,40 @@ msgstr "" msgid "namespace package" msgstr "namespace package" -#: ../../glossary.rst:1115 msgid "" "A :term:`package` which serves only as a container for subpackages. " "Namespace packages may have no physical representation, and specifically are " "not like a :term:`regular package` because they have no ``__init__.py`` file." msgstr "" +"サブパッケージのコンテナとしてだけ機能する :term:`パッケージ ` で" +"す。\n" +"名前空間パッケージは物理的な実体を持たない場合があり、特に ``__init__.py`` " +"ファイルを持たない点で :term:`通常のパッケージ ` と異なりま" +"す。" -#: ../../glossary.rst:1120 msgid "" "Namespace packages allow several individually installable packages to have a " "common parent package. Otherwise, it is recommended to use a :term:`regular " "package`." msgstr "" +"名前空間パッケージを使うと、個別にインストール可能な複数のパッケージが、共通" +"の親パッケージを持てます。\n" +"それ以外の場合は、:term:`通常のパッケージ ` の使用を推奨しま" +"す。" -#: ../../glossary.rst:1123 msgid "" "For more information, see :pep:`420` and :ref:`reference-namespace-package`." msgstr "" +"詳しくは、:pep:`420` と :ref:`reference-namespace-package` を参照してくださ" +"い。" #: ../../glossary.rst:1125 msgid "See also :term:`module`." msgstr ":term:`module` を参照してください。" -#: ../../glossary.rst:1126 msgid "native code" -msgstr "" +msgstr "native code" -#: ../../glossary.rst:1128 msgid "" "Code that is compiled to machine instructions and runs directly on the " "processor, as opposed to code that is interpreted or runs in a virtual " @@ -2388,6 +2702,14 @@ msgid "" "Rust or Fortran code in :term:`extension modules ` that " "can be called from Python. See also :term:`extension module`." msgstr "" +"(ネイティブコード) 機械語命令にコンパイルされ、プロセッサ上で直接実行される" +"コードです。\n" +"インタープリタで解釈されたり、仮想マシン内で実行されたりするコードと対比され" +"ます。\n" +"Python の文脈では、ネイティブコードは通常、Python から呼び出せる :term:`拡張" +"モジュール ` 内の C、C++、Rust、Fortran のコードを指しま" +"す。\n" +":term:`拡張モジュール ` も参照してください。" #: ../../glossary.rst:1133 msgid "nested scope" @@ -2413,19 +2735,21 @@ msgstr "" msgid "new-style class" msgstr "new-style class" -#: ../../glossary.rst:1144 msgid "" "Old name for the flavor of classes now used for all class objects. In " "earlier Python versions, only new-style classes could use Python's newer, " "versatile features like :attr:`~object.__slots__`, descriptors, properties, :" "meth:`~object.__getattribute__`, class methods, and static methods." msgstr "" +"(新スタイルクラス) 現在すべてのクラスオブジェクトに使われている種類のクラス" +"の、以前の名称です。\n" +"古いバージョンの Python では、:attr:`~object.__slots__`、デスクリプタ、プロパ" +"ティ、:meth:`~object.__getattribute__`、クラスメソッド、静的メソッドといっ" +"た、Python の新しく多様な機能を使えるのは新スタイルクラスだけでした。" -#: ../../glossary.rst:1149 msgid "non-deterministic" -msgstr "" +msgstr "non-deterministic" -#: ../../glossary.rst:1151 msgid "" "Behavior where the outcome of a program can vary between executions with the " "same inputs. In multi-threaded programs, non-deterministic behavior often " @@ -2434,6 +2758,12 @@ msgid "" "using :term:`locks ` and other :term:`synchronization primitives " "` helps ensure deterministic behavior." msgstr "" +"(非決定的) 同じ入力でも、実行ごとにプログラムの結果が変わり得る動作です。\n" +"マルチスレッドプログラムでは、スレッドの相対的なタイミングや実行の入り交じり" +"方が結果に影響する :term:`競合状態 ` が原因で、非決定的な動作" +"になることがよくあります。\n" +":term:`ロック ` やその他の :term:`同期プリミティブ ` による適切な同期は、決定的な動作の保証に役立ちます。" #: ../../glossary.rst:1158 msgid "object" @@ -2448,11 +2778,9 @@ msgstr "" "データ。もしくは、全ての :term:`新スタイルクラス ` の究極の" "基底クラスのこと。" -#: ../../glossary.rst:1163 msgid "optimized scope" -msgstr "" +msgstr "optimized scope" -#: ../../glossary.rst:1165 msgid "" "A scope where target local variable names are reliably known to the compiler " "when the code is compiled, allowing optimization of read and write access to " @@ -2462,49 +2790,58 @@ msgid "" "relying on a known set of local and nonlocal variable names are restricted " "to optimized scopes." msgstr "" +"(最適化されたスコープ) コードのコンパイル時に、対象となるローカル変数名をコン" +"パイラが確実に把握できるスコープです。\n" +"これにより、その名前への読み書きを最適化できます。\n" +"関数、ジェネレータ、コルーチン、内包表記、ジェネレータ式のローカル名前空間" +"は、この方法で最適化されます。\n" +"注意: インタープリタの最適化の大部分は、すべてのスコープに適用されます。\n" +"最適化されたスコープだけに適用されるのは、ローカル変数名と非ローカル変数名の" +"集合が既知であることに依存する最適化だけです。" -#: ../../glossary.rst:1172 msgid "optional module" -msgstr "" +msgstr "optional module" -#: ../../glossary.rst:1174 msgid "" "An :term:`extension module` that is part of the :term:`standard library`, " "but may be absent in some builds of :term:`CPython`, usually due to missing " "third-party libraries or because the module is not available for a given " "platform." msgstr "" +"(オプションモジュール) :term:`標準ライブラリ ` の一部であ" +"る :term:`拡張モジュール ` のうち、一部の :term:`CPython` " +"ビルドでは含まれないことがあるものです。\n" +"通常は、サードパーティライブラリが不足しているか、そのプラットフォームでモ" +"ジュールを利用できないことが理由です。" -#: ../../glossary.rst:1179 msgid "" "See :ref:`optional-module-requirements` for a list of optional modules that " "require third-party libraries." msgstr "" +"サードパーティライブラリを必要とするオプションモジュールの一覧は、:ref:" +"`optional-module-requirements` を参照してください。" #: ../../glossary.rst:1181 msgid "package" msgstr "package" -#: ../../glossary.rst:1183 msgid "" "A Python :term:`module` which can contain submodules or recursively, " "subpackages. Technically, a package is a Python module with a ``__path__`` " "attribute." msgstr "" -"(パッケージ) サブモジュールや再帰的にサブパッケージを含むことの出来る :term:" -"`module` のことです。専門的には、パッケージは ``__path__`` 属性を持つ Python " -"オブジェクトです。" +"(パッケージ) サブモジュールや、再帰的にサブパッケージを含むことができる " +"Python の :term:`モジュール ` です。\n" +"厳密には、パッケージは ``__path__`` 属性を持つ Python モジュールです。" #: ../../glossary.rst:1187 msgid "See also :term:`regular package` and :term:`namespace package`." msgstr "" ":term:`regular package` と :term:`namespace package` を参照してください。" -#: ../../glossary.rst:1188 msgid "parallelism" -msgstr "" +msgstr "parallelism" -#: ../../glossary.rst:1190 msgid "" "Executing multiple operations at the same time (e.g. on multiple CPU " "cores). In Python builds with the :term:`global interpreter lock (GIL) " @@ -2514,6 +2851,14 @@ msgid "" "the GIL. In :term:`free-threaded ` Python, multiple Python " "threads can run Python code simultaneously on different cores." msgstr "" +"(並列性) 複数の操作を(たとえば複数の CPU コアで)同時に実行することです。\n" +":term:`グローバルインタープリタロック(GIL) ` があ" +"る Python ビルドでは、一度に一つのスレッドだけが Python バイトコードを実行し" +"ます。\n" +"そのため、複数の CPU コアを活用するには通常、複数のプロセス(:mod:" +"`multiprocessing` など)や、GIL を解放するネイティブ拡張を使います。\n" +":term:`フリースレッドの ` Python では、複数の Python スレッド" +"が異なるコアで Python コードを同時に実行できます。" #: ../../glossary.rst:1198 msgid "parameter" @@ -2525,9 +2870,8 @@ msgid "" "an :term:`argument` (or in some cases, arguments) that the function can " "accept. There are five kinds of parameter:" msgstr "" -"(仮引数) 名前付の実体で :term:`関数 ` (や :term:`メソッド " -"` ) の定義において関数が受ける :term:`実引数 ` を指定しま" -"す。仮引数には5種類あります:" +"(仮引数) 名前付の実体で :term:`関数 ` (やメソッド ) の定義において" +"関数が受ける :term:`実引数 ` を指定します。仮引数には5種類あります:" #: ../../glossary.rst:1204 msgid "" @@ -2544,7 +2888,6 @@ msgstr "" msgid "def func(foo, bar=None): ..." msgstr "def func(foo, bar=None): ..." -#: ../../glossary.rst:1213 msgid "" ":dfn:`positional-only`: specifies an argument that can be supplied only by " "position. Positional-only parameters can be defined by including a ``/`` " @@ -2553,7 +2896,7 @@ msgid "" msgstr "" ":dfn:`位置専用`: 位置によってのみ与えられる引数を指定します。位置専用の引数は" "関数定義の引数のリストの中でそれらの後ろに ``/`` を含めることで定義できます。" -"例えば下記の *posonly1* と *posonly2* は位置専用引数になります:: " +"例えば下記の *posonly1* と *posonly2* は位置専用引数になります::" #: ../../glossary.rst:1218 msgid "def func(posonly1, posonly2, /, positional_or_keyword): ..." @@ -2572,9 +2915,8 @@ msgstr "" "ように、関数定義の仮引数リストに含めた可変長位置引数または裸の ``*`` の後で" "す::" -#: ../../glossary.rst:1228 msgid "def func(arg, *, kw_only1, kw_only2): ..." -msgstr "" +msgstr "def func(arg, *, kw_only1, kw_only2): ..." #: ../../glossary.rst:1230 msgid "" @@ -2588,9 +2930,8 @@ msgstr "" "個数の位置引数が与えられることを指定します。このような仮引数は、以下の " "*args* のように仮引数名の前に ``*`` をつけることで定義できます::" -#: ../../glossary.rst:1236 msgid "def func(*args, **kwargs): ..." -msgstr "" +msgstr "def func(*args, **kwargs): ..." #: ../../glossary.rst:1238 msgid "" @@ -2612,22 +2953,19 @@ msgstr "" "仮引数はオプションと必須の引数のどちらも指定でき、オプションの引数にはデフォ" "ルト値も指定できます。" -#: ../../glossary.rst:1247 msgid "" "See also the :term:`argument` glossary entry, the FAQ question on :ref:`the " "difference between arguments and parameters `, " "the :class:`inspect.Parameter` class, the :ref:`function` section, and :pep:" "`362`." msgstr "" -":term:`仮引数 ` 、FAQ の :ref:`実引数と仮引数の違いは何ですか? " -"` 、:class:`inspect.Parameter` クラス、 :ref:" -"`function` セクション、:pep:`362` を参照してください。" +"用語集の :term:`実引数 ` の項目、FAQ の :ref:`実引数と仮引数の違い" +"は何ですか? `、:class:`inspect.Parameter` クラ" +"ス、:ref:`function` の節、および :pep:`362` も参照してください。" -#: ../../glossary.rst:1251 msgid "per-object lock" -msgstr "" +msgstr "per-object lock" -#: ../../glossary.rst:1253 msgid "" "A :term:`lock` associated with an individual object instance rather than a " "global lock shared across all objects. In :term:`free-threaded ` です。\n" +":term:`フリースレッドの ` Python では、:class:`dict` や :" +"class:`list` などの組み込み型はオブジェクトごとのロックを使い、同じオブジェク" +"トへの操作を直列化しながら、異なるオブジェクトへの操作を並行して実行できるよ" +"うにします。\n" +"オブジェクトごとのロックを保持する操作は、同じオブジェクトをロックするほかの" +"操作の進行を妨げますが、:term:`ロックフリーな ` 操作はブロックしま" +"せん。" #: ../../glossary.rst:1261 msgid "path entry" @@ -2676,24 +3024,25 @@ msgstr "" msgid "path entry hook" msgstr "path entry hook" -#: ../../glossary.rst:1275 msgid "" "A callable on the :data:`sys.path_hooks` list which returns a :term:`path " "entry finder` if it knows how to find modules on a specific :term:`path " "entry`." msgstr "" +":data:`sys.path_hooks` リスト内の呼び出し可能オブジェクトで、特定の :term:`パ" +"スエントリ ` 上でモジュールを見つける方法を知っている場合に、:" +"term:`パスエントリファインダ ` を返すものです。" #: ../../glossary.rst:1278 msgid "path based finder" msgstr "path based finder" -#: ../../glossary.rst:1280 msgid "" "One of the default :term:`meta path finders ` which " "searches an :term:`import path` for modules." msgstr "" -"デフォルトの :term:`meta path finder` の1つは、モジュールの :term:`import " -"path` を検索します。" +"モジュールを探すために :term:`インポートパス ` を検索する、デ" +"フォルトの :term:`メタパスファインダ ` の一つです。" #: ../../glossary.rst:1282 msgid "path-like object" @@ -2736,7 +3085,6 @@ msgstr "" "PEP は、機能についての簡潔な技術的仕様と提案する機能の論拠 (理論) を伝えるべ" "きです。" -#: ../../glossary.rst:1300 msgid "" "PEPs are intended to be the primary mechanisms for proposing major new " "features, for collecting community input on an issue, and for documenting " @@ -2744,10 +3092,11 @@ msgid "" "responsible for building consensus within the community and documenting " "dissenting opinions." msgstr "" -"PEP は、新機能の提案にかかる、コミュニティによる問題提起の集積と Python にな" -"される設計決断の文書化のための最上位の機構となることを意図しています。PEP の" -"著者にはコミュニティ内の合意形成を行うこと、反対意見を文書化することの責務が" -"あります。" +"PEP は、主要な新機能を提案し、ある問題に対するコミュニティの意見を集め、" +"Python に採用された設計上の決定を文書化するための、主要な仕組みとなることを意" +"図しています。\n" +"PEP の著者には、コミュニティ内で合意を形成し、反対意見を文書化する責任があり" +"ます。" #: ../../glossary.rst:1306 msgid "See :pep:`1`." @@ -2790,14 +3139,14 @@ msgstr "" "ものではありません -- これは API を組み込む前には見落とされていた重大な欠陥が" "露呈したときにのみ行われます。" -#: ../../glossary.rst:1325 msgid "" "Even for provisional APIs, backwards incompatible changes are seen as a " "\"solution of last resort\" - every attempt will still be made to find a " "backwards compatible resolution to any identified problems." msgstr "" -"暫定 API についても、後方互換性のない変更は「最終手段」とみなされています。問" -"題点が判明した場合でも後方互換な解決策を探すべきです。" +"暫定 API であっても、後方互換性のない変更は「最終手段」とみなされます。\n" +"特定された問題に対しては、引き続き、後方互換性のある解決策を見つけるためにあ" +"らゆる努力を行います。" #: ../../glossary.rst:1329 msgid "" @@ -2849,21 +3198,23 @@ msgstr "" "くの言語にはこの仕組みはないので、Python に慣れていない人は代わりに数値のカウ" "ンターを使うかもしれません::" -#: ../../glossary.rst:1349 msgid "" "for i in range(len(food)):\n" " print(food[i])" msgstr "" +"for i in range(len(food)):\n" +" print(food[i])" #: ../../glossary.rst:1352 msgid "As opposed to the cleaner, Pythonic method::" msgstr "これに対し、きれいな Pythonic な方法は::" -#: ../../glossary.rst:1354 msgid "" "for piece in food:\n" " print(piece)" msgstr "" +"for piece in food:\n" +" print(piece)" #: ../../glossary.rst:1356 msgid "qualified name" @@ -2881,7 +3232,6 @@ msgstr "" "されています。トップレベルの関数やクラスでは、修飾名はオブジェクトの名前と同" "じです::" -#: ../../glossary.rst:1363 msgid "" ">>> class C:\n" "... class D:\n" @@ -2895,6 +3245,17 @@ msgid "" ">>> C.D.meth.__qualname__\n" "'C.D.meth'" msgstr "" +">>> class C:\n" +"... class D:\n" +"... def meth(self):\n" +"... pass\n" +"...\n" +">>> C.__qualname__\n" +"'C'\n" +">>> C.D.__qualname__\n" +"'C.D'\n" +">>> C.D.meth.__qualname__\n" +"'C.D.meth'" #: ../../glossary.rst:1375 msgid "" @@ -2906,18 +3267,18 @@ msgstr "" "の親パッケージを含む全体のドット名表記、例えば ``email.mime.text`` を意味しま" "す::" -#: ../../glossary.rst:1379 msgid "" ">>> import email.mime.text\n" ">>> email.mime.text.__name__\n" "'email.mime.text'" msgstr "" +">>> import email.mime.text\n" +">>> email.mime.text.__name__\n" +"'email.mime.text'" -#: ../../glossary.rst:1382 msgid "race condition" -msgstr "" +msgstr "race condition" -#: ../../glossary.rst:1384 msgid "" "A condition of a program where the behavior depends on the relative timing " "or ordering of events, particularly in multi-threaded programs. Race " @@ -2928,6 +3289,16 @@ msgid "" "threaded code. Using :term:`locks ` and other :term:`synchronization " "primitives ` helps prevent race conditions." msgstr "" +"(競合状態) 特にマルチスレッドプログラムにおいて、イベントの相対的なタイミング" +"や順序によって動作が変わる、プログラムの状態です。\n" +"競合状態は、:term:`非決定的な ` 動作や、再現が難しいバグに" +"つながることがあります。\n" +":term:`データ競合 ` は、共有メモリへの同期されていないアクセスが関" +"わる、競合状態の一種です。\n" +":term:`LBYL` コーディングスタイルは、マルチスレッドコードで特に競合状態が起こ" +"りやすいものです。\n" +":term:`ロック ` やその他の :term:`同期プリミティブ ` を使うと、競合状態を防ぐのに役立ちます。" #: ../../glossary.rst:1394 msgid "reference count" @@ -2950,12 +3321,15 @@ msgstr "" "の重要な要素です。プログラマーは、 任意のオブジェクトの参照カウントを知るため" "に :func:`sys.getrefcount` 関数を呼び出すことが出来ます。" -#: ../../glossary.rst:1405 msgid "" "In :term:`CPython`, reference counts are not considered to be stable or well-" "defined values; the number of references to an object, and how that number " "is affected by Python code, may be different between versions." msgstr "" +":term:`CPython` では、参照カウントは安定した値や明確に定義された値とはみなさ" +"れません。\n" +"オブジェクトへの参照の数や、Python コードがその数に与える影響は、バージョンに" +"よって異なる場合があります。" #: ../../glossary.rst:1409 msgid "regular package" @@ -2973,18 +3347,18 @@ msgstr "" msgid "See also :term:`namespace package`." msgstr ":term:`namespace package` を参照してください。" -#: ../../glossary.rst:1415 msgid "reentrant" -msgstr "" +msgstr "reentrant" -#: ../../glossary.rst:1417 msgid "" "A property of a function or :term:`lock` that allows it to be called or " "acquired multiple times by the same thread without causing errors or a :term:" "`deadlock`." msgstr "" +"(再入可能) 同じスレッドが複数回呼び出したり取得したりしても、エラーや :term:`" +"デッドロック ` を引き起こさない、関数や :term:`ロック ` の性" +"質です。" -#: ../../glossary.rst:1421 msgid "" "For functions, reentrancy means the function can be safely called again " "before a previous invocation has completed, which is important when " @@ -2992,18 +3366,29 @@ msgid "" "functions may be :term:`non-deterministic` if they're called reentrantly in " "a multithreaded program." msgstr "" +"関数の再入可能性は、前の呼び出しが完了する前に、安全にもう一度呼び出せること" +"を意味します。\n" +"関数が再帰的に、またはシグナルハンドラから呼び出される可能性がある場合に重要" +"です。\n" +"スレッドセーフでない関数は、マルチスレッドプログラムで再入的に呼び出すと、:" +"term:`非決定的 ` になる場合があります。" -#: ../../glossary.rst:1427 msgid "" "For locks, Python's :class:`threading.RLock` (reentrant lock) is reentrant, " "meaning a thread that already holds the lock can acquire it again without " "blocking. In contrast, :class:`threading.Lock` is not reentrant - " "attempting to acquire it twice from the same thread will cause a deadlock." msgstr "" +"ロックでは、Python の :class:`threading.RLock`(再入可能なロック)が再入可能" +"です。\n" +"これは、すでにロックを保持しているスレッドが、ブロックせずにもう一度そのロッ" +"クを取得できることを意味します。\n" +"一方、:class:`threading.Lock` は再入可能ではなく、同じスレッドから二度取得し" +"ようとすると、デッドロックになります。" -#: ../../glossary.rst:1433 msgid "See also :term:`lock` and :term:`deadlock`." msgstr "" +":term:`ロック ` と :term:`デッドロック ` も参照してください。" #: ../../glossary.rst:1434 msgid "REPL" @@ -3039,7 +3424,6 @@ msgstr "" msgid "sequence" msgstr "sequence" -#: ../../glossary.rst:1447 msgid "" "An :term:`iterable` which supports efficient element access using integer " "indices via the :meth:`~object.__getitem__` special method and defines a :" @@ -3050,8 +3434,15 @@ msgid "" "sequence because the lookups use arbitrary :term:`hashable` keys rather than " "integers." msgstr "" +"(シーケンス) 整数インデックスを使った効率的な要素アクセスを :meth:`~object." +"__getitem__` 特殊メソッドでサポートし、シーケンスの長さを返す :meth:`~object." +"__len__` メソッドを定義する :term:`イテラブル ` です。\n" +"組み込みのシーケンス型には、:class:`list`、:class:`str`、:class:`tuple`、:" +"class:`bytes` などがあります。\n" +":class:`dict` も :meth:`~object.__getitem__` と :meth:`!__len__` をサポートし" +"ますが、検索には整数ではなく任意の :term:`ハッシュ可能な ` キーを使" +"うため、シーケンスではなくマッピングとみなされます。" -#: ../../glossary.rst:1456 msgid "" "The :class:`collections.abc.Sequence` abstract base class defines a much " "richer interface that goes beyond just :meth:`~object.__getitem__` and :meth:" @@ -3061,68 +3452,83 @@ msgid "" "`~abc.ABCMeta.register`. For more documentation on sequence methods " "generally, see :ref:`Common Sequence Operations `." msgstr "" +":class:`collections.abc.Sequence` 抽象基底クラスは、:meth:`~object." +"__getitem__` と :meth:`~object.__len__` に加え、:meth:`~sequence.count`、:" +"meth:`~sequence.index`、:meth:`~object.__contains__`、:meth:`~object." +"__reversed__` を含む、さらに豊富なインターフェースを定義します。\n" +"この拡張されたインターフェースを実装する型は、:func:`~abc.ABCMeta.register` " +"で明示的に登録できます。\n" +"シーケンスのメソッド全般について詳しくは、:ref:`共通のシーケンス演算 " +"` を参照してください。" -#: ../../glossary.rst:1466 msgid "set comprehension" -msgstr "" +msgstr "set comprehension" -#: ../../glossary.rst:1468 msgid "" "A compact way to process all or part of the elements in an iterable and " "return a set with the results. ``results = {c for c in 'abracadabra' if c " "not in 'abc'}`` generates the set of strings ``{'r', 'd'}``. See :ref:" "`comprehensions`." msgstr "" -"(集合内包表記) iterable 内の全てあるいは一部の要素を処理して、その結果からな" -"る集合を返すコンパクトな書き方です。 ``results = {c for c in 'abracadabra' " -"if c not in 'abc'}`` とすると、``{'r', 'd'}`` という文字列の辞書を生成しま" -"す。 :ref:`comprehensions` を参照してください。" +"(集合内包表記) イテラブルのすべて、または一部の要素を処理し、その結果からなる" +"集合を返す簡潔な書き方です。\n" +"``results = {c for c in 'abracadabra' if c not in 'abc'}`` は、文字列の集合 " +"``{'r', 'd'}`` を生成します。\n" +":ref:`comprehensions` を参照してください。" #: ../../glossary.rst:1472 msgid "single dispatch" msgstr "single dispatch" -#: ../../glossary.rst:1474 msgid "" "A form of :term:`generic function` dispatch where the implementation is " "chosen based on the type of a single argument." msgstr "" -":term:`generic function` の一種で実装は一つの引数の型により選択されます。" +"(単一ディスパッチ) :term:`ジェネリック関数 ` のディスパッチ" +"の一形態で、一つの引数の型に基づいて実装を選びます。" #: ../../glossary.rst:1476 msgid "slice" msgstr "slice" -#: ../../glossary.rst:1478 msgid "" "An object of type :class:`slice`, used to describe a portion of a :term:" "`sequence`. A slice object is created when using the :ref:`slicing " "` form of :ref:`subscript notation `, with colons " "inside square brackets, such as in ``variable_name[1:3:5]``." msgstr "" +"(スライス) :term:`シーケンス ` の一部を表すために使う、:class:" +"`slice` 型のオブジェクトです。\n" +"``variable_name[1:3:5]`` のように、角括弧内にコロンを含む :ref:`添字表記 " +"` の :ref:`スライス形式 ` を使うと、スライスオブジェ" +"クトが作成されます。" -#: ../../glossary.rst:1483 msgid "soft deprecated" -msgstr "" +msgstr "soft deprecated" -#: ../../glossary.rst:1485 msgid "" "A soft deprecated API should not be used in new code, but it is safe for " "already existing code to use it. The API remains documented and tested, but " "will not be enhanced further." msgstr "" +"(ソフト非推奨) ソフト非推奨の API は、新しいコードでは使うべきではありません" +"が、既存のコードで使い続けても安全です。\n" +"その API のドキュメントの掲載とテストは続けられますが、それ以上の機能拡張は行" +"われません。" -#: ../../glossary.rst:1489 msgid "" "Soft deprecation, unlike normal deprecation, does not plan on removing the " "API and will not emit warnings." msgstr "" +"通常の非推奨とは異なり、ソフト非推奨では API の削除は予定されておらず、警告も" +"出力されません。" -#: ../../glossary.rst:1492 msgid "" "See `PEP 387: Soft Deprecation `_." msgstr "" +"`PEP 387: Soft Deprecation `_ を参照してください。" #: ../../glossary.rst:1494 msgid "special method" @@ -3140,11 +3546,9 @@ msgstr "" "コア 2 つがついています。特殊メソッドについては :ref:`specialnames` で解説さ" "れています。" -#: ../../glossary.rst:1502 msgid "standard library" -msgstr "" +msgstr "standard library" -#: ../../glossary.rst:1504 msgid "" "The collection of :term:`packages `, :term:`modules ` and :" "term:`extension modules ` distributed as a part of the " @@ -3152,12 +3556,19 @@ msgid "" "may vary based on platform, available system libraries, or other criteria. " "Documentation can be found at :ref:`library-index`." msgstr "" +"(標準ライブラリ) 公式の Python インタープリタパッケージの一部として配布され" +"る、:term:`パッケージ `、:term:`モジュール `、:term:`拡張モ" +"ジュール ` の集まりです。\n" +"具体的に何が含まれるかは、プラットフォーム、利用可能なシステムライブラリ、そ" +"の他の条件によって変わる場合があります。\n" +"ドキュメントは :ref:`library-index` にあります。" -#: ../../glossary.rst:1510 msgid "" "See also :data:`sys.stdlib_module_names` for a list of all possible standard " "library module names." msgstr "" +"標準ライブラリのモジュール名として考えられるものすべての一覧については、:" +"data:`sys.stdlib_module_names` も参照してください。" #: ../../glossary.rst:1512 msgid "statement" @@ -3173,70 +3584,72 @@ msgstr "" "` かキーワードから構成されるもののどちらかです。後者には :" "keyword:`if`、:keyword:`while`、:keyword:`for` があります。" -#: ../../glossary.rst:1517 msgid "static type checker" -msgstr "" +msgstr "static type checker" -#: ../../glossary.rst:1519 msgid "" "An external tool that reads Python code and analyzes it, looking for issues " "such as incorrect types. See also :term:`type hints ` and the :" "mod:`typing` module." msgstr "" +"(静的型チェッカー) Python コードを読み込んで解析し、型の誤りなどの問題を探す" +"外部ツールです。\n" +":term:`型ヒント ` と :mod:`typing` モジュールも参照してください。" -#: ../../glossary.rst:1522 msgid "stdlib" -msgstr "" +msgstr "stdlib" -#: ../../glossary.rst:1524 msgid "An abbreviation of :term:`standard library`." -msgstr "" +msgstr ":term:`標準ライブラリ ` の略です。" -#: ../../glossary.rst:1525 msgid "steal" -msgstr "" +msgstr "steal" -#: ../../glossary.rst:1527 msgid "" "In Python's C API, \"*stealing*\" an argument means that ownership of the " "argument is transferred to the called function. The caller must not use that " "reference after the call. Generally, functions that \"steal\" an argument do " "so even if they fail." msgstr "" +"(参照を盗む) Python の C API で実引数を「*盗む*」とは、実引数の所有権が呼び出" +"された関数に移ることを意味します。\n" +"呼び出し元は、呼び出し後にその参照を使ってはなりません。\n" +"一般に、実引数を「盗む」関数は、失敗した場合でも所有権を受け取ります。" -#: ../../glossary.rst:1532 msgid "See :ref:`api-refcountdetails` for a full explanation." -msgstr "" +msgstr "詳しい説明は、:ref:`api-refcountdetails` を参照してください。" -#: ../../glossary.rst:1533 msgid "strong reference" -msgstr "" +msgstr "strong reference" -#: ../../glossary.rst:1535 msgid "" "In Python's C API, a strong reference is a reference to an object which is " "owned by the code holding the reference. The strong reference is taken by " "calling :c:func:`Py_INCREF` when the reference is created and released with :" "c:func:`Py_DECREF` when the reference is deleted." msgstr "" +"(強参照) Python の C API で、オブジェクトへの参照のうち、それを保持するコード" +"が所有するものです。\n" +"強参照は、参照を作成するときに :c:func:`Py_INCREF` を呼び出すことで取得され、" +"参照を削除するときに :c:func:`Py_DECREF` で解放されます。" -#: ../../glossary.rst:1541 msgid "" "The :c:func:`Py_NewRef` function can be used to create a strong reference to " "an object. Usually, the :c:func:`Py_DECREF` function must be called on the " "strong reference before exiting the scope of the strong reference, to avoid " "leaking one reference." msgstr "" +":c:func:`Py_NewRef` 関数を使うと、オブジェクトへの強参照を作成できます。\n" +"通常は、参照が一つリークするのを避けるために、強参照のスコープを抜ける前に、" +"その強参照に対して :c:func:`Py_DECREF` 関数を呼び出さなければなりません。" -#: ../../glossary.rst:1546 msgid "See also :term:`borrowed reference`." -msgstr "" +msgstr ":term:`借用参照 ` も参照してください。" #: ../../glossary.rst:1547 msgid "subscript" msgstr "添字" -#: ../../glossary.rst:1549 msgid "" "The expression in square brackets of a :ref:`subscription expression " "`, for example, the ``3`` in ``items[3]``. Usually used to " @@ -3244,12 +3657,16 @@ msgid "" "subscripting a :term:`mapping`, or an :term:`index` when subscripting a :" "term:`sequence`." msgstr "" +":ref:`添字式 ` の角括弧内の式です。\n" +"たとえば、``items[3]`` の ``3`` が該当します。\n" +"通常、コンテナの要素を選ぶために使います。\n" +":term:`マッピング ` に添字を指定する場合は :term:`キー `、:" +"term:`シーケンス ` に添字を指定する場合は :term:`インデックス " +"` とも呼ばれます。" -#: ../../glossary.rst:1555 msgid "synchronization primitive" -msgstr "" +msgstr "synchronization primitive" -#: ../../glossary.rst:1557 msgid "" "A basic building block for coordinating (synchronizing) the execution of " "multiple threads to ensure :term:`thread-safe` access to shared resources. " @@ -3262,49 +3679,65 @@ msgid "" "conditions ` and coordinate thread execution. See also :" "term:`lock`." msgstr "" +"(同期プリミティブ) 複数のスレッドの実行を調整(同期)し、共有リソースへの :" +"term:`スレッドセーフな ` アクセスを保証するための基本的な構成要" +"素です。\n" +"Python の :mod:`threading` モジュールは、:class:`~threading.Lock`、:class:" +"`~threading.RLock`、:class:`~threading.Semaphore`、:class:`~threading." +"Condition`、:class:`~threading.Event`、:class:`~threading.Barrier` など、いく" +"つかの同期プリミティブを提供します。\n" +"さらに、:mod:`queue` モジュールは、複数の生産者と複数の消費者をサポートする" +"キューを提供し、マルチスレッドプログラムで特に役立ちます。\n" +"これらのプリミティブは、:term:`競合状態 ` を防いだり、スレッ" +"ドの実行を調整したりするのに役立ちます。\n" +":term:`ロック ` も参照してください。" -#: ../../glossary.rst:1567 msgid "t-string" -msgstr "" +msgstr "t-string" -#: ../../glossary.rst:1568 msgid "t-strings" -msgstr "" +msgstr "t-strings" -#: ../../glossary.rst:1570 msgid "" "String literals prefixed with ``t`` or ``T`` are commonly called \"t-" "strings\" which is short for :ref:`template string literals `." msgstr "" +"``t`` または ``T`` を接頭辞に持つ文字列リテラルは、一般に「t-string」と呼ばれ" +"ます。\n" +"これは :ref:`テンプレート文字列リテラル ` の略です。" #: ../../glossary.rst:1573 msgid "text encoding" msgstr "text encoding" -#: ../../glossary.rst:1575 msgid "" "A string in Python is a sequence of Unicode code points (in range " "``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be " "serialized as a sequence of bytes." msgstr "" +"Python の文字列は、Unicode コードポイントの列(``U+0000``--``U+10FFFF`` の範" +"囲)です。\n" +"文字列を保存または転送するには、バイト列としてシリアライズする必要がありま" +"す。" -#: ../../glossary.rst:1579 msgid "" "Serializing a string into a sequence of bytes is known as \"encoding\", and " "recreating the string from the sequence of bytes is known as \"decoding\"." msgstr "" +"文字列をバイト列にシリアライズすることを「エンコード」、バイト列から文字列を" +"復元することを「デコード」といいます。" -#: ../../glossary.rst:1582 msgid "" "There are a variety of different text serialization :ref:`codecs `, which are collectively referred to as \"text encodings\"." msgstr "" +"文字列をシリアライズするための :ref:`コーデック ` はさま" +"ざまあり、総称して「テキストエンコーディング」と呼ばれます。" #: ../../glossary.rst:1585 msgid "text file" msgstr "text file" -#: ../../glossary.rst:1587 msgid "" "A :term:`file object` able to read and write :class:`str` objects. Often, a " "text file actually accesses a byte-oriented datastream and handles the :term:" @@ -3312,13 +3745,14 @@ msgid "" "text mode (``'r'`` or ``'w'``), :data:`sys.stdin`, :data:`sys.stdout`, and " "instances of :class:`io.StringIO`." msgstr "" -"(テキストファイル) :class:`str` オブジェクトを読み書きできる :term:`file " -"object` です。\n" -"しばしば、テキストファイルは実際にバイト指向のデータストリームにアクセス" -"し、 :term:`テキストエンコーディング ` を自動的に行います。\n" -"テキストファイルの例は、 :data:`sys.stdin`, :data:`sys.stdout`, :class:`io." -"StringIO` インスタンスなどをテキストモード (``'r'`` or ``'w'``) で開いたファ" -"イルです。" +"(テキストファイル) :class:`str` オブジェクトを読み書きできる :term:`ファイル" +"オブジェクト ` です。\n" +"テキストファイルは、多くの場合、実際にはバイト指向のデータストリームにアクセ" +"スし、:term:`テキストエンコーディング ` を自動的に処理しま" +"す。\n" +"例として、テキストモード(``'r'`` または ``'w'``)で開いたファイル、:data:" +"`sys.stdin`、:data:`sys.stdout`、:class:`io.StringIO` のインスタンスがありま" +"す。" #: ../../glossary.rst:1594 msgid "" @@ -3329,32 +3763,40 @@ msgstr "" "オブジェクトについては、 :term:`バイナリファイル ` も参照してく" "ださい。" -#: ../../glossary.rst:1596 msgid "thread state" -msgstr "" +msgstr "thread state" -#: ../../glossary.rst:1599 msgid "" "The information used by the :term:`CPython` runtime to run in an OS thread. " "For example, this includes the current exception, if any, and the state of " "the bytecode interpreter." msgstr "" +"(スレッド状態) :term:`CPython` ランタイムが OS スレッド内で実行するために使う" +"情報です。\n" +"たとえば、現在の例外(あれば)や、バイトコードインタープリタの状態が含まれま" +"す。" -#: ../../glossary.rst:1603 msgid "" "Each thread state is bound to a single OS thread, but threads may have many " "thread states available. At most, one of them may be :term:`attached " "` at once." msgstr "" +"各スレッド状態は、一つの OS スレッドに結び付けられますが、スレッドには複数の" +"スレッド状態が用意されている場合があります。\n" +"一度に :term:`アタッチされる ` のは、そのうち最大一つ" +"です。" -#: ../../glossary.rst:1607 msgid "" "An :term:`attached thread state` is required to call most of Python's C API, " "unless a function explicitly documents otherwise. The bytecode interpreter " "only runs under an attached thread state." msgstr "" +"関数のドキュメントに明示的な例外の記載がない限り、Python の C API の大部分を" +"呼び出すには :term:`アタッチされたスレッド状態 ` が必" +"要です。\n" +"バイトコードインタープリタは、スレッド状態がアタッチされている場合だけ動作し" +"ます。" -#: ../../glossary.rst:1611 msgid "" "Each thread state belongs to a single interpreter, but each interpreter may " "have many thread states, including multiple for the same OS thread. Thread " @@ -3362,18 +3804,23 @@ msgid "" "one can be :term:`attached ` in that thread at any " "given moment." msgstr "" +"各スレッド状態は一つのインタープリタに属しますが、各インタープリタは、同じ " +"OS スレッドに対応する複数の状態も含めて、多数のスレッド状態を持つことができま" +"す。\n" +"複数のインタープリタのスレッド状態を同じスレッドに結び付けられますが、ある時" +"点でそのスレッドに :term:`アタッチできる ` のは一つだ" +"けです。" -#: ../../glossary.rst:1617 msgid "" "See :ref:`Thread State and the Global Interpreter Lock ` for more " "information." msgstr "" +"詳しくは、:ref:`スレッド状態とグローバルインタープリタロック ` を参" +"照してください。" -#: ../../glossary.rst:1619 msgid "thread-safe" -msgstr "" +msgstr "thread-safe" -#: ../../glossary.rst:1621 msgid "" "A module, function, or class that behaves correctly when used by multiple " "threads concurrently. Thread-safe code uses appropriate :term:" @@ -3386,29 +3833,43 @@ msgid "" "experience :term:`race conditions ` and :term:`data races " "` when used in multi-threaded programs." msgstr "" +"(スレッドセーフ) 複数のスレッドから並行して使っても正しく動作するモジュール、" +"関数、クラスです。\n" +"スレッドセーフなコードは、:term:`ロック ` のような適切な :term:`同期プ" +"リミティブ ` を使って共有される可変状態を保護する" +"か、共有される可変状態をまったく持たないように設計されています。\n" +":term:`フリースレッドの ` ビルドでは、:class:`dict`、:class:" +"`list`、:class:`set` のような組み込み型は、内部でロックを使って多くの操作をス" +"レッドセーフにしていますが、スレッドセーフであることが必ずしも保証されている" +"わけではありません。\n" +"スレッドセーフでないコードをマルチスレッドプログラムで使うと、:term:`競合状" +"態 ` や :term:`データ競合 ` が発生することがありま" +"す。" #: ../../glossary.rst:1632 msgid "token" msgstr "トークン" -#: ../../glossary.rst:1635 msgid "" "A small unit of source code, generated by the :ref:`lexical analyzer " "` (also called the *tokenizer*). Names, numbers, strings, " "operators, newlines and similar are represented by tokens." msgstr "" +":ref:`字句解析器 ` (*トークナイザ* とも呼ばれます)が生成する、ソー" +"スコードの小さな単位です。\n" +"名前、数値、文字列、演算子、改行などは、トークンで表されます。" -#: ../../glossary.rst:1640 msgid "" "The :mod:`tokenize` module exposes Python's lexical analyzer. The :mod:" "`token` module contains information on the various types of tokens." msgstr "" +":mod:`tokenize` モジュールは、Python の字句解析器を公開します。\n" +":mod:`token` モジュールは、さまざまな種類のトークンについての情報を含みます。" #: ../../glossary.rst:1643 msgid "triple-quoted string" msgstr "triple-quoted string" -#: ../../glossary.rst:1645 msgid "" "A string which is bound by three instances of either a quotation mark (\") " "or an apostrophe ('). While they don't provide any functionality not " @@ -3418,22 +3879,28 @@ msgid "" "continuation character, making them especially useful when writing " "docstrings." msgstr "" -"(三重クォート文字列) 3つの連続したクォート記号(\")かアポストロフィー(')で囲ま" -"れた文字列。通常の(一重)クォート文字列に比べて表現できる文字列に違いはありま" -"せんが、幾つかの理由で有用です。1つか2つの連続したクォート記号をエスケープ無" -"しに書くことができますし、行継続文字(\\\\)を使わなくても複数行にまたがること" -"ができるので、ドキュメンテーション文字列を書く時に特に便利です。" +"(三重クォート文字列) クォート記号(\")またはアポストロフィー(')を三つ並べ" +"て囲んだ文字列です。\n" +"一重クォート文字列にない機能を提供するわけではありませんが、いくつかの理由で" +"便利です。\n" +"文字列の中にシングルクォートやダブルクォートをエスケープせずに含めることがで" +"き、行継続文字を使わずに複数行にまたがることもできるため、ドキュメンテーショ" +"ン文字列を書く際に特に役立ちます。" #: ../../glossary.rst:1652 msgid "type" msgstr "type" -#: ../../glossary.rst:1654 msgid "" "The type of a Python object determines what kind of object it is; every " "object has a type. An object's type is accessible as its :attr:`~object." "__class__` attribute or can be retrieved with ``type(obj)``." msgstr "" +"(型) Python オブジェクトの型は、それがどのような種類のオブジェクトかを決めま" +"す。\n" +"すべてのオブジェクトには型があります。\n" +"オブジェクトの型には :attr:`~object.__class__` 属性としてアクセスでき、" +"``type(obj)`` でも取得できます。" #: ../../glossary.rst:1658 msgid "type alias" @@ -3451,24 +3918,29 @@ msgstr "" "型エイリアスは :term:`型ヒント ` を単純化するのに有用です。例え" "ば::" -#: ../../glossary.rst:1665 msgid "" "def remove_gray_shades(\n" " colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" " pass" msgstr "" +"def remove_gray_shades(\n" +" colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:\n" +" pass" #: ../../glossary.rst:1669 msgid "could be made more readable like this::" msgstr "これは次のようにより読みやすくできます::" -#: ../../glossary.rst:1671 msgid "" "Color = tuple[int, int, int]\n" "\n" "def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" " pass" msgstr "" +"Color = tuple[int, int, int]\n" +"\n" +"def remove_gray_shades(colors: list[Color]) -> list[Color]:\n" +" pass" #: ../../glossary.rst:1676 ../../glossary.rst:1690 msgid "See :mod:`typing` and :pep:`484`, which describe this functionality." @@ -3486,12 +3958,14 @@ msgstr "" "(型ヒント) 変数、クラス属性、関数のパラメータや返り値の期待される型を指定す" "る :term:`annotation` です。" -#: ../../glossary.rst:1682 msgid "" "Type hints are optional and are not enforced by Python but they are useful " "to :term:`static type checkers `. They can also aid " "IDEs with code completion and refactoring." msgstr "" +"型ヒントは省略可能で、Python によって強制されませんが、:term:`静的型チェッ" +"カー ` に役立ちます。\n" +"IDE によるコード補完やリファクタリングにも役立ちます。" #: ../../glossary.rst:1686 msgid "" @@ -3531,11 +4005,12 @@ msgid "" "When annotating a variable or a class attribute, assignment is optional::" msgstr "変数あるいはクラス属性に注釈を付けたときは、代入部分は任意です::" -#: ../../glossary.rst:1704 msgid "" "class C:\n" " field: 'annotation'" msgstr "" +"class C:\n" +" field: 'annotation'" #: ../../glossary.rst:1707 msgid "" @@ -3545,9 +4020,8 @@ msgstr "" "変数アノテーションは通常は :term:`型ヒント` のために使われます: 例" "えば、この変数は :class:`int` の値を取ることを期待されています::" -#: ../../glossary.rst:1711 msgid "count: int = 0" -msgstr "" +msgstr "count: int = 0" #: ../../glossary.rst:1713 msgid "Variable annotation syntax is explained in section :ref:`annassign`." @@ -3596,16 +4070,17 @@ msgstr "" "シンは、バイトコードコンパイラが出力した :term:`バイトコード ` を実" "行します。" -#: ../../glossary.rst:1731 msgid "walrus operator" -msgstr "" +msgstr "walrus operator" -#: ../../glossary.rst:1733 msgid "" "A light-hearted way to refer to the :ref:`assignment expression ` operator ``:=`` because it looks a bit like a walrus if you " "turn your head." msgstr "" +"(セイウチ演算子) :ref:`代入式 ` の演算子 ``:=`` を指" +"すユーモラスな呼び方です。\n" +"頭を傾けると、少しセイウチに似て見えることに由来します。" #: ../../glossary.rst:1736 msgid "Zen of Python" @@ -3629,17 +4104,14 @@ msgstr "..." msgid "ellipsis literal" msgstr "ellipsisリテラル" -#: ../../glossary.rst:349 msgid "C-contiguous" -msgstr "" +msgstr "C-contiguous" -#: ../../glossary.rst:349 msgid "Fortran contiguous" -msgstr "" +msgstr "Fortran contiguous" -#: ../../glossary.rst:1010 msgid "magic" -msgstr "" +msgstr "magic" #: ../../glossary.rst:1496 msgid "special" diff --git a/howto/a-conceptual-overview-of-asyncio.po b/howto/a-conceptual-overview-of-asyncio.po index f5d8e58ee..e8bab6b00 100644 --- a/howto/a-conceptual-overview-of-asyncio.po +++ b/howto/a-conceptual-overview-of-asyncio.po @@ -16,82 +16,91 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:5 msgid "A conceptual overview of :mod:`!asyncio`" -msgstr "" +msgstr ":mod:`!asyncio` の概念を理解する" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:7 msgid "" "This :ref:`HOWTO ` article seeks to help you build a sturdy mental " "model of how :mod:`asyncio` fundamentally works, helping you understand the " "how and why behind the recommended patterns." msgstr "" +"この :ref:`HOWTO ` では、:mod:`asyncio` の基本的な仕組みをしっかり理" +"解できるように説明します。\n" +"推奨される書き方がどのように動き、なぜ推奨されるのかを理解する助けになるで" +"しょう。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:11 msgid "" "You might be curious about some key :mod:`!asyncio` concepts. By the end of " "this article, you'll be able to comfortably answer these questions:" msgstr "" +":mod:`!asyncio` の主要な概念について、疑問を持っているかもしれません。\n" +"この記事を読み終えるころには、次の問いに無理なく答えられるようになるでしょ" +"う。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:14 msgid "What's happening behind the scenes when an object is awaited?" -msgstr "" +msgstr "オブジェクトを await すると、その裏側では何が起きるのでしょうか?" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:15 msgid "" "How does :mod:`!asyncio` differentiate between a task which doesn't need CPU " "time (such as a network request or file read) as opposed to a task that does " "(such as computing n-factorial)?" msgstr "" +":mod:`!asyncio` は、ネットワーク要求やファイルの読み取りのように CPU 時間を必" +"要としないタスクと、n の階乗を計算するように CPU 時間が必要なタスクを、どのよ" +"うに区別するのでしょうか?" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:18 msgid "" "How to write an asynchronous variant of an operation, such as an async sleep " "or database request." msgstr "" +"非同期のスリープやデータベースへの要求など、ある操作の非同期版はどのように書" +"けばよいのでしょうか?" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:23 msgid "" "The `guide `_ that inspired this HOWTO article, by Alexander Nordin." msgstr "" +"この HOWTO のもとになった、Alexander Nordin による `ガイド `_。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:25 msgid "" "This in-depth `YouTube tutorial series `_ on ``asyncio`` " "created by Python core team member, Łukasz Langa." msgstr "" +"Python コアチームのメンバー Łukasz Langa による、``asyncio`` の詳しい " +"`YouTube チュートリアルシリーズ `_。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:28 msgid "" "`500 Lines or Less: A Web Crawler With asyncio Coroutines `_ by A. Jesse Jiryu " "Davis and Guido van Rossum." msgstr "" +"A. Jesse Jiryu Davis と Guido van Rossum による `500 Lines or Less: A Web " +"Crawler With asyncio Coroutines `_。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:34 msgid "A conceptual overview part 1: the high-level" -msgstr "" +msgstr "概念の説明、第 1 部: 全体像" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:36 msgid "" "In part 1, we'll cover the main, high-level building blocks of :mod:`!" "asyncio`: the event loop, coroutine functions, coroutine objects, tasks, and " "``await``." msgstr "" +"第 1 部では、:mod:`!asyncio` の主要な高水準の構成要素であるイベントループ、コ" +"ルーチン関数、コルーチンオブジェクト、タスク、``await`` を取り上げます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:41 msgid "Event loop" -msgstr "" +msgstr "イベントループ" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:43 msgid "" "Everything in :mod:`!asyncio` happens relative to the event loop. It's the " "star of the show, but prefers to work behind the scenes, managing and " @@ -99,8 +108,13 @@ msgid "" "explicitly granted to it, but a lot of its ability to get things done comes " "from the respect and cooperation of its band members." msgstr "" +":mod:`!asyncio` では、すべてがイベントループを中心に動きます。\n" +"イベントループは主役ですが、表に立つよりも裏方としてリソースを管理し、調整す" +"る役割を担います。\n" +"オーケストラの指揮者のようなものです。\n" +"明示的に与えられた権限もありますが、仕事を進める力の多くは、楽団員が指示に従" +"い協力することから生まれます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:50 msgid "" "In more technical terms, the event loop contains a collection of jobs to be " "run. Some jobs are added directly by you, and some indirectly by :mod:`!" @@ -116,15 +130,32 @@ msgid "" "there's more work to be done, such as when I/O operations complete or timers " "expire." msgstr "" +"もう少し技術的にいうと、イベントループは実行すべきジョブの集合を持っていま" +"す。\n" +"ジョブには、自分で直接追加するものも、:mod:`!asyncio` が間接的に追加するもの" +"もあります。\n" +"イベントループは待機中のジョブを 1 つ選び、関数を呼び出すのと同じように起動し" +"ます (つまり「制御を渡します」)。\n" +"ジョブは実行を始め、中断または完了するとイベントループに制御を戻します。\n" +"するとイベントループは別のジョブを選んで起動します。\n" +"このジョブの集合は、*おおまかには* キューと考えられます。\n" +"ジョブは追加された後、通常は順番に (ただし、常にそうとは限りません) 1 つずつ" +"処理されます。\n" +"イベントループはこの処理を繰り返し続けます。\n" +"実行待ちのジョブがなくなると、CPU 時間を無駄にしないよう休止します。\n" +"I/O 操作の完了やタイマーの期限到来などによって新たな仕事ができると、また動き" +"始めます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:64 msgid "" "Effective execution relies on jobs sharing well and cooperating; a greedy " "job could hog control and leave the other jobs to starve, rendering the " "overall event loop approach rather useless." msgstr "" +"効率よく実行するには、ジョブ同士が処理の機会を分け合い、協力する必要がありま" +"す。\n" +"欲張りなジョブが制御を独占すると、ほかのジョブが実行できなくなり、イベント" +"ループという仕組み全体がほとんど役に立たなくなってしまいます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:70 msgid "" "import asyncio\n" "\n" @@ -133,16 +164,19 @@ msgid "" "event_loop = asyncio.new_event_loop()\n" "event_loop.run_forever()" msgstr "" +"import asyncio\n" +"\n" +"# イベントループを作り、そのジョブの集合を\n" +"# 繰り返し処理し続ける。\n" +"event_loop = asyncio.new_event_loop()\n" +"event_loop.run_forever()" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:79 msgid "Asynchronous functions and coroutines" -msgstr "" +msgstr "非同期関数とコルーチン" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:81 msgid "This is a basic, boring Python function::" -msgstr "" +msgstr "これはごく普通の Python 関数です。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:83 msgid "" "def hello_printer():\n" " print(\n" @@ -151,26 +185,35 @@ msgid "" " \"partner in crime.\"\n" " )" msgstr "" +"def hello_printer():\n" +" print(\n" +" \"Hi, I am a lowly, simple printer, though I have all I \"\n" +" \"need in life -- \\nfresh paper and my dearly beloved octopus \"\n" +" \"partner in crime.\"\n" +" )" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:90 msgid "Calling a regular function invokes its logic or body::" -msgstr "" +msgstr "通常の関数を呼び出すと、その本体の処理が実行されます。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:92 msgid "" ">>> hello_printer()\n" "Hi, I am a lowly, simple printer, though I have all I need in life --\n" "fresh paper and my dearly beloved octopus partner in crime." msgstr "" +">>> hello_printer()\n" +"Hi, I am a lowly, simple printer, though I have all I need in life --\n" +"fresh paper and my dearly beloved octopus partner in crime." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:96 msgid "" "The :ref:`async def `, as opposed to just a plain ``def``, makes " "this an asynchronous function (or \"coroutine function\"). Calling it " "creates and returns a :ref:`coroutine ` object." msgstr "" +"単なる ``def`` の代わりに :ref:`async def ` を使うと、非同期関数 " +"(「コルーチン関数」) になります。\n" +"これを呼び出すと、:ref:`コルーチン ` オブジェクトが作られて返され" +"ます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:102 msgid "" "async def loudmouth_penguin(magic_number: int):\n" " print(\n" @@ -179,20 +222,27 @@ msgid "" " f\"By the way, my lucky number is: {magic_number}.\"\n" " )" msgstr "" +"async def loudmouth_penguin(magic_number: int):\n" +" print(\n" +" \"I am a super special talking penguin. Far cooler than that printer. " +"\"\n" +" f\"By the way, my lucky number is: {magic_number}.\"\n" +" )" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:108 msgid "" "Calling the async function, ``loudmouth_penguin``, does not execute the " "print statement; instead, it creates a coroutine object::" msgstr "" +"非同期関数 ``loudmouth_penguin`` を呼び出しても、print 文は実行されません。\n" +"代わりに、コルーチンオブジェクトが作られます。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:111 msgid "" ">>> loudmouth_penguin(magic_number=3)\n" "" msgstr "" +">>> loudmouth_penguin(magic_number=3)\n" +"" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:114 msgid "" "The terms \"coroutine function\" and \"coroutine object\" are often " "conflated as coroutine. That can be confusing! In this article, coroutine " @@ -201,8 +251,14 @@ msgid "" "also exist as instances of :class:`collections.abc.Coroutine` -- a " "distinction that matters for type checking." msgstr "" +"「コルーチン関数」と「コルーチンオブジェクト」は、どちらも単にコルーチンと呼" +"ばれることがあり、混乱を招きます。\n" +"この記事では、コルーチンはコルーチンオブジェクト、より正確には :class:`types." +"CoroutineType` のインスタンス (ネイティブコルーチン) を指します。\n" +"コルーチンは :class:`collections.abc.Coroutine` のインスタンスとして存在する" +"こともあります。\n" +"この違いは型チェックで重要になります。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:123 msgid "" "A coroutine represents the function's body or logic. A coroutine has to be " "explicitly started; again, merely creating the coroutine does not start it. " @@ -210,16 +266,22 @@ msgid "" "the function's body. That pausing and resuming ability is what allows for " "asynchronous behavior!" msgstr "" +"コルーチンは関数の本体、つまり処理内容を表します。\n" +"コルーチンは明示的に開始する必要があり、繰り返しになりますが、作成しただけで" +"は実行されません。\n" +"特に重要なのは、関数本体のさまざまな位置で実行を中断し、再開できる点です。\n" +"この中断と再開の能力が、非同期の振る舞いを可能にします。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:130 msgid "" "Coroutines and coroutine functions were built by leveraging the " "functionality of :term:`generators ` and :term:" "`generator functions `. Recall, a generator function is a " "function that :keyword:`yield`\\s, like this one::" msgstr "" +"コルーチンとコルーチン関数は、:term:`ジェネレータ ` と :" +"term:`ジェネレータ関数 ` の機能を活用して作られました。\n" +"ジェネレータ関数とは、次のように :keyword:`yield` を使う関数です。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:136 msgid "" "def get_random_number():\n" " # This would be a bad random number generator!\n" @@ -231,27 +293,41 @@ msgid "" " yield 4\n" " ..." msgstr "" +"def get_random_number():\n" +" # これでは乱数生成器としては役に立たない!\n" +" print(\"Hi\")\n" +" yield 1\n" +" print(\"Hello\")\n" +" yield 7\n" +" print(\"Howdy\")\n" +" yield 4\n" +" ..." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:146 msgid "" "Similar to a coroutine function, calling a generator function does not run " "it. Instead, it creates a generator object::" msgstr "" +"コルーチン関数と同様に、ジェネレータ関数を呼び出しても本体は実行されませ" +"ん。\n" +"代わりに、ジェネレータオブジェクトが作られます。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:149 msgid "" ">>> get_random_number()\n" "" msgstr "" +">>> get_random_number()\n" +"" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:152 msgid "" "You can proceed to the next ``yield`` of a generator by using the built-in " "function :func:`next`. In other words, the generator runs, then pauses. For " "example::" msgstr "" +"組み込み関数 :func:`next` を使うと、ジェネレータを次の ``yield`` まで進められ" +"ます。\n" +"つまり、ジェネレータは実行されてから中断します。\n" +"例えば、次のようになります。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:157 msgid "" ">>> generator = get_random_number()\n" ">>> next(generator)\n" @@ -261,28 +337,40 @@ msgid "" "Hello\n" "7" msgstr "" +">>> generator = get_random_number()\n" +">>> next(generator)\n" +"Hi\n" +"1\n" +">>> next(generator)\n" +"Hello\n" +"7" #: ../../howto/a-conceptual-overview-of-asyncio.rst:167 msgid "Tasks" msgstr "Task" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:169 msgid "" "Roughly speaking, :ref:`tasks ` are coroutines (not " "coroutine functions) tied to an event loop. A task also maintains a list of " "callback functions whose importance will become clear in a moment when we " "discuss :keyword:`await`." msgstr "" +"おおまかにいうと、:ref:`タスク ` はイベントループに結び付け" +"られたコルーチンです (コルーチン関数ではありません)。\n" +"タスクはコールバック関数のリストも保持しています。\n" +"この重要性は、後で :keyword:`await` を説明するときに明らかになります。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:174 msgid "" "Creating a task automatically schedules it for execution (by adding a " "callback to run it in the event loop's to-do list, that is, collection of " "jobs). The recommended way to create tasks is via :func:`asyncio." "create_task`." msgstr "" +"タスクを作ると、実行のために自動的にスケジュールされます。\n" +"具体的には、タスクを実行するコールバックが、イベントループの処理待ちリスト、" +"つまりジョブの集合に追加されます。\n" +"タスクの作成には :func:`asyncio.create_task` を使うことが推奨されます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:178 msgid "" ":mod:`!asyncio` automatically associates tasks with the event loop for you. " "This automatic association was purposely designed into :mod:`!asyncio` for " @@ -290,16 +378,22 @@ msgid "" "loop object and pass it to any coroutine function that wants to create " "tasks, adding redundant clutter to your code." msgstr "" +":mod:`!asyncio` はタスクとイベントループを自動的に関連付けます。\n" +"この自動的な関連付けは、簡単に使えるようにするための意図的な設計です。\n" +"これがなければ、イベントループオブジェクトを自分で管理し、タスクを作るすべて" +"のコルーチン関数に渡す必要があり、:mod:`!asyncio` を使うコードが冗長で煩雑に" +"なります。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:187 msgid "" "coroutine = loudmouth_penguin(magic_number=5)\n" "# This creates a Task object and schedules its execution via the event " "loop.\n" "task = asyncio.create_task(coroutine)" msgstr "" +"coroutine = loudmouth_penguin(magic_number=5)\n" +"# Task オブジェクトを作り、イベントループで実行するようにスケジュールする。\n" +"task = asyncio.create_task(coroutine)" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:191 msgid "" "Earlier, we manually created the event loop and set it to run forever. In " "practice, it's recommended to use (and common to see) :func:`asyncio.run`, " @@ -307,8 +401,12 @@ msgid "" "coroutine finishes before advancing. For example, many async programs follow " "this setup::" msgstr "" +"先ほどはイベントループを手動で作り、実行し続けるようにしました。\n" +"実際には :func:`asyncio.run` を使うことが推奨され、よく使われています。\n" +"この関数はイベントループを管理し、渡したコルーチンが完了してから次の処理に進" +"むようにします。\n" +"例えば、多くの非同期プログラムは次のような構成になっています。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:197 msgid "" "import asyncio\n" "\n" @@ -322,6 +420,17 @@ msgid "" " # coroutine main() finishes.\n" " print(\"coroutine main() is done!\")" msgstr "" +"import asyncio\n" +"\n" +"async def main():\n" +" # さまざまな非同期処理を行う...\n" +" ...\n" +"\n" +"if __name__ == \"__main__\":\n" +" asyncio.run(main())\n" +" # main() コルーチンが完了するまで、\n" +" # 次の print 文には進まない。\n" +" print(\"coroutine main() is done!\")" #: ../../howto/a-conceptual-overview-of-asyncio.rst:209 msgid "" @@ -331,7 +440,6 @@ msgid "" "example, consider this program:" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:215 msgid "" "async def hello():\n" " print(\"hello!\")\n" @@ -344,6 +452,16 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"async def hello():\n" +" print(\"hello!\")\n" +"\n" +"async def main():\n" +" asyncio.create_task(hello())\n" +" # しばらく実行した後にイベントループへ制御を渡す、\n" +" # ほかの非同期処理...\n" +" ...\n" +"\n" +"asyncio.run(main())" #: ../../howto/a-conceptual-overview-of-asyncio.rst:229 msgid "" @@ -359,31 +477,32 @@ msgid "" "doesn't happen. But that's no reason to be reckless!" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:245 msgid "await" -msgstr "" +msgstr "await" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:247 msgid "" ":keyword:`await` is a Python keyword that's commonly used in one of two " "different ways::" msgstr "" +":keyword:`await` は Python のキーワードで、一般に次の 2 通りの使い方がありま" +"す。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:250 msgid "" "await task\n" "await coroutine" msgstr "" +"await task\n" +"await coroutine" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:253 msgid "" "In a crucial way, the behavior of ``await`` depends on the type of object " "being awaited." msgstr "" +"``await`` の動作は、待機する対象のオブジェクトの型によって、重要な点で異なり" +"ます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:258 msgid "Awaiting tasks" -msgstr "" +msgstr "タスクの待機" #: ../../howto/a-conceptual-overview-of-asyncio.rst:260 msgid "" @@ -392,7 +511,6 @@ msgid "" "happen. We'll use the following code example to illustrate::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:265 msgid "" "async def plant_a_tree():\n" " dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" @@ -401,8 +519,13 @@ msgid "" " # Other instructions associated with planting a tree.\n" " ..." msgstr "" +"async def plant_a_tree():\n" +" dig_the_hole_task = asyncio.create_task(dig_the_hole())\n" +" await dig_the_hole_task\n" +"\n" +" # 木を植えるためのその他の処理。\n" +" ..." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:272 msgid "" "In this example, imagine the event loop has passed control to the start of " "the coroutine ``plant_a_tree()``. As seen above, the coroutine creates a " @@ -414,24 +537,39 @@ msgid "" "the task finishes, it will add its various callbacks to the event loop, in " "this case, a call to resume ``plant_a_tree()``." msgstr "" +"この例では、イベントループからコルーチン ``plant_a_tree()`` の先頭へ制御が" +"渡ったと考えてください。\n" +"コルーチンは上記のとおりタスクを作り、それを await します。\n" +"``await dig_the_hole_task`` は、``plant_a_tree()`` を再開するためのコールバッ" +"クを、``dig_the_hole_task`` オブジェクトのコールバックのリストに追加しま" +"す。\n" +"その後、イベントループに制御を渡します。\n" +"しばらくすると、イベントループは ``dig_the_hole_task`` に制御を渡し、タスクは" +"必要な処理を終えます。\n" +"タスクが完了すると、登録されているコールバックがイベントループに追加されま" +"す。\n" +"この場合は、``plant_a_tree()`` を再開する呼び出しです。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:283 msgid "" "Generally speaking, when the awaited task finishes (``dig_the_hole_task``), " "the original task or coroutine (``plant_a_tree()``) is added back to the " "event loop's to-do list to be resumed." msgstr "" +"一般に、待機していたタスク (``dig_the_hole_task``) が完了すると、もとのタスク" +"やコルーチン (``plant_a_tree()``) がイベントループの処理待ちリストに戻され、" +"再開されます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:287 msgid "" "This is a basic, yet reliable mental model. In practice, the control " "handoffs are slightly more complex, but not by much. In part 2, we'll walk " "through the details that make this possible." msgstr "" +"これは基本的ですが、頼りになる考え方です。\n" +"実際の制御の受け渡しはもう少し複雑ですが、大きくは違いません。\n" +"第 2 部では、これを可能にする仕組みを詳しく説明します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:293 msgid "Awaiting coroutines" -msgstr "" +msgstr "コルーチンの待機" #: ../../howto/a-conceptual-overview-of-asyncio.rst:295 msgid "" @@ -441,7 +579,6 @@ msgid "" "invoking a regular, synchronous Python function. Consider this program::" msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:303 msgid "" "import asyncio\n" "\n" @@ -460,8 +597,23 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def coro_a():\n" +" print(\"I am coro_a(). Hi!\")\n" +"\n" +"async def coro_b():\n" +" print(\"I am coro_b(). I sure hope no one hogs the event loop...\")\n" +"\n" +"async def main():\n" +" task_b = asyncio.create_task(coro_b())\n" +" num_repeats = 3\n" +" for _ in range(num_repeats):\n" +" await coro_a()\n" +" await task_b\n" +"\n" +"asyncio.run(main())" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:320 msgid "" "The first statement in the coroutine ``main()`` creates ``task_b`` and " "schedules it for execution via the event loop. Then, ``coro_a()`` is " @@ -469,16 +621,23 @@ msgid "" "see the output of all three ``coro_a()`` invocations before ``coro_b()``'s " "output:" msgstr "" +"コルーチン ``main()`` の最初の文は ``task_b`` を作り、イベントループで実行さ" +"れるようにスケジュールします。\n" +"その後、``coro_a()`` が繰り返し await されます。\n" +"この間はイベントループに制御が戻らないため、``coro_a()`` の 3 回分の出力がす" +"べて表示された後に、``coro_b()`` の出力が表示されます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:326 msgid "" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!\n" "I am coro_b(). I sure hope no one hogs the event loop..." msgstr "" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_b(). I sure hope no one hogs the event loop..." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:333 msgid "" "If we change ``await coro_a()`` to ``await asyncio.create_task(coro_a())``, " "the behavior changes. The coroutine ``main()`` cedes control to the event " @@ -486,16 +645,23 @@ msgid "" "of work, calling ``task_b`` and then the task which wraps ``coro_a()`` " "before resuming the coroutine ``main()``." msgstr "" +"``await coro_a()`` を ``await asyncio.create_task(coro_a())`` に変えると、動" +"作が変わります。\n" +"コルーチン ``main()`` はこの文でイベントループに制御を渡します。\n" +"イベントループは待機中の処理を進め、``task_b``、次に ``coro_a()`` を包むタス" +"クを呼び出してから、コルーチン ``main()`` を再開します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:340 msgid "" "I am coro_b(). I sure hope no one hogs the event loop...\n" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!\n" "I am coro_a(). Hi!" msgstr "" +"I am coro_b(). I sure hope no one hogs the event loop...\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!\n" +"I am coro_a(). Hi!" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:347 msgid "" "This behavior of ``await coroutine`` can trip a lot of people up! That " "example highlights how using only ``await coroutine`` could unintentionally " @@ -505,6 +671,13 @@ msgid "" "things, it will log any coroutines that monopolize execution for 100ms or " "longer." msgstr "" +"この ``await coroutine`` の動作でつまずく人は少なくありません。\n" +"この例が示すように、``await coroutine`` だけを使っていると、意図せずほかのタ" +"スクから制御を奪い、実質的にイベントループを止めてしまうことがあります。\n" +":func:`asyncio.run` の ``debug=True`` を指定して :ref:`デバッグモード " +"` を有効にすると、こうした問題の検出に役立ちます。\n" +"このモードでは、ほかの情報に加え、100 ミリ秒以上実行を独占するコルーチンがロ" +"グに記録されます。" #: ../../howto/a-conceptual-overview-of-asyncio.rst:357 msgid "" @@ -517,28 +690,29 @@ msgid "" "negligible performance drag." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:368 msgid "A conceptual overview part 2: the nuts and bolts" -msgstr "" +msgstr "概念の説明、第 2 部: 内部の仕組み" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:370 msgid "" "Part 2 goes into detail on the mechanisms :mod:`!asyncio` uses to manage " "control flow. This is where the magic happens. You'll come away from this " "section knowing what ``await`` does behind the scenes and how to make your " "own asynchronous operators." msgstr "" +"第 2 部では、:mod:`!asyncio` が制御の流れを管理する仕組みを詳しく説明しま" +"す。\n" +"ここに仕掛けの核心があります。\n" +"この節を読むと、``await`` の裏側で何が起きるか、独自の非同期操作をどう作るか" +"が分かるでしょう。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:378 msgid "The inner workings of coroutines" -msgstr "" +msgstr "コルーチンの内部動作" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:380 msgid "" ":mod:`!asyncio` leverages four components of Python to pass around control." msgstr "" +":mod:`!asyncio` は Python の 4 つの構成要素を使って制御を受け渡します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:383 msgid "" ":meth:`coroutine.send(arg) ` is the method used to start or " "resume a coroutine. If the coroutine was paused and is now being resumed, " @@ -546,8 +720,13 @@ msgid "" "statement which originally paused it. If the coroutine is being used for the " "first time (as opposed to being resumed), ``arg`` must be ``None``." msgstr "" +":meth:`coroutine.send(arg) ` は、コルーチンを開始または再開す" +"るメソッドです。\n" +"中断していたコルーチンを再開する場合、引数 ``arg`` は、中断した位置の " +"``yield`` 文の戻り値として渡されます。\n" +"再開ではなく初めてコルーチンを動かす場合は、``arg`` は ``None`` でなければな" +"りません。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:391 msgid "" "class Rock:\n" " def __await__(self):\n" @@ -575,8 +754,32 @@ msgid "" " returned_value = e.value\n" "print(f\"Coroutine main() finished and provided value: {returned_value}.\")" msgstr "" +"class Rock:\n" +" def __await__(self):\n" +" value_sent_in = yield 7\n" +" print(f\"Rock.__await__ resuming with value: {value_sent_in}.\")\n" +" return value_sent_in\n" +"\n" +"async def main():\n" +" print(\"Beginning coroutine main().\")\n" +" rock = Rock()\n" +" print(\"Awaiting rock...\")\n" +" value_from_rock = await rock\n" +" print(f\"Coroutine received value: {value_from_rock} from rock.\")\n" +" return 23\n" +"\n" +"coroutine = main()\n" +"intermediate_result = coroutine.send(None)\n" +"print(f\"Coroutine paused and returned intermediate value: " +"{intermediate_result}.\")\n" +"\n" +"print(f\"Resuming coroutine and sending in value: 42.\")\n" +"try:\n" +" coroutine.send(42)\n" +"except StopIteration as e:\n" +" returned_value = e.value\n" +"print(f\"Coroutine main() finished and provided value: {returned_value}.\")" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:419 msgid "" ":ref:`yield `, as usual, pauses execution and returns control to " "the caller. In the example above, the ``yield``, on line 3, is called by " @@ -586,8 +789,17 @@ msgid "" "s it receives up the call chain. In this case, that's back to ``... = " "coroutine.send(None)`` on line 16." msgstr "" +":ref:`yield ` は通常どおり実行を中断し、呼び出し元に制御を戻しま" +"す。\n" +"上の例では、11 行目の ``... = await rock`` によって 3 行目の ``yield`` が呼ば" +"れます。\n" +"より一般的にいうと、``await`` は与えられたオブジェクトの :meth:`~object." +"__await__` メソッドを呼び出します。\n" +"``await`` には、もう 1 つ特別な役割があります。\n" +"受け取った ``yield`` を呼び出しの連鎖をさかのぼって伝播させる (「受け渡す」) " +"のです。\n" +"この場合は、16 行目の ``... = coroutine.send(None)`` に戻ります。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:429 msgid "" "The coroutine is resumed via the ``coroutine.send(42)`` call on line 21. The " "coroutine picks back up from where it ``yield``\\ ed (or paused) on line 3 " @@ -595,12 +807,15 @@ msgid "" "finishes, it raises a :exc:`StopIteration` exception with the return value " "attached in the :attr:`~StopIteration.value` attribute." msgstr "" +"21 行目の ``coroutine.send(42)`` を呼び出すと、コルーチンが再開されます。\n" +"コルーチンは 3 行目の ``yield`` で中断した位置から動き始め、本体の残りの文を" +"実行します。\n" +"コルーチンが完了すると、戻り値を :attr:`~StopIteration.value` 属性に持つ :" +"exc:`StopIteration` 例外が送出されます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:435 msgid "That snippet produces this output:" -msgstr "" +msgstr "このコードは次の出力を生成します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:437 msgid "" "Beginning coroutine main().\n" "Awaiting rock...\n" @@ -610,29 +825,42 @@ msgid "" "Coroutine received value: 42 from rock.\n" "Coroutine main() finished and provided value: 23." msgstr "" +"Beginning coroutine main().\n" +"Awaiting rock...\n" +"Coroutine paused and returned intermediate value: 7.\n" +"Resuming coroutine and sending in value: 42.\n" +"Rock.__await__ resuming with value: 42.\n" +"Coroutine received value: 42 from rock.\n" +"Coroutine main() finished and provided value: 23." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:447 msgid "" "It's worth pausing for a moment here and making sure you followed the " "various ways that control flow and values were passed. A lot of important " "ideas were covered and it's worth ensuring your understanding is firm." msgstr "" +"ここで少し立ち止まり、制御や値がどのように受け渡されたかを追えているか確認し" +"てください。\n" +"重要な考え方をいくつも取り上げたので、確実に理解しておくとよいでしょう。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:451 msgid "" "The only way to yield (or effectively cede control) from a coroutine is to " "``await`` an object that ``yield``\\ s in its ``__await__`` method. That " "might sound odd to you. You might be thinking:" msgstr "" +"コルーチンから yield する (実質的に制御を渡す) 唯一の方法は、``__await__`` メ" +"ソッド内で ``yield`` するオブジェクトを ``await`` することです。\n" +"奇妙に思えるかもしれません。\n" +"次のような疑問を持ったのではないでしょうか。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:455 msgid "" "1. What about a ``yield`` directly within the coroutine function? The " "coroutine function becomes an :ref:`async generator function `, a different beast entirely." msgstr "" +"1. コルーチン関数の中に直接 ``yield`` を書いたらどうなるのでしょうか?\n" +" その関数は :ref:`非同期ジェネレータ関数 ` になり、まったく別のものになります。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:460 msgid "" "2. What about a :ref:`yield from ` within the coroutine function " "to a (plain) generator? That causes the error: ``SyntaxError: yield from not " @@ -642,20 +870,31 @@ msgid "" "``yield`` was barred as well, but was re-accepted to allow for async " "generators." msgstr "" +"2. コルーチン関数内で、通常のジェネレータに対して :ref:`yield from " +"` を使ったらどうなるのでしょうか?\n" +" ``SyntaxError: yield from not allowed in a coroutine.`` というエラーになり" +"ます。\n" +" これはコルーチンの使い方を 1 つに絞り、単純にするための意図的な設計で" +"す。\n" +" とはいえ、``yield from`` と ``await`` は実質的に同じことをします。\n" +" 当初は ``yield`` も禁止されていましたが、非同期ジェネレータを実現するため" +"に再び認められました。" #: ../../howto/a-conceptual-overview-of-asyncio.rst:471 msgid "Futures" msgstr "Future" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:473 msgid "" "A :ref:`future ` is an object meant to represent a " "computation's status and result. The term is a nod to the idea of something " "still to come or not yet happened, and the object is a way to keep an eye on " "that something." msgstr "" +":ref:`Future ` は、計算の状態と結果を表すためのオブジェク" +"トです。\n" +"この名前は、これから起こること、まだ起きていないことを指しています。\n" +"Future オブジェクトは、その状況を把握する手段です。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:478 msgid "" "A future has a few important attributes. One is its state, which can be " "either \"pending\", \"cancelled\", or \"done\". Another is its result, which " @@ -664,43 +903,60 @@ msgid "" "status and result of that computation, kind of like a status light (red, " "yellow, or green) or indicator." msgstr "" +"Future には重要な属性がいくつかあります。\n" +"1 つは状態で、「待機中」「キャンセル済み」「完了」のいずれかになります。\n" +"もう 1 つは結果で、状態が完了に変わるときに設定されます。\n" +"コルーチンと異なり、Future は実行する計算そのものを表しません。\n" +"赤・黄・緑の状態ランプや表示器のように、その計算の状態と結果を表します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:485 msgid "" ":class:`asyncio.Task` subclasses :class:`asyncio.Future` in order to gain " "these various capabilities. The prior section said tasks store a list of " "callbacks, which wasn't entirely accurate. It's actually the ``Future`` " "class that implements this logic, which ``Task`` inherits." msgstr "" +":class:`asyncio.Task` は、これらの機能を得るために :class:`asyncio.Future` を" +"継承しています。\n" +"前の節ではタスクがコールバックのリストを保持すると説明しましたが、厳密には正" +"確ではありません。\n" +"実際にこの処理を実装するのは ``Future`` クラスで、``Task`` はそれを継承してい" +"ます。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:492 msgid "" "Futures may also be used directly (not via tasks). Tasks mark themselves as " "done when their coroutine is complete. Futures are much more versatile and " "will be marked as done when you say so. In this way, they're the flexible " "interface for you to make your own conditions for waiting and resuming." msgstr "" +"Future はタスクを介さずに直接使うこともできます。\n" +"タスクは自身のコルーチンが完了すると、自分の状態を完了にします。\n" +"Future はもっと柔軟で、指定したタイミングで完了にできます。\n" +"そのため、待機や再開の条件を独自に定めるための柔軟なインターフェースになりま" +"す。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:500 msgid "A homemade asyncio.sleep" -msgstr "" +msgstr "asyncio.sleep を自作する" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:502 msgid "" "We'll go through an example of how you could leverage a future to create " "your own variant of asynchronous sleep (``async_sleep``) which mimics :func:" "`asyncio.sleep`." msgstr "" +"Future を使い、:func:`asyncio.sleep` をまねた独自の非同期スリープ " +"``async_sleep`` を作る例を見ていきましょう。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:506 msgid "" "This snippet registers a few tasks with the event loop and then awaits the " "task created by ``asyncio.create_task``, which wraps the ``async_sleep(3)`` " "coroutine. We want that task to finish only after three seconds have " "elapsed, but without preventing other tasks from running." msgstr "" +"次のコードはイベントループにいくつかのタスクを登録してから、" +"``async_sleep(3)`` コルーチンを包む、``asyncio.create_task`` で作ったタスク" +"を await します。\n" +"ほかのタスクの実行を妨げずに、3 秒経過してからこのタスクを完了させたいと考え" +"ています。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:513 msgid "" "async def other_work():\n" " print(\"I like work. Work work.\")\n" @@ -725,8 +981,29 @@ msgid "" " # asyncio.gather effectively awaits each task in the collection.\n" " await asyncio.gather(*work_tasks)" msgstr "" +"async def other_work():\n" +" print(\"I like work. Work work.\")\n" +"\n" +"async def main():\n" +" # 非同期でスリープしている間に実行する処理があるように、\n" +" # イベントループにほかのタスクをいくつか追加する。\n" +" work_tasks = [\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work()),\n" +" asyncio.create_task(other_work())\n" +" ]\n" +" print(\n" +" \"Beginning asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" await asyncio.create_task(async_sleep(3))\n" +" print(\n" +" \"Done asynchronous sleep at time: \"\n" +" f\"{datetime.datetime.now().strftime(\"%H:%M:%S\")}.\"\n" +" )\n" +" # asyncio.gather は実質的に集合内の各タスクを await する。\n" +" await asyncio.gather(*work_tasks)" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:537 msgid "" "Below, we use a future to enable custom control over when that task will be " "marked as done. If :meth:`future.set_result() ` " @@ -735,8 +1012,13 @@ msgid "" "task, which we'll see in a moment, that will monitor how much time has " "elapsed and, accordingly, call ``future.set_result()``." msgstr "" +"以下では、Future を使ってタスクが完了するタイミングを独自に制御します。\n" +"Future を完了させるメソッド :meth:`future.set_result() ` が呼ばれなければ、このタスクはいつまでも完了しません。\n" +"また、経過時間を監視して、適切なタイミングで ``future.set_result()`` を呼び出" +"す別のタスクも使います。\n" +"そのタスクは後で紹介します。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:548 msgid "" "async def async_sleep(seconds: float):\n" " future = asyncio.Future()\n" @@ -747,8 +1029,15 @@ msgid "" " # Block until the future is marked as done.\n" " await future" msgstr "" +"async def async_sleep(seconds: float):\n" +" future = asyncio.Future()\n" +" time_to_wake = time.time() + seconds\n" +" # 監視タスクをイベントループに追加する。\n" +" watcher_task = asyncio.create_task(_sleep_watcher(future, " +"time_to_wake))\n" +" # Future が完了するまで待機する。\n" +" await future" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:556 msgid "" "Below, we use a rather bare ``YieldToEventLoop()`` object to ``yield`` from " "its ``__await__`` method, ceding control to the event loop. This is " @@ -756,6 +1045,13 @@ msgid "" "offers more clarity, not to mention it's somewhat cheating to use ``asyncio." "sleep`` when showcasing how to implement it!" msgstr "" +"以下では、ごく簡単な ``YieldToEventLoop()`` オブジェクトを使います。\n" +"このオブジェクトは ``__await__`` メソッド内で ``yield`` し、イベントループに" +"制御を渡します。\n" +"これは実質的には ``asyncio.sleep(0)`` を呼ぶのと同じですが、この方法のほうが" +"仕組みがはっきりします。\n" +"それに、``asyncio.sleep`` の実装方法を示すのに ``asyncio.sleep`` 自体を使うの" +"は、少しずるいでしょう。" #: ../../howto/a-conceptual-overview-of-asyncio.rst:562 msgid "" @@ -772,7 +1068,6 @@ msgid "" "true of ``asyncio.sleep``." msgstr "" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:578 msgid "" "class YieldToEventLoop:\n" " def __await__(self):\n" @@ -787,12 +1082,22 @@ msgid "" " else:\n" " await YieldToEventLoop()" msgstr "" +"class YieldToEventLoop:\n" +" def __await__(self):\n" +" yield\n" +"\n" +"async def _sleep_watcher(future, time_to_wake):\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" # Future を完了させる。\n" +" future.set_result(None)\n" +" break\n" +" else:\n" +" await YieldToEventLoop()" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:591 msgid "Here is the full program's output:" -msgstr "" +msgstr "プログラム全体の出力は次のとおりです。" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:593 msgid "" "$ python custom-async-sleep.py\n" "Beginning asynchronous sleep at time: 14:52:22.\n" @@ -801,8 +1106,13 @@ msgid "" "I like work. Work work.\n" "Done asynchronous sleep at time: 14:52:25." msgstr "" +"$ python custom-async-sleep.py\n" +"Beginning asynchronous sleep at time: 14:52:22.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"I like work. Work work.\n" +"Done asynchronous sleep at time: 14:52:25." -#: ../../howto/a-conceptual-overview-of-asyncio.rst:602 msgid "" "You might feel this implementation of asynchronous sleep was unnecessarily " "convoluted. And, well, it was. The example was meant to showcase the " @@ -810,8 +1120,12 @@ msgid "" "complex needs. For reference, you could implement it without futures, like " "so::" msgstr "" +"この非同期スリープの実装は、必要以上に複雑だと感じたかもしれません。\n" +"確かにそのとおりです。\n" +"この例の目的は、より複雑な要件にも応用できる単純な例で、Future の柔軟さを示す" +"ことでした。\n" +"参考までに、Future を使わずに次のように実装することもできます。 ::" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:609 msgid "" "async def simpler_async_sleep(seconds):\n" " time_to_wake = time.time() + seconds\n" @@ -821,10 +1135,19 @@ msgid "" " else:\n" " await YieldToEventLoop()" msgstr "" +"async def simpler_async_sleep(seconds):\n" +" time_to_wake = time.time() + seconds\n" +" while True:\n" +" if time.time() >= time_to_wake:\n" +" return\n" +" else:\n" +" await YieldToEventLoop()" -#: ../../howto/a-conceptual-overview-of-asyncio.rst:617 msgid "" "But that's all for now. Hopefully you're ready to more confidently dive into " "some async programming or check out advanced topics in the :mod:`rest of the " "documentation `." msgstr "" +"今回はここまでです。\n" +"自信を持って非同期プログラミングに取り組んだり、:mod:`ほかのドキュメント " +"` で高度な話題を調べたりする準備ができていれば幸いです。" diff --git a/howto/annotations.po b/howto/annotations.po index 3d8cd26c3..b26c6e252 100644 --- a/howto/annotations.po +++ b/howto/annotations.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: digdugdog, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/annotations.rst:5 @@ -71,7 +71,6 @@ msgstr "" msgid "Accessing The Annotations Dict Of An Object In Python 3.10 And Newer" msgstr "オブジェクトのアノテーション辞書へのアクセス (Python 3.10 以降)" -#: ../../howto/annotations.rst:33 msgid "" "Python 3.10 adds a new function to the standard library: :func:`inspect." "get_annotations`. In Python versions 3.10 through 3.13, calling this " @@ -79,10 +78,11 @@ msgid "" "object that supports annotations. This function can also \"un-stringize\" " "stringized annotations for you." msgstr "" -"Python 3.10 で標準ライブラリに :func:`inspect.get_annotations` 関数が新たに追" -"加されました。Python 3.10 から 3.13 までは、アノテーションに対応しているオブ" -"ジェクトのアノテーション辞書にアクセスするには、この関数を使うのが一番良いで" -"す。文字列で指定されたアノテーションも自動的に文字列でない値に解決してくれま" +"Python 3.10 で標準ライブラリに :func:`inspect.get_annotations` が追加されまし" +"た。\n" +"Python 3.10 から 3.13 では、アノテーションに対応するオブジェクトのアノテー" +"ション辞書を取得するには、この関数を呼び出すのが推奨される方法です。\n" +"この関数では、文字列化されたアノテーションを評価して元の値に戻すこともできま" "す。" #: ../../howto/annotations.rst:40 @@ -311,13 +311,16 @@ msgstr "" "``o`` がクラスならば、 ``sys.modules[o.__module__].__dict__`` を ``globals`` " "とし、 ``dict(vars(o))`` を ``locals`` として :func:`eval` を呼ぶ。" -#: ../../howto/annotations.rst:154 msgid "" "If ``o`` is a wrapped callable using :func:`functools.update_wrapper`, :deco:" "`functools.wraps`, or :func:`functools.partial`, iteratively unwrap it by " "accessing either ``o.__wrapped__`` or ``o.func`` as appropriate, until you " "have found the root unwrapped function." msgstr "" +"``o`` が :func:`functools.update_wrapper`、:deco:`functools.wraps`、または :" +"func:`functools.partial` でラップされた呼び出し可能オブジェクトなら、適切なほ" +"うの ``o.__wrapped__`` または ``o.func`` を繰り返し参照し、ラップされていない" +"元の関数までたどります。" #: ../../howto/annotations.rst:158 msgid "" @@ -370,13 +373,12 @@ msgstr "" msgid "Best Practices For ``__annotations__`` In Any Python Version" msgstr "``__annotations__`` のベストプラクティス (全 Python バージョン共通)" -#: ../../howto/annotations.rst:184 msgid "" "You should avoid assigning to the ``__annotations__`` member of objects " "directly. Let Python manage setting ``__annotations__``." msgstr "" "オブジェクトの ``__annotations__`` 属性に直接代入することは避けるべきです。" -"Python に任せましょう。 " +"Python に任せましょう。" #: ../../howto/annotations.rst:187 msgid "" @@ -436,7 +438,6 @@ msgid "" "in Python 3.10 and newer." msgstr "" -#: ../../howto/annotations.rst:220 msgid "" "In all versions of Python 3, you can set ``__annotations__`` on a function " "object to ``None``. However, subsequently accessing the annotations on that " @@ -446,30 +447,46 @@ msgid "" "``__annotations__`` to any Python value, and will retain whatever value is " "set." msgstr "" +"Python 3 のすべてのバージョンで、関数オブジェクトの ``__annotations__`` に " +"``None`` を設定できます。\n" +"ただし、その後 ``fn.__annotations__`` でアクセスすると、この節の最初の段落で" +"述べたとおり、空の辞書が遅延作成されます。\n" +"これは、どの Python バージョンでもモジュールやクラスには *当てはまりません" +"*。\n" +"これらのオブジェクトでは、``__annotations__`` に任意の Python の値を設定で" +"き、設定した値がそのまま保持されます。" -#: ../../howto/annotations.rst:228 msgid "" "If Python stringizes your annotations for you (using ``from __future__ " "import annotations``), and you specify a string as an annotation, the string " "will itself be quoted. In effect the annotation is quoted *twice.* For " "example::" msgstr "" +"``from __future__ import annotations`` を使って Python にアノテーションを文字" +"列化させる場合に、アノテーションとして文字列を指定すると、その文字列自体が引" +"用符で囲まれます。\n" +"つまり、アノテーションが *二重に* 引用されます。\n" +"例えば、次のようになります。 ::" -#: ../../howto/annotations.rst:234 msgid "" "from __future__ import annotations\n" "def foo(a: \"str\"): pass\n" "\n" "print(foo.__annotations__)" msgstr "" +"from __future__ import annotations\n" +"def foo(a: \"str\"): pass\n" +"\n" +"print(foo.__annotations__)" -#: ../../howto/annotations.rst:239 msgid "" "This prints ``{'a': \"'str'\"}``. This shouldn't really be considered a " "\"quirk\"; it's mentioned here simply because it might be surprising." msgstr "" +"これは ``{'a': \"'str'\"}`` を表示します。\n" +"本来は「癖」と呼ぶような動作ではありませんが、意外に感じるかもしれないため、" +"ここで紹介しています。" -#: ../../howto/annotations.rst:242 msgid "" "If you use a class with a custom metaclass and access ``__annotations__`` on " "the class, you may observe unexpected behavior; see :pep:`749 <749#pep749-" @@ -479,8 +496,16 @@ msgid "" "avoid these bugs by accessing the annotations from the class's :attr:`~type." "__dict__` (for example, ``cls.__dict__.get('__annotations__', None)``)." msgstr "" +"独自のメタクラスを使うクラスの ``__annotations__`` にアクセスすると、予期しな" +"い動作になる場合があります。\n" +"例は :pep:`749 <749#pep749-metaclasses>` を参照してください。\n" +"Python 3.14 以降では :func:`annotationlib.get_annotations`、Python 3.10 以降" +"では :func:`inspect.get_annotations` を使うことで、こうした動作を避けられま" +"す。\n" +"それ以前の Python では、``cls.__dict__.get('__annotations__', None)`` のよう" +"に、クラスの :attr:`~type.__dict__` からアノテーションを取得することで、この" +"問題を回避できます。" -#: ../../howto/annotations.rst:251 msgid "" "In some versions of Python, instances of classes may have an " "``__annotations__`` attribute. However, this is not supported functionality. " @@ -488,3 +513,10 @@ msgid "" "access its class (for example, ``annotationlib." "get_annotations(type(myinstance))`` on Python 3.14+)." msgstr "" +"一部の Python バージョンでは、クラスのインスタンスが ``__annotations__`` 属性" +"を持つことがあります。\n" +"ただし、これはサポートされている機能ではありません。\n" +"インスタンスのアノテーションが必要なら、:func:`type` でそのクラスを取得できま" +"す。\n" +"例えば、Python 3.14 以降では ``annotationlib." +"get_annotations(type(myinstance))`` を使えます。" diff --git a/howto/argparse-optparse.po b/howto/argparse-optparse.po index 9cb0f45da..68132decf 100644 --- a/howto/argparse-optparse.po +++ b/howto/argparse-optparse.po @@ -16,29 +16,28 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/argparse-optparse.rst:8 msgid "Migrating ``optparse`` code to ``argparse``" -msgstr "" +msgstr "``optparse`` を使うコードを ``argparse`` に移行する" -#: ../../howto/argparse-optparse.rst:10 msgid "" "The :mod:`argparse` module offers several higher level features not natively " "provided by the :mod:`optparse` module, including:" msgstr "" +":mod:`argparse` モジュールは、:mod:`optparse` モジュールに標準では備わってい" +"ない、次のような高水準の機能を提供します。" #: ../../howto/argparse-optparse.rst:13 msgid "Handling positional arguments." msgstr "位置引数を扱う" -#: ../../howto/argparse-optparse.rst:14 msgid "Supporting subcommands." -msgstr "" +msgstr "サブコマンドのサポート。" #: ../../howto/argparse-optparse.rst:15 msgid "Allowing alternative option prefixes like ``+`` and ``/``." @@ -58,7 +57,6 @@ msgstr "" "カスタム ``type``, カスタム ``action`` のために遥かに簡単なインターフェイスを" "提供する" -#: ../../howto/argparse-optparse.rst:20 msgid "" "Originally, the :mod:`argparse` module attempted to maintain compatibility " "with :mod:`optparse`. However, the fundamental design differences between " @@ -67,26 +65,36 @@ msgid "" "named options and positional arguments in the declarative interface mean " "that the API has diverged from that of ``optparse`` over time." msgstr "" +":mod:`argparse` モジュールは、当初 :mod:`optparse` との互換性を保とうとしてい" +"ました。\n" +"しかし、位置引数の処理をアプリケーション側に任せてコマンドラインオプションを" +"宣言的に処理する設計と、名前付きオプションと位置引数の両方を宣言的なインター" +"フェースで扱う設計には、根本的な違いがあります。\n" +"そのため、API は時間とともに ``optparse`` から離れていきました。" -#: ../../howto/argparse-optparse.rst:27 msgid "" "As described in :ref:`choosing-an-argument-parser`, applications that are " "currently using :mod:`optparse` and are happy with the way it works can just " "continue to use ``optparse``." msgstr "" +":ref:`choosing-an-argument-parser` で説明しているように、現在 :mod:" +"`optparse` を使っていて、その動作に満足しているアプリケーションは、そのまま " +"``optparse`` を使い続けて構いません。" -#: ../../howto/argparse-optparse.rst:31 msgid "" "Application developers that are considering migrating should also review the " "list of intrinsic behavioural differences described in that section before " "deciding whether or not migration is desirable." msgstr "" +"移行を検討しているアプリケーションの開発者は、移行が望ましいか判断する前に、" +"その節にある本質的な動作の違いの一覧も確認してください。" -#: ../../howto/argparse-optparse.rst:35 msgid "" "For applications that do choose to migrate from :mod:`optparse` to :mod:" "`argparse`, the following suggestions should be helpful:" msgstr "" +":mod:`optparse` から :mod:`argparse` への移行を選んだアプリケーションには、次" +"の指針が役立つでしょう。" #: ../../howto/argparse-optparse.rst:38 msgid "" @@ -126,13 +134,12 @@ msgstr "" "コールバック・アクションと ``callback_*`` キーワード引数を ``type`` や " "``action`` 引数に置き換える。" -#: ../../howto/argparse-optparse.rst:53 msgid "" "Replace string names for ``type`` keyword arguments with the corresponding " "type objects (e.g. int, float, complex, etc)." msgstr "" -"``type`` キーワード引数に渡していた文字列の名前を、それに応じたオブジェクト " -"(例: int, float, complex, ...) に置き換える。" +"``type`` キーワード引数に渡す型名の文字列を、対応する型オブジェクト (例えば " +"``int``、``float``、``complex`` など) に置き換えてください。" #: ../../howto/argparse-optparse.rst:56 msgid "" diff --git a/howto/argparse.po b/howto/argparse.po index 5c32708f5..95f380d31 100644 --- a/howto/argparse.po +++ b/howto/argparse.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/argparse.rst:5 @@ -31,11 +31,10 @@ msgid "" "This tutorial is intended to be a gentle introduction to :mod:`argparse`, " "the recommended command-line parsing module in the Python standard library." msgstr "" -"このチュートリアルでは、:mod:`argparse` を丁寧に説明します。:mod:`argparse` " +"このチュートリアルでは、:mod:`argparse` を丁寧に説明します。 ``argparse`` " "は、Python 標準ライブラリの一部であり、おすすめのコマンドライン引数の解析モ" "ジュールです。" -#: ../../howto/argparse.rst:14 msgid "" "The standard library includes two other libraries directly related to " "command-line parameter processing: the lower level :mod:`optparse` module " @@ -48,6 +47,16 @@ msgid "" "``optparse``, so some aspects of this tutorial will also be relevant to " "``optparse`` users." msgstr "" +"標準ライブラリには、コマンドライン引数の処理に直接関係するライブラリが、ほか" +"に 2 つあります。\n" +"より低水準の :mod:`optparse` モジュールは、アプリケーションに合わせた設定に多" +"くのコードが必要な場合もありますが、``argparse`` がサポートしない動作を指定で" +"きます。\n" +"さらに低水準の :mod:`getopt` は、C プログラマが使う :c:func:`!getopt` 系の関" +"数に相当するものです。\n" +"このガイドでは、これらのモジュールを直接は取り上げません。\n" +"ただし、``argparse`` の主要な概念の多くは ``optparse`` に由来するため、この" +"チュートリアルの一部は ``optparse`` の利用者にも役立ちます。" #: ../../howto/argparse.rst:27 msgid "Concepts" @@ -61,7 +70,6 @@ msgstr "" ":command:`ls` コマンドを使って、このチュートリアルで私たちが学ぶ機能をいくつ" "か見てみましょう:" -#: ../../howto/argparse.rst:32 msgid "" "$ ls\n" "cpython devguide prog.py pypy rm-unused-function.patch\n" @@ -80,6 +88,22 @@ msgid "" "Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" "..." msgstr "" +"$ ls\n" +"cpython devguide prog.py pypy rm-unused-function.patch\n" +"$ ls pypy\n" +"ctypes_configure demo dotviewer include lib_pypy lib-python ...\n" +"$ ls -l\n" +"total 20\n" +"drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython\n" +"drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide\n" +"-rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py\n" +"drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy\n" +"-rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch\n" +"$ ls --help\n" +"Usage: ls [OPTION]... [FILE]...\n" +"List information about the FILEs (the current directory by default).\n" +"Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n" +"..." #: ../../howto/argparse.rst:51 msgid "A few concepts we can learn from the four commands:" @@ -93,7 +117,6 @@ msgstr "" ":command:`ls` コマンドは、まったくオプションを指定せずに実行したとしても役に" "立ちます。デフォルトの動作は、カレントディレクトリの内容を表示することです。" -#: ../../howto/argparse.rst:56 msgid "" "If we want beyond what it provides by default, we tell it a bit more. In " "this case, we want it to display a different directory, ``pypy``. What we " @@ -104,14 +127,14 @@ msgid "" "position is *what you want copied,* and the second position is *where you " "want it copied to*." msgstr "" -"デフォルトの動作で提供される以上のことをしたい場合、すこしだけオプションを指" -"定する必要があります。別のディレクトリ ``pypy`` を表示したい場合、私たちがし" -"たことは、位置引数として知られる引数を指定することです。これは、引数がコマン" -"ドラインのどの位置に現れたかということだけを基に、プログラムがその値について" -"何をするのか分かるべきなので、このように名づけられています。このコンセプト" -"は :command:`cp` のようなコマンドで重要な意味があります。 :command:`cp` コマ" -"ンドのもっとも基本的な使い方は、 ``cp SRC DEST`` です。最初の引数は *何をコ" -"ピーしたいか* であり、二つ目の引数は *どこにコピーしたいか* を意味します。" +"デフォルト以外の動作をさせるには、追加の情報を渡します。\n" +"この例では、別のディレクトリ ``pypy`` の内容を表示させるために、位置引数と呼" +"ばれるものを指定しました。\n" +"コマンドライン上の位置だけで、プログラムがその値の用途を判断できることから、" +"この名前が付いています。\n" +"この考え方は :command:`cp` のようなコマンドではさらに重要です。\n" +"最も基本的な使い方は ``cp SRC DEST`` で、最初の位置は *コピーしたいもの*、2 " +"番目の位置は *コピー先* を表します。" #: ../../howto/argparse.rst:65 msgid "" @@ -141,19 +164,20 @@ msgstr "基礎" msgid "Let us start with a very simple example which does (almost) nothing::" msgstr "(ほとんど)何もしない、とても簡単な例から始めましょう::" -#: ../../howto/argparse.rst:79 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" "parser.parse_args()" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.parse_args()" #: ../../howto/argparse.rst:83 ../../howto/argparse.rst:191 #: ../../howto/argparse.rst:212 msgid "Following is a result of running the code:" msgstr "下記がこのコードを実行した結果です:" -#: ../../howto/argparse.rst:85 msgid "" "$ python prog.py\n" "$ python prog.py --help\n" @@ -168,6 +192,18 @@ msgid "" "usage: prog.py [-h]\n" "prog.py: error: unrecognized arguments: foo" msgstr "" +"$ python prog.py\n" +"$ python prog.py --help\n" +"usage: prog.py [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"$ python prog.py --verbose\n" +"usage: prog.py [-h]\n" +"prog.py: error: unrecognized arguments: --verbose\n" +"$ python prog.py foo\n" +"usage: prog.py [-h]\n" +"prog.py: error: unrecognized arguments: foo" #: ../../howto/argparse.rst:100 ../../howto/argparse.rst:257 #: ../../howto/argparse.rst:301 @@ -190,17 +226,16 @@ msgstr "" "二つ目の実行結果から :mod:`argparse` モジュールの有用性がわかります。ほとんど" "何もしていないのに、すてきなヘルプメッセージが手に入りました。" -#: ../../howto/argparse.rst:108 msgid "" "The ``--help`` option, which can also be shortened to ``-h``, is the only " "option we get for free (i.e. no need to specify it). Specifying anything " "else results in an error. But even then, we do get a useful usage message, " "also for free." msgstr "" -"``--help`` (これは ``-h`` と短縮できます)だけが無料のオプションです(つまり" -"プログラムで指示する必要はありません)。他のオプションを指定するとエラーにな" -"ります。エラー時の有用な用法メッセージも、プログラムで指示することなく出力で" -"きます。" +"``--help`` (短く ``-h`` とも書けます) は、こちらで定義せずに使える唯一のオプ" +"ションです。\n" +"それ以外を指定するとエラーになりますが、その場合も追加の実装なしで役立つ使用" +"方法のメッセージが表示されます。" #: ../../howto/argparse.rst:115 msgid "Introducing Positional arguments" @@ -210,7 +245,6 @@ msgstr "位置引数の入門" msgid "An example::" msgstr "以下に例を示します::" -#: ../../howto/argparse.rst:119 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -218,12 +252,16 @@ msgid "" "args = parser.parse_args()\n" "print(args.echo)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"echo\")\n" +"args = parser.parse_args()\n" +"print(args.echo)" #: ../../howto/argparse.rst:125 msgid "And running the code:" msgstr "このコードを実行してみましょう:" -#: ../../howto/argparse.rst:127 msgid "" "$ python prog.py\n" "usage: prog.py [-h] echo\n" @@ -239,6 +277,19 @@ msgid "" "$ python prog.py foo\n" "foo" msgstr "" +"$ python prog.py\n" +"usage: prog.py [-h] echo\n" +"prog.py: error: the following arguments are required: echo\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] echo\n" +"\n" +"positional arguments:\n" +" echo\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"$ python prog.py foo\n" +"foo" #: ../../howto/argparse.rst:143 msgid "Here is what's happening:" @@ -259,13 +310,13 @@ msgstr "" msgid "Calling our program now requires us to specify an option." msgstr "プログラムを実行すると、オプションを指定するように要求されます。" -#: ../../howto/argparse.rst:151 msgid "" "The :meth:`~ArgumentParser.parse_args` method actually returns some data " "from the options specified, in this case, ``echo``." msgstr "" -":meth:`~ArgumentParser.parse_args` メソッドは指定されたオプションを、この場合" -"は ``echo`` として、返します。" +":meth:`~ArgumentParser.parse_args` メソッドは、指定されたオプションから得た" +"データを返します。\n" +"この例では ``echo`` に指定された値です。" #: ../../howto/argparse.rst:154 msgid "" @@ -291,7 +342,6 @@ msgstr "" "ためには推測するかソースコードを見なけれなりません。もうすこしヘルプメッセー" "ジ分かりやすくしてみましょう::" -#: ../../howto/argparse.rst:164 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -299,12 +349,16 @@ msgid "" "args = parser.parse_args()\n" "print(args.echo)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"echo\", help=\"echo the string you use here\")\n" +"args = parser.parse_args()\n" +"print(args.echo)" #: ../../howto/argparse.rst:170 msgid "And we get:" msgstr "修正した結果は以下のようになります:" -#: ../../howto/argparse.rst:172 msgid "" "$ python prog.py -h\n" "usage: prog.py [-h] echo\n" @@ -315,12 +369,19 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +"$ python prog.py -h\n" +"usage: prog.py [-h] echo\n" +"\n" +"positional arguments:\n" +" echo echo the string you use here\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" #: ../../howto/argparse.rst:183 msgid "Now, how about doing something even more useful::" msgstr "次は、もっと有益なことをしてみませんか?::" -#: ../../howto/argparse.rst:185 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -329,8 +390,13 @@ msgid "" "args = parser.parse_args()\n" "print(args.square**2)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", help=\"display a square of a given " +"number\")\n" +"args = parser.parse_args()\n" +"print(args.square**2)" -#: ../../howto/argparse.rst:193 msgid "" "$ python prog.py 4\n" "Traceback (most recent call last):\n" @@ -338,6 +404,11 @@ msgid "" " print(args.square**2)\n" "TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" msgstr "" +"$ python prog.py 4\n" +"Traceback (most recent call last):\n" +" File \"prog.py\", line 5, in \n" +" print(args.square**2)\n" +"TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'" #: ../../howto/argparse.rst:201 msgid "" @@ -349,7 +420,6 @@ msgstr "" "ションを文字列として扱います。 :mod:`argparse` にオプションの値を整数として扱" "うように伝えましょう::" -#: ../../howto/argparse.rst:205 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -359,8 +429,14 @@ msgid "" "args = parser.parse_args()\n" "print(args.square**2)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", help=\"display a square of a given " +"number\",\n" +" type=int)\n" +"args = parser.parse_args()\n" +"print(args.square**2)" -#: ../../howto/argparse.rst:214 msgid "" "$ python prog.py 4\n" "16\n" @@ -368,6 +444,11 @@ msgid "" "usage: prog.py [-h] square\n" "prog.py: error: argument square: invalid int value: 'four'" msgstr "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py four\n" +"usage: prog.py [-h] square\n" +"prog.py: error: argument square: invalid int value: 'four'" #: ../../howto/argparse.rst:222 msgid "" @@ -389,7 +470,6 @@ msgstr "" "ここまで位置引数を扱ってきました。optional引数を追加する方法についても見てい" "きましょう::" -#: ../../howto/argparse.rst:232 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -398,13 +478,18 @@ msgid "" "if args.verbosity:\n" " print(\"verbosity turned on\")" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"--verbosity\", help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"if args.verbosity:\n" +" print(\"verbosity turned on\")" #: ../../howto/argparse.rst:239 ../../howto/argparse.rst:285 #: ../../howto/argparse.rst:401 ../../howto/argparse.rst:435 msgid "And the output:" msgstr "実行してみましょう:" -#: ../../howto/argparse.rst:241 msgid "" "$ python prog.py --verbosity 1\n" "verbosity turned on\n" @@ -420,6 +505,19 @@ msgid "" "usage: prog.py [-h] [--verbosity VERBOSITY]\n" "prog.py: error: argument --verbosity: expected one argument" msgstr "" +"$ python prog.py --verbosity 1\n" +"verbosity turned on\n" +"$ python prog.py\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [--verbosity VERBOSITY]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --verbosity VERBOSITY\n" +" increase output verbosity\n" +"$ python prog.py --verbosity\n" +"usage: prog.py [-h] [--verbosity VERBOSITY]\n" +"prog.py: error: argument --verbosity: expected one argument" #: ../../howto/argparse.rst:259 msgid "" @@ -465,7 +563,6 @@ msgstr "" "は、実際には ``True`` または ``False`` の二つの値だけが有効です。そうなるよう" "にコードを修正してみましょう::" -#: ../../howto/argparse.rst:277 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -475,8 +572,14 @@ msgid "" "if args.verbose:\n" " print(\"verbosity turned on\")" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"--verbose\", help=\"increase output verbosity\",\n" +" action=\"store_true\")\n" +"args = parser.parse_args()\n" +"if args.verbose:\n" +" print(\"verbosity turned on\")" -#: ../../howto/argparse.rst:287 msgid "" "$ python prog.py --verbose\n" "verbosity turned on\n" @@ -490,6 +593,17 @@ msgid "" " -h, --help show this help message and exit\n" " --verbose increase output verbosity" msgstr "" +"$ python prog.py --verbose\n" +"verbosity turned on\n" +"$ python prog.py --verbose 1\n" +"usage: prog.py [-h] [--verbose]\n" +"prog.py: error: unrecognized arguments: 1\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [--verbose]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --verbose increase output verbosity" #: ../../howto/argparse.rst:303 msgid "" @@ -531,7 +645,6 @@ msgstr "" "コマンドラインになれていれば、オプションの短いバージョンの話題に触れていない" "ことに気付いたでしょう。それはとても簡単です::" -#: ../../howto/argparse.rst:323 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -542,12 +655,19 @@ msgid "" "if args.verbose:\n" " print(\"verbosity turned on\")" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"-v\", \"--verbose\", help=\"increase output " +"verbosity\",\n" +" action=\"store_true\")\n" +"args = parser.parse_args()\n" +"if args.verbose:\n" +" print(\"verbosity turned on\")" #: ../../howto/argparse.rst:331 msgid "And here goes:" msgstr "上記のプログラムを実行するとこうなります:" -#: ../../howto/argparse.rst:333 msgid "" "$ python prog.py -v\n" "verbosity turned on\n" @@ -558,6 +678,14 @@ msgid "" " -h, --help show this help message and exit\n" " -v, --verbose increase output verbosity" msgstr "" +"$ python prog.py -v\n" +"verbosity turned on\n" +"$ python prog.py --help\n" +"usage: prog.py [-h] [-v]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose increase output verbosity" #: ../../howto/argparse.rst:344 msgid "Note that the new ability is also reflected in the help text." @@ -571,7 +699,6 @@ msgstr "位置引数とOptional引数の併用" msgid "Our program keeps growing in complexity::" msgstr "プログラムが複雑になってきました::" -#: ../../howto/argparse.rst:352 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -586,12 +713,23 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbose\", action=\"store_true\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbose:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"else:\n" +" print(answer)" #: ../../howto/argparse.rst:365 msgid "And now the output:" msgstr "出力は以下のようになります:" -#: ../../howto/argparse.rst:367 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] square\n" @@ -603,14 +741,22 @@ msgid "" "$ python prog.py --verbose 4\n" "the square of 4 equals 16" msgstr "" +"$ python prog.py\n" +"usage: prog.py [-h] [-v] square\n" +"prog.py: error: the following arguments are required: square\n" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 --verbose\n" +"the square of 4 equals 16\n" +"$ python prog.py --verbose 4\n" +"the square of 4 equals 16" #: ../../howto/argparse.rst:379 msgid "We've brought back a positional argument, hence the complaint." msgstr "位置引数を元に戻したので、引数を指定しないとエラーになりました。" -#: ../../howto/argparse.rst:381 msgid "Note that the order does not matter." -msgstr "2つのオプションの順序を考慮しないことに注意してください。" +msgstr "指定する順序は関係ありません。" #: ../../howto/argparse.rst:383 msgid "" @@ -620,7 +766,6 @@ msgstr "" "複数の詳細レベルを値にとれるようにプログラムを元に戻して、指定された値を使っ" "てみましょう::" -#: ../../howto/argparse.rst:386 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -637,8 +782,21 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", type=int,\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" -#: ../../howto/argparse.rst:403 msgid "" "$ python prog.py 4\n" "16\n" @@ -652,6 +810,17 @@ msgid "" "$ python prog.py 4 -v 3\n" "16" msgstr "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 -v\n" +"usage: prog.py [-h] [-v VERBOSITY] square\n" +"prog.py: error: argument -v/--verbosity: expected one argument\n" +"$ python prog.py 4 -v 1\n" +"4^2 == 16\n" +"$ python prog.py 4 -v 2\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -v 3\n" +"16" #: ../../howto/argparse.rst:417 msgid "" @@ -662,7 +831,6 @@ msgstr "" "プログラムのバグである最後の結果を除いて、上手く行っているようです。このバグ" "を、``--verbosity`` オプションが取れる値を制限することで修正しましょう::" -#: ../../howto/argparse.rst:420 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -679,8 +847,21 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", type=int, choices=[0, 1, 2],\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" -#: ../../howto/argparse.rst:437 msgid "" "$ python prog.py 4 -v 3\n" "usage: prog.py [-h] [-v {0,1,2}] square\n" @@ -697,6 +878,20 @@ msgid "" " -v, --verbosity {0,1,2}\n" " increase output verbosity" msgstr "" +"$ python prog.py 4 -v 3\n" +"usage: prog.py [-h] [-v {0,1,2}] square\n" +"prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, " +"1, 2)\n" +"$ python prog.py 4 -h\n" +"usage: prog.py [-h] [-v {0,1,2}] square\n" +"\n" +"positional arguments:\n" +" square display a square of a given number\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbosity {0,1,2}\n" +" increase output verbosity" #: ../../howto/argparse.rst:453 msgid "" @@ -716,7 +911,6 @@ msgstr "" "ファイルがその詳細レベル引数を扱う方法と同じです。( ``python --help`` の出力" "を確認してください)::" -#: ../../howto/argparse.rst:460 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -733,6 +927,20 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display the square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity == 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity == 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" #: ../../howto/argparse.rst:475 msgid "" @@ -742,7 +950,6 @@ msgstr "" "もう一つの action である \"count\" を紹介します。これは指定されたオプションの" "出現回数を数えます:" -#: ../../howto/argparse.rst:479 msgid "" "$ python prog.py 4\n" "16\n" @@ -767,6 +974,28 @@ msgid "" "$ python prog.py 4 -vvv\n" "16" msgstr "" +"$ python prog.py 4\n" +"16\n" +"$ python prog.py 4 -v\n" +"4^2 == 16\n" +"$ python prog.py 4 -vv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 --verbosity --verbosity\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -v 1\n" +"usage: prog.py [-h] [-v] square\n" +"prog.py: error: unrecognized arguments: 1\n" +"$ python prog.py 4 -h\n" +"usage: prog.py [-h] [-v] square\n" +"\n" +"positional arguments:\n" +" square display a square of a given number\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbosity increase output verbosity\n" +"$ python prog.py 4 -vvv\n" +"16" #: ../../howto/argparse.rst:504 msgid "" @@ -819,7 +1048,6 @@ msgstr "最後の出力はプログラムにバグがあることを示します msgid "Let's fix::" msgstr "修正しましょう::" -#: ../../howto/argparse.rst:527 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -838,12 +1066,27 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\",\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"\n" +"# バグ修正: == を >= に置き換える\n" +"if args.verbosity >= 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" #: ../../howto/argparse.rst:544 msgid "And this is what it gives:" msgstr "これが結果です:" -#: ../../howto/argparse.rst:546 msgid "" "$ python prog.py 4 -vvv\n" "the square of 4 equals 16\n" @@ -855,14 +1098,22 @@ msgid "" " if args.verbosity >= 2:\n" "TypeError: '>=' not supported between instances of 'NoneType' and 'int'" msgstr "" +"$ python prog.py 4 -vvv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4 -vvvv\n" +"the square of 4 equals 16\n" +"$ python prog.py 4\n" +"Traceback (most recent call last):\n" +" File \"prog.py\", line 11, in \n" +" if args.verbosity >= 2:\n" +"TypeError: '>=' not supported between instances of 'NoneType' and 'int'" -#: ../../howto/argparse.rst:559 msgid "" "First output went well, and fixes the bug we had before. That is, we want " "any value >= 2 to be as verbose as possible." msgstr "" -"最初の出力は上手くいっていますし、以前のバグが修正されています。最も詳細な出" -"力を得るには、2 以上の値が必要です。" +"最初の出力はうまくいき、先ほどのバグが直りました。\n" +"2 以上ならどの値でも最も詳しい出力にしたかったので、この動作で正解です。" #: ../../howto/argparse.rst:562 msgid "Third output not so good." @@ -872,7 +1123,6 @@ msgstr "三番目の結果は、よくありません。" msgid "Let's fix that bug::" msgstr "このバグを修正しましょう::" -#: ../../howto/argparse.rst:566 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -889,6 +1139,20 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"square\", type=int,\n" +" help=\"display a square of a given number\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0,\n" +" help=\"increase output verbosity\")\n" +"args = parser.parse_args()\n" +"answer = args.square**2\n" +"if args.verbosity >= 2:\n" +" print(f\"the square of {args.square} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.square}^2 == {answer}\")\n" +"else:\n" +" print(answer)" #: ../../howto/argparse.rst:581 msgid "" @@ -907,11 +1171,12 @@ msgstr "" msgid "And:" msgstr "こうなりました:" -#: ../../howto/argparse.rst:590 msgid "" "$ python prog.py 4\n" "16" msgstr "" +"$ python prog.py 4\n" +"16" #: ../../howto/argparse.rst:595 msgid "" @@ -935,7 +1200,6 @@ msgstr "" "もし、この小さなプログラムを二乗以外の累乗が行えるように拡張するとどうなるで" "しょうか::" -#: ../../howto/argparse.rst:607 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -951,13 +1215,25 @@ msgid "" "else:\n" " print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0)\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"if args.verbosity >= 2:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"elif args.verbosity >= 1:\n" +" print(f\"{args.x}^{args.y} == {answer}\")\n" +"else:\n" +" print(answer)" #: ../../howto/argparse.rst:621 ../../howto/argparse.rst:659 #: ../../howto/argparse.rst:875 msgid "Output:" msgstr "出力:" -#: ../../howto/argparse.rst:623 msgid "" "$ python prog.py\n" "usage: prog.py [-h] [-v] x y\n" @@ -975,6 +1251,21 @@ msgid "" "$ python prog.py 4 2 -v\n" "4^2 == 16" msgstr "" +"$ python prog.py\n" +"usage: prog.py [-h] [-v] x y\n" +"prog.py: error: the following arguments are required: x, y\n" +"$ python prog.py -h\n" +"usage: prog.py [-h] [-v] x y\n" +"\n" +"positional arguments:\n" +" x the base\n" +" y the exponent\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbosity\n" +"$ python prog.py 4 2 -v\n" +"4^2 == 16" #: ../../howto/argparse.rst:642 msgid "" @@ -985,7 +1276,6 @@ msgstr "" "これまで、出力されるテキストを *変更する* ために詳細レベルを使ってきました。" "かわりに下記の例では、*追加の* テキストを出力するのに詳細レベルを使用します::" -#: ../../howto/argparse.rst:646 msgid "" "import argparse\n" "parser = argparse.ArgumentParser()\n" @@ -1000,8 +1290,19 @@ msgid "" " print(f\"{args.x}^{args.y} == \", end=\"\")\n" "print(answer)" msgstr "" +"import argparse\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"parser.add_argument(\"-v\", \"--verbosity\", action=\"count\", default=0)\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"if args.verbosity >= 2:\n" +" print(f\"Running '{__file__}'\")\n" +"if args.verbosity >= 1:\n" +" print(f\"{args.x}^{args.y} == \", end=\"\")\n" +"print(answer)" -#: ../../howto/argparse.rst:661 msgid "" "$ python prog.py 4 2\n" "16\n" @@ -1011,6 +1312,13 @@ msgid "" "Running 'prog.py'\n" "4^2 == 16" msgstr "" +"$ python prog.py 4 2\n" +"16\n" +"$ python prog.py 4 2 -v\n" +"4^2 == 16\n" +"$ python prog.py 4 2 -vv\n" +"Running 'prog.py'\n" +"4^2 == 16" #: ../../howto/argparse.rst:675 msgid "Specifying ambiguous arguments" @@ -1026,7 +1334,6 @@ msgstr "" "いまいさがあるときは、 ``--`` を使うことで :meth:`~ArgumentParser." "parse_args` に対してこれ以降は位置引数であることを伝えることができます::" -#: ../../howto/argparse.rst:681 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-n', nargs='+')\n" @@ -1047,12 +1354,29 @@ msgid "" ">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" "Namespace(args=['2', '3'], n=['1'])" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-n', nargs='+')\n" +">>> parser.add_argument('args', nargs='*')\n" +"\n" +">>> # 曖昧なので、parse_args はオプションと解釈する\n" +">>> parser.parse_args(['-f'])\n" +"usage: PROG [-h] [-n N [N ...]] [args ...]\n" +"PROG: error: unrecognized arguments: -f\n" +"\n" +">>> parser.parse_args(['--', '-f'])\n" +"Namespace(args=['-f'], n=None)\n" +"\n" +">>> # 曖昧なので、-n オプションは引数を取れるだけ取る\n" +">>> parser.parse_args(['-n', '1', '2', '3'])\n" +"Namespace(args=[], n=['1', '2', '3'])\n" +"\n" +">>> parser.parse_args(['-n', '1', '--', '2', '3'])\n" +"Namespace(args=['2', '3'], n=['1'])" #: ../../howto/argparse.rst:702 msgid "Conflicting options" msgstr "競合するオプション" -#: ../../howto/argparse.rst:704 msgid "" "So far, we have been working with two methods of an :class:`argparse." "ArgumentParser` instance. Let's introduce a third one, :meth:" @@ -1061,14 +1385,14 @@ msgid "" "program so that the new functionality makes more sense: we'll introduce the " "``--quiet`` option, which will be the opposite of the ``--verbose`` one::" msgstr "" -"これまでのところ、 :class:`argparse.ArgumentParser` インスタンスの2つのメソッ" -"ドについて学んできました。ここで3つめのメソッドとして :meth:`~ArgumentParser." -"add_mutually_exclusive_group` を導入しましょう。このメソッドは互いに対立する" -"引数の指定を可能にします。また、新しい機能として理解しやすいように、プログラ" -"ムの残りの部分を変更しましょう: 以下では ``--quiet`` オプションを ``--" -"verbose`` と反対のオプションとして導入します::" +"これまで :class:`argparse.ArgumentParser` インスタンスの 2 つのメソッドを使っ" +"てきました。\n" +"3 つ目の :meth:`~ArgumentParser.add_mutually_exclusive_group` を紹介しましょ" +"う。\n" +"このメソッドでは、互いに同時指定できないオプションを定義できます。\n" +"新しい機能の意味が伝わるよう、プログラムのほかの部分も変更し、``--verbose`` " +"と反対の働きをする ``--quiet`` オプションを導入します。 ::" -#: ../../howto/argparse.rst:712 msgid "" "import argparse\n" "\n" @@ -1088,16 +1412,31 @@ msgid "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" msgstr "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"group = parser.add_mutually_exclusive_group()\n" +"group.add_argument(\"-v\", \"--verbose\", action=\"store_true\")\n" +"group.add_argument(\"-q\", \"--quiet\", action=\"store_true\")\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"\n" +"if args.quiet:\n" +" print(answer)\n" +"elif args.verbose:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"else:\n" +" print(f\"{args.x}^{args.y} == {answer}\")" -#: ../../howto/argparse.rst:730 msgid "" "Our program is now simpler, and we've lost some functionality for the sake " "of demonstration. Anyways, here's the output:" msgstr "" -"プログラムはより簡潔になりましたが、デモのための機能が失われました。ともかく" -"下記が実行結果です:" +"プログラムは簡単になり、説明のためにいくつかの機能を省きました。\n" +"出力を見てみましょう。" -#: ../../howto/argparse.rst:733 msgid "" "$ python prog.py 4 2\n" "4^2 == 16\n" @@ -1112,6 +1451,18 @@ msgid "" "usage: prog.py [-h] [-v | -q] x y\n" "prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" msgstr "" +"$ python prog.py 4 2\n" +"4^2 == 16\n" +"$ python prog.py 4 2 -q\n" +"16\n" +"$ python prog.py 4 2 -v\n" +"4 to the power 2 equals 16\n" +"$ python prog.py 4 2 -vq\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose\n" +"$ python prog.py 4 2 -v --quiet\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose" #: ../../howto/argparse.rst:748 msgid "" @@ -1131,7 +1482,6 @@ msgstr "" "結びの前に、恐らくあなたはプログラムの主な目的をユーザに伝えたいでしょう。万" "が一、彼らがそれを知らないときに備えて::" -#: ../../howto/argparse.rst:755 msgid "" "import argparse\n" "\n" @@ -1152,6 +1502,24 @@ msgid "" "else:\n" " print(f\"{args.x}^{args.y} == {answer}\")" msgstr "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(description=\"calculate X to the power of " +"Y\")\n" +"group = parser.add_mutually_exclusive_group()\n" +"group.add_argument(\"-v\", \"--verbose\", action=\"store_true\")\n" +"group.add_argument(\"-q\", \"--quiet\", action=\"store_true\")\n" +"parser.add_argument(\"x\", type=int, help=\"the base\")\n" +"parser.add_argument(\"y\", type=int, help=\"the exponent\")\n" +"args = parser.parse_args()\n" +"answer = args.x**args.y\n" +"\n" +"if args.quiet:\n" +" print(answer)\n" +"elif args.verbose:\n" +" print(f\"{args.x} to the power {args.y} equals {answer}\")\n" +"else:\n" +" print(f\"{args.x}^{args.y} == {answer}\")" #: ../../howto/argparse.rst:773 msgid "" @@ -1162,7 +1530,6 @@ msgstr "" "使用方法のテキストが少し変化しました。``[-v | -q]`` は ``-v`` または ``-q`` " "のどちらかを使用できるが、同時に両方を使用できないことを意味します:" -#: ../../howto/argparse.rst:777 ../../howto/argparse.rst:804 msgid "" "$ python prog.py --help\n" "usage: prog.py [-h] [-v | -q] x y\n" @@ -1178,6 +1545,19 @@ msgid "" " -v, --verbose\n" " -q, --quiet" msgstr "" +"$ python prog.py --help\n" +"usage: prog.py [-h] [-v | -q] x y\n" +"\n" +"calculate X to the power of Y\n" +"\n" +"positional arguments:\n" +" x the base\n" +" y the exponent\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -v, --verbose\n" +" -q, --quiet" #: ../../howto/argparse.rst:795 msgid "How to translate the argparse output" @@ -1217,9 +1597,8 @@ msgstr "" "す。たとえば、 `Babel `__ を使い、次のコマンドを実" "行します。" -#: ../../howto/argparse.rst:827 msgid "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" -msgstr "" +msgstr "$ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py" #: ../../howto/argparse.rst:831 msgid "" @@ -1239,11 +1618,12 @@ msgstr "" "システム上の :mod:`argparse` モジュールの場所は、次のスクリプトで調べられま" "す::" -#: ../../howto/argparse.rst:838 msgid "" "import argparse\n" "print(argparse.__file__)" msgstr "" +"import argparse\n" +"print(argparse.__file__)" #: ../../howto/argparse.rst:841 msgid "" @@ -1263,33 +1643,39 @@ msgstr "" ":mod:`argparse` 出力内のあなたの文字列を翻訳するには、 :mod:`gettext` を使い" "ます。" -#: ../../howto/argparse.rst:848 msgid "Custom type converters" -msgstr "" +msgstr "独自の型変換" -#: ../../howto/argparse.rst:850 msgid "" "The :mod:`argparse` module allows you to specify custom type converters for " "your command-line arguments. This allows you to modify user input before " "it's stored in the :class:`argparse.Namespace`. This can be useful when you " "need to pre-process the input before it is used in your program." msgstr "" +":mod:`argparse` モジュールでは、コマンドライン引数に独自の型変換処理を指定で" +"きます。\n" +"これにより、利用者の入力を :class:`argparse.Namespace` に格納する前に変換でき" +"ます。\n" +"プログラムで入力を使う前に前処理が必要な場合に役立ちます。" -#: ../../howto/argparse.rst:855 msgid "" "When using a custom type converter, you can use any callable that takes a " "single string argument (the argument value) and returns the converted value. " "However, if you need to handle more complex scenarios, you can use a custom " "action class with the **action** parameter instead." msgstr "" +"独自の型変換処理には、引数の値を表す文字列を 1 つ受け取り、変換した値を返す任" +"意の呼び出し可能オブジェクトを使えます。\n" +"もっと複雑な処理が必要な場合は、代わりに **action** 引数で独自のアクションク" +"ラスを指定できます。" -#: ../../howto/argparse.rst:860 msgid "" "For example, let's say you want to handle arguments with different prefixes " "and process them accordingly::" msgstr "" +"例えば、異なるプレフィクスの引数を受け取り、それぞれに応じて処理したいとしま" +"す。 ::" -#: ../../howto/argparse.rst:863 msgid "" "import argparse\n" "\n" @@ -1303,37 +1689,52 @@ msgid "" "args = parser.parse_args()\n" "print(args)" msgstr "" +"import argparse\n" +"\n" +"parser = argparse.ArgumentParser(prefix_chars='-+')\n" +"\n" +"parser.add_argument('-a', metavar='', action='append',\n" +" type=lambda x: ('-', x))\n" +"parser.add_argument('+a', metavar='', action='append',\n" +" type=lambda x: ('+', x))\n" +"\n" +"args = parser.parse_args()\n" +"print(args)" -#: ../../howto/argparse.rst:877 msgid "" "$ python prog.py -a value1 +a value2\n" "Namespace(a=[('-', 'value1'), ('+', 'value2')])" msgstr "" +"$ python prog.py -a value1 +a value2\n" +"Namespace(a=[('-', 'value1'), ('+', 'value2')])" -#: ../../howto/argparse.rst:882 msgid "In this example, we:" -msgstr "" +msgstr "この例では、次のことを行っています。" -#: ../../howto/argparse.rst:884 msgid "" "Created a parser with custom prefix characters using the ``prefix_chars`` " "parameter." msgstr "" +"``prefix_chars`` 引数を使い、独自のプレフィクス文字を持つパーサを作りました。" -#: ../../howto/argparse.rst:887 msgid "" "Defined two arguments, ``-a`` and ``+a``, which used the ``type`` parameter " "to create custom type converters to store the value in a tuple with the " "prefix." msgstr "" +"``-a`` と ``+a`` という 2 つの引数を定義しました。\n" +"それぞれの ``type`` 引数で独自の型変換処理を指定し、値をプレフィクスと一緒に" +"タプルに格納するようにしました。" -#: ../../howto/argparse.rst:890 msgid "" "Without the custom type converters, the arguments would have treated the ``-" "a`` and ``+a`` as the same argument, which would have been undesirable. By " "using custom type converters, we were able to differentiate between the two " "arguments." msgstr "" +"独自の型変換処理がなければ、``-a`` と ``+a`` は同じ引数として扱われ、望ましく" +"ない結果になります。\n" +"型変換処理を使うことで、2 つの引数を区別できました。" #: ../../howto/argparse.rst:895 msgid "Conclusion" diff --git a/howto/clinic.po b/howto/clinic.po index 8ded29592..26cde45ec 100644 --- a/howto/clinic.po +++ b/howto/clinic.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/clinic.rst:8 diff --git a/howto/cporting.po b/howto/cporting.po index 17ab1a28b..6c3803bd9 100644 --- a/howto/cporting.po +++ b/howto/cporting.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/cporting.rst:7 @@ -50,10 +50,13 @@ msgstr "" "`Porting guide`_ は *py3c* プロジェクトにより提供される、補助コード付きの見解" "提案です。" -#: ../../howto/cporting.rst:17 msgid "" ":ref:`Recommended third party tools ` offer abstractions over " "the Python's C API. Extensions generally need to be re-written to use one of " "them, but the library then handles differences between various Python " "versions and implementations." msgstr "" +":ref:`推奨されるサードパーティーツール ` は、Python の C API を" +"抽象化した機能を提供します。\n" +"これらを使うには通常、拡張を書き直す必要がありますが、その後はライブラリが " +"Python のバージョンや実装の違いを扱ってくれます。" diff --git a/howto/curses.po b/howto/curses.po index 39c220f6f..5e71b4d67 100644 --- a/howto/curses.po +++ b/howto/curses.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/curses.rst:5 @@ -75,7 +75,6 @@ msgstr "" "みのUnixです。ほかにも、OSのインストーラや、カーネル設定などのツールで、これ" "らはグラフィカルサポートが利用可能になる前に動作する必要があります。" -#: ../../howto/curses.rst:35 msgid "" "The curses library provides fairly basic functionality, providing the " "programmer with an abstraction of a display containing multiple non-" @@ -86,6 +85,17 @@ msgid "" "interface concepts such as buttons, checkboxes, or dialogs; if you need such " "features, consider a user interface library such as :pypi:`Urwid`." msgstr "" +"curses ライブラリが提供するのは比較的基本的な機能です。\n" +"画面を、互いに重ならない複数のテキストウィンドウとして扱う仕組みを提供しま" +"す。\n" +"ウィンドウの内容は、テキストの追加や削除、見た目の変更など、さまざまな方法で" +"変更できます。\n" +"curses ライブラリは、意図した表示にするために端末へ送る制御コードを判断しま" +"す。\n" +"ボタン、チェックボックス、ダイアログなどのユーザーインターフェース部品の多く" +"は提供しません。\n" +"そのような機能が必要なら、:pypi:`Urwid` などのユーザーインターフェースライブ" +"ラリを検討してください。" #: ../../howto/curses.rst:45 msgid "" @@ -108,18 +118,19 @@ msgstr "" "述べる全ての関数が利用できるはずです。しかし、古いバージョンの curses を持つ" "いくつかのプロプライエタリ Unix は全てには対応していないでしょう。" -#: ../../howto/curses.rst:55 msgid "" "The Windows version of Python doesn't include the :mod:`curses` module. The " "third-party :pypi:`windows-curses` package provides the same interface on " "Windows." msgstr "" +"Windows 版の Python には :mod:`curses` モジュールが含まれていません。\n" +"サードパーティーの :pypi:`windows-curses` パッケージが、Windows で同じイン" +"ターフェースを提供します。" #: ../../howto/curses.rst:60 msgid "The Python curses module" msgstr "Python の curses module" -#: ../../howto/curses.rst:62 msgid "" "The Python module is a fairly simple wrapper over the C functions provided " "by curses; if you're already familiar with curses programming in C, it's " @@ -129,6 +140,13 @@ msgid "" "mvwaddstr` into a single :meth:`~curses.window.addstr` method. You'll see " "this covered in more detail later." msgstr "" +"Python のモジュールは、curses が提供する C 関数の比較的単純なラッパです。\n" +"C での curses プログラミングに慣れていれば、その知識を Python でも簡単に生か" +"せます。\n" +"最大の違いは、Python のインターフェースでは :c:func:`!addstr`、:c:func:`!" +"mvaddstr`、:c:func:`!mvwaddstr` のような別々の C 関数を 1 つの :meth:" +"`~curses.window.addstr` メソッドにまとめ、扱いやすくしていることです。\n" +"詳しくは後で説明します。" #: ../../howto/curses.rst:70 msgid "" @@ -147,7 +165,6 @@ msgstr "" msgid "Starting and ending a curses application" msgstr "curses アプリケーションの起動と終了" -#: ../../howto/curses.rst:79 msgid "" "Before doing anything, curses must be initialized. This is done by calling " "the :func:`~curses.initscr` function, which will determine the terminal " @@ -156,23 +173,31 @@ msgid "" "object representing the entire screen; this is usually called ``stdscr`` " "after the name of the corresponding C variable. ::" msgstr "" +"何をするにしても、まず curses を初期化する必要があります。\n" +":func:`~curses.initscr` 関数を呼び出すと、端末の種類を判定し、必要な設定コー" +"ドを端末へ送り、内部の各種データ構造を作成します。\n" +"成功すると、:func:`!initscr` は画面全体を表すウィンドウオブジェクトを返しま" +"す。\n" +"これは対応する C の変数名にちなんで、通常 ``stdscr`` と呼ばれます。 ::" -#: ../../howto/curses.rst:87 msgid "" "import curses\n" "stdscr = curses.initscr()" msgstr "" +"import curses\n" +"stdscr = curses.initscr()" -#: ../../howto/curses.rst:90 msgid "" "Usually curses applications turn off automatic echoing of keys to the " "screen, in order to be able to read keys and only display them under certain " "circumstances. This requires calling the :func:`~curses.noecho` function. ::" msgstr "" +"通常、curses アプリケーションではキー入力を自動的に画面へ表示する機能 (エ" +"コー) を無効にし、キーを読み取った後、必要な場合にだけ表示します。\n" +"そのためには :func:`~curses.noecho` 関数を呼び出します。 ::" -#: ../../howto/curses.rst:95 msgid "curses.noecho()" -msgstr "" +msgstr "curses.noecho()" #: ../../howto/curses.rst:97 msgid "" @@ -184,11 +209,9 @@ msgstr "" "する必要があります; これは cbreak モードと呼ばれ、通常の入力がバッファされる" "モードと逆に動作します。 ::" -#: ../../howto/curses.rst:101 msgid "curses.cbreak()" -msgstr "" +msgstr "curses.cbreak()" -#: ../../howto/curses.rst:103 msgid "" "Terminals usually return special keys, such as the cursor keys or navigation " "keys such as Page Up and Home, as a multibyte escape sequence. While you " @@ -197,15 +220,14 @@ msgid "" "const:`curses.KEY_LEFT`. To get curses to do the job, you'll have to enable " "keypad mode. ::" msgstr "" -"端末は通常、カーソルキーや Page Up や Home といった操作キーなどの特別なキーを" -"マルチバイトエスケープシーケンスとして返します。それらのシーケンスを想定して" -"対応する処理を行うアプリケーションを書けるように、 curses はそれを :const:" -"`curses.KEY_LEFT` のような特別な値を返して行ってくれます。 curses にその仕事" -"をさせるには、キーパッドモードを有効にする必要があります。 ::" +"端末は通常、カーソルキーや Page Up、Home などの特殊キーを、複数バイトのエス" +"ケープシーケンスとして返します。\n" +"これらのシーケンスを自分で処理することもできますが、curses に任せると :const:" +"`curses.KEY_LEFT` のような特別な値として受け取れます。\n" +"そのためには、キーパッドモードを有効にします。 ::" -#: ../../howto/curses.rst:110 msgid "stdscr.keypad(True)" -msgstr "" +msgstr "stdscr.keypad(True)" #: ../../howto/curses.rst:112 msgid "" @@ -215,12 +237,14 @@ msgstr "" "curses アプリケーションを終了させるのは起動よりも簡単です。 以下を呼び出す必" "要があります::" -#: ../../howto/curses.rst:115 msgid "" "curses.nocbreak()\n" "stdscr.keypad(False)\n" "curses.echo()" msgstr "" +"curses.nocbreak()\n" +"stdscr.keypad(False)\n" +"curses.echo()" #: ../../howto/curses.rst:119 msgid "" @@ -231,11 +255,9 @@ msgstr "" "cursesに親和性の高い設定をもとに戻します。そして、:func:`~curses.endwin` 関数" "を呼び出し、端末を通常の操作モードに復旧します。 ::" -#: ../../howto/curses.rst:123 msgid "curses.endwin()" -msgstr "" +msgstr "curses.endwin()" -#: ../../howto/curses.rst:125 msgid "" "A common problem when debugging a curses application is to get your terminal " "messed up when the application dies without restoring the terminal to its " @@ -243,11 +265,11 @@ msgid "" "raises an uncaught exception. Keys are no longer echoed to the screen when " "you type them, for example, which makes using the shell difficult." msgstr "" -"curses アプリケーションをデバッグするときの一般的な問題は、アプリケーションが" -"端末を以前の状態に復旧することなく異常終了したときに端末がめちゃめちゃになる" -"ことです。Python ではこの問題はコードにバグがあって、捕捉できない例外が発生し" -"たときによく起きます。タイプしたキーはもはやエコーされません、例えば、シェル" -"を使うのが難しくなります。" +"curses アプリケーションのデバッグでよくある問題は、端末の状態を復元する前にア" +"プリケーションが終了し、端末がおかしな状態のままになることです。\n" +"Python では、コードのバグで例外が発生し、それが捕捉されなかった場合によく起こ" +"ります。\n" +"例えば、入力したキーが画面に表示されなくなり、シェルを使いにくくなります。" #: ../../howto/curses.rst:131 msgid "" @@ -257,7 +279,6 @@ msgstr "" "Pythonでは、これらの複雑さを避けデバッグをより容易にするために、 :func:" "`curses.wrapper` 関数をインポートして、このように使います::" -#: ../../howto/curses.rst:134 msgid "" "from curses import wrapper\n" "\n" @@ -275,8 +296,22 @@ msgid "" "\n" "wrapper(main)" msgstr "" +"from curses import wrapper\n" +"\n" +"def main(stdscr):\n" +" # 画面を消去する\n" +" stdscr.clear()\n" +"\n" +" # i == 10 のとき ZeroDivisionError が発生する。\n" +" for i in range(0, 11):\n" +" v = i-10\n" +" stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))\n" +"\n" +" stdscr.refresh()\n" +" stdscr.getkey()\n" +"\n" +"wrapper(main)" -#: ../../howto/curses.rst:150 msgid "" "The :func:`~curses.wrapper` function takes a callable object and does the " "initializations described above, also initializing colors if color support " @@ -288,19 +323,29 @@ msgid "" "funny state on exception and you'll be able to read the exception's message " "and traceback." msgstr "" +":func:`~curses.wrapper` 関数は呼び出し可能オブジェクトを受け取り、上記の初期" +"化を行います。\n" +"色がサポートされていれば、色の初期化も行います。\n" +"その後、:func:`!wrapper` は渡された呼び出し可能オブジェクトを実行します。\n" +"その呼び出しから戻ると、:func:`!wrapper` は端末をもとの状態に戻します。\n" +"呼び出しは :keyword:`try`...\\ :keyword:`except` の中で行われ、例外が発生する" +"と、それを捕捉して端末の状態を復元してから再送出します。\n" +"そのため、例外が発生しても端末が異常な状態のままにならず、例外のメッセージや" +"トレースバックを読めます。" #: ../../howto/curses.rst:164 msgid "Windows and Pads" msgstr "ウィンドウとパッド" -#: ../../howto/curses.rst:166 msgid "" "Windows are the basic abstraction in curses. A window object represents a " "rectangular area of the screen, and supports methods to display text, erase " "it, allow the user to input strings, and so forth." msgstr "" +"curses の基本となる抽象化はウィンドウです。\n" +"ウィンドウオブジェクトは画面上の長方形の領域を表し、テキストの表示や消去、利" +"用者による文字列の入力などのメソッドを備えています。" -#: ../../howto/curses.rst:170 msgid "" "The ``stdscr`` object returned by the :func:`~curses.initscr` function is a " "window object that covers the entire screen. Many programs may need only " @@ -309,15 +354,22 @@ msgid "" "newwin` function creates a new window of a given size, returning the new " "window object. ::" msgstr "" +":func:`~curses.initscr` 関数が返す ``stdscr`` オブジェクトは、画面全体を覆う" +"ウィンドウオブジェクトです。\n" +"多くのプログラムはこのウィンドウだけで十分ですが、個別に再描画や消去を行うた" +"めに、画面を小さなウィンドウに分けたい場合もあるでしょう。\n" +":func:`~curses.newwin` 関数は、指定されたサイズの新しいウィンドウを作り、その" +"ウィンドウオブジェクトを返します。 ::" -#: ../../howto/curses.rst:177 msgid "" "begin_x = 20; begin_y = 7\n" "height = 5; width = 40\n" "win = curses.newwin(height, width, begin_y, begin_x)" msgstr "" +"begin_x = 20; begin_y = 7\n" +"height = 5; width = 40\n" +"win = curses.newwin(height, width, begin_y, begin_x)" -#: ../../howto/curses.rst:181 msgid "" "Note that the coordinate system used in curses is unusual. Coordinates are " "always passed in the order *y,x*, and the top-left corner of a window is " @@ -326,23 +378,33 @@ msgid "" "difference from most other computer applications, but it's been part of " "curses since it was first written, and it's too late to change things now." msgstr "" +"curses の座標系は独特なので注意してください。\n" +"座標は常に *y,x* の順に渡し、ウィンドウの左上隅が (0,0) です。\n" +"これは *x* 座標を先にする通常の慣習と異なります。\n" +"ほかの多くのアプリケーションと違うのは残念ですが、curses の最初の実装からこの" +"方式なので、今から変更するには遅すぎます。" -#: ../../howto/curses.rst:189 msgid "" "Your application can determine the size of the screen by using the :data:" "`curses.LINES` and :data:`curses.COLS` variables to obtain the *y* and *x* " "sizes. Legal coordinates will then extend from ``(0,0)`` to ``(curses.LINES " "- 1, curses.COLS - 1)``." msgstr "" +"画面のサイズは、:data:`curses.LINES` と :data:`curses.COLS` 変数からそれぞれ " +"*y* 方向と *x* 方向の大きさを取得して調べられます。\n" +"有効な座標の範囲は ``(0,0)`` から ``(curses.LINES - 1, curses.COLS - 1)`` ま" +"でです。" -#: ../../howto/curses.rst:194 msgid "" "When you call a method to display or erase text, the effect doesn't " "immediately show up on the display. Instead you must call the :meth:" "`~curses.window.refresh` method of window objects to update the screen." msgstr "" +"テキストを表示または消去するメソッドを呼び出しても、その結果はすぐには画面に" +"現れません。\n" +"画面を更新するには、ウィンドウオブジェクトの :meth:`~curses.window.refresh` " +"メソッドを呼び出す必要があります。" -#: ../../howto/curses.rst:199 msgid "" "This is because curses was originally written with slow 300-baud terminal " "connections in mind; with these terminals, minimizing the time required to " @@ -352,8 +414,15 @@ msgid "" "window and then clears the window, there's no need to send the original text " "because they're never visible." msgstr "" +"これは、curses が当初、300 ボーという低速な端末接続を想定して書かれたためで" +"す。\n" +"そのような端末では、画面の再描画にかかる時間を最小限にすることが非常に重要で" +"した。\n" +"そこで curses は画面への変更を蓄積し、:meth:`!refresh` が呼ばれたときに最も効" +"率的な方法で表示します。\n" +"例えば、プログラムがウィンドウにテキストを表示してからそのウィンドウを消去し" +"た場合、テキストは実際には表示されないので、端末へ送る必要がありません。" -#: ../../howto/curses.rst:208 msgid "" "In practice, explicitly telling curses to redraw a window doesn't really " "complicate programming with curses much. Most programs go into a flurry of " @@ -362,8 +431,13 @@ msgid "" "redrawn before pausing to wait for user input, by first calling :meth:`!" "stdscr.refresh` or the :meth:`!refresh` method of some other relevant window." msgstr "" +"実際には、ウィンドウの再描画を明示的に指示しても、curses のプログラミングはそ" +"れほど複雑になりません。\n" +"多くのプログラムは一連の処理を行った後、キー入力などの利用者の操作を待って休" +"止します。\n" +"入力待ちに入る前に :meth:`!stdscr.refresh` または必要なほかのウィンドウの :" +"meth:`!refresh` を呼び出し、画面を再描画しておけばよいのです。" -#: ../../howto/curses.rst:216 msgid "" "A pad is a special case of a window; it can be larger than the actual " "display screen, and only a portion of the pad displayed at a time. Creating " @@ -371,8 +445,11 @@ msgid "" "giving the coordinates of the on-screen area where a subsection of the pad " "will be displayed. ::" msgstr "" +"パッドは特殊なウィンドウです。\n" +"実際の画面より大きくでき、一度に表示するのはその一部だけです。\n" +"作成時にはパッドの高さと幅を指定し、更新時にはパッドの一部を表示する画面上の" +"領域の座標を指定します。 ::" -#: ../../howto/curses.rst:222 msgid "" "pad = curses.newpad(100, 100)\n" "# These loops fill the pad with letters; addch() is\n" @@ -389,8 +466,21 @@ msgid "" "# : filled with pad content.\n" "pad.refresh( 0,0, 5,5, 20,75)" msgstr "" +"pad = curses.newpad(100, 100)\n" +"# このループでパッドを文字で埋める。addch() は\n" +"# 次の節で説明する。\n" +"for y in range(0, 99):\n" +" for x in range(0, 99):\n" +" pad.addch(y,x, ord('a') + (x*x+y*y) % 26)\n" +"\n" +"# 画面中央にパッドの一部を表示する。\n" +"# (0,0) : 表示するパッド領域の左上隅の座標。\n" +"# (5,5) : パッドの内容を表示するウィンドウ領域の\n" +"# 左上隅の座標。\n" +"# (20, 75) : パッドの内容を表示するウィンドウ領域の\n" +"# : 右下隅の座標。\n" +"pad.refresh( 0,0, 5,5, 20,75)" -#: ../../howto/curses.rst:237 msgid "" "The :meth:`!refresh` call displays a section of the pad in the rectangle " "extending from coordinate (5,5) to coordinate (20,75) on the screen; the " @@ -398,21 +488,27 @@ msgid "" "Beyond that difference, pads are exactly like ordinary windows and support " "the same methods." msgstr "" +":meth:`!refresh` の呼び出しは、画面上の座標 (5,5) から (20,75) までの長方形" +"に、パッドの一部を表示します。\n" +"表示する部分の左上隅は、パッド上の座標 (0,0) です。\n" +"この点以外は、パッドは通常のウィンドウとまったく同じで、同じメソッドを使えま" +"す。" -#: ../../howto/curses.rst:243 msgid "" "If you have multiple windows and pads on screen there is a more efficient " "way to update the screen and prevent annoying screen flicker as each part of " "the screen gets updated. :meth:`!refresh` actually does two things:" msgstr "" +"画面上に複数のウィンドウやパッドがある場合は、各部分の更新に伴うちらつきを防" +"ぎ、画面をより効率的に更新する方法があります。\n" +":meth:`!refresh` は実際には次の 2 つの処理を行っています。" -#: ../../howto/curses.rst:248 msgid "" "Calls the :meth:`~curses.window.noutrefresh` method of each window to update " "an underlying data structure representing the desired state of the screen." msgstr "" "それぞれのウィンドウの :meth:`~curses.window.noutrefresh` メソッドを呼び出し" -"て、配下にある、スクリーンの望ましい状態を表すデータ構造を更新します。 " +"て、配下にある、スクリーンの望ましい状態を表すデータ構造を更新します。" #: ../../howto/curses.rst:251 msgid "" @@ -422,17 +518,17 @@ msgstr "" ":func:`~curses.doupdate` 関数を呼び出して、データ構造に記録された望ましい状態" "に合致するように、物理スクリーンを更新します。" -#: ../../howto/curses.rst:254 msgid "" "Instead you can call :meth:`!noutrefresh` on a number of windows to update " "the data structure, and then call :func:`!doupdate` to update the screen." msgstr "" +"代わりに、複数のウィンドウで :meth:`!noutrefresh` を呼んでデータ構造を更新" +"し、その後 :func:`!doupdate` を呼んで画面を更新できます。" #: ../../howto/curses.rst:260 msgid "Displaying Text" msgstr "テキストの表示" -#: ../../howto/curses.rst:262 msgid "" "From a C programmer's point of view, curses may sometimes look like a twisty " "maze of functions, all subtly different. For example, :c:func:`!addstr` " @@ -443,6 +539,14 @@ msgid "" "default. :c:func:`!mvwaddstr` allows specifying both a window and a " "coordinate." msgstr "" +"C プログラマから見ると、curses は少しずつ異なる関数が入り組んだ迷路のように見" +"えることがあります。\n" +"例えば、:c:func:`!addstr` は ``stdscr`` ウィンドウの現在のカーソル位置に文字" +"列を表示し、:c:func:`!mvaddstr` は先に指定された y,x 座標へ移動してから表示し" +"ます。\n" +":c:func:`!waddstr` は :c:func:`!addstr` と同様ですが、デフォルトの " +"``stdscr`` の代わりに、使うウィンドウを指定できます。\n" +":c:func:`!mvwaddstr` ではウィンドウと座標の両方を指定できます。" #: ../../howto/curses.rst:271 msgid "" @@ -512,7 +616,6 @@ msgstr "" "属性によって表示するテキストをハイライトすることができます、ボールド体、アン" "ダーライン、反転、カラーなど。より詳しくは次の小節で説明します。" -#: ../../howto/curses.rst:298 msgid "" "The :meth:`~curses.window.addstr` method takes a Python string or bytestring " "as the value to be displayed. The contents of bytestrings are sent to the " @@ -521,22 +624,32 @@ msgid "" "this defaults to the default system encoding as returned by :func:`locale." "getencoding`." msgstr "" +":meth:`~curses.window.addstr` メソッドは、表示する値として Python の文字列ま" +"たはバイト列を受け取ります。\n" +"バイト列の内容はそのまま端末へ送られます。\n" +"ワイド文字に対応していないビルドでは、文字列はウィンドウの :attr:`~window." +"encoding` 属性の値でエンコードされます。\n" +"この属性のデフォルト値は、:func:`locale.getencoding` が返すシステムのデフォル" +"トエンコーディングです。" -#: ../../howto/curses.rst:306 msgid "" "The :meth:`~curses.window.addch` methods take a character, which can be " "either a string of length 1, a bytestring of length 1, or an integer." msgstr "" +":meth:`~curses.window.addch` メソッドは文字を受け取ります。\n" +"文字は、長さ 1 の文字列、長さ 1 のバイト列、または整数で指定できます。" -#: ../../howto/curses.rst:309 msgid "" "Constants are provided for the characters of the terminal's alternate " "character set. For example, :const:`ACS_PLMINUS` is a +/- symbol, and :const:" "`ACS_ULCORNER` is the upper left corner of a box (handy for drawing " "borders). You can also use the appropriate Unicode character." msgstr "" +"端末の代替文字集合の文字に対応する定数が用意されています。\n" +"例えば、:const:`ACS_PLMINUS` は +/- 記号、:const:`ACS_ULCORNER` は枠の左上隅" +"で、罫線を描くのに便利です。\n" +"対応する Unicode 文字を使うこともできます。" -#: ../../howto/curses.rst:316 msgid "" "Windows remember where the cursor was left after the last operation, so if " "you leave out the *y,x* coordinates, the string or character will be " @@ -546,14 +659,13 @@ msgid "" "some location where it won't be distracting; it can be confusing to have the " "cursor blinking at some apparently random location." msgstr "" -"ウィンドウは最後の操作の後のカーソル位置を覚えているため、 *y,x* 座標をうっか" -"り忘れてしまっても、文字列や文字は最後の操作位置に表示されます。 ``move(y," -"x)`` メソッドでカーソルを移動させることもできます。常に点滅するカーソルを表示" -"する端末もあるため、カーソルが特定の位置にいることを保証して注意が反れないよ" -"うにしたいと思うかもしれません; ランダムに見える位置でカーソルが点滅すると面" -"を食らってしまいます。" +"ウィンドウは最後の操作後のカーソル位置を覚えているので、*y,x* 座標を省略する" +"と、文字列や文字は直前の操作でカーソルが残った位置に表示されます。\n" +"``move(y,x)`` メソッドでカーソルを移動することもできます。\n" +"常に点滅するカーソルを表示する端末もあるので、邪魔にならない位置にカーソルを" +"置くとよいでしょう。\n" +"無関係に見える場所でカーソルが点滅すると、混乱を招くことがあります。" -#: ../../howto/curses.rst:324 msgid "" "If your application doesn't need a blinking cursor at all, you can call " "``curs_set(False)`` to make it invisible. The window method :meth:`~curses." @@ -561,18 +673,27 @@ msgid "" "leaves the cursor wherever the last update put it, instead of moving it back " "to the window's cursor position." msgstr "" +"アプリケーションで点滅するカーソルがまったく必要なければ、" +"``curs_set(False)`` を呼んで非表示にできます。\n" +"ウィンドウの :meth:`~curses.window.leaveok` メソッドは、それとは異なる働きを" +"します。\n" +"引数が真の場合、curses はカーソルをウィンドウのカーソル位置に戻さず、最後の更" +"新で移動した位置に残します。" #: ../../howto/curses.rst:333 msgid "Attributes and Color" msgstr "属性とカラー" -#: ../../howto/curses.rst:335 msgid "" "Characters can be displayed in different ways. Status lines in a text-based " "application are commonly shown in reverse video, or a text viewer may need " "to highlight certain words. curses supports this by allowing you to specify " "an attribute for each cell on the screen." msgstr "" +"文字にはさまざまな表示方法があります。\n" +"テキストベースのアプリケーションではステータス行を反転表示することが多く、テ" +"キストビューアでは特定の単語を強調表示したい場合があります。\n" +"curses では画面上の各セルに属性を指定して、これらを実現できます。" #: ../../howto/curses.rst:340 msgid "" @@ -649,12 +770,14 @@ msgstr "" "つまり、反転するステータスラインを画面の最上部に表示するには、コードをこうし" "ます::" -#: ../../howto/curses.rst:366 msgid "" "stdscr.addstr(0, 0, \"Current mode: Typing mode\",\n" " curses.A_REVERSE)\n" "stdscr.refresh()" msgstr "" +"stdscr.addstr(0, 0, \"Current mode: Typing mode\",\n" +" curses.A_REVERSE)\n" +"stdscr.refresh()" #: ../../howto/curses.rst:370 msgid "" @@ -666,7 +789,6 @@ msgstr "" "す。そんな端末の中で最も一般的なものは Linux コンソールで、color xterm もそれ" "に続きます。" -#: ../../howto/curses.rst:374 msgid "" "To use color, you must call the :func:`~curses.start_color` function soon " "after calling :func:`~curses.initscr`, to initialize the default color set " @@ -677,8 +799,16 @@ msgid "" "to the British spelling, you'll have to resign yourself to misspelling it " "for the sake of these functions.)" msgstr "" +"色を使うには、:func:`~curses.initscr` の直後に :func:`~curses.start_color` を" +"呼び出し、デフォルトの色を初期化する必要があります (:func:`curses.wrapper` は" +"これを自動的に行います)。\n" +"初期化後、使用中の端末が実際にカラー表示に対応していれば、:func:`~curses." +"has_colors` は真を返します。\n" +"なお、curses はカナダやイギリスの綴り colour ではなく、アメリカの綴り color " +"を使います。\n" +"イギリス式の綴りに慣れている方も、これらの関数では「綴り間違い」を我慢してく" +"ださい。" -#: ../../howto/curses.rst:384 msgid "" "The curses library maintains a finite number of color pairs, containing a " "foreground (or text) color and a background color. You can get the " @@ -687,16 +817,23 @@ msgid "" "as :const:`A_REVERSE`, but again, such combinations are not guaranteed to " "work on all terminals." msgstr "" +"curses ライブラリは、前景色 (文字の色) と背景色からなる有限個のカラーペアを管" +"理します。\n" +":func:`~curses.color_pair` 関数で、カラーペアに対応する属性値を取得できま" +"す。\n" +"この値は :const:`A_REVERSE` などのほかの属性とビット単位の OR で組み合わせら" +"れますが、その組み合わせがすべての端末で動くとは限りません。" #: ../../howto/curses.rst:391 msgid "An example, which displays a line of text using color pair 1::" msgstr "例として、テキスト行をカラーペア 1 を使って表示します::" -#: ../../howto/curses.rst:393 msgid "" "stdscr.addstr(\"Pretty text\", curses.color_pair(1))\n" "stdscr.refresh()" msgstr "" +"stdscr.addstr(\"Pretty text\", curses.color_pair(1))\n" +"stdscr.refresh()" #: ../../howto/curses.rst:396 msgid "" @@ -706,7 +843,6 @@ msgid "" "hard-wired to white on black, and cannot be changed." msgstr "" -#: ../../howto/curses.rst:401 msgid "" "Colors are numbered, and :func:`start_color` initializes 8 basic colors when " "it activates color mode. They are: 0:black, 1:red, 2:green, 3:yellow, 4:" @@ -714,6 +850,12 @@ msgid "" "named constants for each of these colors: :const:`curses.COLOR_BLACK`, :" "const:`curses.COLOR_RED`, and so forth." msgstr "" +"色には番号が付いており、:func:`start_color` はカラーモードを有効にするときに " +"8 つの基本色を初期化します。\n" +"0 は黒、1 は赤、2 は緑、3 は黄、4 は青、5 はマゼンタ、6 はシアン、7 は白で" +"す。\n" +":mod:`curses` モジュールは各色に :const:`curses.COLOR_BLACK`、:const:`curses." +"COLOR_RED` などの定数を定義しています。" #: ../../howto/curses.rst:407 msgid "" @@ -723,22 +865,20 @@ msgstr "" "やってみましょう。カラー 1 を白背景に赤に変更してみましょう、こうして呼び出し" "ます::" -#: ../../howto/curses.rst:410 msgid "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)" -msgstr "" +msgstr "curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)" -#: ../../howto/curses.rst:412 msgid "" "When you change a color pair, any text already displayed using that color " "pair will change to the new colors. You can also display new text in this " "color with::" msgstr "" -"カラーペアを変更するときには、既に表示された任意のテキストが利用するカラーペ" -"アを新しい色に変更します。新しいテキストをこの色で使うこともできます::" +"カラーペアを変更すると、そのペアを使って既に表示されているテキストも新しい色" +"になります。\n" +"次のように、その色で新たなテキストを表示することもできます。 ::" -#: ../../howto/curses.rst:416 msgid "stdscr.addstr(0,0, \"RED ALERT!\", curses.color_pair(1))" -msgstr "" +msgstr "stdscr.addstr(0,0, \"RED ALERT!\", curses.color_pair(1))" #: ../../howto/curses.rst:418 msgid "" @@ -756,41 +896,51 @@ msgstr "" msgid "User Input" msgstr "ユーザ入力" -#: ../../howto/curses.rst:431 msgid "" "The C curses library offers only very simple input mechanisms. Python's :mod:" "`curses` module adds a basic text-input widget. (Other libraries such as :" "pypi:`Urwid` have more extensive collections of widgets.)" msgstr "" +"C の curses ライブラリが提供する入力機能は、ごく単純なものだけです。\n" +"Python の :mod:`curses` モジュールは、基本的なテキスト入力ウィジェットを追加" +"しています。\n" +"(:pypi:`Urwid` などのほかのライブラリには、より豊富なウィジェットがありま" +"す。)" -#: ../../howto/curses.rst:435 msgid "There are three methods for getting input from a window:" -msgstr "" +msgstr "ウィンドウから入力を取得するメソッドは 3 つあります。" -#: ../../howto/curses.rst:437 msgid "" ":meth:`~curses.window.get_wch` refreshes the screen and then waits for the " "user to hit a key, displaying the key if :func:`~curses.echo` has been " "called earlier. You can optionally specify a coordinate to which the cursor " "should be moved before pausing." msgstr "" +":meth:`~curses.window.get_wch` は画面を更新してから、利用者のキー入力を待ちま" +"す。\n" +"事前に :func:`~curses.echo` が呼ばれていれば、入力されたキーを表示します。\n" +"待機する前にカーソルを移動する座標を指定することもできます。" -#: ../../howto/curses.rst:442 msgid "" ":meth:`~curses.window.getch` does the same thing but returns the code of the " "key instead of a character. With ncurses this is a single byte of the key's " "encoding in the current locale, so a character encoded with several bytes " "takes several calls, one byte per call." msgstr "" +":meth:`~curses.window.getch` は同じ処理をしますが、文字の代わりにキーのコード" +"を返します。\n" +"ncurses では、これは現在のロケールでエンコードされたキーの 1 バイトなので、複" +"数バイトの文字を読むには、1 回に 1 バイトずつ複数回呼び出す必要があります。" -#: ../../howto/curses.rst:448 msgid "" ":meth:`~curses.window.getkey` does the same as :meth:`!getch` but returns a " "string: an ordinary key as a 1-character string, and a special key as its " "name, such as ``KEY_UP``." msgstr "" +":meth:`~curses.window.getkey` は :meth:`!getch` と同じ処理をしますが、文字列" +"を返します。\n" +"通常のキーは 1 文字の文字列、特殊キーは ``KEY_UP`` のような名前になります。" -#: ../../howto/curses.rst:453 msgid "" "It's possible to not wait for the user using the :meth:`~curses.window." "nodelay` window method. After ``nodelay(True)``, the reads for the window " @@ -801,6 +951,16 @@ msgid "" "specified delay (measured in tenths of a second), the read fails the same " "way." msgstr "" +"ウィンドウの :meth:`~curses.window.nodelay` メソッドを使うと、利用者の入力を" +"待たずに済むようにできます。\n" +"``nodelay(True)`` の後は、そのウィンドウの読み取りはノンブロッキングになりま" +"す。\n" +"入力がない場合、:meth:`!get_wch` と :meth:`!getkey` は例外を送出し、:meth:`!" +"getch` は ``-1`` を返します。\n" +"また、:func:`~curses.halfdelay` を使うと、実質的に各読み取りにタイマーを設定" +"できます。\n" +"指定した待ち時間 (0.1 秒単位) 内に入力がなければ、読み取りは同じように失敗し" +"ます。" #: ../../howto/curses.rst:464 msgid "" @@ -811,7 +971,6 @@ msgid "" "KEY_LEFT`. The main loop of your program may look something like this::" msgstr "" -#: ../../howto/curses.rst:472 msgid "" "while True:\n" " c = stdscr.get_wch()\n" @@ -822,8 +981,15 @@ msgid "" " elif c == curses.KEY_HOME:\n" " x = y = 0" msgstr "" +"while True:\n" +" c = stdscr.get_wch()\n" +" if c == 'p':\n" +" PrintDocument()\n" +" elif c == 'q':\n" +" break # while ループを抜ける\n" +" elif c == curses.KEY_HOME:\n" +" x = y = 0" -#: ../../howto/curses.rst:481 msgid "" "The :mod:`curses.ascii` module supplies ASCII class membership functions " "that take either integer or 1-character string arguments; these may be " @@ -832,8 +998,12 @@ msgid "" "arguments and return the same type. For example, :func:`curses.ascii.ctrl` " "returns the control character corresponding to its argument." msgstr "" +":mod:`curses.ascii` モジュールには、整数または 1 文字の文字列を受け取り、" +"ASCII の文字分類を判定する関数があります。\n" +"こうしたループの条件判定を読みやすく書くのに役立つでしょう。\n" +"また、整数または 1 文字の文字列を受け取り、同じ型を返す変換関数もあります。\n" +"例えば、:func:`curses.ascii.ctrl` は引数に対応する制御文字を返します。" -#: ../../howto/curses.rst:488 msgid "" "There's also a method to retrieve an entire line, :meth:`~curses.window." "getstr`. It isn't used very often, because its functionality is quite " @@ -841,24 +1011,35 @@ msgid "" "and the Enter key, which terminates the line. It returns a bytes object, and " "can optionally be limited to a fixed number of bytes. ::" msgstr "" +"1 行全体を取得する :meth:`~curses.window.getstr` メソッドもあります。\n" +"機能がかなり限られるため、あまり使われません。\n" +"編集に使えるのは文字消去文字、行消去文字と、行を確定する Enter キーだけで" +"す。\n" +"バイト列オブジェクトを返し、取得するバイト数に上限を設けることもできます。 ::" -#: ../../howto/curses.rst:495 msgid "" "curses.echo() # Enable echoing of characters\n" "\n" "# Get a line of at most 15 bytes, with the cursor on the top line\n" "s = stdscr.getstr(0,0, 15)" msgstr "" +"curses.echo() # 入力文字の表示を有効にする\n" +"\n" +"# カーソルを最上行に置き、最大 15 バイトの行を取得する\n" +"s = stdscr.getstr(0,0, 15)" -#: ../../howto/curses.rst:500 msgid "" "The :mod:`curses.textpad` module supplies a text box that supports an Emacs-" "like set of keybindings. Various methods of the :class:`~curses.textpad." "Textbox` class support editing with input validation and gathering the edit " "results either with or without trailing spaces. Here's an example::" msgstr "" +":mod:`curses.textpad` モジュールは、Emacs に似たキーバインドを使えるテキスト" +"ボックスを提供します。\n" +":class:`~curses.textpad.Textbox` の各種メソッドでは、入力を検証しながら編集し" +"たり、末尾の空白を残すか取り除くかを選んで編集結果を取得したりできます。\n" +"次に例を示します。 ::" -#: ../../howto/curses.rst:506 msgid "" "import curses\n" "from curses.textpad import Textbox, rectangle\n" @@ -878,6 +1059,23 @@ msgid "" " # Get resulting contents\n" " message = box.gather()" msgstr "" +"import curses\n" +"from curses.textpad import Textbox, rectangle\n" +"\n" +"def main(stdscr):\n" +" stdscr.addstr(0, 0, \"Enter IM message: (hit Ctrl-G to send)\")\n" +"\n" +" editwin = curses.newwin(5,30, 2,1)\n" +" rectangle(stdscr, 1,0, 1+5+1, 1+30+1)\n" +" stdscr.refresh()\n" +"\n" +" box = Textbox(editwin)\n" +"\n" +" # Ctrl-G が押されるまで、利用者に編集させる。\n" +" box.edit()\n" +"\n" +" # 編集結果を取得する\n" +" message = box.gather()" #: ../../howto/curses.rst:524 msgid "" @@ -902,7 +1100,6 @@ msgstr "" "Python の :mod:`curses` モジュールのライブラリページはいまやかなり充実してい" "ます。次はこれを見るべきです。" -#: ../../howto/curses.rst:535 msgid "" "If you're in doubt about the detailed behavior of the curses functions, " "consult the manual pages for your curses implementation, whether it's " @@ -910,8 +1107,12 @@ msgid "" "quirks, and provide complete lists of all the functions, attributes, and :" "ref:`ACS_\\* ` characters available to you." msgstr "" +"curses 関数の詳しい動作に疑問があれば、使用している実装が ncurses であって" +"も、プロプライエタリな Unix ベンダーのものであっても、その実装のマニュアル" +"ページを参照してください。\n" +"特有の動作に加え、利用可能なすべての関数、属性、:ref:`ACS_\\* ` 文字の一覧が記載されています。" -#: ../../howto/curses.rst:542 msgid "" "Because the curses API is so large, some functions aren't supported in the " "Python interface. Often this isn't because they're difficult to implement, " @@ -920,21 +1121,30 @@ msgid "" "would be welcome; see `the Python Developer's Guide `_ to learn more about submitting patches to Python." msgstr "" +"curses の API は非常に大きいため、Python のインターフェースではサポートしてい" +"ない関数もあります。\n" +"多くの場合、実装が難しいからではなく、まだ誰も必要としていないためです。\n" +"また、Python はまだ ncurses に付属するメニューライブラリにも対応していませ" +"ん。\n" +"これらへの対応を追加するパッチを歓迎します。\n" +"Python へのパッチの提出方法については、`Python Developer's Guide `_ を参照してください。" -#: ../../howto/curses.rst:550 msgid "" "`Writing Programs with NCURSES `_: a lengthy tutorial for C programmers." msgstr "" +"`Writing Programs with NCURSES `_: C プログラマ向けの詳しいチュートリアル。" #: ../../howto/curses.rst:552 msgid "`The ncurses man page `_" msgstr "`The ncurses man page `_" -#: ../../howto/curses.rst:553 msgid "" "`The ncurses FAQ `_" msgstr "" +"`ncurses の FAQ `_" #: ../../howto/curses.rst:554 msgid "" @@ -946,9 +1156,11 @@ msgstr "" "v=eN1eZtjLEnU>`_: curses または Urwid を使って端末を制御する PyCon 2013 講演" "ビデオです。" -#: ../../howto/curses.rst:556 msgid "" "`\"Console Applications with Urwid\" `_: video of a PyCon CA 2012 talk demonstrating some " "applications written using Urwid." msgstr "" +"`\"Console Applications with Urwid\" `_: Urwid で書かれたいくつかのアプリケーションを紹介" +"する PyCon CA 2012 の講演動画。" diff --git a/howto/descriptor.po b/howto/descriptor.po index 78817f12a..131113675 100644 --- a/howto/descriptor.po +++ b/howto/descriptor.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/descriptor.rst:5 @@ -31,13 +31,12 @@ msgstr "デスクリプタ ガイド" msgid "Contents" msgstr "内容" -#: ../../howto/descriptor.rst:10 msgid "" ":term:`Descriptors ` let objects customize attribute lookup, " "storage, and deletion." msgstr "" -":term:`デスクリプタ ` を使うと、オブジェクトの属性検索、保存、削" -"除をカスタマイズできます。" +":term:`デスクリプタ ` を使うと、オブジェクトの属性の検索、保存、" +"削除をカスタマイズできます。" #: ../../howto/descriptor.rst:13 msgid "This guide has four major sections:" @@ -70,13 +69,17 @@ msgstr "" "なメカニズムで動作しているのかを紹介します。多くの人はこのレベルの理解は不要" "でしょう。" -#: ../../howto/descriptor.rst:25 msgid "" "The last section has pure Python equivalents for built-in descriptors that " "are written in C. Read this if you're curious about how functions turn into " "bound methods or about the implementation of common tools like :deco:" "`classmethod`, :deco:`staticmethod`, :deco:`property`, and :term:`__slots__`." msgstr "" +"最後の節では、C で書かれた組み込みデスクリプタに相当する処理を、Python だけで" +"実装しています。\n" +"関数が束縛メソッドになる仕組みや、:deco:`classmethod`、:deco:" +"`staticmethod`、:deco:`property`、:term:`__slots__` といったよく使う機能の実" +"装に興味があれば、読んでみてください。" #: ../../howto/descriptor.rst:33 msgid "Primer" @@ -94,18 +97,21 @@ msgstr "" msgid "Simple example: A descriptor that returns a constant" msgstr "シンプルな例: 定数を返すデスクリプタ" -#: ../../howto/descriptor.rst:42 msgid "" "The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method " "always returns the constant ``10``:" msgstr "" +":class:`!Ten` クラスは、:meth:`~object.__get__` メソッドが常に定数 ``10`` を" +"返すデスクリプタです。" -#: ../../howto/descriptor.rst:45 msgid "" "class Ten:\n" " def __get__(self, obj, objtype=None):\n" " return 10" msgstr "" +"class Ten:\n" +" def __get__(self, obj, objtype=None):\n" +" return 10" #: ../../howto/descriptor.rst:51 msgid "" @@ -113,12 +119,14 @@ msgid "" "class:" msgstr "このデスクリプタを使うには他のクラスのクラス変数として保存します:" -#: ../../howto/descriptor.rst:53 msgid "" "class A:\n" " x = 5 # Regular class attribute\n" " y = Ten() # Descriptor instance" msgstr "" +"class A:\n" +" x = 5 # 通常のクラス属性\n" +" y = Ten() # デスクリプタのインスタンス" #: ../../howto/descriptor.rst:59 msgid "" @@ -128,7 +136,6 @@ msgstr "" "インタラクティブセッションを使って、通常の属性ルックアップと、デスクリプタの" "ルックアップの違いを見てみましょう。" -#: ../../howto/descriptor.rst:62 msgid "" ">>> a = A() # Make an instance of class A\n" ">>> a.x # Normal attribute lookup\n" @@ -136,6 +143,11 @@ msgid "" ">>> a.y # Descriptor lookup\n" "10" msgstr "" +">>> a = A() # クラス A のインスタンスを作る\n" +">>> a.x # 通常の属性検索\n" +"5\n" +">>> a.y # デスクリプタによる属性検索\n" +"10" #: ../../howto/descriptor.rst:70 msgid "" @@ -182,7 +194,6 @@ msgid "" msgstr "" "単に定数を返すよりも、なにか処理を実行するデスクリプタの方が面白いでしょう。" -#: ../../howto/descriptor.rst:90 msgid "" "import os\n" "\n" @@ -198,16 +209,27 @@ msgid "" " def __init__(self, dirname):\n" " self.dirname = dirname # Regular instance attribute" msgstr "" +"import os\n" +"\n" +"class DirectorySize:\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return len(os.listdir(obj.dirname))\n" +"\n" +"class Directory:\n" +"\n" +" size = DirectorySize() # デスクリプタのインスタンス\n" +"\n" +" def __init__(self, dirname):\n" +" self.dirname = dirname # 通常のインスタンス属性" -#: ../../howto/descriptor.rst:106 msgid "" "An interactive session shows that the lookup is dynamic — it computes " "different, updated answers each time::" msgstr "" -"インタラクティブセッションで見たように、この探索は動的です。実行ごとに異なる" -"計算を行い、毎回答えが更新されます。" +"対話セッションを見ると、属性の検索が動的に行われ、毎回、その時点の状態に応じ" +"た結果が計算されることが分かります。 ::" -#: ../../howto/descriptor.rst:109 msgid "" ">>> s = Directory('songs')\n" ">>> g = Directory('games')\n" @@ -222,8 +244,18 @@ msgid "" "updated\n" "2" msgstr "" +">>> s = Directory('songs')\n" +">>> g = Directory('games')\n" +">>> s.size # songs ディレクトリには 20 個のファ" +"イルがある\n" +"20\n" +">>> g.size # games ディレクトリには 3 個のファイ" +"ルがある\n" +"3\n" +">>> os.remove('games/chess') # ゲームを 1 つ削除する\n" +">>> g.size # ファイル数は自動的に更新される\n" +"2" -#: ../../howto/descriptor.rst:119 msgid "" "Besides showing how descriptors can run computations, this example also " "reveals the purpose of the parameters to :meth:`~object.__get__`. The " @@ -232,12 +264,18 @@ msgid "" "parameter that lets the :meth:`~object.__get__` method learn the target " "directory. The *objtype* parameter is the class *Directory*." msgstr "" +"この例は、デスクリプタが計算を実行できることに加え、:meth:`~object.__get__` " +"の仮引数の役割も示しています。\n" +"*self* は *DirectorySize* のインスタンスである *size* です。\n" +"*obj* は *Directory* のインスタンスである *g* または *s* です。\n" +":meth:`~object.__get__` は、この *obj* 引数から対象のディレクトリを知ることが" +"できます。\n" +"*objtype* はクラス *Directory* です。" #: ../../howto/descriptor.rst:128 msgid "Managed attributes" msgstr "管理された属性" -#: ../../howto/descriptor.rst:130 msgid "" "A popular use for descriptors is managing access to instance data. The " "descriptor is assigned to a public attribute in the class dictionary while " @@ -245,6 +283,11 @@ msgid "" "dictionary. The descriptor's :meth:`~object.__get__` and :meth:`~object." "__set__` methods are triggered when the public attribute is accessed." msgstr "" +"デスクリプタのよくある用途は、インスタンスデータへのアクセスの管理です。\n" +"デスクリプタはクラス辞書内の公開属性に代入し、実際のデータはインスタンス辞書" +"内のプライベート属性に保存します。\n" +"公開属性にアクセスすると、デスクリプタの :meth:`~object.__get__` や :meth:" +"`~object.__set__` が呼び出されます。" #: ../../howto/descriptor.rst:136 msgid "" @@ -256,7 +299,6 @@ msgstr "" "す。パブリックな属性がアクセスされると、デスクリプタはルックアップや更新のロ" "グ出力をします。" -#: ../../howto/descriptor.rst:140 msgid "" "import logging\n" "\n" @@ -284,6 +326,31 @@ msgid "" " def birthday(self):\n" " self.age += 1 # Calls both __get__() and __set__()" msgstr "" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class LoggedAgeAccess:\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" value = obj._age\n" +" logging.info('Accessing %r giving %r', 'age', value)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" logging.info('Updating %r to %r', 'age', value)\n" +" obj._age = value\n" +"\n" +"class Person:\n" +"\n" +" age = LoggedAgeAccess() # デスクリプタのインスタンス\n" +"\n" +" def __init__(self, name, age):\n" +" self.name = name # 通常のインスタンス属性\n" +" self.age = age # __set__() を呼ぶ\n" +"\n" +" def birthday(self):\n" +" self.age += 1 # __get__() と __set__() の両方を呼ぶ" #: ../../howto/descriptor.rst:169 msgid "" @@ -293,7 +360,6 @@ msgstr "" "インタラクティブセッションの結果で見てわかるように、管理された属性の *age* の" "ログ出力が行われますが、通常の属性の *name* はログ出力されません。" -#: ../../howto/descriptor.rst:178 msgid "" ">>> mary = Person('Mary M', 30) # The initial age update is logged\n" "INFO:root:Updating 'age' to 30\n" @@ -322,6 +388,30 @@ msgid "" "INFO:root:Accessing 'age' giving 40\n" "40" msgstr "" +">>> mary = Person('Mary M', 30) # 年齢の初期設定がログに記録される\n" +"INFO:root:Updating 'age' to 30\n" +">>> dave = Person('David D', 40)\n" +"INFO:root:Updating 'age' to 40\n" +"\n" +">>> vars(mary) # 実際のデータはプライベート属性にあ" +"る\n" +"{'name': 'Mary M', '_age': 30}\n" +">>> vars(dave)\n" +"{'name': 'David D', '_age': 40}\n" +"\n" +">>> mary.age # データを取得し、そのアクセスを記録" +"する\n" +"INFO:root:Accessing 'age' giving 30\n" +"30\n" +">>> mary.birthday() # 更新もログに記録される\n" +"INFO:root:Accessing 'age' giving 30\n" +"INFO:root:Updating 'age' to 31\n" +"\n" +">>> dave.name # 通常の属性の検索は記録されない\n" +"'David D'\n" +">>> dave.age # 管理された属性だけが記録される\n" +"INFO:root:Accessing 'age' giving 40\n" +"40" #: ../../howto/descriptor.rst:203 msgid "" @@ -347,7 +437,6 @@ msgstr "" "クラスがデスクリプタを使うときに、クラスはそれぞれのデスクリプタにどのような" "変数名を使うかを通知します。" -#: ../../howto/descriptor.rst:215 msgid "" "In this example, the :class:`!Person` class has two descriptor instances, " "*name* and *age*. When the :class:`!Person` class is defined, it makes a " @@ -355,8 +444,13 @@ msgid "" "names can be recorded, giving each descriptor its own *public_name* and " "*private_name*:" msgstr "" +"この例では、:class:`!Person` クラスが *name* と *age* という 2 つのデスクリプ" +"タインスタンスを持ちます。\n" +":class:`!Person` の定義時に *LoggedAccess* の :meth:`~object.__set_name__` が" +"呼び出され、フィールド名が記録されます。\n" +"これにより、各デスクリプタが固有の *public_name* と *private_name* を持つよう" +"になります。" -#: ../../howto/descriptor.rst:220 msgid "" "import logging\n" "\n" @@ -389,27 +483,63 @@ msgid "" " def birthday(self):\n" " self.age += 1" msgstr "" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class LoggedAccess:\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.public_name = name\n" +" self.private_name = '_' + name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" value = getattr(obj, self.private_name)\n" +" logging.info('Accessing %r giving %r', self.public_name, value)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" logging.info('Updating %r to %r', self.public_name, value)\n" +" setattr(obj, self.private_name, value)\n" +"\n" +"class Person:\n" +"\n" +" name = LoggedAccess() # 1 つ目のデスクリプタのインスタン" +"ス\n" +" age = LoggedAccess() # 2 つ目のデスクリプタのインスタン" +"ス\n" +"\n" +" def __init__(self, name, age):\n" +" self.name = name # 1 つ目のデスクリプタを呼ぶ\n" +" self.age = age # 2 つ目のデスクリプタを呼ぶ\n" +"\n" +" def birthday(self):\n" +" self.age += 1" -#: ../../howto/descriptor.rst:253 msgid "" "An interactive session shows that the :class:`!Person` class has called :" "meth:`~object.__set_name__` so that the field names would be recorded. Here " "we call :func:`vars` to look up the descriptor without triggering it:" msgstr "" +"対話セッションを見ると、:class:`!Person` クラスが :meth:`~object." +"__set_name__` を呼び出し、フィールド名が記録されたことが分かります。\n" +"ここでは、デスクリプタを呼び出さずに取得するため、:func:`vars` を使います。" -#: ../../howto/descriptor.rst:257 msgid "" ">>> vars(vars(Person)['name'])\n" "{'public_name': 'name', 'private_name': '_name'}\n" ">>> vars(vars(Person)['age'])\n" "{'public_name': 'age', 'private_name': '_age'}" msgstr "" +">>> vars(vars(Person)['name'])\n" +"{'public_name': 'name', 'private_name': '_name'}\n" +">>> vars(vars(Person)['age'])\n" +"{'public_name': 'age', 'private_name': '_age'}" #: ../../howto/descriptor.rst:264 msgid "The new class now logs access to both *name* and *age*:" msgstr "新しいクラスは *name* と *age* の両方でログを出力します。" -#: ../../howto/descriptor.rst:272 msgid "" ">>> pete = Person('Peter P', 10)\n" "INFO:root:Updating 'name' to 'Peter P'\n" @@ -418,36 +548,50 @@ msgid "" "INFO:root:Updating 'name' to 'Catherine C'\n" "INFO:root:Updating 'age' to 20" msgstr "" +">>> pete = Person('Peter P', 10)\n" +"INFO:root:Updating 'name' to 'Peter P'\n" +"INFO:root:Updating 'age' to 10\n" +">>> kate = Person('Catherine C', 20)\n" +"INFO:root:Updating 'name' to 'Catherine C'\n" +"INFO:root:Updating 'age' to 20" #: ../../howto/descriptor.rst:281 msgid "The two *Person* instances contain only the private names:" msgstr "2つの *Person* のインスタンスは、プライベート名しか保持していません。" -#: ../../howto/descriptor.rst:283 msgid "" ">>> vars(pete)\n" "{'_name': 'Peter P', '_age': 10}\n" ">>> vars(kate)\n" "{'_name': 'Catherine C', '_age': 20}" msgstr "" +">>> vars(pete)\n" +"{'_name': 'Peter P', '_age': 10}\n" +">>> vars(kate)\n" +"{'_name': 'Catherine C', '_age': 20}" #: ../../howto/descriptor.rst:292 msgid "Closing thoughts" msgstr "まとめ" -#: ../../howto/descriptor.rst:294 msgid "" "A :term:`descriptor` is what we call any object that defines :meth:`~object." "__get__`, :meth:`~object.__set__`, or :meth:`~object.__delete__`." msgstr "" +":meth:`~object.__get__`、:meth:`~object.__set__`、:meth:`~object.__delete__` " +"のいずれかを定義するオブジェクトを :term:`descriptor` と呼びます。" -#: ../../howto/descriptor.rst:297 msgid "" "Optionally, descriptors can have a :meth:`~object.__set_name__` method. " "This is only used in cases where a descriptor needs to know either the class " "where it was created or the name of class variable it was assigned to. " "(This method, if present, is called even if the class is not a descriptor.)" msgstr "" +"デスクリプタには、必要に応じて :meth:`~object.__set_name__` メソッドを定義で" +"きます。\n" +"これは、デスクリプタが、自身が定義されたクラスや代入先のクラス変数名を知る必" +"要がある場合に使います。\n" +"(このメソッドがあれば、そのクラスがデスクリプタでなくても呼び出されます。)" #: ../../howto/descriptor.rst:302 msgid "" @@ -487,13 +631,17 @@ msgstr "" "したが、デスクリプタはその関係を逆転させ、検索されているデータが問題に介入で" "きるようにします。" -#: ../../howto/descriptor.rst:316 msgid "" "Descriptors are used throughout the language. It is how functions turn into " "bound methods. Common tools like :deco:`classmethod`, :deco:" "`staticmethod`, :deco:`property`, and :deco:`functools.cached_property` are " "all implemented as descriptors." msgstr "" +"デスクリプタは Python の至る所で使われています。\n" +"関数が束縛メソッドになるのも、この仕組みによるものです。\n" +":deco:`classmethod`、:deco:`staticmethod`、:deco:`property`、:deco:" +"`functools.cached_property` といったよく使う機能は、すべてデスクリプタとして" +"実装されています。" #: ../../howto/descriptor.rst:323 msgid "Complete Practical Example" @@ -523,13 +671,13 @@ msgstr "" "す。もし制限に合わなければ、例外を送出し、データが不正な状態になるのを防ぎま" "す。" -#: ../../howto/descriptor.rst:337 msgid "" "This :class:`!Validator` class is both an :term:`abstract base class` and a " "managed attribute descriptor:" msgstr "" +"この :class:`!Validator` クラスは、:term:`abstract base class` であると同時" +"に、属性へのアクセスを管理するデスクリプタでもあります。" -#: ../../howto/descriptor.rst:340 msgid "" "from abc import ABC, abstractmethod\n" "\n" @@ -549,12 +697,30 @@ msgid "" " def validate(self, value):\n" " pass" msgstr "" +"from abc import ABC, abstractmethod\n" +"\n" +"class Validator(ABC):\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.private_name = '_' + name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return getattr(obj, self.private_name)\n" +"\n" +" def __set__(self, obj, value):\n" +" self.validate(value)\n" +" setattr(obj, self.private_name, value)\n" +"\n" +" @abstractmethod\n" +" def validate(self, value):\n" +" pass" -#: ../../howto/descriptor.rst:360 msgid "" "Custom validators need to inherit from :class:`!Validator` and must supply " "a :meth:`!validate` method to test various restrictions as needed." msgstr "" +"独自のバリデータは :class:`!Validator` を継承し、必要な制約を検査する :meth:" +"`!validate` メソッドを実装しなければなりません。" #: ../../howto/descriptor.rst:365 msgid "Custom validators" @@ -565,27 +731,31 @@ msgid "Here are three practical data validation utilities:" msgstr "" "ここでは3つの実践的なバリデーションのユーティリティのサンプルを紹介します。" -#: ../../howto/descriptor.rst:369 msgid "" ":class:`!OneOf` verifies that a value is one of a restricted set of options." msgstr "" +":class:`!OneOf` は、値が指定された選択肢のいずれかであることを検証します。" -#: ../../howto/descriptor.rst:371 msgid "" ":class:`!Number` verifies that a value is either an :class:`int` or :class:" "`float`. Optionally, it verifies that a value is between a given minimum or " "maximum." msgstr "" +":class:`!Number` は、値が :class:`int` または :class:`float` であることを検証" +"します。\n" +"必要に応じて、指定された最小値以上、最大値以下であることも検証します。" -#: ../../howto/descriptor.rst:375 msgid "" ":class:`!String` verifies that a value is a :class:`str`. Optionally, it " "validates a given minimum or maximum length. It can validate a user-defined " "`predicate `_ " "as well." msgstr "" +":class:`!String` は、値が :class:`str` であることを検証します。\n" +"必要に応じて、指定された最小長や最大長の条件も検証します。\n" +"利用者が定義した `述語 `_ による検証もできます。" -#: ../../howto/descriptor.rst:380 msgid "" "class OneOf(Validator):\n" "\n" @@ -640,6 +810,58 @@ msgid "" " f'Expected {self.predicate} to be true for {value!r}'\n" " )" msgstr "" +"class OneOf(Validator):\n" +"\n" +" def __init__(self, *options):\n" +" self.options = set(options)\n" +"\n" +" def validate(self, value):\n" +" if value not in self.options:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be one of {self.options!r}'\n" +" )\n" +"\n" +"class Number(Validator):\n" +"\n" +" def __init__(self, minvalue=None, maxvalue=None):\n" +" self.minvalue = minvalue\n" +" self.maxvalue = maxvalue\n" +"\n" +" def validate(self, value):\n" +" if not isinstance(value, (int, float)):\n" +" raise TypeError(f'Expected {value!r} to be an int or float')\n" +" if self.minvalue is not None and value < self.minvalue:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be at least {self.minvalue!r}'\n" +" )\n" +" if self.maxvalue is not None and value > self.maxvalue:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no more than {self.maxvalue!r}'\n" +" )\n" +"\n" +"class String(Validator):\n" +"\n" +" def __init__(self, minsize=None, maxsize=None, predicate=None):\n" +" self.minsize = minsize\n" +" self.maxsize = maxsize\n" +" self.predicate = predicate\n" +"\n" +" def validate(self, value):\n" +" if not isinstance(value, str):\n" +" raise TypeError(f'Expected {value!r} to be a str')\n" +" if self.minsize is not None and len(value) < self.minsize:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no smaller than {self.minsize!" +"r}'\n" +" )\n" +" if self.maxsize is not None and len(value) > self.maxsize:\n" +" raise ValueError(\n" +" f'Expected {value!r} to be no bigger than {self.maxsize!r}'\n" +" )\n" +" if self.predicate is not None and not self.predicate(value):\n" +" raise ValueError(\n" +" f'Expected {self.predicate} to be true for {value!r}'\n" +" )" #: ../../howto/descriptor.rst:436 msgid "Practical application" @@ -649,7 +871,6 @@ msgstr "実践的なアプリケーション" msgid "Here's how the data validators can be used in a real class:" msgstr "次のコードは実際のクラスでデータバリデータを使う方法のサンプルです。" -#: ../../howto/descriptor.rst:440 msgid "" "class Component:\n" "\n" @@ -662,12 +883,21 @@ msgid "" " self.kind = kind\n" " self.quantity = quantity" msgstr "" +"class Component:\n" +"\n" +" name = String(minsize=3, maxsize=10, predicate=str.isupper)\n" +" kind = OneOf('wood', 'metal', 'plastic')\n" +" quantity = Number(minvalue=0)\n" +"\n" +" def __init__(self, name, kind, quantity):\n" +" self.name = name\n" +" self.kind = kind\n" +" self.quantity = quantity" #: ../../howto/descriptor.rst:453 msgid "The descriptors prevent invalid instances from being created:" msgstr "これらのデスクリプタは、不正インスタンスが作成されるのを防ぎます。" -#: ../../howto/descriptor.rst:455 msgid "" ">>> Component('Widget', 'metal', 5) # Blocked: 'Widget' is not all " "uppercase\n" @@ -693,6 +923,29 @@ msgid "" "\n" ">>> c = Component('WIDGET', 'metal', 5) # Allowed: The inputs are valid" msgstr "" +">>> Component('Widget', 'metal', 5) # 拒否: 'Widget' はすべて大文字では" +"ない\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected to be true for " +"'Widget'\n" +"\n" +">>> Component('WIDGET', 'metle', 5) # 拒否: 'metle' は綴りが違う\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected 'metle' to be one of {'metal', 'plastic', 'wood'}\n" +"\n" +">>> Component('WIDGET', 'metal', -5) # 拒否: -5 は負数\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: Expected -5 to be at least 0\n" +"\n" +">>> Component('WIDGET', 'metal', 'V') # 拒否: 'V' は数値ではない\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: Expected 'V' to be an int or float\n" +"\n" +">>> c = Component('WIDGET', 'metal', 5) # 許可: 入力は有効" #: ../../howto/descriptor.rst:481 msgid "Technical Tutorial" @@ -730,13 +983,17 @@ msgstr "" msgid "Definition and introduction" msgstr "定義と導入" -#: ../../howto/descriptor.rst:500 msgid "" "In general, a descriptor is an attribute value that has one of the methods " "in the descriptor protocol. Those methods are :meth:`~object.__get__`, :" "meth:`~object.__set__`, and :meth:`~object.__delete__`. If any of those " "methods are defined for an attribute, it is said to be a :term:`descriptor`." msgstr "" +"一般に、デスクリプタとは、デスクリプタプロトコルのメソッドのいずれかを持つ属" +"性値です。\n" +"そのメソッドは :meth:`~object.__get__`、:meth:`~object.__set__`、:meth:" +"`~object.__delete__` です。\n" +"これらのいずれかが定義された属性を :term:`descriptor` と呼びます。" #: ../../howto/descriptor.rst:505 msgid "" @@ -757,7 +1014,6 @@ msgstr "" "デスクリプタメソッドを呼び出します。これがどの連鎖順位で行われるかは、どのデ" "スクリプタメソッドが定義されているかに依ります。" -#: ../../howto/descriptor.rst:514 msgid "" "Descriptors are a powerful, general purpose protocol. They are the " "mechanism behind properties, methods, static methods, class methods, and :" @@ -765,6 +1021,11 @@ msgid "" "the underlying C code and offer a flexible set of new tools for everyday " "Python programs." msgstr "" +"デスクリプタは強力で汎用的なプロトコルです。\n" +"プロパティ、メソッド、静的メソッド、クラスメソッド、:func:`super` を支える仕" +"組みであり、Python 自身の至る所で使われています。\n" +"デスクリプタは内部の C コードを簡潔にし、日常的な Python プログラムにも柔軟な" +"道具を提供します。" #: ../../howto/descriptor.rst:522 msgid "Descriptor protocol" @@ -792,13 +1053,16 @@ msgstr "" "リプタとみなされ、探索された際のデフォルトの振る舞いをオーバーライドできま" "す。" -#: ../../howto/descriptor.rst:534 msgid "" "If an object defines :meth:`~object.__set__` or :meth:`~object.__delete__`, " "it is considered a data descriptor. Descriptors that only define :meth:" "`~object.__get__` are called non-data descriptors (they are often used for " "methods but other uses are possible)." msgstr "" +":meth:`~object.__set__` または :meth:`~object.__delete__` を定義するオブジェ" +"クトは、データデスクリプタとみなされます。\n" +":meth:`~object.__get__` だけを定義するものは非データデスクリプタと呼ばれ、メ" +"ソッドによく使われますが、ほかの用途にも使えます。" #: ../../howto/descriptor.rst:539 msgid "" @@ -814,13 +1078,17 @@ msgstr "" "ます。インスタンスの辞書に、非データデスクリプタと同名の項目があれば、辞書の" "項目の方が優先されます。" -#: ../../howto/descriptor.rst:545 msgid "" "To make a read-only data descriptor, define both :meth:`~object.__get__` " "and :meth:`~object.__set__` with the :meth:`~object.__set__` raising an :exc:" "`AttributeError` when called. Defining the :meth:`~object.__set__` method " "with an exception raising placeholder is enough to make it a data descriptor." msgstr "" +"読み取り専用のデータデスクリプタを作るには、:meth:`~object.__get__` と :meth:" +"`~object.__set__` の両方を定義し、:meth:`~object.__set__` が呼ばれたら :exc:" +"`AttributeError` を送出するようにします。\n" +"例外を送出するだけの :meth:`~object.__set__` を定義すれば、データデスクリプタ" +"になります。" #: ../../howto/descriptor.rst:552 msgid "Overview of descriptor invocation" @@ -842,13 +1110,15 @@ msgstr "" "しかし、属性アクセスの際に自動的に呼び出されるのが、一般的なデスクリプタの呼" "び出し方法です。" -#: ../../howto/descriptor.rst:560 msgid "" "The expression ``obj.x`` looks up the attribute ``x`` in the chain of " "namespaces for ``obj``. If the search finds a descriptor outside of the " "instance :attr:`~object.__dict__`, its :meth:`~object.__get__` method is " "invoked according to the precedence rules listed below." msgstr "" +"式 ``obj.x`` は、``obj`` の名前空間の連鎖から属性 ``x`` を探します。\n" +"インスタンスの :attr:`~object.__dict__` 以外でデスクリプタが見つかると、以下" +"の優先順位に従って :meth:`~object.__get__` が呼び出されます。" #: ../../howto/descriptor.rst:565 msgid "" @@ -862,13 +1132,16 @@ msgstr "" msgid "Invocation from an instance" msgstr "インスタンスからの呼び出し" -#: ../../howto/descriptor.rst:572 msgid "" "Instance lookup scans through a chain of namespaces giving data descriptors " "the highest priority, followed by instance variables, then non-data " "descriptors, then class variables, and lastly :meth:`~object.__getattr__` if " "it is provided." msgstr "" +"インスタンスの属性検索は名前空間の連鎖をたどり、データデスクリプタを最優先に" +"します。\n" +"次にインスタンス変数、非データデスクリプタ、クラス変数を調べ、最後に、定義さ" +"れていれば :meth:`~object.__getattr__` を呼び出します。" #: ../../howto/descriptor.rst:577 msgid "" @@ -886,7 +1159,6 @@ msgstr "" "ドットによるルックアップのロジックは\\ :meth:`object.__getattribute__` の中で" "行われます。ピュアPythonで表した等価なロジックは次の通りです。" -#: ../../howto/descriptor.rst:583 msgid "" "def find_name_in_mro(cls, name, default):\n" " \"Emulate _PyType_Lookup() in Objects/typeobject.c\"\n" @@ -914,24 +1186,56 @@ msgid "" " return cls_var # class variable\n" " raise AttributeError(name)" msgstr "" +"def find_name_in_mro(cls, name, default):\n" +" \"Objects/typeobject.c の _PyType_Lookup() を模擬する\"\n" +" for base in cls.__mro__:\n" +" if name in vars(base):\n" +" return vars(base)[name]\n" +" return default\n" +"\n" +"def object_getattribute(obj, name):\n" +" \"Objects/object.c の PyObject_GenericGetAttr() を模擬する\"\n" +" null = sentinel('null')\n" +" objtype = type(obj)\n" +" cls_var = find_name_in_mro(objtype, name, null)\n" +" descr_get = getattr(type(cls_var), '__get__', null)\n" +" if descr_get is not null:\n" +" if (hasattr(type(cls_var), '__set__')\n" +" or hasattr(type(cls_var), '__delete__')):\n" +" return descr_get(cls_var, obj, objtype) # データデスクリプ" +"タ\n" +" if hasattr(obj, '__dict__') and name in vars(obj):\n" +" return vars(obj)[name] # インスタンス変数\n" +" if descr_get is not null:\n" +" return descr_get(cls_var, obj, objtype) # 非データデスクリプ" +"タ\n" +" if cls_var is not null:\n" +" return cls_var # クラス変数\n" +" raise AttributeError(name)" -#: ../../howto/descriptor.rst:719 msgid "" "Note, there is no :meth:`~object.__getattr__` hook in the :meth:`~object." "__getattribute__` code. That is why calling :meth:`~object." "__getattribute__` directly or with ``super().__getattribute__`` will bypass :" "meth:`~object.__getattr__` entirely." msgstr "" +":meth:`~object.__getattribute__` のコード内には :meth:`~object.__getattr__` " +"フックがないことに注意してください。\n" +"そのため、:meth:`~object.__getattribute__` を直接呼んだり ``super()." +"__getattribute__`` で呼んだりすると、:meth:`~object.__getattr__` はまったく呼" +"ばれません。" -#: ../../howto/descriptor.rst:723 msgid "" "Instead, it is the dot operator and the :func:`getattr` function that are " "responsible for invoking :meth:`~object.__getattr__` whenever :meth:`~object." "__getattribute__` raises an :exc:`AttributeError`. Their logic is " "encapsulated in a helper function:" msgstr "" +"代わりに、:meth:`~object.__getattribute__` が :exc:`AttributeError` を送出し" +"たときに :meth:`~object.__getattr__` を呼び出すのは、ドット演算子と :func:" +"`getattr` 関数です。\n" +"その処理は、次の補助関数にまとめられます。" -#: ../../howto/descriptor.rst:728 msgid "" "def getattr_hook(obj, name):\n" " \"Emulate slot_tp_getattr_hook() in Objects/typeobject.c\"\n" @@ -942,54 +1246,63 @@ msgid "" " raise\n" " return type(obj).__getattr__(obj, name) # __getattr__" msgstr "" +"def getattr_hook(obj, name):\n" +" \"Objects/typeobject.c の slot_tp_getattr_hook() を模擬する\"\n" +" try:\n" +" return obj.__getattribute__(name)\n" +" except AttributeError:\n" +" if not hasattr(type(obj), '__getattr__'):\n" +" raise\n" +" return type(obj).__getattr__(obj, name) # __getattr__" #: ../../howto/descriptor.rst:773 msgid "Invocation from a class" msgstr "クラスからの呼び出し" -#: ../../howto/descriptor.rst:775 msgid "" "The logic for a dotted lookup such as ``A.x`` is in :meth:`!type." "__getattribute__`. The steps are similar to those for :meth:`!object." "__getattribute__` but the instance dictionary lookup is replaced by a search " "through the class's :term:`method resolution order`." msgstr "" +"``A.x`` のようなドット記法による検索の処理は、:meth:`!type.__getattribute__` " +"にあります。\n" +"手順は :meth:`!object.__getattribute__` と似ていますが、インスタンス辞書の検" +"索が、そのクラスの :term:`method resolution order` に従う検索に置き換わりま" +"す。" -#: ../../howto/descriptor.rst:780 msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``." msgstr "" -"``a.x`` に対するデスクリプタが見つかった場合、 ``desc.__get__(None, A)`` とい" -"う形式で呼び出されます。" +"デスクリプタが見つかると、``desc.__get__(None, A)`` として呼び出されます。" -#: ../../howto/descriptor.rst:782 msgid "" "The full C implementation can be found in :c:func:`!type_getattro` and :c:" "func:`!_PyType_Lookup` in :source:`Objects/typeobject.c`." msgstr "" -"完全な C での実装は :source:`Objects/typeobject.c` の中の:c:func:`!" -"type_getattro` と :c:func:`!_PyType_Lookup` を参照してください。" +"完全な C 実装は、:source:`Objects/typeobject.c` の :c:func:`!type_getattro` " +"と :c:func:`!_PyType_Lookup` にあります。" #: ../../howto/descriptor.rst:787 msgid "Invocation from super" msgstr "superからの呼び出し" -#: ../../howto/descriptor.rst:789 msgid "" "The logic for super's dotted lookup is in the :meth:`~object." "__getattribute__` method for object returned by :func:`super`." msgstr "" +"``super`` のドット記法による検索の処理は、:func:`super` が返すオブジェクト" +"の :meth:`~object.__getattribute__` メソッドにあります。" -#: ../../howto/descriptor.rst:792 msgid "" "A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__." "__mro__`` for the base class ``B`` immediately following ``A`` and then " "returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is " "returned unchanged." msgstr "" -"``super(A, obj).m`` のようなドットを使ったルックアップは ``obj.__class__." -"__mro__`` を探索して、 ``A`` の直前のクラス ``B`` をまず探し、 ``B." -"__dict__['m'].__get__(obj, A)`` を返します。もしデスクリプタでなければ ``m`` " -"を変更せずに返します。" +"``super(A, obj).m`` のようにドット記法で属性を検索すると、``obj.__class__." +"__mro__`` の中で ``A`` の直後にある基底クラス ``B`` を探し、\n" +"``B.__dict__['m'].__get__(obj, A)`` を返します。\n" +"``m`` がデスクリプタでなければ、そのまま返します。" #: ../../howto/descriptor.rst:797 msgid "" @@ -1007,20 +1320,21 @@ msgstr "" msgid "Summary of invocation logic" msgstr "呼び出しロジックのまとめ" -#: ../../howto/descriptor.rst:806 msgid "" "The mechanism for descriptors is embedded in the :meth:`~object." "__getattribute__` methods for :class:`object`, :class:`type`, and :func:" "`super`." msgstr "" +"デスクリプタの仕組みは、:class:`object`、:class:`type`、:func:`super` の :" +"meth:`~object.__getattribute__` メソッドに組み込まれています。" #: ../../howto/descriptor.rst:809 msgid "The important points to remember are:" msgstr "憶えておくべき重要な点は:" -#: ../../howto/descriptor.rst:811 msgid "Descriptors are invoked by the :meth:`~object.__getattribute__` method." msgstr "" +"デスクリプタは :meth:`~object.__getattribute__` メソッドから呼び出されます。" #: ../../howto/descriptor.rst:813 msgid "" @@ -1053,11 +1367,9 @@ msgid "Non-data descriptors may be overridden by instance dictionaries." msgstr "" "非データデスクリプタは、インスタンス辞書にオーバーライドされることがある" -#: ../../howto/descriptor.rst:830 msgid "Automatic name notification" -msgstr "自動的の名前の伝達" +msgstr "名前の自動通知" -#: ../../howto/descriptor.rst:832 msgid "" "Sometimes it is desirable for a descriptor to know what class variable name " "it was assigned to. When a new class is created, the :class:`type` " @@ -1066,6 +1378,13 @@ msgid "" "called with two arguments. The *owner* is the class where the descriptor is " "used, and the *name* is the class variable the descriptor was assigned to." msgstr "" +"デスクリプタが、代入先のクラス変数名を知りたい場合があります。\n" +"新しいクラスが作られると、メタクラス :class:`type` はそのクラスの辞書を調べま" +"す。\n" +"デスクリプタであるエントリーに :meth:`~object.__set_name__` が定義されていれ" +"ば、2 つの引数を渡して呼び出します。\n" +"*owner* はデスクリプタを使っているクラス、*name* はデスクリプタが代入されたク" +"ラス変数の名前です。" #: ../../howto/descriptor.rst:839 msgid "" @@ -1075,12 +1394,15 @@ msgstr "" "実装の詳細は :source:`Objects/typeobject.c` の中の :c:func:`!type_new` と :c:" "func:`!set_names` を参照してください。" -#: ../../howto/descriptor.rst:842 msgid "" "Since the update logic is in :meth:`!type.__new__`, notifications only take " "place at the time of class creation. If descriptors are added to the class " "afterwards, :meth:`~object.__set_name__` will need to be called manually." msgstr "" +"この更新処理は :meth:`!type.__new__` にあるため、通知はクラスの作成時にだけ行" +"われます。\n" +"後からクラスにデスクリプタを追加した場合は、:meth:`~object.__set_name__` を手" +"動で呼び出す必要があります。" #: ../../howto/descriptor.rst:848 msgid "ORM example" @@ -1106,7 +1428,6 @@ msgstr "" "タンスは、データベースのテーブルへのキーのみを保持します。デスクリプタがルッ" "クアップや更新をします。" -#: ../../howto/descriptor.rst:858 msgid "" "class Field:\n" "\n" @@ -1123,15 +1444,29 @@ msgid "" " conn.execute(self.store, [value, obj.key])\n" " conn.commit()" msgstr "" +"class Field:\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.fetch = f'SELECT {name} FROM {owner.table} WHERE {owner.key}" +"=?;'\n" +" self.store = f'UPDATE {owner.table} SET {name}=? WHERE {owner.key}" +"=?;'\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return conn.execute(self.fetch, [obj.key]).fetchone()[0]\n" +"\n" +" def __set__(self, obj, value):\n" +" conn.execute(self.store, [value, obj.key])\n" +" conn.commit()" -#: ../../howto/descriptor.rst:873 msgid "" "We can use the :class:`!Field` class to define `models `_ that describe the schema for each table in a " "database:" msgstr "" +":class:`!Field` クラスを使うと、データベースの各テーブルのスキーマを表す `モ" +"デル `_ を定義できます。" -#: ../../howto/descriptor.rst:877 msgid "" "class Movie:\n" " table = 'Movies' # Table name\n" @@ -1152,16 +1487,35 @@ msgid "" " def __init__(self, key):\n" " self.key = key" msgstr "" +"class Movie:\n" +" table = 'Movies' # テーブル名\n" +" key = 'title' # 主キー\n" +" director = Field()\n" +" year = Field()\n" +"\n" +" def __init__(self, key):\n" +" self.key = key\n" +"\n" +"class Song:\n" +" table = 'Music'\n" +" key = 'title'\n" +" artist = Field()\n" +" year = Field()\n" +" genre = Field()\n" +"\n" +" def __init__(self, key):\n" +" self.key = key" #: ../../howto/descriptor.rst:898 msgid "To use the models, first connect to the database::" msgstr "モデルを使用するにはまずデータベースに接続します::" -#: ../../howto/descriptor.rst:900 msgid "" ">>> import sqlite3\n" ">>> conn = sqlite3.connect('entertainment.db')" msgstr "" +">>> import sqlite3\n" +">>> conn = sqlite3.connect('entertainment.db')" #: ../../howto/descriptor.rst:903 msgid "" @@ -1171,7 +1525,6 @@ msgstr "" "次のインタラクティブセッションでは、データベースからのデータの取得と、更新方" "法を示しています。" -#: ../../howto/descriptor.rst:931 msgid "" ">>> Movie('Star Wars').director\n" "'George Lucas'\n" @@ -1186,7 +1539,19 @@ msgid "" ">>> Movie('Star Wars').director\n" "'J.J. Abrams'" msgstr "" - +">>> Movie('Star Wars').director\n" +"'George Lucas'\n" +">>> jaws = Movie('Jaws')\n" +">>> f'Released in {jaws.year} by {jaws.director}'\n" +"'Released in 1975 by Steven Spielberg'\n" +"\n" +">>> Song('Country Roads').artist\n" +"'John Denver'\n" +"\n" +">>> Movie('Star Wars').director = 'J.J. Abrams'\n" +">>> Movie('Star Wars').director\n" +"'J.J. Abrams'" + #: ../../howto/descriptor.rst:952 msgid "Pure Python Equivalents" msgstr "ピュアPythonの等価実装" @@ -1216,9 +1581,8 @@ msgstr "" ":func:`property` を呼び出すことで、属性へアクセスすると関数の呼び出しを引き起" "こす、データデスクリプタを簡潔に組み立てられます。シグネチャはこうです::" -#: ../../howto/descriptor.rst:966 msgid "property(fget=None, fset=None, fdel=None, doc=None) -> property" -msgstr "" +msgstr "property(fget=None, fset=None, fdel=None, doc=None) -> property" #: ../../howto/descriptor.rst:968 msgid "" @@ -1227,7 +1591,6 @@ msgstr "" "このドキュメントでは、管理された属性 ``x`` を定義する典型的な使用法を示しま" "す:" -#: ../../howto/descriptor.rst:970 msgid "" "class C:\n" " def getx(self): return self.__x\n" @@ -1235,15 +1598,20 @@ msgid "" " def delx(self): del self.__x\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" msgstr "" +"class C:\n" +" def getx(self): return self.__x\n" +" def setx(self, value): self.__x = value\n" +" def delx(self): del self.__x\n" +" x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../howto/descriptor.rst:992 msgid "" "To see how :func:`property` is implemented in terms of the descriptor " "protocol, here is a pure Python equivalent that implements most of the core " "functionality:" msgstr "" +":func:`property` がデスクリプタプロトコルでどのように実装されているかを見るた" +"め、主要な機能の大部分を Python だけで実装した等価なコードを示します。" -#: ../../howto/descriptor.rst:995 msgid "" "class Property:\n" " \"Emulate PyProperty_Type() in Objects/descrobject.c\"\n" @@ -1285,15 +1653,54 @@ msgid "" " def deleter(self, fdel):\n" " return type(self)(self.fget, self.fset, fdel, self.__doc__)" msgstr "" +"class Property:\n" +" \"Objects/descrobject.c の PyProperty_Type() を模擬する\"\n" +"\n" +" def __init__(self, fget=None, fset=None, fdel=None, doc=None):\n" +" self.fget = fget\n" +" self.fset = fset\n" +" self.fdel = fdel\n" +" if doc is None and fget is not None:\n" +" doc = fget.__doc__\n" +" self.__doc__ = doc\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self.__name__ = name\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" if obj is None:\n" +" return self\n" +" if self.fget is None:\n" +" raise AttributeError\n" +" return self.fget(obj)\n" +"\n" +" def __set__(self, obj, value):\n" +" if self.fset is None:\n" +" raise AttributeError\n" +" self.fset(obj, value)\n" +"\n" +" def __delete__(self, obj):\n" +" if self.fdel is None:\n" +" raise AttributeError\n" +" self.fdel(obj)\n" +"\n" +" def getter(self, fget):\n" +" return type(self)(fget, self.fset, self.fdel, self.__doc__)\n" +"\n" +" def setter(self, fset):\n" +" return type(self)(self.fget, fset, self.fdel, self.__doc__)\n" +"\n" +" def deleter(self, fdel):\n" +" return type(self)(self.fget, self.fset, fdel, self.__doc__)" -#: ../../howto/descriptor.rst:1119 msgid "" "The :func:`property` builtin helps whenever a user interface has granted " "attribute access and then subsequent changes require the intervention of a " "method." msgstr "" -"組み込みの :func:`property` 関数は、ユーザインターフェースへの属性アクセスが" -"与えられ、続く変更がメソッドの介入を要求するときに役立ちます。" +"組み込みの :func:`property` は、利用者向けのインターフェースで属性への直接ア" +"クセスを提供していたものの、後の変更でメソッドによる処理を挟む必要が生じた場" +"合に役立ちます。" #: ../../howto/descriptor.rst:1123 msgid "" @@ -1310,7 +1717,6 @@ msgstr "" "ントコードに影響を与えたくありません。この解決策は、property データデスクリプ" "タ内に値属性へのアクセスをラップすることです:" -#: ../../howto/descriptor.rst:1129 msgid "" "class Cell:\n" " ...\n" @@ -1321,12 +1727,21 @@ msgid "" " self.recalc()\n" " return self._value" msgstr "" +"class Cell:\n" +" ...\n" +"\n" +" @property\n" +" def value(self):\n" +" \"値を返す前にセルを再計算する\"\n" +" self.recalc()\n" +" return self._value" -#: ../../howto/descriptor.rst:1140 msgid "" "Either the built-in :func:`property` or our :func:`!Property` equivalent " "would work in this example." msgstr "" +"この例では、組み込みの :func:`property` でも、それに相当する自作の :func:`!" +"Property` でも動作します。" #: ../../howto/descriptor.rst:1145 msgid "Functions and methods" @@ -1340,17 +1755,17 @@ msgstr "" "Python のオブジェクト指向機能は、関数に基づく環境の上に構築されています。非" "データデスクリプタを使って、この 2 つはシームレスに組み合わされています。" -#: ../../howto/descriptor.rst:1150 msgid "" "Functions stored in class dictionaries get turned into methods when invoked. " "Methods only differ from regular functions in that the object instance is " "prepended to the other arguments. By convention, the instance is called " "*self* but could be called *this* or any other variable name." msgstr "" -"クラス辞書に格納された関数は、実行時にメソッドに変換されます。メソッドと通常" -"の関数はオブジェクトのインスタンスが他の引数よりも前に渡される点だけが異なり" -"ます。監修ではインスタンスは *self* という名前が使われますが、 *this* や他の" -"変数名も使えます。" +"クラス辞書に格納された関数は、呼び出されるときにメソッドに変換されます。\n" +"通常の関数との違いは、ほかの引数より前にオブジェクトのインスタンスが渡される" +"ことだけです。\n" +"慣習上、このインスタンスの引数名は *self* ですが、*this* などの別の名前でも構" +"いません。" #: ../../howto/descriptor.rst:1155 msgid "" @@ -1360,7 +1775,6 @@ msgstr "" "メソッドは、ほぼ次のコードと同等な :class:`types.MethodType` を使えば手動で作" "れます。" -#: ../../howto/descriptor.rst:1158 msgid "" "class MethodType:\n" " \"Emulate PyMethod_Type in Objects/classobject.c\"\n" @@ -1388,16 +1802,44 @@ msgid "" " \"Emulate method_descr_get() in Objects/classobject.c\"\n" " return self" msgstr "" +"class MethodType:\n" +" \"Objects/classobject.c の PyMethod_Type を模擬する\"\n" +"\n" +" def __init__(self, func, obj):\n" +" self.__func__ = func\n" +" self.__self__ = obj\n" +"\n" +" def __call__(self, *args, **kwargs):\n" +" func = self.__func__\n" +" obj = self.__self__\n" +" return func(obj, *args, **kwargs)\n" +"\n" +" def __getattribute__(self, name):\n" +" \"Objects/classobject.c の method_getset() を模擬する\"\n" +" if name == '__doc__':\n" +" return self.__func__.__doc__\n" +" return object.__getattribute__(self, name)\n" +"\n" +" def __getattr__(self, name):\n" +" \"Objects/classobject.c の method_getattro() を模擬する\"\n" +" return getattr(self.__func__, name)\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" \"Objects/classobject.c の method_descr_get() を模擬する\"\n" +" return self" -#: ../../howto/descriptor.rst:1186 msgid "" "To support automatic creation of methods, functions include the :meth:" "`~object.__get__` method for binding methods during attribute access. This " "means that functions are non-data descriptors that return bound methods " "during dotted lookup from an instance. Here's how it works:" msgstr "" +"関数には、属性アクセス時にメソッドを束縛する :meth:`~object.__get__` があり、" +"メソッドを自動的に作れるようになっています。\n" +"つまり、関数は非データデスクリプタであり、インスタンスからドット記法で検索す" +"ると束縛メソッドを返します。\n" +"その仕組みは次のとおりです。" -#: ../../howto/descriptor.rst:1191 msgid "" "class Function:\n" " ...\n" @@ -1408,16 +1850,22 @@ msgid "" " return self\n" " return MethodType(self, obj)" msgstr "" +"class Function:\n" +" ...\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" \"Objects/funcobject.c の func_descr_get() を模擬する\"\n" +" if obj is None:\n" +" return self\n" +" return MethodType(self, obj)" -#: ../../howto/descriptor.rst:1202 msgid "" "Running the following class in the interpreter shows how the function " "descriptor works in practice:" msgstr "" -"次のクラスをインタプリタを起動すると、この関数デスクリプタが実際にどう働くか" -"を見られます::" +"次のクラスをインタープリタで実行すると、関数デスクリプタが実際にどう動くかを" +"確認できます。" -#: ../../howto/descriptor.rst:1205 msgid "" "class D:\n" " def f(self):\n" @@ -1426,6 +1874,12 @@ msgid "" "class D2:\n" " pass" msgstr "" +"class D:\n" +" def f(self):\n" +" return self\n" +"\n" +"class D2:\n" +" pass" #: ../../howto/descriptor.rst:1223 msgid "" @@ -1434,49 +1888,60 @@ msgstr "" "この関数はイントロスペクションをサポートするために :term:`qualified name` も" "持っています。" -#: ../../howto/descriptor.rst:1225 msgid "" ">>> D.f.__qualname__\n" "'D.f'" msgstr "" +">>> D.f.__qualname__\n" +"'D.f'" -#: ../../howto/descriptor.rst:1230 msgid "" "Accessing the function through the class dictionary does not invoke :meth:" "`~object.__get__`. Instead, it just returns the underlying function object::" msgstr "" +"クラス辞書から関数にアクセスしても、:meth:`~object.__get__` は呼び出されませ" +"ん。\n" +"格納されている関数オブジェクトがそのまま返されます。 ::" -#: ../../howto/descriptor.rst:1233 msgid "" ">>> D.__dict__['f']\n" "" msgstr "" +">>> D.__dict__['f']\n" +"" -#: ../../howto/descriptor.rst:1236 msgid "" "Dotted access from a class calls :meth:`~object.__get__` which just returns " "the underlying function unchanged::" msgstr "" +"クラスからドット記法でアクセスすると :meth:`~object.__get__` が呼ばれますが、" +"これは元の関数をそのまま返すだけです。 ::" -#: ../../howto/descriptor.rst:1239 msgid "" ">>> D.f\n" "" msgstr "" +">>> D.f\n" +"" -#: ../../howto/descriptor.rst:1242 msgid "" "The interesting behavior occurs during dotted access from an instance. The " "dotted lookup calls :meth:`~object.__get__` which returns a bound method " "object::" msgstr "" +"興味深い動作が起きるのは、インスタンスからドット記法でアクセスしたときで" +"す。\n" +"この検索では :meth:`~object.__get__` が呼ばれ、束縛メソッドオブジェクトが返さ" +"れます。 ::" -#: ../../howto/descriptor.rst:1245 msgid "" ">>> d = D()\n" ">>> d.f\n" ">" msgstr "" +">>> d = D()\n" +">>> d.f\n" +">" #: ../../howto/descriptor.rst:1249 msgid "" @@ -1486,7 +1951,6 @@ msgstr "" "内部では、束縛メソッドはオリジナルの関数と束縛されたインスタンスを保持してい" "ます。" -#: ../../howto/descriptor.rst:1252 msgid "" ">>> d.f.__func__\n" "\n" @@ -1494,6 +1958,11 @@ msgid "" ">>> d.f.__self__\n" "<__main__.D object at 0x00B18C90>" msgstr "" +">>> d.f.__func__\n" +"\n" +"\n" +">>> d.f.__self__\n" +"<__main__.D object at 0x00B18C90>" #: ../../howto/descriptor.rst:1258 msgid "" @@ -1515,13 +1984,17 @@ msgstr "" "非データデスクリプタは、関数をメソッドに束縛する、各種の一般的なパターンに、" "単純な機構を提供します。" -#: ../../howto/descriptor.rst:1268 msgid "" "To recap, functions have a :meth:`~object.__get__` method so that they can " "be converted to a method when accessed as attributes. The non-data " "descriptor transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. " "Calling ``cls.f(*args)`` becomes ``f(*args)``." msgstr "" +"ここまでを振り返ると、関数は :meth:`~object.__get__` メソッドを持ち、属性とし" +"てアクセスされたときにメソッドに変換できます。\n" +"この非データデスクリプタは ``obj.f(*args)`` という呼び出しを ``f(obj, " +"*args)`` に変換します。\n" +"``cls.f(*args)`` は ``f(*args)`` になります。" #: ../../howto/descriptor.rst:1273 msgid "This chart summarizes the binding and its two most useful variants:" @@ -1610,29 +2083,35 @@ msgid "" msgstr "" "静的メソッドは下にある関数をそのまま返すので、呼び出しの例は面白くありません:" -#: ../../howto/descriptor.rst:1311 msgid "" "class E:\n" " @staticmethod\n" " def f(x):\n" " return x * 10" msgstr "" +"class E:\n" +" @staticmethod\n" +" def f(x):\n" +" return x * 10" -#: ../../howto/descriptor.rst:1318 msgid "" ">>> E.f(3)\n" "30\n" ">>> E().f(3)\n" "30" msgstr "" +">>> E.f(3)\n" +"30\n" +">>> E().f(3)\n" +"30" -#: ../../howto/descriptor.rst:1325 msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`staticmethod` would look like this:" msgstr "" +"非データデスクリプタプロトコルを使い、:deco:`staticmethod` を Python だけで実" +"装すると、次のようになります。" -#: ../../howto/descriptor.rst:1328 msgid "" "import functools\n" "\n" @@ -1653,8 +2132,25 @@ msgid "" " def __annotations__(self):\n" " return self.f.__annotations__" msgstr "" +"import functools\n" +"\n" +"class StaticMethod:\n" +" \"Objects/funcobject.c の PyStaticMethod_Type() を模擬する\"\n" +"\n" +" def __init__(self, f):\n" +" self.f = f\n" +" functools.update_wrapper(self, f)\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" return self.f\n" +"\n" +" def __call__(self, *args, **kwds):\n" +" return self.f(*args, **kwds)\n" +"\n" +" @property\n" +" def __annotations__(self):\n" +" return self.f.__annotations__" -#: ../../howto/descriptor.rst:1349 msgid "" "The :func:`functools.update_wrapper` call adds a ``__wrapped__`` attribute " "that refers to the underlying function. Also it carries forward the " @@ -1662,6 +2158,11 @@ msgid "" "including :attr:`~function.__name__`, :attr:`~function.__qualname__`, and :" "attr:`~function.__doc__`." msgstr "" +":func:`functools.update_wrapper` を呼び出すと、元の関数を参照する " +"``__wrapped__`` 属性が追加されます。\n" +"また、ラッパをラップ対象の関数と同じように見せるため、:attr:`~function." +"__name__`、:attr:`~function.__qualname__`、:attr:`~function.__doc__` などの必" +"要な属性が引き継がれます。" #: ../../howto/descriptor.rst:1418 msgid "Class methods" @@ -1677,21 +2178,27 @@ msgstr "" "ストの先頭に加えます。このフォーマットは、呼び出し元がオブジェクトでもクラス" "でも同じです:" -#: ../../howto/descriptor.rst:1424 msgid "" "class F:\n" " @classmethod\n" " def f(cls, x):\n" " return cls.__name__, x" msgstr "" +"class F:\n" +" @classmethod\n" +" def f(cls, x):\n" +" return cls.__name__, x" -#: ../../howto/descriptor.rst:1431 msgid "" ">>> F.f(3)\n" "('F', 3)\n" ">>> F().f(3)\n" "('F', 3)" msgstr "" +">>> F.f(3)\n" +"('F', 3)\n" +">>> F().f(3)\n" +"('F', 3)" #: ../../howto/descriptor.rst:1438 msgid "" @@ -1706,7 +2213,6 @@ msgstr "" "クラスコンストラクタを作ることです。例えば、クラスメソッド :func:`dict." "fromkeys` は新しい辞書をキーのリストから生成します。等価な pure Python 版は:" -#: ../../howto/descriptor.rst:1444 msgid "" "class Dict(dict):\n" " @classmethod\n" @@ -1717,12 +2223,19 @@ msgid "" " d[key] = value\n" " return d" msgstr "" +"class Dict(dict):\n" +" @classmethod\n" +" def fromkeys(cls, iterable, value=None):\n" +" \"Objects/dictobject.c の dict_fromkeys() を模擬する\"\n" +" d = cls()\n" +" for key in iterable:\n" +" d[key] = value\n" +" return d" #: ../../howto/descriptor.rst:1455 msgid "Now a new dictionary of unique keys can be constructed like this:" msgstr "これで一意なキーを持つ新しい辞書が以下のように構成できます:" -#: ../../howto/descriptor.rst:1457 msgid "" ">>> d = Dict.fromkeys('abracadabra')\n" ">>> type(d) is Dict\n" @@ -1730,14 +2243,19 @@ msgid "" ">>> d\n" "{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" msgstr "" +">>> d = Dict.fromkeys('abracadabra')\n" +">>> type(d) is Dict\n" +"True\n" +">>> d\n" +"{'a': None, 'b': None, 'r': None, 'c': None, 'd': None}" -#: ../../howto/descriptor.rst:1465 msgid "" "Using the non-data descriptor protocol, a pure Python version of :deco:" "`classmethod` would look like this:" msgstr "" +"非データデスクリプタプロトコルを使い、:deco:`classmethod` を Python だけで実" +"装すると、次のようになります。" -#: ../../howto/descriptor.rst:1468 msgid "" "import functools\n" "\n" @@ -1753,6 +2271,19 @@ msgid "" " cls = type(obj)\n" " return MethodType(self.f, cls)" msgstr "" +"import functools\n" +"\n" +"class ClassMethod:\n" +" \"Objects/funcobject.c の PyClassMethod_Type() を模擬する\"\n" +"\n" +" def __init__(self, f):\n" +" self.f = f\n" +" functools.update_wrapper(self, f)\n" +"\n" +" def __get__(self, obj, cls=None):\n" +" if cls is None:\n" +" cls = type(obj)\n" +" return MethodType(self.f, cls)" #: ../../howto/descriptor.rst:1530 msgid "" @@ -1799,7 +2330,6 @@ msgstr "" "class Vehicle:\n" " __slots__ = ('id_number', 'make', 'model')" -#: ../../howto/descriptor.rst:1553 msgid "" ">>> auto = Vehicle()\n" ">>> auto.id_nubmer = 'VYE483814LQEX'\n" @@ -1807,6 +2337,11 @@ msgid "" " ...\n" "AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" msgstr "" +">>> auto = Vehicle()\n" +">>> auto.id_nubmer = 'VYE483814LQEX'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'Vehicle' object has no attribute 'id_nubmer'" #: ../../howto/descriptor.rst:1561 msgid "" @@ -1816,7 +2351,6 @@ msgstr "" "2. デスクリプタが ``__slots__`` に格納されたプライベートな属性へのアクセスを" "制御するような、イミュータブルオブジェクトが作りやすくなる。" -#: ../../howto/descriptor.rst:1564 msgid "" "class Immutable:\n" "\n" @@ -1835,8 +2369,22 @@ msgid "" " def name(self): # Read-only descriptor\n" " return self._name" msgstr "" +"class Immutable:\n" +"\n" +" __slots__ = ('_dept', '_name') # インスタンス辞書を置き換える\n" +"\n" +" def __init__(self, dept, name):\n" +" self._dept = dept # プライベート属性に格納する\n" +" self._name = name # プライベート属性に格納する\n" +"\n" +" @property # 読み取り専用のデスクリプタ\n" +" def dept(self):\n" +" return self._dept\n" +"\n" +" @property\n" +" def name(self): # 読み取り専用のデスクリプタ\n" +" return self._name" -#: ../../howto/descriptor.rst:1582 msgid "" ">>> mark = Immutable('Botany', 'Mark Watney')\n" ">>> mark.dept\n" @@ -1850,6 +2398,17 @@ msgid "" " ...\n" "AttributeError: 'Immutable' object has no attribute 'location'" msgstr "" +">>> mark = Immutable('Botany', 'Mark Watney')\n" +">>> mark.dept\n" +"'Botany'\n" +">>> mark.dept = 'Space Pirate'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: property 'dept' of 'Immutable' object has no setter\n" +">>> mark.location = 'Mars'\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'Immutable' object has no attribute 'location'" #: ../../howto/descriptor.rst:1596 msgid "" @@ -1872,13 +2431,13 @@ msgstr "" "4. 速度の改善。 ``__slots__`` を使うとインスタンス変数の読み込み速度が35%早く" "なります(Apple M1プロセッサで動作させたPython 3.10で測定)" -#: ../../howto/descriptor.rst:1604 msgid "" "5. Blocks tools like :deco:`functools.cached_property` which require an " "instance dictionary to function correctly:" msgstr "" +"5. 正しく動作するためにインスタンス辞書を必要とする :deco:`functools." +"cached_property` などの機能が使えなくなります。" -#: ../../howto/descriptor.rst:1607 msgid "" "from functools import cached_property\n" "\n" @@ -1890,16 +2449,27 @@ msgid "" " return 4 * sum((-1.0)**n / (2.0*n + 1.0)\n" " for n in reversed(range(100_000)))" msgstr "" +"from functools import cached_property\n" +"\n" +"class CP:\n" +" __slots__ = () # インスタンス辞書をなくす\n" +"\n" +" @cached_property # インスタンス辞書が必要\n" +" def pi(self):\n" +" return 4 * sum((-1.0)**n / (2.0*n + 1.0)\n" +" for n in reversed(range(100_000)))" -#: ../../howto/descriptor.rst:1619 msgid "" ">>> CP().pi\n" "Traceback (most recent call last):\n" " ...\n" "TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." msgstr "" +">>> CP().pi\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property." -#: ../../howto/descriptor.rst:1626 msgid "" "It is not possible to create an exact drop-in pure Python version of " "``__slots__`` because it requires direct access to C structures and control " @@ -1908,13 +2478,13 @@ msgid "" "``_slotvalues`` list. Reads and writes to that private structure are " "managed by member descriptors:" msgstr "" -"``__slots__`` はC構造体に直接アクセスし、オブジェクトのメモリ確保を制御する必" -"要があるため、ピュアPythonバージョンを作成することはできません。しかし、プラ" -"イベートの ``__slotvalues`` リストを使ってC構造体のスロットをほぼ忠実にエミュ" -"レートすることはできます。そのプライベートな構造体への読み書きはメンバーのデ" -"スクリプタによって管理されます。" +"``__slots__`` は C 構造体への直接アクセスとオブジェクトのメモリ割り当ての制御" +"を必要とするため、完全に置き換え可能な実装を Python だけで作ることはできませ" +"ん。\n" +"ただし、スロット用の C 構造体をプライベートな ``_slotvalues`` リストで模擬す" +"ることで、ほぼ忠実に再現できます。\n" +"このプライベートな構造への読み書きは、メンバーデスクリプタが管理します。" -#: ../../howto/descriptor.rst:1633 msgid "" "null = sentinel('null')\n" "\n" @@ -1952,12 +2522,48 @@ msgid "" " 'Emulate member_repr() in Objects/descrobject.c'\n" " return f''" msgstr "" +"null = sentinel('null')\n" +"\n" +"class Member:\n" +"\n" +" def __init__(self, name, clsname, offset):\n" +" 'Include/descrobject.h の PyMemberDef を模擬する'\n" +" # Objects/descrobject.c の descr_new() も参照\n" +" self.name = name\n" +" self.clsname = clsname\n" +" self.offset = offset\n" +"\n" +" def __get__(self, obj, objtype=None):\n" +" 'Objects/descrobject.c の member_get() を模擬する'\n" +" # Python/structmember.c の PyMember_GetOne() も参照\n" +" if obj is None:\n" +" return self\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" return value\n" +"\n" +" def __set__(self, obj, value):\n" +" 'Objects/descrobject.c の member_set() を模擬する'\n" +" obj._slotvalues[self.offset] = value\n" +"\n" +" def __delete__(self, obj):\n" +" 'Objects/descrobject.c の member_delete() を模擬する'\n" +" value = obj._slotvalues[self.offset]\n" +" if value is null:\n" +" raise AttributeError(self.name)\n" +" obj._slotvalues[self.offset] = null\n" +"\n" +" def __repr__(self):\n" +" 'Objects/descrobject.c の member_repr() を模擬する'\n" +" return f''" -#: ../../howto/descriptor.rst:1671 msgid "" "The :meth:`!type.__new__` method takes care of adding member objects to " "class variables:" msgstr "" +":meth:`!type.__new__` メソッドが、クラス変数にメンバーオブジェクトを追加しま" +"す。" #: ../../howto/descriptor.rst:1674 msgid "" @@ -1983,7 +2589,6 @@ msgstr "" "スタンスの作成の処理をします。おおざっぱにピュアPythonでのシミュレーションし" "たコードがこちらです。" -#: ../../howto/descriptor.rst:1691 msgid "" "class Object:\n" " 'Simulate how object.__new__() allocates memory for __slots__'\n" @@ -2014,14 +2619,42 @@ msgid "" " )\n" " super().__delattr__(name)" msgstr "" +"class Object:\n" +" 'object.__new__() が __slots__ 用のメモリを確保する仕組みを模擬する'\n" +"\n" +" def __new__(cls, *args, **kwargs):\n" +" 'Objects/typeobject.c の object_new() を模擬する'\n" +" inst = super().__new__(cls)\n" +" if hasattr(cls, 'slot_names'):\n" +" empty_slots = [null] * len(cls.slot_names)\n" +" object.__setattr__(inst, '_slotvalues', empty_slots)\n" +" return inst\n" +"\n" +" def __setattr__(self, name, value):\n" +" 'Objects/object.c の _PyObject_GenericSetAttrWithDict() を模擬する'\n" +" cls = type(self)\n" +" if hasattr(cls, 'slot_names') and name not in cls.slot_names:\n" +" raise AttributeError(\n" +" f'{cls.__name__!r} object has no attribute {name!r}'\n" +" )\n" +" super().__setattr__(name, value)\n" +"\n" +" def __delattr__(self, name):\n" +" 'Objects/object.c の _PyObject_GenericSetAttrWithDict() を模擬する'\n" +" cls = type(self)\n" +" if hasattr(cls, 'slot_names') and name not in cls.slot_names:\n" +" raise AttributeError(\n" +" f'{cls.__name__!r} object has no attribute {name!r}'\n" +" )\n" +" super().__delattr__(name)" -#: ../../howto/descriptor.rst:1722 msgid "" "To use the simulation in a real class, just inherit from :class:`!Object` " "and set the :term:`metaclass` to :class:`Type`:" msgstr "" +"この模擬実装を実際のクラスで使うには、:class:`!Object` を継承し、:term:" +"`metaclass` を :class:`Type` にするだけです。" -#: ../../howto/descriptor.rst:1725 msgid "" "class H(Object, metaclass=Type):\n" " 'Instance variables stored in slots'\n" @@ -2032,6 +2665,14 @@ msgid "" " self.x = x\n" " self.y = y" msgstr "" +"class H(Object, metaclass=Type):\n" +" 'インスタンス変数をスロットに格納する'\n" +"\n" +" slot_names = ['x', 'y']\n" +"\n" +" def __init__(self, x, y):\n" +" self.x = x\n" +" self.y = y" #: ../../howto/descriptor.rst:1736 msgid "" @@ -2039,7 +2680,6 @@ msgid "" msgstr "" "この時点ではメタクラスは *x* と *y* のメンバーオブジェクトをロードします。" -#: ../../howto/descriptor.rst:1738 msgid "" ">>> from pprint import pp\n" ">>> pp(dict(vars(H)))\n" @@ -2050,6 +2690,14 @@ msgid "" " 'x': ,\n" " 'y': }" msgstr "" +">>> from pprint import pp\n" +">>> pp(dict(vars(H)))\n" +"{'__module__': '__main__',\n" +" '__doc__': 'インスタンス変数をスロットに格納する',\n" +" 'slot_names': ['x', 'y'],\n" +" '__init__': ,\n" +" 'x': ,\n" +" 'y': }" #: ../../howto/descriptor.rst:1757 msgid "" @@ -2059,7 +2707,6 @@ msgstr "" "インスタンスが作成されると、属性が保持される ``slot_values`` のリストをイン" "スタンスが保持します:" -#: ../../howto/descriptor.rst:1760 msgid "" ">>> h = H(10, 20)\n" ">>> vars(h)\n" @@ -2068,15 +2715,24 @@ msgid "" ">>> vars(h)\n" "{'_slotvalues': [55, 20]}" msgstr "" +">>> h = H(10, 20)\n" +">>> vars(h)\n" +"{'_slotvalues': [10, 20]}\n" +">>> h.x = 55\n" +">>> vars(h)\n" +"{'_slotvalues': [55, 20]}" #: ../../howto/descriptor.rst:1769 msgid "Misspelled or unassigned attributes will raise an exception:" msgstr "スペルミスや、未アサインの属性は例外を送出します。" -#: ../../howto/descriptor.rst:1771 msgid "" ">>> h.xz\n" "Traceback (most recent call last):\n" " ...\n" "AttributeError: 'H' object has no attribute 'xz'" msgstr "" +">>> h.xz\n" +"Traceback (most recent call last):\n" +" ...\n" +"AttributeError: 'H' object has no attribute 'xz'" diff --git a/howto/enum.po b/howto/enum.po index 216a740de..10eacfd43 100644 --- a/howto/enum.po +++ b/howto/enum.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/enum.rst:5 @@ -44,7 +44,6 @@ msgstr "" "これらは、限られた選択肢の値の一つを取る変数がある場合に便利です。例えば、曜" "日情報があります:" -#: ../../howto/enum.rst:18 msgid "" ">>> from enum import Enum\n" ">>> class Weekday(Enum):\n" @@ -56,12 +55,20 @@ msgid "" "... SATURDAY = 6\n" "... SUNDAY = 7" msgstr "" +">>> from enum import Enum\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7" #: ../../howto/enum.rst:28 msgid "Or perhaps the RGB primary colors::" msgstr "あるいは、RGB三原色でも構いません::" -#: ../../howto/enum.rst:30 msgid "" ">>> from enum import Enum\n" ">>> class Color(Enum):\n" @@ -69,6 +76,11 @@ msgid "" "... GREEN = 2\n" "... BLUE = 3" msgstr "" +">>> from enum import Enum\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3" #: ../../howto/enum.rst:36 msgid "" @@ -102,11 +114,12 @@ msgstr "" "列挙型の性質によって、メンバの値は重要な場合とそうでない場合がありますが、い" "ずれの場合でも、その値は対応するメンバを取得するのに使えます::" -#: ../../howto/enum.rst:50 msgid "" ">>> Weekday(3)\n" "" msgstr "" +">>> Weekday(3)\n" +"" #: ../../howto/enum.rst:53 msgid "" @@ -117,45 +130,50 @@ msgstr "" "ご覧の通り、メンバの ``repr()`` は列挙型の名前、メンバの名前、そして値を表示" "します。メンバの ``str()`` は列挙型の名前とメンバの名前のみを表示します。" -#: ../../howto/enum.rst:57 msgid "" ">>> print(Weekday.THURSDAY)\n" "Weekday.THURSDAY" msgstr "" +">>> print(Weekday.THURSDAY)\n" +"Weekday.THURSDAY" #: ../../howto/enum.rst:60 msgid "The *type* of an enumeration member is the enum it belongs to::" msgstr "列挙型のメンバの型はそのメンバの属する列挙型です::" -#: ../../howto/enum.rst:62 msgid "" ">>> type(Weekday.MONDAY)\n" "\n" ">>> isinstance(Weekday.FRIDAY, Weekday)\n" "True" msgstr "" +">>> type(Weekday.MONDAY)\n" +"\n" +">>> isinstance(Weekday.FRIDAY, Weekday)\n" +"True" -#: ../../howto/enum.rst:67 msgid "Enum members have an attribute that contains just their :attr:`!name`::" msgstr "" +"列挙型のメンバーには、その名前だけを保持する :attr:`!name` 属性がありま" +"す。 ::" -#: ../../howto/enum.rst:69 msgid "" ">>> print(Weekday.TUESDAY.name)\n" "TUESDAY" msgstr "" +">>> print(Weekday.TUESDAY.name)\n" +"TUESDAY" -#: ../../howto/enum.rst:72 msgid "Likewise, they have an attribute for their :attr:`!value`::" -msgstr "" +msgstr "同様に、値を保持する :attr:`!value` 属性もあります。 ::" -#: ../../howto/enum.rst:75 msgid "" ">>> Weekday.WEDNESDAY.value\n" "3" msgstr "" +">>> Weekday.WEDNESDAY.value\n" +"3" -#: ../../howto/enum.rst:78 msgid "" "Unlike many languages that treat enumerations solely as name/value pairs, " "Python Enums can have behavior added. For example, :class:`datetime.date` " @@ -166,19 +184,27 @@ msgid "" "day from the :class:`~datetime.date` instance and return the matching enum " "member::" msgstr "" +"多くの言語では列挙型を名前と値の組だけとして扱いますが、Python の列挙型には動" +"作を追加できます。\n" +"例えば、:class:`datetime.date` には曜日を返す :meth:`~datetime.date.weekday` " +"と :meth:`~datetime.date.isoweekday` という 2 つのメソッドがあります。\n" +"違いは、一方が 0~6、もう一方が 1~7 で数えることです。\n" +"この違いを自分で管理する代わりに、:class:`!Weekday` 列挙型にメソッドを追加" +"し、:class:`~datetime.date` インスタンスから曜日を取り出して、対応する列挙型" +"メンバーを返すようにできます。 ::" -#: ../../howto/enum.rst:87 msgid "" "@classmethod\n" "def from_date(cls, date):\n" " return cls(date.isoweekday())" msgstr "" +"@classmethod\n" +"def from_date(cls, date):\n" +" return cls(date.isoweekday())" -#: ../../howto/enum.rst:91 msgid "The complete :class:`!Weekday` enum now looks like this::" -msgstr "" +msgstr ":class:`!Weekday` 列挙型全体は次のようになります。 ::" -#: ../../howto/enum.rst:93 msgid "" ">>> class Weekday(Enum):\n" "... MONDAY = 1\n" @@ -193,17 +219,31 @@ msgid "" "... def from_date(cls, date):\n" "... return cls(date.isoweekday())" msgstr "" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7\n" +"... #\n" +"... @classmethod\n" +"... def from_date(cls, date):\n" +"... return cls(date.isoweekday())" #: ../../howto/enum.rst:106 msgid "Now we can find out what today is! Observe::" msgstr "さて、これで今日が何曜日か調べることができます! 見てみましょう::" -#: ../../howto/enum.rst:108 msgid "" ">>> import datetime as dt\n" ">>> Weekday.from_date(dt.date.today())\n" "" msgstr "" +">>> import datetime as dt\n" +">>> Weekday.from_date(dt.date.today())\n" +"" #: ../../howto/enum.rst:112 msgid "" @@ -213,15 +253,18 @@ msgstr "" "もちろん、あなたがこれを読んでいるのが他の曜日ならば、その曜日が代わりに表示" "されます。" -#: ../../howto/enum.rst:114 msgid "" "This :class:`!Weekday` enum is great if our variable only needs one day, but " "what if we need several? Maybe we're writing a function to plot chores " "during a week, and don't want to use a :class:`list` -- we could use a " "different type of :class:`Enum`::" msgstr "" +"この :class:`!Weekday` 列挙型は、変数が 1 つの曜日だけを表せばよい場合には便" +"利ですが、複数の曜日が必要ならどうでしょうか?\n" +"例えば、1 週間の家事を割り当てる関数を書いていて、:class:`list` は使いたくな" +"いとします。\n" +"別の種類の :class:`Enum` を使う方法があります。 ::" -#: ../../howto/enum.rst:119 msgid "" ">>> from enum import Flag\n" ">>> class Weekday(Flag):\n" @@ -233,6 +276,15 @@ msgid "" "... SATURDAY = 32\n" "... SUNDAY = 64" msgstr "" +">>> from enum import Flag\n" +">>> class Weekday(Flag):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 4\n" +"... THURSDAY = 8\n" +"... FRIDAY = 16\n" +"... SATURDAY = 32\n" +"... SUNDAY = 64" #: ../../howto/enum.rst:129 msgid "" @@ -242,18 +294,20 @@ msgstr "" "ここでは2つの変更が行われています。:class:`Flag` を継承している点と、値がすべ" "て2の累乗である点です。" -#: ../../howto/enum.rst:132 msgid "" "Just like the original :class:`!Weekday` enum above, we can have a single " "selection::" msgstr "" +"先ほどの :class:`!Weekday` 列挙型と同じように、1 つの曜日を選べます。 ::" -#: ../../howto/enum.rst:134 msgid "" ">>> first_week_day = Weekday.MONDAY\n" ">>> first_week_day\n" "" msgstr "" +">>> first_week_day = Weekday.MONDAY\n" +">>> first_week_day\n" +"" #: ../../howto/enum.rst:138 msgid "" @@ -263,30 +317,34 @@ msgstr "" "ただし、:class:`Flag` は複数のメンバーをひとつの変数にまとめることもできま" "す::" -#: ../../howto/enum.rst:141 msgid "" ">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" ">>> weekend\n" "" msgstr "" +">>> weekend = Weekday.SATURDAY | Weekday.SUNDAY\n" +">>> weekend\n" +"" #: ../../howto/enum.rst:145 msgid "You can even iterate over a :class:`Flag` variable::" msgstr ":class:`Flag` 変数は反復することもできます::" -#: ../../howto/enum.rst:147 msgid "" ">>> for day in weekend:\n" "... print(day)\n" "Weekday.SATURDAY\n" "Weekday.SUNDAY" msgstr "" +">>> for day in weekend:\n" +"... print(day)\n" +"Weekday.SATURDAY\n" +"Weekday.SUNDAY" #: ../../howto/enum.rst:152 msgid "Okay, let's get some chores set up::" msgstr "さて、いくつかの家事を設定してみましょう::" -#: ../../howto/enum.rst:154 msgid "" ">>> chores_for_ethan = {\n" "... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." @@ -295,12 +353,17 @@ msgid "" "... 'answer SO questions': Weekday.SATURDAY,\n" "... }" msgstr "" +">>> chores_for_ethan = {\n" +"... 'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday." +"FRIDAY,\n" +"... 'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,\n" +"... 'answer SO questions': Weekday.SATURDAY,\n" +"... }" #: ../../howto/enum.rst:160 msgid "And a function to display the chores for a given day::" msgstr "指定された日の家事を表示する関数も作成します::" -#: ../../howto/enum.rst:162 msgid "" ">>> def show_chores(chores, day):\n" "... for chore, days in chores.items():\n" @@ -310,6 +373,13 @@ msgid "" ">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" "answer SO questions" msgstr "" +">>> def show_chores(chores, day):\n" +"... for chore, days in chores.items():\n" +"... if day in days:\n" +"... print(chore)\n" +"...\n" +">>> show_chores(chores_for_ethan, Weekday.SATURDAY)\n" +"answer SO questions" #: ../../howto/enum.rst:170 msgid "" @@ -319,7 +389,6 @@ msgstr "" "メンバーの実際の値が重要でない場合は、:func:`auto` を使用することで手間を省く" "ことができます::" -#: ../../howto/enum.rst:173 msgid "" ">>> from enum import auto\n" ">>> class Weekday(Flag):\n" @@ -332,28 +401,42 @@ msgid "" "... SUNDAY = auto()\n" "... WEEKEND = SATURDAY | SUNDAY" msgstr "" +">>> from enum import auto\n" +">>> class Weekday(Flag):\n" +"... MONDAY = auto()\n" +"... TUESDAY = auto()\n" +"... WEDNESDAY = auto()\n" +"... THURSDAY = auto()\n" +"... FRIDAY = auto()\n" +"... SATURDAY = auto()\n" +"... SUNDAY = auto()\n" +"... WEEKEND = SATURDAY | SUNDAY" #: ../../howto/enum.rst:189 msgid "Programmatic access to enumeration members and their attributes" msgstr "列挙型メンバーおよびそれらの属性へのプログラム的アクセス" -#: ../../howto/enum.rst:191 msgid "" "Sometimes it's useful to access members in enumerations programmatically (i." "e. situations where ``Color.RED`` won't do because the exact color is not " "known at program-writing time). ``Enum`` allows such access::" msgstr "" -"プログラム的にメンバーに番号でアクセスしたほうが便利な場合があります (すなわ" -"ち、プログラムを書いている時点で正確な色がまだわからなく、``Color.RED`` と書" -"くのが無理な場合など)。 ``Enum`` ではそのようなアクセスも可能です::" +"列挙型のメンバーに、プログラムで決めた値を使ってアクセスしたい場合がありま" +"す。\n" +"例えば、プログラムを書く時点では具体的な色が決まっておらず、``Color.RED`` と" +"書けない場合です。\n" +"``Enum`` はそのようなアクセスもできます。 ::" -#: ../../howto/enum.rst:195 msgid "" ">>> Color(1)\n" "\n" ">>> Color(3)\n" "" msgstr "" +">>> Color(1)\n" +"\n" +">>> Color(3)\n" +"" #: ../../howto/enum.rst:200 msgid "If you want to access enum members by *name*, use item access::" @@ -361,20 +444,23 @@ msgstr "" "列挙型メンバーに *名前* でアクセスしたい場合はアイテムとしてアクセスできま" "す::" -#: ../../howto/enum.rst:202 msgid "" ">>> Color['RED']\n" "\n" ">>> Color['GREEN']\n" "" msgstr "" +">>> Color['RED']\n" +"\n" +">>> Color['GREEN']\n" +"" -#: ../../howto/enum.rst:207 msgid "" "If you have an enum member and need its :attr:`!name` or :attr:`!value`::" msgstr "" +"列挙型メンバーから :attr:`!name` や :attr:`!value` を取得するには、次のように" +"します。 ::" -#: ../../howto/enum.rst:209 msgid "" ">>> member = Color.RED\n" ">>> member.name\n" @@ -382,6 +468,11 @@ msgid "" ">>> member.value\n" "1" msgstr "" +">>> member = Color.RED\n" +">>> member.name\n" +"'RED'\n" +">>> member.value\n" +"1" #: ../../howto/enum.rst:217 msgid "Duplicating enum members and values" @@ -391,7 +482,6 @@ msgstr "列挙型メンバーと値の重複" msgid "Having two enum members with the same name is invalid::" msgstr "同じ名前の列挙型メンバーを複数持つことはできません::" -#: ../../howto/enum.rst:221 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -401,8 +491,14 @@ msgid "" "...\n" "TypeError: 'SQUARE' already defined as 2" msgstr "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... SQUARE = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: 'SQUARE' already defined as 2" -#: ../../howto/enum.rst:229 msgid "" "However, an enum member can have other names associated with it. Given two " "entries ``A`` and ``B`` with the same value (and ``A`` defined first), ``B`` " @@ -411,12 +507,11 @@ msgid "" "member ``A``. By-name lookup of ``B`` will also return the member ``A``::" msgstr "" "しかし、列挙型メンバー は、別の名前を持つことができます。 同じ値を持つ " -"``A`` と``B`` が与えられた場合(そして ``A`` が先に定義されている場合)、 " +"``A`` と ``B`` が与えられた場合(そして ``A`` が先に定義されている場合)、 " "``B`` はメンバー ``A`` に対するエイリアスとなります。 ``A`` の値での検索で" "は、メンバー ``A`` が返されます。 ``A`` の名前での検索ではメンバー ``A`` を" "返します。``B`` の名前での検索も、メンバー ``A`` を返します::" -#: ../../howto/enum.rst:235 msgid "" ">>> class Shape(Enum):\n" "... SQUARE = 2\n" @@ -431,6 +526,18 @@ msgid "" ">>> Shape(2)\n" "" msgstr "" +">>> class Shape(Enum):\n" +"... SQUARE = 2\n" +"... DIAMOND = 1\n" +"... CIRCLE = 3\n" +"... ALIAS_FOR_SQUARE = 2\n" +"...\n" +">>> Shape.SQUARE\n" +"\n" +">>> Shape.ALIAS_FOR_SQUARE\n" +"\n" +">>> Shape(2)\n" +"" #: ../../howto/enum.rst:250 msgid "" @@ -441,17 +548,16 @@ msgstr "" "すでに定義されている属性と同じ名前のメンバー (一方がメンバーでもう一方がメ" "ソッド、など) の作成、あるいはメンバーと同じ名前の属性の作成はできません。" -#: ../../howto/enum.rst:256 msgid "Ensuring unique enumeration values" -msgstr "番号付けの値が一意であることの確認" +msgstr "列挙型の値が一意であることを保証する" -#: ../../howto/enum.rst:258 msgid "" "By default, enumerations allow multiple names as aliases for the same value. " "When this behavior isn't desired, you can use the :deco:`unique` decorator::" msgstr "" +"デフォルトでは、列挙型は同じ値に対する別名として複数の名前を許容します。\n" +"この動作が望ましくない場合は、:deco:`unique` デコレータを使えます。 ::" -#: ../../howto/enum.rst:261 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -465,6 +571,17 @@ msgid "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" msgstr "" +">>> from enum import Enum, unique\n" +">>> @unique\n" +"... class Mistake(Enum):\n" +"... ONE = 1\n" +"... TWO = 2\n" +"... THREE = 3\n" +"... FOUR = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: duplicate values found in : FOUR -> THREE" #: ../../howto/enum.rst:275 msgid "Using automatic values" @@ -474,7 +591,6 @@ msgstr "値の自動設定を使う" msgid "If the exact value is unimportant you can use :class:`auto`::" msgstr "正確な値が重要でない場合、 :class:`auto` が使えます::" -#: ../../howto/enum.rst:279 msgid "" ">>> from enum import Enum, auto\n" ">>> class Color(Enum):\n" @@ -485,14 +601,22 @@ msgid "" ">>> [member.value for member in Color]\n" "[1, 2, 3]" msgstr "" +">>> from enum import Enum, auto\n" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> [member.value for member in Color]\n" +"[1, 2, 3]" -#: ../../howto/enum.rst:288 msgid "" "The values are chosen by :func:`~Enum._generate_next_value_`, which can be " "overridden::" msgstr "" +"値は :func:`~Enum._generate_next_value_` によって選ばれます。\n" +"この関数はオーバーライドできます。 ::" -#: ../../howto/enum.rst:291 msgid "" ">>> class AutoName(Enum):\n" "... @staticmethod\n" @@ -508,12 +632,26 @@ msgid "" ">>> [member.value for member in Ordinal]\n" "['NORTH', 'SOUTH', 'EAST', 'WEST']" msgstr "" +">>> class AutoName(Enum):\n" +"... @staticmethod\n" +"... def _generate_next_value_(name, start, count, last_values):\n" +"... return name\n" +"...\n" +">>> class Ordinal(AutoName):\n" +"... NORTH = auto()\n" +"... SOUTH = auto()\n" +"... EAST = auto()\n" +"... WEST = auto()\n" +"...\n" +">>> [member.value for member in Ordinal]\n" +"['NORTH', 'SOUTH', 'EAST', 'WEST']" -#: ../../howto/enum.rst:307 msgid "" "The :meth:`~Enum._generate_next_value_` method must be defined before any " "members." msgstr "" +":meth:`~Enum._generate_next_value_` メソッドは、すべてのメンバーより前に定義" +"しなければなりません。" #: ../../howto/enum.rst:310 msgid "Iteration" @@ -523,7 +661,6 @@ msgstr "イテレーション" msgid "Iterating over the members of an enum does not provide the aliases::" msgstr "列挙型のメンバーのイテレートは別名をサポートしていません::" -#: ../../howto/enum.rst:314 msgid "" ">>> list(Shape)\n" "[, , ]\n" @@ -532,13 +669,18 @@ msgid "" "THURSDAY: 8>, , , ]" msgstr "" +">>> list(Shape)\n" +"[, , ]\n" +">>> list(Weekday)\n" +"[, , , , , , ]" -#: ../../howto/enum.rst:319 msgid "" "Note that the aliases ``Shape.ALIAS_FOR_SQUARE`` and ``Weekday.WEEKEND`` " "aren't shown." msgstr "" -"エイリアスである ``Shape.ALIAS_FOR_SQUARE`` と``Weekday.WEEKEND`` が表示され" +"エイリアスである ``Shape.ALIAS_FOR_SQUARE`` と ``Weekday.WEEKEND`` が表示され" "ていないことに注意してください。" #: ../../howto/enum.rst:321 @@ -551,7 +693,6 @@ msgstr "" "型メンバーのマッピングです。これには別名も含め、列挙されたすべての名前が入っ" "ています。" -#: ../../howto/enum.rst:325 msgid "" ">>> for name, member in Shape.__members__.items():\n" "... name, member\n" @@ -561,6 +702,13 @@ msgid "" "('CIRCLE', )\n" "('ALIAS_FOR_SQUARE', )" msgstr "" +">>> for name, member in Shape.__members__.items():\n" +"... name, member\n" +"...\n" +"('SQUARE', )\n" +"('DIAMOND', )\n" +"('CIRCLE', )\n" +"('ALIAS_FOR_SQUARE', )" #: ../../howto/enum.rst:333 msgid "" @@ -570,12 +718,14 @@ msgstr "" "属性 ``__members__`` は列挙型メンバーへの詳細なアクセスに使用できます。以下は" "すべての別名を探す例です::" -#: ../../howto/enum.rst:336 msgid "" ">>> [name for name, member in Shape.__members__.items() if member.name != " "name]\n" "['ALIAS_FOR_SQUARE']" msgstr "" +">>> [name for name, member in Shape.__members__.items() if member.name != " +"name]\n" +"['ALIAS_FOR_SQUARE']" #: ../../howto/enum.rst:341 msgid "" @@ -593,7 +743,6 @@ msgstr "比較" msgid "Enumeration members are compared by identity::" msgstr "列挙型メンバーは同一性を比較できます::" -#: ../../howto/enum.rst:350 msgid "" ">>> Color.RED is Color.RED\n" "True\n" @@ -602,6 +751,12 @@ msgid "" ">>> Color.RED is not Color.BLUE\n" "True" msgstr "" +">>> Color.RED is Color.RED\n" +"True\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED is not Color.BLUE\n" +"True" #: ../../howto/enum.rst:357 msgid "" @@ -611,19 +766,21 @@ msgstr "" "列挙型の値の順序の比較はサポートされて *いません*。Enum メンバーは整数ではあ" "りません (`IntEnum`_ を参照してください)::" -#: ../../howto/enum.rst:360 msgid "" ">>> Color.RED < Color.BLUE\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "TypeError: '<' not supported between instances of 'Color' and 'Color'" msgstr "" +">>> Color.RED < Color.BLUE\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: '<' not supported between instances of 'Color' and 'Color'" #: ../../howto/enum.rst:365 msgid "Equality comparisons are defined though::" msgstr "ただし等価の比較は定義されています::" -#: ../../howto/enum.rst:367 msgid "" ">>> Color.BLUE == Color.RED\n" "False\n" @@ -632,19 +789,28 @@ msgid "" ">>> Color.BLUE == Color.BLUE\n" "True" msgstr "" +">>> Color.BLUE == Color.RED\n" +"False\n" +">>> Color.BLUE != Color.RED\n" +"True\n" +">>> Color.BLUE == Color.BLUE\n" +"True" -#: ../../howto/enum.rst:374 msgid "" "Equality comparisons against non-enumeration values will always return " "``False`` (again, :class:`IntEnum` was explicitly designed to behave " "differently, see below)::" msgstr "" +"列挙型でない値との等価比較は、常に ``False`` を返します。\n" +"ただし、:class:`IntEnum` は明示的に異なる動作をするよう設計されています。\n" +"詳しくは後で説明します。 ::" -#: ../../howto/enum.rst:378 msgid "" ">>> Color.BLUE == 2\n" "False" msgstr "" +">>> Color.BLUE == 2\n" +"False" #: ../../howto/enum.rst:383 msgid "" @@ -682,7 +848,6 @@ msgstr "" "列挙型は Python のクラスであり、通常どおりメソッドや特殊メソッドを持つことが" "できます::" -#: ../../howto/enum.rst:399 msgid "" ">>> class Mood(Enum):\n" "... FUNKY = 1\n" @@ -701,12 +866,27 @@ msgid "" "... return cls.HAPPY\n" "..." msgstr "" +">>> class Mood(Enum):\n" +"... FUNKY = 1\n" +"... HAPPY = 3\n" +"...\n" +"... def describe(self):\n" +"... # ここでは self はメンバー\n" +"... return self.name, self.value\n" +"...\n" +"... def __str__(self):\n" +"... return 'my custom str! {0}'.format(self.value)\n" +"...\n" +"... @classmethod\n" +"... def favorite_mood(cls):\n" +"... # ここでは cls は列挙型\n" +"... return cls.HAPPY\n" +"..." #: ../../howto/enum.rst:416 msgid "Then::" msgstr "上記の結果が以下のようになります::" -#: ../../howto/enum.rst:418 msgid "" ">>> Mood.favorite_mood()\n" "\n" @@ -715,8 +895,13 @@ msgid "" ">>> str(Mood.FUNKY)\n" "'my custom str! 1'" msgstr "" +">>> Mood.favorite_mood()\n" +"\n" +">>> Mood.HAPPY.describe()\n" +"('HAPPY', 3)\n" +">>> str(Mood.FUNKY)\n" +"'my custom str! 1'" -#: ../../howto/enum.rst:425 msgid "" "The rules for what is allowed are as follows: names that start and end with " "a single underscore are reserved by enum and cannot be used; all other " @@ -725,41 +910,55 @@ msgid "" "__str__`, :meth:`~object.__add__`, etc.), descriptors (methods are also " "descriptors), and variable names listed in :attr:`~Enum._ignore_`." msgstr "" +"使用できるものの規則は次のとおりです。\n" +"先頭と末尾がそれぞれ 1 つのアンダースコアである名前は enum が予約しているため" +"使えません。\n" +"それ以外の、列挙型の中で定義した属性はすべて列挙型のメンバーになります。\n" +"ただし、:meth:`~object.__str__` や :meth:`~object.__add__` などの特殊メソッ" +"ド、デスクリプタ (メソッドもデスクリプタです)、:attr:`~Enum._ignore_` に列挙" +"した変数名は例外です。" -#: ../../howto/enum.rst:432 msgid "" "Note: if your enumeration defines :meth:`~object.__new__` and/or :meth:" "`~object.__init__`, any value(s) given to the enum member will be passed " "into those methods. See `Planet`_ for an example." msgstr "" +"注意: 列挙型に :meth:`~object.__new__` や :meth:`~object.__init__` を定義する" +"と、メンバーに指定した値がそれらのメソッドに渡されます。\n" +"例は `Planet`_ を参照してください。" -#: ../../howto/enum.rst:438 msgid "" "The :meth:`~object.__new__` method, if defined, is used during creation of " "the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " "which is used after class creation for lookup of existing members. See :ref:" "`new-vs-init` for more details." msgstr "" +":meth:`~object.__new__` を定義した場合、そのメソッドは Enum メンバーの作成時" +"に使われます。\n" +"その後は Enum の :meth:`~object.__new__` に置き換えられ、クラス作成後の既存メ" +"ンバーの検索に使われます。\n" +"詳しくは :ref:`new-vs-init` を参照してください。" #: ../../howto/enum.rst:445 msgid "Restricted Enum subclassing" msgstr "Enumのサブクラス化の制限" -#: ../../howto/enum.rst:447 msgid "" "A new :class:`Enum` class must have one base enum class, up to one concrete " "data type, and as many :class:`object`-based mixin classes as needed. The " "order of these base classes is::" msgstr "" -"新しい :class:`Enum` クラスは、ベースの enum クラスを1つ、具象データ型を1つ、" -"複数の :class:`object` ベースのミックスインクラスが許容されます。これらのベー" -"スクラスの順序は次の通りです::" +"新しい :class:`Enum` クラスには、基底となる列挙型クラスが 1 つ必要です。\n" +"加えて、具象データ型を最大 1 つ、:class:`object` を基底とするミックスインクラ" +"スを必要なだけ指定できます。\n" +"これらの基底クラスは次の順に並べます。 ::" -#: ../../howto/enum.rst:451 msgid "" "class EnumName([mix-in, ...,] [data-type,] base-enum):\n" " pass" msgstr "" +"class EnumName([mix-in, ...,] [data-type,] base-enum):\n" +" pass" #: ../../howto/enum.rst:454 msgid "" @@ -769,7 +968,6 @@ msgstr "" "列挙型のサブクラスの作成はその列挙型にメンバーが一つも定義されていない場合の" "み行なえます。従って以下は許されません::" -#: ../../howto/enum.rst:457 msgid "" ">>> class MoreColor(Color):\n" "... PINK = 17\n" @@ -778,12 +976,17 @@ msgid "" "...\n" "TypeError: cannot extend " msgstr "" +">>> class MoreColor(Color):\n" +"... PINK = 17\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: cannot extend " #: ../../howto/enum.rst:464 msgid "But this is allowed::" msgstr "以下のような場合は許されます::" -#: ../../howto/enum.rst:466 msgid "" ">>> class Foo(Enum):\n" "... def some_behavior(self):\n" @@ -794,18 +997,26 @@ msgid "" "... SAD = 2\n" "..." msgstr "" +">>> class Foo(Enum):\n" +"... def some_behavior(self):\n" +"... pass\n" +"...\n" +">>> class Bar(Foo):\n" +"... HAPPY = 1\n" +"... SAD = 2\n" +"..." -#: ../../howto/enum.rst:475 msgid "" "Allowing subclassing of enums that define members would lead to a violation " "of some important invariants of types and instances. On the other hand, it " "makes sense to allow sharing some common behavior between a group of " "enumerations. (See `OrderedEnum`_ for an example.)" msgstr "" -"メンバーが定義された列挙型のサブクラス化を許可すると、いくつかのデータ型およ" -"びインスタンスの重要な不変条件の違反を引き起こします。とはいえ、それが許可さ" -"れると、列挙型のグループ間での共通の挙動を共有するという利点もあります。 " -"(`OrderedEnum`_ の例を参照してください。)" +"メンバーを定義した列挙型のサブクラス化を許すと、型やインスタンスに関する重要" +"な不変条件が破られます。\n" +"一方、複数の列挙型で共通の動作を共有できるようにすることには意味がありま" +"す。\n" +"例は `OrderedEnum`_ を参照してください。" #: ../../howto/enum.rst:484 msgid "Dataclass support" @@ -819,7 +1030,6 @@ msgstr "" ":class:`~dataclasses.dataclass` を継承する場合、 :meth:`~Enum.__repr__` は継" "承するクラス名を省略します。 例えば::" -#: ../../howto/enum.rst:489 msgid "" ">>> from dataclasses import dataclass, field\n" ">>> @dataclass\n" @@ -835,6 +1045,19 @@ msgid "" ">>> Creature.DOG\n" "" msgstr "" +">>> from dataclasses import dataclass, field\n" +">>> @dataclass\n" +"... class CreatureDataMixin:\n" +"... size: str\n" +"... legs: int\n" +"... tail: bool = field(repr=False, default=True)\n" +"...\n" +">>> class Creature(CreatureDataMixin, Enum):\n" +"... BEETLE = 'small', 6\n" +"... DOG = 'medium', 4\n" +"...\n" +">>> Creature.DOG\n" +"" #: ../../howto/enum.rst:503 msgid "" @@ -852,15 +1075,17 @@ msgstr "" "dataclass のフィールドだけが値の領域に表示され、dataclassの名前は表示されなく" "なりました" -#: ../../howto/enum.rst:512 msgid "" "Adding :deco:`~dataclasses.dataclass` decorator to :class:`Enum` and its " "subclasses is not supported. It will not raise any errors, but it will " "produce very strange results at runtime, such as members being equal to each " "other::" msgstr "" +":class:`Enum` やそのサブクラスへの :deco:`~dataclasses.dataclass` デコレータ" +"の適用はサポートされていません。\n" +"エラーは発生しませんが、異なるメンバーが等しいと判定されるなど、実行時に非常" +"に奇妙な結果になります。 ::" -#: ../../howto/enum.rst:517 msgid "" ">>> @dataclass # don't do this: it does not make any sense\n" "... class Color(Enum):\n" @@ -872,6 +1097,16 @@ msgid "" ">>> Color.RED == Color.BLUE # problem is here: they should not be equal\n" "True" msgstr "" +">>> @dataclass # 意味のない操作なので、このようにしてはいけな" +"い\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... BLUE = 2\n" +"...\n" +">>> Color.RED is Color.BLUE\n" +"False\n" +">>> Color.RED == Color.BLUE # ここが問題: 等しくなるべきではない\n" +"True" #: ../../howto/enum.rst:529 msgid "Pickling" @@ -881,23 +1116,25 @@ msgstr "Pickle 化" msgid "Enumerations can be pickled and unpickled::" msgstr "列挙型は pickle 化と unpickle 化が行えます::" -#: ../../howto/enum.rst:533 msgid "" ">>> from test.test_enum import Fruit\n" ">>> from pickle import dumps, loads\n" ">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" "True" msgstr "" +">>> from test.test_enum import Fruit\n" +">>> from pickle import dumps, loads\n" +">>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))\n" +"True" -#: ../../howto/enum.rst:538 msgid "" "The usual restrictions for pickling apply: picklable enums must be defined " "in the top level of a module, since unpickling requires them to be " "importable from that module." msgstr "" -"通常の pickle 化の制限事項が適用されます: pickle 可能な列挙型はモジュールの" -"トップレベルで定義されていなくてはならず、unpickle 化はモジュールからインポー" -"ト可能でなければなりません。" +"通常の pickle 化の制約が適用されます。\n" +"unpickle 化の際にモジュールから列挙型をインポートできる必要があるため、" +"pickle 化する列挙型はモジュールのトップレベルで定義しなければなりません。" #: ../../howto/enum.rst:544 msgid "" @@ -907,19 +1144,24 @@ msgstr "" "pickle プロトコルバージョン 4 では他のクラスで入れ子になった列挙型の pickle " "化も容易です。" -#: ../../howto/enum.rst:547 msgid "" "It is possible to modify how enum members are pickled/unpickled by defining :" "meth:`~object.__reduce_ex__` in the enumeration class. The default method " "is by-value, but enums with complicated values may want to use by-name::" msgstr "" +"列挙型クラスに :meth:`~object.__reduce_ex__` を定義すると、メンバーの pickle " +"化・unpickle 化の方法を変更できます。\n" +"デフォルトでは値を使いますが、値が複雑な列挙型では名前を使う方法が適している" +"場合があります。 ::" -#: ../../howto/enum.rst:551 msgid "" ">>> import enum\n" ">>> class MyEnum(enum.Enum):\n" "... __reduce_ex__ = enum.pickle_by_enum_name" msgstr "" +">>> import enum\n" +">>> class MyEnum(enum.Enum):\n" +"... __reduce_ex__ = enum.pickle_by_enum_name" #: ../../howto/enum.rst:557 msgid "" @@ -939,7 +1181,6 @@ msgid "" msgstr "" ":class:`Enum` クラスは呼び出し可能で、以下の関数 API を提供しています::" -#: ../../howto/enum.rst:566 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" ">>> Animal\n" @@ -949,16 +1190,22 @@ msgid "" ">>> list(Animal)\n" "[, , , ]" msgstr "" - -#: ../../howto/enum.rst:574 -msgid "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG')\n" +">>> Animal\n" +"\n" +">>> Animal.ANT\n" +"\n" +">>> list(Animal)\n" +"[, , , ]" + +#: ../../howto/enum.rst:574 +msgid "" "The semantics of this API resemble :class:`~collections.namedtuple`. The " "first argument of the call to :class:`Enum` is the name of the enumeration." msgstr "" "この API の動作は :class:`~collections.namedtuple` と似ています。:class:" "`Enum` 呼び出しの第 1 引数は列挙型の名前です。" -#: ../../howto/enum.rst:577 msgid "" "The second argument is the *source* of enumeration member names. It can be " "a whitespace-separated string of names, a sequence of names, a sequence of 2-" @@ -969,8 +1216,15 @@ msgid "" "class derived from :class:`Enum` is returned. In other words, the above " "assignment to :class:`!Animal` is equivalent to::" msgstr "" +"第 2 引数は列挙型メンバーの名前の *もと* になるものです。\n" +"空白区切りの名前の文字列、名前のシーケンス、キーと値のペアを表す 2 要素タプル" +"のシーケンス、名前を値に対応付ける辞書などのマッピングを指定できます。\n" +"後の 2 つでは、列挙型に任意の値を割り当てられます。\n" +"それ以外では 1 から始まる整数が順に自動で割り当てられます (開始値は " +"``start`` 引数で変更できます)。\n" +":class:`Enum` を継承する新しいクラスが返されます。\n" +"つまり、上記の :class:`!Animal` への代入は次と同じです。 ::" -#: ../../howto/enum.rst:586 msgid "" ">>> class Animal(Enum):\n" "... ANT = 1\n" @@ -979,18 +1233,22 @@ msgid "" "... DOG = 4\n" "..." msgstr "" +">>> class Animal(Enum):\n" +"... ANT = 1\n" +"... BEE = 2\n" +"... CAT = 3\n" +"... DOG = 4\n" +"..." -#: ../../howto/enum.rst:593 msgid "" "The reason for defaulting to ``1`` as the starting number and not ``0`` is " "that ``0`` is ``False`` in a boolean sense, but by default enum members all " "evaluate to ``True``." msgstr "" -"``0`` ではなく``1`` をデフォルトの開始番号とする理由は、``0`` が真偽値として" +"``0`` ではなく ``1`` をデフォルトの開始番号とする理由は、``0`` が真偽値として" "は ``False`` であり、デフォルトの列挙メンバーはすべて ``True`` 評価されるよう" "にするためである。" -#: ../../howto/enum.rst:597 msgid "" "Pickling enums created with the functional API can be tricky as frame stack " "implementation details are used to try and figure out which module the " @@ -998,44 +1256,45 @@ msgid "" "function in a separate module, and also may not work on IronPython or " "Jython). The solution is to specify the module name explicitly as follows::" msgstr "" -"機能 API による Enum の pickle 化は、その列挙型がどのモジュールで作成されたか" -"を見つけ出すためにフレームスタックの実装の詳細が使われるので、トリッキーにな" -"ることがあります (例えば別のモジュールのユーティリティ関数を使うと失敗します" -"し、IronPython や Jython ではうまくいきません)。解決策は、以下のようにモ" -"ジュール名を明示的に指定することです::" +"関数 API で作った列挙型の pickle 化は、注意が必要な場合があります。\n" +"列挙型が作られたモジュールを特定するために、フレームスタックの実装の詳細を使" +"うためです。\n" +"例えば、別モジュールのユーティリティ関数で作ると失敗し、IronPython や Jython " +"でも動かない可能性があります。\n" +"解決策は、次のようにモジュール名を明示的に指定することです。 ::" -#: ../../howto/enum.rst:603 msgid ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" -msgstr "" +msgstr ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)" -#: ../../howto/enum.rst:607 msgid "" "If ``module`` is not supplied, and Enum cannot determine what it is, the new " "Enum members will not be unpicklable; to keep errors closer to the source, " "pickling will be disabled." msgstr "" -"``module`` が与えられない場合、Enum はそれがなにか決定できないため、新しい " -"Enum メンバーは unpickle 化できなくなります; エラーをソースの近いところで発生" -"させるため、pickle 化は無効になります。" +"``module`` が指定されず、Enum 自身もモジュールを特定できない場合、新しい " +"Enum メンバーは unpickle 化できません。\n" +"問題の発生源に近いところでエラーを出すため、pickle 化も無効になります。" -#: ../../howto/enum.rst:611 msgid "" "The new pickle protocol 4 also, in some circumstances, relies on :attr:" "`~type.__qualname__` being set to the location where pickle will be able to " "find the class. For example, if the class was made available in class " "SomeData in the global scope::" msgstr "" +"新しい pickle プロトコル 4 も、場合によっては、pickle がクラスを見つけられる" +"場所を :attr:`~type.__qualname__` に設定しておく必要があります。\n" +"例えば、グローバルスコープのクラス SomeData の中から、このクラスにアクセスで" +"きる場合は次のようにします。 ::" -#: ../../howto/enum.rst:616 msgid "" ">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" msgstr "" +">>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')" #: ../../howto/enum.rst:618 msgid "The complete signature is::" msgstr "完全な構文は以下のようになります::" -#: ../../howto/enum.rst:620 msgid "" "Enum(\n" " value='NewEnumName',\n" @@ -1047,10 +1306,18 @@ msgid "" " start=1,\n" " )" msgstr "" +"Enum(\n" +" value='NewEnumName',\n" +" names=<...>,\n" +" *,\n" +" module='...',\n" +" qualname='...',\n" +" type=,\n" +" start=1,\n" +" )" -#: ../../howto/enum.rst:630 msgid "*value*: What the new enum class will record as its name." -msgstr "" +msgstr "*value*: 新しい列挙型クラスの名前として記録する値。" #: ../../howto/enum.rst:632 msgid "" @@ -1060,41 +1327,36 @@ msgstr "" "*names*: enumのメンバー。 空白またはカンマで区切られた文字列 (値は特に指定が" "ない限り1から始まります)::" -#: ../../howto/enum.rst:635 msgid "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" -msgstr "" +msgstr "'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'" #: ../../howto/enum.rst:637 msgid "or an iterator of names::" msgstr "または名前のイテレータで指定もできます::" -#: ../../howto/enum.rst:639 msgid "['RED', 'GREEN', 'BLUE']" -msgstr "" +msgstr "['RED', 'GREEN', 'BLUE']" #: ../../howto/enum.rst:641 msgid "or an iterator of (name, value) pairs::" msgstr "または (名前, 値) のペアのイテレータでも指定できます::" -#: ../../howto/enum.rst:643 msgid "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" -msgstr "" +msgstr "[('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]" #: ../../howto/enum.rst:645 msgid "or a mapping::" msgstr "またはマッピングでも指定できます::" -#: ../../howto/enum.rst:647 msgid "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" -msgstr "" +msgstr "{'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}" #: ../../howto/enum.rst:649 msgid "*module*: name of module where new enum class can be found." msgstr "*module*: 新しい enum クラスが属するモジュールの名前です。" -#: ../../howto/enum.rst:651 msgid "*qualname*: where in module new enum class can be found." -msgstr "*qualname*: 新しい enum クラスが属するモジュールの場所です。" +msgstr "*qualname*: モジュール内で新しい列挙型クラスを見つけられる場所。" #: ../../howto/enum.rst:653 msgid "*type*: type to mix in to new enum class." @@ -1128,7 +1390,6 @@ msgstr "" ":class:`IntEnum` のメンバーは整数と比較できます;\n" "さらに言うと、異なる整数列挙型どうしでも比較できます::" -#: ../../howto/enum.rst:672 msgid "" ">>> from enum import IntEnum\n" ">>> class Shape(IntEnum):\n" @@ -1146,6 +1407,21 @@ msgid "" ">>> Shape.CIRCLE == Request.POST\n" "True" msgstr "" +">>> from enum import IntEnum\n" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Request(IntEnum):\n" +"... POST = 1\n" +"... GET = 2\n" +"...\n" +">>> Shape == 1\n" +"False\n" +">>> Shape.CIRCLE == 1\n" +"True\n" +">>> Shape.CIRCLE == Request.POST\n" +"True" #: ../../howto/enum.rst:688 msgid "" @@ -1153,7 +1429,6 @@ msgid "" "enumerations::" msgstr "ただし、これらも標準の :class:`Enum` 列挙型とは比較できません::" -#: ../../howto/enum.rst:690 msgid "" ">>> class Shape(IntEnum):\n" "... CIRCLE = 1\n" @@ -1166,13 +1441,22 @@ msgid "" ">>> Shape.CIRCLE == Color.RED\n" "False" msgstr "" +">>> class Shape(IntEnum):\n" +"... CIRCLE = 1\n" +"... SQUARE = 2\n" +"...\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"...\n" +">>> Shape.CIRCLE == Color.RED\n" +"False" #: ../../howto/enum.rst:701 msgid "" ":class:`IntEnum` values behave like integers in other ways you'd expect::" msgstr ":class:`IntEnum` の値は他の用途では整数のように振る舞います::" -#: ../../howto/enum.rst:703 msgid "" ">>> int(Shape.CIRCLE)\n" "1\n" @@ -1181,6 +1465,12 @@ msgid "" ">>> [i for i in range(Shape.SQUARE)]\n" "[0, 1]" msgstr "" +">>> int(Shape.CIRCLE)\n" +"1\n" +">>> ['a', 'b', 'c'][Shape.CIRCLE]\n" +"'b'\n" +">>> [i for i in range(Shape.SQUARE)]\n" +"[0, 1]" #: ../../howto/enum.rst:712 msgid "StrEnum" @@ -1201,7 +1491,6 @@ msgstr "" msgid "IntFlag" msgstr "IntFlag" -#: ../../howto/enum.rst:725 msgid "" "The next variation of :class:`Enum` provided, :class:`IntFlag`, is also " "based on :class:`int`. The difference being :class:`IntFlag` members can be " @@ -1210,12 +1499,12 @@ msgid "" "`IntFlag` members are also integers and can be used wherever an :class:`int` " "is used." msgstr "" -"次の :class:`Enum` の派生型 :class:`IntFlag` も、:class:`int` を基底クラスと" -"しています。\n" -"違いは、 :class:`IntFlag` のメンバーをビット演算子 (&, \\|, ^, ~) を使っ" -"て組み合わせられ、その結果も :class:`IntFlag` メンバーになることです。 :" -"class:`IntEnum` と同様、:class:`IntFlag` のメンバーも整数であり、:class:" -"`int` が使用されるところであればどこでも使えます。" +"次の :class:`Enum` の派生型 :class:`IntFlag` も、:class:`int` を基底としてい" +"ます。\n" +"違いは、:class:`IntFlag` のメンバーをビット演算子 (&, \\|, ^, ~) で組み合わせ" +"ることができ、可能であれば結果も :class:`IntFlag` のメンバーになる点です。\n" +":class:`IntEnum` と同様に、:class:`IntFlag` のメンバーも整数なので、:class:" +"`int` を使える場所ならどこでも使えます。" #: ../../howto/enum.rst:733 msgid "" @@ -1238,7 +1527,6 @@ msgstr "" msgid "Sample :class:`IntFlag` class::" msgstr ":class:`IntFlag` クラスの例::" -#: ../../howto/enum.rst:745 msgid "" ">>> from enum import IntFlag\n" ">>> class Perm(IntFlag):\n" @@ -1254,12 +1542,24 @@ msgid "" ">>> Perm.R in RW\n" "True" msgstr "" +">>> from enum import IntFlag\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> Perm.R | Perm.W\n" +"\n" +">>> Perm.R + Perm.W\n" +"6\n" +">>> RW = Perm.R | Perm.W\n" +">>> Perm.R in RW\n" +"True" #: ../../howto/enum.rst:759 msgid "It is also possible to name the combinations::" msgstr "組み合わせにも名前を付けられます::" -#: ../../howto/enum.rst:761 msgid "" ">>> class Perm(IntFlag):\n" "... R = 4\n" @@ -1274,6 +1574,18 @@ msgid "" ">>> Perm(7)\n" "" msgstr "" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"... RWX = 7\n" +"...\n" +">>> Perm.RWX\n" +"\n" +">>> ~Perm.RWX\n" +"\n" +">>> Perm(7)\n" +"" #: ../../howto/enum.rst:776 msgid "" @@ -1293,13 +1605,16 @@ msgstr "" "ていない (値が0である) 場合、その真偽値としての評価は :data:`False` になるこ" "とです::" -#: ../../howto/enum.rst:784 msgid "" ">>> Perm.R & Perm.X\n" "\n" ">>> bool(Perm.R & Perm.X)\n" "False" msgstr "" +">>> Perm.R & Perm.X\n" +"\n" +">>> bool(Perm.R & Perm.X)\n" +"False" #: ../../howto/enum.rst:789 msgid "" @@ -1310,7 +1625,6 @@ msgstr "" "合わせることができます(ただし、 :class:`IntFlag` 型ではなくなる可能性があり" "ます)::" -#: ../../howto/enum.rst:792 msgid "" ">>> Perm.X | 4\n" "\n" @@ -1318,6 +1632,11 @@ msgid "" ">>> Perm.X + 8\n" "9" msgstr "" +">>> Perm.X | 4\n" +"\n" +"\n" +">>> Perm.X + 8\n" +"9" #: ../../howto/enum.rst:800 msgid "" @@ -1326,21 +1645,23 @@ msgid "" msgstr "" "否定の演算子 ``~`` は、常に正の値を持つ :class:`IntFlag` メンバー を返す::" -#: ../../howto/enum.rst:803 msgid "" ">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" "True" msgstr "" +">>> (~Perm.X).value == (Perm.R|Perm.W).value == 6\n" +"True" #: ../../howto/enum.rst:806 msgid ":class:`IntFlag` members can also be iterated over::" msgstr ":class:`IntFlag` メンバーは反復処理することもできます::" -#: ../../howto/enum.rst:808 msgid "" ">>> list(RW)\n" "[, ]" msgstr "" +">>> list(RW)\n" +"[, ]" #: ../../howto/enum.rst:815 msgid "Flag" @@ -1372,7 +1693,6 @@ msgstr "" "設定されていない状態になった場合、その真偽値としての評価は :data:`False` とな" "ります::" -#: ../../howto/enum.rst:829 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1385,6 +1705,16 @@ msgid "" ">>> bool(Color.RED & Color.GREEN)\n" "False" msgstr "" +">>> from enum import Flag, auto\n" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.RED & Color.GREEN\n" +"\n" +">>> bool(Color.RED & Color.GREEN)\n" +"False" #: ../../howto/enum.rst:840 msgid "" @@ -1394,7 +1724,6 @@ msgstr "" "個別のフラグは 2 のべき乗 (1, 2, 4, 8, ...) の値を持つべきですが、フラグの組" "み合わせはそうはなりません::" -#: ../../howto/enum.rst:843 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -1405,6 +1734,14 @@ msgid "" ">>> Color.WHITE\n" "" msgstr "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"... WHITE = RED | BLUE | GREEN\n" +"...\n" +">>> Color.WHITE\n" +"" #: ../../howto/enum.rst:852 msgid "" @@ -1413,7 +1750,6 @@ msgid "" msgstr "" "\"フラグが設定されていない\" 状態に名前を付けても、その真偽値は変わりません::" -#: ../../howto/enum.rst:855 msgid "" ">>> class Color(Flag):\n" "... BLACK = 0\n" @@ -1426,17 +1762,29 @@ msgid "" ">>> bool(Color.BLACK)\n" "False" msgstr "" +">>> class Color(Flag):\n" +"... BLACK = 0\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.BLACK\n" +"\n" +">>> bool(Color.BLACK)\n" +"False" #: ../../howto/enum.rst:866 msgid ":class:`Flag` members can also be iterated over::" msgstr ":class:`Flag` メンバーは反復処理することもできます::" -#: ../../howto/enum.rst:868 msgid "" ">>> purple = Color.RED | Color.BLUE\n" ">>> list(purple)\n" "[, ]" msgstr "" +">>> purple = Color.RED | Color.BLUE\n" +">>> list(purple)\n" +"[, ]" #: ../../howto/enum.rst:876 msgid "" @@ -1470,22 +1818,24 @@ msgstr "" ":class:`IntEnum` は :mod:`enum` モジュールの一部ですが、単独での実装もとても" "簡単に行なえます::" -#: ../../howto/enum.rst:891 msgid "" "class IntEnum(int, ReprEnum): # or Enum instead of ReprEnum\n" " pass" msgstr "" +"class IntEnum(int, ReprEnum): # ReprEnum の代わりに Enum でもよい\n" +" pass" -#: ../../howto/enum.rst:894 msgid "" "This demonstrates how similar derived enumerations can be defined; for " "example a :class:`!FloatEnum` that mixes in :class:`float` instead of :class:" "`int`." msgstr "" +"このようにして、同様の派生列挙型を定義できます。\n" +"例えば、:class:`int` の代わりに :class:`float` をミックスインする :class:`!" +"FloatEnum` も作れます。" -#: ../../howto/enum.rst:897 msgid "Some rules:" -msgstr "いくつかのルール:" +msgstr "Some rules:" #: ../../howto/enum.rst:899 msgid "" @@ -1519,18 +1869,21 @@ msgstr "" "データ型でなければならなくなります。この制限は、メソッドの追加するだけの、他" "のデータ型を指定しない複合には適用されません。" -#: ../../howto/enum.rst:909 msgid "" "When another data type is mixed in, the :attr:`~Enum.value` attribute is " "*not the same* as the enum member itself, although it is equivalent and will " "compare equal." msgstr "" +"別のデータ型をミックスインした場合、:attr:`~Enum.value` 属性は列挙型メンバー" +"自身とは *同一ではありません*。\n" +"ただし、同等の値であり、等価比較では等しいと判定されます。" -#: ../../howto/enum.rst:912 msgid "" "A ``data type`` is a mixin that defines :meth:`~object.__new__`, or a :class:" "`~dataclasses.dataclass`" msgstr "" +"ここでいう ``データ型`` は、:meth:`~object.__new__` を定義するミックスイン、" +"または :class:`~dataclasses.dataclass` です。" #: ../../howto/enum.rst:914 msgid "" @@ -1540,31 +1893,36 @@ msgid "" "type." msgstr "" -#: ../../howto/enum.rst:917 msgid "" ":ref:`Formatted string literals `, :meth:`str.format`, and :func:" "`format` will use the enum's :meth:`~object.__str__` method." msgstr "" +":ref:`フォーマット済み文字列リテラル `、:meth:`str.format`、:func:" +"`format` は、列挙型の :meth:`~object.__str__` メソッドを使います。" -#: ../../howto/enum.rst:922 msgid "" "Because :class:`IntEnum`, :class:`IntFlag`, and :class:`StrEnum` are " "designed to be drop-in replacements for existing constants, their :meth:" "`~object.__str__` method has been reset to their data types' :meth:`~object." "__str__` method." msgstr "" +":class:`IntEnum`、:class:`IntFlag`、:class:`StrEnum` は既存の定数をそのまま置" +"き換えられるように設計されているため、:meth:`~object.__str__` メソッドは、そ" +"れぞれのデータ型の :meth:`~object.__str__` に設定し直されています。" -#: ../../howto/enum.rst:930 msgid "When to use :meth:`~object.__new__` vs. :meth:`~object.__init__`" -msgstr "" +msgstr ":meth:`~object.__new__` と :meth:`~object.__init__` の使い分け" -#: ../../howto/enum.rst:932 msgid "" ":meth:`~object.__new__` must be used whenever you want to customize the " "actual value of the :class:`Enum` member. Any other modifications may go in " "either :meth:`~object.__new__` or :meth:`~object.__init__`, with :meth:" "`~object.__init__` being preferred." msgstr "" +":class:`Enum` メンバーの実際の値をカスタマイズする場合は、:meth:`~object." +"__new__` を使わなければなりません。\n" +"それ以外の変更は :meth:`~object.__new__` と :meth:`~object.__init__` のどちら" +"でも行えますが、:meth:`~object.__init__` を使うほうが望ましいです。" #: ../../howto/enum.rst:936 msgid "" @@ -1574,7 +1932,6 @@ msgstr "" "例えば、複数の値をコンストラクタに渡すが、その中の1つだけを値として使いたい場" "合は次のようにします:" -#: ../../howto/enum.rst:939 msgid "" ">>> class Coordinate(bytes, Enum):\n" "... \"\"\"\n" @@ -1598,26 +1955,49 @@ msgid "" ">>> print(Coordinate(3))\n" "Coordinate.VY" msgstr "" +">>> class Coordinate(bytes, Enum):\n" +"... \"\"\"\n" +"... 整数のコードで検索できる、バイナリコード付きの座標。\n" +"... \"\"\"\n" +"... def __new__(cls, value, label, unit):\n" +"... obj = bytes.__new__(cls, [value])\n" +"... obj._value_ = value\n" +"... obj.label = label\n" +"... obj.unit = unit\n" +"... return obj\n" +"... PX = (0, 'P.X', 'km')\n" +"... PY = (1, 'P.Y', 'km')\n" +"... VX = (2, 'V.X', 'km/s')\n" +"... VY = (3, 'V.Y', 'km/s')\n" +"...\n" +"\n" +">>> print(Coordinate['PY'])\n" +"Coordinate.PY\n" +"\n" +">>> print(Coordinate(3))\n" +"Coordinate.VY" -#: ../../howto/enum.rst:963 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly." msgstr "" +"``super().__new__()`` は *呼び出さないでください*。\n" +"検索専用の ``__new__`` が見つかるためです。\n" +"代わりに、データ型を直接使ってください。" #: ../../howto/enum.rst:968 msgid "Finer Points" msgstr "細かい点" -#: ../../howto/enum.rst:971 msgid "Supported ``__dunder__`` and ``_sunder_`` names" -msgstr "" +msgstr "サポートされる ``__dunder__`` 名と ``_sunder_`` 名" -#: ../../howto/enum.rst:973 msgid "" "The supported ``__dunder__`` and ``_sunder_`` names can be found in the :ref:" "`Enum API documentation `." msgstr "" +"サポートされる ``__dunder__`` 名と ``_sunder_`` 名は、:ref:`Enum の API ド" +"キュメント ` に記載されています。" #: ../../howto/enum.rst:977 msgid "_Private__names" @@ -1635,7 +2015,6 @@ msgstr "" msgid "``Enum`` member type" msgstr "``Enum`` メンバー型" -#: ../../howto/enum.rst:988 msgid "" "Enum members are instances of their enum class, and are normally accessed as " "``EnumClass.member``. In certain situations, such as writing custom enum " @@ -1644,26 +2023,25 @@ msgid "" "names and attributes/methods from mixed-in classes, upper-case names are " "strongly recommended." msgstr "" -"列挙型メンバーはその列挙型クラスのインスタンスであり、通常は ``EnumClass." -"member`` としてアクセスされます。 振る舞い メンバー しかし、メンバー の名前" -"と、属性/methodsが混在しているクラスとの名前の衝突を避けるために、大文字の名" -"前を使うことを強く推奨します。" +"列挙型のメンバーは、その列挙型クラスのインスタンスであり、通常は ``EnumClass." +"member`` としてアクセスします。\n" +"列挙型の独自の動作を書く場合などには、あるメンバーから別のメンバーへ直接アク" +"セスできると便利であり、この使い方もサポートされています。\n" +"ただし、メンバー名とミックスインしたクラスの属性やメソッド名との衝突を避ける" +"ため、メンバー名には大文字を使うことを強く推奨します。" -#: ../../howto/enum.rst:999 msgid "Creating members that are mixed with other data types" -msgstr "" +msgstr "ほかのデータ型と組み合わせたメンバーを作る" -#: ../../howto/enum.rst:1001 msgid "" "When subclassing other data types, such as :class:`int` or :class:`str`, " "with an :class:`Enum`, all values after the ``=`` are passed to that data " "type's constructor. For example::" msgstr "" -" :class:`int` や:class:`str` などの他のデータ型と :class:`Enum` のサブクラス" +" :class:`int` や :class:`str` などの他のデータ型と :class:`Enum` のサブクラス" "では、 ``=`` 以降の値はすべて、そのデータ型のコンストラクタに渡される。 例え" "ば::" -#: ../../howto/enum.rst:1005 msgid "" ">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" "... example = '11', 16 # so x='11' and base=16\n" @@ -1671,6 +2049,11 @@ msgid "" ">>> MyEnum.example.value # and hex(11) is...\n" "17" msgstr "" +">>> class MyEnum(IntEnum): # help(int) -> int(x, base=10) -> integer\n" +"... example = '11', 16 # つまり x='11'、base=16\n" +"...\n" +">>> MyEnum.example.value # 16 進数の 11 は...\n" +"17" #: ../../howto/enum.rst:1013 msgid "Boolean value of ``Enum`` classes and members" @@ -1690,11 +2073,12 @@ msgstr "" "メンバーの値に依存する独自の enum の真偽値評価を行うには、クラスに次のコード" "を追加してください::" -#: ../../howto/enum.rst:1021 msgid "" "def __bool__(self):\n" " return bool(self.value)" msgstr "" +"def __bool__(self):\n" +" return bool(self.value)" #: ../../howto/enum.rst:1024 msgid "Plain :class:`Enum` classes always evaluate as :data:`True`." @@ -1711,10 +2095,9 @@ msgid "" "the class::" msgstr "" "enum サブクラスに追加のメソッドを与えた場合、後述の `Planet`_ クラスのよう" -"に、そのメソッドはメンバーの :func:`dir` に表示されますが、クラスの :func:" -"`dir` には表示されません::" +"に、そのメソッドはメンバーの :func:`dir` に表示されますが、クラスの " +"``dir()`` には表示されません::" -#: ../../howto/enum.rst:1034 msgid "" ">>> dir(Planet)\n" "['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " @@ -1723,18 +2106,24 @@ msgid "" "['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " "'surface_gravity', 'value']" msgstr "" +">>> dir(Planet)\n" +"['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', " +"'VENUS', '__class__', '__doc__', '__members__', '__module__']\n" +">>> dir(Planet.EARTH)\n" +"['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', " +"'surface_gravity', 'value']" #: ../../howto/enum.rst:1041 msgid "Combining members of ``Flag``" msgstr "``Flag`` のメンバーの組み合わせ" -#: ../../howto/enum.rst:1043 msgid "" "Iterating over a combination of :class:`Flag` members will only return the " "members that are comprised of a single bit::" msgstr "" +":class:`Flag` メンバーの組み合わせをイテレートすると、単一ビットで構成される" +"メンバーだけが返されます。 ::" -#: ../../howto/enum.rst:1046 msgid "" ">>> class Color(Flag):\n" "... RED = auto()\n" @@ -1749,16 +2138,26 @@ msgid "" ">>> Color(7) # not named combination\n" "" msgstr "" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"... MAGENTA = RED | BLUE\n" +"... YELLOW = RED | GREEN\n" +"... CYAN = GREEN | BLUE\n" +"...\n" +">>> Color(3) # 名前付きの組み合わせ\n" +"\n" +">>> Color(7) # 名前のない組み合わせ\n" +"" -#: ../../howto/enum.rst:1061 msgid "``Flag`` and ``IntFlag`` minutia" -msgstr "" +msgstr "``Flag`` と ``IntFlag`` の細部" #: ../../howto/enum.rst:1063 msgid "Using the following snippet for our examples::" msgstr "例として以下のスニペットを使用します::" -#: ../../howto/enum.rst:1065 msgid "" ">>> class Color(IntFlag):\n" "... BLACK = 0\n" @@ -1769,10 +2168,17 @@ msgid "" "... WHITE = RED | GREEN | BLUE\n" "..." msgstr "" +">>> class Color(IntFlag):\n" +"... BLACK = 0\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 4\n" +"... PURPLE = RED | BLUE\n" +"... WHITE = RED | GREEN | BLUE\n" +"..." -#: ../../howto/enum.rst:1074 msgid "the following are true:" -msgstr "" +msgstr "次のことが成り立ちます。" #: ../../howto/enum.rst:1076 msgid "single-bit flags are canonical" @@ -1786,11 +2192,12 @@ msgstr "複数ビットや0ビットのフラグはエイリアスです" msgid "only canonical flags are returned during iteration::" msgstr "反復処理では正規形のフラグのみ返却されます::" -#: ../../howto/enum.rst:1080 msgid "" ">>> list(Color.WHITE)\n" "[, , ]" msgstr "" +">>> list(Color.WHITE)\n" +"[, , ]" #: ../../howto/enum.rst:1083 msgid "" @@ -1798,7 +2205,6 @@ msgid "" "corresponding positive integer value::" msgstr "" -#: ../../howto/enum.rst:1086 msgid "" ">>> Color.BLUE\n" "\n" @@ -1806,12 +2212,16 @@ msgid "" ">>> ~Color.BLUE\n" "" msgstr "" +">>> Color.BLUE\n" +"\n" +"\n" +">>> ~Color.BLUE\n" +"" #: ../../howto/enum.rst:1092 msgid "names of pseudo-flags are constructed from their members' names::" msgstr "名前のないフラグについては、そのメンバーの名前から名前が生成されます::" -#: ../../howto/enum.rst:1094 msgid "" ">>> (Color.RED | Color.GREEN).name\n" "'RED|GREEN'\n" @@ -1824,12 +2234,21 @@ msgid "" ">>> (Perm.R & Perm.W).name is None # effectively Perm(0)\n" "True" msgstr "" +">>> (Color.RED | Color.GREEN).name\n" +"'RED|GREEN'\n" +"\n" +">>> class Perm(IntFlag):\n" +"... R = 4\n" +"... W = 2\n" +"... X = 1\n" +"...\n" +">>> (Perm.R & Perm.W).name is None # 実質的には Perm(0)\n" +"True" -#: ../../howto/enum.rst:1105 msgid "multi-bit flags, aka aliases, can be returned from operations::" msgstr "" +"演算の結果として、複数ビットのフラグ、つまり別名が返されることもあります。 ::" -#: ../../howto/enum.rst:1107 msgid "" ">>> Color.RED | Color.BLUE\n" "\n" @@ -1840,6 +2259,14 @@ msgid "" ">>> Color(0)\n" "" msgstr "" +">>> Color.RED | Color.BLUE\n" +"\n" +"\n" +">>> Color(7) # または Color(-1)\n" +"\n" +"\n" +">>> Color(0)\n" +"" #: ../../howto/enum.rst:1116 msgid "" @@ -1849,11 +2276,12 @@ msgstr "" "メンバーシップ/包含 のチェックでは、値が0のフラグは常に含まれるものとして扱わ" "れます::" -#: ../../howto/enum.rst:1119 msgid "" ">>> Color.BLACK in Color.WHITE\n" "True" msgstr "" +">>> Color.BLACK in Color.WHITE\n" +"True" #: ../../howto/enum.rst:1122 msgid "" @@ -1863,7 +2291,6 @@ msgstr "" "それ以外では、一方のフラグの全ビットが他方のフラグに含まれる場合のみ、Trueが" "返されます::" -#: ../../howto/enum.rst:1125 msgid "" ">>> Color.PURPLE in Color.WHITE\n" "True\n" @@ -1871,12 +2298,19 @@ msgid "" ">>> Color.GREEN in Color.PURPLE\n" "False" msgstr "" +">>> Color.PURPLE in Color.WHITE\n" +"True\n" +"\n" +">>> Color.GREEN in Color.PURPLE\n" +"False" -#: ../../howto/enum.rst:1131 msgid "" "There is a new boundary mechanism that controls how out-of-range / invalid " "bits are handled: ``STRICT``, ``CONFORM``, ``EJECT``, and ``KEEP``:" msgstr "" +"範囲外のビットや無効なビットをどう扱うかを制御する、新しい境界の仕組みがあり" +"ます。\n" +"``STRICT``、``CONFORM``、``EJECT``、``KEEP`` の 4 つです。" #: ../../howto/enum.rst:1134 msgid "STRICT --> raises an exception when presented with invalid values" @@ -1891,21 +2325,17 @@ msgid "EJECT --> lose Flag status and become a normal int with the given value" msgstr "" "EJECT --> フラグのステータスを失い、指定された値を持つ通常の int となります。" -#: ../../howto/enum.rst:1137 msgid "KEEP --> keep the extra bits" -msgstr "" +msgstr "KEEP --> 余分なビットを保持する" -#: ../../howto/enum.rst:1139 msgid "keeps Flag status and extra bits" -msgstr "" +msgstr "Flag としての型と余分なビットを保持します。" -#: ../../howto/enum.rst:1140 msgid "extra bits do not show up in iteration" -msgstr "" +msgstr "余分なビットはイテレーションには現れません。" -#: ../../howto/enum.rst:1141 msgid "extra bits do show up in repr() and str()" -msgstr "" +msgstr "余分なビットは repr() と str() の結果には現れます。" #: ../../howto/enum.rst:1143 msgid "" @@ -1930,7 +2360,6 @@ msgstr "" msgid "Enum Classes" msgstr "Enum クラス" -#: ../../howto/enum.rst:1160 msgid "" "The :class:`EnumType` metaclass is responsible for providing the :meth:" "`~object.__contains__`, :meth:`~object.__dir__`, :meth:`~object.__iter__` " @@ -1941,12 +2370,18 @@ msgid "" "__new__`, :meth:`~object.__getnewargs__`, :meth:`~object.__str__` and :meth:" "`~object.__repr__`)." msgstr "" +"メタクラス :class:`EnumType` は、:meth:`~object.__contains__`、:meth:" +"`~object.__dir__`、:meth:`~object.__iter__` などのメソッドを提供します。\n" +"これにより、通常のクラスでは失敗する ``list(Color)`` や ``some_enum_var in " +"Color`` のような操作を、:class:`Enum` クラスで行えるようになります。\n" +":class:`EnumType` はまた、作成される :class:`Enum` クラスの :meth:`~object." +"__new__`、:meth:`~object.__getnewargs__`、:meth:`~object.__str__`、:meth:" +"`~object.__repr__` などの各メソッドが適切なものになるようにします。" #: ../../howto/enum.rst:1169 msgid "Flag Classes" msgstr "Flag クラス" -#: ../../howto/enum.rst:1171 msgid "" "Flags have an expanded view of aliasing: to be canonical, the value of a " "flag needs to be a power-of-two value, and not a duplicate name. So, in " @@ -1954,12 +2389,17 @@ msgid "" "a. ``0``) or with more than one power-of-two value (e.g. ``3``) is " "considered an alias." msgstr "" +"フラグでは、別名の意味が拡張されています。\n" +"正規のフラグであるには、値が 2 の累乗であり、ほかのメンバーの別名でないことが" +"必要です。\n" +"そのため、:class:`Enum` で別名となるものに加えて、値を持たないフラグ (つまり " +"``0``) や、複数の 2 の累乗の値を組み合わせたフラグ (例えば ``3``) も別名とみ" +"なされます。" #: ../../howto/enum.rst:1177 msgid "Enum Members (aka instances)" msgstr "Enum メンバー (インスタンス)" -#: ../../howto/enum.rst:1179 msgid "" "The most interesting thing about enum members is that they are singletons. :" "class:`EnumType` creates them all while it is creating the enum class " @@ -1967,6 +2407,11 @@ msgid "" "that no new ones are ever instantiated by returning only the existing member " "instances." msgstr "" +"列挙型メンバーの最も興味深い点は、シングルトンであることです。\n" +":class:`EnumType` は列挙型クラスそのものを作る際に、すべてのメンバーを作りま" +"す。\n" +"その後、既存のメンバーインスタンスだけを返す独自の :meth:`~object.__new__` を" +"設定し、新しいインスタンスが作られないようにします。" #: ../../howto/enum.rst:1185 msgid "Flag Members" @@ -1980,11 +2425,12 @@ msgstr "" "フラグのメンバーは、:class:`Flag` クラスと同様に反復処理することができ、正規" "のメンバーのみが返されます。 例えば::" -#: ../../howto/enum.rst:1190 msgid "" ">>> list(Color)\n" "[, , ]" msgstr "" +">>> list(Color)\n" +"[, , ]" #: ../../howto/enum.rst:1193 msgid "(Note that ``BLACK``, ``PURPLE``, and ``WHITE`` do not show up.)" @@ -1997,11 +2443,12 @@ msgid "" msgstr "" "フラグのメンバーを反転させると、負の値ではなく、対応する正の値が返されます::" -#: ../../howto/enum.rst:1198 msgid "" ">>> ~Color.RED\n" "" msgstr "" +">>> ~Color.RED\n" +"" #: ../../howto/enum.rst:1201 msgid "" @@ -2011,11 +2458,12 @@ msgstr "" "フラグのメンバーは、それが含む2のべき乗の値の数に対応するlengthを持ちます。 " "例えば::" -#: ../../howto/enum.rst:1204 msgid "" ">>> len(Color.PURPLE)\n" "2" msgstr "" +">>> len(Color.PURPLE)\n" +"2" #: ../../howto/enum.rst:1211 msgid "Enum Cookbook" @@ -2057,11 +2505,12 @@ msgstr "値として :class:`object` インスタンスを使用する" msgid "use a descriptive string as the value" msgstr "値として解説文字列を使用する" -#: ../../howto/enum.rst:1229 msgid "" "use a tuple as the value and a custom :meth:`~object.__new__` to replace the " "tuple with an :class:`int` value" msgstr "" +"値にタプルを使い、独自の :meth:`~object.__new__` でタプルを :class:`int` の値" +"に置き換える" #: ../../howto/enum.rst:1232 msgid "" @@ -2081,7 +2530,6 @@ msgstr ":class:`auto` を使う" msgid "Using :class:`auto` would look like::" msgstr ":class:`auto` を使うと次のようになります::" -#: ../../howto/enum.rst:1242 msgid "" ">>> class Color(Enum):\n" "... RED = auto()\n" @@ -2091,6 +2539,13 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = auto()\n" +"... BLUE = auto()\n" +"... GREEN = auto()\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../../howto/enum.rst:1252 msgid "Using :class:`object`" @@ -2100,7 +2555,6 @@ msgstr ":class:`object` を使う" msgid "Using :class:`object` would look like::" msgstr ":class:`object` を使うと次のようになります::" -#: ../../howto/enum.rst:1256 msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" @@ -2110,14 +2564,21 @@ msgid "" ">>> Color.GREEN\n" ">" msgstr "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"...\n" +">>> Color.GREEN\n" +">" -#: ../../howto/enum.rst:1264 msgid "" "This is also a good example of why you might want to write your own :meth:" "`~object.__repr__`::" msgstr "" +"この例は、独自の :meth:`~object.__repr__` を書きたくなる理由もよく示していま" +"す。 ::" -#: ../../howto/enum.rst:1267 msgid "" ">>> class Color(Enum):\n" "... RED = object()\n" @@ -2129,6 +2590,15 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = object()\n" +"... GREEN = object()\n" +"... BLUE = object()\n" +"... def __repr__(self):\n" +"... return \"<%s.%s>\" % (self.__class__.__name__, self._name_)\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../../howto/enum.rst:1280 msgid "Using a descriptive string" @@ -2138,7 +2608,6 @@ msgstr "解説文字列を使う" msgid "Using a string as the value would look like::" msgstr "値として文字列を使うと次のようになります::" -#: ../../howto/enum.rst:1284 msgid "" ">>> class Color(Enum):\n" "... RED = 'stop'\n" @@ -2148,16 +2617,20 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class Color(Enum):\n" +"... RED = 'stop'\n" +"... GREEN = 'go'\n" +"... BLUE = 'too fast!'\n" +"...\n" +">>> Color.GREEN\n" +"" -#: ../../howto/enum.rst:1294 msgid "Using a custom :meth:`~object.__new__`" -msgstr "" +msgstr "独自の :meth:`~object.__new__` を使う" -#: ../../howto/enum.rst:1296 msgid "Using an auto-numbering :meth:`~object.__new__` would look like::" -msgstr "" +msgstr "自動採番する :meth:`~object.__new__` を使うと、次のようになります。 ::" -#: ../../howto/enum.rst:1298 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls):\n" @@ -2174,6 +2647,20 @@ msgid "" ">>> Color.GREEN\n" "" msgstr "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls):\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"...\n" +">>> class Color(AutoNumber):\n" +"... RED = ()\n" +"... GREEN = ()\n" +"... BLUE = ()\n" +"...\n" +">>> Color.GREEN\n" +"" #: ../../howto/enum.rst:1313 msgid "" @@ -2183,7 +2670,6 @@ msgstr "" "``AutoNumber`` をより広い用途で使うには、シグニチャに ``*args`` を追加しま" "す::" -#: ../../howto/enum.rst:1315 msgid "" ">>> class AutoNumber(Enum):\n" "... def __new__(cls, *args): # this is the only change from above\n" @@ -2193,6 +2679,13 @@ msgid "" "... return obj\n" "..." msgstr "" +">>> class AutoNumber(Enum):\n" +"... def __new__(cls, *args): # 上の例からの変更はここだけ\n" +"... value = len(cls.__members__) + 1\n" +"... obj = object.__new__(cls)\n" +"... obj._value_ = value\n" +"... return obj\n" +"..." #: ../../howto/enum.rst:1323 msgid "" @@ -2202,7 +2695,6 @@ msgstr "" "``AutoNumber`` を継承すると、追加の引数を取り扱える独自の ``__init__`` が書け" "ます。" -#: ../../howto/enum.rst:1326 msgid "" ">>> class Swatch(AutoNumber):\n" "... def __init__(self, pantone='unknown'):\n" @@ -2218,23 +2710,40 @@ msgid "" ">>> Swatch.BLEACHED_CORAL.pantone\n" "'unknown'" msgstr "" +">>> class Swatch(AutoNumber):\n" +"... def __init__(self, pantone='unknown'):\n" +"... self.pantone = pantone\n" +"... AUBURN = '3497'\n" +"... SEA_GREEN = '1246'\n" +"... BLEACHED_CORAL = () # 新色なので、まだ Pantone コードはない!\n" +"...\n" +">>> Swatch.SEA_GREEN\n" +"\n" +">>> Swatch.SEA_GREEN.pantone\n" +"'1246'\n" +">>> Swatch.BLEACHED_CORAL.pantone\n" +"'unknown'" -#: ../../howto/enum.rst:1342 msgid "" "The :meth:`~object.__new__` method, if defined, is used during creation of " "the Enum members; it is then replaced by Enum's :meth:`~object.__new__` " "which is used after class creation for lookup of existing members." msgstr "" +":meth:`~object.__new__` を定義した場合、そのメソッドは Enum メンバーの作成時" +"に使われます。\n" +"その後は Enum の :meth:`~object.__new__` に置き換えられ、クラス作成後の既存メ" +"ンバーの検索に使われます。" -#: ../../howto/enum.rst:1348 msgid "" "*Do not* call ``super().__new__()``, as the lookup-only ``__new__`` is the " "one that is found; instead, use the data type directly -- e.g.::" msgstr "" +"``super().__new__()`` は *呼び出さないでください*。\n" +"検索専用の ``__new__`` が見つかるためです。\n" +"代わりに、例えば次のようにデータ型を直接使ってください。 ::" -#: ../../howto/enum.rst:1351 msgid "obj = int.__new__(cls, value)" -msgstr "" +msgstr "obj = int.__new__(cls, value)" #: ../../howto/enum.rst:1355 msgid "OrderedEnum" @@ -2249,7 +2758,6 @@ msgstr "" ":class:`IntEnum` をベースとしないため、通常の :class:`Enum` の不変条件 (他の" "列挙型と比較できないなど) のままで、メンバーを順序付けできる列挙型です::" -#: ../../howto/enum.rst:1361 msgid "" ">>> class OrderedEnum(Enum):\n" "... def __ge__(self, other):\n" @@ -2279,6 +2787,33 @@ msgid "" ">>> Grade.C < Grade.A\n" "True" msgstr "" +">>> class OrderedEnum(Enum):\n" +"... def __ge__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value >= other.value\n" +"... return NotImplemented\n" +"... def __gt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value > other.value\n" +"... return NotImplemented\n" +"... def __le__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value <= other.value\n" +"... return NotImplemented\n" +"... def __lt__(self, other):\n" +"... if self.__class__ is other.__class__:\n" +"... return self.value < other.value\n" +"... return NotImplemented\n" +"...\n" +">>> class Grade(OrderedEnum):\n" +"... A = 5\n" +"... B = 4\n" +"... C = 3\n" +"... D = 2\n" +"... F = 1\n" +"...\n" +">>> Grade.C < Grade.A\n" +"True" #: ../../howto/enum.rst:1391 msgid "DuplicateFreeEnum" @@ -2292,7 +2827,6 @@ msgstr "" "値が重複するメンバーがある場合に、エイリアスを作成するのではなくエラーを発生" "させます::" -#: ../../howto/enum.rst:1396 msgid "" ">>> class DuplicateFreeEnum(Enum):\n" "... def __init__(self, *args):\n" @@ -2315,6 +2849,26 @@ msgid "" " ...\n" "ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" msgstr "" +">>> class DuplicateFreeEnum(Enum):\n" +"... def __init__(self, *args):\n" +"... cls = self.__class__\n" +"... if any(self.value == e.value for e in cls):\n" +"... a = self.name\n" +"... e = cls(self.value).name\n" +"... raise ValueError(\n" +"... \"aliases not allowed in DuplicateFreeEnum: %r --> " +"%r\"\n" +"... % (a, e))\n" +"...\n" +">>> class Color(DuplicateFreeEnum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... GRENE = 2\n" +"...\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'" #: ../../howto/enum.rst:1418 msgid "" @@ -2326,15 +2880,12 @@ msgstr "" "サブクラス化に役立つ例です。単に別名を無効にしたいだけなら、 :func:`unique` " "デコレーターを使用して行えます。" -#: ../../howto/enum.rst:1425 msgid "MultiValueEnum" -msgstr "" +msgstr "MultiValueEnum" -#: ../../howto/enum.rst:1427 msgid "Supports having more than one value per member::" -msgstr "" +msgstr "1 つのメンバーに複数の値を持たせられます。 ::" -#: ../../howto/enum.rst:1429 msgid "" ">>> class MultiValueEnum(Enum):\n" "... def __new__(cls, value, *values):\n" @@ -2353,18 +2904,34 @@ msgid "" ">>> DType(9)\n" "" msgstr "" +">>> class MultiValueEnum(Enum):\n" +"... def __new__(cls, value, *values):\n" +"... self = object.__new__(cls)\n" +"... self._value_ = value\n" +"... for v in values:\n" +"... self._add_value_alias_(v)\n" +"... return self\n" +"...\n" +">>> class DType(MultiValueEnum):\n" +"... float32 = 'f', 8\n" +"... double64 = 'd', 9\n" +"...\n" +">>> DType('f')\n" +"\n" +">>> DType(9)\n" +"" #: ../../howto/enum.rst:1448 msgid "Planet" msgstr "Planet" -#: ../../howto/enum.rst:1450 msgid "" "If :meth:`~object.__new__` or :meth:`~object.__init__` is defined, the value " "of the enum member will be passed to those methods::" msgstr "" +":meth:`~object.__new__` や :meth:`~object.__init__` を定義すると、列挙型メン" +"バーの値がこれらのメソッドに渡されます。 ::" -#: ../../howto/enum.rst:1453 msgid "" ">>> class Planet(Enum):\n" "... MERCURY = (3.303e+23, 2.4397e6)\n" @@ -2389,16 +2956,36 @@ msgid "" ">>> Planet.EARTH.surface_gravity\n" "9.802652743337129" msgstr "" +">>> class Planet(Enum):\n" +"... MERCURY = (3.303e+23, 2.4397e6)\n" +"... VENUS = (4.869e+24, 6.0518e6)\n" +"... EARTH = (5.976e+24, 6.37814e6)\n" +"... MARS = (6.421e+23, 3.3972e6)\n" +"... JUPITER = (1.9e+27, 7.1492e7)\n" +"... SATURN = (5.688e+26, 6.0268e7)\n" +"... URANUS = (8.686e+25, 2.5559e7)\n" +"... NEPTUNE = (1.024e+26, 2.4746e7)\n" +"... def __init__(self, mass, radius):\n" +"... self.mass = mass # 単位はキログラム\n" +"... self.radius = radius # 単位はメートル\n" +"... @property\n" +"... def surface_gravity(self):\n" +"... # 万有引力定数 (m3 kg-1 s-2)\n" +"... G = 6.67300E-11\n" +"... return G * self.mass / (self.radius * self.radius)\n" +"...\n" +">>> Planet.EARTH.value\n" +"(5.976e+24, 6378140.0)\n" +">>> Planet.EARTH.surface_gravity\n" +"9.802652743337129" #: ../../howto/enum.rst:1479 msgid "TimePeriod" msgstr "TimePeriod" -#: ../../howto/enum.rst:1481 msgid "An example to show the :attr:`~Enum._ignore_` attribute in use::" -msgstr "" +msgstr ":attr:`~Enum._ignore_` 属性の使用例です。 ::" -#: ../../howto/enum.rst:1483 msgid "" ">>> import datetime as dt\n" ">>> class Period(dt.timedelta, Enum):\n" @@ -2415,14 +3002,31 @@ msgid "" "[, ]" msgstr "" +">>> import datetime as dt\n" +">>> class Period(dt.timedelta, Enum):\n" +"... \"さまざまな長さの時間\"\n" +"... _ignore_ = 'Period i'\n" +"... Period = vars()\n" +"... for i in range(367):\n" +"... Period['day_%d' % i] = i\n" +"...\n" +">>> list(Period)[:2]\n" +"[, ]\n" +">>> list(Period)[-2:]\n" +"[, ]" #: ../../howto/enum.rst:1500 msgid "Subclassing EnumType" msgstr "EnumType のサブクラスを作る" -#: ../../howto/enum.rst:1502 msgid "" "While most enum needs can be met by customizing :class:`Enum` subclasses, " "either with class decorators or custom functions, :class:`EnumType` can be " "subclassed to provide a different Enum experience." msgstr "" +"列挙型に関する要件の多くは、クラスデコレータや独自の関数で :class:`Enum` のサ" +"ブクラスをカスタマイズすれば満たせます。\n" +"一方、:class:`EnumType` のサブクラスを作れば、Enum 自体の使い方を変えることも" +"できます。" diff --git a/howto/free-threading-extensions.po b/howto/free-threading-extensions.po index a24d89637..266744da5 100644 --- a/howto/free-threading-extensions.po +++ b/howto/free-threading-extensions.po @@ -16,74 +16,83 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/free-threading-extensions.rst:7 msgid "C API Extension Support for Free Threading" -msgstr "" +msgstr "C API 拡張のフリースレッド対応" -#: ../../howto/free-threading-extensions.rst:9 msgid "" "Starting with the 3.13 release, CPython has support for running with the :" "term:`global interpreter lock` (GIL) disabled in a configuration called :" "term:`free threading`. This document describes how to adapt C API " "extensions to support free threading." msgstr "" +"CPython 3.13 から、:term:`global interpreter lock` (GIL) を無効にして実行す" +"る :term:`free threading` という構成がサポートされています。\n" +"このドキュメントでは、C API を使う拡張をフリースレッドに対応させる方法を説明" +"します。" -#: ../../howto/free-threading-extensions.rst:16 msgid "Identifying the Free-Threaded Build in C" -msgstr "" +msgstr "C からフリースレッドビルドを識別する" -#: ../../howto/free-threading-extensions.rst:18 msgid "" "The CPython C API exposes the ``Py_GIL_DISABLED`` macro: in the free-" "threaded build it's defined to ``1``, and in the regular build it's not " "defined. You can use it to enable code that only runs under the free-" "threaded build::" msgstr "" +"CPython の C API は ``Py_GIL_DISABLED`` マクロを公開しています。\n" +"フリースレッドビルドでは ``1`` に定義され、通常のビルドでは定義されません。\n" +"これを使って、フリースレッドビルドでだけ実行するコードを有効にできます。 ::" -#: ../../howto/free-threading-extensions.rst:22 msgid "" "#ifdef Py_GIL_DISABLED\n" "/* code that only runs in the free-threaded build */\n" "#endif" msgstr "" +"#ifdef Py_GIL_DISABLED\n" +"/* フリースレッドビルドでだけ実行するコード */\n" +"#endif" -#: ../../howto/free-threading-extensions.rst:28 msgid "" "On Windows, this macro is not defined automatically, but must be specified " "to the compiler when building. The :func:`sysconfig.get_config_var` function " "can be used to determine whether the current running interpreter had the " "macro defined." msgstr "" +"Windows ではこのマクロは自動的には定義されないため、ビルド時にコンパイラへ指" +"定する必要があります。\n" +"実行中のインタープリタでこのマクロが定義されていたかは、:func:`sysconfig." +"get_config_var` 関数で確認できます。" -#: ../../howto/free-threading-extensions.rst:35 msgid "Module Initialization" -msgstr "" +msgstr "モジュールの初期化" -#: ../../howto/free-threading-extensions.rst:37 msgid "" "Extension modules need to explicitly indicate that they support running with " "the GIL disabled; otherwise importing the extension will raise a warning and " "enable the GIL at runtime." msgstr "" +"拡張モジュールは、GIL を無効にした実行に対応していることを明示する必要があり" +"ます。\n" +"そうしなければ、拡張のインポート時に警告が出され、実行時に GIL が有効になりま" +"す。" -#: ../../howto/free-threading-extensions.rst:41 msgid "" "There are two ways to indicate that an extension module supports running " "with the GIL disabled depending on whether the extension uses multi-phase or " "single-phase initialization." msgstr "" +"GIL を無効にした実行に対応していることを示す方法は、拡張が複数フェーズ初期化" +"と単一フェーズ初期化のどちらを使うかによって、2 通りあります。" -#: ../../howto/free-threading-extensions.rst:46 msgid "Multi-Phase Initialization" -msgstr "" +msgstr "複数フェーズ初期化" -#: ../../howto/free-threading-extensions.rst:48 msgid "" "Extensions that use :ref:`multi-phase initialization ` (functions like :c:func:`PyModuleDef_Init`, :c:func:" @@ -92,8 +101,13 @@ msgid "" "module definition. If your extension supports older versions of CPython, you " "should guard the slot with a :c:data:`PY_VERSION_HEX` check." msgstr "" +":ref:`複数フェーズ初期化 ` (:c:func:" +"`PyModuleDef_Init`、:c:func:`PyModExport_* ` エクス" +"ポートフック、:c:func:`PyModule_FromSlotsAndSpec` など) を使う拡張では、モ" +"ジュール定義に :c:data:`Py_mod_gil` スロットを追加してください。\n" +"古い CPython バージョンにも対応する場合は、:c:data:`PY_VERSION_HEX` を確認" +"し、対応するバージョンでだけこのスロットを追加してください。" -#: ../../howto/free-threading-extensions.rst:58 msgid "" "static struct PyModuleDef_Slot module_slots[] = {\n" " ...\n" @@ -103,12 +117,17 @@ msgid "" " {0, NULL}\n" "};" msgstr "" +"static struct PyModuleDef_Slot module_slots[] = {\n" +" ...\n" +"#if PY_VERSION_HEX >= 0x030D0000\n" +" {Py_mod_gil, Py_MOD_GIL_NOT_USED},\n" +"#endif\n" +" {0, NULL}\n" +"};" -#: ../../howto/free-threading-extensions.rst:68 msgid "Single-Phase Initialization" -msgstr "" +msgstr "単一フェーズ初期化" -#: ../../howto/free-threading-extensions.rst:70 msgid "" "Extensions that use legacy :ref:`single-phase initialization ` (that is, :c:func:`PyModule_Create`) should call :c:func:" @@ -117,8 +136,13 @@ msgid "" "you should guard the call with ``#ifdef Py_GIL_DISABLED`` to avoid " "compilation errors in the regular build." msgstr "" +"従来の :ref:`単一フェーズ初期化 ` (つまり :c:" +"func:`PyModule_Create`) を使う拡張では、:c:func:`PyUnstable_Module_SetGIL` を" +"呼び出して、GIL を無効にした実行に対応していることを示してください。\n" +"この関数はフリースレッドビルドでのみ定義されるため、通常のビルドでのコンパイ" +"ルエラーを避けるには、呼び出しを ``#ifdef Py_GIL_DISABLED`` で囲んでくださ" +"い。" -#: ../../howto/free-threading-extensions.rst:78 msgid "" "static struct PyModuleDef moduledef = {\n" " PyModuleDef_HEAD_INIT,\n" @@ -138,22 +162,38 @@ msgid "" " return m;\n" "}" msgstr "" +"static struct PyModuleDef moduledef = {\n" +" PyModuleDef_HEAD_INIT,\n" +" ...\n" +"};\n" +"\n" +"PyMODINIT_FUNC\n" +"PyInit_mymodule(void)\n" +"{\n" +" PyObject *m = PyModule_Create(&moduledef);\n" +" if (m == NULL) {\n" +" return NULL;\n" +" }\n" +"#ifdef Py_GIL_DISABLED\n" +" PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);\n" +"#endif\n" +" return m;\n" +"}" -#: ../../howto/free-threading-extensions.rst:98 msgid "General API Guidelines" -msgstr "" +msgstr "API 全般の指針" -#: ../../howto/free-threading-extensions.rst:100 msgid "Most of the C API is thread-safe, but there are some exceptions." -msgstr "" +msgstr "C API の大部分はスレッドセーフですが、例外もあります。" -#: ../../howto/free-threading-extensions.rst:102 msgid "" "**Struct Fields**: Accessing fields in Python C API objects or structs " "directly is not thread-safe if the field may be concurrently modified." msgstr "" +"**構造体のフィールド**: Python C API のオブジェクトや構造体のフィールドが並行" +"して変更される可能性がある場合、そのフィールドへの直接アクセスはスレッドセー" +"フではありません。" -#: ../../howto/free-threading-extensions.rst:104 msgid "" "**Macros**: Accessor macros like :c:macro:`PyList_GET_ITEM`, :c:macro:" "`PyList_SET_ITEM`, and macros like :c:macro:`PySequence_Fast_GET_SIZE` that " @@ -161,40 +201,50 @@ msgid "" "error checking or locking. These macros are not thread-safe if the container " "object may be modified concurrently." msgstr "" +"**マクロ**: :c:macro:`PyList_GET_ITEM`、:c:macro:`PyList_SET_ITEM` などのアク" +"セス用マクロや、:c:func:`PySequence_Fast` が返すオブジェクトを使う :c:macro:" +"`PySequence_Fast_GET_SIZE` などのマクロは、エラーチェックもロックも行いませ" +"ん。\n" +"コンテナオブジェクトが並行して変更される可能性がある場合、これらのマクロはス" +"レッドセーフではありません。" -#: ../../howto/free-threading-extensions.rst:110 msgid "" "**Borrowed References**: C API functions that return :term:`borrowed " "references ` may not be thread-safe if the containing " "object is modified concurrently. See the section on :ref:`borrowed " "references ` for more information." msgstr "" +"**借用参照**: :term:`借用参照 ` を返す C API 関数は、参照" +"先を保持するオブジェクトが並行して変更される場合、スレッドセーフでないことが" +"あります。\n" +"詳しくは :ref:`借用参照の節 ` を参照してください。" -#: ../../howto/free-threading-extensions.rst:117 msgid "Container Thread Safety" -msgstr "" +msgstr "コンテナのスレッド安全性" -#: ../../howto/free-threading-extensions.rst:119 msgid "" "Containers like :c:struct:`PyListObject`, :c:struct:`PyDictObject`, and :c:" "struct:`PySetObject` perform internal locking in the free-threaded build. " "For example, the :c:func:`PyList_Append` will lock the list before appending " "an item." msgstr "" +":c:struct:`PyListObject`、:c:struct:`PyDictObject`、:c:struct:`PySetObject` " +"などのコンテナは、フリースレッドビルドでは内部でロックを使います。\n" +"例えば、:c:func:`PyList_Append` は要素を追加する前にリストをロックします。" -#: ../../howto/free-threading-extensions.rst:127 msgid "``PyDict_Next``" -msgstr "" +msgstr "``PyDict_Next``" -#: ../../howto/free-threading-extensions.rst:129 msgid "" "A notable exception is :c:func:`PyDict_Next`, which does not lock the " "dictionary. You should use :c:macro:`Py_BEGIN_CRITICAL_SECTION` to protect " "the dictionary while iterating over it if the dictionary may be concurrently " "modified::" msgstr "" +"注意すべき例外は :c:func:`PyDict_Next` で、この関数は辞書をロックしません。\n" +"辞書が並行して変更される可能性がある場合は、:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` を使い、イテレート中の辞書を保護してください。 ::" -#: ../../howto/free-threading-extensions.rst:134 msgid "" "Py_BEGIN_CRITICAL_SECTION(dict);\n" "PyObject *key, *value;\n" @@ -204,113 +254,99 @@ msgid "" "}\n" "Py_END_CRITICAL_SECTION();" msgstr "" +"Py_BEGIN_CRITICAL_SECTION(dict);\n" +"PyObject *key, *value;\n" +"Py_ssize_t pos = 0;\n" +"while (PyDict_Next(dict, &pos, &key, &value)) {\n" +" ...\n" +"}\n" +"Py_END_CRITICAL_SECTION();" -#: ../../howto/free-threading-extensions.rst:144 msgid "Borrowed References" -msgstr "" +msgstr "借用参照" -#: ../../howto/free-threading-extensions.rst:148 msgid "" "Some C API functions return :term:`borrowed references `. These APIs are not thread-safe if the containing object is " "modified concurrently. For example, it's not safe to use :c:func:" "`PyList_GetItem` if the list may be modified concurrently." msgstr "" +"一部の C API 関数は :term:`借用参照 ` を返します。\n" +"参照先を保持するオブジェクトが並行して変更される場合、これらの API はスレッド" +"セーフではありません。\n" +"例えば、リストが並行して変更される可能性がある状況で :c:func:" +"`PyList_GetItem` を使うのは安全ではありません。" -#: ../../howto/free-threading-extensions.rst:153 msgid "" "The following table lists some borrowed reference APIs and their " "replacements that return :term:`strong references `." msgstr "" +"次の表は、借用参照を返す API の一部と、代わりに使える :term:`強参照 ` を返す API を示します。" -#: ../../howto/free-threading-extensions.rst:157 msgid "Borrowed reference API" -msgstr "" +msgstr "借用参照を返す API" -#: ../../howto/free-threading-extensions.rst:157 msgid "Strong reference API" -msgstr "" +msgstr "強参照を返す API" -#: ../../howto/free-threading-extensions.rst:159 msgid ":c:func:`PyList_GetItem`" -msgstr "" +msgstr ":c:func:`PyList_GetItem`" -#: ../../howto/free-threading-extensions.rst:159 -#: ../../howto/free-threading-extensions.rst:161 msgid ":c:func:`PyList_GetItemRef`" -msgstr "" +msgstr ":c:func:`PyList_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:161 msgid ":c:func:`PyList_GET_ITEM`" -msgstr "" +msgstr ":c:func:`PyList_GET_ITEM`" -#: ../../howto/free-threading-extensions.rst:163 msgid ":c:func:`PyDict_GetItem`" -msgstr "" +msgstr ":c:func:`PyDict_GetItem`" -#: ../../howto/free-threading-extensions.rst:163 -#: ../../howto/free-threading-extensions.rst:165 msgid ":c:func:`PyDict_GetItemRef`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemRef`" -#: ../../howto/free-threading-extensions.rst:165 msgid ":c:func:`PyDict_GetItemWithError`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemWithError`" -#: ../../howto/free-threading-extensions.rst:167 msgid ":c:func:`PyDict_GetItemString`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemString`" -#: ../../howto/free-threading-extensions.rst:167 msgid ":c:func:`PyDict_GetItemStringRef`" -msgstr "" +msgstr ":c:func:`PyDict_GetItemStringRef`" -#: ../../howto/free-threading-extensions.rst:169 msgid ":c:func:`PyDict_SetDefault`" -msgstr "" +msgstr ":c:func:`PyDict_SetDefault`" -#: ../../howto/free-threading-extensions.rst:169 msgid ":c:func:`PyDict_SetDefaultRef`" -msgstr "" +msgstr ":c:func:`PyDict_SetDefaultRef`" -#: ../../howto/free-threading-extensions.rst:171 msgid ":c:func:`PyDict_Next`" -msgstr "" +msgstr ":c:func:`PyDict_Next`" -#: ../../howto/free-threading-extensions.rst:171 msgid "none (see :ref:`PyDict_Next`)" -msgstr "" +msgstr "なし (:ref:`PyDict_Next` を参照)" -#: ../../howto/free-threading-extensions.rst:173 msgid ":c:func:`!PyWeakref_GetObject`" -msgstr "" +msgstr ":c:func:`!PyWeakref_GetObject`" -#: ../../howto/free-threading-extensions.rst:173 -#: ../../howto/free-threading-extensions.rst:175 msgid ":c:func:`PyWeakref_GetRef`" -msgstr "" +msgstr ":c:func:`PyWeakref_GetRef`" -#: ../../howto/free-threading-extensions.rst:175 msgid ":c:func:`!PyWeakref_GET_OBJECT`" -msgstr "" +msgstr ":c:func:`!PyWeakref_GET_OBJECT`" -#: ../../howto/free-threading-extensions.rst:177 msgid ":c:func:`PyImport_AddModule`" -msgstr "" +msgstr ":c:func:`PyImport_AddModule`" -#: ../../howto/free-threading-extensions.rst:177 msgid ":c:func:`PyImport_AddModuleRef`" -msgstr "" +msgstr ":c:func:`PyImport_AddModuleRef`" -#: ../../howto/free-threading-extensions.rst:179 msgid ":c:func:`PyCell_GET`" -msgstr "" +msgstr ":c:func:`PyCell_GET`" -#: ../../howto/free-threading-extensions.rst:179 msgid ":c:func:`PyCell_Get`" -msgstr "" +msgstr ":c:func:`PyCell_Get`" -#: ../../howto/free-threading-extensions.rst:182 msgid "" "Not all APIs that return borrowed references are problematic. For example, :" "c:func:`PyTuple_GetItem` is safe because tuples are immutable. Similarly, " @@ -320,19 +356,26 @@ msgid "" "(not accessible by other threads), so using borrowed references in that " "context is safe." msgstr "" +"借用参照を返すすべての API が問題になるわけではありません。\n" +"例えば、タプルはイミュータブルなので :c:func:`PyTuple_GetItem` は安全です。\n" +"また、上記 API の使い方がすべて問題になるわけでもありません。\n" +"例えば、:c:func:`PyDict_GetItem` は関数呼び出しのキーワード引数辞書の解析によ" +"く使われます。\n" +"この辞書は実質的にプライベートで、ほかのスレッドからアクセスできないため、そ" +"の状況で借用参照を使うのは安全です。" -#: ../../howto/free-threading-extensions.rst:190 msgid "" "Some of these functions were added in Python 3.13. You can use the " "`pythoncapi-compat `_ package " "to provide implementations of these functions for older Python versions." msgstr "" +"これらの関数の一部は Python 3.13 で追加されました。\n" +"古い Python バージョン向けには、`pythoncapi-compat `_ パッケージでこれらの関数の実装を利用できます。" -#: ../../howto/free-threading-extensions.rst:198 msgid "Memory Allocation APIs" -msgstr "" +msgstr "メモリ割り当て API" -#: ../../howto/free-threading-extensions.rst:200 msgid "" "Python's memory management C API provides functions in three different :ref:" "`allocation domains `: \"raw\", \"mem\", and \"object\". " @@ -341,43 +384,49 @@ msgid "" "allocated using that domain. This differs from the prior Python versions, " "where this was only a best practice and not a hard requirement." msgstr "" +"Python のメモリ管理 C API は、raw、mem、object という 3 つの :ref:`割り当てド" +"メイン ` の関数を提供します。\n" +"フリースレッドビルドではスレッド安全性のため、object ドメインで割り当てるの" +"は Python オブジェクトだけでなければならず、すべての Python オブジェクトをこ" +"のドメインで割り当てる必要があります。\n" +"以前の Python では、これは推奨事項にすぎず、必須条件ではありませんでした。" -#: ../../howto/free-threading-extensions.rst:209 msgid "" "Search for uses of :c:func:`PyObject_Malloc` in your extension and check " "that the allocated memory is used for Python objects. Use :c:func:" "`PyMem_Malloc` to allocate buffers instead of :c:func:`PyObject_Malloc`." msgstr "" +"拡張内の :c:func:`PyObject_Malloc` の使用箇所を探し、割り当てたメモリを " +"Python オブジェクトに使っているか確認してください。\n" +"バッファの割り当てには、:c:func:`PyObject_Malloc` ではなく :c:func:" +"`PyMem_Malloc` を使ってください。" -#: ../../howto/free-threading-extensions.rst:216 msgid "Thread State and GIL APIs" -msgstr "" +msgstr "スレッド状態と GIL の API" -#: ../../howto/free-threading-extensions.rst:218 msgid "" "Python provides a set of functions and macros to manage thread state and the " "GIL, such as:" msgstr "" +"Python は、スレッド状態と GIL を管理するために、次のような関数やマクロを提供" +"しています。" -#: ../../howto/free-threading-extensions.rst:221 msgid "" ":c:func:`PyThreadState_Ensure`, :c:func:`PyThreadState_EnsureFromView`, and :" "c:func:`PyThreadState_Release`" msgstr "" +":c:func:`PyThreadState_Ensure`、:c:func:`PyThreadState_EnsureFromView`、:c:" +"func:`PyThreadState_Release`" -#: ../../howto/free-threading-extensions.rst:223 msgid ":c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release`" -msgstr "" +msgstr ":c:func:`PyGILState_Ensure` と :c:func:`PyGILState_Release`" -#: ../../howto/free-threading-extensions.rst:224 msgid ":c:func:`PyEval_SaveThread` and :c:func:`PyEval_RestoreThread`" -msgstr "" +msgstr ":c:func:`PyEval_SaveThread` と :c:func:`PyEval_RestoreThread`" -#: ../../howto/free-threading-extensions.rst:225 msgid ":c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS`" -msgstr "" +msgstr ":c:macro:`Py_BEGIN_ALLOW_THREADS` と :c:macro:`Py_END_ALLOW_THREADS`" -#: ../../howto/free-threading-extensions.rst:227 msgid "" "These functions should still be used in the free-threaded build to manage " "thread state even when the :term:`GIL` is disabled. For example, if you " @@ -385,46 +434,60 @@ msgid "" "`PyThreadState_Ensure` before calling into the Python API to ensure that the " "thread has a valid Python thread state." msgstr "" +"フリースレッドビルドで :term:`GIL` が無効な場合も、スレッド状態の管理にはこれ" +"らの関数を引き続き使う必要があります。\n" +"例えば、Python の外部で作成したスレッドから Python API を呼び出す場合は、先" +"に :c:func:`PyThreadState_Ensure` を呼び出し、有効な Python スレッド状態を持" +"つことを保証しなければなりません。" -#: ../../howto/free-threading-extensions.rst:233 msgid "" "You should continue to call :c:func:`PyEval_SaveThread` or :c:macro:" "`Py_BEGIN_ALLOW_THREADS` around blocking operations, such as I/O or lock " "acquisitions, to allow other threads to run the :term:`cyclic garbage " "collector `." msgstr "" +"I/O やロック取得などのブロッキング操作の前後では、引き続き :c:func:" +"`PyEval_SaveThread` や :c:macro:`Py_BEGIN_ALLOW_THREADS` を使ってください。\n" +"これにより、ほかのスレッドが :term:`循環ガベージコレクタ ` を実行できるようになります。" -#: ../../howto/free-threading-extensions.rst:240 msgid "Protecting Internal Extension State" -msgstr "" +msgstr "拡張の内部状態の保護" -#: ../../howto/free-threading-extensions.rst:242 msgid "" "Your extension may have internal state that was previously protected by the " "GIL. You may need to add locking to protect this state. The approach will " "depend on your extension, but some common patterns include:" msgstr "" +"拡張には、以前は GIL によって保護されていた内部状態があるかもしれません。\n" +"その状態を保護するためにロックを追加する必要がある場合があります。\n" +"方法は拡張によりますが、よくあるパターンには次のものがあります。" -#: ../../howto/free-threading-extensions.rst:246 msgid "" "**Caches**: global caches are a common source of shared state. Consider " "using a lock to protect the cache or disabling it in the free-threaded build " "if the cache is not critical for performance." msgstr "" +"**キャッシュ**: グローバルなキャッシュは、共有状態が生まれる典型的な場所で" +"す。\n" +"ロックでキャッシュを保護するか、性能上不可欠でなければ、フリースレッドビルド" +"ではキャッシュを無効にすることを検討してください。" -#: ../../howto/free-threading-extensions.rst:249 msgid "" "**Global State**: global state may need to be protected by a lock or moved " "to thread local storage. C11 and C++11 provide the ``thread_local`` or " "``_Thread_local`` for `thread-local storage `_." msgstr "" +"**グローバルな状態**: グローバルな状態には、ロックによる保護やスレッドローカ" +"ルストレージへの移動が必要な場合があります。\n" +"C11 と C++11 は、`スレッドローカルストレージ `_ のために ``thread_local`` または " +"``_Thread_local`` を提供しています。" -#: ../../howto/free-threading-extensions.rst:256 msgid "Critical Sections" -msgstr "" +msgstr "クリティカルセクション" -#: ../../howto/free-threading-extensions.rst:260 msgid "" "In the free-threaded build, CPython provides a mechanism called \"critical " "sections\" to protect data that would otherwise be protected by the GIL. " @@ -432,12 +495,14 @@ msgid "" "implementation directly, understanding their behavior is crucial when using " "certain C API functions or managing shared state in the free-threaded build." msgstr "" +"CPython のフリースレッドビルドには、通常なら GIL が保護するデータを保護する" +"「クリティカルセクション」という仕組みがあります。\n" +"拡張の開発者がその内部実装を直接扱うことはなくても、特定の C API 関数を使うと" +"きや共有状態を管理するときには、動作を理解しておくことが重要です。" -#: ../../howto/free-threading-extensions.rst:267 msgid "What Are Critical Sections?" -msgstr "" +msgstr "クリティカルセクションとは" -#: ../../howto/free-threading-extensions.rst:269 msgid "" "Conceptually, critical sections act as a deadlock avoidance layer built on " "top of simple mutexes. Each thread maintains a stack of active critical " @@ -446,42 +511,55 @@ msgid "" "func:`PyDict_SetItem`, or explicitly using macros), it attempts to acquire " "the underlying mutex." msgstr "" +"概念的には、クリティカルセクションは単純なミューテックスの上に設けられた、" +"デッドロックを回避するための層です。\n" +"各スレッドは、有効なクリティカルセクションのスタックを保持します。\n" +"スレッドがクリティカルセクションのロックを取得する必要があると、その基盤とな" +"るミューテックスの取得を試みます。\n" +"これは、:c:func:`PyDict_SetItem` のようなスレッドセーフな C API 関数の呼び出" +"しで暗黙に行われる場合も、マクロで明示的に行われる場合もあります。" -#: ../../howto/free-threading-extensions.rst:277 msgid "Using Critical Sections" -msgstr "" +msgstr "クリティカルセクションの使い方" -#: ../../howto/free-threading-extensions.rst:279 msgid "The primary APIs for using critical sections are:" -msgstr "" +msgstr "クリティカルセクションを使う主な API は次のとおりです。" -#: ../../howto/free-threading-extensions.rst:281 msgid "" ":c:macro:`Py_BEGIN_CRITICAL_SECTION` and :c:macro:`Py_END_CRITICAL_SECTION` " "- For locking a single object" msgstr "" +":c:macro:`Py_BEGIN_CRITICAL_SECTION` と :c:macro:`Py_END_CRITICAL_SECTION` — " +"1 つのオブジェクトをロックします。" -#: ../../howto/free-threading-extensions.rst:284 msgid "" ":c:macro:`Py_BEGIN_CRITICAL_SECTION2` and :c:macro:" "`Py_END_CRITICAL_SECTION2` - For locking two objects simultaneously" msgstr "" +":c:macro:`Py_BEGIN_CRITICAL_SECTION2` と :c:macro:`Py_END_CRITICAL_SECTION2` " +"— 2 つのオブジェクトを同時にロックします。" -#: ../../howto/free-threading-extensions.rst:287 msgid "" "These macros must be used in matching pairs and must appear in the same C " "scope, since they establish a new local scope. These macros are no-ops in " "non-free-threaded builds, so they can be safely added to code that needs to " "support both build types." msgstr "" +"これらのマクロは新しいローカルスコープを作るため、必ず対応する組で使い、同じ " +"C のスコープに置く必要があります。\n" +"非フリースレッドビルドでは何もしないので、両方のビルドに対応するコードにも安" +"全に追加できます。" -#: ../../howto/free-threading-extensions.rst:292 msgid "" "A common use of a critical section would be to lock an object while " "accessing an internal attribute of it. For example, if an extension type " "has an internal count field, you could use a critical section while reading " "or writing that field::" msgstr "" +"クリティカルセクションのよくある用途は、オブジェクトの内部属性へのアクセス中" +"に、そのオブジェクトをロックすることです。\n" +"例えば、拡張型に内部的なカウントのフィールドがあれば、その読み書きにクリティ" +"カルセクションを使えます。 ::" #: ../../howto/free-threading-extensions.rst:297 msgid "" @@ -498,11 +576,9 @@ msgid "" "Py_END_CRITICAL_SECTION();" msgstr "" -#: ../../howto/free-threading-extensions.rst:311 msgid "How Critical Sections Work" -msgstr "" +msgstr "クリティカルセクションの仕組み" -#: ../../howto/free-threading-extensions.rst:313 msgid "" "Unlike traditional locks, critical sections do not guarantee exclusive " "access throughout their entire duration. If a thread would block while " @@ -510,60 +586,75 @@ msgid "" "O), the critical section is temporarily suspended—all locks are released—and " "then resumed when the blocking operation completes." msgstr "" +"通常のロックとは異なり、クリティカルセクションはその期間全体にわたる排他的ア" +"クセスを保証しません。\n" +"クリティカルセクション内で別のロックの取得や I/O などによってスレッドがブロッ" +"クする場合、クリティカルセクションは一時的に中断され、すべてのロックが解放さ" +"れます。\n" +"ブロッキング操作が完了すると再開されます。" -#: ../../howto/free-threading-extensions.rst:319 msgid "" "This behavior is similar to what happens with the GIL when a thread makes a " "blocking call. The key differences are:" msgstr "" +"これは、スレッドがブロッキング呼び出しを行うときの GIL の動作に似ています。\n" +"主な違いは次のとおりです。" -#: ../../howto/free-threading-extensions.rst:322 msgid "Critical sections operate on a per-object basis rather than globally" msgstr "" +"クリティカルセクションは全体で 1 つではなく、オブジェクト単位で動作します。" -#: ../../howto/free-threading-extensions.rst:324 msgid "" "Critical sections follow a stack discipline within each thread (the " "\"begin\" and \"end\" macros enforce this since they must be paired and " "within the same scope)" msgstr "" +"クリティカルセクションは各スレッド内でスタックの順序に従います。\n" +"開始マクロと終了マクロは同じスコープ内で対にする必要があるため、この順序が強" +"制されます。" -#: ../../howto/free-threading-extensions.rst:327 msgid "" "Critical sections automatically release and reacquire locks around potential " "blocking operations" msgstr "" +"クリティカルセクションは、ブロックする可能性のある操作の前後で、自動的にロッ" +"クを解放して再取得します。" -#: ../../howto/free-threading-extensions.rst:331 msgid "Deadlock Avoidance" -msgstr "" +msgstr "デッドロックの回避" -#: ../../howto/free-threading-extensions.rst:333 msgid "Critical sections help avoid deadlocks in two ways:" msgstr "" +"クリティカルセクションは、次の 2 つの方法でデッドロックの回避を助けます。" -#: ../../howto/free-threading-extensions.rst:335 msgid "" "If a thread tries to acquire a lock that's already held by another thread, " "it first suspends all of its active critical sections, temporarily releasing " "their locks" msgstr "" +"スレッドが別のスレッドに保持されているロックを取得しようとすると、まず自身の" +"有効なクリティカルセクションをすべて中断し、それらのロックを一時的に解放しま" +"す。" -#: ../../howto/free-threading-extensions.rst:339 msgid "" "When the blocking operation completes, only the top-most critical section is " "reacquired first" msgstr "" +"ブロッキング操作が完了すると、最初に最上位のクリティカルセクションだけが再取" +"得されます。" -#: ../../howto/free-threading-extensions.rst:342 msgid "" "This means you cannot rely on nested critical sections to lock multiple " "objects at once, as the inner critical section may suspend the outer ones. " "Instead, use :c:macro:`Py_BEGIN_CRITICAL_SECTION2` to lock two objects " "simultaneously." msgstr "" +"このため、複数のオブジェクトを同時にロックする目的で、クリティカルセクション" +"の入れ子を使うことはできません。\n" +"内側のクリティカルセクションが外側を中断する可能性があるためです。\n" +"2 つのオブジェクトを同時にロックするには、代わりに :c:macro:" +"`Py_BEGIN_CRITICAL_SECTION2` を使ってください。" -#: ../../howto/free-threading-extensions.rst:346 msgid "" "Note that the locks described above are only :c:type:`PyMutex` based locks. " "The critical section implementation does not know about or affect other " @@ -573,19 +664,28 @@ msgid "" "released. If :c:type:`PyMutex` is used without a critical section, it will " "not be released and therefore does not get the same deadlock avoidance." msgstr "" +"ここで説明したロックは、:c:type:`PyMutex` に基づくロックだけです。\n" +"クリティカルセクションの実装は、POSIX ミューテックスなどのほかのロック機構を" +"認識せず、影響も与えません。\n" +"また、どの :c:type:`PyMutex` でブロックしてもクリティカルセクションは中断され" +"ますが、解放されるのはクリティカルセクションの一部であるミューテックスだけで" +"す。\n" +"クリティカルセクションを使わずに取得した :c:type:`PyMutex` は解放されないた" +"め、同じデッドロック回避の効果は得られません。" -#: ../../howto/free-threading-extensions.rst:355 msgid "Important Considerations" -msgstr "" +msgstr "重要な注意点" -#: ../../howto/free-threading-extensions.rst:357 msgid "" "Critical sections may temporarily release their locks, allowing other " "threads to modify the protected data. Be careful about making assumptions " "about the state of the data after operations that might block." msgstr "" +"クリティカルセクションは一時的にロックを解放することがあるため、ほかのスレッ" +"ドが保護対象のデータを変更できます。\n" +"ブロックする可能性のある操作の後で、データの状態を仮定する際には注意してくだ" +"さい。" -#: ../../howto/free-threading-extensions.rst:361 msgid "" "Because locks can be temporarily released (suspended), entering a critical " "section does not guarantee exclusive access to the protected resource " @@ -594,35 +694,49 @@ msgid "" "I/O), all locks held by the thread via critical sections will be released. " "This is similar to how the GIL can be released during blocking calls." msgstr "" +"ロックが一時的に解放 (中断) される可能性があるため、クリティカルセクションに" +"入っても、その期間全体にわたって保護対象のリソースへ排他的にアクセスできると" +"は限りません。\n" +"クリティカルセクション内で、別のロックの取得やブロッキング I/O などを行う関数" +"を呼び、その処理がブロックすると、そのスレッドがクリティカルセクションを通じ" +"て保持するロックはすべて解放されます。\n" +"これは、ブロッキング呼び出し中に GIL が解放されることがあるのと同様です。" -#: ../../howto/free-threading-extensions.rst:368 msgid "" "Only the lock(s) associated with the most recently entered (top-most) " "critical section are guaranteed to be held at any given time. Locks for " "outer, nested critical sections might have been suspended." msgstr "" +"ある時点で保持が保証されるのは、最後に入った最上位のクリティカルセクションの" +"ロックだけです。\n" +"入れ子になった外側のクリティカルセクションのロックは、中断されている可能性が" +"あります。" -#: ../../howto/free-threading-extensions.rst:372 msgid "" "You can lock at most two objects simultaneously with these APIs. If you need " "to lock more objects, you'll need to restructure your code." msgstr "" +"これらの API で同時にロックできるオブジェクトは最大 2 つです。\n" +"それ以上をロックする必要があれば、コードの構成を見直す必要があります。" -#: ../../howto/free-threading-extensions.rst:375 msgid "" "While critical sections will not deadlock if you attempt to lock the same " "object twice, they are less efficient than purpose-built reentrant locks for " "this use case." msgstr "" +"クリティカルセクションで同じオブジェクトを 2 回ロックしようとしてもデッドロッ" +"クにはなりませんが、この用途に特化した再入可能ロックほど効率的ではありませ" +"ん。" -#: ../../howto/free-threading-extensions.rst:379 msgid "" "When using :c:macro:`Py_BEGIN_CRITICAL_SECTION2`, the order of the objects " "doesn't affect correctness (the implementation handles deadlock avoidance), " "but it's good practice to always lock objects in a consistent order." msgstr "" +":c:macro:`Py_BEGIN_CRITICAL_SECTION2` では、実装がデッドロックを回避するた" +"め、オブジェクトの順序は正しさに影響しません。\n" +"ただし、常に一貫した順序でロックするのがよい習慣です。" -#: ../../howto/free-threading-extensions.rst:383 msgid "" "Remember that the critical section macros are primarily for protecting " "access to *Python objects* that might be involved in internal CPython " @@ -630,44 +744,58 @@ msgid "" "protecting purely internal extension state, standard mutexes or other " "synchronization primitives might be more appropriate." msgstr "" +"クリティカルセクションのマクロは主に、上述のようなデッドロックが起こり得る " +"CPython 内部の操作に関与する *Python オブジェクト* へのアクセスを保護するもの" +"です。\n" +"拡張だけが使う内部状態の保護には、標準のミューテックスなどの同期プリミティブ" +"のほうが適している場合があります。" -#: ../../howto/free-threading-extensions.rst:392 msgid "Per-Object Locks (``ob_mutex``)" -msgstr "" +msgstr "オブジェクトごとのロック (``ob_mutex``)" -#: ../../howto/free-threading-extensions.rst:394 msgid "" "In the free-threaded build, each Python object contains a :c:member:" "`~PyObject.ob_mutex` field of type :c:type:`PyMutex`. This mutex is " "**reserved for use by the critical section API** (:c:macro:" "`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`)." msgstr "" +"フリースレッドビルドでは、各 Python オブジェクトに :c:type:`PyMutex` 型の :c:" +"member:`~PyObject.ob_mutex` フィールドがあります。\n" +"このミューテックスは **クリティカルセクション API 専用** です (:c:macro:" +"`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`)。" -#: ../../howto/free-threading-extensions.rst:401 msgid "" "Do **not** lock ``ob_mutex`` directly with ``PyMutex_Lock(&obj->ob_mutex)``. " "Mixing direct ``PyMutex_Lock`` calls with the critical section API on the " "same mutex can cause deadlocks." msgstr "" +"``PyMutex_Lock(&obj->ob_mutex)`` で ``ob_mutex`` を直接ロック **しないでくだ" +"さい**。\n" +"同じミューテックスに対して、``PyMutex_Lock`` の直接呼び出しとクリティカルセク" +"ション API を混在させると、デッドロックが起こる可能性があります。" -#: ../../howto/free-threading-extensions.rst:405 msgid "" "Even if your own code never uses critical sections on a particular object " "type, **CPython internals may use the critical section API on any Python " "object**." msgstr "" +"自分のコードでは特定の型のオブジェクトにクリティカルセクションを使っていなく" +"ても、**CPython 内部ではどの Python オブジェクトにもクリティカルセクション " +"API を使う可能性があります**。" -#: ../../howto/free-threading-extensions.rst:408 msgid "" "If your extension type needs its own lock, add a separate :c:type:`PyMutex` " "field (or another synchronization primitive) to your object struct. :c:type:" "`PyMutex` is very lightweight, so there is negligible cost to having an " "additional one." msgstr "" +"拡張型に独自のロックが必要な場合は、オブジェクトの構造体に別の :c:type:" +"`PyMutex` フィールド、またはほかの同期プリミティブを追加してください。\n" +":c:type:`PyMutex` は非常に軽量なので、追加で 1 つ持ってもコストはほぼ無視でき" +"ます。" -#: ../../howto/free-threading-extensions.rst:415 msgid "Building Extensions for the Free-Threaded Build" -msgstr "" +msgstr "フリースレッドビルド向けの拡張のビルド" #: ../../howto/free-threading-extensions.rst:417 msgid "" @@ -675,21 +803,22 @@ msgid "" "The wheels, shared libraries, and binaries are indicated by a ``t`` suffix." msgstr "" -#: ../../howto/free-threading-extensions.rst:420 msgid "" "`pypa/manylinux `_ supports the free-" "threaded build, with the ``t`` suffix, such as ``python3.14t``." msgstr "" +"`pypa/manylinux `_ は、``python3.14t`` の" +"ように ``t`` サフィックスを付けたフリースレッドビルドに対応しています。" -#: ../../howto/free-threading-extensions.rst:422 msgid "" "`pypa/cibuildwheel `_ supports " "building wheels for the free-threaded build of Python 3.14 and newer." msgstr "" +"`pypa/cibuildwheel `_ は、Python 3.14 " +"以降のフリースレッドビルド向け wheel の作成に対応しています。" -#: ../../howto/free-threading-extensions.rst:426 msgid "Limited C API and Stable ABI" -msgstr "" +msgstr "Limited C API と Stable ABI" #: ../../howto/free-threading-extensions.rst:428 msgid "" @@ -712,15 +841,18 @@ msgstr "" msgid "Windows" msgstr "Windows" -#: ../../howto/free-threading-extensions.rst:444 msgid "" "Due to a limitation of the official Windows installer, you will need to " "manually define ``Py_GIL_DISABLED=1`` when building extensions from source." msgstr "" +"公式 Windows インストーラの制限により、ソースから拡張をビルドする際は、" +"``Py_GIL_DISABLED=1`` を手動で定義する必要があります。" -#: ../../howto/free-threading-extensions.rst:449 msgid "" "`Porting Extension Modules to Support Free-Threading `_: A community-maintained porting guide for " "extension authors." msgstr "" +"`Porting Extension Modules to Support Free-Threading `_: 拡張の開発者向けにコミュニティが保守している" +"移植ガイド。" diff --git a/howto/free-threading-python.po b/howto/free-threading-python.po index 4dc1621ec..6a855f216 100644 --- a/howto/free-threading-python.po +++ b/howto/free-threading-python.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/free-threading-python.rst:5 msgid "Python support for free threading" -msgstr "" +msgstr "Python のフリースレッド対応" -#: ../../howto/free-threading-python.rst:7 msgid "" "Starting with the 3.13 release, CPython has support for a build of Python " "called :term:`free threading` where the :term:`global interpreter lock` " @@ -36,108 +34,131 @@ msgid "" "programs designed with threading in mind will run faster on multi-core " "hardware." msgstr "" +"CPython 3.13 から、:term:`global interpreter lock` (GIL) を無効にした :term:" +"`free threading` という Python のビルドがサポートされています。\n" +"フリースレッド実行では、利用可能な CPU コアでスレッドを並列に動かし、処理能力" +"を十分に活用できます。\n" +"すべてのソフトウェアが自動的に恩恵を受けるわけではありませんが、スレッドの利" +"用を考慮して設計されたプログラムは、マルチコアのハードウェア上でより速く動作" +"します。" -#: ../../howto/free-threading-python.rst:14 msgid "" "Some third-party packages, in particular ones with an :term:`extension " "module`, may not be ready for use in a free-threaded build, and will re-" "enable the :term:`GIL`." msgstr "" +"一部のサードパーティーパッケージ、特に :term:`extension module` を含むもの" +"は、フリースレッドビルドへの対応ができておらず、:term:`GIL` を再び有効にする" +"場合があります。" -#: ../../howto/free-threading-python.rst:18 msgid "" "This document describes the implications of free threading for Python code. " "See :ref:`freethreading-extensions-howto` for information on how to write C " "extensions that support the free-threaded build." msgstr "" +"このドキュメントでは、フリースレッドが Python コードに与える影響を説明しま" +"す。\n" +"フリースレッドビルドに対応した C 拡張の書き方は、:ref:`freethreading-" +"extensions-howto` を参照してください。" -#: ../../howto/free-threading-python.rst:24 msgid "" ":pep:`703` – Making the Global Interpreter Lock Optional in CPython for an " "overall description of free-threaded Python." msgstr "" +"フリースレッドの Python の全体的な説明は、:pep:`703` — Making the Global " +"Interpreter Lock Optional in CPython を参照してください。" -#: ../../howto/free-threading-python.rst:29 msgid "Installation" -msgstr "" +msgstr "インストール" -#: ../../howto/free-threading-python.rst:31 msgid "" "Starting with Python 3.13, the official macOS and Windows installers " "optionally support installing free-threaded Python binaries. The installers " "are available at https://www.python.org/downloads/." msgstr "" +"Python 3.13 から、macOS と Windows の公式インストーラでは、フリースレッド版 " +"Python のバイナリを追加でインストールできます。\n" +"インストーラは https://www.python.org/downloads/ から入手できます。" -#: ../../howto/free-threading-python.rst:35 msgid "" "For information on other platforms, see the `Installing a Free-Threaded " "Python `_, a " "community-maintained installation guide for installing free-threaded Python." msgstr "" +"ほかのプラットフォームについては、コミュニティが保守しているフリースレッド版 " +"Python のインストールガイド、`Installing a Free-Threaded Python `_ を参照してください。" -#: ../../howto/free-threading-python.rst:39 msgid "" "When building CPython from source, the :option:`--disable-gil` configure " "option should be used to build a free-threaded Python interpreter." msgstr "" +"CPython をソースからビルドする場合、フリースレッドの Python インタープリタを" +"作るには configure の :option:`--disable-gil` オプションを使います。" -#: ../../howto/free-threading-python.rst:44 msgid "Identifying free-threaded Python" -msgstr "" +msgstr "フリースレッド版 Python の識別" -#: ../../howto/free-threading-python.rst:46 msgid "" "To check if the current interpreter supports free-threading, :option:`python " "-VV <-V>` and :data:`sys.version` contain \"free-threading build\". The new :" "func:`sys._is_gil_enabled` function can be used to check whether the GIL is " "actually disabled in the running process." msgstr "" +"実行中のインタープリタがフリースレッドに対応しているかは、:option:`python -" +"VV <-V>` の出力や :data:`sys.version` に \"free-threading build\" が含まれる" +"かで確認できます。\n" +"新しい :func:`sys._is_gil_enabled` 関数では、実行中のプロセスで GIL が実際に" +"無効になっているかを確認できます。" -#: ../../howto/free-threading-python.rst:51 msgid "" "The ``sysconfig.get_config_var(\"Py_GIL_DISABLED\")`` configuration variable " "can be used to determine whether the build supports free threading. If the " "variable is set to ``1``, then the build supports free threading. This is " "the recommended mechanism for decisions related to the build configuration." msgstr "" +"``sysconfig.get_config_var(\"Py_GIL_DISABLED\")`` 設定変数でも、ビルドがフ" +"リースレッドに対応しているかを確認できます。\n" +"値が ``1`` なら対応しています。\n" +"ビルド構成に関する判断には、この方法を使うことが推奨されます。" -#: ../../howto/free-threading-python.rst:58 msgid "The global interpreter lock in free-threaded Python" -msgstr "" +msgstr "フリースレッド版 Python のグローバルインタープリタロック" -#: ../../howto/free-threading-python.rst:60 msgid "" "Free-threaded builds of CPython support optionally running with the GIL " "enabled at runtime using the environment variable :envvar:`PYTHON_GIL` or " "the command-line option :option:`-X gil`." msgstr "" +"CPython のフリースレッドビルドでは、:envvar:`PYTHON_GIL` 環境変数または :" +"option:`-X gil` コマンドラインオプションを使い、実行時に GIL を有効にすること" +"もできます。" -#: ../../howto/free-threading-python.rst:64 msgid "" "The GIL may also automatically be enabled when importing a C-API extension " "module that is not explicitly marked as supporting free threading. A " "warning will be printed in this case." msgstr "" +"フリースレッド対応が明示されていない C API 拡張モジュールをインポートすると、" +"GIL が自動的に有効になることもあります。\n" +"この場合は警告が表示されます。" -#: ../../howto/free-threading-python.rst:68 msgid "" "In addition to individual package documentation, the following websites " "track the status of popular packages support for free threading:" msgstr "" +"個々のパッケージのドキュメントに加え、次のウェブサイトでも、よく使われるパッ" +"ケージのフリースレッド対応状況を確認できます。" -#: ../../howto/free-threading-python.rst:71 msgid "https://py-free-threading.github.io/tracking/" -msgstr "" +msgstr "https://py-free-threading.github.io/tracking/" -#: ../../howto/free-threading-python.rst:72 msgid "https://hugovk.github.io/free-threaded-wheels/" -msgstr "" +msgstr "https://hugovk.github.io/free-threaded-wheels/" -#: ../../howto/free-threading-python.rst:76 msgid "Thread safety" -msgstr "" +msgstr "スレッド安全性" -#: ../../howto/free-threading-python.rst:78 msgid "" "The free-threaded build of CPython aims to provide similar thread-safety " "behavior at the Python level to the default GIL-enabled build. Built-in " @@ -146,76 +167,84 @@ msgid "" "the GIL. See :ref:`threadsafety` for the guarantees provided by built-in " "types." msgstr "" +"CPython のフリースレッドビルドは、Python レベルでは、デフォルトの GIL が有効" +"なビルドと同様のスレッド安全性を提供することを目指しています。\n" +":class:`dict`、:class:`list`、:class:`set` などの組み込み型は内部ロックを使" +"い、GIL と似た動作で並行する変更から保護します。\n" +"組み込み型が提供する保証については、:ref:`threadsafety` を参照してください。" -#: ../../howto/free-threading-python.rst:86 msgid "" "It's recommended to use the :class:`threading.Lock` or other synchronization " "primitives instead of relying on the internal locks of built-in types, when " "possible." msgstr "" +"可能であれば、組み込み型の内部ロックに頼る代わりに、:class:`threading.Lock` " +"などの同期プリミティブを使うことが推奨されます。" -#: ../../howto/free-threading-python.rst:92 msgid "Known limitations" -msgstr "" +msgstr "既知の制限" -#: ../../howto/free-threading-python.rst:94 msgid "" "This section describes known limitations of the free-threaded CPython build." -msgstr "" +msgstr "この節では、CPython のフリースレッドビルドの既知の制限を説明します。" -#: ../../howto/free-threading-python.rst:97 msgid "Immortalization" -msgstr "" +msgstr "不死化" -#: ../../howto/free-threading-python.rst:99 msgid "" "In the free-threaded build, some objects are :term:`immortal`. Immortal " "objects are not deallocated and have reference counts that are never " "modified. This is done to avoid reference count contention that would " "prevent efficient multi-threaded scaling." msgstr "" +"フリースレッドビルドでは、一部のオブジェクトが :term:`immortal` になりま" +"す。\n" +"不死のオブジェクトは解放されず、参照カウントも変更されません。\n" +"これは、効率的なマルチスレッドでの性能向上を妨げる、参照カウントの競合を避け" +"るためです。" -#: ../../howto/free-threading-python.rst:104 msgid "As of the 3.14 release, immortalization is limited to:" -msgstr "" +msgstr "3.14 リリース時点では、不死化されるものは次に限られます。" -#: ../../howto/free-threading-python.rst:106 msgid "" "Code constants: numeric literals, string literals, and tuple literals " "composed of other constants." msgstr "" +"コード内の定数: 数値リテラル、文字列リテラル、ほかの定数からなるタプルリテラ" +"ル。" -#: ../../howto/free-threading-python.rst:108 msgid "Strings interned by :func:`sys.intern`." -msgstr "" +msgstr ":func:`sys.intern` でインターンされた文字列。" #: ../../howto/free-threading-python.rst:112 msgid "Frame objects" msgstr "フレーム (frame) オブジェクト" -#: ../../howto/free-threading-python.rst:114 msgid "" "It is not safe to access :attr:`frame.f_locals` from a :ref:`frame ` object if that frame is currently executing in another thread, and " "doing so may crash the interpreter." msgstr "" +"別のスレッドで実行中の :ref:`フレーム ` オブジェクトの :attr:" +"`frame.f_locals` にアクセスするのは安全ではなく、インタープリタがクラッシュす" +"る可能性があります。" #: ../../howto/free-threading-python.rst:120 msgid "Iterators" msgstr "イテレータ (iterator)" -#: ../../howto/free-threading-python.rst:122 msgid "" "It is generally not thread-safe to access the same iterator object from " "multiple threads concurrently, and threads may see duplicate or missing " "elements." msgstr "" +"一般に、同じイテレータオブジェクトに複数のスレッドから並行してアクセスするこ" +"とは、スレッドセーフではありません。\n" +"要素が重複して取得されたり、取得できない要素が出たりする可能性があります。" -#: ../../howto/free-threading-python.rst:128 msgid "Single-threaded performance" -msgstr "" +msgstr "シングルスレッドの性能" -#: ../../howto/free-threading-python.rst:130 msgid "" "The free-threaded build has additional overhead when executing Python code " "compared to the default GIL-enabled build. The amount of overhead depends " @@ -223,22 +252,24 @@ msgid "" "average overhead ranges from about 1% on macOS aarch64 to 8% on x86-64 Linux " "systems." msgstr "" +"フリースレッドビルドは、デフォルトの GIL が有効なビルドに比べ、Python コード" +"の実行に追加のオーバーヘッドがあります。\n" +"その大きさはワークロードとハードウェアに依存します。\n" +"pyperformance ベンチマークスイートでは、平均のオーバーヘッドは macOS aarch64 " +"の約 1% から x86-64 Linux の約 8% までの範囲です。" -#: ../../howto/free-threading-python.rst:138 msgid "Behavioral changes" -msgstr "" +msgstr "動作の違い" -#: ../../howto/free-threading-python.rst:140 msgid "" "This section describes CPython behavioural changes with the free-threaded " "build." msgstr "" +"この節では、フリースレッドビルドによる CPython の動作の違いを説明します。" -#: ../../howto/free-threading-python.rst:145 msgid "Context variables" -msgstr "" +msgstr "コンテキスト変数" -#: ../../howto/free-threading-python.rst:147 msgid "" "In the free-threaded build, the flag :data:`~sys.flags." "thread_inherit_context` is set to true by default which causes threads " @@ -247,12 +278,17 @@ msgid "" "In the default GIL-enabled build, the flag defaults to false so threads " "start with an empty :class:`~contextvars.Context()`." msgstr "" +"フリースレッドビルドでは、:data:`~sys.flags.thread_inherit_context` フラグは" +"デフォルトで真です。\n" +"そのため、:class:`threading.Thread` で作られたスレッドは、:meth:`~threading." +"Thread.start` の呼び出し元の :class:`~contextvars.Context()` のコピーを持って" +"開始します。\n" +"デフォルトの GIL が有効なビルドでは、このフラグはデフォルトで偽なので、スレッ" +"ドは空の :class:`~contextvars.Context()` で開始します。" -#: ../../howto/free-threading-python.rst:157 msgid "Warning filters" -msgstr "" +msgstr "警告フィルタ" -#: ../../howto/free-threading-python.rst:159 msgid "" "In the free-threaded build, the flag :data:`~sys.flags." "context_aware_warnings` is set to true by default. In the default GIL-" @@ -262,23 +298,30 @@ msgid "" "catch_warnings` modifies the global filters list, which is not thread-safe. " "See the :mod:`warnings` module for more details." msgstr "" +"フリースレッドビルドでは、:data:`~sys.flags.context_aware_warnings` フラグは" +"デフォルトで真です。\n" +"デフォルトの GIL が有効なビルドでは、偽になっています。\n" +"真の場合、:class:`warnings.catch_warnings` コンテキストマネージャは、警告フィ" +"ルタにコンテキスト変数を使います。\n" +"偽の場合、:class:`~warnings.catch_warnings` はグローバルなフィルタのリストを" +"変更するため、スレッドセーフではありません。\n" +"詳しくは :mod:`warnings` モジュールを参照してください。" -#: ../../howto/free-threading-python.rst:168 msgid "Increased memory usage" -msgstr "" +msgstr "メモリ使用量の増加" -#: ../../howto/free-threading-python.rst:170 msgid "" "The free-threaded build will typically use more memory compared to the " "default build. There are multiple reasons for this, mostly due to design " "decisions." msgstr "" +"フリースレッドビルドは、通常、デフォルトのビルドより多くのメモリを使いま" +"す。\n" +"理由はいくつかあり、その多くは設計上の判断によるものです。" -#: ../../howto/free-threading-python.rst:175 msgid "All interned strings are immortal" -msgstr "" +msgstr "インターンされた文字列はすべて不死になる" -#: ../../howto/free-threading-python.rst:177 msgid "" "For modern Python versions (since version 2.3), interning a string (e.g. " "with :func:`sys.intern`) does not cause it to become immortal. Instead, if " @@ -287,12 +330,16 @@ msgid "" "any interned string will become immortal, surviving until interpreter " "shutdown." msgstr "" +"Python 2.3 以降では、:func:`sys.intern` などで文字列をインターンしても、不死" +"にはなりません。\n" +"その文字列への最後の参照がなくなると、インターン済み文字列のテーブルから削除" +"されます。\n" +"フリースレッドビルドではこれとは異なり、インターンされた文字列はすべて不死に" +"なり、インタープリタの終了まで生存します。" -#: ../../howto/free-threading-python.rst:185 msgid "Non-GC objects have a larger object header" -msgstr "" +msgstr "GC の対象でないオブジェクトのヘッダが大きくなる" -#: ../../howto/free-threading-python.rst:187 msgid "" "The free-threaded build uses a different :c:type:`PyObject` structure. " "Instead of having the GC related information allocated before the :c:type:" @@ -302,12 +349,17 @@ msgid "" "GC objects (such as dicts and lists) are the same size for both builds since " "the free-threaded build does not use additional space for the GC info." msgstr "" +"フリースレッドビルドは、異なる :c:type:`PyObject` 構造体を使います。\n" +"デフォルトのビルドのように GC 関連の情報を :c:type:`PyObject` 構造体の前に配" +"置するのではなく、通常のオブジェクトヘッダの一部にしています。\n" +"例えば AMD64 プラットフォームでは、``None`` はフリースレッドビルドで 32 バイ" +"ト、デフォルトのビルドでは 16 バイトを使います。\n" +"辞書やリストなど、GC 対象のオブジェクトのサイズは両ビルドで同じです。\n" +"フリースレッドビルドでは、GC 情報のために別の領域を使わないためです。" -#: ../../howto/free-threading-python.rst:197 msgid "QSBR can delay freeing of memory" -msgstr "" +msgstr "QSBR によってメモリの解放が遅れることがある" -#: ../../howto/free-threading-python.rst:199 msgid "" "In order to safely implement lock-free data structures, a safe memory " "reclamation (SMR) scheme is used, known as quiescent state-based reclamation " @@ -321,12 +373,21 @@ msgid "" "the underlying memory allocator may not immediately return that memory to " "the OS and so the resident set size (RSS) of the process might not decrease." msgstr "" +"ロックを使わないデータ構造を安全に実装するため、quiescent state-based " +"reclamation (QSBR) という安全なメモリ回収 (SMR) の方式を使います。\n" +"ロックなしのアクセスを許すデータ構造の領域には QSBR が使われ、メモリはすぐに" +"は解放されず、解放が遅延されます。\n" +"例として、リストオブジェクトや辞書のキーオブジェクトがあります。\n" +"QSBR の実装の詳細は、CPython ソースツリーの ``InternalDocs/qsbr.md`` を参照し" +"てください。\n" +":func:`gc.collect` を実行すると、QSBR によって保持されているメモリはすべて解" +"放されるはずです。\n" +"ただし、QSBR がメモリを解放しても、下位のメモリアロケータがすぐに OS へ返すと" +"は限らず、プロセスの常駐メモリ量 (RSS) が減らない場合があります。" -#: ../../howto/free-threading-python.rst:213 msgid "mimalloc allocator vs pymalloc" -msgstr "" +msgstr "mimalloc と pymalloc の比較" -#: ../../howto/free-threading-python.rst:215 msgid "" "The default build will normally use the \"pymalloc\" memory allocator for " "small allocations (512 bytes or smaller). The free-threaded build does not " @@ -337,8 +398,16 @@ msgid "" "system. The mimalloc allocator does quite well in these respects as well " "but can have some more overhead." msgstr "" +"デフォルトのビルドは通常、512 バイト以下の小さな割り当てに pymalloc メモリア" +"ロケータを使います。\n" +"フリースレッドビルドは pymalloc を使わず、すべての Python オブジェクトを " +"mimalloc で割り当てます。\n" +"pymalloc には、割り当てブロックごとのオーバーヘッドが小さい、メモリの断片化を" +"効果的に防ぐ、未使用メモリを速やかに OS へ返すといった、メモリ使用量を抑える" +"特性があります。\n" +"mimalloc もこれらの点で優れていますが、オーバーヘッドがやや大きい場合がありま" +"す。" -#: ../../howto/free-threading-python.rst:224 msgid "" "In the free-threaded build, mimalloc manages memory in a number of separate " "heaps (currently four). For example, all GC supporting objects are " @@ -350,20 +419,30 @@ msgid "" "blocks for a page being freed and the memory page being released, either for " "new allocations or back to the OS." msgstr "" +"フリースレッドビルドでは、mimalloc は複数の独立したヒープ (現在は 4 つ) でメ" +"モリを管理します。\n" +"例えば、GC に対応するオブジェクトはすべて専用のヒープから割り当てられます。\n" +"ヒープを分けると、あるヒープの空きメモリを別のヒープからの割り当てに使うこと" +"はできません。\n" +"また、一部のヒープでは、ヒープの基盤となるメモリ領域 (mimalloc の用語で「ペー" +"ジ」) の解放に QSBR (quiescent-state based reclamation) を使います。\n" +"そのため、ページ内の全メモリブロックが解放されてから、そのページが新しい割り" +"当てに使えるようになるか OS へ返されるまでに、遅延が生じます。" -#: ../../howto/free-threading-python.rst:234 msgid "" "The mimalloc allocator also defers returning freed memory back to the OS. " "You can reduce that delay by setting the environment variable :envvar:`!" "MIMALLOC_PURGE_DELAY` to ``0``. Note that this will likely reduce the " "performance of the allocator." msgstr "" +"mimalloc も、解放されたメモリを OS に返すまでに遅延を設けています。\n" +":envvar:`!MIMALLOC_PURGE_DELAY` 環境変数を ``0`` に設定すると、この遅延を短く" +"できます。\n" +"ただし、アロケータの性能が低下する可能性が高いことに注意してください。" -#: ../../howto/free-threading-python.rst:241 msgid "Free-threaded reference counting can cause objects to live longer" -msgstr "" +msgstr "フリースレッドの参照カウントではオブジェクトの寿命が延びることがある" -#: ../../howto/free-threading-python.rst:243 msgid "" "In the default build, when an object's reference count reaches zero, it is " "normally deallocated. The free-threaded build uses \"biased reference " @@ -373,36 +452,40 @@ msgid "" "can be deferred. The queued state is cleared from the \"eval breaker\" " "section of the bytecode evaluator." msgstr "" +"デフォルトのビルドでは、通常、参照カウントがゼロになるとオブジェクトが解放さ" +"れます。\n" +"フリースレッドビルドは「バイアス参照カウント」を使い、現在のスレッドが「所有" +"する」オブジェクトには高速な処理経路、それ以外には低速な経路を使います。\n" +"詳しくは :pep:`703` を参照してください。\n" +"参照カウントが queued (キュー待ち) 状態になると、解放が遅延することがありま" +"す。\n" +"キュー待ち状態は、バイトコード評価器の eval breaker 部分で解除されます。" -#: ../../howto/free-threading-python.rst:251 msgid "" "The free-threaded build also allows a different mode of reference counting, " "known as \"deferred reference counting\". This mode is enabled by setting a " "flag on a per-object basis. Deferred reference counting is enabled for the " "following types:" msgstr "" +"フリースレッドビルドでは、「遅延参照カウント」という別の方式も使えます。\n" +"これはオブジェクトごとにフラグを設定して有効にします。\n" +"次の型で遅延参照カウントが有効になっています。" -#: ../../howto/free-threading-python.rst:256 msgid "module objects" -msgstr "" +msgstr "モジュールオブジェクト" -#: ../../howto/free-threading-python.rst:257 msgid "module top-level functions" -msgstr "" +msgstr "モジュールのトップレベルの関数" -#: ../../howto/free-threading-python.rst:258 msgid "class methods defined in the class scope" -msgstr "" +msgstr "クラススコープで定義されたメソッド" -#: ../../howto/free-threading-python.rst:259 msgid "descriptor objects" -msgstr "" +msgstr "デスクリプタオブジェクト" -#: ../../howto/free-threading-python.rst:260 msgid "thread-local objects, created by :class:`threading.local`" -msgstr "" +msgstr ":class:`threading.local` で作られたスレッドローカルオブジェクト" -#: ../../howto/free-threading-python.rst:262 msgid "" "When deferred reference counting is enabled, references from Python function " "stacks are not added to the reference count. This scheme reduces the " @@ -414,12 +497,19 @@ msgid "" "objects are freed by the GC and not when their reference count goes to zero, " "as is typical." msgstr "" +"遅延参照カウントを有効にすると、Python 関数のスタックからの参照は参照カウント" +"に加算されません。\n" +"この方式は、特に複数のスレッドから使われるオブジェクトについて、参照カウント" +"のオーバーヘッドを減らします。\n" +"スタックからの参照を数えないため、内部の参照カウントがゼロになっても、オブ" +"ジェクトはすぐには解放されません。\n" +"代わりに、次回の GC で調べられ、スタックからの参照がなければ解放されます。\n" +"つまり、通常のように参照カウントがゼロになった時点ではなく、GC によって解放さ" +"れます。" -#: ../../howto/free-threading-python.rst:273 msgid "Per-thread reference counting can delay freeing objects" -msgstr "" +msgstr "スレッドごとの参照カウントによってオブジェクトの解放が遅れることがある" -#: ../../howto/free-threading-python.rst:275 msgid "" "To avoid contention on the reference count fields of frequently shared " "objects, the free-threaded build also uses \"per-thread reference counting\" " @@ -429,20 +519,25 @@ msgid "" "only computed by summing the per-thread counts when the object's local count " "drops to zero. Per-thread reference counting is currently used for:" msgstr "" +"頻繁に共有されるオブジェクトの参照カウントフィールドでの競合を避けるため、フ" +"リースレッドビルドは、選ばれた少数の型に「スレッドごとの参照カウント」も使い" +"ます。\n" +"単一の共有参照カウントを更新する代わりに、各スレッドがローカルな参照カウント" +"の配列を持ち、オブジェクトに割り当てられた一意の ID をインデックスとして使い" +"ます。\n" +"実際の参照カウントを計算するのは、オブジェクトのローカルカウントがゼロになっ" +"たときだけで、その際に各スレッドのカウントを合計します。\n" +"現在、この方式を使うのは次のものです。" -#: ../../howto/free-threading-python.rst:283 msgid "heap type objects (classes created in Python)" -msgstr "" +msgstr "ヒープ型オブジェクト (Python で作成したクラス)" -#: ../../howto/free-threading-python.rst:284 msgid "code objects" -msgstr "" +msgstr "コードオブジェクト" -#: ../../howto/free-threading-python.rst:285 msgid "the ``__dict__`` of module objects" -msgstr "" +msgstr "モジュールオブジェクトの ``__dict__``" -#: ../../howto/free-threading-python.rst:287 msgid "" "Because the per-thread counts must be merged back to the object before it " "can be deallocated, objects using per-thread reference counting are " @@ -452,3 +547,11 @@ msgid "" "section of the bytecode evaluator) or exits. Running :func:`gc.collect` " "will merge the per-thread counts and allow these objects to be freed." msgstr "" +"スレッドごとのカウントをオブジェクトに集約してからでなければ解放できないた" +"め、この方式を使うオブジェクトは、通常、デフォルトのビルドより遅く解放されま" +"す。\n" +"特に、そのオブジェクトを参照したスレッドが、バイトコード評価器の eval " +"breaker などの安全な地点に到達するか、終了するまでは、通常は解放されませ" +"ん。\n" +":func:`gc.collect` を実行すると、スレッドごとのカウントが集約され、これらのオ" +"ブジェクトを解放できるようになります。" diff --git a/howto/functional.po b/howto/functional.po index 740c8d547..245e288ae 100644 --- a/howto/functional.po +++ b/howto/functional.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/functional.rst:5 @@ -256,7 +256,6 @@ msgstr "" "そうだ」と言うのとも別の話です; 目指すのは、出現しうる入力すべてに対してプロ" "グラムが正しい結果を出すことの厳密な証明なのです。" -#: ../../howto/functional.rst:110 msgid "" "The technique used to prove programs correct is to write down " "**invariants**, properties of the input data and of the program's variables " @@ -266,12 +265,12 @@ msgid "" "This continues until you reach the end of the program, at which point the " "invariants should match the desired conditions on the program's output." msgstr "" -"プログラムを証明するために使われているのは **不変式** を書き出していくという" -"テクニックで、不変式とは入力データやプログラム変数のうち常に真である性質のこ" -"とです。コードの一行一行で、 **実行前** の不変式 X と Y が真なら **実行後に" -"** ちょっと違う不変式 X' と Y' が真になることを示していき、これをプログラムの" -"終わりまで続けるわけです。すると最終的な不変式はプログラムの出力に合った条件" -"になっているはずです。" +"プログラムの正しさを証明する手法では、入力データやプログラム変数について常に" +"真である性質、つまり **不変条件** を書き出します。\n" +"コードの各行について、**実行前** に不変条件 X と Y が成り立つなら、**実行後" +"** には少し異なる不変条件 X' と Y' が成り立つことを示します。\n" +"これをプログラムの終わりまで続け、最後の不変条件が、出力に求める条件と一致す" +"ることを確認します。" #: ../../howto/functional.rst:118 msgid "" @@ -446,7 +445,6 @@ msgstr "" "るいは :func:`iter` でイテレータを作れるオブジェクトである必要があります。次" "の二つは同じ意味になります::" -#: ../../howto/functional.rst:221 msgid "" "for i in iter(obj):\n" " print(i)\n" @@ -454,6 +452,11 @@ msgid "" "for i in obj:\n" " print(i)" msgstr "" +"for i in iter(obj):\n" +" print(i)\n" +"\n" +"for i in obj:\n" +" print(i)" #: ../../howto/functional.rst:227 msgid "" @@ -528,7 +531,6 @@ msgstr "" "辞書に対して :func:`iter` すると、辞書のキーでループを回すイテレータが返され" "ます::" -#: ../../howto/functional.rst:272 msgid "" ">>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,\n" "... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}\n" @@ -547,6 +549,22 @@ msgid "" "Nov 11\n" "Dec 12" msgstr "" +">>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,\n" +"... 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}\n" +">>> for key in m:\n" +"... print(key, m[key])\n" +"Jan 1\n" +"Feb 2\n" +"Mar 3\n" +"Apr 4\n" +"May 5\n" +"Jun 6\n" +"Jul 7\n" +"Aug 8\n" +"Sep 9\n" +"Oct 10\n" +"Nov 11\n" +"Dec 12" #: ../../howto/functional.rst:289 msgid "" @@ -589,12 +607,14 @@ msgstr "" "ことでイテレータ化に対応しています。つまりこうやってファイルの各行を読んでい" "くことができるわけです::" -#: ../../howto/functional.rst:310 msgid "" "for line in file:\n" " # do something for each line\n" " ..." msgstr "" +"for line in file:\n" +" # 各行について処理する\n" +" ..." #: ../../howto/functional.rst:314 msgid "" @@ -604,7 +624,6 @@ msgstr "" "セットはイテラブルを受け取れますし、そのセットの要素でイテレートすることもで" "きます::" -#: ../../howto/functional.rst:317 msgid "" ">>> S = {2, 3, 5, 7, 11, 13}\n" ">>> for i in S:\n" @@ -616,12 +635,20 @@ msgid "" "11\n" "13" msgstr "" +">>> S = {2, 3, 5, 7, 11, 13}\n" +">>> for i in S:\n" +"... print(i)\n" +"2\n" +"3\n" +"5\n" +"7\n" +"11\n" +"13" #: ../../howto/functional.rst:330 msgid "Generator expressions and list comprehensions" msgstr "ジェネレータ式とリスト内包表記" -#: ../../howto/functional.rst:332 msgid "" "Two common operations on an iterator's output are 1) performing some " "operation for every element, 2) selecting a subset of elements that meet " @@ -629,10 +656,10 @@ msgid "" "strip off trailing whitespace from each line or extract all the strings " "containing a given substring." msgstr "" -"イテレータの出力に対してよく使う操作トップ 2 は、(1) ひとつずつ全要素に操作を" -"実行する、および (2) 条件に合う要素でサブセットを作る、です。たとえば文字列の" -"リストなら、各行のうしろに付いた邪魔なホワイトスペースを削りたいとか、特定の" -"文字列を含む部分をピックアップしたいなどと思うかもしれません。" +"イテレータの出力に対するよくある操作は、1) 各要素に何らかの処理を行うこと、" +"2) 条件に合う要素だけを選ぶことです。\n" +"例えば、文字列のリストがあれば、各行の末尾の空白を取り除いたり、指定した部分" +"文字列を含む文字列をすべて取り出したりする場合があります。" #: ../../howto/functional.rst:338 msgid "" @@ -646,7 +673,6 @@ msgstr "" "(https://www.haskell.org/) にインスパイアされました。文字列のストリームからホ" "ワイトスペースをすべて削るのは次のコードでできます::" -#: ../../howto/functional.rst:343 msgid "" ">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" "\n" @@ -656,17 +682,25 @@ msgid "" ">>> # List comprehension -- returns list\n" ">>> stripped_list = [line.strip() for line in line_list]" msgstr "" +">>> line_list = [' line 1\\n', 'line 2 \\n', ' \\n', '']\n" +"\n" +">>> # ジェネレータ式 -- イテレータを返す\n" +">>> stripped_iter = (line.strip() for line in line_list)\n" +"\n" +">>> # リスト内包表記 -- リストを返す\n" +">>> stripped_list = [line.strip() for line in line_list]" #: ../../howto/functional.rst:351 msgid "" "You can select only certain elements by adding an ``\"if\"`` condition::" msgstr "特定の要素だけを選び出すのは ``\"if\"`` 条件式を付けることで可能です::" -#: ../../howto/functional.rst:353 msgid "" ">>> stripped_list = [line.strip() for line in line_list\n" "... if line != \"\"]" msgstr "" +">>> stripped_list = [line.strip() for line in line_list\n" +"... if line != \"\"]" #: ../../howto/functional.rst:356 msgid "" @@ -694,7 +728,6 @@ msgstr "" "ジェネレータ式は丸括弧 \"()\" で囲まれ、リスト内包表記は角括弧 \"[]\" で囲ま" "れます。ジェネレータ式の形式は次のとおりです::" -#: ../../howto/functional.rst:367 msgid "" "( expression for expr in sequence1\n" " if condition1\n" @@ -706,6 +739,15 @@ msgid "" " for exprN in sequenceN\n" " if conditionN )" msgstr "" +"( expression for expr in sequence1\n" +" if condition1\n" +" for expr2 in sequence2\n" +" if condition2\n" +" for expr3 in sequence3\n" +" if condition3\n" +" ...\n" +" for exprN in sequenceN\n" +" if conditionN )" #: ../../howto/functional.rst:377 msgid "" @@ -736,9 +778,8 @@ msgstr "" "なっている括弧でも大丈夫です。関数にすぐ渡すイテレータを作りたければこう書け" "るのです::" -#: ../../howto/functional.rst:388 msgid "obj_total = sum(obj.count for obj in list_all_objects())" -msgstr "" +msgstr "obj_total = sum(obj.count for obj in list_all_objects())" #: ../../howto/functional.rst:390 msgid "" @@ -764,7 +805,6 @@ msgstr "" "別の書き方をすると、リスト内包表記やジェネレータ式は次の Python コードと同じ" "意味になります::" -#: ../../howto/functional.rst:399 msgid "" "for expr1 in sequence1:\n" " if not (condition1):\n" @@ -780,6 +820,19 @@ msgid "" " # Output the value of\n" " # the expression." msgstr "" +"for expr1 in sequence1:\n" +" if not (condition1):\n" +" continue # この要素を読み飛ばす\n" +" for expr2 in sequence2:\n" +" if not (condition2):\n" +" continue # この要素を読み飛ばす\n" +" ...\n" +" for exprN in sequenceN:\n" +" if not (conditionN):\n" +" continue # この要素を読み飛ばす\n" +"\n" +" # 式の値を\n" +" # 出力する。" #: ../../howto/functional.rst:413 msgid "" @@ -802,13 +855,16 @@ msgstr "" "ら括弧で囲わなくてはなりません。下にあるリスト内包表記で、最初のは構文エラー" "ですが、二番目は有効です::" -#: ../../howto/functional.rst:429 msgid "" "# Syntax error\n" "[x, y for x in seq1 for y in seq2]\n" "# Correct\n" "[(x, y) for x in seq1 for y in seq2]" msgstr "" +"# 構文エラー\n" +"[x, y for x in seq1 for y in seq2]\n" +"# 正しい書き方\n" +"[(x, y) for x in seq1 for y in seq2]" #: ../../howto/functional.rst:436 msgid "Generators" @@ -859,7 +915,6 @@ msgstr "" "の :term:`bytecode` コンパイラがこれを検出して、特別な方法でコンパイルしてく" "れるのです。" -#: ../../howto/functional.rst:461 msgid "" "When you call a generator function, it doesn't return a single value; " "instead it returns a generator object that supports the iterator protocol. " @@ -870,12 +925,14 @@ msgid "" "preserved. On the next call to the generator's :meth:`~generator.__next__` " "method, the function will resume executing." msgstr "" -"ジェネレータ関数は、呼ばれたときに一回だけ値を返すのではなく、イテレータ プロ" -"トコルに対応したオブジェクトを返します。上の例で ``yield`` を実行したとき、 " -"ジェネレータは ``return`` 文のようにして ``i`` の値を出力します。 ``yield`` " -"と ``return`` 文の大きな違いは、 ``yield`` に到達した段階でジェネレータの実行" -"状態が一時停止になって、ローカル変数が保存される点です。 次回そのジェネレータ" -"の :meth:`~generator.__next__` を呼ぶと、そこから関数が実行を再開します。" +"ジェネレータ関数を呼ぶと、計算結果の値ではなく、イテレータプロトコルに対応す" +"るジェネレータオブジェクトが返されます。\n" +"ジェネレータが ``yield`` 式を実行すると、``return`` 文と同じように ``i`` の値" +"を出力します。\n" +"大きな違いは、``yield`` に到達すると実行が中断され、ローカル変数が保持される" +"点です。\n" +"次にジェネレータの :meth:`~generator.__next__` メソッドを呼ぶと、関数の実行が" +"再開されます。" #: ../../howto/functional.rst:470 msgid "Here's a sample usage of the ``generate_ints()`` generator:" @@ -982,9 +1039,8 @@ msgstr "" "Python 2.5 で、ジェネレータに値を渡す簡単な手段ができました。 :keyword:" "`yield` が、変数に代入したり演算したりできる値を返す式になったのです::" -#: ../../howto/functional.rst:540 msgid "val = (yield i)" -msgstr "" +msgstr "val = (yield i)" #: ../../howto/functional.rst:542 msgid "" @@ -1030,7 +1086,6 @@ msgstr "" "下にあるのは 1 ずつ増える単純なカウンタですが、内部カウンタの値を変更すること" "ができるようになっています。" -#: ../../howto/functional.rst:561 msgid "" "def counter(maximum):\n" " i = 0\n" @@ -1042,6 +1097,15 @@ msgid "" " else:\n" " i += 1" msgstr "" +"def counter(maximum):\n" +" i = 0\n" +" while i < maximum:\n" +" val = (yield i)\n" +" # 値が渡されたら、カウンタを変更する\n" +" if val is not None:\n" +" i = val\n" +" else:\n" +" i += 1" #: ../../howto/functional.rst:573 msgid "And here's an example of changing the counter:" @@ -1087,15 +1151,14 @@ msgid "" "collected." msgstr "" -#: ../../howto/functional.rst:610 msgid "" "If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I " "suggest using a ``try: ... finally:`` suite instead of catching :exc:" "`GeneratorExit`." msgstr "" -":exc:`GeneratorExit` が起こったときにクリーンアップ作業をする必要があるな" -"ら、 :exc:`GeneratorExit` を捕捉するのではなく ``try: ... finaly:`` するよう" -"お勧めします。" +":exc:`GeneratorExit` が発生したときに後片付けを行う必要がある場合は、:exc:" +"`GeneratorExit` を捕捉するのではなく、``try: ... finally:`` を使うことを勧め" +"ます。" #: ../../howto/functional.rst:613 msgid "" @@ -1181,7 +1244,6 @@ msgstr "" "振っていき、(*start* から数え始めたときの) 番号とそれぞれの要素を含む 2 タプ" "ルを返します。" -#: ../../howto/functional.rst:666 msgid "" ">>> for item in enumerate(['subject', 'verb', 'object']):\n" "... print(item)\n" @@ -1189,22 +1251,29 @@ msgid "" "(1, 'verb')\n" "(2, 'object')" msgstr "" +">>> for item in enumerate(['subject', 'verb', 'object']):\n" +"... print(item)\n" +"(0, 'subject')\n" +"(1, 'verb')\n" +"(2, 'object')" -#: ../../howto/functional.rst:672 msgid "" ":func:`enumerate` is often used when looping through a list and recording " "the indexes at which certain conditions are met::" msgstr "" -":func:`enumerate` はよく、リストに対してループさせて、条件に合う所に印を付け" -"ていくときに使われます::" +":func:`enumerate` は、リストをループで処理し、条件を満たす位置のインデックス" +"を記録するときによく使われます。 ::" -#: ../../howto/functional.rst:675 msgid "" "f = open('data.txt', 'r')\n" "for i, line in enumerate(f):\n" " if line.strip() == '':\n" " print('Blank line at line #%i' % i)" msgstr "" +"f = open('data.txt', 'r')\n" +"for i, line in enumerate(f):\n" +" if line.strip() == '':\n" +" print('Blank line at line #%i' % i)" #: ../../howto/functional.rst:680 msgid "" @@ -1217,7 +1286,6 @@ msgstr "" "をすべて集めたリストを作り、ソートして返します。 引数 *key* および *reverse* " "は、リストの :meth:`~list.sort` メソッドにそのまま渡されます。 ::" -#: ../../howto/functional.rst:685 msgid "" ">>> import random\n" ">>> # Generate 8 random numbers between [0, 10000)\n" @@ -1229,6 +1297,15 @@ msgid "" ">>> sorted(rand_list, reverse=True)\n" "[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" msgstr "" +">>> import random\n" +">>> # 0 以上 10000 未満の乱数を 8 個生成する\n" +">>> rand_list = random.sample(range(10000), 8)\n" +">>> rand_list\n" +"[769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]\n" +">>> sorted(rand_list)\n" +"[769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]\n" +">>> sorted(rand_list, reverse=True)\n" +"[9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]" #: ../../howto/functional.rst:695 msgid "" @@ -1254,19 +1331,24 @@ msgstr "" ":func:`zip(iterA, iterB, ...) ` はそれぞれの iterable から1つの要素を取" "り、それらをタプルに入れて返します::" -#: ../../howto/functional.rst:720 msgid "" "zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2), ('c', 3)" msgstr "" +"zip(['a', 'b', 'c'], (1, 2, 3)) =>\n" +" ('a', 1), ('b', 2), ('c', 3)" -#: ../../howto/functional.rst:723 msgid "" "It doesn't construct an in-memory list and :term:`exhaust ` all " "the input iterators before returning; instead tuples are constructed and " "returned only if they're requested. (The technical term for this behaviour " "is `lazy evaluation `__.)" msgstr "" +"メモリ上にリストを作り、すべての入力イテレータを :term:`使い切って " +"` から戻るのではありません。\n" +"タプルは要求されたときにだけ作られて返されます。\n" +"この動作は専門用語で `遅延評価 `__ と呼ばれます。" #: ../../howto/functional.rst:729 msgid "" @@ -1278,11 +1360,12 @@ msgstr "" "違っていれば、出力されるストリームは一番短いイテラブルと同じ長さになりま" "す。 ::" -#: ../../howto/functional.rst:733 msgid "" "zip(['a', 'b'], (1, 2, 3)) =>\n" " ('a', 1), ('b', 2)" msgstr "" +"zip(['a', 'b'], (1, 2, 3)) =>\n" +" ('a', 1), ('b', 2)" #: ../../howto/functional.rst:736 msgid "" @@ -1345,7 +1428,6 @@ msgstr "" "オプションで開始する数 (デフォルトは 0) や数どうしの間隔 (デフォルトは 1) を" "与えられます::" -#: ../../howto/functional.rst:762 msgid "" "itertools.count() =>\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" @@ -1354,6 +1436,12 @@ msgid "" "itertools.count(10, 5) =>\n" " 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ..." msgstr "" +"itertools.count() =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" +"itertools.count(10) =>\n" +" 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" +"itertools.count(10, 5) =>\n" +" 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ..." #: ../../howto/functional.rst:769 msgid "" @@ -1366,11 +1454,12 @@ msgstr "" "をコピーして、 その要素を最初から最後まで無限に繰り返していくイテレータを返し" "ます。 ::" -#: ../../howto/functional.rst:773 msgid "" "itertools.cycle([1, 2, 3, 4, 5]) =>\n" " 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." msgstr "" +"itertools.cycle([1, 2, 3, 4, 5]) =>\n" +" 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ..." #: ../../howto/functional.rst:776 msgid "" @@ -1381,27 +1470,34 @@ msgstr "" ":func:`itertools.repeat(elem, [n]) ` は、与えられた要素を " "*n* 回返しますが、 *n* がなければ永遠に返し続けます。 ::" -#: ../../howto/functional.rst:779 msgid "" "itertools.repeat('abc') =>\n" " abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...\n" "itertools.repeat('abc', 5) =>\n" " abc, abc, abc, abc, abc" msgstr "" +"itertools.repeat('abc') =>\n" +" abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...\n" +"itertools.repeat('abc', 5) =>\n" +" abc, abc, abc, abc, abc" -#: ../../howto/functional.rst:784 msgid "" ":func:`itertools.chain(iterA, iterB, ...) ` takes an " "arbitrary number of iterables as input, and returns all the elements of the " "first iterator, then all the elements of the second, and so on, until all of " "the iterables have been :term:`exhausted`. ::" msgstr "" +":func:`itertools.chain(iterA, iterB, ...) ` は任意の数のイテ" +"ラブルを受け取ります。\n" +"最初のイテレータの全要素、次に 2 番目のイテレータの全要素という順で、すべての" +"イテラブルが :term:`exhausted` になるまで返します。 ::" -#: ../../howto/functional.rst:789 msgid "" "itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" " a, b, c, 1, 2, 3" msgstr "" +"itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>\n" +" a, b, c, 1, 2, 3" #: ../../howto/functional.rst:792 msgid "" @@ -1420,7 +1516,6 @@ msgstr "" "トのスライスとは違って、マイナスの値は *start*, *stop*, *step* に使えませ" "ん。 ::" -#: ../../howto/functional.rst:799 msgid "" "itertools.islice(range(10), 8) =>\n" " 0, 1, 2, 3, 4, 5, 6, 7\n" @@ -1429,6 +1524,12 @@ msgid "" "itertools.islice(range(10), 2, 8, 2) =>\n" " 2, 4, 6" msgstr "" +"itertools.islice(range(10), 8) =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7\n" +"itertools.islice(range(10), 2, 8) =>\n" +" 2, 3, 4, 5, 6, 7\n" +"itertools.islice(range(10), 2, 8, 2) =>\n" +" 2, 4, 6" #: ../../howto/functional.rst:806 msgid "" @@ -1446,7 +1547,6 @@ msgstr "" "たうちの一つが他よりも進んでいってしまうと、大量のメモリを消費することがあり" "ます。 ::" -#: ../../howto/functional.rst:814 msgid "" "itertools.tee( itertools.count() ) =>\n" " iterA, iterB\n" @@ -1457,6 +1557,14 @@ msgid "" "and iterB ->\n" " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..." msgstr "" +"itertools.tee( itertools.count() ) =>\n" +" iterA, iterB\n" +"\n" +"ここで iterA ->\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...\n" +"\n" +"また iterB ->\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ..." #: ../../howto/functional.rst:825 msgid "Calling functions on elements" @@ -1486,7 +1594,6 @@ msgstr "" "プルのストリームを返すとみなして、 そのタプルを引数に使って *func* を呼びま" "す::" -#: ../../howto/functional.rst:837 msgid "" "itertools.starmap(os.path.join,\n" " [('/bin', 'python'), ('/usr', 'bin', 'java'),\n" @@ -1494,6 +1601,11 @@ msgid "" "=>\n" " /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby" msgstr "" +"itertools.starmap(os.path.join,\n" +" [('/bin', 'python'), ('/usr', 'bin', 'java'),\n" +" ('/usr', 'bin', 'perl'), ('/usr', 'bin', 'ruby')])\n" +"=>\n" +" /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby" #: ../../howto/functional.rst:845 msgid "Selecting elements" @@ -1516,11 +1628,12 @@ msgstr "" ":func:`itertools.filterfalse(predicate, iter) ` は :" "func:`filter` とは反対に、 述語が偽を返す要素をすべて返します::" -#: ../../howto/functional.rst:854 msgid "" "itertools.filterfalse(is_even, itertools.count()) =>\n" " 1, 3, 5, 7, 9, 11, 13, 15, ..." msgstr "" +"itertools.filterfalse(is_even, itertools.count()) =>\n" +" 1, 3, 5, 7, 9, 11, 13, 15, ..." #: ../../howto/functional.rst:857 msgid "" @@ -1532,7 +1645,6 @@ msgstr "" "を返している間だけ要素を返します。一度でも述語が偽を返すと、イテレータは出力" "終了の合図をします。 ::" -#: ../../howto/functional.rst:861 msgid "" "def less_than_10(x):\n" " return x < 10\n" @@ -1543,6 +1655,14 @@ msgid "" "itertools.takewhile(is_even, itertools.count()) =>\n" " 0" msgstr "" +"def less_than_10(x):\n" +" return x < 10\n" +"\n" +"itertools.takewhile(less_than_10, itertools.count()) =>\n" +" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n" +"\n" +"itertools.takewhile(is_even, itertools.count()) =>\n" +" 0" #: ../../howto/functional.rst:870 msgid "" @@ -1554,7 +1674,6 @@ msgstr "" "真を返しているうちは要素を無視し、偽になってから残りの出力をすべて返しま" "す。 ::" -#: ../../howto/functional.rst:874 msgid "" "itertools.dropwhile(less_than_10, itertools.count()) =>\n" " 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" @@ -1562,36 +1681,43 @@ msgid "" "itertools.dropwhile(is_even, itertools.count()) =>\n" " 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..." msgstr "" +"itertools.dropwhile(less_than_10, itertools.count()) =>\n" +" 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...\n" +"\n" +"itertools.dropwhile(is_even, itertools.count()) =>\n" +" 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..." -#: ../../howto/functional.rst:880 msgid "" ":func:`itertools.compress(data, selectors) ` takes two " "iterators and returns only those elements of *data* for which the " "corresponding element of *selectors* is true, stopping whenever either one " "is :term:`exhausted`::" msgstr "" +":func:`itertools.compress(data, selectors) ` は 2 つのイ" +"テレータを受け取り、*selectors* の対応する要素が真になる *data* の要素だけを" +"返します。\n" +"どちらか一方が :term:`exhausted` になると終了します。 ::" -#: ../../howto/functional.rst:884 msgid "" "itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" " 1, 2, 5" msgstr "" +"itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>\n" +" 1, 2, 5" #: ../../howto/functional.rst:889 msgid "Combinatoric functions" msgstr "組合せ関数" -#: ../../howto/functional.rst:891 msgid "" "The :func:`itertools.combinations(iterable, r) ` " "returns an iterator giving all possible *r*-tuple combinations of the " "elements contained in *iterable*. ::" msgstr "" -":func:`itertools.combinations(iterable, r) ` は、 " -"*iterable* から *r*-tuple 選択する全ての組み合わせを提供するイテレータを返し" -"ます ::" +":func:`itertools.combinations(iterable, r) ` は、" +"*iterable* 内の要素から *r* 個を選ぶすべての組み合わせを、タプルとして返すイ" +"テレータを作ります。 ::" -#: ../../howto/functional.rst:895 msgid "" "itertools.combinations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1604,6 +1730,16 @@ msgid "" " (2, 3, 4), (2, 3, 5), (2, 4, 5),\n" " (3, 4, 5)" msgstr "" +"itertools.combinations([1, 2, 3, 4, 5], 2) =>\n" +" (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 3), (2, 4), (2, 5),\n" +" (3, 4), (3, 5),\n" +" (4, 5)\n" +"\n" +"itertools.combinations([1, 2, 3, 4, 5], 3) =>\n" +" (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5), (1, 4, 5),\n" +" (2, 3, 4), (2, 3, 5), (2, 4, 5),\n" +" (3, 4, 5)" #: ../../howto/functional.rst:906 msgid "" @@ -1619,7 +1755,6 @@ msgstr "" "permutations>` があり、こちらはこの順序についての制約がなく、 *r* 個選択する" "全ての順列を返します。" -#: ../../howto/functional.rst:913 msgid "" "itertools.permutations([1, 2, 3, 4, 5], 2) =>\n" " (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1633,6 +1768,17 @@ msgid "" " ...\n" " (5, 4, 3, 2, 1)" msgstr "" +"itertools.permutations([1, 2, 3, 4, 5], 2) =>\n" +" (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 1), (2, 3), (2, 4), (2, 5),\n" +" (3, 1), (3, 2), (3, 4), (3, 5),\n" +" (4, 1), (4, 2), (4, 3), (4, 5),\n" +" (5, 1), (5, 2), (5, 3), (5, 4)\n" +"\n" +"itertools.permutations([1, 2, 3, 4, 5]) =>\n" +" (1, 2, 3, 4, 5), (1, 2, 3, 5, 4), (1, 2, 4, 3, 5),\n" +" ...\n" +" (5, 4, 3, 2, 1)" #: ../../howto/functional.rst:925 msgid "" @@ -1650,12 +1796,14 @@ msgstr "" "これらの関数が生成する組み合わせは、位置が基準ですので、 *iterable* の内容が" "一意でなくとも良いことに注目してください::" -#: ../../howto/functional.rst:931 msgid "" "itertools.permutations('aba', 3) =>\n" " ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" " ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')" msgstr "" +"itertools.permutations('aba', 3) =>\n" +" ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),\n" +" ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')" #: ../../howto/functional.rst:935 msgid "" @@ -1665,7 +1813,6 @@ msgstr "" "全く同じタプル ``('a', 'a', 'b')`` が 2度現れていますが、これは 2つの 'a' が" "別の位置からのものだからです。" -#: ../../howto/functional.rst:938 msgid "" "The :func:`itertools.combinations_with_replacement(iterable, r) ` function relaxes a different constraint: " @@ -1674,11 +1821,11 @@ msgid "" "the second element is selected. ::" msgstr "" ":func:`itertools.combinations_with_replacement(iterable, r) ` 関数は別の制約を取り払います: 一回の選択で同" -"じ要素を繰り返し選んでも良い。概念的には、それぞれのタプルの最初のものとして" -"一つ要素が選ばれ、続いて 2つ目の選択のかわりにそれで置き換わります ::" +"combinations_with_replacement>` は、別の制約を緩めます。\n" +"同じタプル内で要素の重複を許すのです。\n" +"概念的には、タプルの最初の位置に入れる要素を 1 つ選び、それを選択元に戻してか" +"ら 2 つ目を選びます。 ::" -#: ../../howto/functional.rst:944 msgid "" "itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>\n" " (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),\n" @@ -1687,6 +1834,12 @@ msgid "" " (4, 4), (4, 5),\n" " (5, 5)" msgstr "" +"itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>\n" +" (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),\n" +" (2, 2), (2, 3), (2, 4), (2, 5),\n" +" (3, 3), (3, 4), (3, 5),\n" +" (4, 4), (4, 5),\n" +" (5, 5)" #: ../../howto/functional.rst:953 msgid "Grouping elements" @@ -1715,7 +1868,6 @@ msgstr "" "要素を集めて、キー値とそのキーに対応する要素のイテレータの 2-タプルのストリー" "ムを返します。" -#: ../../howto/functional.rst:966 msgid "" "city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),\n" " ('Anchorage', 'AK'), ('Nome', 'AK'),\n" @@ -1739,6 +1891,27 @@ msgid "" "iterator-3 =>\n" " ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')" msgstr "" +"city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),\n" +" ('Anchorage', 'AK'), ('Nome', 'AK'),\n" +" ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'),\n" +" ...\n" +" ]\n" +"\n" +"def get_state(city_state):\n" +" return city_state[1]\n" +"\n" +"itertools.groupby(city_list, get_state) =>\n" +" ('AL', iterator-1),\n" +" ('AK', iterator-2),\n" +" ('AZ', iterator-3), ...\n" +"\n" +"ここで\n" +"iterator-1 =>\n" +" ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL')\n" +"iterator-2 =>\n" +" ('Anchorage', 'AK'), ('Nome', 'AK')\n" +"iterator-3 =>\n" +" ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')" #: ../../howto/functional.rst:988 msgid "" @@ -1798,7 +1971,6 @@ msgstr "" msgid "Here's a small but realistic example::" msgstr "以下にあるのは、小さいけれども現実的な一つの例です::" -#: ../../howto/functional.rst:1015 msgid "" "import functools\n" "\n" @@ -1810,8 +1982,16 @@ msgid "" "server_log = functools.partial(log, subsystem='server')\n" "server_log('Unable to open socket')" msgstr "" +"import functools\n" +"\n" +"def log(message, subsystem):\n" +" \"\"\"'message' の内容を指定されたサブシステムに書き込む。\"\"\"\n" +" print('%s: %s' % (subsystem, message))\n" +" ...\n" +"\n" +"server_log = functools.partial(log, subsystem='server')\n" +"server_log('Unable to open socket')" -#: ../../howto/functional.rst:1025 msgid "" ":func:`functools.reduce(func, iter, [initial_value]) ` " "cumulatively performs an operation on all the iterable's elements and, " @@ -1825,8 +2005,20 @@ msgid "" "raised. If the initial value is supplied, it's used as a starting point and " "``func(initial_value, A)`` is the first calculation. ::" msgstr "" +":func:`functools.reduce(func, iter, [initial_value]) ` は、" +"イテラブルの全要素に累積的に演算を適用するため、無限のイテラブルには使えませ" +"ん。\n" +"*func* は 2 つの要素を受け取り、1 つの値を返す関数でなければなりません。\n" +":func:`functools.reduce` は、イテレータが返す最初の 2 要素 A と B から " +"``func(A, B)`` を計算します。\n" +"次に 3 番目の要素 C を取得して ``func(func(A, B), C)`` を計算し、その結果と " +"4 番目の要素に演算を適用するという処理を、イテラブルが :term:`exhausted` にな" +"るまで続けます。\n" +"初期値がなく、イテラブルが何も値を返さない場合は、:exc:`TypeError` が送出され" +"ます。\n" +"初期値を指定した場合は、それを出発点にして、最初に ``func(initial_value, " +"A)`` を計算します。 ::" -#: ../../howto/functional.rst:1037 msgid "" ">>> import operator, functools\n" ">>> functools.reduce(operator.concat, ['A', 'BB', 'C'])\n" @@ -1840,6 +2032,17 @@ msgid "" ">>> functools.reduce(operator.mul, [], 1)\n" "1" msgstr "" +">>> import operator, functools\n" +">>> functools.reduce(operator.concat, ['A', 'BB', 'C'])\n" +"'ABBC'\n" +">>> functools.reduce(operator.concat, [])\n" +"Traceback (most recent call last):\n" +" ...\n" +"TypeError: reduce() of empty iterable with no initial value\n" +">>> functools.reduce(operator.mul, [1, 2, 3], 1)\n" +"6\n" +">>> functools.reduce(operator.mul, [], 1)\n" +"1" #: ../../howto/functional.rst:1049 msgid "" @@ -1859,7 +2062,6 @@ msgstr "" "とはいえ、多くの場合 :func:`functools.reduce` を使うよりは、単に :keyword:" "`for` ループを書いたほうがわかりやすくなります::" -#: ../../howto/functional.rst:1064 msgid "" "import functools\n" "# Instead of:\n" @@ -1870,20 +2072,26 @@ msgid "" "for i in [1, 2, 3]:\n" " product *= i" msgstr "" +"import functools\n" +"# 次の代わりに:\n" +"product = functools.reduce(operator.mul, [1, 2, 3], 1)\n" +"\n" +"# こう書ける:\n" +"product = 1\n" +"for i in [1, 2, 3]:\n" +" product *= i" -#: ../../howto/functional.rst:1073 msgid "" "A related function is :func:`itertools.accumulate(iterable, func=operator." "add) `. It performs the same calculation, but instead " "of returning only the final result, :func:`~itertools.accumulate` returns an " "iterator that also yields each partial result::" msgstr "" -"関連する関数は :func:`itertools.accumulate(iterable, func=operator.add) " -"` です。この関数は同じ計算をしますが、最終結果を返すの" -"ではなく、 :func:`~itertools.accumulate` はそれぞれの中間結果を生成するイテ" -"レータが返り値となります。" +"関連する関数に :func:`itertools.accumulate(iterable, func=operator.add) " +"` があります。\n" +"同じ計算を行いますが、:func:`~itertools.accumulate` は最終結果だけを返すので" +"はなく、途中の結果も順に生成するイテレータを返します。 ::" -#: ../../howto/functional.rst:1078 msgid "" "itertools.accumulate([1, 2, 3, 4, 5]) =>\n" " 1, 3, 6, 10, 15\n" @@ -1891,6 +2099,11 @@ msgid "" "itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>\n" " 1, 2, 6, 24, 120" msgstr "" +"itertools.accumulate([1, 2, 3, 4, 5]) =>\n" +" 1, 3, 6, 10, 15\n" +"\n" +"itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>\n" +" 1, 2, 6, 24, 120" #: ../../howto/functional.rst:1086 msgid "The operator module" @@ -1959,11 +2172,12 @@ msgstr "" "ちょうど良い関数がビルトインやモジュールで存在していれば、新しい関数を定義す" "る必要はまったくありません::" -#: ../../howto/functional.rst:1113 msgid "" "stripped_lines = [line.strip() for line in lines]\n" "existing_files = filter(os.path.exists, file_list)" msgstr "" +"stripped_lines = [line.strip() for line in lines]\n" +"existing_files = filter(os.path.exists, file_list)" #: ../../howto/functional.rst:1116 msgid "" @@ -1977,12 +2191,14 @@ msgstr "" "の 一つが :keyword:`lambda` 式です。 ``lambda`` は引数として複数のパラメータ" "と それをつなぐ式を取り、その式の値を返す無名の関数を作ります::" -#: ../../howto/functional.rst:1121 msgid "" "adder = lambda x, y: x+y\n" "\n" "print_assign = lambda name, value: name + '=' + str(value)" msgstr "" +"adder = lambda x, y: x+y\n" +"\n" +"print_assign = lambda name, value: name + '=' + str(value)" #: ../../howto/functional.rst:1125 msgid "" @@ -1990,7 +2206,6 @@ msgid "" "the usual way::" msgstr "もう一つの選択肢は、ふつうに ``def`` 文で関数を定義するだけです::" -#: ../../howto/functional.rst:1128 msgid "" "def adder(x, y):\n" " return x + y\n" @@ -1998,6 +2213,11 @@ msgid "" "def print_assign(name, value):\n" " return name + '=' + str(value)" msgstr "" +"def adder(x, y):\n" +" return x + y\n" +"\n" +"def print_assign(name, value):\n" +" return name + '=' + str(value)" #: ../../howto/functional.rst:1134 msgid "" @@ -2023,11 +2243,12 @@ msgstr "" "ちゃして読みにくい式になってしまいます。さて、次のコードは何をしているでしょ" "うか、素早くお答えください! ::" -#: ../../howto/functional.rst:1144 msgid "" "import functools\n" "total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" msgstr "" +"import functools\n" +"total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]" #: ../../howto/functional.rst:1147 msgid "" @@ -2038,7 +2259,6 @@ msgstr "" "わかるにはわかるでしょうが、何がどうなっているのか紐解いていくには時間がかか" "るはずです。短い ``def`` 文で入れ子にすると、少し見通しが良くなりますが::" -#: ../../howto/functional.rst:1151 msgid "" "import functools\n" "def combine(a, b):\n" @@ -2046,25 +2266,31 @@ msgid "" "\n" "total = functools.reduce(combine, items)[1]" msgstr "" +"import functools\n" +"def combine(a, b):\n" +" return 0, a[1] + b[1]\n" +"\n" +"total = functools.reduce(combine, items)[1]" #: ../../howto/functional.rst:1157 msgid "But it would be best of all if I had simply used a ``for`` loop::" msgstr "でも単純に ``for`` ループにすれば良かったのです::" -#: ../../howto/functional.rst:1159 msgid "" "total = 0\n" "for a, b in items:\n" " total += b" msgstr "" +"total = 0\n" +"for a, b in items:\n" +" total += b" #: ../../howto/functional.rst:1163 msgid "Or the :func:`sum` built-in and a generator expression::" msgstr "あるいは :func:`sum` ビルトインとジェネレータ式でも良いですね::" -#: ../../howto/functional.rst:1165 msgid "total = sum(b for a, b in items)" -msgstr "" +msgstr "total = sum(b for a, b in items)" #: ../../howto/functional.rst:1167 msgid "" @@ -2116,7 +2342,6 @@ msgstr "" msgid "Revision History and Acknowledgements" msgstr "更新履歴と謝辞" -#: ../../howto/functional.rst:1186 msgid "" "This HOWTO was originally written by A. M. Kuchling. The author would like " "to thank the following people for offering suggestions, corrections and " @@ -2124,36 +2349,38 @@ msgid "" "Nick Efford, Raymond Hettinger, Jim Jewett, Mike Krell, Leandro Lameiro, " "Jussi Salmela, Collin Winter, Blake Winton." msgstr "" +"この HOWTO は、もともと A. M. Kuchling が執筆しました。\n" +"著者は、さまざまな草稿に提案、訂正、協力を寄せてくださった次の方々に感謝しま" +"す: Ian Bicking、Nick Coghlan、Nick Efford、Raymond Hettinger、Jim Jewett、" +"Mike Krell、Leandro Lameiro、Jussi Salmela、Collin Winter、Blake Winton。" -#: ../../howto/functional.rst:1192 msgid "Version 0.1: posted June 30 2006." -msgstr "Version 0.1: posted June 30 2006." +msgstr "バージョン 0.1: 2006 年 6 月 30 日公開。" -#: ../../howto/functional.rst:1194 msgid "Version 0.11: posted July 1 2006. Typo fixes." -msgstr "Version 0.11: posted July 1 2006. Typo fixes." +msgstr "" +"バージョン 0.11: 2006 年 7 月 1 日公開。\n" +"誤記を修正。" -#: ../../howto/functional.rst:1196 msgid "" "Version 0.2: posted July 10 2006. Merged genexp and listcomp sections into " "one. Typo fixes." msgstr "" -"Version 0.2: posted July 10 2006. Merged genexp and listcomp sections into " -"one. Typo fixes." +"バージョン 0.2: 2006 年 7 月 10 日公開。\n" +"ジェネレータ式とリスト内包表記の節を統合。\n" +"誤記を修正。" -#: ../../howto/functional.rst:1199 msgid "" "Version 0.21: Added more references suggested on the tutor mailing list." -msgstr "" -"Version 0.21: Added more references suggested on the tutor mailing list." +msgstr "バージョン 0.21: tutor メーリングリストで提案された参考資料を追加。" -#: ../../howto/functional.rst:1201 msgid "" "Version 0.30: Adds a section on the ``functional`` module written by Collin " "Winter; adds short section on the operator module; a few other edits." msgstr "" -"Version 0.30: Adds a section on the ``functional`` module written by Collin " -"Winter; adds short section on the operator module; a few other edits." +"バージョン 0.30: Collin Winter による ``functional`` モジュールの節を追加。\n" +"operator モジュールの短い節を追加。\n" +"ほかにもいくつか修正。" #: ../../howto/functional.rst:1206 msgid "References" @@ -2180,12 +2407,13 @@ msgstr "" "使っていますが、これらの章で説明されている設計アプローチの多くは、関数型スタ" "イルの Python コードにも適用できます。" -#: ../../howto/functional.rst:1219 msgid "" "https://defmacro.org/2006/06/19/fp.html: A general introduction to " "functional programming that uses Java examples and has a lengthy historical " "introduction." msgstr "" +"https://defmacro.org/2006/06/19/fp.html: Java の例を使った関数型プログラミン" +"グの入門記事で、歴史的背景も詳しく紹介しています。" #: ../../howto/functional.rst:1222 msgid "" @@ -2216,19 +2444,17 @@ msgstr "https://en.wikipedia.org/wiki/Currying: カリー化の概念に関す msgid "Python-specific" msgstr "Python 特有の話" -#: ../../howto/functional.rst:1234 msgid "" "https://gnosis.cx/TPiP/: The first chapter of David Mertz's book :title-" "reference:`Text Processing in Python` discusses functional programming for " "text processing, in the section titled \"Utilizing Higher-Order Functions in " "Text Processing\"." msgstr "" -"https://gnosis.cx/TPiP/: David Mertz's の本の最初の章 :title-reference:`Text " -"Processing in Python` では文書処理のための関数プログラミングについて議論して" -"います、この議論の節には \"Utilizing Higher-Order Functions in Text " -"Processing\" というタイトルがついています。" +"https://gnosis.cx/TPiP/: David Mertz 著 :title-reference:`Text Processing in " +"Python` の第 1 章では、\"Utilizing Higher-Order Functions in Text " +"Processing\" という節で、テキスト処理のための関数型プログラミングを扱っていま" +"す。" -#: ../../howto/functional.rst:1239 msgid "" "Mertz also wrote a 3-part series of articles on functional programming for " "IBM's DeveloperWorks site; see `part 1 `__, and `part 3 `__." msgstr "" +"Mertz は IBM の DeveloperWorks サイト向けに、関数型プログラミングの全 3 回の" +"記事も書いています。\n" +"`第 1 回 `__、`第 2 回 `__、`第 3 " +"回 `__ を参照してください。" #: ../../howto/functional.rst:1247 msgid "Python documentation" @@ -2258,10 +2491,9 @@ msgstr ":mod:`operator` モジュールの文書。" msgid ":pep:`289`: \"Generator Expressions\"" msgstr ":pep:`289`: \"Generator Expressions\"" -#: ../../howto/functional.rst:1257 msgid "" ":pep:`342`: \"Coroutines via Enhanced Generators\" describes the new " "generator features in Python 2.5." msgstr "" -":pep:`342`: \"Coroutines via Enhanced Generators\" describes the new " -"generator features in Python 2.5." +":pep:`342`: \"Coroutines via Enhanced Generators\" は、Python 2.5 の新しい" +"ジェネレータ機能を説明しています。" diff --git a/howto/gdb_helpers.po b/howto/gdb_helpers.po index 49b06932e..a25b26d58 100644 --- a/howto/gdb_helpers.po +++ b/howto/gdb_helpers.po @@ -16,171 +16,186 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/gdb_helpers.rst:5 msgid "Debugging C API extensions and CPython Internals with GDB" -msgstr "" +msgstr "GDB による C API 拡張と CPython 内部のデバッグ" -#: ../../howto/gdb_helpers.rst:9 msgid "" "This document explains how the Python GDB extension, ``python-gdb.py``, can " "be used with the GDB debugger to debug CPython extensions and the CPython " "interpreter itself." msgstr "" +"このドキュメントでは、Python の GDB 拡張 ``python-gdb.py`` を GDB デバッガと" +"組み合わせて、CPython 拡張や CPython インタープリタ自体をデバッグする方法を説" +"明します。" -#: ../../howto/gdb_helpers.rst:13 msgid "" "When debugging low-level problems such as crashes or deadlocks, a low-level " "debugger, such as GDB, is useful to diagnose and correct the issue. By " "default, GDB (or any of its front-ends) doesn't support high-level " "information specific to the CPython interpreter." msgstr "" +"クラッシュやデッドロックなどの低レベルの問題を調べて修正するには、GDB などの" +"低レベルのデバッガが役立ちます。\n" +"デフォルトでは GDB (およびそのフロントエンド) は CPython インタープリタ固有の" +"高レベルの情報に対応していません。" -#: ../../howto/gdb_helpers.rst:18 msgid "" "The ``python-gdb.py`` extension adds CPython interpreter information to GDB. " "The extension helps introspect the stack of currently executing Python " "functions. Given a Python object represented by a :c:expr:`PyObject *` " "pointer, the extension surfaces the type and value of the object." msgstr "" +"``python-gdb.py`` 拡張は CPython インタープリタの情報を GDB に追加します。\n" +"実行中の Python 関数のスタックを調べるのに役立ちます。\n" +":c:expr:`PyObject *` ポインタで表された Python オブジェクトについて、型と値を" +"表示できます。" -#: ../../howto/gdb_helpers.rst:23 msgid "" "Developers who are working on CPython extensions or tinkering with parts of " "CPython that are written in C can use this document to learn how to use the " "``python-gdb.py`` extension with GDB." msgstr "" +"このドキュメントは、CPython 拡張の開発者や CPython の C で書かれた部分を扱う" +"開発者が、GDB で ``python-gdb.py`` 拡張を使う方法を学ぶためのものです。" -#: ../../howto/gdb_helpers.rst:29 msgid "" "This document assumes that you are familiar with the basics of GDB and the " "CPython C API. It consolidates guidance from the `devguide `_ and the `Python wiki `_." msgstr "" +"このドキュメントは GDB と CPython C API の基礎を理解していることを前提として" +"います。\n" +"`開発者ガイド `_ と `Python wiki `_ の説明をまとめたものです。" -#: ../../howto/gdb_helpers.rst:36 msgid "Prerequisites" -msgstr "" +msgstr "前提条件" -#: ../../howto/gdb_helpers.rst:38 msgid "You need to have:" -msgstr "" +msgstr "次のものが必要です:" -#: ../../howto/gdb_helpers.rst:40 msgid "" "GDB 7 or later. (For earlier versions of GDB, see ``Misc/gdbinit`` in the " "sources of Python 3.11 or earlier.)" msgstr "" +"GDB 7 以降。(それ以前の GDB については、Python 3.11 以前のソースにある " +"``Misc/gdbinit`` を参照してください。)" -#: ../../howto/gdb_helpers.rst:42 msgid "" "GDB-compatible debugging information for Python and any extension you are " "debugging." -msgstr "" +msgstr "Python およびデバッグ対象の拡張の、GDB に対応したデバッグ情報。" -#: ../../howto/gdb_helpers.rst:44 msgid "The ``python-gdb.py`` extension." -msgstr "" +msgstr "``python-gdb.py`` 拡張。" -#: ../../howto/gdb_helpers.rst:46 msgid "" "The extension is built with Python, but might be distributed separately or " "not at all. Below, we include tips for a few common systems as examples. " "Note that even if the instructions match your system, they might be outdated." msgstr "" +"この拡張は Python と一緒にビルドされますが、別途配布されていることも、配布さ" +"れていないこともあります。\n" +"以下では一般的なシステムをいくつか例に挙げて説明します。\n" +"お使いのシステムに該当する手順でも、情報が古くなっている可能性に注意してくだ" +"さい。" -#: ../../howto/gdb_helpers.rst:52 msgid "Setup with Python built from source" -msgstr "" +msgstr "ソースからビルドした Python での設定" -#: ../../howto/gdb_helpers.rst:54 msgid "" "When you build CPython from source, debugging information should be " "available, and the build should add a ``python-gdb.py`` file to the root " "directory of your repository." msgstr "" +"CPython をソースからビルドすると、通常はデバッグ情報が利用でき、リポジトリの" +"ルートディレクトリに ``python-gdb.py`` ファイルが追加されます。" -#: ../../howto/gdb_helpers.rst:58 msgid "" "To activate support, you must add the directory containing ``python-gdb.py`` " "to GDB's \"auto-load-safe-path\". If you haven't done this, recent versions " "of GDB will print out a warning with instructions on how to do this." msgstr "" +"サポートを有効にするには、``python-gdb.py`` のあるディレクトリを GDB の " +"\"auto-load-safe-path\" に追加する必要があります。\n" +"追加していない場合、最近の GDB は追加方法を示す警告を表示します。" -#: ../../howto/gdb_helpers.rst:65 msgid "" "If you do not see instructions for your version of GDB, put this in your " "configuration file (``~/.gdbinit`` or ``~/.config/gdb/gdbinit``)::" msgstr "" +"お使いの GDB で手順が表示されない場合は、設定ファイル (``~/.gdbinit`` または " +"``~/.config/gdb/gdbinit``) に次を記述してください。 ::" -#: ../../howto/gdb_helpers.rst:68 msgid "add-auto-load-safe-path /path/to/cpython" -msgstr "" +msgstr "add-auto-load-safe-path /path/to/cpython" -#: ../../howto/gdb_helpers.rst:70 msgid "You can also add multiple paths, separated by ``:``." -msgstr "" +msgstr "``:`` で区切って複数のパスを追加することもできます。" -#: ../../howto/gdb_helpers.rst:74 msgid "Setup for Python from a Linux distro" -msgstr "" +msgstr "Linux ディストリビューションの Python での設定" -#: ../../howto/gdb_helpers.rst:76 msgid "" "Most Linux systems provide debug information for the system Python in a " "package called ``python-debuginfo``, ``python-dbg`` or similar. For example:" msgstr "" +"多くの Linux システムでは、システムの Python のデバッグ情報を ``python-" +"debuginfo`` や ``python-dbg`` などの名前のパッケージで提供しています。\n" +"例えば:" -#: ../../howto/gdb_helpers.rst:80 msgid "Fedora:" -msgstr "" +msgstr "Fedora:" -#: ../../howto/gdb_helpers.rst:82 msgid "" "sudo dnf install gdb\n" "sudo dnf debuginfo-install python3" msgstr "" +"sudo dnf install gdb\n" +"sudo dnf debuginfo-install python3" -#: ../../howto/gdb_helpers.rst:87 msgid "Ubuntu:" -msgstr "" +msgstr "Ubuntu:" -#: ../../howto/gdb_helpers.rst:89 msgid "sudo apt install gdb python3-dbg" -msgstr "" +msgstr "sudo apt install gdb python3-dbg" -#: ../../howto/gdb_helpers.rst:93 msgid "" "On several recent Linux systems, GDB can download debugging symbols " "automatically using *debuginfod*. However, this will not install the " "``python-gdb.py`` extension; you generally do need to install the debug info " "package separately." msgstr "" +"最近の Linux システムの一部では、GDB が *debuginfod* を使ってデバッグシンボル" +"を自動的にダウンロードできます。\n" +"ただし、これでは ``python-gdb.py`` 拡張はインストールされません。\n" +"通常はデバッグ情報のパッケージを別途インストールする必要があります。" -#: ../../howto/gdb_helpers.rst:100 msgid "Using the Debug build and Development mode" -msgstr "" +msgstr "デバッグビルドと開発モードの利用" -#: ../../howto/gdb_helpers.rst:102 msgid "For easier debugging, you might want to:" -msgstr "" +msgstr "デバッグを容易にするため、次の方法も検討してください:" -#: ../../howto/gdb_helpers.rst:104 msgid "" "Use a :ref:`debug build ` of Python. (When building from " "source, use ``configure --with-pydebug``. On Linux distros, install and run " "a package like ``python-debug`` or ``python-dbg``, if available.)" msgstr "" +"Python の :ref:`デバッグビルド ` を使う。(ソースからビルドする場" +"合は ``configure --with-pydebug`` を使います。Linux ディストリビューションで" +"は、``python-debug`` や ``python-dbg`` などのパッケージがあればインストールし" +"て実行します。)" -#: ../../howto/gdb_helpers.rst:107 msgid "Use the runtime :ref:`development mode ` (``-X dev``)." -msgstr "" +msgstr "実行時の :ref:`開発モード ` (``-X dev``) を使う。" #: ../../howto/gdb_helpers.rst:109 msgid "" @@ -189,27 +204,26 @@ msgid "" "process easier." msgstr "" -#: ../../howto/gdb_helpers.rst:115 msgid "Using the ``python-gdb`` extension" -msgstr "" +msgstr "``python-gdb`` 拡張の利用" -#: ../../howto/gdb_helpers.rst:117 msgid "" "When the extension is loaded, it provides two main features: pretty printers " "for Python values, and additional commands." msgstr "" +"この拡張を読み込むと、主に二つの機能が利用できます。\n" +"Python の値を整形して表示するプリティプリンタと、追加のコマンドです。" -#: ../../howto/gdb_helpers.rst:121 msgid "Pretty-printers" -msgstr "" +msgstr "プリティプリンタ" -#: ../../howto/gdb_helpers.rst:123 msgid "" "This is what a GDB backtrace looks like (truncated) when this extension is " "enabled::" msgstr "" +"この拡張を有効にすると、GDB のバックトレースは次のようになります (一部省" +"略)。 ::" -#: ../../howto/gdb_helpers.rst:126 msgid "" "#0 0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at " "address 0x7fffff7fefe8\n" @@ -239,22 +253,52 @@ msgid "" "'__doc__': None}, key=\n" " 0x5c2b8d \"__lltrace__\") at Objects/dictobject.c:2171" msgstr "" +"#0 0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at " +"address 0x7fffff7fefe8\n" +") at Objects/obmalloc.c:748\n" +"#1 0x000000000041b7c0 in _PyObject_DebugMallocApi (id=111 'o', nbytes=24) " +"at Objects/obmalloc.c:1445\n" +"#2 0x000000000041b717 in _PyObject_DebugMalloc (nbytes=24) at Objects/" +"obmalloc.c:1412\n" +"#3 0x000000000044060a in _PyUnicode_New (length=11) at Objects/" +"unicodeobject.c:346\n" +"#4 0x00000000004466aa in PyUnicodeUCS2_DecodeUTF8Stateful (s=0x5c2b8d " +"\"__lltrace__\", size=11, errors=0x0, consumed=\n" +" 0x0) at Objects/unicodeobject.c:2531\n" +"#5 0x0000000000446647 in PyUnicodeUCS2_DecodeUTF8 (s=0x5c2b8d " +"\"__lltrace__\", size=11, errors=0x0)\n" +" at Objects/unicodeobject.c:2495\n" +"#6 0x0000000000440d1b in PyUnicodeUCS2_FromStringAndSize (u=0x5c2b8d " +"\"__lltrace__\", size=11)\n" +" at Objects/unicodeobject.c:551\n" +"#7 0x0000000000440d94 in PyUnicodeUCS2_FromString (u=0x5c2b8d " +"\"__lltrace__\") at Objects/unicodeobject.c:569\n" +"#8 0x0000000000584abd in PyDict_GetItemString (v=\n" +" {'Yuck': , '__builtins__': , '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', " +"'__package__': None, 'y': , 'dict': {0: 0, 1: " +"1, 2: 2, 3: 3}, '__name__': '__main__', 'z': , " +"'__doc__': None}, key=\n" +" 0x5c2b8d \"__lltrace__\") at Objects/dictobject.c:2171" -#: ../../howto/gdb_helpers.rst:142 msgid "" "Notice how the dictionary argument to ``PyDict_GetItemString`` is displayed " "as its ``repr()``, rather than an opaque ``PyObject *`` pointer." msgstr "" +"``PyDict_GetItemString`` の引数の辞書が、内部の分からない ``PyObject *`` ポイ" +"ンタではなく ``repr()`` の結果として表示されている点に注目してください。" -#: ../../howto/gdb_helpers.rst:145 msgid "" "The extension works by supplying a custom printing routine for values of " "type ``PyObject *``. If you need to access lower-level details of an " "object, then cast the value to a pointer of the appropriate type. For " "example::" msgstr "" +"この拡張は ``PyObject *`` 型の値に専用の表示処理を提供します。\n" +"オブジェクトの低レベルの詳細を調べるには、適切な型のポインタにキャストしてく" +"ださい。\n" +"例えば次のようにします。 ::" -#: ../../howto/gdb_helpers.rst:149 msgid "" "(gdb) p globals\n" "$1 = {'__builtins__': , '__name__':\n" @@ -275,14 +319,32 @@ msgid "" "{me_hash = 0, me_key = 0x0, me_value = 0x0}, {\n" " me_hash = 6614918939584953775, me_key = '__package__', me_value = None}}}" msgstr "" +"(gdb) p globals\n" +"$1 = {'__builtins__': , '__name__':\n" +"'__main__', 'ctypes': , '__doc__': None,\n" +"'__package__': None}\n" +"\n" +"(gdb) p *(PyDictObject*)globals\n" +"$2 = {ob_refcnt = 3, ob_type = 0x3dbdf85820, ma_fill = 5, ma_used = 5,\n" +"ma_mask = 7, ma_table = 0x63d0f8, ma_lookup = 0x3dbdc7ea70\n" +", ma_smalltable = {{me_hash = 7065186196740147912,\n" +"me_key = '__builtins__', me_value = },\n" +"{me_hash = -368181376027291943, me_key = '__name__',\n" +"me_value ='__main__'}, {me_hash = 0, me_key = 0x0, me_value = 0x0},\n" +"{me_hash = 0, me_key = 0x0, me_value = 0x0},\n" +"{me_hash = -9177857982131165996, me_key = 'ctypes',\n" +"me_value = },\n" +"{me_hash = -8518757509529533123, me_key = '__doc__', me_value = None},\n" +"{me_hash = 0, me_key = 0x0, me_value = 0x0}, {\n" +" me_hash = 6614918939584953775, me_key = '__package__', me_value = None}}}" -#: ../../howto/gdb_helpers.rst:168 msgid "" "Note that the pretty-printers do not actually call ``repr()``. For basic " "types, they try to match its result closely." msgstr "" +"プリティプリンタは実際に ``repr()`` を呼び出すわけではありません。\n" +"基本的な型では、その結果にできるだけ近い表示を行います。" -#: ../../howto/gdb_helpers.rst:171 msgid "" "An area that can be confusing is that the custom printer for some types look " "a lot like GDB's built-in printer for standard types. For example, the " @@ -290,8 +352,11 @@ msgid "" "representation that is not distinguishable from one of a regular machine-" "level integer::" msgstr "" +"一部の型の専用の表示処理は、標準の型に対する GDB 組み込みの表示処理とよく似て" +"いるため、混同しやすいことがあります。\n" +"例えば Python の ``int`` (:c:expr:`PyLongObject *`) のプリティプリンタによる" +"表示は、通常の機械レベルの整数の表示と区別がつきません。 ::" -#: ../../howto/gdb_helpers.rst:177 msgid "" "(gdb) p some_machine_integer\n" "$3 = 42\n" @@ -299,71 +364,88 @@ msgid "" "(gdb) p some_python_integer\n" "$4 = 42" msgstr "" +"(gdb) p some_machine_integer\n" +"$3 = 42\n" +"\n" +"(gdb) p some_python_integer\n" +"$4 = 42" -#: ../../howto/gdb_helpers.rst:183 msgid "" "The internal structure can be revealed with a cast to :c:expr:`PyLongObject " "*`::" -msgstr "" +msgstr ":c:expr:`PyLongObject *` にキャストすると内部構造を確認できます。 ::" -#: ../../howto/gdb_helpers.rst:185 msgid "" "(gdb) p *(PyLongObject*)some_python_integer\n" "$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " "= 1},\n" "ob_digit = {42}}" msgstr "" +"(gdb) p *(PyLongObject*)some_python_integer\n" +"$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size " +"= 1},\n" +"ob_digit = {42}}" -#: ../../howto/gdb_helpers.rst:189 msgid "" "A similar confusion can arise with the ``str`` type, where the output looks " "a lot like gdb's built-in printer for ``char *``::" msgstr "" +"``str`` 型でも、GDB 組み込みの ``char *`` の表示とよく似ているため、同様に混" +"同しやすいことがあります。 ::" -#: ../../howto/gdb_helpers.rst:192 msgid "" "(gdb) p ptr_to_python_str\n" "$6 = '__builtins__'" msgstr "" +"(gdb) p ptr_to_python_str\n" +"$6 = '__builtins__'" -#: ../../howto/gdb_helpers.rst:195 msgid "" "The pretty-printer for ``str`` instances defaults to using single-quotes (as " "does Python's ``repr`` for strings) whereas the standard printer for ``char " "*`` values uses double-quotes and contains a hexadecimal address::" msgstr "" +"``str`` インスタンスのプリティプリンタは、デフォルトでシングルクォートを使い" +"ます (Python の文字列の ``repr`` と同様です)。\n" +"一方、``char *`` の標準の表示はダブルクォートを使い、16 進数のアドレスも含み" +"ます。 ::" -#: ../../howto/gdb_helpers.rst:199 msgid "" "(gdb) p ptr_to_char_star\n" "$7 = 0x6d72c0 \"hello world\"" msgstr "" +"(gdb) p ptr_to_char_star\n" +"$7 = 0x6d72c0 \"hello world\"" -#: ../../howto/gdb_helpers.rst:202 msgid "" "Again, the implementation details can be revealed with a cast to :c:expr:" "`PyUnicodeObject *`::" msgstr "" +"この場合も :c:expr:`PyUnicodeObject *` にキャストすると実装の詳細を確認できま" +"す。 ::" -#: ../../howto/gdb_helpers.rst:205 msgid "" "(gdb) p *(PyUnicodeObject*)$6\n" "$8 = {ob_base = {ob_refcnt = 33, ob_type = 0x3dad3a95a0}, length = 12,\n" "str = 0x7ffff2128500, hash = 7065186196740147912, state = 1, defenc = 0x0}" msgstr "" +"(gdb) p *(PyUnicodeObject*)$6\n" +"$8 = {ob_base = {ob_refcnt = 33, ob_type = 0x3dad3a95a0}, length = 12,\n" +"str = 0x7ffff2128500, hash = 7065186196740147912, state = 1, defenc = 0x0}" -#: ../../howto/gdb_helpers.rst:210 msgid "``py-list``" -msgstr "" +msgstr "``py-list``" -#: ../../howto/gdb_helpers.rst:212 msgid "" "The extension adds a ``py-list`` command, which lists the Python source code " "(if any) for the current frame in the selected thread. The current line is " "marked with a \">\"::" msgstr "" +"この拡張は ``py-list`` コマンドを追加します。\n" +"このコマンドは選択中のスレッドの現在のフレームに対応する Python ソースコード" +"があれば、それを表示します。\n" +"現在の行には \">\" が付きます。 ::" -#: ../../howto/gdb_helpers.rst:216 msgid "" "(gdb) py-list\n" " 901 if options.profile:\n" @@ -378,24 +460,37 @@ msgid "" " 910 except KeyboardInterrupt:\n" " 911 # properly quit on a keyboard interrupt..." msgstr "" +"(gdb) py-list\n" +" 901 if options.profile:\n" +" 902 options.profile = False\n" +" 903 profile_me()\n" +" 904 return\n" +" 905\n" +">906 u = UI()\n" +" 907 if not u.quit:\n" +" 908 try:\n" +" 909 gtk.main()\n" +" 910 except KeyboardInterrupt:\n" +" 911 # properly quit on a keyboard interrupt..." -#: ../../howto/gdb_helpers.rst:229 msgid "" "Use ``py-list START`` to list at a different line number within the Python " "source, and ``py-list START,END`` to list a specific range of lines within " "the Python source." msgstr "" +"Python ソース内の別の行から表示するには ``py-list START`` を、特定の行範囲を" +"表示するには ``py-list START,END`` を使います。" -#: ../../howto/gdb_helpers.rst:234 msgid "``py-up`` and ``py-down``" -msgstr "" +msgstr "``py-up`` と ``py-down``" -#: ../../howto/gdb_helpers.rst:236 msgid "" "The ``py-up`` and ``py-down`` commands are analogous to GDB's regular ``up`` " "and ``down`` commands, but try to move at the level of CPython frames, " "rather than C frames." msgstr "" +"``py-up`` と ``py-down`` は GDB の通常の ``up`` と ``down`` に相当するコマン" +"ドですが、C のフレームではなく CPython のフレーム単位で移動しようとします。" #: ../../howto/gdb_helpers.rst:240 msgid "" @@ -406,15 +501,13 @@ msgid "" "look up the value of the related ``PyFrameObject *``." msgstr "" -#: ../../howto/gdb_helpers.rst:246 msgid "They emit the frame number (at the C level) within the thread." -msgstr "" +msgstr "これらのコマンドはスレッド内の (C レベルの) フレーム番号を表示します。" #: ../../howto/gdb_helpers.rst:248 ../../howto/gdb_helpers.rst:320 msgid "For example::" msgstr "例えば::" -#: ../../howto/gdb_helpers.rst:250 msgid "" "(gdb) py-up\n" "#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/\n" @@ -428,23 +521,33 @@ msgid "" "(gdb) py-up\n" "Unable to find an older python frame" msgstr "" +"(gdb) py-up\n" +"#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/\n" +"gnome_sudoku/main.py, line 906, in start_game ()\n" +" u = UI()\n" +"(gdb) py-up\n" +"#40 Frame 0x948e82c, for file /usr/lib/python2.6/site-packages/\n" +"gnome_sudoku/gnome_sudoku.py, line 22, in start_game(main=)\n" +" main.start_game()\n" +"(gdb) py-up\n" +"Unable to find an older python frame" -#: ../../howto/gdb_helpers.rst:261 msgid "so we're at the top of the Python stack." -msgstr "" +msgstr "これで Python スタックの先頭に到達しました。" -#: ../../howto/gdb_helpers.rst:263 msgid "" "The frame numbers correspond to those displayed by GDB's standard " "``backtrace`` command. The command skips C frames which are not executing " "Python code." msgstr "" +"フレーム番号は GDB の標準の ``backtrace`` コマンドで表示されるものと対応しま" +"す。\n" +"Python コードを実行していない C のフレームはスキップされます。" -#: ../../howto/gdb_helpers.rst:267 msgid "Going back down::" -msgstr "" +msgstr "逆向きに戻ると次のようになります。 ::" -#: ../../howto/gdb_helpers.rst:269 msgid "" "(gdb) py-down\n" "#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" @@ -484,19 +587,58 @@ msgid "" "(gdb) py-down\n" "Unable to find a newer python frame" msgstr "" +"(gdb) py-down\n" +"#37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"main.py, line 906, in start_game ()\n" +" u = UI()\n" +"(gdb) py-down\n" +"#34 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#23 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#19 (unable to read python frame information)\n" +"(gdb) py-down\n" +"#14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"game_selector.py, line 201, in run_swallowed_dialog " +"(self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, " +"'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 " +"5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 " +"3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\\n7 " +"8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 " +"9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 " +"0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], dialog=, saved_game_model=, sudoku_maker=, main_page=0) " +"at remote 0x98fa6e4>, d=)\n" +" gtk.main()\n" +"(gdb) py-down\n" +"#8 (unable to read python frame information)\n" +"(gdb) py-down\n" +"Unable to find a newer python frame" -#: ../../howto/gdb_helpers.rst:289 msgid "and we're at the bottom of the Python stack." -msgstr "" +msgstr "これで Python スタックの末尾に到達しました。" -#: ../../howto/gdb_helpers.rst:291 msgid "" "Note that in Python 3.12 and newer, the same C stack frame can be used for " "multiple Python stack frames. This means that ``py-up`` and ``py-down`` may " "move multiple Python frames at once. For example::" msgstr "" +"Python 3.12 以降では、複数の Python スタックフレームが同じ C スタックフレーム" +"を使うことがあります。\n" +"このため ``py-up`` と ``py-down`` は複数の Python フレームを一度に移動する場" +"合があります。\n" +"例えば次のようになります。 ::" -#: ../../howto/gdb_helpers.rst:295 msgid "" "(gdb) py-up\n" "#6 Frame 0x7ffff7fb62b0, for file /tmp/rec.py, line 5, in recursive_function " @@ -522,18 +664,40 @@ msgid "" "(gdb) py-up\n" "Unable to find an older python frame" msgstr "" +"(gdb) py-up\n" +"#6 Frame 0x7ffff7fb62b0, for file /tmp/rec.py, line 5, in recursive_function " +"(n=0)\n" +" time.sleep(5)\n" +"#6 Frame 0x7ffff7fb6240, for file /tmp/rec.py, line 7, in recursive_function " +"(n=1)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb61d0, for file /tmp/rec.py, line 7, in recursive_function " +"(n=2)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6160, for file /tmp/rec.py, line 7, in recursive_function " +"(n=3)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb60f0, for file /tmp/rec.py, line 7, in recursive_function " +"(n=4)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6080, for file /tmp/rec.py, line 7, in recursive_function " +"(n=5)\n" +" recursive_function(n-1)\n" +"#6 Frame 0x7ffff7fb6020, for file /tmp/rec.py, line 9, in ()\n" +" recursive_function(5)\n" +"(gdb) py-up\n" +"Unable to find an older python frame" -#: ../../howto/gdb_helpers.rst:315 msgid "``py-bt``" -msgstr "" +msgstr "``py-bt``" -#: ../../howto/gdb_helpers.rst:317 msgid "" "The ``py-bt`` command attempts to display a Python-level backtrace of the " "current thread." msgstr "" +"``py-bt`` コマンドは現在のスレッドの Python レベルのバックトレースを表示しよ" +"うとします。" -#: ../../howto/gdb_helpers.rst:322 msgid "" "(gdb) py-bt\n" "#8 (unable to read python frame information)\n" @@ -569,25 +733,59 @@ msgid "" "0xb771b7f4>)\n" " main.start_game()" msgstr "" +"(gdb) py-bt\n" +"#8 (unable to read python frame information)\n" +"#11 Frame 0x9aead74, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"dialog_swallower.py, line 48, in run_dialog " +"(self=, main_page=0) " +"at remote 0x98fa6e4>, d=)\n" +" gtk.main()\n" +"#14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/" +"game_selector.py, line 201, in run_swallowed_dialog " +"(self=, puzzle=None, saved_games=[{'gsd.auto_fills': 0, 'tracking': {}, " +"'trackers': {}, 'notes': [], 'saved_at': 1270084485, 'game': '7 8 0 0 0 0 0 " +"5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 0 0 0 4 7 9 2 0 0 0 9 0 1 0 0 0 " +"3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 0 0 4 5\\n7 " +"8 0 0 0 0 0 5 6 0 0 9 0 8 0 1 0 0 0 4 6 0 0 0 0 7 0 6 5 1 8 3 4 7 9 2 0 0 0 " +"9 0 1 0 0 0 3 9 7 6 0 0 0 1 8 0 6 0 0 0 0 2 8 0 0 0 5 0 4 0 6 0 0 2 1 0 0 0 " +"0 0 4 5', 'gsd.impossible_hints': 0, 'timer.__absolute_start_time__': , 'gsd.hints': 0, 'timer.active_time': , 'timer.total_time': }], dialog=, saved_game_model=, sudoku_maker=)\n" +" main.start_game()" -#: ../../howto/gdb_helpers.rst:336 msgid "" "The frame numbers correspond to those displayed by GDB's standard " "``backtrace`` command." msgstr "" +"フレーム番号は GDB の標準の ``backtrace`` コマンドで表示されるものと対応しま" +"す。" -#: ../../howto/gdb_helpers.rst:340 msgid "``py-print``" -msgstr "" +msgstr "``py-print``" -#: ../../howto/gdb_helpers.rst:342 msgid "" "The ``py-print`` command looks up a Python name and tries to print it. It " "looks in locals within the current thread, then globals, then finally " "builtins::" msgstr "" +"``py-print`` コマンドは Python の名前を検索し、その値を表示しようとします。\n" +"現在のスレッドのローカル変数、グローバル変数、組み込みの名前の順に検索しま" +"す。 ::" -#: ../../howto/gdb_helpers.rst:346 msgid "" "(gdb) py-print self\n" "local 'self' = ,\n" @@ -599,38 +797,51 @@ msgid "" "(gdb) py-print scarlet_pimpernel\n" "'scarlet_pimpernel' not found" msgstr "" +"(gdb) py-print self\n" +"local 'self' = ,\n" +"main_page=0) at remote 0x98fa6e4>\n" +"(gdb) py-print __name__\n" +"global '__name__' = 'gnome_sudoku.dialog_swallower'\n" +"(gdb) py-print len\n" +"builtin 'len' = \n" +"(gdb) py-print scarlet_pimpernel\n" +"'scarlet_pimpernel' not found" -#: ../../howto/gdb_helpers.rst:356 msgid "" "If the current C frame corresponds to multiple Python frames, ``py-print`` " "only considers the first one." msgstr "" +"現在の C フレームが複数の Python フレームに対応する場合、``py-print`` は最初" +"のものだけを対象にします。" -#: ../../howto/gdb_helpers.rst:360 msgid "``py-locals``" -msgstr "" +msgstr "``py-locals``" -#: ../../howto/gdb_helpers.rst:362 msgid "" "The ``py-locals`` command looks up all Python locals within the current " "Python frame in the selected thread, and prints their representations::" msgstr "" +"``py-locals`` コマンドは、選択中のスレッドの現在の Python フレームにあるすべ" +"てのローカル変数を調べ、それぞれの値の表現を表示します。 ::" -#: ../../howto/gdb_helpers.rst:365 msgid "" "(gdb) py-locals\n" "self = ,\n" "main_page=0) at remote 0x98fa6e4>\n" "d = " msgstr "" +"(gdb) py-locals\n" +"self = ,\n" +"main_page=0) at remote 0x98fa6e4>\n" +"d = " -#: ../../howto/gdb_helpers.rst:370 msgid "" "If the current C frame corresponds to multiple Python frames, locals from " "all of them will be shown::" msgstr "" +"現在の C フレームが複数の Python フレームに対応する場合、すべてのフレームの" +"ローカル変数が表示されます。 ::" -#: ../../howto/gdb_helpers.rst:373 msgid "" "(gdb) py-locals\n" "Locals for recursive_function\n" @@ -647,19 +858,33 @@ msgid "" "n = 5\n" "Locals for " msgstr "" +"(gdb) py-locals\n" +"Locals for recursive_function\n" +"n = 0\n" +"Locals for recursive_function\n" +"n = 1\n" +"Locals for recursive_function\n" +"n = 2\n" +"Locals for recursive_function\n" +"n = 3\n" +"Locals for recursive_function\n" +"n = 4\n" +"Locals for recursive_function\n" +"n = 5\n" +"Locals for " -#: ../../howto/gdb_helpers.rst:390 msgid "Use with GDB commands" -msgstr "" +msgstr "GDB コマンドとの併用" -#: ../../howto/gdb_helpers.rst:392 msgid "" "The extension commands complement GDB's built-in commands. For example, you " "can use a frame numbers shown by ``py-bt`` with the ``frame`` command to go " "a specific frame within the selected thread, like this::" msgstr "" +"拡張のコマンドは GDB 組み込みのコマンドを補完します。\n" +"例えば、``py-bt`` が表示するフレーム番号を ``frame`` コマンドに渡すと、選択中" +"のスレッドの特定のフレームに移動できます。 ::" -#: ../../howto/gdb_helpers.rst:396 msgid "" "(gdb) py-bt\n" "(output snipped)\n" @@ -682,14 +907,34 @@ msgid "" "1547 with test_support.temp_cwd(TESTCWD, quiet=True):\n" ">1548 main()" msgstr "" +"(gdb) py-bt\n" +"(output snipped)\n" +"#68 Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in " +"()\n" +" main()\n" +"(gdb) frame 68\n" +"#68 0x00000000004cd1e6 in PyEval_EvalFrameEx (f=Frame 0xaa4560, for file Lib/" +"test/regrtest.py, line 1548, in (), throwflag=0) at Python/ceval." +"c:2665\n" +"2665 x = call_function(&sp, oparg);\n" +"(gdb) py-list\n" +"1543 # Run the tests in a context manager that temporary changes the " +"CWD to a\n" +"1544 # temporary and writable directory. If it's not possible to " +"create or\n" +"1545 # change the CWD, the original CWD will be used. The original " +"CWD is\n" +"1546 # available from test_support.SAVEDCWD.\n" +"1547 with test_support.temp_cwd(TESTCWD, quiet=True):\n" +">1548 main()" -#: ../../howto/gdb_helpers.rst:411 msgid "" "The ``info threads`` command will give you a list of the threads within the " "process, and you can use the ``thread`` command to select a different one::" msgstr "" +"``info threads`` コマンドはプロセス内のスレッドの一覧を表示します。\n" +"``thread`` コマンドを使うと別のスレッドを選択できます。 ::" -#: ../../howto/gdb_helpers.rst:414 msgid "" "(gdb) info threads\n" " 105 Thread 0x7fffefa18710 (LWP 10260) sem_wait () at ../nptl/sysdeps/unix/" @@ -699,15 +944,24 @@ msgid "" "* 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../" "sysdeps/unix/syscall-template.S:82" msgstr "" +"(gdb) info threads\n" +" 105 Thread 0x7fffefa18710 (LWP 10260) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +" 104 Thread 0x7fffdf5fe710 (LWP 10259) sem_wait () at ../nptl/sysdeps/unix/" +"sysv/linux/x86_64/sem_wait.S:86\n" +"* 1 Thread 0x7ffff7fe2700 (LWP 10145) 0x00000038e46d73e3 in select () at ../" +"sysdeps/unix/syscall-template.S:82" -#: ../../howto/gdb_helpers.rst:419 msgid "" "You can use ``thread apply all COMMAND`` or (``t a a COMMAND`` for short) to " "run a command on all threads. With ``py-bt``, this lets you see what every " "thread is doing at the Python level::" msgstr "" +"``thread apply all COMMAND`` (省略形は ``t a a COMMAND``) を使うと、すべての" +"スレッドでコマンドを実行できます。\n" +"``py-bt`` と組み合わせると、各スレッドが Python レベルで何を実行しているか確" +"認できます。 ::" -#: ../../howto/gdb_helpers.rst:423 msgid "" "(gdb) t a a py-bt\n" "\n" @@ -787,3 +1041,80 @@ msgid "" ", , _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140737213728528), count=1, " +"owner=140737213728528)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffac001640, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140737213728528))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffb8001a10, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffb8001c40, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140737213728528)\n" +" f()\n" +"\n" +"Thread 104 (Thread 0x7fffdf5fe710 (LWP 10259)):\n" +"#5 Frame 0x7fffe4001580, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 155, in _acquire_restore " +"(self=<_RLock(_Verbose__verbose=False, _RLock__owner=140737354016512, " +"_RLock__block=, _RLock__count=1) at remote " +"0xd7ff40>, count_owner=(1, 140736940992272), count=1, " +"owner=140736940992272)\n" +" self.__block.acquire()\n" +"#8 Frame 0x7fffc8002090, for file /home/david/coding/python-svn/Lib/" +"threading.py, line 269, in wait " +"(self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, " +"_RLock__owner=140737354016512, _RLock__block=, _RLock__count=1) at remote 0xd7ff40>, acquire=, _is_owned=, " +"_release_save=, release=, _acquire_restore=, " +"_Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, " +"timeout=None, waiter=, saved_state=(1, " +"140736940992272))\n" +" self._acquire_restore(saved_state)\n" +"#12 Frame 0x7fffac001c90, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 348, in f ()\n" +" cond.wait()\n" +"#16 Frame 0x7fffac0011c0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 37, in task (tid=140736940992272)\n" +" f()\n" +"\n" +"Thread 1 (Thread 0x7ffff7fe2700 (LWP 10145)):\n" +"#5 Frame 0xcb5380, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 16, in _wait ()\n" +" time.sleep(0.01)\n" +"#8 Frame 0x7fffd00024a0, for file /home/david/coding/python-svn/Lib/test/" +"lock_tests.py, line 378, in _check_notify " +"(self=, skipped=[], _mirrorOutput=False, testsRun=39, " +"buffer=False, _original_stderr=, " +"_stdout_buffer=, " +"_stderr_buffer=, " +"_moduleSetUpFailed=False, expectedFailures=[], errors=[], " +"_previousTestClass=, unexpectedSuccesses=[], " +"failures=[], shouldStop=False, failfast=False) at remote 0xc185a0>, " +"_threads=(0,), _後片付けs=[], _type_equality_funcs={: , : " +", : " +", : " +", , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/index.rst:5 msgid "Python HOWTOs" msgstr "Python HOWTO" -#: ../../howto/index.rst:7 msgid "" "Python HOWTOs are documents that cover a specific topic in-depth. Modeled on " "the Linux Documentation Project's HOWTO collection, this collection is an " "effort to foster documentation that's more detailed than the Python Library " "Reference." msgstr "" +"Python HOWTO は特定の話題を掘り下げて解説するドキュメントです。\n" +"Linux Documentation Project の HOWTO 集をモデルに、Python ライブラリリファレ" +"ンスよりも詳しいドキュメントを充実させることを目指しています。" -#: ../../howto/index.rst:43 msgid "General:" -msgstr "" +msgstr "一般:" #: ../../howto/index.rst:45 msgid ":ref:`a-conceptual-overview-of-asyncio`" msgstr ":ref:`a-conceptual-overview-of-asyncio`" -#: ../../howto/index.rst:46 msgid ":ref:`annotations-howto`" -msgstr "" +msgstr ":ref:`annotations-howto`" -#: ../../howto/index.rst:47 msgid ":ref:`argparse-tutorial`" -msgstr "" +msgstr ":ref:`argparse-tutorial`" -#: ../../howto/index.rst:48 msgid ":ref:`descriptorhowto`" -msgstr "" +msgstr ":ref:`descriptorhowto`" -#: ../../howto/index.rst:49 msgid ":ref:`enum-howto`" -msgstr "" +msgstr ":ref:`enum-howto`" -#: ../../howto/index.rst:50 msgid ":ref:`functional-howto`" -msgstr "" +msgstr ":ref:`functional-howto`" -#: ../../howto/index.rst:51 msgid ":ref:`ipaddress-howto`" -msgstr "" +msgstr ":ref:`ipaddress-howto`" -#: ../../howto/index.rst:52 msgid ":ref:`logging-howto`" -msgstr "" +msgstr ":ref:`logging-howto`" -#: ../../howto/index.rst:53 msgid ":ref:`logging-cookbook`" -msgstr "" +msgstr ":ref:`logging-cookbook`" -#: ../../howto/index.rst:54 msgid ":ref:`regex-howto`" -msgstr "" +msgstr ":ref:`regex-howto`" -#: ../../howto/index.rst:55 msgid ":ref:`sortinghowto`" -msgstr "" +msgstr ":ref:`sortinghowto`" -#: ../../howto/index.rst:56 msgid ":ref:`unicode-howto`" -msgstr "" +msgstr ":ref:`unicode-howto`" -#: ../../howto/index.rst:57 msgid ":ref:`urllib-howto`" -msgstr "" +msgstr ":ref:`urllib-howto`" -#: ../../howto/index.rst:59 msgid "Advanced development:" -msgstr "" +msgstr "高度な開発:" #: ../../howto/index.rst:61 msgid ":ref:`curses-howto`" msgstr ":ref:`curses-howto`" -#: ../../howto/index.rst:62 msgid ":ref:`freethreading-python-howto`" -msgstr "" +msgstr ":ref:`freethreading-python-howto`" -#: ../../howto/index.rst:63 msgid ":ref:`freethreading-extensions-howto`" -msgstr "" +msgstr ":ref:`freethreading-extensions-howto`" -#: ../../howto/index.rst:64 msgid ":ref:`isolating-extensions-howto`" -msgstr "" +msgstr ":ref:`isolating-extensions-howto`" -#: ../../howto/index.rst:65 msgid ":ref:`abi3t-migration-howto`" -msgstr "" +msgstr ":ref:`abi3t-migration-howto`" -#: ../../howto/index.rst:66 msgid ":ref:`python_2.3_mro`" -msgstr "" +msgstr ":ref:`python_2.3_mro`" -#: ../../howto/index.rst:67 msgid ":ref:`socket-howto`" -msgstr "" +msgstr ":ref:`socket-howto`" -#: ../../howto/index.rst:68 msgid ":ref:`timerfd-howto`" -msgstr "" +msgstr ":ref:`timerfd-howto`" -#: ../../howto/index.rst:69 msgid ":ref:`cporting-howto`" -msgstr "" +msgstr ":ref:`cporting-howto`" -#: ../../howto/index.rst:71 msgid "Debugging and profiling:" -msgstr "" +msgstr "デバッグとプロファイリング:" -#: ../../howto/index.rst:73 msgid ":ref:`gdb`" -msgstr "" +msgstr ":ref:`gdb`" -#: ../../howto/index.rst:74 msgid ":ref:`instrumentation`" -msgstr "" +msgstr ":ref:`instrumentation`" -#: ../../howto/index.rst:75 msgid ":ref:`perf_profiling`" -msgstr "" +msgstr ":ref:`perf_profiling`" -#: ../../howto/index.rst:76 msgid ":ref:`remote-debugging`" -msgstr "" +msgstr ":ref:`remote-debugging`" diff --git a/howto/instrumentation.po b/howto/instrumentation.po index bad3672db..adcdc837f 100644 --- a/howto/instrumentation.po +++ b/howto/instrumentation.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/instrumentation.rst:7 @@ -91,36 +91,35 @@ msgid "On a Linux machine, this can be done via::" msgstr "" "Linux マシンでは、 SystemTap 開発ツールのインストールは次のように行えます::" -#: ../../howto/instrumentation.rst:39 msgid "$ yum install systemtap-sdt-devel" -msgstr "" +msgstr "$ yum install systemtap-sdt-devel" #: ../../howto/instrumentation.rst:41 msgid "or::" msgstr "もしくは::" -#: ../../howto/instrumentation.rst:43 msgid "$ sudo apt-get install systemtap-sdt-dev" -msgstr "" +msgstr "$ sudo apt-get install systemtap-sdt-dev" -#: ../../howto/instrumentation.rst:46 msgid "" "CPython must then be :option:`configured with the --with-dtrace option <--" "with-dtrace>`:" msgstr "" +"続いて :option:`--with-dtrace オプションで CPython を構成 <--with-dtrace>` す" +"る必要があります:" -#: ../../howto/instrumentation.rst:49 msgid "checking for --with-dtrace... yes" -msgstr "" +msgstr "checking for --with-dtrace... yes" -#: ../../howto/instrumentation.rst:53 msgid "" "On macOS, you can list available DTrace probes by running a Python process " "in the background and listing all probes made available by the Python " "provider::" msgstr "" +"macOS では Python プロセスをバックグラウンドで実行し、Python プロバイダが提供" +"するすべてのプローブを列挙すると、利用可能な DTrace プローブを確認できま" +"す。 ::" -#: ../../howto/instrumentation.rst:57 msgid "" "$ python3.6 -q &\n" "$ sudo dtrace -l -P python$! # or: dtrace -l -m python3.6\n" @@ -141,37 +140,60 @@ msgid "" "29570 python18035 python3.6 _PyEval_EvalFrameDefault line\n" "29571 python18035 python3.6 maybe_dtrace_line line" msgstr "" +"$ python3.6 -q &\n" +"$ sudo dtrace -l -P python$! # or: dtrace -l -m python3.6\n" +"\n" +" ID PROVIDER MODULE FUNCTION NAME\n" +"29564 python18035 python3.6 _PyEval_EvalFrameDefault " +"function-entry\n" +"29565 python18035 python3.6 dtrace_function_entry " +"function-entry\n" +"29566 python18035 python3.6 _PyEval_EvalFrameDefault " +"function-return\n" +"29567 python18035 python3.6 dtrace_function_return " +"function-return\n" +"29568 python18035 python3.6 collect gc-" +"done\n" +"29569 python18035 python3.6 collect gc-" +"start\n" +"29570 python18035 python3.6 _PyEval_EvalFrameDefault line\n" +"29571 python18035 python3.6 maybe_dtrace_line line" -#: ../../howto/instrumentation.rst:70 msgid "" "On Linux, you can verify if the SystemTap static markers are present in the " "built binary by seeing if it contains a \".note.stapsdt\" section." msgstr "" +"Linux では、ビルドしたバイナリに \".note.stapsdt\" セクションが含まれているか" +"調べると、SystemTap の静的マーカーの有無を確認できます。" -#: ../../howto/instrumentation.rst:75 msgid "" "$ readelf -S ./python | grep .note.stapsdt\n" "[30] .note.stapsdt NOTE 0000000000000000 00308d78" msgstr "" +"$ readelf -S ./python | grep .note.stapsdt\n" +"[30] .note.stapsdt NOTE 0000000000000000 00308d78" -#: ../../howto/instrumentation.rst:78 msgid "" "If you've built Python as a shared library (with the :option:`--enable-" "shared` configure option), you need to look instead within the shared " "library. For example::" msgstr "" +"Python を共有ライブラリとしてビルドした場合 (configure オプション :option:`--" +"enable-shared` を指定した場合) は、共有ライブラリの中を調べる必要がありま" +"す。\n" +"例えば次のようにします。 ::" -#: ../../howto/instrumentation.rst:82 msgid "" "$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n" "[29] .note.stapsdt NOTE 0000000000000000 00365b68" msgstr "" +"$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n" +"[29] .note.stapsdt NOTE 0000000000000000 00365b68" #: ../../howto/instrumentation.rst:85 msgid "Sufficiently modern readelf can print the metadata::" msgstr "十分に新しい readelf ではメタデータを出力できます::" -#: ../../howto/instrumentation.rst:87 msgid "" "$ readelf -n ./python\n" "\n" @@ -218,27 +240,75 @@ msgid "" "0x00000000008d6bea\n" " Arguments: 8@%rbp 8@%r12 -4@%eax" msgstr "" +"$ readelf -n ./python\n" +"\n" +"Displaying notes found at file offset 0x00000254 with length 0x00000020:\n" +" Owner Data size Description\n" +" GNU 0x00000010 NT_GNU_ABI_TAG (ABI version " +"tag)\n" +" OS: Linux, ABI: 2.6.32\n" +"\n" +"Displaying notes found at file offset 0x00000274 with length 0x00000024:\n" +" Owner Data size Description\n" +" GNU 0x00000014 NT_GNU_BUILD_ID (unique build " +"ID bitstring)\n" +" Build ID: df924a2b08a7e89f6e11251d4602022977af2670\n" +"\n" +"Displaying notes found at file offset 0x002d6c30 with length 0x00000144:\n" +" Owner Data size Description\n" +" stapsdt 0x00000031 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: gc__start\n" +" Location: 0x00000000004371c3, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bf6\n" +" Arguments: -4@%ebx\n" +" stapsdt 0x00000030 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: gc__done\n" +" Location: 0x00000000004374e1, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bf8\n" +" Arguments: -8@%rax\n" +" stapsdt 0x00000045 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: function__entry\n" +" Location: 0x000000000053db6c, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6be8\n" +" Arguments: 8@%rbp 8@%r12 -4@%eax\n" +" stapsdt 0x00000046 NT_STAPSDT (SystemTap probe " +"descriptors)\n" +" Provider: python\n" +" Name: function__return\n" +" Location: 0x000000000053dba8, Base: 0x0000000000630ce2, Semaphore: " +"0x00000000008d6bea\n" +" Arguments: 8@%rbp 8@%r12 -4@%eax" -#: ../../howto/instrumentation.rst:122 msgid "" "The above metadata contains information for SystemTap describing how it can " "patch strategically placed machine code instructions to enable the tracing " "hooks used by a SystemTap script." msgstr "" +"上記のメタデータには、SystemTap が適所に配置された機械語命令を書き換え、" +"SystemTap スクリプトで使うトレースフックを有効にするための情報が含まれていま" +"す。" #: ../../howto/instrumentation.rst:128 msgid "Static DTrace probes" msgstr "静的 DTrace プローブ" -#: ../../howto/instrumentation.rst:130 msgid "" "The following example DTrace script can be used to show the call/return " "hierarchy of a Python script, only tracing within the invocation of a " "function called \"start\". In other words, import-time function invocations " "are not going to be listed:" msgstr "" +"次の DTrace スクリプトの例は、Python スクリプトの呼び出しと復帰の階層を表示し" +"ます。\n" +"\"start\" という関数の呼び出し中だけをトレースするため、インポート時の関数呼" +"び出しは表示されません:" -#: ../../howto/instrumentation.rst:135 msgid "" "self int indent;\n" "\n" @@ -274,20 +344,51 @@ msgid "" " self->trace = 0;\n" "}" msgstr "" +"self int indent;\n" +"\n" +"python$target:::function-entry\n" +"/copyinstr(arg1) == \"start\"/\n" +"{\n" +" self->trace = 1;\n" +"}\n" +"\n" +"python$target:::function-entry\n" +"/self->trace/\n" +"{\n" +" printf(\"%d\\t%*s:\", timestamp, 15, probename);\n" +" printf(\"%*s\", self->indent, \"\");\n" +" printf(\"%s:%s:%d\\n\", basename(copyinstr(arg0)), copyinstr(arg1), " +"arg2);\n" +" self->indent++;\n" +"}\n" +"\n" +"python$target:::function-return\n" +"/self->trace/\n" +"{\n" +" self->indent--;\n" +" printf(\"%d\\t%*s:\", timestamp, 15, probename);\n" +" printf(\"%*s\", self->indent, \"\");\n" +" printf(\"%s:%s:%d\\n\", basename(copyinstr(arg0)), copyinstr(arg1), " +"arg2);\n" +"}\n" +"\n" +"python$target:::function-return\n" +"/copyinstr(arg1) == \"start\"/\n" +"{\n" +" self->trace = 0;\n" +"}" #: ../../howto/instrumentation.rst:169 ../../howto/instrumentation.rst:227 msgid "It can be invoked like this::" msgstr "この例は次のように実行できます::" -#: ../../howto/instrumentation.rst:171 msgid "$ sudo dtrace -q -s call_stack.d -c \"python3.6 script.py\"" -msgstr "" +msgstr "$ sudo dtrace -q -s call_stack.d -c \"python3.6 script.py\"" #: ../../howto/instrumentation.rst:173 ../../howto/instrumentation.rst:233 msgid "The output looks like this:" msgstr "出力はこのようになります:" -#: ../../howto/instrumentation.rst:175 msgid "" "156641360502280 function-entry:call_stack.py:start:23\n" "156641360518804 function-entry: call_stack.py:function_1:1\n" @@ -308,17 +409,36 @@ msgid "" "156641360732567 function-return: call_stack.py:function_5:21\n" "156641360747370 function-return:call_stack.py:start:28" msgstr "" +"156641360502280 function-entry:call_stack.py:start:23\n" +"156641360518804 function-entry: call_stack.py:function_1:1\n" +"156641360532797 function-entry: call_stack.py:function_3:9\n" +"156641360546807 function-return: call_stack.py:function_3:10\n" +"156641360563367 function-return: call_stack.py:function_1:2\n" +"156641360578365 function-entry: call_stack.py:function_2:5\n" +"156641360591757 function-entry: call_stack.py:function_1:1\n" +"156641360605556 function-entry: call_stack.py:function_3:9\n" +"156641360617482 function-return: call_stack.py:function_3:10\n" +"156641360629814 function-return: call_stack.py:function_1:2\n" +"156641360642285 function-return: call_stack.py:function_2:6\n" +"156641360656770 function-entry: call_stack.py:function_3:9\n" +"156641360669707 function-return: call_stack.py:function_3:10\n" +"156641360687853 function-entry: call_stack.py:function_4:13\n" +"156641360700719 function-return: call_stack.py:function_4:14\n" +"156641360719640 function-entry: call_stack.py:function_5:18\n" +"156641360732567 function-return: call_stack.py:function_5:21\n" +"156641360747370 function-return:call_stack.py:start:28" #: ../../howto/instrumentation.rst:198 msgid "Static SystemTap markers" msgstr "静的 SystemTap マーカー" -#: ../../howto/instrumentation.rst:200 msgid "" "The low-level way to use the SystemTap integration is to use the static " "markers directly. This requires you to explicitly state the binary file " "containing them." msgstr "" +"SystemTap との連携を低レベルで行う方法は、静的マーカーを直接使うことです。\n" +"この場合、マーカーを含むバイナリファイルを明示する必要があります。" #: ../../howto/instrumentation.rst:204 msgid "" @@ -328,7 +448,6 @@ msgstr "" "例えば、この SystemTap スクリプトは Python の呼び出し/返却 (call/return) 階層" "を表示するのに使えます:" -#: ../../howto/instrumentation.rst:207 msgid "" "probe process(\"python\").mark(\"function__entry\") {\n" " filename = user_string($arg1);\n" @@ -348,15 +467,33 @@ msgid "" " thread_indent(-1), funcname, filename, lineno);\n" "}" msgstr "" +"probe process(\"python\").mark(\"function__entry\") {\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +"\n" +" printf(\"%s => %s in %s:%d\\\\n\",\n" +" thread_indent(1), funcname, filename, lineno);\n" +"}\n" +"\n" +"probe process(\"python\").mark(\"function__return\") {\n" +" filename = user_string($arg1);\n" +" funcname = user_string($arg2);\n" +" lineno = $arg3;\n" +"\n" +" printf(\"%s <= %s in %s:%d\\\\n\",\n" +" thread_indent(-1), funcname, filename, lineno);\n" +"}" -#: ../../howto/instrumentation.rst:229 msgid "" "$ stap \\\n" " show-call-hierarchy.stp \\\n" " -c \"./python test.py\"" msgstr "" +"$ stap \\\n" +" show-call-hierarchy.stp \\\n" +" -c \"./python test.py\"" -#: ../../howto/instrumentation.rst:235 msgid "" "11408 python(8274): => __contains__ in Lib/_abcoll.py:362\n" "11414 python(8274): => __getitem__ in Lib/os.py:425\n" @@ -365,6 +502,12 @@ msgid "" "11428 python(8274): <= __getitem__ in Lib/os.py:426\n" "11433 python(8274): <= __contains__ in Lib/_abcoll.py:366" msgstr "" +"11408 python(8274): => __contains__ in Lib/_abcoll.py:362\n" +"11414 python(8274): => __getitem__ in Lib/os.py:425\n" +"11418 python(8274): => encode in Lib/os.py:490\n" +"11424 python(8274): <= encode in Lib/os.py:493\n" +"11428 python(8274): <= __getitem__ in Lib/os.py:426\n" +"11433 python(8274): <= __contains__ in Lib/_abcoll.py:366" #: ../../howto/instrumentation.rst:244 msgid "where the columns are:" @@ -389,30 +532,31 @@ msgstr "" "そして、残りの部分はスクリプトが実行していた呼び出し/返却階層を表示していま" "す。" -#: ../../howto/instrumentation.rst:252 msgid "" "For a :option:`--enable-shared` build of CPython, the markers are contained " "within the libpython shared library, and the probe's dotted path needs to " "reflect this. For example, this line from the above example:" msgstr "" +":option:`--enable-shared` を指定した CPython のビルドでは、マーカーは " +"libpython 共有ライブラリに含まれるため、プローブのドットで区切ったパスにもそ" +"れを反映する必要があります。\n" +"例えば、上の例の次の行は:" -#: ../../howto/instrumentation.rst:256 msgid "probe process(\"python\").mark(\"function__entry\") {" -msgstr "" +msgstr "probe process(\"python\").mark(\"function__entry\") {" -#: ../../howto/instrumentation.rst:260 msgid "should instead read:" -msgstr "" +msgstr "次のように書き換えます:" -#: ../../howto/instrumentation.rst:262 msgid "" "probe process(\"python\").library(\"libpython3.6dm.so.1.0\")." "mark(\"function__entry\") {" msgstr "" +"probe process(\"python\").library(\"libpython3.6dm.so.1.0\")." +"mark(\"function__entry\") {" -#: ../../howto/instrumentation.rst:266 msgid "(assuming a :ref:`debug build ` of CPython 3.6)" -msgstr "" +msgstr "(CPython 3.6 の :ref:`デバッグビルド ` を想定しています)" #: ../../howto/instrumentation.rst:272 msgid "Available static markers" @@ -426,14 +570,13 @@ msgstr "" "このマーカーは Python の関数の実行が開始されたことを示しています。\n" "このマーカーは、ピュア Python (バイトコード) の関数でしか起動されません。" -#: ../../howto/instrumentation.rst:279 msgid "" "The filename, function name, and line number are provided back to the " "tracing script as positional arguments, which must be accessed using " "``$arg1``, ``$arg2``, ``$arg3``:" msgstr "" -"トレーススクリプトには位置引数として、ファイル名、関数名、行番号が渡され、必" -"ず ``$arg1``, ``$arg2``, ``$arg3`` で渡されます:" +"ファイル名、関数名、行番号が位置引数としてトレーススクリプトに渡されます。\n" +"それぞれ ``$arg1``、``$arg2``、``$arg3`` を使ってアクセスしてください:" #: ../../howto/instrumentation.rst:283 msgid "" @@ -455,16 +598,18 @@ msgstr "" msgid "``$arg3`` : ``int`` line number" msgstr "``$arg3`` : ``int`` 行番号" -#: ../../howto/instrumentation.rst:292 msgid "" "This marker is the converse of :c:func:`!function__entry`, and indicates " "that execution of a Python function has ended (either via ``return``, or via " "an exception). It is only triggered for pure-Python (bytecode) functions." msgstr "" +"このマーカーは :c:func:`!function__entry` と対をなし、Python 関数の実行が終了" +"したことを示します (``return`` による終了と例外による終了の両方を含みま" +"す)。\n" +"ピュア Python (バイトコード) の関数でのみ発火します。" -#: ../../howto/instrumentation.rst:296 msgid "The arguments are the same as for :c:func:`!function__entry`" -msgstr "" +msgstr "引数は :c:func:`!function__entry` と同じです。" #: ../../howto/instrumentation.rst:300 msgid "" @@ -476,157 +621,152 @@ msgstr "" "これは Python プロファイラによる行ごとのトレースと同等です。\n" "このマーカーは C 関数の内部では起動されません。" -#: ../../howto/instrumentation.rst:304 msgid "The arguments are the same as for :c:func:`!function__entry`." -msgstr "" +msgstr "引数は :c:func:`!function__entry` と同じです。" -#: ../../howto/instrumentation.rst:308 msgid "" "Fires when the Python interpreter starts a garbage collection cycle. " "``arg0`` is the generation to scan, like :func:`gc.collect`." msgstr "" +"Python インタプリタがガベージコレクションのサイクルを開始したときに発火しま" +"す。\n" +"``arg0`` は :func:`gc.collect` と同様に、走査する世代を指定します。" -#: ../../howto/instrumentation.rst:313 msgid "" "Fires when the Python interpreter finishes a garbage collection cycle. " "``arg0`` is the number of collected objects." msgstr "" -"Python インタプリタによる循環参照のガベージコレクションが完了したときに発火し" -"ます。\n" +"Python インタプリタがガベージコレクションのサイクルを終了したときに発火しま" +"す。\n" "``arg0`` は回収したオブジェクトの数です。" -#: ../../howto/instrumentation.rst:318 msgid "" "Fires before :mod:`importlib` attempts to find and load the module. ``arg0`` " "is the module name." msgstr "" +":mod:`importlib` がモジュールの検索と読み込みを試みる前に発火します。\n" +"``arg0`` はモジュール名です。" -#: ../../howto/instrumentation.rst:325 msgid "" "Fires after :mod:`importlib`'s find_and_load function is called. ``arg0`` is " "the module name, ``arg1`` indicates if module was successfully loaded." msgstr "" +":mod:`importlib` の find_and_load 関数が呼び出された後に発火します。\n" +"``arg0`` はモジュール名で、``arg1`` はモジュールの読み込みが成功したかどうか" +"を示します。" -#: ../../howto/instrumentation.rst:334 msgid "" "Fires when :func:`sys.audit` or :c:func:`PySys_Audit` is called. ``arg0`` is " "the event name as C string, ``arg1`` is a :c:type:`PyObject` pointer to a " "tuple object." msgstr "" +":func:`sys.audit` または :c:func:`PySys_Audit` が呼び出されたときに発火しま" +"す。\n" +"``arg0`` は C 文字列のイベント名、``arg1`` はタプルオブジェクトへの :c:type:" +"`PyObject` ポインタです。" -#: ../../howto/instrumentation.rst:342 msgid "C Entry Points" -msgstr "" +msgstr "C エントリーポイント" -#: ../../howto/instrumentation.rst:344 msgid "" "To simplify triggering of DTrace markers, Python's C API comes with a number " "of helper functions that mirror each static marker. On builds of Python " "without DTrace enabled, these do nothing." msgstr "" +"DTrace マーカーを簡単に発火させられるように、Python の C API は各静的マーカー" +"に対応するヘルパー関数を提供しています。\n" +"DTrace を有効にせずにビルドした Python では、これらの関数は何もしません。" -#: ../../howto/instrumentation.rst:348 msgid "" "In general, it is not necessary to call these yourself, as Python will do it " "for you." -msgstr "" +msgstr "通常は Python が呼び出すため、自分で呼び出す必要はありません。" -#: ../../howto/instrumentation.rst:355 msgid "C API Function" -msgstr "" +msgstr "C API 関数" -#: ../../howto/instrumentation.rst:356 msgid "Static Marker" -msgstr "" +msgstr "静的マーカー" #: ../../howto/instrumentation.rst:357 msgid "Notes" msgstr "注釈" -#: ../../howto/instrumentation.rst:359 msgid ":c:func:`!line`" -msgstr "" +msgstr ":c:func:`!line`" -#: ../../howto/instrumentation.rst:362 msgid ":c:func:`!function__entry`" -msgstr "" +msgstr ":c:func:`!function__entry`" -#: ../../howto/instrumentation.rst:365 msgid ":c:func:`!function__return`" -msgstr "" +msgstr ":c:func:`!function__return`" -#: ../../howto/instrumentation.rst:368 msgid ":c:func:`!gc__start`" -msgstr "" +msgstr ":c:func:`!gc__start`" -#: ../../howto/instrumentation.rst:371 msgid ":c:func:`!gc__done`" -msgstr "" +msgstr ":c:func:`!gc__done`" -#: ../../howto/instrumentation.rst:374 msgid ":c:func:`!instance__new__start`" -msgstr "" +msgstr ":c:func:`!instance__new__start`" -#: ../../howto/instrumentation.rst:375 ../../howto/instrumentation.rst:378 -#: ../../howto/instrumentation.rst:381 ../../howto/instrumentation.rst:384 msgid "Not used by Python" -msgstr "" +msgstr "Python では未使用" -#: ../../howto/instrumentation.rst:377 msgid ":c:func:`!instance__new__done`" -msgstr "" +msgstr ":c:func:`!instance__new__done`" -#: ../../howto/instrumentation.rst:380 msgid ":c:func:`!instance__delete__start`" -msgstr "" +msgstr ":c:func:`!instance__delete__start`" -#: ../../howto/instrumentation.rst:383 msgid ":c:func:`!instance__delete__done`" -msgstr "" +msgstr ":c:func:`!instance__delete__done`" -#: ../../howto/instrumentation.rst:386 msgid ":c:func:`!import__find__load__start`" -msgstr "" +msgstr ":c:func:`!import__find__load__start`" -#: ../../howto/instrumentation.rst:389 msgid ":c:func:`!import__find__load__done`" -msgstr "" +msgstr ":c:func:`!import__find__load__done`" -#: ../../howto/instrumentation.rst:392 msgid ":c:func:`!audit`" -msgstr "" +msgstr ":c:func:`!audit`" -#: ../../howto/instrumentation.rst:397 msgid "C Probing Checks" -msgstr "" +msgstr "C でのプローブの有効性確認" -#: ../../howto/instrumentation.rst:412 msgid "" "All calls to ``PyDTrace`` functions must be guarded by a call to one of " "these functions. This allows Python to minimize performance impact when " "probing is disabled." msgstr "" +"``PyDTrace`` 関数の呼び出しはすべて、これらの関数のいずれかを呼び出して有効性" +"を確認してから行う必要があります。\n" +"これにより、プローブが無効なときの性能への影響を最小限に抑えられます。" -#: ../../howto/instrumentation.rst:416 msgid "" "On builds without DTrace enabled, these functions do nothing and return " "``0``." msgstr "" +"DTrace を有効にせずにビルドした場合、これらの関数は何もせず ``0`` を返しま" +"す。" #: ../../howto/instrumentation.rst:420 msgid "SystemTap Tapsets" msgstr "SystemTap Tapset" -#: ../../howto/instrumentation.rst:422 msgid "" "The higher-level way to use the SystemTap integration is to use a " "\"tapset\": SystemTap's equivalent of a library, which hides some of the " "lower-level details of the static markers." msgstr "" +"SystemTap との連携を高レベルで行う方法は、\"tapset\" を使うことです。\n" +"これは SystemTap のライブラリに相当し、静的マーカーの低レベルの詳細の一部を隠" +"します。" -#: ../../howto/instrumentation.rst:426 msgid "Here is a tapset file, based on a non-shared build of CPython:" msgstr "" +"共有ライブラリを使わない CPython のビルドを対象とする tapset ファイルの例を示" +"します:" #: ../../howto/instrumentation.rst:428 msgid "" @@ -651,17 +791,19 @@ msgid "" "}" msgstr "" -#: ../../howto/instrumentation.rst:449 msgid "" "If this file is installed in SystemTap's tapset directory (e.g. ``/usr/share/" "systemtap/tapset``), then these additional probepoints become available:" msgstr "" +"このファイルを SystemTap の tapset ディレクトリ (例えば ``/usr/share/" +"systemtap/tapset``) にインストールすると、次のプローブポイントが利用できます:" -#: ../../howto/instrumentation.rst:455 msgid "" "This probe point indicates that execution of a Python function has begun. It " "is only triggered for pure-Python (bytecode) functions." msgstr "" +"このプローブポイントは Python 関数の実行が開始されたことを示します。\n" +"ピュア Python (バイトコード) の関数でのみ発火します。" #: ../../howto/instrumentation.rst:460 msgid "" @@ -675,14 +817,15 @@ msgstr "" msgid "Examples" msgstr "使用例" -#: ../../howto/instrumentation.rst:468 msgid "" "This SystemTap script uses the tapset above to more cleanly implement the " "example given above of tracing the Python function-call hierarchy, without " "needing to directly name the static markers:" msgstr "" +"次の SystemTap スクリプトは上の tapset を使い、先ほどの Python 関数の呼び出し" +"階層をトレースする例を簡潔に実装しています。\n" +"静的マーカーの名前を直接指定する必要がありません:" -#: ../../howto/instrumentation.rst:472 msgid "" "probe python.function.entry\n" "{\n" @@ -696,15 +839,28 @@ msgid "" " thread_indent(-1), funcname, filename, lineno);\n" "}" msgstr "" +"probe python.function.entry\n" +"{\n" +" printf(\"%s => %s in %s:%d\\n\",\n" +" thread_indent(1), funcname, filename, lineno);\n" +"}\n" +"\n" +"probe python.function.return\n" +"{\n" +" printf(\"%s <= %s in %s:%d\\n\",\n" +" thread_indent(-1), funcname, filename, lineno);\n" +"}" -#: ../../howto/instrumentation.rst:487 msgid "" "The following script uses the tapset above to provide a top-like view of all " "running CPython code, showing the top 20 most frequently entered bytecode " "frames, each second, across the whole system:" msgstr "" +"次のスクリプトは上の tapset を使い、実行中の CPython コード全体を top のよう" +"に表示します。\n" +"システム全体で最も頻繁に実行が開始されたバイトコードフレームの上位 20 件を毎" +"秒表示します:" -#: ../../howto/instrumentation.rst:491 msgid "" "global fn_calls;\n" "\n" @@ -725,3 +881,21 @@ msgid "" " delete fn_calls;\n" "}" msgstr "" +"global fn_calls;\n" +"\n" +"probe python.function.entry\n" +"{\n" +" fn_calls[pid(), filename, funcname, lineno] += 1;\n" +"}\n" +"\n" +"probe timer.ms(1000) {\n" +" printf(\"\\033[2J\\033[1;1H\") /* clear screen \\*/\n" +" printf(\"%6s %80s %6s %30s %6s\\n\",\n" +" \"PID\", \"FILENAME\", \"LINE\", \"FUNCTION\", \"CALLS\")\n" +" foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {\n" +" printf(\"%6d %80s %6d %30s %6d\\n\",\n" +" pid, filename, lineno, funcname,\n" +" fn_calls[pid, filename, funcname, lineno]);\n" +" }\n" +" delete fn_calls;\n" +"}" diff --git a/howto/ipaddress.po b/howto/ipaddress.po index 947b0187d..0f2afd8e1 100644 --- a/howto/ipaddress.po +++ b/howto/ipaddress.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/ipaddress.rst:9 @@ -114,13 +114,16 @@ msgstr "" "アドレスは整数から直接作成することも可能です。32ビットに収まる値はIPv4アドレ" "スであるとみなされます::" -#: ../../howto/ipaddress.rst:61 msgid "" ">>> ipaddress.ip_address(3221225985)\n" "IPv4Address('192.0.2.1')\n" ">>> ipaddress.ip_address(42540766411282592856903984951653826561)\n" "IPv6Address('2001:db8::1')" msgstr "" +">>> ipaddress.ip_address(3221225985)\n" +"IPv4Address('192.0.2.1')\n" +">>> ipaddress.ip_address(42540766411282592856903984951653826561)\n" +"IPv6Address('2001:db8::1')" #: ../../howto/ipaddress.rst:66 msgid "" @@ -131,7 +134,6 @@ msgstr "" "IPv4またはIPv6アドレスの使用を強制するには、適切なクラスを直接呼び出す必要が" "あります。これは特にIPv6アドレスを小さな整数で作成する場合に役立ちます::" -#: ../../howto/ipaddress.rst:70 msgid "" ">>> ipaddress.ip_address(1)\n" "IPv4Address('0.0.0.1')\n" @@ -140,12 +142,17 @@ msgid "" ">>> ipaddress.IPv6Address(1)\n" "IPv6Address('::1')" msgstr "" +">>> ipaddress.ip_address(1)\n" +"IPv4Address('0.0.0.1')\n" +">>> ipaddress.IPv4Address(1)\n" +"IPv4Address('0.0.0.1')\n" +">>> ipaddress.IPv6Address(1)\n" +"IPv6Address('::1')" #: ../../howto/ipaddress.rst:79 msgid "Defining Networks" msgstr "ネットワークを定義する" -#: ../../howto/ipaddress.rst:81 msgid "" "Host addresses are usually grouped together into IP networks, so :mod:" "`ipaddress` provides a way to create, inspect and manipulate network " @@ -156,29 +163,34 @@ msgid "" "whether or not an address is part of the network and the network address " "defines the expected value of those bits." msgstr "" -"ホストアドレスは通常IPネットワークへ統合され、 :mod:`ipaddress` はネットワー" -"ク定義の作成、検査、操作の手段を提供します。IPネットワークオブジェクトはネッ" -"トワークの一部であるホストアドレスの範囲を定義する文字列から生成されます。こ" -"の情報の最も単純な形式は「ネットワークアドレス/ネットワークプレフィックス」の" -"ペアであり、プレフィックスは先頭のビット数として定義され、アドレスがネット" -"ワークの一部であるかどうか、それらのビットに期待される値がネットワークアドレ" -"スに定義されているかを判断するために比較されます。" +"ホストアドレスは通常 IP ネットワークにまとめられます。\n" +"そのため :mod:`ipaddress` はネットワーク定義を作成、検査、操作する方法を提供" +"しています。\n" +"IP ネットワークオブジェクトは、そのネットワークに属するホストアドレスの範囲を" +"定義する文字列から作成します。\n" +"最も単純な形式は「ネットワークアドレス/ネットワークプレフィックス」の組で" +"す。\n" +"プレフィックスは、アドレスがネットワークに属するかを判定するために比較する、" +"先頭からのビット数を定義します。\n" +"ネットワークアドレスは、そのビット列に期待する値を定義します。" -#: ../../howto/ipaddress.rst:90 msgid "" "As for addresses, a factory function is provided that determines the correct " "IP version automatically::" msgstr "" -"アドレスについては、正しいIPバージョンを自動的に判断するファクトリー関数が提" -"供されます::" +"アドレスと同様に、適切な IP バージョンを自動的に判定するファクトリー関数が用" +"意されています。 ::" -#: ../../howto/ipaddress.rst:93 msgid "" ">>> ipaddress.ip_network('192.0.2.0/24')\n" "IPv4Network('192.0.2.0/24')\n" ">>> ipaddress.ip_network('2001:db8::0/96')\n" "IPv6Network('2001:db8::/96')" msgstr "" +">>> ipaddress.ip_network('192.0.2.0/24')\n" +"IPv4Network('192.0.2.0/24')\n" +">>> ipaddress.ip_network('2001:db8::0/96')\n" +"IPv6Network('2001:db8::/96')" #: ../../howto/ipaddress.rst:98 msgid "" @@ -194,19 +206,17 @@ msgstr "" "トワーク上のネットワークインターフェースを表すのに使用されるため、このような" "定義はインターフェースオブジェクトと呼ばれます。" -#: ../../howto/ipaddress.rst:104 msgid "" "By default, attempting to create a network object with host bits set will " "result in :exc:`ValueError` being raised. To request that the additional " "bits instead be coerced to zero, the flag ``strict=False`` can be passed to " "the constructor::" msgstr "" -"デフォルトでは、ホストビットセットの指定でネットワークオブジェクトを作成しよ" -"うとすると :exc:`ValueError` が発生する結果となります。 ``strict=False`` フラ" -"グをコンストラクタに渡すと、追加分のビットをゼロとして強制的に処理するように" -"要求できます::" +"デフォルトでは、ホスト部のビットに 1 が含まれるネットワークオブジェクトを作成" +"しようとすると :exc:`ValueError` が送出されます。\n" +"コンストラクタに ``strict=False`` を渡すと、代わりにそのビットをゼロにできま" +"す。 ::" -#: ../../howto/ipaddress.rst:109 msgid "" ">>> ipaddress.ip_network('192.0.2.1/24')\n" "Traceback (most recent call last):\n" @@ -215,6 +225,12 @@ msgid "" ">>> ipaddress.ip_network('192.0.2.1/24', strict=False)\n" "IPv4Network('192.0.2.0/24')" msgstr "" +">>> ipaddress.ip_network('192.0.2.1/24')\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: 192.0.2.1/24 has host bits set\n" +">>> ipaddress.ip_network('192.0.2.1/24', strict=False)\n" +"IPv4Network('192.0.2.0/24')" #: ../../howto/ipaddress.rst:116 msgid "" @@ -228,21 +244,23 @@ msgstr "" "特定できる単一のアドレスのみを含むものとして処理され、ネットワークプレフィッ" "クスはネットワークアドレスの全体を含みます::" -#: ../../howto/ipaddress.rst:121 msgid "" ">>> ipaddress.ip_network(3221225984)\n" "IPv4Network('192.0.2.0/32')\n" ">>> ipaddress.ip_network(42540766411282592856903984951653826560)\n" "IPv6Network('2001:db8::/128')" msgstr "" +">>> ipaddress.ip_network(3221225984)\n" +"IPv4Network('192.0.2.0/32')\n" +">>> ipaddress.ip_network(42540766411282592856903984951653826560)\n" +"IPv6Network('2001:db8::/128')" -#: ../../howto/ipaddress.rst:126 msgid "" "As with addresses, creation of a particular kind of network can be forced by " "calling the class constructor directly instead of using the factory function." msgstr "" -"アドレスについては、ファクトリー関数を呼ぶ代わりにクラスコンストラクタを直接" -"呼ぶことで、作成対象のネットワークを特定の種類に強制することができます。" +"アドレスと同様に、ファクトリー関数の代わりにクラスのコンストラクタを直接呼び" +"出すと、作成するネットワークの種類を指定できます。" #: ../../howto/ipaddress.rst:132 msgid "Host Interfaces" @@ -277,9 +295,8 @@ msgstr "" "整数入力は(ネットワークと同様に)受け入れられ、適切なコンストラクタを直接呼び" "出すことで特定のIPバージョンの使用を強制できます。" -#: ../../howto/ipaddress.rst:154 msgid "Inspecting Address/Network/Interface Objects" -msgstr "アドレス/ネットワーク/インターフェースオブジェクト" +msgstr "アドレス/ネットワーク/インターフェースオブジェクトの情報を調べる" #: ../../howto/ipaddress.rst:156 msgid "" @@ -295,7 +312,6 @@ msgstr "" msgid "Extracting the IP version::" msgstr "IPバージョンを抽出する::" -#: ../../howto/ipaddress.rst:162 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> addr6 = ipaddress.ip_address('2001:db8::1')\n" @@ -304,12 +320,17 @@ msgid "" ">>> addr4.version\n" "4" msgstr "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> addr6 = ipaddress.ip_address('2001:db8::1')\n" +">>> addr6.version\n" +"6\n" +">>> addr4.version\n" +"4" #: ../../howto/ipaddress.rst:169 msgid "Obtaining the network from an interface::" msgstr "インターフェースからネットワークを取得する::" -#: ../../howto/ipaddress.rst:171 msgid "" ">>> host4 = ipaddress.ip_interface('192.0.2.1/24')\n" ">>> host4.network\n" @@ -318,12 +339,17 @@ msgid "" ">>> host6.network\n" "IPv6Network('2001:db8::/96')" msgstr "" +">>> host4 = ipaddress.ip_interface('192.0.2.1/24')\n" +">>> host4.network\n" +"IPv4Network('192.0.2.0/24')\n" +">>> host6 = ipaddress.ip_interface('2001:db8::1/96')\n" +">>> host6.network\n" +"IPv6Network('2001:db8::/96')" #: ../../howto/ipaddress.rst:178 msgid "Finding out how many individual addresses are in a network::" msgstr "個別なアドレスがいくつネットワークに存在するかを調べる::" -#: ../../howto/ipaddress.rst:180 msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> net4.num_addresses\n" @@ -332,12 +358,17 @@ msgid "" ">>> net6.num_addresses\n" "4294967296" msgstr "" +">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" +">>> net4.num_addresses\n" +"256\n" +">>> net6 = ipaddress.ip_network('2001:db8::0/96')\n" +">>> net6.num_addresses\n" +"4294967296" #: ../../howto/ipaddress.rst:187 msgid "Iterating through the \"usable\" addresses on a network::" msgstr "「使用可能」なネットワーク上のアドレスを順番にたどる::" -#: ../../howto/ipaddress.rst:189 msgid "" ">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" ">>> for x in net4.hosts():\n" @@ -351,20 +382,29 @@ msgid "" "192.0.2.253\n" "192.0.2.254" msgstr "" +">>> net4 = ipaddress.ip_network('192.0.2.0/24')\n" +">>> for x in net4.hosts():\n" +"... print(x)\n" +"192.0.2.1\n" +"192.0.2.2\n" +"192.0.2.3\n" +"192.0.2.4\n" +"...\n" +"192.0.2.252\n" +"192.0.2.253\n" +"192.0.2.254" -#: ../../howto/ipaddress.rst:202 msgid "" "Obtaining the netmask (i.e. set bits corresponding to the network prefix) or " "the hostmask (any bits that are not part of the netmask):" msgstr "" -"ネットマスクを取得(例: ネットワークプレフィックスに応じてビットを設定)したり" -"ホストマスク(ネットマスクの一部ではない任意のビット)を取得する:" +"ネットマスク (ネットワークプレフィックスに対応するビットが 1 のマスク) やホス" +"トマスク (ネットマスクに含まれないビットが 1 のマスク) を取得する:" #: ../../howto/ipaddress.rst:217 msgid "Exploding or compressing the address::" msgstr "アドレスを展開したり圧縮したりする::" -#: ../../howto/ipaddress.rst:219 msgid "" ">>> addr6.exploded\n" "'2001:0db8:0000:0000:0000:0000:0000:0001'\n" @@ -375,6 +415,14 @@ msgid "" ">>> net6.compressed\n" "'2001:db8::/96'" msgstr "" +">>> addr6.exploded\n" +"'2001:0db8:0000:0000:0000:0000:0000:0001'\n" +">>> addr6.compressed\n" +"'2001:db8::1'\n" +">>> net6.exploded\n" +"'2001:0db8:0000:0000:0000:0000:0000:0000/96'\n" +">>> net6.compressed\n" +"'2001:db8::/96'" #: ../../howto/ipaddress.rst:228 msgid "" @@ -400,7 +448,6 @@ msgstr "" "ネットワークをリストとして扱うと便利な場合があります。これは、ネットワークを" "次のようにインデックス付けすることが可能なことを意味します::" -#: ../../howto/ipaddress.rst:240 msgid "" ">>> net4[1]\n" "IPv4Address('192.0.2.1')\n" @@ -411,6 +458,14 @@ msgid "" ">>> net6[-1]\n" "IPv6Address('2001:db8::ffff:ffff')" msgstr "" +">>> net4[1]\n" +"IPv4Address('192.0.2.1')\n" +">>> net4[-1]\n" +"IPv4Address('192.0.2.255')\n" +">>> net6[1]\n" +"IPv6Address('2001:db8::1')\n" +">>> net6[-1]\n" +"IPv6Address('2001:db8::ffff:ffff')" #: ../../howto/ipaddress.rst:250 msgid "" @@ -420,11 +475,12 @@ msgstr "" "以下のようなリストのメンバーシップの判定用文法が使用可能なように、ネットワー" "クオブジェクト自身が適応します::" -#: ../../howto/ipaddress.rst:253 msgid "" "if address in network:\n" " # do something" msgstr "" +"if address in network:\n" +" # 何らかの処理をする" #: ../../howto/ipaddress.rst:256 msgid "Containment testing is done efficiently based on the network prefix::" @@ -432,7 +488,6 @@ msgstr "" "ネットワークプレフィックスに基づき、所属しているかどうかの判定が効果的にでき" "ます::" -#: ../../howto/ipaddress.rst:258 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> addr4 in ipaddress.ip_network('192.0.2.0/24')\n" @@ -440,24 +495,29 @@ msgid "" ">>> addr4 in ipaddress.ip_network('192.0.3.0/24')\n" "False" msgstr "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> addr4 in ipaddress.ip_network('192.0.2.0/24')\n" +"True\n" +">>> addr4 in ipaddress.ip_network('192.0.3.0/24')\n" +"False" #: ../../howto/ipaddress.rst:266 msgid "Comparisons" msgstr "比較" -#: ../../howto/ipaddress.rst:268 msgid "" ":mod:`ipaddress` provides some simple, hopefully intuitive ways to compare " "objects, where it makes sense::" msgstr "" -":mod:`ipaddress` はオブジェクトの比較をするための単純で、かつ願わくば直観的な" -"方法を意味が通じるように提供します::" +":mod:`ipaddress` は、比較に意味がある場合にオブジェクトを比較する、単純で直感" +"的な方法を提供しています。 ::" -#: ../../howto/ipaddress.rst:271 msgid "" ">>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')\n" "True" msgstr "" +">>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')\n" +"True" #: ../../howto/ipaddress.rst:274 msgid "" @@ -481,7 +541,6 @@ msgstr "" "らオブジェクトを直接受け付けません。直接渡すのではなく、他のモジュールが受け" "付ける整数や文字列に強制的に変換する必要があります::" -#: ../../howto/ipaddress.rst:285 msgid "" ">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" ">>> str(addr4)\n" @@ -489,12 +548,16 @@ msgid "" ">>> int(addr4)\n" "3221225985" msgstr "" +">>> addr4 = ipaddress.ip_address('192.0.2.1')\n" +">>> str(addr4)\n" +"'192.0.2.1'\n" +">>> int(addr4)\n" +"3221225985" #: ../../howto/ipaddress.rst:293 msgid "Getting more detail when instance creation fails" msgstr "インスタンスの生成に失敗した場合にさらに詳細を取得する" -#: ../../howto/ipaddress.rst:295 msgid "" "When creating address/network/interface objects using the version-agnostic " "factory functions, any errors will be reported as :exc:`ValueError` with a " @@ -503,12 +566,13 @@ msgid "" "because it's necessary to know whether the value is *supposed* to be IPv4 or " "IPv6 in order to provide more detail on why it has been rejected." msgstr "" -"上述したバージョンに関知しないファクトリー関数を使用してアドレス/ネットワー" -"ク/インターフェースオブジェクトを作成する場合、渡された値がそのタイプのオブ" -"ジェクトとして認識されなかったと単純に通知する汎用的なメッセージとともに、ど" -"のエラーでも :exc:`ValueError` として報告されます。特定のエラーが提供されない" -"のは、拒否された理由をより詳細に提供するために、値がIPv4またはIPv6である *は" -"ず* かどうかを知る必要があるためです。" +"IP バージョンを自動判定するファクトリー関数でアドレス、ネットワーク、インター" +"フェースのオブジェクトを作成すると、エラーはすべて :exc:`ValueError` として報" +"告されます。\n" +"メッセージは、渡された値をその種類のオブジェクトとして認識できなかったという" +"一般的なものです。\n" +"値が拒否された理由を詳しく説明するには、入力が IPv4 と IPv6 の *どちらを意図" +"しているか* を知る必要があるためです。" #: ../../howto/ipaddress.rst:302 msgid "" @@ -531,7 +595,6 @@ msgstr "" "クラスコンストラクタを直接使用する場合にはこれらのエラーメッセージはさらに非" "常に詳細になっています。例えば::" -#: ../../howto/ipaddress.rst:311 msgid "" ">>> ipaddress.ip_address(\"192.168.0.256\")\n" "Traceback (most recent call last):\n" @@ -552,6 +615,24 @@ msgid "" " ...\n" "ipaddress.NetmaskValueError: '64' is not a valid netmask" msgstr "" +">>> ipaddress.ip_address(\"192.168.0.256\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: '192.168.0.256' does not appear to be an IPv4 or IPv6 address\n" +">>> ipaddress.IPv4Address(\"192.168.0.256\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ipaddress.AddressValueError: Octet 256 (> 255) not permitted in " +"'192.168.0.256'\n" +"\n" +">>> ipaddress.ip_network(\"192.168.0.1/64\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: '192.168.0.1/64' does not appear to be an IPv4 or IPv6 network\n" +">>> ipaddress.IPv4Network(\"192.168.0.1/64\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"ipaddress.NetmaskValueError: '64' is not a valid netmask" #: ../../howto/ipaddress.rst:329 msgid "" @@ -563,10 +644,13 @@ msgstr "" "スとして持ち、エラーの特定のタイプに興味がない場合でも、以下のようにコードを" "記述できます::" -#: ../../howto/ipaddress.rst:333 msgid "" "try:\n" " network = ipaddress.IPv4Network(address)\n" "except ValueError:\n" " print('address/netmask is invalid for IPv4:', address)" msgstr "" +"try:\n" +" network = ipaddress.IPv4Network(address)\n" +"except ValueError:\n" +" print('address/netmask is invalid for IPv4:', address)" diff --git a/howto/isolating-extensions.po b/howto/isolating-extensions.po index 49f5e3139..6f4f01a1b 100644 --- a/howto/isolating-extensions.po +++ b/howto/isolating-extensions.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/isolating-extensions.rst:7 @@ -31,70 +31,85 @@ msgstr "拡張モジュールを分離する" msgid "Abstract" msgstr "概要" -#: ../../howto/isolating-extensions.rst:11 msgid "" "Traditionally, state belonging to Python extension modules was kept in C " "``static`` variables, which have process-wide scope. This document describes " "problems of such per-process state and shows a safer way: per-module state." msgstr "" +"従来、Python 拡張モジュールの状態は、プロセス全体をスコープとする C の " +"``static`` 変数に保持されていました。\n" +"このドキュメントでは、プロセスごとの状態が抱える問題と、より安全な方法である" +"モジュールごとの状態について説明します。" -#: ../../howto/isolating-extensions.rst:16 msgid "" "The document also describes how to switch to per-module state where " "possible. This transition involves allocating space for that state, " "potentially switching from static types to heap types, and—perhaps most " "importantly—accessing per-module state from code." msgstr "" +"また、可能な場合にモジュールごとの状態へ移行する方法も説明します。\n" +"移行には状態の領域の割り当て、必要に応じた静的な型からヒープ型への切り替え、" +"そして特に重要な、コードからモジュールごとの状態へのアクセスが伴います。" -#: ../../howto/isolating-extensions.rst:23 msgid "Who should read this" -msgstr "" +msgstr "対象読者" -#: ../../howto/isolating-extensions.rst:25 msgid "" "This guide is written for maintainers of :ref:`C-API ` " "extensions who would like to make that extension safer to use in " "applications where Python itself is used as a library." msgstr "" +"このガイドは、Python 自体をライブラリとして使うアプリケーションでも安全に利用" +"できる拡張にしたいと考えている、:ref:`C API ` 拡張の保守担当者を" +"対象としています。" #: ../../howto/isolating-extensions.rst:31 msgid "Background" msgstr "背景" -#: ../../howto/isolating-extensions.rst:33 msgid "" "An *interpreter* is the context in which Python code runs. It contains " "configuration (e.g. the import path) and runtime state (e.g. the set of " "imported modules)." msgstr "" +"*インタープリタ* は Python コードが実行されるコンテキストです。\n" +"インポートパスなどの設定と、インポート済みモジュールの集合などの実行時の状態" +"を含みます。" -#: ../../howto/isolating-extensions.rst:37 msgid "" "Python supports running multiple interpreters in one process. There are two " "cases to think about—users may run interpreters:" msgstr "" +"Python は一つのプロセス内で複数のインタープリタを実行できます。\n" +"次の二つの場合を考える必要があります:" -#: ../../howto/isolating-extensions.rst:40 msgid "" "in sequence, with several :c:func:`Py_InitializeEx`/:c:func:`Py_FinalizeEx` " "cycles, and" msgstr "" +":c:func:`Py_InitializeEx` と :c:func:`Py_FinalizeEx` のサイクルを繰り返し、順" +"番に実行する場合。" -#: ../../howto/isolating-extensions.rst:42 msgid "" "in parallel, managing \"sub-interpreters\" using :c:func:" "`Py_NewInterpreter`/:c:func:`Py_EndInterpreter`." msgstr "" +":c:func:`Py_NewInterpreter` と :c:func:`Py_EndInterpreter` で「サブインタープ" +"リタ」を管理し、並列に実行する場合。" -#: ../../howto/isolating-extensions.rst:45 msgid "" "Both cases (and combinations of them) would be most useful when embedding " "Python within a library. Libraries generally shouldn't make assumptions " "about the application that uses them, which include assuming a process-wide " "\"main Python interpreter\"." msgstr "" +"どちらも (また両者の組み合わせも)、Python をライブラリに埋め込む場合に特に役" +"立ちます。\n" +"一般にライブラリは、それを使うアプリケーションについて仮定を置くべきではあり" +"ません。\n" +"プロセス全体に一つの「メインの Python インタープリタ」があるという仮定も同様" +"です。" -#: ../../howto/isolating-extensions.rst:50 msgid "" "Historically, Python extension modules don't handle this use case well. Many " "extension modules (and even some stdlib modules) use *per-process* global " @@ -104,19 +119,28 @@ msgid "" "introduce edge cases that lead to crashes when a module is loaded in more " "than one interpreter in the same process." msgstr "" +"歴史的に、Python 拡張モジュールはこの用途にうまく対応していません。\n" +"C の ``static`` 変数が非常に手軽に使えるため、多くの拡張モジュール (標準ライ" +"ブラリの一部も含みます) は *プロセスごと* のグローバルな状態を使っていま" +"す。\n" +"その結果、インタープリタ固有であるべきデータがインタープリタ間で共有されてし" +"まいます。\n" +"拡張の開発者が注意しないと、同じプロセスの複数のインタープリタにモジュールを" +"読み込んだ場合に、特殊な条件でクラッシュする問題を簡単に持ち込んでしまいま" +"す。" -#: ../../howto/isolating-extensions.rst:58 msgid "" "Unfortunately, *per-interpreter* state is not easy to achieve. Extension " "authors tend to not keep multiple interpreters in mind when developing, and " "it is currently cumbersome to test the behavior." msgstr "" +"残念ながら、*インタープリタごと* の状態を実現するのは簡単ではありません。\n" +"拡張の開発者は複数のインタープリタを考慮せずに開発しがちで、現在はその動作の" +"テストにも手間がかかります。" -#: ../../howto/isolating-extensions.rst:63 msgid "Enter Per-Module State" -msgstr "" +msgstr "モジュールごとの状態の導入" -#: ../../howto/isolating-extensions.rst:65 msgid "" "Instead of focusing on per-interpreter state, Python's C API is evolving to " "better support the more granular *per-module* state. This means that C-level " @@ -125,8 +149,14 @@ msgid "" "multiple module objects corresponding to a single extension can even be " "loaded in a single interpreter." msgstr "" +"Python の C API はインタープリタごとの状態よりも、さらに細かい単位の *モ" +"ジュールごと* の状態を扱いやすくする方向へ進化しています。\n" +"つまり、C レベルのデータは *モジュールオブジェクト* に結び付けるべきです。\n" +"各インタープリタが独自のモジュールオブジェクトを作成することで、データを分離" +"します。\n" +"分離をテストするために、一つの拡張に対応する複数のモジュールオブジェクトを、" +"一つのインタープリタに読み込むこともできます。" -#: ../../howto/isolating-extensions.rst:72 msgid "" "Per-module state provides an easy way to think about lifetime and resource " "ownership: the extension module will initialize when a module object is " @@ -134,8 +164,14 @@ msgid "" "any other :c:expr:`PyObject *`; there are no \"on interpreter shutdown\" " "hooks to think—or forget—about." msgstr "" +"モジュールごとの状態を使うと、寿命とリソースの所有関係を簡単に考えられま" +"す。\n" +"モジュールオブジェクトの作成時に拡張モジュールを初期化し、解放時に後始末をし" +"ます。\n" +"この点ではモジュールは他の :c:expr:`PyObject *` と同じです。\n" +"「インタープリタ終了時」のフックを考慮する必要も、それを忘れる心配もありませ" +"ん。" -#: ../../howto/isolating-extensions.rst:78 msgid "" "Note that there are use cases for different kinds of \"globals\": per-" "process, per-interpreter, per-thread or per-task state. With per-module " @@ -143,17 +179,24 @@ msgid "" "exceptional cases: if you need them, you should give them additional care " "and testing. (Note that this guide does not cover them.)" msgstr "" +"プロセスごと、インタープリタごと、スレッドごと、タスクごとの状態など、異なる" +"種類の「グローバル」な状態にも用途があります。\n" +"モジュールごとの状態を基本としても、これらを使うことはできます。\n" +"ただし例外的な場合として扱い、必要なら追加の注意とテストを行ってください。\n" +"このガイドではこれらは扱いません。" #: ../../howto/isolating-extensions.rst:87 msgid "Isolated Module Objects" msgstr "分離されたモジュールオブジェクト" -#: ../../howto/isolating-extensions.rst:89 msgid "" "The key point to keep in mind when developing an extension module is that " "several module objects can be created from a single shared library. For " "example:" msgstr "" +"拡張モジュールの開発で押さえるべき点は、一つの共有ライブラリから複数のモ" +"ジュールオブジェクトが作成され得るということです。\n" +"例えば:" #: ../../howto/isolating-extensions.rst:93 msgid "" @@ -173,7 +216,6 @@ msgstr "" ">>> old_binascii == binascii\n" "False" -#: ../../howto/isolating-extensions.rst:103 msgid "" "As a rule of thumb, the two modules should be completely independent. All " "objects and state specific to the module should be encapsulated within the " @@ -182,19 +224,26 @@ msgid "" "are possible (see `Managing Global State`_), but they will need more thought " "and attention to edge cases." msgstr "" +"原則として、二つのモジュールは完全に独立しているべきです。\n" +"モジュール固有のすべてのオブジェクトと状態をモジュールオブジェクト内にカプセ" +"ル化し、他のモジュールオブジェクトと共有せず、モジュールオブジェクトの解放時" +"に後始末してください。\n" +"これはあくまで原則なので例外はあります (`グローバルな状態の管理 `_ を参照)。\n" +"ただし、例外的な扱いにはより慎重な検討と特殊な条件への注意が必要です。" -#: ../../howto/isolating-extensions.rst:111 msgid "" "While some modules could do with less stringent restrictions, isolated " "modules make it easier to set clear expectations and guidelines that work " "across a variety of use cases." msgstr "" +"一部のモジュールでは制約を緩められるかもしれません。\n" +"それでもモジュールを分離すると、さまざまな用途に通用する明確な期待動作や指針" +"を定めやすくなります。" -#: ../../howto/isolating-extensions.rst:117 msgid "Surprising Edge Cases" -msgstr "" +msgstr "意外な動作が生じる場合" -#: ../../howto/isolating-extensions.rst:119 msgid "" "Note that isolated modules do create some surprising edge cases. Most " "notably, each module object will typically not share its classes and " @@ -203,8 +252,13 @@ msgid "" "``binascii.Error`` are separate objects. In the following code, the " "exception is *not* caught:" msgstr "" +"モジュールを分離すると、一部の場合に意外な動作が生じます。\n" +"特に、通常は各モジュールオブジェクトがクラスや例外を同種の別のモジュールと共" +"有しません。\n" +"`先ほどの例 `__ の続きでは、``old_binascii.Error`` " +"と ``binascii.Error`` は別のオブジェクトです。\n" +"次のコードでは例外は捕捉 *されません*:" -#: ../../howto/isolating-extensions.rst:126 msgid "" ">>> old_binascii.Error == binascii.Error\n" "False\n" @@ -217,44 +271,57 @@ msgid "" " File \"\", line 2, in \n" "binascii.Error: Non-hexadecimal digit found" msgstr "" +">>> old_binascii.Error == binascii.Error\n" +"False\n" +">>> try:\n" +"... old_binascii.unhexlify(b'qwertyuiop')\n" +"... except binascii.Error:\n" +"... print('boo')\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 2, in \n" +"binascii.Error: Non-hexadecimal digit found" -#: ../../howto/isolating-extensions.rst:139 msgid "" "This is expected. Notice that pure-Python modules behave the same way: it is " "a part of how Python works." msgstr "" +"これは想定された動作です。\n" +"ピュア Python のモジュールも同じように動作します。\n" +"これは Python の仕組みの一部です。" -#: ../../howto/isolating-extensions.rst:142 msgid "" "The goal is to make extension modules safe at the C level, not to make hacks " "behave intuitively. Mutating ``sys.modules`` \"manually\" counts as a hack." msgstr "" +"目標は拡張モジュールを C レベルで安全にすることであり、特殊な操作を直感的に動" +"作させることではありません。\n" +"``sys.modules`` を「手作業で」変更するのは、そうした特殊な操作に当たります。" -#: ../../howto/isolating-extensions.rst:148 msgid "Making Modules Safe with Multiple Interpreters" -msgstr "" +msgstr "複数のインタープリタでも安全なモジュールにする" -#: ../../howto/isolating-extensions.rst:152 msgid "Managing Global State" -msgstr "" +msgstr "グローバルな状態の管理" -#: ../../howto/isolating-extensions.rst:154 msgid "" "Sometimes, the state associated with a Python module is not specific to that " "module, but to the entire process (or something else \"more global\" than a " "module). For example:" msgstr "" +"Python モジュールに関連する状態が、そのモジュール固有ではなく、プロセス全体 " +"(またはモジュールより「広域」のもの) に属する場合もあります。\n" +"例えば:" -#: ../../howto/isolating-extensions.rst:158 msgid "The ``readline`` module manages *the* terminal." -msgstr "" +msgstr "``readline`` モジュールは、そのプロセスの *端末* を管理します。" -#: ../../howto/isolating-extensions.rst:159 msgid "" "A module running on a circuit board wants to control *the* on-board LED." msgstr "" +"回路基板で動作するモジュールは、その *基板上の LED* を制御したいかもしれませ" +"ん。" -#: ../../howto/isolating-extensions.rst:162 msgid "" "In these cases, the Python module should provide *access* to the global " "state, rather than *own* it. If possible, write the module so that multiple " @@ -262,27 +329,36 @@ msgid "" "whether for Python or other languages). If that is not possible, consider " "explicit locking." msgstr "" +"このような場合、Python モジュールはグローバルな状態を *所有* するのではなく、" +"その状態への *アクセス* を提供するべきです。\n" +"可能なら、モジュールの複数のコピーが独立して状態にアクセスできるようにしてく" +"ださい (Python や他の言語用の別のライブラリも同時にアクセスすることがありま" +"す)。\n" +"それが不可能なら、明示的なロックを検討してください。" -#: ../../howto/isolating-extensions.rst:168 msgid "" "If it is necessary to use process-global state, the simplest way to avoid " "issues with multiple interpreters is to explicitly prevent a module from " "being loaded more than once per process—see :ref:`isolating-extensions-" "optout`." msgstr "" +"プロセス全体の状態を使う必要がある場合、複数のインタープリタに起因する問題を" +"避ける最も簡単な方法は、一つのプロセスでモジュールを複数回読み込めないよう明" +"示的に制限することです。\n" +":ref:`isolating-extensions-optout` を参照してください。" -#: ../../howto/isolating-extensions.rst:175 msgid "Managing Per-Module State" -msgstr "" +msgstr "モジュールごとの状態の管理" -#: ../../howto/isolating-extensions.rst:177 msgid "" "To use per-module state, use :ref:`multi-phase extension module " "initialization `. This signals that your module " "supports multiple interpreters correctly." msgstr "" +"モジュールごとの状態を使うには、:ref:`拡張モジュールの複数フェーズ初期化 " +"` を使います。\n" +"これはモジュールが複数のインタープリタを正しくサポートすることを示します。" -#: ../../howto/isolating-extensions.rst:181 msgid "" "Set ``PyModuleDef.m_size`` to a positive number to request that many bytes " "of storage local to the module. Usually, this will be set to the size of " @@ -292,22 +368,33 @@ msgid "" "``csv``'s :py:data:`~csv.field_size_limit`) which the C code needs to " "function." msgstr "" +"``PyModuleDef.m_size`` に正の数を設定すると、そのバイト数のモジュール専用の記" +"憶領域を確保できます。\n" +"通常は、モジュールの C レベルの状態をすべて格納する、モジュール固有の " +"``struct`` のサイズを指定します。\n" +"特に、C コードの動作に必要なクラスへのポインタ (例外を含み、静的な型を除きま" +"す) や、``csv`` の :py:data:`~csv.field_size_limit` などの設定は、ここに格納" +"してください。" -#: ../../howto/isolating-extensions.rst:190 msgid "" "Another option is to store state in the module's ``__dict__``, but you must " "avoid crashing when users modify ``__dict__`` from Python code. This usually " "means error- and type-checking at the C level, which is easy to get wrong " "and hard to test sufficiently." msgstr "" +"状態をモジュールの ``__dict__`` に格納する方法もありますが、ユーザーが " +"Python コードで ``__dict__`` を変更してもクラッシュしないようにする必要があり" +"ます。\n" +"通常は C レベルでエラーや型を検査することになりますが、これは間違えやすく、十" +"分なテストも困難です。" -#: ../../howto/isolating-extensions.rst:195 msgid "" "However, if module state is not needed in C code, storing it in ``__dict__`` " "only is a good idea." msgstr "" +"ただし、C コードでモジュールの状態を使わないなら、``__dict__`` だけに格納する" +"のがよい方法です。" -#: ../../howto/isolating-extensions.rst:198 msgid "" "If the module state includes ``PyObject`` pointers, the module object must " "hold references to those objects and implement the module-level hooks " @@ -316,27 +403,38 @@ msgid "" "and make the code longer; this is the price for modules which can be " "unloaded cleanly." msgstr "" +"モジュールの状態に ``PyObject`` ポインタが含まれる場合、モジュールオブジェク" +"トはそのオブジェクトへの参照を保持し、モジュールレベルのフック " +"``m_traverse``、``m_clear``、``m_free`` を実装する必要があります。\n" +"これらはクラスの ``tp_traverse``、``tp_clear``、``tp_free`` のように働きま" +"す。\n" +"フックの追加には手間がかかり、コードも長くなります。\n" +"これはモジュールをきれいに解放できるようにするための代償です。" -#: ../../howto/isolating-extensions.rst:205 msgid "" "An example of a module with per-module state is currently available as " "`xxlimited `__; example module initialization shown at the bottom of the file." msgstr "" +"モジュールごとの状態を使うモジュールの例として、`xxlimited `__ があります。\n" +"モジュールの初期化の例はファイルの末尾にあります。" -#: ../../howto/isolating-extensions.rst:213 msgid "Opt-Out: Limiting to One Module Object per Process" -msgstr "" +msgstr "対応しない場合: プロセスごとに一つのモジュールオブジェクトに制限する" -#: ../../howto/isolating-extensions.rst:215 msgid "" "A non-negative ``PyModuleDef.m_size`` signals that a module supports " "multiple interpreters correctly. If this is not yet the case for your " "module, you can explicitly make your module loadable only once per process. " "For example::" msgstr "" +"``PyModuleDef.m_size`` が非負であることは、モジュールが複数のインタープリタを" +"正しくサポートすることを示します。\n" +"まだ対応していない場合は、プロセスごとに一度だけ読み込めるよう明示的に制限で" +"きます。\n" +"例えば次のようにします。 ::" -#: ../../howto/isolating-extensions.rst:220 msgid "" "// A process-wide flag\n" "static int loaded = 0;\n" @@ -359,8 +457,28 @@ msgid "" " // ... rest of initialization\n" "}" msgstr "" +"// プロセス全体で共有するフラグ\n" +"static int loaded = 0;\n" +"\n" +"// スレッド安全性を確保するミューテックス (フリースレッド版 Python でのみ必" +"要)\n" +"static PyMutex modinit_mutex = {0};\n" +"\n" +"static int\n" +"exec_module(PyObject* module)\n" +"{\n" +" PyMutex_Lock(&modinit_mutex);\n" +" if (loaded) {\n" +" PyMutex_Unlock(&modinit_mutex);\n" +" PyErr_SetString(PyExc_ImportError,\n" +" \"cannot load module more than once per process\");\n" +" return -1;\n" +" }\n" +" loaded = 1;\n" +" PyMutex_Unlock(&modinit_mutex);\n" +" // ... 残りの初期化処理\n" +"}" -#: ../../howto/isolating-extensions.rst:242 msgid "" "If your module's :c:member:`PyModuleDef.m_clear` function is able to prepare " "for future re-initialization, it should clear the ``loaded`` flag. In this " @@ -368,19 +486,24 @@ msgid "" "but it will, for example, support being loaded after Python runtime shutdown " "(:c:func:`Py_FinalizeEx`) and re-initialization (:c:func:`Py_Initialize`)." msgstr "" +"モジュールの :c:member:`PyModuleDef.m_clear` 関数で将来の再初期化に備えられる" +"場合は、そこで ``loaded`` フラグをクリアしてください。\n" +"この場合、複数のインスタンスの *同時* 存在はサポートしませんが、例えば " +"Python ランタイムを終了 (:c:func:`Py_FinalizeEx`) してから再初期化 (:c:func:" +"`Py_Initialize`) した後で、モジュールを読み込むことはできます。" -#: ../../howto/isolating-extensions.rst:251 msgid "Module State Access from Functions" -msgstr "" +msgstr "関数からモジュールの状態にアクセスする" -#: ../../howto/isolating-extensions.rst:253 msgid "" "Accessing the state from module-level functions is straightforward. " "Functions get the module object as their first argument; for extracting the " "state, you can use ``PyModule_GetState``::" msgstr "" +"モジュールレベルの関数から状態にアクセスするのは簡単です。\n" +"関数の最初の引数にはモジュールオブジェクトが渡されます。\n" +"``PyModule_GetState`` を使うと状態を取得できます。 ::" -#: ../../howto/isolating-extensions.rst:257 msgid "" "static PyObject *\n" "func(PyObject *module, PyObject *args)\n" @@ -392,32 +515,48 @@ msgid "" " // ... rest of logic\n" "}" msgstr "" +"static PyObject *\n" +"func(PyObject *module, PyObject *args)\n" +"{\n" +" my_struct *state = (my_struct*)PyModule_GetState(module);\n" +" if (state == NULL) {\n" +" return NULL;\n" +" }\n" +" // ... 残りの処理\n" +"}" -#: ../../howto/isolating-extensions.rst:268 msgid "" "``PyModule_GetState`` may return ``NULL`` without setting an exception if " "there is no module state, i.e. ``PyModuleDef.m_size`` was zero. In your own " "module, you're in control of ``m_size``, so this is easy to prevent." msgstr "" +"モジュールの状態がない場合、つまり ``PyModuleDef.m_size`` がゼロの場合、" +"``PyModule_GetState`` は例外を設定せずに ``NULL`` を返すことがあります。\n" +"自分のモジュールでは ``m_size`` を管理できるので、これは簡単に防げます。" -#: ../../howto/isolating-extensions.rst:275 msgid "Heap Types" -msgstr "" +msgstr "ヒープ型" -#: ../../howto/isolating-extensions.rst:277 msgid "" "Traditionally, types defined in C code are *static*; that is, ``static " "PyTypeObject`` structures defined directly in code and initialized using " "``PyType_Ready()``." msgstr "" +"従来、C コードで定義する型は *静的* なものです。\n" +"つまり、コード内に ``static PyTypeObject`` 構造体を直接定義し、" +"``PyType_Ready()`` で初期化します。" -#: ../../howto/isolating-extensions.rst:281 msgid "" "Such types are necessarily shared across the process. Sharing them between " "module objects requires paying attention to any state they own or access. To " "limit the possible issues, static types are immutable at the Python level: " "for example, you can't set ``str.myattribute = 123``." msgstr "" +"このような型は必然的にプロセス全体で共有されます。\n" +"モジュールオブジェクト間で共有するには、その型が所有したりアクセスしたりする" +"状態に注意が必要です。\n" +"問題を抑えるため、静的な型は Python レベルでは不変になっています。\n" +"例えば ``str.myattribute = 123`` は設定できません。" #: ../../howto/isolating-extensions.rst:287 msgid "" @@ -429,7 +568,6 @@ msgid "" "process-wide GIL." msgstr "" -#: ../../howto/isolating-extensions.rst:294 msgid "" "Because they are immutable and process-global, static types cannot access " "\"their\" module state. If any method of such a type requires access to " @@ -437,16 +575,18 @@ msgid "" "*heap type* for short. These correspond more closely to classes created by " "Python's ``class`` statement." msgstr "" +"静的な型は不変で、プロセス全体に属するため、「自分の」モジュールの状態にアク" +"セスできません。\n" +"その型のメソッドがモジュールの状態にアクセスする必要がある場合、*ヒープに割り" +"当てる型*、略して *ヒープ型* に変換しなければなりません。\n" +"ヒープ型は Python の ``class`` 文で作成するクラスにより近いものです。" -#: ../../howto/isolating-extensions.rst:301 msgid "For new modules, using heap types by default is a good rule of thumb." -msgstr "" +msgstr "新しいモジュールでは、基本的にヒープ型を使うのがよい方針です。" -#: ../../howto/isolating-extensions.rst:305 msgid "Changing Static Types to Heap Types" -msgstr "" +msgstr "静的な型をヒープ型に変更する" -#: ../../howto/isolating-extensions.rst:307 msgid "" "Static types can be converted to heap types, but note that the heap type API " "was not designed for \"lossless\" conversion from static types—that is, " @@ -455,102 +595,122 @@ msgid "" "unintentionally change a few details (e.g. pickleability or inherited " "slots). Always test the details that are important to you." msgstr "" +"静的な型はヒープ型に変換できます。\n" +"ただし、ヒープ型の API は「完全に同じ動作を保つ」変換、つまり元の静的な型と" +"まったく同じ動作をする型の作成を目的に設計されたものではありません。\n" +"新しい API でクラス定義を書き直すと、pickle 化の可否や継承するスロットなど、" +"一部の詳細が意図せず変わることがあります。\n" +"重要な点は必ずテストしてください。" -#: ../../howto/isolating-extensions.rst:316 msgid "" "Watch out for the following two points in particular (but note that this is " "not a comprehensive list):" -msgstr "" +msgstr "特に次の二点に注意してください (ただし、これですべてではありません):" -#: ../../howto/isolating-extensions.rst:319 msgid "" "Unlike static types, heap type objects are mutable by default. Use the :c:" "macro:`Py_TPFLAGS_IMMUTABLETYPE` flag to prevent mutability." msgstr "" +"静的な型とは異なり、ヒープ型のオブジェクトはデフォルトで可変です。\n" +"変更を禁止するには :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` フラグを使ってくださ" +"い。" -#: ../../howto/isolating-extensions.rst:321 msgid "" "Heap types inherit :c:member:`~PyTypeObject.tp_new` by default, so it may " "become possible to instantiate them from Python code. You can prevent this " "with the :c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` flag." msgstr "" +"ヒープ型はデフォルトで :c:member:`~PyTypeObject.tp_new` を継承するため、" +"Python コードからインスタンスを作成できるようになる場合があります。\n" +":c:macro:`Py_TPFLAGS_DISALLOW_INSTANTIATION` フラグでこれを防げます。" -#: ../../howto/isolating-extensions.rst:327 msgid "Defining Heap Types" -msgstr "" +msgstr "ヒープ型の定義" -#: ../../howto/isolating-extensions.rst:329 msgid "" "Heap types can be created by filling a :c:struct:`PyType_Spec` structure, a " "description or \"blueprint\" of a class, and calling :c:func:" "`PyType_FromModuleAndSpec` to construct a new class object." msgstr "" +"ヒープ型は、クラスの説明や「設計図」に当たる :c:struct:`PyType_Spec` 構造体に" +"値を設定し、:c:func:`PyType_FromModuleAndSpec` を呼び出して新しいクラスオブ" +"ジェクトを構築することで作成できます。" -#: ../../howto/isolating-extensions.rst:334 msgid "" "Other functions, like :c:func:`PyType_FromSpec`, can also create heap types, " "but :c:func:`PyType_FromModuleAndSpec` associates the module with the class, " "allowing access to the module state from methods." msgstr "" +":c:func:`PyType_FromSpec` などの他の関数でもヒープ型を作成できますが、:c:" +"func:`PyType_FromModuleAndSpec` はクラスにモジュールを関連付けるため、メソッ" +"ドからモジュールの状態にアクセスできます。" -#: ../../howto/isolating-extensions.rst:338 msgid "" "The class should generally be stored in *both* the module state (for safe " "access from C) and the module's ``__dict__`` (for access from Python code)." msgstr "" +"一般にクラスは、C から安全にアクセスするためのモジュールの状態と、Python コー" +"ドからアクセスするためのモジュールの ``__dict__`` の *両方* に格納してくださ" +"い。" -#: ../../howto/isolating-extensions.rst:344 msgid "Garbage-Collection Protocol" -msgstr "" +msgstr "ガベージコレクションのプロトコル" -#: ../../howto/isolating-extensions.rst:346 msgid "" "Instances of heap types hold a reference to their type. This ensures that " "the type isn't destroyed before all its instances are, but may result in " "reference cycles that need to be broken by the garbage collector." msgstr "" +"ヒープ型のインスタンスは自分の型への参照を保持します。\n" +"これにより、すべてのインスタンスが破棄されるまで型は破棄されません。\n" +"ただし、ガベージコレクタで解消する必要のある循環参照が生じる場合があります。" -#: ../../howto/isolating-extensions.rst:351 msgid "" "To avoid memory leaks, instances of heap types must implement the garbage " "collection protocol. That is, heap types should:" msgstr "" +"メモリリークを防ぐには、ヒープ型のインスタンスでガベージコレクションのプロト" +"コルを実装する必要があります。\n" +"具体的には、ヒープ型で次を行います:" -#: ../../howto/isolating-extensions.rst:355 msgid "Have the :c:macro:`Py_TPFLAGS_HAVE_GC` flag." -msgstr "" +msgstr ":c:macro:`Py_TPFLAGS_HAVE_GC` フラグを設定する。" -#: ../../howto/isolating-extensions.rst:356 msgid "" "Define a traverse function using :c:data:`Py_tp_traverse`, which visits the " "type (e.g. using ``Py_VISIT(Py_TYPE(self))``)." msgstr "" +":c:data:`Py_tp_traverse` で走査関数を定義し、例えば " +"``Py_VISIT(Py_TYPE(self))`` を使って型を訪問する。" -#: ../../howto/isolating-extensions.rst:359 msgid "" "Please refer to the documentation of :c:macro:`Py_TPFLAGS_HAVE_GC` and :c:" "member:`~PyTypeObject.tp_traverse` for additional considerations." msgstr "" +"その他の注意点は :c:macro:`Py_TPFLAGS_HAVE_GC` と :c:member:`~PyTypeObject." +"tp_traverse` のドキュメントを参照してください。" -#: ../../howto/isolating-extensions.rst:363 msgid "" "The API for defining heap types grew organically, leaving it somewhat " "awkward to use in its current state. The following sections will guide you " "through common issues." msgstr "" +"ヒープ型を定義する API は必要に応じて拡張されてきたため、現在の形には多少使い" +"づらいところがあります。\n" +"以降の節では、よくある問題を説明します。" -#: ../../howto/isolating-extensions.rst:369 msgid "``tp_traverse`` in Python 3.8 and lower" -msgstr "" +msgstr "Python 3.8 以前の ``tp_traverse``" -#: ../../howto/isolating-extensions.rst:371 msgid "" "The requirement to visit the type from ``tp_traverse`` was added in Python " "3.9. If you support Python 3.8 and lower, the traverse function must *not* " "visit the type, so it must be more complicated::" msgstr "" +"``tp_traverse`` から型を訪問するという要件は Python 3.9 で追加されました。\n" +"Python 3.8 以前をサポートする場合、走査関数は型を訪問しては *ならない* ため、" +"少し複雑になります。 ::" -#: ../../howto/isolating-extensions.rst:375 msgid "" "static int my_traverse(PyObject *self, visitproc visit, void *arg)\n" "{\n" @@ -560,48 +720,54 @@ msgid "" " return 0;\n" "}" msgstr "" +"static int my_traverse(PyObject *self, visitproc visit, void *arg)\n" +"{\n" +" if (Py_Version >= 0x03090000) {\n" +" Py_VISIT(Py_TYPE(self));\n" +" }\n" +" return 0;\n" +"}" -#: ../../howto/isolating-extensions.rst:383 msgid "" "Unfortunately, :c:data:`Py_Version` was only added in Python 3.11. As a " "replacement, use:" msgstr "" +"残念ながら :c:data:`Py_Version` が追加されたのは Python 3.11 です。\n" +"代わりに次を使ってください:" -#: ../../howto/isolating-extensions.rst:386 msgid ":c:macro:`PY_VERSION_HEX`, if not using the stable ABI, or" -msgstr "" +msgstr "Stable ABI を使わない場合は :c:macro:`PY_VERSION_HEX`。" -#: ../../howto/isolating-extensions.rst:387 msgid "" ":py:data:`sys.version_info` (via :c:func:`PySys_GetObject` and :c:func:" "`PyArg_ParseTuple`)." msgstr "" +"それ以外は :py:data:`sys.version_info` (:c:func:`PySys_GetObject` と :c:func:" +"`PyArg_ParseTuple` を介して取得)。" -#: ../../howto/isolating-extensions.rst:392 msgid "Delegating ``tp_traverse``" -msgstr "" +msgstr "``tp_traverse`` の委譲" -#: ../../howto/isolating-extensions.rst:394 msgid "" "If your traverse function delegates to the :c:member:`~PyTypeObject." "tp_traverse` of its base class (or another type), ensure that " "``Py_TYPE(self)`` is visited only once. Note that only heap type are " "expected to visit the type in ``tp_traverse``." msgstr "" +"走査関数が基底クラス (または他の型) の :c:member:`~PyTypeObject.tp_traverse` " +"に処理を委譲する場合、``Py_TYPE(self)`` を訪問するのが一度だけになるようにし" +"てください。\n" +"``tp_traverse`` で型を訪問するのはヒープ型だけです。" -#: ../../howto/isolating-extensions.rst:399 msgid "For example, if your traverse function includes::" -msgstr "" +msgstr "例えば、走査関数に次が含まれ、 ::" -#: ../../howto/isolating-extensions.rst:401 msgid "base->tp_traverse(self, visit, arg)" -msgstr "" +msgstr "base->tp_traverse(self, visit, arg)" -#: ../../howto/isolating-extensions.rst:403 msgid "...and ``base`` may be a static type, then it should also include::" -msgstr "" +msgstr "``base`` が静的な型の場合もあるなら、次も追加してください。 ::" -#: ../../howto/isolating-extensions.rst:405 msgid "" "if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" " // a heap type's tp_traverse already visited Py_TYPE(self)\n" @@ -611,39 +777,48 @@ msgid "" " }\n" "}" msgstr "" +"if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {\n" +" // ヒープ型の tp_traverse はすでに Py_TYPE(self) を訪問している\n" +"} else {\n" +" if (Py_Version >= 0x03090000) {\n" +" Py_VISIT(Py_TYPE(self));\n" +" }\n" +"}" -#: ../../howto/isolating-extensions.rst:413 msgid "" "It is not necessary to handle the type's reference count in :c:member:" "`~PyTypeObject.tp_new` and :c:member:`~PyTypeObject.tp_clear`." msgstr "" +":c:member:`~PyTypeObject.tp_new` と :c:member:`~PyTypeObject.tp_clear` で型の" +"参照カウントを操作する必要はありません。" -#: ../../howto/isolating-extensions.rst:418 msgid "Defining ``tp_dealloc``" -msgstr "" +msgstr "``tp_dealloc`` の定義" -#: ../../howto/isolating-extensions.rst:420 msgid "" "If your type has a custom :c:member:`~PyTypeObject.tp_dealloc` function, it " "needs to:" msgstr "" +"型に独自の :c:member:`~PyTypeObject.tp_dealloc` 関数がある場合、次の処理が必" +"要です:" -#: ../../howto/isolating-extensions.rst:423 msgid "" "call :c:func:`PyObject_GC_UnTrack` before any fields are invalidated, and" msgstr "" +"いずれかのフィールドを無効にする前に :c:func:`PyObject_GC_UnTrack` を呼び出" +"す。" -#: ../../howto/isolating-extensions.rst:424 msgid "decrement the reference count of the type." -msgstr "" +msgstr "型の参照カウントを減らす。" -#: ../../howto/isolating-extensions.rst:426 msgid "" "To keep the type valid while ``tp_free`` is called, the type's refcount " "needs to be decremented *after* the instance is deallocated. For example::" msgstr "" +"``tp_free`` の呼び出し中も型を有効に保つため、型の参照カウントはインスタンス" +"を解放した *後* に減らす必要があります。\n" +"例えば次のようにします。 ::" -#: ../../howto/isolating-extensions.rst:429 msgid "" "static void my_dealloc(PyObject *self)\n" "{\n" @@ -654,122 +829,149 @@ msgid "" " Py_DECREF(type);\n" "}" msgstr "" +"static void my_dealloc(PyObject *self)\n" +"{\n" +" PyObject_GC_UnTrack(self);\n" +" ...\n" +" PyTypeObject *type = Py_TYPE(self);\n" +" type->tp_free(self);\n" +" Py_DECREF(type);\n" +"}" -#: ../../howto/isolating-extensions.rst:438 msgid "" "The default ``tp_dealloc`` function does this, so if your type does *not* " "override ``tp_dealloc`` you don't need to add it." msgstr "" +"デフォルトの ``tp_dealloc`` 関数はこの処理を行うため、``tp_dealloc`` をオー" +"バーライド *しない* 型では追加する必要はありません。" -#: ../../howto/isolating-extensions.rst:444 msgid "Not overriding ``tp_free``" -msgstr "" +msgstr "``tp_free`` をオーバーライドしない" -#: ../../howto/isolating-extensions.rst:446 msgid "" "The :c:member:`~PyTypeObject.tp_free` slot of a heap type must be set to :c:" "func:`PyObject_GC_Del`. This is the default; do not override it." msgstr "" +"ヒープ型の :c:member:`~PyTypeObject.tp_free` スロットは :c:func:" +"`PyObject_GC_Del` に設定する必要があります。\n" +"これがデフォルトなので、オーバーライドしないでください。" -#: ../../howto/isolating-extensions.rst:452 msgid "Avoiding ``PyObject_New``" -msgstr "" +msgstr "``PyObject_New`` を避ける" -#: ../../howto/isolating-extensions.rst:454 msgid "GC-tracked objects need to be allocated using GC-aware functions." msgstr "" +"GC が追跡するオブジェクトは、GC に対応した関数で割り当てる必要があります。" -#: ../../howto/isolating-extensions.rst:456 msgid "If you use :c:func:`PyObject_New` or :c:func:`PyObject_NewVar`:" -msgstr "" +msgstr ":c:func:`PyObject_New` や :c:func:`PyObject_NewVar` を使っている場合:" -#: ../../howto/isolating-extensions.rst:458 msgid "" "Get and call type's :c:member:`~PyTypeObject.tp_alloc` slot, if possible. " "That is, replace ``TYPE *o = PyObject_New(TYPE, typeobj)`` with::" msgstr "" +"可能なら、型の :c:member:`~PyTypeObject.tp_alloc` スロットを取得して呼び出し" +"てください。\n" +"つまり ``TYPE *o = PyObject_New(TYPE, typeobj)`` を次に置き換えます。 ::" -#: ../../howto/isolating-extensions.rst:461 msgid "TYPE *o = typeobj->tp_alloc(typeobj, 0);" -msgstr "" +msgstr "TYPE *o = typeobj->tp_alloc(typeobj, 0);" -#: ../../howto/isolating-extensions.rst:463 msgid "" "Replace ``o = PyObject_NewVar(TYPE, typeobj, size)`` with the same, but use " "size instead of the 0." msgstr "" +"``o = PyObject_NewVar(TYPE, typeobj, size)`` も同様に置き換えますが、0 の代わ" +"りに ``size`` を使います。" -#: ../../howto/isolating-extensions.rst:466 msgid "" "If the above is not possible (e.g. inside a custom ``tp_alloc``), call :c:" "func:`PyObject_GC_New` or :c:func:`PyObject_GC_NewVar`::" msgstr "" +"それができない場合 (例えば独自の ``tp_alloc`` の内部) は、:c:func:" +"`PyObject_GC_New` または :c:func:`PyObject_GC_NewVar` を呼び出してくださ" +"い。 ::" -#: ../../howto/isolating-extensions.rst:469 msgid "" "TYPE *o = PyObject_GC_New(TYPE, typeobj);\n" "\n" "TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);" msgstr "" +"TYPE *o = PyObject_GC_New(TYPE, typeobj);\n" +"\n" +"TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);" -#: ../../howto/isolating-extensions.rst:475 msgid "Module State Access from Classes" -msgstr "" +msgstr "クラスからモジュールの状態にアクセスする" -#: ../../howto/isolating-extensions.rst:477 msgid "" "If you have a type object defined with :c:func:`PyType_FromModuleAndSpec`, " "you can call :c:func:`PyType_GetModule` to get the associated module, and " "then :c:func:`PyModule_GetState` to get the module's state." msgstr "" +":c:func:`PyType_FromModuleAndSpec` で定義した型オブジェクトがあれば、:c:func:" +"`PyType_GetModule` で関連付けられたモジュールを取得し、:c:func:" +"`PyModule_GetState` でその状態を取得できます。" -#: ../../howto/isolating-extensions.rst:481 msgid "" "To save a some tedious error-handling boilerplate code, you can combine " "these two steps with :c:func:`PyType_GetModuleState`, resulting in::" msgstr "" +"エラー処理の定型コードを省くには、:c:func:`PyType_GetModuleState` でこの二つ" +"の手順をまとめられます。 ::" -#: ../../howto/isolating-extensions.rst:484 msgid "" "my_struct *state = (my_struct*)PyType_GetModuleState(type);\n" "if (state == NULL) {\n" " return NULL;\n" "}" msgstr "" +"my_struct *state = (my_struct*)PyType_GetModuleState(type);\n" +"if (state == NULL) {\n" +" return NULL;\n" +"}" -#: ../../howto/isolating-extensions.rst:491 msgid "Module State Access from Regular Methods" -msgstr "" +msgstr "通常のメソッドからモジュールの状態にアクセスする" -#: ../../howto/isolating-extensions.rst:493 msgid "" "Accessing the module-level state from methods of a class is somewhat more " "complicated, but is possible thanks to API introduced in Python 3.9. To get " "the state, you need to first get the *defining class*, and then get the " "module state from it." msgstr "" +"クラスのメソッドからモジュールレベルの状態にアクセスするのは少し複雑ですが、" +"Python 3.9 で導入された API により可能になりました。\n" +"まず *メソッドを定義したクラス* を取得し、そのクラスからモジュールの状態を取" +"得します。" -#: ../../howto/isolating-extensions.rst:498 msgid "" "The largest roadblock is getting *the class a method was defined in*, or " "that method's \"defining class\" for short. The defining class can have a " "reference to the module it is part of." msgstr "" +"最大の難所は、*メソッドが定義されたクラス*、略して「定義クラス」を取得するこ" +"とです。\n" +"定義クラスは、そのクラスが属するモジュールへの参照を保持できます。" -#: ../../howto/isolating-extensions.rst:502 msgid "" "Do not confuse the defining class with ``Py_TYPE(self)``. If the method is " "called on a *subclass* of your type, ``Py_TYPE(self)`` will refer to that " "subclass, which may be defined in different module than yours." msgstr "" +"定義クラスと ``Py_TYPE(self)`` を混同しないでください。\n" +"型の *サブクラス* のインスタンスでメソッドが呼び出された場合、" +"``Py_TYPE(self)`` はそのサブクラスを指します。\n" +"そのサブクラスは別のモジュールで定義されているかもしれません。" -#: ../../howto/isolating-extensions.rst:507 msgid "" "The following Python code can illustrate the concept. ``Base." "get_defining_class`` returns ``Base`` even if ``type(self) == Sub``:" msgstr "" +"次の Python コードでこの考え方を示します。\n" +"``Base.get_defining_class`` は ``type(self) == Sub`` の場合でも ``Base`` を返" +"します:" -#: ../../howto/isolating-extensions.rst:511 msgid "" "class Base:\n" " def get_type_of_self(self):\n" @@ -781,14 +983,26 @@ msgid "" "class Sub(Base):\n" " pass" msgstr "" +"class Base:\n" +" def get_type_of_self(self):\n" +" return type(self)\n" +"\n" +" def get_defining_class(self):\n" +" return __class__\n" +"\n" +"class Sub(Base):\n" +" pass" -#: ../../howto/isolating-extensions.rst:523 msgid "" "For a method to get its \"defining class\", it must use the :ref:" "`METH_METHOD | METH_FASTCALL | METH_KEYWORDS ` :c:type:`calling convention ` and the " "corresponding :c:type:`PyCMethod` signature::" msgstr "" +"メソッドが「定義クラス」を取得するには、:ref:`METH_METHOD | METH_FASTCALL | " +"METH_KEYWORDS ` :c:type:`呼び出し規" +"約 ` と、それに対応する :c:type:`PyCMethod` シグネチャを使う必要" +"があります。 ::" #: ../../howto/isolating-extensions.rst:528 msgid "" @@ -800,11 +1014,12 @@ msgid "" " PyObject *kwnames) // NULL, or dict of keyword arguments" msgstr "" -#: ../../howto/isolating-extensions.rst:535 msgid "" "Once you have the defining class, call :c:func:`PyType_GetModuleState` to " "get the state of its associated module." msgstr "" +"定義クラスを取得したら、:c:func:`PyType_GetModuleState` を呼び出して、関連付" +"けられたモジュールの状態を取得します。" #: ../../howto/isolating-extensions.rst:538 msgid "For example::" @@ -837,15 +1052,13 @@ msgid "" "}" msgstr "" -#: ../../howto/isolating-extensions.rst:566 msgid "Module State Access from Slot Methods, Getters and Setters" -msgstr "" +msgstr "スロットメソッド、ゲッター、セッターからモジュールの状態にアクセスする" #: ../../howto/isolating-extensions.rst:570 msgid "This is new in Python 3.11." msgstr "これは Python 3.11 の新機能です。" -#: ../../howto/isolating-extensions.rst:578 msgid "" "Slot methods—the fast C equivalents for special methods, such as :c:member:" "`~PyNumberMethods.nb_add` for :py:attr:`~object.__add__` or :c:member:" @@ -854,15 +1067,23 @@ msgid "" "`PyCMethod`. The same goes for getters and setters defined with :c:type:" "`PyGetSetDef`." msgstr "" +"スロットメソッドは、特殊メソッドに相当する高速な C の処理です。\n" +"例えば :py:attr:`~object.__add__` に対応する :c:member:`~PyNumberMethods." +"nb_add` や、初期化に使う :c:member:`~PyTypeObject.tp_new` があります。\n" +"これらの API は非常に単純で、:c:type:`PyCMethod` とは異なり定義クラスを渡せま" +"せん。\n" +":c:type:`PyGetSetDef` で定義するゲッターやセッターも同様です。" -#: ../../howto/isolating-extensions.rst:585 msgid "" "To access the module state in these cases, use the :c:func:" "`PyType_GetModuleByDef` function, and pass in the module definition. Once " "you have the module, call :c:func:`PyModule_GetState` to get the state::" msgstr "" +"このような場合にモジュールの状態にアクセスするには、:c:func:" +"`PyType_GetModuleByDef` 関数にモジュール定義を渡します。\n" +"モジュールを取得したら、:c:func:`PyModule_GetState` を呼び出して状態を取得し" +"ます。 ::" -#: ../../howto/isolating-extensions.rst:590 msgid "" "PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def);\n" "my_struct *state = (my_struct*)PyModule_GetState(module);\n" @@ -870,34 +1091,46 @@ msgid "" " return NULL;\n" "}" msgstr "" +"PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def);\n" +"my_struct *state = (my_struct*)PyModule_GetState(module);\n" +"if (state == NULL) {\n" +" return NULL;\n" +"}" -#: ../../howto/isolating-extensions.rst:596 msgid "" ":c:func:`!PyType_GetModuleByDef` works by searching the :term:`method " "resolution order` (i.e. all superclasses) for the first superclass that has " "a corresponding module." msgstr "" +":c:func:`!PyType_GetModuleByDef` は :term:`method resolution order` (すべての" +"スーパークラス) を検索し、対応するモジュールを持つ最初のスーパークラスを探し" +"ます。" -#: ../../howto/isolating-extensions.rst:602 msgid "" "In very exotic cases (inheritance chains spanning multiple modules created " "from the same definition), :c:func:`!PyType_GetModuleByDef` might not return " "the module of the true defining class. However, it will always return a " "module with the same definition, ensuring a compatible C memory layout." msgstr "" +"非常に特殊な場合 (同じ定義から作成された複数のモジュールに継承関係がまたがる" +"場合)、:c:func:`!PyType_GetModuleByDef` は本来の定義クラスのモジュールを返さ" +"ないことがあります。\n" +"ただし、必ず同じ定義のモジュールを返すため、C のメモリレイアウトの互換性は保" +"証されます。" -#: ../../howto/isolating-extensions.rst:610 msgid "Lifetime of the Module State" -msgstr "" +msgstr "モジュールの状態の寿命" -#: ../../howto/isolating-extensions.rst:612 msgid "" "When a module object is garbage-collected, its module state is freed. For " "each pointer to (a part of) the module state, you must hold a reference to " "the module object." msgstr "" +"モジュールオブジェクトがガベージコレクションで回収されると、モジュールの状態" +"も解放されます。\n" +"モジュールの状態 (またはその一部) へのポインタを保持する間は、それぞれモ" +"ジュールオブジェクトへの参照を保持しなければなりません。" -#: ../../howto/isolating-extensions.rst:616 msgid "" "Usually this is not an issue, because types created with :c:func:" "`PyType_FromModuleAndSpec`, and their instances, hold a reference to the " @@ -905,20 +1138,25 @@ msgid "" "reference module state from other places, such as callbacks for external " "libraries." msgstr "" +":c:func:`PyType_FromModuleAndSpec` で作成した型とそのインスタンスはモジュール" +"への参照を保持するため、通常これは問題になりません。\n" +"ただし、外部ライブラリのコールバックなど、他の場所からモジュールの状態を参照" +"する場合は、参照カウントに注意する必要があります。" #: ../../howto/isolating-extensions.rst:625 msgid "Open Issues" msgstr "取り掛かり中の問題" -#: ../../howto/isolating-extensions.rst:627 msgid "Several issues around per-module state and heap types are still open." msgstr "" +"モジュールごとの状態とヒープ型には、まだ未解決の問題がいくつかあります。" -#: ../../howto/isolating-extensions.rst:629 msgid "" "Discussions about improving the situation are best held on the `discuss " "forum under c-api tag `__." msgstr "" +"改善について議論するには、`discuss フォーラムの c-api カテゴリ `__ が適しています。" #: ../../howto/isolating-extensions.rst:633 msgid "Per-Class Scope" @@ -932,12 +1170,13 @@ msgid "" "per-class scope)." msgstr "" -#: ../../howto/isolating-extensions.rst:642 msgid "Lossless Conversion to Heap Types" -msgstr "" +msgstr "動作を完全に保ったヒープ型への変換" -#: ../../howto/isolating-extensions.rst:644 msgid "" "The heap type API was not designed for \"lossless\" conversion from static " "types; that is, creating a type that works exactly like a given static type." msgstr "" +"ヒープ型の API は、静的な型から動作を完全に保ったまま変換すること、つまり元の" +"静的な型とまったく同じ動作をする型の作成を目的に設計されたものではありませ" +"ん。" diff --git a/howto/logging-cookbook.po b/howto/logging-cookbook.po index 46e6a6e0f..4aff29d08 100644 --- a/howto/logging-cookbook.po +++ b/howto/logging-cookbook.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/logging-cookbook.rst:5 @@ -59,7 +59,6 @@ msgstr "" "ない) ことが可能で、すべての子 logger への呼び出しは親にまで渡されます。まず" "はメインのモジュールです::" -#: ../../howto/logging-cookbook.rst:24 msgid "" "import logging\n" "import auxiliary_module\n" @@ -92,12 +91,41 @@ msgid "" "auxiliary_module.some_function()\n" "logger.info('done with auxiliary_module.some_function()')" msgstr "" +"import logging\n" +"import auxiliary_module\n" +"\n" +"# 'spam_application' という名前のロガーを作成する\n" +"logger = logging.getLogger('spam_application')\n" +"logger.setLevel(logging.DEBUG)\n" +"# デバッグメッセージも記録するファイルハンドラーを作成する\n" +"fh = logging.FileHandler('spam.log')\n" +"fh.setLevel(logging.DEBUG)\n" +"# より高いログレベルのコンソールハンドラーを作成する\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.ERROR)\n" +"# フォーマッターを作成してハンドラーに設定する\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " +"%(message)s')\n" +"fh.setFormatter(formatter)\n" +"ch.setFormatter(formatter)\n" +"# ロガーにハンドラーを追加する\n" +"logger.addHandler(fh)\n" +"logger.addHandler(ch)\n" +"\n" +"logger.info('creating an instance of auxiliary_module.Auxiliary')\n" +"a = auxiliary_module.Auxiliary()\n" +"logger.info('created an instance of auxiliary_module.Auxiliary')\n" +"logger.info('calling auxiliary_module.Auxiliary.do_something')\n" +"a.do_something()\n" +"logger.info('finished auxiliary_module.Auxiliary.do_something')\n" +"logger.info('calling auxiliary_module.some_function()')\n" +"auxiliary_module.some_function()\n" +"logger.info('done with auxiliary_module.some_function()')" #: ../../howto/logging-cookbook.rst:54 msgid "Here is the auxiliary module::" msgstr "そして補助モジュール (auxiliary module) がこちらです::" -#: ../../howto/logging-cookbook.rst:56 msgid "" "import logging\n" "\n" @@ -118,12 +146,29 @@ msgid "" "def some_function():\n" " module_logger.info('received a call to \"some_function\"')" msgstr "" +"import logging\n" +"\n" +"# ロガーを作成する\n" +"module_logger = logging.getLogger('spam_application.auxiliary')\n" +"\n" +"class Auxiliary:\n" +" def __init__(self):\n" +" self.logger = logging.getLogger('spam_application.auxiliary." +"Auxiliary')\n" +" self.logger.info('creating an instance of Auxiliary')\n" +"\n" +" def do_something(self):\n" +" self.logger.info('doing something')\n" +" a = 1 + 1\n" +" self.logger.info('done doing something')\n" +"\n" +"def some_function():\n" +" module_logger.info('received a call to \"some_function\"')" #: ../../howto/logging-cookbook.rst:74 msgid "The output looks like this:" msgstr "出力はこのようになります:" -#: ../../howto/logging-cookbook.rst:76 msgid "" "2005-03-23 23:47:11,663 - spam_application - INFO -\n" " creating an instance of auxiliary_module.Auxiliary\n" @@ -146,6 +191,26 @@ msgid "" "2005-03-23 23:47:11,673 - spam_application - INFO -\n" " done with auxiliary_module.some_function()" msgstr "" +"2005-03-23 23:47:11,663 - spam_application - INFO -\n" +" creating an instance of auxiliary_module.Auxiliary\n" +"2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO -\n" +" creating an instance of Auxiliary\n" +"2005-03-23 23:47:11,665 - spam_application - INFO -\n" +" created an instance of auxiliary_module.Auxiliary\n" +"2005-03-23 23:47:11,668 - spam_application - INFO -\n" +" calling auxiliary_module.Auxiliary.do_something\n" +"2005-03-23 23:47:11,668 - spam_application.auxiliary.Auxiliary - INFO -\n" +" doing something\n" +"2005-03-23 23:47:11,669 - spam_application.auxiliary.Auxiliary - INFO -\n" +" done doing something\n" +"2005-03-23 23:47:11,670 - spam_application - INFO -\n" +" finished auxiliary_module.Auxiliary.do_something\n" +"2005-03-23 23:47:11,671 - spam_application - INFO -\n" +" calling auxiliary_module.some_function()\n" +"2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO -\n" +" received a call to 'some_function'\n" +"2005-03-23 23:47:11,673 - spam_application - INFO -\n" +" done with auxiliary_module.some_function()" #: ../../howto/logging-cookbook.rst:100 msgid "Logging from multiple threads" @@ -159,7 +224,6 @@ msgstr "" "複数スレッドからのロギングでは特別に何かをする必要はありません。\n" "次の例はmain (初期) スレッドとそれ以外のスレッドからのロギングの例です::" -#: ../../howto/logging-cookbook.rst:105 msgid "" "import logging\n" "import threading\n" @@ -188,12 +252,37 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"import logging\n" +"import threading\n" +"import time\n" +"\n" +"def worker(arg):\n" +" while not arg['stop']:\n" +" logging.debug('Hi from myfunc')\n" +" time.sleep(0.5)\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d " +"%(threadName)s %(message)s')\n" +" info = {'stop': False}\n" +" thread = threading.Thread(target=worker, args=(info,))\n" +" thread.start()\n" +" while True:\n" +" try:\n" +" logging.debug('Hello from main')\n" +" time.sleep(0.75)\n" +" except KeyboardInterrupt:\n" +" info['stop'] = True\n" +" break\n" +" thread.join()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../howto/logging-cookbook.rst:131 msgid "When run, the script should print something like the following:" msgstr "実行すると、出力は以下のようになるはずです:" -#: ../../howto/logging-cookbook.rst:133 msgid "" " 0 Thread-1 Hi from myfunc\n" " 3 MainThread Hello from main\n" @@ -213,6 +302,23 @@ msgid "" "4513 MainThread Hello from main\n" "4518 Thread-1 Hi from myfunc" msgstr "" +" 0 Thread-1 Hi from myfunc\n" +" 3 MainThread Hello from main\n" +" 505 Thread-1 Hi from myfunc\n" +" 755 MainThread Hello from main\n" +"1007 Thread-1 Hi from myfunc\n" +"1507 MainThread Hello from main\n" +"1508 Thread-1 Hi from myfunc\n" +"2010 Thread-1 Hi from myfunc\n" +"2258 MainThread Hello from main\n" +"2512 Thread-1 Hi from myfunc\n" +"3009 MainThread Hello from main\n" +"3013 Thread-1 Hi from myfunc\n" +"3515 Thread-1 Hi from myfunc\n" +"3761 MainThread Hello from main\n" +"4017 Thread-1 Hi from myfunc\n" +"4513 MainThread Hello from main\n" +"4518 Thread-1 Hi from myfunc" #: ../../howto/logging-cookbook.rst:153 msgid "" @@ -245,7 +351,6 @@ msgstr "" "コードの中のログ記録の呼び出しは変更されずに残ります。少し前に取り上げた単純" "なモジュール式の例を少し変えるとこうなります::" -#: ../../howto/logging-cookbook.rst:167 msgid "" "import logging\n" "\n" @@ -273,6 +378,31 @@ msgid "" "logger.error('error message')\n" "logger.critical('critical message')" msgstr "" +"import logging\n" +"\n" +"logger = logging.getLogger('simple_example')\n" +"logger.setLevel(logging.DEBUG)\n" +"# デバッグメッセージも記録するファイルハンドラーを作成する\n" +"fh = logging.FileHandler('spam.log')\n" +"fh.setLevel(logging.DEBUG)\n" +"# より高いログレベルのコンソールハンドラーを作成する\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.ERROR)\n" +"# フォーマッターを作成してハンドラーに設定する\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " +"%(message)s')\n" +"ch.setFormatter(formatter)\n" +"fh.setFormatter(formatter)\n" +"# ロガーにハンドラーを追加する\n" +"logger.addHandler(ch)\n" +"logger.addHandler(fh)\n" +"\n" +"# 「アプリケーション」のコード\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" #: ../../howto/logging-cookbook.rst:192 msgid "" @@ -307,7 +437,6 @@ msgstr "" msgid "Logging to multiple destinations" msgstr "複数の出力先にログを出力する" -#: ../../howto/logging-cookbook.rst:208 msgid "" "Let's say you want to log to console and file with different message formats " "and in differing circumstances. Say you want to log messages with levels of " @@ -315,13 +444,14 @@ msgid "" "console. Let's also assume that the file should contain timestamps, but the " "console messages should not. Here's how you can achieve this::" msgstr "" -"コンソールとファイルに、別々のメッセージ書式で、別々の状況に応じたログ出力を" -"行わせたいとしましょう。例えば DEBUG よりも高いレベルのメッセージはファイルに" -"記録し、INFO 以上のレベルのメッセージはコンソールに出力したいという場合です。" -"また、ファイルにはタイムスタンプを記録し、コンソールには出力しないとします。" -"以下のようにすれば、こうした挙動を実現できます::" +"コンソールとファイルに、それぞれ異なる書式や条件でログを出力したいとしま" +"す。\n" +"例えば DEBUG 以上のレベルのメッセージをファイルに、INFO 以上のメッセージをコ" +"ンソールに出力するとします。\n" +"また、ファイルにはタイムスタンプを含め、コンソールには含めないものとしま" +"す。\n" +"次のように実現できます。 ::" -#: ../../howto/logging-cookbook.rst:214 msgid "" "import logging\n" "\n" @@ -357,24 +487,58 @@ msgid "" "logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" "logger2.error('The five boxing wizards jump quickly.')" msgstr "" +"import logging\n" +"\n" +"# ファイルへのログ出力を設定する。詳細は前の節を参照\n" +"logging.basicConfig(level=logging.DEBUG,\n" +" format='%(asctime)s %(name)-12s %(levelname)-8s " +"%(message)s',\n" +" datefmt='%m-%d %H:%M',\n" +" filename='/tmp/myapp.log',\n" +" filemode='w')\n" +"# INFO 以上のメッセージを sys.stderr に出力するハンドラーを定義する\n" +"console = logging.StreamHandler()\n" +"console.setLevel(logging.INFO)\n" +"# コンソール用のより単純な書式を設定する\n" +"formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')\n" +"# ハンドラーにこの書式を設定する\n" +"console.setFormatter(formatter)\n" +"# ルートロガーにハンドラーを追加する\n" +"logging.getLogger().addHandler(console)\n" +"\n" +"# これでルートロガーや他のロガーに記録できる。まずルートロガーを使う。\n" +"logging.info('Jackdaws love my big sphinx of quartz.')\n" +"\n" +"# 次に、アプリケーションの各部分を表すような\n" +"# 他のロガーをいくつか定義する。\n" +"\n" +"logger1 = logging.getLogger('myapp.area1')\n" +"logger2 = logging.getLogger('myapp.area2')\n" +"\n" +"logger1.debug('Quick zephyrs blow, vexing daft Jim.')\n" +"logger1.info('How quickly daft jumping zebras vex.')\n" +"logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" +"logger2.error('The five boxing wizards jump quickly.')" #: ../../howto/logging-cookbook.rst:246 msgid "When you run this, on the console you will see" msgstr "これを実行すると、コンソールには以下のように出力されます:" -#: ../../howto/logging-cookbook.rst:248 msgid "" "root : INFO Jackdaws love my big sphinx of quartz.\n" "myapp.area1 : INFO How quickly daft jumping zebras vex.\n" "myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack.\n" "myapp.area2 : ERROR The five boxing wizards jump quickly." msgstr "" +"root : INFO Jackdaws love my big sphinx of quartz.\n" +"myapp.area1 : INFO How quickly daft jumping zebras vex.\n" +"myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack.\n" +"myapp.area2 : ERROR The five boxing wizards jump quickly." #: ../../howto/logging-cookbook.rst:255 msgid "and in the file you will see something like" msgstr "そして、ファイルには以下のように出力されるはずです:" -#: ../../howto/logging-cookbook.rst:257 msgid "" "10-22 22:19 root INFO Jackdaws love my big sphinx of quartz.\n" "10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" @@ -383,6 +547,12 @@ msgid "" "quack.\n" "10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly." msgstr "" +"10-22 22:19 root INFO Jackdaws love my big sphinx of quartz.\n" +"10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" +"10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex.\n" +"10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from " +"quack.\n" +"10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly." #: ../../howto/logging-cookbook.rst:265 msgid "" @@ -400,7 +570,6 @@ msgstr "" "この例ではコンソールとファイルのハンドラだけを使っていますが、実際には任意の" "数のハンドラや組み合わせを使えます。" -#: ../../howto/logging-cookbook.rst:271 msgid "" "Note that the above choice of log filename ``/tmp/myapp.log`` implies use of " "a standard location for temporary files on POSIX systems. On Windows, you " @@ -408,11 +577,11 @@ msgid "" "the directory exists and that you have the permissions to create and update " "files in it." msgstr "" -"ここでファイル名として ``/tmp/myapp.log`` を選んだということは、一時ファイル" -"の標準的な場所として POSIX システムを想定していることに注意してください。 " -"Windows の場合、ディレクトリが存在し、そのディレクトリに対してファイルを更新" -"するための適切な権限を有することを保証するために、ログファイル向けのディレク" -"トリ名として異なる選択を取る必要があるでしょう。" +"上のログファイル名 ``/tmp/myapp.log`` は、POSIX システムの一時ファイルの標準" +"的な場所を使っています。\n" +"Windows では、別のディレクトリを選ぶ必要があるかもしれません。\n" +"いずれの場合も、ディレクトリが存在し、その中でファイルを作成・更新する権限が" +"あることを確認してください。" #: ../../howto/logging-cookbook.rst:280 msgid "Custom handling of levels" @@ -446,7 +615,6 @@ msgstr "深刻度 ``DEBUG`` 以上のメッセージをファイル ``app.log`` msgid "Suppose you configure logging with the following JSON:" msgstr "logging モジュールを下記の JSON によって構成したとしましょう:" -#: ../../howto/logging-cookbook.rst:293 msgid "" "{\n" " \"version\": 1,\n" @@ -486,6 +654,43 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" \"version\": 1,\n" +" \"disable_existing_loggers\": false,\n" +" \"formatters\": {\n" +" \"simple\": {\n" +" \"format\": \"%(levelname)-8s - %(message)s\"\n" +" }\n" +" },\n" +" \"handlers\": {\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\"\n" +" },\n" +" \"stderr\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"ERROR\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stderr\"\n" +" },\n" +" \"file\": {\n" +" \"class\": \"logging.FileHandler\",\n" +" \"formatter\": \"simple\",\n" +" \"filename\": \"app.log\",\n" +" \"mode\": \"w\"\n" +" }\n" +" },\n" +" \"root\": {\n" +" \"level\": \"DEBUG\",\n" +" \"handlers\": [\n" +" \"stderr\",\n" +" \"stdout\",\n" +" \"file\"\n" +" ]\n" +" }\n" +"}" #: ../../howto/logging-cookbook.rst:333 msgid "" @@ -497,7 +702,6 @@ msgid "" "section parallel to ``formatters`` and ``handlers``:" msgstr "" -#: ../../howto/logging-cookbook.rst:339 msgid "" "{\n" " \"filters\": {\n" @@ -508,13 +712,20 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" \"filters\": {\n" +" \"warnings_and_below\": {\n" +" \"()\" : \"__main__.filter_maker\",\n" +" \"level\": \"WARNING\"\n" +" }\n" +" }\n" +"}" #: ../../howto/logging-cookbook.rst:350 msgid "and changing the section on the ``stdout`` handler to add it:" msgstr "" "そして ``stdout`` のハンドラに関するセクションにフィルターを追加します:" -#: ../../howto/logging-cookbook.rst:352 msgid "" "{\n" " \"stdout\": {\n" @@ -526,6 +737,15 @@ msgid "" " }\n" "}" msgstr "" +"{\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\",\n" +" \"filters\": [\"warnings_and_below\"]\n" +" }\n" +"}" #: ../../howto/logging-cookbook.rst:364 msgid "" @@ -535,7 +755,6 @@ msgstr "" "フィルターは単なる関数なので、 ``filter_maker`` (ファクトリ関数) は以下のよう" "に定義することができます:" -#: ../../howto/logging-cookbook.rst:367 msgid "" "def filter_maker(level):\n" " level = getattr(logging, level)\n" @@ -545,6 +764,13 @@ msgid "" "\n" " return filter" msgstr "" +"def filter_maker(level):\n" +" level = getattr(logging, level)\n" +"\n" +" def filter(record):\n" +" return record.levelno <= level\n" +"\n" +" return filter" #: ../../howto/logging-cookbook.rst:377 msgid "" @@ -570,7 +796,6 @@ msgstr "" "フィルターを追加した ``main.py`` の全体像は以下のようになり、これで実行できる" "状態になりました:" -#: ../../howto/logging-cookbook.rst:387 msgid "" "import json\n" "import logging\n" @@ -638,42 +863,124 @@ msgid "" "logging.error('An ERROR message')\n" "logging.critical('A CRITICAL message')" msgstr "" - -#: ../../howto/logging-cookbook.rst:455 -msgid "And after running it like this:" -msgstr "これを以下のように実行します:" - -#: ../../howto/logging-cookbook.rst:457 -msgid "python main.py 2>stderr.log >stdout.log" -msgstr "" - -#: ../../howto/logging-cookbook.rst:461 -msgid "We can see the results are as expected:" -msgstr "すると期待通りの結果を得ることができます:" - -#: ../../howto/logging-cookbook.rst:463 -msgid "" -"$ more *.log\n" -"::::::::::::::\n" -"app.log\n" -"::::::::::::::\n" -"DEBUG - A DEBUG message\n" -"INFO - An INFO message\n" -"WARNING - A WARNING message\n" -"ERROR - An ERROR message\n" -"CRITICAL - A CRITICAL message\n" -"::::::::::::::\n" -"stderr.log\n" -"::::::::::::::\n" -"ERROR - An ERROR message\n" -"CRITICAL - A CRITICAL message\n" -"::::::::::::::\n" -"stdout.log\n" -"::::::::::::::\n" -"INFO - An INFO message\n" -"WARNING - A WARNING message" -msgstr "" - +"import json\n" +"import logging\n" +"import logging.config\n" +"\n" +"CONFIG = '''\n" +"{\n" +" \"version\": 1,\n" +" \"disable_existing_loggers\": false,\n" +" \"formatters\": {\n" +" \"simple\": {\n" +" \"format\": \"%(levelname)-8s - %(message)s\"\n" +" }\n" +" },\n" +" \"filters\": {\n" +" \"warnings_and_below\": {\n" +" \"()\" : \"__main__.filter_maker\",\n" +" \"level\": \"WARNING\"\n" +" }\n" +" },\n" +" \"handlers\": {\n" +" \"stdout\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"INFO\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stdout\",\n" +" \"filters\": [\"warnings_and_below\"]\n" +" },\n" +" \"stderr\": {\n" +" \"class\": \"logging.StreamHandler\",\n" +" \"level\": \"ERROR\",\n" +" \"formatter\": \"simple\",\n" +" \"stream\": \"ext://sys.stderr\"\n" +" },\n" +" \"file\": {\n" +" \"class\": \"logging.FileHandler\",\n" +" \"formatter\": \"simple\",\n" +" \"filename\": \"app.log\",\n" +" \"mode\": \"w\"\n" +" }\n" +" },\n" +" \"root\": {\n" +" \"level\": \"DEBUG\",\n" +" \"handlers\": [\n" +" \"stderr\",\n" +" \"stdout\",\n" +" \"file\"\n" +" ]\n" +" }\n" +"}\n" +"'''\n" +"\n" +"def filter_maker(level):\n" +" level = getattr(logging, level)\n" +"\n" +" def filter(record):\n" +" return record.levelno <= level\n" +"\n" +" return filter\n" +"\n" +"logging.config.dictConfig(json.loads(CONFIG))\n" +"logging.debug('A DEBUG message')\n" +"logging.info('An INFO message')\n" +"logging.warning('A WARNING message')\n" +"logging.error('An ERROR message')\n" +"logging.critical('A CRITICAL message')" + +#: ../../howto/logging-cookbook.rst:455 +msgid "And after running it like this:" +msgstr "これを以下のように実行します:" + +msgid "python main.py 2>stderr.log >stdout.log" +msgstr "python main.py 2>stderr.log >stdout.log" + +#: ../../howto/logging-cookbook.rst:461 +msgid "We can see the results are as expected:" +msgstr "すると期待通りの結果を得ることができます:" + +msgid "" +"$ more *.log\n" +"::::::::::::::\n" +"app.log\n" +"::::::::::::::\n" +"DEBUG - A DEBUG message\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stderr.log\n" +"::::::::::::::\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stdout.log\n" +"::::::::::::::\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message" +msgstr "" +"$ more *.log\n" +"::::::::::::::\n" +"app.log\n" +"::::::::::::::\n" +"DEBUG - A DEBUG message\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stderr.log\n" +"::::::::::::::\n" +"ERROR - An ERROR message\n" +"CRITICAL - A CRITICAL message\n" +"::::::::::::::\n" +"stdout.log\n" +"::::::::::::::\n" +"INFO - An INFO message\n" +"WARNING - A WARNING message" + #: ../../howto/logging-cookbook.rst:487 msgid "Configuration server example" msgstr "設定サーバの例" @@ -682,7 +989,6 @@ msgstr "設定サーバの例" msgid "Here is an example of a module using the logging configuration server::" msgstr "ログ記録設定サーバを使うモジュールの例です::" -#: ../../howto/logging-cookbook.rst:491 msgid "" "import logging\n" "import logging.config\n" @@ -713,18 +1019,44 @@ msgid "" " logging.config.stopListening()\n" " t.join()" msgstr "" +"import logging\n" +"import logging.config\n" +"import time\n" +"import os\n" +"\n" +"# 初期設定ファイルを読む\n" +"logging.config.fileConfig('logging.conf')\n" +"\n" +"# 9999 番ポートでリスナーを作成して開始する\n" +"t = logging.config.listen(9999)\n" +"t.start()\n" +"\n" +"logger = logging.getLogger('simpleExample')\n" +"\n" +"try:\n" +" # Ctrl+C が押されるまでログの呼び出しを繰り返し、\n" +" # 新しい設定による違いを確認する\n" +" while True:\n" +" logger.debug('debug message')\n" +" logger.info('info message')\n" +" logger.warning('warn message')\n" +" logger.error('error message')\n" +" logger.critical('critical message')\n" +" time.sleep(5)\n" +"except KeyboardInterrupt:\n" +" # 後片付け\n" +" logging.config.stopListening()\n" +" t.join()" -#: ../../howto/logging-cookbook.rst:520 msgid "" "And here is a script that takes a filename and sends that file to the " "server, properly preceded with the binary-encoded length, as the new logging " "configuration::" msgstr "" -"そしてファイル名を受け取ってそのファイルをサーバに送るスクリプトですが、それ" -"に先だってバイナリエンコード長を新しいログ記録の設定として先に送っておきま" -"す::" +"次は、ファイル名を受け取り、そのファイルを新しいロギング設定としてサーバーに" +"送るスクリプトです。\n" +"ファイルの内容の前に、バイナリ形式で表したデータ長を送ります。 ::" -#: ../../howto/logging-cookbook.rst:524 msgid "" "#!/usr/bin/env python\n" "import socket, sys, struct\n" @@ -743,6 +1075,22 @@ msgid "" "s.close()\n" "print('complete')" msgstr "" +"#!/usr/bin/env python\n" +"import socket, sys, struct\n" +"\n" +"with open(sys.argv[1], 'rb') as f:\n" +" data_to_send = f.read()\n" +"\n" +"HOST = 'localhost'\n" +"PORT = 9999\n" +"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"print('connecting...')\n" +"s.connect((HOST, PORT))\n" +"print('sending config...')\n" +"s.send(struct.pack('>L', len(data_to_send)))\n" +"s.send(data_to_send)\n" +"s.close()\n" +"print('complete')" #: ../../howto/logging-cookbook.rst:545 msgid "Dealing with handlers that block" @@ -831,7 +1179,6 @@ msgstr "" msgid "An example of using these two classes follows (imports omitted)::" msgstr "この2つのクラスを利用する例です (import は省略)::" -#: ../../howto/logging-cookbook.rst:587 msgid "" "que = queue.Queue(-1) # no limit on size\n" "queue_handler = QueueHandler(que)\n" @@ -849,16 +1196,28 @@ msgid "" "root.warning('Look out!')\n" "listener.stop()" msgstr "" +"que = queue.Queue(-1) # サイズの上限なし\n" +"queue_handler = QueueHandler(que)\n" +"handler = logging.StreamHandler()\n" +"listener = QueueListener(que, handler)\n" +"root = logging.getLogger()\n" +"root.addHandler(queue_handler)\n" +"formatter = logging.Formatter('%(threadName)s: %(message)s')\n" +"handler.setFormatter(formatter)\n" +"listener.start()\n" +"# ログ出力には、内部キューを監視する内部スレッドではなく、\n" +"# イベントを生成したスレッド (メインスレッド) が表示される。\n" +"# これが期待する動作。\n" +"root.warning('Look out!')\n" +"listener.stop()" #: ../../howto/logging-cookbook.rst:603 msgid "which, when run, will produce:" msgstr "実行すると次のように出力します:" -#: ../../howto/logging-cookbook.rst:605 msgid "MainThread: Look out!" -msgstr "" +msgstr "MainThread: Look out!" -#: ../../howto/logging-cookbook.rst:609 msgid "" "Although the earlier discussion wasn't specifically talking about async " "code, but rather about slow logging handlers, it should be noted that when " @@ -868,16 +1227,16 @@ msgid "" "application, to use the above approach for logging, so that any blocking " "code runs only in the ``QueueListener`` thread." msgstr "" -"上述の議論は特に同期コードにについてのものではなく、むしろ遅いロギングハンド" -"ラについてでしたが、非同期コードやネットワーク、あるいはファイルハンドラから" -"のロギングでさえも (イベントループをブロックしてしまう) 問題につながる可能性" -"があることには注意すべきでしょう。これはいくつかのロギングが :mod:`asyncio` " -"内部で行われることが理由です。何らかの非同期コードがアプリケーションの中で使" -"われている場合、ロギングには上記のアプローチを使っていかなるブロッキングコー" -"ドも ``QueueListener`` スレッド内だけで実行されるようにしておくことが最も良い" -"でしょう。" +"ここまでは特に非同期コードを対象とせず、処理の遅いロギングハンドラについて説" +"明しました。\n" +"ただし、非同期コードからログを出力する場合、ネットワークハンドラだけでなく" +"ファイルハンドラも、イベントループをブロックして問題を起こす可能性がありま" +"す。\n" +":mod:`asyncio` の内部でもログが出力されるためです。\n" +"アプリケーションで非同期コードを使う場合は、ブロックする処理が " +"``QueueListener`` スレッド内だけで実行されるよう、上記の方法を使うのがよいで" +"しょう。" -#: ../../howto/logging-cookbook.rst:617 msgid "" "Prior to Python 3.5, the :class:`QueueListener` always passed every message " "received from the queue to every handler it was initialized with. (This was " @@ -888,22 +1247,22 @@ msgid "" "of each message with the handler's level, and only passes a message to a " "handler if it's appropriate to do so." msgstr "" -"Python 3.5 以前は、 :class:`QueueListener` クラスは常にキューから受け取った" -"メッセージを、初期化元となっているそれぞれのハンドラーに受け渡していました。 " -"( というのも、レベルフィルターリングは別サイド、つまり、キューが満たされてい" -"る場所で処理されるということが想定されているからです) Python 3.5以降では、" -"キーワードとなる引数 ``respect_handler_level=True`` をリスナーのコントラク" -"ターに受け渡すことで、この挙動を変更することができるようになっています。これ" -"が行われると、各メッセージのレベルをハンドラーのレベルと比較して、そうするこ" -"とが適切な場合のみ、メッセージをハンドラーに渡します。" +"Python 3.5 より前の :class:`QueueListener` は、キューから受け取ったすべての" +"メッセージを、初期化時に渡されたすべてのハンドラに渡していました。\n" +"レベルによるフィルタリングは、キューへ書き込む側ですべて行うと想定していたた" +"めです。\n" +"3.5 以降では、リスナーのコンストラクタにキーワード引数 " +"``respect_handler_level=True`` を渡すと、この動作を変更できます。\n" +"この場合、リスナーは各メッセージのレベルとハンドラのレベルを比較し、条件を満" +"たすメッセージだけをハンドラに渡します。" -#: ../../howto/logging-cookbook.rst:627 msgid "" "The :class:`QueueListener` can be started (and stopped) via the :keyword:" "`with` statement. For example:" msgstr "" +":class:`QueueListener` は :keyword:`with` 文で開始 (および停止) できます。\n" +"例えば:" -#: ../../howto/logging-cookbook.rst:631 msgid "" "with QueueListener(que, handler) as listener:\n" " # The queue listener automatically starts\n" @@ -912,6 +1271,12 @@ msgid "" "# The queue listener automatically stops once\n" "# the 'with' block is exited." msgstr "" +"with QueueListener(que, handler) as listener:\n" +" # with ブロックに入ると、\n" +" # キューリスナーが自動的に開始する。\n" +" pass\n" +"# with ブロックを抜けると、\n" +"# キューリスナーが自動的に停止する。" #: ../../howto/logging-cookbook.rst:643 msgid "Sending and receiving logging events across a network" @@ -927,7 +1292,6 @@ msgstr "" "う。 :class:`SocketHandler` インスタンスを送信端の root logger にアタッチすれ" "ば、簡単に実現できます::" -#: ../../howto/logging-cookbook.rst:649 msgid "" "import logging, logging.handlers\n" "\n" @@ -954,6 +1318,29 @@ msgid "" "logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" "logger2.error('The five boxing wizards jump quickly.')" msgstr "" +"import logging, logging.handlers\n" +"\n" +"rootLogger = logging.getLogger()\n" +"rootLogger.setLevel(logging.DEBUG)\n" +"socketHandler = logging.handlers.SocketHandler('localhost',\n" +" logging.handlers.DEFAULT_TCP_LOGGING_PORT)\n" +"# ソケットハンドラーは書式化前のイベントを pickle で送るため、\n" +"# フォーマッターは設定しない\n" +"rootLogger.addHandler(socketHandler)\n" +"\n" +"# これでルートロガーや他のロガーに記録できる。まずルートロガーを使う。\n" +"logging.info('Jackdaws love my big sphinx of quartz.')\n" +"\n" +"# 次に、アプリケーションの各部分を表すような\n" +"# 他のロガーをいくつか定義する。\n" +"\n" +"logger1 = logging.getLogger('myapp.area1')\n" +"logger2 = logging.getLogger('myapp.area2')\n" +"\n" +"logger1.debug('Quick zephyrs blow, vexing daft Jim.')\n" +"logger1.info('How quickly daft jumping zebras vex.')\n" +"logger2.warning('Jail zesty vixen who grabbed pay from quack.')\n" +"logger2.error('The five boxing wizards jump quickly.')" #: ../../howto/logging-cookbook.rst:673 msgid "" @@ -963,7 +1350,6 @@ msgstr "" "受信端では :mod:`socketserver` モジュールを使って受信プログラムを作成しておき" "ます。簡単な実用プログラムを以下に示します::" -#: ../../howto/logging-cookbook.rst:676 msgid "" "import pickle\n" "import logging\n" @@ -1053,82 +1439,172 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" - -#: ../../howto/logging-cookbook.rst:761 -msgid "" -"First run the server, and then the client. On the client side, nothing is " -"printed on the console; on the server side, you should see something like:" -msgstr "" -"先にサーバを起動しておき、次にクライアントを起動します。クライアント側では、" -"コンソールには何も出力されません; サーバ側では以下のようなメッセージを目にす" -"るはずです::" - -#: ../../howto/logging-cookbook.rst:764 -msgid "" -"About to start TCP server...\n" -" 59 root INFO Jackdaws love my big sphinx of quartz.\n" -" 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" -" 69 myapp.area1 INFO How quickly daft jumping zebras vex.\n" -" 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack.\n" -" 69 myapp.area2 ERROR The five boxing wizards jump quickly." -msgstr "" - -#: ../../howto/logging-cookbook.rst:773 -msgid "" -"Note that there are some security issues with pickle in some scenarios. If " -"these affect you, you can use an alternative serialization scheme by " -"overriding the :meth:`~SocketHandler.makePickle` method and implementing " -"your alternative there, as well as adapting the above script to use your " -"alternative serialization." -msgstr "" -"注意: pickle にはいくつかのシナリオでセキュリティ上の問題があります。これら" -"が影響する場合は、 :meth:`~SocketHandler.makePickle` メソッドをオーバーライド" -"し代替シリアライズ手法を実装して、それを使うように上記のスクリプトを修正する" -"こともできます。" - -#: ../../howto/logging-cookbook.rst:781 -msgid "Running a logging socket listener in production" -msgstr "作成中のロギングソケットのリスナーを実行する" - -#: ../../howto/logging-cookbook.rst:785 -msgid "" -"To run a logging listener in production, you may need to use a process-" -"management tool such as `Supervisor `_. `Here is a " -"Gist `__ which provides the bare-bones files to run " -"the above functionality using Supervisor. It consists of the following files:" -msgstr "" -"作成中のロギングリスナーを実行するためには、 `Supervisor `_ のようなプロセス管理ツールを使う必要があるかもしれません。 `こちらの " -"Gist `__ は Supervisor を使って上記の機能を実行するた" -"めの必要最低限のファイルを提供しています。以下のファイルが必要になります:" - -#: ../../howto/logging-cookbook.rst:792 -msgid "File" -msgstr "ファイル" - -#: ../../howto/logging-cookbook.rst:792 -msgid "Purpose" -msgstr "目的" - -#: ../../howto/logging-cookbook.rst:794 -msgid ":file:`prepare.sh`" -msgstr ":file:`prepare.sh`" - -#: ../../howto/logging-cookbook.rst:794 -msgid "A Bash script to prepare the environment for testing" -msgstr "試験用の環境を準備する Bash スクリプト" - -#: ../../howto/logging-cookbook.rst:797 -msgid ":file:`supervisor.conf`" -msgstr ":file:`supervisor.conf`" - -#: ../../howto/logging-cookbook.rst:797 -msgid "" -"The Supervisor configuration file, which has entries for the listener and a " -"multi-process web application" -msgstr "" -"リスナーとマルチプロセスの web アプリケーションのための設定を含む Supervisor " -"の設定ファイル" +"import pickle\n" +"import logging\n" +"import logging.handlers\n" +"import socketserver\n" +"import struct\n" +"\n" +"\n" +"class LogRecordStreamHandler(socketserver.StreamRequestHandler):\n" +" \"\"\"ストリームで届くログ要求のハンドラー。\n" +"\n" +" This basically logs the record using whatever logging policy is\n" +" configured locally.\n" +" \"\"\"\n" +"\n" +" def handle(self):\n" +" \"\"\"\n" +" Handle multiple requests - each expected to be a 4-byte length,\n" +" followed by the LogRecord in pickle format. Logs the record\n" +" according to whatever policy is configured locally.\n" +" \"\"\"\n" +" while True:\n" +" chunk = self.connection.recv(4)\n" +" if len(chunk) < 4:\n" +" break\n" +" slen = struct.unpack('>L', chunk)[0]\n" +" chunk = self.connection.recv(slen)\n" +" while len(chunk) < slen:\n" +" chunk = chunk + self.connection.recv(slen - len(chunk))\n" +" obj = self.unPickle(chunk)\n" +" record = logging.makeLogRecord(obj)\n" +" self.handleLogRecord(record)\n" +"\n" +" def unPickle(self, data):\n" +" return pickle.loads(data)\n" +"\n" +" def handleLogRecord(self, record):\n" +" # 名前が指定されていれば、レコードが示すロガーではなく\n" +" # その名前のロガーを使う。\n" +" if self.server.logname is not None:\n" +" name = self.server.logname\n" +" else:\n" +" name = record.name\n" +" logger = logging.getLogger(name)\n" +" # 注意: すべてのレコードが記録される。Logger.handle は通常、\n" +" # ロガーのレベルによるフィルタリングの後で呼ばれるため。\n" +" # 処理時間とネットワーク帯域を無駄にしないよう、\n" +" # フィルタリングはクライアント側で行う。\n" +" logger.handle(record)\n" +"\n" +"class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):\n" +" \"\"\"\n" +" Simple TCP socket-based logging receiver suitable for testing.\n" +" \"\"\"\n" +"\n" +" allow_reuse_address = True\n" +"\n" +" def __init__(self, host='localhost',\n" +" port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,\n" +" handler=LogRecordStreamHandler):\n" +" socketserver.ThreadingTCPServer.__init__(self, (host, port), " +"handler)\n" +" self.abort = 0\n" +" self.timeout = 1\n" +" self.logname = None\n" +"\n" +" def serve_until_stopped(self):\n" +" import select\n" +" abort = 0\n" +" while not abort:\n" +" rd, wr, ex = select.select([self.socket.fileno()],\n" +" [], [],\n" +" self.timeout)\n" +" if rd:\n" +" self.handle_request()\n" +" abort = self.abort\n" +"\n" +"def main():\n" +" logging.basicConfig(\n" +" format='%(relativeCreated)5d %(name)-15s %(levelname)-8s " +"%(message)s')\n" +" tcpserver = LogRecordSocketReceiver()\n" +" print('About to start TCP server...')\n" +" tcpserver.serve_until_stopped()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" + +#: ../../howto/logging-cookbook.rst:761 +msgid "" +"First run the server, and then the client. On the client side, nothing is " +"printed on the console; on the server side, you should see something like:" +msgstr "" +"先にサーバを起動しておき、次にクライアントを起動します。クライアント側では、" +"コンソールには何も出力されません; サーバ側では以下のようなメッセージを目にす" +"るはずです::" + +msgid "" +"About to start TCP server...\n" +" 59 root INFO Jackdaws love my big sphinx of quartz.\n" +" 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" +" 69 myapp.area1 INFO How quickly daft jumping zebras vex.\n" +" 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack.\n" +" 69 myapp.area2 ERROR The five boxing wizards jump quickly." +msgstr "" +"About to start TCP server...\n" +" 59 root INFO Jackdaws love my big sphinx of quartz.\n" +" 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim.\n" +" 69 myapp.area1 INFO How quickly daft jumping zebras vex.\n" +" 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack.\n" +" 69 myapp.area2 ERROR The five boxing wizards jump quickly." + +#: ../../howto/logging-cookbook.rst:773 +msgid "" +"Note that there are some security issues with pickle in some scenarios. If " +"these affect you, you can use an alternative serialization scheme by " +"overriding the :meth:`~SocketHandler.makePickle` method and implementing " +"your alternative there, as well as adapting the above script to use your " +"alternative serialization." +msgstr "" +"注意: pickle にはいくつかのシナリオでセキュリティ上の問題があります。これら" +"が影響する場合は、 :meth:`~SocketHandler.makePickle` メソッドをオーバーライド" +"し代替シリアライズ手法を実装して、それを使うように上記のスクリプトを修正する" +"こともできます。" + +msgid "Running a logging socket listener in production" +msgstr "本番環境でロギングソケットのリスナーを実行する" + +msgid "" +"To run a logging listener in production, you may need to use a process-" +"management tool such as `Supervisor `_. `Here is a " +"Gist `__ which provides the bare-bones files to run " +"the above functionality using Supervisor. It consists of the following files:" +msgstr "" +"本番環境でロギングリスナーを実行するには、`Supervisor `_ などのプロセス管理ツールが必要になる場合があります。\n" +"`こちらの Gist `__ には、上記の機能を Supervisor で実" +"行するための最小限のファイルが含まれています。\n" +"構成は次のとおりです:" + +#: ../../howto/logging-cookbook.rst:792 +msgid "File" +msgstr "ファイル" + +#: ../../howto/logging-cookbook.rst:792 +msgid "Purpose" +msgstr "目的" + +#: ../../howto/logging-cookbook.rst:794 +msgid ":file:`prepare.sh`" +msgstr ":file:`prepare.sh`" + +#: ../../howto/logging-cookbook.rst:794 +msgid "A Bash script to prepare the environment for testing" +msgstr "試験用の環境を準備する Bash スクリプト" + +#: ../../howto/logging-cookbook.rst:797 +msgid ":file:`supervisor.conf`" +msgstr ":file:`supervisor.conf`" + +#: ../../howto/logging-cookbook.rst:797 +msgid "" +"The Supervisor configuration file, which has entries for the listener and a " +"multi-process web application" +msgstr "" +"リスナーとマルチプロセスの web アプリケーションのための設定を含む Supervisor " +"の設定ファイル" #: ../../howto/logging-cookbook.rst:801 msgid ":file:`ensure_app.sh`" @@ -1175,9 +1651,8 @@ msgstr "web アプリケーションのための JSON 設定ファイル" msgid ":file:`client.py`" msgstr ":file:`client.py`" -#: ../../howto/logging-cookbook.rst:812 msgid "A Python script to exercise the web application" -msgstr "web アプリケーションを起動するための Python スクリプト" +msgstr "Web アプリケーションの動作を試す Python スクリプト" #: ../../howto/logging-cookbook.rst:815 msgid "" @@ -1231,13 +1706,13 @@ msgstr "" "``bash ensure_app.sh`` を実行して Supervisor が上記の設定で実行されていること" "を確認してください。" -#: ../../howto/logging-cookbook.rst:835 msgid "" "Run ``venv/bin/python client.py`` to exercise the web application, which " "will lead to records being written to the log." msgstr "" -"``venv/bin/python client.py`` を実行して web アプリケーションを起動してくださ" -"い。これによりログにレコードが書き込まれるはずです。" +"``venv/bin/python client.py`` を実行して Web アプリケーションの動作を試してく" +"ださい。\n" +"これによりログにレコードが書き込まれます。" #: ../../howto/logging-cookbook.rst:838 msgid "" @@ -1267,32 +1742,36 @@ msgstr "" "ありそうもないことですが、テスト環境で設定したポートが別の設定と衝突してし" "まった場合、設定ファイルを修正する必要があるかもしれません。" -#: ../../howto/logging-cookbook.rst:849 msgid "" "The default configuration uses a TCP socket on port 9020. You can use a Unix " "Domain socket instead of a TCP socket by doing the following:" msgstr "" +"デフォルトの設定はポート 9020 の TCP ソケットを使います。\n" +"次の変更で、TCP ソケットの代わりに Unix ドメインソケットを使えます:" -#: ../../howto/logging-cookbook.rst:852 msgid "" "In :file:`listener.json`, add a ``socket`` key with the path to the domain " "socket you want to use. If this key is present, the listener listens on the " "corresponding domain socket and not on a TCP socket (the ``port`` key is " "ignored)." msgstr "" +":file:`listener.json` に ``socket`` キーを追加し、使うドメインソケットのパス" +"を指定します。\n" +"このキーがある場合、リスナーは TCP ソケットではなく、指定されたドメインソケッ" +"トで待ち受けます (``port`` キーは無視されます)。" -#: ../../howto/logging-cookbook.rst:857 msgid "" "In :file:`webapp.json`, change the socket handler configuration dictionary " "so that the ``host`` value is the path to the domain socket, and set the " "``port`` value to ``null``." msgstr "" +":file:`webapp.json` のソケットハンドラの設定辞書で、``host`` の値をドメインソ" +"ケットのパスに、``port`` の値を ``null`` に変更します。" #: ../../howto/logging-cookbook.rst:867 msgid "Adding contextual information to your logging output" msgstr "コンテキスト情報をログ記録出力に付加する" -#: ../../howto/logging-cookbook.rst:869 msgid "" "Sometimes you want logging output to contain contextual information in " "addition to the parameters passed to the logging call. For example, in a " @@ -1307,17 +1786,18 @@ msgid "" "logging an application, it could be hard to manage if the number of :class:" "`Logger` instances becomes effectively unbounded." msgstr "" -"時にはログ記録出力にログ関数の呼び出し時に渡されたパラメータに加えてコンテキ" -"スト情報を含めたいこともあるでしょう。たとえば、ネットワークアプリケーション" -"で、クライアント固有の情報 (例: リモートクライアントの名前、 IP アドレス) も" -"ログ記録に残しておきたいと思ったとしましょう。 *extra* パラメータをこの目的に" -"使うこともできますが、いつでもこの方法で情報を渡すのが便利なやり方とも限りま" -"せん。また接続ごとに :class:`Logger` インスタンスを生成する誘惑に駆られるかも" -"しれませんが、生成した :class:`Logger` インスタンスはガーベジコレクションで回" -"収されないので、これは良いアイデアとは言えません。この例は現実的な問題ではな" -"いかもしれませんが、 :class:`Logger` インスタンスの個数がアプリケーションの中" -"でログ記録が行われるレベルの粒度に依存する場合、 :class:`Logger` インスタンス" -"の個数が事実上無制限にならないと、管理が難しくなります。" +"ログ呼び出しに渡す引数に加えて、コンテキスト情報もログに含めたい場合がありま" +"す。\n" +"例えばネットワークアプリケーションで、リモートクライアントのユーザー名や IP " +"アドレスなど、クライアント固有の情報を記録したい場合です。\n" +"*extra* パラメータで実現できますが、この方法で毎回情報を渡すのは便利とは限り" +"ません。\n" +"接続ごとに :class:`Logger` インスタンスを作りたくなるかもしれませんが、これら" +"はガベージコレクションで回収されないため、よい方法ではありません。\n" +":class:`Logger` インスタンスの数がアプリケーションのログ記録の粒度で決まるな" +"ら、実用上は問題ありません。\n" +"しかし :class:`Logger` インスタンスの数が事実上無制限になると、管理が難しくな" +"る可能性があります。" #: ../../howto/logging-cookbook.rst:884 msgid "Using LoggerAdapters to impart contextual information" @@ -1358,7 +1838,6 @@ msgstr "" "スト情報をその委譲された呼び出しに埋め込みます。 :class:`LoggerAdapter` の" "コードから少し抜き出してみます::" -#: ../../howto/logging-cookbook.rst:902 msgid "" "def debug(self, msg, /, *args, **kwargs):\n" " \"\"\"\n" @@ -1368,6 +1847,13 @@ msgid "" " msg, kwargs = self.process(msg, kwargs)\n" " self.logger.debug(msg, *args, **kwargs)" msgstr "" +"def debug(self, msg, /, *args, **kwargs):\n" +" \"\"\"\n" +" Delegate a debug call to the underlying logger, after adding\n" +" contextual information from this adapter instance.\n" +" \"\"\"\n" +" msg, kwargs = self.process(msg, kwargs)\n" +" self.logger.debug(msg, *args, **kwargs)" #: ../../howto/logging-cookbook.rst:910 msgid "" @@ -1408,7 +1894,6 @@ msgstr "" "要なだけです。次に挙げるのはこのクラスを使った例で、コンストラクタで使われる" "「辞書風」オブジェクトにどの振る舞いが必要なのかも示しています::" -#: ../../howto/logging-cookbook.rst:927 msgid "" "class CustomAdapter(logging.LoggerAdapter):\n" " \"\"\"\n" @@ -1418,16 +1903,24 @@ msgid "" " def process(self, msg, kwargs):\n" " return '[%s] %s' % (self.extra['connid'], msg), kwargs" msgstr "" +"class CustomAdapter(logging.LoggerAdapter):\n" +" \"\"\"\n" +" This example adapter expects the passed in dict-like object to have a\n" +" 'connid' key, whose value in brackets is prepended to the log message.\n" +" \"\"\"\n" +" def process(self, msg, kwargs):\n" +" return '[%s] %s' % (self.extra['connid'], msg), kwargs" #: ../../howto/logging-cookbook.rst:935 msgid "which you can use like this::" msgstr "これを次のように使うことができます::" -#: ../../howto/logging-cookbook.rst:937 msgid "" "logger = logging.getLogger(__name__)\n" "adapter = CustomAdapter(logger, {'connid': some_conn_id})" msgstr "" +"logger = logging.getLogger(__name__)\n" +"adapter = CustomAdapter(logger, {'connid': some_conn_id})" #: ../../howto/logging-cookbook.rst:940 msgid "" @@ -1490,7 +1983,6 @@ msgstr "" "といったようにです。その場合、同じフォーマット文字列を使って以下に示すように" "似たような出力を得られます。これはスクリプトの例です::" -#: ../../howto/logging-cookbook.rst:971 msgid "" "import logging\n" "from random import choice\n" @@ -1532,12 +2024,50 @@ msgid "" " a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, " "'parameters')" msgstr "" +"import logging\n" +"from random import choice\n" +"\n" +"class ContextFilter(logging.Filter):\n" +" \"\"\"\n" +" This is a filter which injects contextual information into the log.\n" +"\n" +" Rather than use actual contextual information, we just use random\n" +" data in this demo.\n" +" \"\"\"\n" +"\n" +" USERS = ['jim', 'fred', 'sheila']\n" +" IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']\n" +"\n" +" def filter(self, record):\n" +"\n" +" record.ip = choice(ContextFilter.IPS)\n" +" record.user = choice(ContextFilter.USERS)\n" +" return True\n" +"\n" +"if __name__ == '__main__':\n" +" levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, " +"logging.CRITICAL)\n" +" logging.basicConfig(level=logging.DEBUG,\n" +" format='%(asctime)-15s %(name)-5s %(levelname)-8s " +"IP: %(ip)-15s User: %(user)-8s %(message)s')\n" +" a1 = logging.getLogger('a.b.c')\n" +" a2 = logging.getLogger('d.e.f')\n" +"\n" +" f = ContextFilter()\n" +" a1.addFilter(f)\n" +" a2.addFilter(f)\n" +" a1.debug('A debug message')\n" +" a1.info('An info message with %s', 'some parameters')\n" +" for x in range(10):\n" +" lvl = choice(levels)\n" +" lvlname = logging.getLevelName(lvl)\n" +" a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, " +"'parameters')" #: ../../howto/logging-cookbook.rst:1008 msgid "which, when run, produces something like:" msgstr "実行すると、以下のようになります:" -#: ../../howto/logging-cookbook.rst:1010 msgid "" "2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " "debug message\n" @@ -1564,12 +2094,35 @@ msgid "" "2010-09-06 22:38:15,301 d.e.f INFO IP: 123.231.231.123 User: fred A " "message at INFO level with 2 parameters" msgstr "" +"2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A " +"debug message\n" +"2010-09-06 22:38:15,300 a.b.c INFO IP: 192.168.0.1 User: sheila An " +"info message with some parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f ERROR IP: 127.0.0.1 User: jim A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f DEBUG IP: 127.0.0.1 User: sheila A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f ERROR IP: 123.231.231.123 User: fred A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 192.168.0.1 User: jim A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A " +"message at CRITICAL level with 2 parameters\n" +"2010-09-06 22:38:15,300 d.e.f DEBUG IP: 192.168.0.1 User: jim A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f ERROR IP: 127.0.0.1 User: sheila A " +"message at ERROR level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f DEBUG IP: 123.231.231.123 User: fred A " +"message at DEBUG level with 2 parameters\n" +"2010-09-06 22:38:15,301 d.e.f INFO IP: 123.231.231.123 User: fred A " +"message at INFO level with 2 parameters" #: ../../howto/logging-cookbook.rst:1026 msgid "Use of ``contextvars``" msgstr "``contextvars`` の利用" -#: ../../howto/logging-cookbook.rst:1028 msgid "" "Since Python 3.7, the :mod:`contextvars` module has provided context-local " "storage which works for both :mod:`threading` and :mod:`asyncio` processing " @@ -1578,12 +2131,11 @@ msgid "" "logs can populated with contextual information such as, for example, request " "attributes handled by web applications." msgstr "" -"Python 3.7 以降、 :mod:`contextvars` モジュールは :mod:`threading` と :mod:" -"`asyncio` の両方の処理上のニーズを満たすコンテキストローカルな変数を提供して" -"います。このタイプの変数はスレッドローカルな変数に適しています。以下の例は、" -"マルチスレッド環境において、 いかにして web アプリケーションによって処理され" -"るリクエスト属性のような処理の文脈上の情報とともにログを投入できるかを示しま" -"す。" +"Python 3.7 以降の :mod:`contextvars` モジュールは、:mod:`threading` と :mod:" +"`asyncio` の両方で使えるコンテキストローカルな記憶領域を提供します。\n" +"このため、一般にスレッドローカルな記憶領域より適している場合があります。\n" +"次の例では、マルチスレッド環境で Web アプリケーションが処理するリクエストの属" +"性など、コンテキスト情報をログに追加する方法を示します。" #: ../../howto/logging-cookbook.rst:1034 msgid "" @@ -1606,7 +2158,6 @@ msgstr "" msgid "Let's assume that the library can be simulated by the following code:" msgstr "ここで、ライブラリは以下のコードで模することができるとします:" -#: ../../howto/logging-cookbook.rst:1043 msgid "" "# webapplib.py\n" "import logging\n" @@ -1620,6 +2171,17 @@ msgid "" " # Just sleep for a bit so other threads get to run\n" " time.sleep(0.01)" msgstr "" +"# webapplib.py\n" +"import logging\n" +"import time\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def useful():\n" +" # ライブラリから記録する代表的なイベント\n" +" logger.debug('Hello from webapplib!')\n" +" # 他のスレッドが実行されるよう少し待つ\n" +" time.sleep(0.01)" #: ../../howto/logging-cookbook.rst:1057 msgid "" @@ -1787,7 +2349,6 @@ msgid "" " main()" msgstr "" -#: ../../howto/logging-cookbook.rst:1201 msgid "" "If you run the above, you should find that roughly half the requests go " "into :file:`app1.log` and the rest into :file:`app2.log`, and the all the " @@ -1797,15 +2358,15 @@ msgid "" "dummy request will always appear together in a log line). This is " "illustrated by the following shell output:" msgstr "" -"上記のコードを実行すると、およそ半分のリクエストが :file:`app1.log` に、残り" -"半分が :file:`app2.log` にそれぞれ記録され、同時に全てのリクエストが :file:" -"`app.log` に記録されることがわかるでしょう。それぞれの web アプリケーション固" -"有のログはそれぞれのアプリケーションからのログエントリだけを含み、リクエスト" -"情報が矛盾なくログに表示されている (すなわち、各ダミーリクエストの情報は常に" -"ログの行とともに現れる) はずです。このことは以下のシェルコマンドの出力により" -"例示されています:" +"上のコードを実行すると、リクエストのおよそ半分が :file:`app1.log` に、残り" +"が :file:`app2.log` に記録され、すべてのリクエストが :file:`app.log` にも記録" +"されます。\n" +"各 Web アプリケーション専用のログには、そのアプリケーションのログエントリだけ" +"が含まれます。\n" +"また、リクエストの情報は一貫して表示されます。\n" +"つまり、各ダミーリクエストの情報は常に同じログ行にまとまって現れます。\n" +"次のシェル出力で確認できます:" -#: ../../howto/logging-cookbook.rst:1208 msgid "" "~/logging-contextual-webapp$ python main.py\n" "app1 processed 51 requests\n" @@ -1859,24 +2420,74 @@ msgid "" "~/logging-contextual-webapp$ grep app2 app.log | wc -l\n" "147" msgstr "" - -#: ../../howto/logging-cookbook.rst:1248 -msgid "Imparting contextual information in handlers" -msgstr "ハンドラ内でのコンテキスト情報の付与" - -#: ../../howto/logging-cookbook.rst:1250 -msgid "" -"Each :class:`~Handler` has its own chain of filters. If you want to add " -"contextual information to a :class:`LogRecord` without leaking it to other " -"handlers, you can use a filter that returns a new :class:`~LogRecord` " -"instead of modifying it in-place, as shown in the following script::" -msgstr "" -":class:`~Handler` はそれぞれ一連のフィルタを独自に持っています。コンテキスト" +"~/logging-contextual-webapp$ python main.py\n" +"app1 processed 51 requests\n" +"app2 processed 49 requests\n" +"~/logging-contextual-webapp$ wc -l *.log\n" +" 153 app1.log\n" +" 147 app2.log\n" +" 300 app.log\n" +" 600 total\n" +"~/logging-contextual-webapp$ head -3 app1.log\n" +"Thread-3 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-3 (process_request) app1 webapplib jim 192.168.3.21 POST Hello " +"from webapplib!\n" +"Thread-5 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"~/logging-contextual-webapp$ head -3 app2.log\n" +"Thread-1 (process_request) app2 __main__ sheila 192.168.2.21 GET Request " +"processing started\n" +"Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET Hello " +"from webapplib!\n" +"Thread-2 (process_request) app2 __main__ jim 192.168.2.20 GET Request " +"processing started\n" +"~/logging-contextual-webapp$ head app.log\n" +"Thread-1 (process_request) app2 __main__ sheila 192.168.2.21 GET Request " +"processing started\n" +"Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET Hello " +"from webapplib!\n" +"Thread-2 (process_request) app2 __main__ jim 192.168.2.20 GET Request " +"processing started\n" +"Thread-3 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-2 (process_request) app2 webapplib jim 192.168.2.20 GET Hello " +"from webapplib!\n" +"Thread-3 (process_request) app1 webapplib jim 192.168.3.21 POST Hello " +"from webapplib!\n" +"Thread-4 (process_request) app2 __main__ fred 192.168.2.22 GET Request " +"processing started\n" +"Thread-5 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"Thread-4 (process_request) app2 webapplib fred 192.168.2.22 GET Hello " +"from webapplib!\n" +"Thread-6 (process_request) app1 __main__ jim 192.168.3.21 POST Request " +"processing started\n" +"~/logging-contextual-webapp$ grep app1 app1.log | wc -l\n" +"153\n" +"~/logging-contextual-webapp$ grep app2 app2.log | wc -l\n" +"147\n" +"~/logging-contextual-webapp$ grep app1 app.log | wc -l\n" +"153\n" +"~/logging-contextual-webapp$ grep app2 app.log | wc -l\n" +"147" + +#: ../../howto/logging-cookbook.rst:1248 +msgid "Imparting contextual information in handlers" +msgstr "ハンドラ内でのコンテキスト情報の付与" + +#: ../../howto/logging-cookbook.rst:1250 +msgid "" +"Each :class:`~Handler` has its own chain of filters. If you want to add " +"contextual information to a :class:`LogRecord` without leaking it to other " +"handlers, you can use a filter that returns a new :class:`~LogRecord` " +"instead of modifying it in-place, as shown in the following script::" +msgstr "" +":class:`~Handler` はそれぞれ一連のフィルタを独自に持っています。コンテキスト" "情報を、他のハンドラに漏らすことなく :class:`LogRecord` に付加したい場合、以" "下に示すスクリプトのように、直接レコードを編集する代わりに新しい :class:" "`~LogRecord` を返すフィルタを使うことができます::" -#: ../../howto/logging-cookbook.rst:1255 msgid "" "import copy\n" "import logging\n" @@ -1897,12 +2508,29 @@ msgid "" "\n" " logger.info('A log message')" msgstr "" +"import copy\n" +"import logging\n" +"\n" +"def filter(record: logging.LogRecord):\n" +" record = copy.copy(record)\n" +" record.user = 'jim'\n" +" return record\n" +"\n" +"if __name__ == '__main__':\n" +" logger = logging.getLogger()\n" +" logger.setLevel(logging.INFO)\n" +" handler = logging.StreamHandler()\n" +" formatter = logging.Formatter('%(message)s from %(user)-8s')\n" +" handler.setFormatter(formatter)\n" +" handler.addFilter(filter)\n" +" logger.addHandler(handler)\n" +"\n" +" logger.info('A log message')" #: ../../howto/logging-cookbook.rst:1277 msgid "Logging to a single file from multiple processes" msgstr "複数のプロセスからの単一ファイルへのログ記録" -#: ../../howto/logging-cookbook.rst:1279 msgid "" "Although logging is thread-safe, and logging to a single file from multiple " "threads in a single process *is* supported, logging to a single file from " @@ -1917,26 +2545,31 @@ msgid "" "includes a working socket receiver which can be used as a starting point for " "you to adapt in your own applications." msgstr "" -"ログ記録はスレッドセーフであり、単一プロセスの複数のスレッドからの単一ファイ" -"ルへのログ記録はサポート *されています* が、 *複数プロセス* からの単一ファイ" -"ルへのログ記録はサポート *されません* 。なぜなら、複数のプロセスをまたいで単" -"一のファイルへのアクセスを直列化する標準の方法が Python には存在しないからで" -"す。複数のプロセスから単一ファイルへログ記録しなければならないなら、最も良い" -"方法は、すべてのプロセスが :class:`~handlers.SocketHandler` に対してログ記録" -"を行い、独立したプロセスとしてソケットサーバを動かすことです。ソケットサーバ" -"はソケットから読み取ってファイルにログを書き出します。 (この機能を実行するた" -"めに、既存のプロセスの 1 つのスレッドを割り当てることもできます) :ref:`この" -"節 ` では、このアプローチをさらに詳細に文書化しています。動" -"作するソケット受信プログラムが含まれているので、アプリケーションに組み込むた" -"めの出発点として使用できるでしょう。" - -#: ../../howto/logging-cookbook.rst:1292 +"logging はスレッドセーフで、一つのプロセスの複数のスレッドから単一のファイル" +"にログを記録することはサポート *されています*。\n" +"一方、*複数のプロセス* から単一のファイルに記録することはサポート *されません" +"*。\n" +"Python には、複数のプロセスによる単一ファイルへのアクセスを直列化する標準的な" +"方法がないためです。\n" +"必要な場合は、すべてのプロセスで :class:`~handlers.SocketHandler` にログを送" +"り、別のプロセスにソケットサーバーを実装して、受信したログをファイルに書き込" +"む方法があります。\n" +"既存のプロセスの一つのスレッドを、この処理専用にすることもできます。\n" +":ref:`この節 ` ではこの方法を詳しく説明し、動作するソケット" +"受信プログラムも示しています。\n" +"自分のアプリケーションに合わせて変更する際の出発点として使えます。" + msgid "" "You could also write your own handler which uses the :class:" "`~multiprocessing.Lock` class from the :mod:`multiprocessing` module to " "serialize access to the file from your processes. The stdlib :class:" "`FileHandler` and subclasses do not make use of :mod:`multiprocessing`." msgstr "" +":mod:`multiprocessing` モジュールの :class:`~multiprocessing.Lock` クラスを使" +"い、複数のプロセスからファイルへのアクセスを直列化する独自のハンドラを作るこ" +"ともできます。\n" +"標準ライブラリの :class:`FileHandler` とそのサブクラスは :mod:" +"`multiprocessing` を使っていません。" #: ../../howto/logging-cookbook.rst:1299 msgid "" @@ -1961,7 +2594,6 @@ msgstr "" "listener とアプリケーション内の他のプロセスで完全に異なる設定を使う例になって" "いるので、各自の要求に応じたコードを書く叩き台になるでしょう::" -#: ../../howto/logging-cookbook.rst:1310 msgid "" "# You'll need these imports in your own code\n" "import logging\n" @@ -2080,6 +2712,114 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"# 自分のコードでもこれらのインポートが必要\n" +"import logging\n" +"import logging.handlers\n" +"import multiprocessing\n" +"\n" +"# 次の 2 行のインポートはこの実演用\n" +"from random import choice, random\n" +"import time\n" +"\n" +"#\n" +"# リスナーとワーカーのログ設定を定義できるよう、両プロセスの関数は\n" +"# そのプロセスのログを設定する呼び出し可能オブジェクトを\n" +"# configurer パラメーターで受け取る。これらの関数には、\n" +"# 通信に使うキューも渡す。\n" +"#\n" +"# 実際にはリスナーを自由に設定できるが、この単純な例では、\n" +"# リスナーは受信したレコードにレベルやフィルターの処理を適用しない。\n" +"# 通常は、除外されるイベントをプロセス間で送らないよう、\n" +"# ワーカープロセス側でこれらの処理を行うとよい。\n" +"#\n" +"# 結果を確認しやすいよう、ローテーションするファイルのサイズを小さくする。\n" +"def listener_configurer():\n" +" root = logging.getLogger()\n" +" h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)\n" +" f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s " +"%(levelname)-8s %(message)s')\n" +" h.setFormatter(f)\n" +" root.addHandler(h)\n" +"\n" +"# リスナープロセスの最上位のループ。キューからログイベント\n" +"# (LogRecord) を待ち受けて処理し、\n" +"# LogRecord の代わりに None を受け取ったら終了する。\n" +"def listener_process(queue, configurer):\n" +" configurer()\n" +" while True:\n" +" try:\n" +" record = queue.get()\n" +" if record is None: # 終了を伝える番兵としてリスナーに送る。\n" +" break\n" +" logger = logging.getLogger(record.name)\n" +" logger.handle(record) # レベルやフィルターの処理を適用せず、その" +"まま記録する。\n" +" except Exception:\n" +" import sys, traceback\n" +" print('Whoops! Problem:', file=sys.stderr)\n" +" traceback.print_exc(file=sys.stderr)\n" +"\n" +"# この実演でランダムに選択するための配列\n" +"\n" +"LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING,\n" +" logging.ERROR, logging.CRITICAL]\n" +"\n" +"LOGGERS = ['a.b.c', 'd.e.f']\n" +"\n" +"MESSAGES = [\n" +" 'Random message #1',\n" +" 'Random message #2',\n" +" 'Random message #3',\n" +"]\n" +"\n" +"# ワーカーの設定は、ワーカープロセスの実行開始時に行う。\n" +"# Windows では fork の動作に頼れないため、\n" +"# 各プロセスが開始時にログ設定のコードを実行する。\n" +"def worker_configurer(queue):\n" +" h = logging.handlers.QueueHandler(queue) # 必要なハンドラーはこの一つだ" +"け\n" +" root = logging.getLogger()\n" +" root.addHandler(h)\n" +" # 実演のためすべてのメッセージを送り、他のレベルやフィルターの処理は適用" +"しない。\n" +" root.setLevel(logging.DEBUG)\n" +"\n" +"# ワーカープロセスの最上位のループ。ランダムな間隔を空けて\n" +"# 10 個のイベントを記録してから終了する。\n" +"# print のメッセージは、何か動作していることを確認するためだけのもの。\n" +"def worker_process(queue, configurer):\n" +" configurer(queue)\n" +" name = multiprocessing.current_process().name\n" +" print('Worker started: %s' % name)\n" +" for i in range(10):\n" +" time.sleep(random())\n" +" logger = logging.getLogger(choice(LOGGERS))\n" +" level = choice(LEVELS)\n" +" message = choice(MESSAGES)\n" +" logger.log(level, message)\n" +" print('Worker finished: %s' % name)\n" +"\n" +"# 実演全体を制御する。キューを作成し、リスナーを作成して開始する。\n" +"# 10 個のワーカーを作成して開始し、終了を待つ。\n" +"# 最後にキューに None を送り、リスナーに終了を伝える。\n" +"def main():\n" +" queue = multiprocessing.Queue(-1)\n" +" listener = multiprocessing.Process(target=listener_process,\n" +" args=(queue, listener_configurer))\n" +" listener.start()\n" +" workers = []\n" +" for i in range(10):\n" +" worker = multiprocessing.Process(target=worker_process,\n" +" args=(queue, worker_configurer))\n" +" workers.append(worker)\n" +" worker.start()\n" +" for w in workers:\n" +" w.join()\n" +" queue.put_nowait(None)\n" +" listener.join()\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../howto/logging-cookbook.rst:1415 msgid "" @@ -2087,7 +2827,6 @@ msgid "" "separate thread::" msgstr "上のスクリプトの亜種で、logging をメインプロセスの別スレッドで行う例::" -#: ../../howto/logging-cookbook.rst:1418 msgid "" "import logging\n" "import logging.config\n" @@ -2183,6 +2922,99 @@ msgid "" " q.put(None)\n" " lp.join()" msgstr "" +"import logging\n" +"import logging.config\n" +"import logging.handlers\n" +"from multiprocessing import Process, Queue\n" +"import random\n" +"import threading\n" +"import time\n" +"\n" +"def logger_thread(q):\n" +" while True:\n" +" record = q.get()\n" +" if record is None:\n" +" break\n" +" logger = logging.getLogger(record.name)\n" +" logger.handle(record)\n" +"\n" +"\n" +"def worker_process(q):\n" +" qh = logging.handlers.QueueHandler(q)\n" +" root = logging.getLogger()\n" +" root.setLevel(logging.DEBUG)\n" +" root.addHandler(qh)\n" +" levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL]\n" +" loggers = ['foo', 'foo.bar', 'foo.bar.baz',\n" +" 'spam', 'spam.ham', 'spam.ham.eggs']\n" +" for i in range(100):\n" +" lvl = random.choice(levels)\n" +" logger = logging.getLogger(random.choice(loggers))\n" +" logger.log(lvl, 'Message no. %d', i)\n" +"\n" +"if __name__ == '__main__':\n" +" q = Queue()\n" +" d = {\n" +" 'version': 1,\n" +" 'formatters': {\n" +" 'detailed': {\n" +" 'class': 'logging.Formatter',\n" +" 'format': '%(asctime)s %(name)-15s %(levelname)-8s " +"%(processName)-10s %(message)s'\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'level': 'INFO',\n" +" },\n" +" 'file': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed',\n" +" },\n" +" 'foofile': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-foo.log',\n" +" 'mode': 'w',\n" +" 'formatter': 'detailed',\n" +" },\n" +" 'errors': {\n" +" 'class': 'logging.FileHandler',\n" +" 'filename': 'mplog-errors.log',\n" +" 'mode': 'w',\n" +" 'level': 'ERROR',\n" +" 'formatter': 'detailed',\n" +" },\n" +" },\n" +" 'loggers': {\n" +" 'foo': {\n" +" 'handlers': ['foofile']\n" +" }\n" +" },\n" +" 'root': {\n" +" 'level': 'DEBUG',\n" +" 'handlers': ['console', 'file', 'errors']\n" +" },\n" +" }\n" +" workers = []\n" +" for i in range(5):\n" +" wp = Process(target=worker_process, name='worker %d' % (i + 1), " +"args=(q,))\n" +" workers.append(wp)\n" +" wp.start()\n" +" logging.config.dictConfig(d)\n" +" lp = threading.Thread(target=logger_thread, args=(q,))\n" +" lp.start()\n" +" # この時点で、メインプロセスは独自の仕事を行える\n" +" # それが終わったら、ワーカーの終了を待てる。\n" +" for wp in workers:\n" +" wp.join()\n" +" # ログ用のスレッドにも終了を伝える\n" +" q.put(None)\n" +" lp.join()" #: ../../howto/logging-cookbook.rst:1510 msgid "" @@ -2213,25 +3045,24 @@ msgstr "" "ProcessPoolExecutor` を使いたいのであれば、少し違う方法でキューを作る必要があ" "ります。次のような方法の代わりに" -#: ../../howto/logging-cookbook.rst:1523 msgid "queue = multiprocessing.Queue(-1)" -msgstr "" +msgstr "queue = multiprocessing.Queue(-1)" #: ../../howto/logging-cookbook.rst:1527 msgid "you should use" msgstr "次のコードを利用する必要があります" -#: ../../howto/logging-cookbook.rst:1529 msgid "" "queue = multiprocessing.Manager().Queue(-1) # also works with the examples " "above" msgstr "" +"queue = multiprocessing.Manager().Queue(-1) # also works with the examples " +"above" #: ../../howto/logging-cookbook.rst:1533 msgid "and you can then replace the worker creation from this::" msgstr "そして、次のようなワーカー作成コードがあったとすると::" -#: ../../howto/logging-cookbook.rst:1535 msgid "" "workers = []\n" "for i in range(10):\n" @@ -2242,25 +3073,33 @@ msgid "" "for w in workers:\n" " w.join()" msgstr "" - -#: ../../howto/logging-cookbook.rst:1544 -msgid "to this (remembering to first import :mod:`concurrent.futures`)::" +"workers = []\n" +"for i in range(10):\n" +" worker = multiprocessing.Process(target=worker_process,\n" +" args=(queue, worker_configurer))\n" +" workers.append(worker)\n" +" worker.start()\n" +"for w in workers:\n" +" w.join()" + +#: ../../howto/logging-cookbook.rst:1544 +msgid "to this (remembering to first import :mod:`concurrent.futures`)::" msgstr "" "次のように変更します(最初に :mod:`concurrent.futures` をインポートするのを忘" "れないようにしましょう)::" -#: ../../howto/logging-cookbook.rst:1546 msgid "" "with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:\n" " for i in range(10):\n" " executor.submit(worker_process, queue, worker_configurer)" msgstr "" +"with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:\n" +" for i in range(10):\n" +" executor.submit(worker_process, queue, worker_configurer)" -#: ../../howto/logging-cookbook.rst:1551 msgid "Deploying web applications using Gunicorn and uWSGI" -msgstr "" +msgstr "Gunicorn や uWSGI を使った Web アプリケーションのデプロイ" -#: ../../howto/logging-cookbook.rst:1553 msgid "" "When deploying web applications using `Gunicorn `_ or " "`uWSGI `_ (or similar), " @@ -2271,6 +3110,17 @@ msgid "" "process management tool such as Supervisor - see `Running a logging socket " "listener in production`_ for more details." msgstr "" +"`Gunicorn `_ や `uWSGI `_ などで Web アプリケーションをデプロイすると、ク" +"ライアントのリクエストを処理するために複数のワーカープロセスが作成されま" +"す。\n" +"このような環境では、Web アプリケーション内でファイルに書き込むハンドラを直接" +"作成することは避けてください。\n" +"代わりに :class:`SocketHandler` を使い、Web アプリケーションから別のプロセス" +"のリスナーにログを送ります。\n" +"Supervisor などのプロセス管理ツールで構成できます。\n" +"詳細は `本番環境でロギングソケットのリスナーを実行する `_ を参照してください。" #: ../../howto/logging-cookbook.rst:1563 msgid "Using file rotation" @@ -2290,7 +3140,6 @@ msgstr "" "利用パターンのために、 logging パッケージは :class:`RotatingFileHandler` を提" "供しています::" -#: ../../howto/logging-cookbook.rst:1571 msgid "" "import glob\n" "import logging\n" @@ -2318,6 +3167,31 @@ msgid "" "for filename in logfiles:\n" " print(filename)" msgstr "" +"import glob\n" +"import logging\n" +"import logging.handlers\n" +"\n" +"LOG_FILENAME = 'logging_rotatingfile_example.out'\n" +"\n" +"# 目的の出力レベルを持つロガーを設定する\n" +"my_logger = logging.getLogger('MyLogger')\n" +"my_logger.setLevel(logging.DEBUG)\n" +"\n" +"# ログメッセージのハンドラーをロガーに追加する\n" +"handler = logging.handlers.RotatingFileHandler(\n" +" LOG_FILENAME, maxBytes=20, backupCount=5)\n" +"\n" +"my_logger.addHandler(handler)\n" +"\n" +"# メッセージを記録する\n" +"for i in range(20):\n" +" my_logger.debug('i = %d' % i)\n" +"\n" +"# 作成されたファイルを確認する\n" +"logfiles = glob.glob('%s*' % LOG_FILENAME)\n" +"\n" +"for filename in logfiles:\n" +" print(filename)" #: ../../howto/logging-cookbook.rst:1597 msgid "" @@ -2327,7 +3201,6 @@ msgstr "" "この結果として、アプリケーションのログ履歴の一部である、6 つに別れたファイル" "が得られます:" -#: ../../howto/logging-cookbook.rst:1600 msgid "" "logging_rotatingfile_example.out\n" "logging_rotatingfile_example.out.1\n" @@ -2336,6 +3209,12 @@ msgid "" "logging_rotatingfile_example.out.4\n" "logging_rotatingfile_example.out.5" msgstr "" +"logging_rotatingfile_example.out\n" +"logging_rotatingfile_example.out.1\n" +"logging_rotatingfile_example.out.2\n" +"logging_rotatingfile_example.out.3\n" +"logging_rotatingfile_example.out.4\n" +"logging_rotatingfile_example.out.5" #: ../../howto/logging-cookbook.rst:1609 msgid "" @@ -2394,7 +3273,6 @@ msgstr "" "で、 :meth:`str.format` か :class:`string.Template` を使った format を指定す" "る事ができます。次の例はこの機能を使ってみています:" -#: ../../howto/logging-cookbook.rst:1640 msgid "" ">>> import logging\n" ">>> root = logging.getLogger()\n" @@ -2418,6 +3296,27 @@ msgid "" "2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" ">>>" msgstr "" +">>> import logging\n" +">>> root = logging.getLogger()\n" +">>> root.setLevel(logging.DEBUG)\n" +">>> handler = logging.StreamHandler()\n" +">>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}',\n" +"... style='{')\n" +">>> handler.setFormatter(bf)\n" +">>> root.addHandler(handler)\n" +">>> logger = logging.getLogger('foo.bar')\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:11:55,341 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message\n" +">>> df = logging.Formatter('$asctime $name ${levelname} $message',\n" +"... style='$')\n" +">>> handler.setFormatter(df)\n" +">>> logger.debug('This is a DEBUG message')\n" +"2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message\n" +">>> logger.critical('This is a CRITICAL message')\n" +"2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message\n" +">>>" #: ../../howto/logging-cookbook.rst:1664 msgid "" @@ -2429,12 +3328,14 @@ msgstr "" "全に独立していることに注意してください。次の例でわかるように、メッセージを生" "成する部分では % を使い続けています::" -#: ../../howto/logging-cookbook.rst:1668 msgid "" ">>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')\n" "2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" ">>>" msgstr "" +">>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')\n" +"2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message\n" +">>>" #: ../../howto/logging-cookbook.rst:1672 msgid "" @@ -2474,7 +3375,6 @@ msgstr "" "logging パッケージはそのオブジェクトに対して ``str()`` を使って実際の format " "文字列を生成します。次の2つのクラスを見てください::" -#: ../../howto/logging-cookbook.rst:1691 ../../howto/logging-cookbook.rst:2779 msgid "" "class BraceMessage:\n" " def __init__(self, fmt, /, *args, **kwargs):\n" @@ -2494,6 +3394,23 @@ msgid "" " from string import Template\n" " return Template(self.fmt).substitute(**self.kwargs)" msgstr "" +"class BraceMessage:\n" +" def __init__(self, fmt, /, *args, **kwargs):\n" +" self.fmt = fmt\n" +" self.args = args\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" return self.fmt.format(*self.args, **self.kwargs)\n" +"\n" +"class DollarMessage:\n" +" def __init__(self, fmt, /, **kwargs):\n" +" self.fmt = fmt\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" from string import Template\n" +" return Template(self.fmt).substitute(**self.kwargs)" #: ../../howto/logging-cookbook.rst:1709 msgid "" @@ -2522,7 +3439,6 @@ msgstr "" "です。これらは次の例のようにして利用できます。(上のクラスが ``wherever`` とい" "うモジュールで定義されていると仮定します):" -#: ../../howto/logging-cookbook.rst:1721 msgid "" ">>> from wherever import BraceMessage as __\n" ">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" @@ -2540,6 +3456,21 @@ msgid "" "Message with 2 placeholders\n" ">>>" msgstr "" +">>> from wherever import BraceMessage as __\n" +">>> print(__('Message with {0} {name}', 2, name='placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',\n" +"... point=p))\n" +"Message with coordinates: (0.50, 0.50)\n" +">>> from wherever import DollarMessage as __\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" #: ../../howto/logging-cookbook.rst:1739 msgid "" @@ -2576,7 +3507,6 @@ msgstr "" "次の例のように、 :class:`LoggerAdapter` を利用して上と似たような効果を実現す" "る方法もあります::" -#: ../../howto/logging-cookbook.rst:1754 msgid "" "import logging\n" "\n" @@ -2604,6 +3534,31 @@ msgid "" " logging.basicConfig(level=logging.DEBUG)\n" " main()" msgstr "" +"import logging\n" +"\n" +"class Message:\n" +" def __init__(self, fmt, args):\n" +" self.fmt = fmt\n" +" self.args = args\n" +"\n" +" def __str__(self):\n" +" return self.fmt.format(*self.args)\n" +"\n" +"class StyleAdapter(logging.LoggerAdapter):\n" +" def log(self, level, msg, /, *args, stacklevel=1, **kwargs):\n" +" if self.isEnabledFor(level):\n" +" msg, kwargs = self.process(msg, kwargs)\n" +" self.logger.log(level, Message(msg, args), **kwargs,\n" +" stacklevel=stacklevel+1)\n" +"\n" +"logger = StyleAdapter(logging.getLogger(__name__))\n" +"\n" +"def main():\n" +" logger.debug('Hello, {}', 'world!')\n" +"\n" +"if __name__ == '__main__':\n" +" logging.basicConfig(level=logging.DEBUG)\n" +" main()" #: ../../howto/logging-cookbook.rst:1780 msgid "" @@ -2617,7 +3572,6 @@ msgstr "" msgid "Customizing ``LogRecord``" msgstr "``LogRecord`` のカスタマイズ" -#: ../../howto/logging-cookbook.rst:1791 msgid "" "Every logging event is represented by a :class:`LogRecord` instance. When an " "event is logged and not filtered out by a logger's level, a :class:" @@ -2627,19 +3581,20 @@ msgid "" "disabled). Before Python 3.2, there were only two places where this creation " "was done:" msgstr "" -"全ての logging イベントは :class:`LogRecord` のインスタンスとして表現されま" -"す。イベントのログが取られて logger のレベルでフィルタされなかった場合、イベ" -"ントの情報を含む :class:`LogRecord` が生成され、その logger (と、 propagate " -"が無効になるまでの上位 logger) の handler に渡されます。 Python 3.2 までは、" -"この生成が行われているのは2箇所だけでした:" +"すべてのログイベントは :class:`LogRecord` インスタンスで表されます。\n" +"ログ呼び出しが行われ、ロガーのレベルで除外されなければ、イベントの情報を格納" +"した :class:`LogRecord` が作成されます。\n" +"これはそのロガーのハンドラと、階層の上方向への伝播が無効になっているロガーま" +"での、祖先ロガーのハンドラに渡されます (伝播が無効なロガー自身も含みます)。\n" +"Python 3.2 より前では、レコードを作成する箇所は次の二つだけでした:" -#: ../../howto/logging-cookbook.rst:1798 msgid "" ":meth:`Logger.makeRecord`, which is called in the normal process of logging " "an event. This invoked :class:`LogRecord` directly to create an instance." msgstr "" -":meth:`Logger.makeRecord`: 通常のイベント logging プロセスで呼ばれます。これ" -"は :class:`LogRecord` を直接読んでインスタンスを生成します。" +":meth:`Logger.makeRecord` は、通常のログイベントの処理中に呼び出されます。\n" +"このメソッドは :class:`LogRecord` を直接呼び出してインスタンスを作成していま" +"した。" #: ../../howto/logging-cookbook.rst:1801 msgid "" @@ -2662,15 +3617,14 @@ msgstr "" "そのために :class:`LogRecord` で何か特別なことをしたい場合は、次のどちらかを" "しなければなりません。" -#: ../../howto/logging-cookbook.rst:1810 msgid "" "Create your own :class:`Logger` subclass, which overrides :meth:`Logger." "makeRecord`, and set it using :func:`~logging.setLoggerClass` before any " "loggers that you care about are instantiated." msgstr "" -":meth:`Logger.makeRecord` をオーバーライドした独自の :class:`Logger` のサブク" -"ラスを作り、利用したい logger のどれかがインスタンス化される前に、それを :" -"func:`~logging.setLoggerClass` を使って登録する。" +":meth:`Logger.makeRecord` をオーバーライドする独自の :class:`Logger` サブクラ" +"スを作り、対象とするロガーが一つでもインスタンス化される前に、:func:" +"`~logging.setLoggerClass` で登録する。" #: ../../howto/logging-cookbook.rst:1813 msgid "" @@ -2706,9 +3660,8 @@ msgstr "" "れずに設定しないといけなくなります。 (新しいパッケージやモジュールを追加し、" "モジュールレベルで次の式を実行することで、新しい logger が作られます) ::" -#: ../../howto/logging-cookbook.rst:1828 msgid "logger = logging.getLogger(__name__)" -msgstr "" +msgstr "logger = logging.getLogger(__name__)" #: ../../howto/logging-cookbook.rst:1830 msgid "" @@ -2787,13 +3740,11 @@ msgstr "" "しての実行時のオーバーヘッドになることを念頭に置き、このテクニックは :class:" "`Filter` を利用するだけでは望む結果が得られない場合にのみ使うべきです。" -#: ../../howto/logging-cookbook.rst:1868 msgid "Subclassing QueueHandler and QueueListener- a ZeroMQ example" -msgstr "" +msgstr "QueueHandler と QueueListener のサブクラス化: ZeroMQ の例" -#: ../../howto/logging-cookbook.rst:1871 ../../howto/logging-cookbook.rst:2004 msgid "Subclass ``QueueHandler``" -msgstr "" +msgstr "``QueueHandler`` のサブクラス化" #: ../../howto/logging-cookbook.rst:1873 msgid "" @@ -2805,7 +3756,6 @@ msgstr "" "ZeroMQ の 'publish' ソケットに送信することができます。下の例では、ソケットを" "別に作ってそれを handler に ('queue' として) 渡します::" -#: ../../howto/logging-cookbook.rst:1877 msgid "" "import zmq # using pyzmq, the Python binding for ZeroMQ\n" "import json # for serializing records portably\n" @@ -2821,6 +3771,19 @@ msgid "" "\n" "handler = ZeroMQSocketHandler(sock)" msgstr "" +"import zmq # using pyzmq, the Python binding for ZeroMQ\n" +"import json # for serializing records portably\n" +"\n" +"ctx = zmq.Context()\n" +"sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value\n" +"sock.bind('tcp://*:5556') # or wherever\n" +"\n" +"class ZeroMQSocketHandler(QueueHandler):\n" +" def enqueue(self, record):\n" +" self.queue.send_json(record.__dict__)\n" +"\n" +"\n" +"handler = ZeroMQSocketHandler(sock)" #: ../../howto/logging-cookbook.rst:1892 msgid "" @@ -2830,7 +3793,6 @@ msgstr "" "もちろん同じことを別の設計でもできます。socket を作るのに必要な情報を " "handler に渡す例です::" -#: ../../howto/logging-cookbook.rst:1895 msgid "" "class ZeroMQSocketHandler(QueueHandler):\n" " def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" @@ -2845,10 +3807,21 @@ msgid "" " def close(self):\n" " self.queue.close()" msgstr "" +"class ZeroMQSocketHandler(QueueHandler):\n" +" def __init__(self, uri, socktype=zmq.PUB, ctx=None):\n" +" self.ctx = ctx or zmq.Context()\n" +" socket = zmq.Socket(self.ctx, socktype)\n" +" socket.bind(uri)\n" +" super().__init__(socket)\n" +"\n" +" def enqueue(self, record):\n" +" self.queue.send_json(record.__dict__)\n" +"\n" +" def close(self):\n" +" self.queue.close()" -#: ../../howto/logging-cookbook.rst:1910 ../../howto/logging-cookbook.rst:1940 msgid "Subclass ``QueueListener``" -msgstr "" +msgstr "``QueueListener`` のサブクラス化" #: ../../howto/logging-cookbook.rst:1912 msgid "" @@ -2874,11 +3847,9 @@ msgid "" " return logging.makeLogRecord(msg)" msgstr "" -#: ../../howto/logging-cookbook.rst:1930 msgid "Subclassing QueueHandler and QueueListener- a ``pynng`` example" -msgstr "" +msgstr "QueueHandler と QueueListener のサブクラス化: ``pynng`` の例" -#: ../../howto/logging-cookbook.rst:1932 msgid "" "In a similar way to the above section, we can implement a listener and " "handler using :pypi:`pynng`, which is a Python binding to `NNG `_ の Python バインディングです。\n" +"以下のコードは ``pynng`` をインストールした環境で試せます。\n" +"今回は順序を変えて、リスナーから示します。" -#: ../../howto/logging-cookbook.rst:1942 msgid "" "# listener.py\n" "import json\n" @@ -2948,8 +3924,65 @@ msgid "" "finally:\n" " listener.stop()" msgstr "" +"# listener.py\n" +"import json\n" +"import logging\n" +"import logging.handlers\n" +"\n" +"import pynng\n" +"\n" +"DEFAULT_ADDR = \"tcp://localhost:13232\"\n" +"\n" +"interrupted = False\n" +"\n" +"class NNGSocketListener(logging.handlers.QueueListener):\n" +"\n" +" def __init__(self, uri, /, *handlers, **kwargs):\n" +" # 中断できるようタイムアウトを設定し、\n" +" # 購読用のソケットを開く\n" +" socket = pynng.Sub0(listen=uri, recv_timeout=500)\n" +" # b'' の購読設定はすべてのトピックに一致する\n" +" topics = kwargs.pop('topics', None) or b''\n" +" socket.subscribe(topics)\n" +" # ソケットをキューとして扱う\n" +" super().__init__(socket, *handlers, **kwargs)\n" +"\n" +" def dequeue(self, block):\n" +" data = None\n" +" # 中断されず、ソケットからデータを受信していない間は\n" +" # ループを続ける\n" +" while not interrupted:\n" +" try:\n" +" data = self.queue.recv(block=block)\n" +" break\n" +" except pynng.Timeout:\n" +" pass\n" +" except pynng.Closed: # Ctrl-C を押すと起こることがある\n" +" break\n" +" if data is None:\n" +" return None\n" +" # 発行者から送られたログイベントを取得する\n" +" event = json.loads(data.decode('utf-8'))\n" +" return logging.makeLogRecord(event)\n" +"\n" +" def enqueue_sentinel(self):\n" +" # ソケットは実際にはキューではないため、\n" +" # この実装では使わない\n" +" pass\n" +"\n" +"logging.getLogger('pynng').propagate = False\n" +"listener = NNGSocketListener(DEFAULT_ADDR, logging.StreamHandler(), " +"topics=b'')\n" +"listener.start()\n" +"print('Press Ctrl-C to stop.')\n" +"try:\n" +" while True:\n" +" pass\n" +"except KeyboardInterrupt:\n" +" interrupted = True\n" +"finally:\n" +" listener.stop()" -#: ../../howto/logging-cookbook.rst:2008 msgid "" "# sender.py\n" "import json\n" @@ -2997,15 +4030,62 @@ msgid "" " delay = random.random() * 2 + 0.5\n" " time.sleep(delay)" msgstr "" +"# sender.py\n" +"import json\n" +"import logging\n" +"import logging.handlers\n" +"import time\n" +"import random\n" +"\n" +"import pynng\n" +"\n" +"DEFAULT_ADDR = \"tcp://localhost:13232\"\n" +"\n" +"class NNGSocketHandler(logging.handlers.QueueHandler):\n" +"\n" +" def __init__(self, uri):\n" +" socket = pynng.Pub0(dial=uri, send_timeout=500)\n" +" super().__init__(socket)\n" +"\n" +" def enqueue(self, record):\n" +" # レコードを UTF-8 でエンコードした JSON として送る\n" +" d = dict(record.__dict__)\n" +" data = json.dumps(d)\n" +" self.queue.send(data.encode('utf-8'))\n" +"\n" +" def close(self):\n" +" self.queue.close()\n" +"\n" +"logging.getLogger('pynng').propagate = False\n" +"handler = NNGSocketHandler(DEFAULT_ADDR)\n" +"# 出力にプロセス ID を含める\n" +"logging.basicConfig(level=logging.DEBUG,\n" +" handlers=[logging.StreamHandler(), handler],\n" +" format='%(levelname)-8s %(name)10s %(process)6s " +"%(message)s')\n" +"levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL)\n" +"logger_names = ('myapp', 'myapp.lib1', 'myapp.lib2')\n" +"msgno = 1\n" +"while True:\n" +" # ロガーとレベルをランダムに選んで記録する\n" +" level = random.choice(levels)\n" +" logger = logging.getLogger(random.choice(logger_names))\n" +" logger.log(level, 'Message no. %5d' % msgno)\n" +" msgno += 1\n" +" delay = random.random() * 2 + 0.5\n" +" time.sleep(delay)" -#: ../../howto/logging-cookbook.rst:2055 msgid "" "You can run the above two snippets in separate command shells. If we run the " "listener in one shell and run the sender in two separate shells, we should " "see something like the following. In the first sender shell:" msgstr "" +"上の二つのコードは別々のシェルで実行できます。\n" +"一つのシェルでリスナーを、別の二つのシェルで送信側を実行すると、次のような出" +"力になります。\n" +"一つ目の送信側のシェルでは:" -#: ../../howto/logging-cookbook.rst:2059 msgid "" "$ python sender.py\n" "DEBUG myapp 613 Message no. 1\n" @@ -3018,12 +4098,20 @@ msgid "" "INFO myapp.lib1 613 Message no. 8\n" "(and so on)" msgstr "" +"$ python sender.py\n" +"DEBUG myapp 613 Message no. 1\n" +"WARNING myapp.lib2 613 Message no. 2\n" +"CRITICAL myapp.lib2 613 Message no. 3\n" +"WARNING myapp.lib2 613 Message no. 4\n" +"CRITICAL myapp.lib1 613 Message no. 5\n" +"DEBUG myapp 613 Message no. 6\n" +"CRITICAL myapp.lib1 613 Message no. 7\n" +"INFO myapp.lib1 613 Message no. 8\n" +"(and so on)" -#: ../../howto/logging-cookbook.rst:2072 msgid "In the second sender shell:" -msgstr "" +msgstr "二つ目の送信側のシェルでは:" -#: ../../howto/logging-cookbook.rst:2074 msgid "" "$ python sender.py\n" "INFO myapp.lib2 657 Message no. 1\n" @@ -3036,12 +4124,20 @@ msgid "" "DEBUG myapp.lib1 657 Message no. 8\n" "(and so on)" msgstr "" +"$ python sender.py\n" +"INFO myapp.lib2 657 Message no. 1\n" +"CRITICAL myapp.lib2 657 Message no. 2\n" +"CRITICAL myapp 657 Message no. 3\n" +"CRITICAL myapp.lib1 657 Message no. 4\n" +"INFO myapp.lib1 657 Message no. 5\n" +"WARNING myapp.lib2 657 Message no. 6\n" +"CRITICAL myapp 657 Message no. 7\n" +"DEBUG myapp.lib1 657 Message no. 8\n" +"(and so on)" + +msgid "In the listener shell:" +msgstr "リスナーのシェルでは:" -#: ../../howto/logging-cookbook.rst:2087 -msgid "In the listener shell:" -msgstr "" - -#: ../../howto/logging-cookbook.rst:2089 msgid "" "$ python listener.py\n" "Press Ctrl-C to stop.\n" @@ -3063,12 +4159,31 @@ msgid "" "DEBUG myapp.lib1 657 Message no. 8\n" "(and so on)" msgstr "" +"$ python listener.py\n" +"Press Ctrl-C to stop.\n" +"DEBUG myapp 613 Message no. 1\n" +"WARNING myapp.lib2 613 Message no. 2\n" +"INFO myapp.lib2 657 Message no. 1\n" +"CRITICAL myapp.lib2 613 Message no. 3\n" +"CRITICAL myapp.lib2 657 Message no. 2\n" +"CRITICAL myapp 657 Message no. 3\n" +"WARNING myapp.lib2 613 Message no. 4\n" +"CRITICAL myapp.lib1 613 Message no. 5\n" +"CRITICAL myapp.lib1 657 Message no. 4\n" +"INFO myapp.lib1 657 Message no. 5\n" +"DEBUG myapp 613 Message no. 6\n" +"WARNING myapp.lib2 657 Message no. 6\n" +"CRITICAL myapp 657 Message no. 7\n" +"CRITICAL myapp.lib1 613 Message no. 7\n" +"INFO myapp.lib1 613 Message no. 8\n" +"DEBUG myapp.lib1 657 Message no. 8\n" +"(and so on)" -#: ../../howto/logging-cookbook.rst:2111 msgid "" "As you can see, the logging from the two sender processes is interleaved in " "the listener's output." msgstr "" +"このように、リスナーの出力には二つの送信プロセスのログが入り交じっています。" #: ../../howto/logging-cookbook.rst:2116 msgid "An example dictionary-based configuration" @@ -3086,7 +4201,6 @@ msgstr "" "#configuring-logging>`_ から持ってきました。この辞書を :func:`~config." "dictConfig` に渡して設定を有効にします::" -#: ../../howto/logging-cookbook.rst:2122 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3138,6 +4252,55 @@ msgid "" " }\n" "}" msgstr "" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'verbose': {\n" +" 'format': '{levelname} {asctime} {module} {process:d} {thread:d} " +"{message}',\n" +" 'style': '{',\n" +" },\n" +" 'simple': {\n" +" 'format': '{levelname} {message}',\n" +" 'style': '{',\n" +" },\n" +" },\n" +" 'filters': {\n" +" 'special': {\n" +" '()': 'project.logging.SpecialFilter',\n" +" 'foo': 'bar',\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'level': 'INFO',\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'simple',\n" +" },\n" +" 'mail_admins': {\n" +" 'level': 'ERROR',\n" +" 'class': 'django.utils.log.AdminEmailHandler',\n" +" 'filters': ['special']\n" +" }\n" +" },\n" +" 'loggers': {\n" +" 'django': {\n" +" 'handlers': ['console'],\n" +" 'propagate': True,\n" +" },\n" +" 'django.request': {\n" +" 'handlers': ['mail_admins'],\n" +" 'level': 'ERROR',\n" +" 'propagate': False,\n" +" },\n" +" 'myproject.custom': {\n" +" 'handlers': ['console', 'mail_admins'],\n" +" 'level': 'INFO',\n" +" 'filters': ['special']\n" +" }\n" +" }\n" +"}" #: ../../howto/logging-cookbook.rst:2171 msgid "" @@ -3161,7 +4324,6 @@ msgstr "" "namer と rotator を定義する方法の例は以下の実行可能なスクリプトに示されていま" "す。ここではログファイルを gzip により圧縮する例を示しています::" -#: ../../howto/logging-cookbook.rst:2183 msgid "" "import gzip\n" "import logging\n" @@ -3192,6 +4354,34 @@ msgid "" "for i in range(1000):\n" " root.info(f'Message no. {i + 1}')" msgstr "" +"import gzip\n" +"import logging\n" +"import logging.handlers\n" +"import os\n" +"import shutil\n" +"\n" +"def namer(name):\n" +" return name + \".gz\"\n" +"\n" +"def rotator(source, dest):\n" +" with open(source, 'rb') as f_in:\n" +" with gzip.open(dest, 'wb') as f_out:\n" +" shutil.copyfileobj(f_in, f_out)\n" +" os.remove(source)\n" +"\n" +"\n" +"rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, " +"backupCount=5)\n" +"rh.rotator = rotator\n" +"rh.namer = namer\n" +"\n" +"root = logging.getLogger()\n" +"root.setLevel(logging.INFO)\n" +"root.addHandler(rh)\n" +"f = logging.Formatter('%(asctime)s %(message)s')\n" +"rh.setFormatter(f)\n" +"for i in range(1000):\n" +" root.info(f'Message no. {i + 1}')" #: ../../howto/logging-cookbook.rst:2211 msgid "" @@ -3200,7 +4390,6 @@ msgstr "" "このスクリプトを実行すると、6つの新しいファイルが生成され、そのうち5つは圧縮" "されています:" -#: ../../howto/logging-cookbook.rst:2213 msgid "" "$ ls rotated.log*\n" "rotated.log rotated.log.2.gz rotated.log.4.gz\n" @@ -3210,6 +4399,13 @@ msgid "" "2023-01-20 02:28:17,767 Message no. 997\n" "2023-01-20 02:28:17,767 Message no. 998" msgstr "" +"$ ls rotated.log*\n" +"rotated.log rotated.log.2.gz rotated.log.4.gz\n" +"rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz\n" +"$ zcat rotated.log.1.gz\n" +"2023-01-20 02:28:17,767 Message no. 996\n" +"2023-01-20 02:28:17,767 Message no. 997\n" +"2023-01-20 02:28:17,767 Message no. 998" #: ../../howto/logging-cookbook.rst:2224 msgid "A more elaborate multiprocessing example" @@ -3526,9 +4722,8 @@ msgstr "" ":class:`~logging.handlers.SysLogHandler` のインスタンスに、次のような format " "文字列を持った :class:`~logging.Formatter` インスタンスをアタッチする::" -#: ../../howto/logging-cookbook.rst:2477 msgid "'ASCII section\\ufeffUnicode section'" -msgstr "" +msgstr "'ASCII section\\ufeffUnicode section'" #: ../../howto/logging-cookbook.rst:2479 msgid "" @@ -3595,7 +4790,6 @@ msgstr "" "実現する方法は幾つもありますが、次の例は JSON を使ってイベントを、機械でパー" "スできる形にシリアライズする単純な方法です::" -#: ../../howto/logging-cookbook.rst:2507 msgid "" "import json\n" "import logging\n" @@ -3613,16 +4807,32 @@ msgid "" "logging.basicConfig(level=logging.INFO, format='%(message)s')\n" "logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" msgstr "" +"import json\n" +"import logging\n" +"\n" +"class StructuredMessage:\n" +" def __init__(self, message, /, **kwargs):\n" +" self.message = message\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" return '%s >>> %s' % (self.message, json.dumps(self.kwargs))\n" +"\n" +"_ = StructuredMessage # optional, to improve readability\n" +"\n" +"logging.basicConfig(level=logging.INFO, format='%(message)s')\n" +"logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))" #: ../../howto/logging-cookbook.rst:2523 msgid "If the above script is run, it prints:" msgstr "上のスクリプトを実行すると次のように出力されます:" -#: ../../howto/logging-cookbook.rst:2525 msgid "" "message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " "\"bar\"}" msgstr "" +"message 1 >>> {\"fnum\": 123.456, \"num\": 123, \"bar\": \"baz\", \"foo\": " +"\"bar\"}" #: ../../howto/logging-cookbook.rst:2529 ../../howto/logging-cookbook.rst:2571 msgid "" @@ -3638,7 +4848,6 @@ msgstr "" "より特殊な処理が必要な場合、次の例のように、カスタムの JSON エンコーダを作る" "ことができます::" -#: ../../howto/logging-cookbook.rst:2535 msgid "" "import json\n" "import logging\n" @@ -3670,20 +4879,47 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"import json\n" +"import logging\n" +"\n" +"\n" +"class Encoder(json.JSONEncoder):\n" +" def default(self, o):\n" +" if isinstance(o, set):\n" +" return tuple(o)\n" +" elif isinstance(o, str):\n" +" return o.encode('unicode_escape').decode('ascii')\n" +" return super().default(o)\n" +"\n" +"class StructuredMessage:\n" +" def __init__(self, message, /, **kwargs):\n" +" self.message = message\n" +" self.kwargs = kwargs\n" +"\n" +" def __str__(self):\n" +" s = Encoder().encode(self.kwargs)\n" +" return '%s >>> %s' % (self.message, s)\n" +"\n" +"_ = StructuredMessage # optional, to improve readability\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.INFO, format='%(message)s')\n" +" logging.info(_('message 1', set_value={1, 2, 3}, snowman='\\u2603'))\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../howto/logging-cookbook.rst:2565 msgid "When the above script is run, it prints:" msgstr "上のスクリプトを実行すると次のように出力されます:" -#: ../../howto/logging-cookbook.rst:2567 msgid "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" -msgstr "" +msgstr "message 1 >>> {\"snowman\": \"\\u2603\", \"set_value\": [1, 2, 3]}" #: ../../howto/logging-cookbook.rst:2580 msgid "Customizing handlers with :func:`dictConfig`" msgstr "handler を :func:`dictConfig` を使ってカスタマイズする" -#: ../../howto/logging-cookbook.rst:2582 msgid "" "There are times when you want to customize logging handlers in particular " "ways, and if you use :func:`dictConfig` you may be able to do this without " @@ -3692,14 +4928,13 @@ msgid "" "the file handlers in the stdlib don't offer built-in support. You can " "customize handler creation using a plain function such as::" msgstr "" -"logging handler に特定のカスタマイズを何度もしたい場合で、 :func:" -"`dictConfig` を使っているなら、サブクラスを作らなくてもカスタマイズが可能で" -"す。例えば、ログファイルの owner を設定したいとします。これは POSIX 環境で" -"は :func:`shutil.chown` を使って簡単に実現できますが、標準ライブラリの file " -"handler はこの機能を組み込みでサポートしていません。 handler の生成を通常の関" -"数を使ってカスタマイズすることができます::" +"ロギングハンドラを特定の方法でカスタマイズしたい場合、:func:`dictConfig` を使" +"えばサブクラスを作らずに実現できることがあります。\n" +"例えば、ログファイルの所有者を設定したいとします。\n" +"POSIX では :func:`shutil.chown` で簡単に設定できますが、標準ライブラリのファ" +"イルハンドラにはその機能が組み込まれていません。\n" +"次のような通常の関数で、ハンドラの作成をカスタマイズできます。 ::" -#: ../../howto/logging-cookbook.rst:2589 msgid "" "def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" " if owner:\n" @@ -3708,6 +4943,12 @@ msgid "" " shutil.chown(filename, *owner)\n" " return logging.FileHandler(filename, mode, encoding)" msgstr "" +"def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" +" if owner:\n" +" if not os.path.exists(filename):\n" +" open(filename, 'a').close()\n" +" shutil.chown(filename, *owner)\n" +" return logging.FileHandler(filename, mode, encoding)" #: ../../howto/logging-cookbook.rst:2596 msgid "" @@ -3717,7 +4958,6 @@ msgstr "" "そして、 :func:`dictConfig` に渡される構成設定の中で、この関数を使って " "logging handler を生成するように指定することができます::" -#: ../../howto/logging-cookbook.rst:2599 msgid "" "LOGGING = {\n" " 'version': 1,\n" @@ -3749,6 +4989,35 @@ msgid "" " },\n" "}" msgstr "" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'default': {\n" +" 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'file':{\n" +" # 以下の値はこの辞書から取り出して削除し、\n" +" # ハンドラーの作成、レベルの設定、\n" +" # フォーマッターの設定に使う。\n" +" '()': owned_file_handler,\n" +" 'level':'DEBUG',\n" +" 'formatter': 'default',\n" +" # 以下の値は、ハンドラーを作成する呼び出し可能オブジェクトに\n" +" # キーワード引数として渡す。\n" +" 'owner': ['pulse', 'pulse'],\n" +" 'filename': 'chowntest.log',\n" +" 'mode': 'w',\n" +" 'encoding': 'utf-8',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['file'],\n" +" 'level': 'DEBUG',\n" +" },\n" +"}" #: ../../howto/logging-cookbook.rst:2629 msgid "" @@ -3759,7 +5028,6 @@ msgstr "" "この例は説明用のものですが、owner の user と group を ``pulse`` に設定してい" "ます。これを動くスクリプトに ``chowntest.py`` に組み込んでみます::" -#: ../../howto/logging-cookbook.rst:2633 msgid "" "import logging, logging.config, os, shutil\n" "\n" @@ -3804,12 +5072,53 @@ msgid "" "logger = logging.getLogger('mylogger')\n" "logger.debug('A debug message')" msgstr "" +"import logging, logging.config, os, shutil\n" +"\n" +"def owned_file_handler(filename, mode='a', encoding=None, owner=None):\n" +" if owner:\n" +" if not os.path.exists(filename):\n" +" open(filename, 'a').close()\n" +" shutil.chown(filename, *owner)\n" +" return logging.FileHandler(filename, mode, encoding)\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'default': {\n" +" 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'\n" +" },\n" +" },\n" +" 'handlers': {\n" +" 'file':{\n" +" # 以下の値はこの辞書から取り出して削除し、\n" +" # ハンドラーの作成、レベルの設定、\n" +" # フォーマッターの設定に使う。\n" +" '()': owned_file_handler,\n" +" 'level':'DEBUG',\n" +" 'formatter': 'default',\n" +" # 以下の値は、ハンドラーを作成する呼び出し可能オブジェクトに\n" +" # キーワード引数として渡す。\n" +" 'owner': ['pulse', 'pulse'],\n" +" 'filename': 'chowntest.log',\n" +" 'mode': 'w',\n" +" 'encoding': 'utf-8',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['file'],\n" +" 'level': 'DEBUG',\n" +" },\n" +"}\n" +"\n" +"logging.config.dictConfig(LOGGING)\n" +"logger = logging.getLogger('mylogger')\n" +"logger.debug('A debug message')" #: ../../howto/logging-cookbook.rst:2676 msgid "To run this, you will probably need to run as ``root``:" msgstr "これを実行するには、 ``root`` 権限で実行する必要があるかもしれません:" -#: ../../howto/logging-cookbook.rst:2678 msgid "" "$ sudo python3.3 chowntest.py\n" "$ cat chowntest.log\n" @@ -3817,8 +5126,12 @@ msgid "" "$ ls -l chowntest.log\n" "-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" msgstr "" +"$ sudo python3.3 chowntest.py\n" +"$ cat chowntest.log\n" +"2013-11-05 09:34:51,128 DEBUG mylogger A debug message\n" +"$ ls -l chowntest.log\n" +"-rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log" -#: ../../howto/logging-cookbook.rst:2686 msgid "" "Note that this example uses Python 3.3 because that's where :func:`shutil." "chown` makes an appearance. This approach should work with any Python " @@ -3826,11 +5139,12 @@ msgid "" "With pre-3.3 versions, you would need to implement the actual ownership " "change using e.g. :func:`os.chown`." msgstr "" -":func:`shutil.chown` が追加されたのが Python 3.3 からなので、この例は Python " -"3.3 を使っています。このアプローチ自体は :func:`dictConfig` をサポートした全" -"ての Python バージョン - Python 2.7, 3.2 以降 - で利用できます。 3.3 以前の" -"バージョンでは、オーナーを変更するのに :func:`os.chown` を利用する必要がある" -"でしょう。" +"この例で Python 3.3 を使っているのは、:func:`shutil.chown` が追加されたバー" +"ジョンだからです。\n" +"この方法は :func:`dictConfig` をサポートする Python 2.7、3.2 以降で使えま" +"す。\n" +"3.3 より前では、例えば :func:`os.chown` を使って所有者の変更処理を実装する必" +"要があります。" #: ../../howto/logging-cookbook.rst:2692 msgid "" @@ -3840,17 +5154,15 @@ msgstr "" "実際には、handler を生成する関数はプロジェクト内のどこかにあるユーティリティ" "モジュールに置くことになるでしょう。設定の中で直接関数を参照する代わりに::" -#: ../../howto/logging-cookbook.rst:2695 msgid "'()': owned_file_handler," -msgstr "" +msgstr "'()': owned_file_handler," #: ../../howto/logging-cookbook.rst:2697 msgid "you could use e.g.::" msgstr "次のように書くこともできます::" -#: ../../howto/logging-cookbook.rst:2699 msgid "'()': 'ext://project.util.owned_file_handler'," -msgstr "" +msgstr "'()': 'ext://project.util.owned_file_handler'," #: ../../howto/logging-cookbook.rst:2701 msgid "" @@ -4033,7 +5345,6 @@ msgstr "" "このアプローチによる例をお見せします。最初は :meth:`str.format` を使って" "フォーマットする例です::" -#: ../../howto/logging-cookbook.rst:2808 msgid "" ">>> __ = BraceMessage\n" ">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" @@ -4047,18 +5358,32 @@ msgid "" "point=p))\n" "Message with coordinates: (0.50, 0.50)" msgstr "" +">>> __ = BraceMessage\n" +">>> print(__('Message with {0} {1}', 2, 'placeholders'))\n" +"Message with 2 placeholders\n" +">>> class Point: pass\n" +"...\n" +">>> p = Point()\n" +">>> p.x = 0.5\n" +">>> p.y = 0.5\n" +">>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})', " +"point=p))\n" +"Message with coordinates: (0.50, 0.50)" #: ../../howto/logging-cookbook.rst:2819 msgid "Secondly, formatting with :class:`string.Template`::" msgstr "2つめは :class:`string.Template` でフォーマットする例です::" -#: ../../howto/logging-cookbook.rst:2821 msgid "" ">>> __ = DollarMessage\n" ">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" "Message with 2 placeholders\n" ">>>" msgstr "" +">>> __ = DollarMessage\n" +">>> print(__('Message with $num $what', num=2, what='placeholders'))\n" +"Message with 2 placeholders\n" +">>>" #: ../../howto/logging-cookbook.rst:2826 msgid "" @@ -4083,7 +5408,6 @@ msgstr "" msgid "Configuring filters with :func:`dictConfig`" msgstr "filter を :func:`dictConfig` を使ってカスタマイズする" -#: ../../howto/logging-cookbook.rst:2842 msgid "" "You *can* configure filters using :func:`~logging.config.dictConfig`, though " "it might not be obvious at first glance how to do it (hence this recipe). " @@ -4097,18 +5421,19 @@ msgid "" "callable which returns a :class:`~logging.Filter` instance). Here is a " "complete example::" msgstr "" -":func:`~logging.config.dictConfig` によってフィルタを設定 *出来ます* が、どう" -"やってそれを行うのかが初見では明快とは言えないでしょう(そのためのこのレシピで" -"す)。 :class:`~logging.Filter` のみが唯一標準ライブラリに含まれているだけです" -"し、それは何の要求にも応えてはくれません(ただの基底クラスですから)ので、典型" -"的には :meth:`~logging.Filter.filter` メソッドをオーバライドした :class:" -"`~logging.Filter` のサブクラスをあなた自身で定義する必要があります。これをす" -"るには、設定辞書内のフィルタ指定部分に、 ``()`` キーでそのフィルタを作るのに" -"使われる callable を指定してください(クラスを指定するのが最もわかりやすいです" -"が、 :class:`~logging.Filter` インスタンスを返却する callable を提供すること" -"でも出来ます)。以下に完全な例を示します::" +":func:`~logging.config.dictConfig` でフィルタを設定 *できます*。\n" +"ただし、一見しただけでは方法が分かりにくいため、このレシピで説明します。\n" +"標準ライブラリに含まれるフィルタクラスは :class:`~logging.Filter` だけで、基" +"底クラスとして用意されているため、多くの要件にはそのまま対応できないでしょ" +"う。\n" +"通常は :class:`~logging.Filter` のサブクラスを定義し、:meth:`~logging.Filter." +"filter` をオーバーライドします。\n" +"設定辞書のフィルタの項目では ``()`` キーに、フィルタを作成する呼び出し可能オ" +"ブジェクトを指定します。\n" +"クラスを指定するのが分かりやすい方法ですが、:class:`~logging.Filter` インスタ" +"ンスを返すものであれば指定できます。\n" +"完全な例を示します。 ::" -#: ../../howto/logging-cookbook.rst:2853 msgid "" "import logging\n" "import logging.config\n" @@ -4152,20 +5477,59 @@ msgid "" " logging.debug('hello')\n" " logging.debug('hello - noshow')" msgstr "" - -#: ../../howto/logging-cookbook.rst:2895 -msgid "" -"This example shows how you can pass configuration data to the callable which " +"import logging\n" +"import logging.config\n" +"import sys\n" +"\n" +"class MyFilter(logging.Filter):\n" +" def __init__(self, param=None):\n" +" self.param = param\n" +"\n" +" def filter(self, record):\n" +" if self.param is None:\n" +" allow = True\n" +" else:\n" +" allow = self.param not in record.msg\n" +" if allow:\n" +" record.msg = 'changed: ' + record.msg\n" +" return allow\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'filters': {\n" +" 'myfilter': {\n" +" '()': MyFilter,\n" +" 'param': 'noshow',\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'filters': ['myfilter']\n" +" }\n" +" },\n" +" 'root': {\n" +" 'level': 'DEBUG',\n" +" 'handlers': ['console']\n" +" },\n" +"}\n" +"\n" +"if __name__ == '__main__':\n" +" logging.config.dictConfig(LOGGING)\n" +" logging.debug('hello')\n" +" logging.debug('hello - noshow')" + +msgid "" +"This example shows how you can pass configuration data to the callable which " "constructs the instance, in the form of keyword parameters. When run, the " "above script will print:" msgstr "" -"どのようにして設定データとして、そのインスタンスを構築する callable をキー" -"ワードパラメータの形で渡すのか、をこの例は教えてくれます。上記スクリプトは実" -"行すると、このような出力をします:" +"この例は、インスタンスを構築する呼び出し可能オブジェクトに、設定データをキー" +"ワード引数として渡す方法を示しています。\n" +"上のスクリプトを実行すると、次のように表示されます:" -#: ../../howto/logging-cookbook.rst:2899 msgid "changed: hello" -msgstr "" +msgstr "changed: hello" #: ../../howto/logging-cookbook.rst:2903 msgid "which shows that the filter is working as configured." @@ -4219,7 +5583,6 @@ msgstr "" "外情報がある場合でもログイベントごとに一行に収まることを死守したいと望むとし" "ましょう。フォーマッタのクラスをカスタマイズして、このように出来ます::" -#: ../../howto/logging-cookbook.rst:2930 msgid "" "import logging\n" "\n" @@ -4257,18 +5620,56 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"import logging\n" +"\n" +"class OneLineExceptionFormatter(logging.Formatter):\n" +" def formatException(self, exc_info):\n" +" \"\"\"\n" +" Format an exception so that it prints on a single line.\n" +" \"\"\"\n" +" result = super().formatException(exc_info)\n" +" return repr(result) # or format into one line however you want to\n" +"\n" +" def format(self, record):\n" +" s = super().format(record)\n" +" if record.exc_text:\n" +" s = s.replace('\\n', '') + '|'\n" +" return s\n" +"\n" +"def configure_logging():\n" +" fh = logging.FileHandler('output.txt', 'w')\n" +" f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',\n" +" '%d/%m/%Y %H:%M:%S')\n" +" fh.setFormatter(f)\n" +" root = logging.getLogger()\n" +" root.setLevel(logging.DEBUG)\n" +" root.addHandler(fh)\n" +"\n" +"def main():\n" +" configure_logging()\n" +" logging.info('Sample message')\n" +" try:\n" +" x = 1 / 0\n" +" except ZeroDivisionError as e:\n" +" logging.exception('ZeroDivisionError: %s', e)\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../howto/logging-cookbook.rst:2966 msgid "When run, this produces a file with exactly two lines:" msgstr "実行してみましょう。このように正確に2行の出力を生成します:" -#: ../../howto/logging-cookbook.rst:2968 msgid "" "28/01/2015 07:21:23|INFO|Sample message|\n" "28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback " "(most recent call last):\\n File \"logtest7.py\", line 30, in main\\n x " "= 1 / 0\\nZeroDivisionError: division by zero'|" msgstr "" +"28/01/2015 07:21:23|INFO|Sample message|\n" +"28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback " +"(most recent call last):\\n File \"logtest7.py\", line 30, in main\\n x " +"= 1 / 0\\nZeroDivisionError: division by zero'|" #: ../../howto/logging-cookbook.rst:2973 msgid "" @@ -4284,7 +5685,6 @@ msgstr "" msgid "Speaking logging messages" msgstr "ロギングメッセージを喋る" -#: ../../howto/logging-cookbook.rst:2982 msgid "" "There might be situations when it is desirable to have logging messages " "rendered in an audible rather than a visible format. This is easy to do if " @@ -4300,20 +5700,19 @@ msgid "" "other handlers to be kept waiting. Here is a short example showing the " "approach, which assumes that the ``espeak`` TTS package is available::" msgstr "" -"ロギングメッセージを目で見る形式ではなく音で聴く形式として出力したい、という" -"状況があるかもしれません。これはあなたのシステムで text- to-speech (TTS) 機能" -"が利用可能であれば、容易です。それが Python バインディングを持っていなくと" -"も、です。ほとんどの TTS システムはあなたが実行出来るコマンドラインプログラム" -"を持っていて、このことで、 :mod:`subprocess` を使うことでハンドラが呼び出せま" -"す。ここでは、TTS コマンドラインプログラムはユーザとの対話を期待せず、完了に" -"は時間がかかり、そしてログメッセージの頻度はユーザをメッセージで圧倒してしま" -"うほどには高くはなく、そして並列で喋るよりはメッセージ一つにつき一回喋ること" -"が受け容れられる、としておきます。ここでお見せする実装例では、次が処理される" -"前に一つのメッセージを喋り終わるまで待ち、結果としてほかのハンドラを待たせる" -"ことになります。 ``espeak`` TTS パッケージが手許にあるとして、このアプローチ" -"による短い例はこのようなものです::" - -#: ../../howto/logging-cookbook.rst:2995 +"ログメッセージを画面ではなく音声で出力したい場合もあります。\n" +"システムで音声合成 (TTS) が使えれば、Python バインディングがなくても簡単に実" +"現できます。\n" +"多くの TTS システムにはコマンドラインプログラムがあり、ハンドラから :mod:" +"`subprocess` で呼び出せます。\n" +"ここでは、TTS プログラムがユーザーとの対話を必要とせず、完了に長い時間がかか" +"らないことを前提とします。\n" +"また、ログの頻度がユーザーを圧倒するほど高くなく、メッセージを同時にではなく" +"一つずつ読み上げてもよいものとします。\n" +"次の実装例は、一つのメッセージを読み上げ終わるまで次を処理しないため、他のハ" +"ンドラを待たせる可能性があります。\n" +"``espeak`` TTS パッケージが利用できる場合の短い例を示します。 ::" + msgid "" "import logging\n" "import subprocess\n" @@ -4344,6 +5743,34 @@ msgid "" " configure_logging()\n" " sys.exit(main())" msgstr "" +"import logging\n" +"import subprocess\n" +"import sys\n" +"\n" +"class TTSHandler(logging.Handler):\n" +" def emit(self, record):\n" +" msg = self.format(record)\n" +" # 英語の女性の声でゆっくり話す\n" +" cmd = ['espeak', '-s150', '-ven+f3', msg]\n" +" p = subprocess.Popen(cmd, stdout=subprocess.PIPE,\n" +" stderr=subprocess.STDOUT)\n" +" # プログラムの終了を待つ\n" +" p.communicate()\n" +"\n" +"def configure_logging():\n" +" h = TTSHandler()\n" +" root = logging.getLogger()\n" +" root.addHandler(h)\n" +" # デフォルトのフォーマッターはメッセージをそのまま返す\n" +" root.setLevel(logging.DEBUG)\n" +"\n" +"def main():\n" +" logging.info('Hello')\n" +" logging.debug('Goodbye')\n" +"\n" +"if __name__ == '__main__':\n" +" configure_logging()\n" +" sys.exit(main())" #: ../../howto/logging-cookbook.rst:3024 msgid "" @@ -4365,7 +5792,6 @@ msgstr "" msgid "Buffering logging messages and outputting them conditionally" msgstr "ロギングメッセージをバッファリングし、条件に従って出力する" -#: ../../howto/logging-cookbook.rst:3036 msgid "" "There might be situations where you want to log messages in a temporary area " "and only output them if a certain condition occurs. For example, you may " @@ -4374,11 +5800,12 @@ msgid "" "collected debug information, but if there is an error, you want all the " "debug information to be output as well as the error." msgstr "" -"メッセージを一次領域に記録し、ある種の特定の状況になった場合にだけ出力した" -"い、ということがあるかもしれません。たとえばある関数内でのデバッグのためのロ" -"グ出力をしたくても、エラーなしで終了する限りにおいては収集されたデバッグ情報" -"による混雑は喰らいたくはなく、エラーがあった場合にだけエラー出力とともにデ" -"バッグ情報を見たいのだ、のようなことがあるでしょう。" +"ログメッセージを一時的な領域に記録し、特定の条件が成立した場合にだけ出力した" +"いことがあります。\n" +"例えば、関数内でデバッグイベントの記録を開始し、エラーなく終了した場合は、収" +"集した情報でログを埋めたくないとします。\n" +"一方、エラーが起きた場合は、エラーとともにデバッグ情報をすべて出力したいとし" +"ます。" #: ../../howto/logging-cookbook.rst:3043 msgid "" @@ -4401,7 +5828,6 @@ msgstr "" "ラッシュされます。何か特別なフラッシュの振る舞いをしたければ、このレシピはさ" "らに特殊化した ``MemoryHandler`` とともに利用出来ます。" -#: ../../howto/logging-cookbook.rst:3053 msgid "" "The example script has a simple function, ``foo``, which just cycles through " "all the logging levels, writing to ``sys.stderr`` to say what level it's " @@ -4409,10 +5835,11 @@ msgid "" "pass a parameter to ``foo`` which, if true, will log at ERROR and CRITICAL " "levels - otherwise, it only logs at DEBUG, INFO and WARNING levels." msgstr "" -"スクリプト例では、 ``foo`` という、単に全てのログレベルについて、 ``sys." -"stderr`` にもどのレベルを出力したのかについて書き出しながら実際のログ出力も行" -"う、という単純な関数を使っています。 ``foo`` に真を与えると ERROR と " -"CRITICAL の出力をし、そうでなければ DEBUG, INFO, WARNING だけを出力します。" +"スクリプトの例には、ログレベルを順にたどる単純な関数 ``foo`` があります。\n" +"これから記録するレベルを ``sys.stderr`` に表示してから、そのレベルで実際にロ" +"グを記録します。\n" +"``foo`` の引数に真を渡すと ERROR と CRITICAL のレベルでも記録し、それ以外で" +"は DEBUG、INFO、WARNING だけを記録します。" #: ../../howto/logging-cookbook.rst:3059 msgid "" @@ -4437,7 +5864,6 @@ msgstr "" msgid "Here's the script::" msgstr "スクリプトはこれです::" -#: ../../howto/logging-cookbook.rst:3069 msgid "" "import logging\n" "from logging.handlers import MemoryHandler\n" @@ -4502,12 +5928,73 @@ msgid "" " write_line('Calling decorated foo with True')\n" " assert decorated_foo(True)" msgstr "" +"import logging\n" +"from logging.handlers import MemoryHandler\n" +"import sys\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"logger.addHandler(logging.NullHandler())\n" +"\n" +"def log_if_errors(logger, target_handler=None, flush_level=None, " +"capacity=None):\n" +" if target_handler is None:\n" +" target_handler = logging.StreamHandler()\n" +" if flush_level is None:\n" +" flush_level = logging.ERROR\n" +" if capacity is None:\n" +" capacity = 100\n" +" handler = MemoryHandler(capacity, flushLevel=flush_level, " +"target=target_handler)\n" +"\n" +" def decorator(fn):\n" +" def wrapper(*args, **kwargs):\n" +" logger.addHandler(handler)\n" +" try:\n" +" return fn(*args, **kwargs)\n" +" except Exception:\n" +" logger.exception('call failed')\n" +" raise\n" +" finally:\n" +" super(MemoryHandler, handler).flush()\n" +" logger.removeHandler(handler)\n" +" return wrapper\n" +"\n" +" return decorator\n" +"\n" +"def write_line(s):\n" +" sys.stderr.write('%s\\n' % s)\n" +"\n" +"def foo(fail=False):\n" +" write_line('about to log at DEBUG ...')\n" +" logger.debug('Actually logged at DEBUG')\n" +" write_line('about to log at INFO ...')\n" +" logger.info('Actually logged at INFO')\n" +" write_line('about to log at WARNING ...')\n" +" logger.warning('Actually logged at WARNING')\n" +" if fail:\n" +" write_line('about to log at ERROR ...')\n" +" logger.error('Actually logged at ERROR')\n" +" write_line('about to log at CRITICAL ...')\n" +" logger.critical('Actually logged at CRITICAL')\n" +" return fail\n" +"\n" +"decorated_foo = log_if_errors(logger)(foo)\n" +"\n" +"if __name__ == '__main__':\n" +" logger.setLevel(logging.DEBUG)\n" +" write_line('Calling undecorated foo with False')\n" +" assert not foo(False)\n" +" write_line('Calling undecorated foo with True')\n" +" assert foo(True)\n" +" write_line('Calling decorated foo with False')\n" +" assert not decorated_foo(False)\n" +" write_line('Calling decorated foo with True')\n" +" assert decorated_foo(True)" #: ../../howto/logging-cookbook.rst:3130 msgid "When this script is run, the following output should be observed:" msgstr "実行すればこのような出力になるはずです:" -#: ../../howto/logging-cookbook.rst:3132 msgid "" "Calling undecorated foo with False\n" "about to log at DEBUG ...\n" @@ -4535,6 +6022,31 @@ msgid "" "about to log at CRITICAL ...\n" "Actually logged at CRITICAL" msgstr "" +"Calling undecorated foo with False\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"Calling undecorated foo with True\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"about to log at ERROR ...\n" +"about to log at CRITICAL ...\n" +"Calling decorated foo with False\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"Calling decorated foo with True\n" +"about to log at DEBUG ...\n" +"about to log at INFO ...\n" +"about to log at WARNING ...\n" +"about to log at ERROR ...\n" +"Actually logged at DEBUG\n" +"Actually logged at INFO\n" +"Actually logged at WARNING\n" +"Actually logged at ERROR\n" +"about to log at CRITICAL ...\n" +"Actually logged at CRITICAL" #: ../../howto/logging-cookbook.rst:3160 msgid "" @@ -4550,12 +6062,14 @@ msgstr "" msgid "You can of course use the conventional means of decoration::" msgstr "当然のことですが、デコレーションはいつものやり方でどうぞ::" -#: ../../howto/logging-cookbook.rst:3166 msgid "" "@log_if_errors(logger)\n" "def foo(fail=False):\n" " ..." msgstr "" +"@log_if_errors(logger)\n" +"def foo(fail=False):\n" +" ..." #: ../../howto/logging-cookbook.rst:3174 msgid "Sending logging messages to email, with buffering" @@ -4579,7 +6093,6 @@ msgstr "" "見るためには、ダウンロードしたスクリプトを ``-h`` 引数をつけて実行してくださ" "い)。" -#: ../../howto/logging-cookbook.rst:3184 msgid "" "import logging\n" "import logging.handlers\n" @@ -4646,64 +6159,131 @@ msgid "" " h.flush()\n" " h.close()" msgstr "" - -#: ../../howto/logging-cookbook.rst:3248 -msgid "" -"If you run this script and your SMTP server is correctly set up, you should " -"find that it sends eleven emails to the addressee you specify. The first ten " -"emails will each have ten log messages, and the eleventh will have two " -"messages. That makes up 102 messages as specified in the script." -msgstr "" -"SMTP サーバーを正しく設定した上でスクリプトを実行すると、指定したアドレス宛て" -"に11通のメールを受け取るでしょう。最初の10通のメールはそれぞれ10個のログメッ" -"セージを含み、11通目のメールは2つのログメッセージを含むはずです。これらのログ" -"メッセージはスクリプト内で指定された102個のログメッセージから構成されていま" -"す。" - -#: ../../howto/logging-cookbook.rst:3256 -msgid "Formatting times using UTC (GMT) via configuration" -msgstr "設定によって時刻を UTC(GMT) で書式化する" - -#: ../../howto/logging-cookbook.rst:3258 -msgid "" -"Sometimes you want to format times using UTC, which can be done using a " -"class such as ``UTCFormatter``, shown below::" -msgstr "" -"時刻を UTC でフォーマットしたい場合もあるでしょう。以下に示すように、そのよう" -"なフォーマット処理は ``UTCFormatter`` のようなクラスを使って行うことができま" -"す::" - -#: ../../howto/logging-cookbook.rst:3261 -msgid "" -"import logging\n" -"import time\n" -"\n" -"class UTCFormatter(logging.Formatter):\n" -" converter = time.gmtime" -msgstr "" - -#: ../../howto/logging-cookbook.rst:3267 -msgid "" -"and you can then use the ``UTCFormatter`` in your code instead of :class:" -"`~logging.Formatter`. If you want to do that via configuration, you can use " -"the :func:`~logging.config.dictConfig` API with an approach illustrated by " -"the following complete example::" -msgstr "" -"そしてコード中で ``UTCFormatter`` を :class:`~logging.Formatter` の代わりに使" -"えます。これを設定を通して行いたい場合、 :func:`~logging.config.dictConfig` " -"API を以下の完全な例で示すようなアプローチで使うことが出来ます::" - -#: ../../howto/logging-cookbook.rst:3272 -msgid "" "import logging\n" -"import logging.config\n" -"import time\n" -"\n" -"class UTCFormatter(logging.Formatter):\n" -" converter = time.gmtime\n" +"import logging.handlers\n" +"import smtplib\n" "\n" -"LOGGING = {\n" -" 'version': 1,\n" +"class BufferingSMTPHandler(logging.handlers.BufferingHandler):\n" +" def __init__(self, mailhost, port, username, password, fromaddr, " +"toaddrs,\n" +" subject, capacity):\n" +" logging.handlers.BufferingHandler.__init__(self, capacity)\n" +" self.mailhost = mailhost\n" +" self.mailport = port\n" +" self.username = username\n" +" self.password = password\n" +" self.fromaddr = fromaddr\n" +" if isinstance(toaddrs, str):\n" +" toaddrs = [toaddrs]\n" +" self.toaddrs = toaddrs\n" +" self.subject = subject\n" +" self.setFormatter(logging.Formatter(\"%(asctime)s %(levelname)-5s " +"%(message)s\"))\n" +"\n" +" def flush(self):\n" +" if len(self.buffer) > 0:\n" +" try:\n" +" smtp = smtplib.SMTP(self.mailhost, self.mailport)\n" +" smtp.starttls()\n" +" smtp.login(self.username, self.password)\n" +" msg = \"From: %s\\r\\nTo: %s\\r\\nSubject: %s\\r\\n\\r\\n\" " +"% (self.fromaddr, ','.join(self.toaddrs), self.subject)\n" +" for record in self.buffer:\n" +" s = self.format(record)\n" +" msg = msg + s + \"\\r\\n\"\n" +" smtp.sendmail(self.fromaddr, self.toaddrs, msg)\n" +" smtp.quit()\n" +" except Exception:\n" +" if logging.raiseExceptions:\n" +" raise\n" +" self.buffer = []\n" +"\n" +"if __name__ == '__main__':\n" +" import argparse\n" +"\n" +" ap = argparse.ArgumentParser()\n" +" aa = ap.add_argument\n" +" aa('host', metavar='HOST', help='SMTP server')\n" +" aa('--port', '-p', type=int, default=587, help='SMTP port')\n" +" aa('user', metavar='USER', help='SMTP username')\n" +" aa('password', metavar='PASSWORD', help='SMTP password')\n" +" aa('to', metavar='TO', help='Addressee for emails')\n" +" aa('sender', metavar='SENDER', help='Sender email address')\n" +" aa('--subject', '-s',\n" +" default='Test Logging email from Python logging module (buffering)',\n" +" help='Subject of email')\n" +" options = ap.parse_args()\n" +" logger = logging.getLogger()\n" +" logger.setLevel(logging.DEBUG)\n" +" h = BufferingSMTPHandler(options.host, options.port, options.user,\n" +" options.password, options.sender,\n" +" options.to, options.subject, 10)\n" +" logger.addHandler(h)\n" +" for i in range(102):\n" +" logger.info(\"Info index = %d\", i)\n" +" h.flush()\n" +" h.close()" + +#: ../../howto/logging-cookbook.rst:3248 +msgid "" +"If you run this script and your SMTP server is correctly set up, you should " +"find that it sends eleven emails to the addressee you specify. The first ten " +"emails will each have ten log messages, and the eleventh will have two " +"messages. That makes up 102 messages as specified in the script." +msgstr "" +"SMTP サーバーを正しく設定した上でスクリプトを実行すると、指定したアドレス宛て" +"に11通のメールを受け取るでしょう。最初の10通のメールはそれぞれ10個のログメッ" +"セージを含み、11通目のメールは2つのログメッセージを含むはずです。これらのログ" +"メッセージはスクリプト内で指定された102個のログメッセージから構成されていま" +"す。" + +#: ../../howto/logging-cookbook.rst:3256 +msgid "Formatting times using UTC (GMT) via configuration" +msgstr "設定によって時刻を UTC(GMT) で書式化する" + +#: ../../howto/logging-cookbook.rst:3258 +msgid "" +"Sometimes you want to format times using UTC, which can be done using a " +"class such as ``UTCFormatter``, shown below::" +msgstr "" +"時刻を UTC でフォーマットしたい場合もあるでしょう。以下に示すように、そのよう" +"なフォーマット処理は ``UTCFormatter`` のようなクラスを使って行うことができま" +"す::" + +msgid "" +"import logging\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime" +msgstr "" +"import logging\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime" + +#: ../../howto/logging-cookbook.rst:3267 +msgid "" +"and you can then use the ``UTCFormatter`` in your code instead of :class:" +"`~logging.Formatter`. If you want to do that via configuration, you can use " +"the :func:`~logging.config.dictConfig` API with an approach illustrated by " +"the following complete example::" +msgstr "" +"そしてコード中で ``UTCFormatter`` を :class:`~logging.Formatter` の代わりに使" +"えます。これを設定を通して行いたい場合、 :func:`~logging.config.dictConfig` " +"API を以下の完全な例で示すようなアプローチで使うことが出来ます::" + +msgid "" +"import logging\n" +"import logging.config\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" " 'disable_existing_loggers': False,\n" " 'formatters': {\n" " 'utc': {\n" @@ -4733,16 +6313,54 @@ msgid "" " logging.config.dictConfig(LOGGING)\n" " logging.warning('The local time is %s', time.asctime())" msgstr "" +"import logging\n" +"import logging.config\n" +"import time\n" +"\n" +"class UTCFormatter(logging.Formatter):\n" +" converter = time.gmtime\n" +"\n" +"LOGGING = {\n" +" 'version': 1,\n" +" 'disable_existing_loggers': False,\n" +" 'formatters': {\n" +" 'utc': {\n" +" '()': UTCFormatter,\n" +" 'format': '%(asctime)s %(message)s',\n" +" },\n" +" 'local': {\n" +" 'format': '%(asctime)s %(message)s',\n" +" }\n" +" },\n" +" 'handlers': {\n" +" 'console1': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'utc',\n" +" },\n" +" 'console2': {\n" +" 'class': 'logging.StreamHandler',\n" +" 'formatter': 'local',\n" +" },\n" +" },\n" +" 'root': {\n" +" 'handlers': ['console1', 'console2'],\n" +" }\n" +"}\n" +"\n" +"if __name__ == '__main__':\n" +" logging.config.dictConfig(LOGGING)\n" +" logging.warning('The local time is %s', time.asctime())" #: ../../howto/logging-cookbook.rst:3310 msgid "When this script is run, it should print something like:" msgstr "実行すれば、このような出力になるはずです:" -#: ../../howto/logging-cookbook.rst:3312 msgid "" "2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" "2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" msgstr "" +"2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015\n" +"2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015" #: ../../howto/logging-cookbook.rst:3317 msgid "" @@ -4756,7 +6374,6 @@ msgstr "" msgid "Using a context manager for selective logging" msgstr "ロギングの選択にコンテキストマネージャを使う" -#: ../../howto/logging-cookbook.rst:3326 msgid "" "There are times when it would be useful to temporarily change the logging " "configuration and revert it back after doing something. For this, a context " @@ -4765,15 +6382,12 @@ msgid "" "optionally change the logging level and add a logging handler purely in the " "scope of the context manager::" msgstr "" -"一時的にロギングの設定を変えて、作業をした後に設定を戻せると便利なときがあり" -"ます。\n" -"こういうときの、ロギングコンテキストの保存と復元をする方法ではコンテキストマ" -"ネージャを使うのが一番です。\n" -"以下にあるのがそのためのコンテキストマネージャの簡単な例で、これを使うと、任" -"意にロギングレベルを変更し、コンテキストマネージャのスコープ内で他に影響を及" -"ぼさずロギングハンドラを追加できるようになります::" +"ロギングの設定を一時的に変更し、処理後に元に戻せると便利な場合があります。\n" +"設定を保存・復元するにはコンテキストマネージャが分かりやすい方法です。\n" +"次の簡単な例では、必要に応じてロギングレベルを変更したり、ハンドラを追加した" +"りできます。\n" +"変更はコンテキストマネージャの有効期間だけ適用されます。 ::" -#: ../../howto/logging-cookbook.rst:3333 msgid "" "import logging\n" "import sys\n" @@ -4801,6 +6415,31 @@ msgid "" " self.handler.close()\n" " # implicit return of None => don't swallow exceptions" msgstr "" +"import logging\n" +"import sys\n" +"\n" +"class LoggingContext:\n" +" def __init__(self, logger, level=None, handler=None, close=True):\n" +" self.logger = logger\n" +" self.level = level\n" +" self.handler = handler\n" +" self.close = close\n" +"\n" +" def __enter__(self):\n" +" if self.level is not None:\n" +" self.old_level = self.logger.level\n" +" self.logger.setLevel(self.level)\n" +" if self.handler:\n" +" self.logger.addHandler(self.handler)\n" +"\n" +" def __exit__(self, et, ev, tb):\n" +" if self.level is not None:\n" +" self.logger.setLevel(self.old_level)\n" +" if self.handler:\n" +" self.logger.removeHandler(self.handler)\n" +" if self.handler and self.close:\n" +" self.handler.close()\n" +" # 暗黙に None を返すので、例外を握りつぶさない" #: ../../howto/logging-cookbook.rst:3359 msgid "" @@ -4826,7 +6465,6 @@ msgstr "" "どのように動作するのかを示すためには、次のコード群を上のコードに付け加えると" "よいです::" -#: ../../howto/logging-cookbook.rst:3368 msgid "" "if __name__ == '__main__':\n" " logger = logging.getLogger('foo')\n" @@ -4845,6 +6483,22 @@ msgid "" " logger.info('6. This should appear just once on stderr.')\n" " logger.debug('7. This should not appear.')" msgstr "" +"if __name__ == '__main__':\n" +" logger = logging.getLogger('foo')\n" +" logger.addHandler(logging.StreamHandler())\n" +" logger.setLevel(logging.INFO)\n" +" logger.info('1. This should appear just once on stderr.')\n" +" logger.debug('2. This should not appear.')\n" +" with LoggingContext(logger, level=logging.DEBUG):\n" +" logger.debug('3. This should appear once on stderr.')\n" +" logger.debug('4. This should not appear.')\n" +" h = logging.StreamHandler(sys.stdout)\n" +" with LoggingContext(logger, level=logging.DEBUG, handler=h, " +"close=True):\n" +" logger.debug('5. This should appear twice - once on stderr and once " +"on stdout.')\n" +" logger.info('6. This should appear just once on stderr.')\n" +" logger.debug('7. This should not appear.')" #: ../../howto/logging-cookbook.rst:3383 msgid "" @@ -4875,7 +6529,6 @@ msgstr "" msgid "If we run the resulting script, the result is as follows:" msgstr "出来上がったスクリプトを実行すると、結果は次のようになります::" -#: ../../howto/logging-cookbook.rst:3395 msgid "" "$ python logctx.py\n" "1. This should appear just once on stderr.\n" @@ -4884,6 +6537,12 @@ msgid "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." msgstr "" +"$ python logctx.py\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"6. This should appear just once on stderr." #: ../../howto/logging-cookbook.rst:3404 msgid "" @@ -4893,11 +6552,12 @@ msgstr "" "``stderr`` を ``/dev/null`` へパイプした状態でもう一度実行すると、次のように" "なり、これは ``stdout`` の方に書かれたメッセージだけが現れています:" -#: ../../howto/logging-cookbook.rst:3407 msgid "" "$ python logctx.py 2>/dev/null\n" "5. This should appear twice - once on stderr and once on stdout." msgstr "" +"$ python logctx.py 2>/dev/null\n" +"5. This should appear twice - once on stderr and once on stdout." #: ../../howto/logging-cookbook.rst:3412 msgid "Once again, but piping ``stdout`` to ``/dev/null``, we get:" @@ -4905,7 +6565,6 @@ msgstr "" "``stdout`` を ``/dev/null`` へパイプした状態でさらにもう一度実行すると、こう" "なります:" -#: ../../howto/logging-cookbook.rst:3414 msgid "" "$ python logctx.py >/dev/null\n" "1. This should appear just once on stderr.\n" @@ -4913,6 +6572,11 @@ msgid "" "5. This should appear twice - once on stderr and once on stdout.\n" "6. This should appear just once on stderr." msgstr "" +"$ python logctx.py >/dev/null\n" +"1. This should appear just once on stderr.\n" +"3. This should appear once on stderr.\n" +"5. This should appear twice - once on stderr and once on stdout.\n" +"6. This should appear just once on stderr." #: ../../howto/logging-cookbook.rst:3422 msgid "" @@ -4973,7 +6637,6 @@ msgstr "" "ライン引数を使ってアプリケーションのログの冗長性を制御したいとします。 ``app." "py`` は次のコードのようになるでしょう::" -#: ../../howto/logging-cookbook.rst:3449 msgid "" "import argparse\n" "import importlib\n" @@ -5019,6 +6682,48 @@ msgid "" "if __name__ == '__main__':\n" " sys.exit(main())" msgstr "" +"import argparse\n" +"import importlib\n" +"import logging\n" +"import os\n" +"import sys\n" +"\n" +"def main(args=None):\n" +" scriptname = os.path.basename(__file__)\n" +" parser = argparse.ArgumentParser(scriptname)\n" +" levels = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')\n" +" parser.add_argument('--log-level', default='INFO', choices=levels)\n" +" subparsers = parser.add_subparsers(dest='command',\n" +" help='Available commands:')\n" +" start_cmd = subparsers.add_parser('start', help='Start a service')\n" +" start_cmd.add_argument('name', metavar='NAME',\n" +" help='Name of service to start')\n" +" stop_cmd = subparsers.add_parser('stop',\n" +" help='Stop one or more services')\n" +" stop_cmd.add_argument('names', metavar='NAME', nargs='+',\n" +" help='Name of service to stop')\n" +" restart_cmd = subparsers.add_parser('restart',\n" +" help='Restart one or more " +"services')\n" +" restart_cmd.add_argument('names', metavar='NAME', nargs='+',\n" +" help='Name of service to restart')\n" +" options = parser.parse_args()\n" +" # コマンドを振り分けるコードをすべてこのファイルに置くこともできるが、\n" +" # ここでは説明のため、各コマンドを別のモジュールに実装する。\n" +" try:\n" +" mod = importlib.import_module(options.command)\n" +" cmd = getattr(mod, 'command')\n" +" except (ImportError, AttributeError):\n" +" print('Unable to find the code for command \\'%s\\'' % options." +"command)\n" +" return 1\n" +" # ここを工夫して、ファイルや辞書から設定を読み込んでもよい\n" +" logging.basicConfig(level=options.log_level,\n" +" format='%(levelname)s %(name)s %(message)s')\n" +" cmd(options)\n" +"\n" +"if __name__ == '__main__':\n" +" sys.exit(main())" #: ../../howto/logging-cookbook.rst:3490 msgid "" @@ -5028,7 +6733,6 @@ msgstr "" "``start`` 、 ``stop`` 、 ``restart`` コマンドは個別のモジュールとして実装され" "ます。次は起動コマンドのソースです::" -#: ../../howto/logging-cookbook.rst:3493 msgid "" "# start.py\n" "import logging\n" @@ -5040,12 +6744,20 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Started the \\'%s\\' service.', options.name)" msgstr "" +"# start.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" logger.debug('About to start %s', options.name)\n" +" # ここで実際のコマンド処理を行う ...\n" +" logger.info('Started the \\'%s\\' service.', options.name)" + +#: ../../howto/logging-cookbook.rst:3503 +msgid "and thus for stopping::" +msgstr "停止コマンドのソースは次の通りです::" -#: ../../howto/logging-cookbook.rst:3503 -msgid "and thus for stopping::" -msgstr "停止コマンドのソースは次の通りです::" - -#: ../../howto/logging-cookbook.rst:3505 msgid "" "# stop.py\n" "import logging\n" @@ -5066,12 +6778,29 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Stopped the %s service%s.', services, plural)" msgstr "" +"# stop.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to stop %s', services)\n" +" # ここで実際のコマンド処理を行う ...\n" +" logger.info('Stopped the %s service%s.', services, plural)" #: ../../howto/logging-cookbook.rst:3524 msgid "and similarly for restarting::" msgstr "同様に、再起動のコマンドは次の通りです::" -#: ../../howto/logging-cookbook.rst:3526 msgid "" "# restart.py\n" "import logging\n" @@ -5092,6 +6821,24 @@ msgid "" " # actually do the command processing here ...\n" " logger.info('Restarted the %s service%s.', services, plural)" msgstr "" +"# restart.py\n" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"def command(options):\n" +" n = len(options.names)\n" +" if n == 1:\n" +" plural = ''\n" +" services = '\\'%s\\'' % options.names[0]\n" +" else:\n" +" plural = 's'\n" +" services = ', '.join('\\'%s\\'' % name for name in options.names)\n" +" i = services.rfind(', ')\n" +" services = services[:i] + ' and ' + services[i + 2:]\n" +" logger.debug('About to restart %s', services)\n" +" # ここで実際のコマンド処理を行う ...\n" +" logger.info('Restarted the %s service%s.', services, plural)" #: ../../howto/logging-cookbook.rst:3545 msgid "" @@ -5101,7 +6848,6 @@ msgstr "" "このアプリケーションをデフォルトのログレベルで実行すると、次のような出力が得" "られます:" -#: ../../howto/logging-cookbook.rst:3547 msgid "" "$ python app.py start foo\n" "INFO start Started the 'foo' service.\n" @@ -5112,6 +6858,14 @@ msgid "" "$ python app.py restart foo bar baz\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" +"$ python app.py start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py stop foo bar\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py restart foo bar baz\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." #: ../../howto/logging-cookbook.rst:3558 msgid "" @@ -5129,7 +6883,6 @@ msgstr "" "ログレベルを変更し、ログに出力する情報を変更できるようにしましょう。もし、よ" "り詳細な情報が必要だとしましょう:" -#: ../../howto/logging-cookbook.rst:3564 msgid "" "$ python app.py --log-level DEBUG start foo\n" "DEBUG start About to start foo\n" @@ -5143,35 +6896,52 @@ msgid "" "DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" "INFO restart Restarted the 'foo', 'bar' and 'baz' services." msgstr "" +"$ python app.py --log-level DEBUG start foo\n" +"DEBUG start About to start foo\n" +"INFO start Started the 'foo' service.\n" +"\n" +"$ python app.py --log-level DEBUG stop foo bar\n" +"DEBUG stop About to stop 'foo' and 'bar'\n" +"INFO stop Stopped the 'foo' and 'bar' services.\n" +"\n" +"$ python app.py --log-level DEBUG restart foo bar baz\n" +"DEBUG restart About to restart 'foo', 'bar' and 'baz'\n" +"INFO restart Restarted the 'foo', 'bar' and 'baz' services." #: ../../howto/logging-cookbook.rst:3578 msgid "And if we want less:" msgstr "あるいは情報を減らしたい場合もあるでしょう:" -#: ../../howto/logging-cookbook.rst:3580 msgid "" "$ python app.py --log-level WARNING start foo\n" "$ python app.py --log-level WARNING stop foo bar\n" "$ python app.py --log-level WARNING restart foo bar baz" msgstr "" +"$ python app.py --log-level WARNING start foo\n" +"$ python app.py --log-level WARNING stop foo bar\n" +"$ python app.py --log-level WARNING restart foo bar baz" -#: ../../howto/logging-cookbook.rst:3586 msgid "" "In this case, the commands don't print anything to the console, since " "nothing at ``WARNING`` level or above is logged by them." -msgstr "この場合、コマンドはコンソールに何も出力しなくなります。" +msgstr "" +"この場合、コマンドは ``WARNING`` 以上のレベルのログを記録しないため、コンソー" +"ルには何も表示されません。" #: ../../howto/logging-cookbook.rst:3592 msgid "A Qt GUI for logging" msgstr "Qt GUIのログ出力" -#: ../../howto/logging-cookbook.rst:3594 msgid "" "A question that comes up from time to time is about how to log to a GUI " "application. The `Qt `_ framework is a popular cross-" "platform UI framework with Python bindings using :pypi:`PySide2` or :pypi:" "`PyQt5` libraries." msgstr "" +"GUI アプリケーションにログを表示する方法は、ときどき寄せられる質問です。\n" +"`Qt `_ は広く使われているクロスプラットフォームの UI フ" +"レームワークで、:pypi:`PySide2` や :pypi:`PyQt5` ライブラリによる Python バイ" +"ンディングがあります。" #: ../../howto/logging-cookbook.rst:3599 msgid "" @@ -5189,25 +6959,27 @@ msgstr "" "ンドのタスクを行うワーカースレッドからログ出力を行います(ここではランダムな" "期間にランダムなレベルでメッセージを出しています)。" -#: ../../howto/logging-cookbook.rst:3606 msgid "" "The worker thread is implemented using Qt's ``QThread`` class rather than " "the :mod:`threading` module, as there are circumstances where one has to use " "``QThread``, which offers better integration with other ``Qt`` components." msgstr "" -"ワーカースレッドは :mod:`threading` モジュールではなく、Qtの ``QThread`` クラ" -"スを使っています。これは他の ``Qt`` コンポーネントとうまく統合できるように、 " -"``QThread`` を使う必要があるからです。" +"ワーカースレッドは :mod:`threading` モジュールではなく Qt の ``QThread`` クラ" +"スで実装しています。\n" +"他の ``Qt`` コンポーネントとの連携に優れた ``QThread`` を使う必要がある場合も" +"あるためです。" -#: ../../howto/logging-cookbook.rst:3610 msgid "" "The code should work with recent releases of any of ``PySide6``, ``PyQt6``, " "``PySide2`` or ``PyQt5``. You should be able to adapt the approach to " "earlier versions of Qt. Please refer to the comments in the code snippet for " "more detailed information." msgstr "" +"このコードは ``PySide6``、``PyQt6``、``PySide2``、``PyQt5`` のいずれも最近の" +"リリースで動作するはずです。\n" +"以前の Qt に合わせて変更することもできるでしょう。\n" +"詳しくはコード内のコメントを参照してください。" -#: ../../howto/logging-cookbook.rst:3615 msgid "" "import logging\n" "import random\n" @@ -5283,28 +7055,262 @@ msgid "" "\n" "\n" "#\n" -"# Used to generate random levels for logging.\n" +"# Used to generate random levels for logging.\n" +"#\n" +"LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" +" logging.CRITICAL)\n" +"\n" +"#\n" +"# This worker class represents work that is done in a thread separate to " +"the\n" +"# main thread. The way the thread is kicked off to do work is via a button " +"press\n" +"# that connects to a slot in the worker.\n" +"#\n" +"# Because the default threadName value in the LogRecord isn't much use, we " +"add\n" +"# a qThreadName which contains the QThread name as computed above, and pass " +"that\n" +"# value in an \"extra\" dictionary which is used to update the LogRecord " +"with the\n" +"# QThread name.\n" +"#\n" +"# This example worker just outputs messages sequentially, interspersed with\n" +"# random delays of the order of a few seconds.\n" +"#\n" +"class Worker(QtCore.QObject):\n" +" @Slot()\n" +" def start(self):\n" +" extra = {'qThreadName': ctname() }\n" +" logger.debug('Started work', extra=extra)\n" +" i = 1\n" +" # Let the thread run until interrupted. This allows reasonably " +"clean\n" +" # thread termination.\n" +" while not QtCore.QThread.currentThread().isInterruptionRequested():\n" +" delay = 0.5 + random.random() * 2\n" +" time.sleep(delay)\n" +" try:\n" +" if random.random() < 0.1:\n" +" raise ValueError('Exception raised: %d' % i)\n" +" else:\n" +" level = random.choice(LEVELS)\n" +" logger.log(level, 'Message after delay of %3.1f: %d', " +"delay, i, extra=extra)\n" +" except ValueError as e:\n" +" logger.exception('Failed: %s', e, extra=extra)\n" +" i += 1\n" +"\n" +"#\n" +"# Implement a simple UI for this cookbook example. This contains:\n" +"#\n" +"# * A read-only text edit window which holds formatted log messages\n" +"# * A button to start work and log stuff in a separate thread\n" +"# * A button to log something from the main thread\n" +"# * A button to clear the log window\n" +"#\n" +"class Window(QtWidgets.QWidget):\n" +"\n" +" COLORS = {\n" +" logging.DEBUG: 'black',\n" +" logging.INFO: 'blue',\n" +" logging.WARNING: 'orange',\n" +" logging.ERROR: 'red',\n" +" logging.CRITICAL: 'purple',\n" +" }\n" +"\n" +" def __init__(self, app):\n" +" super().__init__()\n" +" self.app = app\n" +" self.textedit = te = QtWidgets.QPlainTextEdit(self)\n" +" # Set whatever the default monospace font is for the platform\n" +" f = QtGui.QFont('nosuchfont')\n" +" if hasattr(f, 'Monospace'):\n" +" f.setStyleHint(f.Monospace)\n" +" else:\n" +" f.setStyleHint(f.StyleHint.Monospace) # for Qt6\n" +" te.setFont(f)\n" +" te.setReadOnly(True)\n" +" PB = QtWidgets.QPushButton\n" +" self.work_button = PB('Start background work', self)\n" +" self.log_button = PB('Log a message at a random level', self)\n" +" self.clear_button = PB('Clear log window', self)\n" +" self.handler = h = QtHandler(self.update_status)\n" +" # Remember to use qThreadName rather than threadName in the format " +"string.\n" +" fs = '%(asctime)s %(qThreadName)-12s %(levelname)-8s %(message)s'\n" +" formatter = logging.Formatter(fs)\n" +" h.setFormatter(formatter)\n" +" logger.addHandler(h)\n" +" # Set up to terminate the QThread when we exit\n" +" app.aboutToQuit.connect(self.force_quit)\n" +"\n" +" # Lay out all the widgets\n" +" layout = QtWidgets.QVBoxLayout(self)\n" +" layout.addWidget(te)\n" +" layout.addWidget(self.work_button)\n" +" layout.addWidget(self.log_button)\n" +" layout.addWidget(self.clear_button)\n" +" self.setFixedSize(900, 400)\n" +"\n" +" # Connect the non-worker slots and signals\n" +" self.log_button.clicked.connect(self.manual_update)\n" +" self.clear_button.clicked.connect(self.clear_display)\n" +"\n" +" # Start a new worker thread and connect the slots for the worker\n" +" self.start_thread()\n" +" self.work_button.clicked.connect(self.worker.start)\n" +" # Once started, the button should be disabled\n" +" self.work_button.clicked.connect(lambda : self.work_button." +"setEnabled(False))\n" +"\n" +" def start_thread(self):\n" +" self.worker = Worker()\n" +" self.worker_thread = QtCore.QThread()\n" +" self.worker.setObjectName('Worker')\n" +" self.worker_thread.setObjectName('WorkerThread') # for qThreadName\n" +" self.worker.moveToThread(self.worker_thread)\n" +" # This will start an event loop in the worker thread\n" +" self.worker_thread.start()\n" +"\n" +" def kill_thread(self):\n" +" # Just tell the worker to stop, then tell it to quit and wait for " +"that\n" +" # to happen\n" +" self.worker_thread.requestInterruption()\n" +" if self.worker_thread.isRunning():\n" +" self.worker_thread.quit()\n" +" self.worker_thread.wait()\n" +" else:\n" +" print('worker has already exited.')\n" +"\n" +" def force_quit(self):\n" +" # For use when the window is closed\n" +" if self.worker_thread.isRunning():\n" +" self.kill_thread()\n" +"\n" +" # The functions below update the UI and run in the main thread because\n" +" # that's where the slots are set up\n" +"\n" +" @Slot(str, logging.LogRecord)\n" +" def update_status(self, status, record):\n" +" color = self.COLORS.get(record.levelno, 'black')\n" +" s = '
%s
' % (color, status)\n" +" self.textedit.appendHtml(s)\n" +"\n" +" @Slot()\n" +" def manual_update(self):\n" +" # This function uses the formatted message passed in, but also uses\n" +" # information from the record to format the message in an " +"appropriate\n" +" # color according to its severity (level).\n" +" level = random.choice(LEVELS)\n" +" extra = {'qThreadName': ctname() }\n" +" logger.log(level, 'Manually logged!', extra=extra)\n" +"\n" +" @Slot()\n" +" def clear_display(self):\n" +" self.textedit.clear()\n" +"\n" +"\n" +"def main():\n" +" QtCore.QThread.currentThread().setObjectName('MainThread')\n" +" logging.getLogger().setLevel(logging.DEBUG)\n" +" app = QtWidgets.QApplication(sys.argv)\n" +" example = Window(app)\n" +" example.show()\n" +" if hasattr(app, 'exec'):\n" +" rc = app.exec()\n" +" else:\n" +" rc = app.exec_()\n" +" sys.exit(rc)\n" +"\n" +"if __name__=='__main__':\n" +" main()" +msgstr "" +"import logging\n" +"import random\n" +"import sys\n" +"import time\n" +"\n" +"# Qt パッケージ間の細かな違いに対応する\n" +"try:\n" +" from PySide6 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.Signal\n" +" Slot = QtCore.Slot\n" +"except ImportError:\n" +" try:\n" +" from PyQt6 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.pyqtSignal\n" +" Slot = QtCore.pyqtSlot\n" +" except ImportError:\n" +" try:\n" +" from PySide2 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.Signal\n" +" Slot = QtCore.Slot\n" +" except ImportError:\n" +" from PyQt5 import QtCore, QtGui, QtWidgets\n" +" Signal = QtCore.pyqtSignal\n" +" Slot = QtCore.pyqtSlot\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"\n" +"#\n" +"# シグナルを正しく初期化するには、QObject またはそのサブクラスの中に\n" +"# 定義する必要がある。\n" +"#\n" +"class Signaller(QtCore.QObject):\n" +" signal = Signal(str, logging.LogRecord)\n" +"\n" +"#\n" +"# Qt GUI への出力はメインスレッドでのみ行う。\n" +"# そのため、このハンドラーはメインスレッドで実行するよう設定した\n" +"# スロット関数を受け取る設計になっている。この例の関数は、\n" +"# 書式化済みのログメッセージ文字列と、その生成元のログレコードを受け取る。\n" +"# 書式化済みの文字列は便宜上渡しているだけで、\n" +"# スロット関数の中で自由に出力文字列を書式化してもよい。\n" +"#\n" +"# 目的の GUI 更新を行うスロット関数を指定する。\n" +"# ハンドラーは具体的な UI 要素を知らず、意識する必要もない。\n" +"#\n" +"class QtHandler(logging.Handler):\n" +" def __init__(self, slotfunc, *args, **kwargs):\n" +" super().__init__(*args, **kwargs)\n" +" self.signaller = Signaller()\n" +" self.signaller.signal.connect(slotfunc)\n" +"\n" +" def emit(self, record):\n" +" s = self.format(record)\n" +" self.signaller.signal.emit(s, record)\n" +"\n" +"#\n" +"# この例は QThread を使うため、Python 側のスレッド名は\n" +"# \"Dummy-1\" のようになる。以下の関数は、\n" +"# 現在のスレッドの Qt 側の名前を取得する。\n" +"#\n" +"def ctname():\n" +" return QtCore.QThread.currentThread().objectName()\n" +"\n" +"\n" +"#\n" +"# ランダムなログレベルの生成に使う。\n" "#\n" "LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,\n" " logging.CRITICAL)\n" "\n" "#\n" -"# This worker class represents work that is done in a thread separate to " -"the\n" -"# main thread. The way the thread is kicked off to do work is via a button " -"press\n" -"# that connects to a slot in the worker.\n" +"# このワーカークラスは、メインスレッドとは別のスレッドで行う仕事を表す。\n" +"# ボタンを押すと、接続先のワーカーのスロットを介して\n" +"# スレッドに仕事を開始させる。\n" "#\n" -"# Because the default threadName value in the LogRecord isn't much use, we " -"add\n" -"# a qThreadName which contains the QThread name as computed above, and pass " -"that\n" -"# value in an \"extra\" dictionary which is used to update the LogRecord " -"with the\n" -"# QThread name.\n" +"# LogRecord のデフォルトの threadName はあまり役立たないため、\n" +"# 上の方法で取得した QThread 名を qThreadName として追加する。\n" +"# この値を \"extra\" 辞書に入れて渡し、\n" +"# LogRecord に QThread 名を設定する。\n" "#\n" -"# This example worker just outputs messages sequentially, interspersed with\n" -"# random delays of the order of a few seconds.\n" +"# この例のワーカーは、数秒程度のランダムな間隔を空けて\n" +"# メッセージを順番に出力するだけ。\n" "#\n" "class Worker(QtCore.QObject):\n" " @Slot()\n" @@ -5312,9 +7318,8 @@ msgid "" " extra = {'qThreadName': ctname() }\n" " logger.debug('Started work', extra=extra)\n" " i = 1\n" -" # Let the thread run until interrupted. This allows reasonably " -"clean\n" -" # thread termination.\n" +" # 中断されるまでスレッドを実行する。\n" +" # これにより、スレッドを比較的きれいに終了できる。\n" " while not QtCore.QThread.currentThread().isInterruptionRequested():\n" " delay = 0.5 + random.random() * 2\n" " time.sleep(delay)\n" @@ -5330,12 +7335,13 @@ msgid "" " i += 1\n" "\n" "#\n" -"# Implement a simple UI for this cookbook example. This contains:\n" +"# このクックブックの例のための、次の要素を持つ単純な UI を実装する。\n" "#\n" -"# * A read-only text edit window which holds formatted log messages\n" -"# * A button to start work and log stuff in a separate thread\n" -"# * A button to log something from the main thread\n" -"# * A button to clear the log window\n" +"# * 書式化済みログメッセージを表示する、読み取り専用のテキスト編集ウィンド" +"ウ\n" +"# * 別のスレッドで仕事とログ出力を開始するボタン\n" +"# * メインスレッドからログを出力するボタン\n" +"# * ログウィンドウを消去するボタン\n" "#\n" "class Window(QtWidgets.QWidget):\n" "\n" @@ -5351,12 +7357,12 @@ msgid "" " super().__init__()\n" " self.app = app\n" " self.textedit = te = QtWidgets.QPlainTextEdit(self)\n" -" # Set whatever the default monospace font is for the platform\n" +" # プラットフォームのデフォルトの等幅フォントを設定する\n" " f = QtGui.QFont('nosuchfont')\n" " if hasattr(f, 'Monospace'):\n" " f.setStyleHint(f.Monospace)\n" " else:\n" -" f.setStyleHint(f.StyleHint.Monospace) # for Qt6\n" +" f.setStyleHint(f.StyleHint.Monospace) # Qt6 用\n" " te.setFont(f)\n" " te.setReadOnly(True)\n" " PB = QtWidgets.QPushButton\n" @@ -5364,16 +7370,15 @@ msgid "" " self.log_button = PB('Log a message at a random level', self)\n" " self.clear_button = PB('Clear log window', self)\n" " self.handler = h = QtHandler(self.update_status)\n" -" # Remember to use qThreadName rather than threadName in the format " -"string.\n" +" # 書式文字列では threadName ではなく qThreadName を使う。\n" " fs = '%(asctime)s %(qThreadName)-12s %(levelname)-8s %(message)s'\n" " formatter = logging.Formatter(fs)\n" " h.setFormatter(formatter)\n" " logger.addHandler(h)\n" -" # Set up to terminate the QThread when we exit\n" +" # 終了時に QThread も終了するよう設定する\n" " app.aboutToQuit.connect(self.force_quit)\n" "\n" -" # Lay out all the widgets\n" +" # すべてのウィジェットを配置する\n" " layout = QtWidgets.QVBoxLayout(self)\n" " layout.addWidget(te)\n" " layout.addWidget(self.work_button)\n" @@ -5381,14 +7386,14 @@ msgid "" " layout.addWidget(self.clear_button)\n" " self.setFixedSize(900, 400)\n" "\n" -" # Connect the non-worker slots and signals\n" +" # ワーカー以外のスロットとシグナルを接続する\n" " self.log_button.clicked.connect(self.manual_update)\n" " self.clear_button.clicked.connect(self.clear_display)\n" "\n" -" # Start a new worker thread and connect the slots for the worker\n" +" # 新しいワーカースレッドを開始し、ワーカー用のスロットを接続する\n" " self.start_thread()\n" " self.work_button.clicked.connect(self.worker.start)\n" -" # Once started, the button should be disabled\n" +" # 開始後はボタンを無効にする\n" " self.work_button.clicked.connect(lambda : self.work_button." "setEnabled(False))\n" "\n" @@ -5396,15 +7401,14 @@ msgid "" " self.worker = Worker()\n" " self.worker_thread = QtCore.QThread()\n" " self.worker.setObjectName('Worker')\n" -" self.worker_thread.setObjectName('WorkerThread') # for qThreadName\n" +" self.worker_thread.setObjectName('WorkerThread') # qThreadName 用\n" " self.worker.moveToThread(self.worker_thread)\n" -" # This will start an event loop in the worker thread\n" +" # ワーカースレッドでイベントループを開始する\n" " self.worker_thread.start()\n" "\n" " def kill_thread(self):\n" -" # Just tell the worker to stop, then tell it to quit and wait for " -"that\n" -" # to happen\n" +" # ワーカーに停止を伝え、次に終了を指示して、\n" +" # 終了するまで待つ\n" " self.worker_thread.requestInterruption()\n" " if self.worker_thread.isRunning():\n" " self.worker_thread.quit()\n" @@ -5413,12 +7417,13 @@ msgid "" " print('worker has already exited.')\n" "\n" " def force_quit(self):\n" -" # For use when the window is closed\n" +" # ウィンドウが閉じられたときに使う\n" " if self.worker_thread.isRunning():\n" " self.kill_thread()\n" "\n" -" # The functions below update the UI and run in the main thread because\n" -" # that's where the slots are set up\n" +" # 以下の関数は UI を更新する。スロットがメインスレッドに設定されているた" +"め、\n" +" # そこで実行される\n" "\n" " @Slot(str, logging.LogRecord)\n" " def update_status(self, status, record):\n" @@ -5428,10 +7433,9 @@ msgid "" "\n" " @Slot()\n" " def manual_update(self):\n" -" # This function uses the formatted message passed in, but also uses\n" -" # information from the record to format the message in an " -"appropriate\n" -" # color according to its severity (level).\n" +" # この関数は、渡された書式化済みメッセージに加え、\n" +" # レコード内の情報も使い、重要度 (レベル) に応じた\n" +" # 適切な色でメッセージを表示する。\n" " level = random.choice(LEVELS)\n" " extra = {'qThreadName': ctname() }\n" " logger.log(level, 'Manually logged!', extra=extra)\n" @@ -5455,13 +7459,11 @@ msgid "" "\n" "if __name__=='__main__':\n" " main()" -msgstr "" #: ../../howto/logging-cookbook.rst:3846 msgid "Logging to syslog with RFC5424 support" msgstr "RFC5424 をサポートする syslog へのロギング" -#: ../../howto/logging-cookbook.rst:3848 msgid "" "Although :rfc:`5424` dates from 2009, most syslog servers are configured by " "default to use the older :rfc:`3164`, which hails from 2001. When " @@ -5470,6 +7472,12 @@ msgid "" "been widespread deployment of it in syslog servers, the :class:`~logging." "handlers.SysLogHandler` functionality has not been updated." msgstr "" +":rfc:`5424` は 2009 年に公開されましたが、多くの syslog サーバーはデフォルト" +"で 2001 年の古い :rfc:`3164` を使う設定になっています。\n" +"2003 年に ``logging`` が Python に追加された時点では、当時唯一のプロトコルで" +"あった古い方に対応していました。\n" +"RFC 5424 の公開後も syslog サーバーへの普及が進まなかったため、:class:" +"`~logging.handlers.SysLogHandler` の機能は更新されていません。" #: ../../howto/logging-cookbook.rst:3855 msgid "" @@ -5481,7 +7489,6 @@ msgstr "" "の機能をサポートする syslog サーバーへのロギングを可能にする必要がある場合、" "以下のような派生ハンドラクラスを使うことで実現することができます::" -#: ../../howto/logging-cookbook.rst:3859 msgid "" "import datetime as dt\n" "import logging.handlers\n" @@ -5549,8 +7556,68 @@ msgid "" " return f'{version} {asctime} {hostname} {appname} {procid} {msgid} " "{sdata} {msg}'" msgstr "" +"import datetime as dt\n" +"import logging.handlers\n" +"import re\n" +"import socket\n" +"import time\n" +"\n" +"class SysLogHandler5424(logging.handlers.SysLogHandler):\n" +"\n" +" tz_offset = re.compile(r'([+-]\\d{2})(\\d{2})$')\n" +" escaped = re.compile(r'([\\]\"\\\\])')\n" +"\n" +" def __init__(self, *args, **kwargs):\n" +" self.msgid = kwargs.pop('msgid', None)\n" +" self.appname = kwargs.pop('appname', None)\n" +" super().__init__(*args, **kwargs)\n" +"\n" +" def format(self, record):\n" +" version = 1\n" +" asctime = dt.datetime.fromtimestamp(record.created).isoformat()\n" +" m = self.tz_offset.prefixmatch(time.strftime('%z'))\n" +" has_offset = False\n" +" if m and time.timezone:\n" +" hrs, mins = m.groups()\n" +" if int(hrs) or int(mins):\n" +" has_offset = True\n" +" if not has_offset:\n" +" asctime += 'Z'\n" +" else:\n" +" asctime += f'{hrs}:{mins}'\n" +" try:\n" +" hostname = socket.gethostname()\n" +" except Exception:\n" +" hostname = '-'\n" +" appname = self.appname or '-'\n" +" procid = record.process\n" +" msgid = '-'\n" +" msg = super().format(record)\n" +" sdata = '-'\n" +" if hasattr(record, 'structured_data'):\n" +" sd = record.structured_data\n" +" # キーが SD-ID、値が PARAM-NAME から PARAM-VALUE への辞書となる\n" +" # 辞書を指定する (これらの意味は RFC を参照)。\n" +" # ここでは説明のためエラーチェックを省略している。\n" +" # 本番環境で使う際は適切に変更できる\n" +" parts = []\n" +"\n" +" def replacer(m):\n" +" g = m.groups()\n" +" return '\\\\' + g[0]\n" +"\n" +" for sdid, dv in sd.items():\n" +" part = f'[{sdid}'\n" +" for k, v in dv.items():\n" +" s = str(v)\n" +" s = self.escaped.sub(replacer, s)\n" +" part += f' {k}=\"{s}\"'\n" +" part += ']'\n" +" parts.append(part)\n" +" sdata = ''.join(parts)\n" +" return f'{version} {asctime} {hostname} {appname} {procid} {msgid} " +"{sdata} {msg}'" -#: ../../howto/logging-cookbook.rst:3921 msgid "" "You'll need to be familiar with RFC 5424 to fully understand the above code, " "and it may be that you have slightly different needs (e.g. for how you pass " @@ -5558,8 +7625,11 @@ msgid "" "your specific needs. With the above handler, you'd pass structured data " "using something like this::" msgstr "" +"上のコードを完全に理解するには RFC 5424 の知識が必要です。\n" +"構造化データをログに渡す方法など、要件が多少異なる場合もあるでしょう。\n" +"それでも、個別の要件に合わせて変更できるはずです。\n" +"このハンドラには、例えば次のように構造化データを渡します。 ::" -#: ../../howto/logging-cookbook.rst:3926 msgid "" "sd = {\n" " 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" @@ -5569,6 +7639,13 @@ msgid "" "i = 1\n" "logger.debug('Message %d', i, extra=extra)" msgstr "" +"sd = {\n" +" 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},\n" +" 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'}\n" +"}\n" +"extra = {'structured_data': sd}\n" +"i = 1\n" +"logger.debug('Message %d', i, extra=extra)" #: ../../howto/logging-cookbook.rst:3935 msgid "How to treat a logger like an output stream" @@ -5586,7 +7663,6 @@ msgstr "" "きあります。これは file-like な API でロガーをラップするクラスを使うことで実" "現できます。以下はそのようなクラスを例解する短いスクリプトです:" -#: ../../howto/logging-cookbook.rst:3942 msgid "" "import logging\n" "\n" @@ -5623,16 +7699,51 @@ msgid "" "if __name__ == \"__main__\":\n" " main()" msgstr "" +"import logging\n" +"\n" +"class LoggerWriter:\n" +" def __init__(self, logger, level):\n" +" self.logger = logger\n" +" self.level = level\n" +"\n" +" def write(self, message):\n" +" if message != '\\n': # 必要なら、改行だけの出力を避ける\n" +" self.logger.log(self.level, message)\n" +"\n" +" def flush(self):\n" +" # 実際には何もしないが、ファイルライクオブジェクトに期待される場合が" +"ある。\n" +" # 必要に応じて実装する\n" +" pass\n" +"\n" +" def close(self):\n" +" # 実際には何もしないが、ファイルライクオブジェクトに期待される場合が" +"ある。\n" +" # 必要に応じて実装する。フラグを設定し、\n" +" # 以降の write の呼び出しで例外を送出するようにしてもよい\n" +" pass\n" +"\n" +"def main():\n" +" logging.basicConfig(level=logging.DEBUG)\n" +" logger = logging.getLogger('demo')\n" +" info_fp = LoggerWriter(logger, logging.INFO)\n" +" debug_fp = LoggerWriter(logger, logging.DEBUG)\n" +" print('An INFO message', file=info_fp)\n" +" print('A DEBUG message', file=debug_fp)\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" #: ../../howto/logging-cookbook.rst:3977 msgid "When this script is run, it prints" msgstr "このスクリプトを実行すると、次のように出力されます。" -#: ../../howto/logging-cookbook.rst:3979 msgid "" "INFO:demo:An INFO message\n" "DEBUG:demo:A DEBUG message" msgstr "" +"INFO:demo:An INFO message\n" +"DEBUG:demo:A DEBUG message" #: ../../howto/logging-cookbook.rst:3984 msgid "" @@ -5642,13 +7753,16 @@ msgstr "" "また、 ``sys.stdout`` や ``sys.stderr`` をリダイレクトするには " "``LoggerWriter`` を使って以下のようにします:" -#: ../../howto/logging-cookbook.rst:3987 msgid "" "import sys\n" "\n" "sys.stdout = LoggerWriter(logger, logging.INFO)\n" "sys.stderr = LoggerWriter(logger, logging.WARNING)" msgstr "" +"import sys\n" +"\n" +"sys.stdout = LoggerWriter(logger, logging.INFO)\n" +"sys.stderr = LoggerWriter(logger, logging.WARNING)" #: ../../howto/logging-cookbook.rst:3994 msgid "" @@ -5662,7 +7776,6 @@ msgstr "" "で上書きされる *前の* ``sys.stderr`` を使って) 設定を行います。そして、以下の" "ような結果を得るでしょう:" -#: ../../howto/logging-cookbook.rst:3999 msgid "" ">>> print('Foo')\n" "INFO:demo:Foo\n" @@ -5670,6 +7783,11 @@ msgid "" "WARNING:demo:Bar\n" ">>>" msgstr "" +">>> print('Foo')\n" +"INFO:demo:Foo\n" +">>> print('Bar', file=sys.stderr)\n" +"WARNING:demo:Bar\n" +">>>" #: ../../howto/logging-cookbook.rst:4007 msgid "" @@ -5691,17 +7809,17 @@ msgstr "" "いてはなすがままになっています。たとえば、上記の ``LoggerWriter`` の定義で、" "次のようなコードの断片があったとします。" -#: ../../howto/logging-cookbook.rst:4015 msgid "" "sys.stderr = LoggerWriter(logger, logging.WARNING)\n" "1 / 0" msgstr "" +"sys.stderr = LoggerWriter(logger, logging.WARNING)\n" +"1 / 0" #: ../../howto/logging-cookbook.rst:4020 msgid "then running the script results in" msgstr "このスクリプトを実行すると以下のような結果が得られます。" -#: ../../howto/logging-cookbook.rst:4022 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "\n" @@ -5719,8 +7837,22 @@ msgid "" "WARNING:demo::\n" "WARNING:demo:division by zero" msgstr "" +"WARNING:demo:Traceback (most recent call last):\n" +"\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 53, " +"in \n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/test.py\", line 49, " +"in main\n" +"\n" +"WARNING:demo:\n" +"WARNING:demo:1 / 0\n" +"WARNING:demo:ZeroDivisionError\n" +"WARNING:demo::\n" +"WARNING:demo:division by zero" -#: ../../howto/logging-cookbook.rst:4038 msgid "" "As you can see, this output isn't ideal. That's because the underlying code " "which writes to ``sys.stderr`` makes multiple writes, each of which results " @@ -5729,8 +7861,13 @@ msgid "" "when newlines are seen. Let's use a slightly better implementation of " "``LoggerWriter``:" msgstr "" +"この出力は望ましいものではありません。\n" +"内部のコードが ``sys.stderr`` に複数回の書き込みを行い、そのたびに別のログ行" +"になるためです (例えば上の最後の三行)。\n" +"この問題を避けるには、書き込まれた内容をバッファにため、改行が現れたときだけ" +"ログ行を出力します。\n" +"``LoggerWriter`` を少し改善してみましょう:" -#: ../../howto/logging-cookbook.rst:4044 msgid "" "class BufferingLoggerWriter(LoggerWriter):\n" " def __init__(self, logger, level):\n" @@ -5749,6 +7886,22 @@ msgid "" " for part in parts:\n" " self.logger.log(self.level, part)" msgstr "" +"class BufferingLoggerWriter(LoggerWriter):\n" +" def __init__(self, logger, level):\n" +" super().__init__(logger, level)\n" +" self.buffer = ''\n" +"\n" +" def write(self, message):\n" +" if '\\n' not in message:\n" +" self.buffer += message\n" +" else:\n" +" parts = message.split('\\n')\n" +" if self.buffer:\n" +" s = self.buffer + parts.pop(0)\n" +" self.logger.log(self.level, s)\n" +" self.buffer = parts.pop()\n" +" for part in parts:\n" +" self.logger.log(self.level, part)" #: ../../howto/logging-cookbook.rst:4063 msgid "" @@ -5758,7 +7911,6 @@ msgstr "" "この実装は改行があらわれるまでログをバッファリングし、行全体をログに出力する" "だけです。このアプローチにより、より適切な出力が得られます:" -#: ../../howto/logging-cookbook.rst:4066 msgid "" "WARNING:demo:Traceback (most recent call last):\n" "WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " @@ -5769,10 +7921,17 @@ msgid "" "WARNING:demo: 1/0\n" "WARNING:demo:ZeroDivisionError: division by zero" msgstr "" +"WARNING:demo:Traceback (most recent call last):\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 55, " +"in \n" +"WARNING:demo: main()\n" +"WARNING:demo: File \"/home/runner/cookbook-loggerwriter/main.py\", line 52, " +"in main\n" +"WARNING:demo: 1/0\n" +"WARNING:demo:ZeroDivisionError: division by zero" -#: ../../howto/logging-cookbook.rst:4076 msgid "How to uniformly handle newlines in logging output" -msgstr "" +msgstr "ログ出力の改行を統一的に扱う方法" #: ../../howto/logging-cookbook.rst:4078 msgid "" @@ -5785,7 +7944,6 @@ msgid "" "handler mixin, as in the following snippet:" msgstr "" -#: ../../howto/logging-cookbook.rst:4086 msgid "" "# Assume this is in a module mymixins.py\n" "import copy\n" @@ -5803,12 +7961,25 @@ msgid "" " rec.msg = line\n" " super().emit(rec)" msgstr "" +"# mymixins.py モジュールにあるとする\n" +"import copy\n" +"\n" +"class MultilineMixin:\n" +" def emit(self, record):\n" +" s = record.getMessage()\n" +" if '\\n' not in s:\n" +" super().emit(record)\n" +" else:\n" +" lines = s.splitlines()\n" +" rec = copy.copy(record)\n" +" rec.args = None\n" +" for line in lines:\n" +" rec.msg = line\n" +" super().emit(rec)" -#: ../../howto/logging-cookbook.rst:4104 msgid "You can use the mixin as in the following script:" -msgstr "" +msgstr "このミックスインは次のように使えます:" -#: ../../howto/logging-cookbook.rst:4106 msgid "" "import logging\n" "\n" @@ -5829,12 +8000,28 @@ msgid "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" msgstr "" +"import logging\n" +"\n" +"from mymixins import MultilineMixin\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class StreamHandler(MultilineMixin, logging.StreamHandler):\n" +" pass\n" +"\n" +"if __name__ == '__main__':\n" +" logging.basicConfig(level=logging.DEBUG, format='%(asctime)s " +"%(levelname)-9s %(message)s',\n" +" handlers = [StreamHandler()])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" -#: ../../howto/logging-cookbook.rst:4125 msgid "The script, when run, prints something like:" -msgstr "" +msgstr "実行すると、次のように表示されます:" -#: ../../howto/logging-cookbook.rst:4127 msgid "" "2025-07-02 13:54:47,234 DEBUG Single line\n" "2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" @@ -5844,15 +8031,23 @@ msgid "" "2025-07-02 13:54:47,234 DEBUG fool me ...\n" "2025-07-02 13:54:47,234 DEBUG can't get fooled again" msgstr "" +"2025-07-02 13:54:47,234 DEBUG Single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"2025-07-02 13:54:47,234 DEBUG fool me once ...\n" +"2025-07-02 13:54:47,234 DEBUG Another single line\n" +"2025-07-02 13:54:47,234 DEBUG Multiple lines:\n" +"2025-07-02 13:54:47,234 DEBUG fool me ...\n" +"2025-07-02 13:54:47,234 DEBUG can't get fooled again" -#: ../../howto/logging-cookbook.rst:4137 msgid "" "If, on the other hand, you are concerned about `log injection `_, you can use a formatter which " "escapes newlines, as per the following example:" msgstr "" +"一方、`ログインジェクション `_ が気になる場合は、次の例のように改行をエスケープするフォー" +"マッタを使えます:" -#: ../../howto/logging-cookbook.rst:4141 msgid "" "import logging\n" "\n" @@ -5874,14 +8069,33 @@ msgid "" " logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " "again')" msgstr "" +"import logging\n" +"\n" +"logger = logging.getLogger(__name__)\n" +"\n" +"class EscapingFormatter(logging.Formatter):\n" +" def format(self, record):\n" +" s = super().format(record)\n" +" return s.replace('\\n', r'\\n')\n" +"\n" +"if __name__ == '__main__':\n" +" h = logging.StreamHandler()\n" +" h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s " +"%(message)s'))\n" +" logging.basicConfig(level=logging.DEBUG, handlers = [h])\n" +" logger.debug('Single line')\n" +" logger.debug('Multiple lines:\\nfool me once ...')\n" +" logger.debug('Another single line')\n" +" logger.debug('Multiple lines:\\n%s', 'fool me ...\\ncan\\'t get fooled " +"again')" -#: ../../howto/logging-cookbook.rst:4161 msgid "" "You can, of course, use whatever escaping scheme makes the most sense for " "you. The script, when run, should produce output like this:" msgstr "" +"もちろん、用途に合ったエスケープ方法を使えます。\n" +"このスクリプトを実行すると、次のように表示されます:" -#: ../../howto/logging-cookbook.rst:4164 msgid "" "2025-07-09 06:47:33,783 DEBUG Single line\n" "2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me once ...\n" @@ -5889,12 +8103,18 @@ msgid "" "2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " "fooled again" msgstr "" +"2025-07-09 06:47:33,783 DEBUG Single line\n" +"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me once ...\n" +"2025-07-09 06:47:33,783 DEBUG Another single line\n" +"2025-07-09 06:47:33,783 DEBUG Multiple lines:\\nfool me ...\\ncan't get " +"fooled again" -#: ../../howto/logging-cookbook.rst:4171 msgid "" "Escaping behaviour can't be the stdlib default , as it would break backwards " "compatibility." msgstr "" +"このエスケープ処理は後方互換性を損なうため、標準ライブラリのデフォルトにはで" +"きません。" #: ../../howto/logging-cookbook.rst:4177 msgid "Patterns to avoid" @@ -5928,13 +8148,12 @@ msgstr "" "ではエラーがおきることなく、同じファイルを何度も開けます。これは次のように間" "違って使われる可能性があります。" -#: ../../howto/logging-cookbook.rst:4192 msgid "" "Adding a file handler more than once which references the same file (e.g. by " "a copy/paste/forget-to-change error)." msgstr "" -"同じファイルを指すファイルハンドラを1度以上追加する(例えばコピー&ペーストし" -"て書き換え忘れによるエラー)。" +"同じファイルを参照するファイルハンドラを複数回追加する (例えばコピー&ペース" +"ト後の変更忘れによって)。" #: ../../howto/logging-cookbook.rst:4195 msgid "" @@ -5962,7 +8181,6 @@ msgstr "" "ファイルを複数回開くことは、 *一見* 動作しているように見えますが、さまざまな" "問題を引き起こす可能性があります:" -#: ../../howto/logging-cookbook.rst:4205 msgid "" "Logging output can be garbled because multiple threads or processes try to " "write to the same file. Although logging guards against concurrent use of " @@ -5970,11 +8188,12 @@ msgid "" "if concurrent writes are attempted by two different threads using two " "different handler instances which happen to point to the same file." msgstr "" -"複数のスレッドが同一ファイルに書き出そうとすると、ログ出力が文字化けする可能" -"性があります。ログモジュールは同じハンドラーのインスタンスに対して並列で利用" -"しても正しく動くようになっていますが、同じファイルを参照する2つの異なるハンド" -"ラーのインスタンスに対し、2つのスレッドから同時に書き込みをした場合にはそのよ" -"うな保護は働きません。" +"複数のスレッドやプロセスが同じファイルに書き込もうとすると、ログ出力が混ざっ" +"て壊れる可能性があります。\n" +"logging は複数のスレッドによる同じハンドラインスタンスの同時使用を保護しま" +"す。\n" +"しかし、同じファイルを指す別々のハンドラインスタンスを使い、二つのスレッドが" +"同時に書き込む場合には、そのような保護はありません。" #: ../../howto/logging-cookbook.rst:4211 msgid "" @@ -6030,17 +8249,17 @@ msgstr "" "ライブラリ内でロガーに :class:`~logging.NullHandler` 以外のハンドラーを追加す" "る" -#: ../../howto/logging-cookbook.rst:4235 msgid "" "Configuring logging by adding handlers, formatters and filters is the " "responsibility of the application developer, not the library developer. If " "you are maintaining a library, ensure that you don't add handlers to any of " "your loggers other than a :class:`~logging.NullHandler` instance." msgstr "" -"ハンドラーやフォーマッター、フィルターを追加してログ出力をカスタマイズするの" -"はライブラリ開発者ではなく、アプリケーション開発者の責務です。もしあなたがラ" -"イブラリのメンテナンスをしているのであれば、 :class:`~logging.NullHandler` イ" -"ンスタンス以外のロガーを追加してはいけない、ということを意味します。" +"ハンドラ、フォーマッタ、フィルタを追加してロギングを設定するのは、アプリケー" +"ション開発者の責任です。\n" +"ライブラリ開発者の責任ではありません。\n" +"ライブラリを保守している場合、そのロガーに追加するハンドラは :class:" +"`~logging.NullHandler` インスタンスだけにしてください。" #: ../../howto/logging-cookbook.rst:4241 msgid "Creating a lot of loggers" diff --git a/howto/logging.po b/howto/logging.po index 0cb5526d3..31aa76bd7 100644 --- a/howto/logging.po +++ b/howto/logging.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/logging.rst:5 @@ -59,7 +59,6 @@ msgstr "" msgid "When to use logging" msgstr "logging を使うとき" -#: ../../howto/logging.rst:28 msgid "" "You can access logging functionality by creating a logger via ``logger = " "logging.getLogger(__name__)``, and then calling the logger's :meth:`~Logger." @@ -68,6 +67,13 @@ msgid "" "to see which logger methods to use when, see the table below. It states, for " "each of a set of common tasks, the best tool to use for that task." msgstr "" +"``logger = logging.getLogger(__name__)`` でロガーを作成し、:meth:`~Logger." +"debug`、:meth:`~Logger.info`、:meth:`~Logger.warning`、:meth:`~Logger." +"error`、:meth:`~Logger.critical` メソッドを呼び出すと、ロギング機能を利用でき" +"ます。\n" +"いつロギングを使い、どのメソッドを選べばよいかは、次の表を参照してくださ" +"い。\n" +"一般的なタスクごとに、最適な手段を示しています。" #: ../../howto/logging.rst:36 msgid "Task you want to perform" @@ -94,29 +100,30 @@ msgstr "" "プログラムの通常の操作中に発生したイベントの報告 (例えば、状態の監視や障害の" "分析)" -#: ../../howto/logging.rst:42 msgid "" "A logger's :meth:`~Logger.info` (or :meth:`~Logger.debug` method for very " "detailed output for diagnostic purposes)" msgstr "" +"ロガーの :meth:`~Logger.info` (診断用の非常に詳しい出力には :meth:`~Logger." +"debug`) メソッド" #: ../../howto/logging.rst:47 msgid "Issue a warning regarding a particular runtime event" msgstr "特定のランタイムイベントに関わる警告の発行" -#: ../../howto/logging.rst:47 msgid "" ":func:`warnings.warn` in library code if the issue is avoidable and the " "client application should be modified to eliminate the warning" msgstr "" -"その発行が避けられるもので、クライアントアプリケーションを修正してその警告を" -"排除するべきなら :func:`warnings.warn`" +"問題を回避でき、クライアントアプリケーションを修正して警告の原因を取り除くべ" +"き場合は、ライブラリのコードで :func:`warnings.warn` を使う" -#: ../../howto/logging.rst:52 msgid "" "A logger's :meth:`~Logger.warning` method if there is nothing the client " "application can do about the situation, but the event should still be noted" msgstr "" +"クライアントアプリケーションでは対処できなくても、そのイベントを記録すべき場" +"合はロガーの :meth:`~Logger.warning` メソッド" #: ../../howto/logging.rst:58 msgid "Report an error regarding a particular runtime event" @@ -126,27 +133,28 @@ msgstr "特定のランタイムイベントに関わるエラーの報告" msgid "Raise an exception" msgstr "例外の送出" -#: ../../howto/logging.rst:61 msgid "" "Report suppression of an error without raising an exception (e.g. error " "handler in a long-running server process)" msgstr "" -"例外の送出をしないエラーの抑制 (例えば、長期のサーバプロセス中のエラーハンド" -"ラ)" +"例外を送出せずに処理したエラーの報告 (例えば、長時間稼働するサーバープロセス" +"のエラーハンドラ)" -#: ../../howto/logging.rst:61 msgid "" "A logger's :meth:`~Logger.error`, :meth:`~Logger.exception` or :meth:" "`~Logger.critical` method as appropriate for the specific error and " "application domain" msgstr "" +"エラーやアプリケーションの分野に応じて、ロガーの :meth:`~Logger.error`、:" +"meth:`~Logger.exception`、:meth:`~Logger.critical` メソッド" -#: ../../howto/logging.rst:68 msgid "" "The logger methods are named after the level or severity of the events they " "are used to track. The standard levels and their applicability are described " "below (in increasing order of severity):" msgstr "" +"ロガーのメソッド名は、追跡するイベントのレベルや重大度に対応しています。\n" +"標準のレベルとその用途を、重大度の低い順に示します:" #: ../../howto/logging.rst:75 ../../howto/logging.rst:873 msgid "Level" @@ -177,14 +185,14 @@ msgstr "想定された通りのことが起こったことの確認。" msgid "``WARNING``" msgstr "``WARNING``" -#: ../../howto/logging.rst:83 msgid "" "An indication that something unexpected happened, or indicative of some " "problem in the near future (e.g. 'disk space low'). The software is still " "working as expected." msgstr "" -"想定外のことが起こった、または問題が近く起こりそうである (例えば、'disk " -"space low') ことの表示。" +"想定外のことが起こった、または近い将来の問題を示す情報 (例えば「ディスク容量" +"が少ない」)。\n" +"ソフトウェアは引き続き想定どおり動作しています。" #: ../../howto/logging.rst:88 ../../howto/logging.rst:877 msgid "``ERROR``" @@ -200,18 +208,18 @@ msgstr "より重大な問題により、ソフトウェアがある機能を実 msgid "``CRITICAL``" msgstr "``CRITICAL``" -#: ../../howto/logging.rst:91 msgid "" "A serious error, indicating that the program itself may be unable to " "continue running." -msgstr "プログラム自体が実行を続けられないことを表す、重大なエラー。" +msgstr "プログラム自体が実行を継続できない可能性を示す、重大なエラー。" -#: ../../howto/logging.rst:95 msgid "" "The default level is ``WARNING``, which means that only events of this " "severity and higher will be tracked, unless the logging package is " "configured to do otherwise." msgstr "" +"デフォルトのレベルは ``WARNING`` です。\n" +"そのため、別の設定をしない限り、この重大度以上のイベントだけが追跡されます。" #: ../../howto/logging.rst:98 msgid "" @@ -231,12 +239,14 @@ msgstr "簡単な例" msgid "A very simple example is::" msgstr "ごく簡単な例は::" -#: ../../howto/logging.rst:110 msgid "" "import logging\n" "logging.warning('Watch out!') # will print a message to the console\n" "logging.info('I told you so') # will not print anything" msgstr "" +"import logging\n" +"logging.warning('Watch out!') # will print a message to the console\n" +"logging.info('I told you so') # will not print anything" #: ../../howto/logging.rst:114 msgid "If you type these lines into a script and run it, you'll see:" @@ -244,11 +254,9 @@ msgstr "" "これらの行をスクリプトにタイプして実行すると、次のようにコンソールに出力され" "ます:" -#: ../../howto/logging.rst:116 msgid "WARNING:root:Watch out!" -msgstr "" +msgstr "WARNING:root:Watch out!" -#: ../../howto/logging.rst:120 msgid "" "printed out on the console. The ``INFO`` message doesn't appear because the " "default level is ``WARNING``. The printed message includes the indication of " @@ -256,8 +264,14 @@ msgid "" "e. 'Watch out!'. The actual output can be formatted quite flexibly if you " "need that; formatting options will also be explained later." msgstr "" +"これがコンソールに表示されます。\n" +"デフォルトのレベルが ``WARNING`` なので、``INFO`` のメッセージは表示されませ" +"ん。\n" +"表示されるメッセージには、レベルとログ呼び出しで指定したイベントの説明、つま" +"り 'Watch out!' が含まれます。\n" +"必要なら出力の書式を柔軟に設定できます。\n" +"書式設定のオプションは後で説明します。" -#: ../../howto/logging.rst:126 msgid "" "Notice that in this example, we use functions directly on the ``logging`` " "module, like ``logging.debug``, rather than creating a logger and calling " @@ -268,6 +282,13 @@ msgid "" "reason as well as others, it's better to create loggers and call their " "methods." msgstr "" +"この例ではロガーを作成してメソッドを呼ぶ代わりに、``logging.debug`` など " +"``logging`` モジュールの関数を直接使っています。\n" +"これらはルートロガーを操作する関数ですが、この例のように設定がまだ行われてい" +"ない場合は :func:`~logging.basicConfig` を自動的に呼び出すため便利です。\n" +"ただし、大きなプログラムでは通常、ロギングの設定を明示的に制御したくなるで" +"しょう。\n" +"この点などを考えると、ロガーを作成してそのメソッドを呼ぶ方が適しています。" #: ../../howto/logging.rst:135 msgid "Logging to a file" @@ -284,7 +305,6 @@ msgstr "" "を見て行きましょう。以下のサンプルを試すときは Python インタプリタを新しく起" "動して、上のセッションの続きにならないようにしてください::" -#: ../../howto/logging.rst:141 msgid "" "import logging\n" "logger = logging.getLogger(__name__)\n" @@ -295,6 +315,14 @@ msgid "" "logger.warning('And this, too')\n" "logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" msgstr "" +"import logging\n" +"logger = logging.getLogger(__name__)\n" +"logging.basicConfig(filename='example.log', encoding='utf-8', level=logging." +"DEBUG)\n" +"logger.debug('This message should go to the log file')\n" +"logger.info('So should this')\n" +"logger.warning('And this, too')\n" +"logger.error('And non-ASCII stuff, too, like Øresund and Malmö')" #: ../../howto/logging.rst:149 msgid "" @@ -316,13 +344,16 @@ msgid "" "messages:" msgstr "そして、ファイルの中身を確認すると、ログメッセージが確認できます:" -#: ../../howto/logging.rst:159 msgid "" "DEBUG:__main__:This message should go to the log file\n" "INFO:__main__:So should this\n" "WARNING:__main__:And this, too\n" "ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö" msgstr "" +"DEBUG:__main__:This message should go to the log file\n" +"INFO:__main__:So should this\n" +"WARNING:__main__:And this, too\n" +"ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö" #: ../../howto/logging.rst:166 msgid "" @@ -339,20 +370,16 @@ msgid "" "If you want to set the logging level from a command-line option such as:" msgstr "次のようなコマンドラインオプションでログレベルを設定したいと考え:" -#: ../../howto/logging.rst:172 msgid "--log=INFO" -msgstr "" +msgstr "--log=INFO" -#: ../../howto/logging.rst:176 msgid "" "and you have the value of the parameter passed for ``--log`` in some " "variable *loglevel*, you can use::" -msgstr "" -"``--log`` に渡されたパラメータの値を変数 *loglevel* に保存しているとしたら、" +msgstr "``--log`` に渡された値を変数 *loglevel* に保存しているなら、 ::" -#: ../../howto/logging.rst:179 msgid "getattr(logging, loglevel.upper())" -msgstr "" +msgstr "getattr(logging, loglevel.upper())" #: ../../howto/logging.rst:181 msgid "" @@ -364,7 +391,6 @@ msgstr "" "ます。ユーザの入力値をすべてエラーチェックしたくなり、次の例のように実装する" "こともあるでしょう::" -#: ../../howto/logging.rst:185 msgid "" "# assuming loglevel is bound to the string value obtained from the\n" "# command line argument. Convert to upper case to allow the user to\n" @@ -374,13 +400,22 @@ msgid "" " raise ValueError('Invalid log level: %s' % loglevel)\n" "logging.basicConfig(level=numeric_level, ...)" msgstr "" +"# loglevel はコマンドライン引数から取得した文字列とする。\n" +"# --log=DEBUG と --log=debug のどちらでも指定できるよう、\n" +"# 大文字に変換する\n" +"numeric_level = getattr(logging, loglevel.upper(), None)\n" +"if not isinstance(numeric_level, int):\n" +" raise ValueError('Invalid log level: %s' % loglevel)\n" +"logging.basicConfig(level=numeric_level, ...)" -#: ../../howto/logging.rst:193 msgid "" "The call to :func:`basicConfig` should come *before* any calls to a logger's " "methods such as :meth:`~Logger.debug`, :meth:`~Logger.info`, etc. Otherwise, " "that logging event may not be handled in the desired manner." msgstr "" +":func:`basicConfig` は、ロガーの :meth:`~Logger.debug` や :meth:`~Logger." +"info` などのメソッドを呼ぶ *前* に呼び出してください。\n" +"そうしないと、ログイベントが意図した方法で処理されない可能性があります。" #: ../../howto/logging.rst:197 msgid "" @@ -394,11 +429,12 @@ msgstr "" "に新たに始めたいなら、上記の例での呼び出しを次のように変え、*filemode* 引数を" "指定する方法がとれます::" -#: ../../howto/logging.rst:202 msgid "" "logging.basicConfig(filename='example.log', filemode='w', level=logging." "DEBUG)" msgstr "" +"logging.basicConfig(filename='example.log', filemode='w', level=logging." +"DEBUG)" #: ../../howto/logging.rst:204 msgid "" @@ -420,19 +456,19 @@ msgstr "" "変数データのログを取るには、イベント記述メッセージにフォーマット文字列を使" "い、引数に変数データを加えてください。例えば::" -#: ../../howto/logging.rst:214 msgid "" "import logging\n" "logging.warning('%s before you %s', 'Look', 'leap!')" msgstr "" +"import logging\n" +"logging.warning('%s before you %s', 'Look', 'leap!')" #: ../../howto/logging.rst:217 msgid "will display:" msgstr "により、次のように表示されます:" -#: ../../howto/logging.rst:219 msgid "WARNING:root:Look before you leap!" -msgstr "" +msgstr "WARNING:root:Look before you leap!" #: ../../howto/logging.rst:223 msgid "" @@ -462,7 +498,6 @@ msgstr "" "メッセージを表示するのに使われるフォーマットを変更するには、使いたいフォー" "マットを指定する必要があります::" -#: ../../howto/logging.rst:237 msgid "" "import logging\n" "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging." @@ -471,17 +506,25 @@ msgid "" "logging.info('So should this')\n" "logging.warning('And this, too')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(levelname)s:%(message)s', level=logging." +"DEBUG)\n" +"logging.debug('This message should appear on the console')\n" +"logging.info('So should this')\n" +"logging.warning('And this, too')" #: ../../howto/logging.rst:243 msgid "which would print:" msgstr "により、次のように表示されます:" -#: ../../howto/logging.rst:245 msgid "" "DEBUG:This message should appear on the console\n" "INFO:So should this\n" "WARNING:And this, too" msgstr "" +"DEBUG:This message should appear on the console\n" +"INFO:So should this\n" +"WARNING:And this, too" #: ../../howto/logging.rst:251 msgid "" @@ -510,20 +553,21 @@ msgstr "" "イベントの日付と時刻を表示するには、フォーマット文字列に '%(asctime)s' を置い" "てください::" -#: ../../howto/logging.rst:265 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s')\n" "logging.warning('is when this event was logged.')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s')\n" +"logging.warning('is when this event was logged.')" #: ../../howto/logging.rst:269 msgid "which should print something like this:" msgstr "これは以下の様なフォーマットで表示されます:" -#: ../../howto/logging.rst:271 msgid "2010-12-12 11:41:42,612 is when this event was logged." -msgstr "" +msgstr "2010-12-12 11:41:42,612 is when this event was logged." #: ../../howto/logging.rst:275 msgid "" @@ -535,21 +579,23 @@ msgstr "" "`3339` に似ています。日付と時間のフォーマットをより詳細に制御する必要があるな" "ら、以下の例の様に、 ``basicConfig`` に *datefmt* 引数を指定してください::" -#: ../../howto/logging.rst:279 msgid "" "import logging\n" "logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" "%M:%S %p')\n" "logging.warning('is when this event was logged.')" msgstr "" +"import logging\n" +"logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:" +"%M:%S %p')\n" +"logging.warning('is when this event was logged.')" #: ../../howto/logging.rst:283 msgid "which would display something like this:" msgstr "これは次のように表示されます:" -#: ../../howto/logging.rst:285 msgid "12/12/2010 11:46:36 AM is when this event was logged." -msgstr "" +msgstr "12/12/2010 11:46:36 AM is when this event was logged." #: ../../howto/logging.rst:289 msgid "" @@ -576,7 +622,6 @@ msgstr "" "を使いこなすためには、もうちょっと時間をかけて、以下のセクションを読む必要が" "あります。その用意ができたら、好きな飲み物を持って、次に進みましょう。" -#: ../../howto/logging.rst:302 msgid "" "If your logging needs are simple, then use the above examples to incorporate " "logging into your own scripts, and if you run into problems or don't " @@ -584,6 +629,11 @@ msgid "" "`Python discussion forum `_ and you " "should receive help before too long." msgstr "" +"単純なロギングで十分なら、上の例を使って自分のスクリプトに組み込んでくださ" +"い。\n" +"問題や分からないことがあれば、`Python ディスカッションフォーラム `_ の Help カテゴリに質問を投稿すると、ほどなく助" +"けが得られるでしょう。" #: ../../howto/logging.rst:308 msgid "" @@ -662,9 +712,8 @@ msgstr "" "ロガーに名前をつけるときの良い習慣は、ロギングを使う各モジュールに、以下のよ" "うに名付けられた、モジュールレベルロガーを使うことです::" -#: ../../howto/logging.rst:341 msgid "logger = logging.getLogger(__name__)" -msgstr "" +msgstr "logger = logging.getLogger(__name__)" #: ../../howto/logging.rst:343 msgid "" @@ -688,7 +737,6 @@ msgstr "" "の同名のメソッドを呼び出します。これらの関数とメソッドは、同じ署名をもってい" "ます。ルートロガーの名前は、ログ出力では 'root' と表示されます。" -#: ../../howto/logging.rst:352 msgid "" "It is, of course, possible to log messages to different destinations. " "Support is included in the package for writing log messages to files, HTTP " @@ -698,12 +746,13 @@ msgid "" "destination class if you have special requirements not met by any of the " "built-in handler classes." msgstr "" -"もちろん、メッセージを異なる送信先に記録することも出来ます。このパッケージで" -"は、ファイルへ、 HTTP GET/POST 先へ、 SMTP 経由で電子メールへ、汎用のソケット" -"へ、キューへ、または Windows NT イベントログのような OS 毎のログ記録機構へ" -"の、ログメッセージの書きこみがサポートされています。送信先は、 :dfn:" -"`handler` クラスによって取り扱われます。組み込みのハンドラクラスでは満たせな" -"いような、特殊な要件があるなら、独自のログ送信先を生成できます。" +"ログメッセージはさまざまな出力先に送れます。\n" +"このパッケージは、ファイル、HTTP GET/POST の送信先、SMTP によるメール、汎用ソ" +"ケット、キュー、syslog や Windows NT イベントログなどの OS 固有のロギング機構" +"に対応しています。\n" +"出力先は :dfn:`ハンドラ` クラスが扱います。\n" +"組み込みのハンドラクラスでは満たせない要件があれば、独自のログ出力先クラスを" +"作成できます。" #: ../../howto/logging.rst:359 msgid "" @@ -730,9 +779,8 @@ msgstr "" ":func:`basicConfig` が設定するデフォルトのメッセージのフォーマットは次のよう" "になります:" -#: ../../howto/logging.rst:369 msgid "severity:logger name:message" -msgstr "" +msgstr "重大度:ロガー名:メッセージ" #: ../../howto/logging.rst:373 msgid "" @@ -744,9 +792,8 @@ msgstr "" "で、これを変更できます。フォーマット文字列を構成するためのすべてのオプション" "は、 :ref:`formatter-objects` を参照してください。" -#: ../../howto/logging.rst:378 msgid "Logging Flow" -msgstr "Logging Flow" +msgstr "ログ処理の流れ" #: ../../howto/logging.rst:380 msgid "" @@ -1038,28 +1085,25 @@ msgstr "" "す。コンストラクタは三つのオプション引数を取ります -- メッセージのフォーマッ" "ト文字列、日付のフォーマット文字列、スタイル標識です。" -#: ../../howto/logging.rst:559 msgid "" "If there is no message format string, the default is to use the raw " "message. If there is no date format string, the default date format is:" msgstr "" -"フォーマット文字列に何も渡さない場合は、デフォルトで行メッセージが利用されま" -"す。また、日付フォーマットに何も渡さない場合は、デフォルトで以下のフォーマッ" -"トが利用されます:" +"メッセージの書式文字列を指定しなければ、デフォルトではメッセージをそのまま使" +"います。\n" +"日付の書式文字列を指定しなければ、デフォルトの書式は次のとおりです:" -#: ../../howto/logging.rst:562 msgid "%Y-%m-%d %H:%M:%S" -msgstr "" +msgstr "%Y-%m-%d %H:%M:%S" -#: ../../howto/logging.rst:566 msgid "" "with the milliseconds tacked on at the end. The ``style`` is one of ``'%'``, " "``'{'``, or ``'$'``. If one of these is not specified, then ``'%'`` will be " "used." msgstr "" -"時刻の末尾にはミリ秒が付きます。 ``style`` は ``'%'``, ``'{'``, または " -"``'{TX-PL-LABEL}#x27;`` のいずれかです。特に指定がなければ ``'%'`` が使われま" -"す。" +"末尾にはミリ秒が付きます。\n" +"``style`` には ``'%'``、``'{'``、``'$'`` のいずれかを指定します。\n" +"省略すると ``'%'`` が使われます。" #: ../../howto/logging.rst:569 msgid "" @@ -1090,11 +1134,9 @@ msgstr "" "次のメッセージフォーマット文字列は、人が読みやすい形式の時刻、メッセージの深" "刻度、およびメッセージの内容を、順番に出力します::" -#: ../../howto/logging.rst:583 msgid "'%(asctime)s - %(levelname)s - %(message)s'" -msgstr "" +msgstr "'%(asctime)s - %(levelname)s - %(message)s'" -#: ../../howto/logging.rst:585 msgid "" "Formatters use a user-configurable function to convert the creation time of " "a record to a tuple. By default, :func:`time.localtime` is used; to change " @@ -1104,13 +1146,16 @@ msgid "" "want all logging times to be shown in GMT, set the ``converter`` attribute " "in the Formatter class (to ``time.gmtime`` for GMT display)." msgstr "" -"フォーマッタは、ユーザが設定できる関数を使って、生成時刻をタプルに記録しま" -"す。デフォルトでは、 :func:`time.localtime` が使われます。特定のフォーマッタ" -"インスタンスに対してこれを変更するには、インスタンスの ``converter`` 属性を :" -"func:`time.localtime` や :func:`time.gmtime` と同じ署名をもつ関数に設定してく" -"ださい。すべてのフォーマッタインスタンスに対してこれを変更するには、例えば全" -"てのロギング時刻を GMT で表示するには、フォーマッタクラスの ``converter`` 属" -"性を (GMT 表示の ``time.gmtime`` に) 設定してください。" +"フォーマッタは設定可能な関数を使って、レコードの作成時刻をタプルに変換しま" +"す。\n" +"デフォルトでは :func:`time.localtime` が使われます。\n" +"特定のフォーマッタインスタンスで変更するには、その ``converter`` 属性を :" +"func:`time.localtime` または :func:`time.gmtime` と同じシグネチャの関数に設定" +"します。\n" +"すべてのフォーマッタで変更するには、Formatter クラスの ``converter`` 属性を設" +"定します。\n" +"例えば、すべてのログの時刻を GMT で表示するには ``time.gmtime`` に設定しま" +"す。" #: ../../howto/logging.rst:595 msgid "Configuring Logging" @@ -1151,7 +1196,6 @@ msgstr "" "下の例では、Python コードを使って、とても簡単なロガー、コンソールハンドラ、そ" "して簡単なフォーマッタを設定しています::" -#: ../../howto/logging.rst:612 msgid "" "import logging\n" "\n" @@ -1180,6 +1224,32 @@ msgid "" "logger.error('error message')\n" "logger.critical('critical message')" msgstr "" +"import logging\n" +"\n" +"# ロガーを作成する\n" +"logger = logging.getLogger('simple_example')\n" +"logger.setLevel(logging.DEBUG)\n" +"\n" +"# コンソールハンドラーを作成し、レベルを debug に設定する\n" +"ch = logging.StreamHandler()\n" +"ch.setLevel(logging.DEBUG)\n" +"\n" +"# フォーマッターを作成する\n" +"formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - " +"%(message)s')\n" +"\n" +"# ch にフォーマッターを設定する\n" +"ch.setFormatter(formatter)\n" +"\n" +"# ロガーに ch を追加する\n" +"logger.addHandler(ch)\n" +"\n" +"# 「アプリケーション」のコード\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" #: ../../howto/logging.rst:638 msgid "" @@ -1187,7 +1257,6 @@ msgid "" msgstr "" "このモジュールを実行すると、コマンドラインによって以下の出力がなされます:" -#: ../../howto/logging.rst:640 msgid "" "$ python simple_logging_module.py\n" "2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message\n" @@ -1196,6 +1265,12 @@ msgid "" "2005-03-19 15:10:26,697 - simple_example - ERROR - error message\n" "2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message" msgstr "" +"$ python simple_logging_module.py\n" +"2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message\n" +"2005-03-19 15:10:26,620 - simple_example - INFO - info message\n" +"2005-03-19 15:10:26,695 - simple_example - WARNING - warn message\n" +"2005-03-19 15:10:26,697 - simple_example - ERROR - error message\n" +"2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message" #: ../../howto/logging.rst:649 msgid "" @@ -1206,7 +1281,6 @@ msgstr "" "以下の Python モジュールは、ロガー、ハンドラ、フォーマッタをほとんど上述の例" "と同じように生成していますが、オブジェクト名だけが異なります::" -#: ../../howto/logging.rst:653 msgid "" "import logging\n" "import logging.config\n" @@ -1223,12 +1297,25 @@ msgid "" "logger.error('error message')\n" "logger.critical('critical message')" msgstr "" +"import logging\n" +"import logging.config\n" +"\n" +"logging.config.fileConfig('logging.conf')\n" +"\n" +"# ロガーを作成する\n" +"logger = logging.getLogger('simpleExample')\n" +"\n" +"# 「アプリケーション」のコード\n" +"logger.debug('debug message')\n" +"logger.info('info message')\n" +"logger.warning('warn message')\n" +"logger.error('error message')\n" +"logger.critical('critical message')" #: ../../howto/logging.rst:668 msgid "Here is the logging.conf file:" msgstr "これが logging.conf ファイルです:" -#: ../../howto/logging.rst:670 msgid "" "[loggers]\n" "keys=root,simpleExample\n" @@ -1258,13 +1345,38 @@ msgid "" "[formatter_simpleFormatter]\n" "format=%(asctime)s - %(name)s - %(levelname)s - %(message)s" msgstr "" +"[loggers]\n" +"keys=root,simpleExample\n" +"\n" +"[handlers]\n" +"keys=consoleHandler\n" +"\n" +"[formatters]\n" +"keys=simpleFormatter\n" +"\n" +"[logger_root]\n" +"level=DEBUG\n" +"handlers=consoleHandler\n" +"\n" +"[logger_simpleExample]\n" +"level=DEBUG\n" +"handlers=consoleHandler\n" +"qualname=simpleExample\n" +"propagate=0\n" +"\n" +"[handler_consoleHandler]\n" +"class=StreamHandler\n" +"level=DEBUG\n" +"formatter=simpleFormatter\n" +"args=(sys.stdout,)\n" +"\n" +"[formatter_simpleFormatter]\n" +"format=%(asctime)s - %(name)s - %(levelname)s - %(message)s" -#: ../../howto/logging.rst:700 msgid "" "The output is nearly identical to that of the non-config-file-based example:" -msgstr "出力は、設定ファイルに基づく例とだいたい同じです:" +msgstr "出力は、設定ファイルを使わない例とほぼ同じです:" -#: ../../howto/logging.rst:702 msgid "" "$ python simple_logging_config.py\n" "2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message\n" @@ -1273,6 +1385,12 @@ msgid "" "2005-03-19 15:38:56,055 - simpleExample - ERROR - error message\n" "2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message" msgstr "" +"$ python simple_logging_config.py\n" +"2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message\n" +"2005-03-19 15:38:55,979 - simpleExample - INFO - info message\n" +"2005-03-19 15:38:56,054 - simpleExample - WARNING - warn message\n" +"2005-03-19 15:38:56,055 - simpleExample - ERROR - error message\n" +"2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message" #: ../../howto/logging.rst:711 msgid "" @@ -1284,7 +1402,6 @@ msgstr "" "プロパティを変えやすくなるという点で、Python コードの方法より少し優れていま" "す。" -#: ../../howto/logging.rst:715 msgid "" "The :func:`fileConfig` function takes a default parameter, " "``disable_existing_loggers``, which defaults to ``True`` for reasons of " @@ -1294,14 +1411,14 @@ msgid "" "configuration. Please refer to the reference documentation for more " "information, and specify ``False`` for this parameter if you wish." msgstr "" -":func:`fileConfig` 関数はデフォルト引数 ``disable_existing_loggers`` を取り、" -"後方互換性のためにデフォルト値は ``True`` になっています。\n" -"これはあなたの望むものかもしれませんし、そうでないかもしれません。というの" -"は、設定で明示的に指定したクラス (もしくはその親クラス) を除いて、 :func:" -"`fileConfig` が呼び出される前に存在した非ルートロガーを無効化してしまうからで" +":func:`fileConfig` 関数の ``disable_existing_loggers`` パラメータは、後方互換" +"性のためデフォルトで ``True`` です。\n" +"この設定が望ましいとは限りません。\n" +"そのロガー自身または祖先ロガーの名前が設定に明記されていない限り、:func:" +"`fileConfig` の呼び出し前から存在するルート以外のロガーが無効になるためで" "す。\n" -"より詳細なことはリファレンスを参照し、望むならこの引数に ``False`` を指定して" -"ください。" +"詳しくはリファレンスを参照し、必要に応じてこのパラメータを ``False`` にしてく" +"ださい。" #: ../../howto/logging.rst:723 msgid "" @@ -1334,7 +1451,6 @@ msgstr "" "るとき、パッケージ ``mypackage`` のモジュール ``mymodule`` で定義されたクラス" "に) ``mypackage.mymodule.MyHandler`` のどちらかが使えます。" -#: ../../howto/logging.rst:741 msgid "" "In Python 3.2, a new means of configuring logging has been introduced, using " "dictionaries to hold configuration information. This provides a superset of " @@ -1348,14 +1464,16 @@ msgid "" "can construct the dictionary in Python code, receive it in pickled form over " "a socket, or use whatever approach makes sense for your application." msgstr "" -"Python 3.2 では、ロギングを設定するのに新しく、辞書に設定情報を持たせる手段が" -"導入されました。これは、上で概説した設定ファイルに基づく方法による機能の上位" -"版を提供し、新しいアプリケーションやデプロイにはこのメソッドが推奨されます。" -"Python の辞書を使って設定情報を保持し、辞書は他の用途にも使えるので、設定の選" -"択肢が広がります。例えば、JSON フォーマットの設定ファイルや、YAML 処理機能が" -"使えれば YAML フォーマットのファイルを使って、設定辞書を構成できます。また、" -"もちろん、Python コードで辞書を構成し、ソケットを通して pickle 化された形式を" -"受け取るなど、アプリケーションで意味があるいかなるやり方でも使えます。" +"Python 3.2 では、設定情報を辞書に保持する新しいロギング設定方法が導入されまし" +"た。\n" +"これは上述の設定ファイル方式の機能をすべて含み、新しいアプリケーションやデプ" +"ロイに推奨される方法です。\n" +"設定を保持する Python の辞書にはさまざまな方法でデータを入れられるため、選択" +"肢が広がります。\n" +"例えば JSON 形式の設定ファイルや、YAML を処理できる環境なら YAML 形式のファイ" +"ルから設定辞書を構築できます。\n" +"Python コードで辞書を作ったり、ソケットで pickle 形式のデータを受け取ったりす" +"るなど、アプリケーションに適した方法を使えます。" #: ../../howto/logging.rst:753 msgid "" @@ -1364,7 +1482,6 @@ msgid "" msgstr "" "以下は、上記と同じ設定を辞書ベースの新しい手法で記載した YAML 形式の例です:" -#: ../../howto/logging.rst:756 msgid "" "version: 1\n" "formatters:\n" @@ -1385,6 +1502,24 @@ msgid "" " level: DEBUG\n" " handlers: [console]" msgstr "" +"version: 1\n" +"formatters:\n" +" simple:\n" +" format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'\n" +"handlers:\n" +" console:\n" +" class: logging.StreamHandler\n" +" level: DEBUG\n" +" formatter: simple\n" +" stream: ext://sys.stdout\n" +"loggers:\n" +" simpleExample:\n" +" level: DEBUG\n" +" handlers: [console]\n" +" propagate: no\n" +"root:\n" +" level: DEBUG\n" +" handlers: [console]" #: ../../howto/logging.rst:777 msgid "" @@ -1511,11 +1646,12 @@ msgstr "" "ます。ライブラリ *foo* によるすべてのロギングが、 'foo.x', 'foo.x.y' その他に" "該当する名前のロガーによってなされるなら::" -#: ../../howto/logging.rst:839 msgid "" "import logging\n" "logging.getLogger('foo').addHandler(logging.NullHandler())" msgstr "" +"import logging\n" +"logging.getLogger('foo').addHandler(logging.NullHandler())" #: ../../howto/logging.rst:842 msgid "" @@ -1542,7 +1678,6 @@ msgstr "" "するアプリケーション開発者が、ロギングの詳細度 (verbosity) やハンドラを望みの" "とおりに設定することを困難にしたり、不可能にしてしまいます。" -#: ../../howto/logging.rst:853 msgid "" "It is strongly advised that you *do not add any handlers other than* :class:" "`~logging.NullHandler` *to your library's loggers*. This is because the " @@ -1552,12 +1687,14 @@ msgid "" "handlers 'under the hood', you might well interfere with their ability to " "carry out unit tests and deliver logs which suit their requirements." msgstr "" -"*ライブラリのロガーには、* :class:`~logging.NullHandler` *以外のハンドラを追" -"加しない* ことを強く推奨します。これは、ハンドラの設定が、あなたのライブラリ" -"を使うアプリケーション開発者にも伝播するからです。アプリケーション開発者は、" -"対象となる聴衆と、そのアプリケーションにどのハンドラが最も適しているかを知っ" -"ています。ハンドラを 'ボンネットの中で' 加えてしまうと、ユニットテストをして" -"必要に応じたログを送達する能力に干渉しかねません。" +"*ライブラリのロガーには* :class:`~logging.NullHandler` *以外のハンドラを追加" +"しない* ことを強く推奨します。\n" +"ハンドラの設定は、そのライブラリを使うアプリケーション開発者が決めるものだか" +"らです。\n" +"アプリケーション開発者はログの読者や、アプリケーションに最適なハンドラを把握" +"しています。\n" +"ライブラリが内部で勝手にハンドラを追加すると、ユニットテストや、要件に合うロ" +"グの出力を妨げる可能性があります。" #: ../../howto/logging.rst:864 msgid "Logging Levels" @@ -1683,7 +1820,6 @@ msgstr "" msgid "Custom Levels" msgstr "カスタムレベル" -#: ../../howto/logging.rst:924 msgid "" "Defining your own levels is possible, but should not be necessary, as the " "existing levels have been chosen on the basis of practical experience. " @@ -1695,12 +1831,14 @@ msgid "" "difficult for the using developer to control and/or interpret, because a " "given numeric value might mean different things for different libraries." msgstr "" -"独自のレベルを定義することは可能ですが、必須ではなく、実経験上は既存のレベル" -"が選ばれます。しかし、カスタムレベルが必要だと確信するなら、レベルの定義には" -"多大な注意を払うべきで、*ライブラリの開発の際、カスタムレベルを定義することは" -"とても悪いアイデア* になり得ます。これは、複数のライブラリの作者がみな独自の" -"カスタムレベルを定義すると、与えられた数値が異なるライブラリで異なる意味にな" -"りえるため、開発者がこれを制御または解釈するのが難しくなるからです。" +"独自のレベルを定義することはできますが、既存のレベルは実際の経験に基づいて選" +"ばれているため、通常は必要ないはずです。\n" +"それでも必要だと確信する場合は、十分に注意してください。\n" +"特に *ライブラリで独自のレベルを定義するのは、非常によくない考え* かもしれま" +"せん。\n" +"複数のライブラリが独自のレベルを定義すると、同じ数値がライブラリごとに異なる" +"意味を持ち、併用する開発者がログを制御したり解釈したりするのが難しくなる可能" +"性があるためです。" #: ../../howto/logging.rst:937 msgid "Useful Handlers" @@ -1739,13 +1877,12 @@ msgstr "" "ん。代わりに、 :class:`~handlers.RotatingFileHandler` や :class:`~handlers." "TimedRotatingFileHandler` を使用してください。" -#: ../../howto/logging.rst:952 msgid "" ":class:`~handlers.RotatingFileHandler` instances send messages to disk " "files, with support for maximum log file sizes and log file rotation." msgstr "" -":class:`~handlers.RotatingFileHandler` インスタンスは、メッセージをディスク" -"ファイルに送り、最大ログファイル数とログファイル循環をサポートします。" +":class:`~handlers.RotatingFileHandler` インスタンスはメッセージをディスク上の" +"ファイルに送り、ログファイルの最大サイズとローテーションをサポートします。" #: ../../howto/logging.rst:955 msgid "" @@ -1940,7 +2077,6 @@ msgstr "" "ん。 :class:`Handler` サブクラスの :meth:`~Handler.emit` メソッドの間に起こる" "他の例外は、 :meth:`~Handler.handleError` メソッドに渡されます。" -#: ../../howto/logging.rst:1040 msgid "" "The default implementation of :meth:`~Handler.handleError` in :class:" "`Handler` checks to see if a module-level variable, :data:`raiseExceptions`, " @@ -1948,9 +2084,8 @@ msgid "" "the exception is swallowed." msgstr "" ":class:`Handler` の :meth:`~Handler.handleError` のデフォルト実装は、モジュー" -"ルレベル変数 :data:`raiseExceptions` が設定されているかどうかチェックします。" -"設定されているなら、トレースバックが :data:`sys.stderr` に出力されます。設定" -"されていないなら、例外は飲み込まれます。" +"ルレベルの変数 :data:`raiseExceptions` の値を調べます。\n" +"真ならトレースバックを :data:`sys.stderr` に表示し、偽なら例外を無視します。" #: ../../howto/logging.rst:1046 msgid "" @@ -2008,12 +2143,14 @@ msgstr "" "のメソッドは引数にレベルを取って、そのレベルの呼び出しに対して Logger がイベ" "ントを生成するなら true を返します。このようにコードを書くことができます::" -#: ../../howto/logging.rst:1079 msgid "" "if logger.isEnabledFor(logging.DEBUG):\n" " logger.debug('Message with %s, %s', expensive_func1(),\n" " expensive_func2())" msgstr "" +"if logger.isEnabledFor(logging.DEBUG):\n" +" logger.debug('Message with %s, %s', expensive_func1(),\n" +" expensive_func2())" #: ../../howto/logging.rst:1083 msgid "" @@ -2066,15 +2203,15 @@ msgstr "それを避ける方法" msgid "Information about where calls were made from." msgstr "呼び出しがどこから行われたかに関する情報。" -#: ../../howto/logging.rst:1103 msgid "" "Set ``logging._srcfile`` to ``None``. This avoids calling :func:`sys." "_getframe`, which may help to speed up your code in environments like PyPy " "(which can't speed up code that uses :func:`sys._getframe`)." msgstr "" -"``logging._srcfile`` を ``None`` にする。このことにより :func:`sys." -"_getframe` 呼び出しを避けることが出来、PyPy のような環境(:func:`sys." -"_getframe` の高速化が出来ない)において高速化の役に立ちます。" +"``logging._srcfile`` を ``None`` にする。\n" +":func:`sys._getframe` の呼び出しを避けられるため、それを使うコードを高速化で" +"きない PyPy などの環境で、高速化に役立つ可能性があります (:func:`sys." +"_getframe` を使うコードが対象です)。" #: ../../howto/logging.rst:1109 msgid "Threading information." diff --git a/howto/mro.po b/howto/mro.po index 10e752939..c0d569110 100644 --- a/howto/mro.po +++ b/howto/mro.po @@ -16,32 +16,31 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/mro.rst:4 msgid "The Python 2.3 Method Resolution Order" -msgstr "" +msgstr "Python 2.3 のメソッド解決順序" -#: ../../howto/mro.rst:8 msgid "" "This is a historical document, provided as an appendix to the official " "documentation. The Method Resolution Order discussed here was *introduced* " "in Python 2.3, but it is still used in later versions -- including Python 3." msgstr "" +"これは公式ドキュメントの付録として提供する歴史的な文書です。\n" +"ここで説明するメソッド解決順序は Python 2.3 で *導入* されましたが、Python 3 " +"を含む後のバージョンでも使われています。" -#: ../../howto/mro.rst:13 msgid "By `Michele Simionato `__." -msgstr "" +msgstr "著者: `Michele Simionato `__。" #: ../../howto/mro.rst:0 msgid "Abstract" msgstr "概要" -#: ../../howto/mro.rst:17 msgid "" "*This document is intended for Python programmers who want to understand the " "C3 Method Resolution Order used in Python 2.3. Although it is not intended " @@ -49,24 +48,30 @@ msgid "" "not aware of other publicly available documents with the same scope, " "therefore it should be useful.*" msgstr "" +"*この文書は、Python 2.3 で使われる C3 メソッド解決順序を理解したい Python プ" +"ログラマ向けです。\n" +"初心者向けではありませんが、詳しく解説した例を多数交えて学べるようにしていま" +"す。\n" +"同じ範囲を扱う公開文書を他に知らないので、役に立つはずです。*" -#: ../../howto/mro.rst:23 msgid "Disclaimer:" -msgstr "" +msgstr "免責事項:" -#: ../../howto/mro.rst:25 msgid "" "*I donate this document to the Python Software Foundation, under the Python " "2.3 license. As usual in these circumstances, I warn the reader that what " "follows* should *be correct, but I don't give any warranty. Use it at your " "own risk and peril!*" msgstr "" +"*この文書を Python 2.3 ライセンスの下で Python Software Foundation に寄贈しま" +"す。\n" +"このような場合の通例どおり、以下の内容は正しい* はず *ですが、保証はしないこ" +"とをお断りします。\n" +"ご自身の責任でご利用ください。*" -#: ../../howto/mro.rst:30 msgid "Acknowledgments:" -msgstr "" +msgstr "謝辞:" -#: ../../howto/mro.rst:32 msgid "" "*All the people of the Python mailing list who sent me their support. Paul " "Foley who pointed out various imprecisions and made me to add the part on " @@ -75,16 +80,20 @@ msgid "" "Rossum who enthusiastically added this document to the official Python 2.3 " "home-page.*" msgstr "" +"*Python メーリングリストで応援してくださった皆さんに感謝します。\n" +"Paul Foley は不正確な点を指摘し、局所優先順位についての説明を追加するきっかけ" +"をくれました。\n" +"David Goodger は reStructuredText での整形を、David Mertz は編集を手伝ってく" +"れました。\n" +"最後に、Guido van Rossum はこの文書を熱心に公式の Python 2.3 ホームページに加" +"えてくれました。*" -#: ../../howto/mro.rst:40 msgid "The beginning" -msgstr "" +msgstr "はじめに" -#: ../../howto/mro.rst:42 msgid "*Felix qui potuit rerum cognoscere causas* -- Virgilius" -msgstr "" +msgstr "*物事の原因を知ることができた者は幸いである* ― ウェルギリウス" -#: ../../howto/mro.rst:44 msgid "" "Everything started with a post by Samuele Pedroni to the Python development " "mailing list [#]_. In his post, Samuele showed that the Python 2.2 method " @@ -96,8 +105,16 @@ msgid "" "readable discussion of the C3 algorithm for Pythonistas who want to " "understand the reasons for the change." msgstr "" +"すべては Samuele Pedroni による Python 開発メーリングリストへの投稿 [#]_ から" +"始まりました。\n" +"Samuele は Python 2.2 のメソッド解決順序が単調でないことを示し、C3 メソッド解" +"決順序への置き換えを提案しました。\n" +"Guido が賛成したため、Python 2.3 は C3 を使っています。\n" +"C3 自体は Python とは無関係で、Dylan の開発者によって考案され、Lisp 利用者向" +"けの論文 [#]_ に記述されています。\n" +"この文書では、変更の理由を知りたい Python 利用者に向けて、C3 アルゴリズムをで" +"きるだけ読みやすく説明します。" -#: ../../howto/mro.rst:55 msgid "" "First of all, let me point out that what I am going to say only applies to " "the *new style classes* introduced in Python 2.2: *classic classes* " @@ -108,12 +125,20 @@ msgid "" "differs from the Python 2.2 method resolution order are so rare that no real " "breaking of code is expected. Therefore:" msgstr "" +"まず、これからの説明は Python 2.2 で導入された *新スタイルクラス* だけに当て" +"はまります。\n" +"*旧スタイルクラス* は、深さ優先で左から右に調べる従来のメソッド解決順序を維持" +"します。\n" +"したがって、旧スタイルクラスを使う既存のコードは壊れません。\n" +"Python 2.2 の新スタイルクラスを使うコードは、理屈の上では壊れる可能性がありま" +"す。\n" +"しかし、C3 と Python 2.2 のメソッド解決順序が異なる場合は極めてまれなので、実" +"際にコードが壊れることはないと考えられます。\n" +"つまり:" -#: ../../howto/mro.rst:64 msgid "*Don't be scared!*" -msgstr "" +msgstr "*怖がらなくて大丈夫です!*" -#: ../../howto/mro.rst:66 msgid "" "Moreover, unless you make strong use of multiple inheritance and you have " "non-trivial hierarchies, you don't need to understand the C3 algorithm, and " @@ -121,33 +146,40 @@ msgid "" "know how multiple inheritance works, then this paper is for you. The good " "news is that things are not as complicated as you might expect." msgstr "" +"また、多重継承を多用して複雑な階層を作っているのでなければ、C3 アルゴリズムを" +"理解する必要はなく、この文書は読み飛ばして構いません。\n" +"一方、多重継承の仕組みを本当に知りたいなら、この文書はあなたのためのもので" +"す。\n" +"うれしいことに、予想するほど複雑ではありません。" -#: ../../howto/mro.rst:73 msgid "Let me begin with some basic definitions." -msgstr "" +msgstr "まず、基本的な定義から始めます。" -#: ../../howto/mro.rst:75 msgid "" "Given a class C in a complicated multiple inheritance hierarchy, it is a non-" "trivial task to specify the order in which methods are overridden, i.e. to " "specify the order of the ancestors of C." msgstr "" +"複雑な多重継承の階層にあるクラス C について、メソッドのオーバーライドの順序、" +"つまり C の祖先の順序を定めるのは簡単ではありません。" -#: ../../howto/mro.rst:79 msgid "" "The list of the ancestors of a class C, including the class itself, ordered " "from the nearest ancestor to the furthest, is called the class precedence " "list or the *linearization* of C." msgstr "" +"クラス C 自身を含む祖先を、近いものから遠いものへ並べたリストを、クラス優先順" +"位リスト、または C の *線形化* と呼びます。" -#: ../../howto/mro.rst:83 msgid "" "The *Method Resolution Order* (MRO) is the set of rules that construct the " "linearization. In the Python literature, the idiom \"the MRO of C\" is also " "used as a synonymous for the linearization of the class C." msgstr "" +"*メソッド解決順序* (MRO) は、線形化を構築する規則の集まりです。\n" +"Python の文献では「C の MRO」という表現を、クラス C の線形化と同じ意味でも使" +"います。" -#: ../../howto/mro.rst:88 msgid "" "For instance, in the case of single inheritance hierarchy, if C is a " "subclass of C1, and C1 is a subclass of C2, then the linearization of C is " @@ -156,8 +188,11 @@ msgid "" "it is more difficult to construct a linearization that respects *local " "precedence ordering* and *monotonicity*." msgstr "" +"例えば単一継承で、C が C1 のサブクラス、C1 が C2 のサブクラスであれば、C の線" +"形化は単に [C, C1, C2] です。\n" +"しかし多重継承では、*局所優先順位* と *単調性* を満たす線形化の構築が難しくな" +"ります。" -#: ../../howto/mro.rst:96 msgid "" "I will discuss the local precedence ordering later, but I can give the " "definition of monotonicity here. A MRO is monotonic when the following is " @@ -167,26 +202,36 @@ msgid "" "potentially introducing very subtle bugs. Examples where this happens will " "be shown later." msgstr "" +"局所優先順位は後で説明しますが、単調性はここで定義できます。\n" +"次が成り立つ MRO は単調です。\n" +"*C の線形化で C1 が C2 より前にあれば、C のどのサブクラスの線形化でも C1 が " +"C2 より前にある。*\n" +"そうでなければ、新しいクラスを派生させるだけでメソッドの解決順序が変わり、非" +"常に分かりにくいバグを持ち込む可能性があります。\n" +"後でその例を示します。" -#: ../../howto/mro.rst:104 msgid "" "Not all classes admit a linearization. There are cases, in complicated " "hierarchies, where it is not possible to derive a class such that its " "linearization respects all the desired properties." msgstr "" +"すべてのクラスに線形化が存在するわけではありません。\n" +"複雑な階層では、必要な性質をすべて満たす線形化を持つクラスを派生できない場合" +"があります。" -#: ../../howto/mro.rst:108 msgid "Here I give an example of this situation. Consider the hierarchy" msgstr "" +"その例を示します。\n" +"次の階層を考えてください:" -#: ../../howto/mro.rst:116 msgid "" "which can be represented with the following inheritance graph, where I have " "denoted with O the ``object`` class, which is the beginning of any hierarchy " "for new style classes:" msgstr "" +"この階層は次の継承図で表せます。\n" +"O は、新スタイルクラスの階層の起点である ``object`` クラスを表します:" -#: ../../howto/mro.rst:120 msgid "" " -----------\n" "| |\n" @@ -199,110 +244,112 @@ msgid "" " \\ /\n" " ?" msgstr "" +" -----------\n" +"| |\n" +"| O |\n" +"| / \\ |\n" +" - X Y /\n" +" | / | /\n" +" | / |/\n" +" A B\n" +" \\ /\n" +" ?" -#: ../../howto/mro.rst:133 msgid "" "In this case, it is not possible to derive a new class C from A and B, since " "X precedes Y in A, but Y precedes X in B, therefore the method resolution " "order would be ambiguous in C." msgstr "" +"この場合、A と B から新しいクラス C を派生させることはできません。\n" +"A では X が Y に先行するのに、B では Y が X に先行するため、C のメソッド解決" +"順序が曖昧になるからです。" -#: ../../howto/mro.rst:137 msgid "" "Python 2.3 raises an exception in this situation (TypeError: MRO conflict " "among bases Y, X) forbidding the naive programmer from creating ambiguous " "hierarchies. Python 2.2 instead does not raise an exception, but chooses an " "*ad hoc* ordering (CABXYO in this case)." msgstr "" +"Python 2.3 はこの場合に例外 (TypeError: MRO conflict among bases Y, X) を送出" +"し、プログラマがうっかり曖昧な階層を作るのを防ぎます。\n" +"対して Python 2.2 は例外を送出せず、その場限りの順序 (この場合は CABXYO) を選" +"びます。" -#: ../../howto/mro.rst:143 msgid "The C3 Method Resolution Order" -msgstr "" +msgstr "C3 メソッド解決順序" -#: ../../howto/mro.rst:145 msgid "" "Let me introduce a few simple notations which will be useful for the " "following discussion. I will use the shortcut notation::" msgstr "" +"以降の説明に使う簡単な記法を導入します。\n" +"次の省略記法で、 ::" -#: ../../howto/mro.rst:148 msgid "C1 C2 ... CN" -msgstr "" +msgstr "C1 C2 ... CN" -#: ../../howto/mro.rst:150 msgid "to indicate the list of classes [C1, C2, ... , CN]." -msgstr "" +msgstr "クラスのリスト [C1, C2, ... , CN] を表します。" -#: ../../howto/mro.rst:152 msgid "The *head* of the list is its first element::" -msgstr "" +msgstr "リストの *head* は最初の要素です。 ::" -#: ../../howto/mro.rst:154 msgid "head = C1" -msgstr "" +msgstr "head = C1" -#: ../../howto/mro.rst:156 msgid "whereas the *tail* is the rest of the list::" -msgstr "" +msgstr "一方、*tail* はリストの残りの部分です。 ::" -#: ../../howto/mro.rst:158 msgid "tail = C2 ... CN." -msgstr "" +msgstr "tail = C2 ... CN." -#: ../../howto/mro.rst:160 msgid "I shall also use the notation::" -msgstr "" +msgstr "また、次の記法で、 ::" -#: ../../howto/mro.rst:162 msgid "C + (C1 C2 ... CN) = C C1 C2 ... CN" -msgstr "" +msgstr "C + (C1 C2 ... CN) = C C1 C2 ... CN" -#: ../../howto/mro.rst:164 msgid "to denote the sum of the lists [C] + [C1, C2, ... ,CN]." -msgstr "" +msgstr "リストの連結 [C] + [C1, C2, ... , CN] を表します。" -#: ../../howto/mro.rst:166 msgid "Now I can explain how the MRO works in Python 2.3." -msgstr "" +msgstr "これで Python 2.3 の MRO の仕組みを説明する準備ができました。" -#: ../../howto/mro.rst:168 msgid "" "Consider a class C in a multiple inheritance hierarchy, with C inheriting " "from the base classes B1, B2, ... , BN. We want to compute the " "linearization L[C] of the class C. The rule is the following:" msgstr "" +"多重継承の階層で、基底クラス B1、B2、...、BN を継承するクラス C を考えま" +"す。\n" +"クラス C の線形化 L[C] を求める規則は次のとおりです:" -#: ../../howto/mro.rst:173 msgid "" "*the linearization of C is the sum of C plus the merge of the linearizations " "of the parents and the list of the parents.*" msgstr "" +"*C の線形化は、C に、各親クラスの線形化と親クラスのリストをマージしたものを連" +"結して求めます。*" -#: ../../howto/mro.rst:176 msgid "In symbolic notation::" -msgstr "" +msgstr "記号で表すと次のとおりです。 ::" -#: ../../howto/mro.rst:178 msgid "L[C(B1 ... BN)] = C + merge(L[B1] ... L[BN], B1 ... BN)" -msgstr "" +msgstr "L[C(B1 ... BN)] = C + merge(L[B1] ... L[BN], B1 ... BN)" -#: ../../howto/mro.rst:180 msgid "" "In particular, if C is the ``object`` class, which has no parents, the " "linearization is trivial::" -msgstr "" +msgstr "特に C が親を持たない ``object`` クラスなら、線形化は単純です。 ::" -#: ../../howto/mro.rst:183 msgid "L[object] = object." -msgstr "" +msgstr "L[object] = object." -#: ../../howto/mro.rst:185 msgid "" "However, in general one has to compute the merge according to the following " "prescription:" -msgstr "" +msgstr "ただし、一般の場合は次の手順でマージを計算する必要があります:" -#: ../../howto/mro.rst:188 msgid "" "*take the head of the first list, i.e L[B1][0]; if this head is not in the " "tail of any of the other lists, then add it to the linearization of C and " @@ -312,44 +359,53 @@ msgid "" "In this case, it is impossible to construct the merge, Python 2.3 will " "refuse to create the class C and will raise an exception.*" msgstr "" +"*最初のリストの先頭、つまり L[B1][0] を取り出します。\n" +"この要素が他のどのリストの tail にも含まれていなければ、C の線形化に追加し、" +"マージ対象の各リストから取り除きます。\n" +"そうでなければ次のリストの先頭を調べ、条件を満たすならそれを選びます。\n" +"すべてのクラスを取り除くか、条件を満たす先頭要素が見つからなくなるまで繰り返" +"します。\n" +"後者の場合はマージを構築できないため、Python 2.3 はクラス C の作成を拒否して" +"例外を送出します。*" -#: ../../howto/mro.rst:197 msgid "" "This prescription ensures that the merge operation *preserves* the ordering, " "if the ordering can be preserved. On the other hand, if the order cannot be " "preserved (as in the example of serious order disagreement discussed above) " "then the merge cannot be computed." msgstr "" +"この手順は、順序を維持できる場合にマージ処理がその順序を *維持する* ことを保" +"証します。\n" +"逆に、先ほどの順序が矛盾する例のように維持できない場合は、マージを計算できま" +"せん。" -#: ../../howto/mro.rst:202 msgid "" "The computation of the merge is trivial if C has only one parent (single " "inheritance); in this case::" -msgstr "" +msgstr "C の親が一つだけ (単一継承) なら、マージの計算は単純です。 ::" -#: ../../howto/mro.rst:205 msgid "L[C(B)] = C + merge(L[B],B) = C + L[B]" -msgstr "" +msgstr "L[C(B)] = C + merge(L[B],B) = C + L[B]" -#: ../../howto/mro.rst:207 msgid "" "However, in the case of multiple inheritance things are more cumbersome and " "I don't expect you can understand the rule without a couple of examples ;-)" msgstr "" +"多重継承ではもう少し複雑です。\n" +"例をいくつか見ないと、この規則は理解しにくいでしょう ;-)" #: ../../howto/mro.rst:212 msgid "Examples" msgstr "使用例" -#: ../../howto/mro.rst:214 msgid "First example. Consider the following hierarchy:" msgstr "" +"最初の例です。\n" +"次の階層を考えます:" -#: ../../howto/mro.rst:224 msgid "In this case the inheritance graph can be drawn as:" -msgstr "" +msgstr "この場合、継承図は次のように描けます:" -#: ../../howto/mro.rst:226 msgid "" " 6\n" " ---\n" @@ -373,28 +429,48 @@ msgid "" "Level 0 0 | A | (more specialized)\n" " ---" msgstr "" +" 6\n" +" ---\n" +"Level 3 | O | (more general)\n" +" / --- \\\n" +" / | \\ |\n" +" / | \\ |\n" +" / | \\ |\n" +" --- --- --- |\n" +"Level 2 3 | D | 4| E | | F | 5 |\n" +" --- --- --- |\n" +" \\ \\ _ / | |\n" +" \\ / \\ _ | |\n" +" \\ / \\ | |\n" +" --- --- |\n" +"Level 1 1 | B | | C | 2 |\n" +" --- --- |\n" +" \\ / |\n" +" \\ / \\ /\n" +" ---\n" +"Level 0 0 | A | (more specialized)\n" +" ---" -#: ../../howto/mro.rst:251 msgid "The linearizations of O,D,E and F are trivial::" -msgstr "" +msgstr "O、D、E、F の線形化は単純です。 ::" -#: ../../howto/mro.rst:253 msgid "" "L[O] = O\n" "L[D] = D O\n" "L[E] = E O\n" "L[F] = F O" msgstr "" +"L[O] = O\n" +"L[D] = D O\n" +"L[E] = E O\n" +"L[F] = F O" -#: ../../howto/mro.rst:258 msgid "The linearization of B can be computed as::" -msgstr "" +msgstr "B の線形化は次のように計算できます。 ::" -#: ../../howto/mro.rst:260 msgid "L[B] = B + merge(DO, EO, DE)" -msgstr "" +msgstr "L[B] = B + merge(DO, EO, DE)" -#: ../../howto/mro.rst:262 msgid "" "We see that D is a good head, therefore we take it and we are reduced to " "compute ``merge(O,EO,E)``. Now O is not a good head, since it is in the " @@ -402,28 +478,32 @@ msgid "" "the next sequence. Then we see that E is a good head; we take it and we are " "reduced to compute ``merge(O,O)`` which gives O. Therefore::" msgstr "" +"D は先頭要素の条件を満たすので選び、残りは ``merge(O,EO,E)`` になります。\n" +"次の O は列 EO の tail に含まれるため、条件を満たしません。\n" +"この場合は次の列を調べます。\n" +"E は条件を満たすので選び、残りの ``merge(O,O)`` から O が得られます。\n" +"したがって次のようになります。 ::" -#: ../../howto/mro.rst:268 msgid "L[B] = B D E O" -msgstr "" +msgstr "L[B] = B D E O" -#: ../../howto/mro.rst:270 msgid "Using the same procedure one finds::" -msgstr "" +msgstr "同じ手順で次が求まります。 ::" -#: ../../howto/mro.rst:272 msgid "" "L[C] = C + merge(DO,FO,DF)\n" " = C + D + merge(O,FO,F)\n" " = C + D + F + merge(O,O)\n" " = C D F O" msgstr "" +"L[C] = C + merge(DO,FO,DF)\n" +" = C + D + merge(O,FO,F)\n" +" = C + D + F + merge(O,O)\n" +" = C D F O" -#: ../../howto/mro.rst:277 msgid "Now we can compute::" -msgstr "" +msgstr "これで次を計算できます。 ::" -#: ../../howto/mro.rst:279 msgid "" "L[A] = A + merge(BDEO,CDFO,BC)\n" " = A + B + merge(DEO,CDFO,C)\n" @@ -433,29 +513,37 @@ msgid "" " = A + B + C + D + E + F + merge(O,O)\n" " = A B C D E F O" msgstr "" +"L[A] = A + merge(BDEO,CDFO,BC)\n" +" = A + B + merge(DEO,CDFO,C)\n" +" = A + B + C + merge(DEO,DFO)\n" +" = A + B + C + D + merge(EO,FO)\n" +" = A + B + C + D + E + merge(O,FO)\n" +" = A + B + C + D + E + F + merge(O,O)\n" +" = A B C D E F O" -#: ../../howto/mro.rst:287 msgid "" "In this example, the linearization is ordered in a pretty nice way according " "to the inheritance level, in the sense that lower levels (i.e. more " "specialized classes) have higher precedence (see the inheritance graph). " "However, this is not the general case." msgstr "" +"この例の線形化は、継承の階層にきれいに沿っています。\n" +"低い階層、つまり特化したクラスほど優先されるという意味です (継承図を参照)。\n" +"ただし、常にそうなるわけではありません。" -#: ../../howto/mro.rst:292 msgid "" "I leave as an exercise for the reader to compute the linearization for my " "second example:" -msgstr "" +msgstr "二つ目の例の線形化は、読者の練習問題とします:" -#: ../../howto/mro.rst:303 msgid "" "The only difference with the previous example is the change B(D,E) --> B(E," "D); however even such a little modification completely changes the ordering " "of the hierarchy:" msgstr "" +"前の例との違いは B(D,E) を B(E,D) に変えただけです。\n" +"しかし、この小さな変更でも階層の順序は大きく変わります:" -#: ../../howto/mro.rst:307 msgid "" " 6\n" " ---\n" @@ -479,27 +567,53 @@ msgid "" "Level 0 0 | A |\n" " ---" msgstr "" +" 6\n" +" ---\n" +"Level 3 | O |\n" +" / --- \\\n" +" / | \\\n" +" / | \\\n" +" / | \\\n" +" --- --- ---\n" +"Level 2 2 | E | 4 | D | | F | 5\n" +" --- --- ---\n" +" \\ / \\ /\n" +" \\ / \\ /\n" +" \\ / \\ /\n" +" --- ---\n" +"Level 1 1 | B | | C | 3\n" +" --- ---\n" +" \\ /\n" +" \\ /\n" +" ---\n" +"Level 0 0 | A |\n" +" ---" -#: ../../howto/mro.rst:332 msgid "" "Notice that the class E, which is in the second level of the hierarchy, " "precedes the class C, which is in the first level of the hierarchy, i.e. E " "is more specialized than C, even if it is in a higher level." msgstr "" +"階層のレベル 2 にある E が、レベル 1 にある C より先行することに注目してくだ" +"さい。\n" +"つまり、E は高い階層にあるのに、C より特化したものとして扱われます。" -#: ../../howto/mro.rst:336 msgid "" "A lazy programmer can obtain the MRO directly from Python 2.2, since in this " "case it coincides with the Python 2.3 linearization. It is enough to invoke " "the :meth:`~type.mro` method of class A:" msgstr "" +"計算を省きたいプログラマは、Python 2.2 で MRO を直接取得できます。\n" +"この場合は Python 2.3 の線形化と一致するためです。\n" +"クラス A の :meth:`~type.mro` メソッドを呼び出すだけです:" -#: ../../howto/mro.rst:345 msgid "" "Finally, let me consider the example discussed in the first section, " "involving a serious order disagreement. In this case, it is straightforward " "to compute the linearizations of O, X, Y, A and B:" msgstr "" +"最後に、最初の節で扱った、順序に重大な矛盾がある例を考えます。\n" +"O、X、Y、A、B の線形化は簡単に計算できます:" #: ../../howto/mro.rst:349 msgid "" @@ -510,50 +624,56 @@ msgid "" "L[B] = B Y X O" msgstr "" -#: ../../howto/mro.rst:357 msgid "" "However, it is impossible to compute the linearization for a class C that " "inherits from A and B::" -msgstr "" +msgstr "しかし A と B を継承するクラス C の線形化は計算できません。 ::" -#: ../../howto/mro.rst:360 msgid "" "L[C] = C + merge(AXYO, BYXO, AB)\n" " = C + A + merge(XYO, BYXO, B)\n" " = C + A + B + merge(XYO, YXO)" msgstr "" +"L[C] = C + merge(AXYO, BYXO, AB)\n" +" = C + A + merge(XYO, BYXO, B)\n" +" = C + A + B + merge(XYO, YXO)" -#: ../../howto/mro.rst:364 msgid "" "At this point we cannot merge the lists XYO and YXO, since X is in the tail " "of YXO whereas Y is in the tail of XYO: therefore there are no good heads " "and the C3 algorithm stops. Python 2.3 raises an error and refuses to " "create the class C." msgstr "" +"この段階で XYO と YXO をマージすることはできません。\n" +"X は YXO の tail にあり、Y は XYO の tail にあるため、条件を満たす先頭要素が" +"ないからです。\n" +"C3 アルゴリズムはここで停止し、Python 2.3 はエラーを送出してクラス C の作成を" +"拒否します。" -#: ../../howto/mro.rst:370 msgid "Bad Method Resolution Orders" -msgstr "" +msgstr "問題のあるメソッド解決順序" -#: ../../howto/mro.rst:372 msgid "" "A MRO is *bad* when it breaks such fundamental properties as local " "precedence ordering and monotonicity. In this section, I will show that " "both the MRO for classic classes and the MRO for new style classes in Python " "2.2 are bad." msgstr "" +"局所優先順位や単調性といった基本的な性質を満たさない MRO は、*問題がある* と" +"いえます。\n" +"この節では、旧スタイルクラスの MRO と Python 2.2 の新スタイルクラスの MRO " +"が、どちらも問題を持つことを示します。" -#: ../../howto/mro.rst:377 msgid "" "It is easier to start with the local precedence ordering. Consider the " "following example:" msgstr "" +"まずは簡単な局所優先順位から始めます。\n" +"次の例を考えてください:" -#: ../../howto/mro.rst:384 msgid "with inheritance diagram" -msgstr "" +msgstr "継承図は次のとおりです:" -#: ../../howto/mro.rst:386 msgid "" " O\n" " |\n" @@ -565,26 +685,38 @@ msgid "" "\n" " (buy eggs or spam ?)" msgstr "" +" O\n" +" |\n" +"(buy spam) F\n" +" | \\\n" +" | E (buy eggs)\n" +" | /\n" +" G\n" +"\n" +" (buy eggs or spam ?)" -#: ../../howto/mro.rst:399 msgid "" "We see that class G inherits from F and E, with F *before* E: therefore we " "would expect the attribute *G.remember2buy* to be inherited by *F." "remember2buy* and not by *E.remember2buy*: nevertheless Python 2.2 gives" msgstr "" +"G は F、E の順に継承し、F が E より *前* にあります。\n" +"したがって *G.remember2buy* は *E.remember2buy* ではなく *F.remember2buy* を" +"継承すると期待するでしょう。\n" +"しかし Python 2.2 の結果は次のとおりです:" -#: ../../howto/mro.rst:407 msgid "" "This is a breaking of local precedence ordering since the order in the local " "precedence list, i.e. the list of the parents of G, is not preserved in the " "Python 2.2 linearization of G::" msgstr "" +"これは局所優先順位に反しています。\n" +"局所優先順位リスト、つまり G の親のリストの順序が、Python 2.2 による G の線形" +"化では維持されていません。 ::" -#: ../../howto/mro.rst:411 msgid "L[G,P22]= G E F object # F *follows* E" -msgstr "" +msgstr "L[G,P22]= G E F object # F *follows* E" -#: ../../howto/mro.rst:413 msgid "" "One could argue that the reason why F follows E in the Python 2.2 " "linearization is that F is less specialized than E, since F is the " @@ -592,13 +724,15 @@ msgid "" "quite non-intuitive and error prone. This is particularly true since it is " "a different from old style classes:" msgstr "" +"Python 2.2 の線形化で F が E の後になるのは、F が E のスーパークラスで、E よ" +"り特化していないからだという説明はできるでしょう。\n" +"それでも局所優先順位が崩れるのは直感に反し、間違いを招きやすくなります。\n" +"旧スタイルクラスとは動作が異なるため、なおさらです:" -#: ../../howto/mro.rst:425 msgid "" "In this case the MRO is GFEF and the local precedence ordering is preserved." -msgstr "" +msgstr "この場合の MRO は GFEF で、局所優先順位は維持されます。" -#: ../../howto/mro.rst:428 msgid "" "As a general rule, hierarchies such as the previous one should be avoided, " "since it is unclear if F should override E or vice-versa. Python 2.3 solves " @@ -606,16 +740,19 @@ msgid "" "effectively stopping the programmer from generating ambiguous hierarchies. " "The reason for that is that the C3 algorithm fails when the merge::" msgstr "" +"一般に、前のような階層は避けるべきです。\n" +"F が E をオーバーライドすべきか、その逆なのかが不明確だからです。\n" +"Python 2.3 はクラス G の作成時に例外を送出することで、この曖昧さを解消し、曖" +"昧な階層の生成を防ぎます。\n" +"C3 アルゴリズムが失敗するのは、次のマージを計算できないためです。 ::" -#: ../../howto/mro.rst:435 msgid "merge(FO,EFO,FE)" -msgstr "" +msgstr "merge(FO,EFO,FE)" -#: ../../howto/mro.rst:437 msgid "" "cannot be computed, because F is in the tail of EFO and E is in the tail of " "FE." -msgstr "" +msgstr "F は EFO の tail にあり、E は FE の tail にあるので、計算できません。" #: ../../howto/mro.rst:440 msgid "" @@ -624,7 +761,6 @@ msgid "" "the MRO is GEF without any doubt." msgstr "" -#: ../../howto/mro.rst:444 msgid "" " O\n" " |\n" @@ -635,57 +771,67 @@ msgid "" " G\n" " (eggs, no doubt)" msgstr "" +" O\n" +" |\n" +" F (spam)\n" +" / |\n" +"(eggs) E |\n" +" \\ |\n" +" G\n" +" (eggs, no doubt)" -#: ../../howto/mro.rst:456 msgid "" "Python 2.3 forces the programmer to write good hierarchies (or, at least, " "less error-prone ones)." msgstr "" +"Python 2.3 は、プログラマがよい階層、少なくとも間違いを招きにくい階層を書くよ" +"うに促します。" -#: ../../howto/mro.rst:459 msgid "" "On a related note, let me point out that the Python 2.3 algorithm is smart " "enough to recognize obvious mistakes, as the duplication of classes in the " "list of parents:" msgstr "" +"関連する点として、Python 2.3 のアルゴリズムは、親のリストに同じクラスを重複し" +"て指定するような明らかな間違いも検出します:" -#: ../../howto/mro.rst:469 msgid "" "Python 2.2 (both for classic classes and new style classes) in this " "situation, would not raise any exception." msgstr "" +"Python 2.2 では、旧スタイルクラスでも新スタイルクラスでも、この場合に例外は送" +"出されません。" -#: ../../howto/mro.rst:472 msgid "" "Finally, I would like to point out two lessons we have learned from this " "example:" -msgstr "" +msgstr "最後に、この例から分かる二つの点を挙げます:" -#: ../../howto/mro.rst:475 msgid "" "despite the name, the MRO determines the resolution order of attributes, not " "only of methods;" -msgstr "" +msgstr "名前とは裏腹に、MRO はメソッドだけでなく属性の解決順序も決めます。" -#: ../../howto/mro.rst:478 msgid "" "the default food for Pythonistas is spam ! (but you already knew that ;-)" -msgstr "" +msgstr "Python 利用者の定番の食べ物はスパムです! (これはご存じでしたね ;-)" -#: ../../howto/mro.rst:481 msgid "" "Having discussed the issue of local precedence ordering, let me now consider " "the issue of monotonicity. My goal is to show that neither the MRO for " "classic classes nor that for Python 2.2 new style classes is monotonic." msgstr "" +"局所優先順位に続いて、単調性を考えましょう。\n" +"旧スタイルクラスの MRO も Python 2.2 の新スタイルクラスの MRO も単調でないこ" +"とを示します。" -#: ../../howto/mro.rst:486 msgid "" "To prove that the MRO for classic classes is non-monotonic is rather " "trivial, it is enough to look at the diamond diagram:" msgstr "" +"旧スタイルクラスの MRO が単調でないことは、次のダイヤモンド型の継承図を見れば" +"簡単に分かります:" -#: ../../howto/mro.rst:489 msgid "" " C\n" " / \\\n" @@ -695,50 +841,63 @@ msgid "" " \\ /\n" " D" msgstr "" +" C\n" +" / \\\n" +" / \\\n" +"A B\n" +" \\ /\n" +" \\ /\n" +" D" -#: ../../howto/mro.rst:500 msgid "One easily discerns the inconsistency::" -msgstr "" +msgstr "不整合はすぐに見つかります。 ::" -#: ../../howto/mro.rst:502 msgid "" "L[B,P21] = B C # B precedes C : B's methods win\n" "L[D,P21] = D A C B C # B follows C : C's methods win!" msgstr "" +"L[B,P21] = B C # B precedes C : B's methods win\n" +"L[D,P21] = D A C B C # B follows C : C's methods win!" -#: ../../howto/mro.rst:505 msgid "" "On the other hand, there are no problems with the Python 2.2 and 2.3 MROs, " "they give both::" msgstr "" +"一方、Python 2.2 と 2.3 の MRO にはこの問題はなく、どちらも次の結果になりま" +"す。 ::" -#: ../../howto/mro.rst:508 msgid "L[D] = D A B C" -msgstr "" +msgstr "L[D] = D A B C" -#: ../../howto/mro.rst:510 msgid "" "Guido points out in his essay [#]_ that the classic MRO is not so bad in " "practice, since one can typically avoids diamonds for classic classes. But " "all new style classes inherit from ``object``, therefore diamonds are " "unavoidable and inconsistencies shows up in every multiple inheritance graph." msgstr "" +"Guido は論考 [#]_ で、旧スタイルクラスでは通常ダイヤモンド型の継承を避けられ" +"るため、その MRO は実際にはそれほど悪くないと指摘しています。\n" +"しかし、新スタイルクラスはすべて ``object`` を継承するため、ダイヤモンドを避" +"けられず、どの多重継承の図にも不整合が現れます。" -#: ../../howto/mro.rst:516 msgid "" "The MRO of Python 2.2 makes breaking monotonicity difficult, but not " "impossible. The following example, originally provided by Samuele Pedroni, " "shows that the MRO of Python 2.2 is non-monotonic:" msgstr "" +"Python 2.2 の MRO は単調性を破りにくくしていますが、不可能にしたわけではあり" +"ません。\n" +"Samuele Pedroni が最初に示した次の例は、Python 2.2 の MRO が単調でないことを" +"示します:" -#: ../../howto/mro.rst:530 msgid "" "Here are the linearizations according to the C3 MRO (the reader should " "verify these linearizations as an exercise and draw the inheritance " "diagram ;-) ::" msgstr "" +"C3 MRO による線形化は次のとおりです。\n" +"練習として結果を確かめ、継承図を描いてみてください ;-) ::" -#: ../../howto/mro.rst:534 msgid "" "L[A] = A O\n" "L[B] = B O\n" @@ -750,18 +909,26 @@ msgid "" "L[K3]= K3 D A O\n" "L[Z] = Z K1 K2 K3 D A B C E O" msgstr "" +"L[A] = A O\n" +"L[B] = B O\n" +"L[C] = C O\n" +"L[D] = D O\n" +"L[E] = E O\n" +"L[K1]= K1 A B C O\n" +"L[K2]= K2 D B E O\n" +"L[K3]= K3 D A O\n" +"L[Z] = Z K1 K2 K3 D A B C E O" -#: ../../howto/mro.rst:544 msgid "" "Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1, K2 " "and K3, but a different linearization for Z::" msgstr "" +"Python 2.2 は A、B、C、D、E、K1、K2、K3 について同じ線形化を返しますが、Z だ" +"けは異なります。 ::" -#: ../../howto/mro.rst:547 msgid "L[Z,P22] = Z K1 K3 A K2 D B C E O" -msgstr "" +msgstr "L[Z,P22] = Z K1 K3 A K2 D B C E O" -#: ../../howto/mro.rst:549 msgid "" "It is clear that this linearization is *wrong*, since A comes before D " "whereas in the linearization of K3 A comes *after* D. In other words, in K3 " @@ -773,12 +940,20 @@ msgid "" "the linearization of Z K2 *follows* K3. These problems explain why the 2.2 " "rule has been dismissed in favor of the C3 rule." msgstr "" +"この線形化は明らかに *間違っています*。\n" +"K3 の線形化では A が D の *後* にあるのに、ここでは A が D より前だからで" +"す。\n" +"つまり K3 では D から継承したメソッドが A のものをオーバーライドするのに、K3 " +"のサブクラスである Z では A のメソッドが D のものをオーバーライドします。\n" +"これは単調性への違反です。\n" +"さらに Python 2.2 による Z の線形化は、局所優先順位にも反します。\n" +"Z の局所優先順位リストは [K1, K2, K3] で K2 が K3 より前なのに、線形化では " +"K2 が K3 の *後* にあるからです。\n" +"こうした問題のため、2.2 の規則は C3 に置き換えられました。" -#: ../../howto/mro.rst:561 msgid "The end" -msgstr "" +msgstr "おわりに" -#: ../../howto/mro.rst:563 msgid "" "This section is for the impatient reader, who skipped all the previous " "sections and jumped immediately to the end. This section is for the lazy " @@ -791,8 +966,18 @@ msgid "" "the last line to play with the various examples I have discussed in this " "paper.::" msgstr "" +"この節は、前の節をすべて飛ばしてすぐ最後に来た、せっかちな読者のためのもので" +"す。\n" +"また、頭を働かせたくなかった怠け者のプログラマのためでもあります。\n" +"そして多少の傲慢さを持つプログラマのためでもあります。\n" +"そうでなければ、多重継承の階層における C3 メソッド解決順序の文書など読まない" +"でしょう ;-)\n" +"この三つの美徳をすべて兼ね備えていれば (別々では *だめです*)、ご褒美に値しま" +"す。\n" +"ご褒美は、頭を悩ませずに 2.3 の MRO を計算できる、短い Python 2.2 スクリプト" +"です。\n" +"最後の行を変えるだけで、この文書のさまざまな例を試せます。 ::" -#: ../../howto/mro.rst:574 msgid "" "#\n" "\n" @@ -877,34 +1062,116 @@ msgid "" "\n" "#" msgstr "" +"#\n" +"\n" +"\"\"\"Samuele Pedroni による C3 アルゴリズム (筆者が読みやすく変更)。\"\"\"\n" +"\n" +"class __metaclass__(type):\n" +" \"All classes are metamagically modified to be nicely printed\"\n" +" __repr__ = lambda cls: cls.__name__\n" +"\n" +"class ex_2:\n" +" \"Serious order disagreement\" #From Guido\n" +" class O: pass\n" +" class X(O): pass\n" +" class Y(O): pass\n" +" class A(X,Y): pass\n" +" class B(Y,X): pass\n" +" try:\n" +" class Z(A,B): pass #creates Z(A,B) in Python 2.2\n" +" except TypeError:\n" +" pass # Z(A,B) cannot be created in Python 2.3\n" +"\n" +"class ex_5:\n" +" \"My first example\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(D,E): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_6:\n" +" \"My second example\"\n" +" class O: pass\n" +" class F(O): pass\n" +" class E(O): pass\n" +" class D(O): pass\n" +" class C(D,F): pass\n" +" class B(E,D): pass\n" +" class A(B,C): pass\n" +"\n" +"class ex_9:\n" +" \"Difference between Python 2.2 MRO and C3\" #From Samuele\n" +" class O: pass\n" +" class A(O): pass\n" +" class B(O): pass\n" +" class C(O): pass\n" +" class D(O): pass\n" +" class E(O): pass\n" +" class K1(A,B,C): pass\n" +" class K2(D,B,E): pass\n" +" class K3(D,A): pass\n" +" class Z(K1,K2,K3): pass\n" +"\n" +"def merge(seqs):\n" +" print '\\n\\nCPL[%s]=%s' % (seqs[0][0],seqs),\n" +" res = []; i=0\n" +" while 1:\n" +" nonemptyseqs=[seq for seq in seqs if seq]\n" +" if not nonemptyseqs: return res\n" +" i+=1; print '\\n',i,'round: candidates...',\n" +" for seq in nonemptyseqs: # find merge candidates among seq heads\n" +" cand = seq[0]; print ' ',cand,\n" +" nothead=[s for s in nonemptyseqs if cand in s[1:]]\n" +" if nothead: cand=None #reject candidate\n" +" else: break\n" +" if not cand: raise \"Inconsistent hierarchy\"\n" +" res.append(cand)\n" +" for seq in nonemptyseqs: # remove cand\n" +" if seq[0] == cand: del seq[0]\n" +"\n" +"def mro(C):\n" +" \"Compute the class precedence list (mro) according to C3\"\n" +" return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])\n" +"\n" +"def print_mro(C):\n" +" print '\\nMRO[%s]=%s' % (C,mro(C))\n" +" print '\\nP22 MRO[%s]=%s' % (C,C.mro())\n" +"\n" +"print_mro(ex_9.Z)\n" +"\n" +"#" -#: ../../howto/mro.rst:656 msgid "That's all folks," -msgstr "" +msgstr "これでおしまいです。" -#: ../../howto/mro.rst:658 msgid "enjoy !" -msgstr "" +msgstr "楽しんでください!" -#: ../../howto/mro.rst:662 msgid "Resources" -msgstr "" +msgstr "参考資料" -#: ../../howto/mro.rst:664 msgid "" "The thread on python-dev started by Samuele Pedroni: https://mail.python.org/" "pipermail/python-dev/2002-October/029035.html" msgstr "" +"Samuele Pedroni が始めた python-dev のスレッド: https://mail.python.org/" +"pipermail/python-dev/2002-October/029035.html" -#: ../../howto/mro.rst:667 msgid "" "The paper *A Monotonic Superclass Linearization for Dylan*: https://doi." "org/10.1145/236337.236343" msgstr "" +"論文 *A Monotonic Superclass Linearization for Dylan*: https://doi." +"org/10.1145/236337.236343" -#: ../../howto/mro.rst:670 msgid "" "Guido van Rossum's essay, *Unifying types and classes in Python 2.2*: " "https://web.archive.org/web/20140210194412/http://www.python.org/download/" "releases/2.2.2/descrintro" msgstr "" +"Guido van Rossum の論考 *Unifying types and classes in Python 2.2*: https://" +"web.archive.org/web/20140210194412/http://www.python.org/download/" +"releases/2.2.2/descrintro" diff --git a/howto/perf_profiling.po b/howto/perf_profiling.po index f8318c882..e66eec66b 100644 --- a/howto/perf_profiling.po +++ b/howto/perf_profiling.po @@ -12,17 +12,15 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/perf_profiling.rst:7 msgid "Python support for the ``perf map`` compatible profilers" -msgstr "" +msgstr "``perf map`` 対応プロファイラのための Python のサポート" -#: ../../howto/perf_profiling.rst:9 msgid "" "`The Linux perf profiler `_ and `samply " "`_ are powerful tools that allow you to " @@ -30,8 +28,11 @@ msgid "" "Both tools have vibrant ecosystems that aid with the analysis of the data " "they produce." msgstr "" +"`Linux の perf プロファイラ `_ と `samply " +"`_ は、アプリケーションをプロファイリング" +"して性能の情報を得るための強力なツールです。\n" +"どちらも、生成したデータの分析を助けるツール群が活発に開発されています。" -#: ../../howto/perf_profiling.rst:14 msgid "" "The main problem with using these profilers with Python applications is that " "they only get information about native symbols, that is, the names of " @@ -39,8 +40,10 @@ msgid "" "names of Python functions in your code will not appear in the profiler " "output." msgstr "" +"これらを Python アプリケーションに使う際の主な問題は、C で書かれた関数や手続" +"きの名前、つまりネイティブシンボルの情報しか取得できないことです。\n" +"そのため、Python コードの関数名やファイル名がプロファイラの出力に現れません。" -#: ../../howto/perf_profiling.rst:19 msgid "" "Since Python 3.12, the interpreter can run in a special mode that allows " "Python functions to appear in the output of compatible profilers. When this " @@ -49,8 +52,13 @@ msgid "" "will teach the profiler the relationship between this piece of code and the " "associated Python function using :doc:`perf map files <../c-api/perfmaps>`." msgstr "" +"Python 3.12 以降では、対応するプロファイラの出力に Python 関数を表示するため" +"の特別なモードでインタープリタを実行できます。\n" +"このモードでは、各 Python 関数の実行前に、その場でコンパイルした小さなコード" +"片を挿入します。\n" +"そして :doc:`perf map ファイル <../c-api/perfmaps>` を使い、そのコード片と " +"Python 関数の対応をプロファイラに伝えます。" -#: ../../howto/perf_profiling.rst:28 msgid "" "Support for profiling is available on Linux and macOS on select " "architectures. Perf is available on Linux, while samply can be used on both " @@ -59,12 +67,17 @@ msgid "" "of ``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` to see if your system " "is supported." msgstr "" +"このプロファイリング機能は、Linux と macOS の一部のアーキテクチャで利用できま" +"す。\n" +"perf は Linux で、samply は Linux と macOS の両方で使えます。\n" +"macOS での samply 対応は Python 3.15 からです。\n" +"お使いのシステムが対応しているかは、ビルド時の ``configure`` の出力、または " +"``python -m sysconfig | grep HAVE_PERF_TRAMPOLINE`` の出力で確認してくださ" +"い。" -#: ../../howto/perf_profiling.rst:35 msgid "For example, consider the following script:" -msgstr "" +msgstr "例えば、次のスクリプトを考えます:" -#: ../../howto/perf_profiling.rst:37 msgid "" "def foo(n):\n" " result = 0\n" @@ -81,20 +94,32 @@ msgid "" "if __name__ == \"__main__\":\n" " baz(1000000)" msgstr "" +"def foo(n):\n" +" result = 0\n" +" for _ in range(n):\n" +" result += 1\n" +" return result\n" +"\n" +"def bar(n):\n" +" foo(n)\n" +"\n" +"def baz(n):\n" +" bar(n)\n" +"\n" +"if __name__ == \"__main__\":\n" +" baz(1000000)" -#: ../../howto/perf_profiling.rst:54 msgid "We can run ``perf`` to sample CPU stack traces at 9999 hertz::" msgstr "" +"``perf`` を実行して、CPU のスタックトレースを 9999 Hz でサンプリングできま" +"す。 ::" -#: ../../howto/perf_profiling.rst:56 msgid "$ perf record -F 9999 -g -o perf.data python my_script.py" -msgstr "" +msgstr "$ perf record -F 9999 -g -o perf.data python my_script.py" -#: ../../howto/perf_profiling.rst:58 msgid "Then we can use ``perf report`` to analyze the data:" -msgstr "" +msgstr "続いて ``perf report`` でデータを分析します:" -#: ../../howto/perf_profiling.rst:60 msgid "" "$ perf report --stdio -n -g\n" "\n" @@ -149,8 +174,59 @@ msgid "" "| | |--2.97%--_PyObject_Malloc\n" "..." msgstr "" +"$ perf report --stdio -n -g\n" +"\n" +"# Children Self Samples Command Shared Object Symbol\n" +"# ........ ........ ............ .......... .................. ..........................................\n" +"#\n" +" 91.08% 0.00% 0 python.exe python.exe [.] " +"_start\n" +" |\n" +" ---_start\n" +" |\n" +" --90.71%--__libc_start_main\n" +" Py_BytesMain\n" +" |\n" +" |--56.88%--pymain_run_python.constprop.0\n" +" | |\n" +" | |--56.13%--_PyRun_AnyFileObject\n" +" | | _PyRun_SimpleFileObject\n" +" | | |\n" +" | | |--55.02%--run_mod\n" +" | | | |\n" +" | | | --54.65%--" +"PyEval_EvalCode\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | |\n" +" | | | " +"|--51.67%--_PyEval_EvalFrameDefault\n" +" | | | " +"| |\n" +" | | | " +"| |--11.52%--_PyCompactLong_Add\n" +" | | | " +"| | |\n" +" | | | " +"| | |--2.97%--_PyObject_Malloc\n" +"..." -#: ../../howto/perf_profiling.rst:99 msgid "" "As you can see, the Python functions are not shown in the output, only " "``_PyEval_EvalFrameDefault`` (the function that evaluates the Python " @@ -158,13 +234,16 @@ msgid "" "functions use the same C function to evaluate bytecode so we cannot know " "which Python function corresponds to which bytecode-evaluating function." msgstr "" +"このように、Python 関数は出力に現れず、Python バイトコードを評価する関数 " +"``_PyEval_EvalFrameDefault`` だけが表示されます。\n" +"すべての Python 関数が同じ C 関数でバイトコードを評価するため、これだけではど" +"の Python 関数に対応する評価処理か分からず、あまり役に立ちません。" -#: ../../howto/perf_profiling.rst:104 msgid "" "Instead, if we run the same experiment with ``perf`` support enabled we get:" msgstr "" +"一方、``perf`` サポートを有効にして同じ実験を行うと、次のようになります:" -#: ../../howto/perf_profiling.rst:106 msgid "" "$ perf report --stdio -n -g\n" "\n" @@ -226,38 +305,100 @@ msgid "" " | | | " "| | |--3.26%--_PyObject_Malloc" msgstr "" +"$ perf report --stdio -n -g\n" +"\n" +"# Children Self Samples Command Shared Object Symbol\n" +"# ........ ........ ............ .......... .................. .....................................................................\n" +"#\n" +" 90.58% 0.36% 1 python.exe python.exe [.] " +"_start\n" +" |\n" +" ---_start\n" +" |\n" +" --89.86%--__libc_start_main\n" +" Py_BytesMain\n" +" |\n" +" |--55.43%--pymain_run_python.constprop.0\n" +" | |\n" +" | |--54.71%--_PyRun_AnyFileObject\n" +" | | _PyRun_SimpleFileObject\n" +" | | |\n" +" | | |--53.62%--run_mod\n" +" | | | |\n" +" | | | --53.26%--" +"PyEval_EvalCode\n" +" | | | py::" +":/src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::baz:/" +"src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::bar:/" +"src/script.py\n" +" | | | " +"_PyEval_EvalFrameDefault\n" +" | | | " +"PyObject_Vectorcall\n" +" | | | " +"_PyEval_Vector\n" +" | | | py::foo:/" +"src/script.py\n" +" | | | |\n" +" | | | " +"|--51.81%--_PyEval_EvalFrameDefault\n" +" | | | " +"| |\n" +" | | | " +"| |--13.77%--_PyCompactLong_Add\n" +" | | | " +"| | |\n" +" | | | " +"| | |--3.26%--_PyObject_Malloc" -#: ../../howto/perf_profiling.rst:151 msgid "Using the samply profiler" -msgstr "" +msgstr "samply プロファイラの利用" -#: ../../howto/perf_profiling.rst:153 msgid "" "samply is a modern profiler that can be used as an alternative to perf. It " "uses the same perf map files that Python generates, making it compatible " "with Python's profiling support. samply is particularly useful on macOS " "where perf is not available." msgstr "" +"samply は perf の代わりに使えるモダンなプロファイラです。\n" +"Python が生成する perf map ファイルを使うため、Python のプロファイリング機能" +"に対応しています。\n" +"perf が使えない macOS では特に便利です。" -#: ../../howto/perf_profiling.rst:158 msgid "" "To use samply with Python, first install it following the instructions at " "https://github.com/mstange/samply, then run::" msgstr "" +"Python で samply を使うには、まず https://github.com/mstange/samply の手順で" +"インストールし、次を実行します。 ::" -#: ../../howto/perf_profiling.rst:161 msgid "$ samply record PYTHONPERFSUPPORT=1 python my_script.py" -msgstr "" +msgstr "$ samply record PYTHONPERFSUPPORT=1 python my_script.py" -#: ../../howto/perf_profiling.rst:163 msgid "" "This will open a web interface where you can analyze the profiling data " "interactively. The advantage of samply is that it provides a modern web-" "based interface for analyzing profiling data and works on both Linux and " "macOS." msgstr "" +"Web インターフェースが開き、プロファイリングデータを対話的に分析できます。\n" +"samply の利点は、分析用のモダンな Web インターフェースを備え、Linux と macOS " +"の両方で動作することです。" -#: ../../howto/perf_profiling.rst:168 msgid "" "On macOS, samply support requires Python 3.15 or later. Also on macOS, " "samply can't profile signed Python executables due to restrictions by macOS. " @@ -266,51 +407,60 @@ msgid "" "order to attach to running processes on macOS, run ``samply setup`` once " "(and every time samply is updated) to self-sign the samply binary." msgstr "" +"macOS で samply を使うには Python 3.15 以降が必要です。\n" +"また、macOS の制限により、署名された Python 実行ファイルはプロファイリングで" +"きません。\n" +"自分でコンパイルしたものや、未署名またはローカル署名されたもの (Homebrew でイ" +"ンストールしたものなど) を使ってください。\n" +"macOS で実行中のプロセスにアタッチするには、最初に一度、また samply を更新す" +"るたびに ``samply setup`` を実行し、samply バイナリを自己署名してください。" -#: ../../howto/perf_profiling.rst:176 msgid "How to enable ``perf`` profiling support" -msgstr "" +msgstr "``perf`` プロファイリングサポートを有効にする方法" -#: ../../howto/perf_profiling.rst:178 msgid "" "``perf`` profiling support can be enabled either from the start using the " "environment variable :envvar:`PYTHONPERFSUPPORT` or the :option:`-X perf <-" "X>` option, or dynamically using :func:`sys.activate_stack_trampoline` and :" "func:`sys.deactivate_stack_trampoline`." msgstr "" +"``perf`` プロファイリングサポートは、環境変数 :envvar:`PYTHONPERFSUPPORT` ま" +"たは :option:`-X perf <-X>` オプションで起動時から有効にできます。\n" +":func:`sys.activate_stack_trampoline` と :func:`sys." +"deactivate_stack_trampoline` で動的に切り替えることもできます。" -#: ../../howto/perf_profiling.rst:184 msgid "" "The :mod:`!sys` functions take precedence over the :option:`!-X` option, " "the :option:`!-X` option takes precedence over the environment variable." msgstr "" +":mod:`!sys` の関数は :option:`!-X` オプションより優先され、:option:`!-X` オプ" +"ションは環境変数より優先されます。" -#: ../../howto/perf_profiling.rst:187 msgid "Example, using the environment variable::" -msgstr "" +msgstr "環境変数を使う例です。 ::" -#: ../../howto/perf_profiling.rst:189 msgid "" "$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python my_script." "py\n" "$ perf report -g -i perf.data" msgstr "" +"$ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python my_script." +"py\n" +"$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:192 msgid "Example, using the :option:`!-X` option::" -msgstr "" +msgstr ":option:`!-X` オプションを使う例です。 ::" -#: ../../howto/perf_profiling.rst:194 msgid "" "$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" "$ perf report -g -i perf.data" msgstr "" +"$ perf record -F 9999 -g -o perf.data python -X perf my_script.py\n" +"$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:197 msgid "Example, using the :mod:`sys` APIs in file :file:`example.py`:" -msgstr "" +msgstr ":file:`example.py` で :mod:`sys` API を使う例です:" -#: ../../howto/perf_profiling.rst:199 msgid "" "import sys\n" "\n" @@ -320,22 +470,27 @@ msgid "" "\n" "non_profiled_stuff()" msgstr "" +"import sys\n" +"\n" +"sys.activate_stack_trampoline(\"perf\")\n" +"do_profiled_stuff()\n" +"sys.deactivate_stack_trampoline()\n" +"\n" +"non_profiled_stuff()" -#: ../../howto/perf_profiling.rst:209 msgid "...then::" -msgstr "" +msgstr "続いて次を実行します。 ::" -#: ../../howto/perf_profiling.rst:211 msgid "" "$ perf record -F 9999 -g -o perf.data python ./example.py\n" "$ perf report -g -i perf.data" msgstr "" +"$ perf record -F 9999 -g -o perf.data python ./example.py\n" +"$ perf report -g -i perf.data" -#: ../../howto/perf_profiling.rst:216 msgid "How to obtain the best results" -msgstr "" +msgstr "最良の結果を得る方法" -#: ../../howto/perf_profiling.rst:218 msgid "" "For best results, keep frame pointers enabled. On supported GCC-compatible " "toolchains, CPython builds itself with ``-fno-omit-frame-pointer`` and " @@ -345,28 +500,35 @@ msgid "" "allow ``perf`` support is dynamically generated it doesn't have any DWARF " "debugging information available." msgstr "" +"最良の結果を得るには、フレームポインタを有効にしてください。\n" +"対応する GCC 互換ツールチェーンでは、CPython は ``-fno-omit-frame-pointer`` " +"などのフラグを使ってビルドされます (詳細は :option:`--without-frame-" +"pointers` を参照)。\n" +"これにより、プロファイラは DWARF デバッグ情報ではなくフレームポインタだけでス" +"タックをたどれます。\n" +"``perf`` 対応のために挿入するコードは動的に生成され、DWARF デバッグ情報を持た" +"ないためです。" -#: ../../howto/perf_profiling.rst:226 msgid "" "You can check if your system has been compiled with this flag by running::" msgstr "" +"このフラグを使ってコンパイルされたかどうかは、次を実行して確認できます。 ::" -#: ../../howto/perf_profiling.rst:228 msgid "$ python -m sysconfig | grep 'no-omit-frame-pointer'" -msgstr "" +msgstr "$ python -m sysconfig | grep 'no-omit-frame-pointer'" -#: ../../howto/perf_profiling.rst:230 msgid "" "If you don't see any output it means that your interpreter has not been " "compiled with frame pointers and therefore it may not be able to show Python " "functions in the output of ``perf``." msgstr "" +"何も表示されなければ、インタープリタはフレームポインタなしでコンパイルされて" +"います。\n" +"その場合、``perf`` の出力に Python 関数を表示できない可能性があります。" -#: ../../howto/perf_profiling.rst:236 msgid "How to work without frame pointers" -msgstr "" +msgstr "フレームポインタなしで使う方法" -#: ../../howto/perf_profiling.rst:238 msgid "" "If you are working with a Python interpreter that has been compiled without " "frame pointers, you can still use the ``perf`` profiler, but the overhead " @@ -375,47 +537,62 @@ msgid "" "more time to process the data because it will need to use the DWARF " "debugging information to unwind the stack and this is a slow process." msgstr "" +"フレームポインタなしでコンパイルした Python インタープリタでも ``perf`` は使" +"えますが、オーバーヘッドは少し大きくなります。\n" +"Python 関数の呼び出しごとに、スタックをたどるための情報をその場で生成する必要" +"があるためです。\n" +"さらに ``perf`` は DWARF デバッグ情報を使ってスタックをたどる必要があり、この" +"処理は遅いため、データの処理にも時間がかかります。" -#: ../../howto/perf_profiling.rst:245 msgid "" "To enable this mode, you can use the environment variable :envvar:" "`PYTHON_PERF_JIT_SUPPORT` or the :option:`-X perf_jit <-X>` option, which " "will enable the JIT mode for the ``perf`` profiler." msgstr "" +"このモードを有効にするには、環境変数 :envvar:`PYTHON_PERF_JIT_SUPPORT` また" +"は :option:`-X perf_jit <-X>` オプションを使います。\n" +"これにより ``perf`` プロファイラ用の JIT モードが有効になります。" -#: ../../howto/perf_profiling.rst:251 msgid "" "Due to a bug in the ``perf`` tool, only ``perf`` versions higher than v6.8 " "will work with the JIT mode. The fix was also backported to the v6.7.2 " "version of the tool." msgstr "" +"``perf`` ツールのバグのため、JIT モードで動作するのは v6.8 より後のバージョン" +"だけです。\n" +"修正は v6.7.2 にもバックポートされています。" -#: ../../howto/perf_profiling.rst:255 msgid "" "Note that when checking the version of the ``perf`` tool (which can be done " "by running ``perf version``) you must take into account that some distros " "add some custom version numbers including a ``-`` character. This means " "that ``perf 6.7-3`` is not necessarily ``perf 6.7.3``." msgstr "" +"``perf version`` でバージョンを確認するときは、一部のディストリビューション" +"が ``-`` を含む独自のバージョン番号を追加する点に注意してください。\n" +"``perf 6.7-3`` は必ずしも ``perf 6.7.3`` を意味しません。" -#: ../../howto/perf_profiling.rst:260 msgid "" "When using the perf JIT mode, you need an extra step before you can run " "``perf report``. You need to call the ``perf inject`` command to inject the " "JIT information into the ``perf.data`` file.::" msgstr "" +"perf の JIT モードでは、``perf report`` の前に一つ手順が必要です。\n" +"``perf inject`` で JIT 情報を ``perf.data`` ファイルに組み込みます。 ::" -#: ../../howto/perf_profiling.rst:264 msgid "" "$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python -" "Xperf_jit my_script.py\n" "$ perf inject -i perf.data --jit --output perf.jit.data\n" "$ perf report -g -i perf.jit.data" msgstr "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf -o perf.data python -" +"Xperf_jit my_script.py\n" +"$ perf inject -i perf.data --jit --output perf.jit.data\n" +"$ perf report -g -i perf.jit.data" -#: ../../howto/perf_profiling.rst:268 msgid "or using the environment variable::" -msgstr "" +msgstr "環境変数を使う場合は次のようになります。 ::" #: ../../howto/perf_profiling.rst:270 msgid "" @@ -435,7 +612,6 @@ msgid "" "by Python." msgstr "" -#: ../../howto/perf_profiling.rst:282 msgid "" "When using ``--call-graph dwarf``, the ``perf`` tool will take snapshots of " "the stack of the process being profiled and save the information in the " @@ -443,8 +619,11 @@ msgid "" "but you can change the size by passing it after a comma like ``--call-graph " "dwarf,16384``." msgstr "" +"``--call-graph dwarf`` を指定すると、``perf`` は対象プロセスのスタックのス" +"ナップショットを取得し、``perf.data`` に保存します。\n" +"スタックダンプのサイズはデフォルトで 8192 バイトですが、``--call-graph " +"dwarf,16384`` のようにカンマの後に指定すると変更できます。" -#: ../../howto/perf_profiling.rst:288 msgid "" "The size of the stack dump is important because if the size is too small " "``perf`` will not be able to unwind the stack and the output will be " @@ -452,8 +631,11 @@ msgid "" "be able to sample the process as frequently as it would like as the overhead " "will be higher." msgstr "" +"スタックダンプのサイズは重要です。\n" +"小さすぎると ``perf`` がスタックをたどれず、出力が不完全になります。\n" +"大きすぎるとオーバーヘッドが増え、希望する頻度でサンプリングできなくなりま" +"す。" -#: ../../howto/perf_profiling.rst:294 msgid "" "The stack size is particularly important when profiling Python code compiled " "with low optimization levels (like ``-O0``), as these builds tend to have " @@ -461,30 +643,37 @@ msgid "" "Python functions in your profiling output, try increasing the stack dump " "size to 65528 bytes (the maximum)::" msgstr "" +"``-O0`` のような低い最適化レベルでコンパイルした Python をプロファイリングす" +"る場合は、スタックフレームが大きくなりやすいため、特にサイズが重要です。\n" +"``-O0`` でコンパイルした Python の関数が出力に現れない場合は、スタックダンプ" +"のサイズを最大の 65528 バイトに増やしてみてください。 ::" -#: ../../howto/perf_profiling.rst:300 msgid "" "$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python -" "Xperf_jit my_script.py" msgstr "" +"$ perf record -F 9999 -g -k 1 --call-graph dwarf,65528 -o perf.data python -" +"Xperf_jit my_script.py" -#: ../../howto/perf_profiling.rst:302 msgid "Different compilation flags can significantly impact stack sizes:" -msgstr "" +msgstr "コンパイルフラグはスタックのサイズに大きく影響することがあります:" -#: ../../howto/perf_profiling.rst:304 msgid "" "Builds with ``-O0`` typically have much larger stack frames than those with " "``-O1`` or higher" msgstr "" +"通常、``-O0`` のビルドは ``-O1`` 以上のビルドよりも、スタックフレームがはるか" +"に大きくなります。" -#: ../../howto/perf_profiling.rst:305 msgid "" "Adding optimizations (``-O1``, ``-O2``, etc.) typically reduces stack size" msgstr "" +"通常、最適化 (``-O1``、``-O2`` など) を有効にするとスタックのサイズが小さくな" +"ります。" -#: ../../howto/perf_profiling.rst:306 msgid "" "Frame pointers (``-fno-omit-frame-pointer``) generally provide more reliable " "stack unwinding" msgstr "" +"フレームポインタ (``-fno-omit-frame-pointer``) を使うと、一般にスタックをより" +"確実にたどれます。" diff --git a/howto/pyporting.po b/howto/pyporting.po index 54c2b90d3..5688cb12a 100644 --- a/howto/pyporting.po +++ b/howto/pyporting.po @@ -16,68 +16,72 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/pyporting.rst:7 msgid "How to port Python 2 Code to Python 3" -msgstr "" +msgstr "Python 2 のコードを Python 3 に移植する方法" -#: ../../howto/pyporting.rst:9 msgid "" "Python 2 reached its official end-of-life at the start of 2020. This means " "that no new bug reports, fixes, or changes will be made to Python 2 - it's " "no longer supported: see :pep:`373` and `status of Python versions `_." msgstr "" +"Python 2 の公式サポートは 2020 年の初めに終了しました。\n" +"Python 2 に対する新しいバグ報告の受け付け、修正、変更は行われず、サポートされ" +"ていません。\n" +":pep:`373` と `Python 各バージョンの状況 `_ を参照してください。" -#: ../../howto/pyporting.rst:14 msgid "" "If you are looking to port an extension module instead of pure Python code, " "please see :ref:`cporting-howto`." msgstr "" -"もしあなたが標準 Python ライブラリではなく拡張ライブラリでの移植手段を探して" -"いるならば :ref:`cporting-howto` を参照してください。" +"Python だけで書かれたコードではなく、拡張モジュールを移植する場合は :ref:" +"`cporting-howto` を参照してください。" -#: ../../howto/pyporting.rst:17 msgid "" "The archived python-porting_ mailing list may contain some useful guidance." msgstr "" +"アーカイブされた python-porting_ メーリングリストにも、役立つ情報があるかもし" +"れません。" -#: ../../howto/pyporting.rst:19 msgid "" "Since Python 3.11 the original porting guide was discontinued. You can find " "the old guide in the `archive `_." msgstr "" +"従来の移植ガイドは Python 3.11 から廃止されました。\n" +"以前のガイドは `アーカイブ `_ で読めます。" -#: ../../howto/pyporting.rst:25 msgid "Third-party guides" -msgstr "" +msgstr "サードパーティのガイド" -#: ../../howto/pyporting.rst:27 msgid "There are also multiple third-party guides that might be useful:" -msgstr "" +msgstr "次のようなサードパーティのガイドも参考になります:" -#: ../../howto/pyporting.rst:29 msgid "`Guide by Fedora `_" -msgstr "" +msgstr "`Fedora のガイド `_" -#: ../../howto/pyporting.rst:30 msgid "`PyCon 2020 tutorial `_" msgstr "" +"`PyCon 2020 のチュートリアル `_" -#: ../../howto/pyporting.rst:31 msgid "" "`Guide by DigitalOcean `_" msgstr "" +"`DigitalOcean のガイド `_" -#: ../../howto/pyporting.rst:32 msgid "" "`Guide by ActiveState `_" msgstr "" +"`ActiveState のガイド `_" diff --git a/howto/regex.po b/howto/regex.po index 3b3dbac0b..84fe4b384 100644 --- a/howto/regex.po +++ b/howto/regex.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/regex.rst:5 msgid "Regular expression HOWTO" -msgstr "" +msgstr "正規表現 HOWTO" #: ../../howto/regex.rst-1 msgid "Abstract" @@ -83,7 +82,6 @@ msgstr "" "化までは扱いません、それにはマッチングエンジンの内部に対する十分な理解が必要" "だからです。" -#: ../../howto/regex.rst:40 msgid "" "The regular expression language is relatively small and restricted, so not " "all possible string processing tasks can be done using regular expressions. " @@ -93,15 +91,16 @@ msgid "" "be slower than an elaborate regular expression, it will also probably be " "more understandable." msgstr "" -"正規表現言語は相対的に小さく、制限されています、そのため正規表現を使ってあら" -"ゆる文字列処理作業を行なえるわけではありません。正規表現を使って行うことので" -"きる作業もあります、ただ表現はとても複雑なものになります。それらの場合では、" -"Python コードを書いた方がいいでしょう; Python コードは念入りに作られた正規表" -"現より遅くなりますが、おそらくより読み易いでしょう。" +"正規表現の言語は比較的小規模で機能も限られているため、あらゆる文字列処理を正" +"規表現で行えるわけではありません。\n" +"正規表現で処理することは *できても*、その正規表現が非常に複雑になってしまう作" +"業もあります。\n" +"そうした場合は、処理を Python コードで書いた方がよいかもしれません。\n" +"Python コードは工夫を凝らした正規表現より遅くなりますが、おそらく理解しやすく" +"なるでしょう。" -#: ../../howto/regex.rst:49 msgid "Simple patterns" -msgstr "" +msgstr "単純なパターン" #: ../../howto/regex.rst:51 msgid "" @@ -123,9 +122,8 @@ msgstr "" "ついては, コンパイラ作成に関するテキストブックをどれでもいいので参照して下さ" "い。" -#: ../../howto/regex.rst:61 msgid "Matching characters" -msgstr "" +msgstr "文字のマッチング" #: ../../howto/regex.rst:63 msgid "" @@ -162,9 +160,8 @@ msgstr "" "ここに特殊文字の完全な一覧があります; これらの意味はこの HOWTO の残りの部分で" "説明します。" -#: ../../howto/regex.rst:77 msgid ". ^ $ * + ? { } [ ] \\ | ( )" -msgstr "" +msgstr ". ^ $ * + ? { } [ ] \\ | ( )" #: ../../howto/regex.rst:81 msgid "" @@ -185,19 +182,18 @@ msgstr "" "ベットのみにマッチしたい場合、 ``[a-z]`` の正規表現をつかうことになるでしょ" "う。" -#: ../../howto/regex.rst:90 msgid "" "Metacharacters (except ``\\``) are not active inside classes. For example, " "``[akm$]`` will match any of the characters ``'a'``, ``'k'``, ``'m'``, or " "``'$'``; ``'$'`` is usually a metacharacter, but inside a character class " "it's stripped of its special nature." msgstr "" -"(``\\`` を除く) 特殊文字は文字クラスの内部では有効になりません。例えば、 " -"``[akm$]`` は ``'a'``, ``'k'``, ``'m'``, または ``'{TX-PL-LABEL}#x27;`` のい" -"ずれかにマッチします; ``'{TX-PL-LABEL}#x27;`` は通常は特殊文字ですが、文字ク" -"ラス内部ではその特別な性質は取り除かれます。" +"文字クラスの内部では、``\\`` を除く特殊文字は特別な意味を持ちません。\n" +"例えば ``[akm$]`` は ``'a'``、``'k'``、``'m'``、``'$'`` のいずれかにマッチし" +"ます。\n" +"``'$'`` は通常は特殊文字ですが、文字クラスの内部ではその特別な意味を失いま" +"す。" -#: ../../howto/regex.rst:95 msgid "" "You can match the characters not listed within the class by :dfn:" "`complementing` the set. This is indicated by including a ``'^'`` as the " @@ -206,12 +202,11 @@ msgid "" "does not have special meaning. For example: ``[5^]`` will match either a " "``'5'`` or a ``'^'``." msgstr "" -":dfn:`補集合を取る` ことで、文字クラス内のリストにない文字に対してマッチさせ" -"られます。\n" -"補集合は、クラスの最初の文字として ``'^'`` を含めることで表せます。\n" -"例えば、 ``[^5]`` は ``'5'`` 以外の文字にマッチします。\n" -"キャレットが文字クラス以外の場所に現れた場合は、特別な意味は持ちません。\n" -"例えば、 ``[5^]`` は ``'5'`` や ``'^'`` にマッチします。" +":dfn:`補集合を取る` と、文字クラスに挙げていない文字にマッチさせられます。\n" +"文字クラスの最初に ``'^'`` を置いて表します。\n" +"例えば ``[^5]`` は ``'5'`` 以外の文字にマッチします。\n" +"キャレットが文字クラス内の先頭以外の位置にあれば、特別な意味はありません。\n" +"例えば ``[5^]`` は ``'5'`` または ``'^'`` にマッチします。" #: ../../howto/regex.rst:101 msgid "" @@ -239,7 +234,6 @@ msgstr "" "``'\\'`` で始まるいくつかの特殊シーケンスは、数字、アルファベット、空白文字以" "外など、よく使う文字集合を表しています。" -#: ../../howto/regex.rst:113 msgid "" "Let's take an example: ``\\w`` matches any alphanumeric character. If the " "regex pattern is expressed in bytes, this is equivalent to the class ``[a-zA-" @@ -249,12 +243,12 @@ msgid "" "in a string pattern by supplying the :const:`re.ASCII` flag when compiling " "the regular expression." msgstr "" -"一つ例をお見せしましょう: ``\\w`` は任意の英数字文字にマッチします。バイト列" -"パターンに対しては、これは文字クラス ``[a-zA-Z0-9_]`` と等価です。ユニコード" -"パターンに対しては、 ``\\w`` は :mod:`unicodedata` モジュールで提供されてい" -"る Unicode データベースで letters としてマークされている全ての文字とマッチし" -"ます。正規表現のコンパイル時に :const:`re.ASCII` フラグを与えることにより、 " -"``\\w`` を、より制限された定義で使うことが出来ます。" +"例えば、``\\w`` は任意の英数字にマッチします。\n" +"バイト列のパターンでは、これは文字クラス ``[a-zA-Z0-9_]`` と同じです。\n" +"文字列のパターンでは、``\\w`` は :mod:`unicodedata` モジュールが提供する " +"Unicode データベースで文字 (letter) とされるすべての文字にマッチします。\n" +"正規表現のコンパイル時に :const:`re.ASCII` フラグを指定すると、\n" +"文字列のパターンでも ``\\w`` のマッチ対象を ``[a-zA-Z0-9_]`` に制限できます。" #: ../../howto/regex.rst:121 msgid "" @@ -274,9 +268,10 @@ msgstr "" msgid "``\\d``" msgstr "``\\d``" -#: ../../howto/regex.rst:129 msgid "Matches any decimal digit; this is equivalent to the class ``[0-9]``." -msgstr "任意の十進数とマッチします; これは集合 ``[0-9]`` と同じ意味です。" +msgstr "" +"任意の十進数字にマッチします。\n" +"文字クラス ``[0-9]`` と同じです。" #: ../../howto/regex.rst:131 msgid "``\\D``" @@ -355,9 +350,8 @@ msgstr "" "る代替モード (:const:`re.DOTALL`) があります。\n" "``.`` は「任意の文字」にマッチさせたい場合に利用されます。" -#: ../../howto/regex.rst:161 msgid "Repeating things" -msgstr "" +msgstr "繰り返し" #: ../../howto/regex.rst:163 msgid "" @@ -517,7 +511,6 @@ msgid "" "``'b'``, so it succeeds." msgstr "再び ``b`` を試みる。今回の現在位置の文字は ``'b'`` なので成功。" -#: ../../howto/regex.rst:217 msgid "" "The end of the RE has now been reached, and it has matched ``'abcb'``. This " "demonstrates how the matching engine goes as far as it can at first, and if " @@ -526,13 +519,13 @@ msgid "" "``[bcd]*``, and if that subsequently fails, the engine will conclude that " "the string doesn't match the RE at all." msgstr "" -"正規表現の終端に達して、 ``'abcd'`` にマッチしました。\n" -"この説明は、マッチングエンジンが最初に到達できるところまで進みマッチしなかっ" -"た場合、逐次戻って再度残りの正規表現とのマッチを次々と試みること様子を示して" -"います。\n" -"正規表現エンジンは ``[bcd]*`` の 0 回マッチを試すところまで戻り、その後続の正" -"規表現とのマッチに失敗した場合には、エンジンは正規表現と文字列が完全にマッチ" -"しないと結論づけることになります。" +"これで正規表現の末尾に達し、``'abcb'`` にマッチしました。\n" +"この例が示すように、マッチングエンジンはまず可能な限り先へ進みます。\n" +"マッチしなければ少しずつ後戻りし、残りの正規表現とのマッチを繰り返し試みま" +"す。\n" +"``[bcd]*`` が 0 回マッチする場合まで後戻りしても残りの正規表現がマッチしなけ" +"れば、\n" +"その文字列はこの正規表現にマッチしないと判断します。" #: ../../howto/regex.rst:224 msgid "" @@ -587,11 +580,13 @@ msgstr "" "的な値が仮定されます。\n" "*m* の省略は下限は 0 と解釈され、*n* の省略は上限は無限として解釈されます。" -#: ../../howto/regex.rst:246 msgid "" "The simplest case ``{m}`` matches the preceding item exactly *m* times. For " "example, ``a/{2}b`` will only match ``'a//b'``." msgstr "" +"最も単純な ``{m}`` は、直前の要素のちょうど *m* 回の繰り返しにマッチしま" +"す。\n" +"例えば ``a/{2}b`` は ``'a//b'`` だけにマッチします。" #: ../../howto/regex.rst:249 msgid "" @@ -606,9 +601,8 @@ msgstr "" "価です。また ``{0,1}`` は ``?`` と同じです。とはいえ、簡潔さと読みやすさの観" "点から、可能であれば ``*``, ``+``, ``?`` を使う方が望ましいです。" -#: ../../howto/regex.rst:257 msgid "Using regular expressions" -msgstr "" +msgstr "正規表現を使う" #: ../../howto/regex.rst:259 msgid "" @@ -622,9 +616,8 @@ msgstr "" "ンターフェースを提供していて、それらを使うことで正規表現をオブジェクトにコン" "パイルし、マッチを実行することができます。" -#: ../../howto/regex.rst:266 msgid "Compiling regular expressions" -msgstr "" +msgstr "正規表現のコンパイル" #: ../../howto/regex.rst:268 msgid "" @@ -636,27 +629,28 @@ msgstr "" "くの操作、パターンマッチの検索や文字列の置換の実行などのメソッドを持っていま" "す。 ::" -#: ../../howto/regex.rst:272 msgid "" ">>> import re\n" ">>> p = re.compile('ab*')\n" ">>> p\n" "re.compile('ab*')" msgstr "" +">>> import re\n" +">>> p = re.compile('ab*')\n" +">>> p\n" +"re.compile('ab*')" -#: ../../howto/regex.rst:277 msgid "" ":func:`re.compile` also accepts an optional *flags* argument, used to enable " "various special features and syntax variations. We'll go over the available " "settings later, but for now a single example will do::" msgstr "" -":func:`re.compile` はいくつかの *flags* 引数を受け付けることができます、この" -"引数はさまざまな特別な機能を有効にしたり、構文を変化させたりします。利用でき" -"る設定に何があるかは後に飛ばすことにして、簡単な例をやることにしましょう::" +":func:`re.compile` は省略可能な *flags* 引数も受け取ります。\n" +"さまざまな機能や構文上の違いを有効にするための引数です。\n" +"利用できる設定は後で説明しますが、まずは一つ例を見てみましょう。 ::" -#: ../../howto/regex.rst:281 msgid ">>> p = re.compile('ab*', re.IGNORECASE)" -msgstr "" +msgstr ">>> p = re.compile('ab*', re.IGNORECASE)" #: ../../howto/regex.rst:283 msgid "" @@ -684,9 +678,8 @@ msgstr "" "正規表現を文字列としておくことで Python 言語はより簡素に保たれていますが、そ" "のため1つの欠点があります、これについては次の節で話題とします。" -#: ../../howto/regex.rst:297 msgid "The backslash plague" -msgstr "" +msgstr "バックスラッシュの悩み" #: ../../howto/regex.rst:299 msgid "" @@ -781,7 +774,6 @@ msgstr "" "ります。多くの場合 Python コードの中の正規表現はこの raw string 記法を使って" "書かれます。" -#: ../../howto/regex.rst:334 msgid "" "In addition, special escape sequences that are valid in regular expressions, " "but not valid as Python string literals, now result in a :exc:" @@ -789,14 +781,18 @@ msgid "" "the sequences will be invalid if raw string notation or escaping the " "backslashes isn't used." msgstr "" +"また、正規表現としては有効でも Python の文字列リテラルでは有効でない特殊なエ" +"スケープシーケンスは、現在は :exc:`SyntaxWarning` を発生させ、将来は :exc:" +"`SyntaxError` になります。\n" +"つまり、raw string 記法を使うかバックスラッシュをエスケープしなければ、これら" +"のシーケンスは無効になります。" #: ../../howto/regex.rst:342 msgid "Regular String" msgstr "通常の文字列" -#: ../../howto/regex.rst:342 msgid "Raw string" -msgstr "Raw string" +msgstr "raw 文字列" #: ../../howto/regex.rst:344 msgid "``\"ab*\"``" @@ -818,9 +814,8 @@ msgstr "``\"\\\\w+\\\\s+\\\\1\"``" msgid "``r\"\\w+\\s+\\1\"``" msgstr "``r\"\\w+\\s+\\1\"``" -#: ../../howto/regex.rst:353 msgid "Performing matches" -msgstr "" +msgstr "マッチングの実行" #: ../../howto/regex.rst:355 msgid "" @@ -852,47 +847,50 @@ msgstr "``search()``" msgid "Scan through a string, looking for any location where this RE matches." msgstr "文字列を先頭から走査して、正規表現がどこにマッチするか調べます。" -#: ../../howto/regex.rst:366 msgid "``prefixmatch()``" -msgstr "" +msgstr "``prefixmatch()``" -#: ../../howto/regex.rst:366 msgid "" "Determine if the RE matches at the beginning of the string. Previously " "named :ref:`match() `." msgstr "" +"正規表現が文字列の先頭にマッチするかを調べます。\n" +"以前の名前は :ref:`match() ` です。" #: ../../howto/regex.rst:370 msgid "``findall()``" msgstr "``findall()``" -#: ../../howto/regex.rst:370 msgid "Find all substrings where the RE matches, and return them as a list." -msgstr "" +msgstr "正規表現にマッチする部分文字列をすべて見つけ、リストで返します。" #: ../../howto/regex.rst:373 msgid "``finditer()``" msgstr "``finditer()``" -#: ../../howto/regex.rst:373 msgid "" "Find all substrings where the RE matches, and return them as an :term:" "`iterator`." msgstr "" +"正規表現にマッチする部分文字列をすべて見つけ、:term:`iterator` として返しま" +"す。" -#: ../../howto/regex.rst:377 msgid "" ":meth:`~re.Pattern.search` and :meth:`~re.Pattern.prefixmatch` return " "``None`` if no match can be found. If they're successful, a :ref:`match " "object ` instance is returned, containing information about " "the match: where it starts and ends, the substring it matched, and more." msgstr "" +":meth:`~re.Pattern.search` と :meth:`~re.Pattern.prefixmatch` は、マッチが見" +"つからなければ ``None`` を返します。\n" +"見つかれば :ref:`マッチオブジェクト ` を返します。\n" +"このオブジェクトには、開始位置、終了位置、マッチした部分文字列などの情報が含" +"まれます。" -#: ../../howto/regex.rst:382 msgid "" "You can learn about this by interactively experimenting with the :mod:`re` " "module." -msgstr "" +msgstr ":mod:`re` モジュールを対話的に試すと理解が深まります。" #: ../../howto/regex.rst:385 msgid "" @@ -903,15 +901,17 @@ msgstr "" "ンタプリタを起動して、 :mod:`re` モジュールをインポートし、正規表現をコンパイ" "ルします::" -#: ../../howto/regex.rst:388 msgid "" ">>> import re\n" ">>> p = re.compile('[a-z]+')\n" ">>> p\n" "re.compile('[a-z]+')" msgstr "" +">>> import re\n" +">>> p = re.compile('[a-z]+')\n" +">>> p\n" +"re.compile('[a-z]+')" -#: ../../howto/regex.rst:393 msgid "" "Now, you can try matching various strings against the RE ``[a-z]+``. An " "empty string shouldn't match at all, since ``+`` means 'one or more " @@ -919,28 +919,39 @@ msgid "" "case, which will cause the interpreter to print no output. You can " "explicitly print the result of :meth:`!search` to make this clear. ::" msgstr "" +"正規表現 ``[a-z]+`` でさまざまな文字列を試してみましょう。\n" +"``+`` は「1 回以上の繰り返し」なので、空文字列にはマッチしません。\n" +"この場合 :meth:`~re.Pattern.search` は ``None`` を返し、インタープリタには何" +"も表示されません。\n" +":meth:`!search` の結果を明示的に表示すると確認できます。 ::" -#: ../../howto/regex.rst:399 msgid "" ">>> p.search(\"\")\n" ">>> print(p.search(\"\"))\n" "None" msgstr "" +">>> p.search(\"\")\n" +">>> print(p.search(\"\"))\n" +"None" -#: ../../howto/regex.rst:403 msgid "" "Now, let's try it on a string that it should match, such as ``tempo``. In " "this case, :meth:`~re.Pattern.search` will return a :ref:`match object " "`, so you should store the result in a variable for later " "use. ::" msgstr "" +"今度は ``tempo`` など、マッチするはずの文字列を試しましょう。\n" +"この場合 :meth:`~re.Pattern.search` は :ref:`マッチオブジェクト ` を返すので、後で使えるように変数に保存しておきます。 ::" -#: ../../howto/regex.rst:407 msgid "" ">>> m = p.search('tempo')\n" ">>> m\n" "" msgstr "" +">>> m = p.search('tempo')\n" +">>> m\n" +"" #: ../../howto/regex.rst:411 msgid "" @@ -989,7 +1000,6 @@ msgstr "マッチの位置 (start, end) を含むタプルを返す" msgid "Trying these methods will soon clarify their meaning::" msgstr "これらのメソッドを試せば、その意味はすぐに理解できます::" -#: ../../howto/regex.rst:430 msgid "" ">>> m.group()\n" "'tempo'\n" @@ -998,8 +1008,13 @@ msgid "" ">>> m.span()\n" "(0, 5)" msgstr "" +">>> m.group()\n" +"'tempo'\n" +">>> m.start(), m.end()\n" +"(0, 5)\n" +">>> m.span()\n" +"(0, 5)" -#: ../../howto/regex.rst:437 msgid "" ":meth:`~re.Match.group` returns the substring that was matched by the RE. :" "meth:`~re.Match.start` and :meth:`~re.Match.end` return the starting and " @@ -1009,8 +1024,15 @@ msgid "" "meth:`~re.Pattern.prefixmatch` method only checks if the RE matches at the " "start of a string, so :meth:`!start` will always be zero in that case. ::" msgstr "" +":meth:`~re.Match.group` は正規表現にマッチした部分文字列を返します。\n" +":meth:`~re.Match.start` と :meth:`~re.Match.end` は、開始と終了のインデックス" +"を返します。\n" +":meth:`~re.Match.span` は両方のインデックスを一つのタプルで返します。\n" +"パターンの :meth:`~re.Pattern.search` は文字列を走査するので、マッチは必ずし" +"もゼロから始まりません。\n" +"一方 :meth:`~re.Pattern.prefixmatch` は文字列の先頭だけを調べるので、その場" +"合 :meth:`!start` は常にゼロになります。 ::" -#: ../../howto/regex.rst:446 msgid "" ">>> m = p.search('::: message'); print(m)\n" "\n" @@ -1021,6 +1043,14 @@ msgid "" ">>> print(p.prefixmatch('::: message'))\n" "None" msgstr "" +">>> m = p.search('::: message'); print(m)\n" +"\n" +">>> m.group()\n" +"'message'\n" +">>> m.span()\n" +"(4, 11)\n" +">>> print(p.prefixmatch('::: message'))\n" +"None" #: ../../howto/regex.rst:455 msgid "" @@ -1032,7 +1062,6 @@ msgstr "" "ておき, その次に ``None`` なのか調べるのが一般的なスタイルです。普通このよう" "にします::" -#: ../../howto/regex.rst:459 msgid "" "p = re.compile( ... )\n" "m = p.search( 'string goes here' )\n" @@ -1041,6 +1070,12 @@ msgid "" "else:\n" " print('No match')" msgstr "" +"p = re.compile( ... )\n" +"m = p.search( 'string goes here' )\n" +"if m:\n" +" print('Match found: ', m.group())\n" +"else:\n" +" print('No match')" #: ../../howto/regex.rst:466 msgid "" @@ -1051,14 +1086,15 @@ msgstr "" "ります。\n" ":meth:`~re.Pattern.findall` はマッチした文字列のリストを返します::" -#: ../../howto/regex.rst:469 msgid "" ">>> p = re.compile(r'\\d+')\n" ">>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')\n" "['12', '11', '10']" msgstr "" +">>> p = re.compile(r'\\d+')\n" +">>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')\n" +"['12', '11', '10']" -#: ../../howto/regex.rst:473 msgid "" "The ``r`` prefix, making the literal a raw string literal, is needed in this " "example because escape sequences in a normal \"cooked\" string literal that " @@ -1066,6 +1102,11 @@ msgid "" "in a :exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. " "See :ref:`the-backslash-plague`." msgstr "" +"この例では、リテラルを raw string にする接頭辞 ``r`` が必要です。\n" +"正規表現では認識されても Python が認識しないエスケープシーケンスを通常の文字" +"列リテラルに書くと、現在は :exc:`SyntaxWarning` が発生し、将来は :exc:" +"`SyntaxError` になるためです。\n" +":ref:`the-backslash-plague` を参照してください。" #: ../../howto/regex.rst:479 msgid "" @@ -1079,7 +1120,6 @@ msgstr "" "ト ` インスタンスのシーケンスを :term:`iterator` として返しま" "す::" -#: ../../howto/regex.rst:483 msgid "" ">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" ">>> iterator\n" @@ -1091,10 +1131,18 @@ msgid "" "(22, 24)\n" "(29, 31)" msgstr "" +">>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')\n" +">>> iterator\n" +"\n" +">>> for match in iterator:\n" +"... print(match.span())\n" +"...\n" +"(0, 2)\n" +"(22, 24)\n" +"(29, 31)" -#: ../../howto/regex.rst:495 msgid "Module-level functions" -msgstr "" +msgstr "モジュールレベルの関数" #: ../../howto/regex.rst:497 msgid "" @@ -1106,13 +1154,16 @@ msgid "" "``None`` or a :ref:`match object ` instance. ::" msgstr "" -#: ../../howto/regex.rst:504 msgid "" ">>> print(re.prefixmatch(r'From\\s+', 'Fromage amk'))\n" "None\n" ">>> re.prefixmatch(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" "" msgstr "" +">>> print(re.prefixmatch(r'From\\s+', 'Fromage amk'))\n" +"None\n" +">>> re.prefixmatch(r'From\\s+', 'From amk Thu May 14 19:12:10 1998')\n" +"" #: ../../howto/regex.rst:509 msgid "" @@ -1138,9 +1189,8 @@ msgstr "" "イルは関数呼び出しを減らします。ループの外側であれば、内部キャッシュのおかげ" "で、どちらでも大差ありません。" -#: ../../howto/regex.rst:522 msgid "Compilation flags" -msgstr "" +msgstr "コンパイルフラグ" #: ../../howto/regex.rst:526 msgid "" @@ -1233,7 +1283,6 @@ msgstr "" "冗長な正規表現を利用できるようにして、よりきれいで理解しやすくまとめることが" "できます。" -#: ../../howto/regex.rst:563 msgid "" "Perform case-insensitive matching; character class and literal strings will " "match letters by ignoring case. For example, ``[A-Z]`` will match lowercase " @@ -1249,17 +1298,19 @@ msgid "" "also set the :const:`LOCALE` flag." msgstr "" "大文字と小文字を区別しないマッチングを実行します; 文字クラスと文字列リテラル" -"は大文字か小文字かに関係なくパターンにマッチします。例えば、 ``[A-Z]`` は小文" -"字のアルファベットにもマッチします。 :const:`ASCII` フラグによって非 ASCII 文" -"字のマッチングが無効化されていなければ、完全なユニコードのマッチングも可能で" -"す。ユニコードで ``[a-z]`` または ``[A-Z]`` が :const:`IGNORECASE` フラグとと" -"もに使われると、 52個の ASCII 文字に加えて 次の4つの 非 ASCII 文字にマッチし" -"ます: 'İ' (U+0130, ラテン語の大文字 I で、上部に点がついたもの), " -"'ı' (U+0131, ラテン語の小文字 i で上部に点がない), 'ſ' (U+017F, ラテン語の小" -"文字 s), 'K' (U+212A, ケルビン記号)。 ``Spam`` は ``'Spam'``, ``'spam'``, " -"``'spAM'``, そして ``'ſpam'`` にマッチします (ただし最後の文字列はユニコード" -"モードの場合のみマッチします)。この「小文字化」は現在のロケールを考慮しませ" -"ん; ただし :const:`LOCALE` フラグをセットした場合はロケールを考慮します。" +"は大文字か小文字かに関係なくパターンにマッチします。\n" +"例えば、 ``[A-Z]`` は小文字のアルファベットにもマッチします。\n" +":const:`ASCII` フラグによって非 ASCII 文字のマッチングが無効化されていなけれ" +"ば、完全なユニコードのマッチングも可能です。\n" +"ユニコードで ``[a-z]`` または ``[A-Z]`` が :const:`IGNORECASE` フラグとともに" +"使われると、 52個の ASCII 文字に加えて 次の4つの 非 ASCII 文字にマッチしま" +"す: 'İ' (U+0130, ラテン語の大文字 I で、上部に点がついたもの), 'ı' (U+0131, " +"ラテン語の小文字 i で上部に点がない), 'ſ' (U+017F, ラテン文字の小文字の長い " +"s), 'K' (U+212A, ケルビン記号)。\n" +"``Spam`` は ``'Spam'``, ``'spam'``, ``'spAM'``, そして ``'ſpam'`` にマッチし" +"ます (ただし最後の文字列はユニコードモードの場合のみマッチします)。\n" +"この「小文字化」は現在のロケールを考慮しません; ただし :const:`LOCALE` フラグ" +"をセットした場合はロケールを考慮します。" #: ../../howto/regex.rst:581 msgid "" @@ -1269,7 +1320,6 @@ msgstr "" "``\\w``, ``\\W``, ``\\b``, ``\\B`` と小文字大文字の区別を無視したマッチング" "を、 Unicode データベースではなく現在のロケールに従って行います。" -#: ../../howto/regex.rst:584 msgid "" "Locales are a feature of the C library intended to help in writing programs " "that take account of language differences. For example, if you're " @@ -1302,7 +1352,7 @@ msgstr "" "\"文化\" しか扱うことができず、また8ビットのロケールでしか正しく動作しないか" "らです。Python 3 ではユニコード (文字列の) パターンに対してユニコードのマッチ" "ングがデフォルトで有効化されており、これにより異なるロケールまたは言語を同時" -"に扱うことができます。 " +"に扱うことができます。" #: ../../howto/regex.rst:606 msgid "" @@ -1345,7 +1395,6 @@ msgstr "" "チングではなく、ASCII のみのマッチングをするようにします。これは Unicode パ" "ターンにのみ意味があり、byte パターンには無視されます。" -#: ../../howto/regex.rst:639 msgid "" "This flag allows you to write regular expressions that are more readable by " "granting you more flexibility in how you can format them. When this flag " @@ -1356,6 +1405,13 @@ msgid "" "comments are marked by a ``'#'`` that's neither in a character class nor " "preceded by an unescaped backslash." msgstr "" +"このフラグを使うと、正規表現の整形方法の自由度が増し、読みやすく書けます。\n" +"正規表現内の空白は、文字クラス内にある場合や、エスケープされていないバックス" +"ラッシュが直前にある場合を除き、無視されます。\n" +"そのため、正規表現を整理してインデントできます。\n" +"また、エンジンが無視するコメントも書けます。\n" +"文字クラス内ではなく、直前にエスケープされていないバックスラッシュもない " +"``'#'`` からコメントが始まります。" #: ../../howto/regex.rst:648 msgid "" @@ -1365,7 +1421,6 @@ msgstr "" "例えば、ここに :const:`re.VERBOSE` を利用した正規表現があります; 読み易いと思" "いませんか? ::" -#: ../../howto/regex.rst:651 msgid "" "charref = re.compile(r\"\"\"\n" " &[#] # Start of a numeric entity reference\n" @@ -1377,17 +1432,28 @@ msgid "" " ; # Trailing semicolon\n" "\"\"\", re.VERBOSE)" msgstr "" +"charref = re.compile(r\"\"\"\n" +" &[#] # Start of a numeric entity reference\n" +" (\n" +" 0[0-7]+ # Octal form\n" +" | [0-9]+ # Decimal form\n" +" | x[0-9a-fA-F]+ # Hexadecimal form\n" +" )\n" +" ; # Trailing semicolon\n" +"\"\"\", re.VERBOSE)" #: ../../howto/regex.rst:661 msgid "Without the verbose setting, the RE would look like this::" msgstr "冗長な表現を利用しない設定の場合、正規表現はこうなります::" -#: ../../howto/regex.rst:663 msgid "" "charref = re.compile(\"&#(0[0-7]+\"\n" " \"|[0-9]+\"\n" " \"|x[0-9a-fA-F]+);\")" msgstr "" +"charref = re.compile(\"&#(0[0-7]+\"\n" +" \"|[0-9]+\"\n" +" \"|x[0-9a-fA-F]+);\")" #: ../../howto/regex.rst:667 msgid "" @@ -1399,9 +1465,8 @@ msgstr "" "割しています、それでも :const:`re.VERBOSE` を使った場合に比べるとまだ難しく" "なっています。" -#: ../../howto/regex.rst:673 msgid "More pattern power" -msgstr "" +msgstr "パターンのさらなる機能" #: ../../howto/regex.rst:675 msgid "" @@ -1413,9 +1478,8 @@ msgstr "" "くつかの特殊文字とグループを使ってマッチしたテキストの一部をどう取得するかに" "ついて扱います。" -#: ../../howto/regex.rst:683 msgid "More metacharacters" -msgstr "" +msgstr "その他の特殊文字" #: ../../howto/regex.rst:685 msgid "" @@ -1425,7 +1489,6 @@ msgstr "" "これまでで、まだ扱っていない特殊文字がいくつかありました。そのほとんどをこの" "節で扱っていきます。" -#: ../../howto/regex.rst:688 msgid "" "Some of the remaining metacharacters to be discussed are :dfn:`zero-width " "assertions`. They don't cause the engine to advance through the string; " @@ -1436,12 +1499,12 @@ msgid "" "once at a given location, they can obviously be matched an infinite number " "of times." msgstr "" -"残りの特殊文字の内いくつかは :dfn:`ゼロ幅アサーション zero-width-assertions` " -"に関するものです。これらは文字列に対してエンジンを進めません; 文字列を全く利" -"用しない代わりに、単純に成功か失敗かを利用します。例えば、 ``\\b`` は現在位置" -"が単語の境界であることを示します; ``\\b`` によってエンジンの読んでいる位置は" -"全く変化しません。つまり、これはゼロ幅アサーションは繰り返し使うことがありま" -"せん、一度ある位置でマッチしたら、明らかに無限回マッチできます。" +"残りの特殊文字には :dfn:`ゼロ幅アサーション` があります。\n" +"これは文字を一つも消費せず、成功か失敗かを判定するだけなので、エンジンが文字" +"列内を進むことはありません。\n" +"例えば ``\\b`` は現在位置が単語の境界であることを判定し、位置を変えません。\n" +"ゼロ幅アサーションは繰り返すべきではありません。\n" +"ある位置で一度マッチすれば、そこで何度でもマッチできてしまうためです。" #: ../../howto/regex.rst:696 msgid "``|``" @@ -1494,13 +1557,16 @@ msgstr "" "例えば、行の先頭の ``From`` にのみマッチさせたい場合には ``^From`` 正規表現を" "利用します。 ::" -#: ../../howto/regex.rst:714 msgid "" ">>> print(re.search('^From', 'From Here to Eternity'))\n" "\n" ">>> print(re.search('^From', 'Reciting From Memory'))\n" "None" msgstr "" +">>> print(re.search('^From', 'From Here to Eternity'))\n" +"\n" +">>> print(re.search('^From', 'Reciting From Memory'))\n" +"None" #: ../../howto/regex.rst:719 msgid "To match a literal ``'^'``, use ``\\^``." @@ -1518,7 +1584,6 @@ msgstr "" "行の末尾にマッチします、行の末尾は文字列の末尾と改行文字の直前として定義され" "ます。 ::" -#: ../../howto/regex.rst:725 msgid "" ">>> print(re.search('}$', '{block}'))\n" "\n" @@ -1527,6 +1592,12 @@ msgid "" ">>> print(re.search('}$', '{block}\\n'))\n" "" msgstr "" +">>> print(re.search('}$', '{block}'))\n" +"\n" +">>> print(re.search('}$', '{block} '))\n" +"None\n" +">>> print(re.search('}$', '{block}\\n'))\n" +"" #: ../../howto/regex.rst:732 msgid "" @@ -1553,9 +1624,8 @@ msgstr "" "いは: ``\\A`` は依然として文字列の先頭にのみマッチしますが、 ``^`` は文字列内" "に改行文字に続く部分があればそこにマッチすることです。" -#: ../../howto/regex.rst:741 msgid "``\\z``" -msgstr "" +msgstr "``\\z``" #: ../../howto/regex.rst:742 msgid "Matches only at the end of the string." @@ -1565,9 +1635,10 @@ msgstr "文字列の末尾でのみマッチします。" msgid "``\\Z``" msgstr "``\\Z``" -#: ../../howto/regex.rst:745 msgid "The same as ``\\z``. For compatibility with old Python versions." msgstr "" +"``\\z`` と同じです。\n" +"古い Python バージョンとの互換性のためにあります。" #: ../../howto/regex.rst:747 msgid "``\\b``" @@ -1592,7 +1663,6 @@ msgstr "" "以下の例では ``class`` がそのものの単語のときのみマッチします; 別の単語内に含" "まれている場合はマッチしません。 ::" -#: ../../howto/regex.rst:756 msgid "" ">>> p = re.compile(r'\\bclass\\b')\n" ">>> print(p.search('no class at all'))\n" @@ -1602,6 +1672,13 @@ msgid "" ">>> print(p.search('one subclass is'))\n" "None" msgstr "" +">>> p = re.compile(r'\\bclass\\b')\n" +">>> print(p.search('no class at all'))\n" +"\n" +">>> print(p.search('the declassified algorithm'))\n" +"None\n" +">>> print(p.search('one subclass is'))\n" +"None" #: ../../howto/regex.rst:764 msgid "" @@ -1621,7 +1698,6 @@ msgstr "" "じ正規表現のように見えますが、正規表現文字列の前の ``'r'`` が省略されていま" "す。 ::" -#: ../../howto/regex.rst:772 msgid "" ">>> p = re.compile('\\bclass\\b')\n" ">>> print(p.search('no class at all'))\n" @@ -1629,6 +1705,11 @@ msgid "" ">>> print(p.search('\\b' + 'class' + '\\b'))\n" "" msgstr "" +">>> p = re.compile('\\bclass\\b')\n" +">>> print(p.search('no class at all'))\n" +"None\n" +">>> print(p.search('\\b' + 'class' + '\\b'))\n" +"" #: ../../howto/regex.rst:778 msgid "" @@ -1669,13 +1750,16 @@ msgstr "" "て興味ある部分にマッチするようにして、文字列を分割するのに使われます。例え" "ば、RFC-822 ヘッダ行は ``':'`` を挟んでこのようにヘッダ名と値に分割されます:" -#: ../../howto/regex.rst:796 msgid "" "From: author@example.com\n" "User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n" "MIME-Version: 1.0\n" "To: editor@example.com" msgstr "" +"From: author@example.com\n" +"User-Agent: Thunderbird 1.5.0.9 (X11/20061227)\n" +"MIME-Version: 1.0\n" +"To: editor@example.com" #: ../../howto/regex.rst:803 msgid "" @@ -1701,12 +1785,14 @@ msgstr "" "子を使った繰り返しを表現することもできます。例えば、 ``(ab)*`` は ``ab`` の0" "回以上の繰り返しにマッチします。 ::" -#: ../../howto/regex.rst:814 msgid "" ">>> p = re.compile('(ab)*')\n" ">>> print(p.search('ababababab').span())\n" "(0, 10)" msgstr "" +">>> p = re.compile('(ab)*')\n" +">>> print(p.search('ababababab').span())\n" +"(0, 10)" #: ../../howto/regex.rst:818 msgid "" @@ -1727,7 +1813,6 @@ msgstr "" "デフォルト引数にしています。マッチするテキストの範囲をキャプチャしないグルー" "プの書き方はのちほど見ることにします。 ::" -#: ../../howto/regex.rst:827 msgid "" ">>> p = re.compile('(a)b')\n" ">>> m = p.search('ab')\n" @@ -1736,6 +1821,12 @@ msgid "" ">>> m.group(0)\n" "'ab'" msgstr "" +">>> p = re.compile('(a)b')\n" +">>> m = p.search('ab')\n" +">>> m.group()\n" +"'ab'\n" +">>> m.group(0)\n" +"'ab'" #: ../../howto/regex.rst:834 msgid "" @@ -1746,7 +1837,6 @@ msgstr "" "サブグループは左から右へ1づつ番号付けされます。グループはネストしてもかまいま" "せん; 番号を決めるには、単に開き括弧を左から右へ数え上げます。 ::" -#: ../../howto/regex.rst:838 msgid "" ">>> p = re.compile('(a(b)c)d')\n" ">>> m = p.search('abcd')\n" @@ -1757,6 +1847,14 @@ msgid "" ">>> m.group(2)\n" "'b'" msgstr "" +">>> p = re.compile('(a(b)c)d')\n" +">>> m = p.search('abcd')\n" +">>> m.group(0)\n" +"'abcd'\n" +">>> m.group(1)\n" +"'abc'\n" +">>> m.group(2)\n" +"'b'" #: ../../howto/regex.rst:847 msgid "" @@ -1767,11 +1865,12 @@ msgstr "" ":meth:`~re.Match.group` には一回に複数の引数を渡してもかまいません、その場合" "にはそれらのグループに対応する値を含むタプルを返します。 ::" -#: ../../howto/regex.rst:850 msgid "" ">>> m.group(2,1,2)\n" "('b', 'abc', 'b')" msgstr "" +">>> m.group(2,1,2)\n" +"('b', 'abc', 'b')" #: ../../howto/regex.rst:853 msgid "" @@ -1781,11 +1880,12 @@ msgstr "" ":meth:`~re.Match.groups` メソッドは 1 から全てのサブグループの文字列を含むタ" "プルを返します。::" -#: ../../howto/regex.rst:856 msgid "" ">>> m.groups()\n" "('abc', 'b')" msgstr "" +">>> m.groups()\n" +"('abc', 'b')" #: ../../howto/regex.rst:859 msgid "" @@ -1808,12 +1908,14 @@ msgstr "" msgid "For example, the following RE detects doubled words in a string. ::" msgstr "例えば、以下の正規表現は二重になった単語を検出します。 ::" -#: ../../howto/regex.rst:869 msgid "" ">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n" ">>> p.search('Paris in the the spring').group()\n" "'the the'" msgstr "" +">>> p = re.compile(r'\\b(\\w+)\\s+\\1\\b')\n" +">>> p.search('Paris in the the spring').group()\n" +"'the the'" #: ../../howto/regex.rst:873 msgid "" @@ -1826,9 +1928,8 @@ msgstr "" "ん。--- このように繰り返されるテキストフォーマットは少数です。--- しかし、文" "字列の置換をする場合には *とても* 有効であることに気づくでしょう。" -#: ../../howto/regex.rst:879 msgid "Non-capturing and named groups" -msgstr "" +msgstr "取り込まないグループと名前付きグループ" #: ../../howto/regex.rst:881 msgid "" @@ -1844,7 +1945,6 @@ msgstr "" "なっていきます。この問題の解決を助ける二つの機能があります。その両方が正規表" "現を拡張するための一般的な構文を利用します、まずはそれらをみてみましょう。" -#: ../../howto/regex.rst:887 msgid "" "Perl 5 is well known for its powerful additions to standard regular " "expressions. For these new features the Perl developers couldn't choose new " @@ -1854,13 +1954,12 @@ msgid "" "expressions would be assuming that ``&`` was a regular character and " "wouldn't have escaped it by writing ``\\&`` or ``[&]``." msgstr "" -"Perl 5 は標準正規表現にパワフルな拡張を加えたことでよく知られています。それら" -"の新しい機能のために Perl 開発者たちは、Perl正規表現と標準正規表現との混乱を" -"招く違いなしには、新たな一文字メタキャラクタも ``\\`` ではじまる新たな特殊" -"シーケンスもどちらも選択出来ませんでした。たとえば彼らがもし ``&`` を新たなメ" -"タキャラクタとして選んでいたら、 ``&`` が通常文字とみなされていた古い正規表現" -"は ``\\&`` や ``[&]`` のように書くことでエスケープされなければならなかったで" -"しょう。" +"Perl 5 は、標準的な正規表現への強力な拡張でよく知られています。\n" +"新機能のために一文字のメタ文字や ``\\`` で始まる特殊シーケンスを追加すると、" +"標準的な正規表現との違いが混乱を招くため、Perl の開発者はそれらを選べませんで" +"した。\n" +"例えば ``&`` を新しいメタ文字にしたとすると、従来の式では ``&`` を通常の文字" +"として扱っているため、``\\&`` や ``[&]`` としてエスケープしていないはずです。" #: ../../howto/regex.rst:894 msgid "" @@ -1909,7 +2008,6 @@ msgstr "" "出さないグループ: ``(?:...)`` を使います。 ``...`` 部分は任意の正規表現で" "す。 ::" -#: ../../howto/regex.rst:915 msgid "" ">>> m = re.search(\"([abc])+\", \"abc\")\n" ">>> m.groups()\n" @@ -1918,8 +2016,13 @@ msgid "" ">>> m.groups()\n" "()" msgstr "" +">>> m = re.search(\"([abc])+\", \"abc\")\n" +">>> m.groups()\n" +"('c',)\n" +">>> m = re.search(\"(?:[abc])+\", \"abc\")\n" +">>> m.groups()\n" +"()" -#: ../../howto/regex.rst:922 msgid "" "Except for the fact that you can't retrieve the contents of what the group " "matched, a non-capturing group behaves exactly the same as a capturing " @@ -1931,14 +2034,14 @@ msgid "" "performance difference in searching between capturing and non-capturing " "groups; neither form is any faster than the other." msgstr "" -"マッチしたグループの内容を取得しないということを除けば、取り込まないグループ" -"は厳密に取り込むグループと同様に振る舞います; この中に何を入れてもかまいませ" -"ん、 ``*`` のような繰り返しの特殊文字で繰り返したり、他のグループ (取り込むま" -"たは取り込まない) の入れ子にすることもでいます。 ``(?:...)`` は特に、既にある" -"パターンを変更する際に便利です、なぜなら他の番号づけ新しいグループを変更する" -"ことなく新しいグループを追加することができます。取り込むグループと取り込まな" -"いグループで検索のパフォーマンスに差がないことにも触れておくべきことです; ど" -"ちらも同じ速度で動作します。" +"取り込まないグループは、マッチした内容を取得できない点以外は、取り込むグルー" +"プと同じように動作します。\n" +"中に任意の正規表現を置いたり、``*`` などの特殊文字で繰り返したり、他のグルー" +"プ (取り込むものも取り込まないものも) の中に入れ子にしたりできます。\n" +"``(?:...)`` は既存のパターンを変更するときに特に便利です。\n" +"他のグループの番号を変えずに、新しいグループを追加できます。\n" +"なお、検索時の性能はどちらのグループでも変わらず、片方が速いということはあり" +"ません。" #: ../../howto/regex.rst:931 msgid "" @@ -1967,7 +2070,6 @@ msgstr "" "容しています。名前つきグループにも番号が振られますので、グループについての情" "報を、2つの方法で取り出せます::" -#: ../../howto/regex.rst:942 msgid "" ">>> p = re.compile(r'(?P\\b\\w+\\b)')\n" ">>> m = p.search( '(((( Lots of punctuation )))' )\n" @@ -1976,6 +2078,12 @@ msgid "" ">>> m.group(1)\n" "'Lots'" msgstr "" +">>> p = re.compile(r'(?P\\b\\w+\\b)')\n" +">>> m = p.search( '(((( Lots of punctuation )))' )\n" +">>> m.group('word')\n" +"'Lots'\n" +">>> m.group(1)\n" +"'Lots'" #: ../../howto/regex.rst:949 msgid "" @@ -1985,12 +2093,14 @@ msgstr "" "さらに、名前付きのグループを :meth:`~re.Match.groupdict` を使って辞書として取" "り出すこともできます::" -#: ../../howto/regex.rst:952 msgid "" ">>> m = re.search(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" ">>> m.groupdict()\n" "{'first': 'Jane', 'last': 'Doe'}" msgstr "" +">>> m = re.search(r'(?P\\w+) (?P\\w+)', 'Jane Doe')\n" +">>> m.groupdict()\n" +"{'first': 'Jane', 'last': 'Doe'}" #: ../../howto/regex.rst:956 msgid "" @@ -2002,7 +2112,6 @@ msgstr "" "め、便利です。以下は :mod:`imaplib` モジュールで使われている正規表現の例で" "す::" -#: ../../howto/regex.rst:960 msgid "" "InternalDate = re.compile(r'INTERNALDATE \"'\n" " r'(?P[ 123][0-9])-(?P[A-Z][a-z][a-z])-'\n" @@ -2011,6 +2120,12 @@ msgid "" " r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'\n" " r'\"')" msgstr "" +"InternalDate = re.compile(r'INTERNALDATE \"'\n" +" r'(?P[ 123][0-9])-(?P[A-Z][a-z][a-z])-'\n" +" r'(?P[0-9][0-9][0-9][0-9])'\n" +" r' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])'\n" +" r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'\n" +" r'\"')" #: ../../howto/regex.rst:967 msgid "" @@ -2037,16 +2152,17 @@ msgstr "" "同じ単語が2つ連なっているのを見つける正規表現 ``\\b(\\w+)\\s+\\1\\b`` は " "``\\b(?P\\w+)\\s+(?P=word)\\b`` のように書けます::" -#: ../../howto/regex.rst:977 msgid "" ">>> p = re.compile(r'\\b(?P\\w+)\\s+(?P=word)\\b')\n" ">>> p.search('Paris in the the spring').group()\n" "'the the'" msgstr "" +">>> p = re.compile(r'\\b(?P\\w+)\\s+(?P=word)\\b')\n" +">>> p.search('Paris in the the spring').group()\n" +"'the the'" -#: ../../howto/regex.rst:983 msgid "Lookahead assertions" -msgstr "" +msgstr "先読みアサーション" #: ../../howto/regex.rst:985 msgid "" @@ -2061,7 +2177,6 @@ msgstr "" msgid "``(?=...)``" msgstr "``(?=...)``" -#: ../../howto/regex.rst:989 msgid "" "Positive lookahead assertion. This succeeds if the contained regular " "expression, represented here by ``...``, successfully matches at the current " @@ -2069,9 +2184,11 @@ msgid "" "tried, the matching engine doesn't advance at all; the rest of the pattern " "is tried right where the assertion started." msgstr "" -"肯定先読みアサーション。 ``...`` で表わす正規表現が現在位置でマッチすれば成功" -"し、それ以外の場合失敗します。しかし、表現が試行された場合でもエンジンは先に" -"進みません; パターンの残りの部分はアサーションの開始時点から右に試行します。" +"肯定先読みアサーションです。\n" +"ここで ``...`` と表している内部の正規表現が現在位置でマッチすれば成功し、それ" +"以外は失敗します。\n" +"内部の正規表現を試してもマッチングエンジンの位置は進みません。\n" +"残りのパターンは、アサーションを開始したのとまったく同じ位置から試されます。" #: ../../howto/regex.rst:995 msgid "``(?!...)``" @@ -2129,22 +2246,22 @@ msgstr "" "さて、問題を少し複雑にしてみましょう; 拡張子が ``bat`` でないファイル名にマッ" "チしたい場合はどうでしょう?間違った試み:" -#: ../../howto/regex.rst:1019 msgid "``.*[.][^b].*$``" -msgstr "" +msgstr "``.*[.][^b].*$``" -#: ../../howto/regex.rst:1021 msgid "" "The first attempt above tries to exclude ``bat`` by requiring that the first " "character of the extension is not a ``b``. This is wrong, because the " "pattern also doesn't match ``foo.bar``." msgstr "" +"最初の試みでは、拡張子の先頭が ``b`` でないことを条件にして ``bat`` を除外し" +"ようとしています。\n" +"しかし、これでは ``foo.bar`` にもマッチしないため、正しくありません。" #: ../../howto/regex.rst:1025 msgid "``.*[.]([^b]..|.[^a].|..[^t])$``" msgstr "``.*[.]([^b]..|.[^a].|..[^t])$``" -#: ../../howto/regex.rst:1027 msgid "" "The expression gets messier when you try to patch up the first solution by " "requiring one of the following cases to match: the first character of the " @@ -2154,12 +2271,13 @@ msgid "" "with a two-letter extension such as ``sendmail.cf``. We'll complicate the " "pattern again in an effort to fix it." msgstr "" -"正規表現が混乱してきました。最初の解決策を取り繕って、以下の場合に合わせるこ" -"とを要求しています: 拡張子の最初の文字は ``b`` でなく; 二番目の文字は ``a`` " -"でなく; 三番目の文字は ``t`` でない。これは ``foo.bar`` を受け付けますが、 " -"``autoexec.bat`` は拒否します。しかし、三文字の拡張子を要求し、 ``sendmail." -"cf`` のような二文字の拡張子を受け付けません。これを修正するのにパターンを再び" -"複雑にすることになります。" +"最初の試みを修正し、拡張子の最初の文字が ``b`` でない、二文字目が ``a`` でな" +"い、三文字目が ``t`` でない、のいずれかを満たすようにすると、正規表現は複雑に" +"なります。\n" +"これなら ``foo.bar`` を受け入れ、``autoexec.bat`` を除外できます。\n" +"しかし拡張子が三文字であることを要求するため、``sendmail.cf`` のような二文字" +"の拡張子は受け入れられません。\n" +"これを修正すると、パターンはさらに複雑になります。" #: ../../howto/regex.rst:1035 msgid "``.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$``" @@ -2189,9 +2307,8 @@ msgstr "" msgid "A negative lookahead cuts through all this confusion:" msgstr "否定先読みはこの混乱全てを取り除きます:" -#: ../../howto/regex.rst:1048 msgid "``.*[.](?!bat$)[^.]*$``" -msgstr "" +msgstr "``.*[.](?!bat$)[^.]*$``" #: ../../howto/regex.rst:1050 msgid "" @@ -2217,9 +2334,8 @@ msgstr "" msgid "``.*[.](?!bat$|exe$)[^.]*$``" msgstr "``.*[.](?!bat$|exe$)[^.]*$``" -#: ../../howto/regex.rst:1065 msgid "Modifying strings" -msgstr "" +msgstr "文字列の変更" #: ../../howto/regex.rst:1067 msgid "" @@ -2260,11 +2376,9 @@ msgid "" msgstr "" ":meth:`!sub` と同じことをしますが、新しい文字列と置き換えの回数を返します" -#: ../../howto/regex.rst:1087 msgid "Splitting strings" -msgstr "" +msgstr "文字列の分割" -#: ../../howto/regex.rst:1089 msgid "" "The :meth:`~re.Pattern.split` method of a pattern splits a string apart " "wherever the RE matches, returning a list of the pieces. It's similar to " @@ -2273,11 +2387,12 @@ msgid "" "splitting by whitespace or by a fixed string. As you'd expect, there's a " "module-level :func:`re.split` function, too." msgstr "" -":meth:`~re.Match.split` メソッドは文字列を正規表現にマッチした場所で分割し、" -"リストで返却します。文字列の :meth:`~str.split` メソッドに似てはいますが、" -"もっとずっと一般化したデリミタで分割出来ます; 文字列の :meth:`!split` メソッ" -"ドは単に空白文字か固定文字列で分割出来るだけです。ご想像通り、モジュールレベ" -"ルの :func:`re.split` 関数もあります。" +"パターンの :meth:`~re.Pattern.split` メソッドは、正規表現がマッチする箇所で文" +"字列を分割し、各部分のリストを返します。\n" +"文字列の :meth:`~str.split` に似ていますが、区切りの指定にはずっと自由度があ" +"ります。\n" +"文字列の :meth:`!split` は空白か固定文字列でしか分割できません。\n" +"モジュールレベルの :func:`re.split` 関数もあります。" #: ../../howto/regex.rst:1100 msgid "" @@ -2290,7 +2405,6 @@ msgstr "" "されている場合、その内容も結果のリストの一部として返されます。 *maxsplit* が" "非ゼロの場合、最大で *maxsplit* の分割が実行されます。" -#: ../../howto/regex.rst:1105 msgid "" "You can limit the number of splits made, by passing a value for *maxsplit*. " "When *maxsplit* is nonzero, at most *maxsplit* splits will be made, and the " @@ -2298,12 +2412,11 @@ msgid "" "the following example, the delimiter is any sequence of non-alphanumeric " "characters. ::" msgstr "" -"*maxsplit* に値を渡すことで、分割される回数を制限することができます。 " -"*maxsplit* が非ゼロの場合、最大で *maxsplit* の分割が行なわれ、文字列の残りが" -"リストの最終要素として返されます。以下の例では、デリミタは任意の英数文字の" -"シーケンスです。 ::" +"*maxsplit* に値を渡すと、分割回数を制限できます。\n" +"*maxsplit* がゼロでなければ最大でその回数だけ分割し、残りの文字列をリストの最" +"後の要素として返します。\n" +"次の例では、英数字以外の文字が連続する部分が区切りになります。 ::" -#: ../../howto/regex.rst:1111 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p.split('This is a test, short and sweet, of split().')\n" @@ -2311,6 +2424,11 @@ msgid "" ">>> p.split('This is a test, short and sweet, of split().', 3)\n" "['This', 'is', 'a', 'test, short and sweet, of split().']" msgstr "" +">>> p = re.compile(r'\\W+')\n" +">>> p.split('This is a test, short and sweet, of split().')\n" +"['This', 'is', 'a', 'test', 'short', 'and', 'sweet', 'of', 'split', '']\n" +">>> p.split('This is a test, short and sweet, of split().', 3)\n" +"['This', 'is', 'a', 'test, short and sweet, of split().']" #: ../../howto/regex.rst:1117 msgid "" @@ -2323,7 +2441,6 @@ msgstr "" "知りたい場合はよくあります。取りこみ用の括弧を正規表現に使った場合、その値も" "リストの一部として返されます。以下の呼び出しを比較してみましょう::" -#: ../../howto/regex.rst:1122 msgid "" ">>> p = re.compile(r'\\W+')\n" ">>> p2 = re.compile(r'(\\W+)')\n" @@ -2332,6 +2449,12 @@ msgid "" ">>> p2.split('This... is a test.')\n" "['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" msgstr "" +">>> p = re.compile(r'\\W+')\n" +">>> p2 = re.compile(r'(\\W+)')\n" +">>> p.split('This... is a test.')\n" +"['This', 'is', 'a', 'test', '']\n" +">>> p2.split('This... is a test.')\n" +"['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']" #: ../../howto/regex.rst:1129 msgid "" @@ -2341,7 +2464,6 @@ msgstr "" "モジュールレベル関数 :func:`re.split` は最初の引数に利用する正規表現を追加し" "ますが、それ以外は同じです。 ::" -#: ../../howto/regex.rst:1132 msgid "" ">>> re.split(r'[\\W]+', 'Words, words, words.')\n" "['Words', 'words', 'words', '']\n" @@ -2350,32 +2472,35 @@ msgid "" ">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" "['Words', 'words, words.']" msgstr "" +">>> re.split(r'[\\W]+', 'Words, words, words.')\n" +"['Words', 'words', 'words', '']\n" +">>> re.split(r'([\\W]+)', 'Words, words, words.')\n" +"['Words', ', ', 'words', ', ', 'words', '.', '']\n" +">>> re.split(r'[\\W]+', 'Words, words, words.', 1)\n" +"['Words', 'words, words.']" -#: ../../howto/regex.rst:1141 msgid "Search and replace" -msgstr "" +msgstr "検索と置換" -#: ../../howto/regex.rst:1143 msgid "" "Another common task is to find all the matches for a pattern, and replace " "them with a different string. The :meth:`~re.Pattern.sub` method takes a " "replacement value, which can be either a string or a function, and the " "string to be processed." msgstr "" -"もう一つのよくある作業は、パターンにマッチする全ての文字列を探し、異なる文字" -"列に置換します。\n" -":meth:`~re.Pattern.sub` メソッドは置換する値をとります、文字列と関数の両方を" -"とることができ、文字列を処理します。" +"パターンにマッチする部分をすべて探し、別の文字列に置き換えることもよくある作" +"業です。\n" +":meth:`~re.Pattern.sub` は、置換する値 (文字列または関数) と、処理対象の文字" +"列を受け取ります。" -#: ../../howto/regex.rst:1150 msgid "" "Returns the string obtained by replacing the leftmost non-overlapping " "occurrences of the RE in *string* by the replacement *replacement*. If the " "pattern isn't found, *string* is returned unchanged." msgstr "" -"*string* 内で最も長く、他の部分と重複するところがない正規表現を " -"*replacement* に置換した文字列を返します。パターンが見つからなかった場合 " -"*string* は変更されずに返されます。" +"*string* 内で正規表現にマッチする、互いに重ならない部分を左から順に " +"*replacement* に置き換えた文字列を返します。\n" +"パターンが見つからなければ *string* をそのまま返します。" #: ../../howto/regex.rst:1154 msgid "" @@ -2395,7 +2520,6 @@ msgstr "" "ここに :meth:`~re.Pattern.sub` メソッドを使った単純な例があります。これは色の" "名前を ``colour`` に置換します::" -#: ../../howto/regex.rst:1161 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.sub('colour', 'blue socks and red shoes')\n" @@ -2403,6 +2527,11 @@ msgid "" ">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" "'colour socks and red shoes'" msgstr "" +">>> p = re.compile('(blue|white|red)')\n" +">>> p.sub('colour', 'blue socks and red shoes')\n" +"'colour socks and colour shoes'\n" +">>> p.sub('colour', 'blue socks and red shoes', count=1)\n" +"'colour socks and red shoes'" #: ../../howto/regex.rst:1167 msgid "" @@ -2413,7 +2542,6 @@ msgstr "" ":meth:`~re.Pattern.subn` メソッドも同じ働きをしますが、新しい文字列と置換の実" "行回数を含む 2-タプルを返します::" -#: ../../howto/regex.rst:1170 msgid "" ">>> p = re.compile('(blue|white|red)')\n" ">>> p.subn('colour', 'blue socks and red shoes')\n" @@ -2421,6 +2549,11 @@ msgid "" ">>> p.subn('colour', 'no colours at all')\n" "('no colours at all', 0)" msgstr "" +">>> p = re.compile('(blue|white|red)')\n" +">>> p.subn('colour', 'blue socks and red shoes')\n" +"('colour socks and colour shoes', 2)\n" +">>> p.subn('colour', 'no colours at all')\n" +"('no colours at all', 0)" #: ../../howto/regex.rst:1176 msgid "" @@ -2430,12 +2563,14 @@ msgstr "" "空文字列とのマッチは、直前の空文字列とマッチした部分と隣接していない場合にの" "み置換されます。 ::" -#: ../../howto/regex.rst:1179 msgid "" ">>> p = re.compile('x*')\n" ">>> p.sub('-', 'abxd')\n" "'-a-b--d-'" msgstr "" +">>> p = re.compile('x*')\n" +">>> p.sub('-', 'abxd')\n" +"'-a-b--d-'" #: ../../howto/regex.rst:1183 msgid "" @@ -2462,14 +2597,15 @@ msgstr "" "この例は単語 ``section`` に続く ``{`` と ``}`` で閉じられた文字列にマッチ" "し、 ``section`` を ``subsection`` に変更します::" -#: ../../howto/regex.rst:1193 msgid "" ">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" "'subsection{First} subsection{second}'" msgstr "" +">>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)\n" +">>> p.sub(r'subsection{\\1}','section{First} section{second}')\n" +"'subsection{First} subsection{second}'" -#: ../../howto/regex.rst:1197 msgid "" "There's also a syntax for referring to named groups as defined by the ``(?" "P...)`` syntax. ``\\g`` will use the substring matched by the " @@ -2480,15 +2616,15 @@ msgid "" "literal character ``'0'``.) The following substitutions are all equivalent, " "but use all three variations of the replacement string. ::" msgstr "" -"``(?P...)`` 構文で定義された名前つきグループを参照するための構文もあり" -"ます。 ``\\g`` は ``name`` で名前づけされたグループにマッチする文字列を" -"利用し、 ``\\g`` は対応するグループ番号を利用します。つまり " -"``\\g<2>`` は ``\\2`` と等価ですが、 ``\\g<2>0`` のような置換文字列に対しては" -"明確に異なります。 (``\\20`` はグループ番号20への参照と解釈され、グループ2の" -"後にリテラル文字 ``'0'`` が続くとは解釈されません。) 以下に示す置換は全て等価" -"ですが、これらは文字列置換に全部で3種の変種を利用しています。 ::" +"``(?P...)`` で定義した名前付きグループを参照する構文もあります。\n" +"``\\g`` は ``name`` というグループにマッチした部分文字列を使い、" +"``\\g`` はグループ番号で指定します。\n" +"``\\g<2>`` は ``\\2`` と同じですが、``\\g<2>0`` のような置換文字列でも曖昧に" +"なりません。\n" +"``\\20`` は、グループ 2 に文字 ``'0'`` を続けたものではなく、グループ 20 への" +"参照と解釈されます。\n" +"次の三つの置換は、それぞれ異なる書き方で同じ結果を得ます。 ::" -#: ../../howto/regex.rst:1206 msgid "" ">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" ">>> p.sub(r'subsection{\\1}','section{First}')\n" @@ -2498,6 +2634,13 @@ msgid "" ">>> p.sub(r'subsection{\\g}','section{First}')\n" "'subsection{First}'" msgstr "" +">>> p = re.compile('section{ (?P [^}]* ) }', re.VERBOSE)\n" +">>> p.sub(r'subsection{\\1}','section{First}')\n" +"'subsection{First}'\n" +">>> p.sub(r'subsection{\\g<1>}','section{First}')\n" +"'subsection{First}'\n" +">>> p.sub(r'subsection{\\g}','section{First}')\n" +"'subsection{First}'" #: ../../howto/regex.rst:1214 msgid "" @@ -2519,7 +2662,6 @@ msgid "" "hexadecimal::" msgstr "続く例では、置換関数は十進数文字列を十六進数文字列に変換しています::" -#: ../../howto/regex.rst:1223 msgid "" ">>> def hexrepl(match):\n" "... \"Return the hex string for a decimal number\"\n" @@ -2530,6 +2672,14 @@ msgid "" ">>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.')\n" "'Call 0xffd2 for printing, 0xc000 for user code.'" msgstr "" +">>> def hexrepl(match):\n" +"... \"Return the hex string for a decimal number\"\n" +"... value = int(match.group())\n" +"... return hex(value)\n" +"...\n" +">>> p = re.compile(r'\\d+')\n" +">>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.')\n" +"'Call 0xffd2 for printing, 0xc000 for user code.'" #: ../../howto/regex.rst:1232 msgid "" @@ -2546,9 +2696,8 @@ msgstr "" "埋め込んだパターン文字列を使うかしなければいけません、例えば ``sub(\"(?i)b+" "\", \"x\", \"bbbb BBBB\")`` は ``'x x'`` を返します。" -#: ../../howto/regex.rst:1240 msgid "Common problems" -msgstr "" +msgstr "よくある問題" #: ../../howto/regex.rst:1242 msgid "" @@ -2561,11 +2710,9 @@ msgstr "" "振る舞いは直感的ではなく、期待通りに振る舞わないことがあります。この節では最" "もよくある落とし穴を指摘します。" -#: ../../howto/regex.rst:1248 msgid "Use string methods" -msgstr "" +msgstr "文字列メソッドを使う" -#: ../../howto/regex.rst:1250 msgid "" "Sometimes using the :mod:`re` module is a mistake. If you're matching a " "fixed string, or a single character class, and you're not using any :mod:" @@ -2576,12 +2723,14 @@ msgid "" "for the purpose, instead of the large, more generalized regular expression " "engine." msgstr "" -"いくつかの場合 :mod:`re` モジュールを利用することは間違いである場合がありま" -"す。固定文字列や単一の文字クラスにマッチさせる場合や、 :const:`~re." -"IGNORECASE` フラグのような :mod:`re` の機能を利用しない場合、正規表現の全ての" -"能力は必要とされていなでしょう。文字列は固定文字列に対する操作を実行するメ" -"ソッドを持っていて、大きな汎用化された正規表現エンジンではなく、目的のために" -"最適化された単一の小さな C loop で実装されているため、大抵の場合高速です." +":mod:`re` モジュールを使わない方がよい場合もあります。\n" +"固定文字列や単一の文字クラスに一致するか調べるだけで、:const:`~re." +"IGNORECASE` フラグなどの :mod:`re` の機能を使わないなら、正規表現の機能は必要" +"ないかもしれません。\n" +"文字列には固定文字列を扱うメソッドがいくつかあり、通常はこちらの方がはるかに" +"高速です。\n" +"大きく汎用的な正規表現エンジンではなく、その目的に最適化された、小さな一つの " +"C のループで実装されているためです。" #: ../../howto/regex.rst:1258 msgid "" @@ -2605,7 +2754,6 @@ msgstr "" "``\\bword\\b`` として、 ``word`` の両側に単語の境界が要求されるようにします。" "これは :meth:`!replace` の能力を越えた作業です。)" -#: ../../howto/regex.rst:1267 msgid "" "Another common task is deleting every occurrence of a single character from " "a string or replacing it with another single character. You might do this " @@ -2613,10 +2761,10 @@ msgid "" "capable of doing both tasks and will be faster than any regular expression " "operation can be." msgstr "" -"別のよくある作業は、文字列の中に出現する文字を全て削除することと、別の文字で" -"置換することです。この作業を ``re.sub('\\n', ' ', S)`` のようにして行うかもし" -"れませんが、 :meth:`~str.translate` は削除と置換の両方の作業をこなし、正規表" -"現操作よりも高速に行うことができます。" +"よくある作業には、文字列中の特定の一文字をすべて削除したり、別の一文字に置換" +"したりすることもあります。\n" +"``re.sub('\\n', ' ', S)`` のように書くこともできますが、:meth:`~str." +"translate` は両方の作業ができ、どの正規表現による操作よりも高速です。" #: ../../howto/regex.rst:1273 msgid "" @@ -2626,56 +2774,67 @@ msgstr "" "要は、 :mod:`re` モジュールに向う前に問題が高速で単純な文字列メソッドで解決で" "きるか考えましょうということです。" -#: ../../howto/regex.rst:1280 msgid "prefixmatch() (aka match) versus search()" -msgstr "" +msgstr "prefixmatch() (別名 match) と search() の違い" -#: ../../howto/regex.rst:1282 msgid "" ":func:`~re.prefixmatch` was added in Python 3.15 as the :ref:`preferred name " "` for :func:`~re.match`. Before this, it was only " "known as :func:`!match` and the distinction with :func:`~re.search` was " "often misunderstood." msgstr "" +":func:`~re.prefixmatch` は Python 3.15 で、:func:`~re.match` の :ref:`推奨さ" +"れる名前 ` として追加されました。\n" +"それ以前は :func:`!match` という名前だけだったため、:func:`~re.search` との違" +"いがよく誤解されていました。" -#: ../../howto/regex.rst:1287 msgid "" ":func:`!prefixmatch` aka :func:`!match` only checks if the RE matches at the " "beginning of the string while :func:`!search` scans forward through the " "string for a match. ::" msgstr "" +":func:`!prefixmatch` (別名 :func:`!match`) は文字列の先頭にマッチするかだけを" +"調べます。\n" +"一方 :func:`!search` は文字列を前から走査してマッチを探します。 ::" -#: ../../howto/regex.rst:1291 msgid "" ">>> print(re.prefixmatch('super', 'superstition').span())\n" "(0, 5)\n" ">>> print(re.prefixmatch('super', 'insuperable'))\n" "None" msgstr "" +">>> print(re.prefixmatch('super', 'superstition').span())\n" +"(0, 5)\n" +">>> print(re.prefixmatch('super', 'insuperable'))\n" +"None" -#: ../../howto/regex.rst:1296 msgid "" "On the other hand, :func:`~re.search` scans forward through the string, " "reporting the first match it finds. ::" msgstr "" +"一方 :func:`~re.search` は文字列を前から走査し、最初に見つけたマッチを返しま" +"す。 ::" -#: ../../howto/regex.rst:1299 msgid "" ">>> print(re.search('super', 'superstition').span())\n" "(0, 5)\n" ">>> print(re.search('super', 'insuperable').span())\n" "(2, 7)" msgstr "" +">>> print(re.search('super', 'superstition').span())\n" +"(0, 5)\n" +">>> print(re.search('super', 'insuperable').span())\n" +"(2, 7)" -#: ../../howto/regex.rst:1304 msgid "" "This distinction is important to remember when using the old :func:`~re." "match` name in code requiring compatibility with older Python versions." msgstr "" +"古い Python バージョンとの互換性のために :func:`~re.match` という名前を使う" +"コードでは、この違いを覚えておくことが重要です。" -#: ../../howto/regex.rst:1309 msgid "Greedy versus non-greedy" -msgstr "" +msgstr "貪欲と非貪欲" #: ../../howto/regex.rst:1311 msgid "" @@ -2691,7 +2850,6 @@ msgstr "" "す。単一の HTML タグにマッチする素朴な正規表現はうまく動作しません、なぜなら" "ば ``.*`` は貪欲に動作するからです。 ::" -#: ../../howto/regex.rst:1317 msgid "" ">>> s = 'Title'\n" ">>> len(s)\n" @@ -2701,6 +2859,13 @@ msgid "" ">>> print(re.prefixmatch('<.*>', s).group())\n" "Title" msgstr "" +">>> s = 'Title'\n" +">>> len(s)\n" +"32\n" +">>> print(re.prefixmatch('<.*>', s).span())\n" +"(0, 32)\n" +">>> print(re.prefixmatch('<.*>', s).group())\n" +"Title" #: ../../howto/regex.rst:1325 msgid "" @@ -2734,13 +2899,13 @@ msgstr "" "ら、各ステップで ``'>'`` のマッチを試みます。この動作は正しい結果を生成しま" "す::" -#: ../../howto/regex.rst:1338 msgid "" ">>> print(re.prefixmatch('<.*?>', s).group())\n" "" msgstr "" +">>> print(re.prefixmatch('<.*?>', s).group())\n" +"" -#: ../../howto/regex.rst:1341 msgid "" "(Note that parsing HTML or XML with regular expressions is painful. Quick-" "and-dirty patterns will handle common cases, but HTML and XML have special " @@ -2749,11 +2914,11 @@ msgid "" "patterns will be *very* complicated. Use an HTML or XML parser module for " "such tasks.)" msgstr "" -"(HTML や XML を正規表現でパースすることは苦痛を伴うものであることは記憶に留め" -"ておいて下さい。素早く、汚いパターンは大抵の場合うまく動作しますが、HTML と " -"XML は正規表現が破綻する特別な例です; 全ての可能な場合にうまく動作する正規表" -"現を書き上げたときには、パターンは *非常に* 複雑なものになります。そのような" -"作業をする場合には HTML や XML パーサを利用しましょう。)" +"HTML や XML を正規表現で解析するのは大変です。\n" +"間に合わせのパターンでも一般的な場合は扱えますが、HTML や XML には、単純な正" +"規表現では対応できない特殊な場合があります。\n" +"すべての場合を扱おうとすると、パターンは *非常に* 複雑になります。\n" +"このような作業には HTML や XML のパーサモジュールを使ってください。" #: ../../howto/regex.rst:1349 msgid "Using re.VERBOSE" @@ -2799,7 +2964,6 @@ msgstr "" "す。三重クォートを利用することで、正規表現をきちんとフォーマットすることがで" "きます::" -#: ../../howto/regex.rst:1368 msgid "" "pat = re.compile(r\"\"\"\n" " \\s* # Skip leading whitespace\n" @@ -2810,26 +2974,37 @@ msgid "" " \\s*$ # Trailing whitespace to end-of-line\n" "\"\"\", re.VERBOSE)" msgstr "" +"pat = re.compile(r\"\"\"\n" +" \\s* # 先頭の空白を読み飛ばす\n" +" (?P
[^:]+) # ヘッダー名\n" +" \\s* : # 空白とコロン\n" +" (?P.*?) # ヘッダーの値。*? を使って\n" +" # 後ろに続く空白を除去する\n" +" \\s*$ # 行末までの空白\n" +"\"\"\", re.VERBOSE)" #: ../../howto/regex.rst:1377 msgid "This is far more readable than::" msgstr "これは下よりはるかに読みやすいです::" -#: ../../howto/regex.rst:1379 msgid "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" -msgstr "" +msgstr "pat = re.compile(r\"\\s*(?P
[^:]+)\\s*:(?P.*?)\\s*$\")" #: ../../howto/regex.rst:1383 msgid "Feedback" msgstr "フィードバック" -#: ../../howto/regex.rst:1385 msgid "" "Regular expressions are a complicated topic. Did this document help you " "understand them? Were there parts that were unclear, or problems you " "encountered that weren't covered here? If so, please send suggestions for " "improvements to the :ref:`issue tracker `." msgstr "" +"正規表現は複雑な話題です。\n" +"この文書は理解の助けになりましたか?\n" +"不明な点や、ここで扱っていない問題に出会いましたか?\n" +"その場合は :ref:`課題追跡システム ` に改善案をお寄せくださ" +"い。" #: ../../howto/regex.rst:1390 msgid "" diff --git a/howto/remote_debugging.po b/howto/remote_debugging.po index 9b88c68d2..5380df35a 100644 --- a/howto/remote_debugging.po +++ b/howto/remote_debugging.po @@ -16,66 +16,67 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/remote_debugging.rst:4 msgid "Remote debugging attachment protocol" -msgstr "" +msgstr "リモートデバッグのアタッチプロトコル" -#: ../../howto/remote_debugging.rst:6 msgid "" "This protocol enables external tools to attach to a running CPython process " "and execute Python code remotely." msgstr "" +"このプロトコルを使うと、外部ツールから実行中の CPython プロセスにアタッチし、" +"Python コードをリモートで実行できます。" -#: ../../howto/remote_debugging.rst:9 msgid "" "Attaching to another Python process may require additional permissions or " "configuration, depending on the platform." msgstr "" +"別の Python プロセスへのアタッチには、プラットフォームによって追加の権限や設" +"定が必要な場合があります。" -#: ../../howto/remote_debugging.rst:13 msgid "Disabling remote debugging" -msgstr "" +msgstr "リモートデバッグの無効化" -#: ../../howto/remote_debugging.rst:15 msgid "To disable remote debugging support, use any of the following:" -msgstr "" +msgstr "リモートデバッグのサポートを無効にするには、次のいずれかを使います。" -#: ../../howto/remote_debugging.rst:17 msgid "" "Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` " "before starting the interpreter." msgstr "" +"インタープリタを起動する前に、環境変数 :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` " +"を ``1`` に設定します。" -#: ../../howto/remote_debugging.rst:19 msgid "Use the :option:`-X disable-remote-debug` command-line option." msgstr "" +"コマンドラインオプション :option:`-X disable-remote-debug` を使います。" -#: ../../howto/remote_debugging.rst:20 msgid "Compile Python with the :option:`--without-remote-debug` build flag." msgstr "" +"ビルドフラグ :option:`--without-remote-debug` を指定して Python をコンパイル" +"します。" -#: ../../howto/remote_debugging.rst:25 msgid "Permission requirements" -msgstr "" +msgstr "必要な権限" -#: ../../howto/remote_debugging.rst:27 msgid "" "Attaching to a running Python process for remote debugging requires special " "configuration on most platforms. The specific requirements and " "troubleshooting steps depend on your operating system:" msgstr "" +"リモートデバッグのために実行中の Python プロセスにアタッチするには、ほとんど" +"のプラットフォームで特別な設定が必要です。\n" +"具体的な要件と問題の解決手順は、オペレーティングシステムによって異なります。" #: ../../howto/remote_debugging.rst:32 msgid "Linux" msgstr "Linux" -#: ../../howto/remote_debugging.rst:33 msgid "" "In general, you can debug your own processes, but there are several common " "configurations that may disable this. Some Linux distributions enable " @@ -83,32 +84,36 @@ msgid "" "versions of the ``setpriv`` command (util-linux 2.41, released June 2025) " "let you loosen ptrace restrictions on a per-process basis:" msgstr "" +"通常は自分のプロセスをデバッグできますが、よく使われる設定の中にはそれを無効" +"にするものがあります。\n" +"一部の Linux ディストリビューションでは、システムのセキュリティを強化するため" +"に **ptrace の制限** (別名「Yama」) を有効にしています。\n" +"最近の ``setpriv`` コマンド (2025 年 6 月リリースの util-linux 2.41) を使う" +"と、プロセスごとに ptrace の制限を緩められます。" -#: ../../howto/remote_debugging.rst:39 msgid "``setpriv --ptracer any python3``" -msgstr "" +msgstr "``setpriv --ptracer any python3``" -#: ../../howto/remote_debugging.rst:41 msgid "" "(This is configured on the process *being debugged*.) You can also turn off " "ptrace restrictions for all processes until reboot with:" msgstr "" +"(この設定は *デバッグ対象の* プロセスに対して行います。) 次のコマンドで、再起" +"動するまで全プロセスの ptrace の制限を無効にすることもできます。" -#: ../../howto/remote_debugging.rst:44 msgid "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``" -msgstr "" +msgstr "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``" -#: ../../howto/remote_debugging.rst:46 msgid "This can also be configured persistently, usually in ``/etc/sysctl.d``." -msgstr "" +msgstr "通常は ``/etc/sysctl.d`` で、この設定を永続化することもできます。" -#: ../../howto/remote_debugging.rst:50 msgid "" "Disabling ``ptrace_scope`` reduces system hardening and should only be done " "in low-security environments." msgstr "" +"``ptrace_scope`` を無効にするとシステムのセキュリティが弱まるため、安全性の要" +"求が低い環境でのみ行ってください。" -#: ../../howto/remote_debugging.rst:53 msgid "" "It is also possible that the ``ptrace`` system call is disabled because of a " "security filter. In particular, this was common with older versions of some " @@ -120,8 +125,18 @@ msgid "" "disable the system call security filter for that container. This weakens the " "container's isolation and should only be done in low-security environments." msgstr "" +"セキュリティフィルターによって ``ptrace`` システムコールが無効になっている場" +"合もあります。\n" +"特に、一部のコンテナーソフトウェアの古いバージョンではよくあることでした。\n" +"Docker 19.03 以降 (2019 年リリース) と containerd 1.6.7 以降 (2022 年リリー" +"ス) は、Linux カーネル 4.8 以降で実行すると、コンテナー内での ``ptrace`` シス" +"テムコールの使用を自動的に許可します。\n" +"これらのバージョンに更新できない場合は、``--security-opt " +"seccomp=unconfined`` のようなオプションを指定してコンテナーを作成し、そのコン" +"テナーのシステムコール用セキュリティフィルターを無効にできます。\n" +"ただし、コンテナーの隔離が弱まるため、安全性の要求が低い環境でのみ行ってくだ" +"さい。" -#: ../../howto/remote_debugging.rst:63 msgid "" "If you need to trace a process that you *do not* own, you will need " "superuser access or equivalent. This also applies to processes that have " @@ -129,8 +144,12 @@ msgid "" "processes (though this is unusual for Python). Try running the debugging " "command with ``sudo -E``." msgstr "" +"自分が所有して *いない* プロセスをトレースするには、スーパーユーザーまたは同" +"等の権限が必要です。\n" +"これは、set-user-ID や set-group-ID のプロセスなど、セキュリティ資格情報を変" +"更したプロセスにも当てはまります (Python ではまれです)。\n" +"``sudo -E`` を付けてデバッグコマンドを実行してみてください。" -#: ../../howto/remote_debugging.rst:70 msgid "" "The ``CAP_SYS_PTRACE`` capability is equivalent to superuser access, in that " "it allows debugging *any* process, not just your own. You may see advice on " @@ -139,24 +158,32 @@ msgid "" "gives the debugging process much more access than it needs and should only " "be done in low-security environments." msgstr "" +"``CAP_SYS_PTRACE`` ケーパビリティは、自分のプロセスだけでなく *あらゆる* プロ" +"セスをデバッグできる点で、スーパーユーザー権限と同等です。\n" +"インターネット上では、ptrace の制限やシステムコールフィルターを回避するために" +"このケーパビリティを使うよう勧める情報を見かけるかもしれません。\n" +"``sudo`` と同様に実際に機能する場合もありますが、デバッグする側のプロセスに必" +"要以上のアクセス権を与えるため、安全性の要求が低い環境でのみ行ってください。" -#: ../../howto/remote_debugging.rst:77 msgid "" "Finally, note that a process can only have one tracer at a time. If you have " "already attached to a Python process under ``strace``, ``gdb``, etc., you " "won't be able to simultaneously use remote debugging. (Superuser access " "cannot get around this restriction.)" msgstr "" +"最後に、一つのプロセスを同時にトレースできるのは一つのトレーサーだけです。\n" +"``strace`` や ``gdb`` などですでに Python プロセスにアタッチしている場合、同" +"時にリモートデバッグは使えません。\n" +"(スーパーユーザー権限でもこの制限は回避できません。)" #: ../../howto/remote_debugging.rst:83 msgid "macOS" msgstr "macOS" -#: ../../howto/remote_debugging.rst:84 msgid "By default, macOS disables the ability to debug other processes." msgstr "" +"デフォルトでは、macOS は他のプロセスをデバッグする機能を無効にしています。" -#: ../../howto/remote_debugging.rst:86 msgid "" "You can modify your Python binary to opt in to being debugged by giving it " "an **ad-hoc code signature** with an **entitlement** enabling it to be " @@ -164,19 +191,27 @@ msgid "" "actual cryptographic signature or a need for a certificate or anything else " "such as an Apple developer program membership.)" msgstr "" +"Python のバイナリに、デバッグを許可する **エンタイトルメント** を含む **アド" +"ホックコード署名** を付けることで、そのバイナリをデバッグ可能にできます。\n" +"(アドホック「署名」は単なる設定です。\n" +"実際の暗号署名は含まず、証明書や Apple Developer Program への加入なども必要あ" +"りません。)" -#: ../../howto/remote_debugging.rst:92 msgid "" "The following commands will create a file ``get-task-allow.plist`` with the " "necessary entitlement and add it to the Python binary:" msgstr "" +"次のコマンドは、必要なエンタイトルメントを含む ``get-task-allow.plist`` ファ" +"イルを作成し、Python のバイナリに追加します。" -#: ../../howto/remote_debugging.rst:95 msgid "" "echo '{\"com.apple.security.get-task-allow\": true}' | plutil -convert xml1 -" "o get-task-allow.plist -\n" "codesign --sign - --entitlements get-task-allow.plist path/to/bin/python3" msgstr "" +"echo '{\"com.apple.security.get-task-allow\": true}' | plutil -convert xml1 -" +"o get-task-allow.plist -\n" +"codesign --sign - --entitlements get-task-allow.plist path/to/bin/python3" #: ../../howto/remote_debugging.rst:100 msgid "" @@ -187,78 +222,84 @@ msgid "" "differently.)" msgstr "" -#: ../../howto/remote_debugging.rst:105 msgid "" "You should then be able to debug your own Python processes started with that " "binary." msgstr "" +"その後は、そのバイナリで起動した自分の Python プロセスをデバッグできるはずで" +"す。" -#: ../../howto/remote_debugging.rst:108 msgid "" "Alternatively, much as with Linux, processes with superuser privileges e.g. " "``sudo`` are not subject to this check and can debug any user's process on " "the system (though there are additional checks on specific binaries, such as " "OS-provided commands, due to System Integrity Protection)." msgstr "" +"また、Linux と同様に、``sudo`` などのスーパーユーザー権限を持つプロセスはこの" +"検査の対象にならず、システム上のどのユーザーのプロセスもデバッグできます。\n" +"ただし、OS が提供するコマンドなどの特定のバイナリには、システム整合性保護によ" +"る追加の検査があります。" #: ../../howto/remote_debugging.rst:114 msgid "Windows" msgstr "Windows" -#: ../../howto/remote_debugging.rst:115 msgid "" "To attach to another process, you usually need to run your debugging tool " "with administrative privileges. Start the command prompt or terminal as " "Administrator." msgstr "" +"別のプロセスにアタッチするには、通常、管理者権限でデバッグツールを実行する必" +"要があります。\n" +"コマンドプロンプトまたはターミナルを管理者として起動してください。" -#: ../../howto/remote_debugging.rst:119 msgid "" "Some processes may still be inaccessible even with Administrator rights, " "unless you have the ``SeDebugPrivilege`` privilege enabled." msgstr "" +"管理者権限があっても、``SeDebugPrivilege`` 特権を有効にしないとアクセスできな" +"いプロセスもあります。" -#: ../../howto/remote_debugging.rst:122 msgid "" "To resolve file or folder access issues, adjust the security permissions:" msgstr "" +"ファイルやフォルダーへのアクセスの問題を解決するには、セキュリティのアクセス" +"許可を調整します。" -#: ../../howto/remote_debugging.rst:124 msgid "Right-click the file or folder and select **Properties**." -msgstr "" +msgstr "ファイルまたはフォルダーを右クリックし、**プロパティ** を選択します。" -#: ../../howto/remote_debugging.rst:125 msgid "Go to the **Security** tab to view users and groups with access." msgstr "" +"**セキュリティ** タブで、アクセスできるユーザーとグループを確認します。" -#: ../../howto/remote_debugging.rst:126 msgid "Click **Edit** to modify permissions." -msgstr "" +msgstr "**編集** をクリックしてアクセス許可を変更します。" -#: ../../howto/remote_debugging.rst:127 msgid "Select your user account." -msgstr "" +msgstr "自分のユーザーアカウントを選択します。" -#: ../../howto/remote_debugging.rst:128 msgid "In **Permissions**, check **Read** or **Full control** as needed." msgstr "" +"**アクセス許可** で、必要に応じて **読み取り** または **フル コントロール** " +"にチェックを入れます。" -#: ../../howto/remote_debugging.rst:129 msgid "Click **Apply**, then **OK** to confirm." -msgstr "" +msgstr "**適用**、**OK** の順にクリックして確定します。" -#: ../../howto/remote_debugging.rst:134 msgid "" "Ensure you've satisfied all :ref:`permission-requirements` before proceeding." msgstr "" +"先に進む前に、:ref:`permission-requirements` をすべて満たしていることを確認し" +"てください。" -#: ../../howto/remote_debugging.rst:136 msgid "" "This section describes the low-level protocol that enables external tools to " "inject and execute a Python script within a running CPython process." msgstr "" +"この節では、外部ツールから実行中の CPython プロセスに Python スクリプトを注入" +"し、実行するための低水準のプロトコルを説明します。" -#: ../../howto/remote_debugging.rst:139 msgid "" "This mechanism forms the basis of the :func:`sys.remote_exec` function, " "which instructs a remote Python process to execute a ``.py`` file. However, " @@ -268,23 +309,34 @@ msgid "" "file to be executed. This information supports independent reimplementation " "of the protocol, regardless of programming language." msgstr "" +"この仕組みは、リモートの Python プロセスに ``.py`` ファイルの実行を指示する :" +"func:`sys.remote_exec` 関数の基盤です。\n" +"ただし、この節はその関数の使い方を説明するものではありません。\n" +"対象の Python プロセスの ``pid`` と実行する Python ソースファイルのパスを入力" +"として受け取る、基盤となるプロトコルを詳しく説明します。\n" +"ここで説明する情報を使えば、プログラミング言語にかかわらず、このプロトコルを" +"独自に実装できます。" -#: ../../howto/remote_debugging.rst:149 msgid "" "The execution of the injected script depends on the interpreter reaching a " "safe evaluation point. As a result, execution may be delayed depending on " "the runtime state of the target process." msgstr "" +"注入したスクリプトは、インタープリタが安全に評価できる地点に到達してから実行" +"されます。\n" +"そのため、対象プロセスの実行状態によっては、実行が遅れることがあります。" -#: ../../howto/remote_debugging.rst:153 msgid "" "Once injected, the script is executed by the interpreter within the target " "process the next time a safe evaluation point is reached. This approach " "enables remote execution capabilities without modifying the behavior or " "structure of the running Python application." msgstr "" +"スクリプトを注入すると、対象プロセスのインタープリタが次に安全に評価できる地" +"点に到達したときに、そのスクリプトを実行します。\n" +"これにより、実行中の Python アプリケーションの動作や構造を変更せずに、リモー" +"ト実行機能を提供できます。" -#: ../../howto/remote_debugging.rst:158 msgid "" "Subsequent sections provide a step-by-step description of the protocol, " "including techniques for locating interpreter structures in memory, safely " @@ -292,12 +344,15 @@ msgid "" "variations are noted where applicable, and example implementations are " "included to clarify each operation." msgstr "" +"以降の節では、メモリ内でインタープリタの構造体を見つける方法、内部フィールド" +"に安全にアクセスする方法、コードの実行を開始させる方法など、プロトコルの手順" +"を説明します。\n" +"プラットフォームによる違いは該当箇所に記し、各操作を明確にするための実装例も" +"示します。" -#: ../../howto/remote_debugging.rst:165 msgid "Locating the PyRuntime structure" -msgstr "" +msgstr "PyRuntime 構造体の位置の特定" -#: ../../howto/remote_debugging.rst:167 msgid "" "CPython places the ``PyRuntime`` structure in a dedicated binary section to " "help external tools find it at runtime. The name and format of this section " @@ -305,13 +360,22 @@ msgid "" "``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this " "structure by examining the binary on disk." msgstr "" +"外部ツールが実行時に見つけやすいように、CPython は ``PyRuntime`` 構造体をバイ" +"ナリ内の専用セクションに配置します。\n" +"このセクションの名前と形式はプラットフォームによって異なります。\n" +"例えば、ELF システムでは ``.PyRuntime``、macOS では ``__DATA,__PyRuntime`` を" +"使います。\n" +"ツールはディスク上のバイナリを調べることで、この構造体のオフセットを見つけら" +"れます。" -#: ../../howto/remote_debugging.rst:173 msgid "" "The ``PyRuntime`` structure contains CPython’s global interpreter state and " "provides access to other internal data, including the list of interpreters, " "thread states, and debugger support fields." msgstr "" +"``PyRuntime`` 構造体には CPython のグローバルなインタープリタの状態が格納され" +"ており、インタープリタのリスト、スレッド状態、デバッガーを支援するフィールド" +"などの内部データにアクセスできます。" #: ../../howto/remote_debugging.rst:177 msgid "" @@ -321,64 +385,67 @@ msgid "" "where the operating system loaded the binary." msgstr "" -#: ../../howto/remote_debugging.rst:182 msgid "" "The method for finding ``PyRuntime`` depends on the platform, but the steps " "are the same in general:" msgstr "" +"``PyRuntime`` の位置を特定する方法はプラットフォームによって異なりますが、大" +"まかな手順は共通です。" -#: ../../howto/remote_debugging.rst:185 msgid "" "Find the base address where the Python binary or shared library was loaded " "in the target process." msgstr "" +"対象プロセスで Python のバイナリまたは共有ライブラリがロードされたベースアド" +"レスを調べます。" -#: ../../howto/remote_debugging.rst:187 msgid "" "Use the on-disk binary to locate the offset of the ``.PyRuntime`` section." msgstr "" +"ディスク上のバイナリを使って ``.PyRuntime`` セクションのオフセットを調べま" +"す。" -#: ../../howto/remote_debugging.rst:188 msgid "" "Add the section offset to the base address to compute the address in memory." msgstr "" +"ベースアドレスにセクションのオフセットを加え、メモリ内のアドレスを求めます。" -#: ../../howto/remote_debugging.rst:190 msgid "" "The sections below explain how to do this on each supported platform and " "include example code." msgstr "" +"以下の節では、サポートされる各プラットフォームでの方法とコード例を示します。" -#: ../../howto/remote_debugging.rst:194 msgid "Linux (ELF)" -msgstr "" +msgstr "Linux (ELF)" -#: ../../howto/remote_debugging.rst:195 msgid "To find the ``PyRuntime`` structure on Linux:" msgstr "" +"Linux で ``PyRuntime`` 構造体の位置を特定するには、次の手順を実行します。" -#: ../../howto/remote_debugging.rst:197 msgid "" "Read the process’s memory map (for example, ``/proc//maps``) to find " "the address where the Python executable or ``libpython`` was loaded." msgstr "" +"プロセスのメモリマップ (例えば ``/proc//maps``) を読み、Python の実行" +"ファイルまたは ``libpython`` がロードされたアドレスを調べます。" -#: ../../howto/remote_debugging.rst:199 msgid "" "Parse the ELF section headers in the binary to get the offset of the ``." "PyRuntime`` section." msgstr "" +"バイナリの ELF セクションヘッダーを解析し、``.PyRuntime`` セクションのオフ" +"セットを取得します。" -#: ../../howto/remote_debugging.rst:201 msgid "" "Add that offset to the base address from step 1 to get the memory address of " "``PyRuntime``." msgstr "" +"手順 1 のベースアドレスにそのオフセットを加え、``PyRuntime`` のメモリアドレス" +"を求めます。" -#: ../../howto/remote_debugging.rst:204 ../../howto/remote_debugging.rst:266 -#: ../../howto/remote_debugging.rst:336 ../../howto/remote_debugging.rst:605 msgid "The following is an example implementation::" -msgstr "" +msgstr "実装例を示します。 ::" #: ../../howto/remote_debugging.rst:206 msgid "" @@ -403,7 +470,6 @@ msgid "" " return base_address + section_offset" msgstr "" -#: ../../howto/remote_debugging.rst:227 msgid "" "On Linux systems, there are two main approaches to read memory from another " "process. The first is through the ``/proc`` filesystem, specifically by " @@ -416,6 +482,16 @@ msgid "" "significantly slower as it only reads one word at a time and requires " "multiple context switches between the tracer and tracee processes." msgstr "" +"Linux では、別のプロセスのメモリを読む主な方法が二つあります。\n" +"一つは ``/proc`` ファイルシステムを使う方法で、具体的にはプロセスのメモリに直" +"接アクセスできる ``/proc/[pid]/mem`` を読みます。\n" +"これには、対象プロセスと同じユーザーであるか root 権限を持つなど、適切な権限" +"が必要です。\n" +"もう一つは、プロセス間でより効率的にメモリをコピーできる " +"``process_vm_readv()`` システムコールを使う方法です。\n" +"ptrace の ``PTRACE_PEEKTEXT`` 操作でもメモリを読めますが、一度に 1 ワードしか" +"読めず、トレースする側とされる側のプロセス間で複数回のコンテキスト切り替えが" +"必要なため、はるかに低速です。" #: ../../howto/remote_debugging.rst:238 msgid "" @@ -430,32 +506,36 @@ msgid "" "memory." msgstr "" -#: ../../howto/remote_debugging.rst:247 msgid "" "You can read more about the ELF file format in the `ELF specification " "`_." msgstr "" +"ELF ファイル形式の詳細は `ELF の仕様 `_ を参照してください。" -#: ../../howto/remote_debugging.rst:252 msgid "macOS (Mach-O)" -msgstr "" +msgstr "macOS (Mach-O)" -#: ../../howto/remote_debugging.rst:253 msgid "To find the ``PyRuntime`` structure on macOS:" msgstr "" +"macOS で ``PyRuntime`` 構造体の位置を特定するには、次の手順を実行します。" -#: ../../howto/remote_debugging.rst:255 msgid "" "Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target " "process. This handle is needed to read memory using APIs like " "``mach_vm_read_overwrite`` and ``mach_vm_region``." msgstr "" +"``task_for_pid()`` を呼び出し、対象プロセスの ``mach_port_t`` タスクポートを" +"取得します。\n" +"このハンドルは、``mach_vm_read_overwrite`` や ``mach_vm_region`` などの API " +"でメモリを読むために必要です。" -#: ../../howto/remote_debugging.rst:258 msgid "" "Scan the memory regions to find the one containing the Python executable or " "``libpython``." msgstr "" +"メモリ領域を調べ、Python の実行ファイルまたは ``libpython`` を含む領域を探し" +"ます。" #: ../../howto/remote_debugging.rst:260 msgid "" @@ -492,7 +572,6 @@ msgid "" " return base_address + section_offset" msgstr "" -#: ../../howto/remote_debugging.rst:291 msgid "" "On macOS, accessing another process's memory requires using Mach-O specific " "APIs and file formats. The first step is obtaining a ``task_port`` handle " @@ -500,8 +579,13 @@ msgid "" "space. This handle enables memory operations through APIs like " "``mach_vm_read_overwrite()``." msgstr "" +"macOS で別のプロセスのメモリにアクセスするには、Mach-O 固有の API とファイル" +"形式を使います。\n" +"まず、``task_for_pid()`` で ``task_port`` ハンドルを取得し、対象プロセスのメ" +"モリ空間にアクセスできるようにします。\n" +"このハンドルを使うと、``mach_vm_read_overwrite()`` などの API でメモリを操作" +"できます。" -#: ../../howto/remote_debugging.rst:297 msgid "" "The process memory can be examined using ``mach_vm_region()`` to scan " "through the virtual memory space, while ``proc_regionfilename()`` helps " @@ -509,8 +593,13 @@ msgid "" "Python binary or library is found, its Mach-O headers need to be parsed to " "locate the ``PyRuntime`` structure." msgstr "" +"``mach_vm_region()`` で仮想メモリ空間を走査すると、プロセスのメモリを調べられ" +"ます。\n" +"``proc_regionfilename()`` は、各メモリ領域にロードされたバイナリファイルの特" +"定に役立ちます。\n" +"Python のバイナリまたはライブラリを見つけたら、その Mach-O ヘッダーを解析し" +"て ``PyRuntime`` 構造体の位置を特定します。" -#: ../../howto/remote_debugging.rst:302 msgid "" "The Mach-O format organizes code and data into segments and sections. The " "``PyRuntime`` structure lives in a section named ``__PyRuntime`` within the " @@ -520,23 +609,31 @@ msgid "" "address is computed by combining the base address with the appropriate " "section offsets from the Mach-O headers." msgstr "" +"Mach-O 形式では、コードとデータをセグメントとセクションに分けて格納します。\n" +"``PyRuntime`` 構造体は、``__DATA`` セグメント内の ``__PyRuntime`` というセク" +"ションにあります。\n" +"実行時のアドレスを求めるには、バイナリのベースアドレスとなる ``__TEXT`` セグ" +"メントを見つけ、続いて目的のセクションを含む ``__DATA`` セグメントを探しま" +"す。\n" +"ベースアドレスと Mach-O ヘッダーの適切なセクションオフセットを組み合わせて、" +"最終的なアドレスを求めます。" -#: ../../howto/remote_debugging.rst:310 msgid "" "Note that accessing another process's memory on macOS typically requires " "elevated privileges - either root access or special security entitlements " "granted to the debugging process." msgstr "" +"macOS で別のプロセスのメモリにアクセスするには、通常、root 権限やデバッグする" +"側のプロセスに付与された特別なセキュリティエンタイトルメントなど、昇格された" +"権限が必要です。" -#: ../../howto/remote_debugging.rst:316 msgid "Windows (PE)" -msgstr "" +msgstr "Windows (PE)" -#: ../../howto/remote_debugging.rst:317 msgid "To find the ``PyRuntime`` structure on Windows:" msgstr "" +"Windows で ``PyRuntime`` 構造体の位置を特定するには、次の手順を実行します。" -#: ../../howto/remote_debugging.rst:319 msgid "" "Use the ToolHelp API to enumerate all modules loaded in the target process. " "This is done using functions such as `CreateToolhelp32Snapshot `_." msgstr "" +"ToolHelp API を使い、対象プロセスにロードされたすべてのモジュールを列挙しま" +"す。\n" +"これには `CreateToolhelp32Snapshot `_、" +"`Module32First `_、`Module32Next `_ などの関数を使いま" +"す。" -#: ../../howto/remote_debugging.rst:326 msgid "" "Identify the module corresponding to :file:`python.exe` or :file:`python{XY}." "dll`, where ``X`` and ``Y`` are the major and minor version numbers of the " "Python version, and record its base address." msgstr "" +":file:`python.exe` または :file:`python{XY}.dll` に対応するモジュールを特定" +"し、ベースアドレスを記録します。\n" +"``X`` と ``Y`` は Python のメジャーバージョン番号とマイナーバージョン番号で" +"す。" -#: ../../howto/remote_debugging.rst:329 msgid "" "Locate the ``PyRuntim`` section. Due to the PE format's 8-character limit on " "section names (defined as ``IMAGE_SIZEOF_SHORT_NAME``), the original name " "``PyRuntime`` is truncated. This section contains the ``PyRuntime`` " "structure." msgstr "" +"``PyRuntim`` セクションを探します。\n" +"PE 形式のセクション名には 8 文字の制限 (``IMAGE_SIZEOF_SHORT_NAME`` として定" +"義) があるため、元の名前 ``PyRuntime`` は切り詰められます。\n" +"このセクションに ``PyRuntime`` 構造体があります。" -#: ../../howto/remote_debugging.rst:333 msgid "" "Retrieve the section’s relative virtual address (RVA) and add it to the base " "address of the module." msgstr "" +"セクションの相対仮想アドレス (RVA) を取得し、モジュールのベースアドレスに加え" +"ます。" #: ../../howto/remote_debugging.rst:338 msgid "" @@ -592,7 +704,6 @@ msgid "" " return base_address + section_rva" msgstr "" -#: ../../howto/remote_debugging.rst:360 msgid "" "On Windows, accessing another process's memory requires using the Windows " "API functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/" @@ -600,15 +711,22 @@ msgid "" "provides a handle to access the target process's memory space, enabling " "memory operations through ``ReadProcessMemory()``." msgstr "" +"Windows で別のプロセスのメモリにアクセスするには、" +"``CreateToolhelp32Snapshot()`` や ``Module32First()/Module32Next()`` などの " +"Windows API 関数で、ロードされたモジュールを列挙します。\n" +"``OpenProcess()`` 関数は対象プロセスのメモリ空間にアクセスするためのハンドル" +"を返し、``ReadProcessMemory()`` でメモリを操作できるようにします。" -#: ../../howto/remote_debugging.rst:366 msgid "" "The process memory can be examined by enumerating loaded modules to find the " "Python binary or DLL. When found, its PE headers need to be parsed to locate " "the ``PyRuntime`` structure." msgstr "" +"ロードされたモジュールを列挙して Python のバイナリまたは DLL を探すことで、プ" +"ロセスのメモリを調べられます。\n" +"見つかったら、その PE ヘッダーを解析して ``PyRuntime`` 構造体の位置を特定しま" +"す。" -#: ../../howto/remote_debugging.rst:370 msgid "" "The PE format organizes code and data into sections. The ``PyRuntime`` " "structure lives in a section named \"PyRuntim\" (truncated from " @@ -618,38 +736,48 @@ msgid "" "address is computed by combining the base address with the section's virtual " "address from the PE section headers." msgstr "" +"PE 形式では、コードとデータをセクションに分けて格納します。\n" +"``PyRuntime`` 構造体は「PyRuntim」というセクションにあります (PE の名前の長さ" +"制限が 8 文字なので、「PyRuntime」から切り詰められています)。\n" +"実行時のアドレスを求めるには、モジュールエントリーからモジュールのベースアド" +"レスを調べ、PE ヘッダーで目的のセクションを探します。\n" +"ベースアドレスと PE セクションヘッダーのセクション仮想アドレスを組み合わせ" +"て、最終的なアドレスを求めます。" -#: ../../howto/remote_debugging.rst:377 msgid "" "Note that accessing another process's memory on Windows typically requires " "appropriate privileges - either administrative access or the " "``SeDebugPrivilege`` privilege granted to the debugging process." msgstr "" +"Windows で別のプロセスのメモリにアクセスするには、通常、管理者権限やデバッグ" +"する側のプロセスに付与された ``SeDebugPrivilege`` 特権など、適切な権限が必要" +"です。" -#: ../../howto/remote_debugging.rst:383 msgid "Reading _Py_DebugOffsets" -msgstr "" +msgstr "_Py_DebugOffsets の読み取り" -#: ../../howto/remote_debugging.rst:385 msgid "" "Once the address of the ``PyRuntime`` structure has been determined, the " "next step is to read the ``_Py_DebugOffsets`` structure located at the " "beginning of the ``PyRuntime`` block." msgstr "" +"``PyRuntime`` 構造体のアドレスを特定したら、次は ``PyRuntime`` ブロックの先頭" +"にある ``_Py_DebugOffsets`` 構造体を読み取ります。" -#: ../../howto/remote_debugging.rst:389 msgid "" "This structure provides version-specific field offsets that are needed to " "safely read interpreter and thread state memory. These offsets vary between " "CPython versions and must be checked before use to ensure they are " "compatible." msgstr "" +"この構造体は、インタープリタやスレッド状態のメモリを安全に読み取るために必要" +"な、バージョンごとのフィールドオフセットを提供します。\n" +"オフセットは CPython のバージョンによって異なるため、使用前に互換性を確認する" +"必要があります。" -#: ../../howto/remote_debugging.rst:393 msgid "To read and check the debug offsets, follow these steps:" -msgstr "" +msgstr "デバッグ用オフセットを読み取って検査するには、次の手順を実行します。" -#: ../../howto/remote_debugging.rst:395 msgid "" "Read memory from the target process starting at the ``PyRuntime`` address, " "covering the same number of bytes as the ``_Py_DebugOffsets`` structure. " @@ -657,48 +785,58 @@ msgid "" "block. Its layout is defined in CPython’s internal headers and stays the " "same within a given minor version, but may change in major versions." msgstr "" +"対象プロセスの ``PyRuntime`` アドレスから、``_Py_DebugOffsets`` 構造体のサイ" +"ズと同じバイト数のメモリを読み取ります。\n" +"この構造体は ``PyRuntime`` メモリブロックの先頭にあります。\n" +"そのレイアウトは CPython の内部ヘッダーで定義され、同じマイナーバージョン内で" +"は変わりませんが、メジャーバージョンが変わると変更される可能性があります。" -#: ../../howto/remote_debugging.rst:401 msgid "Check that the structure contains valid data:" -msgstr "" +msgstr "構造体に有効なデータが含まれているか確認します。" -#: ../../howto/remote_debugging.rst:403 msgid "The ``cookie`` field must match the expected debug marker." msgstr "" +"``cookie`` フィールドは、想定するデバッグ用マーカーと一致しなければなりませ" +"ん。" -#: ../../howto/remote_debugging.rst:404 msgid "" "The ``version`` field must match the version of the Python interpreter used " "by the debugger." msgstr "" +"``version`` フィールドは、デバッガーが使う Python インタープリタのバージョン" +"と一致しなければなりません。" -#: ../../howto/remote_debugging.rst:406 msgid "" "If either the debugger or the target process is using a pre-release version " "(for example, an alpha, beta, or release candidate), the versions must match " "exactly." msgstr "" +"デバッガーか対象プロセスのいずれかがプレリリース版 (アルファ版、ベータ版、リ" +"リース候補版など) を使っている場合は、バージョンが完全に一致しなければなりま" +"せん。" -#: ../../howto/remote_debugging.rst:409 msgid "" "The ``free_threaded`` field must have the same value in both the debugger " "and the target process." msgstr "" +"``free_threaded`` フィールドは、デバッガーと対象プロセスの両方で同じ値でなけ" +"ればなりません。" -#: ../../howto/remote_debugging.rst:412 msgid "" "If the structure is valid, the offsets it contains can be used to locate " "fields in memory. If any check fails, the debugger should stop the operation " "to avoid reading memory in the wrong format." msgstr "" +"構造体が有効なら、格納されたオフセットを使ってメモリ内のフィールドの位置を特" +"定できます。\n" +"いずれかの検査に失敗した場合は、誤った形式でメモリを読まないように、デバッ" +"ガーは操作を中止するべきです。" -#: ../../howto/remote_debugging.rst:416 msgid "" "The following is an example implementation that reads and checks " "``_Py_DebugOffsets``::" -msgstr "" +msgstr "``_Py_DebugOffsets`` を読み取って検査する実装例を示します。 ::" -#: ../../howto/remote_debugging.rst:419 msgid "" "def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n" " # Step 1: Read memory from the target process at the PyRuntime address\n" @@ -721,12 +859,30 @@ msgid "" "\n" " return debug_offsets" msgstr "" +"def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n" +" # 手順 1: 対象プロセスの PyRuntime アドレスからメモリを読む\n" +" data = read_process_memory(\n" +" pid, address=py_runtime_addr, size=DEBUG_OFFSETS_SIZE\n" +" )\n" +"\n" +" # 手順 2: バイト列を _Py_DebugOffsets 構造体に復元する\n" +" debug_offsets = parse_debug_offsets(data)\n" +"\n" +" # 手順 3: 構造体の内容を検証する\n" +" if debug_offsets.cookie != EXPECTED_COOKIE:\n" +" raise RuntimeError(\"Invalid or missing debug cookie\")\n" +" if debug_offsets.version != LOCAL_PYTHON_VERSION:\n" +" raise RuntimeError(\n" +" \"Mismatch between caller and target Python versions\"\n" +" )\n" +" if debug_offsets.free_threaded != LOCAL_FREE_THREADED:\n" +" raise RuntimeError(\"Mismatch in free-threaded configuration\")\n" +"\n" +" return debug_offsets" -#: ../../howto/remote_debugging.rst:444 msgid "**Process suspension recommended**" -msgstr "" +msgstr "**プロセスの一時停止を推奨**" -#: ../../howto/remote_debugging.rst:446 msgid "" "To avoid race conditions and ensure memory consistency, it is strongly " "recommended that the target process be suspended before performing any " @@ -735,15 +891,21 @@ msgid "" "destroying threads—during normal execution. This can result in invalid " "memory reads or writes." msgstr "" +"競合状態を避けてメモリの一貫性を確保するため、インタープリタの内部状態を読み" +"書きする前に、対象プロセスを一時停止することを強く推奨します。\n" +"Python ランタイムは通常の実行中に、スレッドの作成や破棄など、インタープリタの" +"データ構造の変更を並行して行うことがあります。\n" +"その結果、無効なメモリの読み書きが発生する可能性があります。" -#: ../../howto/remote_debugging.rst:453 msgid "" "A debugger may suspend execution by attaching to the process with ``ptrace`` " "or by sending a ``SIGSTOP`` signal. Execution should only be resumed after " "debugger-side memory operations are complete." msgstr "" +"デバッガーは、``ptrace`` でプロセスにアタッチするか、``SIGSTOP`` シグナルを送" +"ることで実行を一時停止できます。\n" +"デバッガー側のメモリ操作が完了してから実行を再開するべきです。" -#: ../../howto/remote_debugging.rst:459 msgid "" "Some tools, such as profilers or sampling-based debuggers, may operate on a " "running process without suspension. In such cases, tools must be explicitly " @@ -751,12 +913,16 @@ msgid "" "debugger implementations, suspending the process remains the safest and most " "robust approach." msgstr "" +"プロファイラーやサンプリング方式のデバッガーなど、一部のツールはプロセスを停" +"止せずに動作する場合があります。\n" +"その場合、更新途中のメモリや一貫性のないメモリを扱えるように、明示的に設計し" +"なければなりません。\n" +"ほとんどのデバッガー実装では、プロセスを一時停止するのが最も安全で堅牢な方法" +"です。" -#: ../../howto/remote_debugging.rst:467 msgid "Locating the interpreter and thread state" -msgstr "" +msgstr "インタープリタとスレッド状態の位置の特定" -#: ../../howto/remote_debugging.rst:469 msgid "" "Before code can be injected and executed in a remote Python process, the " "debugger must choose a thread in which to schedule execution. This is " @@ -765,8 +931,13 @@ msgid "" "in a ``PyThreadState`` object. These fields are modified by the debugger to " "request execution of injected scripts." msgstr "" +"リモートの Python プロセスにコードを注入して実行する前に、デバッガーは実行を" +"予約するスレッドを選ぶ必要があります。\n" +"リモートコードの注入を制御するフィールドが、``PyThreadState`` オブジェクトに" +"埋め込まれた ``_PyRemoteDebuggerSupport`` 構造体にあるためです。\n" +"デバッガーはこれらのフィールドを変更して、注入したスクリプトの実行を要求しま" +"す。" -#: ../../howto/remote_debugging.rst:476 msgid "" "The ``PyThreadState`` structure represents a thread running inside a Python " "interpreter. It maintains the thread’s evaluation context and contains the " @@ -774,73 +945,93 @@ msgid "" "``PyThreadState`` is therefore a key prerequisite for triggering execution " "remotely." msgstr "" +"``PyThreadState`` 構造体は、Python インタープリタ内で実行するスレッドを表しま" +"す。\n" +"スレッドの評価コンテキストを保持し、デバッガーと協調するためのフィールドを含" +"みます。\n" +"そのため、有効な ``PyThreadState`` の位置を特定することが、リモート実行を開始" +"させるための重要な前提条件です。" -#: ../../howto/remote_debugging.rst:481 msgid "" "A thread is typically selected based on its role or ID. In most cases, the " "main thread is used, but some tools may target a specific thread by its " "native thread ID. Once the target thread is chosen, the debugger must locate " "both the interpreter and the associated thread state structures in memory." msgstr "" +"通常は役割や ID に基づいてスレッドを選びます。\n" +"ほとんどの場合はメインスレッドを使いますが、ネイティブスレッド ID で特定のス" +"レッドを指定するツールもあります。\n" +"対象のスレッドを選んだら、デバッガーはインタープリタと対応するスレッド状態の" +"構造体をメモリ内で探さなければなりません。" -#: ../../howto/remote_debugging.rst:486 msgid "The relevant internal structures are defined as follows:" -msgstr "" +msgstr "関連する内部構造体の定義は次のとおりです。" -#: ../../howto/remote_debugging.rst:488 msgid "" "``PyInterpreterState`` represents an isolated Python interpreter instance. " "Each interpreter maintains its own set of imported modules, built-in state, " "and thread state list. Although most Python applications use a single " "interpreter, CPython supports multiple interpreters in the same process." msgstr "" +"``PyInterpreterState`` は、隔離された Python インタープリタのインスタンスを表" +"します。\n" +"各インタープリタは、インポート済みモジュール、組み込みの状態、スレッド状態の" +"リストをそれぞれ保持します。\n" +"ほとんどの Python アプリケーションは一つのインタープリタを使いますが、" +"CPython は同じプロセス内での複数のインタープリタをサポートします。" -#: ../../howto/remote_debugging.rst:493 msgid "" "``PyThreadState`` represents a thread running within an interpreter. It " "contains execution state and the control fields used by the debugger." msgstr "" +"``PyThreadState`` は、インタープリタ内で実行するスレッドを表します。\n" +"実行状態と、デバッガーが使う制御用フィールドを含みます。" -#: ../../howto/remote_debugging.rst:496 msgid "To locate a thread:" -msgstr "" +msgstr "スレッドの位置を特定するには、次の手順を実行します。" -#: ../../howto/remote_debugging.rst:498 msgid "" "Use the offset ``runtime_state.interpreters_head`` to obtain the address of " "the first interpreter in the ``PyRuntime`` structure. This is the entry " "point to the linked list of active interpreters." msgstr "" +"オフセット ``runtime_state.interpreters_head`` を使い、``PyRuntime`` 構造体か" +"ら最初のインタープリタのアドレスを取得します。\n" +"ここが、動作中のインタープリタの連結リストの先頭です。" -#: ../../howto/remote_debugging.rst:502 msgid "" "Use the offset ``interpreter_state.threads_main`` to access the main thread " "state associated with the selected interpreter. This is typically the most " "reliable thread to target." msgstr "" +"オフセット ``interpreter_state.threads_main`` を使い、選んだインタープリタに" +"対応するメインスレッドの状態にアクセスします。\n" +"通常、最も確実に対象にできるのはこのスレッドです。" -#: ../../howto/remote_debugging.rst:506 msgid "" "Optionally, use the offset ``interpreter_state.threads_head`` to iterate " "through the linked list of all thread states. Each ``PyThreadState`` " "structure contains a ``native_thread_id`` field, which may be compared to a " "target thread ID to find a specific thread." msgstr "" +"必要に応じて、オフセット ``interpreter_state.threads_head`` を使って全スレッ" +"ド状態の連結リストをたどります。\n" +"各 ``PyThreadState`` 構造体には ``native_thread_id`` フィールドがあり、目的の" +"スレッド ID と比較して特定のスレッドを探せます。" -#: ../../howto/remote_debugging.rst:511 msgid "" "Once a valid ``PyThreadState`` has been found, its address can be used in " "later steps of the protocol, such as writing debugger control fields and " "scheduling execution." msgstr "" +"有効な ``PyThreadState`` が見つかったら、そのアドレスを、デバッガーの制御用" +"フィールドへの書き込みや実行の予約など、プロトコルの後続の手順で使えます。" -#: ../../howto/remote_debugging.rst:515 msgid "" "The following is an example implementation that locates the main thread " "state::" -msgstr "" +msgstr "メインスレッドの状態の位置を特定する実装例を示します。 ::" -#: ../../howto/remote_debugging.rst:517 msgid "" "def find_main_thread_state(\n" " pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n" @@ -863,14 +1054,32 @@ msgid "" "\n" " return thread_state_addr" msgstr "" +"def find_main_thread_state(\n" +" pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n" +") -> int:\n" +" # 手順 1: PyRuntime から interpreters_head を読む\n" +" interp_head_ptr = (\n" +" py_runtime_addr + debug_offsets.runtime_state.interpreters_head\n" +" )\n" +" interp_addr = read_pointer(pid, interp_head_ptr)\n" +" if interp_addr == 0:\n" +" raise RuntimeError(\"No interpreter found in the target process\")\n" +"\n" +" # 手順 2: インタープリタから threads_main ポインターを読む\n" +" threads_main_ptr = (\n" +" interp_addr + debug_offsets.interpreter_state.threads_main\n" +" )\n" +" thread_state_addr = read_pointer(pid, threads_main_ptr)\n" +" if thread_state_addr == 0:\n" +" raise RuntimeError(\"Main thread state is not available\")\n" +"\n" +" return thread_state_addr" -#: ../../howto/remote_debugging.rst:538 msgid "" "The following example demonstrates how to locate a thread by its native " "thread ID::" -msgstr "" +msgstr "次の例は、ネイティブスレッド ID でスレッドを探す方法を示します。 ::" -#: ../../howto/remote_debugging.rst:541 msgid "" "def find_thread_by_id(\n" " pid: int,\n" @@ -898,19 +1107,43 @@ msgid "" "\n" " raise RuntimeError(\"Thread with the given ID was not found\")" msgstr "" +"def find_thread_by_id(\n" +" pid: int,\n" +" interp_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" target_tid: int,\n" +") -> int:\n" +" # threads_head から連結リストをたどる\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" interp_addr + debug_offsets.interpreter_state.threads_head\n" +" )\n" +"\n" +" while thread_ptr:\n" +" native_tid_ptr = (\n" +" thread_ptr + debug_offsets.thread_state.native_thread_id\n" +" )\n" +" native_tid = read_int(pid, native_tid_ptr)\n" +" if native_tid == target_tid:\n" +" return thread_ptr\n" +" thread_ptr = read_pointer(\n" +" pid,\n" +" thread_ptr + debug_offsets.thread_state.next\n" +" )\n" +"\n" +" raise RuntimeError(\"Thread with the given ID was not found\")" -#: ../../howto/remote_debugging.rst:568 msgid "" "Once a valid thread state has been located, the debugger can proceed with " "modifying its control fields and scheduling execution, as described in the " "next section." msgstr "" +"有効なスレッド状態の位置を特定したら、デバッガーは次の節で説明するように、制" +"御用フィールドを変更して実行を予約できます。" -#: ../../howto/remote_debugging.rst:573 msgid "Writing control information" -msgstr "" +msgstr "制御情報の書き込み" -#: ../../howto/remote_debugging.rst:575 msgid "" "Once a valid ``PyThreadState`` structure has been identified, the debugger " "may modify control fields within it to schedule the execution of a specified " @@ -918,56 +1151,69 @@ msgid "" "interpreter, and when set correctly, they trigger the execution of remote " "code at a safe point in the evaluation loop." msgstr "" +"有効な ``PyThreadState`` 構造体を特定したら、デバッガーは内部の制御用フィール" +"ドを変更して、指定した Python スクリプトの実行を予約できます。\n" +"インタープリタはこれらのフィールドを定期的に検査し、正しく設定されていれば、" +"評価ループの安全な地点でリモートコードの実行を開始します。" -#: ../../howto/remote_debugging.rst:581 msgid "" "Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure " "used for communication between the debugger and the interpreter. The " "locations of its fields are defined by the ``_Py_DebugOffsets`` structure " "and include the following:" msgstr "" +"各 ``PyThreadState`` には、デバッガーとインタープリタの通信に使う " +"``_PyRemoteDebuggerSupport`` 構造体があります。\n" +"フィールドの位置は ``_Py_DebugOffsets`` 構造体で定義されており、次のものを含" +"みます。" -#: ../../howto/remote_debugging.rst:586 msgid "" "``debugger_script_path``: A fixed-size buffer that holds the full path to a " "Python source file (``.py``). This file must be accessible and readable by " "the target process when execution is triggered." msgstr "" +"``debugger_script_path``: Python ソースファイル (``.py``) の完全なパスを保持" +"する固定長バッファー。\n" +"実行を開始するとき、対象プロセスがこのファイルにアクセスして読み取れる必要が" +"あります。" -#: ../../howto/remote_debugging.rst:590 msgid "" "``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the " "interpreter that a script is ready to be executed." msgstr "" +"``debugger_pending_call``: 整数のフラグ。\n" +"``1`` に設定すると、スクリプトを実行する準備ができたことをインタープリタに伝" +"えます。" -#: ../../howto/remote_debugging.rst:593 msgid "" "``eval_breaker``: A field checked by the interpreter during execution. " "Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this " "field causes the interpreter to pause and check for debugger activity." msgstr "" +"``eval_breaker``: 実行中にインタープリタが検査するフィールド。\n" +"このフィールドのビット 5 (``_PY_EVAL_PLEASE_STOP_BIT``、値は ``1U << 5``) を" +"立てると、インタープリタは処理を中断してデバッガーからの操作を確認します。" -#: ../../howto/remote_debugging.rst:597 msgid "" "To complete the injection, the debugger must perform the following steps:" -msgstr "" +msgstr "注入を完了するには、デバッガーは次の手順を実行しなければなりません。" -#: ../../howto/remote_debugging.rst:599 msgid "Write the full script path into the ``debugger_script_path`` buffer." msgstr "" +"スクリプトの完全なパスを ``debugger_script_path`` バッファーに書き込みます。" -#: ../../howto/remote_debugging.rst:600 msgid "Set ``debugger_pending_call`` to ``1``." -msgstr "" +msgstr "``debugger_pending_call`` を ``1`` に設定します。" -#: ../../howto/remote_debugging.rst:601 msgid "" "Read the current value of ``eval_breaker``, set bit 5 " "(``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This " "signals the interpreter to check for debugger activity." msgstr "" +"``eval_breaker`` の現在の値を読み取り、ビット 5 " +"(``_PY_EVAL_PLEASE_STOP_BIT``) を立て、更新した値を書き戻します。\n" +"これにより、デバッガーからの操作を確認するようインタープリタに通知します。" -#: ../../howto/remote_debugging.rst:607 msgid "" "def inject_script(\n" " pid: int,\n" @@ -1005,21 +1251,59 @@ msgid "" " breaker |= (1 << 5)\n" " write_int(pid, eval_breaker_ptr, breaker)" msgstr "" +"def inject_script(\n" +" pid: int,\n" +" thread_state_addr: int,\n" +" debug_offsets: DebugOffsets,\n" +" script_path: str\n" +") -> None:\n" +" # _PyRemoteDebuggerSupport の先頭のオフセットを求める\n" +" support_base = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.remote_debugger_support\n" +" )\n" +"\n" +" # 手順 1: debugger_script_path にスクリプトのパスを書く\n" +" script_path_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_script_path\n" +" )\n" +" write_string(pid, script_path_ptr, script_path)\n" +"\n" +" # 手順 2: debugger_pending_call を 1 に設定する\n" +" pending_ptr = (\n" +" support_base +\n" +" debug_offsets.debugger_support.debugger_pending_call\n" +" )\n" +" write_int(pid, pending_ptr, 1)\n" +"\n" +" # 手順 3: eval_breaker の _PY_EVAL_PLEASE_STOP_BIT\n" +" # (ビット 5、値は 1 << 5) を立てる\n" +" eval_breaker_ptr = (\n" +" thread_state_addr +\n" +" debug_offsets.debugger_support.eval_breaker\n" +" )\n" +" breaker = read_int(pid, eval_breaker_ptr)\n" +" breaker |= (1 << 5)\n" +" write_int(pid, eval_breaker_ptr, breaker)" -#: ../../howto/remote_debugging.rst:644 msgid "" "Once these fields are set, the debugger may resume the process (if it was " "suspended). The interpreter will process the request at the next safe " "evaluation point, load the script from disk, and execute it." msgstr "" +"これらのフィールドを設定したら、デバッガーは (プロセスを一時停止していた場合" +"は) 実行を再開できます。\n" +"インタープリタは次に安全に評価できる地点で要求を処理し、ディスクからスクリプ" +"トを読み込んで実行します。" -#: ../../howto/remote_debugging.rst:648 msgid "" "It is the responsibility of the debugger to ensure that the script file " "remains present and accessible to the target process during execution." msgstr "" +"実行中、スクリプトファイルが存在し、対象プロセスからアクセスできる状態を保つ" +"責任はデバッガーにあります。" -#: ../../howto/remote_debugging.rst:653 msgid "" "Script execution is asynchronous. The script file cannot be deleted " "immediately after injection. The debugger should wait until the injected " @@ -1029,52 +1313,55 @@ msgid "" "removing the script. Once such an effect is observed, it is safe to assume " "the file is no longer needed." msgstr "" +"スクリプトは非同期に実行されます。\n" +"注入の直後にスクリプトファイルを削除してはいけません。\n" +"デバッガーは、注入したスクリプトによる作用を観測してからファイルを削除するべ" +"きです。\n" +"何を観測するかは、スクリプトの目的によります。\n" +"例えば、リモートプロセスからソケットへの接続があるまで待ってから、スクリプト" +"を削除する方法があります。\n" +"そのような作用を観測できたら、ファイルは不要になったと判断できます。" -#: ../../howto/remote_debugging.rst:662 msgid "Summary" -msgstr "" +msgstr "まとめ" -#: ../../howto/remote_debugging.rst:664 msgid "To inject and execute a Python script in a remote process:" msgstr "" +"リモートプロセスに Python スクリプトを注入して実行する手順は次のとおりです。" -#: ../../howto/remote_debugging.rst:666 msgid "Locate the ``PyRuntime`` structure in the target process’s memory." -msgstr "" +msgstr "対象プロセスのメモリ内で ``PyRuntime`` 構造体の位置を特定します。" -#: ../../howto/remote_debugging.rst:667 msgid "" "Read and validate the ``_Py_DebugOffsets`` structure at the beginning of " "``PyRuntime``." msgstr "" +"``PyRuntime`` の先頭にある ``_Py_DebugOffsets`` 構造体を読み取り、検証しま" +"す。" -#: ../../howto/remote_debugging.rst:669 msgid "Use the offsets to locate a valid ``PyThreadState``." -msgstr "" +msgstr "オフセットを使って、有効な ``PyThreadState`` の位置を特定します。" -#: ../../howto/remote_debugging.rst:670 msgid "Write the path to a Python script into ``debugger_script_path``." -msgstr "" +msgstr "Python スクリプトのパスを ``debugger_script_path`` に書き込みます。" -#: ../../howto/remote_debugging.rst:671 msgid "Set the ``debugger_pending_call`` flag to ``1``." -msgstr "" +msgstr "``debugger_pending_call`` フラグを ``1`` に設定します。" -#: ../../howto/remote_debugging.rst:672 msgid "Set ``_PY_EVAL_PLEASE_STOP_BIT`` in the ``eval_breaker`` field." msgstr "" +"``eval_breaker`` フィールドの ``_PY_EVAL_PLEASE_STOP_BIT`` を立てます。" -#: ../../howto/remote_debugging.rst:673 msgid "" "Resume the process (if suspended). The script will execute at the next safe " "evaluation point." msgstr "" +"一時停止していた場合はプロセスの実行を再開します。\n" +"スクリプトは、次に安全に評価できる地点で実行されます。" -#: ../../howto/remote_debugging.rst:679 msgid "Security and threat model" -msgstr "" +msgstr "セキュリティと脅威モデル" -#: ../../howto/remote_debugging.rst:681 msgid "" "The remote debugging protocol relies on the same operating system primitives " "used by native debuggers such as GDB and LLDB. Attaching to a process " @@ -1085,16 +1372,24 @@ msgid "" "needed to attach to a process, they could equally use GDB to read memory or " "inject code." msgstr "" +"リモートデバッグのプロトコルは、GDB や LLDB などのネイティブデバッガーと同じ " +"OS の基本機能を使います。\n" +"プロセスへのアタッチには、Linux の ``ptrace`` / Yama LSM、macOS の " +"``task_for_pid``、Windows の ``SeDebugPrivilege`` など、それらのデバッガーと " +"**同じ権限** が必要です。\n" +"Python が新たな権限昇格の経路を導入するわけではありません。\n" +"攻撃者がプロセスへのアタッチに必要な権限をすでに持つ場合、GDB を使ってメモリ" +"を読んだりコードを注入したりすることもできます。" -#: ../../howto/remote_debugging.rst:690 msgid "" "The following principles define what is, and is not, considered a security " "vulnerability in this feature:" msgstr "" +"この機能で何をセキュリティ上の脆弱性とみなすか、また、みなさないかは、次の原" +"則で定義されます。" -#: ../../howto/remote_debugging.rst:693 msgid "Attaching requires OS-level privileges" -msgstr "" +msgstr "アタッチには OS レベルの権限が必要" #: ../../howto/remote_debugging.rst:694 msgid "" @@ -1105,13 +1400,12 @@ msgid "" "OS security boundary was already crossed." msgstr "" -#: ../../howto/remote_debugging.rst:700 msgid "" "Crashes or memory errors when reading a compromised process are not " "vulnerabilities" msgstr "" +"侵害されたプロセスを読み取る際のクラッシュやメモリエラーは脆弱性ではない" -#: ../../howto/remote_debugging.rst:701 msgid "" "A tool that reads internal interpreter state from a target process must " "trust that memory to be well-formed. If the target process has been " @@ -1122,24 +1416,34 @@ msgid "" "reading corrupted state) are **not** treated as security issues, though " "fixes that improve robustness are welcome." msgstr "" +"対象プロセスからインタープリタの内部状態を読むツールは、そのメモリの形式が正" +"しいと信頼する必要があります。\n" +"対象プロセスが破損しているか、攻撃者に制御されている場合、デバッガーやプロ" +"ファイラーがクラッシュしたり、無意味な出力を生成したり、予測できない動作をし" +"たりする可能性があります。\n" +"これは、``ptrace`` に基づくすべてのデバッガーが受け入れているのと同じリスクで" +"す。\n" +"この種類のバグ (破損した状態の読み取りによるバッファーオーバーフロー、セグメ" +"ンテーション違反、未定義動作) は、セキュリティの問題とは **みなしません** " +"が、堅牢性を高める修正は歓迎します。" -#: ../../howto/remote_debugging.rst:710 msgid "Vulnerabilities in the target process are not in scope" -msgstr "" +msgstr "対象プロセスの脆弱性は対象外" -#: ../../howto/remote_debugging.rst:711 msgid "" "If the Python process being debugged has already been compromised, the " "attacker already controls execution in that process. Demonstrating further " "impact from that starting point does not constitute a vulnerability in the " "remote debugging protocol." msgstr "" +"デバッグ対象の Python プロセスがすでに侵害されている場合、攻撃者はそのプロセ" +"ス内の実行をすでに制御しています。\n" +"その状態からさらに影響を与えられることを示しても、リモートデバッグのプロトコ" +"ルの脆弱性にはなりません。" -#: ../../howto/remote_debugging.rst:717 msgid "When to use ``PYTHON_DISABLE_REMOTE_DEBUG``" -msgstr "" +msgstr "``PYTHON_DISABLE_REMOTE_DEBUG`` を使う場面" -#: ../../howto/remote_debugging.rst:719 msgid "" "The environment variable :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (and the " "equivalent :option:`-X disable-remote-debug` flag) allows operators to " @@ -1149,10 +1453,19 @@ msgid "" "reducing attack surface is a priority, even though the OS-level privilege " "checks already prevent unprivileged access." msgstr "" +"環境変数 :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (および同等のフラグ :option:`-" +"X disable-remote-debug`) を使うと、運用者は **多層防御** の対策として、プロト" +"コルのプロセス内で動く部分を無効にできます。\n" +"OS レベルの権限検査ですでに権限のないアクセスを防いでいても、プロセスのデバッ" +"グやプロファイリングを想定せず、攻撃対象となる機能を減らすことを優先する環境" +"では役立つことがあります。\n" +"例えば、セキュリティを強化した環境やサンドボックス内への配置が該当します。" -#: ../../howto/remote_debugging.rst:727 msgid "" "Setting this variable does **not** affect other OS-level debugging " "interfaces (``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain " "available according to their own permission models." msgstr "" +"この変数を設定しても、OS レベルの他のデバッグインターフェース (``ptrace``、" +"``/proc``、``task_for_pid`` など) には影響 **しません**。\n" +"それぞれの権限モデルに従って引き続き利用できます。" diff --git a/howto/sockets.po b/howto/sockets.po index 220bf6b69..98c528b63 100644 --- a/howto/sockets.po +++ b/howto/sockets.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/sockets.rst:5 @@ -69,7 +69,6 @@ msgstr "" "提示しよう。だが、まずはブロッキングソケットから始めることにする。ノンブロッ" "キングを扱うより先に、ブロッキングの仕組みを知っておかなくてはならないのだ。" -#: ../../howto/sockets.rst:28 msgid "" "Part of the trouble with understanding these things is that \"socket\" can " "mean a number of subtly different things, depending on context. So first, " @@ -80,26 +79,27 @@ msgid "" "sockets and \"client\" sockets." msgstr "" "話を理解しにくくしている要因として、「ソケット」という言葉が文脈によって微妙" -"に違うものを指すことが挙げられる。そこでまず、「クライアント」ソケット - 対話" -"の両端 - と「サーバ」ソケット - 電話交換手みたいなもの - の区別を付けておこ" -"う。クライアントアプリケーション (たとえばブラウザ) は「クライアント」ソケッ" -"トだけを使うが、話し相手のウェブサーバは「サーバ」ソケットと「クライアント」" -"ソケットの両方を使う。" +"に違うものを指すことが挙げられる。\n" +"そこでまず、「クライアント」ソケット - 対話の一方の端 - と「サーバ」ソケット " +"- 電話交換手みたいなもの - の区別を付けておこう。\n" +"クライアントアプリケーション (たとえばブラウザ) は「クライアント」ソケットだ" +"けを使うが、話し相手のウェブサーバは「サーバ」ソケットと「クライアント」ソ" +"ケットの両方を使う。" #: ../../howto/sockets.rst:37 msgid "History" msgstr "歴史" -#: ../../howto/sockets.rst:39 msgid "" "Of the various forms of :abbr:`IPC (Inter Process Communication)`, sockets " "are by far the most popular. On any given platform, there are likely to be " "other forms of IPC that are faster, but for cross-platform communication, " "sockets are about the only game in town." msgstr "" -"各種 :abbr:`IPC (Inter Process Communication` (プロセス間通信) の中でも、ソ" -"ケットは群を抜いて人気がある。どのプラットフォームにも、ソケットより速い IPC " -"はあるだろう。だが、プラットフォームをまたぐ通信はソケットの独擅場だ。" +"各種 :abbr:`IPC (Inter Process Communication)` (プロセス間通信) の中でも、ソ" +"ケットは群を抜いて人気がある。\n" +"どのプラットフォームにも、ソケットより速い IPC はあるだろう。\n" +"だが、プラットフォームをまたぐ通信はソケットの独擅場だ。" #: ../../howto/sockets.rst:44 msgid "" @@ -125,13 +125,16 @@ msgstr "" "あなたがリンクをクリックしてこのページに来たとき、ブラウザは大雑把に言って次" "のようなことをしたのである::" -#: ../../howto/sockets.rst:56 msgid "" "# create an INET, STREAMing socket\n" "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" "# now connect to the web server on port 80 - the normal http port\n" "s.connect((\"www.python.org\", 80))" msgstr "" +"# INET の STREAM ソケットを作る\n" +"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"# HTTP の通常のポートである 80 番でウェブサーバーに接続する\n" +"s.connect((\"www.python.org\", 80))" #: ../../howto/sockets.rst:61 msgid "" @@ -152,7 +155,6 @@ msgid "" msgstr "" "ウェブサーバで起こる事柄はもう少し複雑だ。まず「サーバソケット」を作る::" -#: ../../howto/sockets.rst:70 msgid "" "# create an INET, STREAMing socket\n" "serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" @@ -161,6 +163,12 @@ msgid "" "# become a server socket\n" "serversocket.listen(5)" msgstr "" +"# INET の STREAM ソケットを作る\n" +"serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"# 外部から接続できるホストとウェルノウンポートにソケットをバインドする\n" +"serversocket.bind((socket.gethostname(), 80))\n" +"# サーバーソケットにする\n" +"serversocket.listen(5)" #: ../../howto/sockets.rst:77 msgid "" @@ -206,7 +214,6 @@ msgstr "" "よし、「サーバーソケット」ができて、80 番ポートで耳を澄ましているところまで来" "た。では、ウェブサーバのメインループに入ろう::" -#: ../../howto/sockets.rst:95 msgid "" "while True:\n" " # accept connections from outside\n" @@ -216,6 +223,13 @@ msgid "" " ct = make_client_thread(clientsocket)\n" " ct.start()" msgstr "" +"while True:\n" +" # 外部からの接続を受け付ける\n" +" (clientsocket, address) = serversocket.accept()\n" +" # clientsocket を使って処理する\n" +" # ここではスレッドを使うサーバーだとする\n" +" ct = make_client_thread(clientsocket)\n" +" ct.start()" #: ../../howto/sockets.rst:103 msgid "" @@ -274,7 +288,6 @@ msgstr "" msgid "Using a Socket" msgstr "ソケットの利用" -#: ../../howto/sockets.rst:133 msgid "" "The first thing to note, is that the web browser's \"client\" socket and the " "web server's \"client\" socket are identical beasts. That is, this is a " @@ -285,11 +298,13 @@ msgid "" "rule of sockets." msgstr "" "はじめに憶えておくべきなのは、ウェブブラウザの「クライアント」ソケットとウェ" -"ブサーバの「クライアント」ソケットがまったく同じ種族だということだ。つまり、" -"これは「ピア・トゥ・ピア」(1 対 1) の会話である。別の言い方をすると、 *設計者" -"として自分で会話のエチケット規則を決めなくてはいけない* ということでもある。" -"通常は、 ``connect`` してくるソケットが要求あるいは宣言をして会話を始める。だ" -"が、それはそう設計しただけのことだ - ソケットの規則ではない。" +"ブサーバの「クライアント」ソケットがまったく同じ種族だということだ。\n" +"つまり、これは「ピア・トゥ・ピア」(対等な相手同士) の会話である。\n" +"別の言い方をすると、 *設計者として自分で会話のエチケット規則を決めなくてはい" +"けない* ということでもある。\n" +"通常は、 ``connect`` してくるソケットが要求やログイン情報を送って会話を始め" +"る。\n" +"だが、それはそう設計しただけのことだ - ソケットの規則ではない。" #: ../../howto/sockets.rst:140 msgid "" @@ -382,7 +397,6 @@ msgstr "" "毎回接続を終わらせるのはイヤだとして、最も単純な解決策は固定長メッセージだろ" "う::" -#: ../../howto/sockets.rst:180 msgid "" "class MySocket:\n" " \"\"\"demonstration class only\n" @@ -418,6 +432,39 @@ msgid "" " bytes_recd = bytes_recd + len(chunk)\n" " return b''.join(chunks)" msgstr "" +"class MySocket:\n" +" \"\"\"説明用のクラス\n" +" - 効率よりも分かりやすさを優先したコード\n" +" \"\"\"\n" +"\n" +" def __init__(self, sock=None):\n" +" if sock is None:\n" +" self.sock = socket.socket(\n" +" socket.AF_INET, socket.SOCK_STREAM)\n" +" else:\n" +" self.sock = sock\n" +"\n" +" def connect(self, host, port):\n" +" self.sock.connect((host, port))\n" +"\n" +" def mysend(self, msg):\n" +" totalsent = 0\n" +" while totalsent < MSGLEN:\n" +" sent = self.sock.send(msg[totalsent:])\n" +" if sent == 0:\n" +" raise RuntimeError(\"socket connection broken\")\n" +" totalsent = totalsent + sent\n" +"\n" +" def myreceive(self):\n" +" chunks = []\n" +" bytes_recd = 0\n" +" while bytes_recd < MSGLEN:\n" +" chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))\n" +" if chunk == b'':\n" +" raise RuntimeError(\"socket connection broken\")\n" +" chunks.append(chunk)\n" +" bytes_recd = bytes_recd + len(chunk)\n" +" return b''.join(chunks)" #: ../../howto/sockets.rst:214 msgid "" @@ -497,7 +544,6 @@ msgstr "" msgid "Binary Data" msgstr "バイナリデータ" -#: ../../howto/sockets.rst:251 msgid "" "It is perfectly possible to send binary data over a socket. The major " "problem is that not all machines use the same formats for binary data. For " @@ -508,8 +554,15 @@ msgid "" "little-endian, with the least significant byte first - that same ``1`` would " "be ``01 00``." msgstr "" +"ソケットでバイナリデータを送ることはもちろん可能だ。\n" +"大きな問題は、すべてのマシンが同じバイナリデータ形式を使うわけではないこと" +"だ。\n" +"例えば、`ネットワークバイトオーダー `_ は最上位バイトを先頭に置くビッグエンディアンなので、" +"値が ``1`` の 16 ビット整数は 16 進数で ``00 01`` という 2 バイトになる。\n" +"一方、一般的なプロセッサーのほとんど (x86/AMD64、ARM、RISC-V) は最下位バイト" +"を先頭に置くリトルエンディアンで、同じ ``1`` が ``01 00`` になる。" -#: ../../howto/sockets.rst:259 msgid "" "Socket libraries have calls for converting 16 and 32 bit integers - ``ntohl, " "htonl, ntohs, htons`` where \"n\" means *network* and \"h\" means *host*, " @@ -517,6 +570,12 @@ msgid "" "order, these do nothing, but where the machine is byte-reversed, these swap " "the bytes around appropriately." msgstr "" +"ソケットライブラリには、16 ビットと 32 ビットの整数を変換する関数 ``ntohl, " +"htonl, ntohs, htons`` がある。\n" +"「n」は *network*、「h」は *host*、「s」は *short*、「l」は *long* を意味す" +"る。\n" +"ネットワークとホストのバイト順が同じなら何もしないが、逆のバイト順を使うマシ" +"ンでは適切にバイトを入れ替える。" #: ../../howto/sockets.rst:265 msgid "" @@ -586,7 +645,6 @@ msgstr "" msgid "When Sockets Die" msgstr "ソケットが死ぬと" -#: ../../howto/sockets.rst:301 msgid "" "Probably the worst thing about using blocking sockets is what happens when " "the other side comes down hard (without doing a ``close``). Your socket is " @@ -600,32 +658,36 @@ msgid "" "automatic recycling of resources. In other words, if you do manage to kill " "the thread, your whole process is likely to be screwed up." msgstr "" -"ブロッキングソケットを使っていて一番いやなのは多分、相手側が意地悪く " -"(``close`` せずに) ダウンするときに起こる事柄だ。自分側のソケットは高確率でハ" -"ングするだろう。TCP は信頼性の高いプロトコルなので、ずっとずっと待ち続けて、" -"なかなか見捨てないのだ。スレッドを使っているのであれば、そのスレッド全体が根" -"本から死んだ状態になる。こうなると、もう手の施しようがない。まあ、ブロッキン" -"グ読み出しの間ロックし続けるといった馬鹿げたことをしていない限り、リソースの" -"点ではたいして消費にならない。だから *ぜったいに* そのスレッドを殺そうとして" -"はいけない - プロセスよりスレッドが効率的である理由のひとつは、自動リソース回" -"収にまつわるオーバヘッドを避けられるという点にあるのだ。つまり別の言い方をす" -"ると、どうにかしてそのスレッドを殺したなら、プロセス全体がぐちゃぐちゃになっ" -"てしまうだろうということだ。" +"ブロッキングソケットを使っていて一番いやなのは多分、相手側が突然 (``close`` " +"せずに) ダウンするときに起こる事柄だ。\n" +"自分側のソケットは高確率でハングするだろう。\n" +"TCP は信頼性の高いプロトコルなので、ずっとずっと待ち続けて、なかなか見捨てな" +"いのだ。\n" +"スレッドを使っているのであれば、そのスレッド全体が根本から死んだ状態にな" +"る。\n" +"こうなると、もう手の施しようがない。\n" +"まあ、ブロッキング読み出しの間ロックし続けるといった馬鹿げたことをしていない" +"限り、リソースの点ではたいして消費にならない。\n" +"だから *ぜったいに* そのスレッドを殺そうとしてはいけない - プロセスよりスレッ" +"ドが効率的である理由のひとつは、自動リソース回収にまつわるオーバヘッドを避け" +"られるという点にあるのだ。\n" +"つまり別の言い方をすると、どうにかしてそのスレッドを殺したなら、プロセス全体" +"がぐちゃぐちゃになってしまうだろうということだ。" #: ../../howto/sockets.rst:315 msgid "Non-blocking Sockets" msgstr "ノンブロッキングソケット" -#: ../../howto/sockets.rst:317 msgid "" "If you've understood the preceding, you already know most of what you need " "to know about the mechanics of using sockets. You'll still use the same " "calls, in much the same ways. It's just that, if you do it right, your app " "will be almost inside-out." msgstr "" -"ここまで理解してきたなら、もうソケットの仕組みについて必要なことはほとんど" -"知っていることになる。これからも同じコールを、ほぼ同じように使っていくだけ、" -"それだけだ。これをちゃんとやっていれば、そのアプリはだいたい完璧であろう。" +"ここまで理解できたなら、ソケットを使う仕組みについて必要なことはほとんど分" +"かっている。\n" +"使う関数も、その使い方も、これまでとほぼ同じだ。\n" +"ただし、適切に実装すると、アプリケーションの構成はほとんど裏返しになる。" #: ../../howto/sockets.rst:322 msgid "" @@ -672,7 +734,6 @@ msgstr "" "い。しかし Python で ``select`` を理解しておけば C でもほとんど問題なく書け" "る、という程度には似ている::" -#: ../../howto/sockets.rst:342 msgid "" "ready_to_read, ready_to_write, in_error = \\\n" " select.select(\n" @@ -681,6 +742,12 @@ msgid "" " potential_errs,\n" " timeout)" msgstr "" +"ready_to_read, ready_to_write, in_error = \\\n" +" select.select(\n" +" potential_readers,\n" +" potential_writers,\n" +" potential_errs,\n" +" timeout)" #: ../../howto/sockets.rst:349 msgid "" diff --git a/howto/sorting.po b/howto/sorting.po index 89ad8700d..c5a998451 100644 --- a/howto/sorting.po +++ b/howto/sorting.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/sorting.rst:4 @@ -55,11 +55,12 @@ msgstr "" "単純な昇順のソートはとても簡単です: :func:`sorted` 関数を呼ぶだけです。そうす" "れば、新たにソートされたリストが返されます::" -#: ../../howto/sorting.rst:19 msgid "" ">>> sorted([5, 2, 3, 1, 4])\n" "[1, 2, 3, 4, 5]" msgstr "" +">>> sorted([5, 2, 3, 1, 4])\n" +"[1, 2, 3, 4, 5]" #: ../../howto/sorting.rst:24 msgid "" @@ -73,13 +74,16 @@ msgstr "" "します)。多くの場合、こちらの方法は :func:`sorted` と比べると不便です - ただ" "し、元々のリストが不要な場合には、わずかですがより効率的です。" -#: ../../howto/sorting.rst:29 msgid "" ">>> a = [5, 2, 3, 1, 4]\n" ">>> a.sort()\n" ">>> a\n" "[1, 2, 3, 4, 5]" msgstr "" +">>> a = [5, 2, 3, 1, 4]\n" +">>> a.sort()\n" +">>> a\n" +"[1, 2, 3, 4, 5]" #: ../../howto/sorting.rst:36 msgid "" @@ -89,35 +93,41 @@ msgstr "" "違いは他にもあります、 :meth:`list.sort` メソッドはリストにのみ定義されていま" "す。一方 :func:`sorted` 関数は任意のイテラブルを受け付けます。" -#: ../../howto/sorting.rst:39 msgid "" ">>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})\n" "[1, 2, 3, 4, 5]" msgstr "" +">>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})\n" +"[1, 2, 3, 4, 5]" #: ../../howto/sorting.rst:45 msgid "Key Functions" msgstr "Key 関数" -#: ../../howto/sorting.rst:47 msgid "" "The :meth:`list.sort` method and the functions :func:`sorted`, :func:`min`, :" "func:`max`, :func:`heapq.nsmallest`, and :func:`heapq.nlargest` have a *key* " "parameter to specify a function (or other callable) to be called on each " "list element prior to making comparisons." msgstr "" +":meth:`list.sort` メソッドと :func:`sorted`、:func:`min`、:func:`max`、:func:" +"`heapq.nsmallest`、:func:`heapq.nlargest` 関数には、比較の前にリストの各要素" +"に対して呼び出す関数 (または他の呼び出し可能オブジェクト) を指定する ``key`` " +"パラメーターがあります。" -#: ../../howto/sorting.rst:53 msgid "" "For example, here's a case-insensitive string comparison using :meth:`str." "casefold`:" msgstr "" +"例えば、:meth:`str.casefold` を使うと、大文字と小文字を区別せずに文字列を比較" +"できます。" -#: ../../howto/sorting.rst:56 msgid "" ">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" msgstr "" +">>> sorted(\"This is a test string from Andrew\".split(), key=str.casefold)\n" +"['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']" #: ../../howto/sorting.rst:61 msgid "" @@ -131,15 +141,14 @@ msgstr "" "りソートを高速に行えます、キー関数は各入力レコードに対してきっちり一回だけ呼" "び出されるからです。" -#: ../../howto/sorting.rst:66 msgid "" "A common pattern is to sort complex objects using some of the object's " "indices as keys. For example:" msgstr "" -"よくある利用パターンはいくつかの要素から成る対象をインデクスのどれかをキーと" -"してソートすることです。例えば:" +"よくある使い方は、複数の要素を持つオブジェクトからインデックスで取り出した値" +"をキーにしてソートすることです。\n" +"例を示します。" -#: ../../howto/sorting.rst:69 msgid "" ">>> student_tuples = [\n" "... ('john', 'A', 15),\n" @@ -149,6 +158,13 @@ msgid "" ">>> sorted(student_tuples, key=lambda student: student[2]) # sort by age\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> student_tuples = [\n" +"... ('john', 'A', 15),\n" +"... ('jane', 'B', 12),\n" +"... ('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_tuples, key=lambda student: student[2]) # 年齢でソート\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:79 msgid "" @@ -157,7 +173,6 @@ msgstr "" "同じテクニックは名前づけされた属性 (named attributes) を使うことでオブジェク" "トに対しても動作します。例えば:" -#: ../../howto/sorting.rst:81 msgid "" ">>> class Student:\n" "... def __init__(self, name, grade, age):\n" @@ -176,6 +191,22 @@ msgid "" "age\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> class Student:\n" +"... def __init__(self, name, grade, age):\n" +"... self.name = name\n" +"... self.grade = grade\n" +"... self.age = age\n" +"... def __repr__(self):\n" +"... return repr((self.name, self.grade, self.age))\n" +"\n" +">>> student_objects = [\n" +"... Student('john', 'A', 15),\n" +"... Student('jane', 'B', 12),\n" +"... Student('dave', 'B', 10),\n" +"... ]\n" +">>> sorted(student_objects, key=lambda student: student.age) # 年齢でソー" +"ト\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:99 msgid "" @@ -207,7 +238,6 @@ msgstr "" msgid "Using those functions, the above examples become simpler and faster:" msgstr "これらの関数を利用すると、上の例はもっと簡単で高速になります:" -#: ../../howto/sorting.rst:113 msgid "" ">>> from operator import itemgetter, attrgetter\n" "\n" @@ -217,16 +247,22 @@ msgid "" ">>> sorted(student_objects, key=attrgetter('age'))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> from operator import itemgetter, attrgetter\n" +"\n" +">>> sorted(student_tuples, key=itemgetter(2))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('age'))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:123 msgid "" "The operator module functions allow multiple levels of sorting. For example, " "to sort by *grade* then by *age*:" msgstr "" -"operator モジュールの関数は複数の段階でのソートを可能にします。例えば、 " -"*grade* でソートしてさらに *age* でソートする場合:" +"operator モジュールの関数では、複数のキーに優先順位を付けてソートできます。\n" +"例えば、まず *grade* で比較し、同じ場合は *age* で比較するには、次のようにし" +"ます。" -#: ../../howto/sorting.rst:126 msgid "" ">>> sorted(student_tuples, key=itemgetter(1,2))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]\n" @@ -234,6 +270,11 @@ msgid "" ">>> sorted(student_objects, key=attrgetter('grade', 'age'))\n" "[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]" msgstr "" +">>> sorted(student_tuples, key=itemgetter(1,2))\n" +"[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('grade', 'age'))\n" +"[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]" #: ../../howto/sorting.rst:134 msgid "" @@ -246,7 +287,6 @@ msgstr "" "す。:func:`~functools.partial` 関数は複数引数の関数の `アリティ `_ を減らし、キー関数に適したものにできます。" -#: ../../howto/sorting.rst:139 msgid "" ">>> from functools import partial\n" ">>> from unicodedata import normalize\n" @@ -259,6 +299,16 @@ msgid "" ">>> sorted(names, key=partial(normalize, 'NFC'))\n" "['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']" msgstr "" +">>> from functools import partial\n" +">>> from unicodedata import normalize\n" +"\n" +">>> names = 'Zoë Åbjørn Núñez Élana Zeke Abe Nubia Eloise'.split()\n" +"\n" +">>> sorted(names, key=partial(normalize, 'NFD'))\n" +"['Abe', 'Åbjørn', 'Eloise', 'Élana', 'Nubia', 'Núñez', 'Zeke', 'Zoë']\n" +"\n" +">>> sorted(names, key=partial(normalize, 'NFC'))\n" +"['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']" #: ../../howto/sorting.rst:153 msgid "Ascending and Descending" @@ -274,7 +324,6 @@ msgstr "" "として受け付けます。このパラメータは降順ソートを行うかどうかの フラグとして利" "用されます。 例えば、学生のデータを *age* の逆順で得たい場合:" -#: ../../howto/sorting.rst:159 msgid "" ">>> sorted(student_tuples, key=itemgetter(2), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]\n" @@ -282,6 +331,11 @@ msgid "" ">>> sorted(student_objects, key=attrgetter('age'), reverse=True)\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" msgstr "" +">>> sorted(student_tuples, key=itemgetter(2), reverse=True)\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]\n" +"\n" +">>> sorted(student_objects, key=attrgetter('age'), reverse=True)\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" #: ../../howto/sorting.rst:168 msgid "Sort Stability and Complex Sorts" @@ -297,12 +351,14 @@ msgstr "" "Sorting_algorithm#Stability>`_ であることが保証されています。これはレコードの" "中に同じキーがある場合、元々の順序が維持されるということを意味します。" -#: ../../howto/sorting.rst:174 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> sorted(data, key=itemgetter(0))\n" "[('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]" msgstr "" +">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" +">>> sorted(data, key=itemgetter(0))\n" +"[('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]" #: ../../howto/sorting.rst:180 msgid "" @@ -312,17 +368,15 @@ msgstr "" "二つの *blue* のレコードが元々の順序を維持して、 ``('blue', 1)`` が " "``('blue', 2)`` の前にあることに注意してください。" -#: ../../howto/sorting.rst:183 msgid "" "This wonderful property lets you build complex sorts in a series of sorting " "steps. For example, to sort the student data by descending *grade* and then " "ascending *age*, do the *age* sort first and then sort again using *grade*:" msgstr "" -"この素晴しい性質によって複数のソートを段階的に組み合わせることができます。例" -"えば、学生データを *grade* の降順にソートし、さらに *age* の昇順にソートした" -"い場合には、まず *age* でソートし、次に *grade* でもう一度ソートします:" +"この性質を使うと、複数回のソートを組み合わせて複雑な順序で並べられます。\n" +"例えば、学生のデータを *grade* の降順に並べ、同じ成績の中では *age* の昇順に" +"並べるには、先に *age* でソートしてから *grade* でもう一度ソートします。" -#: ../../howto/sorting.rst:187 msgid "" ">>> s = sorted(student_objects, key=attrgetter('age')) # sort on " "secondary key\n" @@ -330,6 +384,11 @@ msgid "" "primary key, descending\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> s = sorted(student_objects, key=attrgetter('age')) # 第 2 キーでソー" +"ト\n" +">>> sorted(s, key=attrgetter('grade'), reverse=True) # 次に第 1 キーの" +"降順でソート\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:193 msgid "" @@ -339,7 +398,6 @@ msgstr "" "この処理は、リストおよびフィールド名とソート順序のタプルを複数受け取れるラッ" "パー関数へ抽象化できます。" -#: ../../howto/sorting.rst:196 msgid "" ">>> def multisort(xs, specs):\n" "... for key, reverse in reversed(specs):\n" @@ -349,6 +407,13 @@ msgid "" ">>> multisort(list(student_objects), (('grade', True), ('age', False)))\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> def multisort(xs, specs):\n" +"... for key, reverse in reversed(specs):\n" +"... xs.sort(key=attrgetter(key), reverse=reverse)\n" +"... return xs\n" +"\n" +">>> multisort(list(student_objects), (('grade', True), ('age', False)))\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" #: ../../howto/sorting.rst:206 msgid "" @@ -394,7 +459,6 @@ msgid "" "For example, to sort the student data by *grade* using the DSU approach:" msgstr "例えば、DSU アプローチを利用して学生データを *grade* でソートする場合:" -#: ../../howto/sorting.rst:224 msgid "" ">>> decorated = [(student.grade, i, student) for i, student in " "enumerate(student_objects)]\n" @@ -402,15 +466,20 @@ msgid "" ">>> [student for grade, i, student in decorated] # undecorate\n" "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" msgstr "" +">>> decorated = [(student.grade, i, student) for i, student in " +"enumerate(student_objects)]\n" +">>> decorated.sort()\n" +">>> [student for grade, i, student in decorated] # デコレートを" +"取り除く\n" +"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]" -#: ../../howto/sorting.rst:231 msgid "" "This idiom works because tuples are compared lexicographically; the first " "items are compared; if they are the same then the second items are compared, " "and so on." msgstr "" -"このイディオムはタブルが辞書編集的に比較されるため正しく動作します; 最初の要" -"素が比較され、同じ場合には第二の要素が比較され、以下も同様に動きます。" +"このイディオムが機能するのは、タプルが辞書式順序で比較されるためです。\n" +"最初の要素を比較し、同じなら二番目の要素を比較する、というように進みます。" #: ../../howto/sorting.rst:235 msgid "" @@ -428,34 +497,33 @@ msgstr "" "ソートが安定になります -- もし二つの要素が同じキーを持つ場合、それらの順序が" "ソートされたリストでも維持されます。" -#: ../../howto/sorting.rst:241 msgid "" "The original items do not have to be comparable because the ordering of the " "decorated tuples will be determined by at most the first two items. So for " "example the original list could contain complex numbers which cannot be " "sorted directly." msgstr "" -"元々の要素が比較可能な要素を持つとは限りません、なぜならデコレートされたタブ" -"ルの順序は多くの場合、最初の二つの要素で決定されるからです。例として元のリス" -"トは直接比較できない複素数を含むことができます。" +"デコレートしたタプルの順序は、最大でも最初の二つの要素を比較すれば決まるた" +"め、元の要素は比較可能である必要がありません。\n" +"例えば、元のリストに、そのままではソートできない複素数を含めることもできま" +"す。" -#: ../../howto/sorting.rst:246 msgid "" "Another name for this idiom is `Schwartzian transform `_\\, after Randal L. Schwartz, who " "popularized it among Perl programmers." msgstr "" -"このイディオムの別名に `Schwartzian transform `_ があります。これは Perl プログラマの間で有名な " -"Randal L. Schwartz にちなんでいます。" +"このイディオムは `Schwartzian transform `_ とも呼ばれます。\n" +"Perl プログラマーの間にこの手法を広めた Randal L. Schwartz にちなんだ名前で" +"す。" -#: ../../howto/sorting.rst:250 msgid "" "Now that Python sorting provides key-functions, this technique is not often " "needed." msgstr "" -"いまや Python のソートは key 関数による方法を提供しているので、このテクニック" -"は不要でしょう。" +"現在の Python のソートではキー関数を使えるため、このテクニックが必要になるこ" +"とはあまりありません。" #: ../../howto/sorting.rst:253 msgid "Comparison Functions" @@ -494,50 +562,48 @@ msgstr "" "数を目にすることがよくあります。また、その API の一部として比較関数を提供して" "いるライブラリもあります。例えば、 :func:`locale.strcoll` は比較関数です。" -#: ../../howto/sorting.rst:269 msgid "" "To accommodate those situations, Python provides :class:`functools." "cmp_to_key` to wrap the comparison function to make it usable as a key " "function::" msgstr "" "このような場合に対処するため、Python は比較関数をラップしてキー関数として使え" -"るようにする関数 :class:`functools.cmp_to_key` を提供しています。" +"るようにする関数 :class:`functools.cmp_to_key` を提供しています。 ::" -#: ../../howto/sorting.rst:273 msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order" -msgstr "" +msgstr "sorted(words, key=cmp_to_key(strcoll)) # ロケールに応じたソート順" -#: ../../howto/sorting.rst:276 msgid "Strategies For Unorderable Types and Values" -msgstr "" +msgstr "順序を比較できない型や値への対処" -#: ../../howto/sorting.rst:278 msgid "" "A number of type and value issues can arise when sorting. Here are some " "strategies that can help:" msgstr "" +"ソートでは、型や値に関する問題が起こる場合があります。\n" +"役に立つ対処方法をいくつか紹介します。" -#: ../../howto/sorting.rst:281 msgid "Convert non-comparable input types to strings prior to sorting:" -msgstr "" +msgstr "比較できない型の入力は、ソートの前に文字列に変換します。" -#: ../../howto/sorting.rst:283 msgid "" ">>> data = ['twelve', '11', 10]\n" ">>> sorted(map(str, data))\n" "['10', '11', 'twelve']" msgstr "" +">>> data = ['twelve', '11', 10]\n" +">>> sorted(map(str, data))\n" +"['10', '11', 'twelve']" -#: ../../howto/sorting.rst:289 msgid "" "This is needed because most cross-type comparisons raise a :exc:`TypeError`." msgstr "" +"型が異なる値を比較すると、多くの場合 :exc:`TypeError` が送出されるため、この" +"変換が必要です。" -#: ../../howto/sorting.rst:292 msgid "Remove special values prior to sorting:" -msgstr "" +msgstr "ソートの前に特殊な値を取り除きます。" -#: ../../howto/sorting.rst:294 msgid "" ">>> from math import isnan\n" ">>> from itertools import filterfalse\n" @@ -545,62 +611,74 @@ msgid "" ">>> sorted(filterfalse(isnan, data))\n" "[1.1, 2.2, 3.3]" msgstr "" +">>> from math import isnan\n" +">>> from itertools import filterfalse\n" +">>> data = [3.3, float('nan'), 1.1, 2.2]\n" +">>> sorted(filterfalse(isnan, data))\n" +"[1.1, 2.2, 3.3]" -#: ../../howto/sorting.rst:302 msgid "" "This is needed because the `IEEE-754 standard `_ specifies that, \"Every NaN shall compare unordered with " "everything, including itself.\"" msgstr "" +"`IEEE-754 規格 `_ は「すべての NaN " +"は、自分自身を含むあらゆる値との比較で順序付け不能となる」と定めているため、" +"この処理が必要です。" -#: ../../howto/sorting.rst:306 msgid "Likewise, ``None`` can be stripped from datasets as well:" -msgstr "" +msgstr "同様に、データから ``None`` を取り除くこともできます。" -#: ../../howto/sorting.rst:308 msgid "" ">>> data = [3.3, None, 1.1, 2.2]\n" ">>> sorted(x for x in data if x is not None)\n" "[1.1, 2.2, 3.3]" msgstr "" +">>> data = [3.3, None, 1.1, 2.2]\n" +">>> sorted(x for x in data if x is not None)\n" +"[1.1, 2.2, 3.3]" -#: ../../howto/sorting.rst:314 msgid "This is needed because ``None`` is not comparable to other types." -msgstr "" +msgstr "``None`` と他の型の値では順序を比較できないため、この処理が必要です。" -#: ../../howto/sorting.rst:316 msgid "Convert mapping types into sorted item lists before sorting:" -msgstr "" +msgstr "マッピング型は、ソートの前にソート済みの要素のリストに変換します。" -#: ../../howto/sorting.rst:318 msgid "" ">>> data = [{'a': 1}, {'b': 2}]\n" ">>> sorted(data, key=lambda d: sorted(d.items()))\n" "[{'a': 1}, {'b': 2}]" msgstr "" +">>> data = [{'a': 1}, {'b': 2}]\n" +">>> sorted(data, key=lambda d: sorted(d.items()))\n" +"[{'a': 1}, {'b': 2}]" -#: ../../howto/sorting.rst:324 msgid "" "This is needed because dict-to-dict comparisons raise a :exc:`TypeError`." msgstr "" +"辞書同士の順序を比較すると :exc:`TypeError` が送出されるため、この変換が必要" +"です。" -#: ../../howto/sorting.rst:327 msgid "Convert set types into sorted lists before sorting:" -msgstr "" +msgstr "集合型は、ソートの前にソート済みのリストに変換します。" -#: ../../howto/sorting.rst:329 msgid "" ">>> data = [{'a', 'b', 'c'}, {'b', 'c', 'd'}]\n" ">>> sorted(map(sorted, data))\n" "[['a', 'b', 'c'], ['b', 'c', 'd']]" msgstr "" +">>> data = [{'a', 'b', 'c'}, {'b', 'c', 'd'}]\n" +">>> sorted(map(sorted, data))\n" +"[['a', 'b', 'c'], ['b', 'c', 'd']]" -#: ../../howto/sorting.rst:335 msgid "" "This is needed because the elements contained in set types do not have a " "deterministic order. For example, ``list({'a', 'b'})`` may produce either " "``['a', 'b']`` or ``['b', 'a']``." msgstr "" +"集合型に含まれる要素には決まった順序がないため、この変換が必要です。\n" +"例えば、``list({'a', 'b'})`` の結果は ``['a', 'b']`` にも ``['b', 'a']`` にも" +"なり得ます。" #: ../../howto/sorting.rst:340 msgid "Odds and Ends" @@ -629,7 +707,6 @@ msgstr "" "しい場合元々の順序が維持されます)。面白いことにこの影響はパラメータ無しで :" "func:`reversed` 関数を二回使うことで模倣することができます:" -#: ../../howto/sorting.rst:352 msgid "" ">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" ">>> standard_way = sorted(data, key=itemgetter(0), reverse=True)\n" @@ -639,6 +716,13 @@ msgid "" ">>> standard_way\n" "[('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]" msgstr "" +">>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]\n" +">>> standard_way = sorted(data, key=itemgetter(0), reverse=True)\n" +">>> double_reversed = list(reversed(sorted(reversed(data), " +"key=itemgetter(0))))\n" +">>> assert standard_way == double_reversed\n" +">>> standard_way\n" +"[('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]" #: ../../howto/sorting.rst:361 msgid "" @@ -650,14 +734,15 @@ msgstr "" "ラスに標準のソート順序を追加することは :meth:`~object.__lt__` メソッドを定義" "することで達成できます。" -#: ../../howto/sorting.rst:365 msgid "" ">>> Student.__lt__ = lambda self, other: self.age < other.age\n" ">>> sorted(student_objects)\n" "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" msgstr "" +">>> Student.__lt__ = lambda self, other: self.age < other.age\n" +">>> sorted(student_objects)\n" +"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]" -#: ../../howto/sorting.rst:371 msgid "" "However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :" "meth:`~object.__lt__` is not implemented (see :func:`object.__lt__` for " @@ -665,6 +750,13 @@ msgid "" "six comparison methods be implemented. The :deco:`~functools.total_ordering` " "decorator is provided to make that task easier." msgstr "" +"ただし、:meth:`~object.__lt__` が実装されていない場合、``<`` は代わりに :" +"meth:`~object.__gt__` を使うことがあります (仕組みの詳細は :func:`object." +"__lt__` を参照)。\n" +"予想外の動作を避けるため、:pep:`8` は六つの比較メソッドをすべて実装するよう推" +"奨しています。\n" +"この作業を簡単にするために、:deco:`~functools.total_ordering` デコレーターが" +"提供されています。" #: ../../howto/sorting.rst:378 msgid "" @@ -677,13 +769,16 @@ msgstr "" "ソースにアクセスすることもできます。例えば学生の成績が辞書に保存されている場" "合、それを利用して別の学生の名前のリストをソートすることができます:" -#: ../../howto/sorting.rst:383 msgid "" ">>> students = ['dave', 'john', 'jane']\n" ">>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}\n" ">>> sorted(students, key=newgrades.__getitem__)\n" "['jane', 'dave', 'john']" msgstr "" +">>> students = ['dave', 'john', 'jane']\n" +">>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}\n" +">>> sorted(students, key=newgrades.__getitem__)\n" +"['jane', 'dave', 'john']" #: ../../howto/sorting.rst:391 msgid "Partial Sorts" diff --git a/howto/timerfd.po b/howto/timerfd.po index 966487f6e..9983fff3d 100644 --- a/howto/timerfd.po +++ b/howto/timerfd.po @@ -16,40 +16,39 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../howto/timerfd.rst:5 msgid "timer file descriptor HOWTO" -msgstr "" +msgstr "タイマーファイル記述子 HOWTO" #: ../../howto/timerfd.rst:0 msgid "Release" msgstr "リリース" -#: ../../howto/timerfd.rst:7 msgid "1.13" -msgstr "" +msgstr "1.13" -#: ../../howto/timerfd.rst:9 msgid "" "This HOWTO discusses Python's support for the linux timer file descriptor." msgstr "" +"この HOWTO では、Linux のタイマーファイル記述子を Python で使う方法を説明しま" +"す。" #: ../../howto/timerfd.rst:13 msgid "Examples" msgstr "使用例" -#: ../../howto/timerfd.rst:15 msgid "" "The following example shows how to use a timer file descriptor to execute a " "function twice a second:" msgstr "" +"次の例は、タイマーファイル記述子を使って 1 秒に 2 回関数を実行する方法を示し" +"ます。" -#: ../../howto/timerfd.rst:18 msgid "" "# Practical scripts should use really use a non-blocking timer,\n" "# we use a blocking timer here for simplicity.\n" @@ -71,21 +70,43 @@ msgid "" " # Remember to close the timer file descriptor!\n" " os.close(fd)" msgstr "" +"# 実用的なスクリプトではノンブロッキングのタイマーを使うべきだが、\n" +"# ここでは簡単にするためブロッキングのタイマーを使う。\n" +"import os, time\n" +"\n" +"# タイマーファイル記述子を作成する\n" +"fd = os.timerfd_create(time.CLOCK_REALTIME)\n" +"\n" +"# 1 秒後に初回の満了を迎え、その後は 0.5 秒間隔とする\n" +"os.timerfd_settime(fd, initial=1, interval=0.5)\n" +"\n" +"try:\n" +" # タイマーのイベントを 4 回処理する。\n" +" for _ in range(4):\n" +" # タイマーが満了するまで read() はブロックする\n" +" _ = os.read(fd, 8)\n" +" print(\"Timer expired\")\n" +"finally:\n" +" # 忘れずにタイマーファイル記述子を閉じる。\n" +" os.close(fd)" -#: ../../howto/timerfd.rst:40 msgid "" "To avoid the precision loss caused by the :class:`float` type, timer file " "descriptors allow specifying initial expiration and interval in integer " "nanoseconds with ``_ns`` variants of the functions." msgstr "" +":class:`float` 型による精度の低下を避けるため、タイマーファイル記述子の関数に" +"は ``_ns`` 版が用意されています。\n" +"これらを使うと、最初にタイマーが満了するまでの時間と間隔を、整数のナノ秒単位" +"で指定できます。" -#: ../../howto/timerfd.rst:44 msgid "" "This example shows how :func:`~select.epoll` can be used with timer file " "descriptors to wait until the file descriptor is ready for reading:" msgstr "" +"この例は、タイマーファイル記述子と :func:`~select.epoll` を組み合わせ、ファイ" +"ル記述子が読み取り可能になるまで待つ方法を示します。" -#: ../../howto/timerfd.rst:47 msgid "" "import os, time, select, socket, sys\n" "\n" @@ -202,12 +223,124 @@ msgid "" " os.close(fd)\n" " ep.close()" msgstr "" +"import os, time, select, socket, sys\n" +"\n" +"# epoll オブジェクトを作成する\n" +"ep = select.epoll()\n" +"\n" +"# この例ではループバックアドレスでサーバーに \"stop\" コマンドを送る。\n" +"#\n" +"# $ telnet 127.0.0.1 1234\n" +"# Trying 127.0.0.1...\n" +"# Connected to 127.0.0.1.\n" +"# Escape character is '^]'.\n" +"# stop\n" +"# Connection closed by foreign host.\n" +"#\n" +"sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n" +"sock.bind((\"127.0.0.1\", 1234))\n" +"sock.setblocking(False)\n" +"sock.listen(1)\n" +"ep.register(sock, select.EPOLLIN)\n" +"\n" +"# ノンブロッキングモードでタイマーファイル記述子を作成する。\n" +"num = 3\n" +"fds = []\n" +"for _ in range(num):\n" +" fd = os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)\n" +" fds.append(fd)\n" +" # タイマーファイル記述子を読み取りイベント用に登録する\n" +" ep.register(fd, select.EPOLLIN)\n" +"\n" +"# os.timerfd_settime_ns() でナノ秒単位の時間を指定してタイマーを開始する。\n" +"# タイマー 1 は 0.25 秒間隔、タイマー 2 は 0.5 秒間隔、以下も同様。\n" +"for i, fd in enumerate(fds, start=1):\n" +" one_sec_in_nsec = 10**9\n" +" i = i * one_sec_in_nsec\n" +" os.timerfd_settime_ns(fd, initial=i//4, interval=i//4)\n" +"\n" +"timeout = 3\n" +"try:\n" +" conn = None\n" +" is_active = True\n" +" while is_active:\n" +" # タイマーの満了を最大 3 秒待つ。\n" +" # epoll.poll() は (fd, event) のペアのリストを返す。\n" +" # fd はファイル記述子。\n" +" # sock と conn [socket.accept() の戻り値] はファイル記述子ではなくソ" +"ケットオブジェクト。\n" +" # そのため、ファイル記述子は sock.fileno() と conn.fileno() で取得す" +"る。\n" +" events = ep.poll(timeout)\n" +"\n" +" # 複数のタイマーファイル記述子が同時に読み取り可能になった場合、\n" +" # epoll.poll() は (fd, event) のペアのリストを返す。\n" +" #\n" +" # この例の設定では、\n" +" # 第 1 タイマーは 0.25 秒後から 0.25 秒間隔で満了する。(0.25, " +"0.5, 0.75, 1.0, ...)\n" +" # 第 2 タイマーは 0.5 秒後から 0.5 秒間隔。(0.5, 1.0, 1.5, " +"2.0, ...)\n" +" # 第 3 タイマーは 0.75 秒後から 0.75 秒間隔。(0.75, 1.5, 2.25, " +"3.0, ...)\n" +" #\n" +" # 0.25 秒後には第 1 タイマーだけが満了する。\n" +" # 0.5 秒後には第 1 タイマーと第 2 タイマーが同時に満了する。\n" +" # 0.75 秒後には第 1 タイマーと第 3 タイマーが同時に満了する。\n" +" # 1.5 秒後には第 1、第 2、第 3 タイマーが同時に満了する。\n" +" #\n" +" # タイマーファイル記述子が前回の os.read() の呼び出し以降に\n" +" # 複数回通知された場合、os.read() は通知回数を\n" +" # ホストのバイト順の bytes オブジェクトとして返す。\n" +" print(f\"Signaled events={events}\")\n" +" for fd, event in events:\n" +" if event & select.EPOLLIN:\n" +" if fd == sock.fileno():\n" +" # 接続要求があるか確認する。\n" +" print(f\"Accepting connection {fd}\")\n" +" conn, addr = sock.accept()\n" +" conn.setblocking(False)\n" +" print(f\"Accepted connection {conn} from {addr}\")\n" +" ep.register(conn, select.EPOLLIN)\n" +" elif conn and fd == conn.fileno():\n" +" # 読み取るデータがあるか確認する。\n" +" print(f\"Reading data {fd}\")\n" +" data = conn.recv(1024)\n" +" if data:\n" +" # 安全のため、UnicodeDecodeError 例外を捕捉するべ" +"き。\n" +" cmd = data.decode()\n" +" if cmd.startswith(\"stop\"):\n" +" print(f\"Stopping server\")\n" +" is_active = False\n" +" else:\n" +" print(f\"Unknown command: {cmd}\")\n" +" else:\n" +" # これ以上データがないので接続を閉じる\n" +" print(f\"Closing connection {fd}\")\n" +" ep.unregister(conn)\n" +" conn.close()\n" +" conn = None\n" +" elif fd in fds:\n" +" print(f\"Reading timer {fd}\")\n" +" count = int.from_bytes(os.read(fd, 8), byteorder=sys." +"byteorder)\n" +" print(f\"Timer {fds.index(fd) + 1} expired {count} " +"times\")\n" +" else:\n" +" print(f\"Unknown file descriptor {fd}\")\n" +"finally:\n" +" for fd in fds:\n" +" ep.unregister(fd)\n" +" os.close(fd)\n" +" ep.close()" -#: ../../howto/timerfd.rst:153 msgid "" "This example shows how :func:`~select.select` can be used with timer file " "descriptors to wait until the file descriptor is ready for reading:" msgstr "" +"この例は、タイマーファイル記述子と :func:`~select.select` を組み合わせ、ファ" +"イル記述子が読み取り可能になるまで待つ方法を示します。" #: ../../howto/timerfd.rst:156 msgid "" diff --git a/howto/unicode.po b/howto/unicode.po index 4eef1d2a9..b73f35fd0 100644 --- a/howto/unicode.po +++ b/howto/unicode.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/unicode.rst:5 @@ -92,7 +92,6 @@ msgstr "" "例えば、「ローマ数字の 1」という文字 'Ⅰ' は大文字の 'I' とは別の文字です。\n" "両者は通常は同じに見えますが、異なる意味を持つ別々の2つの文字です。" -#: ../../howto/unicode.rst:40 msgid "" "The Unicode standard describes how characters are represented by **code " "points**. A code point value is an integer in the range 0 to 0x10FFFF " @@ -101,6 +100,12 @@ msgid "" "this document, a code point is written using the notation ``U+265E`` to mean " "the character with value ``0x265e`` (9,822 in decimal)." msgstr "" +"Unicode 標準は、文字を **コードポイント** で表す方法を定めています。\n" +"コードポイントの値は 0 から 0x10FFFF までの整数です (約 110 万個の値があり、`" +"実際に割り当てられた数 `_ " +"はそれより少なくなっています)。\n" +"標準とこの文書では、``U+265E`` という表記で、値が ``0x265e`` (10 進数では " +"9,822) の文字を表します。" #: ../../howto/unicode.rst:48 msgid "" @@ -110,7 +115,6 @@ msgstr "" "Unicode 標準は、文字とそれに対応するコードポイントを列挙した多くの表を含んで" "います:" -#: ../../howto/unicode.rst:51 msgid "" "0061 'a'; LATIN SMALL LETTER A\n" "0062 'b'; LATIN SMALL LETTER B\n" @@ -128,6 +132,21 @@ msgid "" "1F609 '😉'; WINKING FACE\n" "..." msgstr "" +"0061 'a'; LATIN SMALL LETTER A\n" +"0062 'b'; LATIN SMALL LETTER B\n" +"0063 'c'; LATIN SMALL LETTER C\n" +"...\n" +"007B '{'; LEFT CURLY BRACKET\n" +"...\n" +"2167 'Ⅷ'; ROMAN NUMERAL EIGHT\n" +"2168 'Ⅸ'; ROMAN NUMERAL NINE\n" +"...\n" +"265E '♞'; BLACK CHESS KNIGHT\n" +"265F '♟'; BLACK CHESS PAWN\n" +"...\n" +"1F600 '😀'; GRINNING FACE\n" +"1F609 '😉'; WINKING FACE\n" +"..." #: ../../howto/unicode.rst:69 msgid "" @@ -179,19 +198,23 @@ msgstr "" "訳する規則を **文字エンコーディング** または単に **エンコーディング** と呼び" "ます。" -#: ../../howto/unicode.rst:95 msgid "" "The first encoding you might think of is using 32-bit integers as the code " "unit, and then using the CPU's representation of 32-bit integers. In this " "representation, the string \"Python\" might look like this:" msgstr "" +"最初に思い付くエンコーディングは、32 ビット整数をコードユニットとし、CPU の " +"32 ビット整数表現を使う方法かもしれません。\n" +"この方法では、文字列 \"Python\" は例えば次のように表されます。" -#: ../../howto/unicode.rst:99 msgid "" " P y t h o n\n" "0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n" " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" msgstr "" +" P y t h o n\n" +"0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00\n" +" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23" #: ../../howto/unicode.rst:105 msgid "" @@ -232,13 +255,13 @@ msgstr "" "``strlen()`` のような現存する C 関数と互換性がありません、そのためワイド文字" "列関数一式が新たに必要となります。" -#: ../../howto/unicode.rst:121 msgid "" "Therefore this encoding isn't used very much, and people instead choose " "other encodings that are more efficient and convenient, such as UTF-8." msgstr "" +"そのため、このエンコーディングはあまり使われず、代わりに UTF-8 のような、より" +"効率的で便利なエンコーディングが選ばれます。" -#: ../../howto/unicode.rst:124 msgid "" "UTF-8 is one of the most commonly used encodings, and Python often defaults " "to using it. UTF stands for \"Unicode Transformation Format\", and the '8' " @@ -246,6 +269,13 @@ msgid "" "and UTF-32 encodings, but they are less frequently used than UTF-8.) UTF-8 " "uses the following rules:" msgstr "" +"UTF-8 は最も広く使われるエンコーディングの一つで、Python でもデフォルトとして" +"よく使われます。\n" +"UTF は \"Unicode Transformation Format\" の略で、「8」はエンコーディングに 8 " +"ビットの値を使うことを意味します。\n" +"(UTF-16 や UTF-32 というエンコーディングもありますが、UTF-8 ほど頻繁には使わ" +"れません。)\n" +"UTF-8 は次の規則に従います。" #: ../../howto/unicode.rst:130 msgid "" @@ -268,7 +298,6 @@ msgstr "UTF-8 はいくつかの便利な性質を持っています:" msgid "It can handle any Unicode code point." msgstr "任意の Unicode コードポイントを扱うことができる。" -#: ../../howto/unicode.rst:137 msgid "" "A Unicode string is turned into a sequence of bytes that contains embedded " "zero bytes only where they represent the null character (U+0000). This means " @@ -276,6 +305,10 @@ msgid "" "sent through protocols that can't handle zero bytes for anything other than " "end-of-string markers." msgstr "" +"Unicode 文字列をバイト列に変換したとき、値がゼロのバイトが含まれるのは、それ" +"がヌル文字 (U+0000) を表す場合だけです。\n" +"そのため、UTF-8 文字列は ``strcpy()`` などの C 関数で処理でき、文字列の終端以" +"外ではゼロのバイトを扱えないプロトコルでも送信できます。" #: ../../howto/unicode.rst:142 msgid "A string of ASCII text is also valid UTF-8 text." @@ -299,7 +332,6 @@ msgstr "" "の開始を決定し、再同期することができる可能性があります。同様の理由でランダム" "な 8-bit データは正当な UTF-8 とみなされにくくなっています。" -#: ../../howto/unicode.rst:148 msgid "" "UTF-8 is a byte oriented encoding. The encoding specifies that each " "character is represented by a specific sequence of one or more bytes. This " @@ -307,6 +339,12 @@ msgid "" "oriented encodings, like UTF-16 and UTF-32, where the sequence of bytes " "varies depending on the hardware on which the string was encoded." msgstr "" +"UTF-8 はバイト単位のエンコーディングです。\n" +"各文字を、決まった 1 バイト以上の並びで表すように定めています。\n" +"そのため、整数やワード単位のエンコーディングで生じ得るバイト順の問題を避けら" +"れます。\n" +"例えば UTF-16 や UTF-32 では、文字列をエンコードしたハードウェアによってバイ" +"トの並びが変わります。" #: ../../howto/unicode.rst:156 ../../howto/unicode.rst:514 #: ../../howto/unicode.rst:735 @@ -326,12 +364,14 @@ msgstr "" "悟してください。Unicode の起源と発展の `年表 `_ もサイトにあります。" -#: ../../howto/unicode.rst:163 msgid "" "On the Computerphile Youtube channel, Tom Scott briefly `discusses the " "history of Unicode and UTF-8 `_ " "(9 minutes 36 seconds)." msgstr "" +"Computerphile の YouTube チャンネルでは、Tom Scott が `Unicode と UTF-8 の歴" +"史を簡潔に説明しています `_ (9 " +"分 36 秒)。" #: ../../howto/unicode.rst:167 msgid "" @@ -342,7 +382,6 @@ msgstr "" "標準を理解する助けにするために、Jukka Korpela が Unicode 文字表を読むための `" "入門ガイド `_ を書いています。" -#: ../../howto/unicode.rst:171 msgid "" "Another `good introductory article `_ もありま" +"す。\n" +"ここまでの説明で理解できなかった場合は、先に進む前にそちらの記事を読んでみて" +"ください。" #: ../../howto/unicode.rst:176 msgid "" @@ -377,13 +422,15 @@ msgstr "" msgid "The String Type" msgstr "文字列型" -#: ../../howto/unicode.rst:190 msgid "" "Since Python 3.0, the language's :class:`str` type contains Unicode " "characters, meaning any string created using ``\"unicode rocks!\"``, " "``'unicode rocks!'``, or the triple-quoted string syntax is stored as " "Unicode." msgstr "" +"Python 3.0 以降、:class:`str` 型は Unicode 文字を格納します。\n" +"つまり、``\"unicode rocks!\"``、``'unicode rocks!'``、または三重引用符の文字" +"列構文で作った文字列は、すべて Unicode として保存されます。" #: ../../howto/unicode.rst:194 msgid "" @@ -393,7 +440,6 @@ msgstr "" "Python ソースコードのデフォルトエンコーディングは UTF-8 なので、文字列リテラ" "ルの中に Unicode 文字をそのまま含めることができます::" -#: ../../howto/unicode.rst:197 msgid "" "try:\n" " with open('/tmp/input.txt', 'r') as f:\n" @@ -402,32 +448,39 @@ msgid "" " # 'File not found' error message.\n" " print(\"Fichier non trouvé\")" msgstr "" +"try:\n" +" with open('/tmp/input.txt', 'r') as f:\n" +" ...\n" +"except OSError:\n" +" # 「ファイルが見つからない」というエラーメッセージ。\n" +" print(\"Fichier non trouvé\")" #: ../../howto/unicode.rst:204 msgid "" "Side note: Python 3 also supports using Unicode characters in identifiers::" msgstr "追記: Python3 は Unicode 文字を使った識別子もサポートしています::" -#: ../../howto/unicode.rst:206 msgid "" "répertoire = \"/tmp/records.log\"\n" "with open(répertoire, \"w\") as f:\n" " f.write(\"test\\n\")" msgstr "" +"répertoire = \"/tmp/records.log\"\n" +"with open(répertoire, \"w\") as f:\n" +" f.write(\"test\\n\")" -#: ../../howto/unicode.rst:210 msgid "" "If you can't enter a particular character in your editor or want to keep the " "source code ASCII-only for some reason, you can also use escape sequences in " "string literals. (Depending on your system, you may see the actual capital-" "delta glyph instead of a \\u escape.) ::" msgstr "" -"エディタである特定の文字が入力できなかったり、とある理由でソースコードを " -"ASCII のみに保ちたい場合は、文字列リテラルでエスケープシーケンスが使えます。" -"(使ってるシステムによっては、\\u でエスケープされた文字列ではなく、実物の大文" -"字のラムダのグリフが見えるかもしれません。)::" +"エディターで特定の文字を入力できない場合や、何らかの理由でソースコードを " +"ASCII だけにしたい場合は、文字列リテラルでエスケープシーケンスを使えます。\n" +"(システムによっては、\\u エスケープではなく、実際の大文字のデルタのグリフが表" +"示される場合があります。\n" +") ::" -#: ../../howto/unicode.rst:215 msgid "" ">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # Using the character name\n" "'\\u0394'\n" @@ -436,6 +489,12 @@ msgid "" ">>> \"\\U00000394\" # Using a 32-bit hex value\n" "'\\u0394'" msgstr "" +">>> \"\\N{GREEK CAPITAL LETTER DELTA}\" # 文字名を使う\n" +"'\\u0394'\n" +">>> \"\\u0394\" # 16 ビットの 16 進数を使う\n" +"'\\u0394'\n" +">>> \"\\U00000394\" # 32 ビットの 16 進数を使う\n" +"'\\u0394'" #: ../../howto/unicode.rst:222 msgid "" @@ -464,7 +523,6 @@ msgstr "" "く) 、``'backslashreplace'`` (エスケープシーケンス ``\\xNN`` を挿入する) で" "す。次の例はこれらの違いを示しています::" -#: ../../howto/unicode.rst:234 msgid "" ">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" "Traceback (most recent call last):\n" @@ -478,6 +536,17 @@ msgid "" ">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n" "'abc'" msgstr "" +">>> b'\\x80abc'.decode(\"utf-8\", \"strict\")\n" +"Traceback (most recent call last):\n" +" ...\n" +"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:\n" +" invalid start byte\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"replace\")\n" +"'\\ufffdabc'\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"backslashreplace\")\n" +"'\\\\x80abc'\n" +">>> b'\\x80abc'.decode(\"utf-8\", \"ignore\")\n" +"'abc'" #: ../../howto/unicode.rst:246 msgid "" @@ -506,13 +575,16 @@ msgstr "" "文字列を返します。逆の操作は :func:`ord` 組み込み関数です、この関数は一文字" "の Unicode 文字列を引数にとり、コードポイント値を返します::" -#: ../../howto/unicode.rst:258 msgid "" ">>> chr(57344)\n" "'\\ue000'\n" ">>> ord('\\ue000')\n" "57344" msgstr "" +">>> chr(57344)\n" +"'\\ue000'\n" +">>> ord('\\ue000')\n" +"57344" #: ../../howto/unicode.rst:264 msgid "Converting to Bytes" @@ -528,7 +600,6 @@ msgstr "" "のメソッドは、 Unicode 文字列を指定された *encoding* でエンコードして、 :" "class:`bytes` による表現で返します。" -#: ../../howto/unicode.rst:270 msgid "" "The *errors* parameter is the same as the parameter of the :meth:`~bytes." "decode` method but supports a few more possible handlers. As well as " @@ -543,14 +614,13 @@ msgstr "" "``'strict'`` 、 ``'ignore'`` 、 ``'replace'`` (このメソッドでは、エンコードで" "きなかった文字の代わりに疑問符を挿入する) の他に、 ``'xmlcharrefreplace'`` " "(XML 文字参照を挿入する) と ``backslashreplace`` (エスケープシーケンス " -"``\\nNNNN`` を挿入する)、 ``namereplace`` (エスケープシーケンス ``\\N{...}`` " +"``\\uNNNN`` を挿入する)、 ``namereplace`` (エスケープシーケンス ``\\N{...}`` " "を挿入する) があります。" #: ../../howto/unicode.rst:278 msgid "The following example shows the different results::" msgstr "次の例では、それぞれの異なる処理結果が示されています::" -#: ../../howto/unicode.rst:280 msgid "" ">>> u = chr(40960) + 'abcd' + chr(1972)\n" ">>> u.encode('utf-8')\n" @@ -571,6 +641,24 @@ msgid "" ">>> u.encode('ascii', 'namereplace')\n" "b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'" msgstr "" +">>> u = chr(40960) + 'abcd' + chr(1972)\n" +">>> u.encode('utf-8')\n" +"b'\\xea\\x80\\x80abcd\\xde\\xb4'\n" +">>> u.encode('ascii')\n" +"Traceback (most recent call last):\n" +" ...\n" +"UnicodeEncodeError: 'ascii' codec can't encode character '\\ua000' in\n" +" position 0: ordinal not in range(128)\n" +">>> u.encode('ascii', 'ignore')\n" +"b'abcd'\n" +">>> u.encode('ascii', 'replace')\n" +"b'?abcd?'\n" +">>> u.encode('ascii', 'xmlcharrefreplace')\n" +"b'ꀀabcd޴'\n" +">>> u.encode('ascii', 'backslashreplace')\n" +"b'\\\\ua000abcd\\\\u07b4'\n" +">>> u.encode('ascii', 'namereplace')\n" +"b'\\\\N{YI SYLLABLE IT}abcd\\\\u07b4'" #: ../../howto/unicode.rst:299 msgid "" @@ -603,7 +691,6 @@ msgstr "" "``\\u`` を使い、続けてコードポイントを4桁の16進数を書きます。エスケープシーケ" "ンス ``\\U`` も同様です、ただし4桁ではなく8桁の16進数を使います::" -#: ../../howto/unicode.rst:315 msgid "" ">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n" "... # ^^^^ two-digit hex escape\n" @@ -612,6 +699,12 @@ msgid "" ">>> [ord(c) for c in s]\n" "[97, 172, 4660, 8364, 32768]" msgstr "" +">>> s = \"a\\xac\\u1234\\u20ac\\U00008000\"\n" +"... # ^^^^ 2 桁の 16 進エスケープ\n" +"... # ^^^^^^ 4 桁の Unicode エスケープ\n" +"... # ^^^^^^^^^^ 8 桁の Unicode エスケープ\n" +">>> [ord(c) for c in s]\n" +"[97, 172, 4660, 8364, 32768]" #: ../../howto/unicode.rst:322 msgid "" @@ -650,7 +743,6 @@ msgstr "" "はソースファイルの一行目や二行目に特別なコメントを含めることによってできま" "す::" -#: ../../howto/unicode.rst:337 msgid "" "#!/usr/bin/env python\n" "# -*- coding: latin-1 -*-\n" @@ -658,6 +750,11 @@ msgid "" "u = 'abcdé'\n" "print(ord(u[-1]))" msgstr "" +"#!/usr/bin/env python\n" +"# -*- coding: latin-1 -*-\n" +"\n" +"u = 'abcdé'\n" +"print(ord(u[-1]))" #: ../../howto/unicode.rst:343 msgid "" @@ -686,7 +783,6 @@ msgstr "" msgid "Unicode Properties" msgstr "Unicode プロパティ" -#: ../../howto/unicode.rst:358 msgid "" "The Unicode specification includes a database of information about code " "points. For each defined code point, the information includes the " @@ -695,6 +791,13 @@ msgid "" "fractions such as one-third and four-fifths, etc.). There are also display-" "related properties, such as how to use the code point in bidirectional text." msgstr "" +"Unicode の仕様には、コードポイントに関する情報のデータベースが含まれていま" +"す。\n" +"定義済みのコードポイントごとに、文字名、カテゴリー、該当する場合は数値 (ロー" +"マ数字や、3 分の 1、5 分の 4 などの分数といった、数の概念を表す文字の場合) が" +"記録されています。\n" +"双方向テキストでのコードポイントの使い方など、表示に関するプロパティもありま" +"す。" #: ../../howto/unicode.rst:366 msgid "" @@ -704,7 +807,6 @@ msgstr "" "以下のプログラムはいくつかの文字に対する情報を表示し、特定の文字の数値を印字" "します::" -#: ../../howto/unicode.rst:369 msgid "" "import unicodedata\n" "\n" @@ -717,12 +819,21 @@ msgid "" "# Get numeric value of second character\n" "print(unicodedata.numeric(u[1]))" msgstr "" +"import unicodedata\n" +"\n" +"u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231)\n" +"\n" +"for i, c in enumerate(u):\n" +" print(i, '%04x' % ord(c), unicodedata.category(c), end=\" \")\n" +" print(unicodedata.name(c))\n" +"\n" +"# 2 番目の文字の数値を取得する\n" +"print(unicodedata.numeric(u[1]))" #: ../../howto/unicode.rst:380 msgid "When run, this prints:" msgstr "実行すると、このように出力されます::" -#: ../../howto/unicode.rst:382 msgid "" "0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n" "1 0bf2 No TAMIL NUMBER ONE THOUSAND\n" @@ -731,6 +842,12 @@ msgid "" "4 33af So SQUARE RAD OVER S SQUARED\n" "1000.0" msgstr "" +"0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE\n" +"1 0bf2 No TAMIL NUMBER ONE THOUSAND\n" +"2 0f84 Mn TIBETAN MARK HALANTA\n" +"3 1770 Lo TAGBANWA LETTER SA\n" +"4 33af So SQUARE RAD OVER S SQUARED\n" +"1000.0" #: ../../howto/unicode.rst:391 msgid "" @@ -753,11 +870,9 @@ msgstr "" "Values 節 `_ " "を参照してください。" -#: ../../howto/unicode.rst:402 msgid "Comparing Strings" -msgstr "" +msgstr "文字列の比較" -#: ../../howto/unicode.rst:404 msgid "" "Unicode adds some complication to comparing strings, because the same set of " "characters can be represented by different sequences of code points. For " @@ -766,8 +881,14 @@ msgid "" "point for 'COMBINING CIRCUMFLEX ACCENT'. These will produce the same output " "when printed, but one is a string of length 1 and the other is of length 2." msgstr "" +"Unicode では、同じ文字の並びを異なるコードポイント列で表せるため、文字列の比" +"較が少し複雑になります。\n" +"例えば「ê」は、一つのコードポイント U+00EA でも、U+0065 U+0302 という並びでも" +"表せます。\n" +"後者は「e」のコードポイントの後に「COMBINING CIRCUMFLEX ACCENT」のコードポイ" +"ントを置いたものです。\n" +"表示すると同じ出力になりますが、一方は長さ 1、もう一方は長さ 2 の文字列です。" -#: ../../howto/unicode.rst:412 msgid "" "One tool for a case-insensitive comparison is the :meth:`~str.casefold` " "string method that converts a string to a case-insensitive form following an " @@ -775,13 +896,21 @@ msgid "" "handling for characters such as the German letter 'ß' (code point U+00DF), " "which becomes the pair of lowercase letters 'ss'." msgstr "" +"大文字と小文字を区別しない比較に使える方法の一つが、文字列の :meth:`~str." +"casefold` メソッドです。\n" +"Unicode 標準のアルゴリズムに従い、大文字と小文字を区別しない形式に文字列を変" +"換します。\n" +"このアルゴリズムは、ドイツ語の「ß」(コードポイント U+00DF) などの文字を特別に" +"扱い、この文字は小文字二つの「ss」に変換されます。" -#: ../../howto/unicode.rst:421 msgid "" ">>> street = 'Gürzenichstraße'\n" ">>> street.casefold()\n" "'gürzenichstrasse'" msgstr "" +">>> street = 'Gürzenichstraße'\n" +">>> street.casefold()\n" +"'gürzenichstrasse'" #: ../../howto/unicode.rst:425 msgid "" @@ -793,7 +922,6 @@ msgid "" "combining characters differently:" msgstr "" -#: ../../howto/unicode.rst:434 msgid "" "import unicodedata\n" "\n" @@ -810,31 +938,49 @@ msgid "" "print('length of second string=', len(multiple_chars))\n" "print(compare_strs(single_char, multiple_chars))" msgstr "" +"import unicodedata\n" +"\n" +"def compare_strs(s1, s2):\n" +" def NFD(s):\n" +" return unicodedata.normalize('NFD', s)\n" +"\n" +" return NFD(s1) == NFD(s2)\n" +"\n" +"single_char = 'ê'\n" +"multiple_chars = '\\N{LATIN SMALL LETTER E}\\N{COMBINING CIRCUMFLEX " +"ACCENT}'\n" +"print('length of first string=', len(single_char))\n" +"print('length of second string=', len(multiple_chars))\n" +"print(compare_strs(single_char, multiple_chars))" #: ../../howto/unicode.rst:448 msgid "When run, this outputs:" msgstr "実行すると、このように出力されます:" -#: ../../howto/unicode.rst:450 msgid "" "$ python compare-strs.py\n" "length of first string= 1\n" "length of second string= 2\n" "True" msgstr "" +"$ python compare-strs.py\n" +"length of first string= 1\n" +"length of second string= 2\n" +"True" -#: ../../howto/unicode.rst:457 msgid "" "The first argument to the :func:`~unicodedata.normalize` function is a " "string giving the desired normalization form, which can be one of 'NFC', " "'NFKC', 'NFD', and 'NFKD'." msgstr "" +":func:`~unicodedata.normalize` 関数の最初の引数は、目的の正規化形式を表す文字" +"列です。\n" +"'NFC'、'NFKC'、'NFD'、'NFKD' のいずれかを指定できます。" -#: ../../howto/unicode.rst:461 msgid "The Unicode Standard also specifies how to do caseless comparisons::" msgstr "" +"Unicode 標準には、大文字と小文字を区別しない比較の方法も定められています。 ::" -#: ../../howto/unicode.rst:463 msgid "" "import unicodedata\n" "\n" @@ -851,14 +997,32 @@ msgid "" "\n" "print(compare_caseless(single_char, multiple_chars))" msgstr "" +"import unicodedata\n" +"\n" +"def compare_caseless(s1, s2):\n" +" def NFD(s):\n" +" return unicodedata.normalize('NFD', s)\n" +"\n" +" return NFD(NFD(s1).casefold()) == NFD(NFD(s2).casefold())\n" +"\n" +"# 使用例\n" +"single_char = 'ê'\n" +"multiple_chars = '\\N{LATIN CAPITAL LETTER E}\\N{COMBINING CIRCUMFLEX " +"ACCENT}'\n" +"\n" +"print(compare_caseless(single_char, multiple_chars))" -#: ../../howto/unicode.rst:477 msgid "" "This will print ``True``. (Why is :func:`!NFD` invoked twice? Because " "there are a few characters that make :meth:`~str.casefold` return a non-" "normalized string, so the result needs to be normalized again. See section " "3.13 of the Unicode Standard for a discussion and an example.)" msgstr "" +"この例は ``True`` を表示します。\n" +"(:func:`!NFD` を 2 回呼び出すのはなぜでしょうか。\n" +"一部の文字では :meth:`~str.casefold` が正規化されていない文字列を返すため、結" +"果をもう一度正規化する必要があるからです。\n" +"説明と例は Unicode 標準の 3.13 節を参照してください。)" #: ../../howto/unicode.rst:484 msgid "Unicode Regular Expressions" @@ -879,15 +1043,13 @@ msgstr "" "る意味を持ちます。例えば、 ``\\d`` はバイト列では ``[0-9]`` の範囲の文字と一" "致しますが、文字列では ``'Nd'`` カテゴリーにある任意の文字と一致します。" -#: ../../howto/unicode.rst:493 msgid "" "The string in this example has the number 57 written in both Thai and Arabic " "numerals::" msgstr "" "この例にある文字列には、タイ語の数字とアラビア数字の両方で数字の 57 が書いて" -"あります。" +"あります。 ::" -#: ../../howto/unicode.rst:496 msgid "" "import re\n" "p = re.compile(r'\\d+')\n" @@ -896,6 +1058,12 @@ msgid "" "m = p.search(s)\n" "print(repr(m.group()))" msgstr "" +"import re\n" +"p = re.compile(r'\\d+')\n" +"\n" +"s = \"Over \\u0e55\\u0e57 57 flavours\"\n" +"m = p.search(s)\n" +"print(repr(m.group()))" #: ../../howto/unicode.rst:503 msgid "" @@ -907,15 +1075,14 @@ msgstr "" "const:`re.ASCII` を :func:`~re.compile` に渡した場合、 ``\\d+`` は先程とは" "違って部分文字列 \"57\" に一致します。" -#: ../../howto/unicode.rst:507 msgid "" "Similarly, ``\\w`` matches a wide variety of Unicode characters but only " "``[a-zA-Z0-9_]`` in bytes or if :const:`re.ASCII` is supplied, and ``\\s`` " "will match either Unicode whitespace characters or ``[ \\t\\n\\r\\f\\v]``." msgstr "" -"同様に、 ``\\w`` は非常に多くの Unicode 文字に一致しますが、バイト列の場合も" -"しくは :const:`re.ASCII` が渡された場合は ``[a-zA-Z0-9_]`` にしか一致しませ" -"ん。 ``\\s`` は文字列では Unicode 空白文字に、バイト列では " +"同様に、``\\w`` は幅広い Unicode 文字に一致しますが、バイト列の場合や :const:" +"`re.ASCII` を指定した場合には ``[a-zA-Z0-9_]`` だけに一致します。\n" +"``\\s`` も同じ条件に応じて、Unicode の空白文字、または " "``[ \\t\\n\\r\\f\\v]`` に一致します。" #: ../../howto/unicode.rst:518 @@ -982,7 +1149,6 @@ msgstr "" "力です。プログラムは Unicode 文字列をどう受けとり、どう Unicode を外部記憶装" "置や送受信装置に適した形式に変換するのでしょう?" -#: ../../howto/unicode.rst:544 msgid "" "It's possible that you may not need to do anything depending on your input " "sources and output destinations; you should check whether the libraries used " @@ -990,13 +1156,13 @@ msgid "" "Unicode data, for example. Many relational databases also support Unicode-" "valued columns and can return Unicode values from an SQL query." msgstr "" -"入力ソースと出力先に依存しないような方法は可能です; アプリケーションに利用さ" -"れているライブラリが Unicode をそのままサポートしているかを調べなければいけま" -"せん。例えば XML パーサーは大抵 Unicode データを返します。多くのリレーショナ" -"ルデータベースも Unicode 値の入ったコラムをサポートしていますし、 SQL の問い" -"合わせで Unicode 値を返すことができます。" +"入力元と出力先によっては、何もする必要がないかもしれません。\n" +"アプリケーションで使っているライブラリが Unicode をそのまま扱えるか確認してく" +"ださい。\n" +"例えば、XML パーサーは多くの場合 Unicode データを返します。\n" +"多くのリレーショナルデータベースも Unicode 値の列をサポートし、SQL の問い合わ" +"せに Unicode 値を返せます。" -#: ../../howto/unicode.rst:550 msgid "" "Unicode data is usually converted to a particular encoding before it gets " "written to disk or sent over a socket. It's possible to do all the work " @@ -1004,10 +1170,12 @@ msgid "" "bytes with ``bytes.decode(encoding)``. However, the manual approach is not " "recommended." msgstr "" -"Unicode のデータはディスクに書き込まれたり、ソケットを介して送信されたりする" -"にあたって、通常、特定のエンコーディングに変換されます。推奨はされませんが、" -"これを手動で行うことも可能です。ファイルを開き、8バイトオブジェクトを読み込" -"み、バイト列を ``bytes.decode(encoding)`` で変換することにより実現できます。" +"Unicode データは通常、ディスクに書いたりソケット経由で送ったりする前に、特定" +"のエンコーディングに変換されます。\n" +"すべてを自分で処理することもできます。\n" +"ファイルを開き、8 ビットのバイトからなるオブジェクトを読み取り、``bytes." +"decode(encoding)`` でバイト列を変換します。\n" +"ただし、このように手動で処理する方法は推奨しません。" #: ../../howto/unicode.rst:555 msgid "" @@ -1049,12 +1217,14 @@ msgstr "" msgid "Reading Unicode from a file is therefore simple::" msgstr "そのためファイルから Unicode を読むのは単純です::" -#: ../../howto/unicode.rst:576 msgid "" "with open('unicode.txt', encoding='utf-8') as f:\n" " for line in f:\n" " print(repr(line))" msgstr "" +"with open('unicode.txt', encoding='utf-8') as f:\n" +" for line in f:\n" +" print(repr(line))" #: ../../howto/unicode.rst:580 msgid "" @@ -1062,13 +1232,16 @@ msgid "" "writing::" msgstr "読み書きの両方ができる update モードでファイルを開くことも可能です::" -#: ../../howto/unicode.rst:583 msgid "" "with open('test', encoding='utf-8', mode='w+') as f:\n" " f.write('\\u4500 blah blah blah\\n')\n" " f.seek(0)\n" " print(repr(f.readline()[:1]))" msgstr "" +"with open('test', encoding='utf-8', mode='w+') as f:\n" +" f.write('\\u4500 blah blah blah\\n')\n" +" f.seek(0)\n" +" print(repr(f.readline()[:1]))" #: ../../howto/unicode.rst:588 msgid "" @@ -1091,7 +1264,6 @@ msgstr "" "ディアン (big-endian) 用の 'utf-16-be' というような変種があり、これらは特定の" "1つのバイト順を指定していて BOM をスキップしません。" -#: ../../howto/unicode.rst:597 msgid "" "In some areas, it is also convention to use a \"BOM\" at the start of UTF-8 " "encoded files; the name is misleading since UTF-8 is not byte-order " @@ -1099,6 +1271,12 @@ msgid "" "reading such files, use the 'utf-8-sig' codec to automatically skip the mark " "if present." msgstr "" +"UTF-8 でエンコードされたファイルの先頭にも「BOM」を付ける慣習がある分野があり" +"ます。\n" +"UTF-8 はバイト順に依存しないため、この名前は紛らわしいものです。\n" +"このマークは、ファイルが UTF-8 でエンコードされていることを示すだけです。\n" +"このようなファイルを読むときは、'utf-8-sig' コーデックを使えば、マークがあっ" +"た場合に自動的に読み飛ばせます。" #: ../../howto/unicode.rst:604 msgid "Unicode filenames" @@ -1131,12 +1309,14 @@ msgstr "" "イル名を Unicode 文字列として渡すだけで正しいエンコーディングに自動的に変更さ" "れます::" -#: ../../howto/unicode.rst:622 msgid "" "filename = 'filename\\u4500abc'\n" "with open(filename, 'w') as f:\n" " f.write('blah\\n')" msgstr "" +"filename = 'filename\\u4500abc'\n" +"with open(filename, 'w') as f:\n" +" f.write('blah\\n')" #: ../../howto/unicode.rst:626 msgid "" @@ -1146,7 +1326,6 @@ msgstr "" ":func:`os.stat` のような :mod:`os` モジュールの関数も Unicode のファイル名を" "受け付けます。" -#: ../../howto/unicode.rst:629 msgid "" "The :func:`os.listdir` function returns filenames, which raises an issue: " "should it return the Unicode version of filenames, or should it return bytes " @@ -1158,8 +1337,17 @@ msgid "" "assuming the default :term:`filesystem encoding ` is UTF-8, running the following program::" msgstr "" +":func:`os.listdir` 関数はファイル名を返しますが、ここで問題になるのは、ファイ" +"ル名を Unicode で返すべきか、エンコードしたバイト列で返すべきかということで" +"す。\n" +":func:`os.listdir` は、ディレクトリのパスをバイト列と Unicode 文字列のどちら" +"で渡すかに応じて、両方に対応します。\n" +"パスを Unicode 文字列で渡すと、ファイル名をファイルシステムのエンコーディング" +"でデコードし、Unicode 文字列のリストを返します。\n" +"バイト列でパスを渡すと、ファイル名もバイト列で返します。\n" +"例えば、デフォルトの :term:`ファイルシステムエンコーディング ` が UTF-8 の場合、次のプログラムを実行すると、 ::" -#: ../../howto/unicode.rst:639 msgid "" "fn = 'filename\\u4500abc'\n" "f = open(fn, 'w')\n" @@ -1169,17 +1357,26 @@ msgid "" "print(os.listdir(b'.'))\n" "print(os.listdir('.'))" msgstr "" +"fn = 'filename\\u4500abc'\n" +"f = open(fn, 'w')\n" +"f.close()\n" +"\n" +"import os\n" +"print(os.listdir(b'.'))\n" +"print(os.listdir('.'))" #: ../../howto/unicode.rst:647 msgid "will produce the following output:" msgstr "以下の出力結果が生成されます:" -#: ../../howto/unicode.rst:649 msgid "" "$ python listdir-test.py\n" "[b'filename\\xe4\\x94\\x80abc', ...]\n" "['filename\\u4500abc', ...]" msgstr "" +"$ python listdir-test.py\n" +"[b'filename\\xe4\\x94\\x80abc', ...]\n" +"['filename\\u4500abc', ...]" #: ../../howto/unicode.rst:655 msgid "" @@ -1189,13 +1386,16 @@ msgstr "" "最初のリストは UTF-8 でエンコーディングされたファイル名を含み、第二のリスト" "は Unicode 版を含んでいます。" -#: ../../howto/unicode.rst:658 msgid "" "Note that on most occasions, you should can just stick with using Unicode " "with these APIs. The bytes APIs should only be used on systems where " "undecodable file names can be present; that's pretty much only Unix systems " "now." msgstr "" +"ほとんどの場合、これらの API では Unicode を使えば十分です。\n" +"バイト列の API は、デコードできないファイル名が存在し得るシステムでのみ使うべ" +"きです。\n" +"現在では、ほぼ Unix システムに限られます。" #: ../../howto/unicode.rst:665 msgid "Tips for Writing Unicode-aware Programs" @@ -1220,7 +1420,6 @@ msgstr "" "ソフトウェアは内部では Unicode 文字列のみを利用し、入力データはできるだけ早期" "にデコードし、出力の直前でエンコードすべきです。" -#: ../../howto/unicode.rst:675 msgid "" "If you attempt to write processing functions that accept both Unicode and " "byte strings, you will find your program vulnerable to bugs wherever you " @@ -1228,6 +1427,10 @@ msgid "" "or decoding: if you do e.g. ``str + bytes``, a :exc:`TypeError` will be " "raised." msgstr "" +"Unicode 文字列とバイト列の両方を受け付ける処理関数を書こうとすると、この二種" +"類を組み合わせるあらゆる箇所でバグが生じやすくなります。\n" +"自動的なエンコードやデコードは行われません。\n" +"例えば ``str + bytes`` を行うと :exc:`TypeError` が送出されます。" #: ../../howto/unicode.rst:680 msgid "" @@ -1254,20 +1457,23 @@ msgstr "" msgid "Converting Between File Encodings" msgstr "ファイルエンコーディングの変換" -#: ../../howto/unicode.rst:693 msgid "" "The :class:`~codecs.StreamRecoder` class can transparently convert between " "encodings, taking a stream that returns data in encoding #1 and behaving " "like a stream returning data in encoding #2." msgstr "" +":class:`~codecs.StreamRecoder` クラスは、エンコーディング間の変換を透過的に行" +"えます。\n" +"エンコーディング #1 でデータを返すストリームを受け取り、エンコーディング #2 " +"でデータを返すストリームとして動作します。" -#: ../../howto/unicode.rst:697 msgid "" "For example, if you have an input file *f* that's in Latin-1, you can wrap " "it with a :class:`~codecs.StreamRecoder` to return bytes encoded in UTF-8::" msgstr "" +"例えば、Latin-1 の入力ファイル ``f`` を :class:`~codecs.StreamRecoder` でラッ" +"プすると、UTF-8 でエンコードされたバイト列を返すようにできます。 ::" -#: ../../howto/unicode.rst:701 msgid "" "new_f = codecs.StreamRecoder(f,\n" " # en/decoder: used by read() to encode its results and\n" @@ -1277,20 +1483,30 @@ msgid "" " # reader/writer: used to read and write to the stream.\n" " codecs.getreader('latin-1'), codecs.getwriter('latin-1') )" msgstr "" +"new_f = codecs.StreamRecoder(f,\n" +" # エンコーダー/デコーダー: read() の結果のエンコードと\n" +" # write() の入力のデコードに使う。\n" +" codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),\n" +"\n" +" # リーダー/ライター: ストリームの読み書きに使う。\n" +" codecs.getreader('latin-1'), codecs.getwriter('latin-1') )" #: ../../howto/unicode.rst:711 msgid "Files in an Unknown Encoding" msgstr "不明なエンコーディングのファイル" -#: ../../howto/unicode.rst:713 msgid "" "What can you do if you need to make a change to a file, but don't know the " "file's encoding? If you know the encoding is ASCII-compatible and only want " "to examine or modify the ASCII parts, you can open the file with the " "``surrogateescape`` error handler::" msgstr "" +"ファイルを変更したいのに、そのエンコーディングが分からない場合はどうすればよ" +"いでしょうか。\n" +"ASCII 互換のエンコーディングだと分かっていて、ASCII の部分だけを調べたり変更" +"したりしたい場合は、``surrogateescape`` エラーハンドラーを指定してファイルを" +"開けます。 ::" -#: ../../howto/unicode.rst:718 msgid "" "with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " data = f.read()\n" @@ -1301,23 +1517,35 @@ msgid "" " encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" " f.write(data)" msgstr "" +"with open(fname, 'r', encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" +" data = f.read()\n" +"\n" +"# 文字列 'data' を変更する\n" +"\n" +"with open(fname + '.new', 'w',\n" +" encoding=\"ascii\", errors=\"surrogateescape\") as f:\n" +" f.write(data)" -#: ../../howto/unicode.rst:727 msgid "" "The ``surrogateescape`` error handler will decode any non-ASCII bytes as " "code points in a special range running from U+DC80 to U+DCFF. These code " "points will then turn back into the same bytes when the ``surrogateescape`` " "error handler is used to encode the data and write it back out." msgstr "" +"``surrogateescape`` エラーハンドラーは、ASCII 以外のバイトを U+DC80 から " +"U+DCFF までの特別な範囲のコードポイントにデコードします。\n" +"``surrogateescape`` エラーハンドラーを使ってデータをエンコードし、書き戻す" +"と、これらのコードポイントは元と同じバイトに戻ります。" -#: ../../howto/unicode.rst:737 msgid "" "One section of `Mastering Python 3 Input/Output `_, a PyCon 2010 talk by David " "Beazley, discusses text processing and binary data handling." msgstr "" +"David Beazley による PyCon 2010 の講演 `Mastering Python 3 Input/Output " +"`_ では、テ" +"キスト処理とバイナリデータの扱いを説明する節があります。" -#: ../../howto/unicode.rst:741 msgid "" "The `PDF slides for Marc-André Lemburg's presentation \"Writing Unicode-" "aware Applications in Python\" から入手可能です、そして" -"文字エンコーディングの問題と同様にアプリケーションの国際化やローカライズにつ" -"いても議論されています。このスライドは Python 2.x のみをカバーしています。" +"`Marc-André Lemburg の講演 \"Writing Unicode-aware Applications in Python\" " +"の PDF スライド `_ は、文字エンコーディングの問題に" +"加え、アプリケーションの国際化とローカライズの方法を説明しています。\n" +"このスライドは Python 2.x だけを対象にしています。" -#: ../../howto/unicode.rst:747 msgid "" "`The Guts of Unicode in Python `_ is a PyCon 2013 talk by Benjamin Peterson that " "discusses the internal Unicode representation in Python 3.3." msgstr "" +"`The Guts of Unicode in Python `_ は、Python 3.3 の Unicode の内部表現を解説する、" +"Benjamin Peterson による PyCon 2013 の講演です。" #: ../../howto/unicode.rst:754 msgid "Acknowledgements" diff --git a/howto/urllib2.po b/howto/urllib2.po index 0e46426f1..d0f36991d 100644 --- a/howto/urllib2.po +++ b/howto/urllib2.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../howto/urllib2.rst:5 @@ -38,17 +38,17 @@ msgstr "" "同じように Python でインターネットリソースを取得するのに以下の記事が役に立ち" "ます:" -#: ../../howto/urllib2.rst:15 msgid "" "`Basic Authentication `__" msgstr "" +"`Basic 認証 `__" #: ../../howto/urllib2.rst:17 msgid "A tutorial on *Basic Authentication*, with examples in Python." msgstr "*Basic 認証* についてのチュートリアルで Python の例がついています。" -#: ../../howto/urllib2.rst:19 msgid "" "**urllib.request** is a Python module for fetching URLs (Uniform Resource " "Locators). It offers a very simple interface, in the form of the *urlopen* " @@ -57,14 +57,14 @@ msgid "" "common situations - like basic authentication, cookies, proxies and so on. " "These are provided by objects called handlers and openers." msgstr "" -"**urllib.request** は URLs (Uniform Resource Locators) を取得するための " -"Python モジュールです。このモジュールはとても簡単なインターフェースを " -"*urlopen* 関数の形式で提供しています。また、このモジュールは一般的な状況で利" -"用するためにいくらか複雑なインターフェースも提供しています - basic 認証やクッ" -"キー、プロキシ等。これらは handler や opener と呼ばれるオブジェクトとして提供" -"されます。" +"**urllib.request** は、URL (Uniform Resource Locator) からリソースを取得する " +"Python モジュールです。\n" +"*urlopen* 関数という、とても単純なインターフェースを提供します。\n" +"この関数は、さまざまなプロトコルを使って URL からリソースを取得できます。\n" +"また、Basic 認証、クッキー、プロキシなど、よくある状況を扱うための、少し複雑" +"なインターフェースも提供します。\n" +"これらは handler や opener と呼ばれるオブジェクトによって提供されます。" -#: ../../howto/urllib2.rst:26 msgid "" "urllib.request supports fetching URLs for many \"URL schemes\" (identified " "by the string before the ``\":\"`` in URL - for example ``\"ftp\"`` is the " @@ -72,9 +72,11 @@ msgid "" "protocols (e.g. FTP, HTTP). This tutorial focuses on the most common case, " "HTTP." msgstr "" -"urllib.request は多くの \"URL スキーム\" (URL の \":\" の前の文字列で識別され" -"るもの - 例えば \"ftp://python.org/\" では \"ftp\") の URL を、関連するネット" -"ワークプロトコル(例えば FTP, HTTP) を利用することで、取得できます。" +"urllib.request は、多くの「URL スキーム」に対応するネットワークプロトコル " +"(FTP、HTTP など) を使って、URL からリソースを取得できます。\n" +"URL スキームは URL の ``\":\"`` より前の文字列で識別されます。\n" +"例えば、``\"ftp://python.org/\"`` の URL スキームは ``\"ftp\"`` です。\n" +"このチュートリアルでは、最も一般的な HTTP に焦点を当てます。" #: ../../howto/urllib2.rst:31 msgid "" @@ -104,12 +106,14 @@ msgstr "URL を取得する" msgid "The simplest way to use urllib.request is as follows::" msgstr "urllib.request を利用する最も簡単な方法は以下です::" -#: ../../howto/urllib2.rst:45 msgid "" "import urllib.request\n" "with urllib.request.urlopen('http://python.org/') as response:\n" " html = response.read()" msgstr "" +"import urllib.request\n" +"with urllib.request.urlopen('http://python.org/') as response:\n" +" html = response.read()" #: ../../howto/urllib2.rst:49 msgid "" @@ -121,7 +125,6 @@ msgstr "" "func:`shutil.copyfileobj` と :func:`tempfile.NamedTemporaryFile` 関数を使って" "行うことができます::" -#: ../../howto/urllib2.rst:53 msgid "" "import shutil\n" "import tempfile\n" @@ -134,6 +137,16 @@ msgid "" "with open(tmp_file.name) as html:\n" " pass" msgstr "" +"import shutil\n" +"import tempfile\n" +"import urllib.request\n" +"\n" +"with urllib.request.urlopen('http://python.org/') as response:\n" +" with tempfile.NamedTemporaryFile(delete=False) as tmp_file:\n" +" shutil.copyfileobj(response, tmp_file)\n" +"\n" +"with open(tmp_file.name) as html:\n" +" pass" #: ../../howto/urllib2.rst:64 msgid "" @@ -165,7 +178,6 @@ msgstr "" "オブジェクトで、これはつまりレスポンスに ``.read()`` と呼び出せることを意味し" "ています::" -#: ../../howto/urllib2.rst:77 msgid "" "import urllib.request\n" "\n" @@ -173,6 +185,11 @@ msgid "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" msgstr "" +"import urllib.request\n" +"\n" +"req = urllib.request.Request('http://python.org/')\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" #: ../../howto/urllib2.rst:83 msgid "" @@ -182,9 +199,8 @@ msgstr "" "urllib.request は同じリクエストインターフェースを全ての URL スキームに対して" "利用できるようにしています。例えば、FTP リクエストの場合はこうできます::" -#: ../../howto/urllib2.rst:86 msgid "req = urllib.request.Request('ftp://example.com/')" -msgstr "" +msgstr "req = urllib.request.Request('ftp://example.com/')" #: ../../howto/urllib2.rst:88 msgid "" @@ -226,7 +242,6 @@ msgstr "" "ストオブジェクトに ``data`` 引数として渡します。エンコーディングは :mod:" "`urllib.parse` ライブラリの関数を使って行います。 ::" -#: ../../howto/urllib2.rst:107 msgid "" "import urllib.parse\n" "import urllib.request\n" @@ -242,6 +257,19 @@ msgid "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" msgstr "" +"import urllib.parse\n" +"import urllib.request\n" +"\n" +"url = 'http://www.someserver.com/cgi-bin/register.cgi'\n" +"values = {'name' : 'Michael Foord',\n" +" 'location' : 'Northampton',\n" +" 'language' : 'Python' }\n" +"\n" +"data = urllib.parse.urlencode(values)\n" +"data = data.encode('ascii') # data は bytes にする\n" +"req = urllib.request.Request(url, data)\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" #: ../../howto/urllib2.rst:121 msgid "" @@ -254,7 +282,6 @@ msgstr "" "Specification, Form Submission `_ を見て下さい)。" -#: ../../howto/urllib2.rst:126 msgid "" "If you do not pass the ``data`` argument, urllib uses a **GET** request. One " "way in which GET and POST requests differ is that POST requests often have " @@ -266,21 +293,22 @@ msgid "" "side-effects, nor a POST requests from having no side-effects. Data can also " "be passed in an HTTP GET request by encoding it in the URL itself." msgstr "" -"``data`` 引数を渡さない場合、urllib は **GET** リクエストを利用します。GET " -"と POST リクエストの一つの違いは、POST リクエストにしばしば、「副作用」がある" -"ことです: POST リクエストはいくつかの方法によってシステムの状態を変化させま" -"す (例えば100ポンドのスパムの缶詰をドアの前まで配達する注文を web サイトで行" -"う)。とはいえ HTTP 標準で明確にされている内容では、POST は *常に* 副作用を持" -"ち、GET リクエストは *決して* 副作用を持たないことを意図するけれども、、GET " -"リクエストが副作用を持つことも、POST リクエストが副作用を持たないことも、妨げ" -"られません。HTTP の GET リクエストでもデータ自身をエンコーディングすることで" -"データを渡すことができます。" +"``data`` 引数を渡さない場合、urllib は **GET** リクエストを利用します。\n" +"GET と POST リクエストの一つの違いは、POST リクエストにしばしば、「副作用」が" +"あることです: POST リクエストはいくつかの方法によってシステムの状態を変化させ" +"ます (例えば100ポンドのスパムの缶詰をドアの前まで配達する注文を web サイトで" +"行う)。\n" +"とはいえ HTTP 標準で明確にされている内容では、POST は *常に* 副作用を持ち、" +"GET リクエストは *決して* 副作用を持たないことを意図するけれども、GET リクエ" +"ストが副作用を持つことも、POST リクエストが副作用を持たないことも、妨げられま" +"せん。\n" +"HTTP の GET リクエストでも、URL 自体にデータをエンコードすることでデータを渡" +"せます。" #: ../../howto/urllib2.rst:136 msgid "This is done as follows::" msgstr "以下のようにして行います::" -#: ../../howto/urllib2.rst:138 msgid "" ">>> import urllib.request\n" ">>> import urllib.parse\n" @@ -295,6 +323,18 @@ msgid "" ">>> full_url = url + '?' + url_values\n" ">>> data = urllib.request.urlopen(full_url)" msgstr "" +">>> import urllib.request\n" +">>> import urllib.parse\n" +">>> data = {}\n" +">>> data['name'] = 'Somebody Here'\n" +">>> data['location'] = 'Northampton'\n" +">>> data['language'] = 'Python'\n" +">>> url_values = urllib.parse.urlencode(data)\n" +">>> print(url_values) # 順序は下の出力と異なる場合がある。\n" +"name=Somebody+Here&language=Python&location=Northampton\n" +">>> url = 'http://www.example.com/example.cgi'\n" +">>> full_url = url + '?' + url_values\n" +">>> data = urllib.request.urlopen(full_url)" #: ../../howto/urllib2.rst:151 msgid "" @@ -338,7 +378,6 @@ msgstr "" "できます。以下の例は上の例と同じですが、自身を Internet Explorer [#]_ のバー" "ジョンの一つとして扱っています。 ::" -#: ../../howto/urllib2.rst:171 msgid "" "import urllib.parse\n" "import urllib.request\n" @@ -356,32 +395,50 @@ msgid "" "with urllib.request.urlopen(req) as response:\n" " the_page = response.read()" msgstr "" +"import urllib.parse\n" +"import urllib.request\n" +"\n" +"url = 'http://www.someserver.com/cgi-bin/register.cgi'\n" +"user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'\n" +"values = {'name': 'Michael Foord',\n" +" 'location': 'Northampton',\n" +" 'language': 'Python' }\n" +"headers = {'User-Agent': user_agent}\n" +"\n" +"data = urllib.parse.urlencode(values)\n" +"data = data.encode('ascii')\n" +"req = urllib.request.Request(url, data, headers)\n" +"with urllib.request.urlopen(req) as response:\n" +" the_page = response.read()" -#: ../../howto/urllib2.rst:187 msgid "" "The response also has two useful methods. See the section on `info and " "geturl`_ which comes after we have a look at what happens when things go " "wrong." msgstr "" -"レスポンスは二つの便利なメソッドも持っています。 `info と geturl`_ の節を見て" -"下さい、この節は後で問題が起きた場合に見ておくべき内容です。" +"レスポンスには便利なメソッドが二つあります。\n" +"問題が起きたときの動作を説明した後の、`info と geturl `_ の" +"節を参照してください。" #: ../../howto/urllib2.rst:192 msgid "Handling Exceptions" msgstr "例外を処理する" -#: ../../howto/urllib2.rst:194 msgid "" "*urlopen* raises :exc:`~urllib.error.URLError` when it cannot handle a " "response (though as usual with Python APIs, built-in exceptions such as :exc:" "`ValueError`, :exc:`TypeError` etc. may also be raised)." msgstr "" +"*urlopen* はレスポンスを処理できない場合に :exc:`~urllib.error.URLError` を送" +"出します (ただし、他の Python API と同様に、:exc:`ValueError` や :exc:" +"`TypeError` などの組み込み例外が送出される場合もあります)。" -#: ../../howto/urllib2.rst:198 msgid "" ":exc:`~urllib.error.HTTPError` is the subclass of :exc:`~urllib.error." "URLError` raised in the specific case of HTTP URLs." msgstr "" +":exc:`~urllib.error.HTTPError` は :exc:`~urllib.error.URLError` のサブクラス" +"で、HTTP URL に固有の場合に送出されます。" #: ../../howto/urllib2.rst:201 msgid "The exception classes are exported from the :mod:`urllib.error` module." @@ -420,7 +477,6 @@ msgstr "" msgid "HTTPError" msgstr "HTTPError" -#: ../../howto/urllib2.rst:224 msgid "" "Every HTTP response from the server contains a numeric \"status code\". " "Sometimes the status code indicates that the server is unable to fulfil the " @@ -431,17 +487,29 @@ msgid "" "HTTPError`. Typical errors include '404' (page not found), '403' (request " "forbidden), and '401' (authentication required)." msgstr "" +"サーバーからのすべての HTTP レスポンスには、数値の「ステータスコード」が含ま" +"れます。\n" +"ステータスコードは、サーバーがリクエストを処理できないことを示す場合がありま" +"す。\n" +"デフォルトのハンドラーは、そうしたレスポンスの一部を処理します。\n" +"例えば、別の URL から文書を取得するようクライアントに要求する「リダイレクト」" +"の場合、urllib が処理します。\n" +"処理できないレスポンスに対しては、urlopen が :exc:`~urllib.error.HTTPError` " +"を送出します。\n" +"よくあるエラーには、'404' (ページが見つからない)、'403' (リクエストが禁止され" +"ている)、'401' (認証が必要) があります。" #: ../../howto/urllib2.rst:232 msgid "" "See section 10 of :rfc:`2616` for a reference on all the HTTP error codes." msgstr "HTTP のエラーコード全てについては :rfc:`2616` の10節を参照して下さい。" -#: ../../howto/urllib2.rst:234 msgid "" "The :exc:`~urllib.error.HTTPError` instance raised will have an integer " "'code' attribute, which corresponds to the error sent by the server." msgstr "" +"送出された :exc:`~urllib.error.HTTPError` インスタンスには、サーバーが送った" +"エラーに対応する整数の 'code' 属性があります。" #: ../../howto/urllib2.rst:238 msgid "Error Codes" @@ -457,14 +525,15 @@ msgstr "" "100--299番台のコードは成功を意味しているので、たいていの場合は400--599番台の" "エラーコードのみを見るだけですみます。" -#: ../../howto/urllib2.rst:244 msgid "" ":attr:`http.server.BaseHTTPRequestHandler.responses` is a useful dictionary " "of response codes that shows all the response codes used by :rfc:`2616`. An " "excerpt from the dictionary is shown below ::" msgstr "" +":attr:`http.server.BaseHTTPRequestHandler.responses` は、:rfc:`2616` で使われ" +"るすべてのレスポンスコードを確認できる便利な辞書です。\n" +"辞書からの抜粋を示します。 ::" -#: ../../howto/urllib2.rst:248 msgid "" "responses = {\n" " ...\n" @@ -489,6 +558,28 @@ msgid "" " ...\n" " }" msgstr "" +"responses = {\n" +" ...\n" +" : ('OK', 'Request fulfilled, document follows'),\n" +" ...\n" +" : ('Forbidden',\n" +" 'Request forbidden -- authorization will " +"'\n" +" 'not help'),\n" +" : ('Not Found',\n" +" 'Nothing matches the given URI'),\n" +" ...\n" +" : (\"I'm a Teapot\",\n" +" 'Server refuses to brew coffee because " +"'\n" +" 'it is a teapot'),\n" +" ...\n" +" : ('Service Unavailable',\n" +" 'The server cannot process the " +"'\n" +" 'request due to a high load'),\n" +" ...\n" +" }" #: ../../howto/urllib2.rst:268 msgid "" @@ -503,7 +594,6 @@ msgstr "" "スポンスとして扱えます。これは code 属性だけでなく、 ``urllib.response`` モ" "ジュールが返すような read, geturl, info メソッドも持つことを意味します::" -#: ../../howto/urllib2.rst:273 msgid "" ">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" ">>> try:\n" @@ -520,23 +610,37 @@ msgid "" " Page Not Found\\n\n" " ..." msgstr "" +">>> req = urllib.request.Request('http://www.python.org/fish.html')\n" +">>> try:\n" +"... urllib.request.urlopen(req)\n" +"... except urllib.error.HTTPError as e:\n" +"... print(e.code)\n" +"... print(e.read())\n" +"...\n" +"404\n" +"b'\\n\\n\\nPage Not Found\\n\n" +" ..." -#: ../../howto/urllib2.rst:288 msgid "Wrapping it Up" -msgstr "エラーをラップする" +msgstr "まとめ" -#: ../../howto/urllib2.rst:290 msgid "" "So if you want to be prepared for :exc:`~urllib.error.HTTPError` *or* :exc:" "`~urllib.error.URLError` there are two basic approaches. I prefer the second " "approach." msgstr "" +":exc:`~urllib.error.HTTPError` *または* :exc:`~urllib.error.URLError` に対応" +"するには、基本的に二つの方法があります。\n" +"筆者は二番目の方法を好んでいます。" #: ../../howto/urllib2.rst:294 msgid "Number 1" msgstr "その1" -#: ../../howto/urllib2.rst:299 msgid "" "from urllib.request import Request, urlopen\n" "from urllib.error import URLError, HTTPError\n" @@ -552,12 +656,27 @@ msgid "" "else:\n" " # everything is fine" msgstr "" +"from urllib.request import Request, urlopen\n" +"from urllib.error import URLError, HTTPError\n" +"req = Request(someurl)\n" +"try:\n" +" response = urlopen(req)\n" +"except HTTPError as e:\n" +" print('The server couldn\\'t fulfill the request.')\n" +" print('Error code: ', e.code)\n" +"except URLError as e:\n" +" print('We failed to reach a server.')\n" +" print('Reason: ', e.reason)\n" +"else:\n" +" # すべて正常" -#: ../../howto/urllib2.rst:316 msgid "" "The ``except HTTPError`` *must* come first, otherwise ``except URLError`` " "will *also* catch an :exc:`~urllib.error.HTTPError`." msgstr "" +"``except HTTPError`` を *必ず* 先に書いてください。\n" +"そうしないと、``except URLError`` が :exc:`~urllib.error.HTTPError` *も* 捕捉" +"してしまいます。" #: ../../howto/urllib2.rst:320 msgid "Number 2" @@ -585,12 +704,14 @@ msgstr "" msgid "info and geturl" msgstr "info と geturl" -#: ../../howto/urllib2.rst:343 msgid "" "The response returned by urlopen (or the :exc:`~urllib.error.HTTPError` " "instance) has two useful methods :meth:`!info` and :meth:`!geturl` and is " "defined in the module :mod:`urllib.response`." msgstr "" +"urlopen が返すレスポンス (または :exc:`~urllib.error.HTTPError` インスタン" +"ス) には、便利なメソッド :meth:`!info` と :meth:`!geturl` があります。\n" +"これらは :mod:`urllib.response` モジュールで定義されています。" #: ../../howto/urllib2.rst:347 msgid "" @@ -656,26 +777,23 @@ msgstr "" "たいと思うでしょう、例えばクッキーを処理する opener が得たい場合や、リダイレ" "クションを処理しない opener を得たい場合。" -#: ../../howto/urllib2.rst:376 msgid "" "To create an opener, instantiate an ``OpenerDirector``, and then call ``." "add_handler(some_handler_instance)`` repeatedly." msgstr "" -"opener を作成するには、 ``OpenerDirector`` をインスタンス化して、続けて、 ``." -"add_handler(some_handler_instance)`` を呼び出します。" +"opener を作るには、``OpenerDirector`` のインスタンスを作成し、``." +"add_handler(some_handler_instance)`` を繰り返し呼び出します。" -#: ../../howto/urllib2.rst:379 msgid "" "Alternatively, you can use ``build_opener``, which is a convenience function " "for creating opener objects with a single function call. ``build_opener`` " "adds several handlers by default, but provides a quick way to add more and/" "or override the default handlers." msgstr "" -"それに代わる方法として、 ``build_opener`` を利用することもできます、これは " -"opener オブジェクトを一回の関数呼び出しで作成できる便利な関数です。 " -"``build_opener`` はいくつかのハンドラをデフォルトで追加しますが、デフォルトの" -"ハンドラに対して追加、継承のどちらかまたは両方を行うのに手っ取り早い方法を提" -"供してくれます。" +"代わりに、一度の関数呼び出しで opener オブジェクトを作れる便利な関数 " +"``build_opener`` も使えます。\n" +"``build_opener`` はデフォルトでいくつかのハンドラーを追加しますが、さらにハン" +"ドラーを追加したり、デフォルトのハンドラーを置き換えたりするのも簡単です。" #: ../../howto/urllib2.rst:384 msgid "" @@ -685,15 +803,14 @@ msgstr "" "追加したくなる可能性がある handler としては、プロキシ処理、認証など、一般的で" "すがいくらか特定の状況に限られるものでしょう。" -#: ../../howto/urllib2.rst:387 msgid "" "``install_opener`` can be used to make an ``opener`` object the (global) " "default opener. This means that calls to ``urlopen`` will use the opener you " "have installed." msgstr "" -"``install_opener`` も (グローバルな) デフォルト ``opener`` オブジェクトの作成" -"に利用できます。つまり、 ``urlopen`` を呼び出すと、インストールした opener が" -"利用されます。" +"``install_opener`` を使うと、``opener`` オブジェクトを (グローバルな) デフォ" +"ルトの opener に設定できます。\n" +"以降、``urlopen`` の呼び出しは、登録した opener を使います。" #: ../../howto/urllib2.rst:391 msgid "" @@ -709,7 +826,6 @@ msgstr "" msgid "Basic Authentication" msgstr "Basic 認証" -#: ../../howto/urllib2.rst:399 msgid "" "To illustrate creating and installing a handler we will use the " "``HTTPBasicAuthHandler``. For a more detailed discussion of this subject -- " @@ -717,6 +833,10 @@ msgid "" "Authentication Tutorial `__." msgstr "" +"ハンドラーの作成と登録の例として、``HTTPBasicAuthHandler`` を使います。\n" +"Basic 認証の仕組みを含む詳しい説明は、`Basic 認証のチュートリアル `__ を参照してください。" #: ../../howto/urllib2.rst:405 msgid "" @@ -733,23 +853,21 @@ msgstr "" msgid "e.g." msgstr "例" -#: ../../howto/urllib2.rst:412 msgid "WWW-Authenticate: Basic realm=\"cPanel Users\"" -msgstr "" +msgstr "WWW-Authenticate: Basic realm=\"cPanel Users\"" -#: ../../howto/urllib2.rst:417 msgid "" "The client should then retry the request with the appropriate name and " "password for the realm included as a header in the request. This is 'basic " "authentication'. In order to simplify this process we can create an instance " "of ``HTTPBasicAuthHandler`` and an opener to use this handler." msgstr "" -"クライアントはリクエストヘッダに含まれる realm に対して適切な名前とパスワード" -"とともにリクエストを再試行する必要があります。これが 'basic 認証' です。一連" -"の流れを簡単化するために、 ``HTTPBasicAuthHandler`` のインスタンスを作成し、 " -"opener が handler を利用するようにします。" +"クライアントは、その realm に適した名前とパスワードをリクエストヘッダーに含め" +"て、リクエストを再試行します。\n" +"これが「Basic 認証」です。\n" +"この処理を簡単にするために、``HTTPBasicAuthHandler`` のインスタンスと、そのハ" +"ンドラーを使う opener を作成できます。" -#: ../../howto/urllib2.rst:422 msgid "" "The ``HTTPBasicAuthHandler`` uses an object called a password manager to " "handle the mapping of URLs and realms to passwords and usernames. If you " @@ -761,25 +879,26 @@ msgid "" "providing an alternative combination for a specific realm. We indicate this " "by providing ``None`` as the realm argument to the ``add_password`` method." msgstr "" -"``HTTPBasicAuthHandler`` はパスワードマネージャーと呼ばれる、 URL と realm を" -"パスワードとユーザ名への対応づけを処理する、オブジェクトを利用します。 realm " -"が何なのか(サーバから返される認証ヘッダから) 知りたい場合には、 " -"``HTTPPasswordMgr`` を利用できます。多くの場合、realm が何なのかについて気に" -"することはありません。そのような場合には ``HTTPPasswordMgrWithDefaultRealm`` " -"を使うと便利です。これは URL に対してデフォルトのユーザ名とパスワードを指定で" -"きます。これによって特定の realm に対する代替の組み合わせを提供することなしに" -"利用できるようになります。このことは ``add_password`` メソッドの realm 引数と" -"して ``None`` を与えることで明示することができます。" +"``HTTPBasicAuthHandler`` は、パスワードマネージャーというオブジェクトを使い、" +"URL と realm をユーザー名とパスワードに対応付けます。\n" +"サーバーからの認証ヘッダーで realm が分かっている場合は、``HTTPPasswordMgr`` " +"を使えます。\n" +"realm を特に気にしないことも多く、その場合は " +"``HTTPPasswordMgrWithDefaultRealm`` が便利です。\n" +"これを使うと、URL に対するデフォルトのユーザー名とパスワードを指定できま" +"す。\n" +"特定の realm に別の組み合わせを指定していなければ、このデフォルト値が使われま" +"す。\n" +"デフォルト値を登録するには、``add_password`` メソッドの ``realm`` 引数に " +"``None`` を渡します。" -#: ../../howto/urllib2.rst:432 msgid "" "The top-level URL is the first URL that requires authentication. URLs " "\"deeper\" than the URL you pass to .add_password() will also match. ::" msgstr "" -"トップレベルの URL が認証が必要なはじめに URL です。この URL よりも「深い」" -"URL を渡しても .add_password() は同様にマッチします。::" +"トップレベルの URL は、認証が必要になる最初の URL です。\n" +"``.add_password()`` に渡した URL より「深い」URL も対象になります。 ::" -#: ../../howto/urllib2.rst:435 msgid "" "# create a password manager\n" "password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" @@ -801,8 +920,26 @@ msgid "" "# Now all calls to urllib.request.urlopen use our opener.\n" "urllib.request.install_opener(opener)" msgstr "" +"# パスワードマネージャーを作成する\n" +"password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()\n" +"\n" +"# ユーザー名とパスワードを追加する。\n" +"# realm が分かっていれば、None の代わりに指定できる。\n" +"top_level_url = \"http://example.com/foo/\"\n" +"password_mgr.add_password(None, top_level_url, username, password)\n" +"\n" +"handler = urllib.request.HTTPBasicAuthHandler(password_mgr)\n" +"\n" +"# \"opener\" (OpenerDirector のインスタンス) を作成する\n" +"opener = urllib.request.build_opener(handler)\n" +"\n" +"# opener を使って URL を取得する\n" +"opener.open(a_url)\n" +"\n" +"# opener を登録する。\n" +"# 以降の urllib.request.urlopen の呼び出しはすべてこの opener を使う。\n" +"urllib.request.install_opener(opener)" -#: ../../howto/urllib2.rst:457 msgid "" "In the above example we only supplied our ``HTTPBasicAuthHandler`` to " "``build_opener``. By default openers have the handlers for normal situations " @@ -811,6 +948,12 @@ msgid "" "``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``, " "``FileHandler``, ``DataHandler``, ``HTTPErrorProcessor``." msgstr "" +"上の例では、``build_opener`` に ``HTTPBasicAuthHandler`` だけを渡しました。\n" +"デフォルトの opener には、通常の状況に対応するハンドラーが備わっています。\n" +"``ProxyHandler`` (:envvar:`!http_proxy` 環境変数などのプロキシ設定がある場" +"合)、``UnknownHandler``、``HTTPHandler``、``HTTPDefaultErrorHandler``、" +"``HTTPRedirectHandler``、``FTPHandler``、``FileHandler``、``DataHandler``、" +"``HTTPErrorProcessor`` です。" #: ../../howto/urllib2.rst:464 msgid "" @@ -849,12 +992,14 @@ msgstr "" "`Basic Authentication`_ handler を設定したときと同じような流れで行うことがで" "きます: ::" -#: ../../howto/urllib2.rst:483 msgid "" ">>> proxy_support = urllib.request.ProxyHandler({})\n" ">>> opener = urllib.request.build_opener(proxy_support)\n" ">>> urllib.request.install_opener(opener)" msgstr "" +">>> proxy_support = urllib.request.ProxyHandler({})\n" +">>> opener = urllib.request.build_opener(proxy_support)\n" +">>> urllib.request.install_opener(opener)" #: ../../howto/urllib2.rst:489 msgid "" @@ -904,7 +1049,6 @@ msgstr "" "ベルからは隠蔽されていています。しかし、以下を利用することで全てのソケットに" "対してグローバルにデフォルトタイムアウトを設定することができます ::" -#: ../../howto/urllib2.rst:511 msgid "" "import socket\n" "import urllib.request\n" @@ -918,6 +1062,17 @@ msgid "" "req = urllib.request.Request('http://www.voidspace.org.uk')\n" "response = urllib.request.urlopen(req)" msgstr "" +"import socket\n" +"import urllib.request\n" +"\n" +"# 秒単位のタイムアウト\n" +"timeout = 10\n" +"socket.setdefaulttimeout(timeout)\n" +"\n" +"# この urllib.request.urlopen の呼び出しは、socket モジュールに\n" +"# 設定したデフォルトのタイムアウトを使う\n" +"req = urllib.request.Request('http://www.voidspace.org.uk')\n" +"response = urllib.request.urlopen(req)" #: ../../howto/urllib2.rst:528 msgid "Footnotes" @@ -927,9 +1082,8 @@ msgstr "脚注" msgid "This document was reviewed and revised by John Lee." msgstr "このドキュメントは John Lee によって査読、改訂されました。" -#: ../../howto/urllib2.rst:532 msgid "Google for example." -msgstr "Google を例題にする。" +msgstr "例えば Google です。" #: ../../howto/urllib2.rst:533 msgid "" @@ -971,9 +1125,11 @@ msgstr "" "報を利用します。localhost のサーバでスクリプトをテストしようとすると、urllib " "がプロキシを利用するのを止めなければいけません。" -#: ../../howto/urllib2.rst:545 msgid "" "urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe `_." msgstr "" +"SSL プロキシ (CONNECT メソッド) 用の urllib opener: `ASPN Cookbook Recipe " +"`_。" diff --git a/improve-page-nojs.po b/improve-page-nojs.po index 9c3c80390..2afdb2bc9 100644 --- a/improve-page-nojs.po +++ b/improve-page-nojs.po @@ -12,44 +12,50 @@ msgstr "" "PO-Revision-Date: 2026-02-19 14:44+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../improve-page-nojs.rst:5 msgid "Improve a documentation page" -msgstr "" +msgstr "ドキュメントのページを改善する" -#: ../../improve-page-nojs.rst:13 msgid "" "We are always interested to hear ideas about improvements to the " "documentation." -msgstr "" +msgstr "ドキュメントの改善に関するアイデアをいつでもお待ちしています。" -#: ../../improve-page-nojs.rst:17 msgid "" "If the bug or suggested improvement concerns the translation of this " "documentation, open an issue or edit the page in `translation's repository " "`_ instead." msgstr "" +"不備や改善の提案がこのドキュメントの翻訳に関する場合は、代わりに `翻訳用リポ" +"ジトリ `_ で issue を作成するか、ページを編集してくださ" +"い。" -#: ../../improve-page-nojs.rst:21 msgid "You have a few ways to ask questions or suggest changes:" -msgstr "" +msgstr "質問したり、変更を提案したりする方法はいくつかあります:" -#: ../../improve-page-nojs.rst:23 msgid "" "You can start a discussion about the page on the Python discussion forum. " "This link will start a topic in the Documentation category: `New " "Documentation topic `_." msgstr "" +"Python のディスカッションフォーラムで、このページについての議論を始められま" +"す。\n" +"次のリンクから Documentation カテゴリのトピックを作成できます: `新しい " +"Documentation トピック `_。" -#: ../../improve-page-nojs.rst:27 msgid "" "You can open an issue on the Python GitHub issue tracker. This link will " "create a new issue with the \"docs\" label: `New docs issue `_." msgstr "" +"Python の GitHub issue tracker で issue を作成できます。\n" +"次のリンクから「docs」ラベルの付いた新しい issue を作成できます: `新しい " +"docs issue `_。" diff --git a/improve-page.po b/improve-page.po index 7155edb3d..8ba4b1926 100644 --- a/improve-page.po +++ b/improve-page.po @@ -12,41 +12,41 @@ msgstr "" "PO-Revision-Date: 2026-02-19 14:44+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../improve-page.rst:5 msgid "Improve a documentation page" -msgstr "" +msgstr "ドキュメントのページを改善する" -#: ../../improve-page.rst:43 msgid "" "We are always interested to hear ideas about improvements to the " "documentation." -msgstr "" +msgstr "ドキュメントの改善に関するアイデアをいつでもお待ちしています。" -#: ../../improve-page.rst:45 msgid "" "You were reading \"PAGETITLE\" at ``_. The source for that page is " "on `GitHub `_." msgstr "" +"閲覧していたのは ``_ にある「PAGETITLE」です。\n" +"このページのソースは `GitHub `_ にあります。" -#: ../../improve-page.rst:50 msgid "" "If the bug or suggested improvement concerns the translation of this " "documentation, open an issue or edit the page in `translation's repository " "`_ instead." msgstr "" +"不備や改善の提案がこのドキュメントの翻訳に関する場合は、代わりに `翻訳用リポ" +"ジトリ `_ で issue を作成するか、ページを編集してくださ" +"い。" -#: ../../improve-page.rst:54 msgid "You have a few ways to ask questions or suggest changes:" -msgstr "" +msgstr "質問したり、変更を提案したりする方法はいくつかあります:" -#: ../../improve-page.rst:56 msgid "" "You can start a discussion about the page on the Python discussion forum. " "This link will start a pre-populated topic: `Question about page " @@ -54,8 +54,13 @@ msgid "" "category=documentation&title=Question+about+page+" "%22PAGETITLE%22&body=About+the+page+at+PAGEURL%3A>`_." msgstr "" +"Python のディスカッションフォーラムで、このページについての議論を始められま" +"す。\n" +"次のリンクから、内容があらかじめ入力されたトピックを作成できます: `ページ" +"「PAGETITLE」についての質問 `_。" -#: ../../improve-page.rst:60 msgid "" "You can open an issue on the Python GitHub issue tracker. This link will " "create a new pre-populated issue: `Docs: problem with page \"PAGETITLE\" " @@ -63,10 +68,16 @@ msgid "" "yml&title=Docs%3A+problem+with+page+" "%22PAGETITLE%22&description=The+page+at+PAGEURL+has+a+problem%3A>`_." msgstr "" +"Python の GitHub issue tracker で issue を作成できます。\n" +"次のリンクから、内容があらかじめ入力された新しい issue を作成できます: " +"`Docs: ページ「PAGETITLE」の問題 `_。" -#: ../../improve-page.rst:64 msgid "" "You can `edit the page on GitHub `_ to open a pull request and begin the " "contribution process." msgstr "" +"`GitHub でページを編集 `_ して、プルリクエストを作成し、貢献を始められます。" diff --git a/install/index.po b/install/index.po index dd8808bd0..523447180 100644 --- a/install/index.po +++ b/install/index.po @@ -782,7 +782,6 @@ msgstr "(Windows の場合はスラッシュをバックスラッシュに脳内 msgid "Alternate installation: Unix (the prefix scheme)" msgstr "別の場所へのインストール: Unix (prefix スキーム)" -#: ../../install/index.rst:400 msgid "" "The \"prefix scheme\" is useful when you wish to use one Python installation " "to perform the build/install (i.e., to run the setup script), but install " @@ -792,13 +791,13 @@ msgid "" "and home schemes come before. However, there are at least two known cases " "where the prefix scheme will be useful." msgstr "" -"あるインストール済みの Python を使ってモジュールのビルド/インストールを (例え" -"ば setup スクリプトを実行して) 行いたいけれども、 別のインストール済みの " -"Python のサードパーティ製モジュール置き場 (あるいは、そう見えるようなディレク" -"トリ構造) に、ビルドされた モジュールをインストールしたい場合には、\"prefix " -"スキーム\" が便利です。そんな作業はまったくありえそうにない、と思うなら、確か" -"にその通りです --- \"home スキーム\" を先に説明したのもそのためです。とはい" -"え、prefix スキームが有用なケースは少なくとも二つあります。" +"ある Python 環境を使ってビルドやインストール (setup スクリプトの実行) を行い" +"ながら、別の Python 環境のサードパーティーモジュール用ディレクトリ (またはそ" +"れに似た構成のディレクトリ) にモジュールをインストールしたい場合、プレフィッ" +"クススキームが便利です。\n" +"少し変わった使い方に思えるかもしれませんが、その通りです。\n" +"そのため、ユーザースキームとホームスキームを先に説明しました。\n" +"それでも、プレフィックススキームが役立つ場面は少なくとも 2 つあります。" #: ../../install/index.rst:407 msgid "" diff --git a/installing/index.po b/installing/index.po index 124d1fcbf..c629d3512 100644 --- a/installing/index.po +++ b/installing/index.po @@ -16,33 +16,35 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../installing/index.rst:7 msgid "Installing Python modules" msgstr "Python モジュールのインストール" -#: ../../installing/index.rst:9 msgid "" "As a popular open source development project, Python has an active " "supporting community of contributors and users that also make their software " "available for other Python developers to use under open-source license terms." msgstr "" +"Python は人気のあるオープンソース開発プロジェクトで、貢献者やユーザーからなる" +"活発なコミュニティに支えられています。\n" +"コミュニティの人々も自分のソフトウェアをオープンソースライセンスで公開し、ほ" +"かの Python 開発者が使えるようにしています。" -#: ../../installing/index.rst:13 msgid "" "This allows Python users to share and collaborate effectively, benefiting " "from the solutions others have already created to common (and sometimes even " "rare!) problems, as well as potentially contributing their own solutions to " "the common pool." msgstr "" -"これはほかの人が既に挙げた共通の(あるいは時折極めて稀有な!)問題や、彼ら自身の" -"解法による潜在的な貢献が共通の場所に蓄えられることによる恩恵によって、Python " -"ユーザに共有と協調を効果的に行なうことの助けとなっています。" +"これにより、Python ユーザーは効果的に共有や協力を行えます。\n" +"よくある問題 (ときには珍しい問題も!) に対してほかの人がすでに作った解決策を" +"活用でき、自分の解決策を共有して貢献することもできます。" #: ../../installing/index.rst:18 msgid "" @@ -70,11 +72,12 @@ msgstr "" msgid "Key terms" msgstr "重要用語集" -#: ../../installing/index.rst:35 msgid "" ":program:`pip` is the preferred installer program. It is included by default " "with the Python binary installers." msgstr "" +":program:`pip` は推奨されるインストール用プログラムです。\n" +"Python のバイナリインストーラーにはデフォルトで含まれています。" #: ../../installing/index.rst:37 msgid "" @@ -86,25 +89,29 @@ msgstr "" "ンで使用するためにパッケージをインストールできるようにする半独立型のPython環" "境です。" -#: ../../installing/index.rst:40 msgid "" "``venv`` is the standard tool for creating virtual environments. It defaults " "to installing :program:`pip` into all created virtual environments." msgstr "" +"``venv`` は仮想環境を作成するための標準ツールです。\n" +"デフォルトでは、作成するすべての仮想環境に :program:`pip` をインストールしま" +"す。" -#: ../../installing/index.rst:42 msgid "" "``virtualenv`` is a third-party alternative (and predecessor) to ``venv``." msgstr "" +"``virtualenv`` は ``venv`` の代わりに使えるサードパーティー製のツールで、" +"``venv`` よりも前から存在します。" -#: ../../installing/index.rst:44 msgid "" "The `Python Package Index (PyPI) `__ is a public " "repository of open source licensed packages made available for use by other " "Python users." msgstr "" +"`Python Package Index (PyPI) `__ は、ほかの Python ユーザー" +"が使えるようにオープンソースライセンスで提供されているパッケージの公開リポジ" +"トリです。" -#: ../../installing/index.rst:47 msgid "" "The `Python Packaging Authority `__ is the group of " "developers and documentation authors responsible for the maintenance and " @@ -112,11 +119,16 @@ msgid "" "file format standards. They maintain a variety of tools, documentation, and " "issue trackers on `GitHub `__." msgstr "" +"`Python Packaging Authority `__ は、標準のパッケージン" +"グツールと、それらに関連するメタデータやファイル形式の標準の維持・発展を担う" +"開発者やドキュメント執筆者のグループです。\n" +"`GitHub `__ で、さまざまなツール、ドキュメント、課題" +"管理システムを管理しています。" #: ../../installing/index.rst:54 msgid "" "The use of ``venv`` is now recommended for creating virtual environments." -msgstr "仮想環境の作成には、 ``venv`` の使用をお勧めします。" +msgstr "仮想環境の作成には、 ``venv`` の使用が今は推奨されています。" #: ../../installing/index.rst:59 msgid "" @@ -138,15 +150,15 @@ msgstr "" "パッケージングのための標準ツールはすべてコマンドラインから使われることを想定" "しています。" -#: ../../installing/index.rst:69 msgid "" "The following command will install the latest version of a module and its " "dependencies from PyPI::" msgstr "" +"次のコマンドは、モジュールの最新バージョンとその依存パッケージを PyPI からイ" +"ンストールします。 ::" -#: ../../installing/index.rst:72 msgid "python -m pip install SomePackage" -msgstr "" +msgstr "python -m pip install SomePackage" #: ../../installing/index.rst:76 msgid "" @@ -176,11 +188,12 @@ msgstr "" "ます。``>`` や ``<`` などの比較演算子など、シェルが解釈する特殊文字を使う場" "合、パッケージ名とバージョンを二重引用符で囲んでください::" -#: ../../installing/index.rst:88 msgid "" "python -m pip install SomePackage==1.0.4 # specific version\n" "python -m pip install \"SomePackage>=1.0.4\" # minimum version" msgstr "" +"python -m pip install SomePackage==1.0.4 # 特定のバージョン\n" +"python -m pip install \"SomePackage>=1.0.4\" # 最小バージョンを指定" #: ../../installing/index.rst:91 msgid "" @@ -192,25 +205,25 @@ msgstr "" "試みても効果はありません。既に存在しているモジュールのアップグレードには、明" "示的にそれを要求しなければなりません::" -#: ../../installing/index.rst:95 msgid "python -m pip install --upgrade SomePackage" -msgstr "" +msgstr "python -m pip install --upgrade SomePackage" -#: ../../installing/index.rst:97 msgid "" "More information and resources regarding :program:`pip` and its capabilities " "can be found in the `Python Packaging User Guide `__." msgstr "" +":program:`pip` とその機能についての詳しい情報や資料は、`Python Packaging " +"User Guide `__ を参照してください。" -#: ../../installing/index.rst:100 msgid "" "Creation of virtual environments is done through the :mod:`venv` module. " "Installing packages into an active virtual environment uses the commands " "shown above." msgstr "" -"仮想環境の作成は :mod:`venv` モジュールを通して行われます。\n" -"有効な仮想環境にインストールするには 上記のコマンドを使います。 " +"仮想環境は :mod:`venv` モジュールを使って作成します。\n" +"有効化した仮想環境にパッケージをインストールするには、上記のコマンドを使いま" +"す。" #: ../../installing/index.rst:106 msgid "" @@ -245,7 +258,6 @@ msgstr "" msgid "... install scientific Python packages?" msgstr "... 科学技術計算用の Python パッケージをインストールするには?" -#: ../../installing/index.rst:127 msgid "" "A number of scientific Python packages have complex binary dependencies, and " "aren't currently easy to install using :program:`pip` directly. It will " @@ -253,6 +265,11 @@ msgid "" "packaging.python.org/science/>`__ rather than attempting to install them " "with :program:`pip`." msgstr "" +"科学技術計算用の Python パッケージには、バイナリの依存関係が複雑で、現時点で" +"は :program:`pip` で直接インストールするのが難しいものがいくつもあります。\n" +"こうしたパッケージは、:program:`pip` でインストールしようとするよりも、`別の" +"方法 `__ でインストールするほうが簡単" +"な場合が多いです。" #: ../../installing/index.rst:135 msgid "" @@ -266,34 +283,40 @@ msgstr "" msgid "... work with multiple versions of Python installed in parallel?" msgstr "... インストールされた複数のバージョンの Python を並行して使うには?" -#: ../../installing/index.rst:142 msgid "" "On Linux, macOS, and other POSIX systems, use the versioned Python commands " "in combination with the ``-m`` switch to run the appropriate copy of :" "program:`pip`::" msgstr "" +"Linux、macOS、その他の POSIX システムでは、バージョン番号付きの Python コマン" +"ドに ``-m`` オプションを組み合わせ、対応する :program:`pip` を実行してくださ" +"い。 ::" -#: ../../installing/index.rst:146 msgid "" "python3 -m pip install SomePackage # default Python 3\n" "python3.14 -m pip install SomePackage # specifically Python 3.14" msgstr "" +"python3 -m pip install SomePackage # デフォルトの Python 3\n" +"python3.14 -m pip install SomePackage # Python 3.14 を指定" -#: ../../installing/index.rst:149 msgid "Appropriately versioned :program:`pip` commands may also be available." msgstr "" +"対応するバージョン番号が付いた :program:`pip` コマンドを使える場合もありま" +"す。" -#: ../../installing/index.rst:151 msgid "" "On Windows, use the :program:`py` Python launcher in combination with the ``-" "m`` switch::" msgstr "" +"Windows では、:program:`py` Python ランチャーに ``-m`` オプションを組み合わせ" +"て使ってください。 ::" -#: ../../installing/index.rst:154 msgid "" "py -3 -m pip install SomePackage # default Python 3\n" "py -3.14 -m pip install SomePackage # specifically Python 3.14" msgstr "" +"py -3 -m pip install SomePackage # デフォルトの Python 3\n" +"py -3.14 -m pip install SomePackage # Python 3.14 を指定" #: ../../installing/index.rst:166 msgid "Common installation issues" @@ -303,7 +326,6 @@ msgstr "よくあるインストールに関する問題" msgid "Installing into the system Python on Linux" msgstr "Linux で、システムの Python 内にインストールする" -#: ../../installing/index.rst:171 msgid "" "On Linux systems, a Python installation will typically be included as part " "of the distribution. Installing into this Python installation requires root " @@ -311,60 +333,77 @@ msgid "" "package manager and other components of the system if a component is " "unexpectedly upgraded using :program:`pip`." msgstr "" +"Linux システムでは、通常、ディストリビューションの一部として Python がインス" +"トールされています。\n" +"この Python にパッケージをインストールするには、システムの root 権限が必要で" +"す。\n" +":program:`pip` で構成要素が予期せずアップグレードされると、システムのパッケー" +"ジマネージャーやほかの構成要素の動作に支障をきたす可能性があります。" -#: ../../installing/index.rst:177 msgid "" "On such systems, it is often better to use a virtual environment or a per-" "user installation when installing packages with :program:`pip`." msgstr "" +"このようなシステムで :program:`pip` を使ってパッケージをインストールする場合" +"は、仮想環境やユーザー単位のインストールを使うほうがよいことが多いです。" #: ../../installing/index.rst:182 msgid "Pip not installed" msgstr "pip がインストールされていない" -#: ../../installing/index.rst:184 msgid "" "It is possible that :program:`pip` does not get installed by default. One " "potential fix is::" msgstr "" +":program:`pip` がデフォルトではインストールされない場合もあります。\n" +"解決方法の一つとして、次のコマンドを試せます。 ::" -#: ../../installing/index.rst:186 msgid "python -m ensurepip --default-pip" -msgstr "" +msgstr "python -m ensurepip --default-pip" -#: ../../installing/index.rst:188 msgid "" "There are also additional resources for `installing pip `__." msgstr "" +"`pip のインストール `__ に関" +"する資料もあります。" #: ../../installing/index.rst:193 msgid "Installing binary extensions" msgstr "バイナリの拡張のインストール" -#: ../../installing/index.rst:195 msgid "" "Python once relied heavily on source-based distribution, with end users " "being expected to compile extension modules from source as part of the " "installation process." msgstr "" +"かつて Python はソースコードによる配布に大きく依存していました。\n" +"エンドユーザーは、インストール作業の一環として拡張モジュールをソースからコン" +"パイルすることを求められていました。" -#: ../../installing/index.rst:199 msgid "" "With the introduction of the binary wheel format, and the ability to publish " "wheels through PyPI, this problem is diminishing, as users are more " "regularly able to install pre-built extensions rather than needing to build " "them themselves." msgstr "" +"バイナリの wheel 形式が導入され、PyPI を通じて wheel を公開できるようになった" +"ことで、この問題は減りつつあります。\n" +"ユーザーが自分でビルドする必要がなく、ビルド済みの拡張モジュールをインストー" +"ルできる場合が増えているためです。" -#: ../../installing/index.rst:204 msgid "" "Some of the solutions for installing `scientific software `__ that are not yet available as pre-built wheel files " "may also help with obtaining other binary extensions without needing to " "build them locally." msgstr "" +"ビルド済みの wheel ファイルがまだ提供されていない `科学技術計算用ソフトウェ" +"ア `__ をインストールするための方法の" +"中には、ほかのバイナリ拡張を手元でビルドせずに入手するのに役立つものもありま" +"す。" #: ../../installing/index.rst:211 msgid "" diff --git a/library/__future__.po b/library/__future__.po index 51457420b..a8aa46b79 100644 --- a/library/__future__.po +++ b/library/__future__.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/__future__.rst:2 @@ -42,13 +42,17 @@ msgstr "" "標準になるリリースの前に Python コンパイラーが future 文を含むモジュールで " "Python の新機能を使用できるようにします。" -#: ../../library/__future__.rst:16 msgid "" "While these future statements are given additional special meaning by the " "Python compiler, they are still executed like any other import statement and " "the :mod:`!__future__` exists and is handled by the import system the same " "way any other Python module would be. This design serves three purposes:" msgstr "" +"Python コンパイラはこれらの future 文に特別な意味を与えますが、文自体は他の " +"import 文と同じように実行されます。\n" +":mod:`!__future__` も実在するモジュールで、インポートシステムは他の Python モ" +"ジュールと同じように扱います。\n" +"この設計には三つの目的があります。" #: ../../library/__future__.rst:21 msgid "" @@ -58,48 +62,52 @@ msgstr "" "import 文を解析する既存のツールを混乱させることを避け、インポートしようとして" "いるモジュールを見つけられるようにするため。" -#: ../../library/__future__.rst:24 msgid "" "To document when incompatible changes were introduced, and when they will be " "--- or were --- made mandatory. This is a form of executable documentation, " "and can be inspected programmatically via importing :mod:`!__future__` and " "examining its contents." msgstr "" +"互換性のない変更がいつ導入され、いつ必須になる予定か、またはいつ必須になった" +"かを記録するため。\n" +"これは実行可能なドキュメントの一種で、:mod:`!__future__` をインポートして内容" +"を調べることで、プログラムから確認できます。" -#: ../../library/__future__.rst:29 msgid "" "To ensure that :ref:`future statements ` run under releases prior to " "Python 2.1 at least yield runtime exceptions (the import of :mod:`!" "__future__` will fail, because there was no module of that name prior to " "2.1)." msgstr "" +"Python 2.1 より前のリリースで :ref:`future 文 ` を実行した場合に、少" +"なくとも実行時例外が発生するようにするため。\n" +"(2.1 より前にはその名前のモジュールがないため、:mod:`!__future__` のインポー" +"トは失敗します。)" #: ../../library/__future__.rst:34 msgid "Module Contents" msgstr "モジュールコンテンツ" -#: ../../library/__future__.rst:36 msgid "" "No feature description will ever be deleted from :mod:`!__future__`. Since " "its introduction in Python 2.1 the following features have found their way " "into the language using this mechanism:" msgstr "" +":mod:`!__future__` から機能の説明が削除されることはありません。\n" +"Python 2.1 での導入以来、次の機能がこの仕組みを通して言語に取り入れられまし" +"た。" -#: ../../library/__future__.rst:45 msgid "feature" -msgstr "feature" +msgstr "機能" -#: ../../library/__future__.rst:46 msgid "optional in" -msgstr "optional in" +msgstr "選択可能になったリリース" -#: ../../library/__future__.rst:47 msgid "mandatory in" -msgstr "mandatory in" +msgstr "必須になったリリース" -#: ../../library/__future__.rst:48 msgid "effect" -msgstr "effect" +msgstr "内容" #: ../../library/__future__.rst:50 msgid "2.1.0b1" @@ -150,9 +158,8 @@ msgstr ":pep:`328`: *Imports: Multi-Line and Absolute/Relative*" msgid "2.6" msgstr "2.6" -#: ../../library/__future__.rst:68 msgid ":pep:`343`: *The “with” Statement*" -msgstr "" +msgstr ":pep:`343`: *「with」文*" #: ../../library/__future__.rst:70 ../../library/__future__.rst:74 msgid "2.6.0a2" @@ -182,35 +189,34 @@ msgstr ":pep:`479`: *StopIteration handling inside generators*" msgid "3.7.0b1" msgstr "3.7.0b1" -#: ../../library/__future__.rst:83 msgid "Never [1]_" -msgstr "" +msgstr "予定なし [1]_" -#: ../../library/__future__.rst:84 msgid "" ":pep:`563`: *Postponed evaluation of annotations*, :pep:`649`: *Deferred " "evaluation of annotations using descriptors*" msgstr "" +":pep:`563`: *アノテーションの評価の延期*、:pep:`649`: *デスクリプタを使ったア" +"ノテーションの遅延評価*" #: ../../library/__future__.rst:93 msgid "Each statement in :file:`__future__.py` is of the form::" msgstr ":file:`__future__.py` のそれぞれの文は次のような形式をしています::" -#: ../../library/__future__.rst:95 msgid "" "FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" " CompilerFlag)" msgstr "" +"FeatureName = _Feature(OptionalRelease, MandatoryRelease,\n" +" CompilerFlag)" -#: ../../library/__future__.rst:98 msgid "" "where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both " "are 5-tuples of the same form as :data:`sys.version_info`::" msgstr "" -"ここで、普通は、 *OptionalRelease* は *MandatoryRelease* より小さく、2つと" -"も :data:`sys.version_info` と同じフォーマットの5つのタプルからなります::" +"通常、*OptionalRelease* は *MandatoryRelease* より小さく、どちらも :data:" +"`sys.version_info` と同じ形式の 5 要素のタプルです。 ::" -#: ../../library/__future__.rst:101 msgid "" "(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int\n" " PY_MINOR_VERSION, # the 1; an int\n" @@ -220,6 +226,13 @@ msgid "" " PY_RELEASE_SERIAL # the 3; an int\n" ")" msgstr "" +"(PY_MAJOR_VERSION, # 2.1.0a3 の 2。整数\n" +" PY_MINOR_VERSION, # 1。整数\n" +" PY_MICRO_VERSION, # 0。整数\n" +" PY_RELEASE_LEVEL, # \"alpha\", \"beta\", \"candidate\", \"final\" のいずれ" +"か。文字列\n" +" PY_RELEASE_SERIAL # 3。整数\n" +")" #: ../../library/__future__.rst:110 msgid "" @@ -267,13 +280,16 @@ msgstr "" "のフラグは :class:`_Feature` インスタンスの :attr:`_Feature.compiler_flag` 属" "性に保存されています。" -#: ../../library/__future__.rst:133 msgid "" "``from __future__ import annotations`` was previously scheduled to become " "mandatory in Python 3.10, but the change was delayed and ultimately " "canceled. This feature will eventually be deprecated and removed. See :pep:" "`649` and :pep:`749`." msgstr "" +"``from __future__ import annotations`` は、以前は Python 3.10 で必須になる予" +"定でしたが、延期された後、最終的に取りやめになりました。\n" +"この機能はいずれ非推奨となり、削除される予定です。\n" +":pep:`649` と :pep:`749` を参照してください。" #: ../../library/__future__.rst:141 msgid ":ref:`future`" diff --git a/library/__main__.po b/library/__main__.po index e4cd7ef8a..e1a4a14f2 100644 --- a/library/__main__.po +++ b/library/__main__.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Inada Naoki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/__main__.rst:2 @@ -76,12 +76,14 @@ msgstr "" "通常、インポートされる Python ファイル自体のファイル名から拡張子 ``.py`` を除" "いたものとなります::" -#: ../../library/__main__.rst:31 msgid "" ">>> import configparser\n" ">>> configparser.__name__\n" "'configparser'" msgstr "" +">>> import configparser\n" +">>> configparser.__name__\n" +"'configparser'" #: ../../library/__main__.rst:35 msgid "" @@ -91,12 +93,14 @@ msgstr "" "インポートされるファイルがパッケージの一部である場合は、 ``__name__`` にはそ" "のパッケージのパスも含まれます::" -#: ../../library/__main__.rst:38 msgid "" ">>> from concurrent.futures import process\n" ">>> process.__name__\n" "'concurrent.futures.process'" msgstr "" +">>> from concurrent.futures import process\n" +">>> process.__name__\n" +"'concurrent.futures.process'" #: ../../library/__main__.rst:42 msgid "" @@ -132,21 +136,23 @@ msgstr "以下のものがトップレベルのスクリプト環境となりま msgid "the scope of an interactive prompt::" msgstr "インタラクティブプロンプトのスコープ::" -#: ../../library/__main__.rst:57 msgid "" ">>> __name__\n" "'__main__'" msgstr "" +">>> __name__\n" +"'__main__'" #: ../../library/__main__.rst:60 msgid "the Python module passed to the Python interpreter as a file argument:" msgstr "Python インタープリタにファイル引数として渡される Python モジュール:" -#: ../../library/__main__.rst:62 msgid "" "$ python helloworld.py\n" "Hello, world!" msgstr "" +"$ python helloworld.py\n" +"Hello, world!" #: ../../library/__main__.rst:67 msgid "" @@ -156,17 +162,17 @@ msgstr "" "Python インタープリタにPython :option:`-m` オプションとして渡される Python モ" "ジュールまたはパッケージ:" -#: ../../library/__main__.rst:70 msgid "" "$ python -m tarfile\n" "usage: tarfile.py [-h] [-v] (...)" msgstr "" +"$ python -m tarfile\n" +"usage: tarfile.py [-h] [-v] (...)" #: ../../library/__main__.rst:75 msgid "Python code read by the Python interpreter from standard input:" msgstr "標準入力から Python インタープリタが読み込む Python コード:" -#: ../../library/__main__.rst:77 msgid "" "$ echo \"import this\" | python\n" "The Zen of Python, by Tim Peters\n" @@ -175,6 +181,12 @@ msgid "" "Explicit is better than implicit.\n" "..." msgstr "" +"$ echo \"import this\" | python\n" +"The Zen of Python, by Tim Peters\n" +"\n" +"Beautiful is better than ugly.\n" +"Explicit is better than implicit.\n" +"..." #: ../../library/__main__.rst:86 msgid "" @@ -182,7 +194,6 @@ msgid "" msgstr "" "Python インタープリタに :option:`-c` オプションで渡される Python コード:" -#: ../../library/__main__.rst:88 msgid "" "$ python -c \"import this\"\n" "The Zen of Python, by Tim Peters\n" @@ -191,6 +202,12 @@ msgid "" "Explicit is better than implicit.\n" "..." msgstr "" +"$ python -c \"import this\"\n" +"The Zen of Python, by Tim Peters\n" +"\n" +"Beautiful is better than ugly.\n" +"Explicit is better than implicit.\n" +"..." #: ../../library/__main__.rst:97 msgid "" @@ -212,12 +229,14 @@ msgstr "" "このことから、モジュールが import 文で初期化された場合以外の場合でのみコード" "を実行するため、次のコードがしばしば用いられます::" -#: ../../library/__main__.rst:105 msgid "" "if __name__ == '__main__':\n" " # Execute when the module is not initialized from an import statement.\n" " ..." msgstr "" +"if __name__ == '__main__':\n" +" # モジュールが import 文で初期化された場合以外に実行する。\n" +" ..." #: ../../library/__main__.rst:111 msgid "" @@ -264,7 +283,6 @@ msgstr "" "最もよくあるのが、プログラムの主要な処理を ``main`` 関数の中にカプセル化する" "ことです::" -#: ../../library/__main__.rst:131 msgid "" "# echo.py\n" "\n" @@ -286,6 +304,25 @@ msgid "" "if __name__ == '__main__':\n" " sys.exit(main()) # next section explains the use of sys.exit" msgstr "" +"# echo.py\n" +"\n" +"import shlex\n" +"import sys\n" +"\n" +"def echo(phrase: str) -> None:\n" +" \"\"\"print を呼び出すだけのダミーのラッパー。\"\"\"\n" +" # 説明のため、この関数に有用で再利用可能な処理が\n" +" # 含まれていると考える\n" +" print(phrase)\n" +"\n" +"def main() -> int:\n" +" \"\"\"入力された引数を標準出力に出力する\"\"\"\n" +" phrase = shlex.join(sys.argv)\n" +" echo(phrase)\n" +" return 0\n" +"\n" +"if __name__ == '__main__':\n" +" sys.exit(main()) # sys.exit の使い方は次の節で説明" #: ../../library/__main__.rst:151 msgid "" @@ -320,35 +357,42 @@ msgstr "" msgid "Packaging Considerations" msgstr "パッケージングで考慮すべき点" -#: ../../library/__main__.rst:167 msgid "" "``main`` functions are often used to create command-line tools by specifying " "them as entry points for console scripts. When this is done, `pip `_ inserts the function call into a template script, where the " "return value of ``main`` is passed into :func:`sys.exit`. For example::" msgstr "" +"``main`` 関数は、コンソールスクリプトのエントリーポイントに指定して、コマンド" +"ラインツールを作るためによく使われます。\n" +"この場合、`pip `_ は関数呼び出しをテンプレートのスクリ" +"プトに挿入し、``main`` の戻り値を :func:`sys.exit` に渡します。\n" +"例えば、次のようになります。 ::" -#: ../../library/__main__.rst:173 msgid "sys.exit(main())" -msgstr "" +msgstr "sys.exit(main())" -#: ../../library/__main__.rst:175 msgid "" "Since the call to ``main`` is wrapped in :func:`sys.exit`, the expectation " "is that your function will return some value acceptable as an input to :func:" "`sys.exit`; typically, an integer or ``None`` (which is implicitly returned " "if your function does not have a return statement)." msgstr "" +"``main`` の呼び出しは :func:`sys.exit` で囲まれるため、関数は :func:`sys." +"exit` の入力として受け付けられる値を返すことが想定されています。\n" +"通常は整数か ``None`` です (関数に return 文がない場合は暗黙に ``None`` を返" +"します)。" -#: ../../library/__main__.rst:180 msgid "" "By proactively following this convention ourselves, our module will have the " "same behavior when run directly (i.e. ``python echo.py``) as it will have if " "we later package it as a console script entry-point in a pip-installable " "package." msgstr "" +"最初からこの慣習に従っておくと、モジュールを直接実行した場合 (``python echo." +"py`` など) と、後で pip でインストール可能なパッケージのコンソールスクリプト" +"のエントリーポイントとして配布した場合とで、同じ動作になります。" -#: ../../library/__main__.rst:185 msgid "" "In particular, be careful about returning strings from your ``main`` " "function. :func:`sys.exit` will interpret a string argument as a failure " @@ -357,53 +401,68 @@ msgid "" "py`` example from earlier exemplifies using the ``sys.exit(main())`` " "convention." msgstr "" +"特に、``main`` 関数から文字列を返す場合は注意してください。\n" +":func:`sys.exit` は文字列の引数を失敗のメッセージとして扱うため、プログラムは" +"失敗を示す終了コード ``1`` で終了し、その文字列は :data:`sys.stderr` に出力さ" +"れます。\n" +"先ほどの ``echo.py`` は、``sys.exit(main())`` の慣習に従った例です。" -#: ../../library/__main__.rst:193 msgid "" "`Python Packaging User Guide `_ contains a " "collection of tutorials and references on how to distribute and install " "Python packages with modern tools." msgstr "" +"`Python Packaging User Guide `_ には、現在使わ" +"れているツールで Python パッケージを配布・インストールする方法について、" +"チュートリアルとリファレンスがまとめられています。" -#: ../../library/__main__.rst:199 msgid "``__main__.py`` in Python Packages" -msgstr "" +msgstr "Python パッケージの ``__main__.py``" -#: ../../library/__main__.rst:201 msgid "" "If you are not familiar with Python packages, see section :ref:`tut-" "packages` of the tutorial. Most commonly, the ``__main__.py`` file is used " "to provide a command-line interface for a package. Consider the following " "hypothetical package, \"bandclass\":" msgstr "" +"Python パッケージについてよく知らない場合は、チュートリアルの :ref:`tut-" +"packages` を参照してください。\n" +"``__main__.py`` ファイルは、主にパッケージのコマンドラインインターフェースを" +"提供するために使われます。\n" +"次のような「bandclass」という架空のパッケージを考えてみます。" -#: ../../library/__main__.rst:206 msgid "" "bandclass\n" " ├── __init__.py\n" " ├── __main__.py\n" " └── student.py" msgstr "" +"bandclass\n" +" ├── __init__.py\n" +" ├── __main__.py\n" +" └── student.py" -#: ../../library/__main__.rst:213 msgid "" "``__main__.py`` will be executed when the package itself is invoked directly " "from the command line using the :option:`-m` flag. For example:" msgstr "" +"コマンドラインから :option:`-m` フラグでパッケージ自体を直接実行すると、" +"``__main__.py`` が実行されます。\n" +"例を示します。" -#: ../../library/__main__.rst:216 msgid "$ python -m bandclass" -msgstr "" +msgstr "$ python -m bandclass" -#: ../../library/__main__.rst:220 msgid "" "This command will cause ``__main__.py`` to run. How you utilize this " "mechanism will depend on the nature of the package you are writing, but in " "this hypothetical case, it might make sense to allow the teacher to search " "for students::" msgstr "" +"このコマンドで ``__main__.py`` が実行されます。\n" +"この仕組みの使い方は、作成するパッケージの性質によります。\n" +"この架空の例では、教師が生徒を検索できるようにするとよいでしょう。 ::" -#: ../../library/__main__.rst:225 msgid "" "# bandclass/__main__.py\n" "\n" @@ -413,69 +472,98 @@ msgid "" "student_name = sys.argv[1] if len(sys.argv) >= 2 else ''\n" "print(f'Found student: {search_students(student_name)}')" msgstr "" +"# bandclass/__main__.py\n" +"\n" +"import sys\n" +"from .student import search_students\n" +"\n" +"student_name = sys.argv[1] if len(sys.argv) >= 2 else ''\n" +"print(f'Found student: {search_students(student_name)}')" -#: ../../library/__main__.rst:233 msgid "" "Note that ``from .student import search_students`` is an example of a " "relative import. This import style can be used when referencing modules " "within a package. For more details, see :ref:`intra-package-references` in " "the :ref:`tut-modules` section of the tutorial." msgstr "" +"``from .student import search_students`` は相対インポートの例です。\n" +"この書き方は、パッケージ内のモジュールを参照するときに使えます。\n" +"詳しくは、チュートリアルの :ref:`tut-modules` にある :ref:`intra-package-" +"references` を参照してください。" -#: ../../library/__main__.rst:241 msgid "" "The content of ``__main__.py`` typically isn't fenced with an ``if __name__ " "== '__main__'`` block. Instead, those files are kept short and import " "functions to execute from other modules. Those other modules can then be " "easily unit-tested and are properly reusable." msgstr "" +"通常、``__main__.py`` の内容は ``if __name__ == '__main__'`` ブロックでは囲み" +"ません。\n" +"代わりに、ファイルを短く保ち、実行する関数を他のモジュールからインポートしま" +"す。\n" +"そうすれば、それらのモジュールを簡単にユニットテストでき、再利用もしやすくな" +"ります。" -#: ../../library/__main__.rst:246 msgid "" "If used, an ``if __name__ == '__main__'`` block will still work as expected " "for a ``__main__.py`` file within a package, because its ``__name__`` " "attribute will include the package's path if imported::" msgstr "" +"パッケージ内の ``__main__.py`` で ``if __name__ == '__main__'`` ブロックを" +"使った場合も、期待どおりに動作します。\n" +"インポートされたときには、``__name__`` 属性にパッケージのパスが含まれるためで" +"す。 ::" -#: ../../library/__main__.rst:250 msgid "" ">>> import asyncio.__main__\n" ">>> asyncio.__main__.__name__\n" "'asyncio.__main__'" msgstr "" +">>> import asyncio.__main__\n" +">>> asyncio.__main__.__name__\n" +"'asyncio.__main__'" -#: ../../library/__main__.rst:254 msgid "" "This won't work for ``__main__.py`` files in the root directory of a ``." "zip`` file though. Hence, for consistency, a minimal ``__main__.py`` " "without a ``__name__`` check is preferred." msgstr "" +"ただし、``.zip`` ファイルのルートディレクトリにある ``__main__.py`` では、こ" +"の方法は使えません。\n" +"そのため、一貫性を保つには、``__name__`` のチェックを含まない最小限の " +"``__main__.py`` にする方がよいでしょう。" -#: ../../library/__main__.rst:260 msgid "" "See :mod:`venv` for an example of a package with a minimal ``__main__.py`` " "in the standard library. It doesn't contain a ``if __name__ == '__main__'`` " "block. You can invoke it with ``python -m venv [directory]``." msgstr "" +"標準ライブラリ内で最小限の ``__main__.py`` を持つパッケージの例は、:mod:" +"`venv` を参照してください。\n" +"``if __name__ == '__main__'`` ブロックは含まれていません。\n" +"``python -m venv [directory]`` で実行できます。" -#: ../../library/__main__.rst:264 msgid "" "See :mod:`runpy` for more details on the :option:`-m` flag to the " "interpreter executable." msgstr "" +"インタープリタ実行ファイルの :option:`-m` フラグの詳細は、:mod:`runpy` を参照" +"してください。" -#: ../../library/__main__.rst:267 msgid "" "See :mod:`zipapp` for how to run applications packaged as *.zip* files. In " "this case Python looks for a ``__main__.py`` file in the root directory of " "the archive." msgstr "" +"*.zip* ファイルにまとめたアプリケーションの実行方法は、:mod:`zipapp` を参照し" +"てください。\n" +"この場合、Python はアーカイブのルートディレクトリにある ``__main__.py`` を探" +"します。" #: ../../library/__main__.rst:274 msgid "``import __main__``" msgstr "``import __main__``" -#: ../../library/__main__.rst:276 msgid "" "Regardless of which module a Python program was started with, other modules " "running within that same program can import the top-level environment's " @@ -483,12 +571,15 @@ msgid "" "doesn't import a ``__main__.py`` file but rather whichever module that " "received the special name ``'__main__'``." msgstr "" +"Python プログラムをどのモジュールから起動したかにかかわらず、同じプログラム内" +"の他のモジュールは、``__main__`` モジュールをインポートすることでトップレベル" +"環境のスコープ (:term:`名前空間 `) をインポートできます。\n" +"これは ``__main__.py`` というファイルのインポートではなく、特別な名前 " +"``'__main__'`` が割り当てられたモジュールのインポートです。" -#: ../../library/__main__.rst:282 msgid "Here is an example module that consumes the ``__main__`` namespace::" -msgstr "" +msgstr "``__main__`` の名前空間を利用するモジュールの例を示します。 ::" -#: ../../library/__main__.rst:284 msgid "" "# namely.py\n" "\n" @@ -503,12 +594,22 @@ msgid "" "\n" " print(__main__.my_name)" msgstr "" +"# namely.py\n" +"\n" +"import __main__\n" +"\n" +"def did_user_define_their_name():\n" +" return 'my_name' in dir(__main__)\n" +"\n" +"def print_user_name():\n" +" if not did_user_define_their_name():\n" +" raise ValueError('Define the variable `my_name`!')\n" +"\n" +" print(__main__.my_name)" -#: ../../library/__main__.rst:297 msgid "Example usage of this module could be as follows::" -msgstr "" +msgstr "このモジュールは、例えば次のように使えます。 ::" -#: ../../library/__main__.rst:299 msgid "" "# start.py\n" "\n" @@ -527,39 +628,60 @@ msgid "" "if __name__ == \"__main__\":\n" " sys.exit(main())" msgstr "" +"# start.py\n" +"\n" +"import sys\n" +"\n" +"from namely import print_user_name\n" +"\n" +"# my_name = \"Dinsdale\"\n" +"\n" +"def main():\n" +" try:\n" +" print_user_name()\n" +" except ValueError as ve:\n" +" return str(ve)\n" +"\n" +"if __name__ == \"__main__\":\n" +" sys.exit(main())" -#: ../../library/__main__.rst:316 msgid "Now, if we started our program, the result would look like this:" -msgstr "" +msgstr "このプログラムを起動すると、次のような結果になります。" -#: ../../library/__main__.rst:318 msgid "" "$ python start.py\n" "Define the variable `my_name`!" msgstr "" +"$ python start.py\n" +"Define the variable `my_name`!" -#: ../../library/__main__.rst:323 msgid "" "The exit code of the program would be 1, indicating an error. Uncommenting " "the line with ``my_name = \"Dinsdale\"`` fixes the program and now it exits " "with status code 0, indicating success:" msgstr "" +"プログラムの終了コードは、エラーを示す 1 になります。\n" +"``my_name = \"Dinsdale\"`` の行のコメントを外すとプログラムは正しく動作し、成" +"功を示す終了コード 0 で終了します。" -#: ../../library/__main__.rst:327 msgid "" "$ python start.py\n" "Dinsdale" msgstr "" +"$ python start.py\n" +"Dinsdale" -#: ../../library/__main__.rst:332 msgid "" "Note that importing ``__main__`` doesn't cause any issues with " "unintentionally running top-level code meant for script use which is put in " "the ``if __name__ == \"__main__\"`` block of the ``start`` module. Why does " "this work?" msgstr "" +"``__main__`` をインポートしても、``start`` モジュールの ``if __name__ == " +"\"__main__\"`` ブロックにある、スクリプト用のトップレベルコードが意図せず実行" +"されることはありません。\n" +"なぜこのように動作するのでしょうか。" -#: ../../library/__main__.rst:336 msgid "" "Python inserts an empty ``__main__`` module in :data:`sys.modules` at " "interpreter startup, and populates it by running top-level code. In our " @@ -571,14 +693,24 @@ msgid "" "` in the import system's reference for details on how " "this works." msgstr "" +"Python はインタープリタの起動時に空の ``__main__`` モジュールを :data:`sys." +"modules` に追加し、トップレベルコードを実行してその内容を埋めていきます。\n" +"この例では、``start`` モジュールが一行ずつ実行され、``namely`` をインポートし" +"ます。\n" +"今度は ``namely`` が ``__main__`` (実体は ``start``) をインポートするので、循" +"環インポートになります。\n" +"しかし、内容が部分的に埋まった ``__main__`` モジュールが :data:`sys.modules` " +"にあるため、Python はそれを ``namely`` に渡せます。\n" +"詳しい仕組みは、インポートシステムのリファレンスの :ref:`__main__ に関する特" +"別な考慮事項 ` を参照してください。" -#: ../../library/__main__.rst:345 msgid "" "The Python REPL is another example of a \"top-level environment\", so " "anything defined in the REPL becomes part of the ``__main__`` scope::" msgstr "" +"Python の REPL も「トップレベル環境」の一例なので、REPL で定義したものはすべ" +"て ``__main__`` のスコープの一部になります。 ::" -#: ../../library/__main__.rst:348 msgid "" ">>> import namely\n" ">>> namely.did_user_define_their_name()\n" @@ -593,9 +725,22 @@ msgid "" ">>> namely.print_user_name()\n" "Jabberwocky" msgstr "" +">>> import namely\n" +">>> namely.did_user_define_their_name()\n" +"False\n" +">>> namely.print_user_name()\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Define the variable `my_name`!\n" +">>> my_name = 'Jabberwocky'\n" +">>> namely.did_user_define_their_name()\n" +"True\n" +">>> namely.print_user_name()\n" +"Jabberwocky" -#: ../../library/__main__.rst:361 msgid "" "The ``__main__`` scope is used in the implementation of :mod:`pdb` and :mod:" "`rlcompleter`." msgstr "" +"``__main__`` のスコープは、:mod:`pdb` と :mod:`rlcompleter` の実装で使われて" +"います。" diff --git a/library/_thread.po b/library/_thread.po index 5fe2e5c85..a370ab56c 100644 --- a/library/_thread.po +++ b/library/_thread.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/_thread.rst:2 @@ -74,59 +74,70 @@ msgstr "" msgid "When the function returns, the thread silently exits." msgstr "関数が戻るとき、スレッドは静かに終了します。" -#: ../../library/_thread.rst:47 msgid "" "When the function terminates with an unhandled exception, :func:`sys." "unraisablehook` is called to handle the exception. The *object* attribute of " "the hook argument is *function*. By default, a stack trace is printed and " "then the thread exits (but other threads continue to run)." msgstr "" +"処理されない例外によって関数が終了すると、例外を処理するために :func:`sys." +"unraisablehook` が呼び出されます。\n" +"フックに渡される引数の ``object`` 属性は ``function`` です。\n" +"デフォルトではスタックトレースを表示してスレッドを終了します (他のスレッドは" +"実行を続けます)。" -#: ../../library/_thread.rst:52 msgid "" "When the function raises a :exc:`SystemExit` exception, it is silently " "ignored." msgstr "" +"関数が :exc:`SystemExit` 例外を送出した場合は、何も表示せずに無視します。" -#: ../../library/_thread.rst:55 msgid "" "Raises an :ref:`auditing event ` ``_thread.start_new_thread`` with " "arguments ``function``, ``args``, ``kwargs``." msgstr "" +"引数 ``function``、``args``、``kwargs`` を指定して、:ref:`監査イベント " +"` ``_thread.start_new_thread`` を発生させます。" -#: ../../library/_thread.rst:57 msgid ":func:`sys.unraisablehook` is now used to handle unhandled exceptions." msgstr "" +"処理されない例外を扱うために :func:`sys.unraisablehook` を使うようになりまし" +"た。" -#: ../../library/_thread.rst:63 msgid "" "Simulate the effect of a signal arriving in the main thread. A thread can " "use this function to interrupt the main thread, though there is no guarantee " "that the interruption will happen immediately." msgstr "" +"メインスレッドにシグナルが届いたときの効果を模倣します。\n" +"スレッドはこの関数でメインスレッドに割り込めますが、即座に割り込む保証はあり" +"ません。" -#: ../../library/_thread.rst:67 msgid "" "If given, *signum* is the number of the signal to simulate. If *signum* is " "not given, :const:`signal.SIGINT` is simulated." msgstr "" +"``signum`` を指定した場合は、模倣するシグナルの番号になります。\n" +"``signum`` を指定しない場合は、:const:`signal.SIGINT` を模倣します。" -#: ../../library/_thread.rst:70 msgid "" "If the given signal isn't handled by Python (it was set to :const:`signal." "SIG_DFL` or :const:`signal.SIG_IGN`), this function does nothing." msgstr "" +"指定したシグナルを Python が処理しない場合 (:const:`signal.SIG_DFL` または :" +"const:`signal.SIG_IGN` に設定されている場合)、この関数は何もしません。" -#: ../../library/_thread.rst:74 msgid "The *signum* argument is added to customize the signal number." -msgstr "" +msgstr "シグナル番号を変更できるよう、``signum`` 引数が追加されました。" -#: ../../library/_thread.rst:78 msgid "" "This does not emit the corresponding signal but schedules a call to the " "associated handler (if it exists). If you want to truly emit the signal, " "use :func:`signal.raise_signal`." msgstr "" +"この関数は実際にシグナルを発生させるのではなく、対応するハンドラーがあれば、" +"その呼び出しを予約します。\n" +"実際にシグナルを発生させるには :func:`signal.raise_signal` を使ってください。" #: ../../library/_thread.rst:85 msgid "" @@ -157,25 +168,25 @@ msgstr "" "な、マジッククッキーとして意図されています。スレッドが終了し、他のスレッドが" "作られたとき、スレッド ID は再利用されるかもしれません。" -#: ../../library/_thread.rst:113 msgid "" "Return the native integral Thread ID of the current thread assigned by the " "kernel. This is a non-negative integer. Its value may be used to uniquely " "identify this particular thread system-wide (until the thread terminates, " "after which the value may be recycled by the OS)." msgstr "" +"カーネルが割り当てた、現在のスレッドのネイティブなスレッド ID を返します。\n" +"これは非負の整数です。\n" +"この値で、システム全体においてこのスレッドを一意に識別できます (スレッドが終" +"了するまでで、その後は OS が値を再利用することがあります)。" -#: ../../library/_thread.rst:118 ../../library/_thread.rst:146 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/_thread.rst:122 msgid "Added support for GNU/kFreeBSD." -msgstr "" +msgstr "GNU/kFreeBSD のサポートが追加されました。" -#: ../../library/_thread.rst:125 msgid "Added support for Solaris." -msgstr "" +msgstr "Solaris のサポートが追加されました。" #: ../../library/_thread.rst:131 msgid "" @@ -210,16 +221,17 @@ msgstr "" "トフォームに関する情報がない場合は 4096 の整数倍のスタックサイズを選ぶといい" "かもしれません)。" -#: ../../library/_thread.rst:148 msgid "Unix platforms with POSIX threads support." -msgstr "" +msgstr "POSIX スレッドをサポートする Unix プラットフォーム。" -#: ../../library/_thread.rst:153 msgid "" "The maximum value allowed for the *timeout* parameter of :meth:`Lock.acquire " "`. Specifying a timeout greater than this value will " "raise an :exc:`OverflowError`." msgstr "" +":meth:`Lock.acquire ` の ``timeout`` パラメーターに指" +"定できる最大値です。\n" +"この値を超えるタイムアウトを指定すると :exc:`OverflowError` が送出されます。" #: ../../library/_thread.rst:169 msgid "This is the type of lock objects." @@ -241,13 +253,15 @@ msgstr "" "ている場合には解除されるまで待ってからロックを獲得します (同時にロックを獲得" "できるスレッドはひとつだけであり、これこそがロックの存在理由です)。" -#: ../../library/_thread.rst:179 msgid "" "If the *blocking* argument is present, the action depends on its value: if " "it is false, the lock is only acquired if it can be acquired immediately " "without waiting, while if it is true, the lock is acquired unconditionally " "as above." msgstr "" +"``blocking`` 引数を指定した場合、動作はその値によって変わります。\n" +"偽なら、待たずにすぐ獲得できる場合だけロックを獲得します。\n" +"真なら、上で説明したように無条件にロックを獲得します。" #: ../../library/_thread.rst:184 msgid "" @@ -273,9 +287,8 @@ msgstr "新しい *timeout* 引数。" msgid "Lock acquires can now be interrupted by signals on POSIX." msgstr "POSIX ではロックの取得がシグナルに割り込まれるようになりました。" -#: ../../library/_thread.rst:198 msgid "Lock acquires can now be interrupted by signals on Windows." -msgstr "" +msgstr "Windows でのロックの獲得をシグナルで中断できるようになりました。" #: ../../library/_thread.rst:203 msgid "" @@ -285,13 +298,13 @@ msgstr "" "ロックを解放します。そのロックは既に獲得されたものでなければなりませんが、し" "かし同じスレッドによって獲得されたものである必要はありません。" -#: ../../library/_thread.rst:208 msgid "" "Return the status of the lock: ``True`` if it has been acquired by some " "thread, ``False`` if not." msgstr "" -"ロックの状態を返します: 同じスレッドによって獲得されたものなら ``True`` 、違" -"うのなら ``False`` を返します。" +"ロックの状態を返します。\n" +"いずれかのスレッドがロックを獲得していれば ``True``、そうでなければ " +"``False`` を返します。" #: ../../library/_thread.rst:211 msgid "" @@ -301,7 +314,6 @@ msgstr "" "これらのメソッドに加えて、ロックオブジェクトは :keyword:`with` 文を通じて以下" "の例のように使うこともできます。 ::" -#: ../../library/_thread.rst:214 msgid "" "import _thread\n" "\n" @@ -310,16 +322,23 @@ msgid "" "with a_lock:\n" " print(\"a_lock is locked while this executes\")" msgstr "" +"import _thread\n" +"\n" +"a_lock = _thread.allocate_lock()\n" +"\n" +"with a_lock:\n" +" print(\"a_lock is locked while this executes\")" #: ../../library/_thread.rst:221 msgid "**Caveats:**" msgstr "**警告:**" -#: ../../library/_thread.rst:225 msgid "" "Interrupts always go to the main thread (the :exc:`KeyboardInterrupt` " "exception will be received by that thread.)" msgstr "" +"割り込みは常にメインスレッドに届きます (:exc:`KeyboardInterrupt` 例外を受け取" +"るのはこのスレッドです)。" #: ../../library/_thread.rst:228 msgid "" diff --git a/library/abc.po b/library/abc.po index cb0db1bf6..4a3cb0ee7 100644 --- a/library/abc.po +++ b/library/abc.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: 甲斐 智丈, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/abc.rst:2 @@ -53,10 +53,10 @@ msgid "" "term:`hashable` or if it is a :term:`mapping`." msgstr "" ":mod:`collections` モジュール には、抽象基底クラス から派生するいくつかの具象" -"クラスがある。もちろん、これらはさらに派生させることができる。さらに、:mod:" -"`collections.抽象基底クラス` サブモジュールには、クラスやインスタンス が特定" -"のインターフェース 、たとえば 、:term:`hashable`であるか、:term:`mapping`であ" -"るかをテストするために使用できる抽象基底クラス があります。" +"クラスがある。もちろん、これらはさらに派生させることができる。さらに、 :mod:" +"`collections.abc` サブモジュールには、クラスやインスタンス が特定のインター" +"フェース 、たとえば 、 :term:`hashable` であるか、 :term:`mapping` であるかを" +"テストするために使用できる抽象基底クラス があります。" #: ../../library/abc.rst:23 msgid "" @@ -77,15 +77,17 @@ msgstr "" "ことで、:class:`!ABC` を継承するだけで抽象基底クラスを作成でき、しばしば混乱" "しがちなメタクラスの使用を避けることができます。例えば::" -#: ../../library/abc.rst:32 msgid "" "from abc import ABC\n" "\n" "class MyABC(ABC):\n" " pass" msgstr "" +"from abc import ABC\n" +"\n" +"class MyABC(ABC):\n" +" pass" -#: ../../library/abc.rst:37 msgid "" "Note that the type of :class:`!ABC` is still :class:`ABCMeta`, therefore " "inheriting from :class:`!ABC` requires the usual precautions regarding " @@ -93,14 +95,22 @@ msgid "" "One may also define an abstract base class by passing the metaclass keyword " "and using :class:`!ABCMeta` directly, for example::" msgstr "" +":class:`!ABC` の型は :class:`ABCMeta` なので、:class:`!ABC` を継承する場合" +"も、メタクラスを使う際の通常の注意が必要です。\n" +"多重継承ではメタクラスが競合する場合があります。\n" +"また、``metaclass`` キーワードに :class:`!ABCMeta` を直接指定して、抽象基底ク" +"ラスを定義することもできます。 ::" -#: ../../library/abc.rst:43 msgid "" "from abc import ABCMeta\n" "\n" "class MyABC(metaclass=ABCMeta):\n" " pass" msgstr "" +"from abc import ABCMeta\n" +"\n" +"class MyABC(metaclass=ABCMeta):\n" +" pass" #: ../../library/abc.rst:53 msgid "Metaclass for defining Abstract Base Classes (ABCs)." @@ -125,11 +135,10 @@ msgstr "" "Resolution Order, メソッド解決順)には現れませんし、この ABC のメソッド実装が" "(:func:`super` を通してだけでなく)呼び出し可能になるわけでもありません。 [#]_" -#: ../../library/abc.rst:64 msgid "" "Classes created with a metaclass of :class:`!ABCMeta` have the following " "method:" -msgstr "" +msgstr "メタクラスが :class:`!ABCMeta` のクラスには、次のメソッドがあります。" #: ../../library/abc.rst:68 msgid "" @@ -137,7 +146,6 @@ msgid "" msgstr "" "*subclass* を \"仮想的サブクラス\" としてこの ABC に登録します。たとえば::" -#: ../../library/abc.rst:71 msgid "" "from abc import ABC\n" "\n" @@ -149,6 +157,15 @@ msgid "" "assert issubclass(tuple, MyABC)\n" "assert isinstance((), MyABC)" msgstr "" +"from abc import ABC\n" +"\n" +"class MyABC(ABC):\n" +" pass\n" +"\n" +"MyABC.register(tuple)\n" +"\n" +"assert issubclass(tuple, MyABC)\n" +"assert isinstance((), MyABC)" #: ../../library/abc.rst:81 msgid "Returns the registered subclass, to allow usage as a class decorator." @@ -156,11 +173,12 @@ msgstr "" "クラスデコレータとして使うことができるように、登録されたサブクラスを返しま" "す。" -#: ../../library/abc.rst:84 msgid "" "To detect calls to :meth:`!register`, you can use the :func:" "`get_cache_token` function." msgstr "" +":meth:`!register` の呼び出しを検出するには、:func:`get_cache_token` 関数を使" +"えます。" #: ../../library/abc.rst:88 msgid "You can also override this method in an abstract base class:" @@ -170,7 +188,6 @@ msgstr "また、次のメソッドを抽象基底クラスの中でオーバー msgid "(Must be defined as a class method.)" msgstr "(クラスメソッドとして定義しなければなりません。)" -#: ../../library/abc.rst:94 msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of :func:`issubclass` further without " @@ -178,8 +195,13 @@ msgid "" "subclass of the ABC. (This class method is called from the :meth:`~type." "__subclasscheck__` method of the ABC.)" msgstr "" +"``subclass`` がこの ABC のサブクラスとみなされるか調べます。\n" +"このメソッドで :func:`issubclass` の動作をさらにカスタマイズすれば、ABC のサ" +"ブクラスとみなしたいクラスごとに :meth:`register` を呼ぶ必要がなくなりま" +"す。\n" +"(このクラスメソッドは、ABC の :meth:`~type.__subclasscheck__` メソッドから呼" +"び出されます。)" -#: ../../library/abc.rst:100 msgid "" "This method should return ``True``, ``False`` or :data:`NotImplemented`. If " "it returns ``True``, the *subclass* is considered a subclass of this ABC. If " @@ -187,13 +209,18 @@ msgid "" "ABC, even if it would normally be one. If it returns :data:`!" "NotImplemented`, the subclass check is continued with the usual mechanism." msgstr "" +"このメソッドは ``True``、``False``、:data:`NotImplemented` のいずれかを返す必" +"要があります。\n" +"``True`` を返すと、``subclass`` はこの ABC のサブクラスとみなされます。\n" +"``False`` を返すと、通常ならサブクラスであっても、``subclass`` はこの ABC の" +"サブクラスとはみなされません。\n" +":data:`!NotImplemented` を返すと、通常の仕組みでサブクラスの検査を続けます。" #: ../../library/abc.rst:110 msgid "" "For a demonstration of these concepts, look at this example ABC definition::" msgstr "この概念のデモとして、次の ABC 定義の例を見てください::" -#: ../../library/abc.rst:112 msgid "" "class Foo:\n" " def __getitem__(self, index):\n" @@ -222,8 +249,33 @@ msgid "" "\n" "MyIterable.register(Foo)" msgstr "" +"class Foo:\n" +" def __getitem__(self, index):\n" +" ...\n" +" def __len__(self):\n" +" ...\n" +" def get_iterator(self):\n" +" return iter(self)\n" +"\n" +"class MyIterable(ABC):\n" +"\n" +" @abstractmethod\n" +" def __iter__(self):\n" +" while False:\n" +" yield None\n" +"\n" +" def get_iterator(self):\n" +" return self.__iter__()\n" +"\n" +" @classmethod\n" +" def __subclasshook__(cls, C):\n" +" if cls is MyIterable:\n" +" if any(\"__iter__\" in B.__dict__ for B in C.__mro__):\n" +" return True\n" +" return NotImplemented\n" +"\n" +"MyIterable.register(Foo)" -#: ../../library/abc.rst:139 msgid "" "The ABC ``MyIterable`` defines the standard iterable method, :meth:`~object." "__iter__`, as an abstract method. The implementation given here can still " @@ -231,16 +283,24 @@ msgid "" "the ``MyIterable`` abstract base class, but it does not have to be " "overridden in non-abstract derived classes." msgstr "" +"ABC ``MyIterable`` は、イテラブルの標準的なメソッド :meth:`~object.__iter__` " +"を抽象メソッドとして定義しています。\n" +"ここで定義した実装は、サブクラスから呼び出すこともできます。\n" +":meth:`!get_iterator` メソッドも抽象基底クラス ``MyIterable`` の一部ですが、" +"抽象クラスではない派生クラスでオーバーライドする必要はありません。" -#: ../../library/abc.rst:145 msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " "that has an :meth:`~object.__iter__` method in its :attr:`~object.__dict__` " "(or in that of one of its base classes, accessed via the :attr:`~type." "__mro__` list) is considered a ``MyIterable`` too." msgstr "" +"ここで定義したクラスメソッド :meth:`__subclasshook__` は、:attr:`~object." +"__dict__` に :meth:`~object.__iter__` メソッドを持つクラスを ``MyIterable`` " +"とみなします。\n" +"また、:attr:`~type.__mro__` リストからたどれる基底クラスのいずれかがそのメ" +"ソッドを持つ場合も、同様にみなします。" -#: ../../library/abc.rst:150 msgid "" "Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, " "even though it does not define an :meth:`~object.__iter__` method (it uses " @@ -249,16 +309,20 @@ msgid "" "``get_iterator`` available as a method of ``Foo``, so it is provided " "separately." msgstr "" +"最後の行では、:meth:`~object.__iter__` メソッドを定義していない ``Foo`` も、" +"``MyIterable`` の仮想的サブクラスにしています (``Foo`` は :meth:`~object." +"__len__` と :meth:`~object.__getitem__` に基づく古いイテラブルプロトコルを" +"使っています)。\n" +"ただし、これによって ``get_iterator`` が ``Foo`` のメソッドとして使えるように" +"なるわけではないので、別途定義しています。" -#: ../../library/abc.rst:159 msgid "The :mod:`!abc` module also provides the following decorator:" -msgstr "" +msgstr ":mod:`!abc` モジュールは、次のデコレータも提供します。" #: ../../library/abc.rst:163 msgid "A decorator indicating abstract methods." msgstr "抽象メソッドを示すデコレータです。" -#: ../../library/abc.rst:165 msgid "" "Using this decorator requires that the class's metaclass is :class:`ABCMeta` " "or is derived from it. A class that has a metaclass derived from :class:`!" @@ -267,8 +331,14 @@ msgid "" "the normal 'super' call mechanisms. :deco:`!abstractmethod` may be used to " "declare abstract methods for properties and descriptors." msgstr "" +"このデコレータを使うには、クラスのメタクラスが :class:`ABCMeta` またはその派" +"生クラスである必要があります。\n" +"メタクラスが :class:`!ABCMeta` から派生しているクラスは、すべての抽象メソッド" +"と抽象プロパティがオーバーライドされるまで、インスタンス化できません。\n" +"抽象メソッドは、通常の super 呼び出しの仕組みで呼び出せます。\n" +":deco:`!abstractmethod` は、プロパティやデスクリプタの抽象メソッドを宣言する" +"ためにも使えます。" -#: ../../library/abc.rst:172 msgid "" "Dynamically adding abstract methods to a class, or attempting to modify the " "abstraction status of a method or class once it is created, are only " @@ -277,15 +347,22 @@ msgid "" "\"virtual subclasses\" registered with the ABC's :meth:`~ABCMeta.register` " "method are not affected." msgstr "" +"クラスへの抽象メソッドの動的な追加や、作成済みのメソッドやクラスが抽象である" +"かどうかの変更は、:func:`update_abstractmethods` 関数を使う場合にのみサポート" +"されます。\n" +":deco:`!abstractmethod` が影響するのは、通常の継承によるサブクラスだけで" +"す。\n" +"ABC の :meth:`~ABCMeta.register` メソッドで登録された「仮想的サブクラス」には" +"影響しません。" -#: ../../library/abc.rst:179 msgid "" "When :deco:`!abstractmethod` is applied in combination with other method " "descriptors, it should be applied as the innermost decorator, as shown in " "the following usage examples::" msgstr "" +":deco:`!abstractmethod` を他のメソッドデスクリプタと組み合わせる場合は、次の" +"例のように最も内側のデコレータとして適用してください。 ::" -#: ../../library/abc.rst:183 msgid "" "class C(ABC):\n" " @abstractmethod\n" @@ -317,8 +394,36 @@ msgid "" " ...\n" " x = property(_get_x, _set_x)" msgstr "" +"class C(ABC):\n" +" @abstractmethod\n" +" def my_abstract_method(self, arg1):\n" +" ...\n" +" @classmethod\n" +" @abstractmethod\n" +" def my_abstract_classmethod(cls, arg2):\n" +" ...\n" +" @staticmethod\n" +" @abstractmethod\n" +" def my_abstract_staticmethod(arg3):\n" +" ...\n" +"\n" +" @property\n" +" @abstractmethod\n" +" def my_abstract_property(self):\n" +" ...\n" +" @my_abstract_property.setter\n" +" @abstractmethod\n" +" def my_abstract_property(self, val):\n" +" ...\n" +"\n" +" @abstractmethod\n" +" def _get_x(self):\n" +" ...\n" +" @abstractmethod\n" +" def _set_x(self, val):\n" +" ...\n" +" x = property(_get_x, _set_x)" -#: ../../library/abc.rst:213 msgid "" "In order to correctly interoperate with the abstract base class machinery, " "the descriptor must identify itself as abstract using :attr:`!" @@ -326,8 +431,12 @@ msgid "" "of the methods used to compose the descriptor are abstract. For example, " "Python's built-in :deco:`property` does the equivalent of::" msgstr "" +"抽象基底クラスの仕組みと正しく連携するには、デスクリプタが抽象であることを :" +"attr:`!__isabstractmethod__` で示す必要があります。\n" +"一般に、デスクリプタを構成するメソッドのいずれかが抽象なら、この属性を " +"``True`` にするべきです。\n" +"例えば、Python の組み込み :deco:`property` は次と同等の処理を行います。 ::" -#: ../../library/abc.rst:219 msgid "" "class Descriptor:\n" " ...\n" @@ -336,6 +445,12 @@ msgid "" " return any(getattr(f, '__isabstractmethod__', False) for\n" " f in (self._fget, self._fset, self._fdel))" msgstr "" +"class Descriptor:\n" +" ...\n" +" @property\n" +" def __isabstractmethod__(self):\n" +" return any(getattr(f, '__isabstractmethod__', False) for\n" +" f in (self._fget, self._fset, self._fdel))" #: ../../library/abc.rst:228 msgid "" @@ -350,29 +465,31 @@ msgstr "" "ことができます。これは協調的多重継承を使ったフレームワークにおいて super 呼び" "出しの終点として有効です。" -#: ../../library/abc.rst:235 msgid "The :mod:`!abc` module also supports the following legacy decorators:" -msgstr "" +msgstr ":mod:`!abc` モジュールは、次の古いデコレータもサポートしています。" -#: ../../library/abc.rst:240 msgid "" "It is now possible to use :deco:`classmethod` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" +":deco:`classmethod` と :deco:`abstractmethod` を組み合わせて使えるようになっ" +"たため、このデコレータは不要になりました。" -#: ../../library/abc.rst:244 msgid "" "A subclass of the built-in :class:`classmethod`, indicating an abstract " "classmethod. Otherwise it is similar to :deco:`abstractmethod`." msgstr "" +"抽象クラスメソッドを表す、組み込みの :class:`classmethod` のサブクラスで" +"す。\n" +"それ以外の点では :deco:`abstractmethod` と同様です。" -#: ../../library/abc.rst:247 msgid "" "This special case is deprecated, as the :deco:`classmethod` decorator is now " "correctly identified as abstract when applied to an abstract method::" msgstr "" +"抽象メソッドに :deco:`classmethod` デコレータを適用すれば、抽象であると正しく" +"認識されるようになったため、この特別なデコレータは非推奨です。 ::" -#: ../../library/abc.rst:251 msgid "" "class C(ABC):\n" " @classmethod\n" @@ -380,26 +497,33 @@ msgid "" " def my_abstract_classmethod(cls, arg):\n" " ..." msgstr "" +"class C(ABC):\n" +" @classmethod\n" +" @abstractmethod\n" +" def my_abstract_classmethod(cls, arg):\n" +" ..." -#: ../../library/abc.rst:261 msgid "" "It is now possible to use :deco:`staticmethod` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" +":deco:`staticmethod` と :deco:`abstractmethod` を組み合わせて使えるようになっ" +"たため、このデコレータは不要になりました。" -#: ../../library/abc.rst:265 msgid "" "A subclass of the built-in :class:`staticmethod`, indicating an abstract " "staticmethod. Otherwise it is similar to :deco:`abstractmethod`." msgstr "" +"抽象静的メソッドを表す、組み込みの :class:`staticmethod` のサブクラスです。\n" +"それ以外の点では :deco:`abstractmethod` と同様です。" -#: ../../library/abc.rst:268 msgid "" "This special case is deprecated, as the :deco:`staticmethod` decorator is " "now correctly identified as abstract when applied to an abstract method::" msgstr "" +"抽象メソッドに :deco:`staticmethod` デコレータを適用すれば、抽象であると正し" +"く認識されるようになったため、この特別なデコレータは非推奨です。 ::" -#: ../../library/abc.rst:272 msgid "" "class C(ABC):\n" " @staticmethod\n" @@ -407,27 +531,33 @@ msgid "" " def my_abstract_staticmethod(arg):\n" " ..." msgstr "" +"class C(ABC):\n" +" @staticmethod\n" +" @abstractmethod\n" +" def my_abstract_staticmethod(arg):\n" +" ..." -#: ../../library/abc.rst:281 msgid "" "It is now possible to use :deco:`property`, :deco:`property.getter`, :deco:" "`property.setter` and :deco:`property.deleter` with :deco:`abstractmethod`, " "making this decorator redundant." msgstr "" +":deco:`property`、:deco:`property.getter`、:deco:`property.setter`、:deco:" +"`property.deleter` を :deco:`abstractmethod` と組み合わせて使えるようになった" +"ため、このデコレータは不要になりました。" -#: ../../library/abc.rst:286 msgid "" "A subclass of the built-in :class:`property`, indicating an abstract " "property." -msgstr "" +msgstr "抽象プロパティを表す、組み込みの :class:`property` のサブクラスです。" -#: ../../library/abc.rst:289 msgid "" "This special case is deprecated, as the :deco:`property` decorator is now " "correctly identified as abstract when applied to an abstract method::" msgstr "" +"抽象メソッドに :deco:`property` デコレータを適用すれば、抽象であると正しく認" +"識されるようになったため、この特別なデコレータは非推奨です。 ::" -#: ../../library/abc.rst:293 msgid "" "class C(ABC):\n" " @property\n" @@ -435,6 +565,11 @@ msgid "" " def my_abstract_property(self):\n" " ..." msgstr "" +"class C(ABC):\n" +" @property\n" +" @abstractmethod\n" +" def my_abstract_property(self):\n" +" ..." #: ../../library/abc.rst:299 msgid "" @@ -446,7 +581,6 @@ msgstr "" "ドの1つ以上を abstract にすることで、読み書きできる抽象プロパティを定義するこ" "とができます::" -#: ../../library/abc.rst:303 msgid "" "class C(ABC):\n" " @property\n" @@ -458,6 +592,15 @@ msgid "" " def x(self, val):\n" " ..." msgstr "" +"class C(ABC):\n" +" @property\n" +" def x(self):\n" +" ...\n" +"\n" +" @x.setter\n" +" @abstractmethod\n" +" def x(self, val):\n" +" ..." #: ../../library/abc.rst:313 msgid "" @@ -467,17 +610,19 @@ msgstr "" "構成するメソッド全てが abstract でない場合、abstract と定義されたメソッドのみ" "が、具象サブクラスによってオーバーライドする必要があります::" -#: ../../library/abc.rst:316 msgid "" "class D(C):\n" " @C.x.setter\n" " def x(self, val):\n" " ..." msgstr "" +"class D(C):\n" +" @C.x.setter\n" +" def x(self, val):\n" +" ..." -#: ../../library/abc.rst:322 msgid "The :mod:`!abc` module also provides the following functions:" -msgstr "" +msgstr ":mod:`!abc` モジュールは、次の関数も提供します。" #: ../../library/abc.rst:326 msgid "Returns the current abstract base class cache token." @@ -494,27 +639,30 @@ msgstr "" "任意のABCでの :meth:`ABCMeta.register` の呼び出しごとに、トークンは変更されま" "す。" -#: ../../library/abc.rst:336 msgid "" "A function to recalculate an abstract class's abstraction status. This " "function should be called if a class's abstract methods have been " "implemented or changed after it was created. Usually, this function should " "be called from within a class decorator." msgstr "" +"抽象クラスが抽象であるかどうかを再計算する関数です。\n" +"クラスを作成した後で、その抽象メソッドを実装したり変更したりした場合に呼び出" +"してください。\n" +"通常はクラスデコレータの中から呼び出します。" -#: ../../library/abc.rst:341 msgid "Returns *cls*, to allow usage as a class decorator." -msgstr "" +msgstr "クラスデコレータとして使えるように、``cls`` を返します。" -#: ../../library/abc.rst:343 msgid "If *cls* is not an instance of :class:`ABCMeta`, does nothing." -msgstr "" +msgstr "``cls`` が :class:`ABCMeta` のインスタンスでなければ、何もしません。" -#: ../../library/abc.rst:347 msgid "" "This function assumes that *cls*'s superclasses are already updated. It does " "not update any subclasses." msgstr "" +"この関数は、``cls`` のスーパークラスがすでに更新されていることを前提としま" +"す。\n" +"サブクラスの更新は行いません。" #: ../../library/abc.rst:353 msgid "Footnotes" diff --git a/library/aifc.po b/library/aifc.po index 4942c005a..44f1142a1 100644 --- a/library/aifc.po +++ b/library/aifc.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/aifc.rst:2 msgid ":mod:`!aifc` --- Read and write AIFF and AIFC files" -msgstr "" +msgstr ":mod:`!aifc` --- AIFF および AIFC ファイルの読み書き" #: ../../library/aifc.rst:10 msgid "" @@ -36,8 +35,9 @@ msgstr "" "ルは Python 3.11 で非推奨となったあと、:ref:`Python 3.13 で削除` されました。削除の決定は :pep:`594` でなされました。" -#: ../../library/aifc.rst:14 msgid "" "The last version of Python that provided the :mod:`!aifc` module was `Python " "3.12 `_." msgstr "" +":mod:`!aifc` モジュールを提供していた最後の Python バージョンは、`Python " +"3.12 `_ です。" diff --git a/library/allos.po b/library/allos.po index 6845185d2..ed5e593ee 100644 --- a/library/allos.po +++ b/library/allos.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/allos.rst:5 diff --git a/library/annotationlib.po b/library/annotationlib.po index a4bad3581..29c5fa42d 100644 --- a/library/annotationlib.po +++ b/library/annotationlib.po @@ -16,27 +16,25 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/annotationlib.rst:2 msgid ":mod:`!annotationlib` --- Functionality for introspecting annotations" -msgstr "" +msgstr ":mod:`!annotationlib` --- アノテーションを調べるための機能" -#: ../../library/annotationlib.rst:9 msgid "**Source code:** :source:`Lib/annotationlib.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/annotationlib.py`" -#: ../../library/annotationlib.rst:18 msgid "" "The :mod:`!annotationlib` module provides tools for introspecting :term:" "`annotations ` on modules, classes, and functions." msgstr "" +":mod:`!annotationlib` モジュールは、モジュール、クラス、関数の :term:`アノ" +"テーション ` を調べるためのツールを提供します。" -#: ../../library/annotationlib.rst:21 msgid "" "Annotations are :ref:`lazily evaluated ` and often contain " "forward references to objects that are not yet defined when the annotation " @@ -44,36 +42,47 @@ msgid "" "to retrieve annotations in a reliable way, even in the presence of forward " "references and other edge cases." msgstr "" +"アノテーションは :ref:`遅延評価 ` され、作成時にはまだ定義さ" +"れていないオブジェクトへの前方参照を含むことがよくあります。\n" +"このモジュールは、前方参照やその他の特殊な場合があっても、アノテーションを確" +"実に取得するための低水準のツール群を提供します。" -#: ../../library/annotationlib.rst:26 msgid "" "This module supports retrieving annotations in three main formats (see :" "class:`Format`), each of which works best for different use cases:" msgstr "" +"このモジュールは、アノテーションを取得するための三つの主要な形式をサポートし" +"ます (:class:`Format` を参照)。\n" +"それぞれ適した用途が異なります。" -#: ../../library/annotationlib.rst:29 msgid "" ":attr:`~Format.VALUE` evaluates the annotations and returns their value. " "This is most straightforward to work with, but it may raise errors, for " "example if the annotations contain references to undefined names." msgstr "" +":attr:`~Format.VALUE` は、アノテーションを評価してその値を返します。\n" +"最も直接的に扱える形式ですが、未定義の名前を参照するアノテーションなどでは、" +"エラーが発生する場合があります。" -#: ../../library/annotationlib.rst:32 msgid "" ":attr:`~Format.FORWARDREF` returns :class:`ForwardRef` objects for " "annotations that cannot be resolved, allowing you to inspect the annotations " "without evaluating them. This is useful when you need to work with " "annotations that may contain unresolved forward references." msgstr "" +":attr:`~Format.FORWARDREF` は、解決できないアノテーションに対して :class:" +"`ForwardRef` オブジェクトを返すので、それらを評価せずに調べられます。\n" +"未解決の前方参照を含む可能性のあるアノテーションを扱う場合に便利です。" -#: ../../library/annotationlib.rst:36 msgid "" ":attr:`~Format.STRING` returns the annotations as a string, similar to how " "it would appear in the source file. This is useful for documentation " "generators that want to display annotations in a readable way." msgstr "" +":attr:`~Format.STRING` は、ソースファイルでの表記に近い文字列としてアノテー" +"ションを返します。\n" +"アノテーションを読みやすく表示するドキュメント生成ツールなどに便利です。" -#: ../../library/annotationlib.rst:40 msgid "" "The :func:`get_annotations` function is the main entry point for retrieving " "annotations. Given a function, class, or module, it returns an annotations " @@ -83,72 +92,88 @@ msgid "" "func:`call_annotate_function`, as well as the :func:`call_evaluate_function` " "function for working with :term:`evaluate functions `." msgstr "" +"アノテーションを取得する主な入口は :func:`get_annotations` 関数です。\n" +"関数、クラス、モジュールを渡すと、指定した形式のアノテーション辞書を返しま" +"す。\n" +"このモジュールには、アノテーションの評価に使う :term:`annotate 関数 " +"` を直接扱う :func:`get_annotate_from_class_namespace` " +"や :func:`call_annotate_function`、および :term:`evaluate 関数 ` を扱う :func:`call_evaluate_function` もあります。" -#: ../../library/annotationlib.rst:51 msgid "" "Most functionality in this module can execute arbitrary code; see :ref:`the " "security section ` for more information." msgstr "" +"このモジュールの大半の機能では、任意のコードが実行される可能性があります。\n" +"詳しくは :ref:`セキュリティの節 ` を参照してくださ" +"い。" -#: ../../library/annotationlib.rst:56 msgid "" ":pep:`649` proposed the current model for how annotations work in Python." msgstr "" +"現在の Python のアノテーションの動作モデルは :pep:`649` で提案されました。" -#: ../../library/annotationlib.rst:58 msgid "" ":pep:`749` expanded on various aspects of :pep:`649` and introduced the :mod:" "`!annotationlib` module." msgstr "" +":pep:`749` は :pep:`649` のさまざまな側面を詳しく規定し、:mod:`!" +"annotationlib` モジュールを導入しました。" -#: ../../library/annotationlib.rst:61 msgid "" ":ref:`annotations-howto` provides best practices for working with " "annotations." msgstr "" +"アノテーションを扱う際の推奨方法は :ref:`annotations-howto` を参照してくださ" +"い。" -#: ../../library/annotationlib.rst:64 msgid "" ":pypi:`typing-extensions` provides a backport of :func:`get_annotations` " "that works on earlier versions of Python." msgstr "" +":pypi:`typing-extensions` は、以前の Python バージョンでも使える :func:" +"`get_annotations` のバックポートを提供します。" -#: ../../library/annotationlib.rst:68 msgid "Annotation semantics" -msgstr "" +msgstr "アノテーションの意味論" -#: ../../library/annotationlib.rst:70 msgid "" "The way annotations are evaluated has changed over the history of Python 3, " "and currently still depends on a :ref:`future import `. There have " "been execution models for annotations:" msgstr "" +"Python 3 の歴史の中で、アノテーションの評価方法は変化してきました。\n" +"現在も :ref:`future インポート ` によって動作が変わります。\n" +"これまで、次の実行モデルが使われてきました。" -#: ../../library/annotationlib.rst:74 msgid "" "*Stock semantics* (default in Python 3.0 through 3.13; see :pep:`3107` and :" "pep:`526`): Annotations are evaluated eagerly, as they are encountered in " "the source code." msgstr "" +"*従来の意味論* (Python 3.0 から 3.13 までのデフォルト。:pep:`3107` と :pep:" +"`526` を参照): ソースコード内でアノテーションに到達した時点で、即座に評価しま" +"す。" -#: ../../library/annotationlib.rst:77 msgid "" "*Stringified annotations* (used with ``from __future__ import annotations`` " "in Python 3.7 and newer; see :pep:`563`): Annotations are stored as strings " "only." msgstr "" +"*文字列化されたアノテーション* (Python 3.7 以降で ``from __future__ import " +"annotations`` を使った場合。:pep:`563` を参照): アノテーションを文字列として" +"のみ保存します。" -#: ../../library/annotationlib.rst:80 msgid "" "*Deferred evaluation* (default in Python 3.14 and newer; see :pep:`649` and :" "pep:`749`): Annotations are evaluated lazily, only when they are accessed." msgstr "" +"*遅延評価* (Python 3.14 以降のデフォルト。:pep:`649` と :pep:`749` を参照): " +"アノテーションにアクセスしたときに初めて評価します。" -#: ../../library/annotationlib.rst:83 msgid "As an example, consider the following program::" -msgstr "" +msgstr "例として、次のプログラムを考えます。 ::" -#: ../../library/annotationlib.rst:85 msgid "" "def func(a: Cls) -> None:\n" " print(a)\n" @@ -157,31 +182,39 @@ msgid "" "\n" "print(func.__annotations__)" msgstr "" +"def func(a: Cls) -> None:\n" +" print(a)\n" +"\n" +"class Cls: pass\n" +"\n" +"print(func.__annotations__)" -#: ../../library/annotationlib.rst:92 msgid "This will behave as follows:" -msgstr "" +msgstr "動作は次のようになります。" -#: ../../library/annotationlib.rst:94 msgid "" "Under stock semantics (Python 3.13 and earlier), it will throw a :exc:" "`NameError` at the line where ``func`` is defined, because ``Cls`` is an " "undefined name at that point." msgstr "" +"従来の意味論 (Python 3.13 以前) では、``func`` を定義する行で :exc:" +"`NameError` が送出されます。\n" +"その時点では ``Cls`` が未定義だからです。" -#: ../../library/annotationlib.rst:97 msgid "" "Under stringified annotations (if ``from __future__ import annotations`` is " "used), it will print ``{'a': 'Cls', 'return': 'None'}``." msgstr "" +"文字列化されたアノテーション (``from __future__ import annotations`` を使った" +"場合) では、``{'a': 'Cls', 'return': 'None'}`` が表示されます。" -#: ../../library/annotationlib.rst:99 msgid "" "Under deferred evaluation (Python 3.14 and later), it will print ``{'a': " ", 'return': None}``." msgstr "" +"遅延評価 (Python 3.14 以降) では、``{'a': , 'return': None}`` が" +"表示されます。" -#: ../../library/annotationlib.rst:102 msgid "" "Stock semantics were used when function annotations were first introduced in " "Python 3.0 (by :pep:`3107`) because this was the simplest, most obvious way " @@ -201,24 +234,42 @@ msgid "" "__future__ import annotations`` is present, but this behavior will " "eventually be removed." msgstr "" +"Python 3.0 で関数のアノテーションが初めて導入されたとき (:pep:`3107`)、実装方" +"法として最も単純で分かりやすかったため、従来の意味論が採用されました。\n" +"Python 3.6 で変数のアノテーションが導入されたとき (:pep:`526`) も、同じ実行モ" +"デルが使われました。\n" +"しかし、アノテーションを型ヒントとして使うと、アノテーションに到達した時点で" +"はまだ定義されていない名前を参照したい場合などに、問題が生じました。\n" +"また、モジュールのインポート時にアノテーションを評価することには、性能上の問" +"題もありました。\n" +"そのため、Python 3.7 では :pep:`563` により、``from __future__ import " +"annotations`` という構文でアノテーションを文字列として保存する機能が導入され" +"ました。\n" +"当初は将来この動作をデフォルトにする予定でしたが、実行時にアノテーションを調" +"べる用途では、文字列化されたアノテーションを処理しにくいという問題が現れまし" +"た。\n" +"代案の :pep:`649` は、三つ目の実行モデルである遅延評価を導入し、Python 3.14 " +"に実装されました。\n" +"``from __future__ import annotations`` がある場合は今も文字列化されたアノテー" +"ションが使われますが、この動作はいずれ削除される予定です。" #: ../../library/annotationlib.rst:121 msgid "Classes" msgstr "クラス" -#: ../../library/annotationlib.rst:125 msgid "" "An :class:`~enum.IntEnum` describing the formats in which annotations can be " "returned. Members of the enum, or their equivalent integer values, can be " "passed to :func:`get_annotations` and other functions in this module, as " "well as to :attr:`~object.__annotate__` functions." msgstr "" +"アノテーションを返す形式を表す :class:`~enum.IntEnum` です。\n" +"列挙型のメンバーまたは対応する整数値を、:func:`get_annotations` などのこのモ" +"ジュールの関数や、:attr:`~object.__annotate__` 関数に渡せます。" -#: ../../library/annotationlib.rst:133 msgid "Values are the result of evaluating the annotation expressions." -msgstr "" +msgstr "値は、アノテーションの式を評価した結果です。" -#: ../../library/annotationlib.rst:138 msgid "" "Special value used to signal that an annotate function is being evaluated in " "a special environment with fake globals. When passed this value, annotate " @@ -227,50 +278,63 @@ msgid "" "not support execution in this environment. This format is only used " "internally and should not be passed to the functions in this module." msgstr "" +"annotate 関数が、仮のグローバル名前空間を持つ特別な環境で評価されていることを" +"示す特別な値です。\n" +"この値を渡された annotate 関数は、:attr:`Format.VALUE` 形式と同じ値を返すか、" +"この環境での実行をサポートしないことを示す :exc:`NotImplementedError` を送出" +"する必要があります。\n" +"この形式は内部でのみ使われ、このモジュールの関数に渡すべきではありません。" -#: ../../library/annotationlib.rst:149 msgid "" "Values are real annotation values (as per :attr:`Format.VALUE` format) for " "defined values, and :class:`ForwardRef` proxies for undefined values. Real " "objects may contain references to :class:`ForwardRef` proxy objects." msgstr "" +"定義済みの値には実際のアノテーションの値 (:attr:`Format.VALUE` 形式と同じ)、" +"未定義の値には :class:`ForwardRef` プロキシを使います。\n" +"実際のオブジェクトが :class:`ForwardRef` プロキシオブジェクトへの参照を含むこ" +"ともあります。" -#: ../../library/annotationlib.rst:157 msgid "" "Values are the text string of the annotation as it appears in the source " "code, up to modifications including, but not restricted to, whitespace " "normalizations and constant values optimizations." msgstr "" +"値は、ソースコード内のアノテーションの表記を文字列にしたものです。\n" +"ただし、空白の正規化や定数値の最適化などの変更が加わる場合があり、変更はこれ" +"らに限りません。" -#: ../../library/annotationlib.rst:161 msgid "" "The exact values of these strings may change in future versions of Python." msgstr "" +"これらの文字列の厳密な値は、将来の Python バージョンで変わる可能性がありま" +"す。" -#: ../../library/annotationlib.rst:167 msgid "A proxy object for forward references in annotations." -msgstr "" +msgstr "アノテーションの前方参照を表すプロキシオブジェクトです。" -#: ../../library/annotationlib.rst:169 msgid "" "Instances of this class are returned when the :attr:`~Format.FORWARDREF` " "format is used and annotations contain a name that cannot be resolved. This " "can happen when a forward reference is used in an annotation, such as when a " "class is referenced before it is defined." msgstr "" +":attr:`~Format.FORWARDREF` 形式を使い、アノテーションに解決できない名前が含ま" +"れている場合、このクラスのインスタンスが返されます。\n" +"例えば、定義前のクラスを参照するなど、アノテーションが前方参照を含む場合に起" +"こります。" -#: ../../library/annotationlib.rst:176 msgid "" "A string containing the code that was evaluated to produce the :class:" "`~ForwardRef`. The string may not be exactly equivalent to the original " "source." msgstr "" +":class:`~ForwardRef` を生成するために評価されたコードを含む文字列です。\n" +"元のソースコードと完全には一致しない場合があります。" -#: ../../library/annotationlib.rst:182 msgid "Evaluate the forward reference, returning its value." -msgstr "" +msgstr "前方参照を評価し、その値を返します。" -#: ../../library/annotationlib.rst:184 msgid "" "If the *format* argument is :attr:`~Format.VALUE` (the default), this method " "may throw an exception, such as :exc:`NameError`, if the forward reference " @@ -284,16 +348,31 @@ msgid "" "``list[ForwardRef('undefined')]``. If the *format* argument is :attr:" "`~Format.STRING`, the method will return :attr:`~ForwardRef.__forward_arg__`." msgstr "" +"``format`` 引数が :attr:`~Format.VALUE` (デフォルト) の場合、前方参照が解決で" +"きない名前を参照していると、:exc:`NameError` などの例外が送出されることがあり" +"ます。\n" +"このメソッドの引数を使うと、そうしなければ未定義となる名前に値を束縛できま" +"す。\n" +"``format`` 引数が :attr:`~Format.FORWARDREF` の場合、メソッドは例外を送出せ" +"ず、:class:`~ForwardRef` インスタンスを返すことがあります。\n" +"例えば、前方参照オブジェクトが ``list[undefined]`` というコードを含み、" +"``undefined`` が未定義の名前である場合、:attr:`~Format.FORWARDREF` 形式で評価" +"すると ``list[ForwardRef('undefined')]`` を返します。\n" +"``format`` 引数が :attr:`~Format.STRING` の場合は、:attr:`~ForwardRef." +"__forward_arg__` を返します。" -#: ../../library/annotationlib.rst:196 msgid "" "The *owner* parameter provides the preferred mechanism for passing scope " "information to this method. The owner of a :class:`~ForwardRef` is the " "object that contains the annotation from which the :class:`~ForwardRef` " "derives, such as a module object, type object, or function object." msgstr "" +"このメソッドにスコープの情報を渡すには、``owner`` パラメーターを使う方法を推" +"奨します。\n" +":class:`~ForwardRef` の所有者は、その :class:`~ForwardRef` の元となったアノ" +"テーションを含むオブジェクトです。\n" +"モジュールオブジェクト、型オブジェクト、関数オブジェクトなどが該当します。" -#: ../../library/annotationlib.rst:201 msgid "" "The *globals*, *locals*, and *type_params* parameters provide a more precise " "mechanism for influencing the names that are available when the :class:" @@ -307,8 +386,19 @@ msgid "" "an annotation found in the class namespace of a generic class ``C``, " "*type_params* should be set to ``C.__type_params__``." msgstr "" +"``globals``、``locals``、``type_params`` パラメーターを使うと、:class:" +"`~ForwardRef` の評価時に利用できる名前をより細かく制御できます。\n" +"``globals`` と ``locals`` は :func:`eval` に渡され、名前を評価するグローバル" +"名前空間とローカル名前空間を表します。\n" +"``type_params`` は、:ref:`ジェネリッククラス ` や :ref:`ジェ" +"ネリック関数 ` の専用構文で作成されたオブジェクトに関係し" +"ます。\n" +"前方参照の評価時にスコープ内にある :ref:`型パラメーター ` のタプ" +"ルです。\n" +"例えば、ジェネリッククラス ``C`` のクラス名前空間にあるアノテーションから取得" +"した :class:`~ForwardRef` を評価する場合、``type_params`` に ``C." +"__type_params__`` を指定してください。" -#: ../../library/annotationlib.rst:212 msgid "" ":class:`~ForwardRef` instances returned by :func:`get_annotations` retain " "references to information about the scope they originated from, so calling " @@ -317,19 +407,26 @@ msgid "" "any information about their scope, so passing arguments to this method may " "be necessary to evaluate them successfully." msgstr "" +":func:`get_annotations` が返す :class:`~ForwardRef` インスタンスは、元のス" +"コープの情報への参照を保持します。\n" +"そのため、追加の引数を指定せずにこのメソッドを呼ぶだけで、評価できる場合があ" +"ります。\n" +"他の方法で作った :class:`~ForwardRef` インスタンスにはスコープの情報がない場" +"合があるため、正しく評価するには引数を渡す必要があるかもしれません。" -#: ../../library/annotationlib.rst:219 msgid "" "If no *owner*, *globals*, *locals*, or *type_params* are provided and the :" "class:`~ForwardRef` does not contain information about its origin, empty " "globals and locals dictionaries are used." msgstr "" +"``owner``、``globals``、``locals``、``type_params`` をどれも指定せず、:class:" +"`~ForwardRef` に元のスコープの情報がない場合、グローバルとローカルの名前空間" +"には空の辞書を使います。" #: ../../library/annotationlib.rst:227 msgid "Functions" msgstr "関数" -#: ../../library/annotationlib.rst:231 msgid "" "Convert an annotations dict containing runtime values to a dict containing " "only strings. If the values are not already strings, they are converted " @@ -337,29 +434,39 @@ msgid "" "annotate functions that support the :attr:`~Format.STRING` format but do not " "have access to the code creating the annotations." msgstr "" +"実行時の値を含むアノテーション辞書を、文字列だけを含む辞書に変換します。\n" +"値がまだ文字列でなければ、:func:`type_repr` で変換します。\n" +"これは、:attr:`~Format.STRING` 形式をサポートするものの、アノテーションを作成" +"したコードにはアクセスできない、ユーザー定義の annotate 関数を補助するための" +"関数です。" -#: ../../library/annotationlib.rst:238 msgid "" "For example, this is used to implement the :attr:`~Format.STRING` format " "for :class:`typing.TypedDict` classes created through the functional syntax:" msgstr "" +"例えば、関数形式の構文で作成した :class:`typing.TypedDict` クラスの :attr:" +"`~Format.STRING` 形式は、この関数で実装されています。" -#: ../../library/annotationlib.rst:241 msgid "" ">>> from typing import TypedDict\n" ">>> Movie = TypedDict(\"movie\", {\"name\": str, \"year\": int})\n" ">>> get_annotations(Movie, format=Format.STRING)\n" "{'name': 'str', 'year': 'int'}" msgstr "" +">>> from typing import TypedDict\n" +">>> Movie = TypedDict(\"movie\", {\"name\": str, \"year\": int})\n" +">>> get_annotations(Movie, format=Format.STRING)\n" +"{'name': 'str', 'year': 'int'}" -#: ../../library/annotationlib.rst:252 msgid "" "Call the :term:`annotate function` *annotate* with the given *format*, a " "member of the :class:`Format` enum, and return the annotations dictionary " "produced by the function." msgstr "" +":term:`annotate 関数 ` ``annotate`` を、:class:`Format` 列" +"挙型のメンバーである ``format`` を指定して呼び出し、その関数が生成したアノ" +"テーション辞書を返します。" -#: ../../library/annotationlib.rst:256 msgid "" "This helper function is required because annotate functions generated by the " "compiler for functions, classes, and modules only support the :attr:`~Format." @@ -369,22 +476,32 @@ msgid "" "when implementing functionality that needs to partially evaluate annotations " "while a class is being constructed." msgstr "" +"関数、クラス、モジュールのためにコンパイラが生成する annotate 関数は、直接呼" +"び出した場合には :attr:`~Format.VALUE` 形式しかサポートしないため、この補助関" +"数が必要です。\n" +"他の形式をサポートするため、この関数は特別な環境で annotate 関数を呼び出し、" +"それらの形式のアノテーションを生成できるようにします。\n" +"クラスの作成途中でアノテーションを部分的に評価する機能を実装する際に役立ちま" +"す。" -#: ../../library/annotationlib.rst:265 msgid "" "*owner* is the object that owns the annotation function, usually a function, " "class, or module. If provided, it is used in the :attr:`~Format.FORWARDREF` " "format to produce a :class:`ForwardRef` object that carries more information." msgstr "" +"``owner`` はアノテーション関数を所有するオブジェクトで、通常は関数、クラス、" +"モジュールのいずれかです。\n" +"指定すると、:attr:`~Format.FORWARDREF` 形式で、より多くの情報を持つ :class:" +"`ForwardRef` オブジェクトを生成するために使われます。" -#: ../../library/annotationlib.rst:272 msgid "" ":PEP:`PEP 649 <649#the-stringizer-and-the-fake-globals-environment>` " "contains an explanation of the implementation technique used by this " "function." msgstr "" +"この関数で使われている実装手法は、:PEP:`PEP 649 <649#the-stringizer-and-the-" +"fake-globals-environment>` で説明されています。" -#: ../../library/annotationlib.rst:280 msgid "" "Call the :term:`evaluate function` *evaluate* with the given *format*, a " "member of the :class:`Format` enum, and return the value produced by the " @@ -392,56 +509,57 @@ msgid "" "always returns a dictionary mapping strings to annotations, while this " "function returns a single value." msgstr "" +":term:`evaluate 関数 ` ``evaluate`` を、:class:`Format` 列" +"挙型のメンバーである ``format`` を指定して呼び出し、その関数が生成した値を返" +"します。\n" +":func:`call_annotate_function` と似ていますが、そちらは常に文字列をアノテー" +"ションに対応付ける辞書を返すのに対し、この関数は一つの値を返します。" -#: ../../library/annotationlib.rst:286 msgid "" "This is intended for use with the evaluate functions generated for lazily " "evaluated elements related to type aliases and type parameters:" msgstr "" +"この関数は、型エイリアスや型パラメーターに関係する、遅延評価される要素のため" +"に生成された evaluate 関数で使うことを想定しています。" -#: ../../library/annotationlib.rst:289 msgid ":meth:`typing.TypeAliasType.evaluate_value`, the value of type aliases" -msgstr "" +msgstr ":meth:`typing.TypeAliasType.evaluate_value`: 型エイリアスの値" -#: ../../library/annotationlib.rst:290 msgid ":meth:`typing.TypeVar.evaluate_bound`, the bound of type variables" -msgstr "" +msgstr ":meth:`typing.TypeVar.evaluate_bound`: 型変数の上限" -#: ../../library/annotationlib.rst:291 msgid "" ":meth:`typing.TypeVar.evaluate_constraints`, the constraints of type " "variables" -msgstr "" +msgstr ":meth:`typing.TypeVar.evaluate_constraints`: 型変数の制約" -#: ../../library/annotationlib.rst:293 msgid "" ":meth:`typing.TypeVar.evaluate_default`, the default value of type variables" -msgstr "" +msgstr ":meth:`typing.TypeVar.evaluate_default`: 型変数のデフォルト値" -#: ../../library/annotationlib.rst:295 msgid "" ":meth:`typing.ParamSpec.evaluate_default`, the default value of parameter " "specifications" msgstr "" +":meth:`typing.ParamSpec.evaluate_default`: パラメーター仕様のデフォルト値" -#: ../../library/annotationlib.rst:297 msgid "" ":meth:`typing.TypeVarTuple.evaluate_default`, the default value of type " "variable tuples" msgstr "" +":meth:`typing.TypeVarTuple.evaluate_default`: 型変数タプルのデフォルト値" -#: ../../library/annotationlib.rst:300 msgid "" "*owner* is the object that owns the evaluate function, such as the type " "alias or type variable object." msgstr "" +"``owner`` は evaluate 関数を所有するオブジェクトです。\n" +"型エイリアスや型変数のオブジェクトなどが該当します。" -#: ../../library/annotationlib.rst:303 msgid "" "*format* can be used to control the format in which the value is returned:" -msgstr "" +msgstr "``format`` で、値を返す形式を制御できます。" -#: ../../library/annotationlib.rst:305 msgid "" ">>> type Alias = undefined\n" ">>> call_evaluate_function(Alias.evaluate_value, Format.VALUE)\n" @@ -453,8 +571,16 @@ msgid "" ">>> call_evaluate_function(Alias.evaluate_value, Format.STRING)\n" "'undefined'" msgstr "" +">>> type Alias = undefined\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.VALUE)\n" +"Traceback (most recent call last):\n" +"...\n" +"NameError: name 'undefined' is not defined\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.FORWARDREF)\n" +"ForwardRef('undefined')\n" +">>> call_evaluate_function(Alias.evaluate_value, Format.STRING)\n" +"'undefined'" -#: ../../library/annotationlib.rst:321 msgid "" "Retrieve the :term:`annotate function` from a class namespace dictionary " "*namespace*. Return :const:`!None` if the namespace does not contain an " @@ -463,40 +589,55 @@ msgid "" "function can be retrieved with ``cls.__annotate__``. See :ref:`below " "` for an example using this function in a metaclass." msgstr "" +"クラスの名前空間辞書 ``namespace`` から :term:`annotate 関数 ` を取得します。\n" +"名前空間に annotate 関数がなければ :const:`!None` を返します。\n" +"主に、クラスの作成が完了する前 (メタクラス内など) に役立ちます。\n" +"クラスができた後は、``cls.__annotate__`` で annotate 関数を取得できます。\n" +"メタクラスでこの関数を使う例は :ref:`後述 ` します。" #: ../../library/annotationlib.rst:331 msgid "Compute the annotations dict for an object." msgstr "オブジェクトに対するアノテーション辞書を計算します。" -#: ../../library/annotationlib.rst:333 msgid "" "*obj* may be a callable, class, module, or other object with :attr:`~object." "__annotate__` or :attr:`~object.__annotations__` attributes. Passing any " "other object raises :exc:`TypeError`." msgstr "" +"``obj`` には、呼び出し可能オブジェクト、クラス、モジュール、または :attr:" +"`~object.__annotate__` 属性か :attr:`~object.__annotations__` 属性を持つ他の" +"オブジェクトを指定できます。\n" +"それ以外のオブジェクトを渡すと :exc:`TypeError` が送出されます。" -#: ../../library/annotationlib.rst:337 msgid "" "The *format* parameter controls the format in which annotations are " "returned, and must be a member of the :class:`Format` enum or its integer " "equivalent. The different formats work as follows:" msgstr "" +"``format`` パラメーターはアノテーションを返す形式を制御し、:class:`Format` 列" +"挙型のメンバーまたは対応する整数値を指定する必要があります。\n" +"各形式の動作は次のとおりです。" -#: ../../library/annotationlib.rst:341 msgid "" "VALUE: :attr:`!object.__annotations__` is tried first; if that does not " "exist, the :attr:`!object.__annotate__` function is called if it exists." msgstr "" +"VALUE: まず :attr:`!object.__annotations__` を試します。\n" +"それがなければ、:attr:`!object.__annotate__` 関数があれば呼び出します。" -#: ../../library/annotationlib.rst:344 msgid "" "FORWARDREF: If :attr:`!object.__annotations__` exists and can be evaluated " "successfully, it is used; otherwise, the :attr:`!object.__annotate__` " "function is called. If it does not exist either, :attr:`!object." "__annotations__` is tried again and any error from accessing it is re-raised." msgstr "" +"FORWARDREF: :attr:`!object.__annotations__` があり、正常に評価できればそれを" +"使います。\n" +"そうでなければ :attr:`!object.__annotate__` 関数を呼び出します。\n" +"その関数もない場合は、再び :attr:`!object.__annotations__` を試し、アクセス時" +"のエラーを再送出します。" -#: ../../library/annotationlib.rst:349 msgid "" "When calling :attr:`!object.__annotate__` it is first called with :attr:" "`~Format.FORWARDREF`. If this is not implemented, it will then check if :" @@ -505,15 +646,22 @@ msgid "" "back to using :attr:`~Format.VALUE`. If :attr:`~Format.VALUE` fails, the " "error from this call will be raised." msgstr "" +":attr:`!object.__annotate__` は、まず :attr:`~Format.FORWARDREF` を指定して呼" +"び出します。\n" +"その形式が実装されていなければ、:attr:`~Format.VALUE_WITH_FAKE_GLOBALS` のサ" +"ポートを確認し、仮のグローバル名前空間を持つ環境で使います。\n" +"どちらの形式もサポートされていなければ、:attr:`~Format.VALUE` を使います。\n" +":attr:`~Format.VALUE` での呼び出しが失敗した場合は、そのエラーを送出します。" -#: ../../library/annotationlib.rst:355 msgid "" "STRING: If :attr:`!object.__annotate__` exists, it is called first; " "otherwise, :attr:`!object.__annotations__` is used and stringified using :" "func:`annotations_to_string`." msgstr "" +"STRING: :attr:`!object.__annotate__` があれば、まずそれを呼び出します。\n" +"なければ :attr:`!object.__annotations__` を使い、:func:" +"`annotations_to_string` で文字列化します。" -#: ../../library/annotationlib.rst:359 msgid "" "When calling :attr:`!object.__annotate__` it is first called with :attr:" "`~Format.STRING`. If this is not implemented, it will then check if :attr:" @@ -523,115 +671,157 @@ msgid "" "`annotations_to_string`. If :attr:`~Format.VALUE` fails, the error from this " "call will be raised." msgstr "" +":attr:`!object.__annotate__` は、まず :attr:`~Format.STRING` を指定して呼び出" +"します。\n" +"その形式が実装されていなければ、:attr:`~Format.VALUE_WITH_FAKE_GLOBALS` のサ" +"ポートを確認し、仮のグローバル名前空間を持つ環境で使います。\n" +"どちらの形式もサポートされていなければ、:attr:`~Format.VALUE` を使い、その結" +"果を :func:`annotations_to_string` で変換します。\n" +":attr:`~Format.VALUE` での呼び出しが失敗した場合は、そのエラーを送出します。" -#: ../../library/annotationlib.rst:366 msgid "" "Returns a dict. :func:`!get_annotations` returns a new dict every time it's " "called; calling it twice on the same object will return two different but " "equivalent dicts." msgstr "" +"辞書を返します。\n" +":func:`!get_annotations` は呼び出すたびに新しい辞書を返します。\n" +"同じオブジェクトに対して 2 回呼び出すと、内容は同じでも別々の辞書が返されま" +"す。" -#: ../../library/annotationlib.rst:370 msgid "This function handles several details for you:" -msgstr "" +msgstr "この関数は、次の細部も処理します。" -#: ../../library/annotationlib.rst:372 msgid "" "If *eval_str* is true, values of type :class:`!str` will be un-stringized " "using :func:`eval`. This is intended for use with stringized annotations " "(``from __future__ import annotations``). It is an error to set *eval_str* " "to true with formats other than :attr:`Format.VALUE`." msgstr "" +"``eval_str`` が真の場合、:class:`!str` 型の値を :func:`eval` で評価し、文字列" +"化される前の値に戻します。\n" +"これは、文字列化されたアノテーション (``from __future__ import " +"annotations``) で使うことを想定しています。\n" +":attr:`Format.VALUE` 以外の形式で ``eval_str`` を真にすると、エラーになりま" +"す。" -#: ../../library/annotationlib.rst:377 msgid "" "If *obj* doesn't have an annotations dict, returns an empty dict. (Functions " "and methods always have an annotations dict; classes, modules, and other " "types of callables may not.)" msgstr "" +"``obj`` にアノテーション辞書がなければ、空の辞書を返します。\n" +"(関数とメソッドには常にアノテーション辞書がありますが、クラス、モジュール、他" +"の種類の呼び出し可能オブジェクトにはない場合があります。)" -#: ../../library/annotationlib.rst:381 msgid "" "Ignores inherited annotations on classes, as well as annotations on " "metaclasses. If a class doesn't have its own annotations dict, returns an " "empty dict." msgstr "" +"クラスが継承したアノテーションと、メタクラスのアノテーションは無視します。\n" +"クラス自体にアノテーション辞書がなければ、空の辞書を返します。" -#: ../../library/annotationlib.rst:384 msgid "" "All accesses to object members and dict values are done using ``getattr()`` " "and ``dict.get()`` for safety." msgstr "" +"安全のため、オブジェクトのメンバーと辞書の値へのアクセスには、すべて " +"``getattr()`` と ``dict.get()`` を使います。" -#: ../../library/annotationlib.rst:387 msgid "" "*eval_str* controls whether or not values of type :class:`!str` are replaced " "with the result of calling :func:`eval` on those values:" msgstr "" +"``eval_str`` は、:class:`!str` 型の値を、その値に対して :func:`eval` を呼び出" +"した結果に置き換えるかどうかを制御します。" -#: ../../library/annotationlib.rst:390 msgid "" "If eval_str is true, :func:`eval` is called on values of type :class:`!str`. " "(Note that :func:`!get_annotations` doesn't catch exceptions; if :func:" "`eval` raises an exception, it will unwind the stack past the :func:`!" "get_annotations` call.)" msgstr "" +"``eval_str`` が真の場合、:class:`!str` 型の値に対して :func:`eval` を呼び出し" +"ます。\n" +"(:func:`!get_annotations` は例外を捕捉しません。\n" +":func:`eval` が例外を送出すると、:func:`!get_annotations` の呼び出し元まで伝" +"播します。)" -#: ../../library/annotationlib.rst:394 msgid "" "If *eval_str* is false (the default), values of type :class:`!str` are " "unchanged." msgstr "" +"``eval_str`` が偽 (デフォルト) の場合、:class:`!str` 型の値は変更しません。" -#: ../../library/annotationlib.rst:397 msgid "" "*globals* and *locals* are passed in to :func:`eval`; see the documentation " "for :func:`eval` for more information. If *globals* or *locals* is :const:`!" "None`, this function may replace that value with a context-specific default, " "contingent on ``type(obj)``:" msgstr "" +"``globals`` と ``locals`` は :func:`eval` に渡されます。\n" +"詳しくは :func:`eval` のドキュメントを参照してください。\n" +"``globals`` または ``locals`` が :const:`!None` の場合、この関数は " +"``type(obj)`` に応じて、その値を文脈に適したデフォルト値に置き換えることがあ" +"ります。" -#: ../../library/annotationlib.rst:402 msgid "If *obj* is a module, *globals* defaults to ``obj.__dict__``." msgstr "" +"``obj`` がモジュールの場合、``globals`` のデフォルト値は ``obj.__dict__`` で" +"す。" -#: ../../library/annotationlib.rst:403 msgid "" "If *obj* is a class, *globals* defaults to ``sys.modules[obj.__module__]." "__dict__`` and *locals* defaults to the *obj* class namespace." msgstr "" +"``obj`` がクラスの場合、``globals`` のデフォルト値は ``sys.modules[obj." +"__module__].__dict__``、``locals`` のデフォルト値は ``obj`` のクラス名前空間" +"です。" -#: ../../library/annotationlib.rst:406 msgid "" "If *obj* is a callable, *globals* defaults to :attr:`obj.__globals__ " "`, although if *obj* is a wrapped function (using :" "func:`functools.update_wrapper`) or a :class:`functools.partial` object, it " "is unwrapped until a non-wrapped function is found." msgstr "" +"``obj`` が呼び出し可能オブジェクトの場合、``globals`` のデフォルト値は :attr:" +"`obj.__globals__ ` です。\n" +"ただし、``obj`` が (:func:`functools.update_wrapper` を使って) ラップされた関" +"数か :class:`functools.partial` オブジェクトの場合は、ラップされていない関数" +"が見つかるまでラッパーをたどって外します。" -#: ../../library/annotationlib.rst:412 msgid "" "Calling :func:`!get_annotations` is best practice for accessing the " "annotations dict of any object. See :ref:`annotations-howto` for more " "information on annotations best practices." msgstr "" +"オブジェクトのアノテーション辞書へのアクセスには、:func:`!get_annotations` の" +"呼び出しを推奨します。\n" +"アノテーションの推奨される扱い方については、:ref:`annotations-howto` を参照し" +"てください。" -#: ../../library/annotationlib.rst:416 msgid "" ">>> def f(a: int, b: str) -> float:\n" "... pass\n" ">>> get_annotations(f)\n" "{'a': , 'b': , 'return': }" msgstr "" +">>> def f(a: int, b: str) -> float:\n" +"... pass\n" +">>> get_annotations(f)\n" +"{'a': , 'b': , 'return': }" -#: ../../library/annotationlib.rst:427 msgid "" "Convert an arbitrary Python value to a format suitable for use by the :attr:" "`~Format.STRING` format. This calls :func:`repr` for most objects, but has " "special handling for some objects, such as type objects." msgstr "" +"任意の Python の値を、:attr:`~Format.STRING` 形式での使用に適した表現に変換し" +"ます。\n" +"大半のオブジェクトには :func:`repr` を呼び出しますが、型オブジェクトなど一部" +"のオブジェクトには特別な処理を行います。" -#: ../../library/annotationlib.rst:431 msgid "" "This is meant as a helper for user-provided annotate functions that support " "the :attr:`~Format.STRING` format but do not have access to the code " @@ -639,16 +829,19 @@ msgid "" "string representation for other objects that contain values that are " "commonly encountered in annotations." msgstr "" +"これは、:attr:`~Format.STRING` 形式をサポートするものの、アノテーションを作成" +"したコードにはアクセスできない、ユーザー定義の annotate 関数を補助するための" +"関数です。\n" +"アノテーションでよく使われる値を含む他のオブジェクトについても、読みやすい文" +"字列表現を提供するために使えます。" #: ../../library/annotationlib.rst:441 msgid "Recipes" msgstr "レシピ" -#: ../../library/annotationlib.rst:446 msgid "Using annotations in a metaclass" -msgstr "" +msgstr "メタクラスでのアノテーションの利用" -#: ../../library/annotationlib.rst:448 msgid "" "A :ref:`metaclass ` may want to inspect or even modify the " "annotations in a class body during class creation. Doing so requires " @@ -661,21 +854,33 @@ msgid "" "format will usually be best, because this allows the annotations to refer to " "names that cannot yet be resolved when the class is created." msgstr "" +":ref:`メタクラス ` では、クラスの作成中にクラス本体のアノテー" +"ションを調べたり変更したりしたい場合があります。\n" +"そのためには、クラスの名前空間辞書からアノテーションを取得する必要がありま" +"す。\n" +"``from __future__ import annotations`` を使って作成されたクラスでは、アノテー" +"ションは辞書の ``__annotations__`` キーにあります。\n" +"それ以外のアノテーションを持つクラスでは、:func:" +"`get_annotate_from_class_namespace` で annotate 関数を取得し、:func:" +"`call_annotate_function` で呼び出してアノテーションを取得できます。\n" +"クラスの作成時にはまだ解決できない名前をアノテーションで参照できるよう、通常" +"は :attr:`~Format.FORWARDREF` 形式を使うのが最適です。" -#: ../../library/annotationlib.rst:459 msgid "" "To modify the annotations, it is best to create a wrapper annotate function " "that calls the original annotate function, makes any necessary adjustments, " "and returns the result." msgstr "" +"アノテーションを変更するには、元の annotate 関数を呼び出して必要な調整を加" +"え、結果を返すラッパーの annotate 関数を作るのがよい方法です。" -#: ../../library/annotationlib.rst:463 msgid "" "Below is an example of a metaclass that filters out all :class:`typing." "ClassVar` annotations from the class and puts them in a separate attribute:" msgstr "" +"次の例は、クラスからすべての :class:`typing.ClassVar` アノテーションを取り出" +"し、別の属性に格納するメタクラスです。" -#: ../../library/annotationlib.rst:466 msgid "" "import annotationlib\n" "import typing\n" @@ -725,12 +930,55 @@ msgid "" "attribute\n" " return typ" msgstr "" +"import annotationlib\n" +"import typing\n" +"\n" +"class ClassVarSeparator(type):\n" +" def __new__(mcls, name, bases, ns):\n" +" if \"__annotations__\" in ns: # from __future__ import annotations\n" +" annotations = ns[\"__annotations__\"]\n" +" classvar_keys = {\n" +" key for key, value in annotations.items()\n" +" # 簡単にするため文字列を比較する。より堅牢な方法には\n" +" # annotationlib.ForwardRef.evaluate を使える\n" +" if value.startswith(\"ClassVar\")\n" +" }\n" +" classvars = {key: annotations[key] for key in classvar_keys}\n" +" ns[\"__annotations__\"] = {\n" +" key: value for key, value in annotations.items()\n" +" if key not in classvar_keys\n" +" }\n" +" wrapped_annotate = None\n" +" elif annotate := annotationlib.get_annotate_from_class_namespace(ns):\n" +" annotations = annotationlib.call_annotate_function(\n" +" annotate, format=annotationlib.Format.FORWARDREF\n" +" )\n" +" classvar_keys = {\n" +" key for key, value in annotations.items()\n" +" if typing.get_origin(value) is typing.ClassVar\n" +" }\n" +" classvars = {key: annotations[key] for key in classvar_keys}\n" +"\n" +" def wrapped_annotate(format):\n" +" annos = annotationlib.call_annotate_function(annotate, format, " +"owner=typ)\n" +" return {key: value for key, value in annos.items() if key not in " +"classvar_keys}\n" +"\n" +" else: # アノテーションなし\n" +" classvars = {}\n" +" wrapped_annotate = None\n" +" typ = super().__new__(mcls, name, bases, ns)\n" +"\n" +" if wrapped_annotate is not None:\n" +" # 元の __annotate__ を、ClassVar を取り除くラッパーで包む\n" +" typ.__annotate__ = wrapped_annotate\n" +" typ.classvars = classvars # ClassVar を別の属性に格納する\n" +" return typ" -#: ../../library/annotationlib.rst:514 msgid "Creating a custom callable annotate function" -msgstr "" +msgstr "独自の呼び出し可能オブジェクトによる annotate 関数の作成" -#: ../../library/annotationlib.rst:516 msgid "" "Custom :term:`annotate functions ` may be literal " "functions like those automatically generated for functions, classes, and " @@ -738,59 +986,77 @@ msgid "" "in which case any :term:`callable` can be used as an :term:`annotate " "function`." msgstr "" +"独自の :term:`annotate 関数 ` は、関数、クラス、モジュール" +"用に自動生成されるものと同じように、通常の関数で実装できます。\n" +"クラスによるカプセル化を使いたい場合には、任意の :term:`呼び出し可能オブジェ" +"クト ` を :term:`annotate 関数 ` として使えま" +"す。" -#: ../../library/annotationlib.rst:521 msgid "" "To provide the :attr:`~Format.VALUE`, :attr:`~Format.STRING`, or :attr:" "`~Format.FORWARDREF` formats directly, an :term:`annotate function` must " "provide the following attribute:" msgstr "" +":attr:`~Format.VALUE`、:attr:`~Format.STRING`、:attr:`~Format.FORWARDREF` 形" +"式を直接提供するには、:term:`annotate 関数 ` に次の属性が" +"必要です。" -#: ../../library/annotationlib.rst:525 msgid "" "A callable ``__call__`` with signature ``__call__(format, /) -> dict``, that " "does not raise a :exc:`NotImplementedError` when called with a supported " "format." msgstr "" +"``__call__(format, /) -> dict`` というシグネチャの呼び出し可能な " +"``__call__``。\n" +"サポートする形式を指定して呼び出した場合に、:exc:`NotImplementedError` を送出" +"しないもの。" -#: ../../library/annotationlib.rst:528 msgid "" "To provide the :attr:`~Format.VALUE_WITH_FAKE_GLOBALS` format, which is used " "to automatically generate :attr:`~Format.STRING` or :attr:`~Format." "FORWARDREF` if they are not supported directly, :term:`annotate functions " "` must provide the following attributes:" msgstr "" +":attr:`~Format.VALUE_WITH_FAKE_GLOBALS` 形式は、:attr:`~Format.STRING` や :" +"attr:`~Format.FORWARDREF` が直接サポートされていない場合に、それらを自動生成" +"するために使われます。\n" +"この形式を提供する :term:`annotate 関数 ` には、次の属性が" +"必要です。" -#: ../../library/annotationlib.rst:533 msgid "" "A callable ``__call__`` with signature ``__call__(format, /) -> dict``, that " "does not raise a :exc:`NotImplementedError` when called with :attr:`~Format." "VALUE_WITH_FAKE_GLOBALS`." msgstr "" +"``__call__(format, /) -> dict`` というシグネチャの呼び出し可能な " +"``__call__``。\n" +":attr:`~Format.VALUE_WITH_FAKE_GLOBALS` を指定して呼び出した場合に、:exc:" +"`NotImplementedError` を送出しないもの。" -#: ../../library/annotationlib.rst:536 msgid "" "A :ref:`code object ` ``__code__`` containing the compiled " "code for the annotate function." msgstr "" +"annotate 関数のコンパイル済みコードを含む :ref:`コードオブジェクト ` ``__code__``。" -#: ../../library/annotationlib.rst:538 msgid "" "Optional: A tuple of the function's positional defaults ``__defaults__``, if " "the function represented by ``__code__`` uses any positional defaults." msgstr "" +"任意: ``__code__`` が表す関数が位置引数のデフォルト値を使う場合、その値のタプ" +"ル ``__defaults__``。" -#: ../../library/annotationlib.rst:540 msgid "" "Optional: A dict of the function's keyword defaults ``__kwdefaults__``, if " "the function represented by ``__code__`` uses any keyword defaults." msgstr "" +"任意: ``__code__`` が表す関数がキーワード引数のデフォルト値を使う場合、その値" +"の辞書 ``__kwdefaults__``。" -#: ../../library/annotationlib.rst:542 msgid "Optional: All other :ref:`function attributes `." -msgstr "" +msgstr "任意: その他すべての :ref:`関数の属性 `。" -#: ../../library/annotationlib.rst:544 msgid "" "class Annotate:\n" " called_formats = []\n" @@ -814,21 +1080,42 @@ msgid "" " __builtins__ = {}\n" " __closure__ = None" msgstr "" +"class Annotate:\n" +" called_formats = []\n" +"\n" +" def __call__(self, format=None, /, *, _self=None):\n" +" # 仮のグローバル名前空間で呼ぶ場合、_self が実際の self の値、\n" +" # self が形式になる。\n" +" if _self is not None:\n" +" self, format = _self, self\n" +"\n" +" self.called_formats.append(format)\n" +" if format <= 2: # VALUE または VALUE_WITH_FAKE_GLOBALS\n" +" return {\"x\": MyType}\n" +" raise NotImplementedError\n" +"\n" +" __code__ = __call__.__code__\n" +" __defaults__ = (None,)\n" +" __kwdefaults__ = property(lambda self: dict(_self=self))\n" +"\n" +" __globals__ = {}\n" +" __builtins__ = {}\n" +" __closure__ = None" -#: ../../library/annotationlib.rst:568 msgid "This can then be called with:" -msgstr "" +msgstr "次のように呼び出せます。" -#: ../../library/annotationlib.rst:570 msgid "" ">>> from annotationlib import call_annotate_function, Format\n" ">>> call_annotate_function(Annotate(), format=Format.STRING)\n" "{'x': 'MyType'}" msgstr "" +">>> from annotationlib import call_annotate_function, Format\n" +">>> call_annotate_function(Annotate(), format=Format.STRING)\n" +"{'x': 'MyType'}" -#: ../../library/annotationlib.rst:576 msgid "Or used as the annotate function for an object:" -msgstr "" +msgstr "また、オブジェクトの annotate 関数としても使えます。" #: ../../library/annotationlib.rst:578 msgid "" @@ -840,25 +1127,29 @@ msgid "" "{'x': 'MyType'}" msgstr "" -#: ../../library/annotationlib.rst:589 msgid "Limitations of the ``STRING`` format" -msgstr "" +msgstr "``STRING`` 形式の制限" -#: ../../library/annotationlib.rst:591 msgid "" "The :attr:`~Format.STRING` format is meant to approximate the source code of " "the annotation, but the implementation strategy used means that it is not " "always possible to recover the exact source code." msgstr "" +":attr:`~Format.STRING` 形式は、アノテーションのソースコードに近い表現を生成す" +"るためのものです。\n" +"ただし、使用している実装手法のため、元のソースコードを完全に復元できるとは限" +"りません。" -#: ../../library/annotationlib.rst:595 msgid "" "First, the stringifier of course cannot recover any information that is not " "present in the compiled code, including comments, whitespace, " "parenthesization, and operations that get simplified by the compiler." msgstr "" +"第一に、文字列化の仕組みは、コンパイル済みコードに残っていない情報を復元でき" +"ません。\n" +"コメント、空白、括弧の付け方、コンパイラによって簡略化された演算などが該当し" +"ます。" -#: ../../library/annotationlib.rst:599 msgid "" "Second, the stringifier can intercept almost all operations that involve " "names looked up in some scope, but it cannot intercept operations that " @@ -867,8 +1158,14 @@ msgid "" "enough that it is possible to achieve arbitrary code execution even with no " "access to any globals or builtins. For example:" msgstr "" +"第二に、文字列化の仕組みは、スコープから検索した名前を含む演算のほとんどを横" +"取りできますが、定数だけを対象にした演算は横取りできません。\n" +"そのため、信頼できないコードに対して ``STRING`` 形式を要求することも安全では" +"ありません。\n" +"Python は十分に強力なので、グローバル名や組み込み名に一切アクセスしなくても、" +"任意のコードを実行できます。\n" +"例を示します。" -#: ../../library/annotationlib.rst:605 msgid "" ">>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__." "__builtins__[\"print\"](\"Hello world\")): pass\n" @@ -877,14 +1174,20 @@ msgid "" "Hello world\n" "{'x': 'None'}" msgstr "" +">>> def f(x: (1).__class__.__base__.__subclasses__()[-1].__init__." +"__builtins__[\"print\"](\"Hello world\")): pass\n" +"...\n" +">>> annotationlib.get_annotations(f, format=annotationlib.Format.STRING)\n" +"Hello world\n" +"{'x': 'None'}" -#: ../../library/annotationlib.rst:614 msgid "" "This particular example works as of the time of writing, but it relies on " "implementation details and is not guaranteed to work in the future." msgstr "" +"この例は執筆時点では動作しますが、実装の詳細に依存しており、将来も動作する保" +"証はありません。" -#: ../../library/annotationlib.rst:617 msgid "" "Among the different kinds of expressions that exist in Python, as " "represented by the :mod:`ast` module, some expressions are supported, " @@ -892,170 +1195,148 @@ msgid "" "code; others are unsupported, meaning that they may result in incorrect " "output or an error." msgstr "" +":mod:`ast` モジュールで表される Python のさまざまな式のうち、一部はサポートさ" +"れており、``STRING`` 形式で元のソースコードをおおむね復元できます。\n" +"その他の式はサポートされておらず、誤った出力やエラーを生じる場合があります。" -#: ../../library/annotationlib.rst:622 msgid "The following are supported (sometimes with caveats):" -msgstr "" +msgstr "次のものがサポートされています (一部には注意事項があります)。" -#: ../../library/annotationlib.rst:624 msgid ":class:`ast.BinOp`" -msgstr "" +msgstr ":class:`ast.BinOp`" -#: ../../library/annotationlib.rst:625 msgid ":class:`ast.UnaryOp`" -msgstr "" +msgstr ":class:`ast.UnaryOp`" -#: ../../library/annotationlib.rst:627 msgid "" ":class:`ast.Invert` (``~``), :class:`ast.UAdd` (``+``), and :class:`ast." "USub` (``-``) are supported" msgstr "" +":class:`ast.Invert` (``~``)、:class:`ast.UAdd` (``+``)、:class:`ast.USub` " +"(``-``) はサポートされています。" -#: ../../library/annotationlib.rst:628 msgid ":class:`ast.Not` (``not``) is not supported" -msgstr "" +msgstr ":class:`ast.Not` (``not``) はサポートされていません。" -#: ../../library/annotationlib.rst:630 msgid ":class:`ast.Dict` (except when using ``**`` unpacking)" -msgstr "" +msgstr ":class:`ast.Dict` (``**`` によるアンパックを使う場合を除く)" -#: ../../library/annotationlib.rst:631 msgid ":class:`ast.Set`" -msgstr "" +msgstr ":class:`ast.Set`" -#: ../../library/annotationlib.rst:632 msgid ":class:`ast.Compare`" -msgstr "" +msgstr ":class:`ast.Compare`" -#: ../../library/annotationlib.rst:634 msgid ":class:`ast.Eq` and :class:`ast.NotEq` are supported" -msgstr "" +msgstr ":class:`ast.Eq` と :class:`ast.NotEq` はサポートされています。" -#: ../../library/annotationlib.rst:635 msgid "" ":class:`ast.Lt`, :class:`ast.LtE`, :class:`ast.Gt`, and :class:`ast.GtE` are " "supported, but the operand may be flipped" msgstr "" +":class:`ast.Lt`、:class:`ast.LtE`、:class:`ast.Gt`、:class:`ast.GtE` はサポー" +"トされていますが、オペランドが入れ替わる場合があります。" -#: ../../library/annotationlib.rst:636 msgid "" ":class:`ast.Is`, :class:`ast.IsNot`, :class:`ast.In`, and :class:`ast.NotIn` " "are not supported" msgstr "" +":class:`ast.Is`、:class:`ast.IsNot`、:class:`ast.In`、:class:`ast.NotIn` はサ" +"ポートされていません。" -#: ../../library/annotationlib.rst:638 msgid ":class:`ast.Call` (except when using ``**`` unpacking)" -msgstr "" +msgstr ":class:`ast.Call` (``**`` によるアンパックを使う場合を除く)" -#: ../../library/annotationlib.rst:639 msgid "" ":class:`ast.Constant` (though not the exact representation of the constant; " "for example, escape sequences in strings are lost; hexadecimal numbers are " "converted to decimal)" msgstr "" +":class:`ast.Constant` (ただし、定数の厳密な表記は保持されません。例えば、文字" +"列内のエスケープシーケンスは失われ、16 進数は 10 進数に変換されます)" -#: ../../library/annotationlib.rst:641 msgid ":class:`ast.Attribute` (assuming the value is not a constant)" -msgstr "" +msgstr ":class:`ast.Attribute` (対象の値が定数ではない場合)" -#: ../../library/annotationlib.rst:642 msgid ":class:`ast.Subscript` (assuming the value is not a constant)" -msgstr "" +msgstr ":class:`ast.Subscript` (対象の値が定数ではない場合)" -#: ../../library/annotationlib.rst:643 msgid ":class:`ast.Starred` (``*`` unpacking)" -msgstr "" +msgstr ":class:`ast.Starred` (``*`` によるアンパック)" -#: ../../library/annotationlib.rst:644 msgid ":class:`ast.Name`" -msgstr "" +msgstr ":class:`ast.Name`" -#: ../../library/annotationlib.rst:645 msgid ":class:`ast.List`" -msgstr "" +msgstr ":class:`ast.List`" -#: ../../library/annotationlib.rst:646 msgid ":class:`ast.Tuple`" -msgstr "" +msgstr ":class:`ast.Tuple`" -#: ../../library/annotationlib.rst:647 msgid ":class:`ast.Slice`" -msgstr "" +msgstr ":class:`ast.Slice`" -#: ../../library/annotationlib.rst:649 msgid "" "The following are unsupported, but throw an informative error when " "encountered by the stringifier:" msgstr "" +"次のものはサポートされていませんが、文字列化の処理で検出すると、説明のあるエ" +"ラーを送出します。" -#: ../../library/annotationlib.rst:652 msgid "" ":class:`ast.FormattedValue` (f-strings; error is not detected if conversion " "specifiers like ``!r`` are used)" msgstr "" +":class:`ast.FormattedValue` (f 文字列。ただし、``!r`` などの変換指定子がある" +"場合はエラーを検出できません)" -#: ../../library/annotationlib.rst:654 msgid ":class:`ast.JoinedStr` (f-strings)" -msgstr "" +msgstr ":class:`ast.JoinedStr` (f 文字列)" -#: ../../library/annotationlib.rst:656 msgid "The following are unsupported and result in incorrect output:" -msgstr "" +msgstr "次のものはサポートされておらず、誤った出力になります。" -#: ../../library/annotationlib.rst:658 msgid ":class:`ast.BoolOp` (``and`` and ``or``)" -msgstr "" +msgstr ":class:`ast.BoolOp` (``and`` と ``or``)" -#: ../../library/annotationlib.rst:659 msgid ":class:`ast.IfExp`" -msgstr "" +msgstr ":class:`ast.IfExp`" -#: ../../library/annotationlib.rst:660 msgid ":class:`ast.Lambda`" -msgstr "" +msgstr ":class:`ast.Lambda`" -#: ../../library/annotationlib.rst:661 msgid ":class:`ast.ListComp`" -msgstr "" +msgstr ":class:`ast.ListComp`" -#: ../../library/annotationlib.rst:662 msgid ":class:`ast.SetComp`" -msgstr "" +msgstr ":class:`ast.SetComp`" -#: ../../library/annotationlib.rst:663 msgid ":class:`ast.DictComp`" -msgstr "" +msgstr ":class:`ast.DictComp`" -#: ../../library/annotationlib.rst:664 msgid ":class:`ast.GeneratorExp`" -msgstr "" +msgstr ":class:`ast.GeneratorExp`" -#: ../../library/annotationlib.rst:666 msgid "" "The following are disallowed in annotation scopes and therefore not relevant:" msgstr "" +"次のものはアノテーションスコープで禁止されているため、対象になりません。" -#: ../../library/annotationlib.rst:668 msgid ":class:`ast.NamedExpr` (``:=``)" -msgstr "" +msgstr ":class:`ast.NamedExpr` (``:=``)" -#: ../../library/annotationlib.rst:669 msgid ":class:`ast.Await`" -msgstr "" +msgstr ":class:`ast.Await`" -#: ../../library/annotationlib.rst:670 msgid ":class:`ast.Yield`" -msgstr "" +msgstr ":class:`ast.Yield`" -#: ../../library/annotationlib.rst:671 msgid ":class:`ast.YieldFrom`" -msgstr "" +msgstr ":class:`ast.YieldFrom`" -#: ../../library/annotationlib.rst:675 msgid "Limitations of the ``FORWARDREF`` format" -msgstr "" +msgstr "``FORWARDREF`` 形式の制限" -#: ../../library/annotationlib.rst:677 msgid "" "The :attr:`~Format.FORWARDREF` format aims to produce real values as much as " "possible, with anything that cannot be resolved replaced with :class:" @@ -1064,12 +1345,15 @@ msgid "" "literals or that use unsupported expression types may raise exceptions when " "evaluated using the :attr:`~Format.FORWARDREF` format." msgstr "" +":attr:`~Format.FORWARDREF` 形式は、可能な限り実際の値を生成し、解決できないも" +"のを :class:`ForwardRef` オブジェクトに置き換えようとします。\n" +"制限はおおむね :attr:`~Format.STRING` 形式と同じです。\n" +"リテラルに対する演算や、サポートされていない種類の式を含むアノテーションを :" +"attr:`~Format.FORWARDREF` 形式で評価すると、例外が送出される場合があります。" -#: ../../library/annotationlib.rst:684 msgid "Below are a few examples of the behavior with unsupported expressions:" -msgstr "" +msgstr "サポートされていない式での動作例をいくつか示します。" -#: ../../library/annotationlib.rst:686 msgid "" ">>> from annotationlib import get_annotations, Format\n" ">>> def zerodiv(x: 1 / 0): ...\n" @@ -1085,12 +1369,23 @@ msgid "" ">>> get_annotations(ifexp, format=Format.STRING)\n" "{'x': '1'}" msgstr "" +">>> from annotationlib import get_annotations, Format\n" +">>> def zerodiv(x: 1 / 0): ...\n" +">>> get_annotations(zerodiv, format=Format.STRING)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> get_annotations(zerodiv, format=Format.FORWARDREF)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ZeroDivisionError: division by zero\n" +">>> def ifexp(x: 1 if y else 0): ...\n" +">>> get_annotations(ifexp, format=Format.STRING)\n" +"{'x': '1'}" -#: ../../library/annotationlib.rst:705 msgid "Security implications of introspecting annotations" -msgstr "" +msgstr "アノテーションを調べる際のセキュリティへの影響" -#: ../../library/annotationlib.rst:707 msgid "" "Much of the functionality in this module involves executing code related to " "annotations, which can then do arbitrary things. For example, :func:" @@ -1102,8 +1397,17 @@ msgid "" "functions in the :mod:`typing` module that work with annotations, such as :" "func:`typing.get_type_hints`." msgstr "" +"このモジュールの多くの機能はアノテーションに関係するコードを実行し、そのコー" +"ドは任意の操作を行えます。\n" +"例えば、:func:`get_annotations` は任意の :term:`annotate 関数 ` を呼び出す可能性があり、:meth:`ForwardRef.evaluate` は任意の文字列" +"に対して :func:`eval` を呼び出す可能性があります。\n" +"アノテーション内のコードは、任意のシステムコールを実行したり、無限ループに" +"入ったり、その他のあらゆる操作を行ったりするかもしれません。\n" +"この点は、:attr:`~object.__annotations__` 属性へのあらゆるアクセスや、:func:" +"`typing.get_type_hints` など、アノテーションを扱う :mod:`typing` モジュールの" +"関数にも当てはまります。" -#: ../../library/annotationlib.rst:716 msgid "" "Any security issue arising from this also applies immediately after " "importing code that may contain untrusted annotations: importing code can " @@ -1113,3 +1417,10 @@ msgid "" "``__annotations__`` dictionary or directly creating a :class:`ForwardRef` " "object." msgstr "" +"このことから生じるセキュリティの問題は、信頼できないアノテーションを含む可能" +"性があるコードをインポートした直後にも当てはまります。\n" +"コードのインポートでは、常に任意の操作が実行され得るためです。\n" +"ただし、信頼できない入力元から文字列などを受け取り、アノテーションを調べる " +"API に渡すのは安全ではありません。\n" +"例えば、``__annotations__`` 辞書の編集や、:class:`ForwardRef` オブジェクトの" +"直接作成によって、そのような入力を渡す場合が該当します。" diff --git a/library/archiving.po b/library/archiving.po index 38d6e0c57..9b1efb54d 100644 --- a/library/archiving.po +++ b/library/archiving.po @@ -16,20 +16,23 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/archiving.rst:5 msgid "Data Compression and Archiving" msgstr "データ圧縮とアーカイブ" -#: ../../library/archiving.rst:7 msgid "" "The modules described in this chapter support data compression with the " "zlib, gzip, bzip2, lzma, and zstd algorithms, and the creation of ZIP- and " "tar-format archives. See also :ref:`archiving-operations` provided by the :" "mod:`shutil` module." msgstr "" +"この章のモジュールは、zlib、gzip、bzip2、lzma、zstd アルゴリズムによるデータ" +"圧縮と、ZIP 形式・tar 形式のアーカイブ作成をサポートします。\n" +":mod:`shutil` モジュールが提供する :ref:`archiving-operations` も参照してくだ" +"さい。" diff --git a/library/argparse.po b/library/argparse.po index bff0ef792..6a7ea8824 100644 --- a/library/argparse.po +++ b/library/argparse.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/argparse.rst:2 @@ -36,7 +36,6 @@ msgstr "" msgid "**Source code:** :source:`Lib/argparse.py`" msgstr "**ソースコード:** :source:`Lib/argparse.py`" -#: ../../library/argparse.rst:13 msgid "" "While :mod:`!argparse` is the default recommended standard library module " "for implementing basic command line applications, authors with more exacting " @@ -48,6 +47,14 @@ msgid "" "option parameter values that start with ``-`` even when they correspond to " "another defined option)." msgstr "" +":mod:`!argparse` は基本的なコマンドラインアプリケーションの実装に推奨される標" +"準ライブラリのモジュールですが、動作を厳密に制御したい場合には、必要な制御が" +"できないことがあります。\n" +"``argparse`` が必要な動作をサポートしていない場合、代替手段については :ref:" +"`choosing-an-argument-parser` を参照してください。\n" +"例えば、オプションと位置引数の混在を完全に禁止したり、``-`` で始まる値が他の" +"定義済みオプションと一致する場合でもオプションの値として受け付けたりしたい場" +"合が該当します。" #: ../../library/argparse.rst-1 msgid "Tutorial" @@ -63,7 +70,6 @@ msgstr "" "リアル ` では、コマンドラインの解析についてより優しく説明" "しています。" -#: ../../library/argparse.rst:31 msgid "" "The :mod:`!argparse` module makes it easy to write user-friendly command-" "line interfaces. The program defines what arguments it requires, and :mod:`!" @@ -72,14 +78,23 @@ msgid "" "messages. The module will also issue errors when users give the program " "invalid arguments." msgstr "" +":mod:`!argparse` モジュールを使うと、使いやすいコマンドラインインターフェース" +"を簡単に作成できます。\n" +"プログラムで必要な引数を定義すると、:mod:`!argparse` が :data:`sys.argv` から" +"それらを解析する方法を判断します。\n" +":mod:`!argparse` はヘルプと使用法のメッセージも自動生成し、ユーザーが不正な引" +"数を渡すとエラーを表示します。" -#: ../../library/argparse.rst:37 msgid "" "The :mod:`!argparse` module's support for command-line interfaces is built " "around an instance of :class:`argparse.ArgumentParser`. It is a container " "for argument specifications and has options that apply to the parser as " "whole::" msgstr "" +":mod:`!argparse` のコマンドラインインターフェースのサポートは、:class:" +"`argparse.ArgumentParser` のインスタンスを中心に構成されています。\n" +"このオブジェクトは引数の仕様を格納し、パーサー全体に適用するオプションを持ち" +"ます。 ::" #: ../../library/argparse.rst:41 msgid "" @@ -123,18 +138,20 @@ msgstr "" ":meth:`ArgumentParser.parse_args` メソッドはパーサーを実行し、抽出したデータ" "を :class:`argparse.Namespace` オブジェクト内に配置します::" -#: ../../library/argparse.rst:58 msgid "" "args = parser.parse_args()\n" "print(args.filename, args.count, args.verbose)" msgstr "" +"args = parser.parse_args()\n" +"print(args.filename, args.count, args.verbose)" -#: ../../library/argparse.rst:62 msgid "" "If you're looking for a guide about how to upgrade :mod:`optparse` code to :" "mod:`!argparse`, see :ref:`Upgrading Optparse Code `." msgstr "" +":mod:`optparse` のコードを :mod:`!argparse` に移行する方法は、:ref:`Optparse " +"のコードのアップグレード ` を参照してください。" #: ../../library/argparse.rst:66 msgid "ArgumentParser objects" @@ -150,11 +167,12 @@ msgstr "" "ワード引数として渡すべきです。各引数についてはあとで詳しく説明しますが、簡単" "に言うと:" -#: ../../library/argparse.rst:80 msgid "" "prog_ - The name of the program (default: generated from the ``__main__`` " "module attributes and ``sys.argv[0]``)" msgstr "" +"prog_ - プログラム名 (デフォルト: ``__main__`` モジュールの属性と ``sys." +"argv[0]`` から生成)" #: ../../library/argparse.rst:83 msgid "" @@ -223,27 +241,29 @@ msgstr "" "add_help_ - ``-h/--help`` オプションをパーサーに追加する (デフォルト: " "``True``)" -#: ../../library/argparse.rst:110 msgid "" "allow_abbrev_ - Allows long options to be abbreviated if the abbreviation is " "unambiguous (default: ``True``)" msgstr "" +"allow_abbrev_ - 意味が一意に決まる場合に、長いオプションの省略を許可する (デ" +"フォルト: ``True``)" -#: ../../library/argparse.rst:113 msgid "" "exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits " "with error info when an error occurs. (default: ``True``)" msgstr "" +"exit_on_error_ - エラーが起きたときに、:class:`!ArgumentParser` がエラー情報" +"を表示して終了するかどうか (デフォルト: ``True``)" -#: ../../library/argparse.rst:116 msgid "" "suggest_on_error_ - Enables suggestions for mistyped argument choices and " "subparser names (default: ``True``)" msgstr "" +"suggest_on_error_ - 引数の選択肢やサブパーサー名の入力ミスに対して候補を提示" +"する (デフォルト: ``True``)" -#: ../../library/argparse.rst:119 msgid "color_ - Allow color output (default: ``True``)" -msgstr "" +msgstr "color_ - 色付きの出力を許可する (デフォルト: ``True``)" #: ../../library/argparse.rst:121 msgid "*allow_abbrev* parameter was added." @@ -261,13 +281,11 @@ msgstr "" msgid "*exit_on_error* parameter was added." msgstr "*exit_on_error* 引数が追加されました。" -#: ../../library/argparse.rst:131 msgid "*suggest_on_error* and *color* parameters were added." -msgstr "" +msgstr "``suggest_on_error`` と ``color`` パラメーターが追加されました。" -#: ../../library/argparse.rst:134 msgid "*suggest_on_error* default changed to ``True``." -msgstr "" +msgstr "``suggest_on_error`` のデフォルト値が ``True`` に変わりました。" #: ../../library/argparse.rst:137 ../../library/argparse.rst:699 msgid "The following sections describe how each of these are used." @@ -277,39 +295,45 @@ msgstr "以下の節では各オプションの利用方法を説明します。 msgid "prog" msgstr "``prog``" -#: ../../library/argparse.rst:146 msgid "" "By default, :class:`ArgumentParser` calculates the name of the program to " "display in help messages depending on the way the Python interpreter was run:" msgstr "" +"デフォルトでは、:class:`ArgumentParser` は Python インタープリタの実行方法に" +"応じて、ヘルプに表示するプログラム名を求めます。" -#: ../../library/argparse.rst:149 msgid "" "The :func:`base name ` of ``sys.argv[0]`` if a file was " "passed as argument." msgstr "" +"ファイルを引数に渡した場合は、``sys.argv[0]`` の :func:`ベース名 `。" -#: ../../library/argparse.rst:151 msgid "" "The Python interpreter name followed by ``sys.argv[0]`` if a directory or a " "zipfile was passed as argument." msgstr "" +"ディレクトリか ZIP ファイルを引数に渡した場合は、Python インタープリタの名前" +"に ``sys.argv[0]`` を続けたもの。" -#: ../../library/argparse.rst:153 msgid "" "The Python interpreter name followed by ``-m`` followed by the module or " "package name if the :option:`-m` option was used." msgstr "" +":option:`-m` オプションを使った場合は、Python インタープリタの名前に ``-m``、" +"モジュール名またはパッケージ名を続けたもの。" -#: ../../library/argparse.rst:156 msgid "" "This default is almost always desirable because it will make the help " "messages match the string that was used to invoke the program on the command " "line. However, to change this default behavior, another value can be " "supplied using the ``prog=`` argument to :class:`ArgumentParser`::" msgstr "" +"このデフォルトの動作では、コマンドラインでプログラムを実行した文字列とヘルプ" +"の表記が一致するので、ほとんどの場合に適しています。\n" +"変更したい場合は、:class:`ArgumentParser` の ``prog=`` 引数に別の値を指定でき" +"ます。 ::" -#: ../../library/argparse.rst:161 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.print_help()\n" @@ -318,15 +342,22 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(prog='myprogram')\n" +">>> parser.print_help()\n" +"usage: myprogram [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" -#: ../../library/argparse.rst:168 msgid "" "Note that the program name, whether determined from ``sys.argv[0]``, from " "the ``__main__`` module attributes or from the ``prog=`` argument, is " "available to help messages using the ``%(prog)s`` format specifier." msgstr "" +"プログラム名は、``sys.argv[0]``、``__main__`` モジュールの属性、``prog=`` 引" +"数のどれから決まった場合でも、ヘルプ内で書式指定子 ``%(prog)s`` を使って参照" +"できます。" -#: ../../library/argparse.rst:175 msgid "" ">>> parser = argparse.ArgumentParser(prog='myprogram')\n" ">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" @@ -337,25 +368,35 @@ msgid "" " -h, --help show this help message and exit\n" " --foo FOO foo of the myprogram program" msgstr "" +">>> parser = argparse.ArgumentParser(prog='myprogram')\n" +">>> parser.add_argument('--foo', help='foo of the %(prog)s program')\n" +">>> parser.print_help()\n" +"usage: myprogram [-h] [--foo FOO]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO foo of the myprogram program" -#: ../../library/argparse.rst:184 msgid "" "The default ``prog`` value now reflects how ``__main__`` was actually " "executed, rather than always being ``os.path.basename(sys.argv[0])``." msgstr "" +"デフォルトの ``prog`` 値は、常に ``os.path.basename(sys.argv[0])`` になるので" +"はなく、``__main__`` の実際の実行方法を反映するようになりました。" #: ../../library/argparse.rst:189 msgid "usage" msgstr "usage" -#: ../../library/argparse.rst:191 msgid "" "By default, :class:`ArgumentParser` calculates the usage message from the " "arguments it contains. The default message can be overridden with the " "``usage=`` keyword argument::" msgstr "" +"デフォルトでは、:class:`ArgumentParser` は登録された引数から使用法のメッセー" +"ジを生成します。\n" +"``usage=`` キーワード引数を指定すると、このメッセージを置き換えられます。 ::" -#: ../../library/argparse.rst:195 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " "[options]')\n" @@ -371,6 +412,19 @@ msgid "" " -h, --help show this help message and exit\n" " --foo [FOO] foo help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s " +"[options]')\n" +">>> parser.add_argument('--foo', nargs='?', help='foo help')\n" +">>> parser.add_argument('bar', nargs='+', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [options]\n" +"\n" +"positional arguments:\n" +" bar bar help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo [FOO] foo help" #: ../../library/argparse.rst:208 msgid "" @@ -380,7 +434,6 @@ msgstr "" "``%(prog)s`` フォーマット指定子を、使用法メッセージ内でプログラム名として利用" "できます。" -#: ../../library/argparse.rst:211 msgid "" "When a custom usage message is specified for the main parser, you may also " "want to consider passing the ``prog`` argument to :meth:`~ArgumentParser." @@ -388,12 +441,15 @@ msgid "" "`~_SubParsersAction.add_parser`, to ensure consistent command prefixes and " "usage information across subparsers." msgstr "" +"メインのパーサーに独自の使用法メッセージを指定する場合は、サブパーサー間でコ" +"マンドの先頭部分や使用法の情報を揃えるため、:meth:`~ArgumentParser." +"add_subparsers` に ``prog`` 引数を渡すか、:meth:`~_SubParsersAction." +"add_parser` に ``prog`` と ``usage`` 引数を渡すことも検討してください。" #: ../../library/argparse.rst:221 msgid "description" msgstr "description" -#: ../../library/argparse.rst:223 msgid "" "Most calls to the :class:`ArgumentParser` constructor will use the " "``description=`` keyword argument. This argument gives a brief description " @@ -401,6 +457,11 @@ msgid "" "description is displayed between the command-line usage string and the help " "messages for the various arguments." msgstr "" +":class:`ArgumentParser` コンストラクターを呼ぶ際は、多くの場合 " +"``description=`` キーワード引数を使います。\n" +"この引数には、プログラムが何をどのように行うかの簡潔な説明を指定します。\n" +"ヘルプでは、コマンドラインの使用法を示す文字列と各引数のヘルプの間に表示され" +"ます。" #: ../../library/argparse.rst:229 msgid "" @@ -424,7 +485,6 @@ msgstr "" "します。このテキストは :class:`ArgumentParser` の ``epilog=`` 引数に指定でき" "ます::" -#: ../../library/argparse.rst:240 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... description='A foo that bars',\n" @@ -439,6 +499,18 @@ msgid "" "\n" "And that's how you'd foo a bar" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... description='A foo that bars',\n" +"... epilog=\"And that's how you'd foo a bar\")\n" +">>> parser.print_help()\n" +"usage: argparse.py [-h]\n" +"\n" +"A foo that bars\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"And that's how you'd foo a bar" #: ../../library/argparse.rst:253 msgid "" @@ -470,7 +542,6 @@ msgstr "" "すべての位置アクションとオプションのアクションをそれらから集め、そのアクショ" "ンを構築中の :class:`ArgumentParser` オブジェクトに追加します::" -#: ../../library/argparse.rst:268 msgid "" ">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" ">>> parent_parser.add_argument('--parent', type=int)\n" @@ -485,16 +556,27 @@ msgid "" ">>> bar_parser.parse_args(['--bar', 'YYY'])\n" "Namespace(bar='YYY', parent=None)" msgstr "" +">>> parent_parser = argparse.ArgumentParser(add_help=False)\n" +">>> parent_parser.add_argument('--parent', type=int)\n" +"\n" +">>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])\n" +">>> foo_parser.add_argument('foo')\n" +">>> foo_parser.parse_args(['--parent', '2', 'XXX'])\n" +"Namespace(foo='XXX', parent=2)\n" +"\n" +">>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])\n" +">>> bar_parser.add_argument('--bar')\n" +">>> bar_parser.parse_args(['--bar', 'YYY'])\n" +"Namespace(bar='YYY', parent=None)" -#: ../../library/argparse.rst:281 msgid "" "Note that most parent parsers will specify ``add_help=False``. Otherwise, " "the :class:`ArgumentParser` will see two ``-h/--help`` options (one in the " "parent and one in the child) and raise an error." msgstr "" -"一番親になるパーサーに ``add_help=False`` を指定していることに注目してくださ" -"い。こうしないと、:class:`ArgumentParser` は2つの ``-h/--help`` オプションを" -"与えられる (1つは親から、もうひとつは子から) ことになり、エラーを発生します。" +"多くの親パーサーでは ``add_help=False`` を指定します。\n" +"そうしないと、:class:`ArgumentParser` は親と子に一つずつ、計二つの ``-h/--" +"help`` オプションを検出してエラーを発生させます。" #: ../../library/argparse.rst:286 msgid "" @@ -531,7 +613,6 @@ msgstr "" "`ArgumentParser` オブジェクトはコマンドラインヘルプの中の description_ と " "epilog_ を折り返して表示します::" -#: ../../library/argparse.rst:310 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -554,6 +635,26 @@ msgid "" "words\n" "will be wrapped across a couple lines" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... description='''this description\n" +"... was indented weird\n" +"... but that is okay''',\n" +"... epilog='''\n" +"... likewise for this epilog whose whitespace will\n" +"... be cleaned up and whose words will be wrapped\n" +"... across a couple lines''')\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"this description was indented weird but that is okay\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"likewise for this epilog whose whitespace will be cleaned up and whose " +"words\n" +"will be wrapped across a couple lines" #: ../../library/argparse.rst:330 msgid "" @@ -564,7 +665,6 @@ msgstr "" "``formatter_class=`` に :class:`RawDescriptionHelpFormatter` を渡した場合、 " "description_ と epilog_ は整形済みとされ改行されません::" -#: ../../library/argparse.rst:334 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -588,14 +688,38 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description=textwrap.dedent('''\\\n" +"... Please do not mess up this text!\n" +"... --------------------------------\n" +"... I have indented it\n" +"... exactly the way\n" +"... I want it\n" +"... '''))\n" +">>> parser.print_help()\n" +"usage: PROG [-h]\n" +"\n" +"Please do not mess up this text!\n" +"--------------------------------\n" +" I have indented it\n" +" exactly the way\n" +" I want it\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" -#: ../../library/argparse.rst:356 msgid "" ":class:`RawTextHelpFormatter` maintains whitespace for all sorts of help " "text, including argument descriptions. However, multiple newlines are " "replaced with one. If you wish to preserve multiple blank lines, add spaces " "between the newlines." msgstr "" +":class:`RawTextHelpFormatter` は、引数の説明を含むすべてのヘルプテキストの空" +"白を保持します。\n" +"ただし、連続する改行は一つにまとめられます。\n" +"複数の空行を残したい場合は、改行の間にスペースを入れてください。" #: ../../library/argparse.rst:361 msgid "" @@ -605,7 +729,6 @@ msgstr "" ":class:`ArgumentDefaultsHelpFormatter` は各引数のデフォルト値を自動的にヘルプ" "に追加します::" -#: ../../library/argparse.rst:364 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -622,6 +745,20 @@ msgid "" " -h, --help show this help message and exit\n" " --foo FOO FOO! (default: 42)" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n" +">>> parser.add_argument('--foo', type=int, default=42, help='FOO!')\n" +">>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [--foo FOO] [bar ...]\n" +"\n" +"positional arguments:\n" +" bar BAR! (default: [1, 2, 3])\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO FOO! (default: 42)" #: ../../library/argparse.rst:379 msgid "" @@ -632,7 +769,6 @@ msgstr "" ":class:`MetavarTypeHelpFormatter` は、各引数の値の表示名に type_ 引数の値を使" "用します (通常は dest_ の値が使用されます)::" -#: ../../library/argparse.rst:383 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... prog='PROG',\n" @@ -649,20 +785,37 @@ msgid "" " -h, --help show this help message and exit\n" " --foo int" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... prog='PROG',\n" +"... formatter_class=argparse.MetavarTypeHelpFormatter)\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', type=float)\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [--foo int] float\n" +"\n" +"positional arguments:\n" +" float\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo int" #: ../../library/argparse.rst:400 msgid "prefix_chars" msgstr "prefix_chars" -#: ../../library/argparse.rst:402 msgid "" "Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``. " "Parsers that need to support different or additional prefix characters, e.g. " "for options like ``+f`` or ``/foo``, may specify them using the " "``prefix_chars=`` argument to the :class:`ArgumentParser` constructor::" msgstr "" +"ほとんどのコマンドラインオプションでは、``-f/--foo`` のように接頭辞として ``-" +"`` を使います。\n" +"``+f`` や ``/foo`` のように、別の文字や追加の文字を接頭辞としてサポートする必" +"要があるパーサーでは、:class:`ArgumentParser` コンストラクターの " +"``prefix_chars=`` 引数でそれらの文字を指定できます。 ::" -#: ../../library/argparse.rst:408 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" ">>> parser.add_argument('+f')\n" @@ -670,6 +823,11 @@ msgid "" ">>> parser.parse_args('+f X ++bar Y'.split())\n" "Namespace(bar='Y', f='X')" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')\n" +">>> parser.add_argument('+f')\n" +">>> parser.add_argument('++bar')\n" +">>> parser.parse_args('+f X ++bar Y'.split())\n" +"Namespace(bar='Y', f='X')" #: ../../library/argparse.rst:414 msgid "" @@ -699,7 +857,6 @@ msgstr "" "た場合、指定された文字のいずれかで始まる引数はファイルとして扱われ、そのファ" "イルに含まれる引数リストに置換されます。例えば::" -#: ../../library/argparse.rst:429 msgid "" ">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" "... fp.write('-f\\nbar')\n" @@ -709,8 +866,14 @@ msgid "" ">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" "Namespace(f='bar')" msgstr "" +">>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:\n" +"... fp.write('-f\\nbar')\n" +"...\n" +">>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')\n" +">>> parser.add_argument('-f')\n" +">>> parser.parse_args(['-f', 'foo', '@args.txt'])\n" +"Namespace(f='bar')" -#: ../../library/argparse.rst:437 msgid "" "Arguments read from a file must be one per line by default (but see also :" "meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they " @@ -719,18 +882,26 @@ msgid "" "'@args.txt']`` is considered equivalent to the expression ``['-f', 'foo', '-" "f', 'bar']``." msgstr "" +"デフォルトでは、ファイルから読み込む引数は 1 行に一つずつ記述します (:meth:" +"`~ArgumentParser.convert_arg_line_to_args` も参照してください)。\n" +"読み込んだ引数は、コマンドラインでそのファイルを指定した引数の位置にあるもの" +"として扱われます。\n" +"上の例では、``['-f', 'foo', '@args.txt']`` は ``['-f', 'foo', '-f', 'bar']`` " +"と同じものとして扱われます。" -#: ../../library/argparse.rst:445 msgid "" "Each line is treated as a single argument, so an empty line is read as an " "empty string (``''``)." msgstr "" +"各行が一つの引数として扱われるので、空行は空文字列 (``''``) として読み込まれ" +"ます。" -#: ../../library/argparse.rst:448 msgid "" ":class:`ArgumentParser` uses :term:`filesystem encoding and error handler` " "to read the file containing arguments." msgstr "" +":class:`ArgumentParser` は、引数を記述したファイルを :term:`filesystem " +"encoding and error handler` を使って読み込みます。" #: ../../library/argparse.rst:451 msgid "" @@ -740,7 +911,6 @@ msgstr "" "``fromfile_prefix_chars=`` 引数のデフォルト値は ``None`` で、引数がファイル参" "照として扱われることがないことを意味しています。" -#: ../../library/argparse.rst:454 msgid "" ":class:`ArgumentParser` changed encoding and errors to read arguments files " "from default (e.g. :func:`locale.getpreferredencoding(False) ` と ``\"strict\"`` など) から :term:" +"`filesystem encoding and error handler` に変更しました。\n" +"Windows では、引数ファイルを ANSI コードページではなく UTF-8 でエンコードして" +"ください。" #: ../../library/argparse.rst:462 msgid "argument_default" @@ -772,7 +948,6 @@ msgstr "" "全体で :meth:`~ArgumentParser.parse_args` メソッド呼び出しの属性の生成を抑制" "するには、``argument_default=SUPPRESS`` を指定します::" -#: ../../library/argparse.rst:473 msgid "" ">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" ">>> parser.add_argument('--foo')\n" @@ -782,6 +957,13 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace()" msgstr "" +">>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('bar', nargs='?')\n" +">>> parser.parse_args(['--foo', '1', 'BAR'])\n" +"Namespace(bar='BAR', foo='1')\n" +">>> parser.parse_args([])\n" +"Namespace()" #: ../../library/argparse.rst:484 msgid "allow_abbrev" @@ -802,7 +984,6 @@ msgid "This feature can be disabled by setting ``allow_abbrev`` to ``False``::" msgstr "" "この機能は、``allow_abbrev`` に ``False`` を指定することで無効にできます::" -#: ../../library/argparse.rst:492 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" ">>> parser.add_argument('--foobar', action='store_true')\n" @@ -811,6 +992,12 @@ msgid "" "usage: PROG [-h] [--foobar] [--foonley]\n" "PROG: error: unrecognized arguments: --foon" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)\n" +">>> parser.add_argument('--foobar', action='store_true')\n" +">>> parser.add_argument('--foonley', action='store_false')\n" +">>> parser.parse_args(['--foon'])\n" +"usage: PROG [-h] [--foobar] [--foonley]\n" +"PROG: error: unrecognized arguments: --foon" #: ../../library/argparse.rst:503 msgid "conflict_handler" @@ -828,7 +1015,6 @@ msgstr "" "デフォルトでは、:class:`ArgumentParser` オブジェクトは、すでに利用されている" "オプション文字列を使って新しい引数をつくろうとしたときに例外を送出します::" -#: ../../library/argparse.rst:510 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo', help='old foo help')\n" @@ -837,6 +1023,12 @@ msgid "" " ..\n" "ArgumentError: argument --foo: conflicting option string(s): --foo" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-f', '--foo', help='old foo help')\n" +">>> parser.add_argument('--foo', help='new foo help')\n" +"Traceback (most recent call last):\n" +" ..\n" +"ArgumentError: argument --foo: conflicting option string(s): --foo" #: ../../library/argparse.rst:517 msgid "" @@ -849,7 +1041,6 @@ msgstr "" "で上書きするほうが便利な場合があります。この動作をするには、:class:" "`ArgumentParser` の ``conflict_handler=`` 引数に ``'resolve'`` を渡します::" -#: ../../library/argparse.rst:522 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', " "conflict_handler='resolve')\n" @@ -863,6 +1054,17 @@ msgid "" " -f FOO old foo help\n" " --foo FOO new foo help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', " +"conflict_handler='resolve')\n" +">>> parser.add_argument('-f', '--foo', help='old foo help')\n" +">>> parser.add_argument('--foo', help='new foo help')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [-f FOO] [--foo FOO]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -f FOO old foo help\n" +" --foo FOO new foo help" #: ../../library/argparse.rst:533 msgid "" @@ -880,12 +1082,15 @@ msgstr "" msgid "add_help" msgstr "add_help" -#: ../../library/argparse.rst:542 msgid "" "By default, :class:`ArgumentParser` objects add an option which simply " "displays the parser's help message. If ``-h`` or ``--help`` is supplied at " "the command line, the :class:`!ArgumentParser` help will be printed." msgstr "" +"デフォルトでは、:class:`ArgumentParser` オブジェクトに、パーサーのヘルプを表" +"示するオプションが追加されます。\n" +"コマンドラインで ``-h`` または ``--help`` を指定すると、:class:`!" +"ArgumentParser` のヘルプが表示されます。" #: ../../library/argparse.rst:546 msgid "" @@ -896,7 +1101,6 @@ msgstr "" "必要に応じて、この help オプションを無効にする場合があります。これは :class:" "`ArgumentParser` の ``add_help=`` 引数に ``False`` を渡すことで可能です::" -#: ../../library/argparse.rst:550 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> parser.add_argument('--foo', help='foo help')\n" @@ -906,6 +1110,13 @@ msgid "" "options:\n" " --foo FOO foo help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> parser.add_argument('--foo', help='foo help')\n" +">>> parser.print_help()\n" +"usage: PROG [--foo FOO]\n" +"\n" +"options:\n" +" --foo FOO foo help" #: ../../library/argparse.rst:558 msgid "" @@ -919,7 +1130,6 @@ msgstr "" "オプションではありません。この場合、``prefix_chars`` の最初の文字がヘルプオプ" "ションの接頭辞として利用されます::" -#: ../../library/argparse.rst:564 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" ">>> parser.print_help()\n" @@ -928,17 +1138,25 @@ msgid "" "options:\n" " +h, ++help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')\n" +">>> parser.print_help()\n" +"usage: PROG [+h]\n" +"\n" +"options:\n" +" +h, ++help show this help message and exit" #: ../../library/argparse.rst:573 msgid "exit_on_error" msgstr "exit_on_error" -#: ../../library/argparse.rst:575 msgid "" "Normally, when you pass an invalid argument list to the :meth:" "`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`, it will " "print a *message* to :data:`sys.stderr` and exit with a status code of 2." msgstr "" +"通常、:class:`ArgumentParser` の :meth:`~ArgumentParser.parse_args` メソッド" +"に不正な引数リストを渡すと、:data:`sys.stderr` に *メッセージ* を表示し、終了" +"ステータス 2 で終了します。" #: ../../library/argparse.rst:579 msgid "" @@ -948,7 +1166,6 @@ msgstr "" "もしエラーを例外としてプログラム内でキャッチしたい場合は、``exit_on_error`` " "を ``False`` に設定してください::" -#: ../../library/argparse.rst:582 msgid "" ">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" ">>> parser.add_argument('--integers', type=int)\n" @@ -962,12 +1179,21 @@ msgid "" "...\n" "Catching an argumentError" msgstr "" +">>> parser = argparse.ArgumentParser(exit_on_error=False)\n" +">>> parser.add_argument('--integers', type=int)\n" +"_StoreAction(option_strings=['--integers'], dest='integers', nargs=None, " +"const=None, default=None, type=, choices=None, help=None, " +"metavar=None)\n" +">>> try:\n" +"... parser.parse_args('--integers a'.split())\n" +"... except argparse.ArgumentError:\n" +"... print('Catching an argumentError')\n" +"...\n" +"Catching an argumentError" -#: ../../library/argparse.rst:595 msgid "suggest_on_error" -msgstr "" +msgstr "suggest_on_error" -#: ../../library/argparse.rst:597 msgid "" "By default, when a user passes an invalid argument choice or subparser " "name, :class:`ArgumentParser` will exit with error info and provide " @@ -976,8 +1202,14 @@ msgid "" "\"maybe you meant\" suggestion if a close match is found. Note that this " "only applies for arguments when the choices specified are strings::" msgstr "" +"デフォルトでは、ユーザーが引数の選択肢やサブパーサー名として不正な値を渡す" +"と、:class:`ArgumentParser` はエラー情報と入力ミスに対する候補を表示して終了" +"します。\n" +"エラーメッセージには、引数で指定できる選択肢 (定義されている場合) またはサブ" +"パーサー名を列挙し、似たものが見つかれば \"maybe you meant\" とともに候補を表" +"示します。\n" +"引数の場合、この機能が適用されるのは選択肢が文字列のときだけです。 ::" -#: ../../library/argparse.rst:604 msgid "" ">>> parser = argparse.ArgumentParser(suggest_on_error=True)\n" ">>> parser.add_argument('--action', choices=['debug', 'dryrun'])\n" @@ -986,22 +1218,28 @@ msgid "" "tester.py: error: argument --action: invalid choice: 'debugg', maybe you " "meant 'debug'? (choose from debug, dryrun)" msgstr "" +">>> parser = argparse.ArgumentParser(suggest_on_error=True)\n" +">>> parser.add_argument('--action', choices=['debug', 'dryrun'])\n" +">>> parser.parse_args(['--action', 'debugg'])\n" +"usage: tester.py [-h] [--action {debug,dryrun}]\n" +"tester.py: error: argument --action: invalid choice: 'debugg', maybe you " +"meant 'debug'? (choose from debug, dryrun)" -#: ../../library/argparse.rst:610 msgid "" "You can disable suggestions by setting ``suggest_on_error`` to ``False``." msgstr "" +"``suggest_on_error`` を ``False`` に設定すると、候補の提示を無効にできます。" -#: ../../library/argparse.rst:613 msgid "" "Changed default value of ``suggest_on_error`` from ``False`` to ``True``." msgstr "" +"``suggest_on_error`` のデフォルト値が ``False`` から ``True`` に変わりまし" +"た。" #: ../../library/argparse.rst:617 msgid "color" msgstr "color" -#: ../../library/argparse.rst:619 msgid "" "By default, the help message is printed in color using `ANSI escape " "sequences `__. If you want " @@ -1009,8 +1247,12 @@ msgid "" "environment `, or in the argument parser itself " "by setting ``color`` to ``False``::" msgstr "" +"デフォルトでは、ヘルプは `ANSI エスケープシーケンス `__ を使って色付きで表示されます。\n" +"プレーンテキストで表示したい場合は、:ref:`ローカル環境の設定 ` で色を無効にするか、引数パーサーの ``color`` を " +"``False`` に設定してください。 ::" -#: ../../library/argparse.rst:625 msgid "" ">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" "... color=False)\n" @@ -1019,22 +1261,32 @@ msgid "" "... help='an integer for the accumulator')\n" ">>> parser.parse_args(['--help'])" msgstr "" +">>> parser = argparse.ArgumentParser(description='Process some integers.',\n" +"... color=False)\n" +">>> parser.add_argument('--action', choices=['sum', 'max'])\n" +">>> parser.add_argument('integers', metavar='N', type=int, nargs='+',\n" +"... help='an integer for the accumulator')\n" +">>> parser.parse_args(['--help'])" -#: ../../library/argparse.rst:632 msgid "" "Note that when ``color=True``, colored output depends on both environment " "variables and terminal capabilities. However, if ``color=False``, colored " "output is always disabled, even if environment variables like " "``FORCE_COLOR`` are set." msgstr "" +"``color=True`` の場合、色付きで表示されるかどうかは環境変数と端末の機能によっ" +"て決まります。\n" +"一方、``color=False`` の場合は、``FORCE_COLOR`` のような環境変数が設定されて" +"いても、色付きの出力は常に無効になります。" -#: ../../library/argparse.rst:639 msgid "" "To highlight inline code in your description, epilog, or argument ``help`` " "text, you can use single or double backticks::" msgstr "" +"``description``、``epilog``、引数の ``help`` テキストでインラインのコードを強" +"調表示するには、シングルバッククォートまたはダブルバッククォートで囲みま" +"す。 ::" -#: ../../library/argparse.rst:642 msgid "" ">>> parser = argparse.ArgumentParser(\n" "... formatter_class=argparse.RawDescriptionHelpFormatter,\n" @@ -1045,13 +1297,24 @@ msgid "" "... ''')\n" ">>> parser.add_argument('--foo', help='set the `foo` value')" msgstr "" +">>> parser = argparse.ArgumentParser(\n" +"... formatter_class=argparse.RawDescriptionHelpFormatter,\n" +"... description='Run ``python -m myapp`` to start.',\n" +"... epilog='''Examples:\n" +"... `python -m myapp --verbose`\n" +"... ``python -m myapp --config settings.json``\n" +"... ''')\n" +">>> parser.add_argument('--foo', help='set the `foo` value')" -#: ../../library/argparse.rst:651 msgid "" "When colors are enabled, the text inside backticks will be displayed in a " "distinct color to help examples stand out. When colors are disabled, " "backticks are preserved as-is, which is readable in plain text." msgstr "" +"色が有効な場合、バッククォートで囲んだテキストは別の色で表示され、例が目立つ" +"ようになります。\n" +"色が無効な場合はバッククォートがそのまま残り、プレーンテキストでも読める形に" +"なります。" #: ../../library/argparse.rst:659 msgid "The add_argument() method" @@ -1065,11 +1328,12 @@ msgstr "" "1つのコマンドライン引数がどう解析されるかを定義します。各引数についての詳細は" "後述しますが、簡単に言うと:" -#: ../../library/argparse.rst:668 msgid "" "`name or flags`_ - Either a name or a list of option strings, e.g. ``'foo'`` " "or ``'-f', '--foo'``." msgstr "" +"`name or flags`_ - 名前、またはオプション文字列のリスト (例: ``'foo'``、``'-" +"f', '--foo'``)。" #: ../../library/argparse.rst:671 msgid "" @@ -1086,13 +1350,12 @@ msgid "" "const_ - A constant value required by some action_ and nargs_ selections." msgstr "const_ - 一部の action_ と nargs_ の組み合わせで利用される定数。" -#: ../../library/argparse.rst:678 msgid "" "default_ - The value produced if the argument is absent from the command " "line and if it is absent from the namespace object." msgstr "" "default_ - コマンドラインに対応する引数が存在せず、さらに namespace オブジェ" -"クトにも存在しない場合に利用される値。 " +"クトにも存在しない場合に利用される値。" #: ../../library/argparse.rst:681 msgid "" @@ -1124,13 +1387,11 @@ msgid "" "meth:`parse_args`." msgstr "dest_ - :meth:`parse_args` が返すオブジェクトに追加される属性名。" -#: ../../library/argparse.rst:695 msgid "deprecated_ - Whether or not use of the argument is deprecated." -msgstr "" +msgstr "deprecated_ - この引数の使用が非推奨かどうか。" -#: ../../library/argparse.rst:697 msgid "The method returns an :class:`Action` object representing the argument." -msgstr "" +msgstr "このメソッドは、引数を表す :class:`Action` オブジェクトを返します。" #: ../../library/argparse.rst:705 msgid "name or flags" @@ -1154,17 +1415,15 @@ msgstr "" msgid "For example, an optional argument could be created like::" msgstr "たとえば、オプション引数は次のように作成します::" -#: ../../library/argparse.rst:715 msgid ">>> parser.add_argument('-f', '--foo')" -msgstr "" +msgstr ">>> parser.add_argument('-f', '--foo')" #: ../../library/argparse.rst:717 msgid "while a positional argument could be created like::" msgstr "一方、位置引数は次のように作成します::" -#: ../../library/argparse.rst:719 msgid ">>> parser.add_argument('bar')" -msgstr "" +msgstr ">>> parser.add_argument('bar')" #: ../../library/argparse.rst:721 msgid "" @@ -1175,7 +1434,6 @@ msgstr "" ":meth:`~ArgumentParser.parse_args` が呼ばれたとき、オプション引数は接頭辞 ``-" "`` により識別され、それ以外の引数は位置引数として扱われます::" -#: ../../library/argparse.rst:725 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-f', '--foo')\n" @@ -1188,8 +1446,17 @@ msgid "" "usage: PROG [-h] [-f FOO] bar\n" "PROG: error: the following arguments are required: bar" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-f', '--foo')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args(['BAR'])\n" +"Namespace(bar='BAR', foo=None)\n" +">>> parser.parse_args(['BAR', '--foo', 'FOO'])\n" +"Namespace(bar='BAR', foo='FOO')\n" +">>> parser.parse_args(['--foo', 'FOO'])\n" +"usage: PROG [-h] [-f FOO] bar\n" +"PROG: error: the following arguments are required: bar" -#: ../../library/argparse.rst:736 msgid "" "By default, :mod:`!argparse` automatically handles the internal naming and " "display names of arguments, simplifying the process without requiring " @@ -1198,6 +1465,13 @@ msgid "" "the argument name, with underscores ``_`` replacing hyphens ``-``. The " "metavar_ parameter defaults to the upper-cased name. For example::" msgstr "" +"デフォルトでは、:mod:`!argparse` が引数の内部的な名前と表示名を自動的に決める" +"ため、追加の設定は必要ありません。\n" +"そのため、dest_ と metavar_ パラメーターを指定する必要はありません。\n" +"オプション引数の場合、dest_ のデフォルトは、引数名のハイフン ``-`` をアンダー" +"スコア ``_`` に置き換えたものです。\n" +"metavar_ のデフォルトは、この名前を大文字にしたものです。\n" +"例えば次のようになります。 ::" #: ../../library/argparse.rst:744 msgid "" @@ -1233,11 +1507,12 @@ msgstr "" "引数は、コマンドライン引数がどう処理されるかを指定します。提供されているアク" "ションは:" -#: ../../library/argparse.rst:767 msgid "" "``'store'`` - This just stores the argument's value. This is the default " "action." msgstr "" +"``'store'`` - 引数の値を格納します。\n" +"これがデフォルトのアクションです。" #: ../../library/argparse.rst:770 msgid "" @@ -1251,22 +1526,26 @@ msgstr "" "ください。``'store_const'`` アクションは、何かの種類のフラグを指定するオプ" "ション引数によく使われます。例えば::" -#: ../../library/argparse.rst:775 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_const', const=42)\n" ">>> parser.parse_args(['--foo'])\n" "Namespace(foo=42)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_const', const=42)\n" +">>> parser.parse_args(['--foo'])\n" +"Namespace(foo=42)" -#: ../../library/argparse.rst:780 msgid "" "``'store_true'`` and ``'store_false'`` - These are special cases of " "``'store_const'`` that respectively store the values ``True`` and ``False`` " "with default values of ``False`` and ``True``::" msgstr "" +"``'store_true'`` と ``'store_false'`` - ``'store_const'`` の特殊な形で、それ" +"ぞれ ``True`` と ``False`` を格納し、デフォルト値はそれぞれ ``False`` と " +"``True`` になります。 ::" -#: ../../library/argparse.rst:785 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -1275,8 +1554,13 @@ msgid "" ">>> parser.parse_args('--foo --bar'.split())\n" "Namespace(foo=True, bar=False, baz=True)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_true')\n" +">>> parser.add_argument('--bar', action='store_false')\n" +">>> parser.add_argument('--baz', action='store_false')\n" +">>> parser.parse_args('--foo --bar'.split())\n" +"Namespace(foo=True, bar=False, baz=True)" -#: ../../library/argparse.rst:792 msgid "" "``'append'`` - This appends each argument value to a list. It is useful for " "allowing an option to be specified multiple times. If the default value is a " @@ -1284,24 +1568,36 @@ msgid "" "and any values from the command line will be appended after those default " "values. Example usage::" msgstr "" +"``'append'`` - 引数の値をリストに追加します。\n" +"同じオプションを複数回指定できるようにする場合に便利です。\n" +"デフォルト値が空でないリストの場合、解析結果のリストはそのデフォルト値の要素" +"から始まり、コマンドラインから取得した値はその後ろに追加されます。\n" +"使用例です。 ::" -#: ../../library/argparse.rst:798 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='append', default=['0'])\n" ">>> parser.parse_args('--foo 1 --foo 2'.split())\n" "Namespace(foo=['0', '1', '2'])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='append', default=['0'])\n" +">>> parser.parse_args('--foo 1 --foo 2'.split())\n" +"Namespace(foo=['0', '1', '2'])" -#: ../../library/argparse.rst:803 msgid "" "``'append_const'`` - This appends the value specified by the const_ keyword " "argument to a list; note that the const_ keyword argument defaults to " "``None``. The ``'append_const'`` action is typically useful when multiple " "arguments need to store constants to the same list. For example::" msgstr "" +"``'append_const'`` - const_ キーワード引数で指定した値をリストに追加しま" +"す。\n" +"const_ キーワード引数のデフォルト値は ``None`` です。\n" +"``'append_const'`` アクションは、複数の引数で同じリストに定数を格納したい場合" +"に便利です。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:809 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--str', dest='types', action='append_const', " @@ -1311,8 +1607,14 @@ msgid "" ">>> parser.parse_args('--str --int'.split())\n" "Namespace(types=[, ])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--str', dest='types', action='append_const', " +"const=str)\n" +">>> parser.add_argument('--int', dest='types', action='append_const', " +"const=int)\n" +">>> parser.parse_args('--str --int'.split())\n" +"Namespace(types=[, ])" -#: ../../library/argparse.rst:815 msgid "" "``'extend'`` - This appends each item from a multi-value argument to a list. " "The ``'extend'`` action is typically used with the nargs_ keyword argument " @@ -1320,8 +1622,13 @@ msgid "" "``'?'``, each character of the argument string will be appended to the list. " "Example usage::" msgstr "" +"``'extend'`` - 複数の値を持つ引数の各要素をリストに追加します。\n" +"``'extend'`` アクションは通常、nargs_ キーワード引数に ``'+'`` または " +"``'*'`` を指定して使います。\n" +"nargs_ が ``None`` (デフォルト) または ``'?'`` の場合は、引数文字列の各文字が" +"リストに追加されることに注意してください。\n" +"使用例です。 ::" -#: ../../library/argparse.rst:823 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " @@ -1330,38 +1637,49 @@ msgid "" "\"f4\"])\n" "Namespace(foo=['f1', 'f2', 'f3', 'f4'])" msgstr "" - -#: ../../library/argparse.rst:830 -msgid "" -"``'count'`` - This counts the number of times an argument occurs. For " -"example, this is useful for increasing verbosity levels::" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\"--foo\", action=\"extend\", nargs=\"+\", " +"type=str)\n" +">>> parser.parse_args([\"--foo\", \"f1\", \"--foo\", \"f2\", \"f3\", " +"\"f4\"])\n" +"Namespace(foo=['f1', 'f2', 'f3', 'f4'])" + +msgid "" +"``'count'`` - This counts the number of times an argument occurs. For " +"example, this is useful for increasing verbosity levels::" msgstr "" +"``'count'`` - 引数が指定された回数を数えます。\n" +"例えば、出力の詳細度を上げるために使えます。 ::" -#: ../../library/argparse.rst:833 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" ">>> parser.parse_args(['-vvv'])\n" "Namespace(verbose=3)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--verbose', '-v', action='count', default=0)\n" +">>> parser.parse_args(['-vvv'])\n" +"Namespace(verbose=3)" -#: ../../library/argparse.rst:838 msgid "" "Unless explicitly set, the *default* will be ``None``. If the default value " "is a non-zero number, the count starts from that number rather than from " "zero." msgstr "" +"明示的に設定しなければ、*default* は ``None`` です。\n" +"デフォルト値がゼロ以外の数値の場合、ゼロではなくその値から数え始めます。" -#: ../../library/argparse.rst:842 msgid "" "``'help'`` - This prints a complete help message for all the options in the " "current parser and then exits. By default a help action is automatically " "added to the parser. See :class:`ArgumentParser` for details of how the " "output is created." msgstr "" -"``'help'`` - このアクションは現在のパーサー中のすべてのオプションのヘルプメッ" -"セージを表示し、終了します。出力の生成方法の詳細については :class:" -"`ArgumentParser` を参照してください。" +"``'help'`` - 現在のパーサーのすべてのオプションについてヘルプを表示し、終了し" +"ます。\n" +"デフォルトでは、このヘルプアクションはパーサーに自動的に追加されます。\n" +"出力の生成方法の詳細は :class:`ArgumentParser` を参照してください。" #: ../../library/argparse.rst:847 msgid "" @@ -1373,7 +1691,6 @@ msgstr "" "出しに ``version=`` キーワード引数を期待します。指定されたときはバージョン情" "報を表示して終了します::" -#: ../../library/argparse.rst:851 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -1382,8 +1699,13 @@ msgid "" ">>> parser.parse_args(['--version'])\n" "PROG 2.0" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--version', action='version', version='%(prog)s " +"2.0')\n" +">>> parser.parse_args(['--version'])\n" +"PROG 2.0" -#: ../../library/argparse.rst:857 msgid "" "You may also specify an arbitrary action by passing an :class:`Action` " "subclass (e.g. :class:`BooleanOptionalAction`) or other object that " @@ -1391,8 +1713,13 @@ msgid "" "arguments (e.g. ``'store'``, ``'append'``, ``'extend'``, or custom actions " "with non-zero ``nargs``) can be used with positional arguments." msgstr "" +":class:`Action` のサブクラス (:class:`BooleanOptionalAction` など) や、同じイ" +"ンターフェースを実装する別のオブジェクトを渡して、任意のアクションを指定する" +"こともできます。\n" +"位置引数に使えるのは、コマンドライン引数を消費するアクション (``'store'``、" +"``'append'``、``'extend'``、``nargs`` がゼロ以外のカスタムアクションなど) だ" +"けです。" -#: ../../library/argparse.rst:863 msgid "" "The recommended way to create a custom action is to extend :class:`Action`, " "overriding the :meth:`!__call__` method and optionally the :meth:`!__init__` " @@ -1400,12 +1727,16 @@ msgid "" "using the :meth:`~ArgumentParser.register` method and reference them by " "their registered name." msgstr "" +"カスタムアクションを作るには、:class:`Action` を継承して :meth:`!__call__` メ" +"ソッドをオーバーライドし、必要に応じて :meth:`!__init__` と :meth:`!" +"format_usage` メソッドもオーバーライドする方法を推奨します。\n" +":meth:`~ArgumentParser.register` メソッドでカスタムアクションを登録し、その登" +"録名で参照することもできます。" #: ../../library/argparse.rst:868 msgid "An example of a custom action::" msgstr "カスタムアクションの例です::" -#: ../../library/argparse.rst:870 msgid "" ">>> class FooAction(argparse.Action):\n" "... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" @@ -1425,6 +1756,23 @@ msgid "" ">>> args\n" "Namespace(bar='1', foo='2')" msgstr "" +">>> class FooAction(argparse.Action):\n" +"... def __init__(self, option_strings, dest, nargs=None, **kwargs):\n" +"... if nargs is not None:\n" +"... raise ValueError(\"nargs not allowed\")\n" +"... super().__init__(option_strings, dest, **kwargs)\n" +"... def __call__(self, parser, namespace, values, option_string=None):\n" +"... print('%r %r %r' % (namespace, values, option_string))\n" +"... setattr(namespace, self.dest, values)\n" +"...\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=FooAction)\n" +">>> parser.add_argument('bar', action=FooAction)\n" +">>> args = parser.parse_args('1 --foo 2'.split())\n" +"Namespace(bar=None, foo=None) '1' None\n" +"Namespace(bar='1', foo=None) '2' '--foo'\n" +">>> args\n" +"Namespace(bar='1', foo='2')" #: ../../library/argparse.rst:888 msgid "For more details, see :class:`Action`." @@ -1434,7 +1782,6 @@ msgstr "詳細は :class:`Action` を参照してください。" msgid "nargs" msgstr "nargs" -#: ../../library/argparse.rst:896 msgid "" ":class:`ArgumentParser` objects usually associate a single command-line " "argument with a single action to be taken. The ``nargs`` keyword argument " @@ -1442,6 +1789,12 @@ msgid "" "action. See also :ref:`specifying-ambiguous-arguments`. The supported values " "are:" msgstr "" +":class:`ArgumentParser` オブジェクトは通常、一つのコマンドライン引数に対して" +"一つのアクションを実行します。\n" +"``nargs`` キーワード引数を使うと、一つのアクションに別の個数のコマンドライン" +"引数を対応させられます。\n" +":ref:`specifying-ambiguous-arguments` も参照してください。\n" +"指定できる値は次のとおりです。" #: ../../library/argparse.rst:901 msgid "" @@ -1451,7 +1804,6 @@ msgstr "" "``N`` (整数) -- ``N`` 個の引数がコマンドラインから集められ、リストに格納され" "ます。例えば::" -#: ../../library/argparse.rst:904 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs=2)\n" @@ -1459,6 +1811,11 @@ msgid "" ">>> parser.parse_args('c --foo a b'.split())\n" "Namespace(bar=['c'], foo=['a', 'b'])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs=2)\n" +">>> parser.add_argument('bar', nargs=1)\n" +">>> parser.parse_args('c --foo a b'.split())\n" +"Namespace(bar=['c'], foo=['a', 'b'])" #: ../../library/argparse.rst:910 msgid "" @@ -1483,7 +1840,6 @@ msgstr "" "いというケースもありえます。この場合は const_ の値が生成されます。この動作の" "例です::" -#: ../../library/argparse.rst:922 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" @@ -1495,6 +1851,15 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace(bar='d', foo='d')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs='?', const='c', default='d')\n" +">>> parser.add_argument('bar', nargs='?', default='d')\n" +">>> parser.parse_args(['XX', '--foo', 'YY'])\n" +"Namespace(bar='XX', foo='YY')\n" +">>> parser.parse_args(['XX', '--foo'])\n" +"Namespace(bar='XX', foo='c')\n" +">>> parser.parse_args([])\n" +"Namespace(bar='d', foo='d')" #: ../../library/argparse.rst:932 msgid "" @@ -1503,7 +1868,6 @@ msgid "" msgstr "" "``nargs='?'`` のよくある利用例の1つは、入出力ファイルの指定オプションです::" -#: ../../library/argparse.rst:935 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', nargs='?')\n" @@ -1515,6 +1879,15 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace(infile=None, outfile=None)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('infile', nargs='?')\n" +">>> parser.add_argument('outfile', nargs='?')\n" +">>> parser.parse_args(['input.txt', 'output.txt'])\n" +"Namespace(infile='input.txt', outfile='output.txt')\n" +">>> parser.parse_args(['input.txt'])\n" +"Namespace(infile='input.txt', outfile=None)\n" +">>> parser.parse_args([])\n" +"Namespace(infile=None, outfile=None)" #: ../../library/argparse.rst:947 msgid "" @@ -1527,7 +1900,6 @@ msgstr "" "が ``nargs='*'`` を持つことにあまり意味はありませんが、複数のオプション引数" "が ``nargs='*'`` を持つことはありえます。例えば::" -#: ../../library/argparse.rst:952 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', nargs='*')\n" @@ -1536,15 +1908,23 @@ msgid "" ">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" "Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', nargs='*')\n" +">>> parser.add_argument('--bar', nargs='*')\n" +">>> parser.add_argument('baz', nargs='*')\n" +">>> parser.parse_args('a b --foo x y --bar 1 2'.split())\n" +"Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])" -#: ../../library/argparse.rst:961 msgid "" "``'+'``. Just like ``'*'``, all command-line arguments present are gathered " "into a list. Additionally, an error message will be generated if there " "wasn't at least one command-line argument present. For example::" msgstr "" +"``'+'`` - ``'*'`` と同様に、コマンドラインで指定された引数をすべてリストに集" +"めます。\n" +"ただし、コマンドライン引数が一つもなければエラーメッセージを表示します。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:965 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('foo', nargs='+')\n" @@ -1554,8 +1934,14 @@ msgid "" "usage: PROG [-h] foo [foo ...]\n" "PROG: error: the following arguments are required: foo" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('foo', nargs='+')\n" +">>> parser.parse_args(['a', 'b'])\n" +"Namespace(foo=['a', 'b'])\n" +">>> parser.parse_args([])\n" +"usage: PROG [-h] foo [foo ...]\n" +"PROG: error: the following arguments are required: foo" -#: ../../library/argparse.rst:973 msgid "" "If the ``nargs`` keyword argument is not provided, the number of arguments " "consumed is determined by the action_. Generally this means a single " @@ -1563,6 +1949,12 @@ msgid "" "be produced. Actions that do not consume command-line arguments (e.g. " "``'store_const'``) set ``nargs=0``." msgstr "" +"``nargs`` キーワード引数を指定しなかった場合、消費する引数の数は action_ に" +"よって決まります。\n" +"通常は、一つのコマンドライン引数を消費して、リストではなく単一の値を生成しま" +"す。\n" +"コマンドライン引数を消費しないアクション (``'store_const'`` など) では、" +"``nargs=0`` が設定されます。" #: ../../library/argparse.rst:983 msgid "const" @@ -1595,7 +1987,6 @@ msgstr "" "`~ArgumentParser.add_argument` に与えられなければ、``None`` のデフォルト値を" "受け取ります。" -#: ../../library/argparse.rst:997 msgid "" "When :meth:`~ArgumentParser.add_argument` is called with option strings " "(like ``-f`` or ``--foo``) and ``nargs='?'``. This creates an optional " @@ -1604,6 +1995,13 @@ msgid "" "command-line argument following it, the value from ``const`` will be used. " "See the nargs_ description for examples." msgstr "" +":meth:`~ArgumentParser.add_argument` にオプション文字列 (``-f`` や ``--foo`` " +"など) と ``nargs='?'`` を指定した場合。\n" +"この場合、その後にコマンドライン引数を 0 個または 1 個指定できるオプション引" +"数が作られます。\n" +"コマンドラインの解析時に、オプション文字列の後に引数がなければ ``const`` の値" +"が使われます。\n" +"例は nargs_ の説明を参照してください。" #: ../../library/argparse.rst:1004 msgid "" @@ -1632,7 +2030,6 @@ msgstr "" "る値を指定します。オプション引数では、オプション文字列がコマンドライン上に存" "在しなかったときに ``default`` の値が利用されます::" -#: ../../library/argparse.rst:1020 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" @@ -1641,20 +2038,30 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=42)\n" +">>> parser.parse_args(['--foo', '2'])\n" +"Namespace(foo='2')\n" +">>> parser.parse_args([])\n" +"Namespace(foo=42)" -#: ../../library/argparse.rst:1027 msgid "" "If the target namespace already has an attribute set, the action *default* " "will not overwrite it::" msgstr "" +"対象の名前空間にすでに属性が設定されている場合、アクションの *default* はその" +"値を上書きしません。 ::" -#: ../../library/argparse.rst:1030 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=42)\n" ">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" "Namespace(foo=101)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=42)\n" +">>> parser.parse_args([], namespace=argparse.Namespace(foo=101))\n" +"Namespace(foo=101)" #: ../../library/argparse.rst:1035 msgid "" @@ -1668,7 +2075,6 @@ msgstr "" "に、type_ 変換引数が与えられていればそれらを適用します。そうでない場合、パー" "サーは値をそのまま使用します::" -#: ../../library/argparse.rst:1040 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--length', default='10', type=int)\n" @@ -1676,6 +2082,11 @@ msgid "" ">>> parser.parse_args()\n" "Namespace(length=10, width=10.5)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--length', default='10', type=int)\n" +">>> parser.add_argument('--width', default=10.5, type=int)\n" +">>> parser.parse_args()\n" +"Namespace(length=10, width=10.5)" #: ../../library/argparse.rst:1046 msgid "" @@ -1685,7 +2096,6 @@ msgstr "" "nargs_ が ``?`` か ``*`` である位置引数では、コマンドライン引数が指定されな" "かった場合 ``default`` の値が使われます。例えば::" -#: ../../library/argparse.rst:1049 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', nargs='?', default=42)\n" @@ -1694,20 +2104,31 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace(foo=42)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('foo', nargs='?', default=42)\n" +">>> parser.parse_args(['a'])\n" +"Namespace(foo='a')\n" +">>> parser.parse_args([])\n" +"Namespace(foo=42)" -#: ../../library/argparse.rst:1056 msgid "" "Because ``nargs='*'`` gathers any supplied values into a list, an absent " "positional argument yields an empty list (``[]``). Only a non-``None`` " "*default* overrides this (so ``default=None`` still gives ``[]``)." msgstr "" +"``nargs='*'`` は指定された値をリストに集めるため、位置引数が指定されなければ" +"空リスト (``[]``) になります。\n" +"この動作を変更できるのは *default* が ``None`` 以外の場合だけです " +"(``default=None`` でも ``[]`` になります)。" -#: ../../library/argparse.rst:1060 msgid "" "For required_ arguments, the ``default`` value is ignored. For example, this " "applies to positional arguments with nargs_ values other than ``?`` or " "``*``, or optional arguments marked as ``required=True``." msgstr "" +"required_ の引数では ``default`` の値は無視されます。\n" +"例えば、nargs_ が ``?`` や ``*`` 以外の位置引数や、``required=True`` を指定し" +"たオプション引数が該当します。" #: ../../library/argparse.rst:1064 msgid "" @@ -1717,7 +2138,6 @@ msgstr "" "``default=argparse.SUPPRESS`` を渡すと、コマンドライン引数が存在しないときに" "属性の追加をしなくなります::" -#: ../../library/argparse.rst:1067 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" @@ -1726,6 +2146,12 @@ msgid "" ">>> parser.parse_args(['--foo', '1'])\n" "Namespace(foo='1')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default=argparse.SUPPRESS)\n" +">>> parser.parse_args([])\n" +"Namespace()\n" +">>> parser.parse_args(['--foo', '1'])\n" +"Namespace(foo='1')" #: ../../library/argparse.rst:1078 msgid "type" @@ -1750,10 +2176,10 @@ msgid "" "If the type_ keyword is used with the default_ keyword, the type converter " "is only applied if the default is a string." msgstr "" -"もし type_ キーワードが default_ キーワードとともに使用された場合、default_ " -"の値が文字列のときのみ、type converter による変換などが行われます。" +"もし type_ キーワードが default_ キーワードとともに使用された場合、" +"``default`` の値が文字列のときのみ、type converter による変換などが行われま" +"す。" -#: ../../library/argparse.rst:1089 msgid "" "The argument to ``type`` can be a callable that accepts a single string or " "the name of a registered type (see :meth:`~ArgumentParser.register`) If the " @@ -1761,13 +2187,17 @@ msgid "" "`ValueError`, the exception is caught and a nicely formatted error message " "is displayed. Other exception types are not handled." msgstr "" +"``type`` には、一つの文字列を受け取る呼び出し可能オブジェクト、または登録済み" +"の型の名前 (:meth:`~ArgumentParser.register` を参照) を渡せます。\n" +"この関数が :exc:`ArgumentTypeError`、:exc:`TypeError`、:exc:`ValueError` を送" +"出すると、その例外を捕捉して読みやすい形式のエラーメッセージを表示します。\n" +"それ以外の例外は処理しません。" #: ../../library/argparse.rst:1095 msgid "Common built-in types and functions can be used as type converters:" msgstr "" "一般的なビルトインデータ型や関数を ``type`` 引数の値として直接指定できます::" -#: ../../library/argparse.rst:1097 msgid "" "import argparse\n" "import pathlib\n" @@ -1779,12 +2209,20 @@ msgid "" "parser.add_argument('code_point', type=ord)\n" "parser.add_argument('datapath', type=pathlib.Path)" msgstr "" +"import argparse\n" +"import pathlib\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument('count', type=int)\n" +"parser.add_argument('distance', type=float)\n" +"parser.add_argument('street', type=ascii)\n" +"parser.add_argument('code_point', type=ord)\n" +"parser.add_argument('datapath', type=pathlib.Path)" #: ../../library/argparse.rst:1109 msgid "User defined functions can be used as well:" msgstr "ユーザが定義した関数も使用できます::" -#: ../../library/argparse.rst:1111 msgid "" ">>> def hyphenated(string):\n" "... return '-'.join([word[:4] for word in string.casefold().split()])\n" @@ -1794,27 +2232,40 @@ msgid "" ">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" "Namespace(short_title='\"the-tale-of-two-citi')" msgstr "" +">>> def hyphenated(string):\n" +"... return '-'.join([word[:4] for word in string.casefold().split()])\n" +"...\n" +">>> parser = argparse.ArgumentParser()\n" +">>> _ = parser.add_argument('short_title', type=hyphenated)\n" +">>> parser.parse_args(['\"The Tale of Two Cities\"'])\n" +"Namespace(short_title='\"the-tale-of-two-citi')" -#: ../../library/argparse.rst:1121 msgid "" "The :func:`bool` function is not recommended as a type converter. All it " "does is convert empty strings to ``False`` and non-empty strings to " "``True``. This is usually not what is desired::" msgstr "" +":func:`bool` 関数を型変換に使うことは推奨しません。\n" +"空文字列を ``False`` に、空でない文字列を ``True`` に変換するだけなので、通常" +"は意図した結果になりません。 ::" -#: ../../library/argparse.rst:1125 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> _ = parser.add_argument('--verbose', type=bool)\n" ">>> parser.parse_args(['--verbose', 'False'])\n" "Namespace(verbose=True)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> _ = parser.add_argument('--verbose', type=bool)\n" +">>> parser.parse_args(['--verbose', 'False'])\n" +"Namespace(verbose=True)" -#: ../../library/argparse.rst:1130 msgid "" "See :class:`BooleanOptionalAction` or ``action='store_true'`` for common " "alternatives." msgstr "" +"よく使われる代替手段については、:class:`BooleanOptionalAction` または " +"``action='store_true'`` を参照してください。" #: ../../library/argparse.rst:1133 msgid "" @@ -1840,7 +2291,6 @@ msgstr "" "発生しうる) :exc:`~json.JSONDecodeError` は適切に整形されて表示されません。ま" "た、:exc:`FileNotFoundError` が発生しても parser は何も処理しません。" -#: ../../library/argparse.rst:1143 msgid "" "Even :class:`~argparse.FileType` has its limitations for use with the " "``type`` keyword. If one argument uses :class:`~argparse.FileType` and then " @@ -1849,6 +2299,12 @@ msgid "" "the parser has run and then use the :keyword:`with`-statement to manage the " "files." msgstr "" +":class:`~argparse.FileType` でさえ、``type`` キーワードでの使用には制限があり" +"ます。\n" +"ある引数で :class:`~argparse.FileType` を使い、その後の引数でエラーが起きる" +"と、エラーは報告されますが、ファイルは自動的には閉じられません。\n" +"この場合は、引数の解析が終わってから :keyword:`with` 文でファイルを管理する方" +"が適切です。" #: ../../library/argparse.rst:1150 msgid "" @@ -1876,7 +2332,6 @@ msgstr "" "き、引数の値がチェックされ、その値が選択肢の中に含まれていない場合はエラー" "メッセージを表示します::" -#: ../../library/argparse.rst:1165 msgid "" ">>> parser = argparse.ArgumentParser(prog='game.py')\n" ">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" @@ -1887,6 +2342,14 @@ msgid "" "game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" "'paper', 'scissors')" msgstr "" +">>> parser = argparse.ArgumentParser(prog='game.py')\n" +">>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])\n" +">>> parser.parse_args(['rock'])\n" +"Namespace(move='rock')\n" +">>> parser.parse_args(['fire'])\n" +"usage: game.py [-h] {rock,paper,scissors}\n" +"game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',\n" +"'paper', 'scissors')" #: ../../library/argparse.rst:1174 msgid "" @@ -1905,19 +2368,24 @@ msgstr "" "ただし、:class:`enum.Enum` を渡すことは推奨されません。使用方法、ヘルプ、エ" "ラーメッセージなどでどのように表示されるかを制御することが難いからです。" -#: ../../library/argparse.rst:1180 msgid "" "Note that *choices* are checked after any type_ conversions have been " "performed, so objects in *choices* should match the type_ specified. This " "can make *choices* appear unfamiliar in usage, help, or error messages." msgstr "" +"*choices* の検査は type_ による変換の後に行われるので、*choices* のオブジェク" +"トは指定した type_ に合うものにしてください。\n" +"そのため、使用法、ヘルプ、エラーメッセージに表示される *choices* が、ユーザー" +"にとってなじみのない表記になることがあります。" -#: ../../library/argparse.rst:1185 msgid "" "To keep *choices* user-friendly, consider a custom type wrapper that " "converts and formats values, or omit type_ and handle conversion in your " "application code." msgstr "" +"*choices* をユーザーにわかりやすく表示するには、値の変換と書式化を行う独自の" +"型ラッパーを使うか、type_ を指定せず、アプリケーションのコードで変換すること" +"を検討してください。" #: ../../library/argparse.rst:1189 msgid "" @@ -1936,15 +2404,17 @@ msgstr "" msgid "required" msgstr "required" -#: ../../library/argparse.rst:1200 msgid "" "In general, the :mod:`!argparse` module assumes that flags like ``-f`` and " "``--bar`` indicate *optional* arguments, which can always be omitted at the " "command line. To make an option *required*, ``True`` can be specified for " "the ``required=`` keyword argument to :meth:`~ArgumentParser.add_argument`::" msgstr "" +":mod:`!argparse` モジュールは通常、``-f`` や ``--bar`` のようなフラグを、コマ" +"ンドラインで常に省略できる *オプション* 引数として扱います。\n" +"オプションを *必須* にするには、:meth:`~ArgumentParser.add_argument` の " +"``required=`` キーワード引数に ``True`` を指定します。 ::" -#: ../../library/argparse.rst:1205 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', required=True)\n" @@ -1954,6 +2424,13 @@ msgid "" "usage: [-h] --foo FOO\n" ": error: the following arguments are required: --foo" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', required=True)\n" +">>> parser.parse_args(['--foo', 'BAR'])\n" +"Namespace(foo='BAR')\n" +">>> parser.parse_args([])\n" +"usage: [-h] --foo FOO\n" +": error: the following arguments are required: --foo" #: ../../library/argparse.rst:1213 msgid "" @@ -1977,13 +2454,15 @@ msgstr "" msgid "help" msgstr "help" -#: ../../library/argparse.rst:1228 msgid "" "The ``help`` value is a string containing a brief description of the " "argument. When a user requests help (usually by using ``-h`` or ``--help`` " "at the command line), these ``help`` descriptions will be displayed with " "each argument." msgstr "" +"``help`` の値には、引数の簡潔な説明を文字列で指定します。\n" +"ユーザーがヘルプを要求すると (通常はコマンドラインで ``-h`` または ``--" +"help`` を指定します)、各引数とともにこの ``help`` の説明が表示されます。" #: ../../library/argparse.rst:1233 msgid "" @@ -1998,7 +2477,6 @@ msgstr "" "プログラム名 ``%(prog)s`` と、 ``%(default)s`` や ``%(type)s`` など :meth:" "`~ArgumentParser.add_argument` のキーワード引数の多くが含まれます::" -#: ../../library/argparse.rst:1238 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" @@ -2012,6 +2490,17 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(prog='frobble')\n" +">>> parser.add_argument('bar', nargs='?', type=int, default=42,\n" +"... help='the bar to %(prog)s (default: %(default)s)')\n" +">>> parser.print_help()\n" +"usage: frobble [-h] [bar]\n" +"\n" +"positional arguments:\n" +" bar the bar to frobble (default: 42)\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" #: ../../library/argparse.rst:1250 msgid "" @@ -2021,13 +2510,13 @@ msgstr "" "ヘルプ文字列は %-フォーマットをサポートしているので、ヘルプ文字列内にリテラ" "ル ``%`` を表示したい場合は ``%%`` のようにエスケープしなければなりません。" -#: ../../library/argparse.rst:1253 msgid "" ":mod:`!argparse` supports silencing the help entry for certain options, by " "setting the ``help`` value to ``argparse.SUPPRESS``::" msgstr "" +":mod:`!argparse` では、``help`` の値を ``argparse.SUPPRESS`` に設定すると、そ" +"のオプションをヘルプに表示しないようにできます。 ::" -#: ../../library/argparse.rst:1256 msgid "" ">>> parser = argparse.ArgumentParser(prog='frobble')\n" ">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" @@ -2037,12 +2526,18 @@ msgid "" "options:\n" " -h, --help show this help message and exit" msgstr "" +">>> parser = argparse.ArgumentParser(prog='frobble')\n" +">>> parser.add_argument('--foo', help=argparse.SUPPRESS)\n" +">>> parser.print_help()\n" +"usage: frobble [-h]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit" #: ../../library/argparse.rst:1268 msgid "metavar" msgstr "metavar" -#: ../../library/argparse.rst:1270 msgid "" "When :class:`ArgumentParser` generates help messages, it needs some way to " "refer to each expected argument. By default, :class:`!ArgumentParser` " @@ -2053,8 +2548,17 @@ msgid "" "single optional argument ``--foo`` that should be followed by a single " "command-line argument will be referred to as ``FOO``. An example::" msgstr "" +":class:`ArgumentParser` がヘルプを生成する際には、受け付ける各引数を表す名前" +"が必要です。\n" +"デフォルトでは、:class:`!ArgumentParser` オブジェクトは dest_ の値を各引数の" +"「名前」として使います。\n" +"位置引数のアクションでは dest_ の値をそのまま使い、オプション引数のアクション" +"では dest_ の値を大文字にして使います。\n" +"そのため、``dest='bar'`` の位置引数は ``bar`` と表示されます。\n" +"コマンドライン引数を一つ受け取るオプション ``--foo`` では、その値が ``FOO`` " +"と表示されます。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:1279 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2071,12 +2575,25 @@ msgid "" " -h, --help show this help message and exit\n" " --foo FOO" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args('X --foo Y'.split())\n" +"Namespace(bar='X', foo='Y')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo FOO] bar\n" +"\n" +"positional arguments:\n" +" bar\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo FOO" #: ../../library/argparse.rst:1294 msgid "An alternative name can be specified with ``metavar``::" msgstr "代わりの名前を、``metavar`` として指定できます::" -#: ../../library/argparse.rst:1296 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', metavar='YYY')\n" @@ -2093,6 +2610,20 @@ msgid "" " -h, --help show this help message and exit\n" " --foo YYY" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', metavar='YYY')\n" +">>> parser.add_argument('bar', metavar='XXX')\n" +">>> parser.parse_args('X --foo Y'.split())\n" +"Namespace(bar='X', foo='Y')\n" +">>> parser.print_help()\n" +"usage: [-h] [--foo YYY] XXX\n" +"\n" +"positional arguments:\n" +" XXX\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo YYY" #: ../../library/argparse.rst:1311 msgid "" @@ -2113,7 +2644,6 @@ msgstr "" "``nargs`` を指定した場合、metavar が複数回利用されるかもしれません。" "``metavar`` にタプルを渡すと、各引数に対して異なる名前を指定できます::" -#: ../../library/argparse.rst:1319 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', nargs=2)\n" @@ -2126,6 +2656,16 @@ msgid "" " -x X X\n" " --foo bar baz" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x', nargs=2)\n" +">>> parser.add_argument('--foo', nargs=2, metavar=('bar', 'baz'))\n" +">>> parser.print_help()\n" +"usage: PROG [-h] [-x X X] [--foo bar baz]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" -x X X\n" +" --foo bar baz" #: ../../library/argparse.rst:1334 msgid "dest" @@ -2146,15 +2686,17 @@ msgstr "" "決定されます。位置引数のアクションについては、 ``dest`` は通常 :meth:" "`~ArgumentParser.add_argument` の第一引数として渡します::" -#: ../../library/argparse.rst:1343 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('bar')\n" ">>> parser.parse_args(['XXX'])\n" "Namespace(bar='XXX')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_args(['XXX'])\n" +"Namespace(bar='XXX')" -#: ../../library/argparse.rst:1348 msgid "" "For optional argument actions, the value of ``dest`` is normally inferred " "from the option strings. :class:`ArgumentParser` generates the value of " @@ -2167,6 +2709,17 @@ msgid "" "characters will be converted to ``_`` characters to make sure the string is " "a valid attribute name. The examples below illustrate this behavior::" msgstr "" +"オプション引数のアクションでは、通常 ``dest`` の値はオプション文字列から決ま" +"ります。\n" +":class:`ArgumentParser` は、二つのダッシュで始まる最初の長いオプション文字列" +"から、先頭の ``-`` を取り除いて ``dest`` の値にします。\n" +"二つのダッシュで始まる長いオプション文字列がなければ、一つのダッシュで始まる" +"最初の長いオプション文字列から、先頭の ``-`` を取り除きます。\n" +"長いオプション文字列がなければ、最初の短いオプション文字列から先頭の ``-`` を" +"取り除きます。\n" +"属性名として使える文字列にするため、内部の ``-`` はすべて ``_`` に変換しま" +"す。\n" +"以下の例でこの動作を示します。 ::" #: ../../library/argparse.rst:1361 msgid "" @@ -2184,15 +2737,17 @@ msgstr "" msgid "``dest`` allows a custom attribute name to be provided::" msgstr "``dest`` にカスタムの属性名を与えることも可能です::" -#: ../../library/argparse.rst:1372 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', dest='bar')\n" ">>> parser.parse_args('--foo XXX'.split())\n" "Namespace(bar='XXX')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', dest='bar')\n" +">>> parser.parse_args('--foo XXX'.split())\n" +"Namespace(bar='XXX')" -#: ../../library/argparse.rst:1377 msgid "" "Multiple arguments may share the same ``dest``. By default, the value from " "the last such argument given on the command line wins. Use " @@ -2200,16 +2755,21 @@ msgid "" "For conflicting *option strings* rather than ``dest`` names, see " "conflict_handler_." msgstr "" +"複数の引数で同じ ``dest`` を使えます。\n" +"デフォルトでは、それらのうちコマンドラインで最後に指定された引数の値が使われ" +"ます。\n" +"すべての値をリストに集めるには、``action='append'`` を使ってください。\n" +"``dest`` の名前ではなく *オプション文字列* が重複する場合は、" +"conflict_handler_ を参照してください。" -#: ../../library/argparse.rst:1382 msgid "Single-dash long option now takes precedence over short options." msgstr "" +"一つのダッシュで始まる長いオプションが、短いオプションより優先されるようにな" +"りました。" -#: ../../library/argparse.rst:1389 msgid "deprecated" -msgstr "" +msgstr "deprecated" -#: ../../library/argparse.rst:1391 msgid "" "During a project's lifetime, some arguments may need to be removed from the " "command line. Before removing them, you should inform your users that the " @@ -2219,8 +2779,15 @@ msgid "" "the future. For arguments, if ``deprecated`` is ``True``, then a warning " "will be printed to :data:`sys.stderr` when the argument is used::" msgstr "" +"プロジェクトの開発を続けるうちに、コマンドライン引数を削除する必要が生じるこ" +"とがあります。\n" +"削除する前に、その引数が非推奨となり、削除される予定であることをユーザーに知" +"らせてください。\n" +":meth:`~ArgumentParser.add_argument` の ``deprecated`` キーワード引数は、その" +"引数が非推奨で将来削除されるかどうかを指定し、デフォルトは ``False`` です。\n" +"``deprecated`` が ``True`` の引数を使うと、:data:`sys.stderr` に警告が表示さ" +"れます。 ::" -#: ../../library/argparse.rst:1401 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser(prog='snake.py')\n" @@ -2231,20 +2798,31 @@ msgid "" "snake.py: warning: option '--legs' is deprecated\n" "Namespace(legs=4)" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser(prog='snake.py')\n" +">>> parser.add_argument('--legs', default=0, type=int, deprecated=True)\n" +">>> parser.parse_args([])\n" +"Namespace(legs=0)\n" +">>> parser.parse_args(['--legs', '4'])\n" +"snake.py: warning: option '--legs' is deprecated\n" +"Namespace(legs=4)" #: ../../library/argparse.rst:1414 msgid "Action classes" msgstr "Action クラス" -#: ../../library/argparse.rst:1416 msgid "" ":class:`!Action` classes implement the Action API, a callable which returns " "a callable which processes arguments from the command-line. Any object which " "follows this API may be passed as the ``action`` parameter to :meth:" "`~ArgumentParser.add_argument`." msgstr "" +":class:`!Action` クラスは Action API を実装します。\n" +"この API は、呼び出されると、コマンドライン引数を処理する呼び出し可能オブジェ" +"クトを返します。\n" +"この API に従うオブジェクトであれば、:meth:`~ArgumentParser.add_argument` の " +"``action`` パラメーターに渡せます。" -#: ../../library/argparse.rst:1425 msgid "" ":class:`!Action` objects are used by an :class:`ArgumentParser` to represent " "the information needed to parse a single argument from one or more strings " @@ -2252,8 +2830,12 @@ msgid "" "positional arguments plus any keyword arguments passed to :meth:" "`ArgumentParser.add_argument` except for the ``action`` itself." msgstr "" +":class:`ArgumentParser` は :class:`!Action` オブジェクトを使って、コマンドラ" +"インの一つ以上の文字列から一つの引数を解析するために必要な情報を表します。\n" +":class:`!Action` クラスは、二つの位置引数と、:meth:`ArgumentParser." +"add_argument` に渡されたキーワード引数 (``action`` 自身を除く) を受け付けなけ" +"ればなりません。" -#: ../../library/argparse.rst:1431 msgid "" "Instances of :class:`!Action` (or return value of any callable to the " "``action`` parameter) should have attributes :attr:`!dest`, :attr:`!" @@ -2261,63 +2843,82 @@ msgid "" "help`, etc. defined. The easiest way to ensure these attributes are defined " "is to call :meth:`!Action.__init__`." msgstr "" +":class:`!Action` のインスタンス (または ``action`` パラメーターに渡した呼び出" +"し可能オブジェクトの返り値) には、:attr:`!dest`、:attr:`!option_strings`、:" +"attr:`!default`、:attr:`!type`、:attr:`!required`、:attr:`!help` などの属性を" +"定義してください。\n" +"これらの属性を確実に定義する最も簡単な方法は、:meth:`!Action.__init__` を呼び" +"出すことです。" -#: ../../library/argparse.rst:1439 msgid "" ":class:`!Action` instances should be callable, so subclasses must override " "the :meth:`!__call__` method, which should accept four parameters:" msgstr "" +":class:`!Action` のインスタンスは呼び出し可能でなければなりません。\n" +"そのため、サブクラスでは :meth:`!__call__` メソッドをオーバーライドし、次の四" +"つの引数を受け付けるようにしてください。" -#: ../../library/argparse.rst:1442 msgid "" "*parser* - The :class:`ArgumentParser` object which contains this action." -msgstr "" +msgstr "*parser* - このアクションを含む :class:`ArgumentParser` オブジェクト。" -#: ../../library/argparse.rst:1444 msgid "" "*namespace* - The :class:`Namespace` object that will be returned by :meth:" "`~ArgumentParser.parse_args`. Most actions add an attribute to this object " "using :func:`setattr`." msgstr "" +"*namespace* - :meth:`~ArgumentParser.parse_args` が返す :class:`Namespace` オ" +"ブジェクト。\n" +"ほとんどのアクションは :func:`setattr` を使って、このオブジェクトに属性を追加" +"します。" -#: ../../library/argparse.rst:1448 msgid "" "*values* - The associated command-line arguments, with any type conversions " "applied. Type conversions are specified with the type_ keyword argument to :" "meth:`~ArgumentParser.add_argument`." msgstr "" +"*values* - 対応するコマンドライン引数に型変換を適用した値。\n" +"型変換は :meth:`~ArgumentParser.add_argument` の type_ キーワード引数で指定し" +"ます。" -#: ../../library/argparse.rst:1452 msgid "" "*option_string* - The option string that was used to invoke this action. The " "``option_string`` argument is optional, and will be absent if the action is " "associated with a positional argument." msgstr "" +"*option_string* - このアクションの呼び出しに使われたオプション文字列。\n" +"``option_string`` 引数は省略可能で、位置引数に対応するアクションでは指定され" +"ません。" -#: ../../library/argparse.rst:1456 msgid "" "The :meth:`!__call__` method may perform arbitrary actions, but will " "typically set attributes on the ``namespace`` based on ``dest`` and " "``values``." msgstr "" +":meth:`!__call__` メソッドは任意の処理を行えますが、通常は ``dest`` と " +"``values`` に基づいて ``namespace`` の属性を設定します。" -#: ../../library/argparse.rst:1461 msgid "" ":class:`!Action` subclasses can define a :meth:`!format_usage` method that " "takes no argument and return a string which will be used when printing the " "usage of the program. If such method is not provided, a sensible default " "will be used." msgstr "" +":class:`!Action` のサブクラスでは、引数を取らず、プログラムの使用法の表示に使" +"う文字列を返す :meth:`!format_usage` メソッドを定義できます。\n" +"このメソッドを定義しなければ、適切なデフォルトの表示が使われます。" -#: ../../library/argparse.rst:1467 msgid "" "A subclass of :class:`Action` for handling boolean flags with positive and " "negative options. Adding a single argument such as ``--foo`` automatically " "creates both ``--foo`` and ``--no-foo`` options, storing ``True`` and " "``False`` respectively::" msgstr "" +"有効にするオプションと無効にするオプションを持つ真偽値のフラグを扱う、:class:" +"`Action` のサブクラスです。\n" +"``--foo`` のような引数を一つ追加すると、``--foo`` と ``--no-foo`` の両方が自" +"動的に作られ、それぞれ ``True`` と ``False`` を格納します。 ::" -#: ../../library/argparse.rst:1472 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -2325,21 +2926,28 @@ msgid "" ">>> parser.parse_args(['--no-foo'])\n" "Namespace(foo=False)" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)\n" +">>> parser.parse_args(['--no-foo'])\n" +"Namespace(foo=False)" -#: ../../library/argparse.rst:1478 msgid "" "Single-dash long options are also supported. For example, negative option ``-" "nofoo`` is automatically added for positive option ``-foo``. But no " "additional options are added for short options such as ``-f``." msgstr "" +"一つのダッシュで始まる長いオプションもサポートしています。\n" +"例えば、有効にするオプション ``-foo`` に対して、無効にするオプション ``-" +"nofoo`` が自動的に追加されます。\n" +"ただし、``-f`` のような短いオプションに対しては、追加のオプションは作られませ" +"ん。" -#: ../../library/argparse.rst:1485 msgid "Added support for single-dash options." -msgstr "" +msgstr "一つのダッシュで始まるオプションのサポートが追加されました。" -#: ../../library/argparse.rst:1488 msgid "Added support for alternate prefix_chars_." -msgstr "" +msgstr "別の prefix_chars_ を使う場合のサポートが追加されました。" #: ../../library/argparse.rst:1492 msgid "The parse_args() method" @@ -2353,12 +2961,14 @@ msgstr "" "引数の文字列をオブジェクトに変換し、namespace オブジェクトの属性に代入しま" "す。結果の namespace オブジェクトを返します。" -#: ../../library/argparse.rst:1499 msgid "" "Previous calls to :meth:`add_argument` determine exactly what objects are " "created and how they are assigned. See the documentation for :meth:`!" "add_argument` for details." msgstr "" +"どのようなオブジェクトを作り、どう代入するかは、それまでの :meth:" +"`add_argument` の呼び出しで決まります。\n" +"詳細は :meth:`!add_argument` のドキュメントを参照してください。" #: ../../library/argparse.rst:1503 msgid "" @@ -2390,7 +3000,6 @@ msgstr "" "オプションの値の指定に複数の方法をサポートしています。もっとも単純な場合に" "は、オプションとその値は次のように2つの別々の引数として渡されます::" -#: ../../library/argparse.rst:1517 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x')\n" @@ -2400,6 +3009,13 @@ msgid "" ">>> parser.parse_args(['--foo', 'FOO'])\n" "Namespace(foo='FOO', x=None)" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x')\n" +">>> parser.add_argument('--foo')\n" +">>> parser.parse_args(['-x', 'X'])\n" +"Namespace(foo=None, x='X')\n" +">>> parser.parse_args(['--foo', 'FOO'])\n" +"Namespace(foo='FOO', x=None)" #: ../../library/argparse.rst:1525 msgid "" @@ -2411,11 +3027,12 @@ msgstr "" "値は次のように ``=`` で区切られた1つのコマンドライン引数として渡すこともでき" "ます::" -#: ../../library/argparse.rst:1529 msgid "" ">>> parser.parse_args(['--foo=FOO'])\n" "Namespace(foo='FOO', x=None)" msgstr "" +">>> parser.parse_args(['--foo=FOO'])\n" +"Namespace(foo='FOO', x=None)" #: ../../library/argparse.rst:1532 msgid "" @@ -2425,11 +3042,12 @@ msgstr "" "短いオプション (1文字のオプション) では、オプションとその値は次のように連結し" "て渡すことができます::" -#: ../../library/argparse.rst:1535 msgid "" ">>> parser.parse_args(['-xX'])\n" "Namespace(foo=None, x='X')" msgstr "" +">>> parser.parse_args(['-xX'])\n" +"Namespace(foo=None, x='X')" #: ../../library/argparse.rst:1538 msgid "" @@ -2440,7 +3058,6 @@ msgstr "" "い場合、複数の短いオプションは次のように1つの接頭辞 ``-`` だけで連結できま" "す::" -#: ../../library/argparse.rst:1541 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-x', action='store_true')\n" @@ -2449,6 +3066,12 @@ msgid "" ">>> parser.parse_args(['-xyzZ'])\n" "Namespace(x=True, y=True, z='Z')" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-x', action='store_true')\n" +">>> parser.add_argument('-y', action='store_true')\n" +">>> parser.add_argument('-z')\n" +">>> parser.parse_args(['-xyzZ'])\n" +"Namespace(x=True, y=True, z='Z')" #: ../../library/argparse.rst:1550 msgid "Invalid arguments" @@ -2466,7 +3089,6 @@ msgstr "" "ます。それらのエラーが発生した場合、エラーメッセージと使用法メッセージを表示" "して終了します::" -#: ../../library/argparse.rst:1557 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('--foo', type=int)\n" @@ -2487,6 +3109,24 @@ msgid "" "usage: PROG [-h] [--foo FOO] [bar]\n" "PROG: error: unrecognized arguments: badger" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', type=int)\n" +">>> parser.add_argument('bar', nargs='?')\n" +"\n" +">>> # 不正な型\n" +">>> parser.parse_args(['--foo', 'spam'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: argument --foo: invalid int value: 'spam'\n" +"\n" +">>> # 不正なオプション\n" +">>> parser.parse_args(['--bar'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: unrecognized arguments: --bar\n" +"\n" +">>> # 引数の数が不正\n" +">>> parser.parse_args(['spam', 'badger'])\n" +"usage: PROG [-h] [--foo FOO] [bar]\n" +"PROG: error: unrecognized arguments: badger" #: ../../library/argparse.rst:1578 msgid "Arguments containing ``-``" @@ -2554,24 +3194,27 @@ msgstr "" "引数 ``'--'`` を挿入して、:meth:`~ArgumentParser.parse_args` にそれ以降のすべ" "てが位置引数だと教えることができます::" -#: ../../library/argparse.rst:1623 msgid "" ">>> parser.parse_args(['--', '-f'])\n" "Namespace(foo='-f', one=None)" msgstr "" +">>> parser.parse_args(['--', '-f'])\n" +"Namespace(foo='-f', one=None)" -#: ../../library/argparse.rst:1626 msgid "" "See also :ref:`the argparse howto on ambiguous arguments ` for more details." msgstr "" +"詳細は :ref:`argparse の HOWTO の曖昧な引数についての説明 ` も参照してください。" -#: ../../library/argparse.rst:1629 msgid "" "Negative-number matching was expanded to include numbers in scientific " "notation (``-2.5e-6``), numbers containing underscores (``-1_234.5``), and " "complex numbers (``-1.2e-3j``)." msgstr "" +"負数として認識する形式を拡張し、指数表記の数値 (``-2.5e-6``)、アンダースコア" +"を含む数値 (``-1_234.5``)、複素数 (``-1.2e-3j``) も認識するようになりました。" #: ../../library/argparse.rst:1637 msgid "Argument abbreviations (prefix matching)" @@ -2587,7 +3230,6 @@ msgstr "" "`、長いオプションに曖昧さがない (先頭文字列が一意である) かぎ" "り、先頭文字列に短縮して指定できます::" -#: ../../library/argparse.rst:1643 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> parser.add_argument('-bacon')\n" @@ -2600,6 +3242,16 @@ msgid "" "usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" "PROG: error: ambiguous option: -ba could match -badger, -bacon" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('-bacon')\n" +">>> parser.add_argument('-badger')\n" +">>> parser.parse_args('-bac MMM'.split())\n" +"Namespace(bacon='MMM', badger=None)\n" +">>> parser.parse_args('-bad WOOD'.split())\n" +"Namespace(bacon=None, badger='WOOD')\n" +">>> parser.parse_args('-ba BA'.split())\n" +"usage: PROG [-h] [-bacon BACON] [-badger BADGER]\n" +"PROG: error: ambiguous option: -ba could match -badger, -bacon" #: ../../library/argparse.rst:1654 msgid "" @@ -2613,15 +3265,18 @@ msgstr "" msgid "Beyond ``sys.argv``" msgstr "``sys.argv`` 以外" -#: ../../library/argparse.rst:1662 msgid "" "Sometimes it may be useful to have an :class:`ArgumentParser` parse " "arguments other than those of :data:`sys.argv`. This can be accomplished by " "passing a list of strings to :meth:`~ArgumentParser.parse_args`. This is " "useful for testing at the interactive prompt::" msgstr "" +":class:`ArgumentParser` で :data:`sys.argv` 以外の引数を解析したい場合もあり" +"ます。\n" +"その場合は、:meth:`~ArgumentParser.parse_args` に文字列のリストを渡してくださ" +"い。\n" +"対話プロンプトでのテストに便利です。 ::" -#: ../../library/argparse.rst:1667 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument(\n" @@ -2635,6 +3290,17 @@ msgid "" ">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" "Namespace(accumulate=, integers=[1, 2, 3, 4])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument(\n" +"... 'integers', metavar='int', type=int, choices=range(10),\n" +"... nargs='+', help='an integer in the range 0..9')\n" +">>> parser.add_argument(\n" +"... '--sum', dest='accumulate', action='store_const', const=sum,\n" +"... default=max, help='sum the integers (default: find the max)')\n" +">>> parser.parse_args(['1', '2', '3', '4'])\n" +"Namespace(accumulate=, integers=[1, 2, 3, 4])\n" +">>> parser.parse_args(['1', '2', '3', '4', '--sum'])\n" +"Namespace(accumulate=, integers=[1, 2, 3, 4])" #: ../../library/argparse.rst:1682 msgid "The Namespace object" @@ -2658,7 +3324,6 @@ msgstr "" "class:`object` のサブクラスです。もし属性を辞書のように扱える方が良ければ、標" "準的な Python のイディオム :func:`vars` を利用できます::" -#: ../../library/argparse.rst:1693 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -2666,6 +3331,11 @@ msgid "" ">>> vars(args)\n" "{'foo': 'BAR'}" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> args = parser.parse_args(['--foo', 'BAR'])\n" +">>> vars(args)\n" +"{'foo': 'BAR'}" #: ../../library/argparse.rst:1699 msgid "" @@ -2677,7 +3347,6 @@ msgstr "" "既存のオブジェクトに属性を設定する方が良い場合があります。これは " "``namespace=`` キーワード引数を指定することで可能です::" -#: ../../library/argparse.rst:1703 msgid "" ">>> class C:\n" "... pass\n" @@ -2689,16 +3358,23 @@ msgid "" ">>> c.foo\n" "'BAR'" msgstr "" +">>> class C:\n" +"... pass\n" +"...\n" +">>> c = C()\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.parse_args(args=['--foo', 'BAR'], namespace=c)\n" +">>> c.foo\n" +"'BAR'" #: ../../library/argparse.rst:1715 msgid "Other utilities" msgstr "その他のユーティリティ" -#: ../../library/argparse.rst:1718 msgid "Subcommands" -msgstr "" +msgstr "サブコマンド" -#: ../../library/argparse.rst:1725 msgid "" "Many programs split up their functionality into a number of subcommands, for " "example, the ``svn`` program can invoke subcommands like ``svn checkout``, " @@ -2712,36 +3388,54 @@ msgid "" "command name and any :class:`!ArgumentParser` constructor arguments, and " "returns an :class:`!ArgumentParser` object that can be modified as usual." msgstr "" +"多くのプログラムは、機能をいくつかのサブコマンドに分けています。\n" +"例えば ``svn`` プログラムでは、``svn checkout``、``svn update``、``svn " +"commit`` などのサブコマンドを呼び出せます。\n" +"それぞれ異なる種類のコマンドライン引数を必要とする複数の機能を持つプログラム" +"では、このように分ける方法が特に適しています。\n" +":class:`ArgumentParser` では :meth:`!add_subparsers` メソッドでサブコマンドを" +"作成できます。\n" +"通常、:meth:`!add_subparsers` は引数なしで呼び出し、専用のアクションオブジェ" +"クトを返します。\n" +"このオブジェクトの :meth:`~_SubParsersAction.add_parser` メソッドは、コマンド" +"名と任意の :class:`!ArgumentParser` コンストラクター引数を受け取り、通常と同" +"じように設定できる :class:`!ArgumentParser` オブジェクトを返します。" #: ../../library/argparse.rst:1737 msgid "Description of parameters:" msgstr "引数の説明:" -#: ../../library/argparse.rst:1739 msgid "" "*title* - title for the sub-parser group in help output; by default " "\"subcommands\" if description is provided, otherwise uses title for " "positional arguments" msgstr "" +"*title* - ヘルプに表示するサブパーサーグループのタイトル。\n" +"デフォルトでは、``description`` が指定されていれば \"subcommands\"、そうでな" +"ければ位置引数のタイトルを使います。" -#: ../../library/argparse.rst:1743 msgid "" "*description* - description for the sub-parser group in help output, by " "default ``None``" msgstr "" +"*description* - ヘルプに表示するサブパーサーグループの説明。\n" +"デフォルトは ``None`` です。" -#: ../../library/argparse.rst:1746 msgid "" "*prog* - usage information that will be displayed with subcommand help, by " "default the name of the program and any positional arguments before the " "subparser argument" msgstr "" +"*prog* - サブコマンドのヘルプに表示する使用法の情報。\n" +"デフォルトでは、プログラム名とサブパーサー引数より前にあるすべての位置引数で" +"す。" -#: ../../library/argparse.rst:1750 msgid "" "*parser_class* - class which will be used to create sub-parser instances, by " "default the class of the current parser (e.g. :class:`ArgumentParser`)" msgstr "" +"*parser_class* - サブパーサーのインスタンスを作るクラス。\n" +"デフォルトでは、現在のパーサーのクラス (:class:`ArgumentParser` など) です。" #: ../../library/argparse.rst:1753 msgid "" @@ -2749,11 +3443,12 @@ msgid "" "encountered at the command line" msgstr "action_ - コマンドラインにこの引数があったときの基本のアクション。" -#: ../../library/argparse.rst:1756 msgid "" "dest_ - name of the attribute under which subcommand name will be stored; by " "default ``None`` and no value is stored" msgstr "" +"dest_ - サブコマンド名を格納する属性の名前。\n" +"デフォルトは ``None`` で、値は格納されません。" #: ../../library/argparse.rst:1759 msgid "" @@ -2769,17 +3464,17 @@ msgstr "" "help_ - ヘルプ出力に表示されるサブパーサーグループのヘルプです。デフォルトは " "``None`` です" -#: ../../library/argparse.rst:1764 msgid "" "metavar_ - string presenting available subcommands in help; by default it is " "``None`` and presents subcommands in form {cmd1, cmd2, ..}" msgstr "" +"metavar_ - ヘルプで利用可能なサブコマンドを表す文字列。\n" +"デフォルトは ``None`` で、{cmd1, cmd2, ..} の形式で表示されます。" #: ../../library/argparse.rst:1767 msgid "Some example usage::" msgstr "いくつかの使用例::" -#: ../../library/argparse.rst:1769 msgid "" ">>> # create the top-level parser\n" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" @@ -2801,8 +3496,26 @@ msgid "" ">>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])\n" "Namespace(baz='Z', foo=True)" msgstr "" +">>> # 最上位のパーサーを作成する\n" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> parser.add_argument('--foo', action='store_true', help='foo help')\n" +">>> subparsers = parser.add_subparsers(help='subcommand help')\n" +">>>\n" +">>> # \"a\" コマンド用のパーサーを作成する\n" +">>> parser_a = subparsers.add_parser('a', help='a help')\n" +">>> parser_a.add_argument('bar', type=int, help='bar help')\n" +">>>\n" +">>> # \"b\" コマンド用のパーサーを作成する\n" +">>> parser_b = subparsers.add_parser('b', help='b help')\n" +">>> parser_b.add_argument('--baz', choices=('X', 'Y', 'Z'), help='baz " +"help')\n" +">>>\n" +">>> # 引数リストを解析する\n" +">>> parser.parse_args(['a', '12'])\n" +"Namespace(bar=12, foo=False)\n" +">>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])\n" +"Namespace(baz='Z', foo=True)" -#: ../../library/argparse.rst:1788 msgid "" "Note that the object returned by :meth:`~ArgumentParser.parse_args` will " "only contain attributes for the main parser and the subparser that was " @@ -2811,14 +3524,21 @@ msgid "" "``bar`` attributes are present, and when the ``b`` command is specified, " "only the ``foo`` and ``baz`` attributes are present." msgstr "" +":meth:`~ArgumentParser.parse_args` が返すオブジェクトに含まれるのは、メイン" +"パーサーと、コマンドラインで選ばれたサブパーサーの属性だけです。\n" +"それ以外のサブパーサーの属性は含まれません。\n" +"上の例では、``a`` コマンドを指定すると ``foo`` と ``bar`` 属性だけが存在し、" +"``b`` コマンドを指定すると ``foo`` と ``baz`` 属性だけが存在します。" -#: ../../library/argparse.rst:1795 msgid "" "If a subparser defines an argument with the same ``dest`` as the parent " "parser, the two share a single namespace attribute, so the parent's value " "won't be retained. Users should give them distinct ``dest`` values to keep " "both." msgstr "" +"サブパーサーが親パーサーと同じ ``dest`` の引数を定義すると、両者は同じ名前空" +"間の属性を共有するため、親の値は保持されません。\n" +"両方の値を保持するには、異なる ``dest`` を指定してください。" #: ../../library/argparse.rst:1800 msgid "" @@ -2834,7 +3554,6 @@ msgstr "" "メッセージは、上の例にもあるように :meth:`~_SubParsersAction.add_parser` の " "``help=`` 引数によって指定できます)" -#: ../../library/argparse.rst:1808 msgid "" ">>> parser.parse_args(['--help'])\n" "usage: PROG [-h] [--foo] {a,b} ...\n" @@ -2864,16 +3583,46 @@ msgid "" " -h, --help show this help message and exit\n" " --baz {X,Y,Z} baz help" msgstr "" +">>> parser.parse_args(['--help'])\n" +"usage: PROG [-h] [--foo] {a,b} ...\n" +"\n" +"positional arguments:\n" +" {a,b} subcommand help\n" +" a a help\n" +" b b help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --foo foo help\n" +"\n" +">>> parser.parse_args(['a', '--help'])\n" +"usage: PROG a [-h] bar\n" +"\n" +"positional arguments:\n" +" bar bar help\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +">>> parser.parse_args(['b', '--help'])\n" +"usage: PROG b [-h] [--baz {X,Y,Z}]\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +" --baz {X,Y,Z} baz help" -#: ../../library/argparse.rst:1836 msgid "" "The :meth:`~ArgumentParser.add_subparsers` method also supports ``title`` " "and ``description`` keyword arguments. When either is present, the " "subparser's commands will appear in their own group in the help output. For " "example::" msgstr "" +":meth:`~ArgumentParser.add_subparsers` メソッドは ``title`` と " +"``description`` キーワード引数もサポートしています。\n" +"どちらかを指定すると、サブパーサーのコマンドがヘルプ内で独立したグループとし" +"て表示されます。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:1840 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(title='subcommands',\n" @@ -2892,16 +3641,34 @@ msgid "" "\n" " {foo,bar} additional help" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(title='subcommands',\n" +"... description='valid subcommands',\n" +"... help='additional help')\n" +">>> subparsers.add_parser('foo')\n" +">>> subparsers.add_parser('bar')\n" +">>> parser.parse_args(['-h'])\n" +"usage: [-h] {foo,bar} ...\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"subcommands:\n" +" valid subcommands\n" +"\n" +" {foo,bar} additional help" -#: ../../library/argparse.rst:1857 msgid "" "One particularly effective way of handling subcommands is to combine the use " "of the :meth:`~ArgumentParser.add_subparsers` method with calls to :meth:" "`~ArgumentParser.set_defaults` so that each subparser knows which Python " "function it should execute. For example::" msgstr "" +"サブコマンドを扱う特に効果的な方法は、:meth:`~ArgumentParser.add_subparsers` " +"と :meth:`~ArgumentParser.set_defaults` を組み合わせて、各サブパーサーに実行" +"すべき Python 関数を設定することです。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:1862 msgid "" ">>> # subcommand functions\n" ">>> def foo(args):\n" @@ -2935,6 +3702,37 @@ msgid "" ">>> args.func(args)\n" "((XYZYX))" msgstr "" +">>> # サブコマンドの関数\n" +">>> def foo(args):\n" +"... print(args.x * args.y)\n" +"...\n" +">>> def bar(args):\n" +"... print('((%s))' % args.z)\n" +"...\n" +">>> # 最上位のパーサーを作成する\n" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(required=True)\n" +">>>\n" +">>> # \"foo\" コマンド用のパーサーを作成する\n" +">>> parser_foo = subparsers.add_parser('foo')\n" +">>> parser_foo.add_argument('-x', type=int, default=1)\n" +">>> parser_foo.add_argument('y', type=float)\n" +">>> parser_foo.set_defaults(func=foo)\n" +">>>\n" +">>> # \"bar\" コマンド用のパーサーを作成する\n" +">>> parser_bar = subparsers.add_parser('bar')\n" +">>> parser_bar.add_argument('z')\n" +">>> parser_bar.set_defaults(func=bar)\n" +">>>\n" +">>> # 引数を解析し、選ばれた関数を呼び出す\n" +">>> args = parser.parse_args('foo 1 -x 2'.split())\n" +">>> args.func(args)\n" +"2.0\n" +">>>\n" +">>> # 引数を解析し、選ばれた関数を呼び出す\n" +">>> args = parser.parse_args('bar XYZYX'.split())\n" +">>> args.func(args)\n" +"((XYZYX))" #: ../../library/argparse.rst:1894 msgid "" @@ -2947,7 +3745,6 @@ msgid "" "work::" msgstr "" -#: ../../library/argparse.rst:1901 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" @@ -2958,38 +3755,45 @@ msgid "" ">>> parser.parse_args(['2', 'frobble'])\n" "Namespace(subparser_name='2', y='frobble')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers(dest='subparser_name')\n" +">>> subparser1 = subparsers.add_parser('1')\n" +">>> subparser1.add_argument('-x')\n" +">>> subparser2 = subparsers.add_parser('2')\n" +">>> subparser2.add_argument('y')\n" +">>> parser.parse_args(['2', 'frobble'])\n" +"Namespace(subparser_name='2', y='frobble')" -#: ../../library/argparse.rst:1910 msgid "New *required* keyword-only parameter." -msgstr "" +msgstr "キーワード専用の *required* パラメーターが追加されました。" -#: ../../library/argparse.rst:1913 msgid "" "Subparser's *prog* is no longer affected by a custom usage message in the " "main parser." msgstr "" +"メインパーサーに指定した独自の使用法メッセージが、サブパーサーの *prog* に影" +"響しなくなりました。" -#: ../../library/argparse.rst:1921 msgid "" "Create and return a new :class:`ArgumentParser` object for the subcommand " "*name*." msgstr "" +"サブコマンド *name* 用の新しい :class:`ArgumentParser` オブジェクトを作成して" +"返します。" -#: ../../library/argparse.rst:1924 msgid "The *name* argument is the name of the sub-command." -msgstr "" +msgstr "*name* 引数はサブコマンドの名前です。" -#: ../../library/argparse.rst:1926 msgid "The *help* argument provides a short description for this sub-command." -msgstr "" +msgstr "*help* 引数は、このサブコマンドの簡潔な説明を指定します。" -#: ../../library/argparse.rst:1928 msgid "" "The *aliases* argument allows providing alternative names for this sub-" "command. For example::" msgstr "" +"*aliases* 引数では、このサブコマンドの別名を指定できます。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:1931 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> subparsers = parser.add_subparsers()\n" @@ -2998,12 +3802,20 @@ msgid "" ">>> parser.parse_args(['co', 'bar'])\n" "Namespace(foo='bar')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> subparsers = parser.add_subparsers()\n" +">>> checkout = subparsers.add_parser('checkout', aliases=['co'])\n" +">>> checkout.add_argument('foo')\n" +">>> parser.parse_args(['co', 'bar'])\n" +"Namespace(foo='bar')" -#: ../../library/argparse.rst:1938 msgid "" "The *deprecated* argument, if ``True``, marks the sub-command as deprecated " "and will issue a warning when used. For example::" msgstr "" +"*deprecated* 引数を ``True`` にすると、そのサブコマンドを非推奨とし、使用時に" +"警告を表示します。\n" +"例えば次のようになります。 ::" #: ../../library/argparse.rst:1941 msgid "" @@ -3015,15 +3827,15 @@ msgid "" "Namespace()" msgstr "" -#: ../../library/argparse.rst:1948 msgid "" "All other keyword arguments are passed directly to the :class:`!" "ArgumentParser` constructor." msgstr "" +"それ以外のキーワード引数はすべて、:class:`!ArgumentParser` コンストラクターに" +"直接渡されます。" -#: ../../library/argparse.rst:1951 msgid "Added the *deprecated* parameter." -msgstr "" +msgstr "*deprecated* パラメーターが追加されました。" #: ../../library/argparse.rst:1956 msgid "FileType objects" @@ -3043,7 +3855,6 @@ msgstr "" "ズ、エンコーディング、エラー処理でファイルとして開きます (詳細は :func:" "`open` 関数を参照してください。)::" -#: ../../library/argparse.rst:1966 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" @@ -3053,6 +3864,13 @@ msgid "" "Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " "raw=<_io.FileIO name='raw.dat' mode='wb'>)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))\n" +">>> parser.add_argument('out', type=argparse.FileType('w', " +"encoding='UTF-8'))\n" +">>> parser.parse_args(['--raw', 'raw.dat', 'file.txt'])\n" +"Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, " +"raw=<_io.FileIO name='raw.dat' mode='wb'>)" #: ../../library/argparse.rst:1972 msgid "" @@ -3064,15 +3882,17 @@ msgstr "" "`FileType` であれば :data:`sys.stdin` を、書き込み用の :class:`FileType` であ" "れば :data:`sys.stdout` に変換します::" -#: ../../library/argparse.rst:1976 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" ">>> parser.parse_args(['-'])\n" "Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('infile', type=argparse.FileType('r'))\n" +">>> parser.parse_args(['-'])\n" +"Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>)" -#: ../../library/argparse.rst:1983 msgid "" "If one argument uses *FileType* and then a subsequent argument fails, an " "error is reported but the file is not automatically closed. This can also " @@ -3080,6 +3900,11 @@ msgid "" "after the parser has run and then use the :keyword:`with`-statement to " "manage the files." msgstr "" +"ある引数で *FileType* を使い、その後の引数でエラーが起きると、エラーは報告さ" +"れますが、ファイルは自動的には閉じられません。\n" +"出力ファイルの内容を失うこともあります。\n" +"この場合は、引数の解析が終わってから :keyword:`with` 文でファイルを管理する方" +"が適切です。" #: ../../library/argparse.rst:1989 msgid "Added the *encoding* and *errors* parameters." @@ -3089,7 +3914,6 @@ msgstr "*encoding* と *errors* が引数に追加されました。" msgid "Argument groups" msgstr "引数グループ" -#: ../../library/argparse.rst:2001 msgid "" "By default, :class:`ArgumentParser` groups command-line arguments into " "\"positional arguments\" and \"options\" when displaying help messages. When " @@ -3097,8 +3921,11 @@ msgid "" "appropriate groups can be created using the :meth:`!add_argument_group` " "method::" msgstr "" +"デフォルトでは、:class:`ArgumentParser` はヘルプを表示する際に、コマンドライ" +"ン引数を \"positional arguments\" と \"options\" に分けます。\n" +"引数の意味に応じた別の分け方が適している場合は、:meth:`!add_argument_group` " +"メソッドでグループを作成できます。 ::" -#: ../../library/argparse.rst:2007 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group = parser.add_argument_group('group')\n" @@ -3111,8 +3938,17 @@ msgid "" " bar bar help\n" " --foo FOO foo help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> group = parser.add_argument_group('group')\n" +">>> group.add_argument('--foo', help='foo help')\n" +">>> group.add_argument('bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [--foo FOO] bar\n" +"\n" +"group:\n" +" bar bar help\n" +" --foo FOO foo help" -#: ../../library/argparse.rst:2018 msgid "" "The :meth:`add_argument_group` method returns an argument group object which " "has an :meth:`~ArgumentParser.add_argument` method just like a regular :" @@ -3122,8 +3958,14 @@ msgid "" "accepts *title* and *description* arguments which can be used to customize " "this display::" msgstr "" +":meth:`add_argument_group` メソッドは、通常の :class:`ArgumentParser` と同じ" +"ように :meth:`~ArgumentParser.add_argument` メソッドを持つ引数グループオブ" +"ジェクトを返します。\n" +"グループに追加した引数は通常の引数と同じように処理されますが、ヘルプでは別の" +"グループに表示されます。\n" +":meth:`!add_argument_group` の *title* と *description* 引数で、この表示をカ" +"スタマイズできます。 ::" -#: ../../library/argparse.rst:2026 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" ">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" @@ -3143,8 +3985,24 @@ msgid "" "\n" " --bar BAR bar help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)\n" +">>> group1 = parser.add_argument_group('group1', 'group1 description')\n" +">>> group1.add_argument('foo', help='foo help')\n" +">>> group2 = parser.add_argument_group('group2', 'group2 description')\n" +">>> group2.add_argument('--bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [--bar BAR] foo\n" +"\n" +"group1:\n" +" group1 description\n" +"\n" +" foo foo help\n" +"\n" +"group2:\n" +" group2 description\n" +"\n" +" --bar BAR bar help" -#: ../../library/argparse.rst:2044 msgid "" "The optional, keyword-only parameters argument_default_ and " "conflict_handler_ allow for finer-grained control of the behavior of the " @@ -3152,6 +4010,10 @@ msgid "" "`ArgumentParser` constructor, but apply specifically to the argument group " "rather than the entire parser." msgstr "" +"省略可能なキーワード専用パラメーター argument_default_ と conflict_handler_ " +"を使うと、引数グループの動作をより細かく制御できます。\n" +"これらの意味は :class:`ArgumentParser` コンストラクターと同じですが、パーサー" +"全体ではなく、その引数グループだけに適用されます。" #: ../../library/argparse.rst:2049 msgid "" @@ -3161,35 +4023,39 @@ msgstr "" "ユーザー定義グループにないすべての引数は通常の \"位置引数\" と \"オプション引" "数\" セクションに表示されます。" -#: ../../library/argparse.rst:2052 msgid "" "Within each argument group, arguments are displayed in help output in the " "order in which they are added." -msgstr "" +msgstr "各引数グループ内の引数は、追加した順にヘルプに表示されます。" -#: ../../library/argparse.rst:2055 msgid "" "Calling :meth:`add_argument_group` on an argument group now raises an " "exception. This nesting was never supported, often failed to work correctly, " "and was unintentionally exposed through inheritance." msgstr "" +"引数グループに対して :meth:`add_argument_group` を呼び出すと、例外が送出され" +"るようになりました。\n" +"この入れ子構造はもともとサポートされておらず、正しく動作しないことも多くあり" +"ました。\n" +"継承によって意図せず利用可能になっていたものです。" -#: ../../library/argparse.rst:2060 msgid "Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated." msgstr "" +":meth:`add_argument_group` に prefix_chars_ を渡すことは非推奨になりました。" #: ../../library/argparse.rst:2066 msgid "Mutual exclusion" msgstr "相互排他" -#: ../../library/argparse.rst:2070 msgid "" "Create a mutually exclusive group. :mod:`!argparse` will make sure that only " "one of the arguments in the mutually exclusive group was present on the " "command line::" msgstr "" +"相互排他グループを作成します。\n" +":mod:`!argparse` は、そのグループに含まれる複数の引数がコマンドラインで同時に" +"指定されないことを確認します。 ::" -#: ../../library/argparse.rst:2074 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group()\n" @@ -3203,6 +4069,17 @@ msgid "" "usage: PROG [-h] [--foo | --bar]\n" "PROG: error: argument --bar: not allowed with argument --foo" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_mutually_exclusive_group()\n" +">>> group.add_argument('--foo', action='store_true')\n" +">>> group.add_argument('--bar', action='store_false')\n" +">>> parser.parse_args(['--foo'])\n" +"Namespace(bar=True, foo=True)\n" +">>> parser.parse_args(['--bar'])\n" +"Namespace(bar=False, foo=False)\n" +">>> parser.parse_args(['--foo', '--bar'])\n" +"usage: PROG [-h] [--foo | --bar]\n" +"PROG: error: argument --bar: not allowed with argument --foo" #: ../../library/argparse.rst:2086 msgid "" @@ -3213,7 +4090,6 @@ msgstr "" ":meth:`add_mutually_exclusive_group` メソッドの引数 *required* に True 値を指" "定すると、その相互排他引数のどれか1つを選ぶことが要求されます::" -#: ../../library/argparse.rst:2090 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_mutually_exclusive_group(required=True)\n" @@ -3223,16 +4099,26 @@ msgid "" "usage: PROG [-h] (--foo | --bar)\n" "PROG: error: one of the arguments --foo --bar is required" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_mutually_exclusive_group(required=True)\n" +">>> group.add_argument('--foo', action='store_true')\n" +">>> group.add_argument('--bar', action='store_false')\n" +">>> parser.parse_args([])\n" +"usage: PROG [-h] (--foo | --bar)\n" +"PROG: error: one of the arguments --foo --bar is required" -#: ../../library/argparse.rst:2098 msgid "" "Note that currently mutually exclusive argument groups do not support the " "*title* and *description* arguments of :meth:`~ArgumentParser." "add_argument_group`. However, a mutually exclusive group can be added to an " "argument group that has a title and description. For example::" msgstr "" +"現在、相互排他引数グループでは :meth:`~ArgumentParser.add_argument_group` の " +"*title* と *description* 引数はサポートされていません。\n" +"ただし、タイトルと説明を持つ引数グループに、相互排他グループを追加することは" +"できます。\n" +"例えば次のようになります。 ::" -#: ../../library/argparse.rst:2104 msgid "" ">>> parser = argparse.ArgumentParser(prog='PROG')\n" ">>> group = parser.add_argument_group('Group title', 'Group description')\n" @@ -3251,14 +4137,35 @@ msgid "" " --foo FOO foo help\n" " --bar BAR bar help" msgstr "" +">>> parser = argparse.ArgumentParser(prog='PROG')\n" +">>> group = parser.add_argument_group('Group title', 'Group description')\n" +">>> exclusive_group = group.add_mutually_exclusive_group(required=True)\n" +">>> exclusive_group.add_argument('--foo', help='foo help')\n" +">>> exclusive_group.add_argument('--bar', help='bar help')\n" +">>> parser.print_help()\n" +"usage: PROG [-h] (--foo FOO | --bar BAR)\n" +"\n" +"options:\n" +" -h, --help show this help message and exit\n" +"\n" +"Group title:\n" +" Group description\n" +"\n" +" --foo FOO foo help\n" +" --bar BAR bar help" -#: ../../library/argparse.rst:2121 msgid "" "Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` " "on a mutually exclusive group now raises an exception. This nesting was " "never supported, often failed to work correctly, and was unintentionally " "exposed through inheritance." msgstr "" +"相互排他グループに対して :meth:`add_argument_group` または :meth:" +"`add_mutually_exclusive_group` を呼び出すと、例外が送出されるようになりまし" +"た。\n" +"この入れ子構造はもともとサポートされておらず、正しく動作しないことも多くあり" +"ました。\n" +"継承によって意図せず利用可能になっていたものです。" #: ../../library/argparse.rst:2129 msgid "Parser defaults" @@ -3277,7 +4184,6 @@ msgstr "" "を使うと与えられたコマンドライン引数の内容によらず追加の属性を決定することが" "可能です::" -#: ../../library/argparse.rst:2139 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('foo', type=int)\n" @@ -3285,16 +4191,23 @@ msgid "" ">>> parser.parse_args(['736'])\n" "Namespace(bar=42, baz='badger', foo=736)" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('foo', type=int)\n" +">>> parser.set_defaults(bar=42, baz='badger')\n" +">>> parser.parse_args(['736'])\n" +"Namespace(bar=42, baz='badger', foo=736)" -#: ../../library/argparse.rst:2145 msgid "" "Note that defaults can be set at both the parser level using :meth:" "`set_defaults` and at the argument level using :meth:`add_argument`. If both " "are called for the same argument, the last default set for an argument is " "used::" msgstr "" +"デフォルト値は、:meth:`set_defaults` でパーサーに設定することも、:meth:" +"`add_argument` で個々の引数に設定することもできます。\n" +"同じ引数について両方を呼び出した場合は、最後に設定したデフォルト値が使われま" +"す。 ::" -#: ../../library/argparse.rst:2149 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='bar')\n" @@ -3302,6 +4215,11 @@ msgid "" ">>> parser.parse_args([])\n" "Namespace(foo='spam')" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default='bar')\n" +">>> parser.set_defaults(foo='spam')\n" +">>> parser.parse_args([])\n" +"Namespace(foo='spam')" #: ../../library/argparse.rst:2155 msgid "" @@ -3321,13 +4239,16 @@ msgstr "" ":meth:`~ArgumentParser.add_argument` か :meth:`~ArgumentParser.set_defaults` " "によって指定された、 namespace の属性のデフォルト値を取得します::" -#: ../../library/argparse.rst:2165 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', default='badger')\n" ">>> parser.get_default('foo')\n" "'badger'" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', default='badger')\n" +">>> parser.get_default('foo')\n" +"'badger'" #: ../../library/argparse.rst:2172 msgid "Printing help" @@ -3390,23 +4311,27 @@ msgstr "" msgid "Partial parsing" msgstr "部分解析" -#: ../../library/argparse.rst:2209 msgid "" "Sometimes a script only needs to handle a specific set of command-line " "arguments, leaving any unrecognized arguments for another script or program. " "In these cases, the :meth:`~ArgumentParser.parse_known_args` method can be " "useful." msgstr "" +"スクリプトが特定のコマンドライン引数だけを処理し、認識できない引数を別のスク" +"リプトやプログラムに渡したい場合があります。\n" +"その場合は :meth:`~ArgumentParser.parse_known_args` メソッドが便利です。" -#: ../../library/argparse.rst:2214 msgid "" "This method works similarly to :meth:`~ArgumentParser.parse_args`, but it " "does not raise an error for extra, unrecognized arguments. Instead, it " "parses the known arguments and returns a two item tuple that contains the " "populated namespace and the list of any unrecognized arguments." msgstr "" +"このメソッドは :meth:`~ArgumentParser.parse_args` と同様に動作しますが、認識" +"できない余分な引数があってもエラーにはなりません。\n" +"認識できる引数を解析し、値を設定した名前空間と、認識できなかった引数のリスト" +"からなる 2 要素のタプルを返します。" -#: ../../library/argparse.rst:2221 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo', action='store_true')\n" @@ -3414,6 +4339,11 @@ msgid "" ">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" "(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo', action='store_true')\n" +">>> parser.add_argument('bar')\n" +">>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])\n" +"(Namespace(bar='BAR', foo=True), ['--badger', 'spam'])" #: ../../library/argparse.rst:2228 msgid "" @@ -3461,31 +4391,35 @@ msgstr "" "このメソッドをオーバーライドすると便利なこととして、スペースで区切られた行の" "単語1つ1つを別々の引数として扱えます。次の例でその方法を示します::" -#: ../../library/argparse.rst:2251 msgid "" "class MyArgumentParser(argparse.ArgumentParser):\n" " def convert_arg_line_to_args(self, arg_line):\n" " return arg_line.split()" msgstr "" +"class MyArgumentParser(argparse.ArgumentParser):\n" +" def convert_arg_line_to_args(self, arg_line):\n" +" return arg_line.split()" -#: ../../library/argparse.rst:2255 msgid "" "Note that with this override an argument can no longer contain spaces, since " "each space-separated word becomes a separate argument." msgstr "" +"このようにオーバーライドすると、スペースで区切られた単語がそれぞれ別の引数に" +"なるため、引数にスペースを含められなくなります。" #: ../../library/argparse.rst:2260 msgid "Exiting methods" msgstr "終了メソッド" -#: ../../library/argparse.rst:2264 msgid "" "This method terminates the program, exiting with the specified *status* and, " "if given, it prints a *message* to :data:`sys.stderr` before that. The user " "can override this method to handle these steps differently::" msgstr "" +"このメソッドは、指定された *status* でプログラムを終了します。\n" +"*message* が指定されていれば、終了前に :data:`sys.stderr` に表示します。\n" +"このメソッドをオーバーライドして、これらの処理を変更できます。 ::" -#: ../../library/argparse.rst:2268 msgid "" "class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" " def exit(self, status=0, message=None):\n" @@ -3493,12 +4427,18 @@ msgid "" " raise Exception(f'Exiting because of an error: {message}')\n" " exit(status)" msgstr "" +"class ErrorCatchingArgumentParser(argparse.ArgumentParser):\n" +" def exit(self, status=0, message=None):\n" +" if status:\n" +" raise Exception(f'Exiting because of an error: {message}')\n" +" exit(status)" -#: ../../library/argparse.rst:2276 msgid "" "This method prints a usage message, including the *message*, to :data:`sys." "stderr` and terminates the program with a status code of 2." msgstr "" +"このメソッドは、*message* を含む使用法メッセージを :data:`sys.stderr` に表示" +"し、ステータスコード 2 でプログラムを終了します。" #: ../../library/argparse.rst:2281 msgid "Intermixed parsing" @@ -3516,13 +4456,16 @@ msgstr "" "parse_known_intermixed_args` メソッドは、このような方法での解析をサポートして" "います。" -#: ../../library/argparse.rst:2291 msgid "" "These parsers do not support all the :mod:`!argparse` features, and will " "raise exceptions if unsupported features are used. In particular, " "subparsers, and mutually exclusive groups that include both optionals and " "positionals are not supported." msgstr "" +"これらのパーサーは :mod:`!argparse` のすべての機能をサポートしているわけでは" +"なく、未対応の機能を使うと例外を送出します。\n" +"特に、サブパーサーと、オプション引数と位置引数の両方を含む相互排他グループに" +"は対応していません。" #: ../../library/argparse.rst:2296 msgid "" @@ -3535,7 +4478,6 @@ msgstr "" "parse_intermixed_args` の違いを表しています: 前者は ``['2', '3']`` を、解析さ" "れない引数として返し、後者は全ての位置引数を ``rest`` に入れて返しています::" -#: ../../library/argparse.rst:2302 msgid "" ">>> parser = argparse.ArgumentParser()\n" ">>> parser.add_argument('--foo')\n" @@ -3546,6 +4488,14 @@ msgid "" ">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" "Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" msgstr "" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.add_argument('--foo')\n" +">>> parser.add_argument('cmd')\n" +">>> parser.add_argument('rest', nargs='*', type=int)\n" +">>> parser.parse_known_args('doit 1 --foo bar 2 3'.split())\n" +"(Namespace(cmd='doit', foo='bar', rest=[1]), ['2', '3'])\n" +">>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())\n" +"Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])" #: ../../library/argparse.rst:2311 msgid "" @@ -3559,32 +4509,35 @@ msgstr "" ":meth:`~ArgumentParser.parse_intermixed_args` は、解析されない引数が残された" "場合にはエラーを送出します。" -#: ../../library/argparse.rst:2320 msgid "Registering custom types or actions" -msgstr "" +msgstr "独自の型やアクションの登録" -#: ../../library/argparse.rst:2324 msgid "" "Sometimes it's desirable to use a custom string in error messages to provide " "more user-friendly output. In these cases, :meth:`!register` can be used to " "register custom actions or types with a parser and allow you to reference " "the type by their registered name instead of their callable name." msgstr "" +"エラーメッセージに独自の文字列を使って、出力をユーザーにわかりやすくしたい場" +"合があります。\n" +"その場合は、:meth:`!register` で独自のアクションや型をパーサーに登録すると、" +"呼び出し可能オブジェクトの名前の代わりに登録名で型を参照できます。" -#: ../../library/argparse.rst:2329 msgid "" "The :meth:`!register` method accepts three arguments - a *registry_name*, " "specifying the internal registry where the object will be stored (e.g., " "``action``, ``type``), *value*, which is the key under which the object will " "be registered, and object, the callable to be registered." msgstr "" +":meth:`!register` メソッドは三つの引数を受け取ります。\n" +"*registry_name* はオブジェクトを格納する内部レジストリ (``action``、``type`` " +"など)、*value* は登録に使うキー、``object`` は登録する呼び出し可能オブジェク" +"トです。" -#: ../../library/argparse.rst:2334 msgid "" "The following example shows how to register a custom type with a parser::" -msgstr "" +msgstr "次の例は、パーサーに独自の型を登録する方法を示します。 ::" -#: ../../library/argparse.rst:2336 msgid "" ">>> import argparse\n" ">>> parser = argparse.ArgumentParser()\n" @@ -3599,6 +4552,18 @@ msgid "" "usage: PROG [-h] [--foo FOO]\n" "PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" msgstr "" +">>> import argparse\n" +">>> parser = argparse.ArgumentParser()\n" +">>> parser.register('type', 'hexadecimal integer', lambda s: int(s, 16))\n" +">>> parser.add_argument('--foo', type='hexadecimal integer')\n" +"_StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, " +"default=None, type='hexadecimal integer', choices=None, required=False, " +"help=None, metavar=None, deprecated=False)\n" +">>> parser.parse_args(['--foo', '0xFA'])\n" +"Namespace(foo=250)\n" +">>> parser.parse_args(['--foo', '1.2'])\n" +"usage: PROG [-h] [--foo FOO]\n" +"PROG: error: argument --foo: invalid 'hexadecimal integer' value: '1.2'" #: ../../library/argparse.rst:2348 msgid "Exceptions" diff --git a/library/array.po b/library/array.po index 415335a17..caaf6fbee 100644 --- a/library/array.po +++ b/library/array.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/array.rst:2 @@ -92,9 +92,8 @@ msgstr "``'u'``" msgid "wchar_t" msgstr "wchar_t" -#: ../../library/array.rst:25 ../../library/array.rst:27 msgid "Unicode character" -msgstr "Unicode文字(unicode型)" +msgstr "Unicode 文字" #: ../../library/array.rst:25 ../../library/array.rst:29 #: ../../library/array.rst:31 ../../library/array.rst:33 @@ -110,9 +109,8 @@ msgstr "\\(1)" msgid "``'w'``" msgstr "``'w'``" -#: ../../library/array.rst:27 msgid "Py_UCS4" -msgstr "" +msgstr "Py_UCS4" #: ../../library/array.rst:27 ../../library/array.rst:37 #: ../../library/array.rst:39 ../../library/array.rst:47 @@ -196,9 +194,8 @@ msgstr "unsigned long long" msgid "``'e'``" msgstr "``'e'``" -#: ../../library/array.rst:45 msgid "_Float16" -msgstr "" +msgstr "_Float16" #: ../../library/array.rst:45 ../../library/array.rst:47 #: ../../library/array.rst:49 @@ -221,13 +218,11 @@ msgstr "``'d'``" msgid "double" msgstr "double" -#: ../../library/array.rst:51 msgid "``'Zf'``" -msgstr "" +msgstr "``'Zf'``" -#: ../../library/array.rst:51 msgid "float complex" -msgstr "" +msgstr "float complex" #: ../../library/array.rst:51 ../../library/array.rst:53 msgid "complex" @@ -237,13 +232,11 @@ msgstr "複素数" msgid "\\(4)" msgstr "\\(4)" -#: ../../library/array.rst:53 msgid "``'Zd'``" -msgstr "" +msgstr "``'Zd'``" -#: ../../library/array.rst:53 msgid "double complex" -msgstr "" +msgstr "double complex" #: ../../library/array.rst:53 msgid "16" @@ -253,30 +246,35 @@ msgstr "16" msgid "Notes:" msgstr "注釈:" -#: ../../library/array.rst:60 msgid "It can be 16 bits or 32 bits depending on the platform." msgstr "" +"プラットフォームによって、16 ビットの場合と 32 ビットの場合があります。" -#: ../../library/array.rst:62 msgid "" "``array('u')`` now uses :c:type:`wchar_t` as C type instead of deprecated " "``Py_UNICODE``. This change doesn't affect its behavior because " "``Py_UNICODE`` is alias of :c:type:`wchar_t` since Python 3.3." msgstr "" +"``array('u')`` の C の型は、非推奨の ``Py_UNICODE`` から :c:type:`wchar_t` に" +"変更されました。\n" +"Python 3.3 以降、``Py_UNICODE`` は :c:type:`wchar_t` の別名なので、この変更に" +"よる動作の違いはありません。" -#: ../../library/array.rst:67 msgid "Please migrate to ``'w'`` typecode." -msgstr "" +msgstr "型コード ``'w'`` に移行してください。" -#: ../../library/array.rst:74 msgid "" "The IEEE 754 binary16 \"half precision\" type was introduced in the 2008 " "revision of the `IEEE 754 standard `_. This type is not " "widely supported by C compilers. It's available as :c:expr:`_Float16` type, " "if the compiler supports the Annex H of the C23 standard." msgstr "" +"IEEE 754 binary16「半精度」型は、`IEEE 754 規格 `_ の " +"2008 年の改訂で導入されました。\n" +"この型は C コンパイラでは広くサポートされていません。\n" +"コンパイラが C23 規格の附属書 H をサポートしていれば、:c:expr:`_Float16` 型と" +"して使えます。" -#: ../../library/array.rst:83 msgid "" "Complex types (``Zf`` and ``Zd``) are available unconditionally, regardless " "on support for complex types (the Annex G of the C11 standard) by the C " @@ -284,14 +282,21 @@ msgid "" "by a two-element C array containing, respectively, the real and imaginary " "parts." msgstr "" +"複素数型 (``Zf`` と ``Zd``) は、C コンパイラによる複素数型 (C11 規格の附属書 " +"G) のサポートの有無にかかわらず、常に利用できます。\n" +"C11 規格の規定に従い、各複素数型は実部と虚部を順に格納する 2 要素の C の配列" +"で表されます。" -#: ../../library/array.rst:93 msgid "" "The :ref:`ctypes ` and :ref:`struct ` modules, as well as third-party modules like `numpy `__, use similar -- but slightly different -- type codes." msgstr "" +":ref:`ctypes ` モジュール、:ref:`struct " +"` モジュール、`numpy `__ などのサード" +"パーティー製モジュールも、似ているものの少し異なる型コードを使っています。" #: ../../library/array.rst:99 msgid "" @@ -306,27 +311,27 @@ msgstr "" msgid "The module defines the following item:" msgstr "このモジュールは以下の項目を定義しています:" -#: ../../library/array.rst:108 msgid "A tuple with all available type codes." -msgstr "" +msgstr "利用可能なすべての型コードを含むタプルです。" -#: ../../library/array.rst:110 msgid "The type changed from :class:`str` to :class:`tuple`." -msgstr "" +msgstr "型が :class:`str` から :class:`tuple` に変わりました。" #: ../../library/array.rst:114 msgid "The module defines the following type:" msgstr "このモジュールでは次の型を定義しています:" -#: ../../library/array.rst:119 msgid "" "A new array whose items are restricted by *typecode*, and initialized from " "the optional *initializer* value, which must be a :class:`bytes` or :class:" "`bytearray` object, a Unicode string, or iterable over elements of the " "appropriate type." msgstr "" +"要素の型を *typecode* で制限した新しい配列を作成します。\n" +"省略可能な *initializer* を指定すると、その値で初期化します。\n" +"この値は :class:`bytes` オブジェクト、:class:`bytearray` オブジェクト、" +"Unicode 文字列、または適切な型の要素を返すイテラブルでなければなりません。" -#: ../../library/array.rst:124 msgid "" "If given a :class:`bytes` or :class:`bytearray` object, the initializer is " "passed to the new array's :meth:`frombytes` method; if given a Unicode " @@ -334,8 +339,12 @@ msgid "" "otherwise, the initializer's iterator is passed to the :meth:`extend` method " "to add initial items to the array." msgstr "" +":class:`bytes` または :class:`bytearray` オブジェクトを指定した場合、" +"``initializer`` は新しい配列の :meth:`frombytes` メソッドに渡されます。\n" +"Unicode 文字列を指定した場合は :meth:`fromunicode` メソッドに渡されます。\n" +"それ以外の場合は、``initializer`` のイテレーターを :meth:`extend` メソッドに" +"渡して、初期値となる要素を配列に追加します。" -#: ../../library/array.rst:131 msgid "" "Array objects support the ordinary :ref:`mutable ` :term:" "`sequence` operations of indexing, slicing, concatenation, and " @@ -344,10 +353,17 @@ msgid "" "is raised. Array objects also implement the buffer interface, and may be " "used wherever :term:`bytes-like objects ` are supported." msgstr "" +"配列オブジェクトは、インデックス参照、スライス、連結、繰り返しといった、通常" +"の :ref:`ミュータブルな ` :term:`シーケンス ` の" +"操作をサポートします。\n" +"スライス代入では、代入する値は同じ型コードの配列オブジェクトでなければなら" +"ず、それ以外の場合は :exc:`TypeError` を送出します。\n" +"配列オブジェクトはバッファインターフェースも実装しており、:term:`bytes-like " +"オブジェクト ` を受け付ける場所で使えます。" -#: ../../library/array.rst:137 msgid "Arrays are :ref:`generic ` over the type of their contents." msgstr "" +"配列は、要素の型をパラメーターとする :ref:`ジェネリック型 ` です。" #: ../../library/array.rst:139 msgid "" @@ -365,9 +381,8 @@ msgstr "アレイを作るときに使う型コード文字です。" msgid "The length in bytes of one array item in the internal representation." msgstr "アレイの要素 1 つの内部表現に使われるバイト長です。" -#: ../../library/array.rst:154 msgid "Append a new item with the specified value to the end of the array." -msgstr "" +msgstr "指定した値を持つ新しい要素を配列の末尾に追加します。" #: ../../library/array.rst:159 msgid "" @@ -396,13 +411,12 @@ msgid "" "backward compatibility and should be avoided in new code. The buffer " "interface is documented in :ref:`bufferobjects`." msgstr "" -"C やC++ で書いたコードからアレイオブジェクトを使う場合 (:meth:`buffer_info` " -"の情報を使う意味のある唯一の方法です) は、アレイオブジェクトでサポートしてい" -"るバッファインターフェースを使う方がより理にかなっています。このメソッドは後" -"方互換性のために保守されており、新しいコードでの使用は避けるべきです。バッ" -"ファインターフェースの説明は :ref:`bufferobjects` にあります。" +"C やC++ で書いたコードからアレイオブジェクトを使う場合 (``buffer_info()`` の" +"情報を使う意味のある唯一の方法です) は、アレイオブジェクトでサポートしている" +"バッファインターフェースを使う方がより理にかなっています。このメソッドは後方" +"互換性のために保守されており、新しいコードでの使用は避けるべきです。バッファ" +"インターフェースの説明は :ref:`bufferobjects` にあります。" -#: ../../library/array.rst:178 msgid "" "\"Byteswap\" all items of the array. This is only supported for values " "which are 1, 2, 4, 8 or 16 bytes in size; for other types of values, :exc:" @@ -411,10 +425,15 @@ msgid "" "types the order of components (the real part, followed by imaginary part) is " "preserved." msgstr "" +"配列の全要素のバイト順を逆にします。\n" +"サイズが 1、2、4、8、16 バイトの値だけをサポートし、それ以外の型の値では :" +"exc:`RuntimeError` を送出します。\n" +"バイト順が異なるマシンで書き込まれたファイルからデータを読み込む際に便利で" +"す。\n" +"複素数型の場合、成分の順序 (実部、虚部の順) は変わりません。" -#: ../../library/array.rst:187 msgid "Return the number of occurrences of *value* in the array." -msgstr "" +msgstr "配列内で *value* が出現する回数を返します。" #: ../../library/array.rst:192 msgid "" @@ -429,12 +448,14 @@ msgstr "" "ない場合、アレイに値を追加できるような正しい型の要素からなるイテレーション可" "能オブジェクトでなければなりません。" -#: ../../library/array.rst:200 msgid "" "Appends items from the :term:`bytes-like object`, interpreting its content " "as an array of machine values (as if it had been read from a file using the :" "meth:`fromfile` method)." msgstr "" +":term:`bytes-like object` の内容をマシンのデータ形式の配列として解釈し、要素" +"を追加します (:meth:`fromfile` メソッドでファイルから読み込んだ場合と同じで" +"す)。" #: ../../library/array.rst:204 msgid ":meth:`!fromstring` is renamed to :meth:`frombytes` for clarity." @@ -462,31 +483,39 @@ msgstr "" "リストから要素を追加します。型に関するエラーが発生した場合にアレイが変更され" "ないことを除き、 ``for x in list: a.append(x)`` と同じです。" -#: ../../library/array.rst:224 msgid "" "Extends this array with data from the given Unicode string. The array must " "have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised. " "Use ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to " "an array of some other type." msgstr "" +"指定した Unicode 文字列のデータを配列に追加します。\n" +"配列の型コードは ``'u'`` または ``'w'`` でなければならず、それ以外では :exc:" +"`ValueError` を送出します。\n" +"他の型の配列に Unicode データを追加するには、``array.frombytes(unicodestring." +"encode(enc))`` を使ってください。" -#: ../../library/array.rst:232 msgid "" "Return the smallest *i* such that *i* is the index of the first occurrence " "of *value* in the array. The optional arguments *start* and *stop* can be " "specified to search for *value* within a subsection of the array. Raise :" "exc:`ValueError` if *value* is not found." msgstr "" +"配列内で *value* が最初に出現するインデックス *i* (つまり、該当する最小の " +"*i*) を返します。\n" +"省略可能な引数 *start* と *stop* を指定すると、配列の一部分から *value* を探" +"せます。\n" +"*value* が見つからなければ :exc:`ValueError` を送出します。" -#: ../../library/array.rst:237 msgid "Added optional *start* and *stop* parameters." -msgstr "" +msgstr "省略可能な *start* と *stop* パラメーターが追加されました。" -#: ../../library/array.rst:243 msgid "" "Insert a new item *value* in the array before position *index*. Negative " "values are treated as being relative to the end of the array." msgstr "" +"配列の *index* が示す位置の直前に、新しい要素 *value* を挿入します。\n" +"負のインデックスは配列の末尾からの相対位置として扱われます。" #: ../../library/array.rst:249 msgid "" @@ -498,13 +527,11 @@ msgstr "" "フォルトで ``-1`` になっていて、最後の要素を取り除いて返すようになっていま" "す。" -#: ../../library/array.rst:256 msgid "Remove the first occurrence of *value* from the array." -msgstr "" +msgstr "配列内で最初に出現する *value* を削除します。" -#: ../../library/array.rst:261 msgid "Remove all elements from the array." -msgstr "" +msgstr "配列のすべての要素を削除します。" #: ../../library/array.rst:268 msgid "Reverse the order of the items in the array." @@ -519,9 +546,9 @@ msgstr "" "array をマシンの値の array に変換して、 bytes の形で返します (:meth:`tofile` " "メソッドを使ってファイルに書かれるバイト列と同じです)。" -#: ../../library/array.rst:277 msgid ":meth:`!tostring` is renamed to :meth:`tobytes` for clarity." msgstr "" +"名前を明確にするため、:meth:`!tostring` を :meth:`tobytes` に改名しました。" #: ../../library/array.rst:283 msgid "Write all items (as machine values) to the :term:`file object` *f*." @@ -532,12 +559,16 @@ msgstr "" msgid "Convert the array to an ordinary list with the same items." msgstr "アレイを同じ要素を持つ普通のリストに変換します。" -#: ../../library/array.rst:293 msgid "" "Convert the array to a Unicode string. The array must have a type ``'u'`` " "or ``'w'``; otherwise a :exc:`ValueError` is raised. Use ``array.tobytes()." "decode(enc)`` to obtain a Unicode string from an array of some other type." msgstr "" +"配列を Unicode 文字列に変換します。\n" +"配列の型コードは ``'u'`` または ``'w'`` でなければならず、それ以外では :exc:" +"`ValueError` を送出します。\n" +"他の型の配列から Unicode 文字列を得るには、``array.tobytes().decode(enc)`` を" +"使ってください。" #: ../../library/array.rst:298 msgid "" @@ -552,13 +583,16 @@ msgid "" "Examples::" msgstr "" -#: ../../library/array.rst:310 msgid "" "array('l')\n" "array('w', 'hello \\u2641')\n" "array('l', [1, 2, 3, 4, 5])\n" "array('d', [1.0, 2.0, 3.14, -inf, nan])" msgstr "" +"array('l')\n" +"array('w', 'hello \\u2641')\n" +"array('l', [1, 2, 3, 4, 5])\n" +"array('d', [1.0, 2.0, 3.14, -inf, nan])" #: ../../library/array.rst:318 msgid "Module :mod:`struct`" diff --git a/library/ast.po b/library/ast.po index 5d4b98a84..4859ebdec 100644 --- a/library/ast.po +++ b/library/ast.po @@ -16,27 +16,29 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/ast.rst:2 msgid ":mod:`!ast` --- Abstract syntax trees" -msgstr "" +msgstr ":mod:`!ast` --- 抽象構文木" #: ../../library/ast.rst:11 msgid "**Source code:** :source:`Lib/ast.py`" msgstr "**ソースコード:** :source:`Lib/ast.py`" -#: ../../library/ast.rst:15 msgid "" "The :mod:`!ast` module helps Python applications to process trees of the " "Python abstract syntax grammar. The abstract syntax itself might change " "with each Python release; this module helps to find out programmatically " "what the current grammar looks like." msgstr "" +":mod:`!ast` モジュールは、Python の抽象構文を表す木を Python アプリケーション" +"で処理するための機能を提供します。\n" +"抽象構文自体は Python のリリースごとに変わる可能性がありますが、このモジュー" +"ルを使えば、現在の文法をプログラムから調べられます。" #: ../../library/ast.rst:20 msgid "" @@ -54,15 +56,13 @@ msgstr "" "`compile` を使って Python コード・オブジェクトにコンパイルすることができま" "す。" -#: ../../library/ast.rst:30 msgid "Abstract grammar" -msgstr "" +msgstr "抽象文法" #: ../../library/ast.rst:32 msgid "The abstract grammar is currently defined as follows:" msgstr "抽象文法は、現在次のように定義されています:" -#: ../../library/ast.rst:34 msgid "" "-- ASDL's 4 builtin types are:\n" "-- identifier, int, string, constant\n" @@ -239,18 +239,194 @@ msgid "" "end_col_offset)\n" "}\n" msgstr "" +"-- ASDL の四つの組み込み型:\n" +"-- identifier, int, string, constant\n" +"\n" +"module Python\n" +"{\n" +" mod = Module(stmt* body, type_ignore* type_ignores)\n" +" | Interactive(stmt* body)\n" +" | Expression(expr body)\n" +" | FunctionType(expr* argtypes, expr returns)\n" +"\n" +" stmt = FunctionDef(identifier name, arguments args,\n" +" stmt* body, expr* decorator_list, expr? returns,\n" +" string? type_comment, type_param* type_params)\n" +" | AsyncFunctionDef(identifier name, arguments args,\n" +" stmt* body, expr* decorator_list, expr? " +"returns,\n" +" string? type_comment, type_param* type_params)\n" +"\n" +" | ClassDef(identifier name,\n" +" expr* bases,\n" +" keyword* keywords,\n" +" stmt* body,\n" +" expr* decorator_list,\n" +" type_param* type_params)\n" +" | Return(expr? value)\n" +"\n" +" | Delete(expr* targets)\n" +" | Assign(expr* targets, expr value, string? type_comment)\n" +" | TypeAlias(expr name, type_param* type_params, expr value)\n" +" | AugAssign(expr target, operator op, expr value)\n" +" -- 'simple' は括弧のない単純な名前へのアノテーションを示す\n" +" | AnnAssign(expr target, expr annotation, expr? value, int " +"simple)\n" +"\n" +" -- 対象言語では else がキーワードなので 'orelse' を使う\n" +" | For(expr target, expr iter, stmt* body, stmt* orelse, string? " +"type_comment)\n" +" | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, " +"string? type_comment)\n" +" | While(expr test, stmt* body, stmt* orelse)\n" +" | If(expr test, stmt* body, stmt* orelse)\n" +" | With(withitem* items, stmt* body, string? type_comment)\n" +" | AsyncWith(withitem* items, stmt* body, string? type_comment)\n" +"\n" +" | Match(expr subject, match_case* cases)\n" +"\n" +" | Raise(expr? exc, expr? cause)\n" +" | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* " +"finalbody)\n" +" | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* " +"finalbody)\n" +" | Assert(expr test, expr? msg)\n" +"\n" +" | Import(alias* names, int? is_lazy)\n" +" | ImportFrom(identifier? module, alias* names, int? level, int? " +"is_lazy)\n" +"\n" +" | Global(identifier* names)\n" +" | Nonlocal(identifier* names)\n" +" | Expr(expr value)\n" +" | Pass | Break | Continue\n" +"\n" +" -- col_offset はパーサーが使う UTF-8 文字列内のバイトオフセット\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- BoolOp() は left と right を使えるか?\n" +" expr = BoolOp(boolop op, expr* values)\n" +" | NamedExpr(expr target, expr value)\n" +" | BinOp(expr left, operator op, expr right)\n" +" | UnaryOp(unaryop op, expr operand)\n" +" | Lambda(arguments args, expr body)\n" +" | IfExp(expr test, expr body, expr orelse)\n" +" | Dict(expr?* keys, expr* values)\n" +" | Set(expr* elts)\n" +" | ListComp(expr elt, comprehension* generators)\n" +" | SetComp(expr elt, comprehension* generators)\n" +" | DictComp(expr key, expr? value, comprehension* generators)\n" +" | GeneratorExp(expr elt, comprehension* generators)\n" +" -- yield 式が現れる位置は文法によって制限される\n" +" | Await(expr value)\n" +" | Yield(expr? value)\n" +" | YieldFrom(expr value)\n" +" -- 次の二つを区別するため、比較にはシーケンスが必要\n" +" -- x < 4 < 3 と (x < 4) < 3\n" +" | Compare(expr left, cmpop* ops, expr* comparators)\n" +" | Call(expr func, expr* args, keyword* keywords)\n" +" | FormattedValue(expr value, int conversion, expr? format_spec)\n" +" | Interpolation(expr value, constant str, int conversion, expr? " +"format_spec)\n" +" | JoinedStr(expr* values)\n" +" | TemplateStr(expr* values)\n" +" | Constant(constant value, string? kind)\n" +"\n" +" -- 以下の式は代入のコンテキストに現れうる\n" +" | Attribute(expr value, identifier attr, expr_context ctx)\n" +" | Subscript(expr value, expr slice, expr_context ctx)\n" +" | Starred(expr value, expr_context ctx)\n" +" | Name(identifier id, expr_context ctx)\n" +" | List(expr* elts, expr_context ctx)\n" +" | Tuple(expr* elts, expr_context ctx)\n" +"\n" +" -- Subscript 内にのみ現れる\n" +" | Slice(expr? lower, expr? upper, expr? step)\n" +"\n" +" -- col_offset はパーサーが使う UTF-8 文字列内のバイトオフセット\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" expr_context = Load | Store | Del\n" +"\n" +" boolop = And | Or\n" +"\n" +" operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift\n" +" | RShift | BitOr | BitXor | BitAnd | FloorDiv\n" +"\n" +" unaryop = Invert | Not | UAdd | USub\n" +"\n" +" cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn\n" +"\n" +" comprehension = (expr target, expr iter, expr* ifs, int is_async)\n" +"\n" +" excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)\n" +" attributes (int lineno, int col_offset, int? end_lineno, " +"int? end_col_offset)\n" +"\n" +" arguments = (arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs,\n" +" expr?* kw_defaults, arg? kwarg, expr* defaults)\n" +"\n" +" arg = (identifier arg, expr? annotation, string? type_comment)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- 呼び出しに渡すキーワード引数 (**kwargs の identifier は NULL)\n" +" keyword = (identifier? arg, expr value)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" -- インポート名と、省略可能な 'as' による別名。\n" +" alias = (identifier name, identifier? asname)\n" +" attributes (int lineno, int col_offset, int? end_lineno, int? " +"end_col_offset)\n" +"\n" +" withitem = (expr context_expr, expr? optional_vars)\n" +"\n" +" match_case = (pattern pattern, expr? guard, stmt* body)\n" +"\n" +" pattern = MatchValue(expr value)\n" +" | MatchSingleton(constant value)\n" +" | MatchSequence(pattern* patterns)\n" +" | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n" +" | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, " +"pattern* kwd_patterns)\n" +"\n" +" | MatchStar(identifier? name)\n" +" -- MatchMapping の省略可能な \"rest\" パラメーターで残りのマッピ" +"ングのキーをキャプチャする\n" +"\n" +" | MatchAs(pattern? pattern, identifier? name)\n" +" | MatchOr(pattern* patterns)\n" +"\n" +" attributes (int lineno, int col_offset, int end_lineno, int " +"end_col_offset)\n" +"\n" +" type_ignore = TypeIgnore(int lineno, string tag)\n" +"\n" +" type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n" +" | ParamSpec(identifier name, expr? default_value)\n" +" | TypeVarTuple(identifier name, expr? default_value)\n" +" attributes (int lineno, int col_offset, int end_lineno, int " +"end_col_offset)\n" +"}\n" #: ../../library/ast.rst:41 msgid "Node classes" msgstr "Node クラス" -#: ../../library/ast.rst:45 msgid "" "This is the abstract base of all AST node classes. The actual node classes " "are derived from the :file:`Parser/Python.asdl` file, which is reproduced :" "ref:`above `. They are defined in the :mod:`!_ast` C " "module and re-exported in :mod:`!ast`." msgstr "" +"すべての AST ノードクラスの抽象基底クラスです。\n" +"実際のノードクラスは、:ref:`上に掲載した ` :file:`Parser/" +"Python.asdl` ファイルから生成されます。\n" +"これらは C モジュール :mod:`!_ast` で定義され、:mod:`!ast` から再エクスポート" +"されます。" #: ../../library/ast.rst:50 msgid "" @@ -303,20 +479,22 @@ msgstr "" "ストで表されます。全ての属性は AST を :func:`compile` でコンパイルする際には" "存在しなければならず、そして妥当な値でなければなりません。" -#: ../../library/ast.rst:78 msgid "" "The :attr:`!_field_types` attribute on each concrete class is a dictionary " "mapping field names (as also listed in :attr:`_fields`) to their types." msgstr "" +"各具象クラスの :attr:`!_field_types` 属性は、フィールド名 (:attr:`_fields` に" +"も列挙されています) をその型に対応付ける辞書です。" -#: ../../library/ast.rst:81 msgid "" ">>> ast.TypeVar._field_types\n" "{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " "| None}" msgstr "" +">>> ast.TypeVar._field_types\n" +"{'name': , 'bound': ast.expr | None, 'default_value': ast.expr " +"| None}" -#: ../../library/ast.rst:93 msgid "" "Instances of :class:`ast.expr` and :class:`ast.stmt` subclasses have :attr:" "`lineno`, :attr:`col_offset`, :attr:`end_lineno`, and :attr:`end_col_offset` " @@ -327,13 +505,14 @@ msgid "" "the node. The UTF-8 offset is recorded because the parser uses UTF-8 " "internally." msgstr "" -":class:`ast.expr` や :class:`ast.stmt` のサブクラスのインスタンスは :attr:" -"`lineno`, :attr:`col_offset`, :attr:`end_lineno`, および :attr:" -"`end_col_offset` 属性を持ちます。 :attr:`lineno` と :attr:`end_lineno` はソー" -"ステキストの範囲を最初と最後の行番号で表し (1 から数え始めるので、最初の行の" -"行番号は 1 となります)、 :attr:`col_offset` と :attr:`end_col_offset` はノー" -"ドが生成した最初と最後のトークンの UTF-8 バイトオフセットです。 UTF-8 オフ" -"セットはパーサが内部で使用するので記録されます。" +":class:`ast.expr` と :class:`ast.stmt` のサブクラスのインスタンスは、:attr:" +"`lineno`、:attr:`col_offset`、:attr:`end_lineno`、:attr:`end_col_offset` 属性" +"を持ちます。\n" +":attr:`lineno` と :attr:`end_lineno` は、対応するソーステキストの最初と最後の" +"行番号です (1 から数えるので、先頭行は 1 です)。\n" +":attr:`col_offset` と :attr:`end_col_offset` は、ノードの生成元となった最初と" +"最後のトークンに対応する UTF-8 バイトオフセットです。\n" +"パーサーは内部で UTF-8 を使うため、この形式のオフセットを記録します。" #: ../../library/ast.rst:102 msgid "" @@ -376,11 +555,12 @@ msgstr "" "たとえば、 :class:`ast.UnaryOp` ノードを生成して属性を埋めるには、次のように" "することができます ::" -#: ../../library/ast.rst:117 msgid "" "node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" " lineno=0, col_offset=0)" msgstr "" +"node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),\n" +" lineno=0, col_offset=0)" #: ../../library/ast.rst:120 msgid "" @@ -404,7 +584,6 @@ msgstr "" "単純なインデックスはその値で表現され、幅を持つスライスはタプルで表現されま" "す。" -#: ../../library/ast.rst:138 msgid "" "AST node constructors were changed to provide sensible defaults for omitted " "fields: optional fields now default to ``None``, list fields default to an " @@ -412,14 +591,21 @@ msgid "" "`Load() `. Previously, omitted attributes would not exist on " "constructed nodes (accessing them raised :exc:`AttributeError`)." msgstr "" +"AST ノードのコンストラクターが、省略されたフィールドに適切なデフォルト値を設" +"定するようになりました。\n" +"省略可能なフィールドは ``None``、リストのフィールドは空リスト、:class:`!ast." +"expr_context` 型のフィールドは :class:`Load() ` がデフォルトになり" +"ます。\n" +"以前は、省略された属性は作成したノードに存在せず、アクセスすると :exc:" +"`AttributeError` が送出されていました。" -#: ../../library/ast.rst:146 msgid "" "The :meth:`~object.__repr__` output of :class:`~ast.AST` nodes includes the " "values of the node fields." msgstr "" +":class:`~ast.AST` ノードの :meth:`~object.__repr__` の出力に、ノードのフィー" +"ルドの値が含まれるようになりました。" -#: ../../library/ast.rst:151 msgid "" "Previous versions of Python provided the AST classes :class:`!ast.Num`, :" "class:`!ast.Str`, :class:`!ast.Bytes`, :class:`!ast.NameConstant` and :class:" @@ -427,15 +613,21 @@ msgid "" "removed in Python 3.14, and their functionality has been replaced with :" "class:`ast.Constant`." msgstr "" +"以前の Python には、AST クラス :class:`!ast.Num`、:class:`!ast.Str`、:class:" +"`!ast.Bytes`、:class:`!ast.NameConstant`、:class:`!ast.Ellipsis` がありました" +"が、Python 3.8 で非推奨になりました。\n" +"これらは Python 3.14 で削除され、その機能は :class:`ast.Constant` に置き換え" +"られました。" -#: ../../library/ast.rst:159 msgid "" "Old classes :class:`!ast.Index` and :class:`!ast.ExtSlice` are still " "available, but they will be removed in future Python releases. In the " "meantime, instantiating them will return an instance of a different class." msgstr "" +"古いクラス :class:`!ast.Index` と :class:`!ast.ExtSlice` はまだ利用できます" +"が、将来の Python で削除されます。\n" +"現在、これらをインスタンス化すると、別のクラスのインスタンスが返されます。" -#: ../../library/ast.rst:166 msgid "" "Previous versions of Python allowed the creation of AST nodes that were " "missing required fields. Similarly, AST node constructors allowed arbitrary " @@ -443,8 +635,11 @@ msgid "" "did not match any of the fields of the AST node. These cases now raise a :" "exc:`TypeError`." msgstr "" +"以前の Python では、必須のフィールドが欠けた AST ノードを作成できました。\n" +"また、AST ノードのコンストラクターに任意のキーワード引数を渡すことができ、" +"ノードのフィールドに対応していなくても属性として設定されていました。\n" +"これらの場合に :exc:`TypeError` を送出するようになりました。" -#: ../../library/ast.rst:173 msgid "" "In the :ref:`grammar above `, the AST node classes that " "correspond to production rules with variants (aka \"sums\") are abstract " @@ -452,6 +647,11 @@ msgid "" "instances of these abstract node classes. This behavior is deprecated and " "will be removed in Python 3.20." msgstr "" +":ref:`上の文法 ` で選択肢のある生成規則 (\"sums\" とも呼ば" +"れます) に対応する AST ノードクラスは、抽象クラスです。\n" +"以前の Python では、これらの抽象ノードクラスのインスタンスを直接作成できまし" +"た。\n" +"この動作は非推奨で、Python 3.20 で削除されます。" #: ../../library/ast.rst:181 msgid "" @@ -463,27 +663,29 @@ msgstr "" "Snakes `__ プロジェクトと" "そのすべての貢献者の成果物をもとにしています。" -#: ../../library/ast.rst:190 msgid "Root nodes" -msgstr "" +msgstr "ルートノード" -#: ../../library/ast.rst:194 msgid "" "A Python module, as with :ref:`file input `. Node type generated " "by :func:`ast.parse` in the default ``\"exec\"`` *mode*." msgstr "" +":ref:`ファイル入力 ` のような Python モジュールを表します。\n" +":func:`ast.parse` の *mode* がデフォルトの ``\"exec\"`` のときに生成される" +"ノード型です。" -#: ../../library/ast.rst:197 msgid "``body`` is a :class:`list` of the module's :ref:`ast-statements`." msgstr "" +"``body`` は、モジュールの :ref:`文 ` の :class:`list` です。" -#: ../../library/ast.rst:199 msgid "" "``type_ignores`` is a :class:`list` of the module's type ignore comments; " "see :func:`ast.parse` for more details." msgstr "" +"``type_ignores`` は、モジュールの型検査を無視するコメントの :class:`list` で" +"す。\n" +"詳細は :func:`ast.parse` を参照してください。" -#: ../../library/ast.rst:202 msgid "" ">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" "Module(\n" @@ -493,37 +695,48 @@ msgid "" " Name(id='x', ctx=Store())],\n" " value=Constant(value=1))])" msgstr "" +">>> print(ast.dump(ast.parse('x = 1'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))])" -#: ../../library/ast.rst:215 msgid "" "A single Python :ref:`expression input `. Node type " "generated by :func:`ast.parse` when *mode* is ``\"eval\"``." msgstr "" +"Python の単一の :ref:`式入力 ` を表します。\n" +":func:`ast.parse` の *mode* が ``\"eval\"`` のときに生成されるノード型です。" -#: ../../library/ast.rst:218 msgid "" "``body`` is a single node, one of the :ref:`expression types `." msgstr "" +"``body`` は、:ref:`式の型 ` のいずれかの単一ノードです。" -#: ../../library/ast.rst:221 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" " body=Constant(value=123))" msgstr "" +">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Constant(value=123))" -#: ../../library/ast.rst:230 msgid "" "A single :ref:`interactive input `, like in :ref:`tut-interac`. " "Node type generated by :func:`ast.parse` when *mode* is ``\"single\"``." msgstr "" +":ref:`対話モード ` などでの、単一の :ref:`対話的な入力 " +"` を表します。\n" +":func:`ast.parse` の *mode* が ``\"single\"`` のときに生成されるノード型で" +"す。" -#: ../../library/ast.rst:233 msgid "``body`` is a :class:`list` of :ref:`statement nodes `." -msgstr "" +msgstr "``body`` は :ref:`文ノード ` の :class:`list` です。" -#: ../../library/ast.rst:235 msgid "" ">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" "Interactive(\n" @@ -537,35 +750,49 @@ msgid "" " Name(id='y', ctx=Store())],\n" " value=Constant(value=2))])" msgstr "" +">>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))\n" +"Interactive(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1)),\n" +" Assign(\n" +" targets=[\n" +" Name(id='y', ctx=Store())],\n" +" value=Constant(value=2))])" -#: ../../library/ast.rst:252 msgid "" "A representation of an old-style type comments for functions, as Python " "versions prior to 3.5 didn't support :pep:`484` annotations. Node type " "generated by :func:`ast.parse` when *mode* is ``\"func_type\"``." msgstr "" +"関数の旧形式の型コメントを表します。\n" +"Python 3.5 より前のバージョンでは、:pep:`484` のアノテーションはサポートされ" +"ていませんでした。\n" +":func:`ast.parse` の *mode* が ``\"func_type\"`` のときに生成されるノード型で" +"す。" -#: ../../library/ast.rst:256 msgid "Such type comments would look like this::" -msgstr "" +msgstr "この形式の型コメントは、次のようなものです。 ::" -#: ../../library/ast.rst:258 msgid "" "def sum_two_number(a, b):\n" " # type: (int, int) -> int\n" " return a + b" msgstr "" +"def sum_two_number(a, b):\n" +" # type: (int, int) -> int\n" +" return a + b" -#: ../../library/ast.rst:262 msgid "" "``argtypes`` is a :class:`list` of :ref:`expression nodes `." msgstr "" +"``argtypes`` は :ref:`式ノード ` の :class:`list` です。" -#: ../../library/ast.rst:264 msgid "``returns`` is a single :ref:`expression node `." -msgstr "" +msgstr "``returns`` は単一の :ref:`式ノード ` です。" -#: ../../library/ast.rst:266 msgid "" ">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " "indent=4))\n" @@ -577,12 +804,20 @@ msgid "" " value=Name(id='List'),\n" " slice=Name(id='int')))" msgstr "" +">>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), " +"indent=4))\n" +"FunctionType(\n" +" argtypes=[\n" +" Name(id='int'),\n" +" Name(id='str')],\n" +" returns=Subscript(\n" +" value=Name(id='List'),\n" +" slice=Name(id='int')))" #: ../../library/ast.rst:281 msgid "Literals" msgstr "リテラル" -#: ../../library/ast.rst:285 msgid "" "A constant value. The ``value`` attribute of the ``Constant`` literal " "contains the Python object it represents. The values represented can be " @@ -590,15 +825,22 @@ msgid "" "class:`complex`, and :class:`bool`, and the constants :data:`None` and :data:" "`Ellipsis`." msgstr "" +"定数値を表します。\n" +"``Constant`` リテラルの ``value`` 属性には、それが表す Python オブジェクトが" +"格納されます。\n" +"表せる値は、:class:`str`、:class:`bytes`、:class:`int`、:class:`float`、:" +"class:`complex`、:class:`bool` のインスタンスと、定数 :data:`None`、:data:" +"`Ellipsis` です。" -#: ../../library/ast.rst:290 msgid "" "The ``kind`` attribute is an optional string. For string literals with a " "``u`` prefix, ``kind`` is set to ``'u'``. For all other constants, ``kind`` " "is ``None``." msgstr "" +"``kind`` 属性は省略可能な文字列です。\n" +"接頭辞 ``u`` のある文字列リテラルでは ``kind`` は ``'u'`` になります。\n" +"それ以外の定数では ``None`` です。" -#: ../../library/ast.rst:294 msgid "" ">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" "Expression(\n" @@ -607,6 +849,12 @@ msgid "" "Expression(\n" " body=Constant(value='hello', kind='u'))" msgstr "" +">>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Constant(value=123))\n" +">>> print(ast.dump(ast.parse(\"u'hello'\", mode='eval'), indent=4))\n" +"Expression(\n" +" body=Constant(value='hello', kind='u'))" #: ../../library/ast.rst:306 msgid "" @@ -634,17 +882,14 @@ msgstr "``conversion`` は整数です:" msgid "-1: no formatting" msgstr "-1: 書式指定なし" -#: ../../library/ast.rst:315 msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` formatting" -msgstr "" +msgstr "97 (``ord('a')``): ``!a`` による :func:`ASCII ` 形式への変換" -#: ../../library/ast.rst:316 msgid "114 (``ord('r')``): ``!r`` :func:`repr` formatting" -msgstr "" +msgstr "114 (``ord('r')``): ``!r`` による :func:`repr` 形式への変換" -#: ../../library/ast.rst:317 msgid "115 (``ord('s')``): ``!s`` :func:`string ` formatting" -msgstr "" +msgstr "115 (``ord('s')``): ``!s`` による :func:`文字列 ` への変換" #: ../../library/ast.rst:319 msgid "" @@ -664,7 +909,6 @@ msgstr "" ":class:`FormattedValue` ノードと :class:`Constant` ノードの集まりからなる f-" "string です。" -#: ../../library/ast.rst:329 msgid "" ">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " "indent=4))\n" @@ -686,15 +930,35 @@ msgid "" " values=[\n" " Constant(value='.3')]))]))" msgstr "" +">>> print(ast.dump(ast.parse('f\"sin({a}) is {sin(a):.3}\"', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=JoinedStr(\n" +" values=[\n" +" Constant(value='sin('),\n" +" FormattedValue(\n" +" value=Name(id='a'),\n" +" conversion=-1),\n" +" Constant(value=') is '),\n" +" FormattedValue(\n" +" value=Call(\n" +" func=Name(id='sin'),\n" +" args=[\n" +" Name(id='a')]),\n" +" conversion=-1,\n" +" format_spec=JoinedStr(\n" +" values=[\n" +" Constant(value='.3')]))]))" -#: ../../library/ast.rst:355 msgid "" "Node representing a template string literal, comprising a series of :class:" "`Interpolation` and :class:`Constant` nodes. These nodes may be any order, " "and do not need to be interleaved." msgstr "" +"テンプレート文字列リテラルを表すノードで、一連の :class:`Interpolation` ノー" +"ドと :class:`Constant` ノードからなります。\n" +"これらのノードはどのような順序でもよく、交互に並ぶ必要はありません。" -#: ../../library/ast.rst:359 msgid "" ">>> expr = ast.parse('t\"{name} finished {place:ordinal}\"', mode='eval')\n" ">>> print(ast.dump(expr, indent=4))\n" @@ -714,57 +978,74 @@ msgid "" " values=[\n" " Constant(value='ordinal')]))]))" msgstr "" +">>> expr = ast.parse('t\"{name} finished {place:ordinal}\"', mode='eval')\n" +">>> print(ast.dump(expr, indent=4))\n" +"Expression(\n" +" body=TemplateStr(\n" +" values=[\n" +" Interpolation(\n" +" value=Name(id='name'),\n" +" str='name',\n" +" conversion=-1),\n" +" Constant(value=' finished '),\n" +" Interpolation(\n" +" value=Name(id='place'),\n" +" str='place',\n" +" conversion=-1,\n" +" format_spec=JoinedStr(\n" +" values=[\n" +" Constant(value='ordinal')]))]))" -#: ../../library/ast.rst:383 msgid "" "Node representing a single interpolation field in a template string literal." -msgstr "" +msgstr "テンプレート文字列リテラル内の一つの補間フィールドを表すノードです。" -#: ../../library/ast.rst:385 msgid "" "``value`` is any expression node (such as a literal, a variable, or a " "function call). This has the same meaning as ``FormattedValue.value``." msgstr "" +"``value`` は任意の式ノード (リテラル、変数、関数呼び出しなど) です。\n" +"``FormattedValue.value`` と同じ意味を持ちます。" -#: ../../library/ast.rst:388 msgid "" "``str`` is a constant containing the text of the interpolation expression." -msgstr "" +msgstr "``str`` は、補間する式のテキストを格納する定数です。" -#: ../../library/ast.rst:390 msgid "" "If ``str`` is set to ``None``, then ``value`` is used to generate code when " "calling :func:`ast.unparse`. This no longer guarantees that the generated " "code is identical to the original and is intended for code generation." msgstr "" +"``str`` を ``None`` に設定すると、:func:`ast.unparse` の呼び出し時には " +"``value`` からコードを生成します。\n" +"この場合、生成したコードが元のコードと同一である保証はなくなり、コード生成の" +"用途を想定しています。" -#: ../../library/ast.rst:396 msgid "-1: no conversion" -msgstr "" +msgstr "-1: 変換なし" -#: ../../library/ast.rst:397 msgid "97 (``ord('a')``): ``!a`` :func:`ASCII ` conversion" -msgstr "" +msgstr "97 (``ord('a')``): ``!a`` による :func:`ASCII ` 形式への変換" -#: ../../library/ast.rst:398 msgid "114 (``ord('r')``): ``!r`` :func:`repr` conversion" -msgstr "" +msgstr "114 (``ord('r')``): ``!r`` による :func:`repr` 形式への変換" -#: ../../library/ast.rst:399 msgid "115 (``ord('s')``): ``!s`` :func:`string ` conversion" -msgstr "" +msgstr "115 (``ord('s')``): ``!s`` による :func:`文字列 ` への変換" -#: ../../library/ast.rst:401 msgid "This has the same meaning as ``FormattedValue.conversion``." -msgstr "" +msgstr "``FormattedValue.conversion`` と同じ意味を持ちます。" -#: ../../library/ast.rst:402 msgid "" "``format_spec`` is a :class:`JoinedStr` node representing the formatting of " "the value, or ``None`` if no format was specified. Both ``conversion`` and " "``format_spec`` can be set at the same time. This has the same meaning as " "``FormattedValue.format_spec``." msgstr "" +"``format_spec`` は、値の書式指定を表す :class:`JoinedStr` ノードです。\n" +"書式指定がなければ ``None`` になります。\n" +"``conversion`` と ``format_spec`` は同時に指定できます。\n" +"``FormattedValue.format_spec`` と同じ意味を持ちます。" #: ../../library/ast.rst:411 msgid "" @@ -777,7 +1058,6 @@ msgstr "" "ば ``(x,y)=something`` のような場合) は :class:`Store` であり、そうでない場合" "は :class:`Load` です。" -#: ../../library/ast.rst:415 msgid "" ">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -794,6 +1074,20 @@ msgid "" " Constant(value=2),\n" " Constant(value=3)]))" msgstr "" +">>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=List(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)]))\n" +">>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Tuple(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)]))" #: ../../library/ast.rst:435 msgid "A set. ``elts`` holds a list of nodes representing the set's elements." @@ -801,7 +1095,6 @@ msgstr "" "集合 (set) をあらわします。 ``elts`` は集合の各要素を表現するノードのリストを" "保持します。" -#: ../../library/ast.rst:437 msgid "" ">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" "Expression(\n" @@ -811,6 +1104,13 @@ msgid "" " Constant(value=2),\n" " Constant(value=3)]))" msgstr "" +">>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Set(\n" +" elts=[\n" +" Constant(value=1),\n" +" Constant(value=2),\n" +" Constant(value=3)]))" #: ../../library/ast.rst:450 msgid "" @@ -822,16 +1122,14 @@ msgstr "" "ト を順序が一致した形で (それぞれ :code:`dictionary.keys()` と :code:" "`dictionary.values()` を呼び出したときに返される順序で) 保持します。" -#: ../../library/ast.rst:454 msgid "" "When doing dictionary unpacking using dictionary literals the expression to " "be expanded goes in the ``values`` list, with a ``None`` at the " "corresponding position in ``keys``." msgstr "" -"辞書リテラルを使って辞書を展開した場合、展開された式ツリーにおいて辞書は " -"``values`` リストに入り、 ``keys`` の対応する位置には ``None`` が入ります。" +"辞書リテラルで辞書のアンパックを行う場合、展開対象の式が ``values`` リストに" +"入り、``keys`` の対応する位置には ``None`` が入ります。" -#: ../../library/ast.rst:458 msgid "" ">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" "Expression(\n" @@ -843,6 +1141,15 @@ msgid "" " Constant(value=1),\n" " Name(id='d')]))" msgstr "" +">>> print(ast.dump(ast.parse('{\"a\":1, **d}', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Dict(\n" +" keys=[\n" +" Constant(value='a'),\n" +" None],\n" +" values=[\n" +" Constant(value=1),\n" +" Name(id='d')]))" #: ../../library/ast.rst:472 msgid "Variables" @@ -866,7 +1173,6 @@ msgstr "" "るために使うことができます。変数の参照はこれら3つの場合を区別するためのコンテ" "キストによって与えられます。" -#: ../../library/ast.rst:488 msgid "" ">>> print(ast.dump(ast.parse('a'), indent=4))\n" "Module(\n" @@ -889,8 +1195,27 @@ msgid "" " targets=[\n" " Name(id='a', ctx=Del())])])" msgstr "" +">>> print(ast.dump(ast.parse('a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Name(id='a'))])\n" +"\n" +">>> print(ast.dump(ast.parse('a = 1'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='a', ctx=Store())],\n" +" value=Constant(value=1))])\n" +"\n" +">>> print(ast.dump(ast.parse('del a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Delete(\n" +" targets=[\n" +" Name(id='a', ctx=Del())])])" -#: ../../library/ast.rst:514 msgid "" "A ``*var`` variable reference. ``value`` holds the variable, typically a :" "class:`Name` node. This type must be used when building a :class:`Call` node " @@ -898,9 +1223,8 @@ msgid "" msgstr "" "``*var`` 形式の変数の参照をあらわします。 ``value`` は変数、典型的には :" "class:`Name` ノード、を保持します。この型は ``*args`` を伴う関数呼び出しノー" -"ド :class:`Call` を構築する際に使用します。 " +"ド :class:`Call` を構築する際に使用します。" -#: ../../library/ast.rst:518 msgid "" ">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" "Module(\n" @@ -916,6 +1240,19 @@ msgid "" " ctx=Store())],\n" " value=Name(id='it'))])" msgstr "" +">>> print(ast.dump(ast.parse('a, *b = it'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Starred(\n" +" value=Name(id='b', ctx=Store()),\n" +" ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='it'))])" #: ../../library/ast.rst:538 msgid "Expressions" @@ -935,7 +1272,6 @@ msgstr "" "`Lambda` ノード :class:`Yield` ノードまたは :class:`YieldFrom` ノードのいずれ" "かを保持します。" -#: ../../library/ast.rst:547 msgid "" ">>> print(ast.dump(ast.parse('-a'), indent=4))\n" "Module(\n" @@ -945,6 +1281,13 @@ msgid "" " op=USub(),\n" " operand=Name(id='a')))])" msgstr "" +">>> print(ast.dump(ast.parse('-a'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=UnaryOp(\n" +" op=USub(),\n" +" operand=Name(id='a')))])" #: ../../library/ast.rst:560 msgid "" @@ -962,7 +1305,6 @@ msgstr "" "単項演算の演算子をあらわします。 :class:`Not` は論理否定キーワード ``not`` で" "あり、 :class:`Invert` はビット反転演算子 ``~`` です。" -#: ../../library/ast.rst:572 msgid "" ">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" "Expression(\n" @@ -970,16 +1312,19 @@ msgid "" " op=Not(),\n" " operand=Name(id='x')))" msgstr "" +">>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))\n" +"Expression(\n" +" body=UnaryOp(\n" +" op=Not(),\n" +" operand=Name(id='x')))" -#: ../../library/ast.rst:583 msgid "" "A binary operation (like addition or division). ``op`` is the operator, and " "``left`` and ``right`` are any expression nodes." msgstr "" -"(加算や減算のような) 二項演算をあらわします。 ``op`` は演算子、 ``left`` と " -"``right`` は任意の式ツリーのノードです。" +"加算や除算のような二項演算を表します。\n" +"``op`` は演算子で、``left`` と ``right`` は任意の式ノードです。" -#: ../../library/ast.rst:586 msgid "" ">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" "Expression(\n" @@ -988,6 +1333,12 @@ msgid "" " op=Add(),\n" " right=Name(id='y')))" msgstr "" +">>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))\n" +"Expression(\n" +" body=BinOp(\n" +" left=Name(id='x'),\n" +" op=Add(),\n" +" right=Name(id='y')))" #: ../../library/ast.rst:610 msgid "Binary operator tokens." @@ -1009,7 +1360,6 @@ msgstr "" msgid "This doesn't include ``not``, which is a :class:`UnaryOp`." msgstr "``not`` は単項演算 :class:`UnaryOp` のため、ここには含まれません。" -#: ../../library/ast.rst:622 msgid "" ">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" "Expression(\n" @@ -1019,6 +1369,13 @@ msgid "" " Name(id='x'),\n" " Name(id='y')]))" msgstr "" +">>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))\n" +"Expression(\n" +" body=BoolOp(\n" +" op=Or(),\n" +" values=[\n" +" Name(id='x'),\n" +" Name(id='y')]))" #: ../../library/ast.rst:636 msgid "Boolean operator tokens." @@ -1033,7 +1390,6 @@ msgstr "" "2つ以上の値の比較をあらわします。 ``left`` 比較の中の最初の値、``ops`` は演算" "子のリスト、 ``comparators`` は2つ目以降の値のリストです。" -#: ../../library/ast.rst:645 msgid "" ">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" "Expression(\n" @@ -1046,6 +1402,16 @@ msgid "" " Name(id='a'),\n" " Constant(value=10)]))" msgstr "" +">>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Compare(\n" +" left=Constant(value=1),\n" +" ops=[\n" +" LtE(),\n" +" Lt()],\n" +" comparators=[\n" +" Name(id='a'),\n" +" Constant(value=10)]))" #: ../../library/ast.rst:670 msgid "Comparison operator tokens." @@ -1059,23 +1425,21 @@ msgstr "" "関数呼び出しをあらわします。 ``func`` は関数で、多くの場合 :class:`Name` また" "は :class:`Attribute` のオブジェクトです。 関数呼び出しの引数:" -#: ../../library/ast.rst:678 msgid "``args`` holds a list of the arguments passed by position." -msgstr "``args`` は位置引数のリストを保持します。 " +msgstr "``args`` は位置引数のリストを保持します。" -#: ../../library/ast.rst:679 msgid "" "``keywords`` holds a list of :class:`.keyword` objects representing " "arguments passed by keyword." msgstr "" +"``keywords`` は、キーワードで渡す引数を表す :class:`.keyword` オブジェクトの" +"リストを保持します。" -#: ../../library/ast.rst:682 msgid "" "The ``args`` and ``keywords`` arguments are optional and default to empty " "lists." -msgstr "" +msgstr "``args`` と ``keywords`` 引数は省略可能で、デフォルトは空リストです。" -#: ../../library/ast.rst:684 msgid "" ">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " "indent=4))\n" @@ -1093,6 +1457,21 @@ msgid "" " keyword(\n" " value=Name(id='e'))]))" msgstr "" +">>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), " +"indent=4))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='func'),\n" +" args=[\n" +" Name(id='a'),\n" +" Starred(\n" +" value=Name(id='d'))],\n" +" keywords=[\n" +" keyword(\n" +" arg='b',\n" +" value=Name(id='c')),\n" +" keyword(\n" +" value=Name(id='e'))]))" #: ../../library/ast.rst:704 msgid "" @@ -1110,7 +1489,6 @@ msgstr "" "``a if b else c`` のような式をあらわします。各フィールドは単一のノードを保持" "します。以下の例では、3つの式ノードはすべて :class:`Name` ノードです。" -#: ../../library/ast.rst:713 msgid "" ">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" "Expression(\n" @@ -1119,6 +1497,12 @@ msgid "" " body=Name(id='a'),\n" " orelse=Name(id='c')))" msgstr "" +">>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))\n" +"Expression(\n" +" body=IfExp(\n" +" test=Name(id='b'),\n" +" body=Name(id='a'),\n" +" orelse=Name(id='c')))" #: ../../library/ast.rst:725 msgid "" @@ -1132,7 +1516,6 @@ msgstr "" "はその属性がどのように振る舞うかに応じて :class:`Load`、 :class:`Store` また" "は :class:`Del` のいずれかです。" -#: ../../library/ast.rst:730 msgid "" ">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" "Expression(\n" @@ -1140,6 +1523,11 @@ msgid "" " value=Name(id='snake'),\n" " attr='colour'))" msgstr "" +">>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Attribute(\n" +" value=Name(id='snake'),\n" +" attr='colour'))" #: ../../library/ast.rst:741 msgid "" @@ -1153,7 +1541,6 @@ msgstr "" "であってもよい :class:`Assign` ノードと異なり、このノードの場合は ``target`` " "と ``value`` の両方が単一のノードでなければなりません。" -#: ../../library/ast.rst:746 msgid "" ">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" "Expression(\n" @@ -1161,6 +1548,11 @@ msgid "" " target=Name(id='x', ctx=Store()),\n" " value=Constant(value=4)))" msgstr "" +">>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))\n" +"Expression(\n" +" body=NamedExpr(\n" +" target=Name(id='x', ctx=Store()),\n" +" value=Constant(value=4)))" #: ../../library/ast.rst:757 msgid "Subscripting" @@ -1179,7 +1571,6 @@ msgstr "" "ん。 ``ctx`` は要素の参照により実行されるアクションに応じて :class:`Load`、 :" "class:`Store` または :class:`Del` のいずれかです。" -#: ../../library/ast.rst:767 msgid "" ">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1192,6 +1583,16 @@ msgid "" " upper=Constant(value=2)),\n" " Constant(value=3)])))" msgstr "" +">>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Subscript(\n" +" value=Name(id='l'),\n" +" slice=Tuple(\n" +" elts=[\n" +" Slice(\n" +" lower=Constant(value=1),\n" +" upper=Constant(value=2)),\n" +" Constant(value=3)])))" #: ../../library/ast.rst:783 msgid "" @@ -1203,7 +1604,6 @@ msgstr "" "わします。 :class:`Subscript` の *slice* フィールドでの直接指定か、または :" "class:`Tuple` の要素として指定する場合のみ利用可能です。" -#: ../../library/ast.rst:787 msgid "" ">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" "Expression(\n" @@ -1213,6 +1613,13 @@ msgid "" " lower=Constant(value=1),\n" " upper=Constant(value=2))))" msgstr "" +">>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))\n" +"Expression(\n" +" body=Subscript(\n" +" value=Name(id='l'),\n" +" slice=Slice(\n" +" lower=Constant(value=1),\n" +" upper=Constant(value=2))))" #: ../../library/ast.rst:799 msgid "Comprehensions" @@ -1228,18 +1635,18 @@ msgstr "" "たは ``key`` と ``value``) は各要素として評価される部品をあらわす単一のノード" "です。" -#: ../../library/ast.rst:810 msgid "" "For dictionary comprehensions using unpacking, for example ``{**item for " "item in items}``, the expression to be expanded goes in ``key`` and " "``value`` is ``None``." msgstr "" +"``{**item for item in items}`` のようにアンパックを使う辞書内包表記では、展開" +"する式が ``key`` に入り、``value`` は ``None`` になります。" #: ../../library/ast.rst:814 msgid "``generators`` is a list of :class:`comprehension` nodes." msgstr "``generators`` は :class:`comprehension` ノードのリストです。" -#: ../../library/ast.rst:816 msgid "" ">>> print(ast.dump(\n" "... ast.parse('[x for x in numbers]', mode='eval'),\n" @@ -1282,6 +1689,46 @@ msgid "" " iter=Name(id='numbers'),\n" " is_async=0)]))" msgstr "" +">>> print(ast.dump(\n" +"... ast.parse('[x for x in numbers]', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Name(id='x'),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers'),\n" +" is_async=0)]))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x: x**2 for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" +"Expression(\n" +" body=DictComp(\n" +" key=Name(id='x'),\n" +" value=BinOp(\n" +" left=Name(id='x'),\n" +" op=Pow(),\n" +" right=Constant(value=2)),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers'),\n" +" is_async=0)]))\n" +">>> print(ast.dump(\n" +"... ast.parse('{x for x in numbers}', mode='eval'),\n" +"... indent=4,\n" +"... ))\n" +"Expression(\n" +" body=SetComp(\n" +" elt=Name(id='x'),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='numbers'),\n" +" is_async=0)]))" #: ../../library/ast.rst:862 msgid "" @@ -1303,7 +1750,6 @@ msgstr "" "``is_async`` は内包表記が非同期であることを示します (``async for`` を " "``for`` の代わりに使います)。値は整数です (0 または 1)。" -#: ../../library/ast.rst:870 msgid "" ">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " "mode='eval'),\n" @@ -1363,6 +1809,63 @@ msgid "" " iter=Name(id='soc'),\n" " is_async=1)]))" msgstr "" +">>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', " +"mode='eval'),\n" +"... indent=4)) # 一つの内包表記に複数の for 節。\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Call(\n" +" func=Name(id='ord'),\n" +" args=[\n" +" Name(id='c')]),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='line', ctx=Store()),\n" +" iter=Name(id='file'),\n" +" is_async=0),\n" +" comprehension(\n" +" target=Name(id='c', ctx=Store()),\n" +" iter=Name(id='line'),\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', " +"mode='eval'),\n" +"... indent=4)) # ジェネレーター式\n" +"Expression(\n" +" body=GeneratorExp(\n" +" elt=BinOp(\n" +" left=Name(id='n'),\n" +" op=Pow(),\n" +" right=Constant(value=2)),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='n', ctx=Store()),\n" +" iter=Name(id='it'),\n" +" ifs=[\n" +" Compare(\n" +" left=Name(id='n'),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=5)]),\n" +" Compare(\n" +" left=Name(id='n'),\n" +" ops=[\n" +" Lt()],\n" +" comparators=[\n" +" Constant(value=10)])],\n" +" is_async=0)]))\n" +"\n" +">>> print(ast.dump(ast.parse('[i async for i in soc]', mode='eval'),\n" +"... indent=4)) # 非同期内包表記\n" +"Expression(\n" +" body=ListComp(\n" +" elt=Name(id='i'),\n" +" generators=[\n" +" comprehension(\n" +" target=Name(id='i', ctx=Store()),\n" +" iter=Name(id='soc'),\n" +" is_async=1)]))" #: ../../library/ast.rst:932 msgid "Statements" @@ -1393,7 +1896,6 @@ msgstr "" "``type_comment`` はコメントとして型アノテーションをあらわすオプション文字列で" "す。" -#: ../../library/ast.rst:946 msgid "" ">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment\n" "Module(\n" @@ -1416,25 +1918,54 @@ msgid "" " ctx=Store())],\n" " value=Name(id='c'))])" msgstr "" - -#: ../../library/ast.rst:972 -msgid "" -"An assignment with a type annotation. ``target`` is a single node and can be " -"a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " -"``annotation`` is the annotation, such as a :class:`Constant` or :class:" -"`Name` node. ``value`` is a single optional node." -msgstr "" - -#: ../../library/ast.rst:977 -msgid "" -"``simple`` is always either 0 (indicating a \"complex\" target) or 1 " -"(indicating a \"simple\" target). A \"simple\" target consists solely of a :" -"class:`Name` node that does not appear between parentheses; all other " -"targets are considered complex. Only simple targets appear in the :attr:" -"`~object.__annotations__` dictionary of modules and classes." +">>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # 多重代入\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" value=Constant(value=1))])\n" +"\n" +">>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # アンパック\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Tuple(\n" +" elts=[\n" +" Name(id='a', ctx=Store()),\n" +" Name(id='b', ctx=Store())],\n" +" ctx=Store())],\n" +" value=Name(id='c'))])" + +msgid "" +"An assignment with a type annotation. ``target`` is a single node and can be " +"a :class:`Name`, an :class:`Attribute` or a :class:`Subscript`. " +"``annotation`` is the annotation, such as a :class:`Constant` or :class:" +"`Name` node. ``value`` is a single optional node." +msgstr "" +"型アノテーションを伴う代入です。\n" +"``target`` は単一のノードで、:class:`Name`、:class:`Attribute`、:class:" +"`Subscript` のいずれかです。\n" +"``annotation`` はアノテーションを表す :class:`Constant` や :class:`Name` など" +"のノードです。\n" +"``value`` は省略可能な単一のノードです。" + +msgid "" +"``simple`` is always either 0 (indicating a \"complex\" target) or 1 " +"(indicating a \"simple\" target). A \"simple\" target consists solely of a :" +"class:`Name` node that does not appear between parentheses; all other " +"targets are considered complex. Only simple targets appear in the :attr:" +"`~object.__annotations__` dictionary of modules and classes." msgstr "" +"``simple`` は常に 0 (「複雑な」代入先) または 1 (「単純な」代入先) のいずれか" +"です。\n" +"「単純な」代入先は、括弧で囲まれていない :class:`Name` ノードだけからなり、そ" +"れ以外はすべて複雑な代入先とみなされます。\n" +"モジュールやクラスの :attr:`~object.__annotations__` 辞書に含まれるのは、単純" +"な代入先だけです。" -#: ../../library/ast.rst:983 msgid "" ">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" "Module(\n" @@ -1477,6 +2008,46 @@ msgid "" " annotation=Name(id='int'),\n" " simple=0)])" msgstr "" +">>> print(ast.dump(ast.parse('c: int'), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='c', ctx=Store()),\n" +" annotation=Name(id='int'),\n" +" simple=1)])\n" +"\n" +">>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # 括弧を伴うアノテー" +"ション\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='a', ctx=Store()),\n" +" annotation=Name(id='int'),\n" +" value=Constant(value=1),\n" +" simple=0)])\n" +"\n" +">>> print(ast.dump(ast.parse('a.b: int'), indent=4)) # 属性のアノテーション\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Attribute(\n" +" value=Name(id='a'),\n" +" attr='b',\n" +" ctx=Store()),\n" +" annotation=Name(id='int'),\n" +" simple=0)])\n" +"\n" +">>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # 添字付きのアノテー" +"ション\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Subscript(\n" +" value=Name(id='a'),\n" +" slice=Constant(value=1),\n" +" ctx=Store()),\n" +" annotation=Name(id='int'),\n" +" simple=0)])" #: ../../library/ast.rst:1027 msgid "" @@ -1498,7 +2069,6 @@ msgstr "" ":class:`Assign` と異なり、 ``target`` 属性は class :class:`Tuple` や :class:" "`List` であってはいけません。" -#: ../../library/ast.rst:1035 msgid "" ">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" "Module(\n" @@ -1508,6 +2078,13 @@ msgid "" " op=Add(),\n" " value=Constant(value=2))])" msgstr "" +">>> print(ast.dump(ast.parse('x += 2'), indent=4))\n" +"Module(\n" +" body=[\n" +" AugAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" op=Add(),\n" +" value=Constant(value=2))])" #: ../../library/ast.rst:1048 msgid "" @@ -1520,7 +2097,6 @@ msgstr "" "指定します。 ``cause`` はオプションで、 ``raise x from y`` の ``y`` にあたり" "ます。" -#: ../../library/ast.rst:1052 msgid "" ">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" "Module(\n" @@ -1529,6 +2105,12 @@ msgid "" " exc=Name(id='x'),\n" " cause=Name(id='y'))])" msgstr "" +">>> print(ast.dump(ast.parse('raise x from y'), indent=4))\n" +"Module(\n" +" body=[\n" +" Raise(\n" +" exc=Name(id='x'),\n" +" cause=Name(id='y'))])" #: ../../library/ast.rst:1064 msgid "" @@ -1538,7 +2120,6 @@ msgstr "" "アサーションです。 ``test`` は :class:`Compare` ノードなどのような条件を保持" "します。 ``msg`` は失敗した時のメッセージを保持します。" -#: ../../library/ast.rst:1067 msgid "" ">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" "Module(\n" @@ -1547,6 +2128,12 @@ msgid "" " test=Name(id='x'),\n" " msg=Name(id='y'))])" msgstr "" +">>> print(ast.dump(ast.parse('assert x,y'), indent=4))\n" +"Module(\n" +" body=[\n" +" Assert(\n" +" test=Name(id='x'),\n" +" msg=Name(id='y'))])" #: ../../library/ast.rst:1079 msgid "" @@ -1556,7 +2143,6 @@ msgstr "" "``del`` 文をあらわします。 ``targets`` は :class:`Name`, :class:" "`Attribute`, :class:`Subscript` などのノードのリストです。" -#: ../../library/ast.rst:1082 msgid "" ">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" "Module(\n" @@ -1567,28 +2153,40 @@ msgid "" " Name(id='y', ctx=Del()),\n" " Name(id='z', ctx=Del())])])" msgstr "" +">>> print(ast.dump(ast.parse('del x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Delete(\n" +" targets=[\n" +" Name(id='x', ctx=Del()),\n" +" Name(id='y', ctx=Del()),\n" +" Name(id='z', ctx=Del())])])" #: ../../library/ast.rst:1096 msgid "A ``pass`` statement." msgstr "``pass`` 文をあらわします。" -#: ../../library/ast.rst:1098 msgid "" ">>> print(ast.dump(ast.parse('pass'), indent=4))\n" "Module(\n" " body=[\n" " Pass()])" msgstr "" +">>> print(ast.dump(ast.parse('pass'), indent=4))\n" +"Module(\n" +" body=[\n" +" Pass()])" -#: ../../library/ast.rst:1108 msgid "" "A :ref:`type alias ` created through the :keyword:`type` " "statement. ``name`` is the name of the alias, ``type_params`` is a list of :" "ref:`type parameters `, and ``value`` is the value of the " "type alias." msgstr "" +":keyword:`type` 文で作成した :ref:`型エイリアス ` です。\n" +"``name`` はエイリアスの名前、``type_params`` は :ref:`型パラメーター ` のリスト、``value`` は型エイリアスの値です。" -#: ../../library/ast.rst:1113 msgid "" ">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" "Module(\n" @@ -1597,6 +2195,12 @@ msgid "" " name=Name(id='Alias', ctx=Store()),\n" " value=Name(id='int'))])" msgstr "" +">>> print(ast.dump(ast.parse('type Alias = int'), indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" value=Name(id='int'))])" #: ../../library/ast.rst:1124 msgid "" @@ -1613,7 +2217,6 @@ msgstr "インポート" msgid "An import statement. ``names`` is a list of :class:`alias` nodes." msgstr "インポート文です。 ``names`` は :class:`alias` ノードのリストです。" -#: ../../library/ast.rst:1134 msgid "" ">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" "Module(\n" @@ -1625,6 +2228,15 @@ msgid "" " alias(name='z')],\n" " is_lazy=0)])" msgstr "" +">>> print(ast.dump(ast.parse('import x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Import(\n" +" names=[\n" +" alias(name='x'),\n" +" alias(name='y'),\n" +" alias(name='z')],\n" +" is_lazy=0)])" #: ../../library/ast.rst:1149 msgid "" @@ -1638,7 +2250,6 @@ msgstr "" "のような構文の場合は ``None`` を指定します。 ``level`` は相対インポートのレベ" "ルを表す整数を保持します (0 は絶対インポートを意味します)。" -#: ../../library/ast.rst:1154 msgid "" ">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" "Module(\n" @@ -1652,6 +2263,17 @@ msgid "" " level=0,\n" " is_lazy=0)])" msgstr "" +">>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" ImportFrom(\n" +" module='y',\n" +" names=[\n" +" alias(name='x'),\n" +" alias(name='y'),\n" +" alias(name='z')],\n" +" level=0,\n" +" is_lazy=0)])" #: ../../library/ast.rst:1171 msgid "" @@ -1661,7 +2283,6 @@ msgstr "" "いずれのパラメータも名前をあらわす生の文字列です。 ``asname`` は標準の名前を" "使う場合は ``None`` を指定できます。" -#: ../../library/ast.rst:1174 msgid "" ">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" "Module(\n" @@ -1674,6 +2295,16 @@ msgid "" " level=2,\n" " is_lazy=0)])" msgstr "" +">>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))\n" +"Module(\n" +" body=[\n" +" ImportFrom(\n" +" module='foo.bar',\n" +" names=[\n" +" alias(name='a', asname='b'),\n" +" alias(name='c')],\n" +" level=2,\n" +" is_lazy=0)])" #: ../../library/ast.rst:1188 msgid "Control flow" @@ -1704,7 +2335,6 @@ msgstr "" "``elif`` 節は AST において固有の表現を持たず、先行する節をあらわすノードの " "``orelse`` セクションに追加の :class:`If` ノードとして現れます。" -#: ../../library/ast.rst:1203 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... if x:\n" @@ -1731,8 +2361,31 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... if x:\n" +"... ...\n" +"... elif y:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" If(\n" +" test=Name(id='x'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" If(\n" +" test=Name(id='y'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1233 msgid "" "A ``for`` loop. ``target`` holds the variable(s) the loop assigns to, as a " "single :class:`Name`, :class:`Tuple`, :class:`List`, :class:`Attribute` or :" @@ -1741,8 +2394,16 @@ msgid "" "Those in ``orelse`` are executed if the loop finishes normally, rather than " "via a ``break`` statement." msgstr "" +"``for`` ループです。\n" +"``target`` はループの代入先となる変数を、単一の :class:`Name`、:class:" +"`Tuple`、:class:`List`、:class:`Attribute`、:class:`Subscript` のいずれかの" +"ノードとして保持します。\n" +"``iter`` は繰り返しの対象となるオブジェクトを、同じく単一のノードとして保持し" +"ます。\n" +"``body`` と ``orelse`` は実行するノードのリストを保持します。\n" +"``orelse`` 内のノードは、``break`` 文によらずループが正常に終了した場合に実行" +"されます。" -#: ../../library/ast.rst:1244 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... for x in y:\n" @@ -1762,6 +2423,23 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... for x in y:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" For(\n" +" target=Name(id='x', ctx=Store()),\n" +" iter=Name(id='y'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])" #: ../../library/ast.rst:1267 msgid "" @@ -1771,7 +2449,6 @@ msgstr "" "``while`` ループです。 ``test`` は :class:`Compare` のような条件をあらわす" "ノードを保持します。" -#: ../../library/ast.rst:1270 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... while x:\n" @@ -1790,12 +2467,27 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... while x:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" While(\n" +" test=Name(id='x'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])" #: ../../library/ast.rst:1293 msgid "The ``break`` and ``continue`` statements." msgstr "``break`` 文および ``continue`` 文です。" -#: ../../library/ast.rst:1295 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... for a in b:\n" @@ -1823,6 +2515,31 @@ msgid "" " orelse=[\n" " Continue()])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... for a in b:\n" +"... if a > 5:\n" +"... break\n" +"... else:\n" +"... continue\n" +"...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" For(\n" +" target=Name(id='a', ctx=Store()),\n" +" iter=Name(id='b'),\n" +" body=[\n" +" If(\n" +" test=Compare(\n" +" left=Name(id='a'),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=5)]),\n" +" body=[\n" +" Break()],\n" +" orelse=[\n" +" Continue()])])])" #: ../../library/ast.rst:1326 msgid "" @@ -1832,7 +2549,6 @@ msgstr "" "``try`` ブロックです。 :class:`ExceptHandler` ノードのリストである " "``handlers`` を除き、全ての属性はそれぞれの節で実行するノードのリストです。" -#: ../../library/ast.rst:1329 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -1871,15 +2587,52 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... try:\n" +"... ...\n" +"... except Exception:\n" +"... ...\n" +"... except OtherException as e:\n" +"... ...\n" +"... else:\n" +"... ...\n" +"... finally:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Try(\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='Exception'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" ExceptHandler(\n" +" type=Name(id='OtherException'),\n" +" name='e',\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])],\n" +" orelse=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" finalbody=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])" -#: ../../library/ast.rst:1371 msgid "" "``try`` blocks which are followed by ``except*`` clauses. The attributes are " "the same as for :class:`Try` but the :class:`ExceptHandler` nodes in " "``handlers`` are interpreted as ``except*`` blocks rather than ``except``." msgstr "" +"``except*`` 節を伴う ``try`` ブロックです。\n" +"属性は :class:`Try` と同じですが、``handlers`` 内の :class:`ExceptHandler` " +"ノードは ``except`` ではなく ``except*`` ブロックとして解釈されます。" -#: ../../library/ast.rst:1375 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... try:\n" @@ -1900,10 +2653,28 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" - -#: ../../library/ast.rst:1400 -msgid "" -"A single ``except`` clause. ``type`` is the exception type it will match, " +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... try:\n" +"... ...\n" +"... except* Exception:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" TryStar(\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='Exception'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" + +#: ../../library/ast.rst:1400 +msgid "" +"A single ``except`` clause. ``type`` is the exception type it will match, " "typically a :class:`Name` node (or ``None`` for a catch-all ``except:`` " "clause). ``name`` is a raw string for the name to hold the exception, or " "``None`` if the clause doesn't have ``as foo``. ``body`` is a list of nodes." @@ -1914,7 +2685,6 @@ msgstr "" "持する変数の名前をあらわす生の文字列で、 ``as foo`` を持たない節の場合は " "``None`` を指定します。 ``body`` はノードのリストです。" -#: ../../library/ast.rst:1405 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... try:\n" @@ -1937,6 +2707,26 @@ msgid "" " body=[\n" " Pass()])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... try:\n" +"... a + 1\n" +"... except TypeError:\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Try(\n" +" body=[\n" +" Expr(\n" +" value=BinOp(\n" +" left=Name(id='a'),\n" +" op=Add(),\n" +" right=Constant(value=1)))],\n" +" handlers=[\n" +" ExceptHandler(\n" +" type=Name(id='TypeError'),\n" +" body=[\n" +" Pass()])])])" #: ../../library/ast.rst:1431 msgid "" @@ -1961,7 +2751,6 @@ msgstr "" "class:`Tuple` または :class:`List` のいずれかのノードか、または、この部分が不" "要な場合は ``None`` を設定します。" -#: ../../library/ast.rst:1446 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... with a as b, c as d:\n" @@ -1985,39 +2774,65 @@ msgid "" " Name(id='b'),\n" " Name(id='d')]))])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... with a as b, c as d:\n" +"... something(b, d)\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" With(\n" +" items=[\n" +" withitem(\n" +" context_expr=Name(id='a'),\n" +" optional_vars=Name(id='b', ctx=Store())),\n" +" withitem(\n" +" context_expr=Name(id='c'),\n" +" optional_vars=Name(id='d', ctx=Store()))],\n" +" body=[\n" +" Expr(\n" +" value=Call(\n" +" func=Name(id='something'),\n" +" args=[\n" +" Name(id='b'),\n" +" Name(id='d')]))])])" -#: ../../library/ast.rst:1472 msgid "Pattern matching" -msgstr "" +msgstr "パターンマッチ" -#: ../../library/ast.rst:1477 msgid "" "A ``match`` statement. ``subject`` holds the subject of the match (the " "object that is being matched against the cases) and ``cases`` contains an " "iterable of :class:`match_case` nodes with the different cases." msgstr "" +"``match`` 文です。\n" +"``subject`` はマッチ対象 (各 case と照合するオブジェクト) を保持し、" +"``cases`` は各 case を表す :class:`match_case` ノードのイテラブルを保持しま" +"す。" -#: ../../library/ast.rst:1485 msgid "" "A single case pattern in a ``match`` statement. ``pattern`` contains the " "match pattern that the subject will be matched against. Note that the :class:" "`AST` nodes produced for patterns differ from those produced for " "expressions, even when they share the same syntax." msgstr "" +"``match`` 文の一つの case パターンです。\n" +"``pattern`` は、対象と照合するパターンを保持します。\n" +"構文が同じでも、パターン用に生成される :class:`AST` ノードは、式用に生成され" +"るノードとは異なります。" -#: ../../library/ast.rst:1490 msgid "" "The ``guard`` attribute contains an expression that will be evaluated if the " "pattern matches the subject." msgstr "" +"``guard`` 属性は、パターンが対象にマッチした場合に評価する式を保持します。" -#: ../../library/ast.rst:1493 msgid "" "``body`` contains a list of nodes to execute if the pattern matches and the " "result of evaluating the guard expression is true." msgstr "" +"``body`` は、パターンがマッチし、ガード式の評価結果が真だった場合に実行する" +"ノードのリストを保持します。" -#: ../../library/ast.rst:1496 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2051,16 +2866,50 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] if x>0:\n" +"... ...\n" +"... case tuple():\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" guard=Compare(\n" +" left=Name(id='x'),\n" +" ops=[\n" +" Gt()],\n" +" comparators=[\n" +" Constant(value=0)]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='tuple')),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1534 msgid "" "A match literal or value pattern that compares by equality. ``value`` is an " "expression node. Permitted value nodes are restricted as described in the " "match statement documentation. This pattern succeeds if the match subject is " "equal to the evaluated value." msgstr "" +"等価比較を行うリテラルパターンまたは値パターンです。\n" +"``value`` は式ノードです。\n" +"指定できる値ノードは、match 文のドキュメントに記載されたとおりに制限されま" +"す。\n" +"マッチ対象が、式を評価した値と等しければ成功します。" -#: ../../library/ast.rst:1539 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2079,15 +2928,33 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case \"Relevant\":\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchValue(\n" +" value=Constant(value='Relevant')),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1562 msgid "" "A match literal pattern that compares by identity. ``value`` is the " "singleton to be compared against: ``None``, ``True``, or ``False``. This " "pattern succeeds if the match subject is the given constant." msgstr "" +"同一性を比較するリテラルパターンです。\n" +"``value`` は比較対象のシングルトンで、``None``、``True``、``False`` のいずれ" +"かです。\n" +"マッチ対象がこの定数と同一のオブジェクトなら成功します。" -#: ../../library/ast.rst:1566 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2105,16 +2972,34 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case None:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSingleton(value=None),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1588 msgid "" "A match sequence pattern. ``patterns`` contains the patterns to be matched " "against the subject elements if the subject is a sequence. Matches a " "variable length sequence if one of the subpatterns is a ``MatchStar`` node, " "otherwise matches a fixed length sequence." msgstr "" +"シーケンスパターンです。\n" +"``patterns`` は、対象がシーケンスである場合にその各要素と照合するパターンを保" +"持します。\n" +"サブパターンの一つが ``MatchStar`` ノードなら可変長のシーケンスに、それ以外な" +"ら固定長のシーケンスにマッチします。" -#: ../../library/ast.rst:1593 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2137,16 +3022,37 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [1, 2]:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=1)),\n" +" MatchValue(\n" +" value=Constant(value=2))]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1620 msgid "" "Matches the rest of the sequence in a variable length match sequence " "pattern. If ``name`` is not ``None``, a list containing the remaining " "sequence elements is bound to that name if the overall sequence pattern is " "successful." msgstr "" +"可変長のシーケンスパターンで、シーケンスの残りの部分にマッチします。\n" +"``name`` が ``None`` でなければ、シーケンスパターン全体が成功したときに、残り" +"の要素を含むリストをその名前に束縛します。" -#: ../../library/ast.rst:1624 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2179,8 +3085,37 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [1, 2, *rest]:\n" +"... ...\n" +"... case [*_]:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=1)),\n" +" MatchValue(\n" +" value=Constant(value=2)),\n" +" MatchStar(name='rest')]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchStar()]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1661 msgid "" "A match mapping pattern. ``keys`` is a sequence of expression nodes. " "``patterns`` is a corresponding sequence of pattern nodes. ``rest`` is an " @@ -2188,8 +3123,13 @@ msgid "" "elements. Permitted key expressions are restricted as described in the match " "statement documentation." msgstr "" +"マッピングパターンです。\n" +"``keys`` は式ノードのシーケンス、``patterns`` はそれに対応するパターンノード" +"のシーケンスです。\n" +"``rest`` は省略可能な名前で、マッピングの残りの要素を取得する場合に指定しま" +"す。\n" +"キーに使える式は、match 文のドキュメントに記載されたとおりに制限されます。" -#: ../../library/ast.rst:1667 msgid "" "This pattern succeeds if the subject is a mapping, all evaluated key " "expressions are present in the mapping, and the value corresponding to each " @@ -2197,8 +3137,11 @@ msgid "" "dict containing the remaining mapping elements is bound to that name if the " "overall mapping pattern is successful." msgstr "" +"対象がマッピングで、すべてのキー式の評価結果がそのマッピングに存在し、各キー" +"に対応する値が対応するサブパターンにマッチすれば成功します。\n" +"``rest`` が ``None`` でなければ、マッピングパターン全体が成功したときに、残り" +"の要素を含む辞書をその名前に束縛します。" -#: ../../library/ast.rst:1673 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2229,8 +3172,35 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case {1: _, 2: _}:\n" +"... ...\n" +"... case {**rest}:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchMapping(\n" +" keys=[\n" +" Constant(value=1),\n" +" Constant(value=2)],\n" +" patterns=[\n" +" MatchAs(),\n" +" MatchAs()]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchMapping(rest='rest'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1708 msgid "" "A match class pattern. ``cls`` is an expression giving the nominal class to " "be matched. ``patterns`` is a sequence of pattern nodes to be matched " @@ -2240,22 +3210,33 @@ msgid "" "the corresponding patterns (specified as keyword values in the class " "pattern)." msgstr "" +"クラスパターンです。\n" +"``cls`` は照合に使うクラスを表す式です。\n" +"``patterns`` はパターンノードのシーケンスで、クラスが定義するパターンマッチ用" +"の属性の並びと照合します。\n" +"``kwd_attrs`` は追加で照合する属性のシーケンス (クラスパターンのキーワード引" +"数の名前)、``kwd_patterns`` はそれらに対応するパターン (クラスパターンのキー" +"ワード引数の値) です。" -#: ../../library/ast.rst:1715 msgid "" "This pattern succeeds if the subject is an instance of the nominated class, " "all positional patterns match the corresponding class-defined attributes, " "and any specified keyword attributes match their corresponding pattern." msgstr "" +"対象が指定したクラスのインスタンスで、すべての位置パターンがクラスで定義した" +"対応する属性にマッチし、キーワードで指定した属性もそれぞれ対応するパターンに" +"マッチすれば成功します。" -#: ../../library/ast.rst:1719 msgid "" "Note: classes may define a property that returns self in order to match a " "pattern node against the instance being matched. Several builtin types are " "also matched that way, as described in the match statement documentation." msgstr "" +"クラスに ``self`` を返すプロパティを定義すると、パターンノードをインスタンス" +"自体と照合できます。\n" +"match 文のドキュメントで説明しているように、一部の組み込み型も同じように照合" +"されます。" -#: ../../library/ast.rst:1723 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2298,24 +3279,95 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case Point2D(0, 0):\n" +"... ...\n" +"... case Point3D(x=0, y=0, z=0):\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='Point2D'),\n" +" patterns=[\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0))]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchClass(\n" +" cls=Name(id='Point3D'),\n" +" kwd_attrs=[\n" +" 'x',\n" +" 'y',\n" +" 'z'],\n" +" kwd_patterns=[\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0)),\n" +" MatchValue(\n" +" value=Constant(value=0))]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1770 msgid "" "A match \"as-pattern\", capture pattern or wildcard pattern. ``pattern`` " "contains the match pattern that the subject will be matched against. If the " "pattern is ``None``, the node represents a capture pattern (i.e a bare name) " "and will always succeed." msgstr "" +"AS パターン、キャプチャパターン、またはワイルドカードパターンです。\n" +"``pattern`` は、対象と照合するパターンを保持します。\n" +"``pattern`` が ``None`` の場合、このノードはキャプチャパターン (名前だけのパ" +"ターン) を表し、常に成功します。" -#: ../../library/ast.rst:1775 msgid "" "The ``name`` attribute contains the name that will be bound if the pattern " "is successful. If ``name`` is ``None``, ``pattern`` must also be ``None`` " "and the node represents the wildcard pattern." msgstr "" - -#: ../../library/ast.rst:1779 -msgid "" +"``name`` 属性は、パターンが成功した場合に束縛する名前を保持します。\n" +"``name`` が ``None`` の場合は ``pattern`` も ``None`` でなければならず、ノー" +"ドはワイルドカードパターンを表します。" + +msgid "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] as y:\n" +"... ...\n" +"... case _:\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchAs(\n" +" pattern=MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" name='y'),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))]),\n" +" match_case(\n" +" pattern=MatchAs(),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" +msgstr "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" "... case [x] as y:\n" @@ -2342,9 +3394,7 @@ msgid "" " body=[\n" " Expr(\n" " value=Constant(value=Ellipsis))])])])" -msgstr "" -#: ../../library/ast.rst:1812 msgid "" "A match \"or-pattern\". An or-pattern matches each of its subpatterns in " "turn to the subject, until one succeeds. The or-pattern is then deemed to " @@ -2352,8 +3402,12 @@ msgid "" "``patterns`` attribute contains a list of match pattern nodes that will be " "matched against the subject." msgstr "" +"OR パターンです。\n" +"各サブパターンを順に対象と照合し、どれか一つが成功すれば OR パターン全体が成" +"功します。\n" +"どのサブパターンも成功しなければ失敗します。\n" +"``patterns`` 属性は、対象と照合するパターンノードのリストを保持します。" -#: ../../library/ast.rst:1818 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\n" "... match x:\n" @@ -2376,18 +3430,37 @@ msgid "" " Expr(\n" " value=Constant(value=Ellipsis))])])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\n" +"... match x:\n" +"... case [x] | (y):\n" +"... ...\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" Match(\n" +" subject=Name(id='x'),\n" +" cases=[\n" +" match_case(\n" +" pattern=MatchOr(\n" +" patterns=[\n" +" MatchSequence(\n" +" patterns=[\n" +" MatchAs(name='x')]),\n" +" MatchAs(name='y')]),\n" +" body=[\n" +" Expr(\n" +" value=Constant(value=Ellipsis))])])])" -#: ../../library/ast.rst:1845 msgid "Type annotations" -msgstr "" +msgstr "型アノテーション" -#: ../../library/ast.rst:1849 msgid "" "A ``# type: ignore`` comment located at *lineno*. *tag* is the optional tag " "specified by the form ``# type: ignore ``." msgstr "" +"*lineno* 行にある ``# type: ignore`` コメントです。\n" +"*tag* は、``# type: ignore `` の形式で指定する省略可能なタグです。" -#: ../../library/ast.rst:1852 msgid "" ">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " "indent=4))\n" @@ -2411,25 +3484,47 @@ msgid "" " type_ignores=[\n" " TypeIgnore(lineno=1, tag='[assignment]')])" msgstr "" +">>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" Assign(\n" +" targets=[\n" +" Name(id='x', ctx=Store())],\n" +" value=Constant(value=1))],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='')])\n" +">>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', " +"type_comments=True), indent=4))\n" +"Module(\n" +" body=[\n" +" AnnAssign(\n" +" target=Name(id='x', ctx=Store()),\n" +" annotation=Name(id='bool'),\n" +" value=Constant(value=1),\n" +" simple=1)],\n" +" type_ignores=[\n" +" TypeIgnore(lineno=1, tag='[assignment]')])" -#: ../../library/ast.rst:1875 msgid "" ":class:`!TypeIgnore` nodes are not generated when the *type_comments* " "parameter is set to ``False`` (default). See :func:`ast.parse` for more " "details." msgstr "" +"*type_comments* パラメーターが ``False`` (デフォルト) の場合、:class:`!" +"TypeIgnore` ノードは生成されません。\n" +"詳細は :func:`ast.parse` を参照してください。" -#: ../../library/ast.rst:1883 msgid "Type parameters" -msgstr "" +msgstr "型パラメーター" -#: ../../library/ast.rst:1885 msgid "" ":ref:`Type parameters ` can exist on classes, functions, and " "type aliases." msgstr "" +"クラス、関数、型エイリアスには :ref:`型パラメーター ` を定義でき" +"ます。" -#: ../../library/ast.rst:1890 msgid "" "A :class:`typing.TypeVar`. ``name`` is the name of the type variable. " "``bound`` is the bound or constraints, if any. If ``bound`` is a :class:" @@ -2437,8 +3532,13 @@ msgid "" "``default_value`` is the default value; if the :class:`!TypeVar` has no " "default, this attribute will be set to ``None``." msgstr "" +":class:`typing.TypeVar` を表します。\n" +"``name`` は型変数の名前です。\n" +"``bound`` は、指定されていれば上限または制約を保持します。\n" +":class:`Tuple` なら制約、それ以外なら上限を表します。\n" +"``default_value`` はデフォルト値で、:class:`!TypeVar` にデフォルトがなければ " +"``None`` になります。" -#: ../../library/ast.rst:1896 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " "indent=4))\n" @@ -2455,20 +3555,34 @@ msgid "" " value=Name(id='list'),\n" " slice=Name(id='T')))])" msgstr "" +">>> print(ast.dump(ast.parse(\"type Alias[T: int = bool] = list[T]\"), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" TypeVar(\n" +" name='T',\n" +" bound=Name(id='int'),\n" +" default_value=Name(id='bool'))],\n" +" value=Subscript(\n" +" value=Name(id='list'),\n" +" slice=Name(id='T')))])" -#: ../../library/ast.rst:1914 ../../library/ast.rst:1946 -#: ../../library/ast.rst:1973 msgid "Added the *default_value* parameter." -msgstr "" +msgstr "*default_value* パラメーターが追加されました。" -#: ../../library/ast.rst:1919 msgid "" "A :class:`typing.ParamSpec`. ``name`` is the name of the parameter " "specification. ``default_value`` is the default value; if the :class:`!" "ParamSpec` has no default, this attribute will be set to ``None``." msgstr "" +":class:`typing.ParamSpec` を表します。\n" +"``name`` はパラメーター仕様の名前です。\n" +"``default_value`` はデフォルト値で、:class:`!ParamSpec` にデフォルトがなけれ" +"ば ``None`` になります。" -#: ../../library/ast.rst:1923 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " "int]\"), indent=4))\n" @@ -2490,15 +3604,36 @@ msgid "" " Name(id='P'),\n" " Name(id='int')])))])" msgstr "" +">>> print(ast.dump(ast.parse(\"type Alias[**P = [int, str]] = Callable[P, " +"int]\"), indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" ParamSpec(\n" +" name='P',\n" +" default_value=List(\n" +" elts=[\n" +" Name(id='int'),\n" +" Name(id='str')]))],\n" +" value=Subscript(\n" +" value=Name(id='Callable'),\n" +" slice=Tuple(\n" +" elts=[\n" +" Name(id='P'),\n" +" Name(id='int')])))])" -#: ../../library/ast.rst:1951 msgid "" "A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable " "tuple. ``default_value`` is the default value; if the :class:`!TypeVarTuple` " "has no default, this attribute will be set to ``None``." msgstr "" +":class:`typing.TypeVarTuple` を表します。\n" +"``name`` は型変数タプルの名前です。\n" +"``default_value`` はデフォルト値で、:class:`!TypeVarTuple` にデフォルトがなけ" +"れば ``None`` になります。" -#: ../../library/ast.rst:1955 msgid "" ">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " "indent=4))\n" @@ -2515,6 +3650,20 @@ msgid "" " Starred(\n" " value=Name(id='Ts'))])))])" msgstr "" +">>> print(ast.dump(ast.parse(\"type Alias[*Ts = ()] = tuple[*Ts]\"), " +"indent=4))\n" +"Module(\n" +" body=[\n" +" TypeAlias(\n" +" name=Name(id='Alias', ctx=Store()),\n" +" type_params=[\n" +" TypeVarTuple(name='Ts', default_value=Tuple())],\n" +" value=Subscript(\n" +" value=Name(id='tuple'),\n" +" slice=Tuple(\n" +" elts=[\n" +" Starred(\n" +" value=Name(id='Ts'))])))])" #: ../../library/ast.rst:1977 msgid "Function and class definitions" @@ -2549,14 +3698,12 @@ msgstr "" msgid "``returns`` is the return annotation." msgstr "``returns`` は戻り値に対する注釈です。" -#: ../../library/ast.rst:1989 ../../library/ast.rst:2152 msgid "``type_params`` is a list of :ref:`type parameters `." msgstr "" +"``type_params`` は :ref:`型パラメーター ` のリストです。" -#: ../../library/ast.rst:1995 ../../library/ast.rst:2179 -#: ../../library/ast.rst:2190 msgid "Added ``type_params``." -msgstr "" +msgstr "``type_params`` が追加されました。" #: ../../library/ast.rst:2001 msgid "" @@ -2566,7 +3713,6 @@ msgstr "" "``lambda`` は式の中で使うことができる最小限の関数定義です。 :class:" "`FunctionDef` ノードと異なり、 ``body`` は単一のノードとなります。" -#: ../../library/ast.rst:2004 msgid "" ">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" "Module(\n" @@ -2579,6 +3725,16 @@ msgid "" " arg(arg='y')]),\n" " body=Constant(value=Ellipsis)))])" msgstr "" +">>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Lambda(\n" +" args=arguments(\n" +" args=[\n" +" arg(arg='x'),\n" +" arg(arg='y')]),\n" +" body=Constant(value=Ellipsis)))])" #: ../../library/ast.rst:2020 msgid "The arguments for a function." @@ -2617,11 +3773,13 @@ msgstr "" "です。デフォルト値の数nが位置引数の数より少ない場合、それらは最後のn個の引数" "に割り当てられます。" -#: ../../library/ast.rst:2034 msgid "" "A single argument in a list. ``arg`` is a raw string of the argument name; " "``annotation`` is its annotation, such as a :class:`Name` node." msgstr "" +"引数リスト内の一つの引数を表します。\n" +"``arg`` は引数名の文字列で、``annotation`` は :class:`Name` ノードなどで表す" +"アノテーションです。" #: ../../library/ast.rst:2039 msgid "" @@ -2630,7 +3788,6 @@ msgstr "" "``type_comment`` はコメントとして型アノテーションをあらわすオプション文字列で" "す。" -#: ../../library/ast.rst:2041 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -2668,12 +3825,46 @@ msgid "" " Name(id='decorator2')],\n" " returns=Constant(value='return annotation'))])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... @decorator1\n" +"... @decorator2\n" +"... def f(a: 'annotation', b=1, c=2, *d, e, f=3, **g) -> 'return " +"annotation':\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" FunctionDef(\n" +" name='f',\n" +" args=arguments(\n" +" args=[\n" +" arg(\n" +" arg='a',\n" +" annotation=Constant(value='annotation')),\n" +" arg(arg='b'),\n" +" arg(arg='c')],\n" +" vararg=arg(arg='d'),\n" +" kwonlyargs=[\n" +" arg(arg='e'),\n" +" arg(arg='f')],\n" +" kw_defaults=[\n" +" None,\n" +" Constant(value=3)],\n" +" kwarg=arg(arg='g'),\n" +" defaults=[\n" +" Constant(value=1),\n" +" Constant(value=2)]),\n" +" body=[\n" +" Pass()],\n" +" decorator_list=[\n" +" Name(id='decorator1'),\n" +" Name(id='decorator2')],\n" +" returns=Constant(value='return annotation'))])" #: ../../library/ast.rst:2081 msgid "A ``return`` statement." msgstr "``return`` 文です。" -#: ../../library/ast.rst:2083 msgid "" ">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" "Module(\n" @@ -2681,15 +3872,21 @@ msgid "" " Return(\n" " value=Constant(value=4))])" msgstr "" +">>> print(ast.dump(ast.parse('return 4'), indent=4))\n" +"Module(\n" +" body=[\n" +" Return(\n" +" value=Constant(value=4))])" -#: ../../library/ast.rst:2095 msgid "" "A ``yield`` or ``yield from`` expression. Because these are expressions, " "they must be wrapped in an :class:`Expr` node if the value sent back is not " "used." msgstr "" +"``yield`` 式または ``yield from`` 式です。\n" +"これらは式なので、返されてきた値を使わない場合は :class:`Expr` ノードで囲む必" +"要があります。" -#: ../../library/ast.rst:2098 msgid "" ">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" "Module(\n" @@ -2705,6 +3902,19 @@ msgid "" " value=YieldFrom(\n" " value=Name(id='x')))])" msgstr "" +">>> print(ast.dump(ast.parse('yield x'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=Yield(\n" +" value=Name(id='x')))])\n" +"\n" +">>> print(ast.dump(ast.parse('yield from x'), indent=4))\n" +"Module(\n" +" body=[\n" +" Expr(\n" +" value=YieldFrom(\n" +" value=Name(id='x')))])" #: ../../library/ast.rst:2118 msgid "" @@ -2712,7 +3922,6 @@ msgid "" msgstr "" "``global`` および ``nonlocal`` 文です。 ``names`` は生の文字列のリストです。" -#: ../../library/ast.rst:2120 msgid "" ">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" "Module(\n" @@ -2732,6 +3941,23 @@ msgid "" " 'y',\n" " 'z'])])" msgstr "" +">>> print(ast.dump(ast.parse('global x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Global(\n" +" names=[\n" +" 'x',\n" +" 'y',\n" +" 'z'])])\n" +"\n" +">>> print(ast.dump(ast.parse('nonlocal x,y,z'), indent=4))\n" +"Module(\n" +" body=[\n" +" Nonlocal(\n" +" names=[\n" +" 'x',\n" +" 'y',\n" +" 'z'])])" #: ../../library/ast.rst:2143 msgid "A class definition." @@ -2745,12 +3971,14 @@ msgstr "``name`` はクラス名をあらわす生の文字列です。" msgid "``bases`` is a list of nodes for explicitly specified base classes." msgstr "``bases`` は明示的に指定された基底クラスをあらわすノードのリストです。" -#: ../../library/ast.rst:2147 msgid "" "``keywords`` is a list of :class:`.keyword` nodes, principally for " "'metaclass'. Other keywords will be passed to the metaclass, as per :pep:" "`3115`." msgstr "" +"``keywords`` は :class:`.keyword` ノードのリストで、主に 'metaclass' の指定に" +"使います。\n" +"それ以外のキーワードは :pep:`3115` に従ってメタクラスに渡されます。" #: ../../library/ast.rst:2149 msgid "" @@ -2764,7 +3992,6 @@ msgstr "" "``decorator_list`` はノードのリストで、関数定義 :class:`FunctionDef` の場合と" "同様に解釈されます。" -#: ../../library/ast.rst:2154 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... @decorator1\n" @@ -2789,6 +4016,28 @@ msgid "" " Name(id='decorator1'),\n" " Name(id='decorator2')])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... @decorator1\n" +"... @decorator2\n" +"... class Foo(base1, base2, metaclass=meta):\n" +"... pass\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" ClassDef(\n" +" name='Foo',\n" +" bases=[\n" +" Name(id='base1'),\n" +" Name(id='base2')],\n" +" keywords=[\n" +" keyword(\n" +" arg='metaclass',\n" +" value=Name(id='meta'))],\n" +" body=[\n" +" Pass()],\n" +" decorator_list=[\n" +" Name(id='decorator1'),\n" +" Name(id='decorator2')])])" #: ../../library/ast.rst:2183 msgid "Async and await" @@ -2810,7 +4059,6 @@ msgstr "" "``await`` 式をあらわします。 ``value`` は待ち受ける値です。 :class:" "`AsyncFunctionDef` の本体 (body) の中でのみ有効です。" -#: ../../library/ast.rst:2199 msgid "" ">>> print(ast.dump(ast.parse(\"\"\"\\\n" "... async def f():\n" @@ -2827,6 +4075,20 @@ msgid "" " value=Call(\n" " func=Name(id='other_func'))))])])" msgstr "" +">>> print(ast.dump(ast.parse(\"\"\"\\\n" +"... async def f():\n" +"... await other_func()\n" +"... \"\"\"), indent=4))\n" +"Module(\n" +" body=[\n" +" AsyncFunctionDef(\n" +" name='f',\n" +" args=arguments(),\n" +" body=[\n" +" Expr(\n" +" value=Await(\n" +" value=Call(\n" +" func=Name(id='other_func'))))])])" #: ../../library/ast.rst:2220 msgid "" @@ -2838,7 +4100,6 @@ msgstr "" "class:`For` および :class:`With` と同じフィールドを持ちます。 :class:" "`AsyncFunctionDef` の本体 (body) の中でのみ有効です。" -#: ../../library/ast.rst:2225 msgid "" "When a string is parsed by :func:`ast.parse`, operator nodes (subclasses of :" "class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`, :class:`ast." @@ -2846,26 +4107,34 @@ msgid "" "singletons. Changes to one will be reflected in all other occurrences of the " "same value (for example, :class:`ast.Add`)." msgstr "" +":func:`ast.parse` で文字列を解析すると、返される木の演算子ノード (:class:" +"`ast.operator`、:class:`ast.unaryop`、:class:`ast.cmpop`、:class:`ast." +"boolop`、:class:`ast.expr_context` のサブクラス) はシングルトンになります。\n" +"一つを変更すると、同じ値 (例えば :class:`ast.Add`) を持つ他のすべての箇所にも" +"反映されます。" -#: ../../library/ast.rst:2233 msgid ":mod:`!ast` helpers" -msgstr "" +msgstr ":mod:`!ast` の補助機能" -#: ../../library/ast.rst:2235 msgid "" "Apart from the node classes, the :mod:`!ast` module defines these utility " "functions and classes for traversing abstract syntax trees:" msgstr "" +":mod:`!ast` モジュールは、ノードクラスに加えて、抽象構文木をたどるための次の" +"関数とクラスを定義しています。" -#: ../../library/ast.rst:2240 msgid "" "Parse the source into an AST node. Equivalent to ``compile(source, " "filename, mode, flags=FLAGS_VALUE, optimize=optimize, module=module)``, " "where ``FLAGS_VALUE`` is ``ast.PyCF_ONLY_AST`` if ``optimize <= 0`` and " "``ast.PyCF_OPTIMIZED_AST`` otherwise." msgstr "" +"ソースコードを解析し、AST ノードにします。\n" +"``compile(source, filename, mode, flags=FLAGS_VALUE, optimize=optimize, " +"module=module)`` と同じです。\n" +"ここで ``FLAGS_VALUE`` は、``optimize <= 0`` なら ``ast.PyCF_ONLY_AST``、それ" +"以外なら ``ast.PyCF_OPTIMIZED_AST`` です。" -#: ../../library/ast.rst:2245 msgid "" "If ``type_comments=True`` is given, the parser is modified to check and " "return type comments as specified by :pep:`484` and :pep:`526`. This is " @@ -2877,15 +4146,25 @@ msgid "" "the ``type_ignores`` attribute of :class:`Module` (otherwise it is always an " "empty list)." msgstr "" +"``type_comments=True`` を指定すると、パーサーは :pep:`484` と :pep:`526` で定" +"義された型コメントを検査して返すようになります。\n" +"これは :func:`compile` に渡すフラグに :data:`ast.PyCF_TYPE_COMMENTS` を追加す" +"るのと同じです。\n" +"不適切な位置に型コメントがあると構文エラーを報告します。\n" +"このフラグがなければ型コメントは無視され、対応する AST ノードの " +"``type_comment`` フィールドは常に ``None`` になります。\n" +"また、``# type: ignore`` コメントの位置は :class:`Module` の " +"``type_ignores`` 属性として返されます (このフラグがなければ常に空リストで" +"す)。" -#: ../../library/ast.rst:2255 msgid "" "In addition, if ``mode`` is ``'func_type'``, the input syntax is modified to " "correspond to :pep:`484` \"signature type comments\", for example ``(str, " "int) -> List[str]``." msgstr "" +"さらに、``mode`` が ``'func_type'`` の場合、``(str, int) -> List[str]`` のよ" +"うな :pep:`484` の「シグネチャ型コメント」に対応する入力構文を使います。" -#: ../../library/ast.rst:2259 msgid "" "Setting ``feature_version`` to a tuple ``(major, minor)`` will result in a " "\"best-effort\" attempt to parse using that Python version's grammar. For " @@ -2897,13 +4176,22 @@ msgid "" "is the same as when run on the Python version corresponding to " "``feature_version``." msgstr "" +"``feature_version`` にタプル ``(major, minor)`` を指定すると、できる限りその " +"Python バージョンの文法を使って解析します。\n" +"例えば ``feature_version=(3, 9)`` なら、:keyword:`match` 文を受け付けないよう" +"にします。\n" +"現在、``major`` は ``3`` でなければなりません。\n" +"サポートする最も古いバージョンは ``(3, 7)`` (将来の Python では引き上げられる" +"可能性があります)、最も新しいバージョンは ``sys.version_info[0:2]`` です。\n" +"あくまで可能な限り合わせるものであり、解析結果や解析の成否が " +"``feature_version`` に対応する Python で実行した場合と同じになる保証はありま" +"せん。" #: ../../library/ast.rst:2269 msgid "" "If source contains a null character (``\\0``), :exc:`ValueError` is raised." msgstr "" -#: ../../library/ast.rst:2272 msgid "" "Note that successfully parsing source code into an AST object doesn't " "guarantee that the source code provided is valid Python code that can be " @@ -2912,12 +4200,20 @@ msgid "" "node for a return statement, but it cannot be compiled alone (it needs to be " "inside a function node)." msgstr "" +"ソースコードを AST オブジェクトに解析できても、実行可能な正しい Python コード" +"であるとは限りません。\n" +"コンパイルの段階で、さらに :exc:`SyntaxError` が送出される可能性がありま" +"す。\n" +"例えば、``return 42`` というソースからは有効な return 文の AST ノードが生成さ" +"れますが、単独ではコンパイルできません (関数ノードの内部に置く必要がありま" +"す)。" -#: ../../library/ast.rst:2279 msgid "" "In particular, :func:`ast.parse` won't do any scoping checks, which the " "compilation step does." msgstr "" +"特に、:func:`ast.parse` はスコープの検査を行いません。\n" +"これはコンパイルの段階で行われます。" #: ../../library/ast.rst:2283 msgid "" @@ -2934,11 +4230,13 @@ msgstr "" "``type_comments``、``mode='func_type'``、``feature_version`` が追加されまし" "た。" -#: ../../library/ast.rst:2290 msgid "" "The minimum supported version for ``feature_version`` is now ``(3, 7)``. The " "``optimize`` argument was added." msgstr "" +"``feature_version`` でサポートする最も古いバージョンが ``(3, 7)`` になりまし" +"た。\n" +"``optimize`` 引数が追加されました。" #: ../../library/ast.rst:2294 msgid "Added the *module* parameter." @@ -2953,15 +4251,14 @@ msgstr "" ":class:`ast.AST` オブジェクトを逆に構文解析して、 :func:`ast.parse` が元の :" "class:`ast.AST` と等価なオブジェクトを生成できるような文字列を生成します。" -#: ../../library/ast.rst:2305 msgid "" "The produced code string will not necessarily be equal to the original code " "that generated the :class:`ast.AST` object (without any compiler " "optimizations, such as constant tuples/frozensets)." msgstr "" -"生成されたコード文字列は、生成元のコードである :class:`ast.AST` オブジェクト" -"と必ずしも等価であるとは限りません (定数タプルや frozenset などに対するコンパ" -"イラ最適化なしのコードです)。" +":class:`ast.AST` オブジェクトの生成元となったコードと、生成されたコード文字列" +"が一致するとは限りません (定数タプルや frozenset などに対するコンパイラ最適化" +"を行わない場合でも同様です)。" #: ../../library/ast.rst:2310 msgid "" @@ -2982,17 +4279,16 @@ msgstr "" "ます: 文字列、バイト列、数、タプル、リスト、辞書、集合、ブール値、``None``、" "``Ellipsis``。" -#: ../../library/ast.rst:2323 msgid "" "This can be used for evaluating strings containing Python values without the " "need to parse the values oneself. It is not capable of evaluating " "arbitrarily complex expressions, for example involving operators or indexing." msgstr "" -"この関数は Python の式を含んだ文字列を、値自身を解析することなしに評価するの" -"に使えます。この関数は、例えば演算や添え字を含んだ任意の複雑な表現を評価する" -"のには使えません。" +"この関数を使うと、Python の値を含む文字列を、自分で解析する処理を書かずに評価" +"できます。\n" +"演算子やインデックス参照を含む式など、任意の複雑な式を評価することはできませ" +"ん。" -#: ../../library/ast.rst:2328 msgid "" "This function had been documented as \"safe\" in the past without defining " "what that meant. That was misleading. This is specifically designed not to " @@ -3003,6 +4299,17 @@ msgid "" "excessive CPU consumption denial of service on some inputs. Calling it on " "untrusted data is thus not recommended." msgstr "" +"この関数は以前、意味を明確にしないまま「安全」と説明されていましたが、これは" +"誤解を招く表現でした。\n" +"より汎用的な :func:`eval` とは異なり、Python コードを実行しないように設計され" +"ています。\n" +"名前空間や名前の検索はなく、関数などを呼び出すこともできません。\n" +"しかし、攻撃を受けないわけではありません。\n" +"比較的小さな入力でも、メモリや C スタックを使い果たし、プロセスをクラッシュさ" +"せる可能性があります。\n" +"入力によっては、過剰な CPU 使用によるサービス拒否を引き起こす可能性もありま" +"す。\n" +"そのため、信頼できないデータに対して呼び出すことは推奨しません。" #: ../../library/ast.rst:2338 msgid "" @@ -3012,11 +4319,13 @@ msgstr "" "Python の抽象構文木コンパイラのスタックの深さの限界を越えることで、 Python イ" "ンタプリタをクラッシュさせる可能性があります。" -#: ../../library/ast.rst:2341 msgid "" "It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, :exc:" "`MemoryError` and :exc:`RecursionError` depending on the malformed input." msgstr "" +"不正な入力の内容によっては、:exc:`ValueError`、:exc:`TypeError`、:exc:" +"`SyntaxError`、:exc:`MemoryError`、:exc:`RecursionError` を送出することがあり" +"ます。" #: ../../library/ast.rst:2345 msgid "Now allows bytes and set literals." @@ -3026,9 +4335,8 @@ msgstr "バイト列リテラルと集合リテラルが受け取れるように msgid "Now supports creating empty sets with ``'set()'``." msgstr "``'set()'`` による空の集合の生成をサポートするようになりました。" -#: ../../library/ast.rst:2351 msgid "For string inputs, leading spaces and tabs are now stripped." -msgstr "" +msgstr "文字列の入力では、先頭のスペースとタブを取り除くようになりました。" #: ../../library/ast.rst:2357 msgid "" @@ -3047,13 +4355,16 @@ msgstr "" msgid ":class:`AsyncFunctionDef` is now supported." msgstr ":class:`AsyncFunctionDef` がサポートされました。" -#: ../../library/ast.rst:2369 msgid "" "Get source code segment of the *source* that generated *node*. If some " "location information (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.end_lineno`, :" "attr:`~ast.AST.col_offset`, or :attr:`~ast.AST.end_col_offset`) is missing, " "return ``None``." msgstr "" +"*source* から、*node* の生成元となったソースコードの部分を取得します。\n" +"位置情報 (:attr:`~ast.AST.lineno`、:attr:`~ast.AST.end_lineno`、:attr:`~ast." +"AST.col_offset`、:attr:`~ast.AST.end_col_offset`) のいずれかが欠けていれば " +"``None`` を返します。" #: ../../library/ast.rst:2373 msgid "" @@ -3063,7 +4374,6 @@ msgstr "" "*padded* が ``True`` の場合、複数行にわたる文の最初の行が元の位置に一致するよ" "うに空白文字でパディングされます。" -#: ../../library/ast.rst:2381 msgid "" "When you compile a node tree with :func:`compile`, the compiler expects :" "attr:`~ast.AST.lineno` and :attr:`~ast.AST.col_offset` attributes for every " @@ -3072,6 +4382,12 @@ msgid "" "set, by setting them to the values of the parent node. It works recursively " "starting at *node*." msgstr "" +"ノードの木を :func:`compile` でコンパイルする際、コンパイラは、対応するすべて" +"のノードに :attr:`~ast.AST.lineno` と :attr:`~ast.AST.col_offset` 属性がある" +"ことを前提とします。\n" +"生成したノードにこれらを手作業で設定するのは煩雑なので、この補助関数は、まだ" +"設定されていない属性に親ノードの値を再帰的に設定します。\n" +"処理は *node* から始まります。" #: ../../library/ast.rst:2390 msgid "" @@ -3082,12 +4398,14 @@ msgstr "" "*node* で始まるツリー内の各ノードの行番号と終了行番号を *n* ずつ増やします。" "これはファイルの中で別の場所に \"コードを移動する\" ときに便利です。" -#: ../../library/ast.rst:2397 msgid "" "Copy source location (:attr:`~ast.AST.lineno`, :attr:`~ast.AST.col_offset`, :" "attr:`~ast.AST.end_lineno`, and :attr:`~ast.AST.end_col_offset`) from " "*old_node* to *new_node* if possible, and return *new_node*." msgstr "" +"可能であれば、*old_node* のソース上の位置 (:attr:`~ast.AST.lineno`、:attr:" +"`~ast.AST.col_offset`、:attr:`~ast.AST.end_lineno`、:attr:`~ast.AST." +"end_col_offset`) を *new_node* にコピーし、*new_node* を返します。" #: ../../library/ast.rst:2404 msgid "" @@ -3157,9 +4475,8 @@ msgstr "" "ビジターが :meth:`generic_visit` を呼び出すかそれ自身で子ノードを訪れない限り" "訪れられないということです。" -#: ../../library/ast.rst:2446 msgid "Handles all constant nodes." -msgstr "" +msgstr "すべての定数ノードを処理します。" #: ../../library/ast.rst:2448 msgid "" @@ -3171,13 +4488,17 @@ msgstr "" "いけません。そうした目的のために変更を許す特別なビジター (:class:" "`NodeTransformer`) があります。" -#: ../../library/ast.rst:2454 msgid "" "Methods :meth:`!visit_Num`, :meth:`!visit_Str`, :meth:`!visit_Bytes`, :meth:" "`!visit_NameConstant` and :meth:`!visit_Ellipsis` will not be called in " "Python 3.14+. Add the :meth:`visit_Constant` method instead to handle all " "constant nodes." msgstr "" +"Python 3.14 以降では、:meth:`!visit_Num`、:meth:`!visit_Str`、:meth:`!" +"visit_Bytes`、:meth:`!visit_NameConstant`、:meth:`!visit_Ellipsis` メソッドは" +"呼び出されません。\n" +"代わりに :meth:`visit_Constant` メソッドを追加して、すべての定数ノードを処理" +"してください。" #: ../../library/ast.rst:2462 msgid "" @@ -3209,7 +4530,6 @@ msgstr "" "それでは例を示しましょう。Name (たとえば ``foo``) を見つけるたび全て " "``data['foo']`` に書き換える変換器 (transformer) です::" -#: ../../library/ast.rst:2474 msgid "" "class RewriteName(NodeTransformer):\n" "\n" @@ -3220,44 +4540,55 @@ msgid "" " ctx=node.ctx\n" " )" msgstr "" +"class RewriteName(NodeTransformer):\n" +"\n" +" def visit_Name(self, node):\n" +" return Subscript(\n" +" value=Name(id='data'),\n" +" slice=Constant(value=node.id),\n" +" ctx=node.ctx\n" +" )" -#: ../../library/ast.rst:2483 msgid "" "Keep in mind that if the node you're operating on has child nodes you must " "either transform the child nodes yourself or call the :meth:`~ast." "NodeVisitor.generic_visit` method for the node first." msgstr "" +"処理するノードに子ノードがある場合は、子ノードを自分で変換するか、先にその" +"ノードに対して :meth:`~ast.NodeVisitor.generic_visit` メソッドを呼び出す必要" +"があります。" -#: ../../library/ast.rst:2487 msgid "" "For nodes that were part of a collection of statements (that applies to all " "statement nodes), the visitor may also return a list of nodes rather than " "just a single node." msgstr "" -"文のコレクションであるようなノード (全ての文のノードが当てはまります) に対し" -"て、このビジターは単独のノードではなくノードのリストを返すかもしれません。" +"文のコレクションの要素であるノード (すべての文ノードが該当します) に対して" +"は、ビジターは単一のノードの代わりにノードのリストを返すこともできます。" -#: ../../library/ast.rst:2491 msgid "" "If :class:`NodeTransformer` introduces new nodes (that weren't part of " "original tree) without giving them location information (such as :attr:`~ast." "AST.lineno`), :func:`fix_missing_locations` should be called with the new " "sub-tree to recalculate the location information::" msgstr "" +":class:`NodeTransformer` で元の木にない新しいノードを追加し、:attr:`~ast.AST." +"lineno` などの位置情報を設定していない場合は、新しい部分木に対して :func:" +"`fix_missing_locations` を呼び出し、位置情報を補ってください。 ::" -#: ../../library/ast.rst:2496 msgid "" "tree = ast.parse('foo', mode='eval')\n" "new_tree = fix_missing_locations(RewriteName().visit(tree))" msgstr "" +"tree = ast.parse('foo', mode='eval')\n" +"new_tree = fix_missing_locations(RewriteName().visit(tree))" #: ../../library/ast.rst:2499 msgid "Usually you use the transformer like this::" msgstr "たいてい、変換器の使い方は次のようになります::" -#: ../../library/ast.rst:2501 msgid "node = YourTransformer().visit(node)" -msgstr "" +msgstr "node = YourTransformer().visit(node)" #: ../../library/ast.rst:2506 msgid "" @@ -3276,12 +4607,14 @@ msgstr "" "号や列オフセットのような属性はデフォルトではダンプされません。これが必要であ" "れば、 *include_attributes* を true にすると表示できます。" -#: ../../library/ast.rst:2514 msgid "" "If *color* is ``True``, the returned string is syntax highlighted using ANSI " "escape sequences. If ``False`` (the default), colored output is always " "disabled." msgstr "" +"*color* が ``True`` の場合、返される文字列は ANSI エスケープシーケンスで構文" +"を色分けします。\n" +"``False`` (デフォルト) の場合、色付きの出力は常に無効になります。" #: ../../library/ast.rst:2518 msgid "" @@ -3299,14 +4632,15 @@ msgstr "" "インデントされます。 *indent* が文字列 (``\"\\t\"`` など) の場合、その文字列" "が各レベルのインデントに使われます。" -#: ../../library/ast.rst:2525 msgid "" "If *show_empty* is false (the default), optional empty lists and ``Load()`` " "values will be omitted from the output. Optional ``None`` values are always " "omitted." msgstr "" +"*show_empty* が偽 (デフォルト) の場合、省略可能な空リストと ``Load()`` の値は" +"出力から省かれます。\n" +"省略可能な ``None`` の値は常に省かれます。" -#: ../../library/ast.rst:2529 msgid "" ">>> tree = ast.parse('print(None)', '?', 'eval')\n" ">>> print(ast.dump(tree, indent=4))\n" @@ -3323,28 +4657,37 @@ msgid "" " Constant(value=None)],\n" " keywords=[]))" msgstr "" +">>> tree = ast.parse('print(None)', '?', 'eval')\n" +">>> print(ast.dump(tree, indent=4))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print'),\n" +" args=[\n" +" Constant(value=None)]))\n" +">>> print(ast.dump(tree, indent=4, show_empty=True))\n" +"Expression(\n" +" body=Call(\n" +" func=Name(id='print', ctx=Load()),\n" +" args=[\n" +" Constant(value=None)],\n" +" keywords=[]))" #: ../../library/ast.rst:2546 msgid "Added the *indent* option." msgstr "*indent* オプションを追加しました。" -#: ../../library/ast.rst:2549 msgid "Added the *show_empty* option." -msgstr "" +msgstr "*show_empty* オプションが追加されました。" -#: ../../library/ast.rst:2552 msgid "Omit optional ``Load()`` values by default." -msgstr "" +msgstr "省略可能な ``Load()`` の値をデフォルトで省くようになりました。" -#: ../../library/ast.rst:2555 msgid "Added the *color* parameter." -msgstr "" +msgstr "*color* パラメーターを追加しました。" -#: ../../library/ast.rst:2561 msgid "Recursively compares two ASTs." -msgstr "" +msgstr "二つの AST を再帰的に比較します。" -#: ../../library/ast.rst:2563 msgid "" "*compare_attributes* affects whether AST attributes are considered in the " "comparison. If *compare_attributes* is ``False`` (default), then attributes " @@ -3352,10 +4695,15 @@ msgid "" "check whether the ASTs are structurally equal but differ in whitespace or " "similar details. Attributes include line numbers and column offsets." msgstr "" +"*compare_attributes* は、比較に AST の属性を含めるかどうかを指定します。\n" +"``False`` (デフォルト) の場合は属性を無視し、それ以外の場合はすべての属性が等" +"しい必要があります。\n" +"このオプションは、空白などの細部が異なっていても AST の構造が等しいかどうかを" +"調べる際に便利です。\n" +"属性には行番号や列オフセットが含まれます。" -#: ../../library/ast.rst:2576 msgid "Compiler flags" -msgstr "" +msgstr "コンパイラのフラグ" #: ../../library/ast.rst:2578 msgid "" @@ -3380,11 +4728,12 @@ msgid "" msgstr "" "コンパイルされたコードオブジェクトの代わりに抽象構文木を生成して返します。" -#: ../../library/ast.rst:2595 msgid "" "The returned AST is optimized according to the *optimize* argument in :func:" "`compile` or :func:`ast.parse`." msgstr "" +"返される AST は、:func:`compile` または :func:`ast.parse` の *optimize* 引数" +"に従って最適化されます。" #: ../../library/ast.rst:2602 msgid "" @@ -3398,21 +4747,22 @@ msgstr "" msgid "Command-line usage" msgstr "コマンドラインでの使用" -#: ../../library/ast.rst:2615 msgid "" "The output is now syntax highlighted by default. This can be :ref:" "`controlled using environment variables `." msgstr "" +"デフォルトで、出力の構文を色分けするようになりました。\n" +"この動作は :ref:`環境変数で制御できます `。" -#: ../../library/ast.rst:2619 msgid "" "The :mod:`!ast` module can be executed as a script from the command line. It " "is as simple as:" msgstr "" +":mod:`!ast` モジュールは、次のようにコマンドラインからスクリプトとして実行で" +"きます。" -#: ../../library/ast.rst:2622 msgid "python -m ast [-m ] [-a] [infile]" -msgstr "" +msgstr "python -m ast [-m ] [-a] [infile]" #: ../../library/ast.rst:2626 msgid "The following options are accepted:" @@ -3442,15 +4792,17 @@ msgstr "行番号や列オフセットなどの属性を含めます。" msgid "Indentation of nodes in AST (number of spaces)." msgstr "AST におけるノードのインデント (空白の数) です。" -#: ../../library/ast.rst:2655 msgid "" "Python version in the format 3.x (for example, 3.10). Defaults to the " "current version of the interpreter." msgstr "" +"3.x 形式の Python バージョン (例: 3.10)。\n" +"デフォルトは現在のインタープリタのバージョンです。" -#: ../../library/ast.rst:2663 msgid "Optimization level for parser. Defaults to no optimization." msgstr "" +"パーサーの最適化レベル。\n" +"デフォルトでは最適化しません。" #: ../../library/ast.rst:2669 msgid "" @@ -3474,7 +4826,6 @@ msgstr "" "外部ドキュメント `Green Tree Snakes `_ には Python AST についての詳細が書かれています。" -#: ../../library/ast.rst:2684 msgid "" "`ASTTokens `_ " "annotates Python ASTs with the positions of tokens and text in the source " @@ -3483,14 +4834,16 @@ msgid "" msgstr "" "`ASTTokens `_ は " "Python AST を、生成元のソースコードのトークン位置やテキストで注解します。これ" -"はソースコード変換を行うツールで有用です。 " +"はソースコード変換を行うツールで有用です。" -#: ../../library/ast.rst:2689 msgid "" "`leoAst.py `_ unifies the token-based and parse-tree-based views of python programs " "by inserting two-way links between tokens and ast nodes." msgstr "" +"`leoAst.py `_ は、トークンと AST ノードの間に双方向のリンクを挿入することで、Python " +"プログラムのトークンに基づく表現と構文木に基づく表現を結び付けます。" #: ../../library/ast.rst:2694 msgid "" @@ -3503,21 +4856,23 @@ msgstr "" "は自動リファクタリングアプリケーション (codemod) やリンタを作成する際に有用で" "す。" -#: ../../library/ast.rst:2699 msgid "" "`Parso `_ is a Python parser that supports " "error recovery and round-trip parsing for different Python versions (in " "multiple Python versions). Parso is also able to list multiple syntax errors " "in your Python file." msgstr "" +"`Parso `_ は、エラーからの回復と、ソースコード" +"を解析して元に戻す処理をサポートする Python パーサーです。\n" +"複数の Python バージョン上で動作し、異なるバージョンの構文を扱えます。\n" +"Python ファイル内の複数の構文エラーを列挙することもできます。" #: ../../library/ast.rst:58 msgid "? (question mark)" msgstr "? (クエスチョンマーク)" -#: ../../library/ast.rst:58 ../../library/ast.rst:59 msgid "in AST grammar" -msgstr "" +msgstr "AST の文法内" #: ../../library/ast.rst:59 msgid "* (asterisk)" diff --git a/library/asynchat.po b/library/asynchat.po index 9b2b5669c..688ba24db 100644 --- a/library/asynchat.po +++ b/library/asynchat.po @@ -12,29 +12,32 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asynchat.rst:2 msgid ":mod:`!asynchat` --- Asynchronous socket command/response handler" -msgstr "" +msgstr ":mod:`!asynchat` --- 非同期ソケットのコマンド・応答ハンドラー" -#: ../../library/asynchat.rst:10 msgid "" "This module is no longer part of the Python standard library. It was :ref:" "`removed in Python 3.12 ` after being deprecated in " "Python 3.6. The removal was decided in :pep:`594`." msgstr "" +"このモジュールは Python 標準ライブラリから削除されました。\n" +"Python 3.6 で非推奨となり、:ref:`Python 3.12 で削除 ` さ" +"れました。\n" +"削除は :pep:`594` で決定されました。" -#: ../../library/asynchat.rst:14 msgid "Applications should use the :mod:`asyncio` module instead." msgstr "" +"アプリケーションでは、代わりに :mod:`asyncio` モジュールを使ってください。" -#: ../../library/asynchat.rst:16 msgid "" "The last version of Python that provided the :mod:`!asynchat` module was " "`Python 3.11 `_." msgstr "" +":mod:`!asynchat` モジュールが含まれる最後のバージョンは `Python 3.11 " +"`_ です。" diff --git a/library/asyncio-api-index.po b/library/asyncio-api-index.po index 5ba35f823..e15b8a555 100644 --- a/library/asyncio-api-index.po +++ b/library/asyncio-api-index.po @@ -16,33 +16,31 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-api-index.rst:6 msgid "High-level API Index" msgstr "高水準の API インデックス" -#: ../../library/asyncio-api-index.rst:8 msgid "This page lists all high-level async/await enabled asyncio APIs." msgstr "" -"このページには、すべての高水準の 非同期/待機 可能な asyncio API が一覧になっ" -"ています。" +"このページには、async/await に対応する asyncio の高水準 API をすべて列挙して" +"います。" #: ../../library/asyncio-api-index.rst:12 msgid "Tasks" msgstr "Task" -#: ../../library/asyncio-api-index.rst:14 msgid "" "Utilities to run asyncio programs, create Tasks, and await on multiple " "things with timeouts." msgstr "" -"ユーティリティは asyncio プログラムを実行し、タスクを作成し、タイムアウトのあ" -"る複数の機能を待っています。" +"asyncio プログラムの実行、タスクの作成、タイムアウト付きで複数の処理の完了を" +"待つためのユーティリティです。" #: ../../library/asyncio-api-index.rst:21 msgid ":func:`run`" @@ -108,9 +106,8 @@ msgstr "イベントループのまだ終了していないすべてのタスク msgid "``await`` :func:`sleep`" msgstr "``await`` :func:`sleep`" -#: ../../library/asyncio-api-index.rst:45 msgid "Sleep for a number of seconds." -msgstr "数秒間スリープします。" +msgstr "指定した秒数だけスリープします。" #: ../../library/asyncio-api-index.rst:47 msgid "``await`` :func:`gather`" diff --git a/library/asyncio-dev.po b/library/asyncio-dev.po index c7790b7b3..b788aa0d2 100644 --- a/library/asyncio-dev.po +++ b/library/asyncio-dev.po @@ -16,22 +16,21 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-dev.rst:7 msgid "Developing with asyncio" msgstr "asyncio での開発" -#: ../../library/asyncio-dev.rst:9 msgid "" "Asynchronous programming is different from classic \"sequential\" " "programming." msgstr "" -"非同期プログラミングは伝統的な \"同期的\" プログラミングとは異なります。" +"非同期プログラミングは、従来の「逐次的」なプログラミングとは異なります。" #: ../../library/asyncio-dev.rst:12 msgid "" @@ -85,9 +84,8 @@ msgstr "" ":ref:`asyncio ロガー ` のログレベルを :py:const:`logging." "DEBUG` に設定します。例えばアプリケーションの起動時に以下を実行します::" -#: ../../library/asyncio-dev.rst:40 msgid "logging.basicConfig(level=logging.DEBUG)" -msgstr "" +msgstr "logging.basicConfig(level=logging.DEBUG)" #: ../../library/asyncio-dev.rst:42 msgid "" @@ -121,15 +119,14 @@ msgstr "" "I/O セレクタが I/O 処理を実行する時間が長すぎる場合、その実行時間が記録されま" "す。" -#: ../../library/asyncio-dev.rst:56 msgid "" "Callbacks taking longer than 100 milliseconds are logged. The :attr:`loop." "slow_callback_duration` attribute can be used to set the minimum execution " "duration in seconds that is considered \"slow\"." msgstr "" -"実行時間が100ミリ秒を超えるコールバックは記録されます。 \"遅い\" の判断基準と" -"なる実行時間の最小値は :attr:`loop.slow_callback_duration` 属性で設定できま" -"す。" +"実行時間が 100 ミリ秒を超えるコールバックはログに記録されます。\n" +":attr:`loop.slow_callback_duration` 属性で、「遅い」とみなす実行時間の最小値" +"を秒単位で設定できます。" #: ../../library/asyncio-dev.rst:64 msgid "Concurrency and Multithreading" @@ -157,11 +154,9 @@ msgstr "" "別の OS スレッドからのコールバック (:term:`callback`) をスケジュールする場" "合、 :meth:`loop.call_soon_threadsafe` メソッドを使ってください。例:" -#: ../../library/asyncio-dev.rst:75 msgid "loop.call_soon_threadsafe(callback, *args)" -msgstr "" +msgstr "loop.call_soon_threadsafe(callback, *args)" -#: ../../library/asyncio-dev.rst:77 msgid "" "Almost all asyncio objects are not thread safe, which is typically not a " "problem unless there is code that works with them from outside of a Task or " @@ -172,11 +167,10 @@ msgstr "" "バックの外側で非同期オブジェクトを使うコードが存在しない限り、それが問題には" "なることはほとんどありません。もしそのような目的で低レベルの asyncio API を呼" "び出すようなコードを書く必要がある場合、 :meth:`loop.call_soon_threadsafe` メ" -"ソッドを使ってください。例: " +"ソッドを使ってください。例:" -#: ../../library/asyncio-dev.rst:83 msgid "loop.call_soon_threadsafe(fut.cancel)" -msgstr "" +msgstr "loop.call_soon_threadsafe(fut.cancel)" #: ../../library/asyncio-dev.rst:85 msgid "" @@ -185,11 +179,10 @@ msgid "" "`concurrent.futures.Future` to access the result::" msgstr "" "別の OS スレッドからコルーチンオブジェクトをスケジュールする場合は、 :func:" -"`run_coroutine_threadsafe` メソッドを使ってください。 :func:" -"`run_coroutine_threadsafe` は結果にアクセスするための :class:`concurrent." +"`run_coroutine_threadsafe` メソッドを使ってください。 " +"``run_coroutine_threadsafe()`` は結果にアクセスするための :class:`concurrent." "futures.Future` オブジェクトを返します:" -#: ../../library/asyncio-dev.rst:89 msgid "" "async def coro_func():\n" " return await asyncio.sleep(1, 42)\n" @@ -200,6 +193,14 @@ msgid "" "# Wait for the result:\n" "result = future.result()" msgstr "" +"async def coro_func():\n" +" return await asyncio.sleep(1, 42)\n" +"\n" +"# 後で、別の OS スレッド内で実行する:\n" +"\n" +"future = asyncio.run_coroutine_threadsafe(coro_func(), loop)\n" +"# 結果を待つ:\n" +"result = future.result()" #: ../../library/asyncio-dev.rst:98 msgid "To handle signals the event loop must be run in the main thread." @@ -207,13 +208,16 @@ msgstr "" "シグナルの処理を行うには、イベントループはメインスレッド内で実行しなければな" "りません。" -#: ../../library/asyncio-dev.rst:101 msgid "" "The :meth:`loop.run_in_executor` method can be used with a :class:" "`concurrent.futures.ThreadPoolExecutor` or :class:`~concurrent.futures." "InterpreterPoolExecutor` to execute blocking code in a different OS thread " "without blocking the OS thread that the event loop runs in." msgstr "" +":meth:`loop.run_in_executor` メソッドを :class:`concurrent.futures." +"ThreadPoolExecutor` または :class:`~concurrent.futures." +"InterpreterPoolExecutor` と組み合わせると、イベントループの OS スレッドをブ" +"ロックせずに、別の OS スレッドでブロッキングコードを実行できます。" #: ../../library/asyncio-dev.rst:107 msgid "" @@ -241,7 +245,6 @@ msgstr "" msgid "Running Blocking Code" msgstr "ブロッキングコードの実行" -#: ../../library/asyncio-dev.rst:123 msgid "" "Blocking (CPU-bound) code should not be called directly. For example, if a " "function performs a CPU-intensive calculation for 1 second, all concurrent " @@ -249,15 +252,17 @@ msgid "" msgstr "" "ブロッキングコード (CPU バウンドなコード) を直接呼び出すべきではありません。" "たとえば、 CPU 負荷の高い関数を1秒実行したとすると、並行に処理されている全て" -"の非同期タスクと I/O 処理は1秒遅れる可能性があります。 " +"の非同期タスクと I/O 処理は1秒遅れる可能性があります。" -#: ../../library/asyncio-dev.rst:128 msgid "" "An executor can be used to run a task in a different thread, including in a " "different interpreter, or even in a different process to avoid blocking the " "OS thread with the event loop. See the :meth:`loop.run_in_executor` method " "for more details." msgstr "" +"Executor を使うと、別のスレッド (別のインタープリタを含む) や別のプロセスで処" +"理を実行し、イベントループの OS スレッドがブロックされるのを避けられます。\n" +"詳細は :meth:`loop.run_in_executor` メソッドを参照してください。" #: ../../library/asyncio-dev.rst:138 msgid "Logging" @@ -279,9 +284,8 @@ msgstr "" "デフォルトのログレベルは :py:const:`logging.INFO` ですが、これは簡単に調節で" "きます:" -#: ../../library/asyncio-dev.rst:146 msgid "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" -msgstr "" +msgstr "logging.getLogger(\"asyncio\").setLevel(logging.WARNING)" #: ../../library/asyncio-dev.rst:149 msgid "" @@ -297,18 +301,15 @@ msgstr "" msgid "Detect never-awaited coroutines" msgstr "待ち受け処理を伴わないコルーチンの検出" -#: ../../library/asyncio-dev.rst:159 msgid "" "When a coroutine function is called, but not awaited (e.g. ``coro()`` " "instead of ``await coro()``) or the coroutine is not scheduled with :meth:" "`asyncio.create_task`, asyncio will emit a :exc:`RuntimeWarning`::" msgstr "" -"コルーチンが呼び出されただけで、待ち受け処理がない場合 (たとえば ``await " -"coro()`` のかわりに ``coro()`` と書いてしまった場合) 、またはコルーチンが :" -"meth:`asyncio.create_task` を使わずにスケジュールされた場合、 asyncio は :" -"exc:`RuntimeWarning` 警告を送出します:" +"コルーチン関数を呼び出しただけで、await も :meth:`asyncio.create_task` による" +"スケジュールも行わなかった場合 (例えば ``await coro()`` の代わりに " +"``coro()`` と書いた場合)、asyncio は :exc:`RuntimeWarning` を出します。 ::" -#: ../../library/asyncio-dev.rst:164 msgid "" "import asyncio\n" "\n" @@ -320,23 +321,32 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def test():\n" +" print(\"never scheduled\")\n" +"\n" +"async def main():\n" +" test()\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-dev.rst:174 ../../library/asyncio-dev.rst:219 #: ../../library/asyncio-dev.rst:393 ../../library/asyncio-dev.rst:450 msgid "Output::" msgstr "出力::" -#: ../../library/asyncio-dev.rst:176 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" " test()" msgstr "" +"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" +" test()" #: ../../library/asyncio-dev.rst:179 ../../library/asyncio-dev.rst:235 msgid "Output in debug mode::" msgstr "デバッグモードの出力::" -#: ../../library/asyncio-dev.rst:181 msgid "" "test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" "Coroutine created at (most recent call last)\n" @@ -349,6 +359,16 @@ msgid "" " test()\n" " test()" msgstr "" +"test.py:7: RuntimeWarning: coroutine 'test' was never awaited\n" +"Coroutine created at (most recent call last)\n" +" File \"../t.py\", line 9, in \n" +" asyncio.run(main(), debug=True)\n" +"\n" +" < .. >\n" +"\n" +" File \"../t.py\", line 7, in main\n" +" test()\n" +" test()" #: ../../library/asyncio-dev.rst:192 msgid "" @@ -358,11 +378,12 @@ msgstr "" "通常の修正方法はコルーチンを待ち受ける (await) か、 :meth:`asyncio." "create_task` 関数を呼び出すことです:" -#: ../../library/asyncio-dev.rst:195 msgid "" "async def main():\n" " await test()" msgstr "" +"async def main():\n" +" await test()" #: ../../library/asyncio-dev.rst:200 msgid "Detect never-retrieved exceptions" @@ -384,7 +405,6 @@ msgstr "" msgid "Example of an unhandled exception::" msgstr "処理されない例外の例:" -#: ../../library/asyncio-dev.rst:209 msgid "" "import asyncio\n" "\n" @@ -396,8 +416,16 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def bug():\n" +" raise Exception(\"not consumed\")\n" +"\n" +"async def main():\n" +" asyncio.create_task(bug())\n" +"\n" +"asyncio.run(main())" -#: ../../library/asyncio-dev.rst:221 msgid "" "Task exception was never retrieved\n" "future: \n" @@ -408,6 +436,14 @@ msgid "" " raise Exception(\"not consumed\")\n" "Exception: not consumed" msgstr "" +"Task exception was never retrieved\n" +"future: \n" +" exception=Exception('not consumed')>\n" +"\n" +"Traceback (most recent call last):\n" +" File \"test.py\", line 4, in bug\n" +" raise Exception(\"not consumed\")\n" +"Exception: not consumed" #: ../../library/asyncio-dev.rst:230 msgid "" @@ -417,11 +453,9 @@ msgstr "" "タスクが生成された箇所を特定するには、 :ref:`デバッグモードを有効化して " "` トレースバックを取得してください:" -#: ../../library/asyncio-dev.rst:233 msgid "asyncio.run(main(), debug=True)" -msgstr "" +msgstr "asyncio.run(main(), debug=True)" -#: ../../library/asyncio-dev.rst:237 msgid "" "Task exception was never retrieved\n" "future: \n" @@ -438,23 +472,36 @@ msgid "" " raise Exception(\"not consumed\")\n" "Exception: not consumed" msgstr "" +"Task exception was never retrieved\n" +"future: \n" +" exception=Exception('not consumed') created at asyncio/tasks.py:321>\n" +"\n" +"source_traceback: Object created at (most recent call last):\n" +" File \"../t.py\", line 9, in \n" +" asyncio.run(main(), debug=True)\n" +"\n" +"< .. >\n" +"\n" +"Traceback (most recent call last):\n" +" File \"../t.py\", line 4, in bug\n" +" raise Exception(\"not consumed\")\n" +"Exception: not consumed" -#: ../../library/asyncio-dev.rst:254 msgid "Asynchronous generators best practices" -msgstr "" +msgstr "非同期ジェネレーターを使う際の推奨事項" -#: ../../library/asyncio-dev.rst:256 msgid "" "Writing correct and efficient asyncio code requires awareness of certain " "pitfalls. This section outlines essential best practices that can save you " "hours of debugging." msgstr "" +"正しく効率的な asyncio コードを書くには、いくつかの落とし穴を知っておく必要が" +"あります。\n" +"この節では、長時間のデバッグを避けるために役立つ重要な実践方法を説明します。" -#: ../../library/asyncio-dev.rst:261 msgid "Close asynchronous generators explicitly" -msgstr "" +msgstr "非同期ジェネレーターを明示的に閉じる" -#: ../../library/asyncio-dev.rst:263 msgid "" "It is recommended to manually close the :term:`asynchronous generator " "`. If a generator exits early - for " @@ -463,14 +510,23 @@ msgid "" "occur after the tasks it depends on have completed, or during the event loop " "shutdown when the async-generator's garbage collection hook is called." msgstr "" +":term:`非同期ジェネレーター ` は明示的に閉じ" +"ることを推奨します。\n" +"例えば ``async for`` ループの本体で例外が起きるなどして、途中でジェネレーター" +"の使用を終えると、非同期の後始末処理が予期しないコンテキストで実行される可能" +"性があります。\n" +"依存するタスクが完了した後や、イベントループの終了中に非同期ジェネレーターの" +"ガベージコレクション用フックが呼び出されたときに、後始末が行われることがあり" +"ます。" -#: ../../library/asyncio-dev.rst:271 msgid "" "To avoid this, explicitly close the generator by calling its :meth:`~agen." "aclose` method, or use the :func:`contextlib.aclosing` context manager::" msgstr "" +"これを避けるには、:meth:`~agen.aclose` メソッドを呼び出して明示的にジェネレー" +"ターを閉じるか、:func:`contextlib.aclosing` コンテキストマネージャーを使って" +"ください。 ::" -#: ../../library/asyncio-dev.rst:275 msgid "" "import asyncio\n" "import contextlib\n" @@ -486,15 +542,29 @@ msgid "" "\n" "asyncio.run(func())" msgstr "" +"import asyncio\n" +"import contextlib\n" +"\n" +"async def gen():\n" +" yield 1\n" +" yield 2\n" +"\n" +"async def func():\n" +" async with contextlib.aclosing(gen()) as g:\n" +" async for x in g:\n" +" break # 最後までイテレーションしない\n" +"\n" +"asyncio.run(func())" -#: ../../library/asyncio-dev.rst:289 msgid "" "As noted above, the cleanup code for these asynchronous generators is " "deferred. The following example demonstrates that the finalization of an " "asynchronous generator can occur in an unexpected order::" msgstr "" +"前述のとおり、これらの非同期ジェネレーターの後始末処理は後回しにされます。\n" +"次の例は、非同期ジェネレーターの終了処理が予期しない順序で行われる場合を示し" +"ています。 ::" -#: ../../library/asyncio-dev.rst:293 msgid "" "import asyncio\n" "work_done = False\n" @@ -522,12 +592,35 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"work_done = False\n" +"\n" +"async def cursor():\n" +" try:\n" +" yield 1\n" +" finally:\n" +" assert work_done\n" +"\n" +"async def rows():\n" +" global work_done\n" +" try:\n" +" yield 2\n" +" finally:\n" +" await asyncio.sleep(0.1) # 非同期の処理を模倣する\n" +" work_done = True\n" +"\n" +"\n" +"async def main():\n" +" async for c in cursor():\n" +" async for r in rows():\n" +" break\n" +" break\n" +"\n" +"asyncio.run(main())" -#: ../../library/asyncio-dev.rst:319 msgid "For this example, we get the following output::" -msgstr "" +msgstr "この例の出力は次のようになります。 ::" -#: ../../library/asyncio-dev.rst:321 msgid "" "unhandled exception during asyncio.run() shutdown\n" "task: ()> exception=AssertionError()>\n" +"Traceback (most recent call last):\n" +" File \"example.py\", line 6, in cursor\n" +" yield 1\n" +"asyncio.exceptions.CancelledError\n" +"\n" +"During handling of the above exception, another exception occurred:\n" +"\n" +"Traceback (most recent call last):\n" +" File \"example.py\", line 8, in cursor\n" +" assert work_done\n" +" ^^^^^^^^^\n" +"AssertionError" -#: ../../library/asyncio-dev.rst:336 msgid "" "The ``cursor()`` asynchronous generator was finalized before the ``rows`` " "generator - an unexpected behavior." msgstr "" +"``cursor()`` 非同期ジェネレーターの終了処理が ``rows`` ジェネレーターより先に" +"行われています。\n" +"これは意図しない動作です。" -#: ../../library/asyncio-dev.rst:339 msgid "" "The example can be fixed by explicitly closing the ``cursor`` and ``rows`` " "async-generators::" msgstr "" +"この例は、``cursor`` と ``rows`` の非同期ジェネレーターを明示的に閉じることで" +"修正できます。 ::" -#: ../../library/asyncio-dev.rst:342 msgid "" "async def main():\n" " async with contextlib.aclosing(cursor()) as cursor_gen:\n" @@ -568,6 +678,13 @@ msgid "" " break\n" " break" msgstr "" +"async def main():\n" +" async with contextlib.aclosing(cursor()) as cursor_gen:\n" +" async for c in cursor_gen:\n" +" async with contextlib.aclosing(rows()) as rows_gen:\n" +" async for r in rows_gen:\n" +" break\n" +" break" #: ../../library/asyncio-dev.rst:352 msgid "Create asynchronous generators only when the event loop is running" @@ -579,27 +696,33 @@ msgid "" "generator iterator>` only after the event loop has been created." msgstr "" -#: ../../library/asyncio-dev.rst:358 msgid "" "To ensure that asynchronous generators close reliably, the event loop uses " "the :func:`sys.set_asyncgen_hooks` function to register callback functions. " "These callbacks update the list of running asynchronous generators to keep " "it in a consistent state." msgstr "" +"非同期ジェネレーターを確実に閉じるため、イベントループは :func:`sys." +"set_asyncgen_hooks` 関数でコールバック関数を登録します。\n" +"これらのコールバックは、実行中の非同期ジェネレーターの一覧を更新し、整合性を" +"保ちます。" -#: ../../library/asyncio-dev.rst:363 msgid "" "When the :meth:`loop.shutdown_asyncgens() ` " "function is called, the running generators are stopped gracefully and the " "list is cleared." msgstr "" +":meth:`loop.shutdown_asyncgens() ` 関数が呼" +"び出されると、実行中のジェネレーターの終了処理を行い、一覧を空にします。" -#: ../../library/asyncio-dev.rst:367 msgid "" "The asynchronous generator invokes the corresponding system hook during its " "first iteration. At the same time, the generator records that the hook has " "been called and does not call it again." msgstr "" +"非同期ジェネレーターは、最初のイテレーションで対応するシステムフックを呼び出" +"します。\n" +"同時に、フックを呼び出したことを記録し、以後は再び呼び出しません。" #: ../../library/asyncio-dev.rst:371 msgid "" @@ -614,7 +737,6 @@ msgstr "" msgid "Consider the following example::" msgstr "次に示す例について考えてみてください。::" -#: ../../library/asyncio-dev.rst:379 msgid "" "import asyncio\n" "\n" @@ -630,8 +752,20 @@ msgid "" " print(runner.run(anext(agen)))\n" " del agen" msgstr "" +"import asyncio\n" +"\n" +"async def agenfn():\n" +" try:\n" +" yield 10\n" +" finally:\n" +" await asyncio.sleep(0)\n" +"\n" +"\n" +"with asyncio.Runner() as runner:\n" +" agen = agenfn()\n" +" print(runner.run(anext(agen)))\n" +" del agen" -#: ../../library/asyncio-dev.rst:395 msgid "" "10\n" "Exception ignored while closing generator :\n" +"Traceback (most recent call last):\n" +" File \"example.py\", line 13, in \n" +" del agen\n" +" ^^^^\n" +"RuntimeError: async generator ignored GeneratorExit" -#: ../../library/asyncio-dev.rst:403 msgid "This example can be fixed as follows::" -msgstr "" +msgstr "この例は次のように修正できます。 ::" -#: ../../library/asyncio-dev.rst:405 msgid "" "import asyncio\n" "\n" @@ -664,10 +804,23 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def agenfn():\n" +" try:\n" +" yield 10\n" +" finally:\n" +" await asyncio.sleep(0)\n" +"\n" +"async def main():\n" +" agen = agenfn()\n" +" print(await anext(agen))\n" +" del agen\n" +"\n" +"asyncio.run(main())" -#: ../../library/asyncio-dev.rst:422 msgid "Avoid concurrent iteration and closure of the same generator" -msgstr "" +msgstr "同じジェネレーターのイテレーションとクローズを並行して行わない" #: ../../library/asyncio-dev.rst:424 msgid "" @@ -676,11 +829,9 @@ msgid "" "lead to an inconsistent state of the async generator and can cause errors." msgstr "" -#: ../../library/asyncio-dev.rst:429 msgid "Let's consider the following example::" -msgstr "" +msgstr "次の例を考えてみてください。 ::" -#: ../../library/asyncio-dev.rst:431 msgid "" "import asyncio\n" "\n" @@ -701,8 +852,25 @@ msgid "" "\n" "asyncio.run(amain())" msgstr "" +"import asyncio\n" +"\n" +"async def consumer():\n" +" for idx in range(100):\n" +" await asyncio.sleep(0)\n" +" message = yield idx\n" +" print('received', message)\n" +"\n" +"async def amain():\n" +" agenerator = consumer()\n" +" await agenerator.asend(None)\n" +"\n" +" fa = asyncio.create_task(agenerator.asend('A'))\n" +" fb = asyncio.create_task(agenerator.asend('B'))\n" +" await fa\n" +" await fb\n" +"\n" +"asyncio.run(amain())" -#: ../../library/asyncio-dev.rst:452 msgid "" "received A\n" "Traceback (most recent call last):\n" @@ -722,9 +890,27 @@ msgid "" " await fb\n" "RuntimeError: anext(): asynchronous generator is already running" msgstr "" +"received A\n" +"Traceback (most recent call last):\n" +" File \"test.py\", line 38, in \n" +" asyncio.run(amain())\n" +" ~~~~~~~~~~~^^^^^^^^^\n" +" File \"Lib/asyncio/runners.py\", line 204, in run\n" +" return runner.run(main)\n" +" ~~~~~~~~~~^^^^^^\n" +" File \"Lib/asyncio/runners.py\", line 127, in run\n" +" return self._loop.run_until_complete(task)\n" +" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n" +" File \"Lib/asyncio/base_events.py\", line 719, in run_until_complete\n" +" return future.result()\n" +" ~~~~~~~~~~~~~^^\n" +" File \"test.py\", line 36, in amain\n" +" await fb\n" +"RuntimeError: anext(): asynchronous generator is already running" -#: ../../library/asyncio-dev.rst:471 msgid "" "Therefore, it is recommended to avoid using asynchronous generators in " "parallel tasks or across multiple event loops." msgstr "" +"そのため、並行して動くタスクや複数のイベントループで非同期ジェネレーターを共" +"有して使うことは避けるよう推奨します。" diff --git a/library/asyncio-eventloop.po b/library/asyncio-eventloop.po index 5580bb684..d3236717d 100644 --- a/library/asyncio-eventloop.po +++ b/library/asyncio-eventloop.po @@ -17,23 +17,21 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-eventloop.rst:8 msgid "Event loop" -msgstr "" +msgstr "イベントループ" -#: ../../library/asyncio-eventloop.rst:10 msgid "" "**Source code:** :source:`Lib/asyncio/events.py`, :source:`Lib/asyncio/" "base_events.py`" msgstr "" -"**ソースコード:** :source:`Lib/asyncio/profile.py` と :source:`Lib/asyncio/" -"pstats.py`" +"**ソースコード:** :source:`Lib/asyncio/events.py`, :source:`Lib/asyncio/" +"base_events.py`" #: ../../library/asyncio-eventloop.rst:16 msgid "Preface" @@ -77,29 +75,29 @@ msgstr "以下の低水準関数はイベントループの取得、設定、生 msgid "Return the running event loop in the current OS thread." msgstr "現在の OS スレッドで実行中のイベントループを取得します。" -#: ../../library/asyncio-eventloop.rst:36 msgid "Raise a :exc:`RuntimeError` if there is no running event loop." -msgstr "" +msgstr "実行中のイベントループがなければ :exc:`RuntimeError` を送出します。" -#: ../../library/asyncio-eventloop.rst:38 msgid "This function can only be called from a coroutine or a callback." -msgstr "" +msgstr "この関数は、コルーチンまたはコールバックからのみ呼び出せます。" #: ../../library/asyncio-eventloop.rst:44 msgid "Get the current event loop." msgstr "現在のイベントループを取得します。" -#: ../../library/asyncio-eventloop.rst:46 msgid "" "When called from a coroutine or a callback (e.g. scheduled with call_soon or " "similar API), this function will always return the running event loop." msgstr "" +"コルーチンまたはコールバック (``call_soon()`` などの API でスケジュールしたも" +"の) から呼び出すと、常に実行中のイベントループを返します。" -#: ../../library/asyncio-eventloop.rst:50 msgid "" "If there is no running event loop set, the function will return the result " "of the ``get_event_loop_policy().get_event_loop()`` call." msgstr "" +"実行中のイベントループがなければ、``get_event_loop_policy()." +"get_event_loop()`` の呼び出し結果を返します。" #: ../../library/asyncio-eventloop.rst:53 msgid "" @@ -111,24 +109,28 @@ msgstr "" "なため、コルーチンやコールバックでは :func:`get_event_loop` よりも :func:" "`get_running_loop` を使うほうが好ましいと考えられます。" -#: ../../library/asyncio-eventloop.rst:58 msgid "" "As noted above, consider using the higher-level :func:`asyncio.run` " "function, instead of using these lower level functions to manually create " "and close an event loop." msgstr "" +"前述のとおり、これらの低水準関数でイベントループを手動で作成・クローズする代" +"わりに、より高水準な :func:`asyncio.run` の使用を検討してください。" -#: ../../library/asyncio-eventloop.rst:62 msgid "Raises a :exc:`RuntimeError` if there is no current event loop." msgstr "" +"現在のイベントループがなければ :exc:`RuntimeError` を送出するようになりまし" +"た。" -#: ../../library/asyncio-eventloop.rst:67 msgid "" "The :mod:`!asyncio` policy system is deprecated and will be removed in " "Python 3.16; from there on, this function will return the current running " "event loop if present else it will return the loop set by :func:" "`set_event_loop`." msgstr "" +":mod:`!asyncio` のポリシーシステムは非推奨で、Python 3.16 で削除されます。\n" +"それ以降、この関数は実行中のイベントループがあればそれを返し、なければ :func:" +"`set_event_loop` で設定したループを返します。" #: ../../library/asyncio-eventloop.rst:74 msgid "Set *loop* as the current event loop for the current OS thread." @@ -163,7 +165,6 @@ msgid "" msgstr "" "`イベントループのメソッド`_ 節は、イベントループ API のリファレンスです。" -#: ../../library/asyncio-eventloop.rst:92 msgid "" "The `Callback Handles`_ section documents the :class:`Handle` and :class:" "`TimerHandle` instances which are returned from scheduling methods such as :" @@ -171,7 +172,7 @@ msgid "" msgstr "" "`コールバックハンドル`_ 節は :meth:`loop.call_soon` や :meth:`loop." "call_later` などのスケジューリングメソッドが返す :class:`Handle` や :class:" -"`TimerHandle` インスタンスについて解説しています。 " +"`TimerHandle` インスタンスについて解説しています。" #: ../../library/asyncio-eventloop.rst:96 msgid "" @@ -194,9 +195,8 @@ msgid "" "The `Examples`_ section showcases how to work with some event loop APIs." msgstr "`使用例`_ 節ではイベントループ API の具体的な使い方を紹介しています。" -#: ../../library/asyncio-eventloop.rst:109 msgid "Event loop methods" -msgstr "" +msgstr "イベントループのメソッド" #: ../../library/asyncio-eventloop.rst:111 msgid "Event loops have **low-level** APIs for the following:" @@ -206,10 +206,8 @@ msgstr "イベントループは以下の **低水準な** API を持ってい msgid "Running and stopping the loop" msgstr "ループの開始と停止" -#: ../../library/asyncio-eventloop.rst:123 msgid "Run until the *future* (an instance of :class:`Future`) has completed." -msgstr "" -"*フューチャー* (:class:`Future` インスタンス) が完了するまで実行します。" +msgstr "*future* (:class:`Future` のインスタンス) が完了するまで実行します。" #: ../../library/asyncio-eventloop.rst:126 msgid "" @@ -321,7 +319,6 @@ msgstr ":func:`asyncio.run` を使った場合はこの関数を呼び出す必 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/asyncio-eventloop.rst:185 msgid "" "try:\n" " loop.run_forever()\n" @@ -329,34 +326,46 @@ msgid "" " loop.run_until_complete(loop.shutdown_asyncgens())\n" " loop.close()" msgstr "" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.run_until_complete(loop.shutdown_asyncgens())\n" +" loop.close()" -#: ../../library/asyncio-eventloop.rst:196 msgid "" "Schedule the closure of the default executor and wait for it to join all of " "the threads in the :class:`~concurrent.futures.ThreadPoolExecutor`. Once " "this method has been called, using the default executor with :meth:`loop." "run_in_executor` will raise a :exc:`RuntimeError`." msgstr "" +"デフォルトの Executor の終了をスケジュールし、:class:`~concurrent.futures." +"ThreadPoolExecutor` のすべてのスレッドの終了を待ちます。\n" +"このメソッドを呼び出した後で :meth:`loop.run_in_executor` によりデフォルトの " +"Executor を使うと、:exc:`RuntimeError` が送出されます。" -#: ../../library/asyncio-eventloop.rst:202 msgid "" "The *timeout* parameter specifies the amount of time (in :class:`float` " "seconds) the executor will be given to finish joining. With the default, " "``None``, the executor is allowed an unlimited amount of time." msgstr "" +"*timeout* は、Executor のスレッドの終了を待つ制限時間を秒単位の :class:" +"`float` で指定します。\n" +"デフォルトの ``None`` では、待ち時間に制限はありません。" -#: ../../library/asyncio-eventloop.rst:207 msgid "" "If the *timeout* is reached, a :exc:`RuntimeWarning` is emitted and the " "default executor is terminated without waiting for its threads to finish " "joining." msgstr "" +"*timeout* に達すると :exc:`RuntimeWarning` を出し、スレッドの終了を待たずにデ" +"フォルトの Executor の終了処理を行います。" -#: ../../library/asyncio-eventloop.rst:213 msgid "" "Do not call this method when using :func:`asyncio.run`, as the latter " "handles default executor shutdown automatically." msgstr "" +":func:`asyncio.run` はデフォルトの Executor の終了処理を自動的に行うため、こ" +"れを使う場合はこのメソッドを呼び出さないでください。" #: ../../library/asyncio-eventloop.rst:218 msgid "Added the *timeout* parameter." @@ -390,30 +399,38 @@ msgstr "" "コールバックは登録された順に呼び出されます。各コールバックは厳密に1回だけ呼び" "出されます。" -#: ../../library/asyncio-eventloop.rst:235 msgid "" "The optional keyword-only *context* argument specifies a custom :class:" "`contextvars.Context` for the *callback* to run in. Callbacks use the " "current context when no *context* is provided." msgstr "" +"省略可能なキーワード専用引数 *context* には、*callback* の実行に使う :class:" +"`contextvars.Context` を指定します。\n" +"*context* を指定しなければ、現在のコンテキストを使います。" -#: ../../library/asyncio-eventloop.rst:239 msgid "Unlike :meth:`call_soon_threadsafe`, this method is not thread-safe." msgstr "" +":meth:`call_soon_threadsafe` とは異なり、このメソッドはスレッドセーフではあり" +"ません。" -#: ../../library/asyncio-eventloop.rst:243 msgid "" "A thread-safe variant of :meth:`call_soon`. When scheduling callbacks from " "another thread, this function *must* be used, since :meth:`call_soon` is not " "thread-safe." msgstr "" +":meth:`call_soon` のスレッドセーフな版です。\n" +":meth:`call_soon` はスレッドセーフではないため、別のスレッドからコールバック" +"をスケジュールする場合は *必ず* この関数を使ってください。" -#: ../../library/asyncio-eventloop.rst:247 msgid "" "This function is safe to be called from a reentrant context or signal " "handler, however, it is not safe or fruitful to use the returned handle in " "such contexts." msgstr "" +"この関数は、再入可能なコンテキストやシグナルハンドラーから安全に呼び出せま" +"す。\n" +"ただし、そのようなコンテキストで返されたハンドルを使うことは、安全でも有用で" +"もありません。" #: ../../library/asyncio-eventloop.rst:250 msgid "" @@ -451,12 +468,14 @@ msgstr "" "をコールバックに渡すことを許していません。キーワード引数を渡すためには :func:" "`functools.partial` を使ってください:" -#: ../../library/asyncio-eventloop.rst:268 msgid "" "# will schedule \"print(\"Hello\", flush=True)\"\n" "loop.call_soon(\n" " functools.partial(print, \"Hello\", flush=True))" msgstr "" +"# print(\"Hello\", flush=True) をスケジュールする\n" +"loop.call_soon(\n" +" functools.partial(print, \"Hello\", flush=True))" #: ../../library/asyncio-eventloop.rst:272 msgid "" @@ -505,12 +524,14 @@ msgstr "" "*callback* は厳密に一度だけ呼び出されます。2つのコールバックが完全に同じ時間" "にスケジュールされた場合、呼び出しの順序は未定義です。" -#: ../../library/asyncio-eventloop.rst:299 msgid "" "The optional positional *args* will be passed to the callback when it is " "called. Use :func:`functools.partial` :ref:`to pass keyword arguments " "` to *callback*." msgstr "" +"省略可能な位置引数 *args* は、コールバックの呼び出し時に渡されます。\n" +"*callback* に :ref:`キーワード引数を渡す ` には、:" +"func:`functools.partial` を使ってください。" #: ../../library/asyncio-eventloop.rst:304 msgid "" @@ -522,12 +543,14 @@ msgstr "" "する際のコンテキスト :class:`contextvars.Context` を設定することができます。" "コンテキスト *context* が指定されない場合は現在のコンテキストが使われます。" -#: ../../library/asyncio-eventloop.rst:310 msgid "" "For performance, callbacks scheduled with :meth:`loop.call_later` may run up " "to one clock-resolution early (see ``time.get_clock_info('monotonic')." "resolution``)." msgstr "" +"性能上の理由から、:meth:`loop.call_later` でスケジュールしたコールバックは、" +"時計の分解能の 1 単位分だけ早く実行される可能性があります (``time." +"get_clock_info('monotonic').resolution`` を参照)。" #: ../../library/asyncio-eventloop.rst:318 msgid "" @@ -550,12 +573,14 @@ msgstr "" msgid "This method's behavior is the same as :meth:`call_later`." msgstr "このメソッドの振る舞いは :meth:`call_later` と同じです。" -#: ../../library/asyncio-eventloop.rst:336 msgid "" "For performance, callbacks scheduled with :meth:`loop.call_at` may run up to " "one clock-resolution early (see ``time.get_clock_info('monotonic')." "resolution``)." msgstr "" +"性能上の理由から、:meth:`loop.call_at` でスケジュールしたコールバックは、時計" +"の分解能の 1 単位分だけ早く実行される可能性があります (``time." +"get_clock_info('monotonic').resolution`` を参照)。" #: ../../library/asyncio-eventloop.rst:344 msgid "" @@ -588,16 +613,14 @@ msgstr "" msgid "The :func:`asyncio.sleep` function." msgstr "関数 :func:`asyncio.sleep`。" -#: ../../library/asyncio-eventloop.rst:365 msgid "Creating futures and tasks" -msgstr "" +msgstr "Future とタスクの作成" #: ../../library/asyncio-eventloop.rst:369 msgid "Create an :class:`asyncio.Future` object attached to the event loop." msgstr "" "イベントループに接続した :class:`asyncio.Future` オブジェクトを生成します。" -#: ../../library/asyncio-eventloop.rst:371 msgid "" "This is the preferred way to create Futures in asyncio. This lets third-" "party event loops provide alternative implementations of the Future object " @@ -605,7 +628,7 @@ msgid "" msgstr "" "asyncio でフューチャーオブジェクトを作成するために推奨される方法です。このメ" "ソッドにより、サードパーティ製のイベントループがFutures クラスの(パフォーマン" -"スや計測方法が優れた) 代替実装を提供することを可能にします。 " +"スや計測方法が優れた) 代替実装を提供することを可能にします。" #: ../../library/asyncio-eventloop.rst:379 msgid "" @@ -624,12 +647,15 @@ msgstr "" "サードパーティのイベントループは相互運用のための自身の :class:`Task` のサブク" "ラスを使用できます。この場合、結果は :class:`Task` のサブクラスになります。" -#: ../../library/asyncio-eventloop.rst:386 msgid "" "The full function signature is largely the same as that of the :class:`Task` " "constructor (or factory) - all of the keyword arguments to this function are " "passed through to that interface." msgstr "" +"関数のシグネチャ全体は :class:`Task` のコンストラクター (またはファクトリー) " +"とほぼ同じです。\n" +"この関数に渡したキーワード引数はすべて、そのコンストラクターやファクトリーに" +"渡されます。" #: ../../library/asyncio-eventloop.rst:390 msgid "" @@ -649,13 +675,17 @@ msgstr "" "の :class:`contextvars.Context` を指定できます。*context* が省略された場合、" "現在のコンテキストのコピーが作成されます。" -#: ../../library/asyncio-eventloop.rst:397 msgid "" "An optional keyword-only *eager_start* argument allows specifying if the " "task should execute eagerly during the call to create_task, or be scheduled " "later. If *eager_start* is not passed the mode set by :meth:`loop." "set_task_factory` will be used." msgstr "" +"省略可能なキーワード専用引数 *eager_start* では、``create_task()`` の呼び出し" +"中にタスクの実行を即座に開始するか、後で実行するようにスケジュールするかを指" +"定できます。\n" +"*eager_start* を渡さない場合は :meth:`loop.set_task_factory` で設定したモード" +"を使います。" #: ../../library/asyncio-eventloop.rst:402 msgid "Added the *name* parameter." @@ -665,30 +695,34 @@ msgstr "*name* パラメータを追加しました。" msgid "Added the *context* parameter." msgstr "*context* パラメータを追加しました。" -#: ../../library/asyncio-eventloop.rst:408 msgid "" "Added ``kwargs`` which passes on arbitrary extra parameters, including " "``name`` and ``context``." msgstr "" +"``name`` と ``context`` を含む任意の追加パラメーターを渡す ``kwargs`` が追加" +"されました。" -#: ../../library/asyncio-eventloop.rst:411 msgid "" "Rolled back the change that passes on *name* and *context* (if it is None), " "while still passing on other arbitrary keyword arguments (to avoid breaking " "backwards compatibility with 3.13.3)." msgstr "" +"*name* と、値が ``None`` の場合の *context* を渡す変更を取り消しました。\n" +"それ以外の任意のキーワード引数は、3.13.3 との後方互換性を保つため、引き続き渡" +"されます。" -#: ../../library/asyncio-eventloop.rst:415 msgid "" "All *kwargs* are now passed on. The *eager_start* parameter works with eager " "task factories." msgstr "" +"すべての *kwargs* を渡すようになりました。\n" +"*eager_start* パラメーターは、タスクを即座に実行するファクトリーで機能しま" +"す。" #: ../../library/asyncio-eventloop.rst:420 msgid "Set a task factory that will be used by :meth:`loop.create_task`." msgstr ":meth:`loop.create_task` が使用するタスクファクトリーを設定します。" -#: ../../library/asyncio-eventloop.rst:423 msgid "" "If *factory* is ``None`` the default task factory will be set. Otherwise, " "*factory* must be a *callable* with the signature matching ``(loop, coro, " @@ -696,22 +730,32 @@ msgid "" "*coro* is a coroutine object. The callable must pass on all *kwargs*, and " "return a :class:`asyncio.Task`-compatible object." msgstr "" +"*factory* が ``None`` の場合は、デフォルトのタスクファクトリーを設定しま" +"す。\n" +"それ以外の場合、*factory* はシグネチャが ``(loop, coro, **kwargs)`` に対応す" +"る *呼び出し可能オブジェクト* でなければなりません。\n" +"ここで *loop* は使用するイベントループへの参照、*coro* はコルーチンオブジェク" +"トです。\n" +"この呼び出し可能オブジェクトは、すべての *kwargs* を呼び出し先に渡し、:class:" +"`asyncio.Task` と互換性のあるオブジェクトを返す必要があります。" -#: ../../library/asyncio-eventloop.rst:429 msgid "Required that all *kwargs* are passed on to :class:`asyncio.Task`." msgstr "" +"すべての *kwargs* を :class:`asyncio.Task` に渡すことが必須になりました。" -#: ../../library/asyncio-eventloop.rst:432 msgid "" "*name* is no longer passed to task factories. *context* is no longer passed " "to task factories if it is ``None``." msgstr "" +"*name* をタスクファクトリーに渡さなくなりました。\n" +"*context* も、値が ``None`` の場合は渡さなくなりました。" -#: ../../library/asyncio-eventloop.rst:436 msgid "" "*name* and *context* are now unconditionally passed on to task factories " "again." msgstr "" +"*name* と *context* を、再び無条件にタスクファクトリーに渡すようになりまし" +"た。" #: ../../library/asyncio-eventloop.rst:441 msgid "Return a task factory or ``None`` if the default one is in use." @@ -841,17 +885,16 @@ msgstr "" "致確認は行われません (これは深刻なセキュリティリスクであり、中間者攻撃を受け" "る可能性があります)。" -#: ../../library/asyncio-eventloop.rst:506 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to getaddrinfo() for *host* resolution. If given, " "these should all be integers from the corresponding :mod:`socket` module " "constants." msgstr "" -"*family*, *proto*, *flags* は任意のアドレスファミリであり、*host* 解決のため" -"の getaddrinfo() 経由で渡されるプロトコルおよびフラグになります。このオプショ" -"ンが与えられた場合、これらはすべて :mod:`socket` モジュール定数に従った整数で" -"なければなりません。" +"*family*、*proto*、*flags* は省略可能な引数で、それぞれアドレスファミリー、プ" +"ロトコル、フラグを指定します。\n" +"*host* の名前解決のために ``getaddrinfo()`` に渡されます。\n" +"指定する場合は、:mod:`socket` モジュールの対応する整数定数を使ってください。" #: ../../library/asyncio-eventloop.rst:511 msgid "" @@ -899,14 +942,14 @@ msgstr "" "*port*、 *family*、 *proto*、 *flags*、 *happy_eyeballs_delay*、 " "*interleave* および *local_addr* のいずれも指定してはいけません。" -#: ../../library/asyncio-eventloop.rst:536 -#: ../../library/asyncio-eventloop.rst:662 -#: ../../library/asyncio-eventloop.rst:910 msgid "" "The *sock* argument transfers ownership of the socket to the transport " "created. To close the socket, call the transport's :meth:`~asyncio." "BaseTransport.close` method." msgstr "" +"*sock* 引数を渡すと、ソケットの所有権は作成されたトランスポートに移ります。\n" +"ソケットを閉じるには、トランスポートの :meth:`~asyncio.BaseTransport.close` " +"メソッドを呼び出してください。" #: ../../library/asyncio-eventloop.rst:540 msgid "" @@ -930,17 +973,15 @@ msgstr "" "の) 待ち時間を秒単位で指定します。指定した待ち時間を超えると接続は中断しま" "す。 ``None`` が与えられた場合はデフォルト値 ``60.0`` が使われます。" -#: ../../library/asyncio-eventloop.rst:548 -#: ../../library/asyncio-eventloop.rst:817 -#: ../../library/asyncio-eventloop.rst:921 -#: ../../library/asyncio-eventloop.rst:1010 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" +"*ssl_shutdown_timeout* は、接続を中断する前に SSL の終了処理を待つ時間を秒単" +"位で指定します。\n" +"``None`` (デフォルト) の場合は ``30.0`` 秒です。" -#: ../../library/asyncio-eventloop.rst:552 msgid "" "*all_errors* determines what exceptions are raised when a connection cannot " "be created. By default, only a single ``Exception`` is raised: the first " @@ -949,6 +990,12 @@ msgid "" "``True``, an ``ExceptionGroup`` will be raised containing all exceptions " "(even if there is only one)." msgstr "" +"*all_errors* は、接続を確立できなかった場合に送出する例外を指定します。\n" +"デフォルトでは ``Exception`` を一つだけ送出します。\n" +"例外が一つだけの場合や、すべてのエラーメッセージが同じ場合は最初の例外、それ" +"以外の場合はエラーメッセージをまとめた一つの ``OSError`` です。\n" +"``all_errors`` が ``True`` の場合、すべての例外を含む ``ExceptionGroup`` を送" +"出します (例外が一つだけでも同じです)。" #: ../../library/asyncio-eventloop.rst:562 #: ../../library/asyncio-eventloop.rst:829 @@ -973,7 +1020,6 @@ msgstr "*ssl_handshake_timeout* 引数が追加されました。" msgid "Added the *happy_eyeballs_delay* and *interleave* parameters." msgstr "*happy_eyeballs_delay* と *interleave* が追加されました。" -#: ../../library/asyncio-eventloop.rst:577 msgid "" "Happy Eyeballs Algorithm: Success with Dual-Stack Hosts. When a server's " "IPv4 path and protocol are working, but the server's IPv6 path and protocol " @@ -983,6 +1029,15 @@ msgid "" "This document specifies requirements for algorithms that reduce this user-" "visible delay and provides an algorithm." msgstr "" +"Happy Eyeballs アルゴリズム: デュアルスタックホストでの接続を成功させる方" +"法。\n" +"サーバーへの IPv4 の経路とプロトコルが機能していても、IPv6 の経路とプロトコル" +"が機能していないと、デュアルスタックのクライアントアプリケーションでは、IPv4 " +"専用のクライアントに比べて接続が大幅に遅れることがあります。\n" +"デュアルスタックのクライアントで利用者の使い勝手が悪くなるため、これは望まし" +"くありません。\n" +"この文書は、利用者に見えるこの遅延を減らすアルゴリズムの要件を定め、一つのア" +"ルゴリズムを示します。" #: ../../library/asyncio-eventloop.rst:586 msgid "For more information: https://datatracker.ietf.org/doc/html/rfc6555" @@ -1002,11 +1057,12 @@ msgstr "*ssl_shutdown_timeout* パラメータが追加されました。" msgid "*all_errors* was added." msgstr "*all_errors* が追加されました" -#: ../../library/asyncio-eventloop.rst:595 msgid "" "Raises a ``ValueError`` if ``ssl.check_hostname`` is ``True`` and " "``server_hostname`` is not supplied." msgstr "" +"``ssl.check_hostname`` が ``True`` で、``server_hostname`` が指定されていない" +"場合に ``ValueError`` を送出するようになりました。" #: ../../library/asyncio-eventloop.rst:601 msgid "" @@ -1061,33 +1117,32 @@ msgstr "" "``(local_host, local_port)`` のタプルを指定します。 *local_host* と " "*local_port* は :meth:`getaddrinfo` メソッドを使用して検索されます。" -#: ../../library/asyncio-eventloop.rst:633 msgid "" "On Windows, when using the proactor event loop with ``local_addr=None``, an :" "exc:`OSError` with :attr:`!errno.WSAEINVAL` will be raised when running it." msgstr "" +"Windows で Proactor イベントループを使い、``local_addr=None`` として実行する" +"と、:attr:`!errno.WSAEINVAL` の :exc:`OSError` が送出されます。" -#: ../../library/asyncio-eventloop.rst:637 msgid "" "*remote_addr*, if given, is a ``(remote_host, remote_port)`` tuple used to " "connect the socket to a remote address. The *remote_host* and *remote_port* " "are looked up using :meth:`getaddrinfo`." msgstr "" -"*remote_addr* が指定される場合、``(remote_host, remote_por)`` のタプルで、ソ" -"ケットをリモートアドレスに束縛するために使用されます。*remote_host* と " -"*remote_port* は :meth:`getaddrinfo` を使用して検索されます。" +"*remote_addr* を指定する場合は、ソケットをリモートアドレスに接続するための " +"``(remote_host, remote_port)`` タプルを渡します。\n" +"*remote_host* と *remote_port* は :meth:`getaddrinfo` を使って検索されます。" -#: ../../library/asyncio-eventloop.rst:641 msgid "" "*family*, *proto*, *flags* are the optional address family, protocol and " "flags to be passed through to :meth:`getaddrinfo` for *host* resolution. If " "given, these should all be integers from the corresponding :mod:`socket` " "module constants." msgstr "" -"*family*, *proto*, *flags* は任意のアドレスファミリです。これらのファミリ、プ" -"ロトコル、フラグは、*host* 解決のため :meth:`getaddrinfo` 経由でオプションで" -"渡されます。これらのオプションを指定する場合、すべて :mod:`socket` モジュール" -"定数に従った整数でなければなりません。" +"*family*、*proto*、*flags* は省略可能な引数で、それぞれアドレスファミリー、プ" +"ロトコル、フラグを指定します。\n" +"*host* の名前解決のために :meth:`getaddrinfo` に渡されます。\n" +"指定する場合は、:mod:`socket` モジュールの対応する整数定数を使ってください。" #: ../../library/asyncio-eventloop.rst:646 msgid "" @@ -1178,11 +1233,12 @@ msgstr "" "SO_REUSEPORT ` を使っており、複数のプロセスが異なる " "UID で同一のソケットに対して割り当てられるのを明確に禁止します。" -#: ../../library/asyncio-eventloop.rst:693 msgid "" "The *reuse_address* parameter, disabled since Python 3.8.1, 3.7.6 and " "3.6.10, has been entirely removed." msgstr "" +"Python 3.8.1、3.7.6、3.6.10 以降で無効になっていた *reuse_address* パラメー" +"ターが、完全に削除されました。" #: ../../library/asyncio-eventloop.rst:703 msgid "Create a Unix connection." @@ -1214,29 +1270,26 @@ msgstr "" "このメソッドの引数についての詳細は :meth:`loop.create_connection` メソッドの" "ドキュメントを参照してください。" -#: ../../library/asyncio-eventloop.rst:718 -#: ../../library/asyncio-eventloop.rst:874 -#: ../../library/asyncio-eventloop.rst:1380 -#: ../../library/asyncio-eventloop.rst:1939 -#: ../../library/asyncio-eventloop.rst:1946 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/asyncio-eventloop.rst:720 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`." msgstr "" +"*ssl_handshake_timeout* パラメーターが追加されました。\n" +"*path* パラメーターに :term:`path-like object` を指定できるようになりました。" #: ../../library/asyncio-eventloop.rst:730 msgid "Creating network servers" msgstr "ネットワークサーバの生成" -#: ../../library/asyncio-eventloop.rst:746 msgid "" "Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening on " "*port* of the *host* address." msgstr "" +"アドレス *host* のポート *port* で接続を待ち受ける TCP サーバー (ソケットタイ" +"プ :const:`~socket.SOCK_STREAM`) を作成します。" #: ../../library/asyncio-eventloop.rst:749 msgid "Returns a :class:`Server` object." @@ -1279,20 +1332,27 @@ msgstr "" "*host* が空の文字列か ``None`` の場合、すべてのインターフェースが想定され、複" "合的なソケットのリスト (通常は一つが IPv4、もう一つが IPv6) が返されます。" -#: ../../library/asyncio-eventloop.rst:769 msgid "" "The *port* parameter can be set to specify which port the server should " "listen on. If ``0`` or ``None`` (the default), a random unused port will be " "selected (note that if *host* resolves to multiple network interfaces, a " "different random port will be selected for each interface)." msgstr "" +"*port* パラメーターには、サーバーが待ち受けるポートを指定できます。\n" +"``0`` または ``None`` (デフォルト) の場合、未使用のポートがランダムに選ばれま" +"す。\n" +"*host* が複数のネットワークインターフェースに解決される場合は、インターフェー" +"スごとに異なるランダムなポートが選ばれることに注意してください。" -#: ../../library/asyncio-eventloop.rst:774 msgid "" "*family* can be set to either :const:`socket.AF_INET` or :const:`~socket." "AF_INET6` to force the socket to use IPv4 or IPv6. If not set, the *family* " "will be determined from host name (defaults to :const:`~socket.AF_UNSPEC`)." msgstr "" +"*family* に :const:`socket.AF_INET` または :const:`~socket.AF_INET6` を指定す" +"ると、ソケットでそれぞれ IPv4 または IPv6 を使うよう強制できます。\n" +"指定しなければホスト名から決まり、デフォルト値は :const:`~socket.AF_UNSPEC` " +"です。" #: ../../library/asyncio-eventloop.rst:779 msgid "*flags* is a bitmask for :meth:`getaddrinfo`." @@ -1307,11 +1367,13 @@ msgstr "" "*sock* にソケットオブジェクトを設定することができます。指定した場合、 *host* " "と *port* を指定してはいけません。" -#: ../../library/asyncio-eventloop.rst:786 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." msgstr "" +"*sock* 引数を渡すと、ソケットの所有権は作成されたサーバーに移ります。\n" +"ソケットを閉じるには、サーバーの :meth:`~asyncio.Server.close` メソッドを呼び" +"出してください。" #: ../../library/asyncio-eventloop.rst:790 msgid "" @@ -1352,15 +1414,15 @@ msgstr "" "SO_REUSEPORT を使用します)。このオプションは、Windows ではサポートされていま" "せん。" -#: ../../library/asyncio-eventloop.rst:806 msgid "" "*keep_alive* set to ``True`` keeps connections active by enabling the " "periodic transmission of messages." msgstr "" +"*keep_alive* を ``True`` にすると、定期的なメッセージ送信を有効にして接続を維" +"持します。" -#: ../../library/asyncio-eventloop.rst:811 msgid "Added the *keep_alive* parameter." -msgstr "" +msgstr "*keep_alive* パラメーターが追加されました。" #: ../../library/asyncio-eventloop.rst:813 msgid "" @@ -1388,12 +1450,14 @@ msgstr "" msgid "The *host* parameter can be a sequence of strings." msgstr "*host* パラメータに文字列のシーケンスを指定できるようになりました。" -#: ../../library/asyncio-eventloop.rst:837 msgid "" "Added *ssl_handshake_timeout* and *start_serving* parameters. The socket " "option :ref:`socket.TCP_NODELAY ` is set by default " "for all TCP connections." msgstr "" +"*ssl_handshake_timeout* と *start_serving* パラメーターが追加されました。\n" +"すべての TCP 接続で、デフォルトでソケットオプション :ref:`socket.TCP_NODELAY " +"` を設定するようになりました。" #: ../../library/asyncio-eventloop.rst:847 msgid "" @@ -1405,11 +1469,12 @@ msgstr "" "`StreamReader` と :class:`StreamWriter` のペアを返し、async/await コードから" "使うことができます。" -#: ../../library/asyncio-eventloop.rst:859 msgid "" "Similar to :meth:`loop.create_server` but works with the :py:const:`~socket." "AF_UNIX` socket family." msgstr "" +":meth:`loop.create_server` と似ていますが、ソケットファミリー :py:const:" +"`~socket.AF_UNIX` を使います。" #: ../../library/asyncio-eventloop.rst:862 msgid "" @@ -1421,12 +1486,14 @@ msgstr "" "須です。 抽象 Unix ソケット、 :class:`str`、 :class:`bytes`、 and :class:" "`~pathlib.Path` 形式でのパスがサポートされています。" -#: ../../library/asyncio-eventloop.rst:867 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " "been replaced after the server has been created." msgstr "" +"*cleanup_socket* が真の場合、サーバーを閉じると Unix ソケットをファイルシステ" +"ムから自動的に削除します。\n" +"ただし、サーバーを作成した後にソケットが置き換えられていれば削除しません。" #: ../../library/asyncio-eventloop.rst:871 msgid "" @@ -1436,15 +1503,16 @@ msgstr "" "このメソッドの引数についての詳細は :meth:`loop.create_server` メソッドのド" "キュメントを参照してください。" -#: ../../library/asyncio-eventloop.rst:878 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :class:`~pathlib.Path` object." msgstr "" +"*ssl_handshake_timeout* と *start_serving* パラメーターが追加されました。\n" +"*path* パラメーターに :class:`~pathlib.Path` オブジェクトを指定できるようにな" +"りました。" -#: ../../library/asyncio-eventloop.rst:887 msgid "Added the *cleanup_socket* parameter." -msgstr "" +msgstr "*cleanup_socket* パラメーターが追加されました。" #: ../../library/asyncio-eventloop.rst:895 msgid "Wrap an already accepted connection into a transport/protocol pair." @@ -1550,34 +1618,41 @@ msgstr "" "システムが *sendfile* システムコールをサポートしておらず、かつ *fallback* が " "``False`` の場合、 :exc:`SendfileNotAvailableError` 例外を送出します。" -#: ../../library/asyncio-eventloop.rst:970 msgid "TLS upgrade" -msgstr "" +msgstr "TLS へのアップグレード" #: ../../library/asyncio-eventloop.rst:978 msgid "Upgrade an existing transport-based connection to TLS." msgstr "既存のトランスポートベースの接続を TLS にアップグレードします。" -#: ../../library/asyncio-eventloop.rst:980 msgid "" "Create a TLS coder/decoder instance and insert it between the *transport* " "and the *protocol*. The coder/decoder implements both *transport*-facing " "protocol and *protocol*-facing transport." msgstr "" +"TLS のエンコード・デコードを行うインスタンスを作成し、*transport* と " +"*protocol* の間に挿入します。\n" +"このインスタンスは、*transport* に対するプロトコルと、*protocol* に対するトラ" +"ンスポートの両方のインターフェースを実装します。" -#: ../../library/asyncio-eventloop.rst:984 msgid "" "Return the created two-interface instance. After *await*, the *protocol* " "must stop using the original *transport* and communicate with the returned " "object only because the coder caches *protocol*-side data and sporadically " "exchanges extra TLS session packets with *transport*." msgstr "" +"作成した、二つのインターフェースを持つインスタンスを返します。\n" +"*await* の後、*protocol* は元の *transport* の使用をやめ、返されたオブジェク" +"トだけを使って通信する必要があります。\n" +"エンコーダーが *protocol* 側のデータをキャッシュし、必要に応じて追加の TLS " +"セッションパケットを *transport* と交換するためです。" -#: ../../library/asyncio-eventloop.rst:989 msgid "" "In some situations (e.g. when the passed transport is already closing) this " "may return ``None``." msgstr "" +"渡されたトランスポートがすでに終了処理中である場合など、状況によっては " +"``None`` を返すことがあります。" #: ../../library/asyncio-eventloop.rst:994 msgid "" @@ -1619,25 +1694,27 @@ msgstr "" "ファイル記述子 *fd* に対する読み込みが可能かどうかの監視を開始し、 *fd* が読" "み込み可能になると、指定した引数でコールバック *callback* を呼び出します。" -#: ../../library/asyncio-eventloop.rst:1031 -#: ../../library/asyncio-eventloop.rst:1045 msgid "" "Any preexisting callback registered for *fd* is cancelled and replaced by " "*callback*." msgstr "" +"*fd* にすでに登録されているコールバックがあれば、キャンセルして *callback* に" +"置き換えます。" -#: ../../library/asyncio-eventloop.rst:1036 msgid "" "Stop monitoring the *fd* file descriptor for read availability. Returns " "``True`` if *fd* was previously being monitored for reads." msgstr "" +"ファイル記述子 *fd* が読み込み可能になるのを監視する処理を停止します。\n" +"それまで *fd* の読み込みを監視していた場合は ``True`` を返します。" -#: ../../library/asyncio-eventloop.rst:1041 msgid "" "Start monitoring the *fd* file descriptor for write availability and invoke " "*callback* with the specified arguments *args* once *fd* is available for " "writing." msgstr "" +"ファイル記述子 *fd* が書き込み可能になるのを監視し始めます。\n" +"書き込み可能になると、指定した引数 *args* で *callback* を呼び出します。" #: ../../library/asyncio-eventloop.rst:1048 #: ../../library/asyncio-eventloop.rst:1367 @@ -1648,11 +1725,12 @@ msgstr "" "コールバック *callback* に :ref:`キーワード引数を渡す ` 場合は :func:`functools.partial` を使ってください。" -#: ../../library/asyncio-eventloop.rst:1053 msgid "" "Stop monitoring the *fd* file descriptor for write availability. Returns " "``True`` if *fd* was previously being monitored for writes." msgstr "" +"ファイル記述子 *fd* が書き込み可能になるのを監視する処理を停止します。\n" +"それまで *fd* の書き込みを監視していた場合は ``True`` を返します。" #: ../../library/asyncio-eventloop.rst:1056 msgid "" @@ -1704,15 +1782,15 @@ msgstr "受信したデータをバイトオブジェクトとして返します msgid "*sock* must be a non-blocking socket." msgstr "*sock* はノンブロッキングソケットでなければなりません。" -#: ../../library/asyncio-eventloop.rst:1080 msgid "" "Even though this method was always documented as a coroutine method, " "releases before Python 3.7 returned a :class:`Future`. Since Python 3.7 this " "is an ``async def`` method." msgstr "" "このメソッドは常にコルーチンメソッドとしてドキュメントに記載されてきました" -"が、 Python 3.7 以前のリリースでは :class:`Future` オブジェクトを返していまし" -"た。 Python 3.7 からは ``async def`` メソッドになりました。" +"が、 Python 3.7 より前のリリースでは :class:`Future` オブジェクトを返していま" +"した。\n" +"Python 3.7 からは ``async def`` メソッドになりました。" #: ../../library/asyncio-eventloop.rst:1088 msgid "" @@ -1727,25 +1805,25 @@ msgstr "" msgid "Return the number of bytes written to the buffer." msgstr "バッファに書き込んだデータのバイト数を返します。" -#: ../../library/asyncio-eventloop.rst:1100 msgid "" "Receive a datagram of up to *bufsize* from *sock*. Asynchronous version of :" "meth:`socket.recvfrom() `." msgstr "" +"*sock* から最大 *bufsize* バイトのデータグラムを受信します。\n" +":meth:`socket.recvfrom() ` の非同期版です。" -#: ../../library/asyncio-eventloop.rst:1103 msgid "Return a tuple of (received data, remote address)." -msgstr "" +msgstr "(受信したデータ, 送信元アドレス) のタプルを返します。" -#: ../../library/asyncio-eventloop.rst:1112 msgid "" "Receive a datagram of up to *nbytes* from *sock* into *buf*. Asynchronous " "version of :meth:`socket.recvfrom_into() `." msgstr "" +"*sock* から最大 *nbytes* バイトのデータグラムを受信し、*buf* に格納します。\n" +":meth:`socket.recvfrom_into() ` の非同期版です。" -#: ../../library/asyncio-eventloop.rst:1116 msgid "Return a tuple of (number of bytes received, remote address)." -msgstr "" +msgstr "(受信したバイト数, 送信元アドレス) のタプルを返します。" #: ../../library/asyncio-eventloop.rst:1125 msgid "" @@ -1768,26 +1846,25 @@ msgstr "" "場合は例外が送出されます。エラーとなった場合、接続の受信側で正しく処理された" "データの総量を特定する方法はありません。" -#: ../../library/asyncio-eventloop.rst:1136 -#: ../../library/asyncio-eventloop.rst:1199 msgid "" "Even though the method was always documented as a coroutine method, before " "Python 3.7 it returned a :class:`Future`. Since Python 3.7, this is an " "``async def`` method." msgstr "" "このメソッドは常にコルーチンメソッドとしてドキュメントに記載されてきました" -"が、 Python 3.7 以前のリリースでは :class:`Future` オブジェクトを返していまし" -"た。 Python 3.7 からは ``async def`` メソッドになりました。" +"が、 Python 3.7 より前のリリースでは :class:`Future` オブジェクトを返していま" +"した。\n" +"Python 3.7 からは ``async def`` メソッドになりました。" -#: ../../library/asyncio-eventloop.rst:1144 msgid "" "Send a datagram from *sock* to *address*. Asynchronous version of :meth:" "`socket.sendto() `." msgstr "" +"*sock* から *address* にデータグラムを送信します。\n" +":meth:`socket.sendto() ` の非同期版です。" -#: ../../library/asyncio-eventloop.rst:1148 msgid "Return the number of bytes sent." -msgstr "" +msgstr "送信したバイト数を返します。" #: ../../library/asyncio-eventloop.rst:1157 msgid "Connect *sock* to a remote socket at *address*." @@ -1798,7 +1875,6 @@ msgid "" "Asynchronous version of :meth:`socket.connect() `." msgstr ":meth:`socket.connect() ` の非同期版です。" -#: ../../library/asyncio-eventloop.rst:1163 msgid "" "With :class:`SelectorEventLoop`, *address* does not need to be resolved: " "for :const:`~socket.AF_INET` and :const:`~socket.AF_INET6` sockets, " @@ -1806,8 +1882,12 @@ msgid "" "calling :func:`socket.inet_pton`, and uses :meth:`loop.getaddrinfo` to " "resolve it if it is not." msgstr "" +":class:`SelectorEventLoop` では、*address* を事前に名前解決する必要はありませ" +"ん。\n" +":const:`~socket.AF_INET` と :const:`~socket.AF_INET6` のソケットでは、" +"``sock_connect`` はまず :func:`socket.inet_pton` で *address* が解決済みかど" +"うかを確認し、未解決なら :meth:`loop.getaddrinfo` で解決します。" -#: ../../library/asyncio-eventloop.rst:1169 msgid "" ":class:`ProactorEventLoop`, the default event loop on Windows, does not " "resolve *address*. The host must already be a numeric IP address; passing a " @@ -1815,11 +1895,18 @@ msgid "" "getaddrinfo` first, or use :meth:`loop.create_connection`, which resolves " "the address on every platform." msgstr "" +"Windows のデフォルトである :class:`ProactorEventLoop` は、*address* の名前解" +"決を行いません。\n" +"ホストは数値の IP アドレスでなければならず、ホスト名を渡すと :exc:`OSError` " +"を送出します。\n" +"先に :meth:`loop.getaddrinfo` でアドレスを解決するか、すべてのプラットフォー" +"ムで名前解決を行う :meth:`loop.create_connection` を使ってください。" -#: ../../library/asyncio-eventloop.rst:1175 msgid "" "With :class:`SelectorEventLoop`, ``address`` no longer needs to be resolved." msgstr "" +":class:`SelectorEventLoop` では、``address`` を事前に名前解決する必要がなくな" +"りました。" #: ../../library/asyncio-eventloop.rst:1181 msgid "" @@ -1912,7 +1999,6 @@ msgstr ":meth:`socket.getaddrinfo` の非同期版です。" msgid "Asynchronous version of :meth:`socket.getnameinfo`." msgstr ":meth:`socket.getnameinfo` の非同期版です。" -#: ../../library/asyncio-eventloop.rst:1256 msgid "" "Both *getaddrinfo* and *getnameinfo* internally utilize their synchronous " "versions through the loop's default thread pool executor. When this executor " @@ -1921,8 +2007,13 @@ msgid "" "consider using a custom executor for other user tasks, or setting a default " "executor with a larger number of workers." msgstr "" +"*getaddrinfo* と *getnameinfo* は、内部ではループのデフォルトのスレッドプー" +"ル Executor を通じて同期版を呼び出します。\n" +"この Executor に空きがなくなると処理が遅れ、高水準のネットワークライブラリで" +"タイムアウトが増えることがあります。\n" +"これを軽減するには、他のユーザー処理に別の Executor を使うか、ワーカー数の多" +"い Executor をデフォルトに設定することを検討してください。" -#: ../../library/asyncio-eventloop.rst:1263 msgid "" "Both *getaddrinfo* and *getnameinfo* methods were always documented to " "return a coroutine, but prior to Python 3.7 they were, in fact, returning :" @@ -1930,24 +2021,24 @@ msgid "" "coroutines." msgstr "" "*getaddrinfo* と *getnameinfo* の2つのメソッドは、いずれも常にコルーチンメ" -"ソッドとしてドキュメントに記載されてきましたが、 Python 3.7 以前のリリースで" -"は、実際には :class:`asyncio.Future` オブジェクトを返していました。 Python " -"3.7 からはどちらのメソッドもコルーチンになりました。" +"ソッドとしてドキュメントに記載されてきましたが、 Python 3.7 より前のリリース" +"では、実際には :class:`asyncio.Future` オブジェクトを返していました。\n" +"Python 3.7 からはどちらのメソッドもコルーチンになりました。" #: ../../library/asyncio-eventloop.rst:1271 msgid "Working with pipes" msgstr "パイプとやりとりする" -#: ../../library/asyncio-eventloop.rst:1276 msgid "Register the read end of *pipe* in the event loop." -msgstr "イベントループの読み込み側終端に *pipe* を登録します。" +msgstr "*pipe* の読み込み側の終端をイベントループに登録します。" -#: ../../library/asyncio-eventloop.rst:1281 -#: ../../library/asyncio-eventloop.rst:1300 msgid "" "*pipe* is a :term:`file-like object `. See :ref:`Supported " "pipe objects ` for the objects supported as *pipe*." msgstr "" +"*pipe* は :term:`ファイルライクオブジェクト ` です。\n" +"指定できるオブジェクトについては :ref:`サポートされるパイプオブジェクト " +"` を参照してください。" #: ../../library/asyncio-eventloop.rst:1285 msgid "" @@ -1959,14 +2050,12 @@ msgstr "" "`ReadTransport` のインターフェースをサポートし、 *protocol* は " "*protocol_factory* ファクトリでインスタンス化されたオブジェクトです。" -#: ../../library/asyncio-eventloop.rst:1289 -#: ../../library/asyncio-eventloop.rst:1308 msgid "" "With :class:`SelectorEventLoop` event loop, the *pipe* is set to non-" "blocking mode." msgstr "" -":class:`SelectorEventLoop` イベントループの場合、*pipe* は非ブロックモードに" -"設定されていなければなりません。" +":class:`SelectorEventLoop` イベントループでは、*pipe* が非ブロックモードに設" +"定されます。" #: ../../library/asyncio-eventloop.rst:1295 msgid "Register the write end of *pipe* in the event loop." @@ -1982,11 +2071,9 @@ msgstr "" "`WriteTransport` のインスタンスであり、 *protocol* は *protocol_factory* ファ" "クトリでインスタンス化されたオブジェクトです。" -#: ../../library/asyncio-eventloop.rst:1314 msgid "Supported pipe objects" -msgstr "" +msgstr "サポートされるパイプオブジェクト" -#: ../../library/asyncio-eventloop.rst:1315 msgid "" "These methods only work with objects the operating system can poll for " "readiness or perform overlapped I/O on. Regular files on disk are **not** " @@ -1994,28 +2081,33 @@ msgid "" "use :meth:`loop.run_in_executor` to read and write regular files without " "blocking the event loop." msgstr "" +"これらのメソッドで扱えるのは、OS が読み書きの準備状況をポーリングできるオブ" +"ジェクト、またはオーバーラップ I/O を実行できるオブジェクトだけです。\n" +"ディスク上の通常のファイルは、どのプラットフォームでも **サポートされません" +"**。\n" +"asyncio に非同期ファイル I/O はないため、イベントループをブロックせずに通常の" +"ファイルを読み書きするには :meth:`loop.run_in_executor` を使ってください。" -#: ../../library/asyncio-eventloop.rst:1321 msgid "" "On Unix, with :class:`SelectorEventLoop`, *pipe* must wrap one of the " "following:" msgstr "" +"Unix の :class:`SelectorEventLoop` では、*pipe* は次のいずれかをラップする必" +"要があります。" -#: ../../library/asyncio-eventloop.rst:1324 msgid "" "a pipe, such as an end of an :func:`os.pipe` pair or a FIFO created with :" "func:`os.mkfifo`;" msgstr "" +":func:`os.pipe` で作成したペアの一端や、:func:`os.mkfifo` で作成した FIFO な" +"どのパイプ" -#: ../../library/asyncio-eventloop.rst:1326 msgid "a socket;" -msgstr "" +msgstr "ソケット" -#: ../../library/asyncio-eventloop.rst:1327 msgid "a character device, such as a terminal." -msgstr "" +msgstr "端末などのキャラクターデバイス" -#: ../../library/asyncio-eventloop.rst:1329 msgid "" "On Windows, where only :class:`ProactorEventLoop` implements these methods, " "*pipe* must wrap a handle opened for overlapped I/O (that is, created with " @@ -2026,6 +2118,15 @@ msgid "" "created by :func:`os.pipe` are **not** opened for overlapped I/O and " "therefore cannot be used with these methods." msgstr "" +"Windows では、これらのメソッドを実装しているのは :class:`ProactorEventLoop` " +"だけです。\n" +"ハンドルを I/O 完了ポートに関連付ける必要があるため、*pipe* はオーバーラップ " +"I/O 用に開かれたハンドル (``FILE_FLAG_OVERLAPPED`` フラグで作成したもの) を" +"ラップしなければなりません。\n" +"オーバーラップ I/O 用に開かれていないハンドルは拒否されます。\n" +"特に、標準ストリーム (:data:`sys.stdin`、:data:`sys.stdout`、:data:`sys." +"stderr`)、コンソールのハンドル、:func:`os.pipe` で作成したパイプは、オーバー" +"ラップ I/O 用には開かれていないため、これらのメソッドでは **使えません**。" #: ../../library/asyncio-eventloop.rst:1340 msgid "" @@ -2045,23 +2146,23 @@ msgstr "" msgid "Unix signals" msgstr "Unix シグナル" -#: ../../library/asyncio-eventloop.rst:1356 msgid "" "Set *callback* as the handler for the *signum* signal, passing *args* as " "positional arguments." msgstr "" +"*callback* をシグナル *signum* のハンドラーに設定し、*args* を位置引数として" +"渡します。" -#: ../../library/asyncio-eventloop.rst:1359 msgid "" "The callback will be invoked by *loop*, along with other queued callbacks " "and runnable coroutines of that event loop. Unlike signal handlers " "registered using :func:`signal.signal`, a callback registered with this " "function is allowed to interact with the event loop." msgstr "" -"コールバックは *loop*、登録された他のコールバック、およびイベントループの実行" -"可能なコルーチンから呼び出されます。 :func:`signal.signal` を使って登録された" -"シグナルハンドラと異なり、この関数で登録されたコールバックはイベントループと" -"相互作用することが可能です。" +"このコールバックは、キューに入っている他のコールバックや実行可能なコルーチン" +"とともに、イベントループ *loop* によって呼び出されます。\n" +":func:`signal.signal` で登録したシグナルハンドラとは異なり、この関数で登録し" +"たコールバックはイベントループとやりとりできます。" #: ../../library/asyncio-eventloop.rst:1364 msgid "" @@ -2098,13 +2199,13 @@ msgstr ":mod:`signal` モジュール。" msgid "Executing code in thread or process pools" msgstr "スレッドまたはプロセスプールでコードを実行する" -#: ../../library/asyncio-eventloop.rst:1392 msgid "" "Arrange for *func* to be called in the specified executor passing *args* as " "positional arguments." msgstr "" +"指定した Executor 内で、*args* を位置引数として *func* を呼び出すように手配し" +"ます。" -#: ../../library/asyncio-eventloop.rst:1395 msgid "" "The *executor* argument should be an :class:`concurrent.futures.Executor` " "instance. The default executor is used if *executor* is ``None``. The " @@ -2112,8 +2213,13 @@ msgid "" "a :class:`concurrent.futures.ThreadPoolExecutor` will be lazy-initialized " "and used by :func:`run_in_executor` if needed." msgstr "" +"*executor* 引数には :class:`concurrent.futures.Executor` のインスタンスを指定" +"します。\n" +"``None`` の場合はデフォルトの Executor を使います。\n" +"デフォルトの Executor は :meth:`loop.set_default_executor` で設定できます。\n" +"設定しなければ、:func:`run_in_executor` が必要になった時点で :class:" +"`concurrent.futures.ThreadPoolExecutor` を初期化して使います。" -#: ../../library/asyncio-eventloop.rst:1403 msgid "" "import asyncio\n" "import concurrent.futures\n" @@ -2161,14 +2267,62 @@ msgid "" "if __name__ == '__main__':\n" " asyncio.run(main())" msgstr "" +"import asyncio\n" +"import concurrent.futures\n" +"\n" +"def blocking_io():\n" +" # ログ記録などのファイル操作はイベントループをブロックする\n" +" # 可能性があるので、スレッドプールで実行する。\n" +" with open('/dev/urandom', 'rb') as f:\n" +" return f.read(100)\n" +"\n" +"def cpu_bound():\n" +" # CPU バウンドな処理はイベントループをブロックする。\n" +" # 通常はプロセスプールで実行する方がよい。\n" +" return sum(i * i for i in range(10 ** 7))\n" +"\n" +"async def main():\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" ## 実行方法:\n" +"\n" +" # 1. ループのデフォルトの Executor で実行する:\n" +" result = await loop.run_in_executor(\n" +" None, blocking_io)\n" +" print('default thread pool', result)\n" +"\n" +" # 2. 自分で作成したスレッドプールで実行する:\n" +" with concurrent.futures.ThreadPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, blocking_io)\n" +" print('custom thread pool', result)\n" +"\n" +" # 3. 自分で作成したプロセスプールで実行する:\n" +" with concurrent.futures.ProcessPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, cpu_bound)\n" +" print('custom process pool', result)\n" +"\n" +" # 4. 自分で作成したインタープリタプールで実行する:\n" +" with concurrent.futures.InterpreterPoolExecutor() as pool:\n" +" result = await loop.run_in_executor(\n" +" pool, cpu_bound)\n" +" print('custom interpreter pool', result)\n" +"\n" +"if __name__ == '__main__':\n" +" asyncio.run(main())" -#: ../../library/asyncio-eventloop.rst:1449 msgid "" "Note that the entry point guard (``if __name__ == '__main__'``) is required " "for option 3 due to the peculiarities of :mod:`multiprocessing`, which is " "used by :class:`~concurrent.futures.ProcessPoolExecutor`. See :ref:`Safe " "importing of main module `." msgstr "" +"例の 3 番では、:class:`~concurrent.futures.ProcessPoolExecutor` が使う :mod:" +"`multiprocessing` の特性により、エントリーポイントのガード (``if __name__ == " +"'__main__'``) が必要です。\n" +":ref:`メインモジュールの安全なインポート ` " +"を参照してください。" #: ../../library/asyncio-eventloop.rst:1454 msgid "This method returns a :class:`asyncio.Future` object." @@ -2194,23 +2348,27 @@ msgstr "" "`~concurrent.futures.ThreadPoolExecutor`) にデフォルト値を設定させるようにな" "りました。" -#: ../../library/asyncio-eventloop.rst:1468 msgid "" "Set *executor* as the default executor used by :meth:`run_in_executor`. " "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`, which includes :class:`~concurrent.futures." "InterpreterPoolExecutor`." msgstr "" +"*executor* を、:meth:`run_in_executor` が使うデフォルトの Executor に設定しま" +"す。\n" +"*executor* は :class:`~concurrent.futures.ThreadPoolExecutor` のインスタンス" +"でなければなりません。\n" +"これには :class:`~concurrent.futures.InterpreterPoolExecutor` も含まれます。" -#: ../../library/asyncio-eventloop.rst:1473 msgid "" "*executor* must be an instance of :class:`~concurrent.futures." "ThreadPoolExecutor`." msgstr "" +"*executor* は :class:`~concurrent.futures.ThreadPoolExecutor` のインスタンス" +"でなければならなくなりました。" -#: ../../library/asyncio-eventloop.rst:1479 msgid "Error handling API" -msgstr "" +msgstr "エラー処理 API" #: ../../library/asyncio-eventloop.rst:1481 msgid "Allows customizing how exceptions are handled in the event loop." @@ -2235,18 +2393,21 @@ msgstr "" "``dict`` オブジェクトです (*context* についての詳細は :meth:" "`call_exception_handler` メソッドのドキュメントを参照してください)。" -#: ../../library/asyncio-eventloop.rst:1495 msgid "" "If the handler is called on behalf of a :class:`~asyncio.Task` or :class:" "`~asyncio.Handle`, it is run in the :class:`contextvars.Context` of that " "task or callback handle." msgstr "" +":class:`~asyncio.Task` または :class:`~asyncio.Handle` のためにハンドラーを呼" +"び出す場合、そのタスクまたはコールバックハンドルの :class:`contextvars." +"Context` で実行します。" -#: ../../library/asyncio-eventloop.rst:1501 msgid "" "The handler may be called in the :class:`~contextvars.Context` of the task " "or handle where the exception originated." msgstr "" +"例外が発生したタスクまたはハンドルの :class:`~contextvars.Context` で、ハンド" +"ラーを呼び出す場合があるようになりました。" #: ../../library/asyncio-eventloop.rst:1506 msgid "" @@ -2300,9 +2461,8 @@ msgstr "'exception' (任意): 例外オブジェクト;" msgid "'future' (optional): :class:`asyncio.Future` instance;" msgstr "'future' (任意): :class:`asyncio.Future` インスタンス;" -#: ../../library/asyncio-eventloop.rst:1532 msgid "'task' (optional): :class:`asyncio.Task` instance;" -msgstr "" +msgstr "'task' (省略可能): :class:`asyncio.Task` のインスタンス" #: ../../library/asyncio-eventloop.rst:1533 msgid "'handle' (optional): :class:`asyncio.Handle` instance;" @@ -2317,17 +2477,14 @@ msgid "'transport' (optional): :ref:`Transport ` instance;" msgstr "" "'transport' (任意): :ref:`トランスポート ` インスタンス;" -#: ../../library/asyncio-eventloop.rst:1536 msgid "'socket' (optional): :class:`socket.socket` instance;" -msgstr "" +msgstr "'socket' (省略可能): :class:`socket.socket` のインスタンス" -#: ../../library/asyncio-eventloop.rst:1537 msgid "'source_traceback' (optional): Traceback of the source;" -msgstr "" +msgstr "'source_traceback' (省略可能): 生成元のトレースバック" -#: ../../library/asyncio-eventloop.rst:1538 msgid "'handle_traceback' (optional): Traceback of the handle;" -msgstr "" +msgstr "'handle_traceback' (省略可能): ハンドルのトレースバック" #: ../../library/asyncio-eventloop.rst:1539 msgid "'asyncgen' (optional): Asynchronous generator that caused" @@ -2337,11 +2494,14 @@ msgstr "" msgid "the exception." msgstr "" -#: ../../library/asyncio-eventloop.rst:1544 msgid "" "This method should not be overloaded in subclassed event loops. For custom " "exception handling, use the :meth:`set_exception_handler` method." msgstr "" +"イベントループのサブクラスで、このメソッドをオーバーライドしないでくださ" +"い。\n" +"例外処理をカスタマイズするには :meth:`set_exception_handler` を使ってくださ" +"い。" #: ../../library/asyncio-eventloop.rst:1549 msgid "Enabling debug mode" @@ -2371,24 +2531,24 @@ msgstr "" "新しい :ref:`Python 開発モード ` を使ってデバッグモードを有効化する" "ことができるようになりました。" -#: ../../library/asyncio-eventloop.rst:1570 msgid "" "This attribute can be used to set the minimum execution duration in seconds " "that is considered \"slow\". When debug mode is enabled, \"slow\" callbacks " "are logged." msgstr "" +"この属性は、「遅い」とみなす実行時間の最小値を秒単位で設定するために使いま" +"す。\n" +"デバッグモードが有効な場合、「遅い」コールバックがログに記録されます。" -#: ../../library/asyncio-eventloop.rst:1574 msgid "Default value is 100 milliseconds." -msgstr "" +msgstr "デフォルト値は 100 ミリ秒です。" #: ../../library/asyncio-eventloop.rst:1578 msgid "The :ref:`debug mode of asyncio `." msgstr ":ref:`asyncio のデバッグモード `。" -#: ../../library/asyncio-eventloop.rst:1582 msgid "Running subprocesses" -msgstr "" +msgstr "サブプロセスの実行" #: ../../library/asyncio-eventloop.rst:1584 msgid "" @@ -2400,12 +2560,15 @@ msgstr "" "高水準の関数である :func:`asyncio.create_subprocess_shell` や :func:`asyncio." "create_subprocess_exec` を代わりに使うことを検討してください。" -#: ../../library/asyncio-eventloop.rst:1591 msgid "" "On Windows, the default event loop :class:`ProactorEventLoop` supports " "subprocesses, whereas :class:`SelectorEventLoop` does not. See :ref:" "`Subprocess Support on Windows ` for details." msgstr "" +"Windows では、デフォルトの :class:`ProactorEventLoop` はサブプロセスをサポー" +"トしますが、:class:`SelectorEventLoop` はサポートしません。\n" +"詳細は :ref:`Windows でのサブプロセスのサポート ` を参照してください。" #: ../../library/asyncio-eventloop.rst:1603 msgid "" @@ -2468,17 +2631,15 @@ msgstr "その他の引数:" msgid "*stdin* can be any of these:" msgstr "*stdin* は下記のいずれかをとることができます:" -#: ../../library/asyncio-eventloop.rst:1629 -#: ../../library/asyncio-eventloop.rst:1640 -#: ../../library/asyncio-eventloop.rst:1650 msgid "a file-like object" -msgstr "" +msgstr "ファイルライクオブジェクト" -#: ../../library/asyncio-eventloop.rst:1630 msgid "" "an existing file descriptor (a positive integer), for example those created " "with :meth:`os.pipe`" msgstr "" +"既存のファイル記述子 (正の整数)。\n" +"例えば :meth:`os.pipe` で作成したもの。" #: ../../library/asyncio-eventloop.rst:1631 #: ../../library/asyncio-eventloop.rst:1641 @@ -2546,13 +2707,16 @@ msgstr "" "していません。ストリームからテキストに変換するには :func:`bytes.decode` 関数" "を使ってください。" -#: ../../library/asyncio-eventloop.rst:1669 msgid "" "If a file-like object passed as *stdin*, *stdout* or *stderr* represents a " "pipe, then the other side of this pipe should be registered with :meth:" "`~loop.connect_write_pipe` or :meth:`~loop.connect_read_pipe` for use with " "the event loop." msgstr "" +"*stdin*、*stdout*、*stderr* として渡したファイルライクオブジェクトがパイプを" +"表す場合、イベントループで使うには、パイプのもう一方の端を :meth:`~loop." +"connect_write_pipe` または :meth:`~loop.connect_read_pipe` で登録してくださ" +"い。" #: ../../library/asyncio-eventloop.rst:1674 msgid "" @@ -2572,12 +2736,12 @@ msgstr "" "`asyncio.SubprocessTransport` 基底クラスに適合するオブジェクトで、 " "*protocol* は *protocol_factory* によりインスタンス化されたオブジェクトです。" -#: ../../library/asyncio-eventloop.rst:1681 -#: ../../library/asyncio-eventloop.rst:1707 msgid "" "If the transport is closed or is garbage collected, the child process is " "killed if it is still running." msgstr "" +"トランスポートを閉じた場合や、トランスポートがガベージコレクションで回収され" +"た場合、子プロセスがまだ実行中なら強制終了します。" #: ../../library/asyncio-eventloop.rst:1689 msgid "" @@ -2639,9 +2803,8 @@ msgstr "" "ください。シェルコマンドを構成する文字列内の空白文字と特殊文字のエスケープ" "は、 :func:`shlex.quote` 関数を使うと適切に行うことができます。" -#: ../../library/asyncio-eventloop.rst:1720 msgid "Callback handles" -msgstr "" +msgstr "コールバックハンドル" #: ../../library/asyncio-eventloop.rst:1724 msgid "" @@ -2651,10 +2814,11 @@ msgstr "" ":meth:`loop.call_soon` や :meth:`loop.call_soon_threadsafe` が返すコールバッ" "クのラッパーです。" -#: ../../library/asyncio-eventloop.rst:1729 msgid "" "Return the :class:`contextvars.Context` object associated with the handle." msgstr "" +"ハンドルに関連付けられた :class:`contextvars.Context` オブジェクトを返しま" +"す。" #: ../../library/asyncio-eventloop.rst:1736 msgid "" @@ -2692,9 +2856,8 @@ msgstr "" "戻り値の時刻は絶対値で、 :meth:`loop.time` と同じ参照時刻を使って定義されてい" "ます。" -#: ../../library/asyncio-eventloop.rst:1763 msgid "Server objects" -msgstr "" +msgstr "サーバーオブジェクト" #: ../../library/asyncio-eventloop.rst:1765 msgid "" @@ -2706,9 +2869,8 @@ msgstr "" "create_unix_server`、 :func:`start_server` および :func:`start_unix_server` " "関数により生成されます。" -#: ../../library/asyncio-eventloop.rst:1769 msgid "Do not instantiate the :class:`Server` class directly." -msgstr "" +msgstr ":class:`Server` クラスを直接インスタンス化しないでください。" #: ../../library/asyncio-eventloop.rst:1773 msgid "" @@ -2720,7 +2882,6 @@ msgstr "" "の中で使われた場合、 ``async with`` 文が完了した時に Server オブジェクトがク" "ローズされること、およびそれ以降に接続を受け付けないことが保証されます。" -#: ../../library/asyncio-eventloop.rst:1778 msgid "" "srv = await loop.create_server(...)\n" "\n" @@ -2729,6 +2890,12 @@ msgid "" "\n" "# At this point, srv is closed and no longer accepts new connections." msgstr "" +"srv = await loop.create_server(...)\n" +"\n" +"async with srv:\n" +" # 何らかの処理\n" +"\n" +"# この時点で srv は閉じられており、新しい接続を受け付けない。" #: ../../library/asyncio-eventloop.rst:1786 msgid "Server object is an asynchronous context manager since Python 3.7." @@ -2736,11 +2903,12 @@ msgstr "" "Python 3.7 から、 Server オブジェクトは非同期のコンテキストマネージャになりま" "した。" -#: ../../library/asyncio-eventloop.rst:1789 msgid "" "This class was exposed publicly as ``asyncio.Server`` in Python 3.9.11, " "3.10.3 and 3.11." msgstr "" +"このクラスは Python 3.9.11、3.10.3、3.11 で ``asyncio.Server`` として公開され" +"ました。" #: ../../library/asyncio-eventloop.rst:1794 msgid "" @@ -2756,43 +2924,49 @@ msgid "" "open." msgstr "既存の受信中のクライアントとの接続を表すソケットはオープンのままです。" -#: ../../library/asyncio-eventloop.rst:1800 msgid "" "The server is closed asynchronously; use the :meth:`wait_closed` coroutine " "to wait until the server is closed (and no more connections are active)." msgstr "" +"サーバーは非同期に閉じられます。\n" +"サーバーが閉じられ、すべての接続が終了するまで待つには、:meth:`wait_closed` " +"コルーチンを使ってください。" -#: ../../library/asyncio-eventloop.rst:1806 msgid "Close all existing incoming client connections." -msgstr "" +msgstr "受け付け済みのすべてのクライアント接続を閉じます。" -#: ../../library/asyncio-eventloop.rst:1808 msgid "" "Calls :meth:`~asyncio.BaseTransport.close` on all associated transports." msgstr "" +"関連付けられたすべてのトランスポートに対して :meth:`~asyncio.BaseTransport." +"close` を呼び出します。" -#: ../../library/asyncio-eventloop.rst:1811 msgid "" ":meth:`close` should be called before :meth:`close_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" +"新しいクライアント接続との競合を避けるため、サーバーを閉じる際は :meth:" +"`close_clients` の前に :meth:`close` を呼び出してください。" -#: ../../library/asyncio-eventloop.rst:1818 msgid "" "Close all existing incoming client connections immediately, without waiting " "for pending operations to complete." msgstr "" +"保留中の処理の完了を待たずに、受け付け済みのすべてのクライアント接続を即座に" +"閉じます。" -#: ../../library/asyncio-eventloop.rst:1821 msgid "" "Calls :meth:`~asyncio.WriteTransport.abort` on all associated transports." msgstr "" +"関連付けられたすべてのトランスポートに対して :meth:`~asyncio.WriteTransport." +"abort` を呼び出します。" -#: ../../library/asyncio-eventloop.rst:1824 msgid "" ":meth:`close` should be called before :meth:`abort_clients` when closing the " "server to avoid races with new clients connecting." msgstr "" +"新しいクライアント接続との競合を避けるため、サーバーを閉じる際は :meth:" +"`abort_clients` の前に :meth:`close` を呼び出してください。" #: ../../library/asyncio-eventloop.rst:1831 msgid "Return the event loop associated with the server object." @@ -2802,11 +2976,12 @@ msgstr "サーバオブジェクトに付随するイベントループを返し msgid "Start accepting connections." msgstr "接続の受け付けを開始します。" -#: ../../library/asyncio-eventloop.rst:1840 msgid "" "This method is idempotent, so it can be called when the server is already " "serving." msgstr "" +"このメソッドはべき等なので、サーバーがすでに接続を受け付けていても呼び出せま" +"す。" #: ../../library/asyncio-eventloop.rst:1843 msgid "" @@ -2822,13 +2997,12 @@ msgstr "" "start_serving()`` または :meth:`Server.serve_forever` メソッドを使ってオブ" "ジェクトが接続の受け付けを開始するようにすることができます。" -#: ../../library/asyncio-eventloop.rst:1855 msgid "" "Start accepting connections until the coroutine is cancelled. Cancellation " "of ``serve_forever`` task causes the server to be closed." msgstr "" "接続の受け入れを開始し、コルーチンがキャンセルされるまで継続します。 " -"``serve_forever`` タスクのキャンセルによりサーバーもクローズされます。 " +"``serve_forever`` タスクのキャンセルによりサーバーもクローズされます。" #: ../../library/asyncio-eventloop.rst:1859 msgid "" @@ -2839,7 +3013,6 @@ msgstr "" "す。ひとつの *Server* オブジェクトにつき ``serve_forever`` タスクはひとつだけ" "存在できます。" -#: ../../library/asyncio-eventloop.rst:1865 msgid "" "async def client_connected(reader, writer):\n" " # Communicate with the client with\n" @@ -2853,23 +3026,38 @@ msgid "" "\n" "asyncio.run(main('127.0.0.1', 0))" msgstr "" +"async def client_connected(reader, writer):\n" +" # reader/writer ストリームでクライアントと通信する。\n" +" # 例えば次のようにする:\n" +" await reader.readline()\n" +"\n" +"async def main(host, port):\n" +" srv = await asyncio.start_server(\n" +" client_connected, host, port)\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main('127.0.0.1', 0))" #: ../../library/asyncio-eventloop.rst:1881 msgid "Return ``True`` if the server is accepting new connections." msgstr "サーバーが新規に接続の受け入れを開始した場合 ``True`` を返します。" -#: ../../library/asyncio-eventloop.rst:1888 msgid "" "Wait until the :meth:`close` method completes and all active connections " "have finished." msgstr "" +":meth:`close` メソッドが完了し、すべてのアクティブな接続が終了するまで待ちま" +"す。" -#: ../../library/asyncio-eventloop.rst:1891 msgid "" "``wait_closed()`` now waits until the server is closed and all active " "connections have finished. Previously, it returned immediately if the " "server was already closed, even if connections were still active." msgstr "" +"``wait_closed()`` は、サーバーが閉じられ、すべてのアクティブな接続が終了する" +"まで待つようになりました。\n" +"以前は、サーバーがすでに閉じられていると、接続がまだ残っていても即座に返って" +"いました。" #: ../../library/asyncio-eventloop.rst:1899 msgid "" @@ -2886,27 +3074,26 @@ msgstr "" "バーソケットのリストを直接返していました。 Python 3.7 ではリストのコピーが返" "されるようになりました。" -#: ../../library/asyncio-eventloop.rst:1912 msgid "Event loop implementations" -msgstr "" +msgstr "イベントループの実装" -#: ../../library/asyncio-eventloop.rst:1914 msgid "" "asyncio ships with two different event loop implementations: :class:" "`SelectorEventLoop` and :class:`ProactorEventLoop`." msgstr "" "asyncio は2つの異なるイベントループの実装、 :class:`SelectorEventLoop` と :" -"class:`ProactorEventLoop`、 を提供します: " +"class:`ProactorEventLoop`、 を提供します:" -#: ../../library/asyncio-eventloop.rst:1917 msgid "By default asyncio is configured to use :class:`EventLoop`." msgstr "" +"デフォルトでは、asyncio は :class:`EventLoop` を使うように設定されています。" -#: ../../library/asyncio-eventloop.rst:1922 msgid "" "A subclass of :class:`AbstractEventLoop` based on the :mod:`selectors` " "module." msgstr "" +":mod:`selectors` モジュールに基づく :class:`AbstractEventLoop` のサブクラスで" +"す。" #: ../../library/asyncio-eventloop.rst:1925 msgid "" @@ -2917,7 +3104,6 @@ msgstr "" "プラットフォーム上で利用可能な最も効率の良い *selector* を使います。特定のセ" "レクタ実装を使うように手動で構成することも可能です::" -#: ../../library/asyncio-eventloop.rst:1929 msgid "" "import asyncio\n" "import selectors\n" @@ -2929,40 +3115,54 @@ msgid "" "SelectSelector())\n" "asyncio.run(main(), loop_factory=loop_factory)" msgstr "" +"import asyncio\n" +"import selectors\n" +"\n" +"async def main():\n" +" ...\n" +"\n" +"loop_factory = lambda: asyncio.SelectorEventLoop(selectors." +"SelectSelector())\n" +"asyncio.run(main(), loop_factory=loop_factory)" -#: ../../library/asyncio-eventloop.rst:1944 msgid "" "A subclass of :class:`AbstractEventLoop` for Windows that uses \"I/O " "Completion Ports\" (IOCP)." msgstr "" +"I/O 完了ポート (IOCP) を使う、Windows 用の :class:`AbstractEventLoop` のサブ" +"クラスです。" -#: ../../library/asyncio-eventloop.rst:1950 msgid "" "`MSDN documentation on I/O Completion Ports `_." msgstr "" +"`I/O 完了ポートの MSDN ドキュメント `_。" -#: ../../library/asyncio-eventloop.rst:1955 msgid "" "An alias to the most efficient available subclass of :class:" "`AbstractEventLoop` for the given platform." msgstr "" +"そのプラットフォームで利用可能な、最も効率的な :class:`AbstractEventLoop` の" +"サブクラスの別名です。" -#: ../../library/asyncio-eventloop.rst:1958 msgid "" "It is an alias to :class:`SelectorEventLoop` on Unix and :class:" "`ProactorEventLoop` on Windows." msgstr "" +"Unix では :class:`SelectorEventLoop`、Windows では :class:" +"`ProactorEventLoop` の別名です。" #: ../../library/asyncio-eventloop.rst:1964 msgid "Abstract base class for asyncio-compliant event loops." msgstr "asyncio に適合するイベントループの抽象基底クラスです。" -#: ../../library/asyncio-eventloop.rst:1966 msgid "" "The :ref:`asyncio-event-loop-methods` section lists all methods that an " "alternative implementation of ``AbstractEventLoop`` should have defined." msgstr "" +":ref:`asyncio-event-loop-methods` の節には、``AbstractEventLoop`` の代替実装" +"で定義すべきメソッドをすべて列挙しています。" #: ../../library/asyncio-eventloop.rst:1972 msgid "Examples" @@ -2992,7 +3192,6 @@ msgstr "" ":meth:`loop.call_soon` メソッドを使ってコールバックをスケジュールする例です。" "コールバックは ``\"Hello World\"`` を出力しイベントループを停止します::" -#: ../../library/asyncio-eventloop.rst:1990 msgid "" "import asyncio\n" "\n" @@ -3012,6 +3211,24 @@ msgid "" "finally:\n" " loop.close()" msgstr "" +"import asyncio\n" +"\n" +"def hello_world(loop):\n" +" \"\"\"'Hello World' を表示してイベントループを停止するコールバック" +"\"\"\"\n" +" print('Hello World')\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# hello_world() の呼び出しをスケジュールする\n" +"loop.call_soon(hello_world, loop)\n" +"\n" +"# loop.stop() で終了するブロッキング呼び出し\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" #: ../../library/asyncio-eventloop.rst:2010 msgid "" @@ -3035,7 +3252,6 @@ msgstr "" "call_later` メソッドを使って自身を5秒後に実行するよう再スケジュールし、イベン" "トループを停止します::" -#: ../../library/asyncio-eventloop.rst:2023 msgid "" "import asyncio\n" "import datetime as dt\n" @@ -3059,6 +3275,27 @@ msgid "" "finally:\n" " loop.close()" msgstr "" +"import asyncio\n" +"import datetime as dt\n" +"\n" +"def display_date(end_time, loop):\n" +" print(dt.datetime.now())\n" +" if (loop.time() + 1.0) < end_time:\n" +" loop.call_later(1, display_date, end_time, loop)\n" +" else:\n" +" loop.stop()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"# display_date() の最初の呼び出しをスケジュールする\n" +"end_time = loop.time() + 5.0\n" +"loop.call_soon(display_date, end_time, loop)\n" +"\n" +"# loop.stop() で終了するブロッキング呼び出し\n" +"try:\n" +" loop.run_forever()\n" +"finally:\n" +" loop.close()" #: ../../library/asyncio-eventloop.rst:2047 msgid "" @@ -3080,7 +3317,6 @@ msgstr "" "ファイル記述子が :meth:`loop.add_reader` メソッドを使って何らかのデータを受信" "するまで待機し、その後イベントループをクローズします::" -#: ../../library/asyncio-eventloop.rst:2059 msgid "" "import asyncio\n" "from socket import socketpair\n" @@ -3115,14 +3351,45 @@ msgid "" " wsock.close()\n" " loop.close()" msgstr "" +"import asyncio\n" +"from socket import socketpair\n" +"\n" +"# 接続されたファイル記述子のペアを作成する\n" +"rsock, wsock = socketpair()\n" +"\n" +"loop = asyncio.new_event_loop()\n" +"\n" +"def reader():\n" +" data = rsock.recv(100)\n" +" print(\"Received:\", data.decode())\n" +"\n" +" # 処理が済んだので、ファイル記述子の登録を解除する\n" +" loop.remove_reader(rsock)\n" +"\n" +" # イベントループを停止する\n" +" loop.stop()\n" +"\n" +"# 読み込みイベント用にファイル記述子を登録する\n" +"loop.add_reader(rsock, reader)\n" +"\n" +"# ネットワークからのデータ受信を模倣する\n" +"loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +"try:\n" +" # イベントループを実行する\n" +" loop.run_forever()\n" +"finally:\n" +" # 処理が済んだので、ソケットとイベントループを閉じる。\n" +" rsock.close()\n" +" wsock.close()\n" +" loop.close()" -#: ../../library/asyncio-eventloop.rst:2094 msgid "" "A similar :ref:`example ` using " "transports, protocols, and the :meth:`loop.create_connection` method." msgstr "" "トランスポート、プロトコル、および :meth:`loop.create_connection` メソッドを" -"使用した同じような :ref:`例 `。 " +"使用した同じような :ref:`例 `。" #: ../../library/asyncio-eventloop.rst:2098 msgid "" @@ -3136,15 +3403,15 @@ msgstr "" msgid "Set signal handlers for SIGINT and SIGTERM" msgstr "SIGINT および SIGTERM 用のシグナルハンドラーの設定" -#: ../../library/asyncio-eventloop.rst:2108 msgid "(This ``signal`` example only works on Unix.)" -msgstr "" +msgstr "(この ``signal`` の例は Unix でのみ動作します。)" -#: ../../library/asyncio-eventloop.rst:2110 msgid "" "Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal." "SIGTERM` using the :meth:`loop.add_signal_handler` method::" msgstr "" +":meth:`loop.add_signal_handler` メソッドで、シグナル :const:`~signal.SIGINT` " +"と :const:`~signal.SIGTERM` のハンドラーを登録します。 ::" #: ../../library/asyncio-eventloop.rst:2113 msgid "" diff --git a/library/asyncio-exceptions.po b/library/asyncio-exceptions.po index fc8b37b65..eedbbc191 100644 --- a/library/asyncio-exceptions.po +++ b/library/asyncio-exceptions.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-exceptions.rst:8 diff --git a/library/asyncio-extending.po b/library/asyncio-extending.po index 0fbdfd359..d5aaae181 100644 --- a/library/asyncio-extending.po +++ b/library/asyncio-extending.po @@ -12,145 +12,151 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-extending.rst:6 msgid "Extending" -msgstr "" +msgstr "拡張" -#: ../../library/asyncio-extending.rst:8 msgid "" "The main direction for :mod:`asyncio` extending is writing custom *event " "loop* classes. Asyncio has helpers that could be used to simplify this task." msgstr "" +":mod:`asyncio` を拡張する主な方法は、独自の *イベントループ* クラスを書くこと" +"です。\n" +"asyncio には、この作業を簡単にするための補助機能があります。" -#: ../../library/asyncio-extending.rst:13 msgid "" "Third-parties should reuse existing asyncio code with caution, a new Python " "version is free to break backward compatibility in *internal* part of API." msgstr "" +"サードパーティーが既存の asyncio コードを再利用する際は注意してください。\n" +"新しい Python バージョンでは、API の *内部的な* 部分について後方互換性が失わ" +"れる可能性があります。" -#: ../../library/asyncio-extending.rst:19 msgid "Writing a Custom Event Loop" -msgstr "" +msgstr "独自のイベントループを書く" -#: ../../library/asyncio-extending.rst:21 msgid "" ":class:`asyncio.AbstractEventLoop` declares very many methods. Implementing " "all them from scratch is a tedious job." msgstr "" +":class:`asyncio.AbstractEventLoop` には非常に多くのメソッドが宣言されており、" +"すべてを一から実装するのは大変な作業です。" -#: ../../library/asyncio-extending.rst:24 msgid "" "A loop can get many common methods implementation for free by inheriting " "from :class:`asyncio.BaseEventLoop`." msgstr "" +":class:`asyncio.BaseEventLoop` を継承すれば、多くの共通メソッドの実装をそのま" +"ま利用できます。" -#: ../../library/asyncio-extending.rst:27 msgid "" "In turn, the successor should implement a bunch of *private* methods " "declared but not implemented in :class:`asyncio.BaseEventLoop`." msgstr "" +"その代わり、サブクラスでは :class:`asyncio.BaseEventLoop` に宣言されているも" +"のの実装されていない *非公開* メソッドを実装する必要があります。" -#: ../../library/asyncio-extending.rst:30 msgid "" "For example, ``loop.create_connection()`` checks arguments, resolves DNS " "addresses, and calls ``loop._make_socket_transport()`` that should be " "implemented by inherited class. The ``_make_socket_transport()`` method is " "not documented and is considered as an *internal* API." msgstr "" +"例えば ``loop.create_connection()`` は、引数の検査と DNS によるアドレス解決を" +"行い、サブクラスで実装すべき ``loop._make_socket_transport()`` を呼び出しま" +"す。\n" +"``_make_socket_transport()`` は文書化されておらず、*内部* API とみなされま" +"す。" -#: ../../library/asyncio-extending.rst:38 msgid "Future and Task private constructors" -msgstr "" +msgstr "Future と Task の非公開コンストラクター" -#: ../../library/asyncio-extending.rst:40 msgid "" ":class:`asyncio.Future` and :class:`asyncio.Task` should be never created " "directly, please use corresponding :meth:`loop.create_future` and :meth:" "`loop.create_task`, or :func:`asyncio.create_task` factories instead." msgstr "" +":class:`asyncio.Future` と :class:`asyncio.Task` は直接作成しないでくださ" +"い。\n" +"代わりに、それぞれに対応するファクトリー :meth:`loop.create_future` と :meth:" +"`loop.create_task`、または :func:`asyncio.create_task` を使ってください。" -#: ../../library/asyncio-extending.rst:44 msgid "" "However, third-party *event loops* may *reuse* built-in future and task " "implementations for the sake of getting a complex and highly optimized code " "for free." msgstr "" +"ただし、サードパーティーの *イベントループ* は、複雑で高度に最適化されたコー" +"ドを自前で実装せずに利用するために、組み込みの Future と Task の実装を *再利" +"用* してもかまいません。" -#: ../../library/asyncio-extending.rst:47 msgid "For this purpose the following, *private* constructors are listed:" -msgstr "" +msgstr "この目的のために、以下の *非公開* コンストラクターを紹介します。" -#: ../../library/asyncio-extending.rst:51 msgid "Create a built-in future instance." -msgstr "" +msgstr "組み込みの Future インスタンスを作成します。" -#: ../../library/asyncio-extending.rst:53 msgid "*loop* is an optional event loop instance." -msgstr "" +msgstr "*loop* は省略可能なイベントループのインスタンスです。" -#: ../../library/asyncio-extending.rst:57 msgid "Create a built-in task instance." -msgstr "" +msgstr "組み込みの Task インスタンスを作成します。" -#: ../../library/asyncio-extending.rst:59 msgid "" "*loop* is an optional event loop instance. The rest of arguments are " "described in :meth:`loop.create_task` description." msgstr "" +"*loop* は省略可能なイベントループのインスタンスです。\n" +"他の引数については :meth:`loop.create_task` を参照してください。" -#: ../../library/asyncio-extending.rst:64 msgid "*context* argument is added." -msgstr "" +msgstr "*context* 引数が追加されました。" -#: ../../library/asyncio-extending.rst:69 msgid "Task lifetime support" -msgstr "" +msgstr "タスクの生存期間の管理" -#: ../../library/asyncio-extending.rst:71 msgid "" "A third party task implementation should call the following functions to " "keep a task visible by :func:`asyncio.all_tasks` and :func:`asyncio." "current_task`:" msgstr "" +"サードパーティーのタスク実装では、:func:`asyncio.all_tasks` と :func:" +"`asyncio.current_task` でタスクを取得できるように、次の関数を呼び出す必要があ" +"ります。" -#: ../../library/asyncio-extending.rst:76 msgid "Register a new *task* as managed by *asyncio*." -msgstr "" +msgstr "新しい *task* を *asyncio* が管理するタスクとして登録します。" -#: ../../library/asyncio-extending.rst:78 msgid "Call the function from a task constructor." -msgstr "" +msgstr "タスクのコンストラクターから呼び出してください。" -#: ../../library/asyncio-extending.rst:82 msgid "Unregister a *task* from *asyncio* internal structures." -msgstr "" +msgstr "*asyncio* の内部データ構造から *task* の登録を解除します。" -#: ../../library/asyncio-extending.rst:84 msgid "The function should be called when a task is about to finish." -msgstr "" +msgstr "タスクが終了する直前に呼び出してください。" -#: ../../library/asyncio-extending.rst:88 msgid "Switch the current task to the *task* argument." -msgstr "" +msgstr "現在のタスクを、引数 *task* に切り替えます。" -#: ../../library/asyncio-extending.rst:90 msgid "" "Call the function just before executing a portion of embedded *coroutine* (:" "meth:`coroutine.send` or :meth:`coroutine.throw`)." msgstr "" +"タスク内の *コルーチン* を部分的に実行する直前 (:meth:`coroutine.send` また" +"は :meth:`coroutine.throw` の呼び出し直前) に呼び出してください。" -#: ../../library/asyncio-extending.rst:95 msgid "Switch the current task back from *task* to ``None``." -msgstr "" +msgstr "現在のタスクを *task* から ``None`` に戻します。" -#: ../../library/asyncio-extending.rst:97 msgid "" "Call the function just after :meth:`coroutine.send` or :meth:`coroutine." "throw` execution." msgstr "" +":meth:`coroutine.send` または :meth:`coroutine.throw` の実行直後に呼び出して" +"ください。" diff --git a/library/asyncio-future.po b/library/asyncio-future.po index db0eaaa78..039f64612 100644 --- a/library/asyncio-future.po +++ b/library/asyncio-future.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-future.rst:8 @@ -99,18 +99,21 @@ msgstr "" "引数 *obj* が上記のいずれにもあてはまらない場合は :exc:`TypeError` 例外を送出" "します。" -#: ../../library/asyncio-future.rst:54 msgid "" "Save a reference to the result of this function, to avoid a task " "disappearing mid-execution." msgstr "" +"タスクが実行途中で消えないように、この関数の返り値への参照を保持してくださ" +"い。" -#: ../../library/asyncio-future.rst:57 msgid "" "See also the :func:`create_task` function which is the preferred way for " "creating new tasks or use :class:`asyncio.TaskGroup` which keeps reference " "to the task internally." msgstr "" +"新しいタスクの作成に推奨される :func:`create_task` 関数も参照してください。\n" +"または、タスクへの参照を内部で保持する :class:`asyncio.TaskGroup` を使ってく" +"ださい。" #: ../../library/asyncio-future.rst:61 msgid "The function accepts any :term:`awaitable` object." @@ -118,11 +121,12 @@ msgstr "" "この関数はどんな :term:`awaitable` なオブジェクトでも受け入れるようになりまし" "た。" -#: ../../library/asyncio-future.rst:64 msgid "" "Deprecation warning is emitted if *obj* is not a Future-like object and " "*loop* is not specified and there is no running event loop." msgstr "" +"*obj* が Future に相当するオブジェクトではなく、*loop* を指定せず、実行中のイ" +"ベントループもない場合に、非推奨の警告が出ます。" #: ../../library/asyncio-future.rst:71 msgid "" @@ -132,11 +136,12 @@ msgstr "" ":class:`concurrent.futures.Future` オブジェクトを :class:`asyncio.Future` オ" "ブジェクトでラップします。" -#: ../../library/asyncio-future.rst:74 msgid "" "Deprecation warning is emitted if *future* is not a Future-like object and " "*loop* is not specified and there is no running event loop." msgstr "" +"*future* が Future に相当するオブジェクトではなく、*loop* を指定せず、実行中" +"のイベントループもない場合に、非推奨の警告が出ます。" #: ../../library/asyncio-future.rst:81 msgid "Future Object" @@ -149,12 +154,15 @@ msgid "" msgstr "" "Future は非同期処理の最終結果を表すクラスです。スレッドセーフではありません。" -#: ../../library/asyncio-future.rst:88 msgid "" "Future is an :term:`awaitable` object. Coroutines can await on Future " "objects until they either have a result or an exception set, or until they " "are cancelled. A Future can be awaited multiple times and the result is same." msgstr "" +"Future は :term:`awaitable` オブジェクトです。\n" +"コルーチンは Future を await して、結果か例外が設定されるか、キャンセルされる" +"まで待機できます。\n" +"同じ Future を複数回 await でき、その結果は同じです。" #: ../../library/asyncio-future.rst:93 msgid "" @@ -179,19 +187,21 @@ msgstr "" "呼び出すことです。これによりイベントループの代替実装は、自身に最適化された " "Future オブジェクトの実装を合わせて提供することができます。" -#: ../../library/asyncio-future.rst:104 msgid "Futures are :ref:`generic ` over the type of their results." msgstr "" +"Future は、結果の型をパラメーターとする :ref:`ジェネリック型 ` で" +"す。" #: ../../library/asyncio-future.rst:106 msgid "Added support for the :mod:`contextvars` module." msgstr ":mod:`contextvars` モジュールのサポートを追加。" -#: ../../library/asyncio-future.rst:109 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" +"*loop* が指定されておらず、実行中のイベントループもない場合に、非推奨の警告を" +"出すようになりました。" #: ../../library/asyncio-future.rst:115 msgid "Return the result of the Future." @@ -221,20 +231,21 @@ msgstr "" "Future が *キャンセルされた* 場合、このメソッドは :exc:`CancelledError` 例外" "を送出します。" -#: ../../library/asyncio-future.rst:126 msgid "" "If the Future's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" +"Future の結果がまだ得られない場合は、:exc:`InvalidStateError` を送出します。" #: ../../library/asyncio-future.rst:131 msgid "Mark the Future as *done* and set its result." msgstr "Future を *完了* とマークし、結果を設定します。" -#: ../../library/asyncio-future.rst:133 ../../library/asyncio-future.rst:140 msgid "" "Raises an :exc:`InvalidStateError` error if the Future is already *done*." msgstr "" +"Future がすでに *完了* している場合は、:exc:`InvalidStateError` を送出しま" +"す。" #: ../../library/asyncio-future.rst:138 msgid "Mark the Future as *done* and set an exception." @@ -265,11 +276,12 @@ msgstr "" "通常の場合、このメソッドは Future に処理結果や例外を設定する前に Future が *" "キャンセルされていない* ことを確認するために使用されます::" -#: ../../library/asyncio-future.rst:158 msgid "" "if not fut.cancelled():\n" " fut.set_result(42)" msgstr "" +"if not fut.cancelled():\n" +" fut.set_result(42)" #: ../../library/asyncio-future.rst:163 msgid "Add a callback to be run when the Future is *done*." @@ -305,12 +317,14 @@ msgstr "" "コールバックにパラメータを渡すには、次の例のように :func:`functools.partial` " "を使うことができます::" -#: ../../library/asyncio-future.rst:178 msgid "" "# Call 'print(\"Future:\", fut)' when \"fut\" is done.\n" "fut.add_done_callback(\n" " functools.partial(print, \"Future:\"))" msgstr "" +"# fut が完了したら print(\"Future:\", fut) を呼び出す。\n" +"fut.add_done_callback(\n" +" functools.partial(print, \"Future:\"))" #: ../../library/asyncio-future.rst:182 msgid "" @@ -346,15 +360,15 @@ msgstr "" "す。そうでない場合 Future の状態を *キャンセル* に変更した上でコールバックを" "スケジュールし、 ``True`` を返します。" -#: ../../library/asyncio-future.rst:201 msgid "" "The optional string argument *msg* is passed as the argument to the :exc:" "`CancelledError` exception raised when a cancelled Future is awaited." msgstr "" +"省略可能な文字列引数 *msg* は、キャンセル済みの Future を await したときに送" +"出する :exc:`CancelledError` の引数として渡されます。" -#: ../../library/asyncio-future.rst:205 msgid "Added the *msg* parameter." -msgstr "" +msgstr "*msg* パラメーターが追加されました。" #: ../../library/asyncio-future.rst:210 msgid "Return the exception that was set on this Future." @@ -388,7 +402,6 @@ msgstr "" "この例は Future オブジェクトを生成し、Future に結果を設定するための非同期タス" "クを生成してスケジュールし、そして Future に結果が設定されるまで待機します::" -#: ../../library/asyncio-future.rst:234 msgid "" "async def set_after(fut, delay, value):\n" " # Sleep for *delay* seconds.\n" @@ -418,6 +431,33 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"async def set_after(fut, delay, value):\n" +" # delay 秒スリープする。\n" +" await asyncio.sleep(delay)\n" +"\n" +" # Future fut の結果に value を設定する。\n" +" fut.set_result(value)\n" +"\n" +"async def main():\n" +" # 現在のイベントループを取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # 新しい Future オブジェクトを作成する。\n" +" fut = loop.create_future()\n" +"\n" +" # set_after() コルーチンを別のタスクで並行して実行する。\n" +" # ここではイベントループへの参照をすでに持っているので、\n" +" # 低水準の loop.create_task() API を使っている。\n" +" # そうでなければ asyncio.create_task() を使えばよい。\n" +" loop.create_task(\n" +" set_after(fut, 1, '... world'))\n" +"\n" +" print('hello ...')\n" +"\n" +" # fut の結果が得られるまで待ち (1 秒)、表示する。\n" +" print(await fut)\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-future.rst:265 msgid "" @@ -468,8 +508,9 @@ msgstr "" "asyncio の Future は :func:`concurrent.futures.wait` および :func:" "`concurrent.futures.as_completed` との互換性がありません。" -#: ../../library/asyncio-future.rst:286 msgid "" ":meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument, but :" "meth:`concurrent.futures.Future.cancel` does not." msgstr "" +":meth:`asyncio.Future.cancel` は省略可能な ``msg`` 引数を受け付けますが、:" +"meth:`concurrent.futures.Future.cancel` は受け付けません。" diff --git a/library/asyncio-graph.po b/library/asyncio-graph.po index ce3ee52bb..9f3b059f0 100644 --- a/library/asyncio-graph.po +++ b/library/asyncio-graph.po @@ -16,63 +16,66 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-graph.rst:8 msgid "Call graph introspection" -msgstr "" +msgstr "呼び出しグラフのイントロスペクション" -#: ../../library/asyncio-graph.rst:10 msgid "**Source code:** :source:`Lib/asyncio/graph.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/asyncio/graph.py`" -#: ../../library/asyncio-graph.rst:14 msgid "" "asyncio has powerful runtime call graph introspection utilities to trace the " "entire call graph of a running *coroutine* or *task*, or a suspended " "*future*. These utilities and the underlying machinery can be used from " "within a Python program or by external profilers and debuggers." msgstr "" +"asyncio は、実行中の *コルーチン* や *タスク*、または中断中の *Future* の呼び" +"出しグラフ全体を実行時にたどる、強力なイントロスペクション機能を備えていま" +"す。\n" +"これらの機能とその基盤の仕組みは、Python プログラム内からも、外部のプロファイ" +"ラーやデバッガーからも利用できます。" -#: ../../library/asyncio-graph.rst:22 msgid ":ref:`asyncio-introspection-tools`" -msgstr "" +msgstr ":ref:`asyncio-introspection-tools`" -#: ../../library/asyncio-graph.rst:23 msgid "" "Command-line tools for inspecting tasks in another running Python process." msgstr "" +"実行中の別の Python プロセス内のタスクを調べるコマンドラインツールです。" -#: ../../library/asyncio-graph.rst:31 msgid "" "Print the async call graph for the current task or the provided :class:" "`Task` or :class:`Future`." msgstr "" +"現在のタスク、または指定した :class:`Task` や :class:`Future` の非同期呼び出" +"しグラフを表示します。" -#: ../../library/asyncio-graph.rst:34 msgid "" "This function prints entries starting from the top frame and going down " "towards the invocation point." msgstr "" +"スタックの最上部のフレームから、呼び出し元の起点に向かって順に表示します。" -#: ../../library/asyncio-graph.rst:37 msgid "" "The function receives an optional *future* argument. If not passed, the " "current running task will be used." msgstr "" +"省略可能な *future* 引数を受け取ります。\n" +"指定しなければ、現在実行中のタスクを使います。" -#: ../../library/asyncio-graph.rst:40 ../../library/asyncio-graph.rst:99 msgid "" "If the function is called on *the current task*, the optional keyword-only " "*depth* argument can be used to skip the specified number of frames from top " "of the stack." msgstr "" +"*現在のタスク* に対して呼び出す場合、省略可能なキーワード専用引数 *depth* " +"で、スタックの最上部から飛ばすフレーム数を指定できます。" -#: ../../library/asyncio-graph.rst:44 msgid "" "If the optional keyword-only *limit* argument is provided, each call stack " "in the resulting graph is truncated to include at most ``abs(limit)`` " @@ -82,22 +85,26 @@ msgid "" "``0``, the call stack is not printed at all, only \"awaited by\" information " "is printed." msgstr "" +"省略可能なキーワード専用引数 *limit* を指定すると、グラフ内の各コールスタック" +"のエントリー数を最大 ``abs(limit)`` 個に制限します。\n" +"*limit* が正なら呼び出し元の起点に近いエントリーを、負ならスタックの最上部に" +"近いエントリーを残します。\n" +"*limit* を省略するか ``None`` にすると、すべてのエントリーを含めます。\n" +"``0`` の場合、コールスタックは表示せず、何に await されているかの情報だけを表" +"示します。" -#: ../../library/asyncio-graph.rst:52 msgid "" "If *file* is omitted or ``None``, the function will print to :data:`sys." "stdout`." msgstr "" +"*file* を省略するか ``None`` にすると、:data:`sys.stdout` に出力します。" -#: ../../library/asyncio-graph.rst:55 msgid "**Example:**" -msgstr "" +msgstr "**例:**" -#: ../../library/asyncio-graph.rst:57 msgid "The following Python code:" -msgstr "" +msgstr "次の Python コードは、" -#: ../../library/asyncio-graph.rst:59 msgid "" "import asyncio\n" "\n" @@ -110,12 +117,21 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def test():\n" +" asyncio.print_call_graph()\n" +"\n" +"async def main():\n" +" async with asyncio.TaskGroup() as g:\n" +" g.create_task(test(), name='test')\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-graph.rst:72 msgid "will print::" msgstr "このサンプルコードは以下を出力します::" -#: ../../library/asyncio-graph.rst:74 msgid "" "* Task(name='test', id=0x1039f0fe0)\n" "+ Call stack:\n" @@ -126,6 +142,14 @@ msgid "" " | File 'taskgroups.py', line 107, in async TaskGroup.__aexit__()\n" " | File 't2.py', line 7, in async main()" msgstr "" +"* Task(name='test', id=0x1039f0fe0)\n" +"+ Call stack:\n" +"| File 't2.py', line 4, in async test()\n" +"+ Awaited by:\n" +" * Task(name='Task-1', id=0x103a5e060)\n" +" + Call stack:\n" +" | File 'taskgroups.py', line 107, in async TaskGroup.__aexit__()\n" +" | File 't2.py', line 7, in async main()" #: ../../library/asyncio-graph.rst:85 msgid "" @@ -133,11 +157,12 @@ msgid "" "and there's no current task, the function returns an empty string." msgstr "" -#: ../../library/asyncio-graph.rst:92 msgid "" "Capture the async call graph for the current task or the provided :class:" "`Task` or :class:`Future`." msgstr "" +"現在のタスク、または指定した :class:`Task` や :class:`Future` の非同期呼び出" +"しグラフを取得します。" #: ../../library/asyncio-graph.rst:95 msgid "" @@ -146,43 +171,37 @@ msgid "" "returns ``None``." msgstr "" -#: ../../library/asyncio-graph.rst:103 msgid "Returns a ``FutureCallGraph`` data class object:" -msgstr "" +msgstr "``FutureCallGraph`` データクラスのオブジェクトを返します。" -#: ../../library/asyncio-graph.rst:105 msgid "``FutureCallGraph(future, call_stack, awaited_by)``" -msgstr "" +msgstr "``FutureCallGraph(future, call_stack, awaited_by)``" -#: ../../library/asyncio-graph.rst:107 msgid "" "Where *future* is a reference to a :class:`Future` or a :class:`Task` (or " "their subclasses.)" msgstr "" +"*future* は :class:`Future` または :class:`Task` (またはそのサブクラス) への" +"参照です。" -#: ../../library/asyncio-graph.rst:110 msgid "``call_stack`` is a tuple of ``FrameCallGraphEntry`` objects." -msgstr "" +msgstr "``call_stack`` は ``FrameCallGraphEntry`` オブジェクトのタプルです。" -#: ../../library/asyncio-graph.rst:112 msgid "``awaited_by`` is a tuple of ``FutureCallGraph`` objects." -msgstr "" +msgstr "``awaited_by`` は ``FutureCallGraph`` オブジェクトのタプルです。" -#: ../../library/asyncio-graph.rst:114 msgid "``FrameCallGraphEntry(frame)``" -msgstr "" +msgstr "``FrameCallGraphEntry(frame)``" -#: ../../library/asyncio-graph.rst:116 msgid "" "Where *frame* is a frame object of a regular Python function in the call " "stack." msgstr "" +"*frame* は、コールスタック内の通常の Python 関数のフレームオブジェクトです。" -#: ../../library/asyncio-graph.rst:121 msgid "Low level utility functions" -msgstr "" +msgstr "低水準の補助関数" -#: ../../library/asyncio-graph.rst:123 msgid "" "To introspect an async call graph asyncio requires cooperation from control " "flow structures, such as :func:`shield` or :class:`TaskGroup`. Any time an " @@ -192,24 +211,32 @@ msgid "" "such intermediate future objects are connected with the tasks they wrap or " "control." msgstr "" +"非同期呼び出しグラフを調べるために、asyncio は :func:`shield` や :class:" +"`TaskGroup` などの制御フローを扱う仕組みとの連携を必要とします。\n" +":meth:`Future.add_done_callback() ` のよう" +"な低水準 API を使う中間的な :class:`Future` オブジェクトが関わる場合は、次の" +"二つの関数を使ってください。\n" +"これにより、その Future が、ラップしたり制御したりするタスクとどうつながって" +"いるかを asyncio に伝えます。" -#: ../../library/asyncio-graph.rst:134 msgid "Record that *future* is awaited on by *waiter*." -msgstr "" +msgstr "*future* が *waiter* に await されていることを記録します。" -#: ../../library/asyncio-graph.rst:136 ../../library/asyncio-graph.rst:149 msgid "" "Both *future* and *waiter* must be instances of :class:`Future` or :class:" "`Task` or their subclasses, otherwise the call would have no effect." msgstr "" +"*future* と *waiter* はどちらも :class:`Future` または :class:`Task`、あるい" +"はそのサブクラスのインスタンスでなければなりません。\n" +"それ以外の場合、呼び出しても何も起こりません。" -#: ../../library/asyncio-graph.rst:140 msgid "" "A call to ``future_add_to_awaited_by()`` must be followed by an eventual " "call to the :func:`future_discard_from_awaited_by` function with the same " "arguments." msgstr "" +"``future_add_to_awaited_by()`` を呼び出した後は、いずれ同じ引数で :func:" +"`future_discard_from_awaited_by` を呼び出す必要があります。" -#: ../../library/asyncio-graph.rst:147 msgid "Record that *future* is no longer awaited on by *waiter*." -msgstr "" +msgstr "*future* が *waiter* に await されなくなったことを記録します。" diff --git a/library/asyncio-llapi-index.po b/library/asyncio-llapi-index.po index 3dae2a249..5242de58c 100644 --- a/library/asyncio-llapi-index.po +++ b/library/asyncio-llapi-index.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-llapi-index.rst:6 @@ -46,9 +46,10 @@ msgstr "実行中のイベントループを取得するために **利用が推 msgid ":func:`asyncio.get_event_loop`" msgstr ":func:`asyncio.get_event_loop`" -#: ../../library/asyncio-llapi-index.rst:22 msgid "Get an event loop instance (running or current via the current policy)." msgstr "" +"実行中のイベントループ、または現在のポリシーが返す現在のイベントループのイン" +"スタンスを取得します。" #: ../../library/asyncio-llapi-index.rst:24 msgid ":func:`asyncio.set_event_loop`" @@ -81,11 +82,10 @@ msgstr ":ref:`asyncio.get_running_loop() を使う `。" msgid "Event Loop Methods" msgstr "イベントループのメソッド" -#: ../../library/asyncio-llapi-index.rst:39 msgid "" "See also the main documentation section about the :ref:`asyncio-event-loop-" "methods`." -msgstr "" +msgstr ":ref:`asyncio-event-loop-methods` の本編も参照してください。" #: ../../library/asyncio-llapi-index.rst:42 msgid "Lifecycle" @@ -123,17 +123,15 @@ msgstr ":meth:`loop.close`" msgid "Close the event loop." msgstr "イベントループをクローズします。" -#: ../../library/asyncio-llapi-index.rst:59 msgid ":meth:`loop.is_running`" -msgstr "" +msgstr ":meth:`loop.is_running`" #: ../../library/asyncio-llapi-index.rst:60 msgid "Return ``True`` if the event loop is running." msgstr "イベントループが実行中の場合 ``True`` を返します。" -#: ../../library/asyncio-llapi-index.rst:62 msgid ":meth:`loop.is_closed`" -msgstr "" +msgstr ":meth:`loop.is_closed`" #: ../../library/asyncio-llapi-index.rst:63 msgid "Return ``True`` if the event loop is closed." @@ -175,9 +173,8 @@ msgstr "コールバックのスケジューリング" msgid ":meth:`loop.call_soon`" msgstr ":meth:`loop.call_soon`" -#: ../../library/asyncio-llapi-index.rst:87 msgid "Invoke a callback soon." -msgstr "コールバックを即座に実行します。" +msgstr "コールバックがまもなく実行されるようにスケジュールします。" #: ../../library/asyncio-llapi-index.rst:89 msgid ":meth:`loop.call_soon_threadsafe`" @@ -203,9 +200,8 @@ msgstr ":meth:`loop.call_at`" msgid "Invoke a callback *at* the given time." msgstr "*与えられた時刻に* コールバックを実行します。" -#: ../../library/asyncio-llapi-index.rst:99 msgid "Thread/Interpreter/Process Pool" -msgstr "" +msgstr "スレッド・インタープリタ・プロセスのプール" #: ../../library/asyncio-llapi-index.rst:104 msgid "``await`` :meth:`loop.run_in_executor`" @@ -394,25 +390,21 @@ msgstr ":class:`~socket.socket` からデータを受信します。" msgid "``await`` :meth:`loop.sock_recv_into`" msgstr "``await`` :meth:`loop.sock_recv_into`" -#: ../../library/asyncio-llapi-index.rst:190 msgid "Receive data from the :class:`~socket.socket` into a buffer." -msgstr ":class:`~socket.socket` からデータを受信し、バッファに送信します。" +msgstr ":class:`~socket.socket` からデータを受信し、バッファに格納します。" -#: ../../library/asyncio-llapi-index.rst:192 msgid "``await`` :meth:`loop.sock_recvfrom`" -msgstr "" +msgstr "``await`` :meth:`loop.sock_recvfrom`" -#: ../../library/asyncio-llapi-index.rst:193 msgid "Receive a datagram from the :class:`~socket.socket`." -msgstr "" +msgstr ":class:`~socket.socket` からデータグラムを受信します。" -#: ../../library/asyncio-llapi-index.rst:195 msgid "``await`` :meth:`loop.sock_recvfrom_into`" -msgstr "" +msgstr "``await`` :meth:`loop.sock_recvfrom_into`" -#: ../../library/asyncio-llapi-index.rst:196 msgid "Receive a datagram from the :class:`~socket.socket` into a buffer." msgstr "" +":class:`~socket.socket` からデータグラムを受信し、バッファに格納します。" #: ../../library/asyncio-llapi-index.rst:198 msgid "``await`` :meth:`loop.sock_sendall`" @@ -422,13 +414,13 @@ msgstr "``await`` :meth:`loop.sock_sendall`" msgid "Send data to the :class:`~socket.socket`." msgstr ":class:`~socket.socket` にデータを送信します。" -#: ../../library/asyncio-llapi-index.rst:201 msgid "``await`` :meth:`loop.sock_sendto`" -msgstr "" +msgstr "``await`` :meth:`loop.sock_sendto`" -#: ../../library/asyncio-llapi-index.rst:202 msgid "Send a datagram via the :class:`~socket.socket` to the given address." msgstr "" +":class:`~socket.socket` を通じて、指定したアドレスにデータグラムを送信しま" +"す。" #: ../../library/asyncio-llapi-index.rst:204 msgid "``await`` :meth:`loop.sock_connect`" @@ -450,9 +442,8 @@ msgstr ":class:`~socket.socket` の接続を受け入れます。" msgid "``await`` :meth:`loop.sock_sendfile`" msgstr "``await`` :meth:`loop.sock_sendfile`" -#: ../../library/asyncio-llapi-index.rst:211 msgid "Send a file over the :class:`~socket.socket`." -msgstr "Send a file over the :class:`~socket.socket`." +msgstr ":class:`~socket.socket` を通じてファイルを送信します。" #: ../../library/asyncio-llapi-index.rst:213 msgid ":meth:`loop.add_reader`" @@ -562,11 +553,12 @@ msgstr ":meth:`loop.default_exception_handler`" msgid "The default exception handler implementation." msgstr "デフォルトの例外ハンドラー実装です。" -#: ../../library/asyncio-llapi-index.rst:270 msgid "" ":ref:`Using asyncio.new_event_loop() and loop.run_forever() " "`." msgstr "" +":ref:`asyncio.new_event_loop() と loop.run_forever() を使う " +"`。" #: ../../library/asyncio-llapi-index.rst:273 msgid ":ref:`Using loop.call_later() `." @@ -702,9 +694,8 @@ msgstr "" "ドです。該当するトランスポートは :meth:`loop.create_connection`, :meth:`loop." "create_unix_connection`, :meth:`loop.connect_write_pipe` などの戻り値です:" -#: ../../library/asyncio-llapi-index.rst:339 msgid "Write Transports" -msgstr "トランスポートにデータを書き込みます。" +msgstr "書き込みトランスポート" #: ../../library/asyncio-llapi-index.rst:344 msgid ":meth:`transport.write() `" @@ -759,15 +750,15 @@ msgstr "" ":meth:`transport.get_write_buffer_size() `" -#: ../../library/asyncio-llapi-index.rst:361 msgid "Return the current size of the output buffer." -msgstr "" +msgstr "出力バッファの現在のサイズを返します。" -#: ../../library/asyncio-llapi-index.rst:363 msgid "" ":meth:`transport.get_write_buffer_limits() `" msgstr "" +":meth:`transport.get_write_buffer_limits() `" #: ../../library/asyncio-llapi-index.rst:365 msgid "Return high and low water marks for write flow control." @@ -813,9 +804,8 @@ msgstr "" "サブプロセスに対するトランスポートの低レベルな抽象化です。 :meth:`loop." "subprocess_exec` や :meth:`loop.subprocess_shell` の戻り値です:" -#: ../../library/asyncio-llapi-index.rst:390 msgid "Subprocess Transports" -msgstr "サブプロセス化されたトランスポート" +msgstr "サブプロセストランスポート" #: ../../library/asyncio-llapi-index.rst:395 msgid ":meth:`transport.get_pid() `" @@ -1002,9 +992,8 @@ msgstr "" msgid "Subprocess Protocols" msgstr "サブプロセスプロトコル" -#: ../../library/asyncio-llapi-index.rst:487 msgid "``callback`` :meth:`~SubprocessProtocol.pipe_data_received`" -msgstr "" +msgstr "``callback`` :meth:`~SubprocessProtocol.pipe_data_received`" #: ../../library/asyncio-llapi-index.rst:488 msgid "" @@ -1013,9 +1002,8 @@ msgstr "" "子プロセスが標準出力 (*stdout*) または標準エラー出力 (*stderr*) のパイプに" "データを書き込んだときに呼び出されます。" -#: ../../library/asyncio-llapi-index.rst:491 msgid "``callback`` :meth:`~SubprocessProtocol.pipe_connection_lost`" -msgstr "" +msgstr "``callback`` :meth:`~SubprocessProtocol.pipe_connection_lost`" #: ../../library/asyncio-llapi-index.rst:492 msgid "" @@ -1029,12 +1017,14 @@ msgid "" msgstr "" "``callback`` :meth:`process_exited() `" -#: ../../library/asyncio-llapi-index.rst:497 msgid "" "Called when the child process has exited. It can be called before :meth:" "`~SubprocessProtocol.pipe_data_received` and :meth:`~SubprocessProtocol." "pipe_connection_lost` methods." msgstr "" +"子プロセスが終了したときに呼び出されます。\n" +":meth:`~SubprocessProtocol.pipe_data_received` や :meth:`~SubprocessProtocol." +"pipe_connection_lost` より先に呼び出されることもあります。" #: ../../library/asyncio-llapi-index.rst:503 msgid "Event Loop Policies" diff --git a/library/asyncio-platforms.po b/library/asyncio-platforms.po index 98128dcb9..ace45d59c 100644 --- a/library/asyncio-platforms.po +++ b/library/asyncio-platforms.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-platforms.rst:9 @@ -48,12 +48,15 @@ msgstr "" ":meth:`loop.add_reader` と :meth:`loop.add_writer` をファイル I/O を監視する" "ためには使えません。" -#: ../../library/asyncio-platforms.rst:22 msgid "" ":meth:`loop.connect_read_pipe` and :meth:`loop.connect_write_pipe` cannot be " "used with regular files. See :ref:`Supported pipe objects ` for the objects that are accepted on each platform." msgstr "" +":meth:`loop.connect_read_pipe` と :meth:`loop.connect_write_pipe` は、通常の" +"ファイルには使えません。\n" +"各プラットフォームで受け付けるオブジェクトについては、:ref:`サポートされるパ" +"イプオブジェクト ` を参照してください。" #: ../../library/asyncio-platforms.rst:29 msgid "Windows" @@ -143,12 +146,15 @@ msgid "" msgstr "" ":meth:`loop.add_reader` と :meth:`loop.add_writer` はサポートされていません。" -#: ../../library/asyncio-platforms.rst:70 msgid "" ":meth:`loop.connect_read_pipe` and :meth:`loop.connect_write_pipe` only " "accept a handle opened for overlapped I/O. See :ref:`Supported pipe objects " "` for which objects are supported." msgstr "" +":meth:`loop.connect_read_pipe` と :meth:`loop.connect_write_pipe` は、オー" +"バーラップ I/O 用に開かれたハンドルだけを受け付けます。\n" +"対応するオブジェクトについては、:ref:`サポートされるパイプオブジェクト " +"` を参照してください。" #: ../../library/asyncio-platforms.rst:74 msgid "" @@ -202,7 +208,6 @@ msgstr "" "class:`~selectors.SelectSelector` または :class:`~selectors.PollSelector` を" "使うように手動で設定します。以下はその例です::" -#: ../../library/asyncio-platforms.rst:104 msgid "" "import asyncio\n" "import selectors\n" @@ -211,3 +216,9 @@ msgid "" "loop = asyncio.SelectorEventLoop(selector)\n" "asyncio.set_event_loop(loop)" msgstr "" +"import asyncio\n" +"import selectors\n" +"\n" +"selector = selectors.SelectSelector()\n" +"loop = asyncio.SelectorEventLoop(selector)\n" +"asyncio.set_event_loop(loop)" diff --git a/library/asyncio-policy.po b/library/asyncio-policy.po index 81426ea31..8283b708d 100644 --- a/library/asyncio-policy.po +++ b/library/asyncio-policy.po @@ -16,24 +16,25 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-policy.rst:8 msgid "Policies" msgstr "ポリシー" -#: ../../library/asyncio-policy.rst:12 msgid "" "Policies are deprecated and will be removed in Python 3.16. Users are " "encouraged to use the :func:`asyncio.run` function or the :class:`asyncio." "Runner` with *loop_factory* to use the desired loop implementation." msgstr "" +"ポリシーは非推奨で、Python 3.16 で削除されます。\n" +"使いたいイベントループの実装を選ぶには、:func:`asyncio.run` 関数、または :" +"class:`asyncio.Runner` に *loop_factory* を指定する方法を推奨します。" -#: ../../library/asyncio-policy.rst:18 msgid "" "An event loop policy is a global object used to get and set the current :ref:" "`event loop `, as well as create new event loops. The " @@ -42,19 +43,31 @@ msgid "" "implementations, or substituted by a :ref:`custom policy ` that can override these behaviors." msgstr "" +"イベントループポリシーは、現在の :ref:`イベントループ ` " +"の取得・設定と、新しいイベントループの作成に使うグローバルオブジェクトで" +"す。\n" +"異なるイベントループの実装を使うには、デフォルトのポリシーを :ref:`組み込みの" +"別のポリシー ` に :ref:`置き換える ` ことができます。\n" +"また、これらの動作を変更する :ref:`カスタムポリシー ` に置き換えることもできます。" -#: ../../library/asyncio-policy.rst:27 msgid "" "The :ref:`policy object ` gets and sets a separate " "event loop per *context*. This is per-thread by default, though custom " "policies could define *context* differently." msgstr "" +":ref:`ポリシーオブジェクト ` は、*コンテキスト* ごと" +"に独立したイベントループを取得・設定します。\n" +"デフォルトではスレッドごとですが、カスタムポリシーでは *コンテキスト* を別の" +"単位で定義できます。" -#: ../../library/asyncio-policy.rst:32 msgid "" "Custom event loop policies can control the behavior of :func:" "`get_event_loop`, :func:`set_event_loop`, and :func:`new_event_loop`." msgstr "" +"カスタムイベントループポリシーは、:func:`get_event_loop`、:func:" +"`set_event_loop`、:func:`new_event_loop` の動作を制御できます。" #: ../../library/asyncio-policy.rst:35 msgid "" @@ -79,11 +92,11 @@ msgstr "" msgid "Return the current process-wide policy." msgstr "プロセス全体にわたる現在のポリシーを返します。" -#: ../../library/asyncio-policy.rst:51 msgid "" "The :func:`get_event_loop_policy` function is deprecated and will be removed " "in Python 3.16." msgstr "" +":func:`get_event_loop_policy` 関数は非推奨で、Python 3.16 で削除されます。" #: ../../library/asyncio-policy.rst:57 msgid "Set the current process-wide policy to *policy*." @@ -94,11 +107,11 @@ msgid "If *policy* is set to ``None``, the default policy is restored." msgstr "" "*policy* が ``None`` の場合、デフォルトポリシーが現在のポリシーに戻されます。" -#: ../../library/asyncio-policy.rst:61 msgid "" "The :func:`set_event_loop_policy` function is deprecated and will be removed " "in Python 3.16." msgstr "" +":func:`set_event_loop_policy` 関数は非推奨で、Python 3.16 で削除されます。" #: ../../library/asyncio-policy.rst:69 msgid "Policy Objects" @@ -136,11 +149,12 @@ msgstr "現在のコンテキストにイベントループ *loop* を設定し msgid "Create and return a new event loop object." msgstr "新しいイベントループオブジェクトを生成して返します。" -#: ../../library/asyncio-policy.rst:98 msgid "" "The :class:`AbstractEventLoopPolicy` class is deprecated and will be removed " "in Python 3.16." msgstr "" +":class:`AbstractEventLoopPolicy` クラスは非推奨で、Python 3.16 で削除されま" +"す。" #: ../../library/asyncio-policy.rst:105 msgid "asyncio ships with the following built-in policies:" @@ -154,13 +168,12 @@ msgstr "" "デフォルトの asyncio ポリシーです。Unix では :class:`SelectorEventLoop` 、" "Windows では :class:`ProactorEventLoop` を使います。" -#: ../../library/asyncio-policy.rst:113 msgid "" "There is no need to install the default policy manually. asyncio is " "configured to use the default policy automatically." msgstr "" "デフォルトのポリシーを手動でインストールする必要はありません。 asyncio はデ" -"フォルトポリシーを使うように自動的に構成されます。 " +"フォルトポリシーを使うように自動的に構成されます。" #: ../../library/asyncio-policy.rst:118 msgid "On Windows, :class:`ProactorEventLoop` is now used by default." @@ -168,17 +181,19 @@ msgstr "" "Windows では :class:`ProactorEventLoop` がデフォルトで使われるようになりまし" "た。" -#: ../../library/asyncio-policy.rst:120 msgid "" "The :meth:`get_event_loop` method of the default asyncio policy now raises " "a :exc:`RuntimeError` if there is no set event loop." msgstr "" +"asyncio のデフォルトポリシーの :meth:`get_event_loop` は、イベントループが設" +"定されていなければ :exc:`RuntimeError` を送出するようになりました。" -#: ../../library/asyncio-policy.rst:124 msgid "" "The :class:`DefaultEventLoopPolicy` class is deprecated and will be removed " "in Python 3.16." msgstr "" +":class:`DefaultEventLoopPolicy` クラスは非推奨で、Python 3.16 で削除されま" +"す。" #: ../../library/asyncio-policy.rst:131 msgid "" @@ -188,15 +203,15 @@ msgstr "" ":class:`SelectorEventLoop` イベントループ実装を使った別のイベントループポリ" "シーです。" -#: ../../library/asyncio-policy.rst:134 ../../library/asyncio-policy.rst:146 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/asyncio-policy.rst:136 msgid "" "The :class:`WindowsSelectorEventLoopPolicy` class is deprecated and will be " "removed in Python 3.16." msgstr "" +":class:`WindowsSelectorEventLoopPolicy` クラスは非推奨で、Python 3.16 で削除" +"されます。" #: ../../library/asyncio-policy.rst:143 msgid "" @@ -206,11 +221,12 @@ msgstr "" ":class:`ProactorEventLoop` イベントループ実装を使った別のイベントループポリ" "シーです。" -#: ../../library/asyncio-policy.rst:148 msgid "" "The :class:`WindowsProactorEventLoopPolicy` class is deprecated and will be " "removed in Python 3.16." msgstr "" +":class:`WindowsProactorEventLoopPolicy` クラスは非推奨で、Python 3.16 で削除" +"されます。" #: ../../library/asyncio-policy.rst:156 msgid "Custom Policies" diff --git a/library/asyncio-protocol.po b/library/asyncio-protocol.po index cc3e13ccf..8f55a1139 100644 --- a/library/asyncio-protocol.po +++ b/library/asyncio-protocol.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-protocol.rst:9 @@ -339,12 +339,14 @@ msgstr "" "例えば、以下のコードはトランスポート内のソケットオブジェクトを取得しようとし" "ます::" -#: ../../library/asyncio-protocol.rst:182 msgid "" "sock = transport.get_extra_info('socket')\n" "if sock is not None:\n" " print(sock.getsockopt(...))" msgstr "" +"sock = transport.get_extra_info('socket')\n" +"if sock is not None:\n" +" print(sock.getsockopt(...))" #: ../../library/asyncio-protocol.rst:186 msgid "Categories of information that can be queried on some transports:" @@ -564,7 +566,6 @@ msgstr "" "が *low* の値以下になると :meth:`~BaseProtocol.resume_writing` メソッドが呼び" "出されます。" -#: ../../library/asyncio-protocol.rst:315 msgid "" "The defaults are implementation-specific. If only the high watermark is " "given, the low watermark defaults to an implementation-specific value less " @@ -575,13 +576,16 @@ msgid "" "Use of zero for either limit is generally sub-optimal as it reduces " "opportunities for doing I/O and computation concurrently." msgstr "" -"デフォルト値は実装固有になります。 *high* のみ与えられた場合、 *low* は " -"*high* 以下の実装固有のデフォルト値になります。 *high* をゼロに設定すると " -"*low* も強制的にゼロになり、バッファーが空でなくなるとすぐに :meth:" -"`~BaseProtocol.pause_writing` メソッドが呼び出されるようになります。 *low* を" -"ゼロに設定すると、バッファーが空にな :meth:`~BaseProtocol.resume_writing` が" -"呼び出されるようになります。どちらかにゼロを設定することは I/O と計算を並行に" -"実行する機会を減少させるため、一般に最適ではありません。" +"デフォルト値は実装固有になります。\n" +"*high* のみ与えられた場合、 *low* は *high* 以下の実装固有のデフォルト値にな" +"ります。\n" +"*high* をゼロに設定すると *low* も強制的にゼロになり、バッファーが空でなくな" +"るとすぐに :meth:`~BaseProtocol.pause_writing` メソッドが呼び出されるようにな" +"ります。\n" +"*low* をゼロに設定すると、バッファーが空になって初めて :meth:`~BaseProtocol." +"resume_writing` が呼び出されるようになります。\n" +"どちらかにゼロを設定することは I/O と計算を並行に実行する機会を減少させるた" +"め、一般に最適ではありません。" #: ../../library/asyncio-protocol.rst:326 msgid "Use :meth:`~WriteTransport.get_write_buffer_limits` to get the limits." @@ -665,9 +669,8 @@ msgstr "" "` メソッドが引数 :const:`None` で呼び出されま" "す。" -#: ../../library/asyncio-protocol.rst:382 msgid "Subprocess Transports" -msgstr "サブプロセス化されたトランスポート" +msgstr "サブプロセストランスポート" #: ../../library/asyncio-protocol.rst:386 msgid "Return the subprocess process id as an integer." @@ -680,23 +683,27 @@ msgid "" msgstr "" "整数のファイル記述子 *fd* に該当する通信パイプのトランスポートを返します:" -#: ../../library/asyncio-protocol.rst:393 msgid "" "``0``: writable streaming transport of the standard input (*stdin*), or :" "const:`None` if the subprocess was not created with ``stdin=PIPE``" msgstr "" +"``0``: 標準入力 (*stdin*) の書き込み可能なストリーミングトランスポート。\n" +"サブプロセスの作成時に ``stdin=PIPE`` を指定していなければ :const:`None`。" -#: ../../library/asyncio-protocol.rst:395 msgid "" "``1``: readable streaming transport of the standard output (*stdout*), or :" "const:`None` if the subprocess was not created with ``stdout=PIPE``" msgstr "" +"``1``: 標準出力 (*stdout*) の読み込み可能なストリーミングトランスポート。\n" +"サブプロセスの作成時に ``stdout=PIPE`` を指定していなければ :const:`None`。" -#: ../../library/asyncio-protocol.rst:397 msgid "" "``2``: readable streaming transport of the standard error (*stderr*), or :" "const:`None` if the subprocess was not created with ``stderr=PIPE``" msgstr "" +"``2``: 標準エラー出力 (*stderr*) の読み込み可能なストリーミングトランスポー" +"ト。\n" +"サブプロセスの作成時に ``stderr=PIPE`` を指定していなければ :const:`None`。" #: ../../library/asyncio-protocol.rst:399 msgid "other *fd*: :const:`None`" @@ -847,15 +854,15 @@ msgstr "" msgid "Connection Callbacks" msgstr "通信のコールバック" -#: ../../library/asyncio-protocol.rst:492 msgid "" "Connection callbacks are called on all protocols, exactly once per a " "successful connection. All other protocol callbacks can only be called " "between those two methods." msgstr "" -"コネクションコールバックは全てのプロトコルから、成功したコネクションそれぞれ" -"につきただ一度だけ呼び出されます。その他の全てのプロトコルコールバックはこれ" -"ら2つのメソッドの間に呼び出すことができます。 " +"コネクションコールバックはすべてのプロトコルに対して、成功した接続ごとにそれ" +"ぞれ一度だけ呼び出されます。\n" +"他のプロトコルコールバックは、これら二つのメソッドの呼び出しの間にのみ呼び出" +"されます。" #: ../../library/asyncio-protocol.rst:498 msgid "Called when a connection is made." @@ -879,9 +886,9 @@ msgid "" "means a regular EOF is received, or the connection was aborted or closed by " "this side of the connection." msgstr "" -"引数は例外オブジェクトまたは :const:`None` になります。:const:`None` のとき、" -"通常の EOF が受信されたか、あるいはコネクションがこちら側から中止またはクロー" -"ズされたことを意味します。" +"引数は例外オブジェクトまたは :const:`None` になります。 ``None`` のとき、通常" +"の EOF が受信されたか、あるいはコネクションがこちら側から中止またはクローズさ" +"れたことを意味します。" #: ../../library/asyncio-protocol.rst:514 msgid "Flow Control Callbacks" @@ -924,16 +931,15 @@ msgstr "" "pause_writing` は呼び出されません: バッファーサイズは必ず制限値を超えなければ" "なりません。" -#: ../../library/asyncio-protocol.rst:533 msgid "" "Conversely, :meth:`~BaseProtocol.resume_writing` is called when the buffer " "size is equal or lower than the low watermark. These end conditions are " "important to ensure that things go as expected when either mark is zero." msgstr "" "それに対して、 :meth:`~BaseProtocol.resume_writing` はバッファーサイズが最低" -"水位点と等しいかそれよりも小さい場合に呼び出されます。これらの境界条件は、ど" -"ちらの基準値もゼロである場合の処理が期待通りとなることを保証するために重要で" -"す。" +"水位点と等しいかそれよりも小さい場合に呼び出されます。\n" +"これらの境界条件は、どちらかの基準値がゼロである場合の処理が期待通りとなるこ" +"とを保証するために重要です。" #: ../../library/asyncio-protocol.rst:540 msgid "Streaming Protocols" @@ -1028,13 +1034,16 @@ msgstr "" msgid "State machine:" msgstr "ステートマシン:" -#: ../../library/asyncio-protocol.rst:585 msgid "" "start -> connection_made\n" " [-> data_received]*\n" " [-> eof_received]?\n" "-> connection_lost -> end" msgstr "" +"start -> connection_made\n" +" [-> data_received]*\n" +" [-> eof_received]?\n" +"-> connection_lost -> end" #: ../../library/asyncio-protocol.rst:594 msgid "Buffered Streaming Protocols" @@ -1124,7 +1133,6 @@ msgstr "" "`~BufferedProtocol.get_buffer` と :meth:`~BufferedProtocol.buffer_updated` が" "呼び出されることはありません。" -#: ../../library/asyncio-protocol.rst:643 msgid "" "start -> connection_made\n" " [-> get_buffer\n" @@ -1133,6 +1141,12 @@ msgid "" " [-> eof_received]?\n" "-> connection_lost -> end" msgstr "" +"start -> connection_made\n" +" [-> get_buffer\n" +" [-> buffer_updated]?\n" +" ]*\n" +" [-> eof_received]?\n" +"-> connection_lost -> end" #: ../../library/asyncio-protocol.rst:654 msgid "Datagram Protocols" @@ -1175,15 +1189,15 @@ msgstr "" "どの場合、データグラムが配信できなければそのまま通知されることなく破棄されま" "す。" -#: ../../library/asyncio-protocol.rst:677 msgid "" "On BSD systems (macOS, FreeBSD, etc.) flow control is not supported for " "datagram protocols, because there is no reliable way to detect send failures " "caused by writing too many packets." msgstr "" -"BSD システム (macOS, FreeBSD など) ではフロー制御はサポートされていません。こ" -"れは非常に多くのパケットを書き込もうとしたことによる送信の失敗を検出する信頼" -"できる方法が存在しないためです。" +"BSD システム (macOS, FreeBSD など) ではデータグラムプロトコルのフロー制御はサ" +"ポートされていません。\n" +"これは非常に多くのパケットを書き込もうとしたことによる送信の失敗を検出する信" +"頼できる方法が存在しないためです。" #: ../../library/asyncio-protocol.rst:681 msgid "" @@ -1241,14 +1255,12 @@ msgstr "*fd* はクローズされたファイル記述子を表す整数です msgid "Called when the child process has exited." msgstr "子プロセスが終了したときに呼び出されます。" -#: ../../library/asyncio-protocol.rst:716 msgid "" "It can be called before :meth:`~SubprocessProtocol.pipe_data_received` and :" "meth:`~SubprocessProtocol.pipe_connection_lost` methods." msgstr "" -"これは、 :meth:`~SubprocessProtocol.pipe_data_received` と :meth:" -"`~SubprocessProtocol.pipe_connection_lost` メソッドの前に呼び出すことができま" -"す。" +":meth:`~SubprocessProtocol.pipe_data_received` や :meth:`~SubprocessProtocol." +"pipe_connection_lost` より先に呼び出されることもあります。" #: ../../library/asyncio-protocol.rst:721 msgid "Examples" @@ -1266,7 +1278,6 @@ msgstr "" ":meth:`loop.create_server` メソッドを使って TCP エコーサーバーを生成し、受信" "したデータをそのまま送り返して、最後にコネクションをクローズします::" -#: ../../library/asyncio-protocol.rst:731 msgid "" "import asyncio\n" "\n" @@ -1303,6 +1314,39 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"\n" +"class EchoServerProtocol(asyncio.Protocol):\n" +" def connection_made(self, transport):\n" +" peername = transport.get_extra_info('peername')\n" +" print('Connection from {}'.format(peername))\n" +" self.transport = transport\n" +"\n" +" def data_received(self, data):\n" +" message = data.decode()\n" +" print('Data received: {!r}'.format(message))\n" +"\n" +" print('Send: {!r}'.format(message))\n" +" self.transport.write(data)\n" +"\n" +" print('Close the client socket')\n" +" self.transport.close()\n" +"\n" +"\n" +"async def main():\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" server = await loop.create_server(\n" +" EchoServerProtocol,\n" +" '127.0.0.1', 8888)\n" +"\n" +" async with server:\n" +" await server.serve_forever()\n" +"\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-protocol.rst:769 msgid "" @@ -1324,7 +1368,6 @@ msgstr "" ":meth:`loop.create_connection` メソッドを使った TCP エコークライアントは、" "データを送信したあとコネクションがクローズされるまで待機します::" -#: ../../library/asyncio-protocol.rst:780 msgid "" "import asyncio\n" "\n" @@ -1368,6 +1411,46 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"\n" +"class EchoClientProtocol(asyncio.Protocol):\n" +" def __init__(self, message, on_con_lost):\n" +" self.message = message\n" +" self.on_con_lost = on_con_lost\n" +"\n" +" def connection_made(self, transport):\n" +" transport.write(self.message.encode())\n" +" print('Data sent: {!r}'.format(self.message))\n" +"\n" +" def data_received(self, data):\n" +" print('Data received: {!r}'.format(data.decode()))\n" +"\n" +" def connection_lost(self, exc):\n" +" print('The server closed the connection')\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" on_con_lost = loop.create_future()\n" +" message = 'Hello World!'\n" +"\n" +" transport, protocol = await loop.create_connection(\n" +" lambda: EchoClientProtocol(message, on_con_lost),\n" +" '127.0.0.1', 8888)\n" +"\n" +" # プロトコルが接続の切断を通知するまで待ち、\n" +" # トランスポートを閉じる。\n" +" try:\n" +" await on_con_lost\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-protocol.rst:825 msgid "" @@ -1390,7 +1473,6 @@ msgstr "" ":meth:`loop.create_datagram_endpoint` メソッドを使った UDP エコーサーバーは受" "信したデータをそのまま送り返します::" -#: ../../library/asyncio-protocol.rst:837 msgid "" "import asyncio\n" "\n" @@ -1427,6 +1509,39 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"\n" +"class EchoServerProtocol:\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +"\n" +" def datagram_received(self, data, addr):\n" +" message = data.decode()\n" +" print('Received %r from %s' % (message, addr))\n" +" print('Send %r to %s' % (message, addr))\n" +" self.transport.sendto(data, addr)\n" +"\n" +"\n" +"async def main():\n" +" print(\"Starting UDP server\")\n" +"\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # 一つのプロトコルインスタンスで、\n" +" # すべてのクライアント要求を処理する。\n" +" transport, protocol = await loop.create_datagram_endpoint(\n" +" EchoServerProtocol,\n" +" local_addr=('127.0.0.1', 9999))\n" +"\n" +" try:\n" +" await asyncio.sleep(3600) # 1 時間処理を続ける。\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-protocol.rst:876 msgid "UDP Echo Client" @@ -1440,7 +1555,6 @@ msgstr "" ":meth:`loop.create_datagram_endpoint` メソッドを使った UDP エコークライアント" "はデータを送信し、応答を受信するとトランスポートをクローズします::" -#: ../../library/asyncio-protocol.rst:881 msgid "" "import asyncio\n" "\n" @@ -1490,6 +1604,52 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"\n" +"class EchoClientProtocol:\n" +" def __init__(self, message, on_con_lost):\n" +" self.message = message\n" +" self.on_con_lost = on_con_lost\n" +" self.transport = None\n" +"\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +" print('Send:', self.message)\n" +" self.transport.sendto(self.message.encode())\n" +"\n" +" def datagram_received(self, data, addr):\n" +" print(\"Received:\", data.decode())\n" +"\n" +" print(\"Close the socket\")\n" +" self.transport.close()\n" +"\n" +" def error_received(self, exc):\n" +" print('Error received:', exc)\n" +"\n" +" def connection_lost(self, exc):\n" +" print(\"Connection closed\")\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" on_con_lost = loop.create_future()\n" +" message = \"Hello World!\"\n" +"\n" +" transport, protocol = await loop.create_datagram_endpoint(\n" +" lambda: EchoClientProtocol(message, on_con_lost),\n" +" remote_addr=('127.0.0.1', 9999))\n" +"\n" +" try:\n" +" await on_con_lost\n" +" finally:\n" +" transport.close()\n" +"\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-protocol.rst:933 msgid "Connecting Existing Sockets" @@ -1503,7 +1663,6 @@ msgstr "" "プロトコルを設定した :meth:`loop.create_connection` メソッドを使ってソケット" "がデータを受信するまで待機します::" -#: ../../library/asyncio-protocol.rst:938 msgid "" "import asyncio\n" "import socket\n" @@ -1554,6 +1713,53 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import socket\n" +"\n" +"\n" +"class MyProtocol(asyncio.Protocol):\n" +"\n" +" def __init__(self, on_con_lost):\n" +" self.transport = None\n" +" self.on_con_lost = on_con_lost\n" +"\n" +" def connection_made(self, transport):\n" +" self.transport = transport\n" +"\n" +" def data_received(self, data):\n" +" print(\"Received:\", data.decode())\n" +"\n" +" # 処理が済んだのでトランスポートを閉じる。\n" +" # connection_lost() は自動的に呼び出される。\n" +" self.transport.close()\n" +"\n" +" def connection_lost(self, exc):\n" +" # ソケットが閉じられた\n" +" self.on_con_lost.set_result(True)\n" +"\n" +"\n" +"async def main():\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +" on_con_lost = loop.create_future()\n" +"\n" +" # 接続されたソケットのペアを作成する\n" +" rsock, wsock = socket.socketpair()\n" +"\n" +" # データを待ち受けるためにソケットを登録する。\n" +" transport, protocol = await loop.create_connection(\n" +" lambda: MyProtocol(on_con_lost), sock=rsock)\n" +"\n" +" # ネットワークからのデータ受信を模倣する。\n" +" loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +" try:\n" +" await protocol.on_con_lost\n" +" finally:\n" +" transport.close()\n" +" wsock.close()\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-protocol.rst:989 msgid "" @@ -1592,7 +1798,6 @@ msgid "The subprocess is created by the :meth:`loop.subprocess_exec` method::" msgstr "" "サブプロセスは :meth:`loop.subprocess_exec` メソッドにより生成されます::" -#: ../../library/asyncio-protocol.rst:1007 msgid "" "import asyncio\n" "import sys\n" @@ -1652,6 +1857,61 @@ msgid "" "date = asyncio.run(get_date())\n" "print(f\"Current date: {date}\")" msgstr "" +"import asyncio\n" +"import sys\n" +"\n" +"class DateProtocol(asyncio.SubprocessProtocol):\n" +" def __init__(self, exit_future):\n" +" self.exit_future = exit_future\n" +" self.output = bytearray()\n" +" self.pipe_closed = False\n" +" self.exited = False\n" +"\n" +" def pipe_connection_lost(self, fd, exc):\n" +" self.pipe_closed = True\n" +" self.check_for_exit()\n" +"\n" +" def pipe_data_received(self, fd, data):\n" +" self.output.extend(data)\n" +"\n" +" def process_exited(self):\n" +" self.exited = True\n" +" # process_exited() は pipe_connection_lost() より先に\n" +" # 呼び出されることがあるので、両方が呼び出されるまで待つ。\n" +" self.check_for_exit()\n" +"\n" +" def check_for_exit(self):\n" +" if self.pipe_closed and self.exited:\n" +" self.exit_future.set_result(True)\n" +"\n" +"async def get_date():\n" +" # 低水準 API を使うため、イベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" code = 'import datetime as dt; print(dt.datetime.now())'\n" +" exit_future = asyncio.Future(loop=loop)\n" +"\n" +" # DateProtocol で制御するサブプロセスを作成し、\n" +" # 標準出力をパイプにリダイレクトする。\n" +" transport, protocol = await loop.subprocess_exec(\n" +" lambda: DateProtocol(exit_future),\n" +" sys.executable, '-c', code,\n" +" stdin=None, stderr=None)\n" +"\n" +" # プロトコルの process_exited() メソッドを使って、\n" +" # サブプロセスの終了を待つ。\n" +" await exit_future\n" +"\n" +" # 標準出力のパイプを閉じる。\n" +" transport.close()\n" +"\n" +" # プロトコルの pipe_data_received() メソッドが\n" +" # 集めた出力を読み出す。\n" +" data = bytes(protocol.output)\n" +" return data.decode('ascii').rstrip()\n" +"\n" +"date = asyncio.run(get_date())\n" +"print(f\"Current date: {date}\")" #: ../../library/asyncio-protocol.rst:1065 msgid "" diff --git a/library/asyncio-queue.po b/library/asyncio-queue.po index 9ea485f0f..c3f06da09 100644 --- a/library/asyncio-queue.po +++ b/library/asyncio-queue.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-queue.rst:7 @@ -101,11 +101,12 @@ msgstr "キューが空ならば ``True`` を、そうでなければ ``False`` msgid "Return ``True`` if there are :attr:`maxsize` items in the queue." msgstr "キューに要素が :attr:`maxsize` 個あれば ``True`` を返します。" -#: ../../library/asyncio-queue.rst:57 msgid "" "If the queue was initialized with ``maxsize=0`` (the default), then :meth:" "`full` never returns ``True``." msgstr "" +"``maxsize=0`` (デフォルト) で初期化したキューでは、:meth:`full` が ``True`` " +"を返すことはありません。" #: ../../library/asyncio-queue.rst:63 msgid "" @@ -115,23 +116,23 @@ msgstr "" "キューから要素を削除して返します。キューが空の場合項目が利用可能になるまで待" "機します。" -#: ../../library/asyncio-queue.rst:66 msgid "" "Raises :exc:`QueueShutDown` if the queue has been shut down and is empty, or " "if the queue has been shut down immediately." msgstr "" +"キューがシャットダウン済みで空の場合、または即時シャットダウンされた場合は、:" +"exc:`QueueShutDown` を送出します。" -#: ../../library/asyncio-queue.rst:71 msgid "" "Return an item if one is immediately available, else raise :exc:`QueueEmpty`." msgstr "" -"直ちに利用できるアイテムがあるときはそれを、そうでなければ :exc:`QueueEmpty` " -"を返します。" +"直ちに利用できる要素がある場合はその要素を返し、そうでなければ :exc:" +"`QueueEmpty` を送出します。" -#: ../../library/asyncio-queue.rst:74 msgid "" "Raises :exc:`QueueShutDown` if the queue has been shut down and is empty." msgstr "" +"キューがシャットダウン済みで空の場合、:exc:`QueueShutDown` を送出します。" #: ../../library/asyncio-queue.rst:79 msgid "Block until all items in the queue have been received and processed." @@ -158,9 +159,8 @@ msgstr "" "要素をキューに入力します。キューが満杯の場合、要素を追加する前に空きスロット" "が利用できるようになるまで待機します。" -#: ../../library/asyncio-queue.rst:93 ../../library/asyncio-queue.rst:101 msgid "Raises :exc:`QueueShutDown` if the queue has been shut down." -msgstr "" +msgstr "キューがシャットダウン済みの場合、:exc:`QueueShutDown` を送出します。" #: ../../library/asyncio-queue.rst:97 msgid "Put an item into the queue without blocking." @@ -174,36 +174,40 @@ msgstr "直ちに利用できるスロットがない場合、:exc:`QueueFull` msgid "Return the number of items in the queue." msgstr "キュー内の要素数を返します。" -#: ../../library/asyncio-queue.rst:109 msgid "Put a :class:`Queue` instance into a shutdown mode." -msgstr "" +msgstr ":class:`Queue` インスタンスをシャットダウンモードにします。" -#: ../../library/asyncio-queue.rst:111 msgid "" "The queue can no longer grow. Future calls to :meth:`~Queue.put` raise :exc:" "`QueueShutDown`. Currently blocked callers of :meth:`~Queue.put` will be " "unblocked and will raise :exc:`QueueShutDown` in the formerly awaiting task." msgstr "" +"以後、キューに要素を追加できなくなります。\n" +":meth:`~Queue.put` を呼び出すと :exc:`QueueShutDown` を送出します。\n" +"すでに :meth:`~Queue.put` でブロックしている呼び出し元もブロックを解除され、" +"待機していたタスク内で :exc:`QueueShutDown` が送出されます。" -#: ../../library/asyncio-queue.rst:116 msgid "" "If *immediate* is false (the default), the queue can be wound down normally " "with :meth:`~Queue.get` calls to extract tasks that have already been loaded." msgstr "" +"*immediate* が偽 (デフォルト) の場合、:meth:`~Queue.get` で格納済みのタスクを" +"取り出し、通常の手順で処理を進めてキューを終了できます。" -#: ../../library/asyncio-queue.rst:120 msgid "" "And if :meth:`~Queue.task_done` is called for each remaining task, a " "pending :meth:`~Queue.join` will be unblocked normally." msgstr "" +"残っている各タスクに対して :meth:`~Queue.task_done` を呼び出せば、待機中の :" +"meth:`~Queue.join` のブロックは通常どおり解除されます。" -#: ../../library/asyncio-queue.rst:123 msgid "" "Once the queue is empty, future calls to :meth:`~Queue.get` will raise :exc:" "`QueueShutDown`." msgstr "" +"キューが空になると、以後の :meth:`~Queue.get` は :exc:`QueueShutDown` を送出" +"します。" -#: ../../library/asyncio-queue.rst:126 msgid "" "If *immediate* is true, the queue is terminated immediately. The queue is " "drained to be completely empty and the count of unfinished tasks is reduced " @@ -212,24 +216,35 @@ msgid "" "get` are unblocked and will raise :exc:`QueueShutDown` because the queue is " "empty." msgstr "" +"*immediate* が真の場合、キューを即座に終了します。\n" +"キューからすべての要素を取り除いて空にし、取り除いたタスクの数だけ未完了タス" +"ク数を減らします。\n" +"未完了タスク数がゼロになると、:meth:`~Queue.join` の呼び出し元のブロックを解" +"除します。\n" +"また、:meth:`~Queue.get` でブロックしている呼び出し元もブロックを解除されます" +"が、キューが空なので :exc:`QueueShutDown` が送出されます。" -#: ../../library/asyncio-queue.rst:134 msgid "" "Use caution when using :meth:`~Queue.join` with *immediate* set to true. " "This unblocks the join even when no work has been done on the tasks, " "violating the usual invariant for joining a queue." msgstr "" +"*immediate* を真に設定するときは、:meth:`~Queue.join` の使用に注意してくださ" +"い。\n" +"タスクが処理されていなくても ``join()`` のブロックが解除され、キューの完了待" +"機で通常成り立つ不変条件が破られます。" -#: ../../library/asyncio-queue.rst:142 msgid "Indicate that a formerly enqueued work item is complete." -msgstr "" +msgstr "キューに投入されていた作業項目の処理が完了したことを通知します。" -#: ../../library/asyncio-queue.rst:144 msgid "" "Used by queue consumers. For each :meth:`~Queue.get` used to fetch a work " "item, a subsequent call to :meth:`task_done` tells the queue that the " "processing on the work item is complete." msgstr "" +"キューから作業を取り出す側が使います。\n" +":meth:`~Queue.get` で作業項目を取り出すたびに、処理後に :meth:`task_done` を" +"呼び出して、作業が完了したことをキューに伝えます。" #: ../../library/asyncio-queue.rst:148 msgid "" @@ -241,25 +256,21 @@ msgstr "" "`~Queue.put` でキューに追加された全アイテムの :meth:`task_done` の呼び出しを" "受信したとき) に再開します。" -#: ../../library/asyncio-queue.rst:153 msgid "" "Raises :exc:`ValueError` if called more times than there were items placed " "in the queue." msgstr "" -"キューに追加されているアイテム数以上の呼び出しが行われたときに :exc:" -"`ValueError` を送出します。" +"呼び出し回数がキューに追加されたアイテムの総数を超えると :exc:`ValueError` を" +"送出します。" #: ../../library/asyncio-queue.rst:158 msgid "Priority Queue" msgstr "優先度付きのキュー" -#: ../../library/asyncio-queue.rst:162 msgid "" "A variant of :class:`Queue`; retrieves entries in priority order (lowest " "first)." -msgstr "" -":class:`Queue` の変種です; 優先順位にしたがって要素を取り出します (最低順位が" -"最初に取り出されます)。" +msgstr ":class:`Queue` の一種で、優先度の値が小さい要素から取り出します。" #: ../../library/asyncio-queue.rst:165 msgid "Entries are typically tuples of the form ``(priority_number, data)``." @@ -297,12 +308,14 @@ msgstr "" "サイズが *maxsize* に達したキューに対して :meth:`~Queue.put_nowait` メソッド" "が 呼ばれたときに送出される例外です。" -#: ../../library/asyncio-queue.rst:195 msgid "" "Exception raised when :meth:`~Queue.put`, :meth:`~Queue.put_nowait`, :meth:" "`~Queue.get` or :meth:`~Queue.get_nowait` is called on a queue which has " "been shut down." msgstr "" +"シャットダウン済みのキューに対して :meth:`~Queue.put`、:meth:`~Queue." +"put_nowait`、:meth:`~Queue.get`、:meth:`~Queue.get_nowait` を呼び出したときに" +"送出される例外です。" #: ../../library/asyncio-queue.rst:203 msgid "Examples" @@ -315,7 +328,6 @@ msgstr "" "キューを使って、並行処理を行う複数のタスクにワークロードを分散させることがで" "きます::" -#: ../../library/asyncio-queue.rst:210 msgid "" "import asyncio\n" "import random\n" @@ -371,3 +383,56 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import random\n" +"import time\n" +"\n" +"\n" +"async def worker(name, queue):\n" +" while True:\n" +" # キューから作業項目を取り出す。\n" +" sleep_for = await queue.get()\n" +"\n" +" # sleep_for 秒スリープする。\n" +" await asyncio.sleep(sleep_for)\n" +"\n" +" # 作業項目の処理が完了したことをキューに通知する。\n" +" queue.task_done()\n" +"\n" +" print(f'{name} has slept for {sleep_for:.2f} seconds')\n" +"\n" +"\n" +"async def main():\n" +" # 作業を格納するキューを作成する。\n" +" queue = asyncio.Queue()\n" +"\n" +" # ランダムな待ち時間を生成してキューに追加する。\n" +" total_sleep_time = 0\n" +" for _ in range(20):\n" +" sleep_for = random.uniform(0.05, 1.0)\n" +" total_sleep_time += sleep_for\n" +" queue.put_nowait(sleep_for)\n" +"\n" +" # キューを並行して処理する三つのワーカータスクを作成する。\n" +" tasks = []\n" +" for i in range(3):\n" +" task = asyncio.create_task(worker(f'worker-{i}', queue))\n" +" tasks.append(task)\n" +"\n" +" # キューの全項目の処理が完了するまで待つ。\n" +" started_at = time.monotonic()\n" +" await queue.join()\n" +" total_slept_for = time.monotonic() - started_at\n" +"\n" +" # ワーカータスクをキャンセルする。\n" +" for task in tasks:\n" +" task.cancel()\n" +" # すべてのワーカータスクのキャンセルが完了するまで待つ。\n" +" await asyncio.gather(*tasks, return_exceptions=True)\n" +"\n" +" print('====')\n" +" print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds')\n" +" print(f'total expected sleep time: {total_sleep_time:.2f} seconds')\n" +"\n" +"\n" +"asyncio.run(main())" diff --git a/library/asyncio-runner.po b/library/asyncio-runner.po index 9c35e3335..a333a142d 100644 --- a/library/asyncio-runner.po +++ b/library/asyncio-runner.po @@ -17,15 +17,14 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-runner.rst:6 msgid "Runners" -msgstr "" +msgstr "Runner" #: ../../library/asyncio-runner.rst:8 msgid "**Source code:** :source:`Lib/asyncio/runners.py`" @@ -51,19 +50,18 @@ msgstr "" msgid "Running an asyncio Program" msgstr "非同期プログラムの実行" -#: ../../library/asyncio-runner.rst:27 msgid "Execute *coro* in an asyncio event loop and return the result." -msgstr "" +msgstr "asyncio のイベントループで *coro* を実行し、その結果を返します。" -#: ../../library/asyncio-runner.rst:29 ../../library/asyncio-runner.rst:121 msgid "The argument can be any awaitable object." -msgstr "" +msgstr "引数には任意の awaitable オブジェクトを指定できます。" -#: ../../library/asyncio-runner.rst:31 msgid "" "This function runs the awaitable, taking care of managing the asyncio event " "loop, *finalizing asynchronous generators*, and closing the executor." msgstr "" +"この関数は awaitable を実行し、asyncio のイベントループの管理、*非同期ジェネ" +"レーターの終了処理*、Executor の終了処理を行います。" #: ../../library/asyncio-runner.rst:35 ../../library/asyncio-runner.rst:131 msgid "" @@ -83,7 +81,6 @@ msgstr "" "``False`` は明示的にデバッグモードを無効化します。 グローバルな :ref:" "`asyncio-debug-mode` 設定を尊重するために ``None`` が使用されます。" -#: ../../library/asyncio-runner.rst:42 msgid "" "If *loop_factory* is not ``None``, it is used to create a new event loop; " "otherwise :func:`asyncio.new_event_loop` is used. The loop is closed at the " @@ -92,19 +89,29 @@ msgid "" "*loop_factory* to configure the event loop instead of policies. Passing :" "class:`asyncio.EventLoop` allows running asyncio without the policy system." msgstr "" +"*loop_factory* が ``None`` でなければ、それを使って新しいイベントループを作成" +"します。\n" +"それ以外の場合は :func:`asyncio.new_event_loop` を使います。\n" +"終了時にループを閉じます。\n" +"この関数は asyncio プログラムのメインのエントリーポイントとして使い、できれば" +"一度だけ呼び出してください。\n" +"イベントループの設定には、ポリシーの代わりに *loop_factory* を使うことを推奨" +"します。\n" +":class:`asyncio.EventLoop` を渡すと、ポリシーシステムを使わずに asyncio を実" +"行できます。" -#: ../../library/asyncio-runner.rst:50 msgid "" "The executor is given a timeout duration of 5 minutes to shutdown. If the " "executor hasn't finished within that duration, a warning is emitted and the " "executor is closed." msgstr "" +"Executor の終了を待つ制限時間は 5 分です。\n" +"その時間内に終了しなければ、警告を出して Executor の終了処理を行います。" #: ../../library/asyncio-runner.rst:54 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/asyncio-runner.rst:56 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -112,6 +119,11 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"async def main():\n" +" await asyncio.sleep(1)\n" +" print('hello')\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-runner.rst:64 msgid "Updated to use :meth:`loop.shutdown_default_executor`." @@ -129,20 +141,20 @@ msgstr "" msgid "Added *loop_factory* parameter." msgstr "*loop_factory* 引数が追加されました。" -#: ../../library/asyncio-runner.rst:77 ../../library/asyncio-runner.rst:136 msgid "*coro* can be any awaitable object." -msgstr "" +msgstr "*coro* に任意の awaitable オブジェクトを指定できるようになりました。" -#: ../../library/asyncio-runner.rst:81 msgid "" "The :mod:`!asyncio` policy system is deprecated and will be removed in " "Python 3.16; from there on, an explicit *loop_factory* is needed to " "configure the event loop." msgstr "" +":mod:`!asyncio` のポリシーシステムは非推奨で、Python 3.16 で削除されます。\n" +"それ以降、イベントループを設定するには *loop_factory* を明示的に指定する必要" +"があります。" -#: ../../library/asyncio-runner.rst:87 msgid "Runner context manager" -msgstr "" +msgstr "Runner コンテキストマネージャー" #: ../../library/asyncio-runner.rst:91 msgid "" @@ -152,27 +164,31 @@ msgstr "" "同じコンテキスト上での *複数* の非同期関数呼び出しをシンプルにするコンテキス" "トマネージャ。" -#: ../../library/asyncio-runner.rst:94 msgid "" "Sometimes several top-level async functions should be called in the same :" "ref:`event loop ` and :class:`contextvars.Context`." msgstr "" +"複数のトップレベルの非同期関数を、同じ :ref:`イベントループ ` と :class:`contextvars.Context` で呼び出したい場合があります。" -#: ../../library/asyncio-runner.rst:101 msgid "" "*loop_factory* could be used for overriding the loop creation. It is the " "responsibility of the *loop_factory* to set the created loop as the current " "one. By default :func:`asyncio.new_event_loop` is used and set as current " "event loop with :func:`asyncio.set_event_loop` if *loop_factory* is ``None``." msgstr "" +"*loop_factory* で、ループの作成方法を変更できます。\n" +"作成したループを現在のループとして設定するのは *loop_factory* の役割です。\n" +"*loop_factory* が ``None`` の場合は、デフォルトで :func:`asyncio." +"new_event_loop` を使い、:func:`asyncio.set_event_loop` で現在のイベントループ" +"に設定します。" -#: ../../library/asyncio-runner.rst:106 msgid "" "Basically, :func:`asyncio.run` example can be rewritten with the runner " "usage::" msgstr "" +":func:`asyncio.run` の例は、Runner を使って次のように書き換えられます。 ::" -#: ../../library/asyncio-runner.rst:108 msgid "" "async def main():\n" " await asyncio.sleep(1)\n" @@ -181,84 +197,95 @@ msgid "" "with asyncio.Runner() as runner:\n" " runner.run(main())" msgstr "" +"async def main():\n" +" await asyncio.sleep(1)\n" +" print('hello')\n" +"\n" +"with asyncio.Runner() as runner:\n" +" runner.run(main())" -#: ../../library/asyncio-runner.rst:119 msgid "Execute *coro* in the embedded event loop." -msgstr "" +msgstr "内部のイベントループで *coro* を実行します。" -#: ../../library/asyncio-runner.rst:123 msgid "If the argument is a coroutine, it is wrapped in a Task." -msgstr "" +msgstr "引数がコルーチンの場合、Task でラップします。" -#: ../../library/asyncio-runner.rst:125 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the code to run in. The runner's default " "context is used if context is ``None``." msgstr "" +"省略可能なキーワード専用引数 *context* には、コードの実行に使う :class:" +"`contextvars.Context` を指定できます。\n" +"``context`` が ``None`` の場合は、Runner のデフォルトのコンテキストを使いま" +"す。" -#: ../../library/asyncio-runner.rst:129 msgid "Returns the awaitable's result or raises an exception." -msgstr "" +msgstr "awaitable の結果を返すか、例外を送出します。" -#: ../../library/asyncio-runner.rst:140 msgid "Close the runner." -msgstr "" +msgstr "Runner を閉じます。" -#: ../../library/asyncio-runner.rst:142 msgid "" "Finalize asynchronous generators, shutdown default executor, close the event " "loop and release embedded :class:`contextvars.Context`." msgstr "" +"非同期ジェネレーターの終了処理を行い、デフォルトの Executor とイベントループ" +"を閉じ、内部の :class:`contextvars.Context` を解放します。" -#: ../../library/asyncio-runner.rst:147 msgid "Return the event loop associated with the runner instance." -msgstr "" +msgstr "Runner インスタンスに関連付けられたイベントループを返します。" -#: ../../library/asyncio-runner.rst:151 msgid "" ":class:`Runner` uses the lazy initialization strategy, its constructor " "doesn't initialize underlying low-level structures." msgstr "" +":class:`Runner` は遅延初期化を採用しており、コンストラクターでは内部の低水準" +"なデータ構造を初期化しません。" -#: ../../library/asyncio-runner.rst:154 msgid "" "Embedded *loop* and *context* are created at the :keyword:`with` body " "entering or the first call of :meth:`run` or :meth:`get_loop`." msgstr "" +"内部の *loop* と *context* は、:keyword:`with` 文の本体に入るとき、または :" +"meth:`run` か :meth:`get_loop` を初めて呼び出すときに作成されます。" -#: ../../library/asyncio-runner.rst:159 msgid "Handling Keyboard Interruption" -msgstr "" +msgstr "キーボード割り込みの処理" -#: ../../library/asyncio-runner.rst:163 msgid "" "When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, :exc:" "`KeyboardInterrupt` exception is raised in the main thread by default. " "However this doesn't work with :mod:`asyncio` because it can interrupt " "asyncio internals and can hang the program from exiting." msgstr "" +":kbd:`Ctrl-C` で :const:`signal.SIGINT` が発生すると、デフォルトではメインス" +"レッドで :exc:`KeyboardInterrupt` が送出されます。\n" +"しかし :mod:`asyncio` では、内部の処理が中断されてプログラムが終了できなくな" +"る可能性があるため、この動作は適していません。" -#: ../../library/asyncio-runner.rst:168 msgid "" "To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as " "follows:" msgstr "" +"この問題を軽減するため、:mod:`asyncio` は :const:`signal.SIGINT` を次のように" +"処理します。" -#: ../../library/asyncio-runner.rst:170 msgid "" ":meth:`asyncio.Runner.run` installs a custom :const:`signal.SIGINT` handler " "before any user code is executed and removes it when exiting from the " "function." msgstr "" +":meth:`asyncio.Runner.run` はユーザーコードの実行前に独自の :const:`signal." +"SIGINT` ハンドラーを設定し、関数を終了するときに取り除きます。" -#: ../../library/asyncio-runner.rst:172 msgid "" "The :class:`~asyncio.Runner` creates the main task for the passed coroutine " "for its execution." msgstr "" +":class:`~asyncio.Runner` は、渡されたコルーチンを実行するメインタスクを作成し" +"ます。" -#: ../../library/asyncio-runner.rst:174 msgid "" "When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal " "handler cancels the main task by calling :meth:`asyncio.Task.cancel` which " @@ -267,11 +294,22 @@ msgid "" "used for resource cleanup. After the main task is cancelled, :meth:`asyncio." "Runner.run` raises :exc:`KeyboardInterrupt`." msgstr "" +":kbd:`Ctrl-C` によって :const:`signal.SIGINT` が発生すると、独自のシグナルハ" +"ンドラーが :meth:`asyncio.Task.cancel` を呼び出してメインタスクをキャンセルし" +"ます。\n" +"これにより、メインタスク内で :exc:`asyncio.CancelledError` が送出されます。\n" +"Python のスタックが巻き戻されるため、``try/except`` や ``try/finally`` ブロッ" +"クでリソースを解放できます。\n" +"メインタスクのキャンセル後、:meth:`asyncio.Runner.run` は :exc:" +"`KeyboardInterrupt` を送出します。" -#: ../../library/asyncio-runner.rst:180 msgid "" "A user could write a tight loop which cannot be interrupted by :meth:" "`asyncio.Task.cancel`, in which case the second following :kbd:`Ctrl-C` " "immediately raises the :exc:`KeyboardInterrupt` without cancelling the main " "task." msgstr "" +"ユーザーが書いたループが処理を譲らずに繰り返し続け、:meth:`asyncio.Task." +"cancel` で中断できない場合があります。\n" +"その場合、2 回目の :kbd:`Ctrl-C` はメインタスクをキャンセルせず、即座に :exc:" +"`KeyboardInterrupt` を送出します。" diff --git a/library/asyncio-stream.po b/library/asyncio-stream.po index c51b43665..d040fad36 100644 --- a/library/asyncio-stream.po +++ b/library/asyncio-stream.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-stream.rst:7 @@ -46,7 +46,6 @@ msgid "Here is an example of a TCP echo client written using asyncio streams::" msgstr "" "以下は asyncio ストリームを使って書いた TCP エコークライアントの例です::" -#: ../../library/asyncio-stream.rst:22 ../../library/asyncio-stream.rst:455 msgid "" "import asyncio\n" "\n" @@ -67,6 +66,24 @@ msgid "" "\n" "asyncio.run(tcp_echo_client('Hello World!'))" msgstr "" +"import asyncio\n" +"\n" +"async def tcp_echo_client(message):\n" +" reader, writer = await asyncio.open_connection(\n" +" '127.0.0.1', 8888)\n" +"\n" +" print(f'Send: {message!r}')\n" +" writer.write(message.encode())\n" +" await writer.drain()\n" +"\n" +" data = await reader.read(100)\n" +" print(f'Received: {data.decode()!r}')\n" +"\n" +" print('Close the connection')\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"asyncio.run(tcp_echo_client('Hello World!'))" #: ../../library/asyncio-stream.rst:42 msgid "See also the `Examples`_ section below." @@ -114,12 +131,15 @@ msgid "" "create_connection`." msgstr "残りの引数は直接 :meth:`loop.create_connection` に渡されます。" -#: ../../library/asyncio-stream.rst:74 ../../library/asyncio-stream.rst:154 msgid "" "The *sock* argument transfers ownership of the socket to the :class:" "`StreamWriter` created. To close the socket, call its :meth:`~asyncio." "StreamWriter.close` method." msgstr "" +"*sock* 引数を渡すと、ソケットの所有権は作成された :class:`StreamWriter` に移" +"ります。\n" +"ソケットを閉じるには、その :meth:`~asyncio.StreamWriter.close` メソッドを呼び" +"出してください。" #: ../../library/asyncio-stream.rst:78 msgid "Added the *ssl_handshake_timeout* parameter." @@ -171,20 +191,21 @@ msgid "" "The rest of the arguments are passed directly to :meth:`loop.create_server`." msgstr "残りの引数は直接 :meth:`loop.create_server` に渡されます。" -#: ../../library/asyncio-stream.rst:121 ../../library/asyncio-stream.rst:189 msgid "" "The *sock* argument transfers ownership of the socket to the server created. " "To close the socket, call the server's :meth:`~asyncio.Server.close` method." msgstr "" +"*sock* 引数を渡すと、ソケットの所有権は作成されたサーバーに移ります。\n" +"ソケットを閉じるには、サーバーの :meth:`~asyncio.Server.close` メソッドを呼び" +"出してください。" #: ../../library/asyncio-stream.rst:125 msgid "Added the *ssl_handshake_timeout* and *start_serving* parameters." msgstr "" "*ssl_handshake_timeout* と *start_serving* パラメータが追加されました。" -#: ../../library/asyncio-stream.rst:134 msgid "Added the *keep_alive* parameter." -msgstr "" +msgstr "*keep_alive* パラメーターが追加されました。" #: ../../library/asyncio-stream.rst:139 msgid "Unix Sockets" @@ -207,15 +228,15 @@ msgstr "" msgid "See also the documentation of :meth:`loop.create_unix_connection`." msgstr ":meth:`loop.create_unix_connection` のドキュメントも参照してください。" -#: ../../library/asyncio-stream.rst:158 ../../library/asyncio-stream.rst:193 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/asyncio-stream.rst:160 msgid "" "Added the *ssl_handshake_timeout* parameter. The *path* parameter can now be " "a :term:`path-like object`" msgstr "" +"*ssl_handshake_timeout* パラメーターが追加されました。\n" +"*path* パラメーターに :term:`path-like object` を指定できるようになりました。" #: ../../library/asyncio-stream.rst:177 msgid "Start a Unix socket server." @@ -225,37 +246,41 @@ msgstr "Unix のソケットサーバーを起動します。" msgid "Similar to :func:`start_server` but works with Unix sockets." msgstr ":func:`start_server` と似ていますが Unix ソケットに対して動作します。" -#: ../../library/asyncio-stream.rst:181 msgid "" "If *cleanup_socket* is true then the Unix socket will automatically be " "removed from the filesystem when the server is closed, unless the socket has " "been replaced after the server has been created." msgstr "" +"*cleanup_socket* が真の場合、サーバーを閉じると Unix ソケットをファイルシステ" +"ムから自動的に削除します。\n" +"ただし、サーバーを作成した後にソケットが置き換えられていれば削除しません。" #: ../../library/asyncio-stream.rst:185 msgid "See also the documentation of :meth:`loop.create_unix_server`." msgstr ":meth:`loop.create_unix_server` のドキュメントも参照してください。" -#: ../../library/asyncio-stream.rst:195 msgid "" "Added the *ssl_handshake_timeout* and *start_serving* parameters. The *path* " "parameter can now be a :term:`path-like object`." msgstr "" +"*ssl_handshake_timeout* と *start_serving* パラメーターが追加されました。\n" +"*path* パラメーターに :term:`path-like object` を指定できるようになりました。" -#: ../../library/asyncio-stream.rst:205 msgid "Added the *cleanup_socket* parameter." -msgstr "" +msgstr "*cleanup_socket* パラメーターが追加されました。" #: ../../library/asyncio-stream.rst:210 msgid "StreamReader" msgstr "StreamReader" -#: ../../library/asyncio-stream.rst:214 msgid "" "Represents a reader object that provides APIs to read data from the IO " "stream. As an :term:`asynchronous iterable`, the object supports the :" "keyword:`async for` statement." msgstr "" +"I/O ストリームからデータを読み込む API を提供するリーダーオブジェクトです。\n" +":term:`非同期イテラブル ` なので、:keyword:`async " +"for` 文をサポートします。" #: ../../library/asyncio-stream.rst:218 msgid "" @@ -265,9 +290,8 @@ msgstr "" "*StreamReader* オブジェクトを直接インスタンス化することは推奨されません; 代わ" "りに :func:`open_connection` や :func:`start_server` を使ってください。" -#: ../../library/asyncio-stream.rst:224 msgid "Acknowledge the EOF." -msgstr "EOF の肯定応答を行います。" +msgstr "EOF に達したことをストリームに通知します。" #: ../../library/asyncio-stream.rst:229 msgid "Read up to *n* bytes from the stream." @@ -366,17 +390,22 @@ msgstr "" "外が送出され、内部バッファーがリセットされます。このとき :attr:" "`IncompleteReadError.partial` 属性は区切り文字の一部を含むかもしれません。" -#: ../../library/asyncio-stream.rst:282 msgid "" "The *separator* may also be a tuple of separators. In this case the return " "value will be the shortest possible that has any separator as the suffix. " "For the purposes of :exc:`LimitOverrunError`, the shortest possible " "separator is considered to be the one that matched." msgstr "" +"*separator* には、区切り文字のタプルも指定できます。\n" +"この場合、いずれかの区切り文字を末尾に持つ、できる限り短いデータを返しま" +"す。\n" +":exc:`LimitOverrunError` の判定では、該当する最短の区切り文字がマッチしたもの" +"として扱います。" -#: ../../library/asyncio-stream.rst:292 msgid "The *separator* parameter may now be a :class:`tuple` of separators." msgstr "" +"*separator* パラメーターに、区切り文字の :class:`tuple` を指定できるようにな" +"りました。" #: ../../library/asyncio-stream.rst:297 msgid "Return ``True`` if the buffer is empty and :meth:`feed_eof` was called." @@ -412,21 +441,23 @@ msgstr "" "込みに失敗した場合、データは送信可能になるまで内部の書き込みバッファーに格納" "されて待機します。" -#: ../../library/asyncio-stream.rst:319 msgid "" "The *data* buffer should be a bytes, bytearray, or C-contiguous one-" "dimensional memoryview object." msgstr "" +"*data* バッファには、``bytes``、``bytearray``、または C 形式で連続した 1 次元" +"の ``memoryview`` オブジェクトを指定してください。" #: ../../library/asyncio-stream.rst:322 ../../library/asyncio-stream.rst:335 msgid "The method should be used along with the ``drain()`` method::" msgstr "このメソッドは ``drain()`` メソッドと組み合わせて使うべきです::" -#: ../../library/asyncio-stream.rst:324 msgid "" "stream.write(data)\n" "await stream.drain()" msgstr "" +"stream.write(data)\n" +"await stream.drain()" #: ../../library/asyncio-stream.rst:330 msgid "" @@ -438,27 +469,30 @@ msgstr "" "を即座に書き込みます。書き込みに失敗した場合、データは送信可能になるまで内部" "の書き込みバッファーに格納されて待機します。" -#: ../../library/asyncio-stream.rst:337 msgid "" "stream.writelines(lines)\n" "await stream.drain()" msgstr "" +"stream.writelines(lines)\n" +"await stream.drain()" #: ../../library/asyncio-stream.rst:342 msgid "The method closes the stream and the underlying socket." msgstr "このメソッドはストリームと背後にあるソケットをクローズします。" -#: ../../library/asyncio-stream.rst:344 msgid "" "The method should be used, though not mandatory, along with the " "``wait_closed()`` method::" msgstr "" +"必須ではありませんが、このメソッドは ``wait_closed()`` と組み合わせて使ってく" +"ださい。 ::" -#: ../../library/asyncio-stream.rst:347 msgid "" "stream.close()\n" "await stream.wait_closed()" msgstr "" +"stream.close()\n" +"await stream.wait_closed()" #: ../../library/asyncio-stream.rst:352 msgid "" @@ -491,13 +525,13 @@ msgstr "" msgid "Wait until it is appropriate to resume writing to the stream. Example::" msgstr "ストリームへの書き込み再開に適切な状態になるまで待ちます。使用例::" -#: ../../library/asyncio-stream.rst:375 msgid "" "writer.write(data)\n" "await writer.drain()" msgstr "" +"writer.write(data)\n" +"await writer.drain()" -#: ../../library/asyncio-stream.rst:378 msgid "" "This is a flow control method that interacts with the underlying IO write " "buffer. When the size of the buffer reaches the high watermark, *drain()* " @@ -505,11 +539,11 @@ msgid "" "writing can be resumed. When there is nothing to wait for, the :meth:" "`drain` returns immediately." msgstr "" -"このメソッドは背後にある IO 書き込みバッファーとやりとりを行うフロー制御メ" -"ソッドです。バッファーのサイズが最高水位点に達した場合、*drain()* はバッファ" -"のサイズが最低水位点を下回るまで減量され、書き込み再開可能になるまで書き込み" -"をブロックします。待ち受けの必要がない場合、 :meth:`drain` は即座にリターンし" -"ます。" +"このメソッドは背後にある IO 書き込みバッファとやりとりを行うフロー制御メソッ" +"ドです。\n" +"バッファのサイズが最高水位点に達すると、*drain()* はサイズが最低水位点まで減" +"り、書き込みを再開できるようになるまで待機します。\n" +"待つ必要がない場合、:meth:`drain` はすぐに返ります。" #: ../../library/asyncio-stream.rst:387 msgid "" @@ -520,9 +554,8 @@ msgid "" "explicitly with ``await asyncio.sleep(0)`` (see :func:`asyncio.sleep`)." msgstr "" -#: ../../library/asyncio-stream.rst:399 msgid "Upgrade an existing stream-based connection to TLS." -msgstr "" +msgstr "既存のストリームベースの接続を TLS にアップグレードします。" #: ../../library/asyncio-stream.rst:401 msgid "Parameters:" @@ -540,25 +573,30 @@ msgstr "" "*server_hostname*: 対象のサーバーの証明書との照合に使われるホスト名を設定また" "は上書きします。" -#: ../../library/asyncio-stream.rst:408 msgid "" "*ssl_handshake_timeout* is the time in seconds to wait for the TLS handshake " "to complete before aborting the connection. ``60.0`` seconds if ``None`` " "(default)." msgstr "" +"*ssl_handshake_timeout* は、接続を中断する前に TLS ハンドシェイクの完了を待つ" +"時間を秒単位で指定します。\n" +"``None`` (デフォルト) の場合は ``60.0`` 秒です。" -#: ../../library/asyncio-stream.rst:412 msgid "" "*ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown " "to complete before aborting the connection. ``30.0`` seconds if ``None`` " "(default)." msgstr "" +"*ssl_shutdown_timeout* は、接続を中断する前に SSL の終了処理を待つ時間を秒単" +"位で指定します。\n" +"``None`` (デフォルト) の場合は ``30.0`` 秒です。" -#: ../../library/asyncio-stream.rst:421 msgid "" "Raises a ``ValueError`` if ``sslcontext.check_hostname`` is ``True`` and " "``server_hostname`` is not supplied." msgstr "" +"``sslcontext.check_hostname`` が ``True`` で、``server_hostname`` が指定され" +"ていない場合に ``ValueError`` を送出するようになりました。" #: ../../library/asyncio-stream.rst:428 msgid "" @@ -571,12 +609,14 @@ msgstr "" msgid "Wait until the stream is closed." msgstr "ストリームがクローズされるまで待機します。" -#: ../../library/asyncio-stream.rst:438 msgid "" "Should be called after :meth:`close` to wait until the underlying connection " "is closed, ensuring that all data has been flushed before e.g. exiting the " "program." msgstr "" +":meth:`close` の後に呼び出して、下層の接続が閉じられるまで待ってください。\n" +"これにより、例えばプログラムを終了する前に、すべてのデータがフラッシュされた" +"ことを確認できます。" #: ../../library/asyncio-stream.rst:446 msgid "Examples" @@ -609,7 +649,6 @@ msgstr "ストリームを使った TCP Echo サーバー" msgid "TCP echo server using the :func:`asyncio.start_server` function::" msgstr ":func:`asyncio.start_server` 関数を使った TCP Echo サーバーです::" -#: ../../library/asyncio-stream.rst:488 msgid "" "import asyncio\n" "\n" @@ -640,6 +679,34 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def handle_echo(reader, writer):\n" +" data = await reader.read(100)\n" +" message = data.decode()\n" +" addr = writer.get_extra_info('peername')\n" +"\n" +" print(f\"Received {message!r} from {addr!r}\")\n" +"\n" +" print(f\"Send: {message!r}\")\n" +" writer.write(data)\n" +" await writer.drain()\n" +"\n" +" print(\"Close the connection\")\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"async def main():\n" +" server = await asyncio.start_server(\n" +" handle_echo, '127.0.0.1', 8888)\n" +"\n" +" addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)\n" +" print(f'Serving on {addrs}')\n" +"\n" +" async with server:\n" +" await server.serve_forever()\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-stream.rst:520 msgid "" @@ -661,7 +728,6 @@ msgid "" msgstr "" "コマンドラインから渡された URL の HTTP ヘッダーを問い合わせる簡単な例です::" -#: ../../library/asyncio-stream.rst:529 msgid "" "import asyncio\n" "import urllib.parse\n" @@ -699,22 +765,55 @@ msgid "" "url = sys.argv[1]\n" "asyncio.run(print_http_headers(url))" msgstr "" +"import asyncio\n" +"import urllib.parse\n" +"import sys\n" +"\n" +"async def print_http_headers(url):\n" +" url = urllib.parse.urlsplit(url)\n" +" if url.scheme == 'https':\n" +" reader, writer = await asyncio.open_connection(\n" +" url.hostname, 443, ssl=True)\n" +" else:\n" +" reader, writer = await asyncio.open_connection(\n" +" url.hostname, 80)\n" +"\n" +" query = (\n" +" f\"HEAD {url.path or '/'} HTTP/1.0\\r\\n\"\n" +" f\"Host: {url.hostname}\\r\\n\"\n" +" f\"\\r\\n\"\n" +" )\n" +"\n" +" writer.write(query.encode('latin-1'))\n" +" while True:\n" +" line = await reader.readline()\n" +" if not line:\n" +" break\n" +"\n" +" line = line.decode('latin1').rstrip()\n" +" if line:\n" +" print(f'HTTP header> {line}')\n" +"\n" +" # 本文を無視し、ソケットを閉じる\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +"url = sys.argv[1]\n" +"asyncio.run(print_http_headers(url))" #: ../../library/asyncio-stream.rst:566 msgid "Usage::" msgstr "使い方::" -#: ../../library/asyncio-stream.rst:568 msgid "python example.py http://example.com/path/page.html" -msgstr "" +msgstr "python example.py http://example.com/path/page.html" #: ../../library/asyncio-stream.rst:570 msgid "or with HTTPS::" msgstr "または HTTPS を使用::" -#: ../../library/asyncio-stream.rst:572 msgid "python example.py https://example.com/path/page.html" -msgstr "" +msgstr "python example.py https://example.com/path/page.html" #: ../../library/asyncio-stream.rst:578 msgid "Register an open socket to wait for data using streams" @@ -728,7 +827,6 @@ msgstr "" ":func:`open_connection` 関数を使ってソケットがデータを受信するまで待つコルー" "チンです::" -#: ../../library/asyncio-stream.rst:583 msgid "" "import asyncio\n" "import socket\n" @@ -760,6 +858,34 @@ msgid "" "\n" "asyncio.run(wait_for_data())" msgstr "" +"import asyncio\n" +"import socket\n" +"\n" +"async def wait_for_data():\n" +" # 低水準 API を使うため、現在のイベントループへの参照を取得する。\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # 接続されたソケットのペアを作成する。\n" +" rsock, wsock = socket.socketpair()\n" +"\n" +" # データを待ち受けるために、開いているソケットを登録する。\n" +" reader, writer = await asyncio.open_connection(sock=rsock)\n" +"\n" +" # ネットワークからのデータ受信を模倣する\n" +" loop.call_soon(wsock.send, 'abc'.encode())\n" +"\n" +" # データを待つ\n" +" data = await reader.read(100)\n" +"\n" +" # データを受信して処理が済んだので、ソケットを閉じる\n" +" print(\"Received:\", data.decode())\n" +" writer.close()\n" +" await writer.wait_closed()\n" +"\n" +" # もう一方のソケットを閉じる\n" +" wsock.close()\n" +"\n" +"asyncio.run(wait_for_data())" #: ../../library/asyncio-stream.rst:615 msgid "" diff --git a/library/asyncio-subprocess.po b/library/asyncio-subprocess.po index 75888b1d4..61a3b1340 100644 --- a/library/asyncio-subprocess.po +++ b/library/asyncio-subprocess.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-subprocess.rst:7 @@ -50,7 +50,6 @@ msgstr "" "以下は、 asyncio モジュールがどのようにシェルコマンドを実行し、結果を取得でき" "るかを示す例です::" -#: ../../library/asyncio-subprocess.rst:22 msgid "" "import asyncio\n" "\n" @@ -70,31 +69,48 @@ msgid "" "\n" "asyncio.run(run('ls /zzz'))" msgstr "" +"import asyncio\n" +"\n" +"async def run(cmd):\n" +" proc = await asyncio.create_subprocess_shell(\n" +" cmd,\n" +" stdout=asyncio.subprocess.PIPE,\n" +" stderr=asyncio.subprocess.PIPE)\n" +"\n" +" stdout, stderr = await proc.communicate()\n" +"\n" +" print(f'[{cmd!r} exited with {proc.returncode}]')\n" +" if stdout:\n" +" print(f'[stdout]\\n{stdout.decode()}')\n" +" if stderr:\n" +" print(f'[stderr]\\n{stderr.decode()}')\n" +"\n" +"asyncio.run(run('ls /zzz'))" #: ../../library/asyncio-subprocess.rst:40 msgid "will print::" msgstr "このサンプルコードは以下を出力します::" -#: ../../library/asyncio-subprocess.rst:42 msgid "" "['ls /zzz' exited with 1]\n" "[stderr]\n" "ls: /zzz: No such file or directory" msgstr "" +"['ls /zzz' exited with 1]\n" +"[stderr]\n" +"ls: /zzz: No such file or directory" -#: ../../library/asyncio-subprocess.rst:46 msgid "" "Because all asyncio subprocess functions are asynchronous and asyncio " "provides many tools to work with such functions, it is easy to execute and " "monitor multiple subprocesses in parallel. It is indeed trivial to modify " "the above example to run several commands simultaneously::" msgstr "" -"全ての asyncio のサブプロセス関数は非同期ですが、 asyncio モジュールはこれら" -"の非同期関数と協調するための多くのツールを提供しているので、複数のサブプロセ" -"スを並列に実行して監視することは簡単です。実際、上記のサンプルコードを複数の" -"コマンドを同時に実行するように修正するのはきわめて単純です::" +"asyncio のサブプロセス関数はすべて非同期で、asyncio にはこれらの関数を扱うた" +"めのツールが多数あるため、複数のサブプロセスを並列に実行して監視するのは簡単" +"です。\n" +"実際、上の例を変更して複数のコマンドを同時に実行するのはごく簡単です。 ::" -#: ../../library/asyncio-subprocess.rst:51 msgid "" "async def main():\n" " await asyncio.gather(\n" @@ -103,6 +119,12 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"async def main():\n" +" await asyncio.gather(\n" +" run('ls /zzz'),\n" +" run('sleep 1; echo \"hello\"'))\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-subprocess.rst:58 msgid "See also the `Examples`_ subsection." @@ -116,14 +138,16 @@ msgstr "サブプロセスの生成" msgid "Create a subprocess." msgstr "サブプロセスを作成します。" -#: ../../library/asyncio-subprocess.rst:70 -#: ../../library/asyncio-subprocess.rst:92 msgid "" "The *limit* argument sets the buffer limit for :class:`StreamReader` " "wrappers for :attr:`~asyncio.subprocess.Process.stdout` and :attr:`~asyncio." "subprocess.Process.stderr` (if :const:`subprocess.PIPE` is passed to " "*stdout* and *stderr* arguments)." msgstr "" +"*limit* 引数は、:attr:`~asyncio.subprocess.Process.stdout` と :attr:" +"`~asyncio.subprocess.Process.stderr` をラップする :class:`StreamReader` の" +"バッファの上限を設定します (*stdout* と *stderr* 引数に :const:`subprocess." +"PIPE` を渡した場合)。" #: ../../library/asyncio-subprocess.rst:74 #: ../../library/asyncio-subprocess.rst:96 @@ -206,20 +230,25 @@ msgstr "定数" msgid "Can be passed to the *stdin*, *stdout* or *stderr* parameters." msgstr "*stdin*, *stdout* または *stderr* に渡すことができます。" -#: ../../library/asyncio-subprocess.rst:139 msgid "" "If *PIPE* is passed to *stdin* argument, the :attr:`Process.stdin ` attribute will point to a :class:`~asyncio." "StreamWriter` instance." msgstr "" +"*stdin* 引数に *PIPE* を渡すと、:attr:`Process.stdin ` 属性は :class:`~asyncio.StreamWriter` インスタンスを指しま" +"す。" -#: ../../library/asyncio-subprocess.rst:143 msgid "" "If *PIPE* is passed to *stdout* or *stderr* arguments, the :attr:`Process." "stdout ` and :attr:`Process.stderr " "` attributes will point to :class:" "`~asyncio.StreamReader` instances." msgstr "" +"*stdout* または *stderr* 引数に *PIPE* を渡すと、対応する :attr:`Process." +"stdout ` 属性または :attr:`Process.stderr " +"` 属性は :class:`~asyncio.StreamReader` イ" +"ンスタンスを指します。" #: ../../library/asyncio-subprocess.rst:151 msgid "" @@ -255,12 +284,14 @@ msgstr "" "プロセスと通信したり、サブプロセスの完了を監視したりするための高水準のラッ" "パーです。" -#: ../../library/asyncio-subprocess.rst:173 msgid "" "An object that wraps OS processes created by the :func:`~asyncio." "create_subprocess_exec` and :func:`~asyncio.create_subprocess_shell` " "functions." msgstr "" +":func:`~asyncio.create_subprocess_exec` 関数や :func:`~asyncio." +"create_subprocess_shell` 関数で作成した OS のプロセスをラップするオブジェクト" +"です。" #: ../../library/asyncio-subprocess.rst:177 msgid "" @@ -278,12 +309,14 @@ msgstr "" "Popen と異なり、 Process インスタンスは :meth:`~subprocess.Popen.poll` メソッ" "ドに相当するメソッドを持っていません;" -#: ../../library/asyncio-subprocess.rst:184 msgid "" "the :meth:`~asyncio.subprocess.Process.communicate` and :meth:`~asyncio." "subprocess.Process.wait` methods don't have a *timeout* parameter: use the :" "func:`~asyncio.wait_for` function;" msgstr "" +":meth:`~asyncio.subprocess.Process.communicate` メソッドと :meth:`~asyncio." +"subprocess.Process.wait` メソッドには *timeout* パラメーターがありません。\n" +":func:`~asyncio.wait_for` 関数を使ってください。" #: ../../library/asyncio-subprocess.rst:188 msgid "" @@ -320,17 +353,16 @@ msgstr "子プロセスが終了するのを待ち受けます。" msgid "Set and return the :attr:`returncode` attribute." msgstr ":attr:`returncode` 属性を設定し、その値を返します。" -#: ../../library/asyncio-subprocess.rst:208 msgid "" "This method can deadlock when using ``stdout=PIPE`` or ``stderr=PIPE`` and " "the child process generates so much output that it blocks waiting for the OS " "pipe buffer to accept more data. Use the :meth:`communicate` method when " "using pipes to avoid this condition." msgstr "" -"``stdout=PIPE`` または ``stderr=PIPE`` を使っており、OS パイプバッファがさら" -"なるデータを受け付けるようになるまで子プロセスをブロックするほど大量の出力を" -"生成場合、このメソッドはデッドロックする可能性があります。この条件を避けるた" -"め、パイプを使用する場合は :meth:`communicate` メソッドを使ってください。" +"``stdout=PIPE`` または ``stderr=PIPE`` を使う場合、子プロセスが大量に出力し" +"て OS のパイプバッファに空きができるまでブロックされると、このメソッドはデッ" +"ドロックする可能性があります。\n" +"パイプを使うときは :meth:`communicate` メソッドでこの状況を回避してください。" #: ../../library/asyncio-subprocess.rst:217 msgid "Interact with process:" @@ -364,17 +396,16 @@ msgstr "" msgid "Return a tuple ``(stdout_data, stderr_data)``." msgstr "``(stdout_data, stderr_data)`` のタプルを返します。" -#: ../../library/asyncio-subprocess.rst:229 msgid "" "If either :exc:`BrokenPipeError` or :exc:`ConnectionResetError` exception is " "raised when writing *input* into *stdin*, the exception is ignored. This " "condition occurs when the process exits before all data are written into " "*stdin*." msgstr "" -"*input* を標準入力 *stdin* nに書き込んでいる時に :exc:`BrokenPipeError` また" -"は :exc:`ConnectionResetError` 例外が送出された場合、例外は無視されます。この" -"ような条件は、全てのデータが *stdin* に書き込まれる前にプロセスが終了した場合" -"に起こります。" +"*input* を *stdin* に書き込む際に :exc:`BrokenPipeError` または :exc:" +"`ConnectionResetError` が送出された場合、その例外は無視されます。\n" +"これは、すべてのデータを *stdin* に書き込む前にプロセスが終了すると発生しま" +"す。" #: ../../library/asyncio-subprocess.rst:234 msgid "" @@ -397,87 +428,98 @@ msgstr "" "い。そのため、返されるデータのサイズが大きいかまたは無制限の場合はこのメソッ" "ドを使わないようにしてください。" -#: ../../library/asyncio-subprocess.rst:245 msgid "*stdin* gets closed when ``input=None`` too." -msgstr "" +msgstr "``input=None`` の場合も *stdin* を閉じるようになりました。" #: ../../library/asyncio-subprocess.rst:249 msgid "Sends the signal *signal* to the child process." msgstr "子プロセスにシグナル *signal* を送信します。" -#: ../../library/asyncio-subprocess.rst:253 msgid "" "On Windows, :py:const:`~signal.SIGTERM` is an alias for :meth:`terminate`. " "``CTRL_C_EVENT`` and ``CTRL_BREAK_EVENT`` can be sent to processes started " "with a *creationflags* parameter which includes ``CREATE_NEW_PROCESS_GROUP``." msgstr "" +"Windows では :py:const:`~signal.SIGTERM` の送信は :meth:`terminate` の呼び出" +"しと同じです。\n" +"*creationflags* パラメーターに ``CREATE_NEW_PROCESS_GROUP`` を含めて起動した" +"プロセスには、``CTRL_C_EVENT`` と ``CTRL_BREAK_EVENT`` を送信できます。" #: ../../library/asyncio-subprocess.rst:260 msgid "Stop the child process." msgstr "子プロセスを停止します。" -#: ../../library/asyncio-subprocess.rst:262 msgid "" "On POSIX systems this method sends :py:const:`~signal.SIGTERM` to the child " "process." msgstr "" +"POSIX システムでは、子プロセスに :py:const:`~signal.SIGTERM` を送信します。" -#: ../../library/asyncio-subprocess.rst:265 msgid "" "On Windows the Win32 API function :c:func:`!TerminateProcess` is called to " "stop the child process." msgstr "" +"Windows では、Win32 API 関数 :c:func:`!TerminateProcess` を呼び出して子プロセ" +"スを停止します。" #: ../../library/asyncio-subprocess.rst:270 msgid "Kill the child process." msgstr "子プロセスを強制終了 (kill) します。" -#: ../../library/asyncio-subprocess.rst:272 msgid "" "On POSIX systems this method sends :py:data:`~signal.SIGKILL` to the child " "process." msgstr "" +"POSIX システムでは、子プロセスに :py:data:`~signal.SIGKILL` を送信します。" #: ../../library/asyncio-subprocess.rst:275 msgid "On Windows this method is an alias for :meth:`terminate`." msgstr "Windows では、このメソッドは :meth:`terminate` のエイリアスです。" -#: ../../library/asyncio-subprocess.rst:279 msgid "" "Standard input stream (:class:`~asyncio.StreamWriter`) or ``None`` if the " "process was created with ``stdin=None``." msgstr "" +"標準入力ストリーム (:class:`~asyncio.StreamWriter`) です。\n" +"``stdin=None`` でプロセスを作成した場合は ``None`` です。" -#: ../../library/asyncio-subprocess.rst:284 msgid "" "Standard output stream (:class:`~asyncio.StreamReader`) or ``None`` if the " "process was created with ``stdout=None``." msgstr "" +"標準出力ストリーム (:class:`~asyncio.StreamReader`) です。\n" +"``stdout=None`` でプロセスを作成した場合は ``None`` です。" -#: ../../library/asyncio-subprocess.rst:289 msgid "" "Standard error stream (:class:`~asyncio.StreamReader`) or ``None`` if the " "process was created with ``stderr=None``." msgstr "" +"標準エラーストリーム (:class:`~asyncio.StreamReader`) です。\n" +"``stderr=None`` でプロセスを作成した場合は ``None`` です。" -#: ../../library/asyncio-subprocess.rst:294 msgid "" "Use the :meth:`communicate` method rather than :attr:`process.stdin.write() " "`, :attr:`await process.stdout.read() ` or :attr:`await " "process.stderr.read() `. This avoids deadlocks due to streams " "pausing reading or writing and blocking the child process." msgstr "" +":attr:`process.stdin.write() `、:attr:`await process.stdout.read() " +"`、:attr:`await process.stderr.read() ` の代わりに :meth:" +"`communicate` メソッドを使ってください。\n" +"これにより、ストリームの読み書きが一時停止して子プロセスがブロックされること" +"によるデッドロックを回避できます。" #: ../../library/asyncio-subprocess.rst:303 msgid "Process identification number (PID)." msgstr "子プロセスのプロセス番号 (PID) です。" -#: ../../library/asyncio-subprocess.rst:305 msgid "" "Note that for processes created by the :func:`~asyncio." "create_subprocess_shell` function, this attribute is the PID of the spawned " "shell." msgstr "" +":func:`~asyncio.create_subprocess_shell` 関数で作成したプロセスでは、この属性" +"は起動したシェルの PID です。" #: ../../library/asyncio-subprocess.rst:310 msgid "Return code of the process when it exits." @@ -489,20 +531,26 @@ msgstr "" "この属性が ``None`` であることは、プロセスがまだ終了していないことを示してい" "ます。" -#: ../../library/asyncio-subprocess.rst:314 msgid "" "For processes created with :func:`~asyncio.create_subprocess_exec`, a " "negative value ``-N`` indicates that the child was terminated by signal " "``N`` (POSIX only)." msgstr "" +":func:`~asyncio.create_subprocess_exec` で作成したプロセスでは、負の値 ``-" +"N`` は子プロセスがシグナル ``N`` によって終了したことを示します (POSIX の" +"み)。" -#: ../../library/asyncio-subprocess.rst:318 msgid "" "For processes created with :func:`~asyncio.create_subprocess_shell`, the " "return code reflects the exit status of the shell itself (e.g. ``/bin/sh``), " "which may map signals to codes such as ``128+N``. See the documentation of " "the shell (for example, the Bash manual's Exit Status) for details." msgstr "" +":func:`~asyncio.create_subprocess_shell` で作成したプロセスでは、戻りコードは" +"シェル自体 (例えば ``/bin/sh``) の終了ステータスを反映します。\n" +"シェルによってはシグナルを ``128+N`` などのコードに対応付けます。\n" +"詳しくは、シェルのドキュメント (例えば Bash マニュアルの Exit Status) を参照" +"してください。" #: ../../library/asyncio-subprocess.rst:329 msgid "Subprocess and Threads" @@ -557,7 +605,6 @@ msgid "" "The subprocess is created by the :func:`create_subprocess_exec` function::" msgstr "サブプロセスは :func:`create_subprocess_exec` 関数により生成されます::" -#: ../../library/asyncio-subprocess.rst:358 msgid "" "import asyncio\n" "import sys\n" @@ -582,6 +629,27 @@ msgid "" "date = asyncio.run(get_date())\n" "print(f\"Current date: {date}\")" msgstr "" +"import asyncio\n" +"import sys\n" +"\n" +"async def get_date():\n" +" code = 'import datetime as dt; print(dt.datetime.now())'\n" +"\n" +" # サブプロセスを作成し、標準出力をパイプにリダイレクトする。\n" +" proc = await asyncio.create_subprocess_exec(\n" +" sys.executable, '-c', code,\n" +" stdout=asyncio.subprocess.PIPE)\n" +"\n" +" # 出力を 1 行読み込む。\n" +" data = await proc.stdout.readline()\n" +" line = data.decode('ascii').rstrip()\n" +"\n" +" # サブプロセスの終了を待つ。\n" +" await proc.wait()\n" +" return line\n" +"\n" +"date = asyncio.run(get_date())\n" +"print(f\"Current date: {date}\")" #: ../../library/asyncio-subprocess.rst:382 msgid "" diff --git a/library/asyncio-sync.po b/library/asyncio-sync.po index 46e5604d8..2dc420c78 100644 --- a/library/asyncio-sync.po +++ b/library/asyncio-sync.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio-sync.rst:7 @@ -107,7 +107,6 @@ msgstr "" "Lock の望ましい使用方法は、 :keyword:`async with` 文と組み合わせて使うことで" "す::" -#: ../../library/asyncio-sync.rst:50 msgid "" "lock = asyncio.Lock()\n" "\n" @@ -115,13 +114,17 @@ msgid "" "async with lock:\n" " # access shared state" msgstr "" +"lock = asyncio.Lock()\n" +"\n" +"# ... 後で\n" +"async with lock:\n" +" # 共有状態にアクセスする" #: ../../library/asyncio-sync.rst:56 ../../library/asyncio-sync.rst:201 #: ../../library/asyncio-sync.rst:309 msgid "which is equivalent to::" msgstr "これは以下のコードと等価です::" -#: ../../library/asyncio-sync.rst:58 msgid "" "lock = asyncio.Lock()\n" "\n" @@ -132,6 +135,14 @@ msgid "" "finally:\n" " lock.release()" msgstr "" +"lock = asyncio.Lock()\n" +"\n" +"# ... 後で\n" +"await lock.acquire()\n" +"try:\n" +" # 共有状態にアクセスする\n" +"finally:\n" +" lock.release()" #: ../../library/asyncio-sync.rst:67 ../../library/asyncio-sync.rst:113 #: ../../library/asyncio-sync.rst:189 ../../library/asyncio-sync.rst:297 @@ -216,7 +227,6 @@ msgstr "" msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/asyncio-sync.rst:120 msgid "" "async def waiter(event):\n" " print('waiting for it ...')\n" @@ -239,6 +249,26 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"async def waiter(event):\n" +" print('waiting for it ...')\n" +" await event.wait()\n" +" print('... got it!')\n" +"\n" +"async def main():\n" +" # Event オブジェクトを作成する。\n" +" event = asyncio.Event()\n" +"\n" +" # 'event' がセットされるまで待機するタスクを起動する。\n" +" waiter_task = asyncio.create_task(waiter(event))\n" +"\n" +" # 1 秒待ってからイベントをセットする。\n" +" await asyncio.sleep(1)\n" +" event.set()\n" +"\n" +" # 待機中のタスクが終了するまで待つ。\n" +" await waiter_task\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-sync.rst:144 msgid "Wait until the event is set." @@ -266,11 +296,12 @@ msgstr "" msgid "Clear (unset) the event." msgstr "イベントをクリア (アンセット) します" -#: ../../library/asyncio-sync.rst:160 msgid "" "Subsequent tasks awaiting on :meth:`~Event.wait` will now block until the :" "meth:`~Event.set` method is called again." msgstr "" +"以降に :meth:`~Event.wait` を await するタスクは、:meth:`~Event.set` メソッド" +"が再び呼び出されるまでブロックされます。" #: ../../library/asyncio-sync.rst:165 msgid "Return ``True`` if the event is set." @@ -322,7 +353,6 @@ msgstr "" "Condition の望ましい使用方法は :keyword:`async with` 文と組み合わせて使うこと" "です::" -#: ../../library/asyncio-sync.rst:195 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -330,8 +360,12 @@ msgid "" "async with cond:\n" " await cond.wait()" msgstr "" +"cond = asyncio.Condition()\n" +"\n" +"# ... 後で\n" +"async with cond:\n" +" await cond.wait()" -#: ../../library/asyncio-sync.rst:203 msgid "" "cond = asyncio.Condition()\n" "\n" @@ -342,6 +376,14 @@ msgid "" "finally:\n" " cond.release()" msgstr "" +"cond = asyncio.Condition()\n" +"\n" +"# ... 後で\n" +"await cond.acquire()\n" +"try:\n" +" await cond.wait()\n" +"finally:\n" +" cond.release()" #: ../../library/asyncio-sync.rst:215 msgid "Acquire the underlying lock." @@ -355,11 +397,12 @@ msgstr "" "このメソッドは下層のロックが *解除される* まで待機し、ロックを *ロック状態* " "に変更して ``True`` を返します。" -#: ../../library/asyncio-sync.rst:222 msgid "" "Wake up *n* tasks (1 by default) waiting on this condition. If fewer than " "*n* tasks are waiting they are all awakened." msgstr "" +"この条件変数で待機しているタスクを *n* 個 (デフォルトは 1 個) 起こします。\n" +"待機しているタスクが *n* 個未満なら、すべて起こします。" #: ../../library/asyncio-sync.rst:225 ../../library/asyncio-sync.rst:240 msgid "" @@ -418,24 +461,30 @@ msgstr "" "動されると、 Condition は再びロックを獲得し、メソッドは ``True`` を返しま" "す。" -#: ../../library/asyncio-sync.rst:264 msgid "" "Note that a task *may* return from this call spuriously, which is why the " "caller should always re-check the state and be prepared to :meth:`~Condition." "wait` again. For this reason, you may prefer to use :meth:`~Condition." "wait_for` instead." msgstr "" +"この呼び出しは、通知を受けていなくても返る *場合があります*。\n" +"そのため、呼び出し側では必ず状態を再確認し、必要なら再び :meth:`~Condition." +"wait` できるようにしてください。\n" +"このため、代わりに :meth:`~Condition.wait_for` を使う方が適している場合もあり" +"ます。" -#: ../../library/asyncio-sync.rst:272 msgid "Wait until a predicate becomes *true*." -msgstr "引数 predicate の条件が *真* になるまで待機します。" +msgstr "``predicate`` の評価結果が *真* になるまで待機します。" -#: ../../library/asyncio-sync.rst:274 msgid "" "The predicate must be a callable which result will be interpreted as a " "boolean value. The method will repeatedly :meth:`~Condition.wait` until the " "predicate evaluates to *true*. The final value is the return value." msgstr "" +"``predicate`` は呼び出し可能オブジェクトでなければならず、その結果はブール値" +"として解釈されます。\n" +"このメソッドは ``predicate`` の評価結果が *真* になるまで :meth:`~Condition." +"wait` を繰り返し、最後の評価結果を返します。" #: ../../library/asyncio-sync.rst:281 msgid "Semaphore" @@ -475,7 +524,6 @@ msgstr "" "セマフォの望ましい使用方法は、 :keyword:`async with` 文と組み合わせて使うこと" "です::" -#: ../../library/asyncio-sync.rst:303 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -483,8 +531,12 @@ msgid "" "async with sem:\n" " # work with shared resource" msgstr "" +"sem = asyncio.Semaphore(10)\n" +"\n" +"# ... 後で\n" +"async with sem:\n" +" # 共有リソースを操作する" -#: ../../library/asyncio-sync.rst:311 msgid "" "sem = asyncio.Semaphore(10)\n" "\n" @@ -495,6 +547,14 @@ msgid "" "finally:\n" " sem.release()" msgstr "" +"sem = asyncio.Semaphore(10)\n" +"\n" +"# ... 後で\n" +"await sem.acquire()\n" +"try:\n" +" # 共有リソースを操作する\n" +"finally:\n" +" sem.release()" #: ../../library/asyncio-sync.rst:323 msgid "Acquire a semaphore." @@ -538,25 +598,23 @@ msgstr "BoundedSemaphore" msgid "A bounded semaphore object. Not thread-safe." msgstr "有限セマフォオブジェクトです。スレッドセーフではありません。" -#: ../../library/asyncio-sync.rst:349 msgid "" "Bounded Semaphore is a version of :class:`Semaphore` that raises a :exc:" "`ValueError` in :meth:`~Semaphore.release` if it increases the internal " "counter above the initial *value*." msgstr "" -"有限セマフォは :class:`Semaphore` の一種で、 :meth:`~Semaphore.release` メ" -"ソッドの呼び出しにより内部カウンターが *初期値* よりも増加してしまう場合は :" -"exc:`ValueError` 例外を送出します。" +"有限セマフォは :class:`Semaphore` の一種です。\n" +":meth:`~Semaphore.release` によって内部カウンターが初期値 *value* を超える場" +"合、:exc:`ValueError` を送出します。" -#: ../../library/asyncio-sync.rst:358 msgid "Barrier" -msgstr "" +msgstr "Barrier" -#: ../../library/asyncio-sync.rst:362 msgid "A barrier object. Not thread-safe." msgstr "" +"バリアオブジェクトです。\n" +"スレッドセーフではありません。" -#: ../../library/asyncio-sync.rst:364 msgid "" "A barrier is a simple synchronization primitive that allows to block until " "*parties* number of tasks are waiting on it. Tasks can wait on the :meth:" @@ -564,18 +622,22 @@ msgid "" "tasks end up waiting on :meth:`~Barrier.wait`. At that point all of the " "waiting tasks would unblock simultaneously." msgstr "" +"バリアは、*parties* 個のタスクが待機するまでブロックできる単純な同期プリミ" +"ティブです。\n" +"タスクは :meth:`~Barrier.wait` メソッドで待機でき、指定した数のタスクが :" +"meth:`~Barrier.wait` で待機するまでブロックされます。\n" +"その時点で、待機しているすべてのタスクのブロックが同時に解除されます。" -#: ../../library/asyncio-sync.rst:370 msgid "" ":keyword:`async with` can be used as an alternative to awaiting on :meth:" "`~Barrier.wait`." msgstr "" +":meth:`~Barrier.wait` を await する代わりに :keyword:`async with` を使えま" +"す。" -#: ../../library/asyncio-sync.rst:373 msgid "The barrier can be reused any number of times." -msgstr "" +msgstr "バリアは何度でも再利用できます。" -#: ../../library/asyncio-sync.rst:379 msgid "" "async def example_barrier():\n" " # barrier with 3 parties\n" @@ -598,40 +660,68 @@ msgid "" "\n" "asyncio.run(example_barrier())" msgstr "" +"async def example_barrier():\n" +" # 3 タスクが参加するバリア\n" +" b = asyncio.Barrier(3)\n" +"\n" +" # 待機するタスクを 2 つ作成する\n" +" asyncio.create_task(b.wait())\n" +" asyncio.create_task(b.wait())\n" +"\n" +" await asyncio.sleep(0)\n" +" print(b)\n" +"\n" +" # 3 回目の .wait() の呼び出しでバリアを通過する\n" +" await b.wait()\n" +" print(b)\n" +" print(\"barrier passed\")\n" +"\n" +" await asyncio.sleep(0)\n" +" print(b)\n" +"\n" +"asyncio.run(example_barrier())" -#: ../../library/asyncio-sync.rst:400 msgid "Result of this example is::" -msgstr "" +msgstr "この例の実行結果は次のとおりです。 ::" -#: ../../library/asyncio-sync.rst:402 msgid "" "\n" "\n" "barrier passed\n" "" msgstr "" +"\n" +"\n" +"barrier passed\n" +"" -#: ../../library/asyncio-sync.rst:412 msgid "" "Pass the barrier. When all the tasks party to the barrier have called this " "function, they are all unblocked simultaneously." msgstr "" +"バリアを通過します。\n" +"バリアに参加するすべてのタスクがこの関数を呼び出すと、すべてのタスクのブロッ" +"クが同時に解除されます。" -#: ../../library/asyncio-sync.rst:415 msgid "" "When a waiting or blocked task in the barrier is cancelled, this task exits " "the barrier which stays in the same state. If the state of the barrier is " "\"filling\", the number of waiting task decreases by 1." msgstr "" +"バリアで待機中またはブロック中のタスクがキャンセルされると、そのタスクはバリ" +"アから抜けます。\n" +"バリアの状態は変わりません。\n" +"バリアが \"filling\" 状態の場合、待機中のタスク数は 1 減ります。" -#: ../../library/asyncio-sync.rst:420 msgid "" "The return value is an integer in the range of 0 to ``parties-1``, different " "for each task. This can be used to select a task to do some special " "housekeeping, e.g.::" msgstr "" +"戻り値は 0 から ``parties-1`` までの整数で、タスクごとに異なります。\n" +"これを使うと、後片付けなどの特別な処理を行うタスクを選べます。\n" +"例えば次のようにします。 ::" -#: ../../library/asyncio-sync.rst:424 msgid "" "...\n" "async with barrier as position:\n" @@ -639,41 +729,52 @@ msgid "" " # Only one task prints this\n" " print('End of *draining phase*')" msgstr "" +"...\n" +"async with barrier as position:\n" +" if position == 0:\n" +" # 1 つのタスクだけがこれを表示する\n" +" print('End of *draining phase*')" -#: ../../library/asyncio-sync.rst:430 msgid "" "This method may raise a :class:`BrokenBarrierError` exception if the barrier " "is broken or reset while a task is waiting. It could raise a :exc:" "`CancelledError` if a task is cancelled." msgstr "" +"タスクの待機中にバリアが broken 状態になるかリセットされると、:class:" +"`BrokenBarrierError` が送出される場合があります。\n" +"タスクがキャンセルされると :exc:`CancelledError` が送出される場合があります。" -#: ../../library/asyncio-sync.rst:437 msgid "" "Return the barrier to the default, empty state. Any tasks waiting on it " "will receive the :class:`BrokenBarrierError` exception." msgstr "" +"バリアをデフォルトの空の状態に戻します。\n" +"バリアで待機しているタスクには :class:`BrokenBarrierError` が送出されます。" -#: ../../library/asyncio-sync.rst:440 msgid "" "If a barrier is broken it may be better to just leave it and create a new " "one." msgstr "" +"バリアが broken 状態になった場合は、そのバリアをそのままにして新しく作り直す" +"方がよいこともあります。" -#: ../../library/asyncio-sync.rst:445 msgid "" "Put the barrier into a broken state. This causes any active or future calls " "to :meth:`~Barrier.wait` to fail with the :class:`BrokenBarrierError`. Use " "this for example if one of the tasks needs to abort, to avoid infinite " "waiting tasks." msgstr "" +"バリアを broken 状態にします。\n" +"これにより、実行中および今後の :meth:`~Barrier.wait` の呼び出しは :class:" +"`BrokenBarrierError` で失敗します。\n" +"例えば、いずれかのタスクが処理を中断する必要があるときに、他のタスクが無限に" +"待機しないようにするために使います。" -#: ../../library/asyncio-sync.rst:452 msgid "The number of tasks required to pass the barrier." -msgstr "" +msgstr "バリアを通過するために必要なタスク数です。" -#: ../../library/asyncio-sync.rst:456 msgid "The number of tasks currently waiting in the barrier while filling." -msgstr "" +msgstr "filling 状態のバリアで現在待機しているタスク数です。" #: ../../library/asyncio-sync.rst:460 msgid "A boolean that is ``True`` if the barrier is in the broken state." diff --git a/library/asyncio-task.po b/library/asyncio-task.po index 80d914973..fbfa07065 100644 --- a/library/asyncio-task.po +++ b/library/asyncio-task.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-task.rst:6 msgid "Coroutines and tasks" -msgstr "" +msgstr "コルーチンとタスク" #: ../../library/asyncio-task.rst:8 msgid "" @@ -38,11 +37,9 @@ msgstr "" msgid "Coroutines" msgstr "コルーチン" -#: ../../library/asyncio-task.rst:21 msgid "**Source code:** :source:`Lib/asyncio/coroutines.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/asyncio/coroutines.py`" -#: ../../library/asyncio-task.rst:25 msgid "" ":term:`Coroutines ` declared with the async/await syntax is the " "preferred way of writing asyncio applications. For example, the following " @@ -50,9 +47,8 @@ msgid "" msgstr "" "async/await 構文で宣言された :term:`コルーチン ` は、 asyncio を" "使ったアプリケーションを書くのに推奨される方法です。例えば、次のコードスニ" -"ペットは \"hello\" を出力し、そこから 1 秒待って \"world\" を出力します:: " +"ペットは \"hello\" を出力し、そこから 1 秒待って \"world\" を出力します::" -#: ../../library/asyncio-task.rst:30 msgid "" ">>> import asyncio\n" "\n" @@ -65,6 +61,16 @@ msgid "" "hello\n" "world" msgstr "" +">>> import asyncio\n" +"\n" +">>> async def main():\n" +"... print('hello')\n" +"... await asyncio.sleep(1)\n" +"... print('world')\n" +"\n" +">>> asyncio.run(main())\n" +"hello\n" +"world" #: ../../library/asyncio-task.rst:41 msgid "" @@ -73,11 +79,12 @@ msgstr "" "単にコルーチンを呼び出しただけでは、コルーチンの実行スケジュールは予約されて" "いないことに注意してください::" -#: ../../library/asyncio-task.rst:44 msgid "" ">>> main()\n" "" msgstr "" +">>> main()\n" +"" #: ../../library/asyncio-task.rst:47 msgid "To actually run a coroutine, asyncio provides the following mechanisms:" @@ -102,7 +109,6 @@ msgstr "" "コルーチンを await すること。次のコード片は 1 秒間待機した後に \"hello\" と出" "力し、 *更に* 2 秒間待機してから \"world\" と出力します::" -#: ../../library/asyncio-task.rst:56 msgid "" "import asyncio\n" "import time\n" @@ -121,18 +127,37 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import time\n" +"\n" +"async def say_after(delay, what):\n" +" await asyncio.sleep(delay)\n" +" print(what)\n" +"\n" +"async def main():\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" await say_after(1, 'hello')\n" +" await say_after(2, 'world')\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-task.rst:73 msgid "Expected output::" msgstr "予想される出力::" -#: ../../library/asyncio-task.rst:75 msgid "" "started at 17:13:52\n" "hello\n" "world\n" "finished at 17:13:55" msgstr "" +"started at 17:13:52\n" +"hello\n" +"world\n" +"finished at 17:13:55" #: ../../library/asyncio-task.rst:80 msgid "" @@ -150,7 +175,6 @@ msgstr "" "上のコード例を編集して、ふたつの ``say_after`` コルーチンを *並行して* 走らせ" "てみましょう::" -#: ../../library/asyncio-task.rst:86 msgid "" "async def main():\n" " task1 = asyncio.create_task(\n" @@ -168,6 +192,20 @@ msgid "" "\n" " print(f\"finished at {time.strftime('%X')}\")" msgstr "" +"async def main():\n" +" task1 = asyncio.create_task(\n" +" say_after(1, 'hello'))\n" +"\n" +" task2 = asyncio.create_task(\n" +" say_after(2, 'world'))\n" +"\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" # 両方のタスクが完了するまで待つ (約 2 秒かかる)。\n" +" await task1\n" +" await task2\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")" #: ../../library/asyncio-task.rst:102 msgid "" @@ -177,21 +215,25 @@ msgstr "" "予想される出力が、スニペットの実行が前回よりも 1 秒早いことを示していることに" "注意してください::" -#: ../../library/asyncio-task.rst:105 msgid "" "started at 17:14:32\n" "hello\n" "world\n" "finished at 17:14:34" msgstr "" +"started at 17:14:32\n" +"hello\n" +"world\n" +"finished at 17:14:34" -#: ../../library/asyncio-task.rst:110 msgid "" "The :class:`asyncio.TaskGroup` class provides a more modern alternative to :" "func:`create_task`. Using this API, the last example becomes::" msgstr "" +":class:`asyncio.TaskGroup` クラスは、:func:`create_task` に代わるより新しい手" +"段です。\n" +"この API を使うと、直前の例は次のようになります。 ::" -#: ../../library/asyncio-task.rst:114 msgid "" "async def main():\n" " async with asyncio.TaskGroup() as tg:\n" @@ -207,10 +249,22 @@ msgid "" "\n" " print(f\"finished at {time.strftime('%X')}\")" msgstr "" +"async def main():\n" +" async with asyncio.TaskGroup() as tg:\n" +" task1 = tg.create_task(\n" +" say_after(1, 'hello'))\n" +"\n" +" task2 = tg.create_task(\n" +" say_after(2, 'world'))\n" +"\n" +" print(f\"started at {time.strftime('%X')}\")\n" +"\n" +" # コンテキストマネージャーを抜けるときに暗黙に await する。\n" +"\n" +" print(f\"finished at {time.strftime('%X')}\")" -#: ../../library/asyncio-task.rst:128 msgid "The timing and output should be the same as for the previous version." -msgstr "" +msgstr "実行にかかる時間と出力は、直前の例と同じになるはずです。" #: ../../library/asyncio-task.rst:130 msgid ":class:`asyncio.TaskGroup`." @@ -246,7 +300,6 @@ msgstr "" "Python のコルーチンは *awaitable* であり、他のコルーチンから待機されることが" "できます::" -#: ../../library/asyncio-task.rst:152 msgid "" "import asyncio\n" "\n" @@ -264,6 +317,21 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def nested():\n" +" return 42\n" +"\n" +"async def main():\n" +" # \"nested()\" を呼び出すだけでは何も起こらない。\n" +" # コルーチンオブジェクトは作成されるが await されないので、\n" +" # まったく実行されない。\n" +" nested() # \"RuntimeWarning\" が発生する。\n" +"\n" +" # 今度は await してみる:\n" +" print(await nested()) # \"42\" と表示する。\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-task.rst:170 msgid "" @@ -300,7 +368,6 @@ msgstr "" ":func:`asyncio.create_task` のような関数で、コルーチンが *Task* にラップされ" "ているとき、自動的にコルーチンは即時実行されるようにスケジュールされます::" -#: ../../library/asyncio-task.rst:187 msgid "" "import asyncio\n" "\n" @@ -318,6 +385,20 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def nested():\n" +" return 42\n" +"\n" +"async def main():\n" +" # nested() がまもなく \"main()\" と並行して実行されるようにする。\n" +" task = asyncio.create_task(nested())\n" +"\n" +" # \"task\" で \"nested()\" をキャンセルしたり、\n" +" # 単に await して完了を待ったりできる:\n" +" await task\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio-task.rst:205 msgid "Futures" @@ -363,7 +444,6 @@ msgstr "" "Future オブジェクトはライブラリや asyncio のAPIで外部に提供されることもあり、" "await (待機)されることができます::" -#: ../../library/asyncio-task.rst:221 msgid "" "async def main():\n" " await function_that_returns_a_future_object()\n" @@ -374,6 +454,14 @@ msgid "" " some_python_coroutine()\n" " )" msgstr "" +"async def main():\n" +" await function_that_returns_a_future_object()\n" +"\n" +" # これも有効:\n" +" await asyncio.gather(\n" +" function_that_returns_a_future_object(),\n" +" some_python_coroutine()\n" +" )" #: ../../library/asyncio-task.rst:230 msgid "" @@ -383,9 +471,8 @@ msgstr "" "Future オブジェクトを返す低レベル関数の良い例は :meth:`loop.run_in_executor` " "です。" -#: ../../library/asyncio-task.rst:235 msgid "Creating tasks" -msgstr "" +msgstr "タスクの作成" #: ../../library/asyncio-task.rst:237 msgid "**Source code:** :source:`Lib/asyncio/tasks.py`" @@ -400,12 +487,15 @@ msgstr "" "ケジュールします。\n" "Task オブジェクトを返します。" -#: ../../library/asyncio-task.rst:246 msgid "" "The full function signature is largely the same as that of the :class:`Task` " "constructor (or factory) - all of the keyword arguments to this function are " "passed through to that interface." msgstr "" +"関数のシグネチャ全体は :class:`Task` のコンストラクター (またはファクトリー) " +"とほぼ同じです。\n" +"この関数に渡したキーワード引数はすべて、そのコンストラクターやファクトリーに" +"渡されます。" #: ../../library/asyncio-task.rst:250 msgid "" @@ -417,13 +507,17 @@ msgstr "" "の :class:`contextvars.Context` を指定できます。*context* が省略された場合、" "現在のコンテキストのコピーが作成されます。" -#: ../../library/asyncio-task.rst:254 msgid "" "An optional keyword-only *eager_start* argument allows specifying if the " "task should execute eagerly during the call to create_task, or be scheduled " "later. If *eager_start* is not passed the mode set by :meth:`loop." "set_task_factory` will be used." msgstr "" +"省略可能なキーワード専用引数 *eager_start* では、``create_task()`` の呼び出し" +"中にタスクの実行を即座に開始するか、後で実行するようにスケジュールするかを指" +"定できます。\n" +"*eager_start* を渡さない場合は :meth:`loop.set_task_factory` で設定したモード" +"を使います。" #: ../../library/asyncio-task.rst:259 msgid "" @@ -434,12 +528,14 @@ msgstr "" "行されます。現在のスレッドに実行中のループが無い場合は、 :exc:`RuntimeError` " "が送出されます。" -#: ../../library/asyncio-task.rst:265 msgid "" ":meth:`asyncio.TaskGroup.create_task` is a new alternative leveraging " "structural concurrency; it allows for waiting for a group of related tasks " "with strong safety guarantees." msgstr "" +":meth:`asyncio.TaskGroup.create_task` は、構造化された並行処理を使う新しい代" +"替手段です。\n" +"強い安全性の保証のもとで、関連するタスクのグループを待機できます。" #: ../../library/asyncio-task.rst:271 msgid "" @@ -454,7 +550,6 @@ msgstr "" "なくてもガーベジコレクションされる可能性があります。信頼性のある \"fire-and-" "forget\" バックグラウンドタスクが必要な場合、コレクションを使ってください。" -#: ../../library/asyncio-task.rst:278 msgid "" "background_tasks = set()\n" "\n" @@ -469,8 +564,18 @@ msgid "" " # completion:\n" " task.add_done_callback(background_tasks.discard)" msgstr "" +"background_tasks = set()\n" +"\n" +"for i in range(10):\n" +" task = asyncio.create_task(some_coro(param=i))\n" +"\n" +" # タスクを集合に追加する。これにより強参照が作成される。\n" +" background_tasks.add(task)\n" +"\n" +" # 完了したタスクへの参照を保持し続けないように、\n" +" # 各タスクが完了したら集合から自身への参照を削除するようにする:\n" +" task.add_done_callback(background_tasks.discard)" -#: ../../library/asyncio-task.rst:291 msgid "" "Note that this approach never awaits the tasks, so if a task fails, its " "exception is never retrieved and asyncio logs a \"Task exception was never " @@ -478,13 +583,21 @@ msgid "" "class:`asyncio.TaskGroup` which keeps a strong reference to each task, " "awaits them and propagates their exceptions::" msgstr "" +"この方法ではタスクを await しないため、タスクが失敗しても例外は取得されませ" +"ん。\n" +"タスクがガベージコレクションされると、asyncio は \"Task exception was never " +"retrieved\" というメッセージをログに記録します。\n" +"これを避けるには :class:`asyncio.TaskGroup` を使ってください。\n" +"各タスクへの強参照を保持してタスクを await し、例外を伝播させます。 ::" -#: ../../library/asyncio-task.rst:298 msgid "" "async with asyncio.TaskGroup() as tg:\n" " for i in range(10):\n" " tg.create_task(some_coro(param=i))" msgstr "" +"async with asyncio.TaskGroup() as tg:\n" +" for i in range(10):\n" +" tg.create_task(some_coro(param=i))" #: ../../library/asyncio-task.rst:304 ../../library/asyncio-task.rst:1265 msgid "Added the *name* parameter." @@ -494,13 +607,13 @@ msgstr "*name* パラメータを追加しました。" msgid "Added the *context* parameter." msgstr "*context* パラメータを追加しました。" -#: ../../library/asyncio-task.rst:310 msgid "Added the *eager_start* parameter by passing on all *kwargs*." msgstr "" +"すべての *kwargs* を渡すようにすることで、*eager_start* パラメーターが追加さ" +"れました。" -#: ../../library/asyncio-task.rst:315 msgid "Task cancellation" -msgstr "" +msgstr "タスクのキャンセル" #: ../../library/asyncio-task.rst:317 msgid "" @@ -510,7 +623,6 @@ msgstr "" "タスクは簡単に、そして安全にキャンセルできます。タスクがキャンセルされた場" "合、:exc:`asyncio.CancelledError` が次の機会に送出されます。" -#: ../../library/asyncio-task.rst:321 msgid "" "It is recommended that coroutines use ``try/finally`` blocks to robustly " "perform clean-up logic. In case :exc:`asyncio.CancelledError` is explicitly " @@ -518,8 +630,13 @@ msgid "" "`asyncio.CancelledError` directly subclasses :exc:`BaseException` so most " "code will not need to be aware of it." msgstr "" +"後片付けを確実に行うため、コルーチンでは ``try/finally`` ブロックを使うことを" +"推奨します。\n" +":exc:`asyncio.CancelledError` を明示的に捕捉した場合、通常は後片付けが終わっ" +"たら伝播させてください。\n" +":exc:`asyncio.CancelledError` は :exc:`BaseException` の直接のサブクラスなの" +"で、ほとんどのコードでは特別に意識する必要はありません。" -#: ../../library/asyncio-task.rst:327 msgid "" "The asyncio components that enable structured concurrency, like :class:" "`asyncio.TaskGroup` and :func:`asyncio.timeout`, are implemented using " @@ -529,88 +646,114 @@ msgid "" "exc:`asyncio.CancelledError` is truly desired, it is necessary to also call " "``uncancel()`` to completely remove the cancellation state." msgstr "" +":class:`asyncio.TaskGroup` や :func:`asyncio.timeout` など、構造化された並行" +"処理を実現する asyncio の構成要素は内部でキャンセルを使って実装されていま" +"す。\n" +"コルーチンが :exc:`asyncio.CancelledError` を握りつぶすと、正しく動作しない場" +"合があります。\n" +"同様に、ユーザーのコードから :meth:`uncancel ` を呼び" +"出すことも通常は避けてください。\n" +"ただし、本当に :exc:`asyncio.CancelledError` を抑制したい場合は、キャンセル状" +"態を完全に解除するために ``uncancel()`` も呼び出す必要があります。" -#: ../../library/asyncio-task.rst:339 msgid "Task groups" -msgstr "" +msgstr "タスクグループ" -#: ../../library/asyncio-task.rst:341 msgid "" "Task groups combine a task creation API with a convenient and reliable way " "to wait for all tasks in the group to finish." msgstr "" +"タスクグループは、タスクを作成する API と、グループ内のすべてのタスクの終了を" +"便利かつ確実に待つ手段を組み合わせたものです。" -#: ../../library/asyncio-task.rst:346 msgid "" "An :ref:`asynchronous context manager ` holding a " "group of tasks. Tasks can be added to the group using :meth:`create_task`. " "All tasks are awaited when the context manager exits." msgstr "" +"タスクのグループを保持する :ref:`非同期コンテキストマネージャー ` です。\n" +":meth:`create_task` でタスクをグループに追加できます。\n" +"コンテキストマネージャーを抜けるときに、すべてのタスクを await します。" -#: ../../library/asyncio-task.rst:355 msgid "" "Create a task in this task group. The signature matches that of :func:" "`asyncio.create_task`. If the task group is inactive (e.g. not yet entered, " "already finished, or in the process of shutting down), we will close the " "given ``coro`` and raise :exc:`RuntimeError`." msgstr "" +"このタスクグループにタスクを作成します。\n" +"シグネチャは :func:`asyncio.create_task` と同じです。\n" +"タスクグループが非アクティブ (まだ開始していない、すでに終了した、終了処理中" +"など) の場合は、渡された ``coro`` を閉じて :exc:`RuntimeError` を送出します。" -#: ../../library/asyncio-task.rst:363 msgid "Close the given coroutine if the task group is not active." msgstr "" +"タスクグループがアクティブでない場合、渡されたコルーチンを閉じるようになりま" +"した。" -#: ../../library/asyncio-task.rst:367 msgid "Passes on all *kwargs* to :meth:`loop.create_task`" -msgstr "" +msgstr "すべての *kwargs* を :meth:`loop.create_task` に渡すようになりました。" -#: ../../library/asyncio-task.rst:371 msgid "" "Cancel the task group. This is a non-exceptional, early exit of the task " "group's lifetime -- useful once the group's goal has been met or its " "services no longer needed." msgstr "" +"タスクグループをキャンセルします。\n" +"例外を発生させずにタスクグループの処理を早期に終了します。\n" +"グループの目的を達成した場合や、グループの処理が不要になった場合に役立ちま" +"す。" -#: ../../library/asyncio-task.rst:375 msgid "" ":meth:`~asyncio.Task.cancel` will be called on any tasks in the group that " "aren't yet done, as well as the parent (body) of the group. The task group " "context manager will exit *without* :exc:`asyncio.CancelledError` being " "raised." msgstr "" +"グループ内でまだ完了していないタスクと、グループの親 (本体) に対して :meth:" +"`~asyncio.Task.cancel` を呼び出します。\n" +"タスクグループのコンテキストマネージャーは、:exc:`asyncio.CancelledError` を" +"送出 *せずに* 終了します。" -#: ../../library/asyncio-task.rst:379 msgid "" "If :meth:`cancel` is called before entering the task group, the group will " "be cancelled upon entry. This is useful for patterns where one piece of " "code passes an unused :class:`asyncio.TaskGroup` instance to another in " "order to have the ability to cancel anything run within the group." msgstr "" +"タスクグループに入る前に :meth:`cancel` を呼び出すと、グループに入った時点で" +"キャンセルされます。\n" +"これは、あるコードから別のコードへ未使用の :class:`asyncio.TaskGroup` インス" +"タンスを渡し、グループ内で実行される処理をキャンセルできるようにするパターン" +"で役立ちます。" -#: ../../library/asyncio-task.rst:384 msgid "" ":meth:`cancel` is idempotent and may be called after the task group has " "already exited." msgstr "" +":meth:`cancel` は冪等で、タスクグループがすでに終了した後にも呼び出せます。" -#: ../../library/asyncio-task.rst:387 msgid "Some ways to use :meth:`cancel`:" -msgstr "" +msgstr ":meth:`cancel` の使用方法の例:" -#: ../../library/asyncio-task.rst:389 msgid "call it from the task group body based on some condition or event" -msgstr "" +msgstr "条件やイベントに応じてタスクグループの本体から呼び出す" -#: ../../library/asyncio-task.rst:390 msgid "" "pass the task group instance to child tasks via :meth:`create_task`, " "allowing a child task to conditionally cancel the entire group" msgstr "" +":meth:`create_task` で子タスクにタスクグループのインスタンスを渡し、子タスク" +"が条件に応じてグループ全体をキャンセルできるようにする" -#: ../../library/asyncio-task.rst:392 msgid "" "pass the task group instance or bound :meth:`cancel` method to some other " "task *before* opening the task group, allowing remote cancellation" msgstr "" +"タスクグループを開始する *前に*、タスクグループのインスタンスまたは束縛され" +"た :meth:`cancel` メソッドを他のタスクに渡し、そのタスクからキャンセルできる" +"ようにする" #: ../../library/asyncio-task.rst:397 ../../library/asyncio-task.rst:565 #: ../../library/asyncio-task.rst:738 ../../library/asyncio-task.rst:799 @@ -618,7 +761,6 @@ msgstr "" msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/asyncio-task.rst:399 msgid "" "async def main():\n" " async with asyncio.TaskGroup() as tg:\n" @@ -627,8 +769,13 @@ msgid "" " print(f\"Both tasks have completed now: {task1.result()}, {task2." "result()}\")" msgstr "" +"async def main():\n" +" async with asyncio.TaskGroup() as tg:\n" +" task1 = tg.create_task(some_coro(...))\n" +" task2 = tg.create_task(another_coro(...))\n" +" print(f\"Both tasks have completed now: {task1.result()}, {task2." +"result()}\")" -#: ../../library/asyncio-task.rst:405 msgid "" "The ``async with`` statement will wait for all tasks in the group to finish. " "While waiting, new tasks may still be added to the group (for example, by " @@ -638,8 +785,14 @@ msgid "" "last task has finished and the ``async with`` block is exited, no new tasks " "may be added to the group." msgstr "" +"``async with`` 文はグループ内のすべてのタスクが終了するまで待ちます。\n" +"待機中も新しいタスクをグループに追加できます (例えば、いずれかのコルーチンに " +"``tg`` を渡し、そのコルーチンで ``tg.create_task()`` を呼び出します)。\n" +"条件に応じて ``tg.cancel()`` でタスクグループ全体の終了を要求することもできま" +"す。\n" +"最後のタスクが終了して ``async with`` ブロックを抜けると、グループに新しいタ" +"スクを追加することはできません。" -#: ../../library/asyncio-task.rst:413 msgid "" "The first time any of the tasks belonging to the group fails with an " "exception other than :exc:`asyncio.CancelledError`, the remaining tasks in " @@ -650,16 +803,26 @@ msgid "" "exc:`asyncio.CancelledError` will interrupt an ``await``, but it will not " "bubble out of the containing ``async with`` statement." msgstr "" +"グループ内のいずれかのタスクが :exc:`asyncio.CancelledError` 以外の例外で初め" +"て失敗した時点で、グループ内の残りのタスクをキャンセルします。\n" +"それ以降はグループにタスクを追加できません。\n" +"この時点で ``async with`` 文の本体がまだ実行中 (つまり :meth:`~object." +"__aexit__` がまだ呼び出されていない) なら、``async with`` 文を直接含むタスク" +"もキャンセルされます。\n" +"これによって生じる :exc:`asyncio.CancelledError` は ``await`` を中断します" +"が、それを含む ``async with`` 文の外には伝播しません。" -#: ../../library/asyncio-task.rst:423 msgid "" "Once all tasks have finished, if any tasks have failed with an exception " "other than :exc:`asyncio.CancelledError`, those exceptions are combined in " "an :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup` (as appropriate; see " "their documentation) which is then raised." msgstr "" +"すべてのタスクが終了した時点で、:exc:`asyncio.CancelledError` 以外の例外で失" +"敗したタスクがあれば、それらの例外を :exc:`ExceptionGroup` または :exc:" +"`BaseExceptionGroup` にまとめて送出します (どちらを使うかは、それぞれのドキュ" +"メントを参照してください)。" -#: ../../library/asyncio-task.rst:430 msgid "" "Two base exceptions are treated specially: If any task fails with :exc:" "`KeyboardInterrupt` or :exc:`SystemExit`, the task group still cancels the " @@ -667,8 +830,12 @@ msgid "" "`KeyboardInterrupt` or :exc:`SystemExit` is re-raised instead of :exc:" "`ExceptionGroup` or :exc:`BaseExceptionGroup`." msgstr "" +"基底例外のうち、2 つは特別に扱います。\n" +"いずれかのタスクが :exc:`KeyboardInterrupt` または :exc:`SystemExit` で失敗し" +"た場合も、タスクグループは残りのタスクをキャンセルして終了を待ちます。\n" +"ただし、その後は :exc:`ExceptionGroup` や :exc:`BaseExceptionGroup` ではな" +"く、最初の :exc:`KeyboardInterrupt` または :exc:`SystemExit` を再送出します。" -#: ../../library/asyncio-task.rst:436 msgid "" "If the body of the ``async with`` statement exits with an exception (so :" "meth:`~object.__aexit__` is called with an exception set), this is treated " @@ -682,8 +849,19 @@ msgid "" "with``: if it raises :exc:`GeneratorExit` and none of the other tasks raise " "exceptions that would be reported, then the :exc:`GeneratorExit` is reraised." msgstr "" +"``async with`` 文の本体が例外によって終了した場合 (つまり例外が設定された状態" +"で :meth:`~object.__aexit__` が呼び出された場合) は、タスクが失敗した場合と同" +"じように扱います。\n" +"残りのタスクをキャンセルして終了を待ち、キャンセル以外の例外を例外グループに" +"まとめて送出します。\n" +":meth:`~object.__aexit__` に渡された例外も、:exc:`asyncio.CancelledError` で" +"なければ例外グループに含めます。\n" +":exc:`KeyboardInterrupt` と :exc:`SystemExit` には、前の段落と同じ特別な扱い" +"をします。\n" +"``async with`` の本体に限り、さらに特別な扱いがあります。\n" +"本体が :exc:`GeneratorExit` を送出し、他のタスクが報告対象となる例外を送出し" +"なかった場合は、その :exc:`GeneratorExit` を再送出します。" -#: ../../library/asyncio-task.rst:452 msgid "" "Task groups are careful not to mix up the internal cancellation used to " "\"wake up\" their :meth:`~object.__aexit__` with cancellation requests for " @@ -693,30 +871,41 @@ msgid "" "group will process its exceptions, and then the outer task group will " "receive another cancellation and process its own exceptions." msgstr "" +"タスクグループは、:meth:`~object.__aexit__` を「起こす」ための内部的なキャン" +"セルと、タスクグループが実行されているタスクに対する外部からのキャンセル要求" +"を区別します。\n" +"特に、タスクグループが構文上入れ子になっていて、両方のグループの子タスクで同" +"時に例外が発生した場合は、まず内側のグループが例外を処理します。\n" +"その後、外側のグループが別のキャンセルを受け取り、自身の例外を処理します。" -#: ../../library/asyncio-task.rst:460 msgid "" "In the case where a task group is cancelled externally and also must raise " "an :exc:`ExceptionGroup`, it will call the parent task's :meth:`~asyncio." "Task.cancel` method. This ensures that a :exc:`asyncio.CancelledError` will " "be raised at the next :keyword:`await`, so the cancellation is not lost." msgstr "" +"タスクグループが外部からキャンセルされ、かつ :exc:`ExceptionGroup` を送出する" +"必要もある場合は、親タスクの :meth:`~asyncio.Task.cancel` メソッドを呼び出し" +"ます。\n" +"これにより、次の :keyword:`await` で :exc:`asyncio.CancelledError` が送出さ" +"れ、キャンセルが失われないようにします。" -#: ../../library/asyncio-task.rst:466 msgid "" "Task groups preserve the cancellation count reported by :meth:`asyncio.Task." "cancelling`." msgstr "" +"タスクグループは :meth:`asyncio.Task.cancelling` が返すキャンセル回数を保持し" +"ます。" -#: ../../library/asyncio-task.rst:471 msgid "" "Improved handling of simultaneous internal and external cancellations and " "correct preservation of cancellation counts." msgstr "" +"内部と外部からのキャンセルが同時に発生した場合の処理が改善され、キャンセル回" +"数が正しく保持されるようになりました。" -#: ../../library/asyncio-task.rst:476 msgid "Addition of the special case for :exc:`GeneratorExit`." -msgstr "" +msgstr ":exc:`GeneratorExit` の特別な扱いが追加されました。" #: ../../library/asyncio-task.rst:479 msgid "Sleeping" @@ -741,22 +930,21 @@ msgstr "" "``sleep()`` は常に現在の Task を一時中断し、他の Task が実行されるのを許可し" "ます。" -#: ../../library/asyncio-task.rst:492 msgid "" "Setting the delay to 0 provides an optimized path to allow other tasks to " "run. This can be used by long-running functions to avoid blocking the event " "loop for the full duration of the function call." msgstr "" -"delay を 0 に設定することで、他のタスクを実行可能にする最適な方針を提供しま" -"す。この方法は、実行時間の長い関数が、その実行時間全体にわたってイベントルー" -"プをブロックしないようにするために利用できます。" +"``delay`` を 0 に設定すると、最適化された処理経路で他のタスクを実行できるよう" +"にします。\n" +"長時間実行する関数でこれを使うと、関数の呼び出し中ずっとイベントループをブ" +"ロックしてしまうのを避けられます。" #: ../../library/asyncio-task.rst:498 msgid "" "Example of coroutine displaying the current date every second for 5 seconds::" msgstr "現在の時刻を5秒間、毎秒表示するコルーチンの例::" -#: ../../library/asyncio-task.rst:501 msgid "" "import asyncio\n" "import datetime as dt\n" @@ -772,6 +960,19 @@ msgid "" "\n" "asyncio.run(display_date())" msgstr "" +"import asyncio\n" +"import datetime as dt\n" +"\n" +"async def display_date():\n" +" loop = asyncio.get_running_loop()\n" +" end_time = loop.time() + 5.0\n" +" while True:\n" +" print(dt.datetime.now())\n" +" if (loop.time() + 1.0) >= end_time:\n" +" break\n" +" await asyncio.sleep(1)\n" +"\n" +"asyncio.run(display_date())" #: ../../library/asyncio-task.rst:516 ../../library/asyncio-task.rst:614 #: ../../library/asyncio-task.rst:713 ../../library/asyncio-task.rst:887 @@ -779,13 +980,13 @@ msgstr "" msgid "Removed the *loop* parameter." msgstr "*loop* パラメータが削除されました。" -#: ../../library/asyncio-task.rst:519 msgid "Raises :exc:`ValueError` if *delay* is :data:`~math.nan`." msgstr "" +"*delay* が :data:`~math.nan` の場合に :exc:`ValueError` を送出するようになり" +"ました。" -#: ../../library/asyncio-task.rst:524 msgid "Running tasks concurrently" -msgstr "" +msgstr "タスクの並行実行" #: ../../library/asyncio-task.rst:528 msgid "" @@ -853,7 +1054,6 @@ msgstr "" "これは、起動された 1 つの Task あるいは Future のキャンセルが、他の Task ある" "いは Future のキャンセルを引き起こすのを避けるためです。" -#: ../../library/asyncio-task.rst:556 msgid "" "A new alternative to create and run tasks concurrently and wait for their " "completion is :class:`asyncio.TaskGroup`. *TaskGroup* provides stronger " @@ -862,8 +1062,14 @@ msgid "" "*TaskGroup* will, while *gather* will not, cancel the remaining scheduled " "tasks." msgstr "" +"タスクを作成して並行に実行し、完了を待つための新しい代替手段として :class:" +"`asyncio.TaskGroup` があります。\n" +"サブタスクを入れ子にスケジュールする場合、*TaskGroup* は *gather* よりも強い" +"安全性を保証します。\n" +"タスク (またはタスクがスケジュールしたサブタスク) が例外を送出すると、" +"*TaskGroup* はスケジュール済みの残りのタスクをキャンセルしますが、*gather* は" +"キャンセルしません。" -#: ../../library/asyncio-task.rst:567 msgid "" "import asyncio\n" "\n" @@ -901,8 +1107,42 @@ msgid "" "# Task C: factorial(4) = 24\n" "# [2, 6, 24]" msgstr "" +"import asyncio\n" +"\n" +"async def factorial(name, number):\n" +" f = 1\n" +" for i in range(2, number + 1):\n" +" print(f\"Task {name}: Compute factorial({number}), currently i={i}..." +"\")\n" +" await asyncio.sleep(1)\n" +" f *= i\n" +" print(f\"Task {name}: factorial({number}) = {f}\")\n" +" return f\n" +"\n" +"async def main():\n" +" # 3 つの呼び出しを並行に実行するようスケジュールする:\n" +" L = await asyncio.gather(\n" +" factorial(\"A\", 2),\n" +" factorial(\"B\", 3),\n" +" factorial(\"C\", 4),\n" +" )\n" +" print(L)\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# 期待される出力:\n" +"#\n" +"# Task A: Compute factorial(2), currently i=2...\n" +"# Task B: Compute factorial(3), currently i=2...\n" +"# Task C: Compute factorial(4), currently i=2...\n" +"# Task A: factorial(2) = 2\n" +"# Task B: Compute factorial(3), currently i=3...\n" +"# Task C: Compute factorial(4), currently i=3...\n" +"# Task B: factorial(3) = 6\n" +"# Task C: Compute factorial(4), currently i=4...\n" +"# Task C: factorial(4) = 24\n" +"# [2, 6, 24]" -#: ../../library/asyncio-task.rst:603 msgid "" "If *return_exceptions* is false, cancelling gather() after it has been " "marked done won't cancel any submitted awaitables. For instance, gather can " @@ -910,6 +1150,12 @@ msgid "" "calling ``gather.cancel()`` after catching an exception (raised by one of " "the awaitables) from gather won't cancel any other awaitables." msgstr "" +"*return_exceptions* が偽の場合、完了状態になった後で ``gather()`` をキャンセ" +"ルしても、渡された awaitable はキャンセルされません。\n" +"例えば、``gather`` は例外を呼び出し元に伝播した時点で完了状態になることがあり" +"ます。\n" +"そのため、いずれかの awaitable が送出した例外を ``gather`` から捕捉した後で " +"``gather.cancel()`` を呼び出しても、他の awaitable はキャンセルされません。" #: ../../library/asyncio-task.rst:610 msgid "" @@ -919,22 +1165,21 @@ msgstr "" "*gather* 自身がキャンセルされた場合は、 *return_exceptions* の値に関わらず" "キャンセルが伝搬されます。" -#: ../../library/asyncio-task.rst:617 msgid "" "Deprecation warning is emitted if no positional arguments are provided or " "not all positional arguments are Future-like objects and there is no running " "event loop." msgstr "" +"位置引数が渡されていない場合、または位置引数のすべてが Future のようなオブ" +"ジェクトというわけではなく、かつ実行中のイベントループがない場合に、非推奨の" +"警告を出すようになりました。" -#: ../../library/asyncio-task.rst:626 msgid "Eager task factory" -msgstr "" +msgstr "即時実行するタスクファクトリー" -#: ../../library/asyncio-task.rst:630 msgid "A task factory for eager task execution." -msgstr "" +msgstr "タスクの実行を即座に開始するタスクファクトリーです。" -#: ../../library/asyncio-task.rst:632 msgid "" "When using this factory (via :meth:`loop.set_task_factory(asyncio." "eager_task_factory) `), coroutines begin execution " @@ -943,14 +1188,21 @@ msgid "" "overhead of loop scheduling is avoided for coroutines that complete " "synchronously." msgstr "" +"このファクトリーを :meth:`loop.set_task_factory(asyncio.eager_task_factory) " +"` で使うと、:class:`Task` の構築中にコルーチンの実行を" +"同期的に開始します。\n" +"タスクがイベントループにスケジュールされるのは、処理がブロックした場合だけで" +"す。\n" +"同期的に完了するコルーチンではループへのスケジュールに伴うオーバーヘッドを避" +"けられるため、性能が向上する場合があります。" -#: ../../library/asyncio-task.rst:638 msgid "" "A common example where this is beneficial is coroutines which employ caching " "or memoization to avoid actual I/O when possible." msgstr "" +"これが役立つ典型例は、キャッシュやメモ化を使って可能な限り実際の I/O を避ける" +"コルーチンです。" -#: ../../library/asyncio-task.rst:643 msgid "" "Immediate execution of the coroutine is a semantic change. If the coroutine " "returns or raises, the task is never scheduled to the event loop. If the " @@ -958,31 +1210,45 @@ msgid "" "change may introduce behavior changes to existing applications. For example, " "the application's task execution order is likely to change." msgstr "" +"コルーチンを即座に実行すると、実行の意味が変わります。\n" +"コルーチンが値を返すか例外を送出すると、タスクはイベントループにスケジュール" +"されません。\n" +"コルーチンの実行がブロックすると、タスクはイベントループにスケジュールされま" +"す。\n" +"この変更により、既存のアプリケーションの動作が変わる可能性があります。\n" +"例えば、タスクの実行順序は変わる可能性が高いでしょう。" -#: ../../library/asyncio-task.rst:654 msgid "" "Create an eager task factory, similar to :func:`eager_task_factory`, using " "the provided *custom_task_constructor* when creating a new task instead of " "the default :class:`Task`." msgstr "" +":func:`eager_task_factory` と同様に即時実行するタスクファクトリーを作成しま" +"す。\n" +"新しいタスクの作成には、デフォルトの :class:`Task` の代わりに、指定された " +"*custom_task_constructor* を使います。" -#: ../../library/asyncio-task.rst:658 msgid "" "*custom_task_constructor* must be a *callable* with the signature matching " "the signature of :class:`Task.__init__ `. The callable must return a :" "class:`asyncio.Task`-compatible object." msgstr "" +"*custom_task_constructor* は :class:`Task.__init__ ` と同じシグネチャを" +"持つ *呼び出し可能オブジェクト* でなければなりません。\n" +"このオブジェクトは :class:`asyncio.Task` と互換性のあるオブジェクトを返す必要" +"があります。" -#: ../../library/asyncio-task.rst:662 msgid "" "This function returns a *callable* intended to be used as a task factory of " "an event loop via :meth:`loop.set_task_factory(factory) `)." msgstr "" +"この関数は、:meth:`loop.set_task_factory(factory) ` で" +"イベントループのタスクファクトリーとして使うための *呼び出し可能オブジェクト" +"* を返します。" -#: ../../library/asyncio-task.rst:669 msgid "Shielding from cancellation" -msgstr "" +msgstr "キャンセルからの保護" #: ../../library/asyncio-task.rst:673 msgid "" @@ -1001,21 +1267,20 @@ msgstr "" msgid "The statement::" msgstr "文::" -#: ../../library/asyncio-task.rst:680 msgid "" "task = asyncio.create_task(something())\n" "res = await shield(task)" msgstr "" +"task = asyncio.create_task(something())\n" +"res = await shield(task)" #: ../../library/asyncio-task.rst:683 msgid "is equivalent to::" msgstr "は、以下と同じです ::" -#: ../../library/asyncio-task.rst:685 msgid "res = await something()" -msgstr "" +msgstr "res = await something()" -#: ../../library/asyncio-task.rst:687 msgid "" "*except* that if the coroutine containing it is cancelled, the Task running " "in ``something()`` is not cancelled. From the point of view of " @@ -1023,11 +1288,11 @@ msgid "" "still cancelled, so the \"await\" expression still raises a :exc:" "`CancelledError`." msgstr "" -"それを含むコルーチンがキャンセルされた場合を *除き*、``something()`` 内で動作" -"している Task はキャンセルされません。\n" -"``something()`` 側から見るとキャンセルは発生しません。\n" -"呼び出し元がキャンセルされた場合でも、 \"await\" 式は :exc:`CancelledError` " -"を送出します。" +"ただし、これを含むコルーチンがキャンセルされても、``something()`` を実行して" +"いる Task はキャンセルされない *という違いがあります*。\n" +"``something()`` 側から見ると、キャンセルは発生していません。\n" +"呼び出し元はキャンセルされるため、\"await\" 式は :exc:`CancelledError` を送出" +"します。" #: ../../library/asyncio-task.rst:693 msgid "" @@ -1046,7 +1311,6 @@ msgstr "" "完全にキャンセルを無視したい場合 (推奨はしません) は、 ``shield()`` 関数は次" "のように try/except 節と組み合わせることになるでしょう::" -#: ../../library/asyncio-task.rst:700 msgid "" "task = asyncio.create_task(something())\n" "try:\n" @@ -1054,71 +1318,92 @@ msgid "" "except CancelledError:\n" " res = None" msgstr "" +"task = asyncio.create_task(something())\n" +"try:\n" +" res = await shield(task)\n" +"except CancelledError:\n" +" res = None" -#: ../../library/asyncio-task.rst:708 msgid "" "Save a reference to tasks passed to this function, to avoid a task " "disappearing mid-execution. The event loop only keeps weak references to " "tasks. A task that isn't referenced elsewhere may get garbage collected at " "any time, even before it's done." msgstr "" +"タスクが実行途中で消えないように、この関数に渡すタスクへの参照を保持してくだ" +"さい。\n" +"イベントループはタスクへの弱参照しか保持しません。\n" +"他から参照されていないタスクは、完了前でもいつでもガベージコレクションされる" +"可能性があります。" -#: ../../library/asyncio-task.rst:716 msgid "" "Deprecation warning is emitted if *aw* is not Future-like object and there " "is no running event loop." msgstr "" +"*aw* が Future のようなオブジェクトでなく、実行中のイベントループもない場合" +"に、非推奨の警告を出すようになりました。" #: ../../library/asyncio-task.rst:722 msgid "Timeouts" msgstr "タイムアウト" -#: ../../library/asyncio-task.rst:726 msgid "" "Return an :ref:`asynchronous context manager ` that " "can be used to limit the amount of time spent waiting on something." msgstr "" +"待機に費やす時間を制限できる :ref:`非同期コンテキストマネージャー ` を返します。" -#: ../../library/asyncio-task.rst:730 msgid "" "*delay* can either be ``None``, or a float/int number of seconds to wait. If " "*delay* is ``None``, no time limit will be applied; this can be useful if " "the delay is unknown when the context manager is created." msgstr "" +"*delay* には ``None``、または待機する秒数を浮動小数点数か整数で指定できま" +"す。\n" +"*delay* が ``None`` の場合、時間制限は適用されません。\n" +"コンテキストマネージャーの作成時点で待機時間が分からない場合に便利です。" -#: ../../library/asyncio-task.rst:735 msgid "" "In either case, the context manager can be rescheduled after creation using :" "meth:`Timeout.reschedule`." msgstr "" +"どちらの場合も、作成後に :meth:`Timeout.reschedule` でコンテキストマネー" +"ジャーの期限を変更できます。" -#: ../../library/asyncio-task.rst:740 msgid "" "async def main():\n" " async with asyncio.timeout(10):\n" " await long_running_task()" msgstr "" +"async def main():\n" +" async with asyncio.timeout(10):\n" +" await long_running_task()" -#: ../../library/asyncio-task.rst:744 msgid "" "If ``long_running_task`` takes more than 10 seconds to complete, the context " "manager will cancel the current task and handle the resulting :exc:`asyncio." "CancelledError` internally, transforming it into a :exc:`TimeoutError` which " "can be caught and handled." msgstr "" +"``long_running_task`` の完了に 10 秒を超えてかかると、コンテキストマネー" +"ジャーは現在のタスクをキャンセルします。\n" +"その結果生じる :exc:`asyncio.CancelledError` を内部で処理し、捕捉して処理でき" +"る :exc:`TimeoutError` に変換します。" -#: ../../library/asyncio-task.rst:751 msgid "" "The :func:`asyncio.timeout` context manager is what transforms the :exc:" "`asyncio.CancelledError` into a :exc:`TimeoutError`, which means the :exc:" "`TimeoutError` can only be caught *outside* of the context manager." msgstr "" +":exc:`asyncio.CancelledError` を :exc:`TimeoutError` に変換するのは :func:" +"`asyncio.timeout` のコンテキストマネージャーです。\n" +"そのため、:exc:`TimeoutError` を捕捉できるのはコンテキストマネージャーの *外" +"側* だけです。" -#: ../../library/asyncio-task.rst:756 msgid "Example of catching :exc:`TimeoutError`::" -msgstr "" +msgstr ":exc:`TimeoutError` を捕捉する例です。 ::" -#: ../../library/asyncio-task.rst:758 msgid "" "async def main():\n" " try:\n" @@ -1129,55 +1414,65 @@ msgid "" "\n" " print(\"This statement will run regardless.\")" msgstr "" +"async def main():\n" +" try:\n" +" async with asyncio.timeout(10):\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" print(\"The long operation timed out, but we've handled it.\")\n" +"\n" +" print(\"This statement will run regardless.\")" -#: ../../library/asyncio-task.rst:767 msgid "" "The context manager produced by :func:`asyncio.timeout` can be rescheduled " "to a different deadline and inspected." msgstr "" +":func:`asyncio.timeout` が生成するコンテキストマネージャーは、期限を変更した" +"り、状態を調べたりできます。" -#: ../../library/asyncio-task.rst:772 msgid "" "An :ref:`asynchronous context manager ` for " "cancelling overdue coroutines." msgstr "" +"期限を超えたコルーチンをキャンセルするための :ref:`非同期コンテキストマネー" +"ジャー ` です。" -#: ../../library/asyncio-task.rst:775 msgid "" "Prefer using :func:`asyncio.timeout` or :func:`asyncio.timeout_at` rather " "than instantiating :class:`!Timeout` directly." msgstr "" +":class:`!Timeout` を直接インスタンス化するよりも、:func:`asyncio.timeout` ま" +"たは :func:`asyncio.timeout_at` を使うことを推奨します。" -#: ../../library/asyncio-task.rst:778 msgid "" "``when`` should be an absolute time at which the context should time out, as " "measured by the event loop's clock:" msgstr "" +"``when`` には、イベントループの時計で計測した、タイムアウトすべき絶対時刻を指" +"定してください。" -#: ../../library/asyncio-task.rst:781 msgid "If ``when`` is ``None``, the timeout will never trigger." -msgstr "" +msgstr "``when`` が ``None`` の場合、タイムアウトは発生しません。" -#: ../../library/asyncio-task.rst:782 msgid "" "If ``when < loop.time()``, the timeout will trigger on the next iteration of " "the event loop." msgstr "" +"``when < loop.time()`` の場合、イベントループの次の反復でタイムアウトが発生し" +"ます。" -#: ../../library/asyncio-task.rst:787 msgid "" "Return the current deadline, or ``None`` if the current deadline is not set." msgstr "" +"現在の期限を返します。\n" +"期限が設定されていなければ ``None`` を返します。" -#: ../../library/asyncio-task.rst:792 msgid "Reschedule the timeout." -msgstr "" +msgstr "タイムアウトの期限を変更します。" -#: ../../library/asyncio-task.rst:796 msgid "Return whether the context manager has exceeded its deadline (expired)." -msgstr "" +msgstr "コンテキストマネージャーが期限を過ぎたかどうかを返します。" -#: ../../library/asyncio-task.rst:801 msgid "" "async def main():\n" " try:\n" @@ -1194,18 +1489,31 @@ msgid "" " if cm.expired():\n" " print(\"Looks like we haven't finished on time.\")" msgstr "" +"async def main():\n" +" try:\n" +" # 開始時には期限が分からないので、``None`` を渡す。\n" +" async with asyncio.timeout(None) as cm:\n" +" # 期限が分かったので設定する。\n" +" new_deadline = get_running_loop().time() + 10\n" +" cm.reschedule(new_deadline)\n" +"\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" pass\n" +"\n" +" if cm.expired():\n" +" print(\"Looks like we haven't finished on time.\")" -#: ../../library/asyncio-task.rst:816 msgid "Timeout context managers can be safely nested." -msgstr "" +msgstr "タイムアウトのコンテキストマネージャーは安全に入れ子にできます。" -#: ../../library/asyncio-task.rst:822 msgid "" "Similar to :func:`asyncio.timeout`, except *when* is the absolute time to " "stop waiting, or ``None``." msgstr "" +":func:`asyncio.timeout` と似ていますが、*when* には待機を終了する絶対時刻、ま" +"たは ``None`` を指定します。" -#: ../../library/asyncio-task.rst:827 msgid "" "async def main():\n" " loop = get_running_loop()\n" @@ -1218,6 +1526,16 @@ msgid "" "\n" " print(\"This statement will run regardless.\")" msgstr "" +"async def main():\n" +" loop = get_running_loop()\n" +" deadline = loop.time() + 20\n" +" try:\n" +" async with asyncio.timeout_at(deadline):\n" +" await long_running_task()\n" +" except TimeoutError:\n" +" print(\"The long operation timed out, but we've handled it.\")\n" +"\n" +" print(\"This statement will run regardless.\")" #: ../../library/asyncio-task.rst:843 msgid "" @@ -1236,13 +1554,14 @@ msgstr "" "す。\n" "*timeout* が ``None`` の場合、 Future が完了するまで待ちます。" -#: ../../library/asyncio-task.rst:850 msgid "If a timeout occurs, it cancels *aw* and raises :exc:`TimeoutError`." msgstr "" +"タイムアウトが発生すると *aw* をキャンセルし、:exc:`TimeoutError` を送出しま" +"す。" -#: ../../library/asyncio-task.rst:852 msgid "To prevent *aw* from being cancelled, wrap it in :func:`shield`." msgstr "" +"*aw* がキャンセルされないようにするには :func:`shield` でラップしてください。" #: ../../library/asyncio-task.rst:854 msgid "" @@ -1258,7 +1577,6 @@ msgstr "" msgid "If the wait is cancelled, the future *aw* is also cancelled." msgstr "待機が中止された場合 *aw* も中止されます。" -#: ../../library/asyncio-task.rst:864 msgid "" "async def eternity():\n" " # Sleep for one hour\n" @@ -1278,33 +1596,55 @@ msgid "" "#\n" "# timeout!" msgstr "" +"async def eternity():\n" +" # 1 時間スリープする\n" +" await asyncio.sleep(3600)\n" +" print('yay!')\n" +"\n" +"async def main():\n" +" # 最大 1 秒待つ\n" +" try:\n" +" await asyncio.wait_for(eternity(), timeout=1.0)\n" +" except TimeoutError:\n" +" print('timeout!')\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# 期待される出力:\n" +"#\n" +"# timeout!" -#: ../../library/asyncio-task.rst:882 msgid "" "When *aw* is cancelled due to a timeout, ``wait_for`` waits for *aw* to be " "cancelled. Previously, it raised :exc:`TimeoutError` immediately." msgstr "" +"タイムアウトにより *aw* をキャンセルする場合、``wait_for`` は *aw* のキャンセ" +"ルが完了するまで待つようになりました。\n" +"以前は :exc:`TimeoutError` を即座に送出していました。" -#: ../../library/asyncio-task.rst:890 msgid "Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`." msgstr "" +":exc:`asyncio.TimeoutError` の代わりに :exc:`TimeoutError` を送出するようにな" +"りました。" -#: ../../library/asyncio-task.rst:893 msgid "" "Implemented using :func:`asyncio.timeout`, a coroutine passed as *aw* is no " "longer wrapped in a :class:`Task` when *timeout* is positive." msgstr "" +":func:`asyncio.timeout` を使った実装になり、*timeout* が正の場合に *aw* とし" +"て渡されたコルーチンを :class:`Task` でラップしなくなりました。" -#: ../../library/asyncio-task.rst:899 msgid "Waiting primitives" -msgstr "" +msgstr "待機プリミティブ" -#: ../../library/asyncio-task.rst:904 msgid "" "Run :class:`~asyncio.Future` and :class:`~asyncio.Task` instances in the " "*aws* iterable concurrently and block until the condition specified by " "*return_when*." msgstr "" +"イテラブル *aws* に含まれる :class:`~asyncio.Future` と :class:`~asyncio." +"Task` のインスタンスを並行に実行し、*return_when* で指定した条件が満たされる" +"までブロックします。" #: ../../library/asyncio-task.rst:908 msgid "The *aws* iterable must not be empty." @@ -1318,9 +1658,8 @@ msgstr "Task/Future からなる 2 つの集合 ``(done, pending)`` を返しま msgid "Usage::" msgstr "使い方::" -#: ../../library/asyncio-task.rst:914 msgid "done, pending = await asyncio.wait(aws)" -msgstr "" +msgstr "done, pending = await asyncio.wait(aws)" #: ../../library/asyncio-task.rst:916 msgid "" @@ -1330,12 +1669,14 @@ msgstr "" "*timeout* (浮動小数点数または整数) が指定されていたら、処理を返すのを待つ最大" "秒数を制御するのに使われます。" -#: ../../library/asyncio-task.rst:919 msgid "" "Note that this function does not raise :exc:`TimeoutError`. Futures or Tasks " "that aren't done when the timeout occurs are simply returned in the second " "set." msgstr "" +"この関数は :exc:`TimeoutError` を送出しません。\n" +"タイムアウト時点で完了していない Future や Task は、単に 2 番目の集合に入れて" +"返されます。" #: ../../library/asyncio-task.rst:923 msgid "" @@ -1357,12 +1698,13 @@ msgstr "説明" msgid "The function will return when any future finishes or is cancelled." msgstr "いずれかのフューチャが終了したかキャンセルされたときに返します。" -#: ../../library/asyncio-task.rst:936 msgid "" "The function will return when any future finishes by raising an exception. " "If no future raises an exception then it is equivalent to :const:" "`ALL_COMPLETED`." msgstr "" +"いずれかのフューチャが例外を送出して終了すると、この関数は返ります。\n" +"例外を送出するフューチャがない場合は、:const:`ALL_COMPLETED` と等価です。" #: ../../library/asyncio-task.rst:941 msgid "The function will return when all futures finish or are cancelled." @@ -1376,28 +1718,29 @@ msgstr "" ":func:`~asyncio.wait_for` と異なり、 ``wait()`` はタイムアウトが起きたとき" "に Future をキャンセルしません。" -#: ../../library/asyncio-task.rst:946 msgid "" "If ``wait()`` is cancelled, the futures in *aws* are not cancelled and " "continue to run." msgstr "" +"``wait()`` がキャンセルされても、*aws* 内の Future はキャンセルされずに実行を" +"続けます。" -#: ../../library/asyncio-task.rst:952 msgid "Passing coroutine objects to ``wait()`` directly is forbidden." -msgstr "" +msgstr "``wait()`` にコルーチンオブジェクトを直接渡すことは禁止されました。" -#: ../../library/asyncio-task.rst:955 ../../library/asyncio-task.rst:1017 msgid "Added support for generators yielding tasks." -msgstr "" +msgstr "タスクを yield するジェネレーターをサポートするようになりました。" -#: ../../library/asyncio-task.rst:961 msgid "" "Run :ref:`awaitable objects ` in the *aws* iterable " "concurrently. The returned object can be iterated to obtain the results of " "the awaitables as they finish." msgstr "" +"イテラブル *aws* に含まれる :ref:`awaitable オブジェクト ` を並行に実行します。\n" +"返されたオブジェクトを反復すると、awaitable の完了に応じて結果を取得できま" +"す。" -#: ../../library/asyncio-task.rst:965 msgid "" "The object returned by ``as_completed()`` can be iterated as an :term:" "`asynchronous iterator` or a plain :term:`iterator`. When asynchronous " @@ -1405,8 +1748,13 @@ msgid "" "are tasks or futures. This makes it easy to correlate previously-scheduled " "tasks with their results. Example::" msgstr "" +"``as_completed()`` が返すオブジェクトは :term:`asynchronous iterator` として" +"も通常の :term:`iterator` としても反復できます。\n" +"非同期反復の場合、もともと渡された awaitable が Task または Future なら、その" +"オブジェクトを yield します。\n" +"これにより、スケジュール済みのタスクと結果を簡単に対応付けられます。\n" +"例えば次のように使います。 ::" -#: ../../library/asyncio-task.rst:971 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1422,21 +1770,38 @@ msgid "" " else:\n" " print(\"IPv4 connection established.\")" msgstr "" +"ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" +"ipv6_connect = create_task(open_connection(\"::1\", 80))\n" +"tasks = [ipv4_connect, ipv6_connect]\n" +"\n" +"async for earliest_connect in as_completed(tasks):\n" +" # earliest_connect は完了している。await するか\n" +" # earliest_connect.result() を呼び出すと結果を取得できる。\n" +" reader, writer = await earliest_connect\n" +"\n" +" if earliest_connect is ipv6_connect:\n" +" print(\"IPv6 connection established.\")\n" +" else:\n" +" print(\"IPv4 connection established.\")" -#: ../../library/asyncio-task.rst:985 msgid "" "During asynchronous iteration, implicitly-created tasks will be yielded for " "supplied awaitables that aren't tasks or futures." msgstr "" +"非同期反復では、渡された awaitable が Task や Future でない場合、暗黙に作成さ" +"れたタスクを yield します。" -#: ../../library/asyncio-task.rst:988 msgid "" "When used as a plain iterator, each iteration yields a new coroutine that " "returns the result or raises the exception of the next completed awaitable. " "This pattern is compatible with Python versions older than 3.13::" msgstr "" +"通常のイテレーターとして使う場合、反復のたびに新しいコルーチンを yield しま" +"す。\n" +"このコルーチンは、次に完了する awaitable の結果を返すか、その例外を送出しま" +"す。\n" +"この使い方は Python 3.13 より前のバージョンと互換性があります。 ::" -#: ../../library/asyncio-task.rst:992 msgid "" "ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" "ipv6_connect = create_task(open_connection(\"::1\", 80))\n" @@ -1448,36 +1813,53 @@ msgid "" " # awaitable that finishes next.\n" " reader, writer = await next_connect" msgstr "" +"ipv4_connect = create_task(open_connection(\"127.0.0.1\", 80))\n" +"ipv6_connect = create_task(open_connection(\"::1\", 80))\n" +"tasks = [ipv4_connect, ipv6_connect]\n" +"\n" +"for next_connect in as_completed(tasks):\n" +" # next_connect は元のタスクオブジェクトではない。\n" +" # await すると、次に完了する awaitable の結果を取得するか、\n" +" # その例外を送出する。\n" +" reader, writer = await next_connect" -#: ../../library/asyncio-task.rst:1002 msgid "" "A :exc:`TimeoutError` is raised if the timeout occurs before all awaitables " "are done. This is raised by the ``async for`` loop during asynchronous " "iteration or by the coroutines yielded during plain iteration." msgstr "" +"すべての awaitable が完了する前にタイムアウトすると、:exc:`TimeoutError` を送" +"出します。\n" +"非同期反復では ``async for`` ループが、通常の反復では yield されたコルーチン" +"が、この例外を送出します。" -#: ../../library/asyncio-task.rst:1006 msgid "" "``as_completed()`` does not cancel the tasks running the supplied " "awaitables: if a timeout occurs or the iteration is cancelled, the remaining " "tasks continue to run." msgstr "" +"``as_completed()`` は、渡された awaitable を実行しているタスクをキャンセルし" +"ません。\n" +"タイムアウトした場合や反復がキャンセルされた場合も、残りのタスクは実行を続け" +"ます。" -#: ../../library/asyncio-task.rst:1013 msgid "" "Deprecation warning is emitted if not all awaitable objects in the *aws* " "iterable are Future-like objects and there is no running event loop." msgstr "" +"イテラブル *aws* に含まれる awaitable オブジェクトのすべてが Future のような" +"オブジェクトというわけではなく、かつ実行中のイベントループがない場合に、非推" +"奨の警告を出すようになりました。" -#: ../../library/asyncio-task.rst:1020 msgid "" "The result can now be used as either an :term:`asynchronous iterator` or as " "a plain :term:`iterator` (previously it was only a plain iterator)." msgstr "" +"結果を :term:`asynchronous iterator` としても通常の :term:`iterator` としても" +"使えるようになりました (以前は通常のイテレーターとしてのみ使えました)。" -#: ../../library/asyncio-task.rst:1026 msgid "Running in threads" -msgstr "" +msgstr "スレッドでの実行" #: ../../library/asyncio-task.rst:1031 msgid "Asynchronously run function *func* in a separate thread." @@ -1499,14 +1881,15 @@ msgid "" "Return a coroutine that can be awaited to get the eventual result of *func*." msgstr "関数 *func* の最終結果を待ち受けできるコルーチンを返します。" -#: ../../library/asyncio-task.rst:1040 msgid "" "This coroutine function is primarily intended to be used for executing IO-" "bound functions/methods that would otherwise block the event loop if they " "were run in the main thread. For example::" msgstr "" +"このコルーチン関数は主に、メインスレッドで実行するとイベントループをブロック" +"してしまう I/O バウンドの関数やメソッドを実行するためのものです。\n" +"例えば次のように使います。 ::" -#: ../../library/asyncio-task.rst:1044 msgid "" "def blocking_io():\n" " print(f\"start blocking_io at {time.strftime('%X')}\")\n" @@ -1534,14 +1917,42 @@ msgid "" "# blocking_io complete at 19:50:54\n" "# finished main at 19:50:54" msgstr "" +"def blocking_io():\n" +" print(f\"start blocking_io at {time.strftime('%X')}\")\n" +" # time.sleep() は、ファイル操作などのブロックする\n" +" # I/O バウンドの処理に置き換えられる。\n" +" time.sleep(1)\n" +" print(f\"blocking_io complete at {time.strftime('%X')}\")\n" +"\n" +"async def main():\n" +" print(f\"started main at {time.strftime('%X')}\")\n" +"\n" +" await asyncio.gather(\n" +" asyncio.to_thread(blocking_io),\n" +" asyncio.sleep(1))\n" +"\n" +" print(f\"finished main at {time.strftime('%X')}\")\n" +"\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# 期待される出力:\n" +"#\n" +"# started main at 19:50:53\n" +"# start blocking_io at 19:50:53\n" +"# blocking_io complete at 19:50:54\n" +"# finished main at 19:50:54" -#: ../../library/asyncio-task.rst:1070 msgid "" "Directly calling ``blocking_io()`` in any coroutine would block the event " "loop for its duration, resulting in an additional 1 second of run time. " "Instead, by using ``asyncio.to_thread()``, we can run it in a separate " "thread without blocking the event loop." msgstr "" +"コルーチン内で ``blocking_io()`` を直接呼び出すと、実行中ずっとイベントループ" +"をブロックするため、実行時間が 1 秒長くなります。\n" +"代わりに ``asyncio.to_thread()`` を使えば、イベントループをブロックせずに別の" +"スレッドで実行できます。" #: ../../library/asyncio-task.rst:1077 msgid "" @@ -1551,9 +1962,8 @@ msgid "" "``asyncio.to_thread()`` can also be used for CPU-bound functions." msgstr "" -#: ../../library/asyncio-task.rst:1086 msgid "Scheduling from other threads" -msgstr "" +msgstr "他のスレッドからのスケジュール" #: ../../library/asyncio-task.rst:1090 msgid "Submit a coroutine to the given event loop. Thread-safe." @@ -1578,7 +1988,6 @@ msgstr "" "び出すためのものです。\n" "例えば次のように使います::" -#: ../../library/asyncio-task.rst:1098 msgid "" "def in_thread(loop: asyncio.AbstractEventLoop) -> None:\n" " # Run some blocking IO\n" @@ -1601,12 +2010,32 @@ msgid "" " # Run something in a thread\n" " await asyncio.to_thread(in_thread, loop)" msgstr "" +"def in_thread(loop: asyncio.AbstractEventLoop) -> None:\n" +" # ブロックする I/O を実行する\n" +" pathlib.Path(\"example.txt\").write_text(\"hello world\", " +"encoding=\"utf8\")\n" +"\n" +" # コルーチンを作成する\n" +" coro = asyncio.sleep(1, result=3)\n" +"\n" +" # 指定されたループにコルーチンを送る\n" +" future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +"\n" +" # 省略可能な timeout 引数を指定して結果を待つ\n" +" assert future.result(timeout=2) == 3\n" +"\n" +"async def amain() -> None:\n" +" # 実行中のループを取得する\n" +" loop = asyncio.get_running_loop()\n" +"\n" +" # スレッドで処理を実行する\n" +" await asyncio.to_thread(in_thread, loop)" -#: ../../library/asyncio-task.rst:1118 msgid "It's also possible to run the other way around. Example::" msgstr "" +"逆に、別のスレッドで実行するイベントループへ処理を送ることもできます。\n" +"例えば次のようにします。 ::" -#: ../../library/asyncio-task.rst:1120 msgid "" "@contextlib.contextmanager\n" "def loop_in_thread() -> Generator[asyncio.AbstractEventLoop]:\n" @@ -1641,6 +2070,38 @@ msgid "" " # Wait for the result with an optional timeout argument\n" " assert future.result(timeout=2) == 3" msgstr "" +"@contextlib.contextmanager\n" +"def loop_in_thread() -> Generator[asyncio.AbstractEventLoop]:\n" +" loop_fut = concurrent.futures.Future[asyncio.AbstractEventLoop]()\n" +" stop_event = asyncio.Event()\n" +"\n" +" async def main() -> None:\n" +" loop_fut.set_result(asyncio.get_running_loop())\n" +" await stop_event.wait()\n" +"\n" +" with concurrent.futures.ThreadPoolExecutor(1) as tpe:\n" +" complete_fut = tpe.submit(asyncio.run, main())\n" +" for fut in concurrent.futures.as_completed((loop_fut, " +"complete_fut)):\n" +" if fut is loop_fut:\n" +" loop = loop_fut.result()\n" +" try:\n" +" yield loop\n" +" finally:\n" +" loop.call_soon_threadsafe(stop_event.set)\n" +" else:\n" +" fut.result()\n" +"\n" +"# 別のスレッドにループを作成する\n" +"with loop_in_thread() as loop:\n" +" # コルーチンを作成する\n" +" coro = asyncio.sleep(1, result=3)\n" +"\n" +" # 指定されたループにコルーチンを送る\n" +" future = asyncio.run_coroutine_threadsafe(coro, loop)\n" +"\n" +" # 省略可能な timeout 引数を指定して結果を待つ\n" +" assert future.result(timeout=2) == 3" #: ../../library/asyncio-task.rst:1152 msgid "" @@ -1650,7 +2111,6 @@ msgstr "" "コルーチンから例外が送出された場合、返された Future に通知されます。\n" "これはイベントループの Task をキャンセルするのにも使えます::" -#: ../../library/asyncio-task.rst:1156 msgid "" "try:\n" " result = future.result(timeout)\n" @@ -1662,6 +2122,15 @@ msgid "" "else:\n" " print(f'The coroutine returned: {result!r}')" msgstr "" +"try:\n" +" result = future.result(timeout)\n" +"except TimeoutError:\n" +" print('The coroutine took too long, cancelling the task...')\n" +" future.cancel()\n" +"except Exception as exc:\n" +" print(f'The coroutine raised an exception: {exc!r}')\n" +"else:\n" +" print(f'The coroutine returned: {result!r}')" #: ../../library/asyncio-task.rst:1166 msgid "" @@ -1712,13 +2181,11 @@ msgstr "" "*loop* が ``None`` の場合、 :func:`get_running_loop` は現在のループを取得する" "のに使われます。" -#: ../../library/asyncio-task.rst:1203 msgid "Return ``True`` if *obj* is a coroutine object." -msgstr "" +msgstr "*obj* がコルーチンオブジェクトなら ``True`` を返します。" -#: ../../library/asyncio-task.rst:1210 msgid "Task object" -msgstr "" +msgstr "Task オブジェクト" #: ../../library/asyncio-task.rst:1214 msgid "" @@ -1752,7 +2219,6 @@ msgstr "" "Task が Future の完了を待っているときは、イベントループは他の Task やコール" "バックを動作させるか、 IO 処理を実行します。" -#: ../../library/asyncio-task.rst:1228 msgid "" "Use the high-level :func:`asyncio.create_task` function to create Tasks, or " "the low-level :meth:`loop.create_task` or :func:`ensure_future` functions. " @@ -1761,26 +2227,29 @@ msgstr "" "Task を作成するには高レベルの :func:`asyncio.create_task` 関数、あるいは低レ" "ベルの :meth:`loop.create_task` 関数や :func:`ensure_future` 関数を使用してく" "ださい。\n" -"手作業での Task の実装は推奨されません。" +"Task を直接インスタンス化することは推奨されません。" -#: ../../library/asyncio-task.rst:1233 msgid "" "To cancel a running Task use the :meth:`cancel` method. Calling it will " "cause the Task to throw a :exc:`CancelledError` exception into the wrapped " "coroutine. If a coroutine is awaiting on a future-like object during " "cancellation, the awaited object will be cancelled." msgstr "" +"実行中の Task をキャンセルするには :meth:`cancel` メソッドを使ってくださ" +"い。\n" +"このメソッドを呼び出すと、Task がラップしているコルーチンに :exc:" +"`CancelledError` を送出します。\n" +"キャンセル時にコルーチンが Future のようなオブジェクトを await している場合、" +"そのオブジェクトもキャンセルされます。" -#: ../../library/asyncio-task.rst:1238 msgid "" ":meth:`cancelled` can be used to check if the Task was cancelled. The method " "returns ``True`` if the wrapped coroutine did not suppress the :exc:" "`CancelledError` exception and was actually cancelled." msgstr "" -":meth:`cancelled` は、タスクがキャンセルされたかを調べるのに使用できます。タ" -"スクを内包するコルーチンで :exc:`CancelledError` 例外が抑制されておらず、かつ" -"タスクが実際にキャンセルされている場合に、このメソッドは ``True`` を変えま" -"す。" +":meth:`cancelled` を使うと Task がキャンセルされたかどうかを確認できます。\n" +"Task が内包するコルーチンが :exc:`CancelledError` 例外を抑制せず、実際にキャ" +"ンセルされた場合、このメソッドは ``True`` を返します。" #: ../../library/asyncio-task.rst:1243 msgid "" @@ -1790,15 +2259,17 @@ msgstr "" ":class:`asyncio.Task` は、:meth:`Future.set_result` と :meth:`Future." "set_exception` を除いて、:class:`Future` の API をすべて継承しています。" -#: ../../library/asyncio-task.rst:1247 msgid "" "An optional keyword-only *context* argument allows specifying a custom :" "class:`contextvars.Context` for the *coro* to run in. If no *context* is " "provided, the Task copies the current context and later runs its coroutine " "in the copied context." msgstr "" +"省略可能なキーワード専用引数 *context* では、*coro* を実行するための独自の :" +"class:`contextvars.Context` を指定できます。\n" +"*context* を指定しない場合、Task は現在のコンテキストをコピーし、後でそのコ" +"ピーの中でコルーチンを実行します。" -#: ../../library/asyncio-task.rst:1252 msgid "" "An optional keyword-only *eager_start* argument allows eagerly starting the " "execution of the :class:`asyncio.Task` at task creation time. If set to " @@ -1807,26 +2278,33 @@ msgid "" "coroutine returns or raises without blocking, the task will be finished " "eagerly and will skip scheduling to the event loop." msgstr "" +"省略可能なキーワード専用引数 *eager_start* では、:class:`asyncio.Task` の作成" +"時に実行を即座に開始するよう指定できます。\n" +"``True`` に設定され、イベントループが実行中であれば、タスクはコルーチンの実行" +"を即座に開始し、コルーチンが初めてブロックするまで実行します。\n" +"コルーチンがブロックせずに値を返すか例外を送出すると、タスクはその場で完了" +"し、イベントループへのスケジュールを省略します。" -#: ../../library/asyncio-task.rst:1259 msgid "" "Tasks are :ref:`generic ` over the return type of their wrapped " "coroutines." msgstr "" +"Task は、ラップするコルーチンの戻り値の型を型パラメーターとする :ref:`ジェネ" +"リック型 ` です。" #: ../../library/asyncio-task.rst:1262 msgid "Added support for the :mod:`contextvars` module." msgstr ":mod:`contextvars` モジュールのサポートを追加。" -#: ../../library/asyncio-task.rst:1268 msgid "" "Deprecation warning is emitted if *loop* is not specified and there is no " "running event loop." msgstr "" +"*loop* が指定されておらず、実行中のイベントループもない場合に、非推奨の警告を" +"出すようになりました。" -#: ../../library/asyncio-task.rst:1275 msgid "Added the *eager_start* parameter." -msgstr "" +msgstr "*eager_start* パラメーターが追加されました。" #: ../../library/asyncio-task.rst:1280 msgid "Return ``True`` if the Task is *done*." @@ -1860,11 +2338,12 @@ msgstr "" "Task が *キャンセル* されている場合、このメソッドは :exc:`CancelledError` 例" "外を送出します。" -#: ../../library/asyncio-task.rst:1296 msgid "" "If the Task's result isn't yet available, this method raises an :exc:" "`InvalidStateError` exception." msgstr "" +"Task の結果がまだ利用できない場合、このメソッドは :exc:`InvalidStateError` を" +"送出します。" #: ../../library/asyncio-task.rst:1301 msgid "Return the exception of the Task." @@ -1938,7 +2417,6 @@ msgid "Only one stack frame is returned for a suspended coroutine." msgstr "" "サスペンドされているコルーチンの場合スタックフレームが 1 個だけ返されます。" -#: ../../library/asyncio-task.rst:1345 msgid "" "The optional *limit* argument sets the maximum number of frames to return; " "by default all available frames are returned. The ordering of the returned " @@ -1946,11 +2424,12 @@ msgid "" "newest frames of a stack are returned, but the oldest frames of a traceback " "are returned. (This matches the behavior of the traceback module.)" msgstr "" -"オプション引数 *limit* は返すフレームの最大数を指定します; デフォルトでは取得" -"可能な全てのフレームを返します。返されるリストの順番は、スタックが返される" -"か、トレースバックが返されるかによって変わります: スタックでは新しい順に並ん" -"だリストが返されますが、トレースバックでは古い順に並んだリストが返されます" -"(これは traceback モジュールの振る舞いと一致します)。" +"省略可能な *limit* 引数は返すフレーム数の上限を指定します。\n" +"デフォルトでは取得可能なすべてのフレームを返します。\n" +"返されるリストの順序は、スタックとトレースバックのどちらを返すかによって異な" +"ります。\n" +"スタックの場合は最も新しいフレーム群、トレースバックの場合は最も古いフレーム" +"群が返されます (これは traceback モジュールの動作と一致します)。" #: ../../library/asyncio-task.rst:1354 msgid "Print the stack or traceback for this Task." @@ -1968,30 +2447,33 @@ msgstr "" msgid "The *limit* argument is passed to :meth:`get_stack` directly." msgstr "引数 *limit* は :meth:`get_stack` にそのまま渡されます。" -#: ../../library/asyncio-task.rst:1361 msgid "" "The *file* argument is an I/O stream to which the output is written; by " "default output is written to :data:`sys.stdout`." msgstr "" +"*file* 引数は出力先の I/O ストリームです。\n" +"デフォルトでは :data:`sys.stdout` に出力します。" #: ../../library/asyncio-task.rst:1366 msgid "Return the coroutine object wrapped by the :class:`Task`." msgstr ":class:`Task` がラップしているコルーチンオブジェクトを返します。" -#: ../../library/asyncio-task.rst:1370 msgid "" "This will return ``None`` for Tasks which have already completed eagerly. " "See the :ref:`Eager Task Factory `." msgstr "" +"即時実行ですでに完了した Task では ``None`` を返します。\n" +":ref:`即時実行するタスクファクトリー ` を参照してくださ" +"い。" -#: ../../library/asyncio-task.rst:1377 msgid "Newly added eager task execution means result may be ``None``." msgstr "" +"即時実行するタスクが追加されたため、結果が ``None`` になる場合があります。" -#: ../../library/asyncio-task.rst:1381 msgid "" "Return the :class:`contextvars.Context` object associated with the task." msgstr "" +"タスクに関連付けられた :class:`contextvars.Context` オブジェクトを返します。" #: ../../library/asyncio-task.rst:1388 msgid "Return the name of the Task." @@ -2015,31 +2497,31 @@ msgid "" msgstr "" "引数 *value* は文字列に変換可能なオブジェクトであれば何でもかまいません。" -#: ../../library/asyncio-task.rst:1403 msgid "" "In the default Task implementation, the name will be visible in the :func:" "`repr` output of a task object." msgstr "" -"Task のデフォルト実装では、名前はオブジェクトの :func:`repr` メソッドの出力で" +"デフォルトの Task 実装では、タスクオブジェクトの :func:`repr` の出力で名前を" "確認できます。" #: ../../library/asyncio-task.rst:1410 msgid "Request the Task to be cancelled." msgstr "このタスクに、自身のキャンセルを要求します。" -#: ../../library/asyncio-task.rst:1412 msgid "" "If the Task is already *done* or *cancelled*, return ``False``, otherwise, " "return ``True``." msgstr "" +"Task がすでに *完了* または *キャンセル* されている場合は ``False`` を、それ" +"以外の場合は ``True`` を返します。" -#: ../../library/asyncio-task.rst:1415 msgid "" "The method arranges for a :exc:`CancelledError` exception to be thrown into " "the wrapped coroutine on the next cycle of the event loop." msgstr "" +"このメソッドは、イベントループの次のサイクルで、ラップしているコルーチンに :" +"exc:`CancelledError` を送出するように手配します。" -#: ../../library/asyncio-task.rst:1418 msgid "" "The coroutine then has a chance to clean up or even deny the request by " "suppressing the exception with a :keyword:`try` ... ... ``except " @@ -2050,31 +2532,37 @@ msgid "" "suppress the cancellation, it needs to call :meth:`Task.uncancel` in " "addition to catching the exception." msgstr "" +"コルーチンは、:keyword:`try` ... ``except CancelledError`` ... :keyword:" +"`finally` ブロックで後片付けをしたり、例外を抑制してキャンセル要求を拒否した" +"りできます。\n" +"このため、:meth:`Future.cancel` と異なり、:meth:`Task.cancel` は Task がキャ" +"ンセルされることを保証しません。\n" +"ただし、キャンセルを完全に抑制するのは一般的ではなく、強く非推奨とします。\n" +"それでもキャンセルを抑制する場合、コルーチンは例外を捕捉するだけでなく :meth:" +"`Task.uncancel` も呼び出す必要があります。" -#: ../../library/asyncio-task.rst:1428 msgid "" "If the Task being cancelled is currently awaiting on a future-like object, " "that awaited object will also be cancelled. This cancellation propagates " "down the entire chain of awaited objects." msgstr "" +"キャンセルされる Task が Future のようなオブジェクトを await している場合、そ" +"のオブジェクトもキャンセルされます。\n" +"このキャンセルは、await されているオブジェクトの連鎖全体に伝播します。" -#: ../../library/asyncio-task.rst:1432 msgid "Added the *msg* parameter." -msgstr "" +msgstr "*msg* パラメーターが追加されました。" -#: ../../library/asyncio-task.rst:1435 msgid "The ``msg`` parameter is propagated from cancelled task to its awaiter." msgstr "" +"``msg`` パラメーターが、キャンセルされたタスクからそのタスクを await する側へ" +"伝播するようになりました。" -#: ../../library/asyncio-task.rst:1440 msgid "" "The following example illustrates how coroutines can intercept the " "cancellation request::" -msgstr "" -"以下の例は、コルーチンがどのようにしてキャンセルのリクエストを阻止するかを示" -"しています::" +msgstr "次の例は、コルーチンがキャンセル要求を捕捉する方法を示しています。 ::" -#: ../../library/asyncio-task.rst:1443 msgid "" "async def cancel_me():\n" " print('cancel_me(): before sleep')\n" @@ -2110,6 +2598,39 @@ msgid "" "# cancel_me(): after sleep\n" "# main(): cancel_me is cancelled now" msgstr "" +"async def cancel_me():\n" +" print('cancel_me(): before sleep')\n" +"\n" +" try:\n" +" # 1 時間待つ\n" +" await asyncio.sleep(3600)\n" +" except asyncio.CancelledError:\n" +" print('cancel_me(): cancel sleep')\n" +" raise\n" +" finally:\n" +" print('cancel_me(): after sleep')\n" +"\n" +"async def main():\n" +" # \"cancel_me\" タスクを作成する\n" +" task = asyncio.create_task(cancel_me())\n" +"\n" +" # 1 秒待つ\n" +" await asyncio.sleep(1)\n" +"\n" +" task.cancel()\n" +" try:\n" +" await task\n" +" except asyncio.CancelledError:\n" +" print(\"main(): cancel_me is cancelled now\")\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# 期待される出力:\n" +"#\n" +"# cancel_me(): before sleep\n" +"# cancel_me(): cancel sleep\n" +"# cancel_me(): after sleep\n" +"# main(): cancel_me is cancelled now" #: ../../library/asyncio-task.rst:1479 msgid "Return ``True`` if the Task is *cancelled*." @@ -2125,21 +2646,19 @@ msgstr "" "ているコルーチンが内部で送出された :exc:`CancelledError` 例外を伝達したと" "き、 Task は実際に *キャンセル* されます。" -#: ../../library/asyncio-task.rst:1487 msgid "Decrement the count of cancellation requests to this Task." -msgstr "" +msgstr "この Task に対するキャンセル要求の回数を減らします。" -#: ../../library/asyncio-task.rst:1489 msgid "Returns the remaining number of cancellation requests." -msgstr "" +msgstr "残っているキャンセル要求の回数を返します。" -#: ../../library/asyncio-task.rst:1491 msgid "" "Note that once execution of a cancelled task completed, further calls to :" "meth:`uncancel` are ineffective." msgstr "" +"キャンセルされたタスクの実行が完了した後は、:meth:`uncancel` を呼び出しても効" +"果はありません。" -#: ../../library/asyncio-task.rst:1496 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. In particular, if a Task gets successfully uncancelled, this " @@ -2147,8 +2666,13 @@ msgid "" "func:`asyncio.timeout` to continue running, isolating cancellation to the " "respective structured block. For example::" msgstr "" +"このメソッドは asyncio の内部で使うもので、ユーザーのコードからの使用は想定し" +"ていません。\n" +"特に、Task のキャンセル状態を正常に解除できると、キャンセルの影響をそれぞれの" +"構造化されたブロック内に限定でき、:ref:`taskgroups` や :func:`asyncio." +"timeout` などの構造化された並行処理を継続できます。\n" +"例えば次のようになります。 ::" -#: ../../library/asyncio-task.rst:1503 msgid "" "async def make_request_with_timeout():\n" " try:\n" @@ -2161,8 +2685,17 @@ msgid "" " # Outer code not affected by the timeout:\n" " await unrelated_code()" msgstr "" +"async def make_request_with_timeout():\n" +" try:\n" +" async with asyncio.timeout(1):\n" +" # タイムアウトの影響を受ける構造化されたブロック:\n" +" await make_request()\n" +" await make_another_request()\n" +" except TimeoutError:\n" +" log(\"There was a timeout\")\n" +" # 外側のコードはタイムアウトの影響を受けない:\n" +" await unrelated_code()" -#: ../../library/asyncio-task.rst:1514 msgid "" "While the block with ``make_request()`` and ``make_another_request()`` might " "get cancelled due to the timeout, ``unrelated_code()`` should continue " @@ -2170,15 +2703,22 @@ msgid "" "`uncancel`. :class:`TaskGroup` context managers use :func:`uncancel` in a " "similar fashion." msgstr "" +"``make_request()`` と ``make_another_request()`` を含むブロックはタイムアウト" +"によってキャンセルされる可能性がありますが、その場合も ``unrelated_code()`` " +"は実行を続ける必要があります。\n" +"これを実現するのが :meth:`uncancel` です。\n" +":class:`TaskGroup` コンテキストマネージャーも同様に :func:`uncancel` を使いま" +"す。" -#: ../../library/asyncio-task.rst:1520 msgid "" "If end-user code is, for some reason, suppressing cancellation by catching :" "exc:`CancelledError`, it needs to call this method to remove the " "cancellation state." msgstr "" +"何らかの理由でユーザーのコードが :exc:`CancelledError` を捕捉してキャンセルを" +"抑制する場合、キャンセル状態を解除するためにこのメソッドを呼び出す必要があり" +"ます。" -#: ../../library/asyncio-task.rst:1524 msgid "" "When this method decrements the cancellation count to zero, the method " "checks if a previous :meth:`cancel` call had arranged for :exc:" @@ -2186,18 +2726,24 @@ msgid "" "that arrangement will be rescinded (by resetting the internal " "``_must_cancel`` flag)." msgstr "" +"このメソッドによってキャンセル回数がゼロになると、以前の :meth:`cancel` の呼" +"び出しがタスクへの :exc:`CancelledError` の送出を手配していたかどうかを確認し" +"ます。\n" +"まだ送出されていなければ、内部の ``_must_cancel`` フラグをリセットして、その" +"手配を取り消します。" -#: ../../library/asyncio-task.rst:1530 msgid "Changed to rescind pending cancellation requests upon reaching zero." msgstr "" +"キャンセル回数がゼロになったら、保留中のキャンセル要求を取り消すようになりま" +"した。" -#: ../../library/asyncio-task.rst:1535 msgid "" "Return the number of pending cancellation requests to this Task, i.e., the " "number of calls to :meth:`cancel` less the number of :meth:`uncancel` calls." msgstr "" +"この Task に対する保留中のキャンセル要求の回数、つまり :meth:`cancel` の呼び" +"出し回数から :meth:`uncancel` の呼び出し回数を引いた値を返します。" -#: ../../library/asyncio-task.rst:1539 msgid "" "Note that if this number is greater than zero but the Task is still " "executing, :meth:`cancelled` will still return ``False``. This is because " @@ -2205,9 +2751,15 @@ msgid "" "the task not being cancelled after all if the cancellation requests go down " "to zero." msgstr "" +"この回数がゼロより大きくても、Task がまだ実行中なら :meth:`cancelled` は " +"``False`` を返します。\n" +":meth:`uncancel` を呼び出してこの回数を減らし、キャンセル要求がゼロになれば、" +"最終的にタスクがキャンセルされないこともあるためです。" -#: ../../library/asyncio-task.rst:1545 msgid "" "This method is used by asyncio's internals and isn't expected to be used by " "end-user code. See :meth:`uncancel` for more details." msgstr "" +"このメソッドは asyncio の内部で使うもので、ユーザーのコードからの使用は想定し" +"ていません。\n" +"詳しくは :meth:`uncancel` を参照してください。" diff --git a/library/asyncio-threading.po b/library/asyncio-threading.po index 6723acf0d..6847b7b29 100644 --- a/library/asyncio-threading.po +++ b/library/asyncio-threading.po @@ -12,15 +12,14 @@ msgstr "" "PO-Revision-Date: 2026-06-11 17:36+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-threading.rst:6 msgid "asyncio and free-threaded Python" -msgstr "" +msgstr "asyncio とフリースレッド Python" #: ../../library/asyncio-threading.rst:8 msgid "" @@ -31,22 +30,24 @@ msgid "" "limited by the :term:`global interpreter lock` in CPython." msgstr "" -#: ../../library/asyncio-threading.rst:15 msgid "" "However, in :ref:`free-threaded Python `, the " "GIL is disabled and Python can run true multi-threaded code. This means that " "asyncio can now take advantage of multiple CPU cores without the limitations " "imposed by the GIL." msgstr "" +"一方、:ref:`フリースレッド Python ` では GIL が無" +"効になり、Python コードを複数のスレッドで真に並列実行できます。\n" +"これにより、asyncio でも GIL の制限を受けずに複数の CPU コアを活用できます。" -#: ../../library/asyncio-threading.rst:20 msgid "" "Since Python 3.14, asyncio has first-class support for free-threaded Python, " "and the implementation of asyncio is safe to use in a multi-threaded " "environment." msgstr "" +"Python 3.14 以降、asyncio はフリースレッド Python を正式にサポートしており、" +"マルチスレッド環境でも安全に使える実装になっています。" -#: ../../library/asyncio-threading.rst:24 msgid "" "A single event loop on one core can handle many connections concurrently, " "but the Python code that runs to handle each one still executes serially. " @@ -57,8 +58,16 @@ msgid "" "multiple CPU cores. It is also useful when you need to run blocking or CPU-" "bound code from an asyncio application." msgstr "" +"1 つのコア上のイベントループでも多数の接続を並行に処理できますが、各接続を処" +"理する Python コードは依然として逐次実行されます。\n" +"リクエストごとに相応の計算が必要になると、その処理がボトルネックとなり、1 つ" +"のコアでは追いつかなくなります。\n" +"asyncio とスレッドの組み合わせが特に役立つのはこのような場合です。\n" +"スレッドごとにイベントループを実行すると、異なるリクエストの処理を複数の CPU " +"コアで並列に実行できます。\n" +"asyncio アプリケーションからブロックするコードや CPU バウンドのコードを実行す" +"る必要がある場合にも役立ちます。" -#: ../../library/asyncio-threading.rst:37 msgid "" "`Scaling asyncio on Free-Threaded Python `__, a blog post by Kumar Aditya " @@ -66,32 +75,39 @@ msgid "" "under free-threaded Python, together with benchmarks of the resulting " "improvements." msgstr "" +"Kumar Aditya によるブログ記事 `Scaling asyncio on Free-Threaded Python " +"`__ " +"では、フリースレッド Python 上で asyncio を安全かつ効率的に動作させるための内" +"部的な変更と、改善の効果を示すベンチマークを紹介しています。" -#: ../../library/asyncio-threading.rst:45 msgid "Thread safety considerations" -msgstr "" +msgstr "スレッド安全性に関する注意点" -#: ../../library/asyncio-threading.rst:47 msgid "" "While asyncio is designed to be thread-safe in a free-threaded Python " "environment, there are still some considerations to keep in mind when using " "asyncio with threads:" msgstr "" +"asyncio はフリースレッド Python 環境で安全に動作するように設計されています" +"が、スレッドと組み合わせて使う際には、次の点に注意する必要があります。" -#: ../../library/asyncio-threading.rst:51 msgid "" "**Event loop**: Each thread should have its own event loop which should not " "be shared across threads. This ensures that the event loop can manage its " "own tasks and callbacks without interference from other threads." msgstr "" +"**イベントループ**: 各スレッドが専用のイベントループを持ち、スレッド間で共有" +"しないようにしてください。\n" +"これにより、イベントループは他のスレッドから干渉されずに自身のタスクやコール" +"バックを管理できます。" -#: ../../library/asyncio-threading.rst:56 msgid "" "**Task management**: Tasks and futures created in one thread should not be " "awaited or manipulated from another thread." msgstr "" +"**タスクの管理**: あるスレッドで作成した Task や Future を、別のスレッドから " +"await したり操作したりしないでください。" -#: ../../library/asyncio-threading.rst:59 msgid "" "**Thread-safe APIs**: When interacting with asyncio from multiple threads, " "it's important to use thread-safe APIs provided by asyncio, such as :func:" @@ -99,8 +115,13 @@ msgid "" "loop from another thread. If you need to call a callback from a different " "thread, you can use :meth:`loop.call_soon_threadsafe` to schedule it safely." msgstr "" +"**スレッドセーフな API**: 複数のスレッドから asyncio を使う場合は、asyncio が" +"提供するスレッドセーフな API を使うことが重要です。\n" +"例えば、別のスレッドからイベントループにコルーチンを送るには :func:`asyncio." +"run_coroutine_threadsafe` を使います。\n" +"別のスレッドからコールバックを呼び出す必要がある場合は、:meth:`loop." +"call_soon_threadsafe` で安全にスケジュールできます。" -#: ../../library/asyncio-threading.rst:66 msgid "" "**Synchronization**: The synchronization primitives provided by asyncio " "(like :class:`asyncio.Lock` and :class:`asyncio.Event`) are not designed to " @@ -108,24 +129,29 @@ msgid "" "should use the synchronization primitives from the :mod:`threading` module " "instead." msgstr "" +"**同期**: asyncio が提供する同期プリミティブ (:class:`asyncio.Lock` や :" +"class:`asyncio.Event` など) は、スレッドをまたいで使うようには設計されていま" +"せん。\n" +"スレッド間で同期する必要がある場合は、代わりに :mod:`threading` モジュールの" +"同期プリミティブを使ってください。" -#: ../../library/asyncio-threading.rst:74 msgid "Using asyncio with threads" -msgstr "" +msgstr "asyncio とスレッドの併用" -#: ../../library/asyncio-threading.rst:76 msgid "" "asyncio supports running one event loop per thread, which allows you to take " "advantage of multiple CPU cores in a free-threaded Python environment. Each " "thread can run its own event loop, and tasks can be scheduled on those loops " "independently." msgstr "" +"asyncio はスレッドごとに 1 つのイベントループを実行できるため、フリースレッ" +"ド Python 環境で複数の CPU コアを活用できます。\n" +"各スレッドは専用のイベントループを実行し、それぞれのループに独立してタスクを" +"スケジュールできます。" -#: ../../library/asyncio-threading.rst:81 msgid "Here's an example of how to use asyncio with threads::" -msgstr "" +msgstr "asyncio とスレッドを併用する例を示します。 ::" -#: ../../library/asyncio-threading.rst:83 msgid "" "import asyncio\n" "import threading\n" @@ -147,27 +173,51 @@ msgid "" "for t in threads:\n" " t.join()" msgstr "" +"import asyncio\n" +"import threading\n" +"\n" +"async def worker(name: str) -> None:\n" +" print(f\"Worker {name} starting\")\n" +" await asyncio.sleep(1)\n" +" print(f\"Worker {name} done\")\n" +"\n" +"def run_loop(name: str) -> None:\n" +" asyncio.run(worker(name))\n" +"\n" +"threads = [\n" +" threading.Thread(target=run_loop, args=(f\"T{i}\",))\n" +" for i in range(4)\n" +"]\n" +"for t in threads:\n" +" t.start()\n" +"for t in threads:\n" +" t.join()" -#: ../../library/asyncio-threading.rst:103 msgid "" "In this example, each thread creates its own event loop with :func:`asyncio." "run` and runs a coroutine on it. The threads execute concurrently, and in a " "free-threaded build they can run on separate CPU cores in parallel." msgstr "" +"この例では、各スレッドが :func:`asyncio.run` で専用のイベントループを作成し、" +"その上でコルーチンを実行します。\n" +"スレッドは並行に実行され、フリースレッドビルドでは別々の CPU コアで並列に実行" +"できます。" -#: ../../library/asyncio-threading.rst:110 msgid "Producer/consumer across threads" -msgstr "" +msgstr "スレッドをまたぐ生産者と消費者" -#: ../../library/asyncio-threading.rst:112 msgid "" "When a regular (non-asyncio) thread needs to hand work to an asyncio event " "loop running in another thread, use a thread-safe primitive such as :class:" "`queue.Queue` rather than :class:`asyncio.Queue`, which is only safe within " "a single event loop.::" msgstr "" +"通常の (asyncio ではない) スレッドから、別のスレッドで動いている asyncio のイ" +"ベントループに処理を渡すには、:class:`queue.Queue` などのスレッドセーフなプリ" +"ミティブを使ってください。\n" +":class:`asyncio.Queue` を安全に使えるのは、単一のイベントループ内だけで" +"す。 ::" -#: ../../library/asyncio-threading.rst:117 msgid "" "import asyncio\n" "import queue\n" @@ -199,6 +249,35 @@ msgid "" "producer(q)\n" "consumer_thread.join()" msgstr "" +"import asyncio\n" +"import queue\n" +"import threading\n" +"\n" +"def producer(q: queue.Queue[int]) -> None:\n" +" for i in range(5):\n" +" print(f\"Producing {i}\")\n" +" q.put(i)\n" +" q.shutdown()\n" +"\n" +"async def consumer(q: queue.Queue[int]) -> None:\n" +" while True:\n" +" try:\n" +" item = q.get_nowait()\n" +" except queue.Empty:\n" +" await asyncio.sleep(0.1)\n" +" continue\n" +" except queue.ShutDown:\n" +" break\n" +" print(f\"Consumed {item}\")\n" +" await asyncio.sleep(item)\n" +"\n" +"q: queue.Queue[int] = queue.Queue()\n" +"consumer_thread = threading.Thread(\n" +" target=lambda: asyncio.run(consumer(q))\n" +")\n" +"consumer_thread.start()\n" +"producer(q)\n" +"consumer_thread.join()" #: ../../library/asyncio-threading.rst:147 msgid "" diff --git a/library/asyncio-tools.po b/library/asyncio-tools.po index 9420a6f3c..24ac5025b 100644 --- a/library/asyncio-tools.po +++ b/library/asyncio-tools.po @@ -16,67 +16,71 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncio-tools.rst:7 msgid "Command-line introspection tools" -msgstr "" +msgstr "コマンドラインのイントロスペクションツール" -#: ../../library/asyncio-tools.rst:9 msgid "**Source code:** :source:`Lib/asyncio/tools.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/asyncio/tools.py`" -#: ../../library/asyncio-tools.rst:13 msgid "" "The :mod:`!asyncio` module can be invoked as a script via ``python -m " "asyncio`` to inspect the task graph of another running Python process " "without modifying it or restarting it. The :mod:`!asyncio.tools` submodule " "implements this interface." msgstr "" +":mod:`!asyncio` モジュールは ``python -m asyncio`` でスクリプトとして実行で" +"き、実行中の別の Python プロセスを変更したり再起動したりせずに、そのタスクグ" +"ラフを調べられます。\n" +"このインターフェースは :mod:`!asyncio.tools` サブモジュールが実装しています。" -#: ../../library/asyncio-tools.rst:18 msgid "The following commands inspect the process identified by ``PID``:" -msgstr "" +msgstr "次のコマンドは、``PID`` で指定したプロセスを調べます。" -#: ../../library/asyncio-tools.rst:20 msgid "" "$ python -m asyncio pstree [--retries N] PID\n" "$ python -m asyncio ps [--retries N] PID" msgstr "" +"$ python -m asyncio pstree [--retries N] PID\n" +"$ python -m asyncio ps [--retries N] PID" -#: ../../library/asyncio-tools.rst:25 msgid "" "The commands read the target process state without executing any code in it. " "They are only available on supported platforms and may require permission to " "inspect another process. See the :ref:`permission requirements ` for details." msgstr "" +"これらのコマンドは、対象プロセス内でコードを実行せずに、その状態を読み取りま" +"す。\n" +"サポートされているプラットフォームでのみ利用でき、別のプロセスを調べるための" +"権限が必要な場合があります。\n" +"詳しくは :ref:`必要な権限 ` を参照してください。" -#: ../../library/asyncio-tools.rst:31 msgid ":ref:`asyncio-graph`" -msgstr "" +msgstr ":ref:`asyncio-graph`" -#: ../../library/asyncio-tools.rst:32 msgid "" "Programmatic APIs for inspecting the async call graph of a task or future in " "the current process." msgstr "" +"現在のプロセス内の Task や Future の非同期呼び出しグラフを、プログラムから調" +"べるための API です。" -#: ../../library/asyncio-tools.rst:35 msgid "" "The command examples below use this program, which creates a task hierarchy " "suitable for inspection and prints its process ID:" msgstr "" +"以下のコマンド例では、調査用のタスク階層を作成してプロセス ID を表示する次の" +"プログラムを使います。" -#: ../../library/asyncio-tools.rst:38 msgid "example.py" -msgstr "" +msgstr "example.py" -#: ../../library/asyncio-tools.rst:38 msgid "" "import asyncio\n" "import os\n" @@ -104,29 +108,55 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"import os\n" +"\n" +"async def play(track):\n" +" await asyncio.sleep(3600)\n" +" print(f\"🎵 Finished: {track}\")\n" +"\n" +"async def album(name, tracks):\n" +" async with asyncio.TaskGroup() as tg:\n" +" for track in tracks:\n" +" tg.create_task(play(track), name=track)\n" +"\n" +"async def main():\n" +" print(f\"PID: {os.getpid()}\")\n" +" async with asyncio.TaskGroup() as tg:\n" +" tg.create_task(\n" +" album(\"Sundowning\", [\"TNDNBTG\", \"Levitate\"]),\n" +" name=\"Sundowning\",\n" +" )\n" +" tg.create_task(\n" +" album(\"TMBTE\", [\"DYWTYLM\", \"Aqua Regia\"]),\n" +" name=\"TMBTE\",\n" +" )\n" +"\n" +"asyncio.run(main())" -#: ../../library/asyncio-tools.rst:67 msgid "Run the program in one terminal and leave it running:" -msgstr "" +msgstr "1 つの端末でプログラムを起動し、実行したままにします。" -#: ../../library/asyncio-tools.rst:69 msgid "" "$ python example.py\n" "PID: 12345" msgstr "" +"$ python example.py\n" +"PID: 12345" -#: ../../library/asyncio-tools.rst:74 msgid "" "Then pass the printed process ID to the commands from another terminal. " "Thread IDs, task IDs, file paths, and line numbers vary between runs and " "source layouts." msgstr "" +"次に、表示されたプロセス ID を、別の端末からコマンドに渡します。\n" +"スレッド ID、タスク ID、ファイルパス、行番号は、実行時やソースコードの配置に" +"よって異なります。" #: ../../library/asyncio-tools.rst:81 msgid "Command-line options" msgstr "コマンドラインオプション" -#: ../../library/asyncio-tools.rst:85 msgid "" "Display task and coroutine relationships as a tree. Each task is shown with " "its full coroutine stack, nested under the task (if any) that is awaiting " @@ -134,8 +164,12 @@ msgid "" "task hierarchy is blocked and where in its coroutine stack execution has " "paused:" msgstr "" +"タスクとコルーチンの関係をツリーとして表示します。\n" +"各タスクはコルーチンのスタック全体とともに表示され、そのタスクを await してい" +"るタスクがあれば、その下に入れ子で配置されます。\n" +"このサブコマンドは、タスク階層のどの枝がブロックしていて、コルーチンのスタッ" +"クのどこで実行が止まっているかを素早く把握するのに役立ちます。" -#: ../../library/asyncio-tools.rst:91 msgid "" "$ python -m asyncio pstree 12345\n" "└── (T) Task-1\n" @@ -167,36 +201,74 @@ msgid "" " └── play example.py:4\n" " └── sleep Lib/asyncio/tasks.py:702" msgstr "" +"$ python -m asyncio pstree 12345\n" +"└── (T) Task-1\n" +" └── main example.py:12\n" +" └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75\n" +" └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124\n" +" ├── (T) Sundowning\n" +" │ └── album example.py:7\n" +" │ └── TaskGroup.__aexit__ Lib/asyncio/taskgroups." +"py:75\n" +" │ └── TaskGroup._aexit Lib/asyncio/taskgroups." +"py:124\n" +" │ ├── (T) TNDNBTG\n" +" │ │ └── play example.py:4\n" +" │ │ └── sleep Lib/asyncio/tasks.py:702\n" +" │ └── (T) Levitate\n" +" │ └── play example.py:4\n" +" │ └── sleep Lib/asyncio/tasks.py:702\n" +" └── (T) TMBTE\n" +" └── album example.py:7\n" +" └── TaskGroup.__aexit__ Lib/asyncio/taskgroups." +"py:75\n" +" └── TaskGroup._aexit Lib/asyncio/taskgroups." +"py:124\n" +" ├── (T) DYWTYLM\n" +" │ └── play example.py:4\n" +" │ └── sleep Lib/asyncio/tasks.py:702\n" +" └── (T) Aqua Regia\n" +" └── play example.py:4\n" +" └── sleep Lib/asyncio/tasks.py:702" -#: ../../library/asyncio-tools.rst:119 msgid "" "If the await graph contains a cycle, ``pstree`` reports an error instead of " "printing a tree. A cycle in the await graph is unusual and typically " "indicates a programming error:" msgstr "" +"await の関係を表すグラフに循環がある場合、``pstree`` はツリーを表示せずにエ" +"ラーを報告します。\n" +"このグラフに循環があるのはまれで、通常はプログラムの誤りを示します。" -#: ../../library/asyncio-tools.rst:123 msgid "" "$ python -m asyncio pstree 12345\n" "ERROR: await-graph contains cycles - cannot print a tree!\n" "\n" "cycle: Task-2 → Task-3 → Task-2" msgstr "" +"$ python -m asyncio pstree 12345\n" +"ERROR: await-graph contains cycles - cannot print a tree!\n" +"\n" +"cycle: Task-2 → Task-3 → Task-2" -#: ../../library/asyncio-tools.rst:132 msgid "" "Display a flat table of all pending tasks in the process *PID*. Each row " "shows the event-loop thread ID, task ID and name, coroutine stack, and the " "awaiting task's stack, name, and ID, if any." msgstr "" +"プロセス *PID* 内の未完了のタスクをすべて、階層のない表で表示します。\n" +"各行には、イベントループのスレッド ID、タスクの ID と名前、コルーチンのスタッ" +"クを表示します。\n" +"そのタスクを await しているタスクがあれば、そのスタック、名前、ID も表示しま" +"す。" -#: ../../library/asyncio-tools.rst:136 msgid "" "This subcommand prints all tasks regardless of whether the await graph " "contains cycles:" msgstr "" +"このサブコマンドは、await の関係を表すグラフに循環があるかどうかにかかわら" +"ず、すべてのタスクを表示します。" -#: ../../library/asyncio-tools.rst:139 msgid "" "$ python -m asyncio ps 12345\n" "tid task id task name coroutine " @@ -226,9 +298,37 @@ msgid "" "play TaskGroup._aexit -> TaskGroup." "__aexit__ -> album TMBTE 0x10a439d70" msgstr "" +"$ python -m asyncio ps 12345\n" +"tid task id task name coroutine " +"stack awaiter " +"chain awaiter name awaiter id\n" +"------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" +"18445801 0x10a456060 Task-1 TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> " +"main " +"0x0\n" +"18445801 0x10a439f60 Sundowning TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> " +"main Task-1 0x10a456060\n" +"18445801 0x10a439d70 TMBTE TaskGroup._aexit -> " +"TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> " +"main Task-1 0x10a456060\n" +"18445801 0x10a2a3a80 TNDNBTG sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album Sundowning 0x10a439f60\n" +"18445801 0x10a2a38a0 Levitate sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album Sundowning 0x10a439f60\n" +"18445801 0x10a2d7150 DYWTYLM sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album TMBTE 0x10a439d70\n" +"18445801 0x10a6bdaa0 Aqua Regia sleep -> " +"play TaskGroup._aexit -> TaskGroup." +"__aexit__ -> album TMBTE 0x10a439d70" -#: ../../library/asyncio-tools.rst:154 msgid "" "Retry failed attempts to inspect the target process up to *N* times. This " "can help when the target process changes while its state is being read." msgstr "" +"対象プロセスの調査に失敗した場合、最大 *N* 回再試行します。\n" +"状態の読み取り中に対象プロセスが変化する場合に役立ちます。" diff --git a/library/asyncio.po b/library/asyncio.po index 98053d806..bf77a9087 100644 --- a/library/asyncio.po +++ b/library/asyncio.po @@ -18,19 +18,18 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/asyncio.rst:107 msgid "High-level APIs" msgstr "高水準 API" -#: ../../library/asyncio.rst:119 msgid "Introspection APIs" -msgstr "" +msgstr "イントロスペクション API" #: ../../library/asyncio.rst:126 msgid "Low-level APIs" @@ -48,7 +47,6 @@ msgstr ":mod:`!asyncio` --- 非同期 I/O" msgid "Hello World!" msgstr "Hello World!" -#: ../../library/asyncio.rst:13 msgid "" "import asyncio\n" "\n" @@ -59,6 +57,14 @@ msgid "" "\n" "asyncio.run(main())" msgstr "" +"import asyncio\n" +"\n" +"async def main():\n" +" print('Hello ...')\n" +" await asyncio.sleep(1)\n" +" print('... World!')\n" +"\n" +"asyncio.run(main())" #: ../../library/asyncio.rst:22 msgid "" @@ -117,24 +123,25 @@ msgstr ":ref:`subprocesses ` を管理する" msgid "distribute tasks via :ref:`queues `;" msgstr ":ref:`キュー ` を使ってタスクを分散する" -#: ../../library/asyncio.rst:48 msgid ":ref:`synchronize ` concurrent code;" -msgstr "並列処理のコードを :ref:`同期 ` させる" +msgstr "並行処理のコードを :ref:`同期 ` させる" -#: ../../library/asyncio.rst:50 msgid "For **introspection**, asyncio provides APIs and tools for:" msgstr "" +"asyncio は **イントロスペクション** のために、次の API とツールを提供していま" +"す。" -#: ../../library/asyncio.rst:52 msgid "" "inspecting the :ref:`async call graph ` of tasks and futures;" msgstr "" +"タスクと Future の :ref:`非同期呼び出しグラフ ` を調べる" -#: ../../library/asyncio.rst:54 msgid "" "inspecting tasks in another running Python process with :ref:`command-line " "tools `;" msgstr "" +":ref:`コマンドラインツール ` で、実行中の別の " +"Python プロセス内のタスクを調べる" #: ../../library/asyncio.rst:57 msgid "" @@ -172,9 +179,8 @@ msgstr "" "コールバックを用いたライブラリと async/await 構文を使ったコードの :ref:`橋渡" "し `" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -214,30 +220,33 @@ msgstr "" ">>> await asyncio.sleep(10, result='hello')\n" "'hello'" -#: ../../library/asyncio.rst:89 msgid "" "This REPL provides limited compatibility with :envvar:`PYTHON_BASIC_REPL`. " "It is recommended that the default REPL is used for full functionality and " "the latest features." msgstr "" +"この REPL と :envvar:`PYTHON_BASIC_REPL` の互換性は限定的です。\n" +"すべての機能と最新の機能を使うには、デフォルトの REPL を推奨します。" -#: ../../library/asyncio.rst:93 msgid "" "Raises an :ref:`auditing event ` ``cpython.run_stdin`` with no " "arguments." msgstr "" "引数無しで :ref:`監査イベント ` ``cpython.run_stdin`` を送出しま" -"す。 " +"す。" -#: ../../library/asyncio.rst:95 msgid "(also 3.11.10, 3.10.15, 3.9.20, and 3.8.20) Emits audit events." msgstr "" +"(3.11.10、3.10.15、3.9.20、3.8.20 も同様) 監査イベントを送出するようになりま" +"した。" -#: ../../library/asyncio.rst:98 msgid "" "Uses PyREPL if possible, in which case :envvar:`PYTHONSTARTUP` is also " "executed. Emits audit events." msgstr "" +"可能な場合は PyREPL を使用するようになり、その場合は :envvar:`PYTHONSTARTUP` " +"も実行されます。\n" +"監査イベントを送出するようになりました。" #: ../../library/asyncio.rst:106 msgid "Reference" diff --git a/library/asyncore.po b/library/asyncore.po index b8e91cf3c..464823a40 100644 --- a/library/asyncore.po +++ b/library/asyncore.po @@ -12,29 +12,32 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:00+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/asyncore.rst:2 msgid ":mod:`!asyncore` --- Asynchronous socket handler" -msgstr "" +msgstr ":mod:`!asyncore` --- 非同期ソケットハンドラー" -#: ../../library/asyncore.rst:10 msgid "" "This module is no longer part of the Python standard library. It was :ref:" "`removed in Python 3.12 ` after being deprecated in " "Python 3.6. The removal was decided in :pep:`594`." msgstr "" +"このモジュールは Python 標準ライブラリから削除されました。\n" +"Python 3.6 で非推奨となり、:ref:`Python 3.12 で削除 ` さ" +"れました。\n" +"削除は :pep:`594` で決定されました。" -#: ../../library/asyncore.rst:14 msgid "Applications should use the :mod:`asyncio` module instead." msgstr "" +"アプリケーションでは、代わりに :mod:`asyncio` モジュールを使ってください。" -#: ../../library/asyncore.rst:16 msgid "" "The last version of Python that provided the :mod:`!asyncore` module was " "`Python 3.11 `_." msgstr "" +":mod:`!asyncore` モジュールを提供していた最後のバージョンは `Python 3.11 " +"`_ です。" diff --git a/library/atexit.po b/library/atexit.po index 6110c5063..878db26b8 100644 --- a/library/atexit.po +++ b/library/atexit.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/atexit.rst:2 msgid ":mod:`!atexit` --- Exit handlers" msgstr ":mod:`!atexit` --- 終了ハンドラー" -#: ../../library/atexit.rst:9 msgid "" "The :mod:`!atexit` module defines functions to register and unregister :dfn:" "`exit handlers`: functions that are automatically executed \"at exit\", that " @@ -34,8 +33,12 @@ msgid "" "called or the main module's execution completes) or, more generally, upon :" "term:`interpreter shutdown`." msgstr "" +":mod:`!atexit` モジュールは、:dfn:`終了ハンドラー` を登録・解除する関数を定義" +"します。\n" +"終了ハンドラーは、プログラムの正常終了時 (例えば :func:`sys.exit` が呼び出さ" +"れたときや、メインモジュールの実行が完了したとき)、より一般的には :term:" +"`interpreter shutdown` 時に自動的に実行される関数です。" -#: ../../library/atexit.rst:15 msgid "" "At exit, all registered exit handlers are called in the *reverse* order in " "which they were registered. If you register ``A``, ``B``, and ``C``, at " @@ -43,6 +46,12 @@ msgid "" "The assumption is that lower level modules will normally be imported before " "higher level modules and thus must be cleaned up later." msgstr "" +"終了時には、登録されているすべての終了ハンドラーを登録した順序の *逆順* に呼" +"び出します。\n" +"``A``、``B``、``C`` の順に登録すると、インタープリタの終了時には ``C``、" +"``B``、``A`` の順に実行します。\n" +"これは、通常は低水準のモジュールが高水準のモジュールより先にインポートされる" +"ので、後片付けは後で行う必要があるという想定に基づいています。" #: ../../library/atexit.rst:22 msgid "" @@ -52,7 +61,6 @@ msgid "" "last exception to be raised is re-raised." msgstr "" -#: ../../library/atexit.rst:27 msgid "" "In programs that use multiple interpreters, each interpreter has its own " "stack of exit handlers, which are executed when the interpreter shuts down " @@ -60,13 +68,22 @@ msgid "" "C API :c:func:`Py_EndInterpreter`). Registration functions in this module " "only affect the interpreter they are called from." msgstr "" +"複数のインタープリタを使うプログラムでは、各インタープリタが終了ハンドラーの" +"スタックを持ちます。\n" +"ハンドラーは、そのインタープリタが終了するとき (例えば :meth:`concurrent." +"interpreters.Interpreter.close` や C API の :c:func:`Py_EndInterpreter` によ" +"る終了時) に実行されます。\n" +"このモジュールの登録用関数が影響するのは、呼び出し元のインタープリタだけで" +"す。" -#: ../../library/atexit.rst:34 msgid "" "**Note:** Exit handlers are not called when the program is killed by a " "signal not handled by Python, when a Python fatal internal error is " "detected, or when :func:`os._exit` is called." msgstr "" +"**注意:** Python が処理しないシグナルによってプログラムが強制終了した場合、" +"Python 内部の致命的なエラーが検出された場合、または :func:`os._exit` が呼び出" +"された場合、終了ハンドラーは呼び出されません。" #: ../../library/atexit.rst:38 msgid "" @@ -76,14 +93,17 @@ msgstr "" "**注意:** クリーンアップ関数内からの関数の登録・登録解除効果は定義されていま" "せん。" -#: ../../library/atexit.rst:42 msgid "" "When writing exit handlers, especially in C API extensions, keep in mind " "that other exit handlers may still run arbitrary Python code after you clean " "up. Such code should succeed or fail with an exception, rather than crash." msgstr "" +"終了ハンドラーを作成するとき、特に C API を使った拡張では、自身の後片付けが終" +"わった後も、他の終了ハンドラーが任意の Python コードを実行する可能性があるこ" +"とに注意してください。\n" +"そのようなコードは正常に実行されるか例外で失敗するべきであり、クラッシュして" +"はいけません。" -#: ../../library/atexit.rst:47 msgid "" "Attempts to start a new thread or :func:`os.fork` a new process in an exit " "handler now leads to :exc:`RuntimeError`. Previously, this could cause race " @@ -91,19 +111,29 @@ msgid "" "while internal :mod:`threading` routines or the new process try to use that " "state, which could lead to crashes rather than clean shutdown." msgstr "" +"終了ハンドラー内で新しいスレッドを開始したり、:func:`os.fork` で新しいプロセ" +"スを作成したりしようとすると、:exc:`RuntimeError` を送出するようになりまし" +"た。\n" +"以前は、Python ランタイムのメインスレッドがスレッド状態を解放する一方で、:" +"mod:`threading` 内部のルーチンや新しいプロセスがその状態を使おうとして、競合" +"状態が発生する可能性がありました。\n" +"その結果、正常に終了せずクラッシュすることがありました。" -#: ../../library/atexit.rst:55 msgid "" "When used with subinterpreters, registered functions are local to the " "interpreter they were registered in." msgstr "" +"サブインタープリタで使う場合、登録した関数は登録先のインタープリタに固有とな" +"りました。" -#: ../../library/atexit.rst:61 msgid "" "Register *func* as an exit handler. Any optional arguments that are to be " "passed to *func* must be passed as arguments to :func:`register`. It is " "possible to register the same function and arguments more than once." msgstr "" +"*func* を終了ハンドラーとして登録します。\n" +"*func* に渡す引数があれば、:func:`register` の引数として渡してください。\n" +"同じ関数と引数を複数回登録することもできます。" #: ../../library/atexit.rst:66 msgid "" @@ -111,7 +141,6 @@ msgid "" "decorator." msgstr "この関数は *func* を返し、これをデコレータとして利用できます。" -#: ../../library/atexit.rst:71 msgid "" "Remove *func* from the list of exit handlers. :func:`unregister` silently " "does nothing if *func* was not previously registered. If *func* has been " @@ -120,33 +149,39 @@ msgid "" "internally during unregistration, so function references do not need to have " "matching identities." msgstr "" +"終了ハンドラーのリストから *func* を削除します。\n" +"*func* が登録されていなければ、:func:`unregister` は何もせず、エラーも出しま" +"せん。\n" +"*func* が複数回登録されていた場合、:mod:`!atexit` の呼び出しスタックから、そ" +"の関数をすべて削除します。\n" +"登録解除では内部で等価比較 (``==``) を使うため、関数の参照先が同一のオブジェ" +"クトである必要はありません。" #: ../../library/atexit.rst:81 msgid "Module :mod:`readline`" msgstr ":mod:`readline` モジュール" -#: ../../library/atexit.rst:82 msgid "" "Useful example of :mod:`!atexit` to read and write :mod:`readline` history " "files." msgstr "" +":mod:`readline` の履歴ファイルを読み書きする、:mod:`!atexit` の実用的な使用例" +"です。" -#: ../../library/atexit.rst:89 msgid ":mod:`!atexit` Example" -msgstr "" +msgstr ":mod:`!atexit` の使用例" -#: ../../library/atexit.rst:91 msgid "" "The following simple example demonstrates how a module can initialize a " "counter from a file when it is imported and save the counter's updated value " "automatically when the program terminates without relying on the application " "making an explicit call into this module at termination. ::" msgstr "" -"次の簡単な例では、あるモジュールを import した時にカウンタを初期化しておき、" -"プログラムが終了するときにアプリケーションがこのモジュールを明示的に呼び出さ" -"なくてもカウンタが更新されるようにする方法を示しています。 ::" +"次の簡単な例では、モジュールのインポート時にファイルからカウンタの値を読み込" +"んで初期化し、プログラムの終了時に更新後の値を自動保存する方法を示します。\n" +"アプリケーションが終了時にこのモジュールを明示的に呼び出す必要はありませ" +"ん。 ::" -#: ../../library/atexit.rst:96 msgid "" "try:\n" " with open('counterfile') as infile:\n" @@ -166,6 +201,23 @@ msgid "" "\n" "atexit.register(savecounter)" msgstr "" +"try:\n" +" with open('counterfile') as infile:\n" +" _count = int(infile.read())\n" +"except FileNotFoundError:\n" +" _count = 0\n" +"\n" +"def incrcounter(n):\n" +" global _count\n" +" _count = _count + n\n" +"\n" +"def savecounter():\n" +" with open('counterfile', 'w') as outfile:\n" +" outfile.write('%d' % _count)\n" +"\n" +"import atexit\n" +"\n" +"atexit.register(savecounter)" #: ../../library/atexit.rst:114 msgid "" @@ -175,7 +227,6 @@ msgstr "" ":func:`register` に指定した位置引数とキーワード引数は登録した関数を呼び出す際" "に渡されます::" -#: ../../library/atexit.rst:117 msgid "" "def goodbye(name, adjective):\n" " print('Goodbye %s, it was %s to meet you.' % (name, adjective))\n" @@ -186,12 +237,19 @@ msgid "" "# or:\n" "atexit.register(goodbye, adjective='nice', name='Donny')" msgstr "" +"def goodbye(name, adjective):\n" +" print('Goodbye %s, it was %s to meet you.' % (name, adjective))\n" +"\n" +"import atexit\n" +"\n" +"atexit.register(goodbye, 'Donny', 'nice')\n" +"# または:\n" +"atexit.register(goodbye, adjective='nice', name='Donny')" #: ../../library/atexit.rst:126 msgid "Usage as a :term:`decorator`::" msgstr ":term:`デコレータ ` として利用する例::" -#: ../../library/atexit.rst:128 msgid "" "import atexit\n" "\n" @@ -199,9 +257,11 @@ msgid "" "def goodbye():\n" " print('You are now leaving the Python sector.')" msgstr "" +"import atexit\n" +"\n" +"@atexit.register\n" +"def goodbye():\n" +" print('You are now leaving the Python sector.')" -#: ../../library/atexit.rst:134 msgid "This only works with functions that can be called without arguments." -msgstr "" -"デコレータとして利用できるのは、その関数が引数なしで呼び出された場合に限られ" -"ます。" +msgstr "デコレータとして利用できるのは、引数なしで呼び出せる関数に限られます。" diff --git a/library/audioop.po b/library/audioop.po index f105909c2..02155c70c 100644 --- a/library/audioop.po +++ b/library/audioop.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/audioop.rst:2 msgid ":mod:`!audioop` --- Manipulate raw audio data" -msgstr "" +msgstr ":mod:`!audioop` --- 生の音声データの操作" #: ../../library/audioop.rst:10 msgid "" @@ -36,8 +35,9 @@ msgstr "" "ルは Python 3.11 で非推奨となったあと、:ref:`Python 3.13 で削除` されました。削除の決定は :pep:`594` でなされました。" -#: ../../library/audioop.rst:14 msgid "" "The last version of Python that provided the :mod:`!audioop` module was " "`Python 3.12 `_." msgstr "" +":mod:`!audioop` モジュールを提供していた最後のバージョンは `Python 3.12 " +"`_ です。" diff --git a/library/audit_events.po b/library/audit_events.po index bf019a629..44ea96b5d 100644 --- a/library/audit_events.po +++ b/library/audit_events.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/audit_events.rst:6 @@ -124,13 +124,11 @@ msgstr "_winapi.TerminateProcess" msgid "``handle``, ``exit_code``" msgstr "``handle``, ``exit_code``" -#: ../../library/audit_events.rst:46 msgid "_posixsubprocess.fork_exec" -msgstr "" +msgstr "_posixsubprocess.fork_exec" -#: ../../library/audit_events.rst:46 msgid "``exec_list``, ``args``, ``env``" -msgstr "" +msgstr "``exec_list``, ``args``, ``env``" #: ../../library/audit_events.rst:48 msgid "ctypes.PyObj_FromPtr" @@ -140,9 +138,8 @@ msgstr "ctypes.PyObj_FromPtr" msgid "``obj``" msgstr "``obj``" -#: ../../library/audit_events.rst:51 msgid "The ``_posixsubprocess.fork_exec`` internal audit event." -msgstr "" +msgstr "内部の監査イベント ``_posixsubprocess.fork_exec``。" #: ../../library/audit_events.rst:3 msgid "audit events" diff --git a/library/base64.po b/library/base64.po index 743fad95a..4f6b3ec88 100644 --- a/library/base64.po +++ b/library/base64.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/base64.rst:2 @@ -32,7 +32,6 @@ msgstr ":mod:`!base64` --- Base16, Base32, Base64, Base85 データのエンコ msgid "**Source code:** :source:`Lib/base64.py`" msgstr "**ソースコード:** :source:`Lib/base64.py`" -#: ../../library/base64.rst:16 msgid "" "This module provides functions for encoding binary data to printable ASCII " "characters and decoding such encodings back to binary data. This includes " @@ -41,6 +40,12 @@ msgid "" "`PDF 2.0 `_, and non-standard " "variants of Base85 used elsewhere." msgstr "" +"このモジュールは、バイナリデータを表示可能な ASCII 文字にエンコードし、エン" +"コードされたデータをバイナリデータに戻す関数を提供します。\n" +":rfc:`4648` で :ref:`規定されているエンコーディング ` " +"(Base64、Base32、Base16)、`PDF 2.0 `_ で規定されている :ref:`Base85 エンコーディング `、その他" +"の場所で使われる Base85 の非標準の変種を含みます。" #: ../../library/base64.rst:24 msgid "" @@ -126,23 +131,25 @@ msgstr "" "成できます。デフォルトは ``None`` で、標準の Base64 アルファベットが使われま" "す。" -#: ../../library/base64.rst:66 msgid "" "If *padded* is true (default), pad the encoded data with the '=' character " "to a size multiple of 4. If *padded* is false, do not add the pad characters." msgstr "" +"*padded* が真 (デフォルト) の場合、エンコードしたデータの長さが 4 の倍数にな" +"るように '=' でパディングします。\n" +"*padded* が偽の場合、パディング文字を追加しません。" -#: ../../library/base64.rst:70 ../../library/base64.rst:323 msgid "" "If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " "most every *wrapcol* characters. If *wrapcol* is zero (default), do not " "insert any newlines." msgstr "" +"*wrapcol* がゼロでない場合、最大 *wrapcol* 文字ごとに改行文字 (``b'\\n'``) を" +"挿入します。\n" +"*wrapcol* がゼロ (デフォルト) の場合、改行を挿入しません。" -#: ../../library/base64.rst:74 ../../library/base64.rst:183 -#: ../../library/base64.rst:231 msgid "Added the *padded* and *wrapcol* parameters." -msgstr "" +msgstr "*padded* と *wrapcol* パラメーターが追加されました。" #: ../../library/base64.rst:81 msgid "" @@ -162,7 +169,6 @@ msgstr "" "ASCII 文字列で、``+`` と ``/`` の代わりに使われる代替アルファベットを指定しま" "す。" -#: ../../library/base64.rst:88 msgid "" "If *padded* is true, the last group of 4 base 64 alphabet characters must be " "padded with the '=' character. If *padded* is false, padding is neither " @@ -171,6 +177,13 @@ msgid "" "*validate* is false, or causes an :exc:`~binascii.Error` when *validate* is " "true unless b'=' is included in *ignorechars*." msgstr "" +"*padded* が真の場合、Base64 アルファベットの最後の 4 文字の組には '=' による" +"パディングが必要です。\n" +"*padded* が偽の場合、パディングは不要で、パディングとしての認識もしません。\n" +"'=' はパディングではなくアルファベット外の文字として扱われるため、*validate* " +"が偽なら黙って破棄されます。\n" +"*validate* が真なら、*ignorechars* に ``b'='`` が含まれていない限り :exc:" +"`~binascii.Error` が発生します。" #: ../../library/base64.rst:96 msgid "" @@ -179,7 +192,6 @@ msgstr "" "*s* が正しくパディングされていない場合は :exc:`binascii.Error` 例外を発生させ" "ます。" -#: ../../library/base64.rst:99 msgid "" "If *ignorechars* is specified, it should be a :term:`bytes-like object` " "containing characters to ignore from the input when *validate* is true. If " @@ -188,6 +200,12 @@ msgid "" "will be ignored. The default value of *validate* is ``True`` if " "*ignorechars* is specified, ``False`` otherwise." msgstr "" +"*ignorechars* を指定する場合は、*validate* が真のときに入力から無視する文字を" +"含む :term:`bytes-like object` を渡してください。\n" +"*ignorechars* にパディング文字 ``'='`` を含めると、エンコードされたデータの末" +"尾より前に現れるパディング文字や、余分なパディング文字を無視します。\n" +"*validate* のデフォルト値は、*ignorechars* を指定した場合は ``True``、それ以" +"外は ``False`` です。" #: ../../library/base64.rst:107 msgid "" @@ -198,17 +216,19 @@ msgid "" "future Python versions)." msgstr "" -#: ../../library/base64.rst:114 msgid "" "If *validate* is true, these non-alphabet characters in the input result in " "a :exc:`binascii.Error`." msgstr "" +"*validate* が真の場合、入力にこれらのアルファベット外の文字があると :exc:" +"`binascii.Error` が発生します。" -#: ../../library/base64.rst:117 msgid "" "If *canonical* is true, non-zero padding bits are rejected. See :func:" "`binascii.a2b_base64` for details." msgstr "" +"*canonical* が真の場合、ゼロでないパディングビットを拒否します。\n" +"詳しくは :func:`binascii.a2b_base64` を参照してください。" #: ../../library/base64.rst:120 msgid "" @@ -218,16 +238,15 @@ msgstr "" "厳密な base64 チェックのについての詳細は :func:`binascii.a2b_base64` を参照し" "てください" -#: ../../library/base64.rst:122 ../../library/base64.rst:220 -#: ../../library/base64.rst:247 msgid "Added the *canonical*, *ignorechars*, and *padded* parameters." -msgstr "" +msgstr "*canonical*、*ignorechars*、*padded* パラメーターが追加されました。" -#: ../../library/base64.rst:125 msgid "" "Accepting the ``+`` and ``/`` characters with an alternative alphabet is now " "deprecated." msgstr "" +"代替アルファベットの使用時に ``+`` と ``/`` を受け入れることは非推奨になりま" +"した。" #: ../../library/base64.rst:132 msgid "" @@ -245,17 +264,20 @@ msgstr "" "標準の base64 アルファベットを使用した :term:`bytes-like object` または " "ASCII 文字列 *s* をデコードし、デコードされた :class:`bytes` を返します。" -#: ../../library/base64.rst:144 msgid "" "Encode :term:`bytes-like object` *s* using the URL- and filesystem-safe " "alphabet, which substitutes ``-`` instead of ``+`` and ``_`` instead of ``/" "`` in the standard Base64 alphabet, and return the encoded :class:`bytes`. " "The result can still contain ``=`` if *padded* is true (default)." msgstr "" +":term:`bytes-like object` *s* を、URL やファイルシステムで安全に使えるアル" +"ファベットでエンコードし、エンコードされた :class:`bytes` を返します。\n" +"このアルファベットは、標準の Base64 アルファベットの ``+`` を ``-`` に、``/" +"`` を ``_`` に置き換えたものです。\n" +"*padded* が真 (デフォルト) の場合、結果には ``=`` が含まれることがあります。" -#: ../../library/base64.rst:150 msgid "Added the *padded* parameter." -msgstr "" +msgstr "*padded* パラメーターが追加されました。" #: ../../library/base64.rst:156 msgid "" @@ -269,15 +291,15 @@ msgstr "" "返します。標準 base64 アルファベットに比べて、``+`` の替わりに ``-`` を、``/" "`` の替わりに ``_`` を置換します。" -#: ../../library/base64.rst:162 msgid "" "Added the *padded* parameter. Padding of input is no longer required by " "default." msgstr "" +"*padded* パラメーターが追加されました。\n" +"デフォルトでは入力のパディングが不要になりました。" -#: ../../library/base64.rst:166 msgid "Accepting the ``+`` and ``/`` characters is now deprecated." -msgstr "" +msgstr "``+`` と ``/`` を受け入れることは非推奨になりました。" #: ../../library/base64.rst:172 msgid "" @@ -287,19 +309,22 @@ msgstr "" "Base32 を使って :term:`bytes-like object` の *s* をエンコードし、エンコードさ" "れた :class:`bytes` を返します。" -#: ../../library/base64.rst:175 msgid "" "If *padded* is true (default), pad the encoded data with the '=' character " "to a size multiple of 8. If *padded* is false, do not add the pad characters." msgstr "" +"*padded* が真 (デフォルト) の場合、エンコードしたデータの長さが 8 の倍数にな" +"るように '=' でパディングします。\n" +"*padded* が偽の場合、パディング文字を追加しません。" -#: ../../library/base64.rst:179 ../../library/base64.rst:256 -#: ../../library/base64.rst:382 ../../library/base64.rst:421 msgid "" "If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " "most every *wrapcol* characters. If *wrapcol* is zero (default), do not add " "any newlines." msgstr "" +"*wrapcol* がゼロでない場合、最大 *wrapcol* 文字ごとに改行文字 (``b'\\n'``) を" +"挿入します。\n" +"*wrapcol* がゼロ (デフォルト) の場合、改行を追加しません。" #: ../../library/base64.rst:189 msgid "" @@ -336,7 +361,6 @@ msgstr "" "ティ上の理由により、これはデフォルトでは ``None`` になっているため、 0 およ" "び 1 は入力として許可されていません。" -#: ../../library/base64.rst:203 msgid "" "If *padded* is true, the last group of 8 base 32 alphabet characters must be " "padded with the '=' character. If *padded* is false, padding is neither " @@ -344,19 +368,26 @@ msgid "" "a non-alphabet character, which means it raises an :exc:`~binascii.Error` " "unless b'=' is included in *ignorechars*." msgstr "" +"*padded* が真の場合、Base32 アルファベットの最後の 8 文字の組には '=' による" +"パディングが必要です。\n" +"*padded* が偽の場合、パディングは不要で、パディングとしての認識もしません。\n" +"'=' はパディングではなくアルファベット外の文字として扱われるため、" +"*ignorechars* に ``b'='`` が含まれていない限り :exc:`~binascii.Error` が発生" +"します。" -#: ../../library/base64.rst:210 ../../library/base64.rst:273 -#: ../../library/base64.rst:397 ../../library/base64.rst:439 msgid "" "*ignorechars* should be a :term:`bytes-like object` containing characters to " "ignore from the input." msgstr "" +"*ignorechars* には、入力から無視する文字を含む :term:`bytes-like object` を指" +"定してください。" -#: ../../library/base64.rst:213 msgid "" "If *canonical* is true, non-zero padding bits are rejected. See :func:" "`binascii.a2b_base32` for details." msgstr "" +"*canonical* が真の場合、ゼロでないパディングビットを拒否します。\n" +"詳しくは :func:`binascii.a2b_base32` を参照してください。" #: ../../library/base64.rst:216 ../../library/base64.rst:276 msgid "" @@ -371,24 +402,27 @@ msgid "" "Similar to :func:`b32encode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" -":func:`b32encode`に似ていますが、:rfc:`4648`で定義されているようにExtended " -"Hex Alphabetを使用します。" +":func:`b32encode` に似ていますが、 :rfc:`4648` で定義されているように" +"Extended Hex Alphabetを使用します。" #: ../../library/base64.rst:237 msgid "" "Similar to :func:`b32decode` but uses the Extended Hex Alphabet, as defined " "in :rfc:`4648`." msgstr "" -":func:`b32decode`に似ていますが、:rfc:`4648`で定義されているようにExtended " -"Hex Alphabetを使用します。" +":func:`b32decode` に似ていますが、 :rfc:`4648` で定義されているように" +"Extended Hex Alphabetを使用します。" -#: ../../library/base64.rst:240 msgid "" "This version does not allow the digit 0 (zero) to the letter O (oh) and " "digit 1 (one) to either the letter I (eye) or letter L (el) mappings, all " "these characters are included in the Extended Hex Alphabet and are not " "interchangeable." msgstr "" +"この方式では、数字の 0 (ゼロ) を文字の O (オー) に、数字の 1 (いち) を文字の " +"I (アイ) または L (エル) に対応付けることはできません。\n" +"これらはすべて Extended Hex Alphabet に含まれる別々の文字で、置き換えられない" +"ためです。" #: ../../library/base64.rst:253 msgid "" @@ -398,10 +432,8 @@ msgstr "" "Base16 を使って :term:`bytes-like object` の *s* をエンコードし、エンコードさ" "れた :class:`bytes` を返します。" -#: ../../library/base64.rst:260 ../../library/base64.rst:388 -#: ../../library/base64.rst:430 msgid "Added the *wrapcol* parameter." -msgstr "" +msgstr "*wrapcol* パラメーターが追加されました。" #: ../../library/base64.rst:266 msgid "" @@ -411,15 +443,13 @@ msgstr "" "Base16 エンコードされた :term:`bytes-like object` または ASCII 文字列 *s* を" "デコードし、デコードされた :class:`bytes` を返します。" -#: ../../library/base64.rst:280 msgid "Added the *ignorechars* parameter." -msgstr "" +msgstr "*ignorechars* パラメーターが追加されました。" #: ../../library/base64.rst:287 msgid "Base85 Encodings" msgstr "Base85 エンコーディング" -#: ../../library/base64.rst:289 msgid "" "Base85 encoding is a family of algorithms which represent four bytes using " "five ASCII characters. Originally implemented in the Unix ``btoa(1)`` " @@ -427,65 +457,70 @@ msgid "" "language and is standardized in PDF 2.0 (ISO 32000-2). This version, in both " "its ``btoa`` and PDF variants, is implemented by :func:`a85encode`." msgstr "" +"Base85 エンコーディングは、4 バイトを 5 つの ASCII 文字で表すアルゴリズム群で" +"す。\n" +"もともとは Unix の ``btoa(1)`` ユーティリティに実装され、その後 Adobe がその" +"一種を PostScript 言語に採用し、PDF 2.0 (ISO 32000-2) で標準化されました。\n" +"この方式の ``btoa`` 版と PDF 版は、どちらも :func:`a85encode` に実装されてい" +"ます。" -#: ../../library/base64.rst:296 msgid "" "A separate version, using a different output character set, was defined as " "an April Fool's joke in :rfc:`1924` but is now used by Git and other " "software. This version is implemented by :func:`b85encode`." msgstr "" +"出力に異なる文字集合を使う別の方式は、エイプリルフールのジョークとして :rfc:" +"`1924` で定義されましたが、現在は Git などのソフトウェアで使われています。\n" +"この方式は :func:`b85encode` に実装されています。" -#: ../../library/base64.rst:300 msgid "" "Finally, a third version, using yet another output character set designed " "for safe inclusion in programming language strings, is defined by ZeroMQ and " "implemented here by :func:`z85encode`." msgstr "" +"さらに、プログラミング言語の文字列に安全に含められるよう設計された、別の出力" +"文字集合を使う 3 番目の方式を ZeroMQ が定義しています。\n" +"この方式は :func:`z85encode` に実装されています。" -#: ../../library/base64.rst:304 msgid "" "The functions present in this module differ in how they handle the following:" -msgstr "" +msgstr "このモジュールの各関数は、次の点の扱いが異なります。" -#: ../../library/base64.rst:306 msgid "Whether to include and expect enclosing ``<~`` and ``~>`` markers." -msgstr "" +msgstr "囲みのマーカー ``<~`` と ``~>`` を出力に含めるか、入力に期待するか。" -#: ../../library/base64.rst:307 msgid "Whether to fold the input into multiple lines." -msgstr "" +msgstr "入力を複数の行に折り返すか。" -#: ../../library/base64.rst:308 msgid "The set of ASCII characters used for encoding." -msgstr "" +msgstr "エンコードに使う ASCII 文字の集合。" -#: ../../library/base64.rst:309 msgid "Compact encodings of sequences of spaces and null bytes." -msgstr "" +msgstr "連続するスペースやヌルバイトの短縮表現。" -#: ../../library/base64.rst:310 msgid "The encoding of zero-padding bytes applied to the input." -msgstr "" +msgstr "入力に加えたゼロパディングのバイトをどうエンコードするか。" -#: ../../library/base64.rst:312 msgid "" "Refer to the documentation of the individual functions for more information." -msgstr "" +msgstr "詳しくは、各関数のドキュメントを参照してください。" -#: ../../library/base64.rst:316 msgid "" "Encode the :term:`bytes-like object` *b* using Ascii85 and return the " "encoded :class:`bytes`." msgstr "" "Ascii85 を使って :term:`bytes-like object` の *b* をエンコードし、エンコード" -"された :class:`bytes` を返します。 " +"された :class:`bytes` を返します。" -#: ../../library/base64.rst:319 msgid "" "*foldspaces* is an optional flag that uses the special short sequence 'y' " "instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This " "feature is not supported by the standard encoding used in PDF." msgstr "" +"*foldspaces* は省略可能なフラグです。\n" +"'btoa' と同様に、連続する 4 つのスペース (ASCII 0x20) の代わりに特別な短縮表" +"現 'y' を使います。\n" +"PDF で使われる標準のエンコーディングは、この機能をサポートしていません。" #: ../../library/base64.rst:327 msgid "" @@ -495,35 +530,42 @@ msgid "" "used in PDF, as it does not preserve the length of the data." msgstr "" -#: ../../library/base64.rst:333 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, as in a PostScript base-85 string literal. Note that while " "ASCII85Decode streams in PDF documents *must* be terminated with ``~>``, " "they *must not* use a leading ``<~``." msgstr "" +"*adobe* は、PostScript の Base85 文字列リテラルのように、エンコードしたバイト" +"列を ``<~`` と ``~>`` で囲むかどうかを制御します。\n" +"PDF 文書の ASCII85Decode ストリームは ``~>`` で終わる *必要があります* が、先" +"頭に ``<~`` を付けては *いけません*。" -#: ../../library/base64.rst:343 msgid "" "Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." msgstr "" "Ascii85 エンコードされた :term:`bytes-like object` または ASCII 文字列 *b* を" -"デコードし、デコードされた :class:`bytes` を返します。 " +"デコードし、デコードされた :class:`bytes` を返します。" -#: ../../library/base64.rst:346 msgid "" "*foldspaces* is a flag that specifies whether the 'y' short sequence should " "be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature " "is not supported by the standard Ascii85 encoding used in PDF and PostScript." msgstr "" +"*foldspaces* は、短縮表現 'y' を連続する 4 つのスペース (ASCII 0x20) として受" +"け入れるかどうかを指定するフラグです。\n" +"PDF や PostScript で使われる標準の Ascii85 エンコーディングは、この機能をサ" +"ポートしていません。" -#: ../../library/base64.rst:351 msgid "" "*adobe* controls whether the ``<~`` and ``~>`` markers are present. While " "the leading ``<~`` is not required, the input must end with ``~>``, or a :" "exc:`ValueError` is raised." msgstr "" +"*adobe* は、マーカー ``<~`` と ``~>`` の有無を指定します。\n" +"先頭の ``<~`` は必須ではありませんが、入力は ``~>`` で終わる必要があり、そう" +"でなければ :exc:`ValueError` を送出します。" #: ../../library/base64.rst:355 msgid "" @@ -532,17 +574,20 @@ msgid "" "by default contains all whitespace characters in ASCII." msgstr "" -#: ../../library/base64.rst:360 msgid "" "If *canonical* is true, non-canonical encodings are rejected. See :func:" "`binascii.a2b_ascii85` for details." msgstr "" +"*canonical* が真の場合、正規形でないエンコーディングを拒否します。\n" +"詳しくは :func:`binascii.a2b_ascii85` を参照してください。" -#: ../../library/base64.rst:365 msgid "" "Added the *canonical* parameter. Single-character final groups are now " "always rejected as encoding violations." msgstr "" +"*canonical* パラメーターが追加されました。\n" +"最後のグループが 1 文字だけの場合は、エンコーディングの規則に違反するものとし" +"て常に拒否するようになりました。" #: ../../library/base64.rst:373 msgid "" @@ -553,55 +598,67 @@ msgstr "" "て :term:`bytes-like object` の *b* をエンコードし、エンコードされた :class:" "`bytes` を返します。" -#: ../../library/base64.rst:376 msgid "" "The input is padded with ``b'\\0'`` so its length is a multiple of 4 bytes " "before encoding. If *pad* is true, all the resulting characters are " "retained in the output, which will always be a multiple of 5 bytes, and thus " "the length of the data may not be preserved on decoding." msgstr "" +"エンコードの前に、入力の長さが 4 バイトの倍数になるよう ``b'\\0'`` でパディン" +"グします。\n" +"*pad* が真の場合、結果の文字はすべて出力に残るため、出力の長さは常に 5 バイト" +"の倍数になります。\n" +"そのため、デコード時にデータの長さが保たれない場合があります。" -#: ../../library/base64.rst:394 msgid "" "Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and " "return the decoded :class:`bytes`." msgstr "" +"Base85 でエンコードされた :term:`bytes-like object` または ASCII 文字列 *b* " +"をデコードし、デコードされた :class:`bytes` を返します。" -#: ../../library/base64.rst:400 ../../library/base64.rst:442 msgid "" "If *canonical* is true, non-canonical encodings are rejected. See :func:" "`binascii.a2b_base85` for details." msgstr "" +"*canonical* が真の場合、正規形でないエンコーディングを拒否します。\n" +"詳しくは :func:`binascii.a2b_base85` を参照してください。" -#: ../../library/base64.rst:405 ../../library/base64.rst:447 msgid "" "Added the *canonical* and *ignorechars* parameters. Single-character final " "groups are now always rejected as encoding violations." msgstr "" +"*canonical* と *ignorechars* パラメーターが追加されました。\n" +"最後のグループが 1 文字だけの場合は、エンコーディングの規則に違反するものとし" +"て常に拒否するようになりました。" -#: ../../library/base64.rst:413 msgid "" "Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ) and " "return the encoded :class:`bytes`." msgstr "" +":term:`bytes-like object` *s* を、ZeroMQ で使われる Z85 でエンコードし、エン" +"コードされた :class:`bytes` を返します。" -#: ../../library/base64.rst:416 msgid "" "The input is padded with ``b'\\0'`` so its length is a multiple of 4 bytes " "before encoding. If *pad* is true, all the resulting characters are " "retained in the output, which will always be a multiple of 5 bytes, as " "required by the ZeroMQ standard." msgstr "" +"エンコードの前に、入力の長さが 4 バイトの倍数になるよう ``b'\\0'`` でパディン" +"グします。\n" +"*pad* が真の場合、結果の文字はすべて出力に残るため、ZeroMQ の標準で要求される" +"とおり、出力の長さは常に 5 バイトの倍数になります。" -#: ../../library/base64.rst:427 msgid "The *pad* parameter was added." -msgstr "" +msgstr "*pad* パラメーターが追加されました。" -#: ../../library/base64.rst:436 msgid "" "Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and " "return the decoded :class:`bytes`." msgstr "" +"Z85 でエンコードされた :term:`bytes-like object` または ASCII 文字列 *s* をデ" +"コードし、デコードされた :class:`bytes` を返します。" #: ../../library/base64.rst:456 msgid "Legacy Interface" @@ -664,12 +721,14 @@ msgstr "モジュールの使用例:" msgid "Security Considerations" msgstr "セキュリティで考慮すべき点" -#: ../../library/base64.rst:509 msgid "" "A new security considerations section was added to :rfc:`4648` (section 12); " "it's recommended to review the security section for any code deployed to " "production." msgstr "" +":rfc:`4648` に、セキュリティ上の考慮事項をまとめた節 (第 12 節) が新たに追加" +"されました。\n" +"本番環境で使うコードでは、このセキュリティの節を確認することを推奨します。" #: ../../library/base64.rst:514 msgid "Module :mod:`binascii`" @@ -699,28 +758,31 @@ msgstr "" "Section 5.2, \"Base64 Content-Transfer-Encoding,\" provides the definition " "of the base64 encoding." -#: ../../library/base64.rst:521 msgid "" "`ISO 32000-2 Portable document format - Part 2: PDF 2.0 `_" msgstr "" +"`ISO 32000-2 Portable document format - Part 2: PDF 2.0 `_" -#: ../../library/base64.rst:522 msgid "" "Section 7.4.3, \"ASCII85Decode Filter,\" provides the definition of the " "Ascii85 encoding used in PDF and PostScript, including the output character " "set and the details of data length preservation using zero-padding and " "partial output groups." msgstr "" +"第 7.4.3 節 \"ASCII85Decode Filter\" は、PDF と PostScript で使われる " +"Ascii85 エンコーディングを定義しています。\n" +"出力の文字集合のほか、ゼロパディングと部分的な出力グループによってデータ長を" +"保持する方法が詳しく説明されています。" -#: ../../library/base64.rst:527 msgid "`ZeroMQ RFC 32/Z85 `_" -msgstr "" +msgstr "`ZeroMQ RFC 32/Z85 `_" -#: ../../library/base64.rst:528 msgid "" "The \"Formal Specification\" section provides the character set used in Z85." msgstr "" +"\"Formal Specification\" の節は、Z85 で使われる文字集合を定義しています。" #: ../../library/base64.rst:10 msgid "base64" diff --git a/library/bdb.po b/library/bdb.po index c92bfccfb..d46792a2b 100644 --- a/library/bdb.po +++ b/library/bdb.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/bdb.rst:2 @@ -30,11 +30,12 @@ msgstr ":mod:`!bdb` --- デバッガーフレームワーク" msgid "**Source code:** :source:`Lib/bdb.py`" msgstr "**ソースコード:** :source:`Lib/bdb.py`" -#: ../../library/bdb.rst:11 msgid "" "The :mod:`!bdb` module handles basic debugger functions, like setting " "breakpoints or managing execution via the debugger." msgstr "" +":mod:`!bdb` モジュールは、ブレークポイントの設定やデバッガーを通じた実行の管" +"理など、デバッガーの基本的な機能を扱います。" #: ../../library/bdb.rst:14 msgid "The following exception is defined:" @@ -44,9 +45,8 @@ msgstr "以下の例外が定義されています:" msgid "Exception raised by the :class:`Bdb` class for quitting the debugger." msgstr ":class:`Bdb` クラスが、デバッガーを終了させるために投げる例外。" -#: ../../library/bdb.rst:21 msgid "The :mod:`!bdb` module also defines two classes:" -msgstr "" +msgstr ":mod:`!bdb` モジュールは、次の 2 つのクラスも定義しています。" #: ../../library/bdb.rst:25 msgid "" @@ -56,18 +56,17 @@ msgstr "" "このクラスはテンポラリブレークポイント、無視するカウント、無効化と再有効化、" "条件付きブレークポイントを実装しています。" -#: ../../library/bdb.rst:28 msgid "" "Breakpoints are indexed by number through a list called :attr:`bpbynumber` " "and by ``(file, line)`` pairs through :attr:`bplist`. The former points to " "a single instance of class :class:`Breakpoint`. The latter points to a list " "of such instances since there may be more than one breakpoint per line." msgstr "" -"ブレークポイントは :attr:`bpbynumber` という名前のリストで番号によりインデッ" -"クスされ、 :attr:`bplist` により ``(file, line)`` の形でインデックスされま" -"す。 :attr:`bpbynumber` は :class:`Breakpoint` クラスのインスタンスを指してい" -"ます。一方 :attr:`bplist` は、同じ行に複数のブレークポイントが設定される場合" -"があるので、インスタンスのリストを指しています。" +"ブレークポイントは :attr:`bpbynumber` というリストでは番号を使って、:attr:" +"`bplist` では ``(file, line)`` の組を使って参照します。\n" +"前者では一つの :class:`Breakpoint` インスタンスが得られます。\n" +"同じ行に複数のブレークポイントを設定できるため、後者ではインスタンスのリスト" +"が得られます。" #: ../../library/bdb.rst:33 msgid "" @@ -111,29 +110,23 @@ msgid "" "formatted:" msgstr "ブレークポイントに関する情報を持つ文字列をフォーマットして返します:" -#: ../../library/bdb.rst:63 msgid "Breakpoint number." -msgstr "" +msgstr "ブレークポイントの番号。" -#: ../../library/bdb.rst:64 msgid "Temporary status (del or keep)." -msgstr "" +msgstr "一時的なブレークポイントかどうか (del または keep)。" -#: ../../library/bdb.rst:65 msgid "File/line position." -msgstr "" +msgstr "ファイルと行の位置。" -#: ../../library/bdb.rst:66 msgid "Break condition." -msgstr "" +msgstr "停止する条件。" -#: ../../library/bdb.rst:67 msgid "Number of times to ignore." -msgstr "" +msgstr "無視する回数。" -#: ../../library/bdb.rst:68 msgid "Number of times hit." -msgstr "" +msgstr "ヒットした回数。" #: ../../library/bdb.rst:74 msgid "" @@ -147,31 +140,29 @@ msgstr "" msgid ":class:`Breakpoint` instances have the following attributes:" msgstr ":class:`Breakpoint` インスタンスは以下の属性を持ちます:" -#: ../../library/bdb.rst:81 msgid "File name of the :class:`Breakpoint`." -msgstr "" +msgstr ":class:`Breakpoint` のファイル名です。" -#: ../../library/bdb.rst:85 msgid "Line number of the :class:`Breakpoint` within :attr:`file`." -msgstr "" +msgstr ":attr:`file` 内での :class:`Breakpoint` の行番号です。" -#: ../../library/bdb.rst:89 msgid "``True`` if a :class:`Breakpoint` at (file, line) is temporary." msgstr "" +"``(file, line)`` の :class:`Breakpoint` が一時的なものであれば ``True`` で" +"す。" -#: ../../library/bdb.rst:93 msgid "Condition for evaluating a :class:`Breakpoint` at (file, line)." -msgstr "" +msgstr "``(file, line)`` の :class:`Breakpoint` を評価する条件です。" -#: ../../library/bdb.rst:97 msgid "" "Function name that defines whether a :class:`Breakpoint` is hit upon " "entering the function." msgstr "" +"関数に入ったときに :class:`Breakpoint` にヒットするかどうかを決める関数名で" +"す。" -#: ../../library/bdb.rst:102 msgid "``True`` if :class:`Breakpoint` is enabled." -msgstr "" +msgstr ":class:`Breakpoint` が有効なら ``True`` です。" #: ../../library/bdb.rst:106 msgid "Numeric index for a single instance of a :class:`Breakpoint`." @@ -183,13 +174,11 @@ msgid "" "`line`) tuples." msgstr "" -#: ../../library/bdb.rst:115 msgid "Number of times to ignore a :class:`Breakpoint`." -msgstr "" +msgstr ":class:`Breakpoint` を無視する回数です。" -#: ../../library/bdb.rst:119 msgid "Count of the number of times a :class:`Breakpoint` has been hit." -msgstr "" +msgstr ":class:`Breakpoint` にヒットした回数です。" #: ../../library/bdb.rst:123 msgid "The :class:`Bdb` class acts as a generic Python debugger base class." @@ -220,7 +209,6 @@ msgstr "" "で発生したかどうかは、フレームのグローバル変数の ``__name__`` によって決定さ" "れます。" -#: ../../library/bdb.rst:135 msgid "" "The *backend* argument specifies the backend to use for :class:`Bdb`. It can " "be either ``'settrace'`` or ``'monitoring'``. ``'settrace'`` uses :func:`sys." @@ -231,14 +219,24 @@ msgid "" "some differences. The debugger developers are encouraged to use the " "``'monitoring'`` backend to achieve better performance." msgstr "" +"*backend* 引数は :class:`Bdb` が使うバックエンドを指定します。\n" +"``'settrace'`` または ``'monitoring'`` を指定できます。\n" +"``'settrace'`` は :func:`sys.settrace` を使い、後方互換性が最も高いバックエン" +"ドです。\n" +"``'monitoring'`` は Python 3.12 で導入された :mod:`sys.monitoring` を使いま" +"す。\n" +"使わないイベントを無効にできるため、大幅に効率がよくなる場合があります。\n" +"両方のバックエンドで同一のインターフェースを保つようにしていますが、いくつか" +"違いがあります。\n" +"性能を高めるため、デバッガーの開発者には ``'monitoring'`` バックエンドの使用" +"を推奨します。" #: ../../library/bdb.rst:145 msgid "Added the *skip* parameter." msgstr "*skip* パラメータが追加されました。" -#: ../../library/bdb.rst:148 msgid "Added the *backend* parameter." -msgstr "" +msgstr "*backend* パラメーターが追加されました。" #: ../../library/bdb.rst:151 msgid "" @@ -246,36 +244,42 @@ msgid "" msgstr "" "以下の :class:`Bdb` のメソッドは、通常オーバーライドする必要はありません。" -#: ../../library/bdb.rst:155 msgid "Return canonical form of *filename*." -msgstr "" +msgstr "*filename* を正規化した形式で返します。" -#: ../../library/bdb.rst:157 msgid "" "For real file names, the canonical form is an operating-system-dependent, :" "func:`case-normalized ` :func:`absolute path `. A *filename* with angle brackets, such as ``\"\"`` " "generated in interactive mode, is returned unchanged." msgstr "" +"実際のファイル名では、正規化された形式とは、OS に応じて :func:`大文字・小文字" +"を正規化した ` :func:`絶対パス ` です。\n" +"対話モードで生成される ``\"\"`` のように山括弧で囲まれた *filename* " +"は、そのまま返します。" -#: ../../library/bdb.rst:164 msgid "" "Start tracing. For ``'settrace'`` backend, this method is equivalent to " "``sys.settrace(self.trace_dispatch)``" msgstr "" +"トレースを開始します。\n" +"``'settrace'`` バックエンドでは、``sys.settrace(self.trace_dispatch)`` と同じ" +"です。" -#: ../../library/bdb.rst:171 msgid "" "Stop tracing. For ``'settrace'`` backend, this method is equivalent to ``sys." "settrace(None)``" msgstr "" +"トレースを停止します。\n" +"``'settrace'`` バックエンドでは、``sys.settrace(None)`` と同じです。" -#: ../../library/bdb.rst:178 msgid "" "Set the :attr:`!botframe`, :attr:`!stopframe`, :attr:`!returnframe` and :" "attr:`quitting ` attributes with values ready to start " "debugging." msgstr "" +":attr:`!botframe`、:attr:`!stopframe`、:attr:`!returnframe`、:attr:`quitting " +"` 属性を、デバッグを開始できる値に設定します。" #: ../../library/bdb.rst:183 msgid "" @@ -313,9 +317,8 @@ msgstr "``\"return\"``: 関数か別のコードブロックからreturnしよ msgid "``\"exception\"``: An exception has occurred." msgstr "``\"exception\"``: 例外が発生しました。" -#: ../../library/bdb.rst:196 msgid "For all the events, specialized functions (see below) are called." -msgstr "" +msgstr "各イベントに対応する専用の関数 (後述) を呼び出します。" #: ../../library/bdb.rst:198 msgid "The *arg* parameter depends on the previous event." @@ -331,7 +334,6 @@ msgstr "" "を参照してください。コードとフレームオブジェクトについてのより詳しい情報" "は、 :ref:`types` を参照してください。" -#: ../../library/bdb.rst:206 msgid "" "If the debugger should stop on the current line, invoke the :meth:" "`user_line` method (which should be overridden in subclasses). Raise a :exc:" @@ -339,8 +341,13 @@ msgid "" "(which can be set from :meth:`user_line`). Return a reference to the :meth:" "`trace_dispatch` method for further tracing in that scope." msgstr "" +"デバッガーが現在の行で停止するべきなら、:meth:`user_line` メソッドを呼び出し" +"ます (サブクラスでオーバーライドしてください)。\n" +":attr:`quitting ` フラグが設定されていれば :exc:`BdbQuit` を送" +"出します (このフラグは :meth:`user_line` から設定できます)。\n" +"そのスコープ内のトレースを続けるために、:meth:`trace_dispatch` メソッドへの参" +"照を返します。" -#: ../../library/bdb.rst:214 msgid "" "If the debugger should stop on this function call, invoke the :meth:" "`user_call` method (which should be overridden in subclasses). Raise a :exc:" @@ -348,8 +355,13 @@ msgid "" "(which can be set from :meth:`user_call`). Return a reference to the :meth:" "`trace_dispatch` method for further tracing in that scope." msgstr "" +"デバッガーがこの関数呼び出しで停止するべきなら、:meth:`user_call` メソッドを" +"呼び出します (サブクラスでオーバーライドしてください)。\n" +":attr:`quitting ` フラグが設定されていれば :exc:`BdbQuit` を送" +"出します (このフラグは :meth:`user_call` から設定できます)。\n" +"そのスコープ内のトレースを続けるために、:meth:`trace_dispatch` メソッドへの参" +"照を返します。" -#: ../../library/bdb.rst:222 msgid "" "If the debugger should stop on this function return, invoke the :meth:" "`user_return` method (which should be overridden in subclasses). Raise a :" @@ -357,8 +369,13 @@ msgid "" "(which can be set from :meth:`user_return`). Return a reference to the :" "meth:`trace_dispatch` method for further tracing in that scope." msgstr "" +"デバッガーがこの関数からのリターンで停止するべきなら、:meth:`user_return` メ" +"ソッドを呼び出します (サブクラスでオーバーライドしてください)。\n" +":attr:`quitting ` フラグが設定されていれば :exc:`BdbQuit` を送" +"出します (このフラグは :meth:`user_return` から設定できます)。\n" +"そのスコープ内のトレースを続けるために、:meth:`trace_dispatch` メソッドへの参" +"照を返します。" -#: ../../library/bdb.rst:230 msgid "" "If the debugger should stop at this exception, invokes the :meth:" "`user_exception` method (which should be overridden in subclasses). Raise a :" @@ -366,6 +383,12 @@ msgid "" "(which can be set from :meth:`user_exception`). Return a reference to the :" "meth:`trace_dispatch` method for further tracing in that scope." msgstr "" +"デバッガーがこの例外で停止するべきなら、:meth:`user_exception` メソッドを呼び" +"出します (サブクラスでオーバーライドしてください)。\n" +":attr:`quitting ` フラグが設定されていれば :exc:`BdbQuit` を送" +"出します (このフラグは :meth:`user_exception` から設定できます)。\n" +"そのスコープ内のトレースを続けるために、:meth:`trace_dispatch` メソッドへの参" +"照を返します。" #: ../../library/bdb.rst:236 msgid "" @@ -375,27 +398,30 @@ msgstr "" "通常、継承クラスは以下のメソッド群をオーバーライドしません。しかし、停止やブ" "レークポイント機能を再定義したい場合には、オーバーライドすることもあります。" -#: ../../library/bdb.rst:241 msgid "Return ``True`` if *module_name* matches any skip pattern." msgstr "" +"*module_name* がいずれかのスキップパターンにマッチすれば ``True`` を返しま" +"す。" #: ../../library/bdb.rst:245 msgid "Return ``True`` if *frame* is below the starting frame in the stack." msgstr "" -#: ../../library/bdb.rst:249 msgid "Return ``True`` if there is an effective breakpoint for this line." -msgstr "" +msgstr "この行に実際に停止するブレークポイントがあれば ``True`` を返します。" -#: ../../library/bdb.rst:251 msgid "" "Check whether a line or function breakpoint exists and is in effect. Delete " "temporary breakpoints based on information from :func:`effective`." msgstr "" +"行または関数のブレークポイントが存在し、実際に停止するかどうかを確認しま" +"す。\n" +":func:`effective` の情報に基づいて、一時的なブレークポイントを削除します。" -#: ../../library/bdb.rst:256 msgid "Return ``True`` if any breakpoint exists for *frame*'s filename." msgstr "" +"*frame* のファイル名に対してブレークポイントが 1 つでもあれば ``True`` を返し" +"ます。" #: ../../library/bdb.rst:258 msgid "" @@ -405,17 +431,19 @@ msgstr "" "継承クラスはデバッガー操作をするために以下のメソッド群をオーバーライドするべ" "きです。" -#: ../../library/bdb.rst:263 msgid "" "Called from :meth:`dispatch_call` if a break might stop inside the called " "function." msgstr "" +"呼び出された関数内で停止する可能性がある場合、:meth:`dispatch_call` から呼び" +"出されます。" -#: ../../library/bdb.rst:266 msgid "" "*argument_list* is not used anymore and will always be ``None``. The " "argument is kept for backwards compatibility." msgstr "" +"*argument_list* は現在使われておらず、常に ``None`` です。\n" +"後方互換性のために残されています。" #: ../../library/bdb.rst:271 msgid "" @@ -487,11 +515,12 @@ msgstr "" "*frame* からデバッグを開始します。*frame* が指定されなかった場合、デバッグは" "呼び出し元のフレームから開始します。" -#: ../../library/bdb.rst:315 msgid "" ":func:`set_trace` will enter the debugger immediately, rather than on the " "next line of code to be executed." msgstr "" +":func:`set_trace` は、次に実行されるコードの行を待たずに、直ちにデバッガに入" +"るようになりました。" #: ../../library/bdb.rst:321 msgid "" @@ -501,11 +530,13 @@ msgstr "" "ブレークポイントに到達するか終了したときにストップします。もしブレークポイン" "トが1つも無い場合、システムのトレース関数を ``None`` に設定します。" -#: ../../library/bdb.rst:328 msgid "" "Set the :attr:`!quitting` attribute to ``True``. This raises :exc:`BdbQuit` " "in the next call to one of the :meth:`!dispatch_\\*` methods." msgstr "" +":attr:`!quitting` 属性を ``True`` に設定します。\n" +"これにより、次にいずれかの :meth:`!dispatch_\\*` メソッドを呼び出すと :exc:" +"`BdbQuit` が送出されます。" #: ../../library/bdb.rst:332 msgid "" @@ -571,9 +602,9 @@ msgstr "" "ら数値に変換されます。 *arg* が非数値の文字列である場合、指定されたブレークポ" "イントが存在しないか削除された場合、 :exc:`ValueError` が上げられます。" -#: ../../library/bdb.rst:374 msgid "Return ``True`` if there is a breakpoint for *lineno* in *filename*." msgstr "" +"*filename* の *lineno* 行にブレークポイントがあれば ``True`` を返します。" #: ../../library/bdb.rst:378 msgid "" @@ -593,27 +624,36 @@ msgstr "" msgid "Return all breakpoints that are set." msgstr "セットされているすべてのブレークポイントを返します。" -#: ../../library/bdb.rst:390 msgid "" "Derived classes and clients can call the following methods to disable and " "restart events to achieve better performance. These methods only work when " "using the ``'monitoring'`` backend." msgstr "" +"派生クラスやクライアントは、次のメソッドでイベントを無効にしたり再開したりし" +"て、性能を高められます。\n" +"これらのメソッドが機能するのは ``'monitoring'`` バックエンドを使う場合だけで" +"す。" -#: ../../library/bdb.rst:396 msgid "" "Disable the current event until the next time :func:`restart_events` is " "called. This is helpful when the debugger is not interested in the current " "line." msgstr "" +"次に :func:`restart_events` が呼び出されるまで、現在のイベントを無効にしま" +"す。\n" +"デバッガーが現在の行を調べる必要がない場合に役立ちます。" -#: ../../library/bdb.rst:404 msgid "" "Restart all the disabled events. This function is automatically called in " "``dispatch_*`` methods after ``user_*`` methods are called. If the " "``dispatch_*`` methods are not overridden, the disabled events will be " "restarted after each user interaction." msgstr "" +"無効にしたすべてのイベントを再開します。\n" +"この関数は ``dispatch_*`` メソッド内で、``user_*`` メソッドの呼び出し後に自動" +"的に呼び出されます。\n" +"``dispatch_*`` メソッドをオーバーライドしていなければ、ユーザーとのやりとりの" +"たびに、無効にしたイベントが再開されます。" #: ../../library/bdb.rst:412 msgid "" @@ -633,15 +673,16 @@ msgid "" "of frames below the frame where the debugger was invoked." msgstr "" -#: ../../library/bdb.rst:424 msgid "" "Return a string with information about a stack entry, which is a ``(frame, " "lineno)`` tuple. The return string contains:" msgstr "" +"スタックのエントリーを表す ``(frame, lineno)`` タプルについての情報を文字列で" +"返します。\n" +"返す文字列には次の情報を含みます。" -#: ../../library/bdb.rst:427 msgid "The canonical filename which contains the frame." -msgstr "" +msgstr "フレームを含むファイルの正規化された名前。" #: ../../library/bdb.rst:428 msgid "The function name or ``\"\"``." @@ -667,11 +708,13 @@ msgstr "" "以下の2つのメソッドは、文字列として渡された :term:`文 ` をデバッグ" "するもので、クライアントから利用されます。" -#: ../../library/bdb.rst:439 msgid "" "Debug a statement executed via the :func:`exec` function. *globals* " "defaults to :attr:`!__main__.__dict__`, *locals* defaults to *globals*." msgstr "" +":func:`exec` 関数で実行する文をデバッグします。\n" +"*globals* のデフォルトは :attr:`!__main__.__dict__`、*locals* のデフォルトは " +"*globals* です。" #: ../../library/bdb.rst:444 msgid "" @@ -681,9 +724,10 @@ msgstr "" ":func:`eval` 関数を利用して式を実行しデバッグします。 *globals* と *locals* " "は :meth:`run` と同じ意味です。" -#: ../../library/bdb.rst:449 msgid "For backwards compatibility. Calls the :meth:`run` method." -msgstr "後方互換性のためのメソッドです。 :meth:`run` を使ってください。" +msgstr "" +"後方互換性のためのメソッドです。\n" +":meth:`run` メソッドを呼び出します。" #: ../../library/bdb.rst:453 msgid "Debug a single function call, and return its result." @@ -693,13 +737,13 @@ msgstr "1つの関数呼び出しをデバッグし、その結果を返しま msgid "Finally, the module defines the following functions:" msgstr "最後に、このモジュールは以下の関数を提供しています:" -#: ../../library/bdb.rst:460 msgid "" "Return ``True`` if we should break here, depending on the way the :class:" "`Breakpoint` *b* was set." msgstr "" +":class:`Breakpoint` *b* の設定に基づき、この位置で停止するべきなら ``True`` " +"を返します。" -#: ../../library/bdb.rst:463 msgid "" "If it was set via line number, it checks if :attr:`b.line ` is the same as the one in *frame*. If the breakpoint was set via :" @@ -707,14 +751,19 @@ msgid "" "the right *frame* (the right function) and if we are on its first executable " "line." msgstr "" +"行番号で設定されたブレークポイントでは、:attr:`b.line ` " +"と *frame* の行番号が同じかどうかを確認します。\n" +":attr:`関数名 ` で設定された場合は、正しい *frame* " +"(正しい関数) 内にいて、その関数の最初の実行可能な行にいるかどうかを確認する必" +"要があります。" -#: ../../library/bdb.rst:472 msgid "" "Return ``(active breakpoint, delete temporary flag)`` or ``(None, None)`` as " "the breakpoint to act upon." msgstr "" +"停止に使うブレークポイントとして ``(active breakpoint, delete temporary " +"flag)``、または ``(None, None)`` を返します。" -#: ../../library/bdb.rst:475 msgid "" "The *active breakpoint* is the first entry in :attr:`bplist ` for the (:attr:`file `, :attr:`line ` cannot be evaluated (in which case, :attr:`ignore ` count is ignored)." msgstr "" +"*active breakpoint* は、存在する (:attr:`file `、:attr:" +"`line `) に対応する :attr:`bplist ` のうち、次の条件を満たす最初のエントリーです。\n" +":attr:`有効 ` で、:func:`checkfuncname` が真を返し、:" +"attr:`条件 ` が偽ではなく、:attr:`無視する回数 ` が正でもないことが条件です。\n" +"一時的なブレークポイントを削除すべきことを表す *flag* が ``False`` になるの" +"は、:attr:`cond ` を評価できない場合だけです (この場" +"合、:attr:`無視する回数 ` は考慮しません)。" -#: ../../library/bdb.rst:486 msgid "If no such entry exists, then ``(None, None)`` is returned." -msgstr "" +msgstr "該当するエントリーがなければ ``(None, None)`` を返します。" #: ../../library/bdb.rst:491 msgid "Start debugging with a :class:`Bdb` instance from caller's frame." @@ -737,6 +794,5 @@ msgstr "" ":class:`Bdb` クラスのインスタンスを使って、呼び出し元のフレームからデバッグを" "開始します。" -#: ../../library/bdb.rst:326 msgid "quitting (bdb.Bdb attribute)" -msgstr "" +msgstr "quitting (bdb.Bdb の属性)" diff --git a/library/binary.po b/library/binary.po index 6df301cbe..afc57702d 100644 --- a/library/binary.po +++ b/library/binary.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/binary.rst:5 diff --git a/library/binascii.po b/library/binascii.po index a9c6a65e8..ed1161d00 100644 --- a/library/binascii.po +++ b/library/binascii.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/binascii.rst:2 msgid ":mod:`!binascii` --- Convert between binary and ASCII" msgstr ":mod:`!binascii` --- バイナリ と ASCII 間の変換" -#: ../../library/binascii.rst:13 msgid "" "The :mod:`!binascii` module contains a number of methods to convert between " "binary and various ASCII-encoded binary representations. Normally, you will " @@ -34,6 +33,12 @@ msgid "" "instead. The :mod:`!binascii` module contains low-level functions written in " "C for greater speed that are used by the higher-level modules." msgstr "" +":mod:`!binascii` モジュールは、バイナリデータと、ASCII でエンコードされたさま" +"ざまなバイナリ表現との間で変換するための関数を提供します。\n" +"通常はこれらの関数を直接使わず、:mod:`base64` などのラッパーモジュールを使い" +"ます。\n" +":mod:`!binascii` は、高水準のモジュールから使われる低水準の関数を含んでおり、" +"高速化のために C で実装されています。" #: ../../library/binascii.rst:22 msgid "" @@ -52,27 +57,29 @@ msgid "ASCII-only unicode strings are now accepted by the ``a2b_*`` functions." msgstr "" "``a2b_*`` 関数は ASCII のみのユニコード文字列を受け取るようになりました。" -#: ../../library/binascii.rst:31 msgid "The :mod:`!binascii` module defines the following functions:" -msgstr "" +msgstr ":mod:`!binascii` モジュールは次の関数を定義しています。" -#: ../../library/binascii.rst:36 msgid "" "Convert a single line of uuencoded data back to binary and return the binary " "data. Lines normally contain 45 (binary) bytes, except for the last line. " "Line data may be followed by whitespace." msgstr "" "uuencode された 1 行のデータをバイナリに変換し、変換後のバイナリデータを返し" -"ます。最後の行を除いて、通常 1 行には (バイナリデータで) 45 バイトが含まれま" -"す。入力データの先頭には空白文字が連続していてもかまいません。" +"ます。\n" +"最後の行を除いて、通常 1 行には (バイナリデータで) 45 バイトが含まれます。\n" +"行データの後ろには空白文字が続いていてもかまいません。" -#: ../../library/binascii.rst:43 msgid "" "Convert binary data to a line of ASCII characters, the return value is the " "converted line, including a newline char. The length of *data* should be at " "most 45. If *backtick* is true, zeros are represented by ``'`'`` instead of " "spaces." msgstr "" +"バイナリデータを 1 行の ASCII 文字列に変換し、改行文字を含む変換結果を返しま" +"す。\n" +"*data* の長さは 45 以下でなければなりません。\n" +"*backtick* が真の場合、ゼロをスペースではなく ``'`'`` で表します。" #: ../../library/binascii.rst:47 msgid "Added the *backtick* parameter." @@ -86,13 +93,13 @@ msgstr "" "base64 でエンコードされたデータのブロックをバイナリに変換し、変換後のバイナリ" "データを返します。一度に 1 行以上のデータを与えてもかまいません。" -#: ../../library/binascii.rst:57 msgid "" "Optional *alphabet* must be a :class:`bytes` object of length 64 which " "specifies an alternative alphabet." msgstr "" +"省略可能な *alphabet* には、代替アルファベットを指定する長さ 64 の :class:" +"`bytes` オブジェクトを渡してください。" -#: ../../library/binascii.rst:60 msgid "" "If *padded* is true, the last group of 4 base 64 alphabet characters must be " "padded with the '=' character. If *padded* is false, padding is neither " @@ -101,8 +108,14 @@ msgid "" "*strict_mode* is false, or causes an :exc:`~binascii.Error` when " "*strict_mode* is true unless b'=' is included in *ignorechars*." msgstr "" +"*padded* が真の場合、Base64 アルファベットの最後の 4 文字の組には '=' による" +"パディングが必要です。\n" +"*padded* が偽の場合、パディングは不要で、パディングとしての認識もしません。\n" +"'=' はパディングではなくアルファベット外の文字として扱われるため、" +"*strict_mode* が偽なら黙って破棄されます。\n" +"*strict_mode* が真なら、*ignorechars* に ``b'='`` が含まれていない限り :exc:" +"`~binascii.Error` が発生します。" -#: ../../library/binascii.rst:68 msgid "" "If *ignorechars* is specified, it should be a :term:`bytes-like object` " "containing characters to ignore from the input when *strict_mode* is true. " @@ -111,90 +124,96 @@ msgid "" "will be ignored. The default value of *strict_mode* is ``True`` if " "*ignorechars* is specified, ``False`` otherwise." msgstr "" +"*ignorechars* を指定する場合は、*strict_mode* が真のときに入力から無視する文" +"字を含む :term:`bytes-like object` を渡してください。\n" +"*ignorechars* にパディング文字 ``'='`` を含めると、エンコードされたデータの末" +"尾より前に現れるパディング文字や、余分なパディング文字を無視します。\n" +"*strict_mode* のデフォルト値は、*ignorechars* を指定した場合は ``True``、それ" +"以外は ``False`` です。" -#: ../../library/binascii.rst:76 msgid "" "If *strict_mode* is true, only valid base64 data will be converted. Invalid " "base64 data will raise :exc:`binascii.Error`." msgstr "" +"*strict_mode* が真の場合、有効な Base64 データのみ変換します。\n" +"無効な Base64 データでは :exc:`binascii.Error` を送出します。" -#: ../../library/binascii.rst:79 msgid "Valid base64:" -msgstr "" +msgstr "有効な Base64 データの条件:" -#: ../../library/binascii.rst:81 msgid "Conforms to :rfc:`4648`." -msgstr "" +msgstr ":rfc:`4648` に準拠している。" -#: ../../library/binascii.rst:82 msgid "Contains only characters from the base64 alphabet." -msgstr "" +msgstr "Base64 アルファベットの文字だけを含む。" -#: ../../library/binascii.rst:83 msgid "" "Contains no excess data after padding (including excess padding, newlines, " "etc.)." msgstr "" +"パディングの後に余分なデータ (余分なパディングや改行などを含む) がない。" -#: ../../library/binascii.rst:84 msgid "Does not start with a padding." -msgstr "" +msgstr "パディングで始まらない。" -#: ../../library/binascii.rst:86 msgid "" "If *canonical* is true, non-zero padding bits in the last group are rejected " "with :exc:`binascii.Error`, enforcing canonical encoding as defined in :rfc:" "`4648` section 3.5. This check is independent of *strict_mode*." msgstr "" +"*canonical* が真の場合、最後のグループのゼロでないパディングビットを :exc:" +"`binascii.Error` で拒否し、:rfc:`4648` の第 3.5 節で定義された正規形のエン" +"コーディングを要求します。\n" +"この検査は *strict_mode* とは独立しています。" -#: ../../library/binascii.rst:90 msgid "Added the *strict_mode* parameter." -msgstr "" +msgstr "*strict_mode* パラメーターが追加されました。" -#: ../../library/binascii.rst:93 msgid "" "Added the *alphabet*, *canonical*, *ignorechars*, and *padded* parameters." msgstr "" +"*alphabet*、*canonical*、*ignorechars*、*padded* パラメーターが追加されまし" +"た。" -#: ../../library/binascii.rst:99 msgid "" "Convert binary data to a line(s) of ASCII characters in base64 coding, as " "specified in :rfc:`4648`." msgstr "" +"バイナリデータを、:rfc:`4648` で規定された Base64 エンコーディングで、1 行以" +"上の ASCII 文字列に変換します。" -#: ../../library/binascii.rst:102 msgid "" "If *padded* is true (default), pad the encoded data with the '=' character " "to a size multiple of 4. If *padded* is false, do not add the pad characters." msgstr "" +"*padded* が真 (デフォルト) の場合、エンコードしたデータの長さが 4 の倍数にな" +"るように '=' でパディングします。\n" +"*padded* が偽の場合、パディング文字を追加しません。" -#: ../../library/binascii.rst:106 ../../library/binascii.rst:166 -#: ../../library/binascii.rst:219 ../../library/binascii.rst:280 msgid "" "If *wrapcol* is non-zero, insert a newline (``b'\\n'``) character after at " "most every *wrapcol* characters. If *wrapcol* is zero (default), do not " "insert any newlines." msgstr "" +"*wrapcol* がゼロでない場合、最大 *wrapcol* 文字ごとに改行文字 (``b'\\n'``) を" +"挿入します。\n" +"*wrapcol* がゼロ (デフォルト) の場合、改行を挿入しません。" -#: ../../library/binascii.rst:110 msgid "" "If *newline* is true (default), a newline character will be added at the end " "of the output." -msgstr "" +msgstr "*newline* が真 (デフォルト) の場合、出力の末尾に改行文字を追加します。" #: ../../library/binascii.rst:113 msgid "Added the *newline* parameter." msgstr "パラメータに *newline* を追加しました。" -#: ../../library/binascii.rst:116 msgid "Added the *alphabet*, *padded* and *wrapcol* parameters." -msgstr "" +msgstr "*alphabet*、*padded*、*wrapcol* パラメーターが追加されました。" -#: ../../library/binascii.rst:122 msgid "Convert Ascii85 data back to binary and return the binary data." -msgstr "" +msgstr "Ascii85 データをバイナリに戻し、バイナリデータを返します。" -#: ../../library/binascii.rst:124 msgid "" "Valid Ascii85 data contains characters from the Ascii85 alphabet in groups " "of five (except for the final group, which may have from two to five " @@ -204,6 +223,14 @@ msgid "" "bytes. A single-character final group is always rejected as an encoding " "violation." msgstr "" +"有効な Ascii85 データは、Ascii85 アルファベットの文字を 5 文字ずつのグループ" +"にしたものです (最後のグループは 2~5 文字でもかまいません)。\n" +"各グループは ``0`` から ``2 ** 32 - 1`` までの範囲の 32 ビットのバイナリデー" +"タを表します。\n" +"特別な文字 ``z`` は、連続する 4 つのヌルバイトを表すグループ ``!!!!!`` の短縮" +"形として受け入れられます。\n" +"最後のグループが 1 文字だけの場合は、エンコーディングの規則に違反するものとし" +"て常に拒否します。" #: ../../library/binascii.rst:132 msgid "" @@ -215,21 +242,26 @@ msgstr "" "0x20)と解釈するかどうかを制御します。この機能は \"標準\" Ascii85 ではサポート" "されていません。" -#: ../../library/binascii.rst:136 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, as in a PostScript base-85 string literal. If *adobe* is true, a " "leading ``<~`` is optionally accepted, while a trailing ``~>`` is " "*required*, and :exc:`binascii.Error` is raised if it is not found." msgstr "" +"*adobe* は、PostScript の Base85 文字列リテラルのように、エンコードされたバイ" +"ト列が ``<~`` と ``~>`` で囲まれているかどうかを指定します。\n" +"*adobe* が真の場合、先頭の ``<~`` は省略できますが、末尾の ``~>`` は *必須* " +"です。\n" +"末尾のマーカーがなければ :exc:`binascii.Error` を送出します。" -#: ../../library/binascii.rst:142 msgid "" "*ignorechars* should be a :term:`bytes-like object` containing characters to " "ignore from the input. This should only contain whitespace characters." msgstr "" +"*ignorechars* には、入力から無視する文字を含む :term:`bytes-like object` を指" +"定してください。\n" +"空白文字だけを含めるようにしてください。" -#: ../../library/binascii.rst:146 msgid "" "If *canonical* is true, non-canonical encodings are rejected with :exc:" "`binascii.Error`. Here \"canonical\" means the encoding that :func:" @@ -237,16 +269,21 @@ msgid "" "zero groups (rather than ``!!!!!``), and partial final groups must use the " "same padding digits as the encoder." msgstr "" +"*canonical* が真の場合、正規形でないエンコーディングを :exc:`binascii.Error` " +"で拒否します。\n" +"ここで「正規形」とは、:func:`b2a_ascii85` が生成するエンコーディングです。\n" +"すべてゼロのグループには ``!!!!!`` ではなく短縮形 ``z`` を使い、最後の不完全" +"なグループにはエンコーダーと同じパディング桁を使う必要があります。" -#: ../../library/binascii.rst:152 msgid "Invalid Ascii85 data will raise :exc:`binascii.Error`." -msgstr "" +msgstr "無効な Ascii85 データでは :exc:`binascii.Error` を送出します。" -#: ../../library/binascii.rst:159 msgid "" "Convert binary data to a formatted sequence of ASCII characters in Ascii85 " "coding. The return value is the converted data." msgstr "" +"バイナリデータを Ascii85 エンコーディングで整形された ASCII 文字列に変換し、" +"変換結果を返します。" #: ../../library/binascii.rst:162 msgid "" @@ -266,21 +303,24 @@ msgid "" "used in PDF, as it does not preserve the length of the data." msgstr "" -#: ../../library/binascii.rst:176 msgid "" "*adobe* controls whether the encoded byte sequence is framed with ``<~`` and " "``~>``, as in a PostScript base-85 string literal. Note that while " "ASCII85Decode streams in PDF documents *must* be terminated with ``~>``, " "they *must not* use a leading ``<~``." msgstr "" +"*adobe* は、PostScript の Base85 文字列リテラルのように、エンコードしたバイト" +"列を ``<~`` と ``~>`` で囲むかどうかを制御します。\n" +"PDF 文書の ASCII85Decode ストリームは ``~>`` で終わる *必要があります* が、先" +"頭に ``<~`` を付けては *いけません*。" -#: ../../library/binascii.rst:186 msgid "" "Convert Base85 data back to binary and return the binary data. More than one " "line may be passed at a time." msgstr "" +"Base85 データをバイナリに戻し、バイナリデータを返します。\n" +"一度に複数行を渡すこともできます。" -#: ../../library/binascii.rst:189 msgid "" "Valid Base85 data contains characters from the Base85 alphabet in groups of " "five (except for the final group, which may have from two to five " @@ -288,119 +328,151 @@ msgid "" "``0`` to ``2 ** 32 - 1``, inclusive. A single-character final group is " "always rejected as an encoding violation." msgstr "" +"有効な Base85 データは、Base85 アルファベットの文字を 5 文字ずつのグループに" +"したものです (最後のグループは 2~5 文字でもかまいません)。\n" +"各グループは ``0`` から ``2 ** 32 - 1`` までの範囲の 32 ビットのバイナリデー" +"タを表します。\n" +"最後のグループが 1 文字だけの場合は、エンコーディングの規則に違反するものとし" +"て常に拒否します。" -#: ../../library/binascii.rst:195 msgid "" "Optional *alphabet* must be a :class:`bytes` object of length 85 which " "specifies an alternative alphabet." msgstr "" +"省略可能な *alphabet* には、代替アルファベットを指定する長さ 85 の :class:" +"`bytes` オブジェクトを渡してください。" -#: ../../library/binascii.rst:198 ../../library/binascii.rst:367 msgid "" "*ignorechars* should be a :term:`bytes-like object` containing characters to " "ignore from the input." msgstr "" +"*ignorechars* には、入力から無視する文字を含む :term:`bytes-like object` を指" +"定してください。" -#: ../../library/binascii.rst:201 msgid "" "If *canonical* is true, non-canonical encodings are rejected with :exc:" "`binascii.Error`. Here \"canonical\" means the encoding that :func:" "`b2a_base85` would produce: partial final groups must use the same padding " "digits as the encoder." msgstr "" +"*canonical* が真の場合、正規形でないエンコーディングを :exc:`binascii.Error` " +"で拒否します。\n" +"ここで「正規形」とは、:func:`b2a_base85` が生成するエンコーディングです。\n" +"最後の不完全なグループには、エンコーダーと同じパディング桁を使う必要がありま" +"す。" -#: ../../library/binascii.rst:206 msgid "Invalid Base85 data will raise :exc:`binascii.Error`." -msgstr "" +msgstr "無効な Base85 データでは :exc:`binascii.Error` を送出します。" -#: ../../library/binascii.rst:213 msgid "" "Convert binary data to a line of ASCII characters in Base85 coding. The " "return value is the converted line." msgstr "" +"バイナリデータを Base85 エンコーディングで 1 行の ASCII 文字列に変換し、その" +"行を返します。" -#: ../../library/binascii.rst:216 msgid "" "Optional *alphabet* must be a :term:`bytes-like object` of length 85 which " "specifies an alternative alphabet." msgstr "" +"省略可能な *alphabet* には、代替アルファベットを指定する長さ 85 の :term:" +"`bytes-like object` を渡してください。" -#: ../../library/binascii.rst:223 msgid "" "If *pad* is true, the zero-padding applied to the end of the input is " "retained in the output, which will always be a multiple of 5 bytes, and thus " "the length of the data may not be preserved on decoding." msgstr "" +"*pad* が真の場合、入力の末尾に加えたゼロパディングを出力に残すため、出力の長" +"さは常に 5 バイトの倍数になります。\n" +"そのため、デコード時にデータの長さが保たれない場合があります。" -#: ../../library/binascii.rst:233 msgid "Convert base32 data back to binary and return the binary data." -msgstr "" +msgstr "Base32 データをバイナリに戻し、バイナリデータを返します。" -#: ../../library/binascii.rst:235 msgid "" "Valid base32 data contains characters from the base32 alphabet specified in :" "rfc:`4648` in groups of eight (if necessary, the final group is padded to " "eight characters with ``=``). Each group encodes 40 bits of binary data in " "the range from ``0`` to ``2 ** 40 - 1``, inclusive." msgstr "" +"有効な Base32 データは、:rfc:`4648` で規定された Base32 アルファベットの文字" +"を 8 文字ずつのグループにしたものです (必要なら、最後のグループを ``=`` で 8 " +"文字までパディングします)。\n" +"各グループは ``0`` から ``2 ** 40 - 1`` までの範囲の 40 ビットのバイナリデー" +"タを表します。" -#: ../../library/binascii.rst:241 msgid "" "This function does not map lowercase characters (which are invalid in " "standard base32) to their uppercase counterparts, nor does it contextually " "map ``0`` to ``O`` and ``1`` to ``I``/``L`` as :rfc:`4648` allows." msgstr "" +"この関数は、標準の Base32 では無効な小文字を大文字に変換しません。\n" +"また、:rfc:`4648` で許可されている、文脈に応じた ``0`` から ``O`` への変換や " +"``1`` から ``I`` または ``L`` への変換も行いません。" -#: ../../library/binascii.rst:246 msgid "" "Optional *alphabet* must be a :class:`bytes` object of length 32 which " "specifies an alternative alphabet." msgstr "" +"省略可能な *alphabet* には、代替アルファベットを指定する長さ 32 の :class:" +"`bytes` オブジェクトを渡してください。" -#: ../../library/binascii.rst:249 msgid "" "If *padded* is true, the last group of 8 base 32 alphabet characters must be " "padded with the '=' character. If *padded* is false, the '=' character is " "treated as other non-alphabet characters (depending on the value of " "*ignorechars*)." msgstr "" +"*padded* が真の場合、Base32 アルファベットの最後の 8 文字の組には '=' による" +"パディングが必要です。\n" +"*padded* が偽の場合、'=' は他のアルファベット外の文字と同様に、*ignorechars* " +"の値に応じて扱われます。" -#: ../../library/binascii.rst:254 msgid "" "*ignorechars* should be a :term:`bytes-like object` containing characters to " "ignore from the input. If *ignorechars* contains the pad character ``'='``, " "the pad characters presented before the end of the encoded data and the " "excess pad characters will be ignored." msgstr "" +"*ignorechars* には、入力から無視する文字を含む :term:`bytes-like object` を指" +"定してください。\n" +"*ignorechars* にパディング文字 ``'='`` を含めると、エンコードされたデータの末" +"尾より前に現れるパディング文字や、余分なパディング文字を無視します。" -#: ../../library/binascii.rst:260 msgid "" "If *canonical* is true, non-zero padding bits in the last group are rejected " "with :exc:`binascii.Error`, enforcing canonical encoding as defined in :rfc:" "`4648` section 3.5." msgstr "" +"*canonical* が真の場合、最後のグループのゼロでないパディングビットを :exc:" +"`binascii.Error` で拒否し、:rfc:`4648` の第 3.5 節で定義された正規形のエン" +"コーディングを要求します。" -#: ../../library/binascii.rst:264 msgid "Invalid base32 data will raise :exc:`binascii.Error`." -msgstr "" +msgstr "無効な Base32 データでは :exc:`binascii.Error` を送出します。" -#: ../../library/binascii.rst:270 msgid "" "Convert binary data to a line of ASCII characters in base32 coding, as " "specified in :rfc:`4648`. The return value is the converted line." msgstr "" +"バイナリデータを、:rfc:`4648` で規定された Base32 エンコーディングで 1 行の " +"ASCII 文字列に変換し、その行を返します。" -#: ../../library/binascii.rst:273 msgid "" "Optional *alphabet* must be a :term:`bytes-like object` of length 32 which " "specifies an alternative alphabet." msgstr "" +"省略可能な *alphabet* には、代替アルファベットを指定する長さ 32 の :term:" +"`bytes-like object` を渡してください。" -#: ../../library/binascii.rst:276 msgid "" "If *padded* is true (default), pad the encoded data with the '=' character " "to a size multiple of 8. If *padded* is false, do not add the pad characters." msgstr "" +"*padded* が真 (デフォルト) の場合、エンコードしたデータの長さが 8 の倍数にな" +"るように '=' でパディングします。\n" +"*padded* が偽の場合、パディング文字を追加しません。" #: ../../library/binascii.rst:288 msgid "" @@ -412,7 +484,6 @@ msgstr "" "度に 1 行以上のデータを渡すことができます。オプション引数 *header* が与えられ" "ており、かつその値が真であれば、アンダースコアは空白文字にデコードされます。" -#: ../../library/binascii.rst:295 msgid "" "Convert binary data to a line(s) of ASCII characters in quoted-printable " "encoding. The return value is the converted line(s). If the optional " @@ -425,15 +496,18 @@ msgid "" "might corrupt the binary data stream." msgstr "" "バイナリデータを quoted-printable 形式でエンコードして 1 行から複数行の " -"ASCII 文字列に変換します。変換後の文字列を返します。オプション引数 " -"*quptetabs* が存在し、かつその値が真であれば、全てのタブおよび空白文字もエン" -"コードされます。オプション引数 *istext* が存在し、かつその値が真であれば、改" -"行はエンコードされませんが、行末の空白文字はエンコードされます。オプション引" -"数 *header* が存在し、かつその値が真である場合、空白文字は :rfc:`1522` にした" -"がってアンダースコアにエンコードされます。オプション引数 *header* が存在し、" -"かつその値が偽である場合、改行文字も同様にエンコードされます。そうでない場" -"合、復帰 (linefeed) 文字の変換によってバイナリデータストリームが破損してしま" -"うかもしれません。" +"ASCII 文字列に変換します。\n" +"変換後の文字列を返します。\n" +"オプション引数 *quotetabs* が存在し、かつその値が真であれば、全てのタブおよび" +"空白文字もエンコードされます。\n" +"オプション引数 *istext* が存在し、かつその値が真であれば、改行はエンコードさ" +"れませんが、行末の空白文字はエンコードされます。\n" +"オプション引数 *header* が存在し、かつその値が真である場合、空白文字は :rfc:" +"`1522` にしたがってアンダースコアにエンコードされます。\n" +"オプション引数 *header* が存在し、かつその値が偽である場合、改行文字も同様に" +"エンコードされます。\n" +"そうでない場合、改行 (linefeed) 文字の変換によってバイナリデータストリームが" +"破損してしまうかもしれません。" #: ../../library/binascii.rst:308 msgid "" @@ -462,7 +536,6 @@ msgstr "" "アルゴリズムとして設計されたもので、一般的なハッシュアルゴリズムには向きませ" "ん。以下のようにして使います::" -#: ../../library/binascii.rst:322 msgid "" "print(binascii.crc32(b\"hello world\"))\n" "# Or, in two pieces:\n" @@ -470,10 +543,14 @@ msgid "" "crc = binascii.crc32(b\" world\", crc)\n" "print('crc32 = {:#010x}'.format(crc))" msgstr "" +"print(binascii.crc32(b\"hello world\"))\n" +"# または、2 つに分けて計算する:\n" +"crc = binascii.crc32(b\"hello\")\n" +"crc = binascii.crc32(b\" world\", crc)\n" +"print('crc32 = {:#010x}'.format(crc))" -#: ../../library/binascii.rst:328 msgid "The result is always unsigned." -msgstr "" +msgstr "結果は常に符号なしになりました。" #: ../../library/binascii.rst:334 msgid "" @@ -485,19 +562,24 @@ msgstr "" "表現に変換されます。したがって、返されるバイトオブジェクトは *data* の2倍の長" "さになります。" -#: ../../library/binascii.rst:338 msgid "" "Similar functionality (but returning a text string) is also conveniently " "accessible using the :meth:`bytes.hex` method." msgstr "" +"同様の機能は :meth:`bytes.hex` メソッドからも手軽に使えます (ただしテキスト文" +"字列を返します)。" -#: ../../library/binascii.rst:341 msgid "" "If *sep* is specified, it must be a single character str or bytes object. It " "will be inserted in the output after every *bytes_per_sep* input bytes. " "Separator placement is counted from the right end of the output by default, " "if you wish to count from the left, supply a negative *bytes_per_sep* value." msgstr "" +"*sep* を指定する場合は、1 文字の ``str`` または ``bytes`` オブジェクトでなけ" +"ればなりません。\n" +"入力の *bytes_per_sep* バイトごとに、出力に区切り文字を挿入します。\n" +"デフォルトでは出力の右端から数えて区切り文字を配置します。\n" +"左端から数えるには *bytes_per_sep* に負の値を指定してください。" #: ../../library/binascii.rst:356 msgid "The *sep* and *bytes_per_sep* parameters were added." @@ -515,15 +597,15 @@ msgstr "" "偶数個含んでいなければなりません。そうでない場合、例外 :exc:`Error` が送出さ" "れます。" -#: ../../library/binascii.rst:370 msgid "" "Similar functionality (but more liberal towards whitespace) is also " "accessible using the :meth:`bytes.fromhex` class method." msgstr "" +"同様の機能は :meth:`bytes.fromhex` クラスメソッドからも使えます (ただし空白文" +"字をより寛容に受け入れます)。" -#: ../../library/binascii.rst:373 msgid "Added the *ignorechars* parameter." -msgstr "" +msgstr "*ignorechars* パラメーターが追加されました。" #: ../../library/binascii.rst:379 msgid "Exception raised on errors. These are usually programming errors." @@ -537,50 +619,47 @@ msgstr "" "変換するデータが不完全な場合に送出される例外です。通常はプログラムのエラーで" "はなく、多少追加読み込みを行って再度変換を試みることで対処できます。" -#: ../../library/binascii.rst:390 msgid "The Base 64 alphabet according to :rfc:`4648`." -msgstr "" +msgstr ":rfc:`4648` で規定された Base64 アルファベットです。" -#: ../../library/binascii.rst:396 msgid "" "The \"URL and filename safe\" Base 64 alphabet according to :rfc:`4648`." msgstr "" +":rfc:`4648` で規定された、URL とファイル名で安全に使える Base64 アルファベッ" +"トです。" -#: ../../library/binascii.rst:402 msgid "The uuencoding alphabet." -msgstr "" +msgstr "uuencode のアルファベットです。" -#: ../../library/binascii.rst:408 msgid "" "The Base 64 alphabet used in the :manpage:`crypt(3)` routine and in the " "GEDCOM format." msgstr "" +":manpage:`crypt(3)` ルーチンと GEDCOM 形式で使われる Base64 アルファベットで" +"す。" -#: ../../library/binascii.rst:414 msgid "The Base 64 alphabet used in BinHex 4 (HQX) within the classic Mac OS." -msgstr "" +msgstr "従来の Mac OS で BinHex 4 (HQX) に使われる Base64 アルファベットです。" -#: ../../library/binascii.rst:420 msgid "The Base85 alphabet." -msgstr "" +msgstr "Base85 アルファベットです。" -#: ../../library/binascii.rst:426 msgid "The Ascii85 alphabet." -msgstr "" +msgstr "Ascii85 アルファベットです。" -#: ../../library/binascii.rst:432 msgid "The `Z85 `_ alphabet." -msgstr "" +msgstr "`Z85 `_ アルファベットです。" -#: ../../library/binascii.rst:438 msgid "The Base 32 alphabet according to :rfc:`4648`." -msgstr "" +msgstr ":rfc:`4648` で規定された Base32 アルファベットです。" -#: ../../library/binascii.rst:444 msgid "" "The \"Extended Hex\" Base 32 alphabet according to :rfc:`4648`. Data encoded " "with this alphabet maintains its sort order during bitwise comparisons." msgstr "" +":rfc:`4648` で規定された \"Extended Hex\" Base32 アルファベットです。\n" +"このアルファベットでエンコードしたデータは、ビット単位の比較でもソート順を保" +"ちます。" #: ../../library/binascii.rst:453 msgid "Module :mod:`base64`" diff --git a/library/bisect.po b/library/bisect.po index 0a32e87a5..dda6e09dc 100644 --- a/library/bisect.po +++ b/library/bisect.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/bisect.rst:2 @@ -44,7 +44,6 @@ msgstr "" "リストの場合、これは線形検索や頻繁な並べ替えよりも改善される可能性がありま" "す。" -#: ../../library/bisect.rst:16 msgid "" "The module is called :mod:`!bisect` because it uses a basic bisection " "algorithm to do its work. Unlike other bisection tools that search for a " @@ -54,8 +53,15 @@ msgid "" "functions only call the :meth:`~object.__lt__` method and will return an " "insertion point between values in an array." msgstr "" +"基本的な二分法アルゴリズムで処理するため、このモジュールは :mod:`!bisect` と" +"呼ばれます。\n" +"特定の値を探す他の二分探索ツールとは異なり、このモジュールの関数は挿入位置を" +"探すように設計されています。\n" +"そのため、値が見つかったかを判断するために :meth:`~object.__eq__` メソッドを" +"呼び出すことはありません。\n" +"代わりに :meth:`~object.__lt__` メソッドだけを呼び出し、配列内の値の間にある" +"挿入位置を返します。" -#: ../../library/bisect.rst:26 msgid "" "The functions in this module are not thread-safe. If multiple threads " "concurrently use :mod:`!bisect` functions on the same sequence, this may " @@ -65,6 +71,13 @@ msgid "" "on the same list from multiple threads may result in the list becoming " "unsorted." msgstr "" +"このモジュールの関数はスレッドセーフではありません。\n" +"複数のスレッドから同じシーケンスに対して :mod:`!bisect` の関数を同時に使う" +"と、動作が未定義になる可能性があります。\n" +"同様に、:mod:`!bisect` の関数がシーケンスを操作している間に別のスレッドがその" +"シーケンスを変更した場合も、結果は未定義です。\n" +"例えば、複数のスレッドから同じリストに対して :py:func:`~bisect.insort_left` " +"を使うと、リストのソート順が崩れる可能性があります。" #: ../../library/bisect.rst:36 msgid "The following functions are provided:" @@ -86,29 +99,29 @@ msgstr "" "insert()`` の第一引数として使うのに適しています。*a* はすでにソートされている" "ものとします。" -#: ../../library/bisect.rst:48 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem < x for elem in a[lo : ip])`` is true for the left " "slice and ``all(elem >= x for elem in a[ip : hi])`` is true for the right " "slice." msgstr "" -"返された挿入点 *ip* パーティションは、左のスライスでは ``all(elem < x for " -"elem in a[lo : ip])`` が真となり、右のスライスでは ``all(elem >= x for elem " -"in a[ip : hi])`` が真となるように、配列 *a* を2つのスライスに分割します。" +"返された挿入位置 *ip* は、配列 *a* を 2 つのスライスに分割します。\n" +"左側のスライスでは ``all(elem < x for elem in a[lo : ip])`` が真となり、右側" +"のスライスでは ``all(elem >= x for elem in a[ip : hi])`` が真となります。" -#: ../../library/bisect.rst:53 msgid "" "*key* specifies a :term:`key function` of one argument that is used to " "extract a comparison key from each element in the array. To support " "searching complex records, the key function is not applied to the *x* value." msgstr "" +"*key* は、配列の各要素から比較用のキーを取り出す、引数を 1 つ受け取る :term:`" +"キー関数 ` を指定します。\n" +"複雑なレコードを検索できるように、キー関数は値 *x* には適用しません。" -#: ../../library/bisect.rst:57 msgid "" "If *key* is ``None``, the elements are compared directly and no key function " "is called." -msgstr "" +msgstr "*key* が ``None`` の場合は要素を直接比較し、キー関数を呼び出しません。" #: ../../library/bisect.rst:60 ../../library/bisect.rst:74 #: ../../library/bisect.rst:92 ../../library/bisect.rst:112 @@ -123,39 +136,42 @@ msgstr "" ":py:func:`~bisect.bisect_left` と似ていますが、 *a* に含まれる *x* のうち、ど" "のエントリーよりも後ろ(右)にくるような挿入点を返します。" -#: ../../library/bisect.rst:70 msgid "" "The returned insertion point *ip* partitions the array *a* into two slices " "such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left " "slice and ``all(elem > x for elem in a[ip : hi])`` is true for the right " "slice." msgstr "" -"返された挿入点 *ip* パーティションは、左のスライスでは ``all(elem <= x for " -"elem in a[lo : ip])`` が真となり、右のスライスでは ``all(elem > x for elem " -"in a[ip : hi])`` が真となるように、配列 *a* を2つのスライスに分割します。" +"返された挿入位置 *ip* は、配列 *a* を 2 つのスライスに分割します。\n" +"左側のスライスでは ``all(elem <= x for elem in a[lo : ip])`` が真となり、右側" +"のスライスでは ``all(elem > x for elem in a[ip : hi])`` が真となります。" #: ../../library/bisect.rst:80 msgid "Insert *x* in *a* in sorted order." msgstr "*x* を *a* にソート順で挿入します。" -#: ../../library/bisect.rst:82 msgid "" "This function first runs :py:func:`~bisect.bisect_left` to locate an " "insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " "insert *x* at the appropriate position to maintain sort order." msgstr "" +"まず :py:func:`~bisect.bisect_left` で挿入位置を探します。\n" +"次に *a* の :meth:`~sequence.insert` メソッドを呼び出し、ソート順を保つ適切な" +"位置に *x* を挿入します。" -#: ../../library/bisect.rst:86 ../../library/bisect.rst:106 msgid "" "To support inserting records in a table, the *key* function (if any) is " "applied to *x* for the search step but not for the insertion step." msgstr "" +"テーブルへのレコードの挿入に対応するため、*key* 関数を指定した場合は、探索の" +"段階で *x* に適用し、挿入の段階では適用しません。" -#: ../../library/bisect.rst:89 ../../library/bisect.rst:109 msgid "" "Keep in mind that the *O*\\ (log *n*) search is dominated by the slow *O*\\ " "(*n*) insertion step." msgstr "" +"*O*\\ (log *n*) の探索よりも、遅い *O*\\ (*n*) の挿入処理が全体の実行時間を支" +"配することに注意してください。" #: ../../library/bisect.rst:99 msgid "" @@ -165,12 +181,14 @@ msgstr "" ":py:func:`~bisect.insort_left` と似ていますが、 *a* に含まれる *x* のうち、ど" "のエントリーよりも後ろに *x* を挿入します。" -#: ../../library/bisect.rst:102 msgid "" "This function first runs :py:func:`~bisect.bisect_right` to locate an " "insertion point. Next, it runs the :meth:`~sequence.insert` method on *a* to " "insert *x* at the appropriate position to maintain sort order." msgstr "" +"まず :py:func:`~bisect.bisect_right` で挿入位置を探します。\n" +"次に *a* の :meth:`~sequence.insert` メソッドを呼び出し、ソート順を保つ適切な" +"位置に *x* を挿入します。" #: ../../library/bisect.rst:117 msgid "Performance Notes" @@ -192,13 +210,13 @@ msgstr "" "二分法は、値の範囲を検索するのに有効です。 特定の値を検索する場合は、辞書の方" "が効率的です。" -#: ../../library/bisect.rst:125 msgid "" "The *insort()* functions are *O*\\ (*n*) because the logarithmic search step " "is dominated by the linear time insertion step." msgstr "" +"*insort()* 関数の計算量は *O*\\ (*n*) です。\n" +"対数時間の探索よりも、線形時間の挿入処理が全体の実行時間を支配するためです。" -#: ../../library/bisect.rst:128 msgid "" "The search functions are stateless and discard key function results after " "they are used. Consequently, if the search functions are used in a loop, " @@ -208,13 +226,22 @@ msgid "" "searching an array of precomputed keys to locate the insertion point (as " "shown in the examples section below)." msgstr "" +"探索関数は状態を保持せず、キー関数の結果を使用後に破棄します。\n" +"そのため、ループ内で探索関数を使うと、配列の同じ要素に対してキー関数を繰り返" +"し呼び出す可能性があります。\n" +"キー関数が遅い場合は、:py:deco:`functools.cache` でラップして重複した計算を避" +"けることを検討してください。\n" +"または、あらかじめ計算したキーの配列を探索して挿入位置を求める方法もあります " +"(後の使用例を参照してください)。" -#: ../../library/bisect.rst:138 msgid "" "`Sorted Collections `_ is a " "high performance module that uses *bisect* to managed sorted collections of " "data." msgstr "" +"`Sorted Collections `_ は、" +"*bisect* を使ってソート済みのデータのコレクションを管理する高性能なモジュール" +"です。" #: ../../library/bisect.rst:142 msgid "" @@ -244,7 +271,6 @@ msgstr "" "使うには厄介であったり、使いにくい場合があります。 以下の5つの関数は、それら" "をソートされたリストの標準的な検索に変換する方法を示しています::" -#: ../../library/bisect.rst:157 msgid "" "def index(a, x):\n" " 'Locate the leftmost value exactly equal to x'\n" @@ -310,7 +336,7 @@ msgstr "" " raise ValueError\n" "\n" "def find_ge(a, x):\n" -" '左端の項目がx以上であることを確認する'\n" +" 'x以上の左端の要素を見つける'\n" " i = bisect_left(a, x)\n" " if i != len(a):\n" " return a[i]\n" @@ -332,7 +358,6 @@ msgstr "" "の集合に基づいて、試験の成績の等級を表す文字を調べます。区切り点は 90 以上は " "'A'、 80 から 89 は 'B'、などです::" -#: ../../library/bisect.rst:203 msgid "" ">>> def grade(score):\n" "... i = bisect([60, 70, 80, 90], score)\n" @@ -341,6 +366,12 @@ msgid "" ">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n" "['F', 'A', 'C', 'C', 'B', 'A', 'A']" msgstr "" +">>> def grade(score):\n" +"... i = bisect([60, 70, 80, 90], score)\n" +"... return \"FDCBA\"[i]\n" +"...\n" +">>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]\n" +"['F', 'A', 'C', 'C', 'B', 'A', 'A']" #: ../../library/bisect.rst:210 msgid "" @@ -352,7 +383,6 @@ msgstr "" "動作します。 引数 *key* はテーブルのレコードの順序付けに使用されるフィールド" "を抽出します::" -#: ../../library/bisect.rst:214 msgid "" ">>> from collections import namedtuple\n" ">>> from operator import attrgetter\n" @@ -384,6 +414,35 @@ msgid "" " Movie(name='Aliens', released=1986, director='Cameron'),\n" " Movie(name='Titanic', released=1997, director='Cameron')]" msgstr "" +">>> from collections import namedtuple\n" +">>> from operator import attrgetter\n" +">>> from bisect import bisect, insort\n" +">>> from pprint import pprint\n" +"\n" +">>> Movie = namedtuple('Movie', ('name', 'released', 'director'))\n" +"\n" +">>> movies = [\n" +"... Movie('Jaws', 1975, 'Spielberg'),\n" +"... Movie('Titanic', 1997, 'Cameron'),\n" +"... Movie('The Birds', 1963, 'Hitchcock'),\n" +"... Movie('Aliens', 1986, 'Cameron')\n" +"... ]\n" +"\n" +">>> # 1960 年より後に公開された最初の映画を探す\n" +">>> by_year = attrgetter('released')\n" +">>> movies.sort(key=by_year)\n" +">>> movies[bisect(movies, 1960, key=by_year)]\n" +"Movie(name='The Birds', released=1963, director='Hitchcock')\n" +"\n" +">>> # ソート順を保ったまま映画を挿入する\n" +">>> romance = Movie('Love Story', 1970, 'Hiller')\n" +">>> insort(movies, romance, key=by_year)\n" +">>> pprint(movies)\n" +"[Movie(name='The Birds', released=1963, director='Hitchcock'),\n" +" Movie(name='Love Story', released=1970, director='Hiller'),\n" +" Movie(name='Jaws', released=1975, director='Spielberg'),\n" +" Movie(name='Aliens', released=1986, director='Cameron'),\n" +" Movie(name='Titanic', released=1997, director='Cameron')]" #: ../../library/bisect.rst:244 msgid "" @@ -394,7 +453,6 @@ msgstr "" "計算されたキーのリストを検索することにより、関数呼び出しの繰り返しを回避する" "ことが可能です::" -#: ../../library/bisect.rst:247 msgid "" ">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" ">>> data.sort(key=lambda r: r[1]) # Or use operator.itemgetter(1).\n" @@ -408,3 +466,15 @@ msgid "" ">>> data[bisect_left(keys, 8)]\n" "('yellow', 8)" msgstr "" +">>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]\n" +">>> data.sort(key=lambda r: r[1]) # または operator.itemgetter(1) を使" +"う。\n" +">>> keys = [r[1] for r in data] # キーのリストを事前に計算する。\n" +">>> data[bisect_left(keys, 0)]\n" +"('black', 0)\n" +">>> data[bisect_left(keys, 1)]\n" +"('blue', 1)\n" +">>> data[bisect_left(keys, 5)]\n" +"('red', 5)\n" +">>> data[bisect_left(keys, 8)]\n" +"('yellow', 8)" diff --git a/library/builtins.po b/library/builtins.po index a87ddda8c..2f3fc7ad6 100644 --- a/library/builtins.po +++ b/library/builtins.po @@ -16,22 +16,24 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/builtins.rst:2 msgid ":mod:`!builtins` --- Built-in objects" msgstr ":mod:`!builtins` --- 組み込みオブジェクト" -#: ../../library/builtins.rst:9 msgid "" "This module provides direct access to all 'built-in' identifiers of Python; " "for example, ``builtins.open`` is the full name for the built-in function :" "func:`open`." msgstr "" +"このモジュールを使うと、Python のすべての「組み込み」識別子に直接アクセスでき" +"ます。\n" +"例えば ``builtins.open`` は、組み込み関数 :func:`open` の完全な名前です。" #: ../../library/builtins.rst:12 msgid "" @@ -47,7 +49,6 @@ msgstr "" "ば、組み込みの :func:`open` をラップした :func:`open` という関数を実装したい" "モジュールがあったとすると、このモジュールは次のように直接的に使われます::" -#: ../../library/builtins.rst:18 msgid "" "import builtins\n" "\n" @@ -66,6 +67,22 @@ msgid "" "\n" " # ..." msgstr "" +"import builtins\n" +"\n" +"def open(path):\n" +" f = builtins.open(path, 'r')\n" +" return UpperCaser(f)\n" +"\n" +"class UpperCaser:\n" +" '''ファイルから得られる出力を大文字に変換するラッパー。'''\n" +"\n" +" def __init__(self, f):\n" +" self._f = f\n" +"\n" +" def read(self, count=-1):\n" +" return self._f.read(count).upper()\n" +"\n" +" # ..." #: ../../library/builtins.rst:35 msgid "" @@ -81,18 +98,14 @@ msgstr "" "詳細部分なので、異なる Python の実装では ``__builtins__`` は使われていないこ" "ともあります。" -#: ../../library/builtins.rst:43 msgid ":ref:`built-in-consts`" -msgstr "" +msgstr ":ref:`built-in-consts`" -#: ../../library/builtins.rst:44 msgid ":ref:`bltin-exceptions`" -msgstr "" +msgstr ":ref:`bltin-exceptions`" -#: ../../library/builtins.rst:45 msgid ":ref:`built-in-funcs`" -msgstr "" +msgstr ":ref:`built-in-funcs`" -#: ../../library/builtins.rst:46 msgid ":ref:`bltin-types`" -msgstr "" +msgstr ":ref:`bltin-types`" diff --git a/library/bz2.po b/library/bz2.po index 53f2e899e..c93c85536 100644 --- a/library/bz2.po +++ b/library/bz2.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/bz2.rst:2 @@ -38,9 +38,8 @@ msgstr "" "このモジュールは、bzip2 アルゴリズムを用いて圧縮・展開を行う包括的なインター" "フェイスを提供します。" -#: ../../library/bz2.rst:14 msgid "The :mod:`!bz2` module contains:" -msgstr "" +msgstr ":mod:`!bz2` モジュールは次の機能を提供します。" #: ../../library/bz2.rst:16 msgid "" @@ -65,13 +64,16 @@ msgid "" msgstr "" "一度に圧縮・展開を行う :func:`compress` および :func:`decompress` 関数。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" #: ../../library/bz2.rst:27 msgid "(De)compression of files" @@ -187,13 +189,12 @@ msgstr "" "``1`` から ``9`` の整数で指定できます。\n" "圧縮率は ``1`` が最低で、``9`` (デフォルト値) が最高です。" -#: ../../library/bz2.rst:83 msgid "" "If *mode* is ``'r'``, the input file may be the concatenation of multiple " "compressed streams." msgstr "" -"*mode* の値が ``'r'`` の場合、入力ファイルは複数の圧縮ストリームでも構いませ" -"ん。" +"*mode* が ``'r'`` の場合、入力ファイルは複数の圧縮ストリームを連結したもので" +"もかまいません。" #: ../../library/bz2.rst:86 msgid "" @@ -206,9 +207,8 @@ msgstr "" "truncate` を除くすべてが備わっています。イテレーションと :keyword:`with` 文を" "サポートしています。" -#: ../../library/bz2.rst:91 msgid ":class:`BZ2File` also provides the following methods and attributes:" -msgstr "" +msgstr ":class:`BZ2File` は次のメソッドと属性も提供します。" #: ../../library/bz2.rst:95 msgid "" @@ -231,50 +231,47 @@ msgstr "" "下層のファイルオブジェクトの位置が変わる惧れがあります(e.g. :class:`BZ2File` " "を *filename* にファイルオブジェクトを渡して作成した場合)。" -#: ../../library/bz2.rst:108 msgid "Return the file descriptor for the underlying file." -msgstr "" +msgstr "下層のファイルのファイル記述子を返します。" -#: ../../library/bz2.rst:114 msgid "Return whether the file was opened for reading." -msgstr "" +msgstr "ファイルが読み込み用に開かれたかどうかを返します。" -#: ../../library/bz2.rst:120 msgid "Return whether the file supports seeking." -msgstr "" +msgstr "ファイルがシークをサポートしているかどうかを返します。" -#: ../../library/bz2.rst:126 msgid "Return whether the file was opened for writing." -msgstr "" +msgstr "ファイルが書き込み用に開かれたかどうかを返します。" -#: ../../library/bz2.rst:132 msgid "" "Read up to *size* uncompressed bytes, while trying to avoid making multiple " "reads from the underlying stream. Reads up to a buffer's worth of data if " "size is negative." msgstr "" +"下層のストリームから複数回読み込むのをなるべく避けながら、展開後のデータを最" +"大 *size* バイト読み込みます。\n" +"``size`` が負の場合、最大でバッファ 1 つ分のデータを読み込みます。" -#: ../../library/bz2.rst:136 msgid "Returns ``b''`` if the file is at EOF." -msgstr "" +msgstr "ファイルが EOF に達している場合は ``b''`` を返します。" -#: ../../library/bz2.rst:142 msgid "Read bytes into *b*." -msgstr "" +msgstr "*b* にバイト列を読み込みます。" -#: ../../library/bz2.rst:144 msgid "Returns the number of bytes read (0 for EOF)." -msgstr "" +msgstr "読み込んだバイト数を返します (EOF の場合は 0)。" #: ../../library/bz2.rst:150 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "``'rb'`` は読み込み用、 ``'wb'`` は書き込み用です。" -#: ../../library/bz2.rst:156 msgid "" "The bzip2 file name. Equivalent to the :attr:`~io.FileIO.name` attribute of " "the underlying :term:`file object`." msgstr "" +"bzip2 ファイルの名前です。\n" +"下層の :term:`ファイルオブジェクト ` の :attr:`~io.FileIO.name` " +"属性と同じです。" #: ../../library/bz2.rst:162 msgid "Support for the :keyword:`with` statement was added." @@ -389,18 +386,17 @@ msgstr "" "タ展開に使用できます。一度に展開したい場合は、:func:`decompress` 関数を使って" "ください。" -#: ../../library/bz2.rst:231 msgid "" "This class does not transparently handle inputs containing multiple " "compressed streams, unlike :func:`decompress` and :class:`BZ2File`. If you " "need to decompress a multi-stream input with :class:`BZ2Decompressor`, you " "must use a new decompressor for each stream." msgstr "" -"このクラスは、:func:`decompress` や :class:`BZ2File` とは異なり、複数の圧縮レ" -"ベルが混在しているデータを透過的に扱うことができません。 :class:" -"`BZ2Decompressor` クラスを用いて、複数のストリームからなるデータを展開する場" -"合は、それぞれのストリームについてデコンプレッサオブジェクトを用意してくださ" -"い。" +"このクラスは、:func:`decompress` や :class:`BZ2File` とは異なり、\n" +"複数の圧縮ストリームを含む入力を透過的に扱うことができません。\n" +":class:`BZ2Decompressor` クラスを用いて、複数のストリームからなるデータを展開" +"する場合は、\n" +"それぞれのストリームについてデコンプレッサオブジェクトを用意してください。" #: ../../library/bz2.rst:238 msgid "" @@ -429,13 +425,12 @@ msgstr "" "``False`` に設定されます。この場合、 :meth:`~.decompress` を次に呼び出すと、" "*data* を ``b''`` として提供し、出力をさらに取得することができます。" -#: ../../library/bz2.rst:251 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -"入力データの全てが圧縮され返された (*max_length* バイトより少ないためか " +"入力データの全てが展開され返された (*max_length* バイトより少ないためか " "*max_length* が負のため) 場合、\n" ":attr:`~.needs_input` 属性は ``True`` になります。" @@ -515,9 +510,8 @@ msgstr "複数ストリームの入力をサポートしました。" msgid "Examples of usage" msgstr "使い方の例" -#: ../../library/bz2.rst:315 msgid "Below are some examples of typical usage of the :mod:`!bz2` module." -msgstr "" +msgstr ":mod:`!bz2` モジュールの典型的な使い方をいくつか示します。" #: ../../library/bz2.rst:317 msgid "" diff --git a/library/calendar.po b/library/calendar.po index 396eaf323..a54d96549 100644 --- a/library/calendar.po +++ b/library/calendar.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/calendar.rst:2 @@ -85,43 +85,42 @@ msgstr "" "使えるいくつかのメソッドを提供しています。しかし整形機能そのものは提供してい" "ません。それはサブクラスの仕事なのです。" -#: ../../library/calendar.rst:39 msgid ":class:`Calendar` instances have the following methods and attributes:" -msgstr "" +msgstr ":class:`Calendar` インスタンスは次のメソッドと属性を持ちます。" -#: ../../library/calendar.rst:43 msgid "The first weekday as an integer (0--6)." -msgstr "" +msgstr "週の最初の曜日を表す整数 (0~6) です。" -#: ../../library/calendar.rst:45 msgid "" "This property can also be set and read using :meth:`~Calendar." "setfirstweekday` and :meth:`~Calendar.getfirstweekday` respectively." msgstr "" +"このプロパティは、:meth:`~Calendar.setfirstweekday` で設定し、:meth:" +"`~Calendar.getfirstweekday` で読み取ることもできます。" -#: ../../library/calendar.rst:51 msgid "Return an :class:`int` for the current first weekday (0--6)." -msgstr "" +msgstr "現在の週の最初の曜日を :class:`int` (0~6) で返します。" -#: ../../library/calendar.rst:53 msgid "Identical to reading the :attr:`~Calendar.firstweekday` property." -msgstr "" +msgstr ":attr:`~Calendar.firstweekday` プロパティを読み取るのと同じです。" -#: ../../library/calendar.rst:57 msgid "" "Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6)." msgstr "" +"週の最初の曜日を、:class:`int` (0~6) で渡された *firstweekday* に設定しま" +"す。" -#: ../../library/calendar.rst:59 msgid "Identical to setting the :attr:`~Calendar.firstweekday` property." -msgstr "" +msgstr ":attr:`~Calendar.firstweekday` プロパティを設定するのと同じです。" -#: ../../library/calendar.rst:63 msgid "" "Return an iterator for the weekday numbers that will be used for one week. " "The first value from the iterator will be the same as the value of the :attr:" "`~Calendar.firstweekday` property." msgstr "" +"1 週間に使う曜日番号のイテレーターを返します。\n" +"イテレーターの最初の値は :attr:`~Calendar.firstweekday` プロパティの値と同じ" +"です。" #: ../../library/calendar.rst:70 msgid "" @@ -135,37 +134,46 @@ msgstr "" "た後の日のうち、週の欠けを埋めるために必要な日を (:class:`datetime.date` オブ" "ジェクトとして) 返します。" -#: ../../library/calendar.rst:78 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " "Days returned will simply be day of the month numbers. For the days outside " "of the specified month, the day number is ``0``." msgstr "" +":meth:`itermonthdates` と同様に *year* 年 *month* 月のイテレーターを返します" +"が、:class:`datetime.date` の範囲には制限されません。\n" +"各日は単に月内の日を表す数値として返されます。\n" +"指定した月に含まれない日は ``0`` です。" -#: ../../library/calendar.rst:86 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " "Days returned will be tuples consisting of a day of the month number and a " "weekday number." msgstr "" +":meth:`itermonthdates` と同様に *year* 年 *month* 月のイテレーターを返します" +"が、:class:`datetime.date` の範囲には制限されません。\n" +"各日は、月内の日を表す数値と曜日番号からなるタプルとして返されます。" -#: ../../library/calendar.rst:94 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " "Days returned will be tuples consisting of a year, a month and a day of the " "month numbers." msgstr "" +":meth:`itermonthdates` と同様に *year* 年 *month* 月のイテレーターを返します" +"が、:class:`datetime.date` の範囲には制限されません。\n" +"各日は、年、月、日を表す数値からなるタプルとして返されます。" -#: ../../library/calendar.rst:104 msgid "" "Return an iterator for the month *month* in the year *year* similar to :meth:" "`itermonthdates`, but not restricted by the :class:`datetime.date` range. " "Days returned will be tuples consisting of a year, a month, a day of the " "month, and a day of the week numbers." msgstr "" +":meth:`itermonthdates` と同様に *year* 年 *month* 月のイテレーターを返します" +"が、:class:`datetime.date` の範囲には制限されません。\n" +"各日は、年、月、日、曜日を表す数値からなるタプルとして返されます。" #: ../../library/calendar.rst:114 msgid "" @@ -230,11 +238,12 @@ msgstr "このクラスはプレインテキストのカレンダーを生成す msgid ":class:`TextCalendar` instances have the following methods:" msgstr ":class:`TextCalendar` インスタンスには以下のメソッドがあります:" -#: ../../library/calendar.rst:161 msgid "" "Print a week's calendar as returned by :meth:`formatweek` and without a " "final newline." msgstr "" +":meth:`formatweek` が返す 1 週間分のカレンダーを、末尾に改行を付けずに表示し" +"ます。" #: ../../library/calendar.rst:167 msgid "" @@ -243,12 +252,15 @@ msgid "" "representing an empty day. The *weekday* parameter is unused." msgstr "" -#: ../../library/calendar.rst:174 msgid "" "Return a single week in a string with no newline. *width* specifies the " "width of the date columns, which are centered. Depends on the first weekday " "as specified in the constructor or set by the :meth:`setfirstweekday` method." msgstr "" +"1 週間分を、改行を含まない文字列で返します。\n" +"*width* は、日付を中央揃えで表示する列の幅を指定します。\n" +"コンストラクターまたは :meth:`setfirstweekday` メソッドで指定した週の最初の曜" +"日に従います。" #: ../../library/calendar.rst:182 msgid "" @@ -257,12 +269,14 @@ msgid "" "day of the week, where ``0`` is Monday and ``6`` is Sunday." msgstr "" -#: ../../library/calendar.rst:189 msgid "" "Return a string containing the header row of weekday names, formatted with " "the given *width* for each column. The names depend on the locale settings " "and are padded to the specified width." msgstr "" +"曜日名のヘッダー行を、各列の幅が *width* になるよう整形した文字列で返しま" +"す。\n" +"曜日名はロケール設定に従い、指定した幅になるよう空白を補います。" #: ../../library/calendar.rst:196 msgid "" @@ -277,19 +291,20 @@ msgstr "" "とができます。 :meth:`setfirstweekday` メソッドでセットされた週の最初の曜日に" "依存します。" -#: ../../library/calendar.rst:205 msgid "" "Return a string representing the month's name centered within the specified " "*width*. If *withyear* is ``True``, include the year in the output. The " "*theyear* and *themonth* parameters specify the year and month for the name " "to be formatted respectively." msgstr "" +"月名を指定した *width* の幅で中央揃えにした文字列を返します。\n" +"*withyear* が ``True`` なら、出力に年も含めます。\n" +"*theyear* と *themonth* はそれぞれ、表示する名前の年と月を指定します。" #: ../../library/calendar.rst:213 msgid "Print a month's calendar as returned by :meth:`formatmonth`." msgstr ":meth:`formatmonth` で返されるひと月分のカレンダーを出力します。" -#: ../../library/calendar.rst:218 msgid "" "Return a *m*-column calendar for an entire year as a multi-line string. " "Optional parameters *w*, *l*, and *c* are for date column width, lines per " @@ -298,11 +313,12 @@ msgid "" "`setfirstweekday` method. The earliest year for which a calendar can be " "generated is platform-dependent." msgstr "" -"*m* 列からなる一年間のカレンダーを複数行の文字列で返します。任意の引数 *w*, " -"*l*, *c* はそれぞれ、日付列の表示幅、各週の行数及び月と月の間のスペースの数を" -"変更するためのものです。 :meth:`setfirstweekday` メソッドでセットされた週の最" -"初の曜日に依存します。カレンダーを出力できる最初の年はプラットフォームに依存" -"します。" +"*m* 列からなる一年間のカレンダーを複数行の文字列で返します。\n" +"任意の引数 *w*, *l*, *c* はそれぞれ、日付列の表示幅、各週の行数及び月と月の間" +"のスペースの数を変更するためのものです。\n" +"コンストラクタで指定された、または :meth:`setfirstweekday` メソッドで設定され" +"た週の最初の曜日に依存します。\n" +"カレンダーを出力できる最初の年はプラットフォームに依存します。" #: ../../library/calendar.rst:228 msgid "" @@ -333,7 +349,6 @@ msgstr "" "一年分のカレンダーを HTML のテーブルとして返します。*width* の値 (デフォルト" "では 3 です) は何ヶ月分を一行に収めるかを指定します。" -#: ../../library/calendar.rst:253 msgid "" "Return a year's calendar as a complete HTML page. *width* (defaulting to 3) " "specifies the number of months per row. *css* is the name for the cascading " @@ -341,93 +356,105 @@ msgid "" "be used. *encoding* specifies the encoding to be used for the output " "(defaulting to ``'utf-8'``)." msgstr "" +"1 年分のカレンダーを完全な HTML ページとして返します。\n" +"*width* (デフォルトは 3) は、1 行に表示する月の数を指定します。\n" +"*css* は使用するカスケーディングスタイルシートの名前です。\n" +"スタイルシートを使わない場合は :const:`None` を渡せます。\n" +"*encoding* は出力のエンコーディングを指定します (デフォルトは ``'utf-8'``)。" -#: ../../library/calendar.rst:262 msgid "" "Return a month name as an HTML table row. If *withyear* is true the year " "will be included in the row, otherwise just the month name will be used." msgstr "" +"月名を HTML の表の行として返します。\n" +"*withyear* が真の場合は行に年も含め、それ以外の場合は月名だけを使います。" -#: ../../library/calendar.rst:267 msgid "" ":class:`!HTMLCalendar` has the following attributes you can override to " "customize the CSS classes used by the calendar:" msgstr "" +":class:`!HTMLCalendar` の次の属性をオーバーライドすると、カレンダーで使う " +"CSS クラスを変更できます。" -#: ../../library/calendar.rst:272 msgid "" "A list of CSS classes used for each weekday. The default class list is::" msgstr "" +"各曜日に使う CSS クラスのリストです。\n" +"デフォルトのリストは次のとおりです。 ::" -#: ../../library/calendar.rst:274 msgid "" "cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" msgstr "" +"cssclasses = [\"mon\", \"tue\", \"wed\", \"thu\", \"fri\", \"sat\", \"sun\"]" -#: ../../library/calendar.rst:276 msgid "more styles can be added for each day::" -msgstr "" +msgstr "各曜日にスタイルを追加できます。 ::" -#: ../../library/calendar.rst:278 msgid "" "cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " "\"sat\", \"sun red\"]" msgstr "" +"cssclasses = [\"mon text-bold\", \"tue\", \"wed\", \"thu\", \"fri\", " +"\"sat\", \"sun red\"]" -#: ../../library/calendar.rst:280 msgid "Note that the length of this list must be seven items." -msgstr "" +msgstr "このリストの要素数は 7 でなければなりません。" -#: ../../library/calendar.rst:285 msgid "The CSS class for a weekday occurring in the previous or coming month." -msgstr "" +msgstr "前月または翌月に属する日に使う CSS クラスです。" -#: ../../library/calendar.rst:292 msgid "" "A list of CSS classes used for weekday names in the header row. The default " "is the same as :attr:`cssclasses`." msgstr "" +"ヘッダー行の曜日名に使う CSS クラスのリストです。\n" +"デフォルトは :attr:`cssclasses` と同じです。" -#: ../../library/calendar.rst:300 msgid "" "The month's head CSS class (used by :meth:`formatmonthname`). The default " "value is ``\"month\"``." msgstr "" +"月の見出しに使う CSS クラスです (:meth:`formatmonthname` が使用します)。\n" +"デフォルト値は ``\"month\"`` です。" -#: ../../library/calendar.rst:308 msgid "" "The CSS class for the whole month's table (used by :meth:`formatmonth`). The " "default value is ``\"month\"``." msgstr "" +"月全体の表に使う CSS クラスです (:meth:`formatmonth` が使用します)。\n" +"デフォルト値は ``\"month\"`` です。" -#: ../../library/calendar.rst:316 msgid "" "The CSS class for the whole year's table of tables (used by :meth:" "`formatyear`). The default value is ``\"year\"``." msgstr "" +"1 年分の各月の表をまとめる表に使う CSS クラスです (:meth:`formatyear` が使用" +"します)。\n" +"デフォルト値は ``\"year\"`` です。" -#: ../../library/calendar.rst:324 msgid "" "The CSS class for the table head for the whole year (used by :meth:" "`formatyear`). The default value is ``\"year\"``." msgstr "" +"年全体の表の見出しに使う CSS クラスです (:meth:`formatyear` が使用します)。\n" +"デフォルト値は ``\"year\"`` です。" -#: ../../library/calendar.rst:330 msgid "" "Note that although the naming for the above described class attributes is " "singular (e.g. ``cssclass_month`` ``cssclass_noday``), one can replace the " "single CSS class with a space separated list of CSS classes, for example::" msgstr "" +"これらのクラス属性の名前は単数形 (例えば ``cssclass_month`` や " +"``cssclass_noday``) ですが、単一の CSS クラスを、スペースで区切った複数の " +"CSS クラスに置き換えることもできます。\n" +"例えば次のように指定します。 ::" -#: ../../library/calendar.rst:334 msgid "\"text-bold text-red\"" -msgstr "" +msgstr "\"text-bold text-red\"" -#: ../../library/calendar.rst:336 msgid "Here is an example how :class:`!HTMLCalendar` can be customized::" -msgstr "" +msgstr ":class:`!HTMLCalendar` をカスタマイズする例です。 ::" -#: ../../library/calendar.rst:338 msgid "" "class CustomHTMLCal(calendar.HTMLCalendar):\n" " cssclasses = [style + \" text-nowrap\" for style in\n" @@ -436,26 +463,40 @@ msgid "" " cssclass_month = \"text-center month\"\n" " cssclass_year = \"text-italic lead\"" msgstr "" +"class CustomHTMLCal(calendar.HTMLCalendar):\n" +" cssclasses = [style + \" text-nowrap\" for style in\n" +" calendar.HTMLCalendar.cssclasses]\n" +" cssclass_month_head = \"text-center month-head\"\n" +" cssclass_month = \"text-center month\"\n" +" cssclass_year = \"text-italic lead\"" -#: ../../library/calendar.rst:348 msgid "" "This subclass of :class:`TextCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." msgstr "" +":class:`TextCalendar` のこのサブクラスは、コンストラクターにロケール名を渡せ" +"ます。\n" +"指定したロケールの月名と曜日名を返します。" -#: ../../library/calendar.rst:354 msgid "" "This subclass of :class:`HTMLCalendar` can be passed a locale name in the " "constructor and will return month and weekday names in the specified locale." msgstr "" +":class:`HTMLCalendar` のこのサブクラスは、コンストラクターにロケール名を渡せ" +"ます。\n" +"指定したロケールの月名と曜日名を返します。" -#: ../../library/calendar.rst:360 msgid "" "The constructor, :meth:`!formatweekday` and :meth:`!formatmonthname` methods " "of these two classes temporarily change the ``LC_TIME`` locale to the given " "*locale*. Because the current locale is a process-wide setting, they are not " "thread-safe." msgstr "" +"これら 2 つのクラスのコンストラクターと :meth:`!formatweekday`、:meth:`!" +"formatmonthname` メソッドは、``LC_TIME`` ロケールを指定された *locale* に一時" +"的に変更します。\n" +"現在のロケールはプロセス全体の設定なので、これらはスレッドセーフではありませ" +"ん。" #: ../../library/calendar.rst:366 msgid "For simple text calendars this module provides the following functions." @@ -475,11 +516,12 @@ msgstr "" "`FRIDAY`, :const:`SATURDAY` 及び :const:`SUNDAY` は便宜上提供されています。例" "えば、日曜日を週の開始日に設定するときは::" -#: ../../library/calendar.rst:375 msgid "" "import calendar\n" "calendar.setfirstweekday(calendar.SUNDAY)" msgstr "" +"import calendar\n" +"calendar.setfirstweekday(calendar.SUNDAY)" #: ../../library/calendar.rst:381 msgid "Returns the current setting for the weekday to start each week." @@ -492,13 +534,12 @@ msgstr "" "*year* が閏年なら :const:`True` を、そうでなければ :const:`False` を返しま" "す。" -#: ../../library/calendar.rst:391 msgid "" "Returns the number of leap years in the range from *y1* to *y2* (exclusive), " "where *y1* and *y2* are years." msgstr "" -"範囲(*y1* ... *y2*)指定された期間の閏年の回数を返します。ここで *y1* や *y2* " -"は年を表します。" +"*y1* 以上 *y2* 未満の年の範囲に含まれる閏年の数を返します。\n" +"*y1* と *y2* は年を表します。" #: ../../library/calendar.rst:394 msgid "This function works for ranges spanning a century change." @@ -512,17 +553,18 @@ msgstr "" "*year* (``1970``--...), *month* (``1``--``12``), *day* (``1``--``31``) で与え" "られた日の曜日(``0`` は月曜日)を返します。" -#: ../../library/calendar.rst:405 msgid "" "Return a header containing abbreviated weekday names. *width* specifies the " "width in characters for one weekday." msgstr "" +"曜日の略称を含むヘッダーを返します。\n" +"*width* は曜日 1 つあたりの幅を文字数で指定します。" -#: ../../library/calendar.rst:411 msgid "" "Returns weekday of first day of the month and number of days in month, for " "the specified *year* and *month*." msgstr "" +"指定した *year* 年 *month* 月の、最初の日の曜日とその月の日数を返します。" #: ../../library/calendar.rst:417 msgid "" @@ -538,24 +580,25 @@ msgstr "" msgid "Prints a month's calendar as returned by :func:`month`." msgstr ":func:`month` 関数によって返される月のカレンダーを出力します。" -#: ../../library/calendar.rst:429 msgid "" "Returns a month's calendar in a multi-line string using the :meth:" "`~TextCalendar.formatmonth` of the :class:`TextCalendar` class." msgstr "" +":class:`TextCalendar` クラスの :meth:`~TextCalendar.formatmonth` を使い、1 か" +"月分のカレンダーを複数行の文字列で返します。" #: ../../library/calendar.rst:435 msgid "" "Prints the calendar for an entire year as returned by :func:`calendar`." msgstr ":func:`calendar` 関数で返される一年間のカレンダーを出力します。" -#: ../../library/calendar.rst:440 msgid "" "Returns a 3-column calendar for an entire year as a multi-line string using " "the :meth:`~TextCalendar.formatyear` of the :class:`TextCalendar` class." msgstr "" +":class:`TextCalendar` クラスの :meth:`~TextCalendar.formatyear` を使い、1 年" +"分の 3 列のカレンダーを複数行の文字列で返します。" -#: ../../library/calendar.rst:446 msgid "" "An unrelated but handy function that takes a time tuple such as returned by " "the :func:`~time.gmtime` function in the :mod:`time` module, and returns the " @@ -563,44 +606,54 @@ msgid "" "encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each other's " "inverse." msgstr "" +"カレンダーとは直接関係しませんが、便利な関数です。\n" +":mod:`time` モジュールの :func:`~time.gmtime` 関数が返すような時刻タプルを受" +"け取り、1970 年をエポックとする POSIX の表現に従った Unix タイムスタンプを返" +"します。\n" +":func:`time.gmtime` と :func:`timegm` は、互いに逆の変換を行います。" -#: ../../library/calendar.rst:453 msgid "The :mod:`!calendar` module exports the following data attributes:" -msgstr "" +msgstr ":mod:`!calendar` モジュールは次のデータ属性を公開します。" -#: ../../library/calendar.rst:457 msgid "" "A sequence that represents the days of the week in the current locale, where " "Monday is day number 0." msgstr "" +"現在のロケールの曜日名を表すシーケンスです。\n" +"月曜日が曜日番号 0 です。" -#: ../../library/calendar.rst:467 msgid "" "A sequence that represents the abbreviated days of the week in the current " "locale, where Mon is day number 0." msgstr "" +"現在のロケールの曜日の略称を表すシーケンスです。\n" +"月曜日 (Mon) が曜日番号 0 です。" -#: ../../library/calendar.rst:482 msgid "" "Aliases for the days of the week, where ``MONDAY`` is ``0`` and ``SUNDAY`` " "is ``6``." msgstr "" +"曜日を表す別名です。\n" +"``MONDAY`` が ``0``、``SUNDAY`` が ``6`` です。" -#: ../../library/calendar.rst:490 msgid "" "Enumeration defining days of the week as integer constants. The members of " "this enumeration are exported to the module scope as :data:`MONDAY` through :" "data:`SUNDAY`." msgstr "" +"曜日を整数定数として定義する列挙型です。\n" +"この列挙型のメンバーは、モジュールのスコープに :data:`MONDAY` から :data:" +"`SUNDAY` として公開されます。" -#: ../../library/calendar.rst:499 msgid "" "A sequence that represents the months of the year in the current locale. " "This follows normal convention of January being month number 1, so it has a " "length of 13 and ``month_name[0]`` is the empty string." msgstr "" +"現在のロケールの月名を表すシーケンスです。\n" +"通常の慣例どおり 1 月の月番号を 1 とするため、長さは 13 で、" +"``month_name[0]`` は空文字列です。" -#: ../../library/calendar.rst:509 msgid "" "In locales with alternative month names forms, the :data:`!month_name` " "sequence may not be suitable when a month name stands by itself and not as " @@ -608,58 +661,76 @@ msgid "" "languages, :data:`!month_name` will produce the month in genitive case. Use :" "data:`standalone_month_name` for a form suitable for standalone use." msgstr "" +"月名に複数の語形があるロケールでは、日付の一部ではなく月名だけを単独で表示す" +"る場合、:data:`!month_name` が適さないことがあります。\n" +"例えばギリシャ語や、多くのスラブ系・バルト系の言語では、:data:`!month_name` " +"は月名の属格を返します。\n" +"単独で使うのに適した語形を得るには :data:`standalone_month_name` を使ってくだ" +"さい。" -#: ../../library/calendar.rst:518 msgid "" "A sequence that represents the abbreviated months of the year in the current " "locale. This follows normal convention of January being month number 1, so " "it has a length of 13 and ``month_abbr[0]`` is the empty string." msgstr "" +"現在のロケールの月名の略称を表すシーケンスです。\n" +"通常の慣例どおり 1 月の月番号を 1 とするため、長さは 13 で、" +"``month_abbr[0]`` は空文字列です。" -#: ../../library/calendar.rst:528 msgid "" "In locales with alternative month names forms, the :data:`!month_abbr` " "sequence may not be suitable when a month name stands by itself and not as " "part of a date. Use :data:`standalone_month_abbr` for a form suitable for " "standalone use." msgstr "" +"月名に複数の語形があるロケールでは、日付の一部ではなく月名だけを単独で表示す" +"る場合、:data:`!month_abbr` が適さないことがあります。\n" +"単独で使うのに適した語形を得るには :data:`standalone_month_abbr` を使ってくだ" +"さい。" -#: ../../library/calendar.rst:535 msgid "" "A sequence that represents the months of the year in the current locale in " "the standalone form if the locale provides one. Else it is equivalent to :" "data:`month_name`." msgstr "" +"現在のロケールの月名を表すシーケンスです。\n" +"ロケールに単独使用の語形があればそれを使い、なければ :data:`month_name` と同" +"じです。" -#: ../../library/calendar.rst:544 msgid "" "A sequence that represents the abbreviated months of the year in the current " "locale in the standalone form if the locale provides one. Else it is " "equivalent to :data:`month_abbr`." msgstr "" +"現在のロケールの月名の略称を表すシーケンスです。\n" +"ロケールに単独使用の語形があればそれを使い、なければ :data:`month_abbr` と同" +"じです。" -#: ../../library/calendar.rst:564 msgid "" "Aliases for the months of the year, where ``JANUARY`` is ``1`` and " "``DECEMBER`` is ``12``." msgstr "" +"月を表す別名です。\n" +"``JANUARY`` が ``1``、``DECEMBER`` が ``12`` です。" -#: ../../library/calendar.rst:572 msgid "" "Enumeration defining months of the year as integer constants. The members of " "this enumeration are exported to the module scope as :data:`JANUARY` " "through :data:`DECEMBER`." msgstr "" +"月を整数定数として定義する列挙型です。\n" +"この列挙型のメンバーは、モジュールのスコープに :data:`JANUARY` から :data:" +"`DECEMBER` として公開されます。" -#: ../../library/calendar.rst:579 msgid "The :mod:`!calendar` module defines the following exceptions:" -msgstr "" +msgstr ":mod:`!calendar` モジュールは次の例外を定義します。" -#: ../../library/calendar.rst:583 msgid "" "A subclass of :exc:`ValueError` and :exc:`IndexError`, raised when the given " "month number is outside of the range 1-12 (inclusive)." msgstr "" +":exc:`ValueError` と :exc:`IndexError` のサブクラスで、指定された月番号が 1~" +"12 の範囲外の場合に送出されます。" #: ../../library/calendar.rst:586 msgid "" @@ -667,19 +738,18 @@ msgid "" "code should avoid catching :exc:`IndexError`." msgstr "" -#: ../../library/calendar.rst:593 msgid "The invalid month number." -msgstr "" +msgstr "無効な月番号です。" -#: ../../library/calendar.rst:598 msgid "" "A subclass of :exc:`ValueError`, raised when the given weekday number is " "outside of the range 0-6 (inclusive)." msgstr "" +":exc:`ValueError` のサブクラスで、指定された曜日番号が 0~6 の範囲外の場合に" +"送出されます。" -#: ../../library/calendar.rst:603 msgid "The invalid weekday number." -msgstr "" +msgstr "無効な曜日番号です。" #: ../../library/calendar.rst:608 msgid "Module :mod:`datetime`" @@ -705,24 +775,25 @@ msgstr "時間に関連した低水準の関数群。" msgid "Command-line usage" msgstr "コマンドラインでの使用" -#: ../../library/calendar.rst:623 msgid "" "The :mod:`!calendar` module can be executed as a script from the command " "line to interactively print a calendar." msgstr "" +":mod:`!calendar` モジュールは、コマンドラインからスクリプトとして実行し、対話" +"的にカレンダーを表示できます。" -#: ../../library/calendar.rst:626 msgid "" "python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" " [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" " [-f FIRST_WEEKDAY] [year] [month]" msgstr "" +"python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]\n" +" [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]\n" +" [-f FIRST_WEEKDAY] [year] [month]" -#: ../../library/calendar.rst:633 msgid "For example, to print a calendar for the year 2000:" -msgstr "" +msgstr "例えば、2000 年のカレンダーを表示するには次のようにします。" -#: ../../library/calendar.rst:635 msgid "" "$ python -m calendar 2000\n" " 2000\n" @@ -762,6 +833,43 @@ msgid "" "23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\n" "30 31" msgstr "" +"$ python -m calendar 2000\n" +" 2000\n" +"\n" +" January February March\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 1 2 3 4 5\n" +" 3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12\n" +"10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19\n" +"17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26\n" +"24 25 26 27 28 29 30 28 29 27 28 29 30 31\n" +"31\n" +"\n" +" April May June\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 7 1 2 3 4\n" +" 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11\n" +"10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18\n" +"17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25\n" +"24 25 26 27 28 29 30 29 30 31 26 27 28 29 30\n" +"\n" +" July August September\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 2 1 2 3 4 5 6 1 2 3\n" +" 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10\n" +"10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17\n" +"17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24\n" +"24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30\n" +"31\n" +"\n" +" October November December\n" +"Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su\n" +" 1 1 2 3 4 5 1 2 3\n" +" 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10\n" +" 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17\n" +"16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24\n" +"23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31\n" +"30 31" #: ../../library/calendar.rst:676 msgid "The following options are accepted:" @@ -771,81 +879,99 @@ msgstr "以下のオプションが使用できます:" msgid "Show the help message and exit." msgstr "ヘルプメッセージを表示して終了します。" -#: ../../library/calendar.rst:688 msgid "The locale to use for month and weekday names. Defaults to English." msgstr "" +"月名と曜日名に使うロケールです。\n" +"デフォルトは英語です。" -#: ../../library/calendar.rst:694 msgid "" "The encoding to use for output. :option:`--encoding` is required if :option:" "`--locale` is set." msgstr "" +"出力に使うエンコーディングです。\n" +":option:`--locale` を設定した場合は :option:`--encoding` が必須です。" -#: ../../library/calendar.rst:700 msgid "Print the calendar to the terminal as text, or as an HTML document." msgstr "" +"カレンダーをテキストとして端末に表示するか、HTML 文書として出力します。" -#: ../../library/calendar.rst:706 msgid "" "The weekday to start each week. Must be a number between 0 (Monday) and 6 " "(Sunday). Defaults to 0." msgstr "" +"週の最初の曜日です。\n" +"0 (月曜日) から 6 (日曜日) までの数値を指定してください。\n" +"デフォルトは 0 です。" -#: ../../library/calendar.rst:714 msgid "The year to print the calendar for. Defaults to the current year." msgstr "" +"カレンダーを表示する年です。\n" +"デフォルトは現在の年です。" -#: ../../library/calendar.rst:720 msgid "" "The month of the specified :option:`year` to print the calendar for. Must be " "a number between 1 and 12. Defaults to printing a calendar for the full year." msgstr "" +":option:`year` で指定した年のうち、カレンダーを表示する月です。\n" +"1~12 の数値を指定してください。\n" +"デフォルトでは 1 年分のカレンダーを表示します。" -#: ../../library/calendar.rst:725 msgid "*Text-mode options:*" -msgstr "" +msgstr "*テキストモードのオプション:*" -#: ../../library/calendar.rst:729 msgid "" "The width of the date column in terminal columns. The date is printed " "centred in the column. Any value lower than 2 is ignored. Defaults to 2." msgstr "" +"日付の列の幅を、端末の桁数で指定します。\n" +"日付は列の中央に表示されます。\n" +"2 未満の値は無視します。\n" +"デフォルトは 2 です。" -#: ../../library/calendar.rst:737 msgid "" "The number of lines for each week in terminal rows. The date is printed top-" "aligned. Any value lower than 1 is ignored. Defaults to 1." msgstr "" +"各週に使う行数を、端末の行数で指定します。\n" +"日付は上揃えで表示されます。\n" +"1 未満の値は無視します。\n" +"デフォルトは 1 です。" -#: ../../library/calendar.rst:745 msgid "" "The space between months in columns. Any value lower than 2 is ignored. " "Defaults to 6." msgstr "" +"月と月の間隔を桁数で指定します。\n" +"2 未満の値は無視します。\n" +"デフォルトは 6 です。" -#: ../../library/calendar.rst:752 msgid "The number of months printed per row. Defaults to 3." msgstr "" +"1 行に表示する月の数です。\n" +"デフォルトは 3 です。" -#: ../../library/calendar.rst:755 msgid "" "By default, today's date is highlighted in color and can be :ref:`controlled " "using environment variables `." msgstr "" +"デフォルトでは今日の日付を色で強調表示します。\n" +"この動作は :ref:`環境変数で制御できます `。" -#: ../../library/calendar.rst:759 msgid "" "By default, the month is now also highlighted in color, and the days of the " "week are also in color. This behavior can be :ref:`controlled using " "environment variables `." msgstr "" +"デフォルトで月も色で強調表示し、曜日にも色を付けるようになりました。\n" +"この動作は :ref:`環境変数で制御できます `。" -#: ../../library/calendar.rst:764 msgid "*HTML-mode options:*" -msgstr "" +msgstr "*HTML モードのオプション:*" -#: ../../library/calendar.rst:768 msgid "" "The path of a CSS stylesheet to use for the calendar. This must either be " "relative to the generated HTML, or an absolute HTTP or ``file:///`` URL." msgstr "" +"カレンダーに使う CSS スタイルシートのパスです。\n" +"生成される HTML からの相対パスか、絶対 HTTP URL または ``file:///`` URL でな" +"ければなりません。" diff --git a/library/cgi.po b/library/cgi.po index 82c98c71b..909eedd0b 100644 --- a/library/cgi.po +++ b/library/cgi.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/cgi.rst:2 @@ -33,7 +33,7 @@ msgid "" "Python 3.11. The removal was decided in :pep:`594`." msgstr "" "このモジュールは今や Python 標準ライブラリの一部ではありません。このモジュー" -"ルは Python 3.11 で非推奨となったあと、 :ref:`Python 3.13 で削除` されました。削除の決定は :pep:`594` でなされました。" #: ../../library/cgi.rst:14 diff --git a/library/cgitb.po b/library/cgitb.po index c126c1321..2ed5ab44b 100644 --- a/library/cgitb.po +++ b/library/cgitb.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/cgitb.rst:2 msgid ":mod:`!cgitb` --- Traceback manager for CGI scripts" -msgstr "" +msgstr ":mod:`!cgitb` --- CGI スクリプトのトレースバック管理" #: ../../library/cgitb.rst:10 msgid "" @@ -43,8 +42,9 @@ msgid "" "core Python team." msgstr "" -#: ../../library/cgitb.rst:18 msgid "" "The last version of Python that provided the :mod:`!cgitb` module was " "`Python 3.12 `_." msgstr "" +":mod:`!cgitb` モジュールを提供していた最後のバージョンは `Python 3.12 " +"`_ です。" diff --git a/library/chunk.po b/library/chunk.po index 9718c81c1..ed9f69e8b 100644 --- a/library/chunk.po +++ b/library/chunk.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/chunk.rst:2 msgid ":mod:`!chunk` --- Read IFF chunked data" -msgstr "" +msgstr ":mod:`!chunk` --- IFF チャンクデータの読み込み" #: ../../library/chunk.rst:10 msgid "" @@ -36,8 +35,9 @@ msgstr "" "ルは Python 3.11 で非推奨となったあと、:ref:`Python 3.13 で削除` されました。削除の決定は :pep:`594` でなされました。" -#: ../../library/chunk.rst:14 msgid "" "The last version of Python that provided the :mod:`!chunk` module was " "`Python 3.12 `_." msgstr "" +":mod:`!chunk` モジュールを提供していた最後のバージョンは `Python 3.12 " +"`_ です。" diff --git a/library/cmath.po b/library/cmath.po index 61ea55e6f..52370ab40 100644 --- a/library/cmath.po +++ b/library/cmath.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/cmath.rst:2 @@ -44,7 +44,6 @@ msgstr "" "これらのメソッドはそのオブジェクトを複素数または浮動小数点数に変換するのにそ" "れぞれ使われ、呼び出された関数はそうして変換された結果を利用します。" -#: ../../library/cmath.rst:18 msgid "" "For functions involving branch cuts, we have the problem of deciding how to " "define those functions on the cut itself. Following Kahan's \"Branch cuts " @@ -54,236 +53,194 @@ msgid "" "axis we look at the sign of the imaginary part, while for a branch cut along " "the imaginary axis we look at the sign of the real part." msgstr "" +"分枝切断を持つ関数では、切断そのものの上で関数をどう定義するかが問題になりま" +"す。\n" +"Kahan の論文 \"Branch cuts for complex elementary functions\" と、C99 以降の " +"C 規格の附属書 G に従い、ゼロの符号で分枝切断のどちら側かを区別します。\n" +"実軸の一部に沿った分枝切断では虚部の符号を使い、虚軸に沿った分枝切断では実部" +"の符号を使います。" -#: ../../library/cmath.rst:26 msgid "" "For example, the :func:`cmath.sqrt` function has a branch cut along the " "negative real axis. An argument of ``-2-0j`` is treated as though it lies " "*below* the branch cut, and so gives a result on the negative imaginary " "axis::" msgstr "" +"例えば :func:`cmath.sqrt` 関数は、負の実軸に沿った分枝切断を持ちます。\n" +"引数 ``-2-0j`` は分枝切断の *下側* にあるものとして扱うため、結果は負の虚軸上" +"になります。 ::" -#: ../../library/cmath.rst:31 msgid "" ">>> cmath.sqrt(-2-0j)\n" "-1.4142135623730951j" msgstr "" +">>> cmath.sqrt(-2-0j)\n" +"-1.4142135623730951j" -#: ../../library/cmath.rst:34 msgid "" "But an argument of ``-2+0j`` is treated as though it lies above the branch " "cut::" -msgstr "" +msgstr "一方、引数 ``-2+0j`` は分枝切断の上側にあるものとして扱います。 ::" -#: ../../library/cmath.rst:37 msgid "" ">>> cmath.sqrt(-2+0j)\n" "1.4142135623730951j" msgstr "" +">>> cmath.sqrt(-2+0j)\n" +"1.4142135623730951j" -#: ../../library/cmath.rst:42 msgid "**Conversions to and from polar coordinates**" -msgstr "" +msgstr "**極座標変換**" -#: ../../library/cmath.rst:44 msgid ":func:`phase(z) `" -msgstr "" +msgstr ":func:`phase(z) `" -#: ../../library/cmath.rst:44 msgid "Return the phase of *z*" -msgstr "" +msgstr "*z* の位相を返します" -#: ../../library/cmath.rst:45 msgid ":func:`polar(z) `" -msgstr "" +msgstr ":func:`polar(z) `" -#: ../../library/cmath.rst:45 msgid "Return the representation of *z* in polar coordinates" -msgstr "" +msgstr "*z* を極座標で表した値を返します" -#: ../../library/cmath.rst:46 msgid ":func:`rect(r, phi) `" -msgstr "" +msgstr ":func:`rect(r, phi) `" -#: ../../library/cmath.rst:46 msgid "Return the complex number *z* with polar coordinates *r* and *phi*" -msgstr "" +msgstr "極座標が *r* と *phi* である複素数 *z* を返します" -#: ../../library/cmath.rst:48 msgid "**Power and logarithmic functions**" -msgstr "" +msgstr "**指数関数と対数関数**" -#: ../../library/cmath.rst:50 msgid ":func:`exp(z) `" -msgstr "" +msgstr ":func:`exp(z) `" -#: ../../library/cmath.rst:50 msgid "Return *e* raised to the power *z*" -msgstr "" +msgstr "*e* の *z* 乗を返します" -#: ../../library/cmath.rst:51 msgid ":func:`log(z[, base]) `" -msgstr "" +msgstr ":func:`log(z[, base]) `" -#: ../../library/cmath.rst:51 msgid "Return the logarithm of *z* to the given *base* (*e* by default)" -msgstr "" +msgstr "*base* (デフォルトは *e*) を底とする *z* の対数を返します" -#: ../../library/cmath.rst:52 msgid ":func:`log10(z) `" -msgstr "" +msgstr ":func:`log10(z) `" -#: ../../library/cmath.rst:52 msgid "Return the base-10 logarithm of *z*" -msgstr "" +msgstr "10 を底とする *z* の対数を返します" -#: ../../library/cmath.rst:53 msgid ":func:`sqrt(z) `" -msgstr "" +msgstr ":func:`sqrt(z) `" -#: ../../library/cmath.rst:53 msgid "Return the square root of *z*" -msgstr "" +msgstr "*z* の平方根を返します" -#: ../../library/cmath.rst:55 msgid "**Trigonometric functions**" -msgstr "" +msgstr "**三角関数**" -#: ../../library/cmath.rst:57 msgid ":func:`acos(z) `" -msgstr "" +msgstr ":func:`acos(z) `" -#: ../../library/cmath.rst:57 msgid "Return the arc cosine of *z*" -msgstr "" +msgstr "*z* の逆余弦を返します" -#: ../../library/cmath.rst:58 msgid ":func:`asin(z) `" -msgstr "" +msgstr ":func:`asin(z) `" -#: ../../library/cmath.rst:58 msgid "Return the arc sine of *z*" -msgstr "" +msgstr "*z* の逆正弦を返します" -#: ../../library/cmath.rst:59 msgid ":func:`atan(z) `" -msgstr "" +msgstr ":func:`atan(z) `" -#: ../../library/cmath.rst:59 msgid "Return the arc tangent of *z*" -msgstr "" +msgstr "*z* の逆正接を返します" -#: ../../library/cmath.rst:60 msgid ":func:`cos(z) `" -msgstr "" +msgstr ":func:`cos(z) `" -#: ../../library/cmath.rst:60 msgid "Return the cosine of *z*" -msgstr "" +msgstr "*z* の余弦を返します" -#: ../../library/cmath.rst:61 msgid ":func:`sin(z) `" -msgstr "" +msgstr ":func:`sin(z) `" -#: ../../library/cmath.rst:61 msgid "Return the sine of *z*" -msgstr "" +msgstr "*z* の正弦を返します" -#: ../../library/cmath.rst:62 msgid ":func:`tan(z) `" -msgstr "" +msgstr ":func:`tan(z) `" -#: ../../library/cmath.rst:62 msgid "Return the tangent of *z*" -msgstr "" +msgstr "*z* の正接を返します" -#: ../../library/cmath.rst:64 msgid "**Hyperbolic functions**" -msgstr "" +msgstr "**双曲線関数**" -#: ../../library/cmath.rst:66 msgid ":func:`acosh(z) `" -msgstr "" +msgstr ":func:`acosh(z) `" -#: ../../library/cmath.rst:66 msgid "Return the inverse hyperbolic cosine of *z*" -msgstr "" +msgstr "*z* の逆双曲線余弦を返します" -#: ../../library/cmath.rst:67 msgid ":func:`asinh(z) `" -msgstr "" +msgstr ":func:`asinh(z) `" -#: ../../library/cmath.rst:67 msgid "Return the inverse hyperbolic sine of *z*" -msgstr "" +msgstr "*z* の逆双曲線正弦を返します" -#: ../../library/cmath.rst:68 msgid ":func:`atanh(z) `" -msgstr "" +msgstr ":func:`atanh(z) `" -#: ../../library/cmath.rst:68 msgid "Return the inverse hyperbolic tangent of *z*" -msgstr "" +msgstr "*z* の逆双曲線正接を返します" -#: ../../library/cmath.rst:69 msgid ":func:`cosh(z) `" -msgstr "" +msgstr ":func:`cosh(z) `" -#: ../../library/cmath.rst:69 msgid "Return the hyperbolic cosine of *z*" -msgstr "" +msgstr "*z* の双曲線余弦を返します" -#: ../../library/cmath.rst:70 msgid ":func:`sinh(z) `" -msgstr "" +msgstr ":func:`sinh(z) `" -#: ../../library/cmath.rst:70 msgid "Return the hyperbolic sine of *z*" -msgstr "" +msgstr "*z* の双曲線正弦を返します" -#: ../../library/cmath.rst:71 msgid ":func:`tanh(z) `" -msgstr "" +msgstr ":func:`tanh(z) `" -#: ../../library/cmath.rst:71 msgid "Return the hyperbolic tangent of *z*" -msgstr "" +msgstr "*z* の双曲線正接を返します" -#: ../../library/cmath.rst:73 msgid "**Classification functions**" -msgstr "" +msgstr "**類別関数**" -#: ../../library/cmath.rst:75 msgid ":func:`isfinite(z) `" -msgstr "" +msgstr ":func:`isfinite(z) `" -#: ../../library/cmath.rst:75 msgid "Check if all components of *z* are finite" -msgstr "" +msgstr "*z* の実部と虚部が両方とも有限かどうかを調べます" -#: ../../library/cmath.rst:76 msgid ":func:`isinf(z) `" -msgstr "" +msgstr ":func:`isinf(z) `" -#: ../../library/cmath.rst:76 msgid "Check if any component of *z* is infinite" -msgstr "" +msgstr "*z* の実部または虚部が無限大かどうかを調べます" -#: ../../library/cmath.rst:77 msgid ":func:`isnan(z) `" -msgstr "" +msgstr ":func:`isnan(z) `" -#: ../../library/cmath.rst:77 msgid "Check if any component of *z* is a NaN" -msgstr "" +msgstr "*z* の実部または虚部が NaN かどうかを調べます" -#: ../../library/cmath.rst:78 msgid ":func:`isclose(a, b, *, rel_tol, abs_tol) `" -msgstr "" +msgstr ":func:`isclose(a, b, *, rel_tol, abs_tol) `" -#: ../../library/cmath.rst:78 msgid "Check if the values *a* and *b* are close to each other" -msgstr "" +msgstr "*a* と *b* が互いに近い値かを調べる" #: ../../library/cmath.rst:80 msgid "**Constants**" @@ -321,13 +278,11 @@ msgstr ":data:`inf`" msgid "Positive infinity" msgstr "正の無限大" -#: ../../library/cmath.rst:86 msgid ":data:`infj`" -msgstr "" +msgstr ":data:`infj`" -#: ../../library/cmath.rst:86 msgid "Pure imaginary infinity" -msgstr "" +msgstr "虚部が無限大の純虚数" #: ../../library/cmath.rst:87 msgid ":data:`nan`" @@ -337,24 +292,24 @@ msgstr ":data:`nan`" msgid "\"Not a number\" (NaN)" msgstr "非数 \"Not a number\" (NaN)" -#: ../../library/cmath.rst:88 msgid ":data:`nanj`" -msgstr "" +msgstr ":data:`nanj`" -#: ../../library/cmath.rst:88 msgid "Pure imaginary NaN" -msgstr "" +msgstr "虚部が NaN の純虚数" #: ../../library/cmath.rst:93 msgid "Conversions to and from polar coordinates" msgstr "極座標変換" -#: ../../library/cmath.rst:95 msgid "" "A Python complex number ``z`` is stored internally using *rectangular* or " "*Cartesian* coordinates. It is completely determined by its *real part* ``z." "real`` and its *imaginary part* ``z.imag``." msgstr "" +"Python の複素数 ``z`` は、内部では *直交座標* (デカルト座標) で保持されま" +"す。\n" +"*実部* ``z.real`` と *虚部* ``z.imag`` によって完全に定まります。" #: ../../library/cmath.rst:99 msgid "" @@ -377,7 +332,6 @@ msgid "" msgstr "" "次の関数はネイティブの直交座標を極座標に変換したりその逆を行うのに使えます。" -#: ../../library/cmath.rst:111 msgid "" "Return the phase of *z* (also known as the *argument* of *z*), as a float. " "``phase(z)`` is equivalent to ``math.atan2(z.imag, z.real)``. The result " @@ -385,155 +339,179 @@ msgid "" "along the negative real axis. The sign of the result is the same as the " "sign of ``z.imag``, even when ``z.imag`` is zero::" msgstr "" +"*z* の位相 (*偏角* とも呼びます) を浮動小数点数で返します。\n" +"``phase(z)`` は ``math.atan2(z.imag, z.real)`` と同じです。\n" +"結果の範囲は [-\\ *π*, *π*] で、分枝切断は負の実軸に沿っています。\n" +"``z.imag`` がゼロの場合も、結果の符号は ``z.imag`` の符号と同じです。 ::" -#: ../../library/cmath.rst:117 msgid "" ">>> phase(-1+0j)\n" "3.141592653589793\n" ">>> phase(-1-0j)\n" "-3.141592653589793" msgstr "" +">>> phase(-1+0j)\n" +"3.141592653589793\n" +">>> phase(-1-0j)\n" +"-3.141592653589793" -#: ../../library/cmath.rst:125 msgid "" "The modulus (absolute value) of a complex number *z* can be computed using " "the built-in :func:`abs` function. There is no separate :mod:`!cmath` " "module function for this operation." msgstr "" +"複素数 *z* の大きさ (絶対値) は、組み込み関数 :func:`abs` で計算できます。\n" +":mod:`!cmath` モジュールには、このための専用の関数はありません。" -#: ../../library/cmath.rst:132 msgid "" "Return the representation of *z* in polar coordinates. Returns a pair ``(r, " "phi)`` where *r* is the modulus of *z* and *phi* is the phase of *z*. " "``polar(z)`` is equivalent to ``(abs(z), phase(z))``." msgstr "" +"*z* の極座標表現を返します。\n" +"戻り値は ``(r, phi)`` の組で、*r* は *z* の大きさ、*phi* は *z* の位相で" +"す。\n" +"``polar(z)`` は ``(abs(z), phase(z))`` と同じです。" -#: ../../library/cmath.rst:140 msgid "" "Return the complex number *z* with polar coordinates *r* and *phi*. " "Equivalent to ``complex(r * math.cos(phi), r * math.sin(phi))``." msgstr "" +"極座標が *r* と *phi* である複素数 *z* を返します。\n" +"``complex(r * math.cos(phi), r * math.sin(phi))`` と同じです。" #: ../../library/cmath.rst:145 msgid "Power and logarithmic functions" msgstr "指数関数と対数関数" -#: ../../library/cmath.rst:149 msgid "" "Return *e* raised to the power *z*, where *e* is the base of natural " "logarithms." -msgstr "" +msgstr "自然対数の底 *e* の *z* 乗を返します。" -#: ../../library/cmath.rst:155 msgid "" "Return the logarithm of *z* to the given *base*. If the *base* is not " "specified, returns the natural logarithm of *z*. There is one branch cut, " "from 0 along the negative real axis to -∞." msgstr "" +"*base* を底とする *z* の対数を返します。\n" +"*base* を指定しない場合は *z* の自然対数を返します。\n" +"分枝切断は 1 つで、0 から負の実軸に沿って -∞ まで延びています。" -#: ../../library/cmath.rst:162 msgid "" "Return the base-10 logarithm of *z*. This has the same branch cut as :func:" "`log`." msgstr "" +"10 を底とする *z* の対数を返します。\n" +"分枝切断は :func:`log` と同じです。" -#: ../../library/cmath.rst:168 msgid "" "Return the square root of *z*. This has the same branch cut as :func:`log`." msgstr "" +"*z* の平方根を返します。\n" +"分枝切断は :func:`log` と同じです。" #: ../../library/cmath.rst:172 msgid "Trigonometric functions" msgstr "三角関数" -#: ../../library/cmath.rst:176 msgid "" "Return the arc cosine of *z*. There are two branch cuts: One extends right " "from 1 along the real axis to ∞. The other extends left from -1 along the " "real axis to -∞." msgstr "" +"*z* の逆余弦を返します。\n" +"分枝切断は 2 つあります。\n" +"一方は 1 から実軸に沿って右に ∞ まで、もう一方は -1 から実軸に沿って左に -∞ " +"まで延びています。" -#: ../../library/cmath.rst:183 msgid "" "Return the arc sine of *z*. This has the same branch cuts as :func:`acos`." msgstr "" +"*z* の逆正弦を返します。\n" +"分枝切断は :func:`acos` と同じです。" -#: ../../library/cmath.rst:188 msgid "" "Return the arc tangent of *z*. There are two branch cuts: One extends from " "``1j`` along the imaginary axis to ``∞j``. The other extends from ``-1j`` " "along the imaginary axis to ``-∞j``." msgstr "" +"*z* の逆正接を返します。\n" +"分枝切断は 2 つあります。\n" +"一方は ``1j`` から虚軸に沿って ``∞j`` まで、もう一方は ``-1j`` から虚軸に沿っ" +"て ``-∞j`` まで延びています。" -#: ../../library/cmath.rst:195 msgid "Return the cosine of *z*." -msgstr "" +msgstr "*z* の余弦を返します。" -#: ../../library/cmath.rst:200 msgid "Return the sine of *z*." -msgstr "" +msgstr "*z* の正弦を返します。" -#: ../../library/cmath.rst:205 msgid "Return the tangent of *z*." -msgstr "" +msgstr "*z* の正接を返します。" #: ../../library/cmath.rst:209 msgid "Hyperbolic functions" msgstr "双曲線関数" -#: ../../library/cmath.rst:213 msgid "" "Return the inverse hyperbolic cosine of *z*. There is one branch cut, " "extending left from 1 along the real axis to -∞." msgstr "" +"*z* の逆双曲線余弦を返します。\n" +"分枝切断は 1 つで、1 から実軸に沿って左に -∞ まで延びています。" -#: ../../library/cmath.rst:219 msgid "" "Return the inverse hyperbolic sine of *z*. There are two branch cuts: One " "extends from ``1j`` along the imaginary axis to ``∞j``. The other extends " "from ``-1j`` along the imaginary axis to ``-∞j``." msgstr "" +"*z* の逆双曲線正弦を返します。\n" +"分枝切断は 2 つあります。\n" +"一方は ``1j`` から虚軸に沿って ``∞j`` まで、もう一方は ``-1j`` から虚軸に沿っ" +"て ``-∞j`` まで延びています。" -#: ../../library/cmath.rst:226 msgid "" "Return the inverse hyperbolic tangent of *z*. There are two branch cuts: One " "extends from ``1`` along the real axis to ``∞``. The other extends from " "``-1`` along the real axis to ``-∞``." msgstr "" +"*z* の逆双曲線正接を返します。\n" +"分枝切断は 2 つあります。\n" +"一方は ``1`` から実軸に沿って ``∞`` まで、もう一方は ``-1`` から実軸に沿って " +"``-∞`` まで延びています。" -#: ../../library/cmath.rst:233 msgid "Return the hyperbolic cosine of *z*." -msgstr "" +msgstr "*z* の双曲線余弦を返します。" -#: ../../library/cmath.rst:238 msgid "Return the hyperbolic sine of *z*." -msgstr "" +msgstr "*z* の双曲線正弦を返します。" -#: ../../library/cmath.rst:243 msgid "Return the hyperbolic tangent of *z*." -msgstr "" +msgstr "*z* の双曲線正接を返します。" #: ../../library/cmath.rst:247 msgid "Classification functions" msgstr "類別関数" -#: ../../library/cmath.rst:251 msgid "" "Return ``True`` if both the real and imaginary parts of *z* are finite, and " "``False`` otherwise." msgstr "" +"*z* の実部と虚部が両方とも有限なら ``True``、それ以外は ``False`` を返しま" +"す。" -#: ../../library/cmath.rst:259 msgid "" "Return ``True`` if either the real or the imaginary part of *z* is an " "infinity, and ``False`` otherwise." msgstr "" +"*z* の実部または虚部が無限大なら ``True``、それ以外は ``False`` を返します。" -#: ../../library/cmath.rst:265 msgid "" "Return ``True`` if either the real or the imaginary part of *z* is a NaN, " "and ``False`` otherwise." msgstr "" +"*z* の実部または虚部が NaN なら ``True``、それ以外は ``False`` を返します。" #: ../../library/cmath.rst:271 msgid "" @@ -543,14 +521,16 @@ msgstr "" "値 *a* と *b* が互いに近い場合 ``True`` を、そうでない場合は ``False`` を返し" "ます。" -#: ../../library/cmath.rst:274 msgid "" "Whether or not two values are considered close is determined according to " "given absolute and relative tolerances. If no errors occur, the result will " "be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``." msgstr "" +"2 つの値が近いとみなされるかは、指定された絶対許容誤差と相対許容誤差で決まり" +"ます。\n" +"エラーが起きなければ、結果は ``abs(a-b) <= max(rel_tol * max(abs(a), " +"abs(b)), abs_tol)`` です。" -#: ../../library/cmath.rst:278 msgid "" "*rel_tol* is the relative tolerance -- it is the maximum allowed difference " "between *a* and *b*, relative to the larger absolute value of *a* or *b*. " @@ -559,6 +539,12 @@ msgid "" "within about 9 decimal digits. *rel_tol* must be nonnegative and less than " "``1.0``." msgstr "" +"*rel_tol* は相対許容誤差です。\n" +"*a* と *b* の絶対値の大きい方に対する、両者の差の許容最大比率を表します。\n" +"例えば、5% の誤差を許容するには ``rel_tol=0.05`` を渡します。\n" +"デフォルトの許容誤差は ``1e-09`` で、2 つの値がおよそ 10 進 9 桁の精度で等し" +"いことを保証します。\n" +"*rel_tol* は非負で ``1.0`` 未満でなければなりません。" #: ../../library/cmath.rst:285 msgid "" @@ -583,7 +569,7 @@ msgstr "" #: ../../library/cmath.rst:300 msgid ":pep:`485` -- A function for testing approximate equality" -msgstr ":pep:`485` -- 近似的に等しいことを調べる関数" +msgstr ":pep:`485` -- A function for testing approximate equality" #: ../../library/cmath.rst:304 msgid "Constants" @@ -613,11 +599,13 @@ msgstr "" "実部がゼロ、虚部が正の無限大の複素数です。``complex(0.0, float('inf'))`` と等" "価です。" -#: ../../library/cmath.rst:340 msgid "" "A floating-point \"not a number\" (NaN) value. Equivalent to " "``float('nan')``. See also :data:`math.nan`." msgstr "" +"浮動小数点数の非数 (NaN) です。\n" +"``float('nan')`` と同じです。\n" +":data:`math.nan` も参照してください。" #: ../../library/cmath.rst:348 msgid "" @@ -639,7 +627,6 @@ msgid "" "zero)." msgstr "" -#: ../../library/cmath.rst:364 msgid "" "A note on branch cuts: They are curves along which the given function fails " "to be continuous. They are a necessary feature of many complex functions. " @@ -649,12 +636,11 @@ msgid "" "choice of branch cuts for numerical purposes, a good reference should be the " "following:" msgstr "" -"分枝切断 (branch cut) に関する注釈: 分枝切断を持つ曲線上では、与えられた関数" -"は連続ではなくなります。これらは多くの複素関数における必然的な特性です。複素" -"関数を計算する必要がある場合、これらの分枝に関して理解しているものと仮定して" -"います。悟りに至るために何らかの (到底基礎的とはいえない) 複素数に関する書を" -"ひもといてください。数値計算を目的とした分枝切断の正しい選択方法についての情" -"報としては、以下がよい参考文献となります:" +"分枝切断 (branch cut) について: 分枝切断は、関数が連続でなくなる曲線で、多く" +"の複素関数に必要なものです。\n" +"複素関数を計算する場合、分枝切断を理解していることを前提とします。\n" +"詳しくは、初歩的すぎない複素関数の教科書を参照してください。\n" +"数値計算に適した分枝切断の選び方については、次の文献が参考になります。" #: ../../library/cmath.rst:374 msgid "" diff --git a/library/cmd.po b/library/cmd.po index 05bf0906c..47109bde8 100644 --- a/library/cmd.po +++ b/library/cmd.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/cmd.rst:2 @@ -67,7 +67,6 @@ msgstr "" "トは :kbd:`Tab` です。 *completekey* が :const:`None` でなく、 :mod:" "`readline` が利用できるならば、コマンド補完は自動的に行われます。" -#: ../../library/cmd.rst:27 msgid "" "The default, ``'tab'``, is treated specially, so that it refers to the :kbd:" "`Tab` key on every :data:`readline.backend`. Specifically, if :data:" @@ -75,6 +74,12 @@ msgid "" "``'tab'``. Note that other values are not treated this way, and might only " "work with a specific backend." msgstr "" +"デフォルト値 ``'tab'`` は、すべての :data:`readline.backend` で :kbd:`Tab` " +"キーを指すように特別に扱われます。\n" +"具体的には、:data:`readline.backend` が ``editline`` の場合、``Cmd`` は " +"``'tab'`` の代わりに ``'^I'`` を使います。\n" +"他の値はこのようには扱われず、特定のバックエンドでしか機能しない可能性があり" +"ます。" #: ../../library/cmd.rst:34 msgid "" @@ -96,9 +101,10 @@ msgstr "" "引数に渡した *stdin* を使いたい場合は、インスタンスの :attr:`use_rawinput` 属" "性を ``False`` にセットしてください。そうしないと *stdin* は無視されます。" -#: ../../library/cmd.rst:43 msgid "``completekey='tab'`` is replaced by ``'^I'`` for ``editline``." msgstr "" +"``editline`` では ``completekey='tab'`` を ``'^I'`` に置き換えるようになりま" +"した。" #: ../../library/cmd.rst:50 msgid "Cmd Objects" @@ -144,7 +150,6 @@ msgstr "" msgid "An end-of-file on input is passed back as the string ``'EOF'``." msgstr "入力のファイル終端は、文字列 ``'EOF'`` として渡されます。" -#: ../../library/cmd.rst:76 msgid "" "An interpreter instance will recognize a command name ``foo`` if and only if " "it has a method :meth:`!do_foo`. As a special case, a line beginning with " @@ -152,15 +157,21 @@ msgid "" "another special case, a line beginning with the character ``'!'`` is " "dispatched to the method :meth:`!do_shell` (if such a method is defined)." msgstr "" +"インタープリタのインスタンスがコマンド名 ``foo`` を認識するのは、:meth:`!" +"do_foo` メソッドを持つ場合に限られます。\n" +"例外として、``'?'`` で始まる行は :meth:`do_help` メソッドに振り分けます。\n" +"また、``'!'`` で始まる行は :meth:`!do_shell` メソッドが定義されていれば、その" +"メソッドに振り分けます。" -#: ../../library/cmd.rst:82 msgid "" "This method will return when the :meth:`postcmd` method returns a true " "value. The *stop* argument to :meth:`postcmd` is the return value from the " "command's corresponding :meth:`!do_\\*` method." msgstr "" +"このメソッドは、:meth:`postcmd` メソッドが真の値を返すと終了します。\n" +":meth:`postcmd` の *stop* 引数は、コマンドに対応する :meth:`!do_\\*` メソッド" +"の戻り値です。" -#: ../../library/cmd.rst:86 msgid "" "If completion is enabled, completing commands will be done automatically, " "and completing of commands args is done by calling :meth:`!complete_foo` " @@ -171,8 +182,15 @@ msgid "" "could be used to provide different completion depending upon which position " "the argument is in." msgstr "" +"補完が有効な場合、コマンド名は自動的に補完します。\n" +"コマンドの引数の補完には、*text*、*line*、*begidx*、*endidx* を引数として :" +"meth:`!complete_foo` を呼び出します。\n" +"*text* はマッチさせる文字列の接頭辞で、返す候補はすべてこの文字列で始まらなけ" +"ればなりません。\n" +"*line* は先頭の空白を取り除いた現在の入力行です。\n" +"*begidx* と *endidx* は接頭辞のテキストの開始・終了インデックスで、引数の位置" +"に応じて補完内容を変えるために使えます。" -#: ../../library/cmd.rst:97 msgid "" "All subclasses of :class:`Cmd` inherit a predefined :meth:`!do_help`. This " "method, called with an argument ``'bar'``, invokes the corresponding method :" @@ -182,6 +200,17 @@ msgid "" "help_\\*` methods or commands that have docstrings), and also lists any " "undocumented commands." msgstr "" +":class:`Cmd` のすべてのサブクラスは、あらかじめ定義された :meth:`!do_help` を" +"継承します。\n" +"引数 ``'bar'`` を渡すと、対応する :meth:`!help_bar` メソッドを呼び出しま" +"す。\n" +"そのメソッドがなければ、:meth:`!do_bar` の docstring がある場合にそれを表示し" +"ます。\n" +"引数なしの場合、:meth:`!do_help` は利用可能なヘルプトピックをすべて表示しま" +"す。\n" +"つまり、対応する :meth:`!help_\\*` メソッドがあるコマンドや、docstring がある" +"コマンドの一覧です。\n" +"説明のないコマンドの一覧も表示します。" #: ../../library/cmd.rst:108 msgid "" @@ -211,18 +240,23 @@ msgstr "" "コマンドの先頭の語が認識されないときに、入力行に対して呼び出されます。このメ" "ソッドがオーバーライドされていないなら、エラーメッセージを表示して戻ります。" -#: ../../library/cmd.rst:131 msgid "" "Method called to complete an input line when no command-specific :meth:`!" "complete_\\*` method is available. By default, it returns an empty list." msgstr "" +"コマンド専用の :meth:`!complete_\\*` メソッドがない場合に、入力行を補完するた" +"めに呼び出されるメソッドです。\n" +"デフォルトでは空のリストを返します。" -#: ../../library/cmd.rst:137 msgid "" "Method called to display a list of strings as a compact set of columns. Each " "column is only as wide as necessary. Columns are separated by two spaces for " "readability." msgstr "" +"文字列のリストを、コンパクトな複数列の形式で表示するために呼び出されるメソッ" +"ドです。\n" +"各列の幅は必要な分だけ確保します。\n" +"読みやすくするため、列の間は 2 つのスペースで区切ります。" #: ../../library/cmd.rst:144 msgid "" @@ -304,13 +338,12 @@ msgstr "" "meth:`cmdloop` 内でチェックされます; これが空でない場合、その要素は、あたかも" "プロンプトから入力されたかのように順に処理されます。" -#: ../../library/cmd.rst:201 msgid "" "A string to issue as an intro or banner. May be overridden by giving the :" "meth:`cmdloop` method an argument." msgstr "" -"イントロあるいはバナーとして表示される文字列。 :meth:`cmdloop` メソッドに引数" -"を与えるために、オーバーライドされるかもしれません。" +"イントロやバナーとして表示する文字列です。\n" +":meth:`cmdloop` メソッドに引数を渡すと、この値を上書きできます。" #: ../../library/cmd.rst:207 msgid "" @@ -318,12 +351,15 @@ msgid "" msgstr "" "ヘルプ出力に文書化されたコマンドのセクションがある場合に表示するヘッダ。" -#: ../../library/cmd.rst:212 msgid "" "The header to issue if the help output has a section for miscellaneous help " "topics (that is, there are :meth:`!help_\\*` methods without corresponding :" "meth:`!do_\\*` methods)." msgstr "" +"ヘルプ出力にその他のヘルプトピックのセクションがある場合に表示する見出しで" +"す。\n" +"これは、対応する :meth:`!do_\\*` メソッドのない :meth:`!help_\\*` メソッドが" +"ある場合です。" #: ../../library/cmd.rst:219 msgid "" @@ -354,11 +390,12 @@ msgstr "" msgid "Cmd Example" msgstr "Cmd の例" -#: ../../library/cmd.rst:244 msgid "" "The :mod:`!cmd` module is mainly useful for building custom shells that let " "a user work with a program interactively." msgstr "" +":mod:`!cmd` モジュールは主に、ユーザーがプログラムを対話的に操作できる独自の" +"シェルを作成するのに役立ちます。" #: ../../library/cmd.rst:247 msgid "" @@ -368,15 +405,17 @@ msgstr "" "この節では、:mod:`turtle` モジュールのいくつかのコマンドを持ったシェルの作成" "方法の簡単な例を示します。" -#: ../../library/cmd.rst:250 msgid "" "Basic turtle commands such as :meth:`~turtle.forward` are added to a :class:" "`Cmd` subclass with method named :meth:`!do_forward`. The argument is " "converted to a number and dispatched to the turtle module. The docstring is " "used in the help utility provided by the shell." msgstr "" +":meth:`~turtle.forward` などの基本的な turtle コマンドを、:meth:`!" +"do_forward` という名前のメソッドで :class:`Cmd` のサブクラスに追加します。\n" +"引数を数値に変換して turtle モジュールに渡します。\n" +"docstring はシェルのヘルプ機能で使われます。" -#: ../../library/cmd.rst:255 msgid "" "The example also includes a basic record and playback facility implemented " "with the :meth:`~Cmd.precmd` method which is responsible for converting the " @@ -384,6 +423,11 @@ msgid "" "do_playback` method reads the file and adds the recorded commands to the :" "attr:`~Cmd.cmdqueue` for immediate playback::" msgstr "" +"この例には、:meth:`~Cmd.precmd` メソッドで実装した簡単な記録・再生機能もあり" +"ます。\n" +"このメソッドは入力を小文字に変換し、コマンドをファイルに書き込みます。\n" +":meth:`!do_playback` メソッドはファイルを読み取り、記録されたコマンドを :" +"attr:`~Cmd.cmdqueue` に追加してすぐに再生します。 ::" #: ../../library/cmd.rst:261 msgid "" @@ -474,7 +518,6 @@ msgstr "" "以下は、turtle シェルでの機能のヘルプ表示、空行によるコマンドの繰り返し、単純" "な記録と再実行のセッション例です:" -#: ../../library/cmd.rst:339 msgid "" "Welcome to the turtle shell. Type help or ? to list commands.\n" "\n" @@ -534,14 +577,70 @@ msgid "" "(turtle) bye\n" "Thank you for using Turtle" msgstr "" +"Welcome to the turtle shell. Type help or ? to list commands.\n" +"\n" +"(turtle) ?\n" +"\n" +"Documented commands (type help ):\n" +"========================================\n" +"bye color goto home playback record right\n" +"circle forward heading left position reset undo\n" +"\n" +"(turtle) help forward\n" +"Move the turtle forward by the specified distance: FORWARD 10\n" +"(turtle) record spiral.cmd\n" +"(turtle) position\n" +"Current position is 0 0\n" +"\n" +"(turtle) heading\n" +"Current heading is 0\n" +"\n" +"(turtle) reset\n" +"(turtle) circle 20\n" +"(turtle) right 30\n" +"(turtle) circle 40\n" +"(turtle) right 30\n" +"(turtle) circle 60\n" +"(turtle) right 30\n" +"(turtle) circle 80\n" +"(turtle) right 30\n" +"(turtle) circle 100\n" +"(turtle) right 30\n" +"(turtle) circle 120\n" +"(turtle) right 30\n" +"(turtle) circle 120\n" +"(turtle) heading\n" +"Current heading is 180\n" +"\n" +"(turtle) forward 100\n" +"(turtle)\n" +"(turtle) right 90\n" +"(turtle) forward 100\n" +"(turtle)\n" +"(turtle) right 90\n" +"(turtle) forward 400\n" +"(turtle) right 90\n" +"(turtle) forward 500\n" +"(turtle) right 90\n" +"(turtle) forward 400\n" +"(turtle) right 90\n" +"(turtle) forward 300\n" +"(turtle) playback spiral.cmd\n" +"Current position is 0 0\n" +"\n" +"Current heading is 0\n" +"\n" +"Current heading is 180\n" +"\n" +"(turtle) bye\n" +"Thank you for using Turtle" #: ../../library/cmd.rst:72 msgid "? (question mark)" msgstr "? (クエスチョンマーク)" -#: ../../library/cmd.rst:72 msgid "in a command interpreter" -msgstr "" +msgstr "コマンドインタープリタでの使用" #: ../../library/cmd.rst:72 msgid "! (exclamation)" diff --git a/library/cmdline.po b/library/cmdline.po index d15814eb8..d3089d273 100644 --- a/library/cmdline.po +++ b/library/cmdline.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/cmdline.rst:5 @@ -54,25 +54,24 @@ msgstr ":mod:`code`" msgid ":ref:`compileall `" msgstr ":ref:`compileall `" -#: ../../library/cmdline.rst:15 msgid "``cProfile``: see :ref:`profiling.tracing `" msgstr "" +"``cProfile``: :ref:`profiling.tracing ` を参照してくだ" +"さい。" #: ../../library/cmdline.rst:16 msgid ":ref:`dis `" msgstr ":ref:`dis `" -#: ../../library/cmdline.rst:17 msgid ":ref:`doctest `" -msgstr "" +msgstr ":ref:`doctest `" #: ../../library/cmdline.rst:18 msgid ":mod:`!encodings.rot_13`" msgstr ":mod:`!encodings.rot_13`" -#: ../../library/cmdline.rst:19 msgid ":ref:`ensurepip `" -msgstr "" +msgstr ":ref:`ensurepip `" #: ../../library/cmdline.rst:20 msgid ":mod:`filecmp`" @@ -94,53 +93,44 @@ msgstr ":ref:`gzip `" msgid ":ref:`http.server `" msgstr ":ref:`http.server `" -#: ../../library/cmdline.rst:25 msgid ":ref:`idlelib `" -msgstr "" +msgstr ":ref:`idlelib `" #: ../../library/cmdline.rst:26 msgid ":ref:`inspect `" msgstr ":ref:`inspect `" -#: ../../library/cmdline.rst:27 msgid ":ref:`json `" -msgstr "" +msgstr ":ref:`json `" -#: ../../library/cmdline.rst:28 msgid ":ref:`mimetypes `" -msgstr "" +msgstr ":ref:`mimetypes `" -#: ../../library/cmdline.rst:29 msgid ":ref:`pdb `" -msgstr "" +msgstr ":ref:`pdb `" -#: ../../library/cmdline.rst:30 msgid ":ref:`pickle `" -msgstr "" +msgstr ":ref:`pickle `" #: ../../library/cmdline.rst:31 msgid ":ref:`pickletools `" msgstr ":ref:`pickletools `" -#: ../../library/cmdline.rst:32 msgid ":ref:`platform `" -msgstr "" +msgstr ":ref:`platform `" #: ../../library/cmdline.rst:33 msgid ":mod:`poplib`" msgstr ":mod:`poplib`" -#: ../../library/cmdline.rst:34 msgid ":ref:`profiling.sampling `" -msgstr "" +msgstr ":ref:`profiling.sampling `" -#: ../../library/cmdline.rst:35 msgid ":ref:`profiling.tracing `" -msgstr "" +msgstr ":ref:`profiling.tracing `" -#: ../../library/cmdline.rst:36 msgid ":ref:`pstats `" -msgstr "" +msgstr ":ref:`pstats `" #: ../../library/cmdline.rst:37 msgid ":ref:`py_compile `" @@ -174,9 +164,8 @@ msgstr ":ref:`site `" msgid ":ref:`sqlite3 `" msgstr ":ref:`sqlite3 `" -#: ../../library/cmdline.rst:45 msgid ":ref:`symtable `" -msgstr "" +msgstr ":ref:`symtable `" #: ../../library/cmdline.rst:46 msgid ":ref:`sysconfig `" @@ -218,13 +207,11 @@ msgstr ":ref:`unittest `" msgid ":ref:`uuid `" msgstr ":ref:`uuid `" -#: ../../library/cmdline.rst:56 msgid ":ref:`venv `" -msgstr "" +msgstr ":ref:`venv `" -#: ../../library/cmdline.rst:57 msgid ":ref:`webbrowser `" -msgstr "" +msgstr ":ref:`webbrowser `" #: ../../library/cmdline.rst:58 msgid ":ref:`zipapp `" diff --git a/library/cmdlinelibs.po b/library/cmdlinelibs.po index 521d9c6ea..6a5d19441 100644 --- a/library/cmdlinelibs.po +++ b/library/cmdlinelibs.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/cmdlinelibs.rst:5 diff --git a/library/code.po b/library/code.po index 0dacf7534..e5029d982 100644 --- a/library/code.po +++ b/library/code.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/code.rst:2 @@ -56,13 +56,16 @@ msgstr "" "``'__name__'`` が ``'__console__'`` に設定され、キー ``'__doc__'`` が " "``None`` に設定された新しく作られた辞書です。" -#: ../../library/code.rst:25 msgid "" "Note that functions and classes objects created under an :class:`!" "InteractiveInterpreter` instance will belong to the namespace specified by " "*locals*. They are only pickleable if *locals* is the namespace of an " "existing module." msgstr "" +":class:`!InteractiveInterpreter` インスタンスで作成した関数やクラスのオブジェ" +"クトは、*locals* で指定した名前空間に属します。\n" +"これらを pickle 化できるのは、*locals* が既存のモジュールの名前空間である場合" +"だけです。" #: ../../library/code.rst:34 msgid "" @@ -165,12 +168,16 @@ msgstr "" "で、 *symbol* は ``'single'`` です。あるいくつかのことが起きる可能性がありま" "す:" -#: ../../library/code.rst:94 msgid "" "The input is incorrect; :func:`compile_command` raised an exception " "(usually :exc:`SyntaxError`). A syntax traceback will be printed by calling " "the :meth:`showsyntaxerror` method. :meth:`runsource` returns ``False``." msgstr "" +"入力が不正で、:func:`compile_command` が例外 (通常は :exc:`SyntaxError`) を送" +"出した場合。\n" +":meth:`showsyntaxerror` メソッドを呼び出して構文エラーのトレースバックを表示" +"します。\n" +":meth:`runsource` は ``False`` を返します。" #: ../../library/code.rst:99 msgid "" @@ -219,7 +226,6 @@ msgstr "" "る可能性がありますし、常に捕らえることができるとは限りません。呼び出し側はそ" "れを処理するために準備しておくべきです。" -#: ../../library/code.rst:123 msgid "" "Display the syntax error that just occurred. This does not display a stack " "trace because there isn't one for syntax errors. If *filename* is given, it " @@ -227,11 +233,13 @@ msgid "" "Python's parser, because it always uses ``''`` when reading from a " "string. The output is written by the :meth:`write` method." msgstr "" -"起きたばかりの構文エラーを表示します。複数の構文エラーに対して一つあるのでは" -"ないため、これはスタックトレースを表示しません。 *filename* が与えられた場合" -"は、Pythonのパーサが与えるデフォルトのファイル名の代わりに例外の中へ入れられ" -"ます。なぜなら、文字列から読み込んでいるときはパーサは常に ``''`` を" -"使うからです。出力は :meth:`write` メソッドによって書き込まれます。" +"起きたばかりの構文エラーを表示します。\n" +"構文エラーにはスタックトレースがないため、スタックトレースは表示しません。\n" +"*filename* を指定すると、Python のパーサーが提供するデフォルトのファイル名の" +"代わりに、その値を例外に設定します。\n" +"これは、文字列から読み込む場合にパーサーが常に ``''`` を使うためで" +"す。\n" +"出力は :meth:`write` メソッドで書き込まれます。" #: ../../library/code.rst:132 msgid "" @@ -306,7 +314,6 @@ msgstr "バナーの表示を抑制するには、空の文字列を渡してく msgid "Print an exit message when exiting." msgstr "終了時に、終了メッセージを表示します。" -#: ../../library/code.rst:177 msgid "" "Push a line of source text to the interpreter. The line should not have a " "trailing newline; it may have internal newlines. The line is appended to a " @@ -318,14 +325,18 @@ msgid "" "is required, ``False`` if the line was dealt with in some way (this is the " "same as :meth:`!runsource`)." msgstr "" -"ソーステキストの一行をインタープリターへ送ります。その行の末尾に改行がついて" -"いてはいけません。内部に改行を持っているかもしれません。その行はバッファへ追" -"加され、ソースとして連結されたバッファの内容が渡されインタープリターの :meth:" -"`~InteractiveInterpreter.runsource` メソッドが呼び出されます。コマンドが実行" -"されたか、有効であることをこれが示している場合は、バッファはリセットされま" -"す。そうでなければ、コマンドが不完全で、その行が付加された後のままバッファは" -"残されます。さらに入力が必要ならば、戻り値は ``True`` です。その行がある方法" -"で処理されたならば、 ``False`` です(これは :meth:`!runsource` と同じです)。" +"ソーステキストの1行をインタープリターへ送ります。\n" +"``line`` の末尾に改行を含めてはいけませんが、内部には含められます。\n" +"その行はバッファに追加され、バッファの内容を連結したものをソースとして、\n" +"インタープリターの :meth:`~InteractiveInterpreter.runsource` メソッドが呼び出" +"されます。\n" +"この呼び出しの結果が、コマンドが実行されたか無効だったことを示す場合、バッ" +"ファはリセットされます。\n" +"そうでない場合、コマンドは不完全なので、その行を追加した後のバッファがそのま" +"ま保持されます。\n" +"さらに入力が必要な場合は ``True`` を返し、その行が何らかの形で処理された場合" +"は ``False`` を返します\n" +"(これは :meth:`!runsource` と同じです)。" #: ../../library/code.rst:189 msgid "Remove any unhandled source text from the input buffer." diff --git a/library/codecs.po b/library/codecs.po index b0f5020cc..b7a6f5caa 100644 --- a/library/codecs.po +++ b/library/codecs.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/codecs.rst:2 @@ -95,7 +95,6 @@ msgstr "" "を送出することを意味します。codec エラー処理についてのより詳しい情報は :ref:" "`codec-base-classes` を参照してください。" -#: ../../library/codecs.rst:54 msgid "" "Return a mapping suitable for encoding with a custom single-byte encoding. " "Given a :class:`str` *string* of up to 256 characters representing a " @@ -103,6 +102,11 @@ msgid "" "``EncodingMap`` or a :class:`dictionary ` mapping character ordinals " "to byte values. Raises a :exc:`TypeError` on invalid input." msgstr "" +"独自の 1 バイトエンコーディングでのエンコードに適したマッピングを返します。\n" +"デコード用のテーブルを表す最大 256 文字の :class:`str` *string* を渡すと、コ" +"ンパクトな内部マッピングオブジェクト ``EncodingMap``、または文字のコードポイ" +"ントをバイト値に対応付ける :class:`辞書 ` を返します。\n" +"入力が不正な場合は :exc:`TypeError` を送出します。" #: ../../library/codecs.rst:60 msgid "The full details for each codec can also be looked up directly:" @@ -116,7 +120,6 @@ msgstr "" "Python codec レジストリから codec 情報を探し、以下で定義するような :class:" "`CodecInfo` オブジェクトを返します。" -#: ../../library/codecs.rst:67 msgid "" "This function first normalizes the *encoding*: all ASCII letters are " "converted to lower case, spaces are replaced with hyphens. Then encoding is " @@ -125,18 +128,28 @@ msgid "" "exc:`LookupError` is raised. Otherwise, the :class:`CodecInfo` object is " "stored in the cache and returned to the caller." msgstr "" +"まず *encoding* を正規化します。\n" +"ASCII の英字をすべて小文字に変換し、スペースをハイフンに置き換えます。\n" +"次に、レジストリのキャッシュでエンコーディングを検索します。\n" +"見つからなければ、登録された検索関数のリストを順に調べます。\n" +":class:`CodecInfo` オブジェクトが見つからない場合は :exc:`LookupError` を送出" +"します。\n" +"見つかった場合は、その :class:`CodecInfo` オブジェクトをキャッシュに保存して" +"呼び出し元に返します。" -#: ../../library/codecs.rst:74 msgid "" "Any characters except ASCII letters and digits and a dot are converted to " "underscore." msgstr "" +"ASCII の英字、数字、ピリオド以外の文字をすべてアンダースコアに変換するように" +"なりました。" -#: ../../library/codecs.rst:77 msgid "" "No characters are converted to underscore anymore. Spaces are converted to " "hyphens." msgstr "" +"アンダースコアへの変換を行わなくなりました。\n" +"スペースはハイフンに変換します。" #: ../../library/codecs.rst:84 msgid "" @@ -270,19 +283,25 @@ msgstr "" "次のように、適切な codec 検索関数を登録することで、カスタムの codecs を利用す" "ることができます。" -#: ../../library/codecs.rst:175 msgid "" "Register a codec search function. Search functions are expected to take one " "argument, being the encoding name in all lower case letters with spaces " "converted to hyphens, and return a :class:`CodecInfo` object. In case a " "search function cannot find a given encoding, it should return ``None``." msgstr "" +"codec 検索関数を登録します。\n" +"検索関数は引数を 1 つ受け取り、:class:`CodecInfo` オブジェクトを返す必要があ" +"ります。\n" +"引数は、小文字に変換され、スペースをハイフンに置き換えたエンコーディング名で" +"す。\n" +"指定されたエンコーディングが見つからない場合は ``None`` を返してください。" -#: ../../library/codecs.rst:184 msgid "" "Unregister a codec search function and clear the registry's cache. If the " "search function is not registered, do nothing." msgstr "" +"codec 検索関数の登録を解除し、レジストリのキャッシュを消去します。\n" +"検索関数が登録されていなければ何もしません。" #: ../../library/codecs.rst:190 msgid "" @@ -339,19 +358,19 @@ msgstr "" "は ``'strict'`` で、エンコード時にエラーがあれば :exc:`ValueError` を送出しま" "す。" -#: ../../library/codecs.rst:216 msgid "" "*buffering* has the same meaning as for the built-in :func:`open` function. " "It defaults to -1 which means that the default buffer size will be used." msgstr "" +"*buffering* は組み込み関数 :func:`open` の引数と同じ意味です。\n" +"デフォルトは -1 で、デフォルトのバッファサイズを使うことを意味します。" #: ../../library/codecs.rst:219 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` モードは削除されました。" -#: ../../library/codecs.rst:224 msgid ":func:`codecs.open` has been superseded by :func:`open`." -msgstr "" +msgstr ":func:`codecs.open` は :func:`open` に置き換えられました。" #: ../../library/codecs.rst:229 msgid "" @@ -390,13 +409,18 @@ msgstr "" "は ``'strict'`` で、エンコード時にエラーがあれば :exc:`ValueError` を送出しま" "す。" -#: ../../library/codecs.rst:248 msgid "" "Uses an incremental encoder to iteratively encode the input provided by " "*iterator*. *iterator* must yield :class:`str` objects. This function is a :" "term:`generator`. The *errors* argument (as well as any other keyword " "argument) is passed through to the incremental encoder." msgstr "" +"インクリメンタル・エンコーダを使って、*iterator* から得られる入力を順にエン" +"コードします。\n" +"*iterator* は :class:`str` オブジェクトを yield する必要があります。\n" +"この関数は :term:`ジェネレーター ` です。\n" +"*errors* 引数とその他のキーワード引数は、インクリメンタル・エンコーダにそのま" +"ま渡されます。" #: ../../library/codecs.rst:253 msgid "" @@ -409,42 +433,49 @@ msgstr "" "従って、 ``base64_codec`` のようなバイトからバイトへのエンコーダはサポートし" "ていません。" -#: ../../library/codecs.rst:260 msgid "" "Uses an incremental decoder to iteratively decode the input provided by " "*iterator*. *iterator* must yield :class:`bytes` objects. This function is " "a :term:`generator`. The *errors* argument (as well as any other keyword " "argument) is passed through to the incremental decoder." msgstr "" +"インクリメンタル・デコーダを使って、*iterator* から得られる入力を順にデコード" +"します。\n" +"*iterator* は :class:`bytes` オブジェクトを yield する必要があります。\n" +"この関数は :term:`ジェネレーター ` です。\n" +"*errors* 引数とその他のキーワード引数は、インクリメンタル・デコーダにそのまま" +"渡されます。" -#: ../../library/codecs.rst:265 msgid "" "This function requires that the codec accept :class:`bytes` objects to " "decode. Therefore it does not support text-to-text encoders such as " "``rot_13``, although ``rot_13`` may be used equivalently with :func:" "`iterencode`." msgstr "" -"この関数では、コーデックはエンコードする :class:`bytes` オブジェクトを受け付" -"ける必要があります。\n" -"従って、 ``rot_13`` のようなテキストからテキストへのエンコーダが :func:" -"`iterencode` で同等に使えるとしても、この関数ではサポートしていません。" +"この関数では、コーデックはデコードする :class:`bytes` オブジェクトを受け付け" +"る必要があります。\n" +"従って、``rot_13`` のようなテキストからテキストへのエンコーダはサポートしませ" +"んが、\n" +"``rot_13`` は :func:`iterencode` で同じように使えます。" -#: ../../library/codecs.rst:273 msgid "" "Return a :class:`tuple` containing the raw bytes of *buffer*, a :ref:`buffer-" "compatible object ` or :class:`str` (encoded to UTF-8 before " "processing), and their length in bytes." msgstr "" +":ref:`バッファ互換のオブジェクト ` または :class:`str` である " +"*buffer* の生のバイト列と、そのバイト数を含む :class:`tuple` を返します。\n" +"``str`` は処理の前に UTF-8 でエンコードします。" -#: ../../library/codecs.rst:277 msgid "The *errors* argument is ignored." -msgstr "" +msgstr "*errors* 引数は無視します。" -#: ../../library/codecs.rst:279 msgid "" ">>> codecs.readbuffer_encode(b\"Zito\")\n" "(b'Zito', 4)" msgstr "" +">>> codecs.readbuffer_encode(b\"Zito\")\n" +"(b'Zito', 4)" #: ../../library/codecs.rst:285 msgid "" @@ -479,12 +510,14 @@ msgstr "" msgid "Codec Base Classes" msgstr "Codec 基底クラス" -#: ../../library/codecs.rst:316 msgid "" "The :mod:`!codecs` module defines a set of base classes which define the " "interfaces for working with codec objects, and can also be used as the basis " "for custom codec implementations." msgstr "" +":mod:`!codecs` モジュールは、codec オブジェクトを扱うためのインターフェースを" +"定義する基底クラス群を提供します。\n" +"独自の codec を実装する基盤としても使えます。" #: ../../library/codecs.rst:320 msgid "" @@ -512,11 +545,12 @@ msgstr "" "エラー処理の簡便化と標準化のため、コーデックは、*errors* 文字列引数を指定した" "場合に別のエラー処理を行うような仕組みを実装してもかまいません\\:" -#: ../../library/codecs.rst:353 msgid "" "The following error handlers can be used with all Python :ref:`standard-" "encodings` codecs:" msgstr "" +"次のエラーハンドラは、Python のすべての :ref:`standard-encodings` の codec で" +"使えます。" #: ../../library/codecs.rst:359 ../../library/codecs.rst:402 #: ../../library/codecs.rst:422 @@ -557,24 +591,31 @@ msgstr "" msgid "``'replace'``" msgstr "``'replace'``" -#: ../../library/codecs.rst:369 msgid "" "Replace with a replacement marker. On encoding, use ``?`` (ASCII character). " "On decoding, use ``�`` (U+FFFD, the official REPLACEMENT CHARACTER). " "Implemented in :func:`replace_errors`." msgstr "" +"代替の文字に置き換えます。\n" +"エンコード時は ASCII 文字の ``?``、デコード時は ``�`` (U+FFFD、正式名称 " +"REPLACEMENT CHARACTER) を使います。\n" +":func:`replace_errors` に実装されています。" #: ../../library/codecs.rst:375 msgid "``'backslashreplace'``" msgstr "``'backslashreplace'``" -#: ../../library/codecs.rst:375 msgid "" "Replace with backslashed escape sequences. On encoding, use hexadecimal form " "of Unicode code point with formats :samp:`\\\\x{hh}` :samp:`\\\\u{xxxx}` :" "samp:`\\\\U{xxxxxxxx}`. On decoding, use hexadecimal form of byte value with " "format :samp:`\\\\x{hh}`. Implemented in :func:`backslashreplace_errors`." msgstr "" +"バックスラッシュによるエスケープシーケンスに置き換えます。\n" +"エンコード時は、Unicode コードポイントを :samp:`\\\\x{hh}`、:samp:`\\" +"\\u{xxxx}`、:samp:`\\\\U{xxxxxxxx}` の形式の 16 進表現にします。\n" +"デコード時は、バイト値を :samp:`\\\\x{hh}` の形式の 16 進表現にします。\n" +":func:`backslashreplace_errors` に実装されています。" #: ../../library/codecs.rst:384 msgid "``'surrogateescape'``" @@ -592,33 +633,38 @@ msgstr "" "ンドラが使用されると、このコードは同じバイト列に戻されます。 (詳しくは :pep:" "`383` を参照。)" -#: ../../library/codecs.rst:398 msgid "" "The following error handlers are only applicable to encoding (within :term:" "`text encodings `):" msgstr "" +"次のエラーハンドラは、:term:`テキストエンコーディング ` のエン" +"コード時にのみ使えます。" #: ../../library/codecs.rst:404 msgid "``'xmlcharrefreplace'``" msgstr "``'xmlcharrefreplace'``" -#: ../../library/codecs.rst:404 msgid "" "Replace with XML/HTML numeric character reference, which is a decimal form " "of Unicode code point with format :samp:`&#{num};`. Implemented in :func:" "`xmlcharrefreplace_errors`." msgstr "" +"Unicode コードポイントを :samp:`&#{num};` の形式で 10 進数で表した、XML/HTML " +"の数値文字参照に置き換えます。\n" +":func:`xmlcharrefreplace_errors` に実装されています。" #: ../../library/codecs.rst:410 msgid "``'namereplace'``" msgstr "``'namereplace'``" -#: ../../library/codecs.rst:410 msgid "" "Replace with ``\\N{...}`` escape sequences, what appears in the braces is " "the Name property from Unicode Character Database. Implemented in :func:" "`namereplace_errors`." msgstr "" +"``\\N{...}`` のエスケープシーケンスに置き換えます。\n" +"波括弧の中には Unicode 文字データベースの Name プロパティを使います。\n" +":func:`namereplace_errors` に実装されています。" #: ../../library/codecs.rst:419 msgid "" @@ -637,32 +683,36 @@ msgstr "``'surrogatepass'``" msgid "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" msgstr "utf-8, utf-16, utf-32, utf-16-be, utf-16-le, utf-32-be, utf-32-le" -#: ../../library/codecs.rst:424 msgid "" "Allow encoding and decoding surrogate code point (``U+D800`` - ``U+DFFF``) " "as normal code point. Otherwise these codecs treat the presence of surrogate " "code point in :class:`str` as an error." msgstr "" +"サロゲートコードポイント (``U+D800``~``U+DFFF``) を通常のコードポイントとし" +"てエンコード・デコードできるようにします。\n" +"この指定がなければ、これらの codec は :class:`str` にサロゲートコードポイント" +"が含まれているとエラーとして扱います。" #: ../../library/codecs.rst:431 msgid "The ``'surrogateescape'`` and ``'surrogatepass'`` error handlers." msgstr "``'surrogateescape'`` および ``'surrogatepass'`` エラーハンドラ。" -#: ../../library/codecs.rst:434 msgid "" "The ``'surrogatepass'`` error handler now works with utf-16\\* and utf-32\\* " "codecs." msgstr "" +"``'surrogatepass'`` エラーハンドラが utf-16\\* と utf-32\\* の codec でも使え" +"るようになりました。" #: ../../library/codecs.rst:438 msgid "The ``'namereplace'`` error handler." msgstr "``'namereplace'`` エラーハンドラです。" -#: ../../library/codecs.rst:441 msgid "" "The ``'backslashreplace'`` error handler now works with decoding and " "translating." msgstr "" +"``'backslashreplace'`` エラーハンドラがデコードと文字変換にも対応しました。" #: ../../library/codecs.rst:445 msgid "" @@ -707,15 +757,14 @@ msgstr "" "対位置として扱われます。境界の外側にある位置を返した場合には :exc:" "`IndexError` が送出されます。" -#: ../../library/codecs.rst:466 msgid "" "Decoding and translating works similarly, except :exc:`UnicodeDecodeError` " "or :exc:`UnicodeTranslateError` will be passed to the handler and that the " "replacement from the error handler will be put into the output directly." msgstr "" -"デコードと翻訳の動作は似ていますが、エラーハンドラに渡されるのが :exc:" -"`UnicodeDecodeError` か :exc:`UnicodeTranslateError` である点と、エラーハンド" -"ラの置換した内容が直接出力されるという点が異なります。" +"デコードと文字変換も同様に動作しますが、ハンドラには :exc:" +"`UnicodeDecodeError` または :exc:`UnicodeTranslateError` が渡されます。\n" +"また、エラーハンドラが返す置換内容は、そのまま出力に入れられます。" #: ../../library/codecs.rst:471 msgid "" @@ -739,76 +788,84 @@ msgid "" "level functions:" msgstr "以下の標準エラーハンドラも、モジュールレベルの関数として利用できます。" -#: ../../library/codecs.rst:485 msgid "Implements the ``'strict'`` error handling." -msgstr "" +msgstr "``'strict'`` エラー処理を実装します。" -#: ../../library/codecs.rst:487 msgid "Each encoding or decoding error raises a :exc:`UnicodeError`." msgstr "" +"エンコードまたはデコードのエラーごとに :exc:`UnicodeError` を送出します。" -#: ../../library/codecs.rst:492 msgid "Implements the ``'ignore'`` error handling." -msgstr "" +msgstr "``'ignore'`` エラー処理を実装します。" -#: ../../library/codecs.rst:494 msgid "" "Malformed data is ignored; encoding or decoding is continued without further " "notice." msgstr "" +"不正な形式のデータを無視し、通知せずにエンコードまたはデコードを続けます。" -#: ../../library/codecs.rst:500 msgid "Implements the ``'replace'`` error handling." -msgstr "" +msgstr "``'replace'`` エラー処理を実装します。" -#: ../../library/codecs.rst:502 msgid "" "Substitutes ``?`` (ASCII character) for encoding errors or ``�`` (U+FFFD, " "the official REPLACEMENT CHARACTER) for decoding errors." msgstr "" +"エンコードエラーでは ASCII 文字の ``?``、デコードエラーでは ``�`` (U+FFFD、正" +"式名称 REPLACEMENT CHARACTER) に置き換えます。" -#: ../../library/codecs.rst:508 msgid "Implements the ``'backslashreplace'`` error handling." -msgstr "" +msgstr "``'backslashreplace'`` エラー処理を実装します。" -#: ../../library/codecs.rst:510 msgid "" "Malformed data is replaced by a backslashed escape sequence. On encoding, " "use the hexadecimal form of Unicode code point with formats :samp:`\\\\x{hh}" "` :samp:`\\\\u{xxxx}` :samp:`\\\\U{xxxxxxxx}`. On decoding, use the " "hexadecimal form of byte value with format :samp:`\\\\x{hh}`." msgstr "" +"不正な形式のデータを、バックスラッシュによるエスケープシーケンスに置き換えま" +"す。\n" +"エンコード時は、Unicode コードポイントを :samp:`\\\\x{hh}`、:samp:`\\" +"\\u{xxxx}`、:samp:`\\\\U{xxxxxxxx}` の形式の 16 進表現にします。\n" +"デコード時は、バイト値を :samp:`\\\\x{hh}` の形式の 16 進表現にします。" -#: ../../library/codecs.rst:516 msgid "Works with decoding and translating." -msgstr "" +msgstr "デコードと文字変換にも対応しました。" -#: ../../library/codecs.rst:522 msgid "" "Implements the ``'xmlcharrefreplace'`` error handling (for encoding within :" "term:`text encoding` only)." msgstr "" +"``'xmlcharrefreplace'`` エラー処理を実装します (:term:`テキストエンコーディン" +"グ ` のエンコード時のみ)。" -#: ../../library/codecs.rst:525 msgid "" "The unencodable character is replaced by an appropriate XML/HTML numeric " "character reference, which is a decimal form of Unicode code point with " "format :samp:`&#{num};` ." msgstr "" +"エンコードできない文字を、対応する XML/HTML の数値文字参照に置き換えます。\n" +"これは Unicode コードポイントを :samp:`&#{num};` の形式で 10 進数で表したもの" +"です。" -#: ../../library/codecs.rst:532 msgid "" "Implements the ``'namereplace'`` error handling (for encoding within :term:" "`text encoding` only)." msgstr "" +"``'namereplace'`` エラー処理を実装します (:term:`テキストエンコーディング " +"` のエンコード時のみ)。" -#: ../../library/codecs.rst:535 msgid "" "The unencodable character is replaced by a ``\\N{...}`` escape sequence. The " "set of characters that appear in the braces is the Name property from " "Unicode Character Database. For example, the German lowercase letter ``'ß'`` " "will be converted to byte sequence ``\\N{LATIN SMALL LETTER SHARP S}`` ." msgstr "" +"エンコードできない文字を ``\\N{...}`` のエスケープシーケンスに置き換えま" +"す。\n" +"波括弧の中には Unicode 文字データベースの Name プロパティを使います。\n" +"例えば、ドイツ語の小文字 ``'ß'`` はバイト列 ``\\N{LATIN SMALL LETTER SHARP S}" +"`` に変換されます。" #: ../../library/codecs.rst:546 msgid "Stateless Encoding and Decoding" @@ -1135,12 +1192,15 @@ msgstr "" msgid "Stream Encoding and Decoding" msgstr "ストリームのエンコードとデコード" -#: ../../library/codecs.rst:737 msgid "" "The :class:`StreamWriter` and :class:`StreamReader` classes provide generic " "working interfaces which can be used to implement new encoding submodules " "very easily. See :mod:`!encodings.utf_8` for an example of how this is done." msgstr "" +":class:`StreamWriter` クラスと :class:`StreamReader` クラスは、汎用的な動作イ" +"ンターフェースを提供し、新しいエンコーディングのサブモジュールを簡単に実装で" +"きるようにします。\n" +"実装例は :mod:`!encodings.utf_8` を参照してください。" #: ../../library/codecs.rst:745 msgid "StreamWriter Objects" @@ -1202,12 +1262,15 @@ msgstr "" msgid "Writes the object's contents encoded to the stream." msgstr "*object* の内容をエンコードしてストリームに書き出します。" -#: ../../library/codecs.rst:778 msgid "" "Writes the concatenated iterable of strings to the stream (possibly by " "reusing the :meth:`write` method). Infinite or very large iterables are not " "supported. The standard bytes-to-bytes codecs do not support this method." msgstr "" +"文字列のイテラブルの内容を連結してストリームに書き込みます (:meth:`write` メ" +"ソッドを再利用する場合もあります)。\n" +"無限のイテラブルや非常に大きいイテラブルはサポートしません。\n" +"標準のバイト列からバイト列への codec では、このメソッドをサポートしません。" #: ../../library/codecs.rst:786 ../../library/codecs.rst:881 msgid "Resets the codec buffers used for keeping internal state." @@ -1299,18 +1362,16 @@ msgid "Decodes data from the stream and returns the resulting object." msgstr "" "ストリームからのデータをデコードし、デコード済のオブジェクトを返します。" -#: ../../library/codecs.rst:834 msgid "" "The *chars* argument indicates the number of decoded code points or bytes to " "return. The :func:`read` method will never return more data than requested, " "but it might return less, if there is not enough available." msgstr "" -"*chars* 引数は、いくつのデコードされたコードポイントまたはバイト列を返すかを" -"表します。 :func:`read` メソッドは、要求された数以上のデータを返すことはあり" -"ませんが、データがそれより少ない場合には要求された数未満のデータを返す場合が" -"あります。" +"*chars* 引数は、デコードして返すコードポイント数またはバイト数を指定しま" +"す。\n" +":func:`read` メソッドは要求された量を超えるデータを返すことはありません。\n" +"利用できるデータが足りない場合は、それより少ない量を返すことがあります。" -#: ../../library/codecs.rst:839 msgid "" "The *size* argument indicates the approximate maximum number of encoded " "bytes or code points to read for decoding. The decoder can modify this " @@ -1318,10 +1379,12 @@ msgid "" "much as possible. This parameter is intended to prevent having to decode " "huge files in one step." msgstr "" -"*size* 引数は、デコード用に読み込むエンコードされたバイト列またはコードポイン" -"トの、およその最大バイト数を表します。デコーダはこの値を適切な値に変更できま" -"す。デフォルト値 -1 の場合、可能な限り多くのデータを読み込みます。この引数の" -"目的は、巨大なファイルの一括デコードを防ぐことにあります。" +"*size* 引数は、デコードのために読み込むエンコード済みデータの、およその最大バ" +"イト数または最大コードポイント数を指定します。\n" +"デコーダは必要に応じてこの設定を変更できます。\n" +"デフォルト値 -1 は、可能な限り多く読み込んでデコードすることを意味します。\n" +"このパラメーターは、巨大なファイルを一度にデコードせずに済むようにするための" +"ものです。" #: ../../library/codecs.rst:846 msgid "" @@ -1454,13 +1517,17 @@ msgstr "" ":class:`StreamRecoder` はデータをあるエンコーディングから別のエンコーディング" "に変換します。異なるエンコーディング環境を扱うとき、便利な場合があります。" -#: ../../library/codecs.rst:928 msgid "" "Creates a :class:`StreamRecoder` instance which implements a two-way " "conversion: *encode* and *decode* work on the frontend — the data visible to " "code calling :meth:`~StreamReader.read` and :meth:`~StreamWriter.write`, " "while *Reader* and *Writer* work on the backend — the data in *stream*." msgstr "" +"双方向の変換を行う :class:`StreamRecoder` インスタンスを作成します。\n" +"*encode* と *decode* はフロントエンド、つまり :meth:`~StreamReader.read` や :" +"meth:`~StreamWriter.write` を呼び出すコードから見えるデータを扱います。\n" +"一方、*Reader* と *Writer* はバックエンド、つまり *stream* 内のデータを扱いま" +"す。" #: ../../library/codecs.rst:934 msgid "" @@ -1529,10 +1596,9 @@ msgstr "" "また、バイト列から文字列オブジェクトを再生成することは *デコード* と呼ばれま" "す。\n" "テキストをシリアライズするコーデックには多くの種類があります。\n" -"それらは、集合的に term:`テキストエンコーディング ` と呼ばれま" -"す。" +"それらは、集合的に :term:`テキストエンコーディング ` と呼ばれ" +"ます。" -#: ../../library/codecs.rst:968 msgid "" "The simplest text encoding (called ``'latin-1'`` or ``'iso-8859-1'``) maps " "the code points 0--255 to the bytes ``0x0``--``0xff``, which means that a " @@ -1545,12 +1611,13 @@ msgstr "" "最も単純なテキストエンコーディング (``'latin-1'`` または ``'iso-8859-1'``) で" "は、0--255 の範囲にあるコードポイントを ``0x0``--``0xff`` のバイトにマップし" "ます。\n" -"つまり、この codec では ``U+00FF`` 以上のコードポイントを含む文字列オブジェク" -"トをエンコードすることはできません。\n" +"つまり、この codec では ``U+00FF`` より大きいのコードポイントを含む文字列オブ" +"ジェクトをエンコードすることはできません。\n" "このようなエンコード処理をしようとすると、次のように :exc:" -"`UnicodeEncodeError` が送出されます (エラーメッセージの細かところは異なる場合" -"があります。): ``UnicodeEncodeError: 'latin-1' codec can't encode character " -"'\\u1234' in position 3: ordinal not in range(256)`` 。" +"`UnicodeEncodeError` が送出されます (エラーメッセージの細かいところは異なる場" +"合があります。\n" +"): ``UnicodeEncodeError: 'latin-1' codec can't encode character '\\u1234' in " +"position 3: ordinal not in range(256)`` 。" #: ../../library/codecs.rst:976 msgid "" @@ -1716,7 +1783,6 @@ msgstr "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK" msgid "INVERTED QUESTION MARK" msgstr "INVERTED QUESTION MARK" -#: ../../library/codecs.rst:1056 msgid "" "in iso-8859-1), this increases the probability that a ``utf-8-sig`` encoding " "can be correctly guessed from the byte sequence. So here the BOM is not used " @@ -1727,19 +1793,21 @@ msgid "" "three bytes if they appear as the first three bytes in the file. In UTF-8, " "the use of the BOM is discouraged and should generally be avoided." msgstr "" -"のようになる)ので、``utf-8-sig`` エンコーディングがバイト列から正しく推測され" -"る確率を高めます。つまりここでは BOM はバイト列を生成する際のバイト順を決定で" -"きるように使われているのではなく、エンコーディングを推測する助けになる印とし" -"て使われているのです。``utf-8-sig`` codec はエンコーディングの際ファイルに最" -"初の3文字として ``0xef``, ``0xbb``, ``0xbf`` を書き込みます。デコーディングの" -"際はファイルの先頭に現れたこれら3バイトはスキップします。UTF-8 では BOM の使" -"用は推奨されておらず、一般的には避けるべきです。" +"に対応します)。\n" +"このため、バイト列から ``utf-8-sig`` エンコーディングを正しく推測できる確率が" +"高まります。\n" +"ここで BOM はバイト順を判定するためではなく、エンコーディングの推測を助ける印" +"として使われます。\n" +"``utf-8-sig`` codec は、エンコード時にファイルの最初の 3 バイトとして " +"``0xef``、``0xbb``、``0xbf`` を書き込みます。\n" +"デコード時は、これらがファイルの最初の 3 バイトに現れた場合にスキップしま" +"す。\n" +"UTF-8 での BOM の使用は推奨されず、通常は避けてください。" #: ../../library/codecs.rst:1069 msgid "Standard Encodings" msgstr "標準エンコーディング" -#: ../../library/codecs.rst:1071 msgid "" "Python comes with a number of codecs built-in, either implemented as C " "functions or with dictionaries as mapping tables. The following table lists " @@ -1751,21 +1819,34 @@ msgid "" "normalized by :func:`~encodings.normalize_encoding`. For example, " "``'utf-8'`` is a valid alias for the ``'utf_8'`` codec." msgstr "" +"Python には、C 関数やマッピングテーブルとしての辞書で実装された多数の codec " +"が組み込まれています。\n" +"次の表には、codec の名前、よく使われる別名、そのエンコーディングが主に使われ" +"る言語を示します。\n" +"別名と言語のどちらも網羅的な一覧ではありません。\n" +"大文字・小文字だけが異なる名前や、アンダースコアの代わりにスペースやハイフン" +"を使った名前も、有効な別名です。\n" +":func:`~encodings.normalize_encoding` で正規化すると同じ名前になるためで" +"す。\n" +"例えば ``'utf-8'`` は ``'utf_8'`` codec の有効な別名です。" -#: ../../library/codecs.rst:1083 msgid "" "The below table lists the most common aliases, for a complete list refer to " "the source :source:`aliases.py ` file." msgstr "" +"次の表には、よく使われる別名を示します。\n" +"完全な一覧はソースファイル :source:`aliases.py ` を" +"参照してください。" -#: ../../library/codecs.rst:1086 msgid "" "On Windows, ``cpXXX`` codecs are available for all code pages. But only " "codecs listed in the following table are guaranteed to exist on other " "platforms." msgstr "" +"Windows では、すべてのコードページに対して ``cpXXX`` codec を利用できます。\n" +"ただし、他のプラットフォームでも存在が保証されるのは、次の表にある codec だけ" +"です。" -#: ../../library/codecs.rst:1092 msgid "" "Some common encodings can bypass the codecs lookup machinery to improve " "performance. These optimization opportunities are only recognized by CPython " @@ -1780,8 +1861,8 @@ msgstr "" "別しない) 別名に対してのみです: utf-8, utf8, latin-1, latin1, iso-8859-1, " "iso8859-1, mbcs (Windows のみ), ascii, us-ascii, utf-16, utf16, utf-32, " "utf32 およびダッシュの代わりにアンダースコアを用いたもの。\n" -"これらのエンコーディングの別のつづりを使用すると実行時間の低下を招くかもしれ" -"ません。" +"これらのエンコーディングの別のつづりを使用すると実行が遅くなることがありま" +"す。" #: ../../library/codecs.rst:1100 msgid "Optimization opportunity recognized for us-ascii." @@ -1950,10 +2031,8 @@ msgstr "cp775" msgid "IBM775" msgstr "IBM775" -#: ../../library/codecs.rst:1145 ../../library/codecs.rst:1212 -#: ../../library/codecs.rst:1279 msgid "Baltic languages" -msgstr "バルト沿岸国" +msgstr "バルト諸語" #: ../../library/codecs.rst:1147 msgid "cp850" @@ -1984,10 +2063,8 @@ msgstr "cp855" msgid "855, IBM855" msgstr "855, IBM855" -#: ../../library/codecs.rst:1151 ../../library/codecs.rst:1199 -#: ../../library/codecs.rst:1264 ../../library/codecs.rst:1301 msgid "Belarusian, Bulgarian, Macedonian, Russian, Serbian" -msgstr "" +msgstr "ベラルーシ語、ブルガリア語、マケドニア語、ロシア語、セルビア語" #: ../../library/codecs.rst:1154 msgid "cp856" @@ -2011,9 +2088,8 @@ msgstr "トルコ語" msgid "cp858" msgstr "cp858" -#: ../../library/codecs.rst:1158 msgid "858, IBM00858" -msgstr "" +msgstr "858, IBM00858" #: ../../library/codecs.rst:1160 msgid "cp860" @@ -2075,9 +2151,8 @@ msgstr "cp865" msgid "865, IBM865" msgstr "865, IBM865" -#: ../../library/codecs.rst:1170 msgid "Danish, Norwegian" -msgstr "デンマーク、ノルウェー" +msgstr "デンマーク語、ノルウェー語" #: ../../library/codecs.rst:1172 msgid "cp866" @@ -2115,9 +2190,8 @@ msgstr "cp875" msgid "cp932" msgstr "cp932" -#: ../../library/codecs.rst:1180 msgid "932, ms932, mskanji, ms-kanji, windows-31j" -msgstr "" +msgstr "932, ms932, mskanji, ms-kanji, windows-31j" #: ../../library/codecs.rst:1180 ../../library/codecs.rst:1216 #: ../../library/codecs.rst:1218 ../../library/codecs.rst:1220 @@ -2153,9 +2227,8 @@ msgstr "950, ms950" msgid "cp1006" msgstr "cp1006" -#: ../../library/codecs.rst:1187 msgid "Urdu" -msgstr "Urdu" +msgstr "ウルドゥー語" #: ../../library/codecs.rst:1189 msgid "cp1026" @@ -2181,9 +2254,8 @@ msgstr "ウクライナ語" msgid "cp1140" msgstr "cp1140" -#: ../../library/codecs.rst:1195 msgid "IBM01140" -msgstr "" +msgstr "IBM01140" #: ../../library/codecs.rst:1197 msgid "cp1250" @@ -2257,9 +2329,8 @@ msgstr "cp1258" msgid "windows-1258" msgstr "windows-1258" -#: ../../library/codecs.rst:1214 msgid "Vietnamese" -msgstr "ベトナム" +msgstr "ベトナム語" #: ../../library/codecs.rst:1216 msgid "euc_jp" @@ -2421,9 +2492,8 @@ msgstr "iso8859_3" msgid "iso-8859-3, latin3, L3" msgstr "iso-8859-3, latin3, L3" -#: ../../library/codecs.rst:1260 msgid "Esperanto, Maltese" -msgstr "エスペラント、マルタ" +msgstr "エスペラント、マルタ語" #: ../../library/codecs.rst:1262 msgid "iso8859_4" @@ -2433,9 +2503,8 @@ msgstr "iso8859_4" msgid "iso-8859-4, latin4, L4" msgstr "iso-8859-4, latin4, L4" -#: ../../library/codecs.rst:1262 msgid "Northern Europe" -msgstr "" +msgstr "北ヨーロッパ" #: ../../library/codecs.rst:1264 msgid "iso8859_5" @@ -2557,9 +2626,8 @@ msgstr "koi8_r" msgid "koi8_t" msgstr "koi8_t" -#: ../../library/codecs.rst:1291 msgid "Tajik" -msgstr "タジク" +msgstr "タジク語" #: ../../library/codecs.rst:1295 msgid "koi8_u" @@ -2573,9 +2641,8 @@ msgstr "kz1048" msgid "kz_1048, strk1048_2002, rk1048" msgstr "kz_1048, strk1048_2002, rk1048" -#: ../../library/codecs.rst:1297 ../../library/codecs.rst:1315 msgid "Kazakh" -msgstr "カザフ" +msgstr "カザフ語" #: ../../library/codecs.rst:1301 msgid "mac_cyrillic" @@ -2605,9 +2672,8 @@ msgstr "maciceland" msgid "mac_latin2" msgstr "mac_latin2" -#: ../../library/codecs.rst:1308 msgid "maclatin2, maccentraleurope, mac_centeuro" -msgstr "" +msgstr "maclatin2, maccentraleurope, mac_centeuro" #: ../../library/codecs.rst:1311 msgid "mac_roman" @@ -2725,17 +2791,15 @@ msgstr "U7, unicode-1-1-utf-7" msgid "utf_8" msgstr "utf_8" -#: ../../library/codecs.rst:1341 msgid "U8, UTF, utf8, cp65001" -msgstr "" +msgstr "U8, UTF, utf8, cp65001" #: ../../library/codecs.rst:1343 msgid "utf_8_sig" msgstr "utf_8_sig" -#: ../../library/codecs.rst:1343 msgid "utf8-sig" -msgstr "" +msgstr "utf8-sig" #: ../../library/codecs.rst:1346 msgid "" @@ -2747,13 +2811,13 @@ msgstr "" "``U+DFFF``) がエンコードされることを許可しなくなりました。utf-32\\* デコーダ" "は、サロゲートコードポイントに対応するバイト列をデコードしなくなりました。" -#: ../../library/codecs.rst:1352 msgid "``cp65001`` is now an alias to ``utf_8``." -msgstr "" +msgstr "``cp65001`` は ``utf_8`` の別名になりました。" -#: ../../library/codecs.rst:1355 msgid "On Windows, ``cpXXX`` codecs are now available for all code pages." msgstr "" +"Windows では、すべてのコードページに対して ``cpXXX`` codec を利用できるように" +"なりました。" #: ../../library/codecs.rst:1360 msgid "Python Specific Encodings" @@ -2802,11 +2866,13 @@ msgstr "" ":rfc:`3490` の実装です。 :mod:`encodings.idna` も参照してください。 " "``errors='strict'`` のみがサポートされています。" -#: ../../library/codecs.rst:1389 msgid "" "This codec builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" +"この codec は ``punycode`` を基にしています。\n" +"そのアルゴリズムは入力が長くなると処理効率が大きく低下するため、信頼できない" +"入力の長さを制限してください。" #: ../../library/codecs.rst:1396 msgid "mbcs" @@ -2850,30 +2916,33 @@ msgstr "punycode" msgid "Implement :rfc:`3492`. Stateful codecs are not supported." msgstr ":rfc:`3492` の実装です。ステートフル codecs は、サポートされません。" -#: ../../library/codecs.rst:1414 msgid "" "The decoding and encoding algorithms scale poorly, so limit the length of " "untrusted input." msgstr "" +"デコードとエンコードのアルゴリズムは、入力が長くなると処理効率が大きく低下す" +"るため、信頼できない入力の長さを制限してください。" #: ../../library/codecs.rst:1420 msgid "raw_unicode_escape" msgstr "raw_unicode_escape" -#: ../../library/codecs.rst:1420 msgid "" "Latin-1 encoding with :samp:`\\\\u{XXXX}` and :samp:`\\\\U{XXXXXXXX}` for " "other code points. Existing backslashes are not escaped in any way. It is " "used in the Python pickle protocol." msgstr "" +"Latin-1 エンコーディングを使い、その範囲外のコードポイントを :samp:`\\" +"\\u{XXXX}` と :samp:`\\\\U{XXXXXXXX}` で表します。\n" +"既存のバックスラッシュはエスケープしません。\n" +"Python の pickle プロトコルで使われています。" #: ../../library/codecs.rst:1430 msgid "undefined" msgstr "undefined" -#: ../../library/codecs.rst:1430 msgid "This Codec should only be used for testing purposes." -msgstr "" +msgstr "この codec はテスト目的にのみ使ってください。" #: ../../library/codecs.rst:1434 msgid "" @@ -2898,9 +2967,8 @@ msgstr "" "ドからデコードします。実際には、Python のソースコードはデフォルトでは UTF-8 " "を使用することに注意してください。" -#: ../../library/codecs.rst:1451 msgid "\"unicode_internal\" codec is removed." -msgstr "" +msgstr "\"unicode_internal\" codec は削除されました。" #: ../../library/codecs.rst:1458 msgid "Binary Transforms" @@ -3047,11 +3115,9 @@ msgstr "" "バイナリ変換のエイリアスが復活しました。(訳注: 2.x にはあったエイリアス。3.2 " "でエイリアスは復活しなかった。)" -#: ../../library/codecs.rst:1514 msgid "Standalone Codec Functions" -msgstr "" +msgstr "単独の codec 関数" -#: ../../library/codecs.rst:1516 msgid "" "The following functions provide encoding and decoding functionality similar " "to codecs, but are not available as named codecs through :func:`codecs." @@ -3059,30 +3125,35 @@ msgid "" "mod:`pickle`) and behave similarly to the ``string_escape`` codec that was " "removed in Python 3." msgstr "" +"次の関数は codec と同様のエンコード・デコード機能を提供しますが、:func:" +"`codecs.encode` や :func:`codecs.decode` で名前を指定して使う codec としては" +"利用できません。\n" +"内部で (例えば :mod:`pickle` から) 使われており、Python 3 で削除された " +"``string_escape`` codec と同様に動作します。" -#: ../../library/codecs.rst:1523 msgid "" "Encode *input* using escape sequences. Similar to how :func:`repr` on bytes " "produces escaped byte values." msgstr "" +"エスケープシーケンスを使って *input* をエンコードします。\n" +"バイト列に対する :func:`repr` が、エスケープしたバイト値を生成するのと同様で" +"す。" -#: ../../library/codecs.rst:1526 msgid "*input* must be a :class:`bytes` object." -msgstr "" +msgstr "*input* は :class:`bytes` オブジェクトでなければなりません。" -#: ../../library/codecs.rst:1528 ../../library/codecs.rst:1537 msgid "" "Returns a tuple ``(output, length)`` where *output* is a :class:`bytes` " "object and *length* is the number of bytes consumed." msgstr "" +"タプル ``(output, length)`` を返します。\n" +"*output* は :class:`bytes` オブジェクト、*length* は消費したバイト数です。" -#: ../../library/codecs.rst:1533 msgid "Decode *input* from escape sequences back to the original bytes." -msgstr "" +msgstr "*input* のエスケープシーケンスをデコードし、元のバイト列に戻します。" -#: ../../library/codecs.rst:1535 msgid "*input* must be a :term:`bytes-like object`." -msgstr "" +msgstr "*input* は :term:`bytes-like object` でなければなりません。" #: ../../library/codecs.rst:1544 msgid "Text Transforms" @@ -3122,17 +3193,14 @@ msgstr "" "``rot13`` エイリアスが復活しました。(訳注: 2.x にはあったエイリアス。3.2 でエ" "イリアスは復活しなかった。)" -#: ../../library/codecs.rst:1568 msgid ":mod:`!encodings` --- Encodings package" -msgstr "" +msgstr ":mod:`!encodings` --- エンコーディングパッケージ" -#: ../../library/codecs.rst:1573 msgid "This module implements the following functions:" -msgstr "" +msgstr "このモジュールは次の関数を実装しています。" -#: ../../library/codecs.rst:1577 msgid "Normalize encoding name *encoding*." -msgstr "" +msgstr "エンコーディング名 *encoding* を正規化します。" #: ../../library/codecs.rst:1579 msgid "" @@ -3142,23 +3210,23 @@ msgid "" "-;#'`` becomes ``'_'``." msgstr "" -#: ../../library/codecs.rst:1584 msgid "Note that *encoding* should be ASCII only." -msgstr "" +msgstr "*encoding* には ASCII 文字だけを使ってください。" -#: ../../library/codecs.rst:1588 msgid "" "The following functions should not be used directly, except for testing " "purposes; :func:`codecs.lookup` should be used instead." msgstr "" +"次の関数は、テスト目的を除いて直接使わないでください。\n" +"代わりに :func:`codecs.lookup` を使ってください。" -#: ../../library/codecs.rst:1594 msgid "" "Search for the codec module corresponding to the given encoding name " "*encoding*." msgstr "" +"指定したエンコーディング名 *encoding* に対応する codec モジュールを検索しま" +"す。" -#: ../../library/codecs.rst:1597 msgid "" "This function first normalizes the *encoding* using :func:" "`normalize_encoding`, then looks for a corresponding alias. It attempts to " @@ -3167,40 +3235,45 @@ msgid "" "``getregentry()`` function that returns a :class:`codecs.CodecInfo` object, " "the codec is cached and returned." msgstr "" +"まず :func:`normalize_encoding` で *encoding* を正規化し、対応する別名を探し" +"ます。\n" +"別名または正規化した名前を使い、encodings パッケージから codec モジュールのイ" +"ンポートを試みます。\n" +"モジュールが見つかり、:class:`codecs.CodecInfo` オブジェクトを返す有効な " +"``getregentry()`` 関数が定義されていれば、codec をキャッシュして返します。" -#: ../../library/codecs.rst:1604 msgid "" "If the codec module defines a ``getaliases()`` function any returned aliases " "are registered for future use." msgstr "" +"codec モジュールに ``getaliases()`` 関数が定義されていれば、返された別名を今" +"後使えるよう登録します。" -#: ../../library/codecs.rst:1610 msgid "" "Search for a Windows code page encoding *encoding* of the form ``cpXXXX``." msgstr "" +"``cpXXXX`` 形式の Windows コードページエンコーディング *encoding* を検索しま" +"す。" -#: ../../library/codecs.rst:1612 msgid "" "If the code page is valid and supported, return a :class:`codecs.CodecInfo` " "object for it." msgstr "" +"コードページが有効でサポートされていれば、その :class:`codecs.CodecInfo` オブ" +"ジェクトを返します。" -#: ../../library/codecs.rst:1615 ../../library/codecs.rst:1705 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/codecs.rst:1620 msgid "This module implements the following exception:" -msgstr "" +msgstr "このモジュールは次の例外を実装しています。" -#: ../../library/codecs.rst:1624 msgid "Raised when a codec is invalid or incompatible." -msgstr "" +msgstr "codec が無効または非互換の場合に送出されます。" -#: ../../library/codecs.rst:1628 msgid "" ":mod:`!encodings.idna` --- Internationalized Domain Names in Applications" -msgstr "" +msgstr ":mod:`!encodings.idna` --- アプリケーションにおける国際化ドメイン名" #: ../../library/codecs.rst:1633 msgid "" @@ -3215,17 +3288,20 @@ msgstr "" "ています。このモジュールは ``punycode`` エンコーディングおよび :mod:" "`stringprep` の上に構築されています。" -#: ../../library/codecs.rst:1640 msgid "" "This module builds on ``punycode``, whose algorithms scale poorly, so limit " "the length of untrusted input." msgstr "" +"このモジュールは ``punycode`` を基にしています。\n" +"そのアルゴリズムは入力が長くなると処理効率が大きく低下するため、信頼できない" +"入力の長さを制限してください。" -#: ../../library/codecs.rst:1643 msgid "" "If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the " "third-party :pypi:`idna` module." msgstr "" +":rfc:`5891` と :rfc:`5895` の IDNA 2008 規格が必要な場合は、サードパーティー" +"の :pypi:`idna` モジュールを使ってください。" #: ../../library/codecs.rst:1646 msgid "" @@ -3273,8 +3349,8 @@ msgstr "" "ベルを要求通りに ACE に変換します。逆に、入力のバイト文字列を ``.`` 区切り文" "字でラベルに分解し、 ACE ラベルを Unicode に変換します。さらに、 :mod:" "`socket` モジュールは Unicode ホスト名を ACE に透過的に変換するため、アプリ" -"ケーションはホスト名を :mod:`socket` モジュールに渡す際にホスト名の変換に煩わ" -"されることがありません。その上で、ホスト名を関数パラメタとして持つ、 :mod:" +"ケーションはホスト名を ``socket`` モジュールに渡す際にホスト名の変換に煩わさ" +"れることがありません。その上で、ホスト名を関数パラメタとして持つ、 :mod:" "`http.client` や :mod:`ftplib` のようなモジュールでは Unicode ホスト名を受理" "します (:mod:`http.client` でもまた、 :mailheader:`Host` フィールドにある " "IDNA ホスト名を、フィールド全体を送信する場合に透過的に送信します)。" @@ -3289,13 +3365,16 @@ msgstr "" "変換は行われません: こうしたホスト名をユーザに提供したいアプリケーションで" "は、Unicode にデコードしてやる必要があります。" -#: ../../library/codecs.rst:1674 msgid "" "The module :mod:`!encodings.idna` also implements the nameprep procedure, " "which performs certain normalizations on host names, to achieve case-" "insensitivity of international domain names, and to unify similar " "characters. The nameprep functions can be used directly if desired." msgstr "" +":mod:`!encodings.idna` モジュールは nameprep 手順も実装しています。\n" +"これは、国際化ドメイン名の大文字・小文字を区別しないようにし、似た文字を統一" +"するため、ホスト名に一定の正規化を行います。\n" +"必要なら nameprep 関数を直接使うこともできます。" #: ../../library/codecs.rst:1682 msgid "" @@ -3317,29 +3396,25 @@ msgstr "" msgid "Convert a label to Unicode, as specified in :rfc:`3490`." msgstr ":rfc:`3490` 仕様に従ってラベルを Unicode に変換します。" -#: ../../library/codecs.rst:1698 msgid ":mod:`!encodings.mbcs` --- Windows ANSI codepage" -msgstr "" +msgstr ":mod:`!encodings.mbcs` --- Windows ANSI コードページ" -#: ../../library/codecs.rst:1703 msgid "This module implements the ANSI codepage (CP_ACP)." -msgstr "" +msgstr "このモジュールは ANSI コードページ (CP_ACP) を実装しています。" -#: ../../library/codecs.rst:1707 msgid "" "Before 3.2, the *errors* argument was ignored; ``'replace'`` was always used " "to encode, and ``'ignore'`` to decode." msgstr "" -"3.2 以前は *errors* 引数は無視されました; エンコードには常に ``'replace'`` " -"が、デコードには ``'ignore'`` が使われました。" +"3.2 より前は *errors* 引数が無視され、エンコードには常に ``'replace'``、デ" +"コードには ``'ignore'`` が使われていました。" #: ../../library/codecs.rst:1711 msgid "Support any error handler." msgstr "任意のエラーハンドラのサポート。" -#: ../../library/codecs.rst:1716 msgid ":mod:`!encodings.utf_8_sig` --- UTF-8 codec with BOM signature" -msgstr "" +msgstr ":mod:`!encodings.utf_8_sig` --- BOM シグネチャ付き UTF-8 codec" #: ../../library/codecs.rst:1721 msgid "" @@ -3375,42 +3450,34 @@ msgstr "ストリーム" msgid "stackable" msgstr "スタック可能" -#: ../../library/codecs.rst:341 msgid "strict" -msgstr "" +msgstr "strict" -#: ../../library/codecs.rst:341 ../../library/codecs.rst:393 -#: ../../library/codecs.rst:416 msgid "error handler's name" -msgstr "" +msgstr "エラーハンドラ名" #: ../../library/codecs.rst:341 msgid "ignore" msgstr "ignore" -#: ../../library/codecs.rst:341 msgid "replace" -msgstr "" +msgstr "replace" -#: ../../library/codecs.rst:341 msgid "backslashreplace" -msgstr "" +msgstr "backslashreplace" -#: ../../library/codecs.rst:341 msgid "surrogateescape" -msgstr "" +msgstr "surrogateescape" #: ../../library/codecs.rst:341 msgid "? (question mark)" msgstr "? (クエスチョンマーク)" -#: ../../library/codecs.rst:341 msgid "replacement character" -msgstr "" +msgstr "置換文字" -#: ../../library/codecs.rst:341 msgid "\\ (backslash)" -msgstr "" +msgstr "\\ (バックスラッシュ)" #: ../../library/codecs.rst:341 ../../library/codecs.rst:393 msgid "escape sequence" @@ -3428,14 +3495,11 @@ msgstr "\\u" msgid "\\U" msgstr "\\U" -#: ../../library/codecs.rst:393 msgid "xmlcharrefreplace" -msgstr "" +msgstr "xmlcharrefreplace" -#: ../../library/codecs.rst:393 msgid "namereplace" -msgstr "" +msgstr "namereplace" -#: ../../library/codecs.rst:416 msgid "surrogatepass" -msgstr "" +msgstr "surrogatepass" diff --git a/library/codeop.po b/library/codeop.po index a48deff6c..cd04d9cc8 100644 --- a/library/codeop.po +++ b/library/codeop.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/codeop.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!codeop` --- Python コードをコンパイルする" msgid "**Source code:** :source:`Lib/codeop.py`" msgstr "**ソースコード:** :source:`Lib/codeop.py`" -#: ../../library/codeop.rst:11 msgid "" "The :mod:`!codeop` module provides utilities upon which the Python read-eval-" "print loop can be emulated, as is done in the :mod:`code` module. As a " @@ -38,6 +37,12 @@ msgid "" "include such a loop in your program you probably want to use the :mod:`code` " "module instead." msgstr "" +":mod:`!codeop` モジュールは、:mod:`code` モジュールが行っているように、" +"Python の read-eval-print (読み込み・評価・表示) ループをエミュレートするため" +"の機能を提供します。\n" +"通常、このモジュールを直接使う必要はありません。\n" +"そのようなループをプログラムに組み込むには、代わりに :mod:`code` モジュールを" +"使うとよいでしょう。" #: ../../library/codeop.rst:17 msgid "There are two parts to this job:" @@ -51,19 +56,19 @@ msgstr "" "入力の一行がPythonの文として完全であるかどうかを見分けられること: 簡単に言え" "ば、次が '``>>>``' か、あるいは '``...``' かどうかを見分けます。" -#: ../../library/codeop.rst:22 msgid "" "Remembering which future statements the user has entered, so subsequent " "input can be compiled with these in effect." msgstr "" -"どのfuture文をユーザが入力したのかを覚えていること。したがって、実質的にそれ" -"に続く入力をこれらとともにコンパイルすることができます。" +"ユーザーが入力した future 文を記憶し、それ以降の入力を、その指定が有効な状態" +"でコンパイルできること。" -#: ../../library/codeop.rst:25 msgid "" "The :mod:`!codeop` module provides a way of doing each of these things, and " "a way of doing them both." msgstr "" +":mod:`!codeop` モジュールは、これらを個別に行う手段と、両方をまとめて行う手段" +"を提供します。" #: ../../library/codeop.rst:28 msgid "To do just the former:" @@ -118,7 +123,6 @@ msgstr "" "えば、バックスラッシュの後ろに改行が2つあって、その後ろにゴミがあるかもしれま" "せん。パーサのAPIがより良くなればすぐに、この挙動は修正されるでしょう。" -#: ../../library/codeop.rst:58 msgid "" "Instances of this class have :meth:`~object.__call__` methods identical in " "signature to the built-in function :func:`compile`, but with the difference " @@ -126,13 +130,12 @@ msgid "" "statement, the instance 'remembers' and compiles all subsequent program " "texts with the statement in force." msgstr "" -"このクラスのインスタンスは組み込み関数 :func:`compile` とシグネチャが一致す" -"る :meth:`~object.__call__` メソッドを持っていますが、インスタンスが :mod:" -"`__future__` 文を含むプログラムテキストをコンパイルする場合は、インスタンスは" -"有効なその文とともに続くすべてのプログラムテキストを'覚えていて'コンパイルす" -"るという違いがあります。" +"このクラスのインスタンスは、組み込み関数 :func:`compile` と同じシグネチャの :" +"meth:`~object.__call__` メソッドを持ちます。\n" +"ただし、:mod:`__future__` 文を含むプログラムテキストをコンパイルすると、その" +"文の指定を記憶し、以後のすべてのプログラムテキストにもその指定を適用してコン" +"パイルします。" -#: ../../library/codeop.rst:67 msgid "" "Instances of this class have :meth:`~object.__call__` methods identical in " "signature to :func:`compile_command`; the difference is that if the instance " @@ -140,8 +143,8 @@ msgid "" "'remembers' and compiles all subsequent program texts with the statement in " "force." msgstr "" -"このクラスのインスタンスは :func:`compile_command` とシグネチャが一致する :" -"meth:`~object.__call__` メソッドを持っています。インスタンスが :mod:" -"`__future__` 文を含むプログラムテキストをコンパイルする場合に、インスタンスは" -"有効なその文とともにそれに続くすべてのプログラムテキストを'覚えていて'コンパ" -"イルするという違いがあります。" +"このクラスのインスタンスは、:func:`compile_command` と同じシグネチャの :meth:" +"`~object.__call__` メソッドを持ちます。\n" +"ただし、:mod:`__future__` 文を含むプログラムテキストをコンパイルすると、その" +"文の指定を記憶し、以後のすべてのプログラムテキストにもその指定を適用してコン" +"パイルします。" diff --git a/library/collections.abc.po b/library/collections.abc.po index fe34a6b57..4667d6021 100644 --- a/library/collections.abc.po +++ b/library/collections.abc.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/collections.abc.rst:2 @@ -54,13 +54,16 @@ msgstr "" ":func:`issubclass` や :func:`isinstance` を使ったインターフェースに対するテス" "トは、以下の3つのいずれかの方法で動作します。" -#: ../../library/collections.abc.rst:27 msgid "" "A newly written class can inherit directly from one of the abstract base " "classes. The class must supply the required abstract methods. The " "remaining mixin methods come from inheritance and can be overridden if " "desired. Other methods may be added as needed:" msgstr "" +"新しく作るクラスは、抽象基底クラスのいずれかを直接継承できます。\n" +"そのクラスでは、必須の抽象メソッドを実装しなければなりません。\n" +"残りの mixin メソッドは継承され、必要に応じてオーバーライドできます。\n" +"他のメソッドも必要に応じて追加できます:" #: ../../library/collections.abc.rst:32 msgid "" @@ -90,7 +93,6 @@ msgstr "" ">>> isinstance(C(), Sequence)\n" "True" -#: ../../library/collections.abc.rst:47 msgid "" "Existing classes and built-in classes can be registered as \"virtual " "subclasses\" of the ABCs. Those classes should define the full API " @@ -99,6 +101,13 @@ msgid "" "determine whether the full interface is supported. The exception to this " "rule is for methods that are automatically inferred from the rest of the API:" msgstr "" +"既存のクラスや組み込みクラスは、ABC の「仮想サブクラス」として登録できま" +"す。\n" +"それらのクラスでは、すべての抽象メソッドとすべての mixin メソッドを含む完全" +"な API を定義する必要があります。\n" +"これにより、利用者は :func:`issubclass` や :func:`isinstance` によるテスト" +"で、完全なインターフェースがサポートされているかどうかを判断できます。\n" +"ただし、API の他の部分から自動的に導かれるメソッドは例外です:" #: ../../library/collections.abc.rst:55 msgid "" @@ -148,11 +157,13 @@ msgstr "" "`reversed` 関数は自動的に ``__getitem__`` と ``__len__`` を使うようにフォール" "バックするからです。" -#: ../../library/collections.abc.rst:79 msgid "" "Some simple interfaces are directly recognizable by the presence of the " "required methods (unless those methods have been set to :const:`None`):" msgstr "" +"単純なインターフェースの中には、必要なメソッドが存在することによって直接認識" +"できるものもあります (ただし、それらのメソッドが :const:`None` に設定されてい" +"ない場合に限ります):" #: ../../library/collections.abc.rst:82 msgid "" @@ -368,12 +379,14 @@ msgstr ":class:`Set`" msgid ":class:`Collection`" msgstr ":class:`Collection`" -#: ../../library/collections.abc.rst:143 msgid "" "``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " "``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " "``__rxor__`` and ``isdisjoint``" msgstr "" +"``__le__``, ``__lt__``, ``__eq__``, ``__ne__``, ``__gt__``, ``__ge__``, " +"``__and__``, ``__or__``, ``__sub__``, ``__rsub__``, ``__xor__``, " +"``__rxor__``, ``isdisjoint``" #: ../../library/collections.abc.rst:148 msgid ":class:`MutableSet`" @@ -433,9 +446,8 @@ msgstr ":class:`MappingView`" msgid ":class:`Sized`" msgstr ":class:`Sized`" -#: ../../library/collections.abc.rst:165 msgid "``__init__``, ``__len__`` and ``__repr__``" -msgstr "" +msgstr "``__init__``, ``__len__``, ``__repr__``" #: ../../library/collections.abc.rst:166 msgid ":class:`ItemsView`" @@ -645,10 +657,9 @@ msgstr "" #: ../../library/collections.abc.rst:265 msgid "ABCs for read-only and mutable :term:`sequences `." msgstr "" -"読み出し専用の :term:`シーケンス ` およびミュータブルな :term:`シー" -"ケンス ` の ABC です。" +"読み出し専用の :term:`シーケンス ` およびミュータブルなシーケンス" +"の ABC です。" -#: ../../library/collections.abc.rst:267 msgid "" "Implementation note: Some of the mixin methods, such as :meth:`~container." "__iter__`, :meth:`~object.__reversed__`, and :meth:`~sequence.index` make " @@ -658,31 +669,35 @@ msgid "" "the underlying method is linear (as it would be with a linked list), the " "mixins will have quadratic performance and will likely need to be overridden." msgstr "" +"実装上の注意: :meth:`~container.__iter__`、:meth:`~object.__reversed__`、:" +"meth:`~sequence.index` などの mixin メソッドは、基となる :meth:`~object." +"__getitem__` メソッドを繰り返し呼び出します。\n" +"そのため、:meth:`~object.__getitem__` が定数時間でアクセスできるように実装さ" +"れていれば、mixin メソッドの実行時間は線形になります。\n" +"しかし、基となるメソッドの実行時間が (連結リストの場合のように) 線形なら、" +"mixin メソッドの実行時間は二次になり、オーバーライドが必要になる可能性が高く" +"なります。" -#: ../../library/collections.abc.rst:279 msgid "Return first index of *value*." -msgstr "" +msgstr "*value* が最初に現れるインデックスを返します。" -#: ../../library/collections.abc.rst:281 msgid "Raises :exc:`ValueError` if the value is not present." -msgstr "" +msgstr "値が存在しない場合は :exc:`ValueError` を送出します。" -#: ../../library/collections.abc.rst:283 msgid "" "Supporting the *start* and *stop* arguments is optional, but recommended." -msgstr "" +msgstr "*start* と *stop* 引数のサポートは任意ですが、推奨されます。" -#: ../../library/collections.abc.rst:285 msgid "" "The :meth:`~sequence.index` method gained support for the *stop* and *start* " "arguments." msgstr "" +":meth:`~sequence.index` メソッドが *stop* と *start* 引数をサポートするように" +"なりました。" -#: ../../library/collections.abc.rst:289 msgid "The :class:`ByteString` ABC has been deprecated." -msgstr "" +msgstr ":class:`ByteString` ABC は非推奨になりました。" -#: ../../library/collections.abc.rst:292 msgid "" "Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj`` " "implements the :ref:`buffer protocol ` at runtime. For use in " @@ -690,8 +705,12 @@ msgid "" "specifies the types your code supports (e.g., ``bytes | bytearray | " "memoryview``)." msgstr "" +"実行時に ``obj`` が :ref:`バッファプロトコル ` を実装している" +"かどうかを調べるには、``isinstance(obj, collections.abc.Buffer)`` を使ってく" +"ださい。\n" +"型アノテーションでは、:class:`Buffer` を使うか、コードがサポートする型を明示" +"した共用体 (例: ``bytes | bytearray | memoryview``) を使ってください。" -#: ../../library/collections.abc.rst:298 msgid "" ":class:`!ByteString` was originally intended to be an abstract class that " "would serve as a supertype of both :class:`bytes` and :class:`bytearray`. " @@ -701,20 +720,28 @@ msgid "" "also never understood as subtypes of :class:`!ByteString` (either at runtime " "or by static type checkers)." msgstr "" +":class:`!ByteString` は当初、:class:`bytes` と :class:`bytearray` の両方の上" +"位型となる抽象クラスとして意図されていました。\n" +"しかし、この ABC はメソッドを一つも持たないため、あるオブジェクトが :class:`!" +"ByteString` のインスタンスだと分かっても、そのオブジェクトに関する有用な情報" +"は何も得られませんでした。\n" +":class:`memoryview` など、他の一般的なバッファ型も、実行時にも静的型チェッ" +"カーによっても :class:`!ByteString` のサブタイプとして認識されることはありま" +"せんでした。" -#: ../../library/collections.abc.rst:306 msgid "See :pep:`PEP 688 <688#current-options>` for more details." -msgstr "" +msgstr "詳細は :pep:`PEP 688 <688#current-options>` を参照してください。" -#: ../../library/collections.abc.rst:311 msgid "ABCs for read-only and mutable :ref:`sets `." -msgstr "読み出し専用でミュータブルな :ref:`集合 ` の ABC です。" +msgstr "" +"読み出し専用の :ref:`集合 ` とミュータブルな集合のための ABC で" +"す。" #: ../../library/collections.abc.rst:316 msgid "ABCs for read-only and mutable :term:`mappings `." msgstr "" -"読み出し専用の :term:`マッピング ` およびミュータブルな :term:`マッ" -"ピング ` の ABC です。" +"読み出し専用の :term:`マッピング ` およびミュータブルなマッピングの " +"ABC です。" #: ../../library/collections.abc.rst:323 msgid "" @@ -731,15 +758,13 @@ msgstr "" ":keyword:`await` で使用できる :term:`awaitable` オブジェクトの ABC です。カス" "タムの実装は、:meth:`~object.__await__` メソッドを提供しなければなりません。" -#: ../../library/collections.abc.rst:331 msgid "" ":term:`Coroutine ` objects and instances of the :class:" "`~collections.abc.Coroutine` ABC are all instances of this ABC." msgstr "" -":class:`~collections.abc.Coroutine` ABC の :term:`Coroutine ` オブ" -"ジェクトとインスタンスは、すべてこの ABC のインスタンスです。" +":term:`コルーチン ` オブジェクトと :class:`~collections.abc." +"Coroutine` ABC のインスタンスは、いずれもこの ABC のインスタンスです。" -#: ../../library/collections.abc.rst:335 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :deco:`types.coroutine`) are *awaitables*, even though they " @@ -747,6 +772,12 @@ msgid "" "Awaitable)`` for them will return ``False``. Use :func:`inspect.isawaitable` " "to detect them." msgstr "" +"CPython では、ジェネレータベースのコルーチン (:deco:`types.coroutine` でデコ" +"レートされた :term:`ジェネレータ `) は、:meth:`~object.__await__` " +"メソッドを持たなくても *awaitable* です。\n" +"それらに対して ``isinstance(gencoro, Awaitable)`` を使うと ``False`` が返りま" +"す。\n" +"検出には :func:`inspect.isawaitable` を使ってください。" #: ../../library/collections.abc.rst:345 msgid "" @@ -763,7 +794,6 @@ msgstr "" "`Coroutine` のすべてのインスタンスは、 :class:`Awaitable` のインスタンスでも" "あります。" -#: ../../library/collections.abc.rst:353 msgid "" "In CPython, generator-based coroutines (:term:`generators ` " "decorated with :deco:`types.coroutine`) are *awaitables*, even though they " @@ -771,16 +801,21 @@ msgid "" "Coroutine)`` for them will return ``False``. Use :func:`inspect.isawaitable` " "to detect them." msgstr "" +"CPython では、ジェネレータベースのコルーチン (:deco:`types.coroutine` でデコ" +"レートされた :term:`ジェネレータ `) は、:meth:`~object.__await__` " +"メソッドを持たなくても *awaitable* です。\n" +"それらに対して ``isinstance(gencoro, Coroutine)`` を使うと ``False`` が返りま" +"す。\n" +"検出には :func:`inspect.isawaitable` を使ってください。" -#: ../../library/collections.abc.rst:359 msgid "" "See :ref:`annotating-generators-and-coroutines` for details on using :class:" "`!Coroutine` in type annotations. The variance and order of type parameters " "correspond to those of :class:`Generator`." msgstr "" ":class:`!Coroutine` を型アノテーションで使う方法の詳細は、 :ref:`annotating-" -"generators-and-coroutines` を参照してください。型パラメータの意味と順序は :" -"class:`Generator` と同様です。" +"generators-and-coroutines` を参照してください。\n" +"型パラメータの変性と順序は :class:`Generator` と同様です。" #: ../../library/collections.abc.rst:368 msgid "" @@ -943,7 +978,6 @@ msgstr "" "meth:`~object.__le__` と :meth:`~object.__ge__` だけを再定義すれば、その他の" "演算は自動的に追随します。" -#: ../../library/collections.abc.rst:456 msgid "" "The :class:`Set` mixin provides a :meth:`!_hash` method to compute a hash " "value for the set; however, :meth:`~object.__hash__` is not defined because " @@ -951,6 +985,12 @@ msgid "" "using mixins, inherit from both :class:`Set` and :class:`Hashable`, then " "define ``__hash__ = Set._hash``." msgstr "" +":class:`Set` mixin は集合のハッシュ値を計算する :meth:`!_hash` メソッドを提供" +"します。\n" +"しかし、すべての集合が :term:`ハッシュ可能 ` またはイミュータブルで" +"あるとは限らないため、:meth:`~object.__hash__` は定義されていません。\n" +"mixin を使って集合をハッシュ可能にするには、:class:`Set` と :class:" +"`Hashable` の両方を継承し、``__hash__ = Set._hash`` を定義してください。" #: ../../library/collections.abc.rst:464 msgid "" diff --git a/library/collections.po b/library/collections.po index 1ce5234de..365d962a0 100644 --- a/library/collections.po +++ b/library/collections.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/collections.rst:2 @@ -184,17 +184,18 @@ msgstr "" "サブコンテキストを作成するメソッド、最初のマッピング以外のすべてにアクセスす" "るためのプロパティがあります:" -#: ../../library/collections.rst:67 msgid "" "A user updateable list of mappings. The list is ordered from first-searched " "to last-searched. It is the only stored state and can be modified to change " "which mappings are searched. The list should always contain at least one " "mapping." msgstr "" -"マッピングのユーザがアップデートできるリストです。このリストは最初に探される" -"ものから最後に探されるものの順に並んでいます。これが唯一のソートされた状態で" -"あり、変更してマッピングが探される順番を変更できます。このリストは常に一つ以" -"上のマッピングを含んでいなければなりません。" +"ユーザーが更新できるマッピングのリストです。\n" +"マッピングは最初に検索されるものから最後に検索されるものの順に並んでいま" +"す。\n" +"保存される状態はこのリストだけであり、リストを変更すると検索対象のマッピング" +"を変更できます。\n" +"リストには常に少なくとも一つのマッピングが含まれていなければなりません。" #: ../../library/collections.rst:74 msgid "" @@ -358,7 +359,6 @@ msgid "" msgstr "" "ユーザ指定のコマンドライン引数、環境変数、デフォルト値、の順に優先させる例::" -#: ../../library/collections.rst:156 msgid "" "import os, argparse\n" "\n" @@ -375,6 +375,20 @@ msgid "" "print(combined['color'])\n" "print(combined['user'])" msgstr "" +"import os, argparse\n" +"\n" +"defaults = {'color': 'red', 'user': 'guest'}\n" +"\n" +"parser = argparse.ArgumentParser()\n" +"parser.add_argument('-u', '--user')\n" +"parser.add_argument('-c', '--color')\n" +"namespace = parser.parse_args()\n" +"command_line_args = {k: v for k, v in vars(namespace).items() if v is not " +"None}\n" +"\n" +"combined = ChainMap(command_line_args, os.environ, defaults)\n" +"print(combined['color'])\n" +"print(combined['user'])" #: ../../library/collections.rst:170 msgid "" @@ -416,7 +430,6 @@ msgstr "" "除を望むなら、チェーンの深いところで見つかったキーを更新するサブクラスを簡単" "に作れます::" -#: ../../library/collections.rst:194 msgid "" "class DeepChainMap(ChainMap):\n" " 'Variant of ChainMap that allows direct updates to inner scopes'\n" @@ -443,6 +456,30 @@ msgid "" ">>> d # display result\n" "DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" msgstr "" +"class DeepChainMap(ChainMap):\n" +" '内側のスコープを直接更新できる ChainMap の変種'\n" +"\n" +" def __setitem__(self, key, value):\n" +" for mapping in self.maps:\n" +" if key in mapping:\n" +" mapping[key] = value\n" +" return\n" +" self.maps[0][key] = value\n" +"\n" +" def __delitem__(self, key):\n" +" for mapping in self.maps:\n" +" if key in mapping:\n" +" del mapping[key]\n" +" return\n" +" raise KeyError(key)\n" +"\n" +">>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': " +"'yellow'})\n" +">>> d['lion'] = 'orange' # 2 階層下の既存のキーを更新\n" +">>> d['snake'] = 'red' # 新しいキーは最上位の辞書に追加\n" +">>> del d['elephant'] # 1 階層下の既存のキーを削除\n" +">>> d # 結果を表示\n" +"DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})" #: ../../library/collections.rst:220 msgid ":class:`Counter` objects" @@ -455,7 +492,6 @@ msgid "" msgstr "" "便利で迅速な検数をサポートするカウンタツールが提供されています。例えば::" -#: ../../library/collections.rst:225 msgid "" ">>> # Tally occurrences of words in a list\n" ">>> cnt = Counter()\n" @@ -472,6 +508,20 @@ msgid "" "[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n" " ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" msgstr "" +">>> # リスト内の単語の出現回数を数える\n" +">>> cnt = Counter()\n" +">>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n" +"... cnt[word] += 1\n" +"...\n" +">>> cnt\n" +"Counter({'blue': 3, 'red': 2, 'green': 1})\n" +"\n" +">>> # Hamlet で最も頻出する単語を 10 個見つける\n" +">>> import re\n" +">>> words = re.findall(r'\\w+', open('hamlet.txt').read().lower())\n" +">>> Counter(words).most_common(10)\n" +"[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n" +" ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]" #: ../../library/collections.rst:244 msgid "" @@ -542,16 +592,17 @@ msgstr "" "は挿入した順番で返されます。ある要素のカウントが 1 未満なら、 :meth:" "`elements` はそれを無視します。" -#: ../../library/collections.rst:294 msgid "" "Return a list of the *n* most common elements and their counts from the most " "common to the least. If *n* is omitted or ``None``, :meth:`most_common` " "returns *all* elements in the counter. Elements with equal counts are " "ordered in the order first encountered:" msgstr "" -"最も多い *n* 要素を、カウントが多いものから少ないものまで順に並べたリストを返" -"します。 *n* が省略されるか ``None`` であれば、 :meth:`most_common` はカウン" -"タの *すべての* 要素を返します。等しいカウントの要素は挿入順に並べられます:" +"出現回数が多い順に *n* 個の要素とそれぞれのカウントを並べたリストを返しま" +"す。\n" +"*n* が省略されるか ``None`` であれば、 :meth:`most_common` はカウンタの *すべ" +"ての* 要素を返します。\n" +"等しいカウントの要素は挿入順に並べられます:" #: ../../library/collections.rst:306 msgid "" @@ -567,11 +618,12 @@ msgstr "" msgid "Compute the sum of the counts." msgstr "カウントの合計を計算します。" -#: ../../library/collections.rst:328 msgid "" "The usual dictionary methods are available for :class:`Counter` objects " "except for these two which work differently for counters:" msgstr "" +"通常の辞書のメソッドは :class:`Counter` オブジェクトでも利用できますが、次の" +"二つはカウンタでは動作が異なります:" #: ../../library/collections.rst:333 msgid "This class method is not implemented for :class:`Counter` objects." @@ -620,7 +672,6 @@ msgstr "" msgid "Common patterns for working with :class:`Counter` objects::" msgstr ":class:`Counter` オブジェクトを使ったよくあるパターン::" -#: ../../library/collections.rst:359 msgid "" "c.total() # total of all counts\n" "c.clear() # reset all counts\n" @@ -632,8 +683,16 @@ msgid "" "c.most_common()[:-n-1:-1] # n least common elements\n" "+c # remove zero and negative counts" msgstr "" +"c.total() # すべてのカウントの合計\n" +"c.clear() # すべてのカウントをリセット\n" +"list(c) # 重複しない要素のリスト\n" +"set(c) # 集合に変換\n" +"dict(c) # 通常の辞書に変換\n" +"c.items() # (elem, cnt) のペアにアクセス\n" +"Counter(dict(list_of_pairs)) # (elem, cnt) のペアのリストから変換\n" +"c.most_common()[:-n-1:-1] # 出現回数が少ない方から n 個の要素\n" +"+c # 0 と負のカウントを削除" -#: ../../library/collections.rst:369 msgid "" "Several mathematical operations are provided for combining :class:`Counter` " "objects to produce multisets (counters that have counts greater than zero). " @@ -645,8 +704,16 @@ msgid "" "accept inputs with signed counts, but the output will exclude results with " "counts of zero or below." msgstr "" +":class:`Counter` オブジェクトを組み合わせて多重集合 (カウントが 0 より大きい" +"カウンタ) を作るために、いくつかの数学演算が用意されています。\n" +"加算と減算は、対応する要素のカウントを加算または減算してカウンタを組み合わせ" +"ます。\n" +"共通部分と和集合は、対応するカウントの最小値と最大値を返します。\n" +"対称差は、対応するカウントの最大値と最小値の差を返します。\n" +"等価性と包含関係の比較では、対応するカウントを比較します。\n" +"各演算には符号付きのカウントを入力できますが、出力からはカウントが 0 以下の結" +"果が除外されます。" -#: ../../library/collections.rst:379 msgid "" ">>> c = Counter(a=3, b=1)\n" ">>> d = Counter(a=1, b=2)\n" @@ -665,6 +732,22 @@ msgid "" ">>> c <= d # inclusion: c[x] <= d[x]\n" "False" msgstr "" +">>> c = Counter(a=3, b=1)\n" +">>> d = Counter(a=1, b=2)\n" +">>> c + d # 二つのカウンタを加算: c[x] + d[x]\n" +"Counter({'a': 4, 'b': 3})\n" +">>> c - d # 減算 (正のカウントのみ残す)\n" +"Counter({'a': 2})\n" +">>> c & d # 共通部分: min(c[x], d[x])\n" +"Counter({'a': 1, 'b': 1})\n" +">>> c | d # 和集合: max(c[x], d[x])\n" +"Counter({'a': 3, 'b': 2})\n" +">>> c ^ d # max(c[x], d[x]) - min(c[x], d[x])\n" +"Counter({'a': 2, 'b': 1})\n" +">>> c == d # 等価性: c[x] == d[x]\n" +"False\n" +">>> c <= d # 包含関係: c[x] <= d[x]\n" +"False" #: ../../library/collections.rst:398 msgid "" @@ -680,10 +763,9 @@ msgid "" msgstr "" "単項加算、単項減算、in-place の多重集合操作のサポートが追加されました。" -#: ../../library/collections.rst:410 msgid "" "Added support for the symmetric difference multiset operation, ``c ^ d``." -msgstr "" +msgstr "多重集合の対称差演算 ``c ^ d`` のサポートが追加されました。" #: ../../library/collections.rst:415 msgid "" @@ -788,10 +870,10 @@ msgstr "" "上げるには、 :func:`itertools.combinations_with_replacement` を参照してくださ" "い::" -#: ../../library/collections.rst:457 msgid "" "map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" msgstr "" +"map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC" #: ../../library/collections.rst:461 msgid ":class:`deque` objects" @@ -851,21 +933,19 @@ msgstr "" "トランザクションの tracking や最近使った要素だけを残したいデータプール (pool " "of data) などにも便利です。" -#: ../../library/collections.rst:487 msgid "Deques are :ref:`generic ` over the type of their contents." msgstr "" +"deque は、要素の型をパラメータとする :ref:`ジェネリック ` です。" #: ../../library/collections.rst:490 msgid "Deque objects support the following methods:" msgstr "Deque オブジェクトは以下のようなメソッドをサポートしています:" -#: ../../library/collections.rst:494 msgid "Add *item* to the right side of the deque." -msgstr "" +msgstr "*item* を deque の右側に追加します。" -#: ../../library/collections.rst:499 msgid "Add *item* to the left side of the deque." -msgstr "" +msgstr "*item* を deque の左側に追加します。" #: ../../library/collections.rst:504 msgid "Remove all elements from the deque leaving it with length 0." @@ -875,9 +955,8 @@ msgstr "deque からすべての要素を削除し、長さを 0 にします。 msgid "Create a shallow copy of the deque." msgstr "deque の浅いコピーを作成します。" -#: ../../library/collections.rst:516 msgid "Count the number of deque elements equal to *value*." -msgstr "" +msgstr "deque 内で *value* と等しい要素の数を数えます。" #: ../../library/collections.rst:523 msgid "" @@ -895,16 +974,17 @@ msgstr "" "イテラブルな引数 iterable から得られる要素を deque の左側に追加し拡張します。" "注意: 左から追加した結果は、イテラブルな引数の順序とは逆になります。" -#: ../../library/collections.rst:536 msgid "" "Return the position of *value* in the deque (at or after index *start* and " "before index *stop*). Returns the first match or raises :exc:`ValueError` " "if not found." msgstr "" +"deque 内の *value* の位置 (インデックス *start* 以上、インデックス *stop* 未" +"満) を返します。\n" +"最初に一致した位置を返し、見つからない場合は :exc:`ValueError` を送出します。" -#: ../../library/collections.rst:545 msgid "Insert *value* into the deque at position *index*." -msgstr "" +msgstr "deque の位置 *index* に *value* を挿入します。" #: ../../library/collections.rst:547 msgid "" @@ -995,7 +1075,6 @@ msgstr "" msgid "Example:" msgstr "例:" -#: ../../library/collections.rst:608 msgid "" ">>> from collections import deque\n" ">>> d = deque('ghi') # make a new deque with three items\n" @@ -1050,6 +1129,56 @@ msgid "" ">>> d\n" "deque(['c', 'b', 'a'])" msgstr "" +">>> from collections import deque\n" +">>> d = deque('ghi') # 3 要素の deque を新しく作成\n" +">>> for elem in d: # deque の要素を反復処理\n" +"... print(elem.upper())\n" +"G\n" +"H\n" +"I\n" +"\n" +">>> d.append('j') # 新しい要素を右側に追加\n" +">>> d.appendleft('f') # 新しい要素を左側に追加\n" +">>> d # deque の表現を表示\n" +"deque(['f', 'g', 'h', 'i', 'j'])\n" +"\n" +">>> d.pop() # 右端の要素を返して削除\n" +"'j'\n" +">>> d.popleft() # 左端の要素を返して削除\n" +"'f'\n" +">>> list(d) # deque の内容をリストにする\n" +"['g', 'h', 'i']\n" +">>> d[0] # 左端の要素を見る\n" +"'g'\n" +">>> d[-1] # 右端の要素を見る\n" +"'i'\n" +"\n" +">>> list(reversed(d)) # deque の内容を逆順のリストにする\n" +"['i', 'h', 'g']\n" +">>> 'h' in d # deque を検索\n" +"True\n" +">>> d.extend('jkl') # 複数の要素を一度に追加\n" +">>> d\n" +"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" +">>> d.rotate(1) # 右にローテート\n" +">>> d\n" +"deque(['l', 'g', 'h', 'i', 'j', 'k'])\n" +">>> d.rotate(-1) # 左にローテート\n" +">>> d\n" +"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n" +"\n" +">>> deque(reversed(d)) # 逆順の deque を新しく作成\n" +"deque(['l', 'k', 'j', 'i', 'h', 'g'])\n" +">>> d.clear() # deque を空にする\n" +">>> d.pop() # 空の deque からは取り出せない\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" d.pop()\n" +"IndexError: pop from an empty deque\n" +"\n" +">>> d.extendleft('abc') # extendleft() は入力の順序を反転する\n" +">>> d\n" +"deque(['c', 'b', 'a'])" #: ../../library/collections.rst:663 msgid ":class:`deque` Recipes" @@ -1067,13 +1196,16 @@ msgstr "" "長さが制限された deque は Unix における ``tail`` フィルタに相当する機能を提供" "します::" -#: ../../library/collections.rst:670 msgid "" "def tail(filename, n=10):\n" " 'Return the last n lines of a file'\n" " with open(filename) as f:\n" " return deque(f, n)" msgstr "" +"def tail(filename, n=10):\n" +" 'ファイルの末尾 n 行を返す'\n" +" with open(filename) as f:\n" +" return deque(f, n)" #: ../../library/collections.rst:675 msgid "" @@ -1083,7 +1215,6 @@ msgstr "" "deque を使用する別のアプローチは、右に要素を追加し左から要素を取り出すことで" "最近追加した要素のシーケンスを保持することです::" -#: ../../library/collections.rst:678 msgid "" "def moving_average(iterable, n=3):\n" " # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" @@ -1097,8 +1228,18 @@ msgid "" " d.append(elem)\n" " yield s / n" msgstr "" +"def moving_average(iterable, n=3):\n" +" # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n" +" # https://en.wikipedia.org/wiki/Moving_average\n" +" it = iter(iterable)\n" +" d = deque(itertools.islice(it, n-1))\n" +" d.appendleft(0)\n" +" s = sum(d)\n" +" for elem in it:\n" +" s += elem - d.popleft()\n" +" d.append(elem)\n" +" yield s / n" -#: ../../library/collections.rst:690 msgid "" "A `round-robin scheduler `_ can be implemented with input iterators stored in a :" @@ -1107,8 +1248,13 @@ msgid "" "`~deque.popleft`; otherwise, it can be cycled back to the end with the :meth:" "`~deque.rotate` method::" msgstr "" +"入力イテレータを :class:`deque` に格納すると、`ラウンドロビンスケジューラ " +"`_ を実装できます。\n" +"位置 0 にあるアクティブなイテレータから値を yield します。\n" +"そのイテレータが :term:`使い果たされた ` 場合は :meth:`~deque." +"popleft` で削除でき、それ以外の場合は :meth:`~deque.rotate` メソッドで末尾に" +"戻せます。 ::" -#: ../../library/collections.rst:697 msgid "" "def roundrobin(*iterables):\n" " \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" @@ -1122,25 +1268,38 @@ msgid "" " # Remove an exhausted iterator.\n" " iterators.popleft()" msgstr "" +"def roundrobin(*iterables):\n" +" \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n" +" iterators = deque(map(iter, iterables))\n" +" while iterators:\n" +" try:\n" +" while True:\n" +" yield next(iterators[0])\n" +" iterators.rotate(-1)\n" +" except StopIteration:\n" +" # 使い果たされたイテレータを削除\n" +" iterators.popleft()" -#: ../../library/collections.rst:709 msgid "" "The :meth:`~deque.rotate` method provides a way to implement :class:`deque` " "slicing and deletion. For example, a pure Python implementation of ``del " "d[n]`` relies on the ``rotate()`` method to position elements to be popped::" msgstr "" -":meth:`~deque.rotate` メソッドは、 :class:`deque` のスライスや削除の機能を提" -"供します。\n" -"例えば、 純粋な Python 実装の ``del d[n]`` は ``rotate()`` メソッドを頼りに、" -"pop される要素の位置を割り出します::" +":meth:`~deque.rotate` メソッドを使うと :class:`deque` のスライスや削除を実装" +"できます。\n" +"例えば、``del d[n]`` を純粋な Python で実装するには、``rotate()`` メソッドで" +"削除対象の要素を取り出せる位置に移動します。 ::" -#: ../../library/collections.rst:713 msgid "" "def delete_nth(d, n):\n" " d.rotate(-n)\n" " d.popleft()\n" " d.rotate(n)" msgstr "" +"def delete_nth(d, n):\n" +" d.rotate(-n)\n" +" d.popleft()\n" +" d.rotate(n)" #: ../../library/collections.rst:718 msgid "" @@ -1185,11 +1344,12 @@ msgstr "" "``None`` です。残りの引数はキーワード引数も含め、 :class:`dict` のコンストラ" "クタに与えられた場合と同様に扱われます。" -#: ../../library/collections.rst:744 msgid "" ":class:`!defaultdict`\\s are :ref:`generic ` over two types, " "signifying (respectively) the types of the dictionary's keys and values." msgstr "" +":class:`!defaultdict` は、辞書のキーと値の型をそれぞれ表す二つの型をパラメー" +"タとする :ref:`ジェネリック ` です。" #: ../../library/collections.rst:748 msgid "" @@ -1207,15 +1367,14 @@ msgstr "" "もし :attr:`default_factory` 属性が ``None`` であれば、このメソッドは :exc:" "`KeyError` 例外を、 *key* を引数として発生させます。" -#: ../../library/collections.rst:756 msgid "" "If :attr:`default_factory` is not ``None``, it is called without arguments " "to provide a default value for the given *key*, this value is inserted in " "the dictionary for the *key*, and returned." msgstr "" -"もし :attr:`default_factory` 属性が ``None`` でない場合、このメソッドは引数な" -"しで呼び出され、与えらえた *key* に対応するデフォルト値を提供します。この値" -"は、辞書内に *key* に対応して登録され、最後に返されます。" +":attr:`default_factory` が ``None`` でない場合は、それを引数なしで呼び出して " +"*key* のデフォルト値を取得します。\n" +"この値を辞書に *key* の値として登録し、返します。" #: ../../library/collections.rst:760 msgid "" @@ -1283,7 +1442,6 @@ msgstr "" ":class:`list` を :attr:`~defaultdict.default_factory` とすることで、キー=値ペ" "アのシーケンスをリストの辞書へ簡単にグループ化できます。:" -#: ../../library/collections.rst:801 msgid "" "When each key is encountered for the first time, it is not already in the " "mapping; so an entry is automatically created using the :attr:`~defaultdict." @@ -1294,13 +1452,15 @@ msgid "" "list. This technique is simpler and faster than an equivalent technique " "using :meth:`dict.setdefault`:" msgstr "" -"それぞれのキーが最初に登場したとき、マッピングにはまだ存在しません。そのため" -"エントリは :attr:`~defaultdict.default_factory` 関数が返す空の :class:`list` " -"を使って自動的に作成されます。 :meth:`list.append` 操作は新しいリストに紐付け" -"られます。キーが再度出現した場合には、通常の参照動作が行われます(そのキーに対" -"応するリストが返ります)。そして :meth:`list.append` 操作で別の値をリストに追" -"加します。このテクニックは :meth:`dict.setdefault` を使った等価なものよりシン" -"プルで速いです:" +"それぞれのキーが最初に登場したとき、マッピングにはまだ存在しません。\n" +"そのためエントリは :attr:`~defaultdict.default_factory` 関数が返す空の :" +"class:`list` を使って自動的に作成されます。\n" +":meth:`list.append` 操作は新しいリストに値を追加します。\n" +"キーが再度出現した場合には、通常の参照動作が行われます(そのキーに対応するリス" +"トが返ります)。\n" +"そして :meth:`list.append` 操作で別の値をリストに追加します。\n" +"このテクニックは :meth:`dict.setdefault` を使った等価なものよりシンプルで速い" +"です:" #: ../../library/collections.rst:816 msgid "" @@ -1312,26 +1472,26 @@ msgstr "" "`defaultdict` を(他の言語の bag や multisetのように)要素の数え上げに便利に使" "うことができます:" -#: ../../library/collections.rst:828 msgid "" "When a letter is first encountered, it is missing from the mapping, so the :" "attr:`~defaultdict.default_factory` function calls :func:`int` to supply a " "default count of zero. The increment operation then builds up the count for " "each letter." msgstr "" -"最初に文字が出現したときは、マッピングが存在しないので :attr:`~defaultdict." -"default_factory` 関数が :func:`int` を呼んでデフォルトのカウント0を生成しま" -"す。インクリメント操作が各文字を数え上げます。" +"最初に文字が出現したときは、その文字がマッピングに存在しないので :attr:" +"`~defaultdict.default_factory` 関数が :func:`int` を呼んでデフォルトのカウン" +"ト0を生成します。\n" +"インクリメント操作が各文字を数え上げます。" -#: ../../library/collections.rst:832 msgid "" "The function :func:`int` which always returns zero is just a special case of " "constant functions. A faster and more flexible way to create constant " "functions is to use a lambda function which can supply any constant value " "(not just zero):" msgstr "" -"常に0を返す :func:`int` は特殊な関数でした。定数を生成するより速くて柔軟な方" -"法は、 0に限らず何でも定数を生成するラムダ関数を使うことです:" +"常に 0 を返す :func:`int` は、一定の値を返す関数の一例にすぎません。\n" +"そのような関数をより高速かつ柔軟に作るには、0 に限らず任意の定数を返せるラム" +"ダ関数を使います。" #: ../../library/collections.rst:845 msgid "" @@ -1357,7 +1517,6 @@ msgstr "" "でも利用でき、場所に対するインデックスの代わりに名前を使ってフィールドにアク" "セスできるようになります。" -#: ../../library/collections.rst:866 msgid "" "Returns a new tuple subclass named *typename*. The new subclass is used to " "create tuple-like objects that have fields accessible by attribute lookup as " @@ -1366,12 +1525,12 @@ msgid "" "`~object.__repr__` method which lists the tuple contents in a ``name=value`` " "format." msgstr "" -"*typename* という名前の tuple の新しいサブクラスを返します。新しいサブクラス" -"は、 tuple に似ているけれどもインデックスやイテレータだけでなく属性名によるア" -"クセスもできるオブジェクトを作るのに使います。このサブクラスのインスタンス" -"は、わかりやすい docstring (型名と属性名が入っています) や、 tuple の内容を " -"``name=value`` という形のリストで返す使いやすい :meth:`~object.__repr__` も" -"持っています。" +"*typename* という名前の新しいタプルのサブクラスを返します。\n" +"このサブクラスでは、インデックスによるアクセスや反復に加えて、属性名でも" +"フィールドにアクセスできるタプルに似たオブジェクトを作成できます。\n" +"インスタンスには *typename* と *field_names* を含む便利な docstring と、タプ" +"ルの内容を ``name=value`` 形式で列挙する便利な :meth:`~object.__repr__` メ" +"ソッドもあります。" #: ../../library/collections.rst:873 msgid "" @@ -1478,7 +1637,6 @@ msgstr "" "*defaults* 引数と :attr:`~somenamedtuple._field_defaults` 属性が追加されまし" "た。" -#: ../../library/collections.rst:921 msgid "" ">>> # Basic example\n" ">>> Point = namedtuple('Point', ['x', 'y'])\n" @@ -1494,6 +1652,20 @@ msgid "" ">>> p # readable __repr__ with a name=value style\n" "Point(x=11, y=22)" msgstr "" +">>> # 基本的な例\n" +">>> Point = namedtuple('Point', ['x', 'y'])\n" +">>> p = Point(11, y=22) # 位置引数またはキーワード引数でインスタンスを作" +"成\n" +">>> p[0] + p[1] # 通常のタプル (11, 22) と同様にインデックスでア" +"クセス可能\n" +"33\n" +">>> x, y = p # 通常のタプルと同様にアンパック\n" +">>> x, y\n" +"(11, 22)\n" +">>> p.x + p.y # フィールドには名前でもアクセス可能\n" +"33\n" +">>> p # name=value 形式の読みやすい __repr__\n" +"Point(x=11, y=22)" #: ../../library/collections.rst:937 msgid "" @@ -1538,12 +1710,14 @@ msgid "" msgstr "" "既存の sequence や Iterable から新しいインスタンスを作るクラスメソッド." -#: ../../library/collections.rst:961 msgid "" ">>> t = [11, 22]\n" ">>> Point._make(t)\n" "Point(x=11, y=22)" msgstr "" +">>> t = [11, 22]\n" +">>> Point._make(t)\n" +"Point(x=11, y=22)" #: ../../library/collections.rst:969 msgid "" @@ -1552,12 +1726,14 @@ msgid "" msgstr "" "フィールド名を対応する値にマッピングする新しい :class:`dict` を返します::" -#: ../../library/collections.rst:972 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._asdict()\n" "{'x': 11, 'y': 22}" msgstr "" +">>> p = Point(x=11, y=22)\n" +">>> p._asdict()\n" +"{'x': 11, 'y': 22}" #: ../../library/collections.rst:978 msgid "Returns an :class:`OrderedDict` instead of a regular :class:`dict`." @@ -1584,7 +1760,6 @@ msgstr "" "指定されたフィールドを新しい値で置き換えた、新しい名前付きタプルを作って返し" "ます::" -#: ../../library/collections.rst:993 msgid "" ">>> p = Point(x=11, y=22)\n" ">>> p._replace(x=33)\n" @@ -1594,6 +1769,13 @@ msgid "" "... inventory[partnum] = record._replace(price=newprices[partnum], " "timestamp=time.now())" msgstr "" +">>> p = Point(x=11, y=22)\n" +">>> p._replace(x=33)\n" +"Point(x=33, y=22)\n" +"\n" +">>> for partnum, record in inventory.items():\n" +"... inventory[partnum] = record._replace(price=newprices[partnum], " +"timestamp=time.now())" #: ../../library/collections.rst:1000 msgid "" @@ -1617,7 +1799,6 @@ msgstr "" "フィールド名をリストにしたタプルです。内省 (introspection) したり、既存の名前" "付きタプルをもとに新しい名前つきタプルを作成する時に便利です。" -#: ../../library/collections.rst:1011 msgid "" ">>> p._fields # view the field names\n" "('x', 'y')\n" @@ -1627,12 +1808,18 @@ msgid "" ">>> Pixel(11, 22, 128, 255, 0)\n" "Pixel(x=11, y=22, red=128, green=255, blue=0)" msgstr "" +">>> p._fields # フィールド名を表示\n" +"('x', 'y')\n" +"\n" +">>> Color = namedtuple('Color', 'red green blue')\n" +">>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)\n" +">>> Pixel(11, 22, 128, 255, 0)\n" +"Pixel(x=11, y=22, red=128, green=255, blue=0)" #: ../../library/collections.rst:1023 msgid "Dictionary mapping field names to default values." msgstr "フィールド名からデフォルト値への対応を持つ辞書です。" -#: ../../library/collections.rst:1025 msgid "" ">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" ">>> Account._field_defaults\n" @@ -1640,6 +1827,11 @@ msgid "" ">>> Account('premium')\n" "Account(type='premium', balance=0)" msgstr "" +">>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])\n" +">>> Account._field_defaults\n" +"{'balance': 0}\n" +">>> Account('premium')\n" +"Account(type='premium', balance=0)" #: ../../library/collections.rst:1033 msgid "" @@ -1667,7 +1859,6 @@ msgstr "" "のは容易です。次の例では計算済みフィールドと固定幅の print format を追加して" "います:" -#: ../../library/collections.rst:1050 msgid "" ">>> class Point(namedtuple('Point', ['x', 'y'])):\n" "... __slots__ = ()\n" @@ -1683,6 +1874,19 @@ msgid "" "Point: x= 3.000 y= 4.000 hypot= 5.000\n" "Point: x=14.000 y= 0.714 hypot=14.018" msgstr "" +">>> class Point(namedtuple('Point', ['x', 'y'])):\n" +"... __slots__ = ()\n" +"... @property\n" +"... def hypot(self):\n" +"... return (self.x ** 2 + self.y ** 2) ** 0.5\n" +"... def __str__(self):\n" +"... return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, " +"self.hypot)\n" +"\n" +">>> for p in Point(3, 4), Point(14, 5/7):\n" +"... print(p)\n" +"Point: x= 3.000 y= 4.000 hypot= 5.000\n" +"Point: x=14.000 y= 0.714 hypot=14.018" #: ../../library/collections.rst:1065 msgid "" @@ -1725,13 +1929,16 @@ msgstr "" "NamedTuple` を参照してください。\n" ":keyword:`class` キーワードを使った洗練された記法も紹介されています::" -#: ../../library/collections.rst:1091 msgid "" "class Component(NamedTuple):\n" " part_number: int\n" " weight: float\n" " description: Optional[str] = None" msgstr "" +"class Component(NamedTuple):\n" +" part_number: int\n" +" weight: float\n" +" description: Optional[str] = None" #: ../../library/collections.rst:1096 msgid "" @@ -1840,13 +2047,12 @@ msgstr "" "は ``(k := next(iter(d)), d.pop(k))`` で実現できます。これにより、該当する要" "素のうちで最も左側の (先頭の) ものを辞書から削除して返すことができます。" -#: ../../library/collections.rst:1140 msgid "" ":class:`OrderedDict` has a :meth:`~OrderedDict.move_to_end` method to " "efficiently reposition an element to an endpoint." msgstr "" -":class:`OrderedDict` には、 効率的に要素を末尾に置き直す :meth:`~OrderedDict." -"move_to_end` メソッドがあります。" +":class:`OrderedDict` には、要素を先頭または末尾に効率よく移動する :meth:" +"`~OrderedDict.move_to_end` メソッドがあります。" #: ../../library/collections.rst:1143 msgid "" @@ -1858,7 +2064,6 @@ msgstr "" "OrderedDict の ``od.move_to_end(k, last=True)`` は ``d[k] = d.pop(k)`` で実現" "できます。" -#: ../../library/collections.rst:1147 msgid "" "A regular :class:`dict` does not have an efficient equivalent for " "OrderedDict's ``od.move_to_end(k, last=False)`` which moves the key and its " @@ -1866,14 +2071,13 @@ msgid "" msgstr "" "組み込みの :class:`dict` では、キーと値のペアを最も左側 (先頭) に移動する " "OrderedDict の ``od.move_to_end(k, last=False)`` を実現する効率の良い方法はあ" -"りません。 " +"りません。" -#: ../../library/collections.rst:1151 msgid "" "Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method." msgstr "" -"Python 3.8 以前は、 :class:`dict` には :meth:`~object.__reversed__` メソッド" -"が欠けています。" +"Python 3.8 より前の :class:`dict` には :meth:`~object.__reversed__` メソッド" +"がありませんでした。" #: ../../library/collections.rst:1158 msgid "" @@ -1905,7 +2109,6 @@ msgstr "" "場合には先頭に移動します。指定した *key* が存在しない場合は :exc:`KeyError` " "を送出します。" -#: ../../library/collections.rst:1177 msgid "" ">>> d = OrderedDict.fromkeys('abcde')\n" ">>> d.move_to_end('b')\n" @@ -1915,6 +2118,13 @@ msgid "" ">>> ''.join(d)\n" "'bacde'" msgstr "" +">>> d = OrderedDict.fromkeys('abcde')\n" +">>> d.move_to_end('b')\n" +">>> ''.join(d)\n" +"'acdeb'\n" +">>> d.move_to_end('b', last=False)\n" +">>> ''.join(d)\n" +"'bacde'" #: ../../library/collections.rst:1189 msgid "" @@ -1924,19 +2134,23 @@ msgstr "" "通常のマッピングのメソッドに加え、順序付き辞書は :func:`reversed` による逆順" "の反復もサポートしています。" -#: ../../library/collections.rst:1194 msgid "" "Equality tests between :class:`OrderedDict` objects are order-sensitive and " "are roughly equivalent to ``list(od1.items())==list(od2.items())``." msgstr "" +":class:`OrderedDict` オブジェクト同士の等価性の比較は順序を考慮し、ほぼ " +"``list(od1.items())==list(od2.items())`` と等価です。" -#: ../../library/collections.rst:1197 msgid "" "Equality tests between :class:`OrderedDict` objects and other :class:" "`~collections.abc.Mapping` objects are order-insensitive like regular " "dictionaries. This allows :class:`OrderedDict` objects to be substituted " "anywhere a regular dictionary is used." msgstr "" +":class:`OrderedDict` オブジェクトと他の :class:`~collections.abc.Mapping` オ" +"ブジェクトの等価性の比較では、通常の辞書と同様に順序は考慮されません。\n" +"このため、通常の辞書を使う場所ならどこでも :class:`OrderedDict` オブジェクト" +"で置き換えられます。" #: ../../library/collections.rst:1202 msgid "" @@ -1970,7 +2184,6 @@ msgstr "" "簡単です。\n" "新しい値が既存の値を上書きする場合、元々の挿入位置が最後尾へ変更されます::" -#: ../../library/collections.rst:1223 msgid "" "class LastUpdatedOrderedDict(OrderedDict):\n" " 'Store items in the order that the keys were last updated.'\n" @@ -1979,14 +2192,20 @@ msgid "" " super().__setitem__(key, value)\n" " self.move_to_end(key)" msgstr "" +"class LastUpdatedOrderedDict(OrderedDict):\n" +" 'キーが最後に更新された順に要素を保存する'\n" +"\n" +" def __setitem__(self, key, value):\n" +" super().__setitem__(key, value)\n" +" self.move_to_end(key)" -#: ../../library/collections.rst:1230 msgid "" "An :class:`OrderedDict` would also be useful for implementing variants of :" "deco:`functools.lru_cache`:" msgstr "" +":class:`OrderedDict` は、:deco:`functools.lru_cache` の変種を実装する際にも役" +"立ちます:" -#: ../../library/collections.rst:1233 msgid "" "from collections import OrderedDict\n" "from time import monotonic\n" @@ -2012,8 +2231,30 @@ msgid "" " self.cache.popitem(last=False)\n" " return result" msgstr "" +"from collections import OrderedDict\n" +"from time import monotonic\n" +"\n" +"class TimeBoundedLRU:\n" +" \"古いエントリーを無効化して更新する LRU キャッシュ\"\n" +"\n" +" def __init__(self, func, maxsize=128, maxage=30):\n" +" self.cache = OrderedDict() # { args : (timestamp, result)}\n" +" self.func = func\n" +" self.maxsize = maxsize\n" +" self.maxage = maxage\n" +"\n" +" def __call__(self, *args):\n" +" if args in self.cache:\n" +" self.cache.move_to_end(args)\n" +" timestamp, result = self.cache[args]\n" +" if monotonic() - timestamp <= self.maxage:\n" +" return result\n" +" result = self.func(*args)\n" +" self.cache[args] = monotonic(), result\n" +" if len(self.cache) > self.maxsize:\n" +" self.cache.popitem(last=False)\n" +" return result" -#: ../../library/collections.rst:1260 msgid "" "class MultiHitLRUCache:\n" " \"\"\" LRU cache that defers caching a result until\n" @@ -2050,6 +2291,41 @@ msgid "" " self.cache.popitem(last=False)\n" " return result" msgstr "" +"class MultiHitLRUCache:\n" +" \"\"\" 結果が複数回要求されるまで\n" +" キャッシュへの保存を遅らせる LRU キャッシュ。\n" +"\n" +"\n" +" 一度しか要求されない結果で LRU キャッシュが置き換わるのを防ぐため、\n" +" 同じ要求が複数回行われるまでキャッシュに保存しない。\n" +"\n" +"\n" +" \"\"\"\n" +"\n" +" def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1):\n" +" self.requests = OrderedDict() # { uncached_key : request_count }\n" +" self.cache = OrderedDict() # { cached_key : function_result }\n" +" self.func = func\n" +" self.maxrequests = maxrequests # キャッシュにない要求の最大数\n" +" self.maxsize = maxsize # 保存する戻り値の最大数\n" +" self.cache_after = cache_after\n" +"\n" +" def __call__(self, *args):\n" +" if args in self.cache:\n" +" self.cache.move_to_end(args)\n" +" return self.cache[args]\n" +" result = self.func(*args)\n" +" self.requests[args] = self.requests.get(args, 0) + 1\n" +" if self.requests[args] <= self.cache_after:\n" +" self.requests.move_to_end(args)\n" +" if len(self.requests) > self.maxrequests:\n" +" self.requests.popitem(last=False)\n" +" else:\n" +" self.requests.pop(args, None)\n" +" self.cache[args] = result\n" +" if len(self.cache) > self.maxsize:\n" +" self.cache.popitem(last=False)\n" +" return result" #: ../../library/collections.rst:1329 msgid ":class:`UserDict` objects" @@ -2067,36 +2343,44 @@ msgstr "" "取って代わられました; しかし、根底の辞書に属性としてアクセスできるので、この" "クラスを使った方が簡単になることもあります。" -#: ../../library/collections.rst:1341 msgid "" "Class that simulates a dictionary. The instance's contents are kept in a " "regular dictionary, which is accessible via the :attr:`data` attribute of :" "class:`!UserDict` instances. If arguments are provided, they are used to " "initialize :attr:`data`, like a regular dictionary." msgstr "" +"辞書をシミュレートするクラスです。\n" +"インスタンスの内容は通常の辞書に保存され、:class:`!UserDict` インスタンスの :" +"attr:`data` 属性を通してアクセスできます。\n" +"引数が指定された場合は、通常の辞書と同様に :attr:`data` の初期化に使われま" +"す。" -#: ../../library/collections.rst:1346 msgid "" "In addition to supporting the methods and operations of mappings, :class:`!" "UserDict` instances provide the following attribute:" msgstr "" +"マッピングのメソッドと演算をサポートするのに加え、:class:`!UserDict` インスタ" +"ンスは次の属性を提供します:" #: ../../library/collections.rst:1351 msgid "" "A real dictionary used to store the contents of the :class:`UserDict` class." msgstr ":class:`UserDict` クラスの内容を保存するために使われる実際の辞書です。" -#: ../../library/collections.rst:1354 msgid ":class:`!UserDict` instances also override the following method:" -msgstr "" +msgstr ":class:`!UserDict` インスタンスは、次のメソッドもオーバーライドします:" -#: ../../library/collections.rst:1358 msgid "" "Remove and return a ``(key, value)`` pair from the wrapped dictionary. Pairs " "are returned in the same order as ``data.popitem()``. (For the default :meth:" "`dict.popitem`, this order is :abbr:`LIFO (last-in, first-out)`.) If the " "dictionary is empty, raises a :exc:`KeyError`." msgstr "" +"ラップしている辞書から ``(key, value)`` のペアを削除して返します。\n" +"ペアは ``data.popitem()`` と同じ順序で返されます (デフォルトの :meth:`dict." +"popitem` の場合、この順序は :abbr:`LIFO (last-in, first-out, 後入先出)` で" +"す)。\n" +"辞書が空の場合は :exc:`KeyError` を送出します。" #: ../../library/collections.rst:1364 msgid ":class:`UserList` objects" diff --git a/library/colorsys.po b/library/colorsys.po index 1a1b7741a..0ddb920b1 100644 --- a/library/colorsys.po +++ b/library/colorsys.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/colorsys.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!colorsys` --- 色体系間の変換" msgid "**Source code:** :source:`Lib/colorsys.py`" msgstr "**ソースコード:** :source:`Lib/colorsys.py`" -#: ../../library/colorsys.rst:11 msgid "" "The :mod:`!colorsys` module defines bidirectional conversions of color " "values between colors expressed in the RGB (Red Green Blue) color space used " @@ -40,17 +39,26 @@ msgid "" "coordinate is between 0 and 1, but the I and Q coordinates can be positive " "or negative. In all other spaces, the coordinates are all between 0 and 1." msgstr "" +":mod:`!colorsys` モジュールは、コンピュータのモニターで使われる RGB (Red " +"Green Blue: 赤・緑・青) 色空間と、他の三つの座標系である YIQ、HLS (Hue " +"Lightness Saturation: 色相・明度・彩度)、HSV (Hue Saturation Value: 色相・彩" +"度・明度) との間で、色の値を双方向に変換する関数を定義しています。\n" +"これらの色空間の座標はすべて浮動小数点数です。\n" +"YIQ 空間では、Y 座標は 0 から 1 の範囲ですが、I 座標と Q 座標は正にも負にもな" +"ります。\n" +"それ以外の空間では、すべての座標が 0 から 1 の範囲です。" -#: ../../library/colorsys.rst:21 msgid "" "More information about color spaces can be found at https://www.poynton.ca/" "pdf/ColourFAQ.pdf and https://www.cambridgeincolour.com/tutorials/color-" "spaces.htm." msgstr "" +"色空間について詳しくは、https://www.poynton.ca/pdf/ColourFAQ.pdf および " +"https://www.cambridgeincolour.com/tutorials/color-spaces.htm を参照してくださ" +"い。" -#: ../../library/colorsys.rst:25 msgid "The :mod:`!colorsys` module defines the following functions:" -msgstr "" +msgstr ":mod:`!colorsys` モジュールは、以下の関数を定義しています:" #: ../../library/colorsys.rst:30 msgid "Convert the color from RGB coordinates to YIQ coordinates." @@ -80,7 +88,6 @@ msgstr "HSV から RGB に変換します。" msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/colorsys.rst:59 msgid "" ">>> import colorsys\n" ">>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4)\n" @@ -88,3 +95,8 @@ msgid "" ">>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4)\n" "(0.2, 0.4, 0.4)" msgstr "" +">>> import colorsys\n" +">>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4)\n" +"(0.5, 0.5, 0.4)\n" +">>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4)\n" +"(0.2, 0.4, 0.4)" diff --git a/library/compileall.po b/library/compileall.po index 5aed1c3e4..a5f93fe0e 100644 --- a/library/compileall.po +++ b/library/compileall.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/compileall.rst:2 @@ -44,9 +44,8 @@ msgstr "" "をライブラリのインストール時に生成することで、ライブラリディレクトリに書き込" "み権限をもたないユーザでも、これらを利用できるようになります。" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -112,25 +111,25 @@ msgstr "" "る時点でソースファイルが存在しない場合に、トレースバックやその他のメッセージ" "に使われるバイトコードファイルにもコンパイルされます。" -#: ../../library/compileall.rst:60 msgid "" "Remove the given prefix from paths recorded in the ``.pyc`` files. Paths are " "made relative to the prefix." msgstr "" +"``.pyc`` ファイルに記録するパスから、指定された接頭辞を取り除きます。\n" +"パスはその接頭辞からの相対パスになります。" -#: ../../library/compileall.rst:63 msgid "This option can be used with ``-p`` but not with ``-d``." -msgstr "" +msgstr "このオプションは ``-p`` と併用できますが、``-d`` とは併用できません。" -#: ../../library/compileall.rst:67 msgid "" "Prepend the given prefix to paths recorded in the ``.pyc`` files. Use ``-p /" "`` to make the paths absolute." msgstr "" +"``.pyc`` ファイルに記録するパスの先頭に、指定された接頭辞を追加します。\n" +"パスを絶対パスにするには ``-p /`` を使ってください。" -#: ../../library/compileall.rst:70 msgid "This option can be used with ``-s`` but not with ``-d``." -msgstr "" +msgstr "このオプションは ``-s`` と併用できますが、``-d`` とは併用できません。" #: ../../library/compileall.rst:74 msgid "" @@ -174,13 +173,14 @@ msgstr "" ":program:`python -m compileall -r 0` は :program:`python -m " "compileall -l` と等価です。" -#: ../../library/compileall.rst:99 msgid "" "Use *N* workers to compile the files within the given directory. If ``0`` is " "used, then the result of :func:`os.process_cpu_count` will be used." msgstr "" +"指定されたディレクトリ内のファイルを *N* 個のワーカーを使ってコンパイルしま" +"す。\n" +"``0`` を指定すると、:func:`os.process_cpu_count` の結果が使われます。" -#: ../../library/compileall.rst:105 msgid "" "Control how the generated byte-code files are invalidated at runtime. The " "``timestamp`` value, means that ``.pyc`` files with the source timestamp and " @@ -192,58 +192,65 @@ msgid "" "`SOURCE_DATE_EPOCH` environment variable is not set, and ``checked-hash`` if " "the ``SOURCE_DATE_EPOCH`` environment variable is set." msgstr "" -"生成したバイトコードファイルを実行時に無効化する方法を制御します。" -"``timestamp`` を指定すると、生成した``.pyc`` ファイルにソースファイルのタイム" -"スタンプとサイズを埋め込みます。``checked-hash`` と ``unchecked-hash`` を指定" -"すると、ハッシュベースの pycファイルが生成されます。ハッシュベースのpycファイ" -"ルは、ソースファイルにタイムスタンプではなくハッシュ値を埋め込みます。Python " -"がバイトコードキャッシュファイルを実行時に検証する方法の詳細を知るには、:ref:" -"`pyc-invalidation` を参照してください。デフォルト値は、:envvar:" -"`SOURCE_DATE_EPOCH` 環境変数が設定されていなければ ``timestamp`` で、" -"``SOURCE_DATE_EPOCH`` 環境変数が設定されていれば、``checked-hash`` になりま" -"す。" +"生成したバイトコードファイルを実行時に無効化する方法を制御します。\n" +"``timestamp`` を指定すると、生成した ``.pyc`` ファイルにソースファイルのタイ" +"ムスタンプとサイズを埋め込みます。\n" +"``checked-hash`` と ``unchecked-hash`` を指定すると、ハッシュベースの pycファ" +"イルが生成されます。\n" +"ハッシュベースの pyc ファイルには、タイムスタンプの代わりにソースファイルの内" +"容のハッシュ値を埋め込みます。\n" +"Python がバイトコードキャッシュファイルを実行時に検証する方法の詳細を知るに" +"は、:ref:`pyc-invalidation` を参照してください。\n" +"デフォルト値は、:envvar:`SOURCE_DATE_EPOCH` 環境変数が設定されていなければ " +"``timestamp`` で、``SOURCE_DATE_EPOCH`` 環境変数が設定されていれば、" +"``checked-hash`` になります。" -#: ../../library/compileall.rst:118 msgid "" "Compile with the given optimization level. May be used multiple times to " "compile for multiple levels at a time (for example, ``compileall -o 1 -o " "2``)." msgstr "" +"指定された最適化レベルでコンパイルします。\n" +"複数回指定すると、複数のレベルで一度にコンパイルできます (例: ``compileall -" +"o 1 -o 2``)。" -#: ../../library/compileall.rst:124 msgid "Ignore symlinks pointing outside the given directory." -msgstr "" +msgstr "指定されたディレクトリの外を指すシンボリックリンクを無視します。" -#: ../../library/compileall.rst:128 msgid "" "If two ``.pyc`` files with different optimization level have the same " "content, use hard links to consolidate duplicate files." msgstr "" +"最適化レベルが異なる二つの ``.pyc`` ファイルの内容が同じ場合、ハードリンクを" +"使って重複するファイルをまとめます。" #: ../../library/compileall.rst:131 msgid "Added the ``-i``, ``-b`` and ``-h`` options." msgstr "``-i``, ``-b``, ``-h`` オプションを追加。" -#: ../../library/compileall.rst:134 msgid "" "Added the ``-j``, ``-r``, and ``-qq`` options. ``-q`` option was changed " "to a multilevel value. ``-b`` will always produce a byte-code file ending " "in ``.pyc``, never ``.pyo``." msgstr "" -"``-j``, ``-r``, ``-qq`` オプションが追加されました。``-q`` オプションが複数の" -"レベルの値に変更されました。``-b`` は常に拡張子 ``.pyc`` のバイトエンコーディ" -"ングファイルを生成し、``.pyo`` を作りません。" +"``-j``、``-r``、``-qq`` オプションが追加されました。\n" +"``-q`` オプションが複数のレベルの値を取るように変更されました。\n" +"``-b`` は常に拡張子が ``.pyc`` のバイトコードファイルを生成し、``.pyo`` は生" +"成しません。" #: ../../library/compileall.rst:139 msgid "Added the ``--invalidation-mode`` option." msgstr "``--invalidation-mode`` オプションが追加されました。" -#: ../../library/compileall.rst:142 msgid "" "Added the ``-s``, ``-p``, ``-e`` and ``--hardlink-dupes`` options. Raised " "the default recursion limit from 10 to :py:func:`sys.getrecursionlimit()`. " "Added the possibility to specify the ``-o`` option multiple times." msgstr "" +"``-s``、``-p``、``-e``、``--hardlink-dupes`` オプションが追加されました。\n" +"デフォルトの再帰上限が 10 から :py:func:`sys.getrecursionlimit()` に引き上げ" +"られました。\n" +"``-o`` オプションを複数回指定できるようになりました。" #: ../../library/compileall.rst:149 msgid "" @@ -255,13 +262,17 @@ msgstr "" "ンはありません。 Python インタプリタ自体のオプションを使ってください: :" "program:`python -O -m compileall`." -#: ../../library/compileall.rst:153 msgid "" "Similarly, the :func:`compile` function respects the :data:`sys." "pycache_prefix` setting. The generated bytecode cache will only be useful " "if :func:`compile` is run with the same :data:`sys.pycache_prefix` (if any) " "that will be used at runtime." msgstr "" +"同様に、:func:`compile` 関数は :data:`sys.pycache_prefix` の設定に従いま" +"す。\n" +"生成されたバイトコードキャッシュを利用するには、:func:`compile` の実行時と" +"コードの実行時で :data:`sys.pycache_prefix` の設定を揃える必要があります (設" +"定しない場合も同様です)。" #: ../../library/compileall.rst:159 msgid "Public functions" @@ -307,13 +318,17 @@ msgstr "" "*force* が真の場合、タイムスタンプが最新のであってもモジュールは再コンパイル" "されます。" -#: ../../library/compileall.rst:179 msgid "" "If *rx* is given, its ``search`` method is called on the complete path to " "each file considered for compilation, and if it returns a true value, the " "file is skipped. This can be used to exclude files matching a regular " "expression, given as a :ref:`re.Pattern ` object." msgstr "" +"*rx* が指定された場合、コンパイル対象の各ファイルの完全なパスを引数として、そ" +"の ``search`` メソッドを呼び出します。\n" +"真の値が返された場合、そのファイルはスキップされます。\n" +":ref:`re.Pattern ` オブジェクトとして渡した正規表現にマッチする" +"ファイルを除外するために使えます。" #: ../../library/compileall.rst:184 ../../library/compileall.rst:261 msgid "" @@ -339,15 +354,17 @@ msgstr "" "す。デフォルトは :pep:`3147` で決められた場所と名前を使い、複数のバージョン" "の Python のバイトコードファイルが共存できるようにします。" -#: ../../library/compileall.rst:194 ../../library/compileall.rst:271 msgid "" "*optimize* specifies the optimization level for the compiler. It is passed " "to the built-in :func:`compile` function. Accepts also a sequence of " "optimization levels which lead to multiple compilations of one :file:`.py` " "file in one call." msgstr "" +"*optimize* はコンパイラの最適化レベルを指定します。\n" +"この値は組み込みの :func:`compile` 関数に渡されます。\n" +"最適化レベルのシーケンスも受け付け、その場合は一回の呼び出しで一つの :file:`." +"py` ファイルを複数回コンパイルします。" -#: ../../library/compileall.rst:198 msgid "" "The argument *workers* specifies how many workers are used to compile files " "in parallel. The default is to not use multiple workers. If the platform " @@ -356,6 +373,12 @@ msgid "" "cores in the system is used. If *workers* is lower than ``0``, a :exc:" "`ValueError` will be raised." msgstr "" +"*workers* 引数は、ファイルを並列にコンパイルするワーカーの数を指定します。\n" +"デフォルトでは複数のワーカーを使いません。\n" +"複数のワーカーを使えないプラットフォームで *workers* 引数が指定された場合は、" +"逐次コンパイルにフォールバックします。\n" +"*workers* が 0 の場合は、システムのコア数が使われます。\n" +"*workers* が ``0`` より小さい場合は :exc:`ValueError` を送出します。" #: ../../library/compileall.rst:205 ../../library/compileall.rst:275 msgid "" @@ -366,19 +389,22 @@ msgstr "" "*invalidation_mode* は、:class:`py_compile.PycInvalidationMode` のメンバーで" "なければならず、生成されたpycファイルを実行時に無効化する方法を制御します。" -#: ../../library/compileall.rst:209 ../../library/compileall.rst:279 msgid "" "The *stripdir*, *prependdir* and *limit_sl_dest* arguments correspond to the " "``-s``, ``-p`` and ``-e`` options described above. They may be specified as " "``str`` or :py:class:`os.PathLike`." msgstr "" +"*stripdir*、*prependdir*、*limit_sl_dest* 引数は、それぞれ上で説明した ``-" +"s``、``-p``、``-e`` オプションに対応します。\n" +"``str`` または :py:class:`os.PathLike` として指定できます。" -#: ../../library/compileall.rst:213 ../../library/compileall.rst:283 msgid "" "If *hardlink_dupes* is true and two ``.pyc`` files with different " "optimization level have the same content, use hard links to consolidate " "duplicate files." msgstr "" +"*hardlink_dupes* が真で、最適化レベルが異なる二つの ``.pyc`` ファイルの内容が" +"同じ場合、ハードリンクを使って重複するファイルをまとめます。" #: ../../library/compileall.rst:216 ../../library/compileall.rst:314 msgid "Added the *legacy* and *optimize* parameter." @@ -411,22 +437,24 @@ msgstr ":term:`path-like object` を受け入れるようになりました。" msgid "The *invalidation_mode* parameter was added." msgstr "*invalidation_mode* 引数を追加しました。" -#: ../../library/compileall.rst:235 ../../library/compileall.rst:298 -#: ../../library/compileall.rst:327 msgid "" "The *invalidation_mode* parameter's default value is updated to ``None``." msgstr "" +"*invalidation_mode* パラメータのデフォルト値が ``None`` に変更されました。" -#: ../../library/compileall.rst:238 msgid "Setting *workers* to 0 now chooses the optimal number of cores." msgstr "" +"*workers* を 0 に設定すると、最適なコア数が選択されるようになりました。" -#: ../../library/compileall.rst:241 msgid "" "Added *stripdir*, *prependdir*, *limit_sl_dest* and *hardlink_dupes* " "arguments. Default value of *maxlevels* was changed from ``10`` to ``sys." "getrecursionlimit()``" msgstr "" +"*stripdir*、*prependdir*、*limit_sl_dest*、*hardlink_dupes* 引数が追加されま" +"した。\n" +"*maxlevels* のデフォルト値が ``10`` から ``sys.getrecursionlimit()`` に変更さ" +"れました。" #: ../../library/compileall.rst:247 msgid "" @@ -449,7 +477,6 @@ msgstr "" "ルが実行される時点でソースファイルが存在しない場合に、トレースバックやその他" "のメッセージに使われるバイトコードファイルにもコンパイルされます。" -#: ../../library/compileall.rst:256 msgid "" "If *rx* is given, its ``search`` method is passed the full path name to the " "file being compiled, and if it returns a true value, the file is not " @@ -457,6 +484,12 @@ msgid "" "matching a regular expression, given as a :ref:`re.Pattern ` " "object." msgstr "" +"*rx* が指定された場合、コンパイル対象のファイルの完全なパス名を、その " +"``search`` メソッドに渡します。\n" +"真の値が返された場合、そのファイルはコンパイルされず、``True`` が返されま" +"す。\n" +":ref:`re.Pattern ` オブジェクトとして渡した正規表現にマッチする" +"ファイルを除外するために使えます。" #: ../../library/compileall.rst:301 msgid "" @@ -498,7 +531,6 @@ msgstr "" ":file:`Lib/` ディレクトリ以下にある全ての :file:`.py` ファイルを強制的に再コ" "ンパイルするには、以下のようにします::" -#: ../../library/compileall.rst:333 msgid "" "import compileall\n" "\n" @@ -512,6 +544,17 @@ msgid "" "import pathlib\n" "compileall.compile_dir(pathlib.Path('Lib/'), force=True)" msgstr "" +"import compileall\n" +"\n" +"compileall.compile_dir('Lib/', force=True)\n" +"\n" +"# .svn ディレクトリ内のファイルを除外して同じコンパイルを実行\n" +"import re\n" +"compileall.compile_dir('Lib/', rx=re.compile(r'[/\\\\][.]svn'), force=True)\n" +"\n" +"# pathlib.Path オブジェクトも使用可能\n" +"import pathlib\n" +"compileall.compile_dir(pathlib.Path('Lib/'), force=True)" #: ../../library/compileall.rst:347 msgid "Module :mod:`py_compile`" diff --git a/library/compression.po b/library/compression.po index 6a3111e11..039538eab 100644 --- a/library/compression.po +++ b/library/compression.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/compression.rst:2 msgid "The :mod:`!compression` package" msgstr ":mod:`!compression` パッケージ" -#: ../../library/compression.rst:8 msgid "" "The :mod:`!compression` package contains the canonical compression modules " "containing interfaces to several different compression algorithms. Some of " @@ -35,24 +34,25 @@ msgid "" "reasons, and will not be removed without a deprecation cycle. The use of " "modules in :mod:`!compression` is encouraged where practical." msgstr "" +":mod:`!compression` パッケージには、複数の圧縮アルゴリズムへのインターフェー" +"スを提供する標準的な圧縮モジュールが含まれています。\n" +"一部のモジュールは、以前から独立したモジュールとして提供されてきました。\n" +"それらは互換性のために元の名前でも引き続き利用でき、非推奨期間を経ずに削除さ" +"れることはありません。\n" +"可能な場合は :mod:`!compression` 内のモジュールを使うことを推奨します。" -#: ../../library/compression.rst:15 msgid ":mod:`!compression.bz2` -- Re-exports :mod:`bz2`" -msgstr "" +msgstr ":mod:`!compression.bz2` -- :mod:`bz2` を再エクスポート" -#: ../../library/compression.rst:16 msgid ":mod:`!compression.gzip` -- Re-exports :mod:`gzip`" -msgstr "" +msgstr ":mod:`!compression.gzip` -- :mod:`gzip` を再エクスポート" -#: ../../library/compression.rst:17 msgid ":mod:`!compression.lzma` -- Re-exports :mod:`lzma`" -msgstr "" +msgstr ":mod:`!compression.lzma` -- :mod:`lzma` を再エクスポート" -#: ../../library/compression.rst:18 msgid ":mod:`!compression.zlib` -- Re-exports :mod:`zlib`" -msgstr "" +msgstr ":mod:`!compression.zlib` -- :mod:`zlib` を再エクスポート" -#: ../../library/compression.rst:19 msgid "" ":mod:`compression.zstd` -- Wrapper for the Zstandard compression library" -msgstr "" +msgstr ":mod:`compression.zstd` -- Zstandard 圧縮ライブラリのラッパ" diff --git a/library/compression.zstd.po b/library/compression.zstd.po index b73ac7152..5ff7c8929 100644 --- a/library/compression.zstd.po +++ b/library/compression.zstd.po @@ -16,22 +16,19 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/compression.zstd.rst:2 msgid "" ":mod:`!compression.zstd` --- Compression compatible with the Zstandard format" -msgstr "" +msgstr ":mod:`!compression.zstd` --- Zstandard 形式に対応した圧縮" -#: ../../library/compression.zstd.rst:10 msgid "**Source code:** :source:`Lib/compression/zstd/__init__.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/compression/zstd/__init__.py`" -#: ../../library/compression.zstd.rst:14 msgid "" "This module provides classes and functions for compressing and decompressing " "data using the Zstandard (or *zstd*) compression algorithm. The `zstd manual " @@ -42,22 +39,30 @@ msgid "" "of ``.zst`` files created by the :program:`zstd` utility, as well as raw " "zstd compressed streams." msgstr "" +"このモジュールは、Zstandard (または *zstd*) 圧縮アルゴリズムを使ってデータを" +"圧縮・展開するクラスと関数を提供します。\n" +"`zstd マニュアル `__ では、Zstandard を「zlib と同等以上の圧縮率で、リアルタイム圧縮を対" +"象とした高速な可逆圧縮アルゴリズム」と説明しています。\n" +":program:`zstd` ユーティリティで作成した ``.zst`` ファイルの内容や、生の " +"zstd 圧縮ストリームの読み書きをサポートするファイルインターフェースも含まれて" +"います。" -#: ../../library/compression.zstd.rst:23 msgid "The :mod:`!compression.zstd` module contains:" -msgstr "" +msgstr ":mod:`!compression.zstd` モジュールには次のものが含まれています:" -#: ../../library/compression.zstd.rst:25 msgid "" "The :func:`.open` function and :class:`ZstdFile` class for reading and " "writing compressed files." msgstr "" +"圧縮ファイルを読み書きする :func:`.open` 関数と :class:`ZstdFile` クラス。" -#: ../../library/compression.zstd.rst:27 msgid "" "The :class:`ZstdCompressor` and :class:`ZstdDecompressor` classes for " "incremental (de)compression." msgstr "" +"インクリメンタルに圧縮・展開を行う :class:`ZstdCompressor` クラスと :class:" +"`ZstdDecompressor` クラス。" #: ../../library/compression.zstd.rst:29 msgid "" @@ -66,55 +71,64 @@ msgid "" msgstr "" "一度に圧縮・展開を行う :func:`compress` および :func:`decompress` 関数。" -#: ../../library/compression.zstd.rst:31 msgid "" "The :func:`train_dict` and :func:`finalize_dict` functions and the :class:" "`ZstdDict` class to train and manage Zstandard dictionaries." msgstr "" +"Zstandard 辞書を学習・管理する :func:`train_dict` 関数、:func:" +"`finalize_dict` 関数、:class:`ZstdDict` クラス。" -#: ../../library/compression.zstd.rst:33 msgid "" "The :class:`CompressionParameter`, :class:`DecompressionParameter`, and :" "class:`Strategy` classes for setting advanced (de)compression parameters." msgstr "" +"圧縮・展開の高度なパラメータを設定する :class:`CompressionParameter` クラ" +"ス、:class:`DecompressionParameter` クラス、:class:`Strategy` クラス。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" #: ../../library/compression.zstd.rst:40 msgid "Exceptions" msgstr "例外" -#: ../../library/compression.zstd.rst:44 msgid "" "This exception is raised when an error occurs during compression or " "decompression, or while initializing the (de)compressor state." msgstr "" +"圧縮・展開中、または圧縮・展開オブジェクトの状態の初期化中にエラーが発生する" +"と送出される例外です。" #: ../../library/compression.zstd.rst:49 msgid "Reading and writing compressed files" msgstr "圧縮ファイルへの読み書き" -#: ../../library/compression.zstd.rst:54 msgid "" "Open a Zstandard-compressed file in binary or text mode, returning a :term:" "`file object`." msgstr "" +"Zstandard で圧縮されたファイルをバイナリモードまたはテキストモードで開き、:" +"term:`ファイルオブジェクト ` を返します。" -#: ../../library/compression.zstd.rst:57 msgid "" "The *file* argument can be either a file name (given as a :class:`str`, :" "class:`bytes` or :term:`path-like ` object), in which case " "the named file is opened, or it can be an existing file object to read from " "or write to." msgstr "" +"*file* 引数には、ファイル名 (:class:`str`、:class:`bytes`、または :term:`パス" +"状オブジェクト `) を指定でき、その場合はその名前のファイル" +"を開きます。\n" +"また、読み書きする既存のファイルオブジェクトも指定できます。" -#: ../../library/compression.zstd.rst:62 msgid "" "The mode argument can be either ``'rb'`` for reading (default), ``'wb'`` for " "overwriting, ``'ab'`` for appending, or ``'xb'`` for exclusive creation. " @@ -122,8 +136,12 @@ msgid "" "respectively. You may also open in text mode with ``'rt'``, ``'wt'``, " "``'at'``, and ``'xt'`` respectively." msgstr "" +"``mode`` 引数には、読み込み用 (デフォルト) の ``'rb'``、上書き用の ``'wb'``、" +"追記用の ``'ab'``、排他的な作成用の ``'xb'`` のいずれかを指定できます。\n" +"それぞれ ``'r'``、``'w'``、``'a'``、``'x'`` と指定しても同じです。\n" +"それぞれ ``'rt'``、``'wt'``、``'at'``、``'xt'`` を指定してテキストモードで開" +"くこともできます。" -#: ../../library/compression.zstd.rst:68 ../../library/compression.zstd.rst:112 msgid "" "When reading, the *options* argument can be a dictionary providing advanced " "decompression parameters; see :class:`DecompressionParameter` for detailed " @@ -131,8 +149,14 @@ msgid "" "`ZstdDict` instance to be used during decompression. When reading, if the " "*level* argument is not None, a :exc:`!TypeError` will be raised." msgstr "" +"読み込み時には、展開の高度なパラメータを指定する辞書を *options* 引数に渡せま" +"す。\n" +"サポートされるパラメータの詳細は :class:`DecompressionParameter` を参照してく" +"ださい。\n" +"*zstd_dict* 引数は、展開時に使う :class:`ZstdDict` インスタンスです。\n" +"読み込み時に *level* 引数が ``None`` でない場合は :exc:`!TypeError` を送出し" +"ます。" -#: ../../library/compression.zstd.rst:75 msgid "" "When writing, the *options* argument can be a dictionary providing advanced " "compression parameters; see :class:`CompressionParameter` for detailed " @@ -141,26 +165,35 @@ msgid "" "or *options* may be non-None. The *zstd_dict* argument is a :class:" "`ZstdDict` instance to be used during compression." msgstr "" +"書き込み時には、圧縮の高度なパラメータを指定する辞書を *options* 引数に渡せま" +"す。\n" +"サポートされるパラメータの詳細は :class:`CompressionParameter` を参照してくだ" +"さい。\n" +"*level* 引数は、圧縮データを書き込む際の圧縮レベルです。\n" +"*level* と *options* のうち、``None`` 以外にできるのは一方だけです。\n" +"*zstd_dict* 引数は、圧縮時に使う :class:`ZstdDict` インスタンスです。" -#: ../../library/compression.zstd.rst:83 msgid "" "In binary mode, this function is equivalent to the :class:`ZstdFile` " "constructor: ``ZstdFile(file, mode, ...)``. In this case, the *encoding*, " "*errors*, and *newline* parameters must not be provided." msgstr "" +"バイナリモードでは、この関数は :class:`ZstdFile` コンストラクタ " +"``ZstdFile(file, mode, ...)`` と等価です。\n" +"この場合、*encoding*、*errors*、*newline* パラメータを指定してはいけません。" -#: ../../library/compression.zstd.rst:87 msgid "" "In text mode, a :class:`ZstdFile` object is created, and wrapped in an :" "class:`io.TextIOWrapper` instance with the specified encoding, error " "handling behavior, and line endings." msgstr "" +"テキストモードでは、:class:`ZstdFile` オブジェクトを作成し、指定されたエン" +"コーディング、エラー処理、改行文字で :class:`io.TextIOWrapper` インスタンスに" +"ラップします。" -#: ../../library/compression.zstd.rst:95 msgid "Open a Zstandard-compressed file in binary mode." -msgstr "" +msgstr "Zstandard で圧縮されたファイルをバイナリモードで開きます。" -#: ../../library/compression.zstd.rst:97 msgid "" "A :class:`ZstdFile` can wrap an already-open :term:`file object`, or operate " "directly on a named file. The *file* argument specifies either the file " @@ -169,22 +202,32 @@ msgid "" "existing file object, the wrapped file will not be closed when the :class:" "`ZstdFile` is closed." msgstr "" +":class:`ZstdFile` は、すでに開かれた :term:`ファイルオブジェクト ` をラップすることも、名前で指定したファイルを直接操作することもできま" +"す。\n" +"*file* 引数には、ラップするファイルオブジェクトか、開くファイルの名前 (:" +"class:`str`、:class:`bytes`、または :term:`パス状オブジェクト `) を指定します。\n" +"既存のファイルオブジェクトをラップした場合、:class:`ZstdFile` を閉じても、" +"ラップされたファイルは閉じられません。" -#: ../../library/compression.zstd.rst:104 msgid "" "The *mode* argument can be either ``'rb'`` for reading (default), ``'wb'`` " "for overwriting, ``'xb'`` for exclusive creation, or ``'ab'`` for appending. " "These can equivalently be given as ``'r'``, ``'w'``, ``'x'`` and ``'a'`` " "respectively." msgstr "" +"*mode* 引数には、読み込み用 (デフォルト) の ``'rb'``、上書き用の ``'wb'``、排" +"他的な作成用の ``'xb'``、追記用の ``'ab'`` のいずれかを指定できます。\n" +"それぞれ ``'r'``、``'w'``、``'x'``、``'a'`` と指定しても同じです。" -#: ../../library/compression.zstd.rst:109 msgid "" "If *file* is a file object (rather than an actual file name), a mode of " "``'w'`` does not truncate the file, and is instead equivalent to ``'a'``." msgstr "" +"*file* が実際のファイル名ではなくファイルオブジェクトの場合、モード ``'w'`` " +"はファイルを切り詰めず、``'a'`` と等価になります。" -#: ../../library/compression.zstd.rst:119 msgid "" "When writing, the *options* argument can be a dictionary providing advanced " "compression parameters; see :class:`CompressionParameter` for detailed " @@ -193,13 +236,23 @@ msgid "" "or *options* may be passed. The *zstd_dict* argument is a :class:`ZstdDict` " "instance to be used during compression." msgstr "" +"書き込み時には、圧縮の高度なパラメータを指定する辞書を *options* 引数に渡せま" +"す。\n" +"サポートされるパラメータの詳細は :class:`CompressionParameter` を参照してくだ" +"さい。\n" +"*level* 引数は、圧縮データを書き込む際の圧縮レベルです。\n" +"*level* と *options* は、一方しか渡せません。\n" +"*zstd_dict* 引数は、圧縮時に使う :class:`ZstdDict` インスタンスです。" -#: ../../library/compression.zstd.rst:127 msgid "" ":class:`!ZstdFile` supports all the members specified by :class:`io." "BufferedIOBase`, except for :meth:`~io.BufferedIOBase.detach` and :meth:`~io." "IOBase.truncate`. Iteration and the :keyword:`with` statement are supported." msgstr "" +":class:`!ZstdFile` は、:meth:`~io.BufferedIOBase.detach` と :meth:`~io." +"IOBase.truncate` を除き、:class:`io.BufferedIOBase` で規定されたすべてのメン" +"バーをサポートします。\n" +"反復処理と :keyword:`with` 文もサポートします。" #: ../../library/compression.zstd.rst:132 msgid "The following method and attributes are also provided:" @@ -215,36 +268,39 @@ msgstr "" "り、少なくとも 1 バイトが返されます。返される正確なバイト数は規定されていませ" "ん (引数 *size* は無視されます)。" -#: ../../library/compression.zstd.rst:140 msgid "" "While calling :meth:`peek` does not change the file position of the :class:" "`ZstdFile`, it may change the position of the underlying file object (for " "example, if the :class:`ZstdFile` was constructed by passing a file object " "for *file*)." msgstr "" +":meth:`peek` を呼び出しても :class:`ZstdFile` のファイル位置は変わりません" +"が、基となるファイルオブジェクトの位置は変わる場合があります (例えば、*file* " +"にファイルオブジェクトを渡して :class:`ZstdFile` を構築した場合)。" #: ../../library/compression.zstd.rst:147 msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "``'rb'`` は読み込み用、 ``'wb'`` は書き込み用です。" -#: ../../library/compression.zstd.rst:151 msgid "" "The name of the Zstandard file. Equivalent to the :attr:`~io.FileIO.name` " "attribute of the underlying :term:`file object`." msgstr "" +"Zstandard ファイルの名前です。\n" +"基となる :term:`ファイルオブジェクト ` の :attr:`~io.FileIO." +"name` 属性と等価です。" #: ../../library/compression.zstd.rst:156 msgid "Compressing and decompressing data in memory" msgstr "メモリ上での圧縮と展開" -#: ../../library/compression.zstd.rst:160 msgid "" "Compress *data* (a :term:`bytes-like object`), returning the compressed data " "as a :class:`bytes` object." msgstr "" +"*data* (:term:`バイト列状オブジェクト `) を圧縮し、圧縮" +"データを :class:`bytes` オブジェクトとして返します。" -#: ../../library/compression.zstd.rst:163 -#: ../../library/compression.zstd.rst:207 msgid "" "The *level* argument is an integer controlling the level of compression. " "*level* is an alternative to setting :attr:`CompressionParameter." @@ -254,70 +310,87 @@ msgid "" "*level* argument must be omitted and in the *options* dictionary the :attr:`!" "CompressionParameter.compression_level` parameter should be set." msgstr "" +"*level* 引数は、圧縮レベルを制御する整数です。\n" +"*level* は、*options* に :attr:`CompressionParameter.compression_level` を設" +"定する代わりに使えます。\n" +"*level* に渡せる値を取得するには、:attr:`~CompressionParameter." +"compression_level` の :meth:`~CompressionParameter.bounds` を使ってくださ" +"い。\n" +"高度な圧縮オプションが必要な場合は *level* 引数を省略し、*options* 辞書に :" +"attr:`!CompressionParameter.compression_level` パラメータを設定してください。" -#: ../../library/compression.zstd.rst:172 -#: ../../library/compression.zstd.rst:216 msgid "" "The *options* argument is a Python dictionary containing advanced " "compression parameters. The valid keys and values for compression parameters " "are documented as part of the :class:`CompressionParameter` documentation." msgstr "" +"*options* 引数は、高度な圧縮パラメータを含む Python の辞書です。\n" +"圧縮パラメータの有効なキーと値は、:class:`CompressionParameter` のドキュメン" +"トに記載されています。" -#: ../../library/compression.zstd.rst:176 msgid "" "The *zstd_dict* argument is an instance of :class:`ZstdDict` containing " "trained data to improve compression efficiency. The function :func:" "`train_dict` can be used to generate a Zstandard dictionary." msgstr "" +"*zstd_dict* 引数は、圧縮効率を改善するための学習済みデータを含む :class:" +"`ZstdDict` インスタンスです。\n" +"Zstandard 辞書を生成するには :func:`train_dict` 関数を使えます。" -#: ../../library/compression.zstd.rst:183 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning the uncompressed " "data as a :class:`bytes` object." msgstr "" +"*data* (:term:`バイト列状オブジェクト `) を展開し、展開し" +"たデータを :class:`bytes` オブジェクトとして返します。" -#: ../../library/compression.zstd.rst:186 -#: ../../library/compression.zstd.rst:308 msgid "" "The *options* argument is a Python dictionary containing advanced " "decompression parameters. The valid keys and values for compression " "parameters are documented as part of the :class:`DecompressionParameter` " "documentation." msgstr "" +"*options* 引数は、高度な展開パラメータを含む Python の辞書です。\n" +"パラメータの有効なキーと値は、:class:`DecompressionParameter` のドキュメント" +"に記載されています。" -#: ../../library/compression.zstd.rst:191 -#: ../../library/compression.zstd.rst:313 msgid "" "The *zstd_dict* argument is an instance of :class:`ZstdDict` containing " "trained data used during compression. This must be the same Zstandard " "dictionary used during compression." msgstr "" +"*zstd_dict* 引数は、圧縮時に使った学習済みデータを含む :class:`ZstdDict` イン" +"スタンスです。\n" +"圧縮時に使ったものと同じ Zstandard 辞書でなければなりません。" -#: ../../library/compression.zstd.rst:195 msgid "" "If *data* is the concatenation of multiple distinct compressed frames, " "decompress all of these frames, and return the concatenation of the results." msgstr "" +"*data* が複数の独立した圧縮フレームを連結したものである場合、すべてのフレーム" +"を展開し、その結果を連結して返します。" #: ../../library/compression.zstd.rst:201 msgid "" "Create a compressor object, which can be used to compress data incrementally." msgstr "データをインクリメンタルに圧縮する圧縮オブジェクトを作成します。" -#: ../../library/compression.zstd.rst:204 msgid "" "For a more convenient way of compressing a single chunk of data, see the " "module-level function :func:`compress`." msgstr "" +"単一のデータチャンクをより手軽に圧縮する方法については、モジュールレベルの :" +"func:`compress` 関数を参照してください。" -#: ../../library/compression.zstd.rst:220 msgid "" "The *zstd_dict* argument is an optional instance of :class:`ZstdDict` " "containing trained data to improve compression efficiency. The function :" "func:`train_dict` can be used to generate a Zstandard dictionary." msgstr "" +"*zstd_dict* 引数は省略可能で、圧縮効率を改善するための学習済みデータを含む :" +"class:`ZstdDict` インスタンスを指定します。\n" +"Zstandard 辞書を生成するには :func:`train_dict` 関数を使えます。" -#: ../../library/compression.zstd.rst:227 msgid "" "Compress *data* (a :term:`bytes-like object`), returning a :class:`bytes` " "object with compressed data if possible, or otherwise an empty :class:`!" @@ -325,20 +398,32 @@ msgid "" "calls to :meth:`!compress` and :meth:`~.flush`. The returned data should be " "concatenated with the output of any previous calls to :meth:`~.compress`." msgstr "" +"*data* (:term:`バイト列状オブジェクト `) を圧縮し、可能で" +"あれば圧縮データを含む :class:`bytes` オブジェクトを返し、それ以外の場合は空" +"の :class:`!bytes` オブジェクトを返します。\n" +"*data* の一部は内部にバッファリングされ、後続の :meth:`!compress` や :meth:" +"`~.flush` の呼び出しで使われる場合があります。\n" +"返されたデータは、それ以前の :meth:`~.compress` の呼び出しによる出力と連結し" +"てください。" -#: ../../library/compression.zstd.rst:234 msgid "" "The *mode* argument is a :class:`ZstdCompressor` attribute, either :attr:`~." "CONTINUE`, :attr:`~.FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`." msgstr "" +"*mode* 引数は :class:`ZstdCompressor` の属性である :attr:`~.CONTINUE`、:attr:" +"`~.FLUSH_BLOCK`、:attr:`~.FLUSH_FRAME` のいずれかです。" -#: ../../library/compression.zstd.rst:238 msgid "" "When all data has been provided to the compressor, call the :meth:`~.flush` " "method to finish the compression process. If :meth:`~.compress` is called " "with *mode* set to :attr:`~.FLUSH_FRAME`, :meth:`~.flush` should not be " "called, as it would write out a new empty frame." msgstr "" +"すべてのデータを圧縮オブジェクトに渡したら、:meth:`~.flush` メソッドを呼び出" +"して圧縮処理を完了してください。\n" +"*mode* を :attr:`~.FLUSH_FRAME` にして :meth:`~.compress` を呼び出した場合" +"は、:meth:`~.flush` を呼び出さないでください。\n" +"呼び出すと、新しい空のフレームが書き出されます。" #: ../../library/compression.zstd.rst:246 msgid "" @@ -348,13 +433,13 @@ msgstr "" "圧縮処理を終了し、コンプレッサの内部バッファにあるあらゆるデータを格納する :" "class:`bytes` オブジェクトを返します。" -#: ../../library/compression.zstd.rst:249 msgid "" "The *mode* argument is a :class:`ZstdCompressor` attribute, either :attr:`~." "FLUSH_BLOCK`, or :attr:`~.FLUSH_FRAME`." msgstr "" +"*mode* 引数は :class:`ZstdCompressor` の属性である :attr:`~.FLUSH_BLOCK`、:" +"attr:`~.FLUSH_FRAME` のいずれかです。" -#: ../../library/compression.zstd.rst:254 msgid "" "Specify the amount of uncompressed data *size* that will be provided for the " "next frame. *size* will be written into the frame header of the next frame " @@ -364,8 +449,15 @@ msgid "" "data size require less memory to decompress, especially at higher " "compression levels." msgstr "" +"次のフレームに渡す非圧縮データの量 *size* を指定します。\n" +":attr:`CompressionParameter.content_size_flag` が ``False`` または ``0`` でな" +"い限り、*size* は次のフレームのヘッダーに書き込まれます。\n" +"サイズが ``0`` の場合、そのフレームは空であることを意味します。\n" +"*size* が ``None`` の場合、フレームヘッダーからフレームサイズが省略されま" +"す。\n" +"非圧縮データのサイズを含むフレームは、特に圧縮レベルが高い場合、展開に必要な" +"メモリが少なくなります。" -#: ../../library/compression.zstd.rst:262 msgid "" "If :attr:`last_mode` is not :attr:`FLUSH_FRAME`, a :exc:`ValueError` is " "raised as the compressor is not at the start of a frame. If the pledged size " @@ -373,41 +465,60 @@ msgid "" "calls to :meth:`!compress` or :meth:`flush` may raise :exc:`ZstdError` and " "the last chunk of data may be lost." msgstr "" +":attr:`last_mode` が :attr:`FLUSH_FRAME` でない場合、圧縮オブジェクトがフレー" +"ムの開始位置にないため、:exc:`ValueError` を送出します。\n" +"宣言したサイズが :meth:`.compress` に渡したデータの実際のサイズと一致しない場" +"合、その後の :meth:`!compress` や :meth:`flush` の呼び出しで :exc:" +"`ZstdError` が送出され、最後のデータチャンクが失われる可能性があります。" -#: ../../library/compression.zstd.rst:269 msgid "" "After :meth:`flush` or :meth:`.compress` are called with mode :attr:" "`FLUSH_FRAME`, the next frame will not include the frame size into the " "header unless :meth:`!set_pledged_input_size` is called again." msgstr "" +"``mode`` を :attr:`FLUSH_FRAME` にして :meth:`flush` または :meth:`." +"compress` を呼び出した後は、:meth:`!set_pledged_input_size` を再度呼び出さな" +"い限り、次のフレームのヘッダーにフレームサイズは含まれません。" -#: ../../library/compression.zstd.rst:275 msgid "" "Collect more data for compression, which may or may not generate output " "immediately. This mode optimizes the compression ratio by maximizing the " "amount of data per block and frame." msgstr "" +"圧縮するデータをさらに集めます。\n" +"すぐに出力が生成される場合も、されない場合もあります。\n" +"このモードはブロックとフレームあたりのデータ量を最大化することで圧縮率を最適" +"化します。" -#: ../../library/compression.zstd.rst:281 msgid "" "Complete and write a block to the data stream. The data returned so far can " "be immediately decompressed. Past data can still be referenced in future " "blocks generated by calls to :meth:`~.compress`, improving compression." msgstr "" +"ブロックを完了し、データストリームに書き込みます。\n" +"それまでに返されたデータはすぐに展開できます。\n" +"その後の :meth:`~.compress` の呼び出しで生成するブロックからも過去のデータを" +"参照でき、圧縮率が向上します。" -#: ../../library/compression.zstd.rst:288 msgid "" "Complete and write out a frame. Future data provided to :meth:`~.compress` " "will be written into a new frame and *cannot* reference past data." msgstr "" +"フレームを完了して書き出します。\n" +"その後 :meth:`~.compress` に渡すデータは新しいフレームに書き込まれ、過去の" +"データを参照することは *できません*。" -#: ../../library/compression.zstd.rst:294 msgid "" "The last mode passed to either :meth:`~.compress` or :meth:`~.flush`. The " "value can be one of :attr:`~.CONTINUE`, :attr:`~.FLUSH_BLOCK`, or :attr:`~." "FLUSH_FRAME`. The initial value is :attr:`~.FLUSH_FRAME`, signifying that " "the compressor is at the start of a new frame." msgstr "" +":meth:`~.compress` または :meth:`~.flush` に最後に渡されたモードです。\n" +"値は :attr:`~.CONTINUE`、:attr:`~.FLUSH_BLOCK`、:attr:`~.FLUSH_FRAME` のいず" +"れかです。\n" +"初期値は :attr:`~.FLUSH_FRAME` で、圧縮オブジェクトが新しいフレームの開始位置" +"にあることを表します。" #: ../../library/compression.zstd.rst:302 msgid "" @@ -417,13 +528,13 @@ msgstr "" "データをインクリメンタルに展開するために使用できる展開オブジェクトを作成しま" "す。" -#: ../../library/compression.zstd.rst:305 msgid "" "For a more convenient way of decompressing an entire compressed stream at " "once, see the module-level function :func:`decompress`." msgstr "" +"圧縮ストリーム全体を一度に展開する、より手軽な方法については、モジュールレベ" +"ルの :func:`decompress` 関数を参照してください。" -#: ../../library/compression.zstd.rst:318 msgid "" "This class does not transparently handle inputs containing multiple " "compressed frames, unlike the :func:`decompress` function and :class:" @@ -431,16 +542,25 @@ msgid "" "`decompress`, :class:`ZstdFile` if working with a :term:`file object`, or " "multiple :class:`!ZstdDecompressor` instances." msgstr "" +"このクラスは、:func:`decompress` 関数や :class:`ZstdFile` クラスとは異なり、" +"複数の圧縮フレームを含む入力を自動的には処理しません。\n" +"複数フレームの入力を展開するには、:func:`decompress`、:term:`ファイルオブジェ" +"クト ` を扱う場合は :class:`ZstdFile`、または複数の :class:`!" +"ZstdDecompressor` インスタンスを使ってください。" -#: ../../library/compression.zstd.rst:326 msgid "" "Decompress *data* (a :term:`bytes-like object`), returning uncompressed data " "as bytes. Some of *data* may be buffered internally, for use in later calls " "to :meth:`!decompress`. The returned data should be concatenated with the " "output of any previous calls to :meth:`!decompress`." msgstr "" +"*data* (:term:`バイト列状オブジェクト `) を展開し、展開し" +"たデータをバイト列として返します。\n" +"*data* の一部は内部にバッファリングされ、後続の :meth:`!decompress` の呼び出" +"しで使われる場合があります。\n" +"返されたデータは、それ以前の :meth:`!decompress` の呼び出しによる出力と連結し" +"てください。" -#: ../../library/compression.zstd.rst:332 msgid "" "If *max_length* is non-negative, the method returns at most *max_length* " "bytes of decompressed data. If this limit is reached and further output can " @@ -449,30 +569,41 @@ msgid "" "provide *data* as ``b''`` to obtain more of the output. The full content can " "thus be read like::" msgstr "" +"*max_length* が非負の場合、このメソッドは展開したデータを最大 *max_length* バ" +"イト返します。\n" +"この上限に達し、さらに出力を生成できる場合 (または EOF に達した場合)、:attr:" +"`~.needs_input` 属性は ``False`` に設定されます。\n" +"この場合、次の :meth:`~.decompress` の呼び出しでは *data* に ``b''`` を渡し" +"て、さらに出力を取得できます。\n" +"そのため、内容全体は次のように読み取れます。 ::" -#: ../../library/compression.zstd.rst:339 msgid "" "process_output(d.decompress(data, max_length))\n" "while not d.eof and not d.needs_input:\n" " process_output(d.decompress(b\"\", max_length))" msgstr "" +"process_output(d.decompress(data, max_length))\n" +"while not d.eof and not d.needs_input:\n" +" process_output(d.decompress(b\"\", max_length))" -#: ../../library/compression.zstd.rst:343 msgid "" "If all of the input data was decompressed and returned (either because this " "was less than *max_length* bytes, or because *max_length* was negative), " "the :attr:`~.needs_input` attribute will be set to ``True``." msgstr "" -"入力データの全てが圧縮され返された (*max_length* バイトより少ないためか " +"入力データの全てが展開され返された (*max_length* バイトより少ないためか " "*max_length* が負のため) 場合、\n" ":attr:`~.needs_input` 属性は ``True`` になります。" -#: ../../library/compression.zstd.rst:348 msgid "" "Attempting to decompress data after the end of a frame will raise a :exc:" "`EOFError`. Any data found after the end of the frame is ignored and saved " "in the :attr:`~.unused_data` attribute." msgstr "" +"フレームの終端に達した後でデータを展開しようとすると、:exc:`EOFError` を送出" +"します。\n" +"フレームの終端より後にあるデータは無視され、:attr:`~.unused_data` 属性に保存" +"されます。" #: ../../library/compression.zstd.rst:354 msgid "``True`` if the end-of-stream marker has been reached." @@ -482,21 +613,19 @@ msgstr "ストリーム終端記号に到達した場合 ``True`` を返しま msgid "Data found after the end of the compressed stream." msgstr "圧縮ストリームの末尾以降に存在したデータを表します。" -#: ../../library/compression.zstd.rst:360 msgid "Before the end of the stream is reached, this will be ``b''``." -msgstr "" +msgstr "ストリームの終端に達するまでは ``b''`` です。" -#: ../../library/compression.zstd.rst:364 msgid "" "``False`` if the :meth:`.decompress` method can provide more decompressed " "data before requiring new compressed input." msgstr "" +":meth:`.decompress` メソッドが新たな圧縮入力を必要とせずに、さらに展開データ" +"を提供できる場合は ``False`` です。" -#: ../../library/compression.zstd.rst:369 msgid "Zstandard dictionaries" -msgstr "" +msgstr "Zstandard 辞書" -#: ../../library/compression.zstd.rst:374 msgid "" "Train a Zstandard dictionary, returning a :class:`ZstdDict` instance. " "Zstandard dictionaries enable more efficient compression of smaller sizes of " @@ -505,14 +634,19 @@ msgid "" "files), Zstandard dictionaries can improve compression ratios and speed " "significantly." msgstr "" +"Zstandard 辞書を学習し、:class:`ZstdDict` インスタンスを返します。\n" +"Zstandard 辞書を使うと、繰り返しが少ないため従来は圧縮が難しかった小さなデー" +"タを、より効率よく圧縮できます。\n" +"複数の似たデータ群 (似たファイルなど) を圧縮する場合、Zstandard 辞書によって" +"圧縮率と速度を大きく改善できます。" -#: ../../library/compression.zstd.rst:381 msgid "" "The *samples* argument (an iterable of :class:`bytes` objects), is the " "population of samples used to train the Zstandard dictionary." msgstr "" +"*samples* 引数 (:class:`bytes` オブジェクトのイテラブル) は、Zstandard 辞書の" +"学習に使うサンプルの集まりです。" -#: ../../library/compression.zstd.rst:384 msgid "" "The *dict_size* argument, an integer, is the maximum size (in bytes) the " "Zstandard dictionary should be. The Zstandard documentation suggests an " @@ -521,56 +655,75 @@ msgid "" "compression, but improve compression ratios. Smaller dictionaries lead to " "faster compression, but reduce the compression ratio." msgstr "" +"整数の *dict_size* 引数は、Zstandard 辞書の最大サイズをバイト単位で指定しま" +"す。\n" +"Zstandard のドキュメントでは最大でも 100 KB 以下にすることを勧めていますが、" +"データによってはさらに小さな最大値で十分な場合があります。\n" +"一般に、辞書が大きいと圧縮は遅くなるものの圧縮率が向上します。\n" +"辞書が小さいと圧縮は速くなるものの圧縮率が低下します。" -#: ../../library/compression.zstd.rst:394 msgid "" "An advanced function for converting a \"raw content\" Zstandard dictionary " "into a regular Zstandard dictionary. \"Raw content\" dictionaries are a " "sequence of bytes that do not need to follow the structure of a normal " "Zstandard dictionary." msgstr "" +"「生の内容」の Zstandard 辞書を通常の Zstandard 辞書に変換する高度な関数で" +"す。\n" +"「生の内容」の辞書は、通常の Zstandard 辞書の構造に従う必要のないバイト列で" +"す。" -#: ../../library/compression.zstd.rst:399 msgid "" "The *zstd_dict* argument is a :class:`ZstdDict` instance with the :attr:" "`~ZstdDict.dict_content` containing the raw dictionary contents." msgstr "" +"*zstd_dict* 引数は、:attr:`~ZstdDict.dict_content` に生の辞書の内容を格納し" +"た :class:`ZstdDict` インスタンスです。" -#: ../../library/compression.zstd.rst:402 msgid "" "The *samples* argument (an iterable of :class:`bytes` objects), contains " "sample data for generating the Zstandard dictionary." msgstr "" +"*samples* 引数 (:class:`bytes` オブジェクトのイテラブル) は、Zstandard 辞書を" +"生成するためのサンプルデータを含みます。" -#: ../../library/compression.zstd.rst:405 msgid "" "The *dict_size* argument, an integer, is the maximum size (in bytes) the " "Zstandard dictionary should be. See :func:`train_dict` for suggestions on " "the maximum dictionary size." msgstr "" +"整数の *dict_size* 引数は、Zstandard 辞書の最大サイズをバイト単位で指定しま" +"す。\n" +"辞書の最大サイズについての推奨は :func:`train_dict` を参照してください。" -#: ../../library/compression.zstd.rst:409 msgid "" "The *level* argument (an integer) is the compression level expected to be " "passed to the compressors using this dictionary. The dictionary information " "varies for each compression level, so tuning for the proper compression " "level can make compression more efficient." msgstr "" +"*level* 引数 (整数) は、この辞書を使う圧縮オブジェクトに渡す予定の圧縮レベル" +"です。\n" +"辞書の情報は圧縮レベルごとに異なるため、適切な圧縮レベルに調整すると圧縮効率" +"を改善できます。" -#: ../../library/compression.zstd.rst:417 msgid "" "A wrapper around Zstandard dictionaries. Dictionaries can be used to improve " "the compression of many small chunks of data. Use :func:`train_dict` if you " "need to train a new dictionary from sample data." msgstr "" +"Zstandard 辞書のラッパです。\n" +"辞書を使うと、多数の小さなデータチャンクの圧縮を改善できます。\n" +"サンプルデータから新しい辞書を学習する必要がある場合は、:func:`train_dict` を" +"使ってください。" -#: ../../library/compression.zstd.rst:421 msgid "" "The *dict_content* argument (a :term:`bytes-like object`), is the already " "trained dictionary information." msgstr "" +"*dict_content* 引数 (:term:`バイト列状オブジェクト `) は、" +"学習済みの辞書情報です。" -#: ../../library/compression.zstd.rst:424 msgid "" "The *is_raw* argument, a boolean, is an advanced parameter controlling the " "meaning of *dict_content*. ``True`` means *dict_content* is a \"raw " @@ -579,8 +732,12 @@ msgid "" "functions, for example, :func:`train_dict` or the external :program:`zstd` " "CLI." msgstr "" +"真偽値の *is_raw* 引数は、*dict_content* の意味を制御する高度なパラメータで" +"す。\n" +"``True`` の場合、*dict_content* は形式の制約がない「生の内容」の辞書です。\n" +"``False`` の場合、*dict_content* は :func:`train_dict` などの Zstandard の関" +"数や外部の :program:`zstd` CLI で作成された通常の Zstandard 辞書です。" -#: ../../library/compression.zstd.rst:430 msgid "" "When passing a :class:`!ZstdDict` to a function, the :attr:`!" "as_digested_dict` and :attr:`!as_undigested_dict` attributes can control how " @@ -591,141 +748,155 @@ msgid "" "passing a digested dictionary will reduce the overhead of loading the " "dictionary." msgstr "" +":class:`!ZstdDict` を関数に渡す際、:attr:`!as_digested_dict` または :attr:`!" +"as_undigested_dict` 属性を ``zstd_dict`` 引数として渡すと、辞書の読み込み方法" +"を制御できます。\n" +"例えば、``compress(data, zstd_dict=zd.as_digested_dict)`` とします。\n" +"辞書の前処理 (digest) は、Zstandard 辞書の読み込み時に行われるコストの高い処" +"理です。\n" +"圧縮や展開を複数回呼び出す場合、前処理済みの辞書を渡すと、辞書の読み込みにか" +"かるオーバーヘッドを減らせます。" -#: ../../library/compression.zstd.rst:439 msgid "Difference for compression" -msgstr "" +msgstr "圧縮時の違い" -#: ../../library/compression.zstd.rst:444 msgid "Digested dictionary" -msgstr "" +msgstr "前処理済みの辞書" -#: ../../library/compression.zstd.rst:445 msgid "Undigested dictionary" -msgstr "" +msgstr "前処理していない辞書" -#: ../../library/compression.zstd.rst:446 msgid "" "Advanced parameters of the compressor which may be overridden by the " "dictionary's parameters" msgstr "" +"辞書のパラメータによって上書きされる可能性がある圧縮オブジェクトの高度なパラ" +"メータ" -#: ../../library/compression.zstd.rst:448 msgid "" "``window_log``, ``hash_log``, ``chain_log``, ``search_log``, ``min_match``, " "``target_length``, ``strategy``, ``enable_long_distance_matching``, " "``ldm_hash_log``, ``ldm_min_match``, ``ldm_bucket_size_log``, " "``ldm_hash_rate_log``, and some non-public parameters." msgstr "" +"``window_log``、``hash_log``、``chain_log``、``search_log``、``min_match``、" +"``target_length``、``strategy``、``enable_long_distance_matching``、" +"``ldm_hash_log``、``ldm_min_match``、``ldm_bucket_size_log``、" +"``ldm_hash_rate_log``、および一部の非公開パラメータ。" #: ../../library/compression.zstd.rst:453 msgid "None" msgstr "None" -#: ../../library/compression.zstd.rst:454 msgid ":class:`!ZstdDict` internally caches the dictionary" -msgstr "" +msgstr ":class:`!ZstdDict` が辞書を内部でキャッシュするか" -#: ../../library/compression.zstd.rst:455 msgid "" "Yes. It's faster when loading a digested dictionary again with the same " "compression level." msgstr "" +"はい。\n" +"同じ圧縮レベルで前処理済みの辞書を再び読み込む場合に高速になります。" -#: ../../library/compression.zstd.rst:457 msgid "" "No. If you wish to load an undigested dictionary multiple times, consider " "reusing a compressor object." msgstr "" +"いいえ。\n" +"前処理していない辞書を複数回読み込む場合は、圧縮オブジェクトの再利用を検討し" +"てください。" -#: ../../library/compression.zstd.rst:460 msgid "" "If passing a :class:`!ZstdDict` without any attribute, an undigested " "dictionary is passed by default when compressing and a digested dictionary " "is generated if necessary and passed by default when decompressing." msgstr "" +"属性を使わずに :class:`!ZstdDict` を渡した場合、圧縮時にはデフォルトで前処理" +"していない辞書が渡されます。\n" +"展開時には、必要に応じて前処理済みの辞書が生成され、デフォルトで渡されます。" -#: ../../library/compression.zstd.rst:466 msgid "" "The content of the Zstandard dictionary, a ``bytes`` object. It's the same " "as the *dict_content* argument in the ``__init__`` method. It can be used " "with other programs, such as the ``zstd`` CLI program." msgstr "" +"Zstandard 辞書の内容を表す ``bytes`` オブジェクトです。\n" +"``__init__`` メソッドの *dict_content* 引数と同じものです。\n" +"``zstd`` CLI プログラムなど、他のプログラムで使うこともできます。" -#: ../../library/compression.zstd.rst:472 msgid "Identifier of the Zstandard dictionary, a non-negative int value." -msgstr "" +msgstr "Zstandard 辞書の識別子を表す非負の整数値です。" -#: ../../library/compression.zstd.rst:474 msgid "" "Non-zero means the dictionary is ordinary, created by Zstandard functions " "and following the Zstandard format." msgstr "" +"0 以外の場合、Zstandard の関数で作成され、Zstandard 形式に従う通常の辞書であ" +"ることを意味します。" -#: ../../library/compression.zstd.rst:477 msgid "" "``0`` means a \"raw content\" dictionary, free of any format restriction, " "used for advanced users." msgstr "" +"``0`` は、上級ユーザー向けの、形式の制約がない「生の内容」の辞書を意味しま" +"す。" -#: ../../library/compression.zstd.rst:482 msgid "" "The meaning of ``0`` for :attr:`!ZstdDict.dict_id` is different from the " "``dictionary_id`` attribute to the :func:`get_frame_info` function." msgstr "" +":attr:`!ZstdDict.dict_id` における ``0`` の意味は、:func:`get_frame_info` 関" +"数が返すオブジェクトの ``dictionary_id`` 属性における意味とは異なります。" -#: ../../library/compression.zstd.rst:488 msgid "Load as a digested dictionary." -msgstr "" +msgstr "前処理済みの辞書として読み込みます。" -#: ../../library/compression.zstd.rst:492 msgid "Load as an undigested dictionary." -msgstr "" +msgstr "前処理していない辞書として読み込みます。" -#: ../../library/compression.zstd.rst:496 msgid "Advanced parameter control" -msgstr "" +msgstr "高度なパラメータの制御" -#: ../../library/compression.zstd.rst:500 msgid "" "An :class:`~enum.IntEnum` containing the advanced compression parameter keys " "that can be used when compressing data." msgstr "" +"データの圧縮時に使える高度な圧縮パラメータのキーを含む :class:`~enum." +"IntEnum` です。" -#: ../../library/compression.zstd.rst:503 -#: ../../library/compression.zstd.rst:737 msgid "" "The :meth:`~.bounds` method can be used on any attribute to get the valid " "values for that parameter." msgstr "" +"各属性で :meth:`~.bounds` メソッドを使うと、そのパラメータの有効な値を取得で" +"きます。" -#: ../../library/compression.zstd.rst:506 msgid "" "Parameters are optional; any omitted parameter will have its value selected " "automatically." msgstr "" +"パラメータは省略可能です。\n" +"省略したパラメータの値は自動的に選択されます。" -#: ../../library/compression.zstd.rst:509 msgid "" "Example getting the lower and upper bound of :attr:`~.compression_level`::" -msgstr "" +msgstr ":attr:`~.compression_level` の下限と上限を取得する例。 ::" -#: ../../library/compression.zstd.rst:511 msgid "lower, upper = CompressionParameter.compression_level.bounds()" -msgstr "" +msgstr "lower, upper = CompressionParameter.compression_level.bounds()" -#: ../../library/compression.zstd.rst:513 msgid "Example setting the :attr:`~.window_log` to the maximum size::" -msgstr "" +msgstr ":attr:`~.window_log` を最大サイズに設定する例。 ::" -#: ../../library/compression.zstd.rst:515 msgid "" "_lower, upper = CompressionParameter.window_log.bounds()\n" "options = {CompressionParameter.window_log: upper}\n" "compress(b'venezuelan beaver cheese', options=options)" msgstr "" +"_lower, upper = CompressionParameter.window_log.bounds()\n" +"options = {CompressionParameter.window_log: upper}\n" +"compress(b'venezuelan beaver cheese', options=options)" -#: ../../library/compression.zstd.rst:521 msgid "" "Return the tuple of int bounds, ``(lower, upper)``, of a compression " "parameter. This method should be called on the attribute you wish to " @@ -733,62 +904,61 @@ msgid "" "compression_level`, one may check the result of ``CompressionParameter." "compression_level.bounds()``." msgstr "" +"圧縮パラメータの整数の範囲を、タプル ``(lower, upper)`` として返します。\n" +"このメソッドは、範囲を取得したい属性に対して呼び出してください。\n" +"例えば、:attr:`~.compression_level` の有効な値を取得するには、" +"``CompressionParameter.compression_level.bounds()`` の結果を調べます。" -#: ../../library/compression.zstd.rst:527 -#: ../../library/compression.zstd.rst:755 msgid "Both the lower and upper bounds are inclusive." -msgstr "" +msgstr "下限と上限は、どちらも範囲に含まれます。" -#: ../../library/compression.zstd.rst:531 msgid "" "A high-level means of setting other compression parameters that affect the " "speed and ratio of compressing data." msgstr "" +"データの圧縮速度や圧縮率に影響する他の圧縮パラメータを設定する、高水準の手段" +"です。" -#: ../../library/compression.zstd.rst:534 msgid "" "Regular compression levels are greater than ``0``. Values greater than " "``20`` are considered \"ultra\" compression and require more memory than " "other levels. Negative values can be used to trade off faster compression " "for worse compression ratios." msgstr "" +"通常の圧縮レベルは ``0`` より大きい値です。\n" +"``20`` より大きい値は「ultra」圧縮とみなされ、他のレベルより多くのメモリを必" +"要とします。\n" +"負の値を使うと、圧縮率を下げる代わりに圧縮を高速化できます。" -#: ../../library/compression.zstd.rst:539 msgid "Setting the level to zero uses :attr:`COMPRESSION_LEVEL_DEFAULT`." msgstr "" +"レベルを 0 に設定すると :attr:`COMPRESSION_LEVEL_DEFAULT` が使われます。" -#: ../../library/compression.zstd.rst:543 msgid "" "Maximum allowed back-reference distance the compressor can use when " "compressing data, expressed as power of two, ``1 << window_log`` bytes. This " "parameter greatly influences the memory usage of compression. Higher values " "require more memory but gain better compression values." msgstr "" +"圧縮時に使用できる後方参照の最大距離を 2 のべき乗で表したものです。\n" +"距離は ``1 << window_log`` バイトになります。\n" +"このパラメータは圧縮時のメモリ使用量に大きく影響します。\n" +"値が大きいほど多くのメモリを必要としますが、圧縮率が向上します。" -#: ../../library/compression.zstd.rst:548 -#: ../../library/compression.zstd.rst:557 -#: ../../library/compression.zstd.rst:568 -#: ../../library/compression.zstd.rst:576 -#: ../../library/compression.zstd.rst:587 -#: ../../library/compression.zstd.rst:602 -#: ../../library/compression.zstd.rst:633 -#: ../../library/compression.zstd.rst:640 -#: ../../library/compression.zstd.rst:648 -#: ../../library/compression.zstd.rst:656 -#: ../../library/compression.zstd.rst:715 -#: ../../library/compression.zstd.rst:764 msgid "A value of zero causes the value to be selected automatically." -msgstr "" +msgstr "値を 0 にすると、自動的に値が選択されます。" -#: ../../library/compression.zstd.rst:552 msgid "" "Size of the initial probe table, as a power of two. The resulting memory " "usage is ``1 << (hash_log+2)`` bytes. Larger tables improve compression " "ratio of strategies <= :attr:`~Strategy.dfast`, and improve compression " "speed of strategies > :attr:`~Strategy.dfast`." msgstr "" +"最初の探索テーブルのサイズを 2 のべき乗で表したものです。\n" +"メモリ使用量は ``1 << (hash_log+2)`` バイトになります。\n" +"テーブルが大きいほど、ストラテジーが :attr:`~Strategy.dfast` 以下の場合は圧縮" +"率が向上し、:attr:`~Strategy.dfast` より大きい場合は圧縮速度が向上します。" -#: ../../library/compression.zstd.rst:561 msgid "" "Size of the multi-probe search table, as a power of two. The resulting " "memory usage is ``1 << (chain_log+2)`` bytes. Larger tables result in better " @@ -796,15 +966,23 @@ msgid "" "`~Strategy.fast` strategy. It's still useful when using :attr:`~Strategy." "dfast` strategy, in which case it defines a secondary probe table." msgstr "" +"複数回の探索に使うテーブルのサイズを 2 のべき乗で表したものです。\n" +"メモリ使用量は ``1 << (chain_log+2)`` バイトになります。\n" +"テーブルが大きいほど圧縮率が向上しますが、圧縮は遅くなります。\n" +"このパラメータは :attr:`~Strategy.fast` ストラテジーでは効果がありません。\n" +":attr:`~Strategy.dfast` ストラテジーでは、二つ目の探索テーブルを定義するため" +"有効です。" -#: ../../library/compression.zstd.rst:572 msgid "" "Number of search attempts, as a power of two. More attempts result in better " "and slower compression. This parameter is useless for :attr:`~Strategy.fast` " "and :attr:`~Strategy.dfast` strategies." msgstr "" +"探索を試みる回数を 2 のべき乗で表したものです。\n" +"回数が多いほど圧縮率が向上しますが、圧縮は遅くなります。\n" +"このパラメータは :attr:`~Strategy.fast` と :attr:`~Strategy.dfast` ストラテ" +"ジーでは役に立ちません。" -#: ../../library/compression.zstd.rst:580 msgid "" "Minimum size of searched matches. Larger values increase compression and " "decompression speed, but decrease ratio. Note that Zstandard can still find " @@ -813,49 +991,66 @@ msgid "" "effective minimum is ``4``; for all strategies > :attr:`~Strategy.fast`, the " "effective maximum is ``6``." msgstr "" +"検索する一致部分の最小サイズです。\n" +"値が大きいほど圧縮と展開が速くなりますが、圧縮率は低下します。\n" +"ただし、Zstandard はこれより小さい一致部分も見つけることがあります。\n" +"このパラメータは、指定したサイズ以上の一致を探すよう検索アルゴリズムを調整す" +"るだけです。\n" +":attr:`~Strategy.btopt` より小さいすべてのストラテジーでは実効的な最小値は " +"``4`` です。\n" +":attr:`~Strategy.fast` より大きいすべてのストラテジーでは実効的な最大値は " +"``6`` です。" -#: ../../library/compression.zstd.rst:591 msgid "The impact of this field depends on the selected :class:`Strategy`." msgstr "" +"このフィールドの効果は、選択した :class:`Strategy` によって異なります。" -#: ../../library/compression.zstd.rst:593 msgid "" "For strategies :attr:`~Strategy.btopt`, :attr:`~Strategy.btultra` and :attr:" "`~Strategy.btultra2`, the value is the length of a match considered \"good " "enough\" to stop searching. Larger values make compression ratios better, " "but compresses slower." msgstr "" +":attr:`~Strategy.btopt`、:attr:`~Strategy.btultra`、:attr:`~Strategy." +"btultra2` ストラテジーでは、この値は、探索を打ち切るのに「十分によい」とみな" +"す一致部分の長さです。\n" +"値が大きいほど圧縮率が向上しますが、圧縮は遅くなります。" -#: ../../library/compression.zstd.rst:598 msgid "" "For strategy :attr:`~Strategy.fast`, it is the distance between match " "sampling. Larger values make compression faster, but with a worse " "compression ratio." msgstr "" +":attr:`~Strategy.fast` ストラテジーでは、一致を調べるサンプリングの間隔で" +"す。\n" +"値が大きいほど圧縮は速くなりますが、圧縮率は低下します。" -#: ../../library/compression.zstd.rst:606 msgid "" "The higher the value of selected strategy, the more complex the compression " "technique used by zstd, resulting in higher compression ratios but slower " "compression." msgstr "" +"選択したストラテジーの値が大きいほど、zstd は複雑な圧縮手法を使うため、圧縮率" +"は向上しますが圧縮は遅くなります。" -#: ../../library/compression.zstd.rst:610 msgid ":class:`Strategy`" -msgstr "" +msgstr ":class:`Strategy`" -#: ../../library/compression.zstd.rst:614 msgid "" "Long distance matching can be used to improve compression for large inputs " "by finding large matches at greater distances. It increases memory usage and " "window size." msgstr "" +"長距離マッチングを使うと、遠く離れた位置にある長い一致部分を見つけ、大きな入" +"力の圧縮を改善できます。\n" +"メモリ使用量とウィンドウサイズは増加します。" -#: ../../library/compression.zstd.rst:618 msgid "" "``True`` or ``1`` enable long distance matching while ``False`` or ``0`` " "disable it." msgstr "" +"``True`` または ``1`` は長距離マッチングを有効にし、``False`` または ``0`` は" +"無効にします。" #: ../../library/compression.zstd.rst:621 msgid "" @@ -865,157 +1060,186 @@ msgid "" "compression strategy >= :attr:`~Strategy.btopt` (compression level 16+)." msgstr "" -#: ../../library/compression.zstd.rst:629 msgid "" "Size of the table for long distance matching, as a power of two. Larger " "values increase memory usage and compression ratio, but decrease compression " "speed." msgstr "" +"長距離マッチング用のテーブルのサイズを 2 のべき乗で表したものです。\n" +"値が大きいほどメモリ使用量と圧縮率が増加しますが、圧縮速度は低下します。" -#: ../../library/compression.zstd.rst:637 msgid "" "Minimum match size for long distance matcher. Larger or too small values can " "often decrease the compression ratio." msgstr "" +"長距離マッチングでの一致部分の最小サイズです。\n" +"値が大きい場合や小さすぎる場合は、圧縮率が低下することがよくあります。" -#: ../../library/compression.zstd.rst:644 msgid "" "Log size of each bucket in the long distance matcher hash table for " "collision resolution. Larger values improve collision resolution but " "decrease compression speed." msgstr "" +"長距離マッチング用のハッシュテーブルで衝突を解決するための、各バケットのサイ" +"ズの対数です。\n" +"値が大きいほど衝突の解決が改善しますが、圧縮速度は低下します。" -#: ../../library/compression.zstd.rst:652 msgid "" "Frequency of inserting/looking up entries into the long distance matcher " "hash table. Larger values improve compression speed. Deviating far from the " "default value will likely result in a compression ratio decrease." msgstr "" +"長距離マッチング用のハッシュテーブルに対して、エントリーを挿入・検索する頻度" +"です。\n" +"値が大きいほど圧縮速度が向上します。\n" +"デフォルト値から大きく外れると、圧縮率が低下する可能性が高くなります。" -#: ../../library/compression.zstd.rst:660 msgid "" "Write the size of the data to be compressed into the Zstandard frame header " "when known prior to compressing." msgstr "" +"圧縮するデータのサイズが圧縮前に分かっている場合、そのサイズを Zstandard フ" +"レームのヘッダーに書き込みます。" -#: ../../library/compression.zstd.rst:663 msgid "This flag only takes effect under the following scenarios:" -msgstr "" +msgstr "このフラグは、次の場合にのみ効果があります:" -#: ../../library/compression.zstd.rst:665 msgid "Calling :func:`compress` for one-shot compression" -msgstr "" +msgstr "一度に圧縮するために :func:`compress` を呼び出す場合" -#: ../../library/compression.zstd.rst:666 msgid "" "Providing all of the data to be compressed in the frame in a single :meth:" "`ZstdCompressor.compress` call, with the :attr:`ZstdCompressor.FLUSH_FRAME` " "mode." msgstr "" +":attr:`ZstdCompressor.FLUSH_FRAME` モードで :meth:`ZstdCompressor.compress` " +"を一度だけ呼び出し、そのフレームに圧縮するすべてのデータを渡す場合。" -#: ../../library/compression.zstd.rst:669 msgid "" "Calling :meth:`ZstdCompressor.set_pledged_input_size` with the exact amount " "of data that will be provided to the compressor prior to any calls to :meth:" "`ZstdCompressor.compress` for the current frame. :meth:`!ZstdCompressor." "set_pledged_input_size` must be called for each new frame." msgstr "" +"現在のフレームに対して :meth:`ZstdCompressor.compress` を呼び出す前に、圧縮オ" +"ブジェクトに渡す正確なデータ量で :meth:`ZstdCompressor." +"set_pledged_input_size` を呼び出す場合。\n" +"新しいフレームごとに :meth:`!ZstdCompressor.set_pledged_input_size` を呼び出" +"さなければなりません。" -#: ../../library/compression.zstd.rst:675 msgid "" "All other compression calls may not write the size information into the " "frame header." msgstr "" +"それ以外の圧縮の呼び出しでは、サイズ情報がフレームヘッダーに書き込まれない場" +"合があります。" -#: ../../library/compression.zstd.rst:678 msgid "" "``True`` or ``1`` enable the content size flag while ``False`` or ``0`` " "disable it." msgstr "" +"``True`` または ``1`` は内容サイズのフラグを有効にし、``False`` または ``0`` " +"は無効にします。" -#: ../../library/compression.zstd.rst:683 msgid "" "A four-byte checksum using XXHash64 of the uncompressed content is written " "at the end of each frame. Zstandard's decompression code verifies the " "checksum. If there is a mismatch a :class:`ZstdError` exception is raised." msgstr "" +"非圧縮の内容から XXHash64 で計算した 4 バイトのチェックサムを、各フレームの末" +"尾に書き込みます。\n" +"Zstandard の展開コードはこのチェックサムを検証します。\n" +"一致しない場合は :class:`ZstdError` 例外を送出します。" -#: ../../library/compression.zstd.rst:688 msgid "" "``True`` or ``1`` enable checksum generation while ``False`` or ``0`` " "disable it." msgstr "" +"``True`` または ``1`` はチェックサムの生成を有効にし、``False`` または ``0`` " +"は無効にします。" -#: ../../library/compression.zstd.rst:693 msgid "" "When compressing with a :class:`ZstdDict`, the dictionary's ID is written " "into the frame header." msgstr "" +":class:`ZstdDict` を使って圧縮する際、辞書の ID をフレームヘッダーに書き込み" +"ます。" -#: ../../library/compression.zstd.rst:696 msgid "" "``True`` or ``1`` enable storing the dictionary ID while ``False`` or ``0`` " "disable it." msgstr "" +"``True`` または ``1`` は辞書 ID の保存を有効にし、``False`` または ``0`` は無" +"効にします。" -#: ../../library/compression.zstd.rst:701 msgid "" "Select how many threads will be spawned to compress in parallel. When :attr:" "`!nb_workers` > 0, enables multi-threaded compression, a value of ``1`` " "means \"one-thread multi-threaded mode\". More workers improve speed, but " "also increase memory usage and slightly reduce compression ratio." msgstr "" +"並列に圧縮するために起動するスレッド数を選択します。\n" +":attr:`!nb_workers` が 0 より大きい場合、マルチスレッド圧縮が有効になりま" +"す。\n" +"値 ``1`` は「1 スレッドのマルチスレッドモード」を意味します。\n" +"ワーカーが多いほど速度が向上しますが、メモリ使用量も増加し、圧縮率はわずかに" +"低下します。" -#: ../../library/compression.zstd.rst:706 msgid "A value of zero disables multi-threading." -msgstr "" +msgstr "値を 0 にすると、マルチスレッド処理が無効になります。" -#: ../../library/compression.zstd.rst:710 msgid "" "Size of a compression job, in bytes. This value is enforced only when :attr:" "`~CompressionParameter.nb_workers` >= 1. Each compression job is completed " "in parallel, so this value can indirectly impact the number of active " "threads." msgstr "" +"圧縮ジョブのサイズ (バイト単位) です。\n" +"この値は、:attr:`~CompressionParameter.nb_workers` が 1 以上の場合にのみ適用" +"されます。\n" +"各圧縮ジョブは並列に実行されるため、この値はアクティブなスレッド数に間接的に" +"影響する場合があります。" -#: ../../library/compression.zstd.rst:719 msgid "" "Sets how much data is reloaded from previous jobs (threads) for new jobs to " "be used by the look behind window during compression. This value is only " "used when :attr:`~CompressionParameter.nb_workers` >= 1. Acceptable values " "vary from 0 to 9." msgstr "" +"新しいジョブで圧縮時の後方参照ウィンドウに使うために、前のジョブ (スレッド) " +"から再読み込みするデータ量を設定します。\n" +"この値は、:attr:`~CompressionParameter.nb_workers` が 1 以上の場合にのみ使わ" +"れます。\n" +"指定できる値は 0 から 9 です。" -#: ../../library/compression.zstd.rst:724 msgid "0 means dynamically set the overlap amount" -msgstr "" +msgstr "0 は重複量を動的に設定することを意味します" -#: ../../library/compression.zstd.rst:725 msgid "1 means no overlap" -msgstr "" +msgstr "1 は重複なしを意味します" -#: ../../library/compression.zstd.rst:726 msgid "9 means use a full window size from the previous job" -msgstr "" +msgstr "9 は前のジョブのウィンドウサイズ全体を使うことを意味します" -#: ../../library/compression.zstd.rst:728 msgid "" "Each increment halves/doubles the overlap size. \"8\" means an overlap of " "``window_size/2``, \"7\" means an overlap of ``window_size/4``, etc." msgstr "" +"値を一つ減らすと重複サイズは半分になり、一つ増やすと倍になります。\n" +"「8」は ``window_size/2``、「7」は ``window_size/4`` の重複を意味します。" -#: ../../library/compression.zstd.rst:733 msgid "" "An :class:`~enum.IntEnum` containing the advanced decompression parameter " "keys that can be used when decompressing data. Parameters are optional; any " "omitted parameter will have its value selected automatically." msgstr "" +"データの展開時に使える高度な展開パラメータのキーを含む :class:`~enum." +"IntEnum` です。\n" +"パラメータは省略可能で、省略したパラメータの値は自動的に選択されます。" -#: ../../library/compression.zstd.rst:740 msgid "Example setting the :attr:`~.window_log_max` to the maximum size::" -msgstr "" +msgstr ":attr:`~.window_log_max` を最大サイズに設定する例。 ::" -#: ../../library/compression.zstd.rst:742 msgid "" "data = compress(b'Some very long buffer of bytes...')\n" "\n" @@ -1024,96 +1248,111 @@ msgid "" "options = {DecompressionParameter.window_log_max: upper}\n" "decompress(data, options=options)" msgstr "" +"data = compress(b'Some very long buffer of bytes...')\n" +"\n" +"_lower, upper = DecompressionParameter.window_log_max.bounds()\n" +"\n" +"options = {DecompressionParameter.window_log_max: upper}\n" +"decompress(data, options=options)" -#: ../../library/compression.zstd.rst:751 msgid "" "Return the tuple of int bounds, ``(lower, upper)``, of a decompression " "parameter. This method should be called on the attribute you wish to " "retrieve the bounds of." msgstr "" +"展開パラメータの整数の範囲を、タプル ``(lower, upper)`` として返します。\n" +"このメソッドは、範囲を取得したい属性に対して呼び出してください。" -#: ../../library/compression.zstd.rst:759 msgid "" "The base-two logarithm of the maximum size of the window used during " "decompression. This can be useful to limit the amount of memory used when " "decompressing data. A larger maximum window size leads to faster " "decompression." msgstr "" +"展開時に使うウィンドウの最大サイズの、2 を底とする対数です。\n" +"展開時のメモリ使用量を制限するのに役立ちます。\n" +"ウィンドウの最大サイズが大きいほど、展開は速くなります。" -#: ../../library/compression.zstd.rst:769 msgid "" "An :class:`~enum.IntEnum` containing strategies for compression. Higher-" "numbered strategies correspond to more complex and slower compression." msgstr "" +"圧縮ストラテジーを含む :class:`~enum.IntEnum` です。\n" +"数値が大きいストラテジーほど、複雑で遅い圧縮に対応します。" -#: ../../library/compression.zstd.rst:775 msgid "" "The values of attributes of :class:`!Strategy` are not necessarily stable " "across zstd versions. Only the ordering of the attributes may be relied " "upon. The attributes are listed below in order." msgstr "" +":class:`!Strategy` の属性の値は、zstd のバージョン間で必ずしも一定ではありま" +"せん。\n" +"依存できるのは属性の順序だけです。\n" +"以下に属性を順番に示します。" -#: ../../library/compression.zstd.rst:779 msgid "The following strategies are available:" -msgstr "" +msgstr "次のストラテジーを利用できます:" #: ../../library/compression.zstd.rst:801 msgid "Miscellaneous" msgstr "その他" -#: ../../library/compression.zstd.rst:805 msgid "" "Retrieve a :class:`FrameInfo` object containing metadata about a Zstandard " "frame. Frames contain metadata related to the compressed data they hold." msgstr "" +"Zstandard フレームのメタデータを含む :class:`FrameInfo` オブジェクトを取得し" +"ます。\n" +"フレームには、格納する圧縮データに関するメタデータが含まれています。" -#: ../../library/compression.zstd.rst:811 msgid "Metadata related to a Zstandard frame." -msgstr "" +msgstr "Zstandard フレームに関するメタデータです。" -#: ../../library/compression.zstd.rst:815 msgid "The size of the decompressed contents of the frame." -msgstr "" +msgstr "フレームの内容を展開したサイズです。" -#: ../../library/compression.zstd.rst:819 msgid "" "An integer representing the Zstandard dictionary ID needed for decompressing " "the frame. ``0`` means the dictionary ID was not recorded in the frame " "header. This may mean that a Zstandard dictionary is not needed, or that the " "ID of a required dictionary was not recorded." msgstr "" +"フレームの展開に必要な Zstandard 辞書の ID を表す整数です。\n" +"``0`` は、辞書 ID がフレームヘッダーに記録されていないことを意味します。\n" +"Zstandard 辞書が不要な場合もあれば、必要な辞書の ID が記録されていない場合も" +"あります。" -#: ../../library/compression.zstd.rst:827 msgid "The default compression level for Zstandard: ``3``." -msgstr "" +msgstr "Zstandard のデフォルトの圧縮レベル: ``3``。" -#: ../../library/compression.zstd.rst:832 msgid "" "Version number of the runtime zstd library as a tuple of integers (major, " "minor, release)." msgstr "" +"実行時に使う zstd ライブラリのバージョン番号を表す整数のタプル (major, " +"minor, release) です。" #: ../../library/compression.zstd.rst:837 msgid "Examples" msgstr "使用例" -#: ../../library/compression.zstd.rst:839 msgid "Reading in a compressed file:" -msgstr "" +msgstr "圧縮ファイルの読み込み:" -#: ../../library/compression.zstd.rst:841 msgid "" "from compression import zstd\n" "\n" "with zstd.open(\"file.zst\") as f:\n" " file_content = f.read()" msgstr "" +"from compression import zstd\n" +"\n" +"with zstd.open(\"file.zst\") as f:\n" +" file_content = f.read()" -#: ../../library/compression.zstd.rst:848 msgid "Creating a compressed file:" -msgstr "" +msgstr "圧縮ファイルの作成:" -#: ../../library/compression.zstd.rst:850 msgid "" "from compression import zstd\n" "\n" @@ -1121,24 +1360,29 @@ msgid "" "with zstd.open(\"file.zst\", \"w\") as f:\n" " f.write(data)" msgstr "" +"from compression import zstd\n" +"\n" +"data = b\"Insert Data Here\"\n" +"with zstd.open(\"file.zst\", \"w\") as f:\n" +" f.write(data)" -#: ../../library/compression.zstd.rst:858 msgid "Compressing data in memory:" -msgstr "" +msgstr "メモリ上でのデータの圧縮:" -#: ../../library/compression.zstd.rst:860 msgid "" "from compression import zstd\n" "\n" "data_in = b\"Insert Data Here\"\n" "data_out = zstd.compress(data_in)" msgstr "" +"from compression import zstd\n" +"\n" +"data_in = b\"Insert Data Here\"\n" +"data_out = zstd.compress(data_in)" -#: ../../library/compression.zstd.rst:867 msgid "Incremental compression:" -msgstr "" +msgstr "インクリメンタルな圧縮:" -#: ../../library/compression.zstd.rst:869 msgid "" "from compression import zstd\n" "\n" @@ -1150,12 +1394,19 @@ msgid "" "# Concatenate all the partial results:\n" "result = b\"\".join([out1, out2, out3, out4])" msgstr "" +"from compression import zstd\n" +"\n" +"comp = zstd.ZstdCompressor()\n" +"out1 = comp.compress(b\"Some data\\n\")\n" +"out2 = comp.compress(b\"Another piece of data\\n\")\n" +"out3 = comp.compress(b\"Even more data\\n\")\n" +"out4 = comp.flush()\n" +"# 部分的な結果をすべて連結する:\n" +"result = b\"\".join([out1, out2, out3, out4])" -#: ../../library/compression.zstd.rst:881 msgid "Writing compressed data to an already-open file:" -msgstr "" +msgstr "すでに開かれたファイルへの圧縮データの書き込み:" -#: ../../library/compression.zstd.rst:883 msgid "" "from compression import zstd\n" "\n" @@ -1165,12 +1416,17 @@ msgid "" " zstf.write(b\"This *will* be compressed\\n\")\n" " f.write(b\"Not compressed\\n\")" msgstr "" +"from compression import zstd\n" +"\n" +"with open(\"myfile\", \"wb\") as f:\n" +" f.write(b\"This data will not be compressed\\n\")\n" +" with zstd.open(f, \"w\") as zstf:\n" +" zstf.write(b\"This *will* be compressed\\n\")\n" +" f.write(b\"Not compressed\\n\")" -#: ../../library/compression.zstd.rst:893 msgid "Creating a compressed file using compression parameters:" -msgstr "" +msgstr "圧縮パラメータを使った圧縮ファイルの作成:" -#: ../../library/compression.zstd.rst:895 msgid "" "from compression import zstd\n" "\n" @@ -1180,3 +1436,10 @@ msgid "" "with zstd.open(\"file.zst\", \"w\", options=options) as f:\n" " f.write(b\"Mind if I squeeze in?\")" msgstr "" +"from compression import zstd\n" +"\n" +"options = {\n" +" zstd.CompressionParameter.checksum_flag: 1\n" +"}\n" +"with zstd.open(\"file.zst\", \"w\", options=options) as f:\n" +" f.write(b\"Mind if I squeeze in?\")" diff --git a/library/concurrency.po b/library/concurrency.po index c41a138e7..941631d27 100644 --- a/library/concurrency.po +++ b/library/concurrency.po @@ -16,17 +16,16 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/concurrency.rst:5 msgid "Concurrent Execution" msgstr "並行実行" -#: ../../library/concurrency.rst:7 msgid "" "The modules described in this chapter provide support for concurrent " "execution of code. The appropriate choice of tool will depend on the task to " @@ -34,10 +33,11 @@ msgid "" "(event driven cooperative multitasking vs preemptive multitasking). Here's " "an overview:" msgstr "" -"この章で記述されているモジュールは、コードの並行実行のサポートを提供します。" -"ツールの適切な選択は、実行されるタスク(IO bound vs CPU bound) や推奨される開" -"発スタイル (イベントドリブンな協調的マルチタスク vs プリエンプティブマルチタ" -"スク) に依存します。ここに概観を示します:" +"この章で説明するモジュールは、コードの並行実行をサポートします。\n" +"適切なツールは、実行するタスク (CPU バウンドか I/O バウンドか) と、好みの開発" +"スタイル (イベント駆動の協調的マルチタスクかプリエンプティブマルチタスクか) " +"によって異なります。\n" +"概要は以下のとおりです:" #: ../../library/concurrency.rst:28 msgid "The following are support modules for some of the above services:" diff --git a/library/concurrent.futures.po b/library/concurrent.futures.po index 0e171e9b5..deff3163d 100644 --- a/library/concurrent.futures.po +++ b/library/concurrent.futures.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/concurrent.futures.rst:2 @@ -37,31 +37,40 @@ msgstr "" "concurrent/futures/process.py` および :source:`Lib/concurrent/futures/" "interpreter.py`" -#: ../../library/concurrent.futures.rst:15 msgid "" "The :mod:`!concurrent.futures` module provides a high-level interface for " "asynchronously executing callables." msgstr "" +":mod:`!concurrent.futures` モジュールは、呼び出し可能オブジェクトを非同期に実" +"行するための高水準インターフェースを提供します。" -#: ../../library/concurrent.futures.rst:18 msgid "" "The asynchronous execution can be performed with threads, using :class:" "`ThreadPoolExecutor` or :class:`InterpreterPoolExecutor`, or separate " "processes, using :class:`ProcessPoolExecutor`. Each implements the same " "interface, which is defined by the abstract :class:`Executor` class." msgstr "" +"非同期実行には、:class:`ThreadPoolExecutor` または :class:" +"`InterpreterPoolExecutor` によるスレッド、あるいは :class:" +"`ProcessPoolExecutor` による別プロセスを使えます。\n" +"いずれも、抽象クラス :class:`Executor` で定義された同じインターフェースを実装" +"しています。" -#: ../../library/concurrent.futures.rst:24 msgid "" ":class:`concurrent.futures.Future` must not be confused with :class:`asyncio." "Future`, which is designed for use with :mod:`asyncio` tasks and coroutines. " "See the :doc:`asyncio's Future ` documentation for a " "detailed comparison of the two." msgstr "" +":class:`concurrent.futures.Future` と :class:`asyncio.Future` を混同しないで" +"ください。\n" +"後者は :mod:`asyncio` のタスクやコルーチンとともに使うよう設計されていま" +"す。\n" +"両者の詳しい比較は、:doc:`asyncio の Future ` のドキュメント" +"を参照してください。" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -93,32 +102,36 @@ msgstr "" "にスケジュールし、呼び出し可能オブジェクトの実行を表現する :class:`Future` オ" "ブジェクトを返します。 ::" -#: ../../library/concurrent.futures.rst:45 msgid "" "with ThreadPoolExecutor(max_workers=1) as executor:\n" " future = executor.submit(pow, 323, 1235)\n" " print(future.result())" msgstr "" +"with ThreadPoolExecutor(max_workers=1) as executor:\n" +" future = executor.submit(pow, 323, 1235)\n" +" print(future.result())" -#: ../../library/concurrent.futures.rst:51 msgid "Similar to :func:`map(fn, *iterables) ` except:" -msgstr "" +msgstr ":func:`map(fn, *iterables) ` と似ていますが、次の違いがあります:" -#: ../../library/concurrent.futures.rst:53 msgid "" "The *iterables* are collected immediately rather than lazily, unless a " "*buffersize* is specified to limit the number of submitted tasks whose " "results have not yet been yielded. If the buffer is full, iteration over the " "*iterables* pauses until a result is yielded from the buffer." msgstr "" +"結果をまだ yield していない投入済みタスクの数を制限する *buffersize* が指定さ" +"れていない限り、*iterables* の要素は遅延せず、直ちに収集されます。\n" +"バッファがいっぱいになると、バッファから結果が yield されるまで *iterables* " +"の反復処理は一時停止します。" -#: ../../library/concurrent.futures.rst:58 msgid "" "*fn* is executed asynchronously and several calls to *fn* may be made " "concurrently." msgstr "" +"*fn* は非同期に実行され、複数の *fn* の呼び出しが並行して行われる場合がありま" +"す。" -#: ../../library/concurrent.futures.rst:61 msgid "" "The returned iterator raises a :exc:`TimeoutError` if :meth:`~iterator." "__next__` is called and the result isn't available after *timeout* seconds " @@ -128,8 +141,9 @@ msgid "" msgstr "" "もし :meth:`~iterator.__next__` が呼ばれその結果が元々の :meth:`Executor." "map` の呼び出しから *timeout* 秒経った後も利用できない場合、返されるイテレー" -"タは :exc:`TimeoutError` を送出します。*timeout* は整数または浮動小数点数で" -"す。もし *timeout* が指定されないか の場合、待ち時間に制限はありません。" +"タは :exc:`TimeoutError` を送出します。\n" +"*timeout* は整数または浮動小数点数です。\n" +"*timeout* を省略するか ``None`` を指定した場合、待ち時間に制限はありません。" #: ../../library/concurrent.futures.rst:67 msgid "" @@ -139,7 +153,6 @@ msgstr "" "もし *fn* の呼び出しが例外を送出した場合、その例外はイテレータから値を受け取" "る時に送出されます。" -#: ../../library/concurrent.futures.rst:70 msgid "" "When using :class:`ProcessPoolExecutor`, this method chops *iterables* into " "a number of chunks which it submits to the pool as separate tasks. The " @@ -149,6 +162,14 @@ msgid "" "size of 1. With :class:`ThreadPoolExecutor` and :class:" "`InterpreterPoolExecutor`, *chunksize* has no effect." msgstr "" +":class:`ProcessPoolExecutor` を使う場合、このメソッドは *iterables* を複数の" +"チャンクに分割し、それぞれを別々のタスクとしてプールに投入します。\n" +"*chunksize* を正の整数に設定すると、各チャンクのおおよそのサイズを指定できま" +"す。\n" +"非常に長いイテラブルでは、*chunksize* に大きな値を使うと、デフォルトのサイズ " +"1 に比べて性能が大幅に向上する場合があります。\n" +":class:`ThreadPoolExecutor` と :class:`InterpreterPoolExecutor` では、" +"*chunksize* は効果がありません。" #: ../../library/concurrent.futures.rst:79 msgid "Added the *chunksize* parameter." @@ -187,29 +208,36 @@ msgstr "" "れます。 *wait* の値に関係なく、すべての未完了のフューチャの実行が完了するま" "で Python プログラム全体は終了しません。" -#: ../../library/concurrent.futures.rst:100 msgid "" "If *cancel_futures* is ``True``, this method will cancel all pending futures " "that the executor has not started running. Any futures that are completed or " "running won't be cancelled, regardless of the value of *cancel_futures*." msgstr "" +"*cancel_futures* が ``True`` の場合、このメソッドは executor がまだ実行を開始" +"していない未完了のフューチャをすべてキャンセルします。\n" +"すでに完了したフューチャや実行中のフューチャは、*cancel_futures* の値にかかわ" +"らずキャンセルされません。" -#: ../../library/concurrent.futures.rst:105 msgid "" "If both *cancel_futures* and *wait* are ``True``, all futures that the " "executor has started running will be completed prior to this method " "returning. The remaining futures are cancelled." msgstr "" +"*cancel_futures* と *wait* がともに ``True`` の場合、executor が実行を開始し" +"たフューチャはすべて、このメソッドが返る前に完了します。\n" +"残りのフューチャはキャンセルされます。" -#: ../../library/concurrent.futures.rst:109 msgid "" "You can avoid having to call this method explicitly if you use the executor " "as a :term:`context manager` via the :keyword:`with` statement, which will " "shutdown the :class:`Executor` (waiting as if :meth:`Executor.shutdown` were " "called with *wait* set to ``True``)::" msgstr "" +":keyword:`with` 文で executor を :term:`コンテキストマネージャ ` として使えば、このメソッドを明示的に呼び出す必要はありません。\n" +":class:`Executor` はシャットダウンされます (*wait* を ``True`` にして :meth:" +"`Executor.shutdown` を呼び出した場合と同様に待機します)。 ::" -#: ../../library/concurrent.futures.rst:114 msgid "" "import shutil\n" "with ThreadPoolExecutor(max_workers=4) as e:\n" @@ -218,6 +246,12 @@ msgid "" " e.submit(shutil.copy, 'src3.txt', 'dest3.txt')\n" " e.submit(shutil.copy, 'src4.txt', 'dest4.txt')" msgstr "" +"import shutil\n" +"with ThreadPoolExecutor(max_workers=4) as e:\n" +" e.submit(shutil.copy, 'src1.txt', 'dest1.txt')\n" +" e.submit(shutil.copy, 'src2.txt', 'dest2.txt')\n" +" e.submit(shutil.copy, 'src3.txt', 'dest3.txt')\n" +" e.submit(shutil.copy, 'src4.txt', 'dest4.txt')" #: ../../library/concurrent.futures.rst:121 msgid "Added *cancel_futures*." @@ -243,7 +277,6 @@ msgstr "" ":class:`Future` に関連づけられた呼び出し可能オブジェクトが、別の :class:" "`Future` の結果を待つ時にデッドロックすることがあります。例::" -#: ../../library/concurrent.futures.rst:134 msgid "" "import time\n" "def wait_on_b():\n" @@ -261,12 +294,26 @@ msgid "" "a = executor.submit(wait_on_b)\n" "b = executor.submit(wait_on_a)" msgstr "" +"import time\n" +"def wait_on_b():\n" +" time.sleep(5)\n" +" print(b.result()) # b は a を待っているため完了しない\n" +" return 5\n" +"\n" +"def wait_on_a():\n" +" time.sleep(5)\n" +" print(a.result()) # a は b を待っているため完了しない\n" +" return 6\n" +"\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=2)\n" +"a = executor.submit(wait_on_b)\n" +"b = executor.submit(wait_on_a)" #: ../../library/concurrent.futures.rst:150 msgid "And::" msgstr "以下でも同様です::" -#: ../../library/concurrent.futures.rst:152 msgid "" "def wait_on_future():\n" " f = executor.submit(pow, 5, 2)\n" @@ -279,6 +326,18 @@ msgid "" "# Note: calling future.result() would also cause a deadlock because\n" "# the single worker thread is already waiting for wait_on_future()." msgstr "" +"def wait_on_future():\n" +" f = executor.submit(pow, 5, 2)\n" +" # ワーカースレッドは一つしかなく、この関数を実行しているため\n" +" # この処理は完了しない\n" +" print(f.result())\n" +"\n" +"executor = ThreadPoolExecutor(max_workers=1)\n" +"future = executor.submit(wait_on_future)\n" +"# 注意: future.result() を呼び出してもデッドロックが起こる。\n" +"\n" +"# 唯一のワーカースレッドはすでに wait_on_future() の終了を待っているためであ" +"る" #: ../../library/concurrent.futures.rst:166 msgid "" @@ -288,7 +347,6 @@ msgstr "" "最大で *max_workers* 個のスレッドを非同期実行に使う :class:`Executor` のサブ" "クラスです。" -#: ../../library/concurrent.futures.rst:169 msgid "" "All threads enqueued to ``ThreadPoolExecutor`` will be joined before the " "interpreter can exit. Note that the exit handler which does this is executed " @@ -297,8 +355,15 @@ msgid "" "exit gracefully. For this reason, it is recommended that " "``ThreadPoolExecutor`` not be used for long-running tasks." msgstr "" +"``ThreadPoolExecutor`` に登録されたすべてのスレッドは、インタープリタの終了前" +"に join されます。\n" +"この処理を行う終了ハンドラは、``atexit`` で追加した終了ハンドラよりも *前に* " +"実行されることに注意してください。\n" +"そのため、スレッドに正常終了を指示できるように、メインスレッドの例外を捕捉し" +"て処理しなければなりません。\n" +"この理由から、長時間実行するタスクには ``ThreadPoolExecutor`` を使わないこと" +"を推奨します。" -#: ../../library/concurrent.futures.rst:176 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker thread; *initargs* is a tuple of arguments passed to the " @@ -306,6 +371,12 @@ msgid "" "jobs will raise a :exc:`~concurrent.futures.thread.BrokenThreadPool`, as " "well as any attempt to submit more jobs to the pool." msgstr "" +"*initializer* は省略可能な呼び出し可能オブジェクトで、各ワーカースレッドの開" +"始時に呼び出されます。\n" +"*initargs* は、この初期化処理に渡す引数のタプルです。\n" +"*initializer* が例外を送出した場合、現在未完了のジョブはすべて :exc:" +"`~concurrent.futures.thread.BrokenThreadPool` を送出し、プールへの新たなジョ" +"ブの投入も同じ例外を送出します。" #: ../../library/concurrent.futures.rst:182 msgid "" @@ -336,31 +407,37 @@ msgstr "" msgid "Added the *initializer* and *initargs* arguments." msgstr "*initializer* と *initargs* 引数が追加されました。" -#: ../../library/concurrent.futures.rst:198 msgid "" "Default value of *max_workers* is changed to ``min(32, os.cpu_count() + " "4)``. This default value preserves at least 5 workers for I/O bound tasks. " "It utilizes at most 32 CPU cores for CPU bound tasks which release the GIL. " "And it avoids using very large resources implicitly on many-core machines." msgstr "" +"*max_workers* のデフォルト値が ``min(32, os.cpu_count() + 4)`` に変更されまし" +"た。\n" +"このデフォルト値により、I/O バウンドのタスクには少なくとも 5 個のワーカーが確" +"保されます。\n" +"GIL を解放する CPU バウンドのタスクには最大 32 個の CPU コアを利用します。\n" +"また、多数のコアを持つマシンで暗黙に大量のリソースを使うことを避けられます。" -#: ../../library/concurrent.futures.rst:204 msgid "" "ThreadPoolExecutor now reuses idle worker threads before starting " "*max_workers* worker threads too." msgstr "" +"ThreadPoolExecutor は、*max_workers* 個のワーカースレッドを起動する前に、待機" +"中のワーカースレッドを再利用するようにもなりました。" -#: ../../library/concurrent.futures.rst:207 msgid "" "Default value of *max_workers* is changed to ``min(32, (os." "process_cpu_count() or 1) + 4)``." msgstr "" +"*max_workers* のデフォルト値が ``min(32, (os.process_cpu_count() or 1) + " +"4)`` に変更されました。" #: ../../library/concurrent.futures.rst:215 msgid "ThreadPoolExecutor Example" msgstr "ThreadPoolExecutor の例" -#: ../../library/concurrent.futures.rst:218 msgid "" "import concurrent.futures\n" "import urllib.request\n" @@ -390,12 +467,38 @@ msgid "" " else:\n" " print('%r page is %d bytes' % (url, len(data)))" msgstr "" +"import concurrent.futures\n" +"import urllib.request\n" +"\n" +"URLS = ['http://www.foxnews.com/',\n" +" 'http://www.cnn.com/',\n" +" 'http://europe.wsj.com/',\n" +" 'http://www.bbc.co.uk/',\n" +" 'http://nonexistent-subdomain.python.org/']\n" +"\n" +"# 一つのページを取得し、URL と内容を報告する\n" +"def load_url(url, timeout):\n" +" with urllib.request.urlopen(url, timeout=timeout) as conn:\n" +" return conn.read()\n" +"\n" +"# with 文を使えばスレッドを速やかに後始末できる\n" +"with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:\n" +" # 読み込みを開始し、各フューチャに URL を対応付ける\n" +" future_to_url = {executor.submit(load_url, url, 60): url for url in " +"URLS}\n" +" for future in concurrent.futures.as_completed(future_to_url):\n" +" url = future_to_url[future]\n" +" try:\n" +" data = future.result()\n" +" except Exception as exc:\n" +" print('%r generated an exception: %s' % (url, exc))\n" +" else:\n" +" print('%r page is %d bytes' % (url, len(data)))" #: ../../library/concurrent.futures.rst:247 msgid "InterpreterPoolExecutor" msgstr "InterpreterPoolExecutor" -#: ../../library/concurrent.futures.rst:251 msgid "" "The :class:`InterpreterPoolExecutor` class uses a pool of interpreters to " "execute calls asynchronously. It is a :class:`ThreadPoolExecutor` subclass, " @@ -403,8 +506,13 @@ msgid "" "that each worker has its own interpreter, and runs each task using that " "interpreter." msgstr "" +":class:`InterpreterPoolExecutor` クラスは、インタープリタのプールを使って呼び" +"出しを非同期に実行します。\n" +":class:`ThreadPoolExecutor` のサブクラスなので、各ワーカーはそれぞれのスレッ" +"ドで動作します。\n" +"異なる点は、各ワーカーが専用のインタープリタを持ち、それを使って各タスクを実" +"行することです。" -#: ../../library/concurrent.futures.rst:257 msgid "" "The biggest benefit to using interpreters instead of only threads is true " "multi-core parallelism. Each interpreter has its own :term:`Global " @@ -412,8 +520,13 @@ msgid "" "interpreter can run on one CPU core, while code in another interpreter runs " "unblocked on a different core." msgstr "" +"スレッドだけを使う代わりにインタープリタを使う最大の利点は、複数のコアで真に" +"並列実行できることです。\n" +"各インタープリタはそれぞれの :term:`グローバルインタープリタロック ` を持ちます。\n" +"そのため、一つのインタープリタのコードをある CPU コアで実行しながら、別のイン" +"タープリタのコードを他のコアで、妨げられることなく実行できます。" -#: ../../library/concurrent.futures.rst:263 msgid "" "The tradeoff is that writing concurrent code for use with multiple " "interpreters can take extra effort. However, this is because it forces you " @@ -425,8 +538,17 @@ msgid "" "deal with several of the big pain points of using threads, like race " "conditions." msgstr "" +"その代わり、複数のインタープリタを使う並行コードの作成には、追加の手間がかか" +"る場合があります。\n" +"しかしこれは、インタープリタがいつ、どのようにやり取りするかを慎重に考え、共" +"有するデータを明示する必要があるためです。\n" +"このことは、複数コアでの真の並列実行をはじめ、追加の手間に見合ういくつかの利" +"点につながります。\n" +"例えば、このように書かれたコードでは、並行処理の振る舞いを考えやすくなる場合" +"があります。\n" +"競合状態など、スレッドを使う際の大きな問題のいくつかに対処せずに済むことも、" +"大きな利点です。" -#: ../../library/concurrent.futures.rst:273 msgid "" "Each worker's interpreter is isolated from all the other interpreters. " "\"Isolated\" means each interpreter has its own runtime state and operates " @@ -439,8 +561,21 @@ msgid "" "different interpreter, including :mod:`sys`, :mod:`builtins`, and even " "``__main__``." msgstr "" +"各ワーカーのインタープリタは、他のすべてのインタープリタから分離されていま" +"す。\n" +"「分離されている」とは、各インタープリタが独自の実行時の状態を持ち、完全に独" +"立して動作することです。\n" +"例えば、一つのインタープリタで :data:`sys.stdout` をリダイレクトしても、他の" +"インタープリタでは自動的にリダイレクトされません。\n" +"一つのインタープリタでモジュールをインポートしても、他のインタープリタでは自" +"動的にインポートされません。\n" +"そのモジュールを必要とするインタープリタごとに、個別にインポートする必要があ" +"ります。\n" +"実際、あるインタープリタでインポートしたモジュールは、別のインタープリタの同" +"じモジュールとは完全に別のオブジェクトです。\n" +"これは :mod:`sys`、:mod:`builtins`、さらには ``__main__`` にも当てはまりま" +"す。" -#: ../../library/concurrent.futures.rst:285 msgid "" "Isolation means a mutable object, or other data, cannot be used by more than " "one interpreter at the same time. That effectively means interpreters " @@ -449,16 +584,27 @@ msgid "" "copies manually. Immutable objects and data, like the builtin singletons, " "strings, and tuples of immutable objects, don't have these limitations." msgstr "" +"分離されているため、ミュータブルなオブジェクトやその他のデータを、複数のイン" +"タープリタで同時に使うことはできません。\n" +"実質的に、インタープリタ間でそのようなオブジェクトやデータを共有することはで" +"きないということです。\n" +"各インタープリタはそれぞれのコピーを持たなければならず、コピー間の変更は手動" +"で同期する必要があります。\n" +"組み込みのシングルトン、文字列、イミュータブルなオブジェクトからなるタプルな" +"ど、イミュータブルなオブジェクトやデータにはこの制約がありません。" -#: ../../library/concurrent.futures.rst:293 msgid "" "Communicating and synchronizing between interpreters is most effectively " "done using dedicated tools, like those proposed in :pep:`734`. One less " "efficient alternative is to serialize with :mod:`pickle` and then send the " "bytes over a shared :mod:`socket ` or :func:`pipe `." msgstr "" +"インタープリタ間の通信や同期には、:pep:`734` で提案されたような専用のツールを" +"使うのが最も効率的です。\n" +"効率は劣りますが、:mod:`pickle` でシリアライズしてから、共有の :mod:`ソケッ" +"ト ` や :func:`パイプ ` を介してバイト列を送る方法もありま" +"す。" -#: ../../library/concurrent.futures.rst:301 msgid "" "A :class:`ThreadPoolExecutor` subclass that executes calls asynchronously " "using a pool of at most *max_workers* threads. Each thread runs tasks in " @@ -468,8 +614,15 @@ msgid "" "Interpreter Lock `, which means code run with this " "executor has true multi-core parallelism." msgstr "" +"最大 *max_workers* 個のスレッドからなるプールを使い、呼び出しを非同期に実行す" +"る :class:`ThreadPoolExecutor` のサブクラスです。\n" +"各スレッドは専用のインタープリタでタスクを実行します。\n" +"ワーカーのインタープリタは互いに分離されているため、それぞれが独自の実行時の" +"状態を持ち、ミュータブルなオブジェクトやその他のデータを共有できません。\n" +"各インタープリタはそれぞれの :term:`グローバルインタープリタロック ` を持つため、この executor で実行するコードは複数のコアで真" +"に並列実行できます。" -#: ../../library/concurrent.futures.rst:309 msgid "" "The optional *initializer* and *initargs* arguments have the same meaning as " "for :class:`!ThreadPoolExecutor`: the initializer is run when each worker is " @@ -477,26 +630,35 @@ msgid "" "executor serializes the *initializer* and *initargs* using :mod:`pickle` " "when sending them to the worker's interpreter." msgstr "" +"省略可能な *initializer* と *initargs* 引数の意味は :class:`!" +"ThreadPoolExecutor` と同じです。\n" +"初期化処理は各ワーカーの作成時に実行されますが、この場合はワーカーのインター" +"プリタ内で実行されます。\n" +"executor は、*initializer* と *initargs* をワーカーのインタープリタに送る際" +"に :mod:`pickle` でシリアライズします。" -#: ../../library/concurrent.futures.rst:317 msgid "" "The executor may replace uncaught exceptions from *initializer* with :class:" "`~concurrent.interpreters.ExecutionFailed`." msgstr "" +"executor は、*initializer* で捕捉されなかった例外を :class:`~concurrent." +"interpreters.ExecutionFailed` に置き換える場合があります。" -#: ../../library/concurrent.futures.rst:320 msgid "Other caveats from parent :class:`ThreadPoolExecutor` apply here." msgstr "" +"親クラス :class:`ThreadPoolExecutor` のその他の注意事項も当てはまります。" -#: ../../library/concurrent.futures.rst:322 msgid "" ":meth:`~Executor.submit` and :meth:`~Executor.map` work like normal, except " "the worker serializes the callable and arguments using :mod:`pickle` when " "sending them to its interpreter. The worker likewise serializes the return " "value when sending it back." msgstr "" +":meth:`~Executor.submit` と :meth:`~Executor.map` は通常どおり動作しますが、" +"ワーカーが呼び出し可能オブジェクトと引数を自分のインタープリタに送る際に :" +"mod:`pickle` でシリアライズする点が異なります。\n" +"戻り値を送り返す際にも、同様にシリアライズします。" -#: ../../library/concurrent.futures.rst:327 msgid "" "When a worker's current task raises an uncaught exception, the worker always " "tries to preserve the exception as-is. If that is successful then it also " @@ -506,6 +668,12 @@ msgid "" "original as-is then it directly preserves the corresponding :class:" "`~concurrent.interpreters.ExecutionFailed` instance instead." msgstr "" +"ワーカーが実行中のタスクで捕捉されない例外が発生すると、ワーカーは常にその例" +"外をそのまま保持しようとします。\n" +"保持できた場合は、元の例外の要約を含む、対応する :class:`~concurrent." +"interpreters.ExecutionFailed` インスタンスを ``__cause__`` にも設定します。\n" +"まれに元の例外をそのまま保持できない場合は、対応する :class:`~concurrent." +"interpreters.ExecutionFailed` インスタンスを直接保持します。" #: ../../library/concurrent.futures.rst:339 msgid "ProcessPoolExecutor" @@ -545,15 +713,17 @@ msgstr "" ":class:`ProcessPoolExecutor` に渡された呼び出し可能オブジェクトから :class:" "`Executor` や :class:`Future` メソッドを呼ぶとデッドロックに陥ります。" -#: ../../library/concurrent.futures.rst:354 msgid "" "Note that the restrictions on functions and arguments needing to picklable " "as per :class:`multiprocessing.Process` apply when using :meth:`~Executor." "submit` and :meth:`~Executor.map` on a :class:`ProcessPoolExecutor`. A " "function defined in a REPL or a lambda should not be expected to work." msgstr "" +":class:`ProcessPoolExecutor` の :meth:`~Executor.submit` と :meth:`~Executor." +"map` を使う際には、:class:`multiprocessing.Process` と同様に、関数と引数が " +"pickle 化可能でなければならないという制約があることに注意してください。\n" +"REPL で定義した関数や lambda が動作することは期待できません。" -#: ../../library/concurrent.futures.rst:361 msgid "" "An :class:`Executor` subclass that executes calls asynchronously using a " "pool of at most *max_workers* processes. If *max_workers* is ``None`` or " @@ -567,8 +737,21 @@ msgid "" "given, the default :mod:`multiprocessing` context is used. See :ref:" "`multiprocessing-start-methods`." msgstr "" +"最大 *max_workers* 個のプロセスからなるプールを使い、呼び出しを非同期に実行す" +"る :class:`Executor` のサブクラスです。\n" +"*max_workers* が ``None`` または省略された場合、デフォルトで :func:`os." +"process_cpu_count` が使われます。\n" +"*max_workers* が ``0`` 以下の場合は :exc:`ValueError` を送出します。\n" +"Windows では、*max_workers* は ``61`` 以下でなければなりません。\n" +"そうでない場合は :exc:`ValueError` を送出します。\n" +"*max_workers* が ``None`` の場合、利用可能なプロセッサ数がそれより多くても、" +"デフォルトで選択される値は最大 ``61`` です。\n" +"*mp_context* には :mod:`multiprocessing` のコンテキストまたは ``None`` を指定" +"でき、ワーカーの起動に使われます。\n" +"*mp_context* が ``None`` または省略された場合、デフォルトの :mod:" +"`multiprocessing` コンテキストが使われます。\n" +":ref:`multiprocessing-start-methods` を参照してください。" -#: ../../library/concurrent.futures.rst:375 msgid "" "*initializer* is an optional callable that is called at the start of each " "worker process; *initargs* is a tuple of arguments passed to the " @@ -576,8 +759,13 @@ msgid "" "jobs will raise a :exc:`~concurrent.futures.process.BrokenProcessPool`, as " "well as any attempt to submit more jobs to the pool." msgstr "" +"*initializer* は省略可能な呼び出し可能オブジェクトで、各ワーカープロセスの開" +"始時に呼び出されます。\n" +"*initargs* は、この初期化処理に渡す引数のタプルです。\n" +"*initializer* が例外を送出した場合、現在未完了のジョブはすべて :exc:" +"`~concurrent.futures.process.BrokenProcessPool` を送出し、プールへの新たな" +"ジョブの投入も同じ例外を送出します。" -#: ../../library/concurrent.futures.rst:381 msgid "" "*max_tasks_per_child* is an optional argument that specifies the maximum " "number of tasks a single process can execute before it will exit and be " @@ -587,6 +775,13 @@ msgid "" "default in absence of a *mp_context* parameter. This feature is incompatible " "with the \"fork\" start method." msgstr "" +"*max_tasks_per_child* は省略可能な引数で、一つのプロセスが終了して新しいワー" +"カープロセスに置き換わるまでに実行できるタスクの最大数を指定します。\n" +"デフォルトの *max_tasks_per_child* は ``None`` で、ワーカープロセスはプールが" +"存在する限り存続します。\n" +"最大数を指定し、*mp_context* パラメータを指定しなかった場合、デフォルトでは " +"multiprocessing の開始方式に \"spawn\" が使われます。\n" +"この機能は \"fork\" 開始方式とは併用できません。" #: ../../library/concurrent.futures.rst:389 msgid "" @@ -600,19 +795,20 @@ msgstr "" "以前は挙動は未定義でしたが、 executor や futures がフリーズしたりデッドロッ" "クを起こすことがしばしばでした。" -#: ../../library/concurrent.futures.rst:396 msgid "" "The *mp_context* argument was added to allow users to control the " "start_method for worker processes created by the pool." msgstr "" +"プールが作成するワーカープロセスの開始方式を利用者が制御できるよう、" +"*mp_context* 引数が追加されました。" -#: ../../library/concurrent.futures.rst:402 msgid "" "The *max_tasks_per_child* argument was added to allow users to control the " "lifetime of workers in the pool." msgstr "" +"プール内のワーカーの存続期間を利用者が制御できるよう、*max_tasks_per_child* " +"引数が追加されました。" -#: ../../library/concurrent.futures.rst:406 msgid "" "On POSIX systems, if your application has multiple threads and the :mod:" "`multiprocessing` context uses the ``\"fork\"`` start method: The :func:`os." @@ -620,56 +816,75 @@ msgid "" "`DeprecationWarning`. Pass a *mp_context* configured to use a different " "start method. See the :func:`os.fork` documentation for further explanation." msgstr "" +"POSIX システムで、アプリケーションが複数のスレッドを持ち、:mod:" +"`multiprocessing` コンテキストが ``\"fork\"`` 開始方式を使う場合、ワーカーを" +"起動するために内部で呼び出す :func:`os.fork` 関数が :exc:" +"`DeprecationWarning` を送出することがあります。\n" +"別の開始方式を使うように設定した *mp_context* を渡してください。\n" +"詳しくは :func:`os.fork` のドキュメントを参照してください。" -#: ../../library/concurrent.futures.rst:414 msgid "" "*max_workers* uses :func:`os.process_cpu_count` by default, instead of :func:" "`os.cpu_count`." msgstr "" +"*max_workers* のデフォルトで、:func:`os.cpu_count` の代わりに :func:`os." +"process_cpu_count` を使うようになりました。" -#: ../../library/concurrent.futures.rst:418 msgid "" "The default process start method (see :ref:`multiprocessing-start-methods`) " "changed away from *fork*. If you require the *fork* start method for :class:" "`ProcessPoolExecutor` you must explicitly pass ``mp_context=multiprocessing." "get_context(\"fork\")``." msgstr "" +"プロセスのデフォルトの開始方式 (:ref:`multiprocessing-start-methods` を参照) " +"が *fork* 以外に変更されました。\n" +":class:`ProcessPoolExecutor` で *fork* 開始方式が必要な場合は、" +"``mp_context=multiprocessing.get_context(\"fork\")`` を明示的に渡さなければな" +"りません。" -#: ../../library/concurrent.futures.rst:424 msgid "" "Fixed a deadlock (:gh:`115634`) where the executor could hang after a worker " "process exited upon reaching its *max_tasks_per_child* limit while tasks " "remained queued." msgstr "" +"キューにタスクが残っている間にワーカープロセスが *max_tasks_per_child* の上限" +"に達して終了すると、executor が停止したままになることがあるデッドロック (:gh:" +"`115634`) を修正しました。" -#: ../../library/concurrent.futures.rst:431 msgid "" "Attempt to terminate all living worker processes immediately by calling :" "meth:`Process.terminate ` on each of " "them. Internally, it will also call :meth:`Executor.shutdown` to ensure that " "all other resources associated with the executor are freed." msgstr "" +"存続中のすべてのワーカープロセスについて :meth:`Process.terminate " +"` を呼び出し、直ちに終了させようとしま" +"す。\n" +"executor に関連するその他のリソースをすべて解放するため、内部では :meth:" +"`Executor.shutdown` も呼び出します。" -#: ../../library/concurrent.futures.rst:436 -#: ../../library/concurrent.futures.rst:448 msgid "" "After calling this method the caller should no longer submit tasks to the " "executor." msgstr "" +"このメソッドを呼び出した後は、executor にタスクを投入しないでください。" -#: ../../library/concurrent.futures.rst:443 msgid "" "Attempt to kill all living worker processes immediately by calling :meth:" "`Process.kill ` on each of them. Internally, " "it will also call :meth:`Executor.shutdown` to ensure that all other " "resources associated with the executor are freed." msgstr "" +"存続中のすべてのワーカープロセスについて :meth:`Process.kill " +"` を呼び出し、直ちに強制終了させようとしま" +"す。\n" +"executor に関連するその他のリソースをすべて解放するため、内部では :meth:" +"`Executor.shutdown` も呼び出します。" #: ../../library/concurrent.futures.rst:456 msgid "ProcessPoolExecutor Example" msgstr "ProcessPoolExecutor の例" -#: ../../library/concurrent.futures.rst:459 msgid "" "import concurrent.futures\n" "import math\n" @@ -704,6 +919,38 @@ msgid "" "if __name__ == '__main__':\n" " main()" msgstr "" +"import concurrent.futures\n" +"import math\n" +"\n" +"PRIMES = [\n" +" 112272535095293,\n" +" 112582705942171,\n" +" 112272535095293,\n" +" 115280095190773,\n" +" 115797848077099,\n" +" 1099726899285419]\n" +"\n" +"def is_prime(n):\n" +" if n < 2:\n" +" return False\n" +" if n == 2:\n" +" return True\n" +" if n % 2 == 0:\n" +" return False\n" +"\n" +" sqrt_n = int(math.floor(math.sqrt(n)))\n" +" for i in range(3, sqrt_n + 1, 2):\n" +" if n % i == 0:\n" +" return False\n" +" return True\n" +"\n" +"def main():\n" +" with concurrent.futures.ProcessPoolExecutor() as executor:\n" +" for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):\n" +" print('%d is prime: %s' % (number, prime))\n" +"\n" +"if __name__ == '__main__':\n" +" main()" #: ../../library/concurrent.futures.rst:494 msgid "Future Objects" @@ -728,13 +975,16 @@ msgstr "" "スタンスは :meth:`Executor.submit` で生成され、テストを除いて直接生成すべきで" "はありません。" -#: ../../library/concurrent.futures.rst:507 msgid "" "Attempt to cancel the call. If the call is currently being executed or " "finished running and cannot be cancelled then the method will return " "``False``, otherwise the call will be cancelled and the method will return " "``True``." msgstr "" +"呼び出しのキャンセルを試みます。\n" +"呼び出しがすでに実行中または実行済みで、キャンセルできない場合は ``False`` を" +"返します。\n" +"それ以外の場合は呼び出しをキャンセルして ``True`` を返します。" #: ../../library/concurrent.futures.rst:514 msgid "Return ``True`` if the call was successfully cancelled." @@ -774,10 +1024,9 @@ msgstr "" "future が完了する前にキャンセルされた場合 :exc:`CancelledError` が送出されま" "す。" -#: ../../library/concurrent.futures.rst:538 msgid "" "If the call raised an exception, this method will raise the same exception." -msgstr "" +msgstr "呼び出しが例外を送出した場合、このメソッドも同じ例外を送出します。" #: ../../library/concurrent.futures.rst:542 msgid "" @@ -837,14 +1086,13 @@ msgstr "" "以下の :class:`Future` メソッドは、ユニットテストでの使用と :class:" "`Executor` を実装することを意図しています。" -#: ../../library/concurrent.futures.rst:574 msgid "" "This method should only be called by :class:`Executor` implementations " "before executing the work associated with the :class:`Future` and by unit " "tests." msgstr "" -"このメソッドは、:class:`Future` に関連付けられたワークやユニットテストによる" -"ワークの実行前に、 :class:`Executor` の実装によってのみ呼び出してください。" +"このメソッドを呼び出してよいのは、:class:`Future` に関連付けられた処理を実行" +"する前の :class:`Executor` の実装と、ユニットテストだけです。" #: ../../library/concurrent.futures.rst:578 msgid "" @@ -858,24 +1106,21 @@ msgstr "" "class:`Future` の完了を (:func:`as_completed` または :func:`wait` により) " "待機するすべてのスレッドが起動します。" -#: ../../library/concurrent.futures.rst:583 msgid "" "If the method returns ``True`` then the :class:`Future` was not cancelled " "and has been put in the running state, i.e. calls to :meth:`Future.running` " "will return ``True``." msgstr "" -"このメソッドが ``True`` を返す場合、 :class:`Future` はキャンセルされて、実行" -"状態に移行されています。つまり、 :meth:`Future.running` を呼び出すと " -"``True`` が返ります。" +"このメソッドが ``True`` を返す場合、 :class:`Future` はキャンセルされておら" +"ず、実行状態に移行しています。\n" +"つまり、 :meth:`Future.running` を呼び出すと ``True`` が返ります。" -#: ../../library/concurrent.futures.rst:587 msgid "" "This method can only be called once and cannot be called after :meth:`Future." "set_result` or :meth:`Future.set_exception` have been called." msgstr "" -"このメソッドは、一度だけ呼び出すことができ、:meth:`Future.set_result` また" -"は :meth:`Future.set_exception` がキャンセルされた後には呼び出すことができま" -"せん。" +"このメソッドは一度だけ呼び出すことができ、:meth:`Future.set_result` または :" +"meth:`Future.set_exception` が呼び出された後には呼び出すことができません。" #: ../../library/concurrent.futures.rst:593 msgid "" @@ -891,12 +1136,12 @@ msgstr "" "このメソッドは、 :class:`Executor` の実装またはユニットテストによってのみ使用" "してください。" -#: ../../library/concurrent.futures.rst:599 -#: ../../library/concurrent.futures.rst:612 msgid "" "This method raises :exc:`concurrent.futures.InvalidStateError` if the :class:" "`Future` is already done." msgstr "" +":class:`Future` がすでに完了している場合、このメソッドは :exc:`concurrent." +"futures.InvalidStateError` を送出します。" #: ../../library/concurrent.futures.rst:606 msgid "" @@ -910,7 +1155,6 @@ msgstr "" msgid "Module Functions" msgstr "モジュール関数" -#: ../../library/concurrent.futures.rst:622 msgid "" "Wait for the :class:`Future` instances (possibly created by different :class:" "`Executor` instances) given by *fs* to complete. Duplicate futures given to " @@ -920,6 +1164,14 @@ msgid "" "named ``not_done``, contains the futures that did not complete (pending or " "running futures)." msgstr "" +"*fs* で指定された :class:`Future` インスタンス (異なる :class:`Executor` イン" +"スタンスで作成されたものでも可) が完了するまで待機します。\n" +"*fs* に重複して指定されたフューチャは一つにまとめられ、一度だけ返されます。\n" +"集合を要素とする、要素数 2 の名前付きタプルを返します。\n" +"最初の集合 ``done`` には、待機が終わるまでに完了したフューチャ (実行済みまた" +"はキャンセル済みのフューチャ) が含まれます。\n" +"二つ目の集合 ``not_done`` には、完了していないフューチャ (保留中または実行中" +"のフューチャ) が含まれます。" #: ../../library/concurrent.futures.rst:630 msgid "" @@ -951,18 +1203,18 @@ msgstr "説明" msgid "The function will return when any future finishes or is cancelled." msgstr "いずれかのフューチャが終了したかキャンセルされたときに返します。" -#: ../../library/concurrent.futures.rst:647 msgid "" "The function will return when any future finishes by raising an exception. " "If no future raises an exception then it is equivalent to :const:" "`ALL_COMPLETED`." msgstr "" +"いずれかのフューチャが例外を送出して終了すると、この関数は返ります。\n" +"例外を送出するフューチャがない場合は、:const:`ALL_COMPLETED` と等価です。" #: ../../library/concurrent.futures.rst:652 msgid "The function will return when all futures finish or are cancelled." msgstr "すべてのフューチャが終了したかキャンセルされたときに返します。" -#: ../../library/concurrent.futures.rst:656 msgid "" "Returns an iterator over the :class:`Future` instances (possibly created by " "different :class:`Executor` instances) given by *fs* that yields futures as " @@ -974,6 +1226,17 @@ msgid "" "original call to :func:`as_completed`. *timeout* can be an int or float. If " "*timeout* is not specified or ``None``, there is no limit to the wait time." msgstr "" +"*fs* で指定された :class:`Future` インスタンス (異なる :class:`Executor` イン" +"スタンスで作成されたものでも可) を、完了するたびに (実行済みまたはキャンセル" +"済みになった順に) yield するイテレータを返します。\n" +"*fs* に重複して指定されたフューチャは、一度だけ返されます。\n" +":func:`as_completed` の呼び出し前に完了していたフューチャが、最初に yield さ" +"れます。\n" +"返されたイテレータの :meth:`~iterator.__next__` が呼び出された際、最初の :" +"func:`as_completed` の呼び出しから *timeout* 秒が経過しても結果を取得できなけ" +"れば、:exc:`TimeoutError` を送出します。\n" +"*timeout* には整数または浮動小数点数を指定できます。\n" +"*timeout* が省略された場合や ``None`` の場合は、待ち時間に制限はありません。" #: ../../library/concurrent.futures.rst:669 msgid ":pep:`3148` -- futures - execute computations asynchronously" @@ -993,47 +1256,58 @@ msgstr "例外クラス" msgid "Raised when a future is cancelled." msgstr "future がキャンセルされたときに送出されます。" -#: ../../library/concurrent.futures.rst:685 msgid "" "A deprecated alias of :exc:`TimeoutError`, raised when a future operation " "exceeds the given timeout." msgstr "" +":exc:`TimeoutError` の非推奨のエイリアスです。\n" +"フューチャの操作が指定されたタイムアウトを超えた場合に送出されます。" #: ../../library/concurrent.futures.rst:690 msgid "This class was made an alias of :exc:`TimeoutError`." msgstr "このクラスは :exc:`TimeoutError` のエイリアスになりました。" -#: ../../library/concurrent.futures.rst:695 msgid "" "Derived from :exc:`RuntimeError`, this exception class is raised when an " "executor is broken for some reason, and cannot be used to submit or execute " "new tasks." msgstr "" +":exc:`RuntimeError` の派生クラスです。\n" +"何らかの理由で executor が壊れて、新しいタスクの投入や実行に使えなくなった場" +"合に送出されます。" -#: ../../library/concurrent.futures.rst:703 msgid "" "Raised when an operation is performed on a future that is not allowed in the " "current state." msgstr "" +"フューチャに対して、現在の状態では許可されていない操作を行った場合に送出され" +"ます。" -#: ../../library/concurrent.futures.rst:712 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception class " "is raised when one of the workers of a :class:`~concurrent.futures." "ThreadPoolExecutor` has failed initializing." msgstr "" +":exc:`~concurrent.futures.BrokenExecutor` の派生クラスです。\n" +":class:`~concurrent.futures.ThreadPoolExecutor` のワーカーのいずれかで初期化" +"に失敗した場合に送出されます。" -#: ../../library/concurrent.futures.rst:723 msgid "" "Derived from :exc:`~concurrent.futures.thread.BrokenThreadPool`, this " "exception class is raised when one of the workers of a :class:`~concurrent." "futures.InterpreterPoolExecutor` has failed initializing." msgstr "" +":exc:`~concurrent.futures.thread.BrokenThreadPool` の派生クラスです。\n" +":class:`~concurrent.futures.InterpreterPoolExecutor` のワーカーのいずれかで初" +"期化に失敗した場合に送出されます。" -#: ../../library/concurrent.futures.rst:734 msgid "" "Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly :exc:" "`RuntimeError`), this exception class is raised when one of the workers of " "a :class:`~concurrent.futures.ProcessPoolExecutor` has terminated in a non-" "clean fashion (for example, if it was killed from the outside)." msgstr "" +":exc:`~concurrent.futures.BrokenExecutor` (以前は :exc:`RuntimeError`) の派生" +"クラスです。\n" +":class:`~concurrent.futures.ProcessPoolExecutor` のワーカーのいずれかが正常で" +"ない形で終了した場合 (例えば、外部から強制終了された場合) に送出されます。" diff --git a/library/concurrent.interpreters.po b/library/concurrent.interpreters.po index d57cf9a10..9ed45f3b0 100644 --- a/library/concurrent.interpreters.po +++ b/library/concurrent.interpreters.po @@ -18,74 +18,74 @@ msgstr "" "Last-Translator: Rafael Fontenelle , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/concurrent.interpreters.rst:2 msgid "" ":mod:`!concurrent.interpreters` --- Multiple interpreters in the same process" msgstr "" +":mod:`!concurrent.interpreters` --- 同じプロセス内の複数のインタープリタ" -#: ../../library/concurrent.interpreters.rst:9 msgid "**Source code:** :source:`Lib/concurrent/interpreters`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/concurrent/interpreters`" -#: ../../library/concurrent.interpreters.rst:13 msgid "" "The :mod:`!concurrent.interpreters` module constructs higher-level " "interfaces on top of the lower level :mod:`!_interpreters` module." msgstr "" +":mod:`!concurrent.interpreters` モジュールは、低水準の :mod:`!_interpreters` " +"モジュールの上に、より高水準のインターフェースを構築します。" -#: ../../library/concurrent.interpreters.rst:16 msgid "" "The module is primarily meant to provide a basic API for managing " "interpreters (AKA \"subinterpreters\") and running things in them. Running " "mostly involves switching to an interpreter (in the current thread) and " "calling a function in that execution context." msgstr "" +"このモジュールの主な目的は、インタープリタ (「サブインタープリタ」とも呼ばれ" +"ます) の管理と、その中での実行のための基本的な API を提供することです。\n" +"実行時には主に、現在のスレッドでインタープリタを切り替え、その実行コンテキス" +"トで関数を呼び出します。" -#: ../../library/concurrent.interpreters.rst:21 msgid "" "For concurrency, interpreters themselves (and this module) don't provide " "much more than isolation, which on its own isn't useful. Actual concurrency " "is available separately through :mod:`threads ` -- see `below " "`_." msgstr "" +"並行処理に関しては、インタープリタ自体 (およびこのモジュール) が提供するのは" +"ほぼ分離だけであり、それだけでは役に立ちません。\n" +"実際の並行処理は、別途 :mod:`スレッド ` によって利用できます。\n" +"`後述の説明 `_ を参照してください。" -#: ../../library/concurrent.interpreters.rst:28 msgid ":class:`~concurrent.futures.InterpreterPoolExecutor`" -msgstr "" +msgstr ":class:`~concurrent.futures.InterpreterPoolExecutor`" -#: ../../library/concurrent.interpreters.rst:29 msgid "Combines threads with interpreters in a familiar interface." msgstr "" +"使い慣れたインターフェースで、スレッドとインタープリタを組み合わせます。" -#: ../../library/concurrent.interpreters.rst:33 msgid ":ref:`isolating-extensions-howto`" -msgstr "" +msgstr ":ref:`isolating-extensions-howto`" -#: ../../library/concurrent.interpreters.rst:34 msgid "How to update an extension module to support multiple interpreters." -msgstr "" +msgstr "複数のインタープリタをサポートするように拡張モジュールを更新する方法。" -#: ../../library/concurrent.interpreters.rst:36 msgid ":pep:`554`" -msgstr "" +msgstr ":pep:`554`" #: ../../library/concurrent.interpreters.rst:38 msgid ":pep:`734`" msgstr ":pep:`734`" -#: ../../library/concurrent.interpreters.rst:40 msgid ":pep:`684`" -msgstr "" +msgstr ":pep:`684`" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -95,33 +95,31 @@ msgstr "" "このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、:ref:" "`wasm-availability` を見てください。" -#: ../../library/concurrent.interpreters.rst:48 msgid "Key details" -msgstr "" +msgstr "主な注意点" -#: ../../library/concurrent.interpreters.rst:50 msgid "" "Before we dive in further, there are a small number of details to keep in " "mind about using multiple interpreters:" msgstr "" +"詳しい説明に入る前に、複数のインタープリタの使用について留意すべき点を挙げま" +"す:" -#: ../../library/concurrent.interpreters.rst:53 msgid "`isolated `_, by default" -msgstr "" +msgstr "デフォルトで `分離される `_" -#: ../../library/concurrent.interpreters.rst:54 msgid "no implicit threads" -msgstr "" +msgstr "暗黙にスレッドは作成されない" -#: ../../library/concurrent.interpreters.rst:55 msgid "not all PyPI packages support use in multiple interpreters yet" msgstr "" +"PyPI のすべてのパッケージが、複数のインタープリタでの使用をサポートしているわ" +"けではない" #: ../../library/concurrent.interpreters.rst:63 msgid "Introduction" msgstr "はじめに" -#: ../../library/concurrent.interpreters.rst:65 msgid "" "An \"interpreter\" is effectively the execution context of the Python " "runtime. It contains all of the state the runtime needs to execute a " @@ -130,6 +128,11 @@ msgid "" "in addition to the current interpreter, related to the current exception and " "the bytecode eval loop.)" msgstr "" +"「インタープリタ」は、実質的に Python ランタイムの実行コンテキストです。\n" +"プログラムの実行に必要な状態をすべて含んでいます。\n" +"これには、インポートの状態や組み込みオブジェクトなどが含まれます。\n" +"(メインスレッドしかない場合でも、各スレッドには現在のインタープリタの状態に加" +"え、現在の例外やバイトコードの評価ループに関する実行時の状態があります)。" #: ../../library/concurrent.interpreters.rst:72 msgid "" @@ -139,26 +142,29 @@ msgid "" "incomplete until version 3.12." msgstr "" -#: ../../library/concurrent.interpreters.rst:80 msgid "Multiple Interpreters and Isolation" -msgstr "" +msgstr "複数のインタープリタと分離" -#: ../../library/concurrent.interpreters.rst:82 msgid "" "A Python implementation may support using multiple interpreters in the same " "process. CPython has this support. Each interpreter is effectively " "isolated from the others (with a limited number of carefully managed process-" "global exceptions to the rule)." msgstr "" +"Python の実装は、同じプロセス内で複数のインタープリタを使うことをサポートする" +"場合があります。\n" +"CPython はこれをサポートしています。\n" +"各インタープリタは、他のインタープリタから実質的に分離されています (プロセス" +"全体で共有されるものに、慎重に管理された少数の例外があります)。" -#: ../../library/concurrent.interpreters.rst:87 msgid "" "That isolation is primarily useful as a strong separation between distinct " "logical components of a program, where you want to have careful control of " "how those components interact." msgstr "" +"この分離は主に、プログラムを構成する別々の論理的な部分を明確に切り離し、それ" +"らのやり取りを慎重に制御したい場合に役立ちます。" -#: ../../library/concurrent.interpreters.rst:93 msgid "" "Interpreters in the same process can technically never be strictly isolated " "from one another since there are few restrictions on memory access within " @@ -167,12 +173,16 @@ msgid "" "interpreters in security-sensitive situations, where they shouldn't have " "access to each other's data." msgstr "" +"同じプロセス内ではメモリアクセスに対する制限がほとんどないため、技術的には、" +"同じプロセス内のインタープリタを互いに厳密に分離することはできません。\n" +"Python ランタイムは可能な限り分離しますが、拡張モジュールは容易にその分離を破" +"ることができます。\n" +"したがって、互いのデータにアクセスできてはならないような、セキュリティが重要" +"な状況では、複数のインタープリタを使わないでください。" -#: ../../library/concurrent.interpreters.rst:101 msgid "Running in an Interpreter" -msgstr "" +msgstr "インタープリタ内での実行" -#: ../../library/concurrent.interpreters.rst:103 msgid "" "Running in a different interpreter involves switching to it in the current " "thread and then calling some function. The runtime will execute the " @@ -180,15 +190,22 @@ msgid "" "interpreters` module provides a basic API for creating and managing " "interpreters, as well as the switch-and-call operation." msgstr "" +"別のインタープリタ内で実行するには、現在のスレッドでそのインタープリタに切り" +"替えてから、関数を呼び出します。\n" +"ランタイムは、現在のインタープリタの状態を使って関数を実行します。\n" +":mod:`!concurrent.interpreters` モジュールは、インタープリタを作成・管理する" +"基本的な API と、この切り替えと呼び出しの操作を提供します。" -#: ../../library/concurrent.interpreters.rst:110 msgid "" "No other threads are automatically started for the operation. There is `a " "helper `_ for that though. There is another " "dedicated helper for calling the builtin :func:`exec` in an interpreter." msgstr "" +"この操作で、他のスレッドが自動的に開始されることはありません。\n" +"ただし、そのための `補助機能 `_ があります。\n" +"インタープリタ内で組み込みの :func:`exec` を呼び出すための専用の補助機能もあ" +"ります。" -#: ../../library/concurrent.interpreters.rst:115 msgid "" "When :func:`exec` (or :func:`eval`) are called in an interpreter, they run " "using the interpreter's :mod:`!__main__` module as the \"globals\" " @@ -196,20 +213,28 @@ msgid "" "module. This is the same as how scripts invoked from the command-line run " "in the :mod:`!__main__` module." msgstr "" +"インタープリタ内で :func:`exec` (または :func:`eval`) を呼び出すと、そのイン" +"タープリタの :mod:`!__main__` モジュールを「グローバル」名前空間として実行し" +"ます。\n" +"どのモジュールにも関連付けられていない関数も同様です。\n" +"これは、コマンドラインから起動したスクリプトが :mod:`!__main__` モジュール内" +"で動作するのと同じです。" -#: ../../library/concurrent.interpreters.rst:125 msgid "Concurrency and Parallelism" -msgstr "" +msgstr "並行処理と並列処理" -#: ../../library/concurrent.interpreters.rst:127 msgid "" "As noted earlier, interpreters do not provide any concurrency on their own. " "They strictly represent the isolated execution context the runtime will use " "*in the current thread*. That isolation makes them similar to processes, " "but they still enjoy in-process efficiency, like threads." msgstr "" +"前述のとおり、インタープリタ自体は並行処理を提供しません。\n" +"厳密には、ランタイムが *現在のスレッドで* 使う、分離された実行コンテキストを" +"表すものです。\n" +"その分離はプロセスに似ていますが、スレッドと同様に、同じプロセス内にあること" +"による効率のよさも得られます。" -#: ../../library/concurrent.interpreters.rst:133 msgid "" "All that said, interpreters do naturally support certain flavors of " "concurrency. There's a powerful side effect of that isolation. It enables a " @@ -217,8 +242,12 @@ msgid "" "It's a similar concurrency model to CSP or the actor model, a model which is " "relatively easy to reason about." msgstr "" +"とはいえ、インタープリタは特定の形態の並行処理を自然にサポートします。\n" +"分離には強力な副次効果があり、async やスレッドとは異なる並行処理の手法が可能" +"になります。\n" +"その並行処理モデルは CSP やアクターモデルに似ており、比較的理解しやすいもので" +"す。" -#: ../../library/concurrent.interpreters.rst:140 msgid "" "You can take advantage of that concurrency model in a single thread, " "switching back and forth between interpreters, Stackless-style. However, " @@ -226,50 +255,65 @@ msgid "" "threads. This mostly involves starting a new thread, where you switch to " "another interpreter and run what you want there." msgstr "" +"単一のスレッドでも、Stackless のようにインタープリタを行き来して、この並行処" +"理モデルを活用できます。\n" +"しかし、このモデルはインタープリタと複数のスレッドを組み合わせたときに、より" +"役立ちます。\n" +"主な手順は、新しいスレッドを起動し、その中で別のインタープリタに切り替えて、" +"必要な処理を実行することです。" -#: ../../library/concurrent.interpreters.rst:146 msgid "" "Each actual thread in Python, even if you're only running in the main " "thread, has its own *current* execution context. Multiple threads can use " "the same interpreter or different ones." msgstr "" +"メインスレッドだけで実行している場合でも、Python の各実スレッドには、それぞれ" +"の *現在の* 実行コンテキストがあります。\n" +"複数のスレッドで同じインタープリタを使うことも、別々のインタープリタを使うこ" +"ともできます。" -#: ../../library/concurrent.interpreters.rst:150 msgid "" "At a high level, you can think of the combination of threads and " "interpreters as threads with opt-in sharing." msgstr "" +"大まかには、スレッドとインタープリタの組み合わせを、明示的に選んだものだけを" +"共有するスレッドと考えることができます。" -#: ../../library/concurrent.interpreters.rst:153 msgid "" "As a significant bonus, interpreters are sufficiently isolated that they do " "not share the :term:`GIL`, which means combining threads with multiple " "interpreters enables full multi-core parallelism. (This has been the case " "since Python 3.12.)" msgstr "" +"大きな利点として、インタープリタは :term:`GIL` を共有しないほど十分に分離され" +"ています。\n" +"そのため、スレッドと複数のインタープリタを組み合わせると、複数コアでの完全な" +"並列実行が可能になります。\n" +"(Python 3.12 以降はこのようになっています)。" -#: ../../library/concurrent.interpreters.rst:159 msgid "Communication Between Interpreters" -msgstr "" +msgstr "インタープリタ間の通信" -#: ../../library/concurrent.interpreters.rst:161 msgid "" "In practice, multiple interpreters are useful only if we have a way to " "communicate between them. This usually involves some form of message " "passing, but can even mean sharing data in some carefully managed way." msgstr "" +"実際には、複数のインタープリタが役立つのは、それらの間で通信する手段がある場" +"合だけです。\n" +"通常は何らかのメッセージパッシングを使いますが、慎重に管理した方法でデータを" +"共有する場合もあります。" -#: ../../library/concurrent.interpreters.rst:166 msgid "" "With this in mind, the :mod:`!concurrent.interpreters` module provides a :" "class:`queue.Queue` implementation, available through :func:`create_queue`." msgstr "" +"このため、:mod:`!concurrent.interpreters` モジュールは :class:`queue.Queue` " +"の実装を提供しており、:func:`create_queue` で利用できます。" -#: ../../library/concurrent.interpreters.rst:173 msgid "\"Sharing\" Objects" -msgstr "" +msgstr "オブジェクトの「共有」" -#: ../../library/concurrent.interpreters.rst:175 msgid "" "Any data actually shared between interpreters loses the thread-safety " "provided by the :term:`GIL`. There are various options for dealing with " @@ -278,21 +322,31 @@ msgid "" "Instead, a copy must be created, which means mutable objects won't stay in " "sync." msgstr "" +"インタープリタ間で実際に共有されるデータは、:term:`GIL` が提供するスレッド" +"セーフ性を失います。\n" +"拡張モジュールでは、これに対処するための選択肢がいくつかあります。\n" +"しかし、Python コードでは、スレッドセーフ性がないため、ごく一部の例外を除いて" +"オブジェクトを実際に共有することはできません。\n" +"代わりにコピーを作成しなければならないため、ミュータブルなオブジェクトの同期" +"は保たれません。" -#: ../../library/concurrent.interpreters.rst:182 msgid "" "By default, most objects are copied with :mod:`pickle` when they are passed " "to another interpreter. Nearly all of the immutable builtin objects are " "either directly shared or copied efficiently. For example:" msgstr "" +"デフォルトでは、ほとんどのオブジェクトは別のインタープリタに渡す際に :mod:" +"`pickle` でコピーされます。\n" +"イミュータブルな組み込みオブジェクトのほぼすべては、直接共有されるか、効率よ" +"くコピーされます。\n" +"例えば、次のものがあります:" #: ../../library/concurrent.interpreters.rst:186 msgid ":const:`None`" msgstr ":const:`None`" -#: ../../library/concurrent.interpreters.rst:187 msgid ":class:`bool` (:const:`True` and :const:`False`)" -msgstr "" +msgstr ":class:`bool` (:const:`True` と :const:`False`)" #: ../../library/concurrent.interpreters.rst:188 msgid ":class:`bytes`" @@ -310,15 +364,15 @@ msgstr ":class:`int`" msgid ":class:`float`" msgstr ":class:`float`" -#: ../../library/concurrent.interpreters.rst:192 msgid ":class:`tuple` (of similarly supported objects)" -msgstr "" +msgstr ":class:`tuple` (同様にサポートされているオブジェクトを要素とするもの)" -#: ../../library/concurrent.interpreters.rst:194 msgid "" "There are a small number of Python types that actually share mutable data " "between interpreters:" msgstr "" +"インタープリタ間で実際にミュータブルなデータを共有する Python の型も、少数で" +"すが存在します:" #: ../../library/concurrent.interpreters.rst:197 msgid ":class:`memoryview`" @@ -336,154 +390,163 @@ msgstr "リファレンス" msgid "This module defines the following functions:" msgstr "このモジュールは以下の関数を定義しています:" -#: ../../library/concurrent.interpreters.rst:208 msgid "" "Return a :class:`list` of :class:`Interpreter` objects, one for each " "existing interpreter." msgstr "" +"既存の各インタープリタに対応する :class:`Interpreter` オブジェクトの :class:" +"`list` を返します。" -#: ../../library/concurrent.interpreters.rst:213 msgid "" "Return an :class:`Interpreter` object for the currently running interpreter." msgstr "" +"現在実行中のインタープリタの :class:`Interpreter` オブジェクトを返します。" -#: ../../library/concurrent.interpreters.rst:218 msgid "" "Return an :class:`Interpreter` object for the main interpreter. This is the " "interpreter the runtime created to run the :term:`REPL` or the script given " "at the command-line. It is usually the only one." msgstr "" +"メインインタープリタの :class:`Interpreter` オブジェクトを返します。\n" +"これは、:term:`REPL` またはコマンドラインで指定されたスクリプトを実行するため" +"に、ランタイムが作成したインタープリタです。\n" +"通常は、これが唯一のインタープリタです。" -#: ../../library/concurrent.interpreters.rst:224 msgid "" "Initialize a new (idle) Python interpreter and return a :class:`Interpreter` " "object for it." msgstr "" +"新しい (実行中でない) Python インタープリタを初期化し、その :class:" +"`Interpreter` オブジェクトを返します。" -#: ../../library/concurrent.interpreters.rst:229 msgid "" "Initialize a new cross-interpreter queue and return a :class:`Queue` object " "for it." msgstr "" +"インタープリタ間で使う新しいキューを初期化し、その :class:`Queue` オブジェク" +"トを返します。" -#: ../../library/concurrent.interpreters.rst:232 msgid "" "*maxsize* is an integer that sets the upperbound limit on the number of " "items that can be placed in the queue. Insertion will be blocked once this " "size has been reached, until queue items are consumed. If *maxsize* is less " "than or equal to zero, the queue size is infinite." msgstr "" +"*maxsize* は、キューに入れられる要素数の上限を設定する整数です。\n" +"このサイズに達すると、キューの要素が取り出されるまで挿入はブロックされま" +"す。\n" +"*maxsize* が 0 以下の場合、キューのサイズに上限はありません。" -#: ../../library/concurrent.interpreters.rst:238 msgid "Interpreter objects" -msgstr "" +msgstr "インタープリタオブジェクト" -#: ../../library/concurrent.interpreters.rst:242 msgid "A single interpreter in the current process." -msgstr "" +msgstr "現在のプロセス内の一つのインタープリタです。" -#: ../../library/concurrent.interpreters.rst:244 msgid "" "Generally, :class:`Interpreter` shouldn't be called directly. Instead, use :" "func:`create` or one of the other module functions." msgstr "" +"通常、:class:`Interpreter` を直接呼び出すべきではありません。\n" +"代わりに :func:`create` または他のモジュール関数を使ってください。" -#: ../../library/concurrent.interpreters.rst:249 -#: ../../library/concurrent.interpreters.rst:255 -#: ../../library/concurrent.interpreters.rst:336 msgid "(read-only)" -msgstr "" +msgstr "(読み出し専用)" -#: ../../library/concurrent.interpreters.rst:251 msgid "The underlying interpreter's ID." -msgstr "" +msgstr "基となるインタープリタの ID です。" -#: ../../library/concurrent.interpreters.rst:257 msgid "A string describing where the interpreter came from." -msgstr "" +msgstr "インタープリタがどこから作成されたかを表す文字列です。" -#: ../../library/concurrent.interpreters.rst:261 msgid "" "Return ``True`` if the interpreter is currently executing code in its :mod:`!" "__main__` module and ``False`` otherwise." msgstr "" +"インタープリタが現在 :mod:`!__main__` モジュール内でコードを実行している場合" +"は ``True``、それ以外の場合は ``False`` を返します。" -#: ../../library/concurrent.interpreters.rst:266 msgid "Finalize and destroy the interpreter." -msgstr "" +msgstr "インタープリタの終了処理を行い、破棄します。" -#: ../../library/concurrent.interpreters.rst:270 msgid "Bind objects in the interpreter's :mod:`!__main__` module." msgstr "" +"インタープリタの :mod:`!__main__` モジュール内にオブジェクトを束縛します。" -#: ../../library/concurrent.interpreters.rst:272 -#: ../../library/concurrent.interpreters.rst:331 msgid "" "Some objects are actually shared and some are copied efficiently, but most " "are copied via :mod:`pickle`. See :ref:`interp-object-sharing`." msgstr "" +"一部のオブジェクトは実際に共有され、効率よくコピーされるものもありますが、ほ" +"とんどは :mod:`pickle` を介してコピーされます。\n" +":ref:`interp-object-sharing` を参照してください。" -#: ../../library/concurrent.interpreters.rst:277 msgid "Run the given source code in the interpreter (in the current thread)." msgstr "" +"指定されたソースコードを、現在のスレッドでそのインタープリタ内で実行します。" -#: ../../library/concurrent.interpreters.rst:281 msgid "" "Return the result of running the given function in the interpreter (in the " "current thread)." msgstr "" +"指定された関数を、現在のスレッドでそのインタープリタ内で実行した結果を返しま" +"す。" -#: ../../library/concurrent.interpreters.rst:288 msgid "Run the given function in the interpreter (in a new thread)." -msgstr "" +msgstr "指定された関数を、新しいスレッドでそのインタープリタ内で実行します。" #: ../../library/concurrent.interpreters.rst:291 msgid "Exceptions" msgstr "例外" -#: ../../library/concurrent.interpreters.rst:295 msgid "" "This exception, a subclass of :exc:`Exception`, is raised when an " "interpreter-related error happens." msgstr "" +":exc:`Exception` のサブクラスで、インタープリタに関するエラーが発生した場合に" +"送出されます。" -#: ../../library/concurrent.interpreters.rst:300 msgid "" "This exception, a subclass of :exc:`InterpreterError`, is raised when the " "targeted interpreter no longer exists." msgstr "" +":exc:`InterpreterError` のサブクラスで、対象のインタープリタがすでに存在しな" +"い場合に送出されます。" -#: ../../library/concurrent.interpreters.rst:305 msgid "" "This exception, a subclass of :exc:`InterpreterError`, is raised when the " "running code raised an uncaught exception." msgstr "" +":exc:`InterpreterError` のサブクラスで、実行中のコードが捕捉されない例外を送" +"出した場合に送出されます。" -#: ../../library/concurrent.interpreters.rst:310 msgid "A basic snapshot of the exception raised in the other interpreter." -msgstr "" +msgstr "別のインタープリタで送出された例外の基本的なスナップショットです。" -#: ../../library/concurrent.interpreters.rst:316 msgid "" "This exception, a subclass of :exc:`TypeError`, is raised when an object " "cannot be sent to another interpreter." msgstr "" +":exc:`TypeError` のサブクラスで、オブジェクトを別のインタープリタに送れない場" +"合に送出されます。" -#: ../../library/concurrent.interpreters.rst:321 msgid "Communicating Between Interpreters" -msgstr "" +msgstr "インタープリタ間での通信" -#: ../../library/concurrent.interpreters.rst:325 msgid "" "A wrapper around a low-level, cross-interpreter queue, which implements all " "the methods of :class:`queue.Queue` except for :meth:`~queue.Queue." "task_done`, :meth:`~queue.Queue.join` and :meth:`~queue.Queue.shutdown`. " "The underlying queue can only be created through :func:`create_queue`." msgstr "" +"インタープリタ間で使う低水準のキューのラッパです。\n" +":class:`queue.Queue` のメソッドのうち、:meth:`~queue.Queue.task_done`、:meth:" +"`~queue.Queue.join`、:meth:`~queue.Queue.shutdown` を除くすべてを実装していま" +"す。\n" +"基となるキューを作成できるのは :func:`create_queue` だけです。" -#: ../../library/concurrent.interpreters.rst:338 msgid "The queue's ID." -msgstr "" +msgstr "キューの ID です。" #: ../../library/concurrent.interpreters.rst:342 msgid "Return the number of items in the queue." @@ -493,11 +556,10 @@ msgstr "キュー内の要素数を返します。" msgid "Return ``True`` if the queue is empty, ``False`` otherwise." msgstr "キューが空ならば ``True`` を、そうでなければ ``False`` を返します。" -#: ../../library/concurrent.interpreters.rst:350 msgid "Return ``True`` if the queue is full, ``False`` otherwise." msgstr "" +"キューがいっぱいの場合は ``True``、それ以外の場合は ``False`` を返します。" -#: ../../library/concurrent.interpreters.rst:354 msgid "" "Put *obj* into the queue. If optional args *block* is true and *timeout* is " "``None`` (the default), block if necessary until a free slot is available. " @@ -507,12 +569,18 @@ msgid "" "free slot is immediately available, else raise the :exc:`QueueFull` " "exception (*timeout* is ignored in that case)." msgstr "" +"*obj* をキューに入れます。\n" +"オプション引数 *block* が真で、*timeout* が ``None`` (デフォルト) の場合、必" +"要に応じて空きができるまでブロックします。\n" +"*timeout* が正の数の場合、最大 *timeout* 秒ブロックし、その間に空きができなけ" +"れば :exc:`QueueFull` 例外を送出します。\n" +"それ以外の場合 (*block* が偽の場合)、直ちに利用できる空きがあればオブジェクト" +"をキューに入れ、なければ :exc:`QueueFull` 例外を送出します (この場合、" +"*timeout* は無視されます)。" -#: ../../library/concurrent.interpreters.rst:365 msgid "Equivalent to ``put(obj, block=False)``." -msgstr "" +msgstr "``put(obj, block=False)`` と等価です。" -#: ../../library/concurrent.interpreters.rst:369 msgid "" "Remove and return an object from the queue. If optional args *block* is " "true and *timeout* is ``None`` (the default), block if necessary until an " @@ -522,32 +590,39 @@ msgid "" "object if one is immediately available, else raise the :exc:`QueueEmpty` " "exception (*timeout* is ignored in that case)." msgstr "" +"キューからオブジェクトを取り出して返します。\n" +"オプション引数 *block* が真で、*timeout* が ``None`` (デフォルト) の場合、必" +"要に応じてオブジェクトが利用できるまでブロックします。\n" +"*timeout* が正の数の場合、最大 *timeout* 秒ブロックし、その間にオブジェクトが" +"利用できなければ :exc:`QueueEmpty` 例外を送出します。\n" +"それ以外の場合 (*block* が偽の場合)、直ちに利用できるオブジェクトがあればそれ" +"を返し、なければ :exc:`QueueEmpty` 例外を送出します (この場合、*timeout* は無" +"視されます)。" -#: ../../library/concurrent.interpreters.rst:380 msgid "Equivalent to ``get(block=False)``." -msgstr "" +msgstr "``get(block=False)`` と等価です。" -#: ../../library/concurrent.interpreters.rst:385 msgid "" "This exception, a subclass of :exc:`queue.Empty`, is raised from :meth:" "`Queue.get` and :meth:`Queue.get_nowait` when the queue is empty." msgstr "" +":exc:`queue.Empty` のサブクラスで、キューが空の場合に :meth:`Queue.get` と :" +"meth:`Queue.get_nowait` から送出されます。" -#: ../../library/concurrent.interpreters.rst:391 msgid "" "This exception, a subclass of :exc:`queue.Full`, is raised from :meth:`Queue." "put` and :meth:`Queue.put_nowait` when the queue is full." msgstr "" +":exc:`queue.Full` のサブクラスで、キューがいっぱいの場合に :meth:`Queue.put` " +"と :meth:`Queue.put_nowait` から送出されます。" #: ../../library/concurrent.interpreters.rst:397 msgid "Basic usage" msgstr "基本的な使い方" -#: ../../library/concurrent.interpreters.rst:399 msgid "Creating an interpreter and running code in it::" -msgstr "" +msgstr "インタープリタを作成し、その中でコードを実行する例。 ::" -#: ../../library/concurrent.interpreters.rst:401 msgid "" "from concurrent import interpreters\n" "\n" @@ -582,12 +657,42 @@ msgid "" "t = interp.call_in_thread(run)\n" "t.join()" msgstr "" +"from concurrent import interpreters\n" +"\n" +"interp = interpreters.create()\n" +"\n" +"# 現在の OS スレッドで実行する\n" +"\n" +"interp.exec('print(\"spam!\")')\n" +"\n" +"interp.exec(\"\"\"if True:\n" +" print('spam!')\n" +" \"\"\")\n" +"\n" +"from textwrap import dedent\n" +"interp.exec(dedent(\"\"\"\n" +" print('spam!')\n" +" \"\"\"))\n" +"\n" +"def run(arg):\n" +" return arg\n" +"\n" +"res = interp.call(run, 'spam!')\n" +"print(res)\n" +"\n" +"def run():\n" +" print('spam!')\n" +"\n" +"interp.call(run)\n" +"\n" +"# 新しい OS スレッドで実行する\n" +"\n" +"t = interp.call_in_thread(run)\n" +"t.join()" -#: ../../library/concurrent.interpreters.rst:434 msgid "Communicating between interpreters with a queue::" -msgstr "" +msgstr "キューを使ってインタープリタ間で通信する例。 ::" -#: ../../library/concurrent.interpreters.rst:436 msgid "" "from concurrent import interpreters\n" "\n" @@ -601,3 +706,14 @@ msgid "" "print(queue.get())\n" "t.join()" msgstr "" +"from concurrent import interpreters\n" +"\n" +"interp = interpreters.create()\n" +"queue = interpreters.create_queue()\n" +"\n" +"def worker(queue):\n" +" queue.put('spam!')\n" +"\n" +"t = interp.call_in_thread(worker, queue)\n" +"print(queue.get())\n" +"t.join()" diff --git a/library/concurrent.po b/library/concurrent.po index d056f7f68..92b422977 100644 --- a/library/concurrent.po +++ b/library/concurrent.po @@ -16,25 +16,23 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/concurrent.rst:2 msgid "The :mod:`!concurrent` package" msgstr ":mod:`!concurrent` パッケージ" -#: ../../library/concurrent.rst:4 msgid "This package contains the following modules:" -msgstr "" +msgstr "このパッケージには、以下のモジュールが含まれています:" #: ../../library/concurrent.rst:6 msgid ":mod:`concurrent.futures` -- Launching parallel tasks" msgstr ":mod:`concurrent.futures` -- 並列タスク実行" -#: ../../library/concurrent.rst:7 msgid "" ":mod:`concurrent.interpreters` -- Multiple interpreters in the same process" -msgstr "" +msgstr ":mod:`concurrent.interpreters` -- 同じプロセス内の複数のインタープリタ" diff --git a/library/configparser.po b/library/configparser.po index d0e777fb0..08116b3a2 100644 --- a/library/configparser.po +++ b/library/configparser.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/configparser.rst:2 @@ -42,30 +42,34 @@ msgstr "" "ラスを使ってユーザーが簡単にカスタマイズできる Python プログラムを作ることが" "できます。" -#: ../../library/configparser.rst:24 msgid "" "This library does *not* interpret or write the value-type prefixes used in " "the Windows Registry extended version of INI syntax." msgstr "" -"このライブラリでは、Windowsのレジストリ用に拡張された INI 文法はサポート *し" -"ていません* 。" +"このライブラリは、Windows レジストリ用に拡張された INI 構文で使われる値の型を" +"表す接頭辞を解釈したり書き込んだりは *しません*。" -#: ../../library/configparser.rst:28 msgid "" "Be cautious when parsing data from untrusted sources. A malicious INI file " "may cause the decoder to consume considerable CPU and memory resources. " "Limiting the size of data to be parsed is recommended." msgstr "" +"信頼できない提供元のデータを解析するときは注意してください。\n" +"悪意のある INI ファイルにより、デコーダーが大量の CPU とメモリ資源を消費する" +"可能性があります。\n" +"解析するデータのサイズを制限することを推奨します。" #: ../../library/configparser.rst:34 msgid "Module :mod:`tomllib`" msgstr "モジュール :mod:`tomllib`" -#: ../../library/configparser.rst:35 msgid "" "TOML is a well-specified format for application configuration files. It is " "specifically designed to be an improved version of INI." msgstr "" +"TOML は、アプリケーションの設定ファイル向けに仕様が明確に定められた形式で" +"す。\n" +"INI を改善することを目的に設計されています。" #: ../../library/configparser.rst:38 msgid "Module :mod:`shlex`" @@ -83,11 +87,12 @@ msgstr "" msgid "Module :mod:`json`" msgstr ":mod:`json` モジュール" -#: ../../library/configparser.rst:43 msgid "" "The ``json`` module implements a subset of JavaScript syntax which is " "sometimes used for configuration, but does not support comments." msgstr "" +"``json`` モジュールは JavaScript の構文のサブセットを実装しています。\n" +"設定に使われることもありますが、コメントはサポートしません。" #: ../../library/configparser.rst:59 msgid "Quick Start" @@ -97,7 +102,6 @@ msgstr "クイックスタート" msgid "Let's take a very basic configuration file that looks like this:" msgstr "次のような、非常に簡単な設定ファイルを例に考えましょう:" -#: ../../library/configparser.rst:63 msgid "" "[DEFAULT]\n" "ServerAliveInterval = 45\n" @@ -112,8 +116,19 @@ msgid "" "Port = 50022\n" "ForwardX11 = no" msgstr "" +"[DEFAULT]\n" +"ServerAliveInterval = 45\n" +"Compression = yes\n" +"CompressionLevel = 9\n" +"ForwardX11 = yes\n" +"\n" +"[forge.example]\n" +"User = hg\n" +"\n" +"[topsecret.server.example]\n" +"Port = 50022\n" +"ForwardX11 = no" -#: ../../library/configparser.rst:78 msgid "" "The structure of INI files is described `in the following section " "<#supported-ini-file-structure>`_. Essentially, the file consists of " @@ -121,8 +136,13 @@ msgid "" "classes can read and write such files. Let's start by creating the above " "configuration file programmatically." msgstr "" +"INI ファイルの構造は `次の節 <#supported-ini-file-structure>`_ で説明しま" +"す。\n" +"基本的には、ファイルはセクションで構成され、各セクションには値を持つキーが含" +"まれます。\n" +":mod:`!configparser` のクラスは、このようなファイルを読み書きできます。\n" +"まず、上の設定ファイルをプログラムで作成してみましょう。" -#: ../../library/configparser.rst:84 msgid "" ">>> import configparser\n" ">>> config = configparser.ConfigParser()\n" @@ -140,6 +160,21 @@ msgid "" "... config.write(configfile)\n" "..." msgstr "" +">>> import configparser\n" +">>> config = configparser.ConfigParser()\n" +">>> config['DEFAULT'] = {'ServerAliveInterval': '45',\n" +"... 'Compression': 'yes',\n" +"... 'CompressionLevel': '9'}\n" +">>> config['forge.example'] = {}\n" +">>> config['forge.example']['User'] = 'hg'\n" +">>> config['topsecret.server.example'] = {}\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['Port'] = '50022' # パーサーを変更する\n" +">>> topsecret['ForwardX11'] = 'no' # ここも同様\n" +">>> config['DEFAULT']['ForwardX11'] = 'yes'\n" +">>> with open('example.ini', 'w') as configfile:\n" +"... config.write(configfile)\n" +"..." #: ../../library/configparser.rst:102 msgid "" @@ -159,7 +194,6 @@ msgstr "" "これで設定ファイルを作成して保存できました。次はこれを読み込み直して、中の" "データを取り出してみましょう。" -#: ../../library/configparser.rst:109 msgid "" ">>> config = configparser.ConfigParser()\n" ">>> config.sections()\n" @@ -191,6 +225,35 @@ msgid "" ">>> config['forge.example']['ForwardX11']\n" "'yes'" msgstr "" +">>> config = configparser.ConfigParser()\n" +">>> config.sections()\n" +"[]\n" +">>> config.read('example.ini')\n" +"['example.ini']\n" +">>> config.sections()\n" +"['forge.example', 'topsecret.server.example']\n" +">>> 'forge.example' in config\n" +"True\n" +">>> 'python.org' in config\n" +"False\n" +">>> config['forge.example']['User']\n" +"'hg'\n" +">>> config['DEFAULT']['Compression']\n" +"'yes'\n" +">>> topsecret = config['topsecret.server.example']\n" +">>> topsecret['ForwardX11']\n" +"'no'\n" +">>> topsecret['Port']\n" +"'50022'\n" +">>> for key in config['forge.example']:\n" +"... print(key)\n" +"user\n" +"compressionlevel\n" +"serveraliveinterval\n" +"compression\n" +"forwardx11\n" +">>> config['forge.example']['ForwardX11']\n" +"'yes'" #: ../../library/configparser.rst:141 msgid "" @@ -204,7 +267,6 @@ msgstr "" "[1]_。 また、セクション内の各キーは大文字小文字を区別せず、全て小文字で保存さ" "れていることにも注意してください [1]_。" -#: ../../library/configparser.rst:146 ../../library/configparser.rst:1001 msgid "" "It is possible to read several configurations into a single :class:" "`ConfigParser`, where the most recently added configuration has the highest " @@ -213,14 +275,20 @@ msgid "" "an ``override.ini`` file, which will override any conflicting keys from the " "``example.ini`` file." msgstr "" +"1 つの :class:`ConfigParser` に複数の設定を読み込むことができ、最後に追加した" +"設定が最も優先されます。\n" +"重複するキーには後から読み込んだ設定の値が使われ、重複しない既存のキーは保持" +"されます。\n" +"次の例では ``override.ini`` ファイルを読み込み、``example.ini`` ファイルと重" +"複するキーの値を上書きします。" -#: ../../library/configparser.rst:153 ../../library/configparser.rst:1008 msgid "" "[DEFAULT]\n" "ServerAliveInterval = -1" msgstr "" +"[DEFAULT]\n" +"ServerAliveInterval = -1" -#: ../../library/configparser.rst:158 ../../library/configparser.rst:1013 msgid "" ">>> config_override = configparser.ConfigParser()\n" ">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" @@ -233,12 +301,23 @@ msgid "" ">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" "-1" msgstr "" +">>> config_override = configparser.ConfigParser()\n" +">>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}\n" +">>> with open('override.ini', 'w') as configfile:\n" +"... config_override.write(configfile)\n" +"...\n" +">>> config_override = configparser.ConfigParser()\n" +">>> config_override.read(['example.ini', 'override.ini'])\n" +"['example.ini', 'override.ini']\n" +">>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))\n" +"-1" -#: ../../library/configparser.rst:172 msgid "" "This behaviour is equivalent to a :meth:`ConfigParser.read` call with " "several files passed to the *filenames* parameter." msgstr "" +"この動作は、*filenames* 引数に複数のファイルを渡して :meth:`ConfigParser." +"read` を呼び出す場合と同じです。" #: ../../library/configparser.rst:177 msgid "Supported Datatypes" @@ -253,13 +332,16 @@ msgstr "" "Config parser は値のデータ型について何も推論せず、常に文字列のまま内部に保存" "します。他のデータ型が必要な場合は自分で変換する必要があります:" -#: ../../library/configparser.rst:183 msgid "" ">>> int(topsecret['Port'])\n" "50022\n" ">>> float(topsecret['CompressionLevel'])\n" "9.0" msgstr "" +">>> int(topsecret['Port'])\n" +"50022\n" +">>> float(topsecret['CompressionLevel'])\n" +"9.0" #: ../../library/configparser.rst:190 msgid "" @@ -279,7 +361,6 @@ msgstr "" "``'on'``/``'off'``、``'true'``/``'false'``、``'1'``/``'0'`` を真偽値として認" "識します [1]_。例えば:" -#: ../../library/configparser.rst:198 msgid "" ">>> topsecret.getboolean('ForwardX11')\n" "False\n" @@ -288,6 +369,12 @@ msgid "" ">>> config.getboolean('forge.example', 'Compression')\n" "True" msgstr "" +">>> topsecret.getboolean('ForwardX11')\n" +"False\n" +">>> config['forge.example'].getboolean('ForwardX11')\n" +"True\n" +">>> config.getboolean('forge.example', 'Compression')\n" +"True" #: ../../library/configparser.rst:207 msgid "" @@ -305,13 +392,13 @@ msgstr "" msgid "Fallback Values" msgstr "代替値" -#: ../../library/configparser.rst:215 msgid "" "As with a dictionary, you can use a section's :meth:`~ConfigParser.get` " "method to provide fallback values:" msgstr "" +"辞書と同様に、セクションの :meth:`~ConfigParser.get` メソッドを使って代替値を" +"指定できます:" -#: ../../library/configparser.rst:218 msgid "" ">>> topsecret.get('Port')\n" "'50022'\n" @@ -321,6 +408,13 @@ msgid "" ">>> topsecret.get('Cipher', '3des-cbc')\n" "'3des-cbc'" msgstr "" +">>> topsecret.get('Port')\n" +"'50022'\n" +">>> topsecret.get('CompressionLevel')\n" +"'9'\n" +">>> topsecret.get('Cipher')\n" +">>> topsecret.get('Cipher', '3des-cbc')\n" +"'3des-cbc'" #: ../../library/configparser.rst:228 msgid "" @@ -335,26 +429,33 @@ msgstr "" "ん。その値を ``'topsecret.server.example'`` から取得しようとした場合、代替値" "を指定しても常にデフォルト値を返します:" -#: ../../library/configparser.rst:234 msgid "" ">>> topsecret.get('CompressionLevel', '3')\n" "'9'" msgstr "" +">>> topsecret.get('CompressionLevel', '3')\n" +"'9'" -#: ../../library/configparser.rst:239 msgid "" "One more thing to be aware of is that the parser-level :meth:`~ConfigParser." "get` method provides a custom, more complex interface, maintained for " "backwards compatibility. When using this method, a fallback value can be " "provided via the ``fallback`` keyword-only argument:" msgstr "" +"もう 1 つ注意が必要なのは、パーサーの :meth:`~ConfigParser.get` メソッドに" +"は、後方互換性のために維持されている独自の、より複雑なインターフェースがある" +"ことです。\n" +"このメソッドを使う場合、代替値はキーワード専用引数 ``fallback`` で指定できま" +"す:" -#: ../../library/configparser.rst:244 msgid "" ">>> config.get('forge.example', 'monster',\n" "... fallback='No such things as monsters')\n" "'No such things as monsters'" msgstr "" +">>> config.get('forge.example', 'monster',\n" +"... fallback='No such things as monsters')\n" +"'No such things as monsters'" #: ../../library/configparser.rst:250 msgid "" @@ -366,7 +467,6 @@ msgstr "" "`~ConfigParser.getfloat` と :meth:`~ConfigParser.getboolean` メソッドでも使え" "ます。例えば:" -#: ../../library/configparser.rst:254 msgid "" ">>> 'BatchMode' in topsecret\n" "False\n" @@ -376,12 +476,18 @@ msgid "" ">>> topsecret.getboolean('BatchMode', fallback=True)\n" "False" msgstr "" +">>> 'BatchMode' in topsecret\n" +"False\n" +">>> topsecret.getboolean('BatchMode', fallback=True)\n" +"True\n" +">>> config['DEFAULT']['BatchMode'] = 'no'\n" +">>> topsecret.getboolean('BatchMode', fallback=True)\n" +"False" #: ../../library/configparser.rst:266 msgid "Supported INI File Structure" msgstr "サポートするINI ファイルの構造" -#: ../../library/configparser.rst:268 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by a specific string (``=`` " @@ -393,20 +499,37 @@ msgid "" "of the value. Depending on the parser's mode, blank lines may be treated as " "parts of multiline values or ignored." msgstr "" +"設定ファイルはセクションで構成されます。\n" +"各セクションは ``[section]`` ヘッダーで始まり、その後に特定の文字列 (デフォル" +"トでは ``=`` または ``:`` [1]_) で区切られたキーと値のエントリーが続きま" +"す。\n" +"デフォルトでは、セクション名は大文字と小文字を区別しますが、キーは区別しませ" +"ん [1]_。\n" +"キーと値の前後の空白は取り除かれます。\n" +"パーサーの設定で許可されていれば値を省略でき [1]_、その場合はキーと値を区切る" +"デリミタも省略できます。\n" +"値の最初の行よりも深くインデントすれば、値を複数行にわたって記述することもで" +"きます。\n" +"パーサーのモードによって、空行は複数行の値の一部として扱われる場合も、無視さ" +"れる場合もあります。" -#: ../../library/configparser.rst:278 msgid "" "By default, a valid section name can be any string that does not contain '\\" "\\n'. To change this, see :attr:`ConfigParser.SECTCRE`." msgstr "" +"デフォルトでは、'\\\\n' を含まない任意の文字列をセクション名にできます。\n" +"これを変更するには :attr:`ConfigParser.SECTCRE` を参照してください。" -#: ../../library/configparser.rst:281 msgid "" "The first section name may be omitted if the parser is configured to allow " "an unnamed top level section with ``allow_unnamed_section=True``. In this " "case, the keys/values may be retrieved by :const:`UNNAMED_SECTION` as in " "``config[UNNAMED_SECTION]``." msgstr "" +"``allow_unnamed_section=True`` を指定して無名の最上位セクションを許可した場" +"合、最初のセクション名は省略できます。\n" +"この場合、``config[UNNAMED_SECTION]`` のように :const:`UNNAMED_SECTION` を" +"使ってキーと値を取得できます。" #: ../../library/configparser.rst:286 msgid "" @@ -422,7 +545,6 @@ msgstr "" msgid "For example:" msgstr "例えば:" -#: ../../library/configparser.rst:292 msgid "" "[Simple Values]\n" "key=value\n" @@ -466,18 +588,58 @@ msgid "" " of a value\n" " # Did I mention we can indent comments, too?" msgstr "" +"[Simple Values]\n" +"key=value\n" +"spaces in keys=allowed\n" +"spaces in values=allowed as well\n" +"spaces around the delimiter = obviously\n" +"you can also use : to delimit keys from values\n" +"\n" +"[All Values Are Strings]\n" +"values like this: 1000000\n" +"or this: 3.14159265359\n" +"are they treated as numbers? : no\n" +"integers, floats and booleans are held as: strings\n" +"can use the API to get converted values directly: true\n" +"\n" +"[Multiline Values]\n" +"chorus: I'm a lumberjack, and I'm okay\n" +" I sleep all night and I work all day\n" +"\n" +"[No Values]\n" +"key_without_value\n" +"empty string value here =\n" +"\n" +"[You can use comments]\n" +"# このように\n" +"; このようにも\n" +"\n" +"# デフォルトでは他の内容がない行にのみ記述できます。\n" +"# インラインコメントは、デリミタを値の一部として使えなくするため、\n" +"# 問題になることがあります。\n" +"# ただし、この動作はカスタマイズできます。\n" +"\n" +" [Sections Can Be Indented]\n" +" can_values_be_as_well = True\n" +" does_that_mean_anything_special = False\n" +" purpose = formatting for readability\n" +" multiline_values = are\n" +" handled just fine as\n" +" long as they are indented\n" +" deeper than the first line\n" +" of a value\n" +" # コメントもインデントできます。" -#: ../../library/configparser.rst:340 msgid "Unnamed Sections" -msgstr "" +msgstr "無名セクション" -#: ../../library/configparser.rst:342 msgid "" "The name of the first section (or unique) may be omitted and values " "retrieved by the :const:`UNNAMED_SECTION` attribute." msgstr "" +"最初のセクション (または唯一のセクション) の名前は省略でき、:const:" +"`UNNAMED_SECTION` 属性を使って値を取得できます。" -#: ../../library/configparser.rst:345 msgid "" ">>> config = \"\"\"\n" "... option = value\n" @@ -490,6 +652,16 @@ msgid "" ">>> unnamed.get(configparser.UNNAMED_SECTION, 'option')\n" "'value'" msgstr "" +">>> config = \"\"\"\n" +"... option = value\n" +"...\n" +"... [ Section 2 ]\n" +"... another = val\n" +"... \"\"\"\n" +">>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)\n" +">>> unnamed.read_string(config)\n" +">>> unnamed.get(configparser.UNNAMED_SECTION, 'option')\n" +"'value'" #: ../../library/configparser.rst:359 msgid "Interpolation of values" @@ -516,7 +688,6 @@ msgstr "" "別なデフォルトセクション中 [1]_ の他の値を参照するフォーマット文字列を含める" "ことができます。追加のデフォルト値を初期化時に提供できます。" -#: ../../library/configparser.rst:376 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -528,6 +699,14 @@ msgid "" "escaped):\n" "gain: 80%%" msgstr "" +"[Paths]\n" +"home_dir: /Users\n" +"my_dir: %(home_dir)s/lumberjack\n" +"my_pictures: %(my_dir)s/Pictures\n" +"\n" +"[Escape]\n" +"# %% で % 記号をエスケープします (エスケープが必要なのは % だけです):\n" +"gain: 80%%" #: ../../library/configparser.rst:387 msgid "" @@ -577,7 +756,6 @@ msgstr "" "たとえば、上記の basic interpolation で指定した設定は、extended " "interpolation を使うと下記のようになります:" -#: ../../library/configparser.rst:412 msgid "" "[Paths]\n" "home_dir: /Users\n" @@ -589,12 +767,19 @@ msgid "" "escaped):\n" "cost: $$80" msgstr "" +"[Paths]\n" +"home_dir: /Users\n" +"my_dir: ${home_dir}/lumberjack\n" +"my_pictures: ${my_dir}/Pictures\n" +"\n" +"[Escape]\n" +"# $$ で $ 記号をエスケープします (エスケープが必要なのは $ だけです):\n" +"cost: $$80" #: ../../library/configparser.rst:423 msgid "Values from other sections can be fetched as well:" msgstr "他のセクションから値を持ってくることもできます:" -#: ../../library/configparser.rst:425 msgid "" "[Common]\n" "home_dir: /Users\n" @@ -613,18 +798,37 @@ msgid "" "my_pictures: ${my_dir}/Pictures\n" "python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" msgstr "" +"[Common]\n" +"home_dir: /Users\n" +"library_dir: /Library\n" +"system_dir: /System\n" +"macports_dir: /opt/local\n" +"\n" +"[Frameworks]\n" +"Python: 3.2\n" +"path: ${Common:system_dir}/Library/Frameworks/\n" +"\n" +"[Arthur]\n" +"nickname: Two Sheds\n" +"last_name: Jackson\n" +"my_dir: ${Common:home_dir}/twosheds\n" +"my_pictures: ${my_dir}/Pictures\n" +"python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}" #: ../../library/configparser.rst:445 msgid "Mapping Protocol Access" msgstr "マップ型プロトコルアクセス" -#: ../../library/configparser.rst:449 msgid "" "Mapping protocol access is a generic name for functionality that enables " "using custom objects as if they were dictionaries. In case of :mod:`!" "configparser`, the mapping interface implementation is using the " "``parser['section']['option']`` notation." msgstr "" +"マップ型プロトコルアクセスとは、独自のオブジェクトを辞書のように使える機能の" +"総称です。\n" +":mod:`!configparser` のマッピングインターフェースでは、``parser['section']" +"['option']`` という記法を使います。" #: ../../library/configparser.rst:454 msgid "" @@ -639,13 +843,17 @@ msgstr "" "サーから取られます。さらに重要なことに、セクションのプロキシの値が変更される" "と、オリジナルのパーサー中の値が実際に変更されます。" -#: ../../library/configparser.rst:460 msgid "" ":mod:`!configparser` objects behave as close to actual dictionaries as " "possible. The mapping interface is complete and adheres to the :class:" "`~collections.abc.MutableMapping` ABC. However, there are a few differences " "that should be taken into account:" msgstr "" +":mod:`!configparser` オブジェクトは、できる限り実際の辞書に近い振る舞いをしま" +"す。\n" +"マッピングインターフェースは完全に実装されており、:class:`~collections.abc." +"MutableMapping` ABC に従います。\n" +"ただし、注意すべき違いがいくつかあります:" #: ../../library/configparser.rst:465 msgid "" @@ -661,11 +869,12 @@ msgstr "" "す。同時に、キー ``'a'`` を含むセクションにおいて、どちらの式も ``True`` を返" "します::" -#: ../../library/configparser.rst:470 msgid "" "\"a\" in parser[\"section\"]\n" "\"A\" in parser[\"section\"]" msgstr "" +"\"a\" in parser[\"section\"]\n" +"\"A\" in parser[\"section\"]" #: ../../library/configparser.rst:473 msgid "" @@ -736,7 +945,6 @@ msgstr "" msgid "Customizing Parser Behaviour" msgstr "パーサーの振る舞いをカスタマイズする" -#: ../../library/configparser.rst:507 msgid "" "There are nearly as many INI format variants as there are applications using " "it. :mod:`!configparser` goes a long way to provide support for the largest " @@ -744,32 +952,40 @@ msgid "" "dictated by historical background and it's very likely that you will want to " "customize some of the features." msgstr "" +"INI 形式には、それを使うアプリケーションとほぼ同じ数の変種があります。\n" +":mod:`!configparser` は、妥当な範囲でできるだけ多くの INI の書式をサポートす" +"るよう努めています。\n" +"デフォルトの機能は主に歴史的な経緯によって決まっているため、機能の一部をカス" +"タマイズしたくなることも多いでしょう。" -#: ../../library/configparser.rst:513 msgid "" "The most common way to change the way a specific config parser works is to " "use the :meth:`!__init__` options:" msgstr "" +"個々の設定パーサーの動作を変える最も一般的な方法は、:meth:`!__init__` のオプ" +"ションを使うことです:" #: ../../library/configparser.rst:516 msgid "*defaults*, default value: ``None``" msgstr "*defaults*, デフォルト値: ``None``" -#: ../../library/configparser.rst:518 msgid "" "This option accepts a dictionary of key-value pairs which will be initially " "put in the ``DEFAULT`` section. This makes for an elegant way to support " "concise configuration files that don't specify values which are the same as " "the documented default." msgstr "" -"このオプションは最初に ``DEFAULT`` セクションに加えられるキー-値の対の辞書を" -"受け付けます。" +"このオプションは、最初に ``DEFAULT`` セクションに追加するキーと値の対を含む辞" +"書を受け付けます。\n" +"これにより、文書に記載されたデフォルト値と同じ値の指定を省いた、簡潔な設定" +"ファイルを容易にサポートできます。" -#: ../../library/configparser.rst:523 msgid "" "Hint: if you want to specify default values for a specific section, use :" "meth:`~ConfigParser.read_dict` before you read the actual file." msgstr "" +"ヒント: 特定のセクションのデフォルト値を指定するには、実際のファイルを読み込" +"む前に :meth:`~ConfigParser.read_dict` を使ってください。" #: ../../library/configparser.rst:526 msgid "*dict_type*, default value: :class:`dict`" @@ -803,7 +1019,6 @@ msgstr "" "注意: 一度の操作でキー-値の対を複数追加する方法もあります。そのような操作に普" "通の辞書を使うと、キーの並びは挿入順になります。例えば:" -#: ../../library/configparser.rst:540 msgid "" ">>> parser = configparser.ConfigParser()\n" ">>> parser.read_dict({'section1': {'key1': 'value1',\n" @@ -821,20 +1036,37 @@ msgid "" ">>> [option for option in parser['section3']]\n" "['foo', 'bar', 'baz']" msgstr "" +">>> parser = configparser.ConfigParser()\n" +">>> parser.read_dict({'section1': {'key1': 'value1',\n" +"... 'key2': 'value2',\n" +"... 'key3': 'value3'},\n" +"... 'section2': {'keyA': 'valueA',\n" +"... 'keyB': 'valueB',\n" +"... 'keyC': 'valueC'},\n" +"... 'section3': {'foo': 'x',\n" +"... 'bar': 'y',\n" +"... 'baz': 'z'}\n" +"... })\n" +">>> parser.sections()\n" +"['section1', 'section2', 'section3']\n" +">>> [option for option in parser['section3']]\n" +"['foo', 'bar', 'baz']" #: ../../library/configparser.rst:558 msgid "*allow_no_value*, default value: ``False``" msgstr "*allow_no_value*, デフォルト値: ``False``" -#: ../../library/configparser.rst:560 msgid "" "Some configuration files are known to include settings without values, but " "which otherwise conform to the syntax supported by :mod:`!configparser`. " "The *allow_no_value* parameter to the constructor can be used to indicate " "that such values should be accepted:" msgstr "" +":mod:`!configparser` がサポートする構文におおむね従っていても、値のない設定を" +"含む設定ファイルがあります。\n" +"そのような値を受け付けるには、コンストラクタの *allow_no_value* 引数を使いま" +"す:" -#: ../../library/configparser.rst:565 msgid "" ">>> import configparser\n" "\n" @@ -864,6 +1096,33 @@ msgid "" " ...\n" "KeyError: 'does-not-exist'" msgstr "" +">>> import configparser\n" +"\n" +">>> sample_config = \"\"\"\n" +"... [mysqld]\n" +"... user = mysql\n" +"... pid-file = /var/run/mysqld/mysqld.pid\n" +"... skip-external-locking\n" +"... old_passwords = 1\n" +"... skip-bdb\n" +"... # 今回は ACID は不要です\n" +"... skip-innodb\n" +"... \"\"\"\n" +">>> config = configparser.ConfigParser(allow_no_value=True)\n" +">>> config.read_string(sample_config)\n" +"\n" +">>> # 値のある設定は従来どおりに扱われます:\n" +">>> config[\"mysqld\"][\"user\"]\n" +"'mysql'\n" +"\n" +">>> # 値のない設定は None を返します:\n" +">>> config[\"mysqld\"][\"skip-bdb\"]\n" +"\n" +">>> # 指定されていない設定は引き続きエラーになります:\n" +">>> config[\"mysqld\"][\"does-not-exist\"]\n" +"Traceback (most recent call last):\n" +" ...\n" +"KeyError: 'does-not-exist'" #: ../../library/configparser.rst:595 msgid "*delimiters*, default value: ``('=', ':')``" @@ -910,11 +1169,13 @@ msgstr "" "ン、空行も可能) の後に使えます。デフォルトではインラインコメントは無効化され" "ていて、``'#'`` と ``';'`` を行全体のコメントに使用します。" -#: ../../library/configparser.rst:615 msgid "" "In previous versions of :mod:`!configparser` behaviour matched " "``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``." msgstr "" +"以前のバージョンの :mod:`!configparser` の動作は、" +"``comment_prefixes=('#',';')`` および ``inline_comment_prefixes=(';',)`` を指" +"定した場合と同じでした。" #: ../../library/configparser.rst:619 msgid "" @@ -932,7 +1193,6 @@ msgstr "" "も、複数行にわたる値で、行の先頭にコメント接頭辞文字を保存する唯一の方法は、" "次の例のように接頭辞を補間することです::" -#: ../../library/configparser.rst:626 msgid "" ">>> from configparser import ConfigParser, ExtendedInterpolation\n" ">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" @@ -973,24 +1233,67 @@ msgid "" "line #2\n" "line #3" msgstr "" +">>> from configparser import ConfigParser, ExtendedInterpolation\n" +">>> parser = ConfigParser(interpolation=ExtendedInterpolation())\n" +">>> # デフォルトの BasicInterpolation も使用できます\n" +">>> parser.read_string(\"\"\"\n" +"... [DEFAULT]\n" +"... hash = #\n" +"...\n" +"... [hashes]\n" +"... shebang =\n" +"... ${hash}!/usr/bin/env python\n" +"... ${hash} -*- coding: utf-8 -*-\n" +"...\n" +"... extensions =\n" +"... enabled_extension\n" +"... another_extension\n" +"... #disabled_by_comment\n" +"... yet_another_extension\n" +"...\n" +"... interpolation not necessary = if # is not at line start\n" +"... even in multiline values = line #1\n" +"... line #2\n" +"... line #3\n" +"... \"\"\")\n" +">>> print(parser['hashes']['shebang'])\n" +"\n" +"#!/usr/bin/env python\n" +"# -*- coding: utf-8 -*-\n" +">>> print(parser['hashes']['extensions'])\n" +"\n" +"enabled_extension\n" +"another_extension\n" +"yet_another_extension\n" +">>> print(parser['hashes']['interpolation not necessary'])\n" +"if # is not at line start\n" +">>> print(parser['hashes']['even in multiline values'])\n" +"line #1\n" +"line #2\n" +"line #3" #: ../../library/configparser.rst:665 msgid "*strict*, default value: ``True``" msgstr "*strict*, デフォルト値: ``True``" -#: ../../library/configparser.rst:667 msgid "" "When set to ``True``, the parser will not allow for any section or option " "duplicates while reading from a single source (using :meth:`~ConfigParser." "read_file`, :meth:`~ConfigParser.read_string` or :meth:`~ConfigParser." "read_dict`). It is recommended to use strict parsers in new applications." msgstr "" +"``True`` に設定すると、パーサーは単一のソースから (:meth:`~ConfigParser." +"read_file`、:meth:`~ConfigParser.read_string`、:meth:`~ConfigParser." +"read_dict` を使って) 読み込む際に、セクションやオプションの重複を許可しませ" +"ん。\n" +"新しいアプリケーションでは、この厳密なパーサーを使うことを推奨します。" -#: ../../library/configparser.rst:672 msgid "" "In previous versions of :mod:`!configparser` behaviour matched " "``strict=False``." msgstr "" +"以前のバージョンの :mod:`!configparser` の動作は、``strict=False`` を指定した" +"場合と同じでした。" #: ../../library/configparser.rst:676 msgid "*empty_lines_in_values*, default value: ``True``" @@ -1011,7 +1314,6 @@ msgstr "" "ルが大きく複雑になったとき、ユーザーがファイル構造を見失いやすいです。この例" "をご覧ください:" -#: ../../library/configparser.rst:685 msgid "" "[Section]\n" "key = multiline\n" @@ -1019,6 +1321,11 @@ msgid "" "\n" " this = is still a part of the multiline value of 'key'" msgstr "" +"[Section]\n" +"key = multiline\n" +" value with a gotcha\n" +"\n" +" this = is still a part of the multiline value of 'key'" #: ../../library/configparser.rst:693 msgid "" @@ -1088,7 +1395,6 @@ msgstr "" msgid "*converters*, default value: not set" msgstr "*converters*, デフォルト値: 未設定" -#: ../../library/configparser.rst:724 msgid "" "Config parsers provide option value getters that perform type conversion. " "By default :meth:`~ConfigParser.getint`, :meth:`~ConfigParser.getfloat`, " @@ -1101,6 +1407,18 @@ msgid "" "``parser_instance.getdecimal('section', 'key', fallback=0)`` and " "``parser_instance['section'].getdecimal('key', 0)``." msgstr "" +"設定パーサーには、型変換を行ってオプションの値を取得するメソッドがありま" +"す。\n" +"デフォルトでは :meth:`~ConfigParser.getint`、:meth:`~ConfigParser." +"getfloat`、:meth:`~ConfigParser.getboolean` が実装されています。\n" +"ほかの取得メソッドが必要な場合は、サブクラスで定義するか、各キーをコンバー" +"ター名、各値をその変換を実装する呼び出し可能オブジェクトとする辞書を渡せま" +"す。\n" +"例えば、``{'decimal': decimal.Decimal}`` を渡すと、パーサーオブジェクトとすべ" +"てのセクションプロキシに :meth:`!getdecimal` が追加されます。\n" +"つまり、``parser_instance.getdecimal('section', 'key', fallback=0)`` と " +"``parser_instance['section'].getdecimal('key', 0)`` のどちらも使えるようにな" +"ります。" #: ../../library/configparser.rst:735 msgid "" @@ -1138,7 +1456,6 @@ msgstr "" "``'false'``, ``'off'`` 。文字列と対応するブール値のカスタム辞書を指定すること" "でこれを上書きできます。たとえば:" -#: ../../library/configparser.rst:752 msgid "" ">>> custom = configparser.ConfigParser()\n" ">>> custom['section1'] = {'funky': 'nope'}\n" @@ -1150,6 +1467,15 @@ msgid "" ">>> custom['section1'].getboolean('funky')\n" "False" msgstr "" +">>> custom = configparser.ConfigParser()\n" +">>> custom['section1'] = {'funky': 'nope'}\n" +">>> custom['section1'].getboolean('funky')\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: Not a boolean: nope\n" +">>> custom.BOOLEAN_STATES = {'sure': True, 'nope': False}\n" +">>> custom['section1'].getboolean('funky')\n" +"False" #: ../../library/configparser.rst:764 msgid "" @@ -1171,7 +1497,6 @@ msgstr "" "すべてのキーは小文字になります。それがふさわしくなければ、このメソッドを上書" "きしてください。例えば:" -#: ../../library/configparser.rst:776 msgid "" ">>> config = \"\"\"\n" "... [Section1]\n" @@ -1194,15 +1519,36 @@ msgid "" ">>> list(custom['Section2'].keys())\n" "['AnotherKey']" msgstr "" +">>> config = \"\"\"\n" +"... [Section1]\n" +"... Key = Value\n" +"...\n" +"... [Section2]\n" +"... AnotherKey = Value\n" +"... \"\"\"\n" +">>> typical = configparser.ConfigParser()\n" +">>> typical.read_string(config)\n" +">>> list(typical['Section1'].keys())\n" +"['key']\n" +">>> list(typical['Section2'].keys())\n" +"['anotherkey']\n" +">>> custom = configparser.RawConfigParser()\n" +">>> custom.optionxform = lambda option: option\n" +">>> custom.read_string(config)\n" +">>> list(custom['Section1'].keys())\n" +"['Key']\n" +">>> list(custom['Section2'].keys())\n" +"['AnotherKey']" -#: ../../library/configparser.rst:800 msgid "" "The optionxform function transforms option names to a canonical form. This " "should be an idempotent function: if the name is already in canonical form, " "it should be returned unchanged." msgstr "" +"``optionxform()`` 関数はオプション名を正規形に変換します。\n" +"この関数は冪等でなければなりません。\n" +"つまり、名前がすでに正規形であれば、そのまま返す必要があります。" -#: ../../library/configparser.rst:807 msgid "" "A compiled regular expression used to parse section headers. The default " "matches ``[section]`` to the name ``\"section\"``. Whitespace is considered " @@ -1210,13 +1556,13 @@ msgid "" "name ``\" larch \"``. Override this attribute if that's unsuitable. For " "example:" msgstr "" -"セクションヘッダを解析するのに使われる、コンパイルされた正規表現です。デフォ" -"ルトでは ``[section]`` が ``\"section\"`` という名前にマッチします。空白はセ" -"クション名の一部と見なされるので、``[ larch ]`` は ``\" larch \"`` という" -"名のセクションとして読み込まれます。これがふさわしくない場合、このメソッドを" -"上書きしてください。例えば:" +"セクションヘッダーを解析するために使われる、コンパイル済みの正規表現です。\n" +"デフォルトでは ``[section]`` にマッチし、名前を ``\"section\"`` とします。\n" +"空白はセクション名の一部と見なされるため、``[ larch ]`` は ``\" larch " +"\"`` という名前のセクションとして読み込まれます。\n" +"これが適切でなければ、この属性を上書きしてください。\n" +"例えば:" -#: ../../library/configparser.rst:813 msgid "" ">>> import re\n" ">>> config = \"\"\"\n" @@ -1236,6 +1582,23 @@ msgid "" ">>> custom.sections()\n" "['Section 1', 'Section 2']" msgstr "" +">>> import re\n" +">>> config = \"\"\"\n" +"... [Section 1]\n" +"... option = value\n" +"...\n" +"... [ Section 2 ]\n" +"... another = val\n" +"... \"\"\"\n" +">>> typical = configparser.ConfigParser()\n" +">>> typical.read_string(config)\n" +">>> typical.sections()\n" +"['Section 1', ' Section 2 ']\n" +">>> custom = configparser.ConfigParser()\n" +">>> custom.SECTCRE = re.compile(r\"\\[ *(?P
[^]]+?) *\\]\")\n" +">>> custom.read_string(config)\n" +">>> custom.sections()\n" +"['Section 1', 'Section 2']" #: ../../library/configparser.rst:835 msgid "" @@ -1251,7 +1614,6 @@ msgstr "" msgid "Legacy API Examples" msgstr "レガシーな API の例" -#: ../../library/configparser.rst:843 msgid "" "Mainly because of backwards compatibility concerns, :mod:`!configparser` " "provides also a legacy API with explicit ``get``/``set`` methods. While " @@ -1259,12 +1621,17 @@ msgid "" "access is preferred for new projects. The legacy API is at times more " "advanced, low-level and downright counterintuitive." msgstr "" +":mod:`!configparser` は、主に後方互換性のために、明示的な ``get`` / ``set`` " +"メソッドを持つレガシーな API も提供しています。\n" +"以下のメソッドが適する用途もありますが、新しいプロジェクトではマップ型プロト" +"コルアクセスを優先してください。\n" +"レガシーな API は、場合によってはより高度で低水準であり、まったく直感的でない" +"こともあります。" #: ../../library/configparser.rst:849 msgid "An example of writing to a configuration file::" msgstr "設定ファイルを書き出す例::" -#: ../../library/configparser.rst:851 msgid "" "import configparser\n" "\n" @@ -1287,12 +1654,31 @@ msgid "" "with open('example.cfg', 'w') as configfile:\n" " config.write(configfile)" msgstr "" +"import configparser\n" +"\n" +"config = configparser.RawConfigParser()\n" +"\n" +"# RawConfigParser の set 関数では、内部的にキーに文字列以外の値も\n" +"# 代入できますが、ファイルへの書き出しや raw でないモードでの取得を\n" +"# 試みるとエラーになります。\n" +"# マップ型プロトコルや ConfigParser の set() による値の設定では、\n" +"# このような代入はできません。\n" +"config.add_section('Section1')\n" +"config.set('Section1', 'an_int', '15')\n" +"config.set('Section1', 'a_bool', 'true')\n" +"config.set('Section1', 'a_float', '3.1415')\n" +"config.set('Section1', 'baz', 'fun')\n" +"config.set('Section1', 'bar', 'Python')\n" +"config.set('Section1', 'foo', '%(bar)s is %(baz)s!')\n" +"\n" +"# 設定ファイルを 'example.cfg' に書き出す\n" +"with open('example.cfg', 'w') as configfile:\n" +" config.write(configfile)" #: ../../library/configparser.rst:872 msgid "An example of reading the configuration file again::" msgstr "設定ファイルを読み込む例::" -#: ../../library/configparser.rst:874 msgid "" "import configparser\n" "\n" @@ -1310,12 +1696,26 @@ msgid "" "if config.getboolean('Section1', 'a_bool'):\n" " print(config.get('Section1', 'foo'))" msgstr "" +"import configparser\n" +"\n" +"config = configparser.RawConfigParser()\n" +"config.read('example.cfg')\n" +"\n" +"# 値が浮動小数点数でなければ getfloat() は例外を送出します\n" +"# getint() と getboolean() もそれぞれの型について同様に動作します\n" +"a_float = config.getfloat('Section1', 'a_float')\n" +"an_int = config.getint('Section1', 'an_int')\n" +"print(a_float + an_int)\n" +"\n" +"# 次の出力では '%(bar)s' や '%(baz)s' は補間されません。\n" +"# これは RawConfigParser() を使用しているためです。\n" +"if config.getboolean('Section1', 'a_bool'):\n" +" print(config.get('Section1', 'foo'))" #: ../../library/configparser.rst:890 msgid "To get interpolation, use :class:`ConfigParser`::" msgstr "補間するには、 :class:`ConfigParser` を使ってください::" -#: ../../library/configparser.rst:892 msgid "" "import configparser\n" "\n" @@ -1349,6 +1749,38 @@ msgid "" "print(cfg.get('Section1', 'monster', fallback=None))\n" " # -> None" msgstr "" +"import configparser\n" +"\n" +"cfg = configparser.ConfigParser()\n" +"cfg.read('example.cfg')\n" +"\n" +"# 1 回の取得操作で補間を無効にするには、\n" +"# get() の省略可能な引数 *raw* を True に設定します。\n" +"print(cfg.get('Section1', 'foo', raw=False)) # -> \"Python is fun!\"\n" +"print(cfg.get('Section1', 'foo', raw=True)) # -> \"%(bar)s is %(baz)s!\"\n" +"\n" +"# 省略可能な引数 *vars* は、補間時に優先される要素を\n" +"# 含む辞書です。\n" +"print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation',\n" +" 'baz': 'evil'}))\n" +"\n" +"# 省略可能な引数 *fallback* で代替値を指定できます\n" +"print(cfg.get('Section1', 'foo'))\n" +" # -> \"Python is fun!\"\n" +"\n" +"print(cfg.get('Section1', 'foo', fallback='Monty is not.'))\n" +" # -> \"Python is fun!\"\n" +"\n" +"print(cfg.get('Section1', 'monster', fallback='No such things as " +"monsters.'))\n" +" # -> \"No such things as monsters.\"\n" +"\n" +"# 単に print(cfg.get('Section1', 'monster')) とすると NoOptionError になりま" +"すが、\n" +"# 次のようにも書けます:\n" +"\n" +"print(cfg.get('Section1', 'monster', fallback=None))\n" +" # -> None" #: ../../library/configparser.rst:923 msgid "" @@ -1358,7 +1790,6 @@ msgstr "" "どちらの型の ConfigParsers でもデフォルト値が利用できます。使われているオプ" "ションがどこにも定義されていなければ、そのデフォルト値が補間に使われます。 ::" -#: ../../library/configparser.rst:926 msgid "" "import configparser\n" "\n" @@ -1371,6 +1802,17 @@ msgid "" "config.remove_option('Section1', 'baz')\n" "print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" msgstr "" +"import configparser\n" +"\n" +"# 'bar' と 'baz' のデフォルト値がそれぞれ 'Life' と 'hard' の新しいインスタン" +"ス\n" +"config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'})\n" +"config.read('example.cfg')\n" +"\n" +"print(config.get('Section1', 'foo')) # -> \"Python is fun!\"\n" +"config.remove_option('Section1', 'bar')\n" +"config.remove_option('Section1', 'baz')\n" +"print(config.get('Section1', 'foo')) # -> \"Life is hard!\"" #: ../../library/configparser.rst:941 msgid "ConfigParser Objects" @@ -1401,7 +1843,6 @@ msgstr "" "す。*inline_comment_prefixes* が与えられた場合、非空行のコメントに接頭する部" "分文字列としての組み合わせとして使われます。" -#: ../../library/configparser.rst:962 msgid "" "When *strict* is ``True`` (the default), the parser won't allow for any " "section or option duplicates while reading from a single source (file, " @@ -1415,13 +1856,15 @@ msgid "" msgstr "" "*strict* が ``True`` (デフォルト) であれば、パーサーは単一のソース (ファイ" "ル、文字列、辞書) 中にセクションやオプションの重複を認めず、 :exc:" -"`DuplicateSectionError` や :exc:`DuplicateOptionError` を送出します。 " +"`DuplicateSectionError` や :exc:`DuplicateOptionError` を送出します。\n" "*empty_lines_in_values* が ``False`` (デフォルト: ``True``) なら、空行はそれ" -"ぞれオプションの終わりを示します。 *allow_no_value* が ``True`` (デフォルト: " -"``False``) なら、値のないオプションが受け付けられます。そのオプションの値は " -"``None`` となり、後端のデリミタを除いてシリアル化されます。" +"ぞれオプションの終わりを示します。\n" +"そうでなければ、複数行のオプション内の空行は値の一部として保持されます。\n" +"*allow_no_value* が ``True`` (デフォルト: ``False``) なら、値のないオプション" +"が受け付けられます。\n" +"そのオプションの値は ``None`` となり、後端のデリミタを除いてシリアル化されま" +"す。" -#: ../../library/configparser.rst:972 msgid "" "When *default_section* is given, it specifies the name for the special " "section holding default values for other sections and interpolation purposes " @@ -1430,6 +1873,12 @@ msgid "" "evaluate an already parsed config file, but will be used when writing parsed " "settings to a new config file." msgstr "" +"*default_section* を指定すると、ほかのセクションのデフォルト値や補間用の値を" +"保持する特別なセクションの名前 (通常は ``\"DEFAULT\"``) を設定できます。\n" +"この値は、インスタンス属性 ``default_section`` を使って実行時に取得、変更でき" +"ます。\n" +"値を変更しても、すでに解析した設定ファイルは再評価されませんが、解析済みの設" +"定を新しい設定ファイルへ書き出す際に使われます。" #: ../../library/configparser.rst:979 msgid "" @@ -1458,7 +1907,6 @@ msgstr "" "フォルトの実装を使うと、値 ``foo %(bar)s`` と ``foo %(BAR)s`` は等しくなりま" "す。" -#: ../../library/configparser.rst:991 msgid "" "When *converters* is given, it should be a dictionary where each key " "represents the name of a type converter and each value is a callable " @@ -1466,13 +1914,20 @@ msgid "" "converter gets its own corresponding :meth:`!get*` method on the parser " "object and section proxies." msgstr "" +"*converters* を指定する場合は、各キーを型コンバーター名、各値を文字列から目的" +"のデータ型への変換を実装する呼び出し可能オブジェクトとする辞書でなければなり" +"ません。\n" +"各コンバーターに対応する :meth:`!get*` メソッドが、パーサーオブジェクトとセク" +"ションプロキシに追加されます。" -#: ../../library/configparser.rst:997 msgid "" "When *allow_unnamed_section* is ``True`` (default: ``False``), the first " "section name can be omitted. See the `\"Unnamed Sections\" section <#unnamed-" "sections>`_." msgstr "" +"*allow_unnamed_section* が ``True`` (デフォルトは ``False``) の場合、最初のセ" +"クション名を省略できます。\n" +"`「無名セクション」の節 <#unnamed-sections>`_ を参照してください。" #: ../../library/configparser.rst:1026 msgid "The default *dict_type* is :class:`collections.OrderedDict`." @@ -1491,28 +1946,31 @@ msgstr "" msgid "The *converters* argument was added." msgstr "*converters* 引数が追加されました。" -#: ../../library/configparser.rst:1037 msgid "" "The *defaults* argument is read with :meth:`read_dict`, providing consistent " "behavior across the parser: non-string keys and values are implicitly " "converted to strings." msgstr "" +"*defaults* 引数は :meth:`read_dict` で読み込まれ、パーサー全体で動作が統一さ" +"れました。\n" +"文字列でないキーと値は暗黙に文字列に変換されます。" -#: ../../library/configparser.rst:1042 ../../library/configparser.rst:1330 msgid "" "The default *dict_type* is :class:`dict`, since it now preserves insertion " "order." msgstr "" +"挿入順を保持するようになったため、*dict_type* のデフォルトは :class:`dict` に" +"なりました。" -#: ../../library/configparser.rst:1046 msgid "" "Raise a :exc:`MultilineContinuationError` when *allow_no_value* is ``True``, " "and a key without a value is continued with an indented line." msgstr "" +"*allow_no_value* が ``True`` で、値のないキーの後にインデントされた行が続く場" +"合、:exc:`MultilineContinuationError` を送出するようになりました。" -#: ../../library/configparser.rst:1050 ../../library/configparser.rst:1334 msgid "The *allow_unnamed_section* argument was added." -msgstr "" +msgstr "*allow_unnamed_section* 引数が追加されました。" #: ../../library/configparser.rst:1055 msgid "Return a dictionary containing the instance-wide defaults." @@ -1573,7 +2031,6 @@ msgstr "" "ファイル名の iterable を読み込んでパースしようと試みます。正常にパースできた" "ファイル名のリストを返します。" -#: ../../library/configparser.rst:1098 msgid "" "If *filenames* is a string, a :class:`bytes` object or a :term:`path-like " "object`, it is treated as a single filename. If a file named in *filenames* " @@ -1588,7 +2045,7 @@ msgstr "" "けないファイルがある場合、そのファイルは無視されます。この挙動は、設定ファイ" "ルが置かれる可能性のある場所(例えば、 カレントディレクトリ、ホームディレクト" "リ、システム全体の設定を行うディレクトリ)のイテラブルを指定して、イテラブルの" -"中で存在する全ての設定ファイルを読むことを想定して設計されています。 " +"中で存在する全ての設定ファイルを読むことを想定して設計されています。" #: ../../library/configparser.rst:1107 msgid "" @@ -1603,7 +2060,6 @@ msgstr "" "を呼ぶ前に 、まず :meth:`read_file` を用いて必要なファイルを読み込んでくださ" "い::" -#: ../../library/configparser.rst:1113 msgid "" "import configparser, os\n" "\n" @@ -1612,12 +2068,20 @@ msgid "" "config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" " encoding='cp1250')" msgstr "" +"import configparser, os\n" +"\n" +"config = configparser.ConfigParser()\n" +"config.read_file(open('defaults.cfg'))\n" +"config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],\n" +" encoding='cp1250')" -#: ../../library/configparser.rst:1120 msgid "" "Added the *encoding* parameter. Previously, all files were read using the " "default encoding for :func:`open`." msgstr "" +"*encoding* 引数が追加されました。\n" +"以前は、すべてのファイルを :func:`open` のデフォルトのエンコーディングで読み" +"込んでいました。" #: ../../library/configparser.rst:1124 msgid "The *filenames* parameter accepts a :term:`path-like object`." @@ -1637,12 +2101,15 @@ msgstr "" "設定データを *f* から読み込んで解析します。*f* は Unicode 文字列を yield する" "イテラブル (例えばテキストモードで開かれたファイル) です。" -#: ../../library/configparser.rst:1136 msgid "" "Optional argument *source* specifies the name of the file being read. If " "not given and *f* has a :attr:`!name` attribute, that is used for *source*; " "the default is ``''``." msgstr "" +"省略可能な引数 *source* は、読み込むファイルの名前を指定します。\n" +"指定されておらず、*f* に :attr:`!name` 属性がある場合、その値が *source* に使" +"われます。\n" +"デフォルトは ``''`` です。" #: ../../library/configparser.rst:1140 msgid "Replaces :meth:`!readfp`." @@ -1687,7 +2154,6 @@ msgstr "" msgid "This method can be used to copy state between parsers." msgstr "このメソッドを使ってパーサー間で状態をコピーできます。" -#: ../../library/configparser.rst:1172 msgid "" "Get an *option* value for the named *section*. If *vars* is provided, it " "must be a dictionary. The *option* is looked up in *vars* (if provided), " @@ -1695,19 +2161,21 @@ msgid "" "*fallback* is provided, it is used as a fallback value. ``None`` can be " "provided as a *fallback* value." msgstr "" -"指名された *section* の *option* の値を取得します。*vars* が提供されるなら、" -"それは辞書でなければならず、(与えられたなら) *vars*, *section*, " -"*DEFAULTSECT* 内からこの順で *option* が探索されます。*fallback* の値として " -"``None`` を与えられます。" +"指定された *section* の *option* の値を取得します。\n" +"*vars* を指定する場合は辞書でなければなりません。\n" +"*option* は *vars* (指定されている場合)、*section*、*DEFAULTSECT* の順に検索" +"されます。\n" +"キーが見つからず、*fallback* が指定されている場合は、その値を代わりに返しま" +"す。\n" +"*fallback* には ``None`` も指定できます。" -#: ../../library/configparser.rst:1178 msgid "" "All the ``'%'`` interpolations are expanded in the return values, unless the " "*raw* argument is true. Values for interpolation keys are looked up in the " "same manner as the option." msgstr "" -"*raw* が真でない時には、全ての ``'%'`` 置換は展開されてから返されます。置換後" -"の値はオプションと同じ順序で探されます。" +"引数 *raw* が真でなければ、戻り値ではすべての ``'%'`` 補間が展開されます。\n" +"補間に使うキーの値は、オプションと同じ方法で検索されます。" #: ../../library/configparser.rst:1182 msgid "" @@ -1728,14 +2196,15 @@ msgstr "" "指定された *section* 中の *option* を整数に型強制する補助メソッドです。 " "*raw*, *vars* および *fallback* の説明は :meth:`get` を参照してください。" -#: ../../library/configparser.rst:1197 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a floating-point number. See :meth:`get` for explanation of *raw*, " "*vars* and *fallback*." msgstr "" +"指定された *section* の *option* を浮動小数点数に変換する便利なメソッドで" +"す。\n" +"*raw*、*vars*、*fallback* の説明は :meth:`get` を参照してください。" -#: ../../library/configparser.rst:1204 msgid "" "A convenience method which coerces the *option* in the specified *section* " "to a Boolean value. Note that the accepted values for the option are " @@ -1746,12 +2215,12 @@ msgid "" "`ValueError`. See :meth:`get` for explanation of *raw*, *vars* and " "*fallback*." msgstr "" -"指定された *section* 中の *option* をブール値に型強制する補助メソッドです。な" -"お、このオプションで受け付けられる値はこのメソッドが ``True`` を返す " -"``'1'``, ``'yes'``, ``'true'``, および ``'on'``,と、このメソッドが ``False`` " -"を返す ``'0'``, ``'no'``, ``'false'``, and ``'off'`` です。その他のいかなる値" -"も :exc:`ValueError` を送出します。 *raw*, *vars* および *fallback* の説明" -"は :meth:`get` を参照してください。" +"指定された *section* の *option* をブール値に変換する便利なメソッドです。\n" +"``'1'``、``'yes'``、``'true'``、``'on'`` に対しては ``True`` を、\n" +"``'0'``、``'no'``、``'false'``、``'off'`` に対しては ``False`` を返します。\n" +"これらの文字列値は大文字と小文字を区別せずに調べられます。\n" +"その他の値に対しては :exc:`ValueError` を送出します。\n" +"*raw*、*vars*、*fallback* の説明は :meth:`get` を参照してください。" #: ../../library/configparser.rst:1217 msgid "" @@ -1804,11 +2273,12 @@ msgstr "" "後で :meth:`read` を呼び出すことでパースできます。 *space_around_delimiters* " "が真なら、キーと値の間のデリミタはスペースで囲まれます。" -#: ../../library/configparser.rst:1245 msgid "" "Raises InvalidWriteError if this would write a representation which cannot " "be accurately parsed by a future :meth:`read` call from this parser." msgstr "" +"このパーサーで後から :meth:`read` を呼び出したときに正確に解析できない表現を" +"書き込もうとすると、``InvalidWriteError`` を送出します。" #: ../../library/configparser.rst:1251 msgid "" @@ -1860,11 +2330,12 @@ msgstr "" "上で、これを文字列引数をとって文字列を返す関数に設定できます。例えば、これを " "``str`` に設定すると、オプション名に大文字小文字の区別をつけられます::" -#: ../../library/configparser.rst:1284 msgid "" "cfgparser = ConfigParser()\n" "cfgparser.optionxform = str" msgstr "" +"cfgparser = ConfigParser()\n" +"cfgparser.optionxform = str" #: ../../library/configparser.rst:1287 msgid "" @@ -1874,30 +2345,36 @@ msgstr "" "なお、設定ファイルを読み込むとき、オプション名の周りの空白は :meth:" "`optionxform` が呼び出される前に取り除かれます。" -#: ../../library/configparser.rst:1293 msgid "" "A special object representing a section name used to reference the unnamed " "section (see :ref:`unnamed-sections`)." msgstr "" +"無名セクションを参照するためのセクション名を表す特別なオブジェクトです (:ref:" +"`unnamed-sections` を参照)。" -#: ../../library/configparser.rst:1298 msgid "" "The maximum depth for recursive interpolation for :meth:`~configparser." "ConfigParser.get` when the *raw* parameter is false. This is relevant only " "when the default *interpolation* is used." msgstr "" +"引数 *raw* が偽の場合に :meth:`~configparser.ConfigParser.get` で行う、再帰的" +"な補間の深さの上限です。\n" +"デフォルトの *interpolation* を使う場合にのみ関係します。" #: ../../library/configparser.rst:1306 msgid "RawConfigParser Objects" msgstr "RawConfigParser オブジェクト" -#: ../../library/configparser.rst:1317 msgid "" "Legacy variant of the :class:`ConfigParser`. It has interpolation disabled " "by default and allows for non-string section names, option names, and values " "via its unsafe ``add_section`` and ``set`` methods, as well as the legacy " "``defaults=`` keyword argument handling." msgstr "" +":class:`ConfigParser` のレガシーな変種です。\n" +"デフォルトで補間が無効になっており、安全でない ``add_section``、``set`` メ" +"ソッドと、レガシーな ``defaults=`` キーワード引数の処理を通じて、文字列でない" +"セクション名、オプション名、値を使用できます。" #: ../../library/configparser.rst:1338 msgid "" @@ -1909,18 +2386,23 @@ msgstr "" "してください。補間を望まない場合、 ``ConfigParser(interpolation=None)`` を使" "用できます。" -#: ../../library/configparser.rst:1345 msgid "" "Add a section named *section* or :const:`UNNAMED_SECTION` to the instance." msgstr "" +"*section* という名前のセクション、または :const:`UNNAMED_SECTION` をインスタ" +"ンスに追加します。" -#: ../../library/configparser.rst:1347 msgid "" "If the given section already exists, :exc:`DuplicateSectionError` is raised. " "If the *default section* name is passed, :exc:`ValueError` is raised. If :" "const:`UNNAMED_SECTION` is passed and support is disabled, :exc:" "`UnnamedSectionDisabledError` is raised." msgstr "" +"指定されたセクションがすでに存在する場合、:exc:`DuplicateSectionError` を送出" +"します。\n" +"*デフォルトセクション* の名前を渡すと、:exc:`ValueError` を送出します。\n" +":const:`UNNAMED_SECTION` を渡し、無名セクションのサポートが無効になっている場" +"合、:exc:`UnnamedSectionDisabledError` を送出します。" #: ../../library/configparser.rst:1352 msgid "" @@ -1931,9 +2413,8 @@ msgstr "" "ることができます。この振る舞いはサポートされておらず、内部エラーを起こす可能" "性があります。" -#: ../../library/configparser.rst:1355 msgid "Added support for :const:`UNNAMED_SECTION`." -msgstr "" +msgstr ":const:`UNNAMED_SECTION` のサポートが追加されました。" #: ../../library/configparser.rst:1361 msgid "" @@ -1967,26 +2448,28 @@ msgstr "" msgid "Exceptions" msgstr "例外" -#: ../../library/configparser.rst:1379 msgid "Base class for all other :mod:`!configparser` exceptions." -msgstr "" +msgstr "ほかのすべての :mod:`!configparser` 例外の基底クラスです。" #: ../../library/configparser.rst:1384 msgid "Exception raised when a specified section is not found." msgstr "指定したセクションが見つからなかった時に起きる例外です。" -#: ../../library/configparser.rst:1389 msgid "" "Exception raised if :meth:`~ConfigParser.add_section` is called with the " "name of a section that is already present or in strict parsers when a " "section if found more than once in a single input file, string or dictionary." msgstr "" +"すでに存在するセクションの名前で :meth:`~ConfigParser.add_section` を呼び出し" +"た場合、または厳密なパーサーで単一の入力ファイル、文字列、辞書に同じセクショ" +"ンが複数回見つかった場合に送出される例外です。" -#: ../../library/configparser.rst:1393 msgid "" "Added the optional *source* and *lineno* attributes and parameters to :meth:" "`!__init__`." msgstr "" +":meth:`!__init__` に省略可能な *source*、*lineno* 属性と引数が追加されまし" +"た。" #: ../../library/configparser.rst:1400 msgid "" @@ -2051,36 +2534,41 @@ msgstr "" msgid "Exception raised when errors occur attempting to parse a file." msgstr "ファイルの構文解析中にエラーが起きた場合に発生する例外です。" -#: ../../library/configparser.rst:1446 msgid "" "The ``filename`` attribute and :meth:`!__init__` constructor argument were " "removed. They have been available using the name ``source`` since 3.2." msgstr "" +"``filename`` 属性と :meth:`!__init__` コンストラクタの引数が削除されまし" +"た。\n" +"これらは 3.2 以降、``source`` という名前で利用できます。" -#: ../../library/configparser.rst:1452 msgid "" "Exception raised when a key without a corresponding value is continued with " "an indented line." msgstr "" +"対応する値のないキーの後にインデントされた行が続く場合に送出される例外です。" -#: ../../library/configparser.rst:1459 msgid "" "Exception raised when attempting to use the :const:`UNNAMED_SECTION` without " "enabling it." msgstr "" +":const:`UNNAMED_SECTION` を有効にせずに使おうとした場合に送出される例外です。" -#: ../../library/configparser.rst:1466 msgid "" "Exception raised when an attempted :meth:`ConfigParser.write` would not be " "parsed accurately with a future :meth:`ConfigParser.read` call." msgstr "" +":meth:`ConfigParser.write` で書き込もうとしている内容が、後の :meth:" +"`ConfigParser.read` 呼び出しで正確に解析できない場合に送出される例外です。" -#: ../../library/configparser.rst:1469 msgid "" "Ex: Writing a key beginning with the :attr:`ConfigParser.SECTCRE` pattern " "would parse as a section header when read. Attempting to write this will " "raise this exception." msgstr "" +"例えば、:attr:`ConfigParser.SECTCRE` のパターンで始まるキーを書き込むと、読み" +"込み時にセクションヘッダーとして解析されます。\n" +"このようなキーを書き込もうとすると、この例外を送出します。" #: ../../library/configparser.rst:1476 msgid "Footnotes" @@ -2120,9 +2608,8 @@ msgstr "Windows ini ファイル" msgid "% (percent)" msgstr "% (パーセント)" -#: ../../library/configparser.rst:365 ../../library/configparser.rst:398 msgid "interpolation in configuration files" -msgstr "" +msgstr "設定ファイル内の補間" #: ../../library/configparser.rst:398 msgid "$ (dollar)" diff --git a/library/constants.po b/library/constants.po index a8919758b..ca82ea468 100644 --- a/library/constants.po +++ b/library/constants.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/constants.rst:4 @@ -46,15 +46,17 @@ msgstr "" ":class:`bool` 型の真値です。``True`` への代入は不正で、:exc:`SyntaxError` を" "送出します。" -#: ../../library/constants.rst:22 msgid "" "An object frequently used to represent the absence of a value, as when " "default arguments are not passed to a function. Assignments to ``None`` are " "illegal and raise a :exc:`SyntaxError`. ``None`` is the sole instance of " "the :class:`~types.NoneType` type." msgstr "" +"関数にデフォルト引数が渡されなかった場合など、値が存在しないことを表すために" +"よく使われるオブジェクトです。\n" +"``None`` への代入は不正で、:exc:`SyntaxError` を送出します。\n" +"``None`` は :class:`~types.NoneType` 型の唯一のインスタンスです。" -#: ../../library/constants.rst:30 msgid "" "A special value which should be returned by the binary special methods (e." "g. :meth:`~object.__eq__`, :meth:`~object.__lt__`, :meth:`~object.__add__`, :" @@ -65,8 +67,16 @@ msgid "" "boolean context. :data:`!NotImplemented` is the sole instance of the :class:" "`types.NotImplementedType` type." msgstr "" +"二項演算の特殊メソッド (例えば :meth:`~object.__eq__`、:meth:`~object." +"__lt__`、:meth:`~object.__add__`、:meth:`~object.__rsub__` など) が、\n" +"もう一方の型に対する演算を実装していないことを示すために返すべき特殊な値で" +"す。\n" +"インプレースの二項演算の特殊メソッド (例えば :meth:`~object.__imul__`、:meth:" +"`~object.__iand__` など) も、同じ目的でこの値を返せます。\n" +"真偽値として評価してはいけません。\n" +":data:`!NotImplemented` は :class:`types.NotImplementedType` 型の唯一のインス" +"タンスです。" -#: ../../library/constants.rst:40 msgid "" "When a binary (or in-place) method returns :data:`!NotImplemented` the " "interpreter will try the reflected operation on the other type (or some " @@ -76,44 +86,56 @@ msgid "" "error message or the :data:`!NotImplemented` value being returned to Python " "code." msgstr "" -"二項演算の (あるいはインプレースの) メソッドが :data:`!NotImplemented` を返し" -"た場合、インタープリタはもう一方の型で定義された対の演算で代用を試みます (あ" -"るいは演算によっては他の代替手段も試みます)。試行された演算全てが :data:`!" -"NotImplemented` を返した場合、インタープリタは適切な例外を送出します。 :data:" -"`!NotImplemented` を正しく返さないと、誤解を招きかねないエラーメッセージに" -"なったり、 :data:`!NotImplemented` が Python コードに返されるようなことになり" -"ます。" +"二項演算 (またはインプレース演算) のメソッドが :data:`!NotImplemented` を返し" +"た場合、\n" +"インタープリタはもう一方の型に定義された対の演算を試みます (演算子によっては" +"別の代替手段を試みます)。\n" +"すべての試行が :data:`!NotImplemented` を返した場合、インタープリタは適切な例" +"外を送出します。\n" +"誤って :data:`!NotImplemented` を返すと、誤解を招くエラーメッセージが表示され" +"たり、\n" +":data:`!NotImplemented` の値が Python コードに返されたりします。" #: ../../library/constants.rst:47 msgid "See :ref:`implementing-the-arithmetic-operations` for examples." msgstr "" "例として :ref:`implementing-the-arithmetic-operations` を参照してください。" -#: ../../library/constants.rst:51 msgid "" ":data:`!NotImplemented` and :exc:`!NotImplementedError` are not " "interchangeable. This constant should only be used as described above; see :" "exc:`NotImplementedError` for details on correct usage of the exception." msgstr "" +":data:`!NotImplemented` と :exc:`!NotImplementedError` は互いに置き換えられま" +"せん。\n" +"この定数は、上で説明した用途にのみ使ってください。\n" +"例外の正しい使い方については :exc:`NotImplementedError` を参照してください。" -#: ../../library/constants.rst:56 msgid "Evaluating :data:`!NotImplemented` in a boolean context was deprecated." msgstr "" +":data:`!NotImplemented` を真偽値として評価することは非推奨となりました。" -#: ../../library/constants.rst:59 msgid "" "Evaluating :data:`!NotImplemented` in a boolean context now raises a :exc:" "`TypeError`. It previously evaluated to :const:`True` and emitted a :exc:" "`DeprecationWarning` since Python 3.9." msgstr "" +":data:`!NotImplemented` を真偽値として評価すると、:exc:`TypeError` が送出され" +"るようになりました。\n" +"以前は :const:`True` と評価され、Python 3.9 以降では :exc:" +"`DeprecationWarning` も発生していました。" -#: ../../library/constants.rst:68 msgid "" "The same as the ellipsis literal \"``...``\", an object frequently used to " "indicate that something is omitted. Assignment to ``Ellipsis`` is possible, " "but assignment to ``...`` raises a :exc:`SyntaxError`. ``Ellipsis`` is the " "sole instance of the :class:`types.EllipsisType` type." msgstr "" +"省略を示すリテラル \"``...``\" と同じオブジェクトで、何かが省略されていること" +"を示すためによく使われます。\n" +"``Ellipsis`` には代入できますが、``...`` に代入すると :exc:`SyntaxError` が送" +"出されます。\n" +"``Ellipsis`` は :class:`types.EllipsisType` 型の唯一のインスタンスです。" #: ../../library/constants.rst:76 msgid "" @@ -150,20 +172,26 @@ msgstr "" "かの定数を追加します。それらは対話的インタープリタシェルで有用ですが、プログ" "ラム中では使うべきではありません。" -#: ../../library/constants.rst:100 msgid "" "Objects that when printed, print a message like \"Use quit() or Ctrl-D (i.e. " "EOF) to exit\", and when accessed directly in the interactive interpreter or " "called as functions, raise :exc:`SystemExit` with the specified exit code." msgstr "" +"表示すると \"Use quit() or Ctrl-D (i.e. EOF) to exit\" のようなメッセージを表" +"示するオブジェクトです。\n" +"対話型インタープリタで直接入力するか、関数として呼び出すと、指定した終了コー" +"ドで :exc:`SystemExit` を送出します。" -#: ../../library/constants.rst:108 msgid "" "Object that when printed, prints the message \"Type help() for interactive " "help, or help(object) for help about object.\", and when accessed directly " "in the interactive interpreter, invokes the built-in help system (see :func:" "`help`)." msgstr "" +"表示すると \"Type help() for interactive help, or help(object) for help " +"about object.\" というメッセージを表示するオブジェクトです。\n" +"対話型インタープリタで直接入力すると、組み込みヘルプシステムを起動します (:" +"func:`help` を参照してください)。" #: ../../library/constants.rst:116 msgid "" diff --git a/library/contextlib.po b/library/contextlib.po index ece751a18..c116d0234 100644 --- a/library/contextlib.po +++ b/library/contextlib.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/contextlib.rst:2 @@ -49,7 +49,6 @@ msgstr "ユーティリティ" msgid "Functions and classes provided:" msgstr "以下の関数とクラスを提供しています:" -#: ../../library/contextlib.rst:23 msgid "" "An :term:`abstract base class` for classes that implement :meth:`~object." "__enter__` and :meth:`~object.__exit__`. A default implementation for :meth:" @@ -57,8 +56,12 @@ msgid "" "__exit__` is an abstract method which by default returns ``None``. See also " "the definition of :ref:`typecontextmanager`." msgstr "" +":meth:`~object.__enter__` と :meth:`~object.__exit__` を実装するクラスのため" +"の :term:`abstract base class` です。\n" +":meth:`~object.__enter__` には ``self`` を返すデフォルトの実装があり、:meth:" +"`~object.__exit__` はデフォルトで ``None`` を返す抽象メソッドです。\n" +":ref:`typecontextmanager` の定義も参照してください。" -#: ../../library/contextlib.rst:34 msgid "" "An :term:`abstract base class` for classes that implement :meth:`~object." "__aenter__` and :meth:`~object.__aexit__`. A default implementation for :" @@ -66,6 +69,11 @@ msgid "" "`~object.__aexit__` is an abstract method which by default returns ``None``. " "See also the definition of :ref:`async-context-managers`." msgstr "" +":meth:`~object.__aenter__` と :meth:`~object.__aexit__` を実装するクラスのた" +"めの :term:`abstract base class` です。\n" +":meth:`~object.__aenter__` には ``self`` を返すデフォルトの実装があり、:meth:" +"`~object.__aexit__` はデフォルトで ``None`` を返す抽象メソッドです。\n" +":ref:`async-context-managers` の定義も参照してください。" #: ../../library/contextlib.rst:46 msgid "" @@ -79,13 +87,15 @@ msgstr "" "`~object.__enter__` と :meth:`~object.__exit__` メソッドを別々に定義しなくて" "も、ファクトリ関数を定義することができます。" -#: ../../library/contextlib.rst:50 msgid "" "While many objects natively support use in with statements, sometimes a " "resource needs to be managed that isn't a context manager in its own right, " "and doesn't implement a ``close()`` method for use with ``contextlib." "closing``." msgstr "" +"多くのオブジェクトは with 文での使用をサポートしていますが、コンテキストマ" +"ネージャではなく、``contextlib.closing`` で使うための ``close()`` メソッドも" +"実装していないリソースを管理する必要が生じることもあります。" #: ../../library/contextlib.rst:54 msgid "" @@ -94,7 +104,6 @@ msgid "" msgstr "" "リソースを正しく管理するよう保証する抽象的な例は以下のようなものでしょう::" -#: ../../library/contextlib.rst:57 msgid "" "from contextlib import contextmanager\n" "\n" @@ -108,17 +117,30 @@ msgid "" " # Code to release resource, e.g.:\n" " release_resource(resource)" msgstr "" +"from contextlib import contextmanager\n" +"\n" +"@contextmanager\n" +"def managed_resource(*args, **kwds):\n" +" # リソースを確保するコードの例:\n" +" resource = acquire_resource(*args, **kwds)\n" +" try:\n" +" yield resource\n" +" finally:\n" +" # リソースを解放するコードの例:\n" +" release_resource(resource)" #: ../../library/contextlib.rst:69 msgid "The function can then be used like this::" msgstr "このとき、関数は次のように使うことができます::" -#: ../../library/contextlib.rst:71 msgid "" ">>> with managed_resource(timeout=3600) as resource:\n" "... # Resource is released at the end of this block,\n" "... # even if code in the block raises an exception" msgstr "" +">>> with managed_resource(timeout=3600) as resource:\n" +"... # ブロック内のコードが例外を送出しても、\n" +"... # ブロックの終わりでリソースは解放されます" #: ../../library/contextlib.rst:75 msgid "" @@ -158,7 +180,6 @@ msgstr "" "に対して例外が処理されたことを示し、:keyword:`!with` 文の直後の文から実行を再" "開します。" -#: ../../library/contextlib.rst:91 msgid "" ":deco:`contextmanager` uses :class:`ContextDecorator` so the context " "managers it creates can be used as decorators as well as in :keyword:`with` " @@ -168,16 +189,24 @@ msgid "" "that context managers support multiple invocations in order to be used as " "decorators)." msgstr "" +":deco:`contextmanager` は :class:`ContextDecorator` を使用するため、作成した" +"コンテキストマネージャは :keyword:`with` 文でもデコレータとしても使用できま" +"す。\n" +"デコレータとして使う場合は、関数を呼び出すたびに、新しいジェネレータインスタ" +"ンスが暗黙に作成されます (これにより、:deco:`contextmanager` が作成する、本来" +"は一度しか使えないコンテキストマネージャも、デコレータとして使うための複数回" +"の呼び出しをサポートするという要件を満たせます)。" #: ../../library/contextlib.rst:98 msgid "Use of :class:`ContextDecorator`." msgstr ":class:`ContextDecorator` の使用。" -#: ../../library/contextlib.rst:104 msgid "" "Similar to :deco:`~contextlib.contextmanager`, but creates an :ref:" "`asynchronous context manager `." msgstr "" +":deco:`~contextlib.contextmanager` に似ていますが、:ref:`非同期コンテキストマ" +"ネージャ ` を作成します。" #: ../../library/contextlib.rst:107 msgid "" @@ -197,7 +226,6 @@ msgstr "" msgid "A simple example::" msgstr "簡単な例::" -#: ../../library/contextlib.rst:115 msgid "" "from contextlib import asynccontextmanager\n" "\n" @@ -213,14 +241,27 @@ msgid "" " async with get_connection() as conn:\n" " return conn.query('SELECT ...')" msgstr "" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def get_connection():\n" +" conn = await acquire_db_connection()\n" +" try:\n" +" yield conn\n" +" finally:\n" +" await release_db_connection(conn)\n" +"\n" +"async def get_all_users():\n" +" async with get_connection() as conn:\n" +" return conn.query('SELECT ...')" -#: ../../library/contextlib.rst:131 msgid "" "Context managers defined with :deco:`asynccontextmanager` can be used either " "as decorators or with :keyword:`async with` statements::" msgstr "" +":deco:`asynccontextmanager` で定義したコンテキストマネージャは、デコレータと" +"しても :keyword:`async with` 文でも使用できます。 ::" -#: ../../library/contextlib.rst:134 msgid "" "import time\n" "from contextlib import asynccontextmanager\n" @@ -237,20 +278,39 @@ msgid "" "async def main():\n" " # ... async code ..." msgstr "" +"import time\n" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def timeit():\n" +" now = time.monotonic()\n" +" try:\n" +" yield\n" +" finally:\n" +" print(f'it took {time.monotonic() - now}s to run')\n" +"\n" +"@timeit()\n" +"async def main():\n" +" # ... 非同期のコード ..." -#: ../../library/contextlib.rst:149 msgid "" "When used as a decorator, a new generator instance is implicitly created on " "each function call. This allows the otherwise \"one-shot\" context managers " "created by :deco:`asynccontextmanager` to meet the requirement that context " "managers support multiple invocations in order to be used as decorators." msgstr "" +"デコレータとして使う場合は、関数を呼び出すたびに、新しいジェネレータインスタ" +"ンスが暗黙に作成されます。\n" +"これにより、:deco:`asynccontextmanager` が作成する、本来は一度しか使えないコ" +"ンテキストマネージャも、デコレータとして使うための複数回の呼び出しをサポート" +"するという要件を満たせます。" -#: ../../library/contextlib.rst:154 msgid "" "Async context managers created with :deco:`asynccontextmanager` can be used " "as decorators." msgstr "" +":deco:`asynccontextmanager` で作成した非同期コンテキストマネージャをデコレー" +"タとして使用できるようになりました。" #: ../../library/contextlib.rst:161 msgid "" @@ -260,7 +320,6 @@ msgstr "" "ブロックの完了時に *thing* を close するコンテキストマネージャを返します。こ" "れは基本的に以下と等価です::" -#: ../../library/contextlib.rst:164 msgid "" "from contextlib import contextmanager\n" "\n" @@ -271,6 +330,14 @@ msgid "" " finally:\n" " thing.close()" msgstr "" +"from contextlib import contextmanager\n" +"\n" +"@contextmanager\n" +"def closing(thing):\n" +" try:\n" +" yield thing\n" +" finally:\n" +" thing.close()" #: ../../library/contextlib.rst:173 msgid "And lets you write code like this::" @@ -278,7 +345,6 @@ msgstr "" "そして、明示的に ``page`` を close する必要なしに、次のように書くことができま" "す::" -#: ../../library/contextlib.rst:175 msgid "" "from contextlib import closing\n" "from urllib.request import urlopen\n" @@ -287,6 +353,12 @@ msgid "" " for line in page:\n" " print(line)" msgstr "" +"from contextlib import closing\n" +"from urllib.request import urlopen\n" +"\n" +"with closing(urlopen('https://www.python.org')) as page:\n" +" for line in page:\n" +" print(line)" #: ../../library/contextlib.rst:182 msgid "" @@ -296,7 +368,6 @@ msgstr "" "``page`` を明示的に close する必要は無く、エラーが発生した場合でも、 :" "keyword:`with` ブロックを出るときに ``page.close()`` が呼ばれます。" -#: ../../library/contextlib.rst:187 msgid "" "Most types managing resources support the :term:`context manager` protocol, " "which closes *thing* on leaving the :keyword:`with` statement. As such, :" @@ -304,6 +375,12 @@ msgid "" "context managers. This example is purely for illustration purposes, as :func:" "`~urllib.request.urlopen` would normally be used in a context manager." msgstr "" +"リソースを管理するほとんどの型は :term:`context manager` プロトコルをサポート" +"し、:keyword:`with` 文を抜けるときに *thing* を閉じます。\n" +"そのため、:func:`!closing` はコンテキストマネージャをサポートしないサードパー" +"ティー製の型で特に役立ちます。\n" +":func:`~urllib.request.urlopen` は通常、コンテキストマネージャとして使用する" +"ため、この例は説明のためのものにすぎません。" #: ../../library/contextlib.rst:196 msgid "" @@ -313,7 +390,6 @@ msgstr "" "ブロックの完了時に *thing* の ``aclose()`` メソッドを呼び出すような非同期コン" "テキストマネージャを返します。これは基本的に以下と等価です::" -#: ../../library/contextlib.rst:199 msgid "" "from contextlib import asynccontextmanager\n" "\n" @@ -324,6 +400,14 @@ msgid "" " finally:\n" " await thing.aclose()" msgstr "" +"from contextlib import asynccontextmanager\n" +"\n" +"@asynccontextmanager\n" +"async def aclosing(thing):\n" +" try:\n" +" yield thing\n" +" finally:\n" +" await thing.aclose()" #: ../../library/contextlib.rst:208 msgid "" @@ -335,7 +419,6 @@ msgstr "" "ロックが終了した場合に、 ``aclosing()`` は非同期ジェネレータの決定論的なク" "リーンアップをサポートすることです::" -#: ../../library/contextlib.rst:212 msgid "" "from contextlib import aclosing\n" "\n" @@ -344,6 +427,12 @@ msgid "" " if value == 42:\n" " break" msgstr "" +"from contextlib import aclosing\n" +"\n" +"async with aclosing(my_generator()) as values:\n" +" async for value in values:\n" +" if value == 42:\n" +" break" #: ../../library/contextlib.rst:219 msgid "" @@ -357,14 +446,16 @@ msgstr "" "は期待通りに動作し、またジェネレータが依存するタスクの寿命が尽きたあとに終了" "のコードが実行されることもありません)。" -#: ../../library/contextlib.rst:231 msgid "" "Return a context manager that returns *enter_result* from :meth:`~object." "__enter__`, but otherwise does nothing. It is intended to be used as a stand-" "in for an optional context manager, for example::" msgstr "" +":meth:`~object.__enter__` から *enter_result* を返し、それ以外は何もしないコ" +"ンテキストマネージャを返します。\n" +"省略可能なコンテキストマネージャの代役として使用することを意図しています。\n" +"例えば次のように使います。 ::" -#: ../../library/contextlib.rst:235 msgid "" "def myfunction(arg, ignore_exceptions=False):\n" " if ignore_exceptions:\n" @@ -376,12 +467,20 @@ msgid "" " with cm:\n" " # Do something" msgstr "" +"def myfunction(arg, ignore_exceptions=False):\n" +" if ignore_exceptions:\n" +" # suppress を使ってすべての例外を無視します。\n" +" cm = contextlib.suppress(Exception)\n" +" else:\n" +" # 例外を無視せず、cm は何も行いません。\n" +" cm = contextlib.nullcontext()\n" +" with cm:\n" +" # 何らかの処理" #: ../../library/contextlib.rst:245 msgid "An example using *enter_result*::" msgstr "*enter_result* を使った例です::" -#: ../../library/contextlib.rst:247 msgid "" "def process_file(file_or_path):\n" " if isinstance(file_or_path, str):\n" @@ -394,6 +493,16 @@ msgid "" " with cm as file:\n" " # Perform processing on the file" msgstr "" +"def process_file(file_or_path):\n" +" if isinstance(file_or_path, str):\n" +" # 文字列の場合はファイルを開きます\n" +" cm = open(file_or_path)\n" +" else:\n" +" # ファイルを閉じる責任は呼び出し側にあります\n" +" cm = nullcontext(file_or_path)\n" +"\n" +" with cm as file:\n" +" # ファイルを処理します" #: ../../library/contextlib.rst:258 msgid "" @@ -403,7 +512,6 @@ msgstr "" ":ref:`非同期コンテキストマネージャ ` の代役として使う" "こともできます::" -#: ../../library/contextlib.rst:261 msgid "" "async def send_http(session=None):\n" " if not session:\n" @@ -416,6 +524,16 @@ msgid "" " async with cm as session:\n" " # Send http requests with session" msgstr "" +"async def send_http(session=None):\n" +" if not session:\n" +" # HTTP セッションがなければ aiohttp で作成します\n" +" cm = aiohttp.ClientSession()\n" +" else:\n" +" # セッションを閉じる責任は呼び出し側にあります\n" +" cm = nullcontext(session)\n" +"\n" +" async with cm as session:\n" +" # session を使って HTTP リクエストを送信します" #: ../../library/contextlib.rst:274 msgid ":term:`asynchronous context manager` support was added." @@ -448,7 +566,6 @@ msgstr "" msgid "For example::" msgstr "例えば::" -#: ../../library/contextlib.rst:293 msgid "" "from contextlib import suppress\n" "\n" @@ -458,12 +575,18 @@ msgid "" "with suppress(FileNotFoundError):\n" " os.remove('someotherfile.tmp')" msgstr "" +"from contextlib import suppress\n" +"\n" +"with suppress(FileNotFoundError):\n" +" os.remove('somefile.tmp')\n" +"\n" +"with suppress(FileNotFoundError):\n" +" os.remove('someotherfile.tmp')" #: ../../library/contextlib.rst:301 msgid "This code is equivalent to::" msgstr "これは以下と等価です::" -#: ../../library/contextlib.rst:303 msgid "" "try:\n" " os.remove('somefile.tmp')\n" @@ -475,6 +598,15 @@ msgid "" "except FileNotFoundError:\n" " pass" msgstr "" +"try:\n" +" os.remove('somefile.tmp')\n" +"except FileNotFoundError:\n" +" pass\n" +"\n" +"try:\n" +" os.remove('someotherfile.tmp')\n" +"except FileNotFoundError:\n" +" pass" #: ../../library/contextlib.rst:313 ../../library/contextlib.rst:362 #: ../../library/contextlib.rst:372 ../../library/contextlib.rst:389 @@ -483,7 +615,6 @@ msgstr "" "このコンテキストマネージャは :ref:`再入可能(リエントラント) ` " "です。" -#: ../../library/contextlib.rst:315 msgid "" "If the code within the :keyword:`!with` block raises a :exc:" "`BaseExceptionGroup`, suppressed exceptions are removed from the group. Any " @@ -491,26 +622,33 @@ msgid "" "group which is created using the original group's :meth:`~BaseExceptionGroup." "derive` method." msgstr "" +":keyword:`!with` ブロック内のコードが :exc:`BaseExceptionGroup` を送出した場" +"合、抑制対象の例外はグループから取り除かれます。\n" +"グループ内の抑制されなかった例外は、元のグループの :meth:" +"`~BaseExceptionGroup.derive` メソッドで作成した新しいグループにまとめて再送出" +"されます。" -#: ../../library/contextlib.rst:323 msgid "" "``suppress`` now supports suppressing exceptions raised as part of a :exc:" "`BaseExceptionGroup`." msgstr "" +"``suppress`` は、:exc:`BaseExceptionGroup` の一部として送出された例外の抑制を" +"サポートするようになりました。" -#: ../../library/contextlib.rst:329 msgid "" "Context manager for temporarily redirecting :data:`sys.stdout` to another :" "term:`file object`." msgstr "" +":data:`sys.stdout` を一時的に別の :term:`file object` にリダイレクトするコン" +"テキストマネージャです。" -#: ../../library/contextlib.rst:332 msgid "" "This tool adds flexibility to existing functions or classes whose output is " "hardwired to :data:`sys.stdout`." msgstr "" +"このツールは、出力先が :data:`sys.stdout` に固定されている既存の関数やクラス" +"を柔軟に使えるようにします。" -#: ../../library/contextlib.rst:335 msgid "" "For example, the output of :func:`help` normally is sent to *sys.stdout*. " "You can capture that output in a string by redirecting the output to an :" @@ -518,13 +656,20 @@ msgid "" "meth:`~object.__enter__` method and so is available as the target of the :" "keyword:`with` statement::" msgstr "" +"例えば、:func:`help` の出力は通常 *sys.stdout* に送られます。\n" +"出力先を :class:`io.StringIO` オブジェクトにリダイレクトすれば、出力を文字列" +"として取得できます。\n" +"置き換え先のストリームは :meth:`~object.__enter__` メソッドから返されるの" +"で、:keyword:`with` 文のターゲットとして使用できます。 ::" -#: ../../library/contextlib.rst:341 msgid "" "with redirect_stdout(io.StringIO()) as f:\n" " help(pow)\n" "s = f.getvalue()" msgstr "" +"with redirect_stdout(io.StringIO()) as f:\n" +" help(pow)\n" +"s = f.getvalue()" #: ../../library/contextlib.rst:345 msgid "" @@ -534,12 +679,14 @@ msgstr "" ":func:`help` の出力をディスク上のファイルに送るためには、出力を通常のファイル" "にリダイレクトします::" -#: ../../library/contextlib.rst:348 msgid "" "with open('help.txt', 'w') as f:\n" " with redirect_stdout(f):\n" " help(pow)" msgstr "" +"with open('help.txt', 'w') as f:\n" +" with redirect_stdout(f):\n" +" help(pow)" #: ../../library/contextlib.rst:352 msgid "To send the output of :func:`help` to *sys.stderr*::" @@ -547,11 +694,12 @@ msgstr "" ":func:`help` の出力を標準エラー出力 (*sys.stderr*) に送るには以下のようにしま" "す::" -#: ../../library/contextlib.rst:354 msgid "" "with redirect_stdout(sys.stderr):\n" " help(pow)" msgstr "" +"with redirect_stdout(sys.stderr):\n" +" help(pow)" #: ../../library/contextlib.rst:357 msgid "" @@ -566,11 +714,12 @@ msgstr "" "りますが、それでも多くのユーティリティスクリプトに対して有用なアプローチで" "す。" -#: ../../library/contextlib.rst:369 msgid "" "Similar to :func:`~contextlib.redirect_stdout` but redirecting the global :" "data:`sys.stderr` to another :term:`file object`." msgstr "" +":func:`~contextlib.redirect_stdout` に似ていますが、グローバルな :data:`sys." +"stderr` を別の :term:`file object` にリダイレクトします。" #: ../../library/contextlib.rst:379 msgid "" @@ -603,25 +752,27 @@ msgstr "" "コンテキストマネージャをデコレータとしても使用できるようにする基底クラスで" "す。" -#: ../../library/contextlib.rst:398 msgid "" "Context managers inheriting from ``ContextDecorator`` have to implement :" "meth:`~object.__enter__` and :meth:`~object.__exit__` as normal. " "``__exit__`` retains its optional exception handling even when used as a " "decorator." msgstr "" +"``ContextDecorator`` を継承するコンテキストマネージャは、通常どおり :meth:" +"`~object.__enter__` と :meth:`~object.__exit__` を実装する必要があります。\n" +"デコレータとして使用した場合も、``__exit__`` で任意に例外処理を行えます。" -#: ../../library/contextlib.rst:403 msgid "" "``ContextDecorator`` is used by :deco:`contextmanager`, so you get this " "functionality automatically." msgstr "" +":deco:`contextmanager` は ``ContextDecorator`` を使用するため、この機能を自動" +"的に利用できます。" #: ../../library/contextlib.rst:406 msgid "Example of ``ContextDecorator``::" msgstr "``ContextDecorator`` の例::" -#: ../../library/contextlib.rst:408 msgid "" "from contextlib import ContextDecorator\n" "\n" @@ -634,12 +785,21 @@ msgid "" " print('Finishing')\n" " return False" msgstr "" +"from contextlib import ContextDecorator\n" +"\n" +"class mycontext(ContextDecorator):\n" +" def __enter__(self):\n" +" print('Starting')\n" +" return self\n" +"\n" +" def __exit__(self, *exc):\n" +" print('Finishing')\n" +" return False" #: ../../library/contextlib.rst:419 ../../library/contextlib.rst:519 msgid "The class can then be used like this::" msgstr "このとき、クラスは次のように使うことができます::" -#: ../../library/contextlib.rst:421 msgid "" ">>> @mycontext()\n" "... def function():\n" @@ -657,29 +817,48 @@ msgid "" "The bit in the middle\n" "Finishing" msgstr "" +">>> @mycontext()\n" +"... def function():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> function()\n" +"Starting\n" +"The bit in the middle\n" +"Finishing\n" +"\n" +">>> with mycontext():\n" +"... print('The bit in the middle')\n" +"...\n" +"Starting\n" +"The bit in the middle\n" +"Finishing" #: ../../library/contextlib.rst:437 msgid "" "This change is just syntactic sugar for any construct of the following form::" msgstr "これは次のような形のコードに対するシンタックスシュガーになります::" -#: ../../library/contextlib.rst:439 msgid "" "def f():\n" " with cm():\n" " # Do stuff" msgstr "" +"def f():\n" +" with cm():\n" +" # 処理を行います" #: ../../library/contextlib.rst:443 msgid "``ContextDecorator`` lets you instead write::" msgstr "``ContextDecorator`` を使うと代わりに次のように書けます::" -#: ../../library/contextlib.rst:445 msgid "" "@cm()\n" "def f():\n" " # Do stuff" msgstr "" +"@cm()\n" +"def f():\n" +" # 処理を行います" #: ../../library/contextlib.rst:449 msgid "" @@ -697,7 +876,6 @@ msgstr "" "すでに基底クラスを持っているコンテキストマネージャーも、``ContextDecorator`` " "を mixin クラスとして利用することで拡張できます::" -#: ../../library/contextlib.rst:455 msgid "" "from contextlib import ContextDecorator\n" "\n" @@ -708,6 +886,14 @@ msgid "" " def __exit__(self, *exc):\n" " return False" msgstr "" +"from contextlib import ContextDecorator\n" +"\n" +"class mycontext(ContextBaseClass, ContextDecorator):\n" +" def __enter__(self):\n" +" return self\n" +"\n" +" def __exit__(self, *exc):\n" +" return False" #: ../../library/contextlib.rst:465 msgid "" @@ -720,7 +906,6 @@ msgstr "" "は複数の :keyword:`with` 文に対応する必要があります。そうでないなら、明示的" "な :keyword:`!with` 文を関数内で利用するべきです。" -#: ../../library/contextlib.rst:470 msgid "" "When the decorated callable is a generator function, coroutine function, or " "asynchronous generator function, the returned wrapper is of the same kind " @@ -729,43 +914,63 @@ msgid "" "object. Wrapped generators and asynchronous generators are explicitly " "closed when iteration ends, as if by :func:`closing` or :func:`aclosing`." msgstr "" +"デコレートする呼び出し可能オブジェクトがジェネレータ関数、コルーチン関数、非" +"同期ジェネレータ関数の場合、返されるラッパーも同じ種類になります。\n" +"コンテキストマネージャは、ジェネレータやコルーチンオブジェクトを作成する呼び" +"出しの間だけでなく、反復や await の間ずっと開いたままになります。\n" +"ラップされたジェネレータと非同期ジェネレータは、反復の終了時に :func:" +"`closing` や :func:`aclosing` を使った場合と同様に明示的に閉じられます。" -#: ../../library/contextlib.rst:478 msgid "" "For asynchronous generators the wrapper re-yields each value with ``async " "for``; values sent with :meth:`~agen.asend` and exceptions thrown with :meth:" "`~agen.athrow` are not forwarded to the wrapped generator." msgstr "" +"非同期ジェネレータのラッパーは、``async for`` を使って各値を再度 yield しま" +"す。\n" +":meth:`~agen.asend` で送った値や :meth:`~agen.athrow` で投げ込んだ例外は、" +"ラップされたジェネレータには転送されません。" -#: ../../library/contextlib.rst:485 msgid "" "Decorating a generator function, coroutine function, or asynchronous " "generator function now keeps the context manager open across iteration or " "await. Previously the context manager exited as soon as the generator or " "coroutine object was created." msgstr "" +"ジェネレータ関数、コルーチン関数、非同期ジェネレータ関数をデコレートすると、" +"反復や await の間もコンテキストマネージャを開いたままにするようになりまし" +"た。\n" +"以前は、ジェネレータやコルーチンオブジェクトを作成するとすぐにコンテキストマ" +"ネージャを終了していました。" -#: ../../library/contextlib.rst:494 msgid "" "Similar to :class:`ContextDecorator`, but the context manager is entered and " "exited with :keyword:`async with`. Decorate coroutine functions and " "asynchronous generator functions with this class; the returned wrapper is of " "the same kind." msgstr "" +":class:`ContextDecorator` に似ていますが、コンテキストマネージャへの出入り" +"に :keyword:`async with` を使います。\n" +"このクラスは、コルーチン関数と非同期ジェネレータ関数のデコレートに使ってくだ" +"さい。\n" +"返されるラッパーも同じ種類になります。" -#: ../../library/contextlib.rst:500 msgid "" "Synchronous functions and generators are accepted, but the wrapper is always " "asynchronous, so the decorated callable must then be awaited or iterated " "with ``async for``. If that change of calling convention is not intended, " "use :class:`ContextDecorator` instead." msgstr "" +"同期関数と同期ジェネレータも受け付けますが、ラッパーは常に非同期になるため、" +"デコレートした呼び出し可能オブジェクトは await するか、``async for`` で反復す" +"る必要があります。\n" +"呼び出し方を変更する意図がない場合は、代わりに :class:`ContextDecorator` を" +"使ってください。" #: ../../library/contextlib.rst:505 msgid "Example of ``AsyncContextDecorator``::" msgstr "``AsyncContextDecorator`` の使用例::" -#: ../../library/contextlib.rst:507 msgid "" "from asyncio import run\n" "from contextlib import AsyncContextDecorator\n" @@ -779,8 +984,18 @@ msgid "" " print('Finishing')\n" " return False" msgstr "" +"from asyncio import run\n" +"from contextlib import AsyncContextDecorator\n" +"\n" +"class mycontext(AsyncContextDecorator):\n" +" async def __aenter__(self):\n" +" print('Starting')\n" +" return self\n" +"\n" +" async def __aexit__(self, *exc):\n" +" print('Finishing')\n" +" return False" -#: ../../library/contextlib.rst:521 msgid "" ">>> @mycontext()\n" "... async def function():\n" @@ -800,8 +1015,24 @@ msgid "" "The bit in the middle\n" "Finishing" msgstr "" +">>> @mycontext()\n" +"... async def function():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> run(function())\n" +"Starting\n" +"The bit in the middle\n" +"Finishing\n" +"\n" +">>> async def function():\n" +"... async with mycontext():\n" +"... print('The bit in the middle')\n" +"...\n" +">>> run(function())\n" +"Starting\n" +"The bit in the middle\n" +"Finishing" -#: ../../library/contextlib.rst:541 msgid "" "Decorating an asynchronous generator function now keeps the context manager " "open across iteration. Previously the context manager exited as soon as the " @@ -809,6 +1040,12 @@ msgid "" "generator functions are also now accepted, with an asynchronous wrapper " "returned." msgstr "" +"非同期ジェネレータ関数をデコレートすると、反復の間もコンテキストマネージャを" +"開いたままにするようになりました。\n" +"以前は、ジェネレータオブジェクトを作成するとすぐにコンテキストマネージャを終" +"了していました。\n" +"同期関数と同期ジェネレータ関数も受け付けるようになり、その場合は非同期のラッ" +"パーを返します。" #: ../../library/contextlib.rst:551 msgid "" @@ -825,7 +1062,6 @@ msgid "" "as follows::" msgstr "例えば、複数のファイルを1つの with 文で簡単に扱うことができます::" -#: ../../library/contextlib.rst:558 msgid "" "with ExitStack() as stack:\n" " files = [stack.enter_context(open(fname)) for fname in filenames]\n" @@ -833,12 +1069,18 @@ msgid "" " # the with statement, even if attempts to open files later\n" " # in the list raise an exception" msgstr "" +"with ExitStack() as stack:\n" +" files = [stack.enter_context(open(fname)) for fname in filenames]\n" +" # リストの後半にあるファイルを開く際に例外が発生しても、\n" +" # 開いたすべてのファイルは with 文の終わりで\n" +" # 自動的に閉じられます" -#: ../../library/contextlib.rst:564 msgid "" "The :meth:`~object.__enter__` method returns the :class:`ExitStack` " "instance, and performs no additional operations." msgstr "" +":meth:`~object.__enter__` メソッドは :class:`ExitStack` インスタンスを返すだ" +"けで、追加の処理は行いません。" #: ../../library/contextlib.rst:567 msgid "" @@ -886,12 +1128,15 @@ msgstr "" "す。アプリケーション独自のより高レベルなコンテキストマネージャーを作るための" "基板として使うのに適しています。" -#: ../../library/contextlib.rst:592 msgid "" "Enters a new context manager and adds its :meth:`~object.__exit__` method to " "the callback stack. The return value is the result of the context manager's " "own :meth:`~object.__enter__` method." msgstr "" +"新しいコンテキストマネージャに入り、その :meth:`~object.__exit__` メソッドを" +"コールバックスタックに追加します。\n" +"戻り値は、コンテキストマネージャ自身の :meth:`~object.__enter__` メソッドの結" +"果です。" #: ../../library/contextlib.rst:596 msgid "" @@ -909,37 +1154,45 @@ msgstr "" "*cm* がコンテキストマネージャでなかった場合、 :exc:`AttributeError` の代わり" "に :exc:`TypeError` 例外を送出します。" -#: ../../library/contextlib.rst:603 msgid "" "Added support for arbitrary descriptors :meth:`!__enter__` and :meth:`!" "__exit__`." msgstr "" +":meth:`!__enter__` と :meth:`!__exit__` に任意のデスクリプタを使用できるよう" +"になりました。" -#: ../../library/contextlib.rst:609 msgid "" "Adds a context manager's :meth:`~object.__exit__` method to the callback " "stack." msgstr "" +"コンテキストマネージャの :meth:`~object.__exit__` メソッドをコールバックス" +"タックに追加します。" -#: ../../library/contextlib.rst:611 msgid "" "As ``__enter__`` is *not* invoked, this method can be used to cover part of " "an :meth:`~object.__enter__` implementation with a context manager's own :" "meth:`~object.__exit__` method." msgstr "" +"``__enter__`` は呼び出され *ない* ため、このメソッドを使えば、:meth:`~object." +"__enter__` の実装の一部を、コンテキストマネージャ自身の :meth:`~object." +"__exit__` メソッドによる終了処理の対象にできます。" -#: ../../library/contextlib.rst:615 msgid "" "If passed an object that is not a context manager, this method assumes it is " "a callback with the same signature as a context manager's :meth:`~object." "__exit__` method and adds it directly to the callback stack." msgstr "" +"コンテキストマネージャでないオブジェクトが渡された場合、このメソッドは、その" +"オブジェクトをコンテキストマネージャの :meth:`~object.__exit__` メソッドと同" +"じシグネチャを持つコールバックと見なし、コールバックスタックに直接追加しま" +"す。" -#: ../../library/contextlib.rst:619 msgid "" "By returning true values, these callbacks can suppress exceptions the same " "way context manager :meth:`~object.__exit__` methods can." msgstr "" +"これらのコールバックは、真の値を返すことで、コンテキストマネージャの :meth:" +"`~object.__exit__` メソッドと同様に例外を抑制できます。" #: ../../library/contextlib.rst:622 msgid "" @@ -949,9 +1202,8 @@ msgstr "" "この関数はデコレータとしても使えるように、受け取ったオブジェクトをそのまま返" "します。" -#: ../../library/contextlib.rst:625 msgid "Added support for arbitrary descriptors :meth:`!__exit__`." -msgstr "" +msgstr ":meth:`!__exit__` に任意のデスクリプタを使用できるようになりました。" #: ../../library/contextlib.rst:630 msgid "" @@ -994,7 +1246,6 @@ msgid "" msgstr "" "例えば、複数のファイルを \"all or nothing\" に開く処理を次のように書けます::" -#: ../../library/contextlib.rst:649 msgid "" "with ExitStack() as stack:\n" " files = [stack.enter_context(open(fname)) for fname in filenames]\n" @@ -1005,6 +1256,15 @@ msgid "" " # they will remain open even after the with statement ends.\n" " # close_files() can then be invoked explicitly to close them all." msgstr "" +"with ExitStack() as stack:\n" +" files = [stack.enter_context(open(fname)) for fname in filenames]\n" +" # close メソッドを保持しますが、まだ呼び出しません。\n" +" close_files = stack.pop_all().close\n" +" # どれかのファイルを開くのに失敗すると、それまでに開いた\n" +" # すべてのファイルが自動的に閉じられます。\n" +" # すべてのファイルを\n" +" # 開けた場合は、with 文が終わった後も開いたままになります。\n" +" # その後、close_files() を明示的に呼んですべて閉じられます。" #: ../../library/contextlib.rst:660 msgid "" @@ -1026,17 +1286,19 @@ msgstr "" "managers>` です。スタック上で同期と非同期の両方のコンテキストマネージャの組み" "合わせをサポートします。また、後処理のためのコルーチンも持っています。" -#: ../../library/contextlib.rst:672 msgid "" "The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must " "be used instead." msgstr "" +":meth:`~ExitStack.close` メソッドは実装されていません。\n" +"代わりに :meth:`aclose` を使用する必要があります。" -#: ../../library/contextlib.rst:678 msgid "" "Similar to :meth:`ExitStack.enter_context` but expects an asynchronous " "context manager." msgstr "" +":meth:`ExitStack.enter_context` に似ていますが、非同期コンテキストマネージャ" +"を受け取ります。" #: ../../library/contextlib.rst:681 msgid "" @@ -1046,35 +1308,35 @@ msgstr "" "*cm* が非同期コンテキストマネージャでなかった場合、 :exc:`AttributeError` の" "代わりに :exc:`TypeError` 例外を送出します。" -#: ../../library/contextlib.rst:685 msgid "" "Added support for arbitrary descriptors :meth:`!__aenter__` and :meth:`!" "__aexit__`." msgstr "" +":meth:`!__aenter__` と :meth:`!__aexit__` に任意のデスクリプタを使用できるよ" +"うになりました。" -#: ../../library/contextlib.rst:690 msgid "" "Similar to :meth:`ExitStack.push` but expects either an asynchronous context " "manager or a coroutine function." msgstr "" +":meth:`ExitStack.push` に似ていますが、非同期コンテキストマネージャまたはコ" +"ルーチン関数を受け取ります。" -#: ../../library/contextlib.rst:693 msgid "Added support for arbitrary descriptors :meth:`!__aexit__`." -msgstr "" +msgstr ":meth:`!__aexit__` に任意のデスクリプタを使用できるようになりました。" -#: ../../library/contextlib.rst:698 msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function." msgstr "" +":meth:`ExitStack.callback` に似ていますが、コルーチン関数を受け取ります。" -#: ../../library/contextlib.rst:703 msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables." msgstr "" +":meth:`ExitStack.close` に似ていますが、待機可能オブジェクトを適切に処理しま" +"す。" -#: ../../library/contextlib.rst:705 msgid "Continuing the example for :deco:`asynccontextmanager`::" -msgstr "" +msgstr ":deco:`asynccontextmanager` の例の続きです。 ::" -#: ../../library/contextlib.rst:707 msgid "" "async with AsyncExitStack() as stack:\n" " connections = [await stack.enter_async_context(get_connection())\n" @@ -1083,16 +1345,23 @@ msgid "" " # the async with statement, even if attempts to open a connection\n" " # later in the list raise an exception." msgstr "" +"async with AsyncExitStack() as stack:\n" +" connections = [await stack.enter_async_context(get_connection())\n" +" for i in range(5)]\n" +" # リストの後半で接続を開く際に例外が発生しても、\n" +" # 開いたすべての接続は async with 文の終わりで\n" +" # 自動的に解放されます。" #: ../../library/contextlib.rst:717 msgid "Examples and Recipes" msgstr "例とレシピ" -#: ../../library/contextlib.rst:719 msgid "" "This section describes some examples and recipes for making effective use of " "the tools provided by :mod:`!contextlib`." msgstr "" +"この節では、:mod:`!contextlib` の提供するツールを効果的に使うための例やレシピ" +"を紹介します。" #: ../../library/contextlib.rst:724 msgid "Supporting a variable number of context managers" @@ -1114,7 +1383,6 @@ msgstr "" "場合や、いくつかのコンテキストマネージャーがオプションとなる場合に、可変数個" "のコンテキストマネージャーが必要になります::" -#: ../../library/contextlib.rst:733 msgid "" "with ExitStack() as stack:\n" " for resource in resources:\n" @@ -1124,6 +1392,13 @@ msgid "" " stack.callback(release_special_resource, special)\n" " # Perform operations that use the acquired resources" msgstr "" +"with ExitStack() as stack:\n" +" for resource in resources:\n" +" stack.enter_context(resource)\n" +" if need_special_resource():\n" +" special = acquire_special_resource()\n" +" stack.callback(release_special_resource, special)\n" +" # 確保したリソースを使う操作を行います" #: ../../library/contextlib.rst:741 msgid "" @@ -1139,7 +1414,6 @@ msgstr "" msgid "Catching exceptions from ``__enter__`` methods" msgstr "``__enter__`` メソッドからの例外をキャッチする" -#: ../../library/contextlib.rst:749 msgid "" "It is occasionally desirable to catch exceptions from an :meth:`~object." "__enter__` method implementation, *without* inadvertently catching " @@ -1148,8 +1422,12 @@ msgid "" "context management protocol can be separated slightly in order to allow " "this::" msgstr "" +":keyword:`with` 文の本体やコンテキストマネージャの :meth:`~object.__exit__` " +"メソッドからの例外を誤って捕捉 *せずに*、:meth:`~object.__enter__` メソッドの" +"実装からの例外だけを捕捉したい場合があります。\n" +":class:`ExitStack` を使えば、コンテキスト管理プロトコルの手順を少し分離するこ" +"とで、これを実現できます。 ::" -#: ../../library/contextlib.rst:755 msgid "" "stack = ExitStack()\n" "try:\n" @@ -1160,6 +1438,14 @@ msgid "" " with stack:\n" " # Handle normal case" msgstr "" +"stack = ExitStack()\n" +"try:\n" +" x = stack.enter_context(cm)\n" +"except Exception:\n" +" # __enter__ の例外を処理します\n" +"else:\n" +" with stack:\n" +" # 通常の場合を処理します" #: ../../library/contextlib.rst:764 msgid "" @@ -1183,12 +1469,14 @@ msgstr "" msgid "Cleaning up in an ``__enter__`` implementation" msgstr "``__enter__`` 実装内のクリーンアップ" -#: ../../library/contextlib.rst:776 msgid "" "As noted in the documentation of :meth:`ExitStack.push`, this method can be " "useful in cleaning up an already allocated resource if later steps in the :" "meth:`~object.__enter__` implementation fail." msgstr "" +":meth:`ExitStack.push` のドキュメントで説明したとおり、このメソッドは :meth:" +"`~object.__enter__` の実装の後半で処理が失敗した場合に、すでに確保したリソー" +"スをクリーンアップするのに役立ちます。" #: ../../library/contextlib.rst:780 msgid "" @@ -1200,7 +1488,6 @@ msgstr "" "数を受け取るコンテキストマネージャーで、この方法を使ってコンテキストマネー" "ジャープロトコルを提供しています::" -#: ../../library/contextlib.rst:784 msgid "" "from contextlib import contextmanager, AbstractContextManager, ExitStack\n" "\n" @@ -1237,6 +1524,40 @@ msgid "" " # We don't need to duplicate any of our resource release logic\n" " self.release_resource()" msgstr "" +"from contextlib import contextmanager, AbstractContextManager, ExitStack\n" +"\n" +"class ResourceManager(AbstractContextManager):\n" +"\n" +" def __init__(self, acquire_resource, release_resource, " +"check_resource_ok=None):\n" +" self.acquire_resource = acquire_resource\n" +" self.release_resource = release_resource\n" +" if check_resource_ok is None:\n" +" def check_resource_ok(resource):\n" +" return True\n" +" self.check_resource_ok = check_resource_ok\n" +"\n" +" @contextmanager\n" +" def _cleanup_on_error(self):\n" +" with ExitStack() as stack:\n" +" stack.push(self)\n" +" yield\n" +" # 検証に成功し、例外は発生しませんでした。\n" +" # したがって、リソースを保持し、\n" +" # 呼び出し側に返します。\n" +" stack.pop_all()\n" +"\n" +" def __enter__(self):\n" +" resource = self.acquire_resource()\n" +" with self._cleanup_on_error():\n" +" if not self.check_resource_ok(resource):\n" +" msg = \"Failed validation for {!r}\"\n" +" raise RuntimeError(msg.format(resource))\n" +" return resource\n" +"\n" +" def __exit__(self, *exc_details):\n" +" # リソースの解放処理を重複して記述する必要はありません\n" +" self.release_resource()" #: ../../library/contextlib.rst:820 msgid "Replacing any use of ``try-finally`` and flag variables" @@ -1254,7 +1575,6 @@ msgstr "" "に ``except`` 句を使うだけでは処理できない) ケースでは次のようなコードになり" "ます::" -#: ../../library/contextlib.rst:827 msgid "" "cleanup_needed = True\n" "try:\n" @@ -1265,6 +1585,14 @@ msgid "" " if cleanup_needed:\n" " cleanup_resources()" msgstr "" +"cleanup_needed = True\n" +"try:\n" +" result = perform_operation()\n" +" if result:\n" +" cleanup_needed = False\n" +"finally:\n" +" if cleanup_needed:\n" +" cleanup_resources()" #: ../../library/contextlib.rst:836 msgid "" @@ -1284,7 +1612,6 @@ msgstr "" ":class:`ExitStack` を使えば、代わりに ``with`` 文の終わりに実行されるコール" "バックを登録し、後でそのコールバックをスキップするかどうかを決定できます::" -#: ../../library/contextlib.rst:844 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1294,12 +1621,20 @@ msgid "" " if result:\n" " stack.pop_all()" msgstr "" +"from contextlib import ExitStack\n" +"\n" +"with ExitStack() as stack:\n" +" stack.callback(cleanup_resources)\n" +" result = perform_operation()\n" +" if result:\n" +" stack.pop_all()" -#: ../../library/contextlib.rst:852 msgid "" "This allows the intended cleanup behaviour to be made explicit up front, " "rather than requiring a separate flag variable." msgstr "" +"これにより、別途フラグ変数を用意せずに、意図したクリーンアップの動作をあらか" +"じめ明示できます。" #: ../../library/contextlib.rst:855 msgid "" @@ -1309,7 +1644,6 @@ msgstr "" "もしあるアプリケーションがこのパターンを多用するのであれば、小さいヘルパーク" "ラスを導入してよりシンプルにすることができます::" -#: ../../library/contextlib.rst:858 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1326,6 +1660,20 @@ msgid "" " if result:\n" " cb.cancel()" msgstr "" +"from contextlib import ExitStack\n" +"\n" +"class Callback(ExitStack):\n" +" def __init__(self, callback, /, *args, **kwds):\n" +" super().__init__()\n" +" self.callback(callback, *args, **kwds)\n" +"\n" +" def cancel(self):\n" +" self.pop_all()\n" +"\n" +"with Callback(cleanup_resources) as cb:\n" +" result = perform_operation()\n" +" if result:\n" +" cb.cancel()" #: ../../library/contextlib.rst:873 msgid "" @@ -1337,7 +1685,6 @@ msgstr "" "`ExitStack.callback` のデコレーター形式を利用してリソース開放処理を宣言するこ" "とができます::" -#: ../../library/contextlib.rst:878 msgid "" "from contextlib import ExitStack\n" "\n" @@ -1349,6 +1696,15 @@ msgid "" " if result:\n" " stack.pop_all()" msgstr "" +"from contextlib import ExitStack\n" +"\n" +"with ExitStack() as stack:\n" +" @stack.callback\n" +" def cleanup_resources():\n" +" ...\n" +" result = perform_operation()\n" +" if result:\n" +" stack.pop_all()" #: ../../library/contextlib.rst:888 msgid "" @@ -1385,7 +1741,6 @@ msgstr "" "ネージャーを別々に書く代わりに、 :class:`ContextDecorator` を継承すると1つの" "定義で両方の機能を提供できます::" -#: ../../library/contextlib.rst:905 msgid "" "from contextlib import ContextDecorator\n" "import logging\n" @@ -1402,37 +1757,59 @@ msgid "" " def __exit__(self, exc_type, exc, exc_tb):\n" " logging.info('Exiting: %s', self.name)" msgstr "" +"from contextlib import ContextDecorator\n" +"import logging\n" +"\n" +"logging.basicConfig(level=logging.INFO)\n" +"\n" +"class track_entry_and_exit(ContextDecorator):\n" +" def __init__(self, name):\n" +" self.name = name\n" +"\n" +" def __enter__(self):\n" +" logging.info('Entering: %s', self.name)\n" +"\n" +" def __exit__(self, exc_type, exc, exc_tb):\n" +" logging.info('Exiting: %s', self.name)" #: ../../library/contextlib.rst:920 msgid "Instances of this class can be used as both a context manager::" msgstr "このクラスのインスタンスはコンテキストマネージャーとしても利用でき::" -#: ../../library/contextlib.rst:922 msgid "" "with track_entry_and_exit('widget loader'):\n" " print('Some time consuming activity goes here')\n" " load_widget()" msgstr "" +"with track_entry_and_exit('widget loader'):\n" +" print('Some time consuming activity goes here')\n" +" load_widget()" #: ../../library/contextlib.rst:926 msgid "And also as a function decorator::" msgstr "また関数デコレーターとしても利用できます::" -#: ../../library/contextlib.rst:928 msgid "" "@track_entry_and_exit('widget loader')\n" "def activity():\n" " print('Some time consuming activity goes here')\n" " load_widget()" msgstr "" +"@track_entry_and_exit('widget loader')\n" +"def activity():\n" +" print('Some time consuming activity goes here')\n" +" load_widget()" -#: ../../library/contextlib.rst:933 msgid "" "Note that there is one additional limitation when using context managers as " "function decorators: there's no way to access the return value of :meth:" "`~object.__enter__`. If that value is needed, then it is still necessary to " "use an explicit ``with`` statement." msgstr "" +"コンテキストマネージャを関数デコレータとして使う場合には、もう 1 つ制限があり" +"ます。\n" +":meth:`~object.__enter__` の戻り値にアクセスする方法がありません。\n" +"その値が必要な場合は、明示的な ``with`` 文を使う必要があります。" #: ../../library/contextlib.rst:940 msgid ":pep:`343` - The \"with\" statement" @@ -1536,7 +1913,6 @@ msgstr "" "また :func:`suppress`, :func:`redirect_stdout`, そして :func:`chdir` もリエン" "トラントです。以下はリエントラントな利用法の非常に単純な例です::" -#: ../../library/contextlib.rst:1002 msgid "" ">>> from contextlib import redirect_stdout\n" ">>> from io import StringIO\n" @@ -1553,6 +1929,20 @@ msgid "" "This is written to the stream rather than stdout\n" "This is also written to the stream" msgstr "" +">>> from contextlib import redirect_stdout\n" +">>> from io import StringIO\n" +">>> stream = StringIO()\n" +">>> write_to_stream = redirect_stdout(stream)\n" +">>> with write_to_stream:\n" +"... print(\"This is written to the stream rather than stdout\")\n" +"... with write_to_stream:\n" +"... print(\"This is also written to the stream\")\n" +"...\n" +">>> print(\"This is written directly to stdout\")\n" +"This is written directly to stdout\n" +">>> print(stream.getvalue())\n" +"This is written to the stream rather than stdout\n" +"This is also written to the stream" #: ../../library/contextlib.rst:1017 msgid "" @@ -1579,7 +1969,6 @@ msgstr "" msgid "Reusable context managers" msgstr "再利用可能なコンテキストマネージャ" -#: ../../library/contextlib.rst:1032 msgid "" "Distinct from both single use and reentrant context managers are " "\"reusable\" context managers (or, to be completely explicit, \"reusable, " @@ -1591,10 +1980,11 @@ msgstr "" "単回使用のコンテキストマネージャとリエントラントなコンテキストマネージャのい" "ずれとも異なるタイプに \"再利用可能\" なコンテキストマネージャがあります (あ" "るいは、より明確には、\"再利用可能だがリエントラントでない\" コンテキストマ" -"ネージャです。リエントラントなコンテキストマネージャもまた再利用可能だからで" -"す)。再利用可能なコンテキストマネージャは複数回利用をサポートしますが、同じコ" -"ンテキストマネージャのインスタンスがすでに with 文で使われている場合には失敗" -"します (もしくは正しく動作しません)。" +"ネージャです。\n" +"リエントラントなコンテキストマネージャもまた再利用可能だからです)。\n" +"再利用可能なコンテキストマネージャは複数回利用をサポートしますが、同じコンテ" +"キストマネージャのインスタンスが外側の with 文ですでに使用中の場合には失敗し" +"ます (もしくは正しく動作しません)。" #: ../../library/contextlib.rst:1039 msgid "" @@ -1606,17 +1996,17 @@ msgstr "" "ネージャの例です (リエントラントなロックのためには :class:`threading.RLock` " "を代わりに使う必要があります)。" -#: ../../library/contextlib.rst:1043 msgid "" "Another example of a reusable, but not reentrant, context manager is :class:" "`ExitStack`, as it invokes *all* currently registered callbacks when leaving " "any with statement, regardless of where those callbacks were added::" msgstr "" -"再利用可能だがリエントラントでないコンテキストマネージャのもうひとつの例は :" -"class:`ExitStack` です。これは現在登録されている *全ての* コールバック関数" -"を、どこで登録されたかにかかわらず、呼び出します::" +"再利用可能だがリエントラントでないコンテキストマネージャのもう一つの例は :" +"class:`ExitStack` です。\n" +"これを使うどの with 文を抜けるときにも、現在登録されている *すべての* コール" +"バックを呼び出します。\n" +"コールバックをどこで登録したかは関係ありません。 ::" -#: ../../library/contextlib.rst:1048 msgid "" ">>> from contextlib import ExitStack\n" ">>> stack = ExitStack()\n" @@ -1644,6 +2034,31 @@ msgid "" "Callback: from outer context\n" "Leaving outer context" msgstr "" +">>> from contextlib import ExitStack\n" +">>> stack = ExitStack()\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from first context\")\n" +"... print(\"Leaving first context\")\n" +"...\n" +"Leaving first context\n" +"Callback: from first context\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from second context\")\n" +"... print(\"Leaving second context\")\n" +"...\n" +"Leaving second context\n" +"Callback: from second context\n" +">>> with stack:\n" +"... stack.callback(print, \"Callback: from outer context\")\n" +"... with stack:\n" +"... stack.callback(print, \"Callback: from inner context\")\n" +"... print(\"Leaving inner context\")\n" +"... print(\"Leaving outer context\")\n" +"...\n" +"Leaving inner context\n" +"Callback: from inner context\n" +"Callback: from outer context\n" +"Leaving outer context" #: ../../library/contextlib.rst:1074 msgid "" @@ -1664,7 +2079,6 @@ msgstr "" "ひとつの :class:`ExitStack` インスタンスを再利用する代わりに複数のインスタン" "スを使うことにより、この問題は回避することができます::" -#: ../../library/contextlib.rst:1082 msgid "" ">>> from contextlib import ExitStack\n" ">>> with ExitStack() as outer_stack:\n" @@ -1679,3 +2093,15 @@ msgid "" "Leaving outer context\n" "Callback: from outer context" msgstr "" +">>> from contextlib import ExitStack\n" +">>> with ExitStack() as outer_stack:\n" +"... outer_stack.callback(print, \"Callback: from outer context\")\n" +"... with ExitStack() as inner_stack:\n" +"... inner_stack.callback(print, \"Callback: from inner context\")\n" +"... print(\"Leaving inner context\")\n" +"... print(\"Leaving outer context\")\n" +"...\n" +"Leaving inner context\n" +"Callback: from inner context\n" +"Leaving outer context\n" +"Callback: from outer context" diff --git a/library/contextvars.po b/library/contextvars.po index 93cf5c6e0..c9f7ed118 100644 --- a/library/contextvars.po +++ b/library/contextvars.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/contextvars.rst:2 @@ -42,12 +42,14 @@ msgstr "" "`~contextvars.copy_context` 関数と :class:`~contextvars.Context` クラスを使う" "べきです。" -#: ../../library/contextvars.rst:15 msgid "" "Context managers that have state should use Context Variables instead of :" "func:`threading.local` to prevent their state from bleeding to other code " "unexpectedly, when used in concurrent code." msgstr "" +"状態を持つコンテキストマネージャは、並行コードで使用した際に、その状態が予期" +"せずほかのコードに漏れるのを防ぐため、:func:`threading.local` ではなくコンテ" +"キスト変数を使うべきです。" #: ../../library/contextvars.rst:19 msgid "See also :pep:`567` for additional details." @@ -63,9 +65,8 @@ msgstr "" "このクラスは新しいコンテキスト変数を宣言するのに使われます。例えば、次の通り" "です:" -#: ../../library/contextvars.rst:31 msgid "var: ContextVar[int] = ContextVar('var', default=42)" -msgstr "" +msgstr "var: ContextVar[int] = ContextVar('var', default=42)" #: ../../library/contextvars.rst:33 msgid "" @@ -93,11 +94,12 @@ msgstr "" "テキスト変数への強参照を持っており、コンテキスト変数がガーベジコレクトされる" "のを防ぎます。" -#: ../../library/contextvars.rst:45 msgid "" ":class:`!ContextVar`\\s are :ref:`generic ` over the type of their " "contained value." msgstr "" +":class:`!ContextVar` は、格納する値の型について :ref:`ジェネリック " +"` です。" #: ../../library/contextvars.rst:50 msgid "The name of the variable. This is a read-only property." @@ -150,13 +152,13 @@ msgstr "" ":class:`~contextvars.Token` オブジェクトを返します。このオブジェクトを :meth:" "`ContextVar.reset` メソッドに渡すことで、以前の値に戻すことができます。" -#: ../../library/contextvars.rst:81 msgid "" "For convenience, the token object can be used as a context manager to avoid " "calling :meth:`ContextVar.reset` manually::" msgstr "" +"便利な使い方として、トークンオブジェクトをコンテキストマネージャとして使え" +"ば、:meth:`ContextVar.reset` を手動で呼び出す必要がなくなります。 ::" -#: ../../library/contextvars.rst:84 msgid "" "var = ContextVar('var', default='default value')\n" "\n" @@ -165,12 +167,16 @@ msgid "" "\n" "assert var.get() == 'default value'" msgstr "" +"var = ContextVar('var', default='default value')\n" +"\n" +"with var.set('new value'):\n" +" assert var.get() == 'new value'\n" +"\n" +"assert var.get() == 'default value'" -#: ../../library/contextvars.rst:91 msgid "It is a shorthand for::" -msgstr "" +msgstr "これは次のコードの短縮形です。 ::" -#: ../../library/contextvars.rst:93 msgid "" "var = ContextVar('var', default='default value')\n" "\n" @@ -182,10 +188,18 @@ msgid "" "\n" "assert var.get() == 'default value'" msgstr "" +"var = ContextVar('var', default='default value')\n" +"\n" +"token = var.set('new value')\n" +"try:\n" +" assert var.get() == 'new value'\n" +"finally:\n" +" var.reset(token)\n" +"\n" +"assert var.get() == 'default value'" -#: ../../library/contextvars.rst:105 msgid "Added support for using tokens as context managers." -msgstr "" +msgstr "トークンをコンテキストマネージャとして使用できるようになりました。" #: ../../library/contextvars.rst:109 msgid "" @@ -199,7 +213,6 @@ msgstr "" msgid "For example::" msgstr "例えば::" -#: ../../library/contextvars.rst:114 msgid "" "var = ContextVar('var')\n" "\n" @@ -210,34 +223,47 @@ msgid "" "# After the reset call the var has no value again, so\n" "# var.get() would raise a LookupError." msgstr "" +"var = ContextVar('var')\n" +"\n" +"token = var.set('new value')\n" +"# 'var' を使うコード。\n" +"# var.get() は 'new value' を返します。\n" +"var.reset(token)\n" +"\n" +"# reset の呼び出し後は var の値が再びなくなるため、\n" +"# var.get() を呼ぶと LookupError が送出されます。" -#: ../../library/contextvars.rst:123 msgid "The same *token* cannot be used twice." -msgstr "" +msgstr "同じ *token* を 2 回使うことはできません。" -#: ../../library/contextvars.rst:128 msgid "" "*Token* objects are returned by the :meth:`ContextVar.set` method. They can " "be passed to the :meth:`ContextVar.reset` method to revert the value of the " "variable to what it was before the corresponding *set*. A single token " "cannot reset a context variable more than once." msgstr "" +"*Token* オブジェクトは :meth:`ContextVar.set` メソッドから返されます。\n" +"これを :meth:`ContextVar.reset` メソッドに渡すと、対応する *set* の呼び出し前" +"の値に変数を戻せます。\n" +"1 つのトークンでコンテキスト変数をリセットできるのは 1 回だけです。" -#: ../../library/contextvars.rst:133 msgid "" "Tokens support the :ref:`context manager protocol ` to " "automatically reset context variables. See :meth:`ContextVar.set`." msgstr "" +"トークンは :ref:`コンテキストマネージャプロトコル ` をサ" +"ポートし、コンテキスト変数を自動的にリセットできます。\n" +":meth:`ContextVar.set` を参照してください。" -#: ../../library/contextvars.rst:136 msgid "" "Tokens are :ref:`generic ` over the same type as the :class:" "`ContextVar` which created them." msgstr "" +"トークンは、それを生成した :class:`ContextVar` と同じ型について :ref:`ジェネ" +"リック ` です。" -#: ../../library/contextvars.rst:141 msgid "Added support for usage as a context manager." -msgstr "" +msgstr "コンテキストマネージャとして使用できるようになりました。" #: ../../library/contextvars.rst:145 msgid "" @@ -277,11 +303,12 @@ msgstr "" "次のスニペットは、現在のコンテキストのコピーを取得し、コンテキストに設定され" "ているすべての変数とその値を表示します::" -#: ../../library/contextvars.rst:170 msgid "" "ctx: Context = copy_context()\n" "print(list(ctx.items()))" msgstr "" +"ctx: Context = copy_context()\n" +"print(list(ctx.items()))" #: ../../library/contextvars.rst:173 msgid "" @@ -292,9 +319,8 @@ msgstr "" "この関数の複雑性は *O*\\ (1) です。つまり、少数のコンテキスト変数を持つコンテ" "キストと多くの変数を持つコンテキストで同程度の速度で動作します。" -#: ../../library/contextvars.rst:180 msgid "A mapping of :class:`ContextVars ` to their values." -msgstr ":class:`ContextVars` とその値の対応付け。" +msgstr ":class:`ContextVar` とその値を対応付けるマッピング。" #: ../../library/contextvars.rst:182 msgid "" @@ -304,47 +330,59 @@ msgstr "" "``Context()`` は、値を持たない空のコンテキストを生成します。現在のコンテキス" "トのコピーを得るには、:func:`~contextvars.copy_context` 関数を利用します。" -#: ../../library/contextvars.rst:186 msgid "" "Each thread has its own effective stack of :class:`!Context` objects. The :" "term:`current context` is the :class:`!Context` object at the top of the " "current thread's stack. All :class:`!Context` objects in the stacks are " "considered to be *entered*." msgstr "" +"各スレッドには、実質的にそれぞれ独立した :class:`!Context` オブジェクトのス" +"タックがあります。\n" +":term:`current context` は、現在のスレッドのスタックの最上部にある :class:`!" +"Context` オブジェクトです。\n" +"スタック内のすべての :class:`!Context` オブジェクトは、*入っている* 状態と見" +"なされます。" -#: ../../library/contextvars.rst:191 msgid "" "*Entering* a context, which can be done by calling its :meth:`~Context.run` " "method, makes the context the current context by pushing it onto the top of " "the current thread's context stack." msgstr "" +"コンテキストに *入る* には、その :meth:`~Context.run` メソッドを呼び出しま" +"す。\n" +"これにより、そのコンテキストが現在のスレッドのコンテキストスタックの最上部に" +"積まれ、現在のコンテキストになります。" -#: ../../library/contextvars.rst:195 msgid "" "*Exiting* from the current context, which can be done by returning from the " "callback passed to the :meth:`~Context.run` method, restores the current " "context to what it was before the context was entered by popping the context " "off the top of the context stack." msgstr "" +"現在のコンテキストから *出る* には、:meth:`~Context.run` メソッドに渡したコー" +"ルバックから戻ります。\n" +"これにより、そのコンテキストがコンテキストスタックの最上部から取り除かれ、現" +"在のコンテキストが、そのコンテキストに入る前のものに戻ります。" -#: ../../library/contextvars.rst:200 msgid "" "Since each thread has its own context stack, :class:`ContextVar` objects " "behave in a similar fashion to :func:`threading.local` when values are " "assigned in different threads." msgstr "" +"各スレッドが独自のコンテキストスタックを持つため、異なるスレッドで値を代入し" +"た場合、:class:`ContextVar` オブジェクトは :func:`threading.local` と同様に振" +"る舞います。" -#: ../../library/contextvars.rst:204 msgid "" "Attempting to enter an already entered context, including contexts entered " "in other threads, raises a :exc:`RuntimeError`." msgstr "" +"ほかのスレッドで入っているコンテキストも含め、すでに入っているコンテキストに" +"入ろうとすると、:exc:`RuntimeError` が送出されます。" -#: ../../library/contextvars.rst:207 msgid "After exiting a context, it can later be re-entered (from any thread)." -msgstr "" +msgstr "コンテキストから出た後は、どのスレッドからでも再び入ることができます。" -#: ../../library/contextvars.rst:209 msgid "" "Any changes to :class:`ContextVar` values via the :meth:`ContextVar.set` " "method are recorded in the current context. The :meth:`ContextVar.get` " @@ -353,24 +391,32 @@ msgid "" "context was entered (if needed, the values can be restored by re-entering " "the context)." msgstr "" +":meth:`ContextVar.set` メソッドによる :class:`ContextVar` の値の変更は、現在" +"のコンテキストに記録されます。\n" +":meth:`ContextVar.get` メソッドは、現在のコンテキストに対応する値を返しま" +"す。\n" +"コンテキストから出ると、そのコンテキストに入っていた間に行ったコンテキスト変" +"数の変更は、実質的に元に戻ります (必要であれば、そのコンテキストに再び入るこ" +"とで変更後の値を復元できます)。" #: ../../library/contextvars.rst:216 msgid "Context implements the :class:`collections.abc.Mapping` interface." msgstr "" "Context は、 :class:`collections.abc.Mapping` インターフェースを実装します。" -#: ../../library/contextvars.rst:220 msgid "" "Enters the Context, executes ``callable(*args, **kwargs)``, then exits the " "Context. Returns *callable*'s return value, or propagates an exception if " "one occurred." msgstr "" +"このコンテキストに入り、``callable(*args, **kwargs)`` を実行してから、このコ" +"ンテキストを出ます。\n" +"*callable* の戻り値を返すか、例外が発生した場合はそれを伝播させます。" #: ../../library/contextvars.rst:224 msgid "Example:" msgstr "例:" -#: ../../library/contextvars.rst:226 msgid "" "import contextvars\n" "\n" @@ -403,6 +449,36 @@ msgid "" "# However, outside of 'ctx', 'var' is still set to 'spam':\n" "print(var.get()) # 'spam'" msgstr "" +"import contextvars\n" +"\n" +"var = contextvars.ContextVar('var')\n" +"var.set('spam')\n" +"print(var.get()) # 'spam'\n" +"\n" +"ctx = contextvars.copy_context()\n" +"\n" +"def main():\n" +" # 'copy_context()' と 'ctx.run(main)' を呼ぶ前に\n" +" # 'var' を 'spam' に設定したため、次のようになります:\n" +" print(var.get()) # 'spam'\n" +" print(ctx[var]) # 'spam'\n" +"\n" +" var.set('ham')\n" +"\n" +" # 'var' を 'ham' に設定した後は:\n" +" print(var.get()) # 'ham'\n" +" print(ctx[var]) # 'ham'\n" +"\n" +"# 'main' 関数が 'var' に行う変更はすべて\n" +"# 'ctx' 内にとどまります。\n" +"ctx.run(main)\n" +"\n" +"# 'main()' 関数は 'ctx' コンテキスト内で実行されたので、\n" +"# 'var' の変更はその中にとどまります:\n" +"print(ctx[var]) # 'ham'\n" +"\n" +"# 一方、'ctx' の外では 'var' は依然として 'spam' に設定されています:\n" +"print(var.get()) # 'spam'" #: ../../library/contextvars.rst:272 msgid "Return a shallow copy of the context object." @@ -461,18 +537,18 @@ msgstr "" msgid "asyncio support" msgstr "asyncio サポート" -#: ../../library/contextvars.rst:318 msgid "" "Context variables are natively supported in :mod:`asyncio` and are ready to " "be used without any extra configuration. For example, here is a simple echo " "server, that uses a context variable to make the address of a remote client " "available in the Task that handles that client::" msgstr "" -"コンテキスト変数は、追加の設定なしに :mod:`asyncio` をサポートします。例え" -"ば、次の単純なechoサーバーは、クライアントを扱う Task の中でリモートクライア" -"ントのアドレスが利用できるように、コンテキスト変数を利用します::" +"コンテキスト変数は :mod:`asyncio` に標準でサポートされており、追加の設定なし" +"に使用できます。\n" +"例えば、以下はコンテキスト変数を使った単純な echo サーバーです。\n" +"リモートクライアントのアドレスを、そのクライアントを扱う Task 内で利用できる" +"ようにしています。 ::" -#: ../../library/contextvars.rst:324 msgid "" "import asyncio\n" "import contextvars\n" @@ -517,3 +593,45 @@ msgid "" "# telnet 127.0.0.1 8081\n" "# curl 127.0.0.1:8081" msgstr "" +"import asyncio\n" +"import contextvars\n" +"\n" +"client_addr_var = contextvars.ContextVar('client_addr')\n" +"\n" +"def render_goodbye():\n" +" # 現在扱っているクライアントのアドレスを、この関数に\n" +" # 明示的に渡さなくても参照できます。\n" +"\n" +" client_addr = client_addr_var.get()\n" +" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n" +"\n" +"async def handle_request(reader, writer):\n" +" addr = writer.transport.get_extra_info('socket').getpeername()\n" +" client_addr_var.set(addr)\n" +"\n" +" # ここから呼び出すどのコードでも、'client_addr_var.get()' を\n" +" # 呼んでクライアントのアドレスを取得できます。\n" +"\n" +" while True:\n" +" line = await reader.readline()\n" +" print(line)\n" +" if not line.strip():\n" +" break\n" +"\n" +" writer.write(b'HTTP/1.1 200 OK\\r\\n') # ステータス行\n" +" writer.write(b'\\r\\n') # ヘッダー\n" +" writer.write(render_goodbye()) # 本文\n" +" writer.close()\n" +"\n" +"async def main():\n" +" srv = await asyncio.start_server(\n" +" handle_request, '127.0.0.1', 8081)\n" +"\n" +" async with srv:\n" +" await srv.serve_forever()\n" +"\n" +"asyncio.run(main())\n" +"\n" +"# テストには telnet や curl を使えます:\n" +"# telnet 127.0.0.1 8081\n" +"# curl 127.0.0.1:8081" diff --git a/library/copy.po b/library/copy.po index bc80fd713..ef667feb7 100644 --- a/library/copy.po +++ b/library/copy.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/copy.rst:2 @@ -58,11 +58,12 @@ msgstr "*obj* の浅い (shallow) コピーを返します。" msgid "Return a deep copy of *obj*." msgstr "*obj* の深い (deep) コピーを返します。" -#: ../../library/copy.rst:32 msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " "from *changes*." msgstr "" +"*obj* と同じ型の新しいオブジェクトを作成し、フィールドを *changes* の値で置き" +"換えます。" #: ../../library/copy.rst:40 msgid "Raised for module specific errors." @@ -87,13 +88,12 @@ msgstr "" "限り) 元のオブジェクト中に見つかったオブジェクトに対する *参照* を挿入しま" "す。" -#: ../../library/copy.rst:50 msgid "" "A *deep copy* constructs a new compound object and then, recursively, " "inserts *copies* into it of the objects found in the original." msgstr "" -"*深いコピー (deep copy)* は新たな複合オブジェクトを作成し、その後元のオブジェ" -"クト中に見つかったオブジェクトの *コピー* を挿入します。" +"*深いコピー (deep copy)* は新しい複合オブジェクトを作成し、元のオブジェクトに" +"含まれるオブジェクトを再帰的に *コピー* して挿入します。" #: ../../library/copy.rst:53 msgid "" @@ -103,13 +103,12 @@ msgstr "" "深いコピー操作には、しばしば浅いコピー操作の時には存在しない 2 つの問題がつい" "てまわります:" -#: ../../library/copy.rst:56 msgid "" "Recursive objects (compound objects that, directly or indirectly, contain a " "reference to themselves) may cause a recursive loop." msgstr "" -"再帰的なオブジェクト (直接、間接に関わらず、自分自身に対する参照を持つ複合オ" -"ブジェクト) は再帰ループを引き起こします。" +"再帰的なオブジェクト (直接または間接に自分自身への参照を含む複合オブジェク" +"ト) は、再帰ループを引き起こすことがあります。" #: ../../library/copy.rst:59 msgid "" @@ -154,7 +153,6 @@ msgstr "" "または深く)「コピー」します。これは :mod:`pickle` モジュールでの扱われかたと" "同じです。" -#: ../../library/copy.rst:75 msgid "" "Shallow copies of many collections can be made using the corresponding :meth:" "`!copy` method (such as :meth:`list.copy`, :meth:`dict.copy` or :meth:`set." @@ -164,28 +162,41 @@ msgid "" "subclass, whereas :func:`copy.copy` normally returns an instance of the same " "type." msgstr "" +"多くのコレクションでは、対応する :meth:`!copy` メソッド (:meth:`list.copy`、:" +"meth:`dict.copy`、:meth:`set.copy` など) で浅いコピーを作成できます。\n" +"また、リストやバイト配列などのシーケンスでは、全体のスライス " +"(``sequence[:]``) を作成することでも浅いコピーを作れます。\n" +"ただし、これらのメソッドやスライス操作は、サブクラスのインスタンスをコピーす" +"るときに基底型のインスタンスを作成することがありますが、:func:`copy.copy` は" +"通常、同じ型のインスタンスを返します。" -#: ../../library/copy.rst:85 msgid "" "Classes can use the same interfaces to control copying that they use to " "control pickling. See the description of module :mod:`pickle` for " "information on these methods. In fact, the :mod:`!copy` module uses the " "registered pickle functions from the :mod:`copyreg` module." msgstr "" +"クラスは、pickle 化の制御に使うのと同じインターフェースでコピーを制御できま" +"す。\n" +"これらのメソッドについては、:mod:`pickle` モジュールの説明を参照してくださ" +"い。\n" +"実際、:mod:`!copy` モジュールは :mod:`copyreg` モジュールに登録された pickle " +"関数を使用します。" -#: ../../library/copy.rst:96 msgid "" "In order for a class to define its own copy implementation, it can define " "special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`." msgstr "" +"クラス独自のコピー処理を実装するには、特殊メソッド :meth:`~object.__copy__` " +"と :meth:`~object.__deepcopy__` を定義できます。" -#: ../../library/copy.rst:102 msgid "" "Called to implement the shallow copy operation; no additional arguments are " "passed." msgstr "" +"浅いコピー操作を実装するために呼び出されます。\n" +"追加の引数は渡されません。" -#: ../../library/copy.rst:108 msgid "" "Called to implement the deep copy operation; it is passed one argument, the " "*memo* dictionary. If the ``__deepcopy__`` implementation needs to make a " @@ -193,20 +204,30 @@ msgid "" "with the component as first argument and the *memo* dictionary as second " "argument. The *memo* dictionary should be treated as an opaque object." msgstr "" +"深いコピー操作を実装するために呼び出されます。\n" +"引数として *memo* 辞書が 1 つ渡されます。\n" +"``__deepcopy__`` の実装内で構成要素の深いコピーが必要な場合は、第 1 引数にそ" +"の構成要素、第 2 引数に *memo* 辞書を渡して :func:`~copy.deepcopy` 関数を呼び" +"出す必要があります。\n" +"*memo* 辞書は内部構造に立ち入らない不透明なオブジェクトとして扱ってください。" -#: ../../library/copy.rst:118 msgid "" "Function :func:`!copy.replace` is more limited than :func:`~copy.copy` and :" "func:`~copy.deepcopy`, and only supports named tuples created by :func:" "`~collections.namedtuple`, :mod:`dataclasses`, and other classes which " "define method :meth:`~object.__replace__`." msgstr "" +":func:`!copy.replace` 関数は :func:`~copy.copy` や :func:`~copy.deepcopy` よ" +"り制限が多く、:func:`~collections.namedtuple` で作成した名前付きタプル、:mod:" +"`dataclasses`、および :meth:`~object.__replace__` メソッドを定義するクラスの" +"みをサポートします。" -#: ../../library/copy.rst:126 msgid "" "This method should create a new object of the same type, replacing fields " "with values from *changes*." msgstr "" +"このメソッドは、フィールドを *changes* の値で置き換えた、同じ型の新しいオブ" +"ジェクトを作成する必要があります。" #: ../../library/copy.rst:134 msgid "Module :mod:`pickle`" @@ -236,6 +257,5 @@ msgstr "__copy__() (コピープロトコル)" msgid "__deepcopy__() (copy protocol)" msgstr "__deepcopy__() (コピープロトコル)" -#: ../../library/copy.rst:115 msgid "__replace__() (replace protocol)" -msgstr "" +msgstr "__replace__() (置換プロトコル)" diff --git a/library/copyreg.po b/library/copyreg.po index b9c399088..e12c1d176 100644 --- a/library/copyreg.po +++ b/library/copyreg.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/copyreg.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!copyreg` --- :mod:`!pickle` サポート関数を登録する" msgid "**Source code:** :source:`Lib/copyreg.py`" msgstr "**ソースコード:** :source:`Lib/copyreg.py`" -#: ../../library/copyreg.rst:15 msgid "" "The :mod:`!copyreg` module offers a way to define functions used while " "pickling specific objects. The :mod:`pickle` and :mod:`copy` modules use " @@ -38,6 +37,14 @@ msgid "" "configuration information about object constructors which are not classes. " "Such constructors may be factory functions or class instances." msgstr "" +":mod:`!copyreg` モジュールは、特定のオブジェクトを pickle 化する際に使う関数" +"を定義する手段を提供します。\n" +":mod:`pickle` と :mod:`copy` モジュールは、そのオブジェクトを pickle 化または" +"コピーするときに、これらの関数を使用します。\n" +"このモジュールは、クラスではないオブジェクトコンストラクタに関する設定情報を" +"提供します。\n" +"このようなコンストラクタには、ファクトリ関数やクラスインスタンスなどがありま" +"す。" #: ../../library/copyreg.rst:24 msgid "" diff --git a/library/crypt.po b/library/crypt.po index 11edcb476..ab0715a40 100644 --- a/library/crypt.po +++ b/library/crypt.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: souma987, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/crypt.rst:2 msgid ":mod:`!crypt` --- Function to check Unix passwords" -msgstr "" +msgstr ":mod:`!crypt` --- Unix パスワードを確認する関数" #: ../../library/crypt.rst:10 msgid "" @@ -36,16 +35,21 @@ msgstr "" "ルは Python 3.11 で非推奨となったあと、:ref:`Python 3.13 で削除` されました。削除の決定は :pep:`594` でなされました。" -#: ../../library/crypt.rst:14 msgid "" "Applications can use the :mod:`hashlib` module from the standard library. " "Other possible replacements are third-party libraries from PyPI: :pypi:" "`legacycrypt`, :pypi:`bcrypt`, or :pypi:`argon2-cffi`. These are not " "supported or maintained by the Python core team." msgstr "" +"アプリケーションでは、標準ライブラリの :mod:`hashlib` モジュールを使用できま" +"す。\n" +"ほかの代替候補として、PyPI のサードパーティー製ライブラリ :pypi:" +"`legacycrypt`、:pypi:`bcrypt`、:pypi:`argon2-cffi` があります。\n" +"これらは Python コアチームによるサポートや保守の対象ではありません。" -#: ../../library/crypt.rst:19 msgid "" "The last version of Python that provided the :mod:`!crypt` module was " "`Python 3.12 `_." msgstr "" +":mod:`!crypt` モジュールを提供していた最後の Python バージョンは `Python " +"3.12 `_ です。" diff --git a/library/crypto.po b/library/crypto.po index 330f7661c..d7d68c774 100644 --- a/library/crypto.po +++ b/library/crypto.po @@ -16,25 +16,25 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/crypto.rst:5 msgid "Cryptographic Services" msgstr "暗号関連のサービス" -#: ../../library/crypto.rst:9 msgid "" "The modules described in this chapter implement various algorithms of a " "cryptographic nature. They are available at the discretion of the " "installation. Here's an overview:" msgstr "" -"この章で記述されているモジュールでは、暗号の本質に関わる様々なアルゴリズムを" -"実装しています。 これらは必要に応じてインストールすることで使用できます。概要" -"を以下に示します:" +"この章で説明するモジュールは、暗号に関するさまざまなアルゴリズムを実装してい" +"ます。\n" +"利用できるかどうかはインストール環境によります。\n" +"概要を以下に示します:" #: ../../library/crypto.rst:7 msgid "cryptography" diff --git a/library/csv.po b/library/csv.po index 80bdd0d96..e965a98db 100644 --- a/library/csv.po +++ b/library/csv.po @@ -17,15 +17,14 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/csv.rst:2 msgid ":mod:`!csv` --- CSV file reading and writing" -msgstr "" +msgstr ":mod:`!csv` --- CSV ファイルの読み書き" #: ../../library/csv.rst:7 msgid "**Source code:** :source:`Lib/csv.py`" @@ -56,7 +55,6 @@ msgstr "" "作し、データの読み書きにおける細々としたことをプログラマ から隠蔽するような単" "一のモジュールを書くことは可能です。" -#: ../../library/csv.rst:26 msgid "" "The :mod:`!csv` module implements classes to read and write tabular data in " "CSV format. It allows programmers to say, \"write this data in the format " @@ -65,13 +63,23 @@ msgid "" "Excel. Programmers can also describe the CSV formats understood by other " "applications or define their own special-purpose CSV formats." msgstr "" +":mod:`!csv` モジュールは、表形式のデータを CSV 形式で読み書きするクラスを実装" +"しています。\n" +"Excel が使う CSV 形式の詳細を知らなくても、「このデータを Excel に適した形式" +"で書き込む」ことや「Excel が生成したこのファイルからデータを読み込む」ことが" +"できます。\n" +"また、ほかのアプリケーションが解釈する CSV 形式を記述したり、特定の用途向けに" +"独自の CSV 形式を定義したりすることもできます。" -#: ../../library/csv.rst:33 msgid "" "The :mod:`!csv` module's :class:`reader` and :class:`writer` objects read " "and write sequences. Programmers can also read and write data in dictionary " "form using the :class:`DictReader` and :class:`DictWriter` classes." msgstr "" +":mod:`!csv` モジュールの :class:`reader` オブジェクトと :class:`writer` オブ" +"ジェクトは、シーケンスを読み書きします。\n" +":class:`DictReader` クラスと :class:`DictWriter` クラスを使えば、辞書形式で" +"データを読み書きすることもできます。" #: ../../library/csv.rst:39 msgid ":pep:`305` - CSV File API" @@ -87,11 +95,9 @@ msgstr "" msgid "Module contents" msgstr "モジュールの内容" -#: ../../library/csv.rst:48 msgid "The :mod:`!csv` module defines the following functions:" -msgstr "" +msgstr ":mod:`!csv` モジュールは以下の関数を定義しています。" -#: ../../library/csv.rst:56 msgid "" "Return a :ref:`reader object ` that will process lines from " "the given *csvfile*. A csvfile must be an iterable of strings, each in the " @@ -105,6 +111,21 @@ msgid "" "parameters in the current dialect. For full details about the dialect and " "formatting parameters, see section :ref:`csv-fmt-params`." msgstr "" +"指定された *csvfile* の行を処理する :ref:`reader オブジェクト ` を返します。\n" +"``csvfile`` は文字列のイテラブルでなければならず、各文字列は reader に定義さ" +"れた CSV 形式である必要があります。\n" +"``csvfile`` には通常、ファイルライクオブジェクトやリストを使います。\n" +"*csvfile* がファイルオブジェクトの場合は、``newline=''`` を指定して開く必要が" +"あります [1]_。\n" +"省略可能な *dialect* 引数では、特定の CSV 表現形式に固有のパラメータ群を指定" +"できます。\n" +":class:`Dialect` クラスのサブクラスのインスタンスか、:func:`list_dialects` 関" +"数が返す文字列のいずれかを指定できます。\n" +"その他の省略可能なキーワード引数 *fmtparams* を指定すると、現在の表現形式の書" +"式パラメータを個別に上書きできます。\n" +"表現形式と書式パラメータの詳細については、:ref:`csv-fmt-params` 節を参照して" +"ください。" #: ../../library/csv.rst:70 msgid "" @@ -123,7 +144,6 @@ msgstr "" msgid "A short usage example::" msgstr "短い利用例::" -#: ../../library/csv.rst:76 msgid "" ">>> import csv\n" ">>> with open('eggs.csv', newline='') as csvfile:\n" @@ -133,16 +153,23 @@ msgid "" "Spam, Spam, Spam, Spam, Spam, Baked Beans\n" "Spam, Lovely Spam, Wonderful Spam" msgstr "" +">>> import csv\n" +">>> with open('eggs.csv', newline='') as csvfile:\n" +"... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')\n" +"... for row in spamreader:\n" +"... print(', '.join(row))\n" +"Spam, Spam, Spam, Spam, Spam, Baked Beans\n" +"Spam, Lovely Spam, Wonderful Spam" -#: ../../library/csv.rst:84 msgid "where :file:`eggs.csv` contains:" -msgstr "" +msgstr "ここで、:file:`eggs.csv` の内容は次のとおりです:" -#: ../../library/csv.rst:86 ../../library/csv.rst:122 msgid "" "Spam Spam Spam Spam Spam |Baked Beans|\n" "Spam |Lovely Spam| |Wonderful Spam|" msgstr "" +"Spam Spam Spam Spam Spam |Baked Beans|\n" +"Spam |Lovely Spam| |Wonderful Spam|" #: ../../library/csv.rst:94 msgid "" @@ -180,7 +207,6 @@ msgstr "" "きます。他の非文字列データは、書き出される前に :func:`str` を使って文字列に変" "換されます。" -#: ../../library/csv.rst:113 msgid "" "import csv\n" "with open('eggs.csv', 'w', newline='') as csvfile:\n" @@ -189,10 +215,15 @@ msgid "" " spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])\n" " spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])" msgstr "" +"import csv\n" +"with open('eggs.csv', 'w', newline='') as csvfile:\n" +" spamwriter = csv.writer(csvfile, delimiter=' ',\n" +" quotechar='|', quoting=csv.QUOTE_MINIMAL)\n" +" spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])\n" +" spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])" -#: ../../library/csv.rst:120 msgid "which writes :file:`eggs.csv` containing:" -msgstr "" +msgstr "これは、次の内容の :file:`eggs.csv` を書き出します:" #: ../../library/csv.rst:130 msgid "" @@ -237,9 +268,8 @@ msgstr "" "パーサが許容する現在の最大フィールドサイズを返します。 *new_limit* が渡された" "ときは、その値が新しい上限になります。" -#: ../../library/csv.rst:161 msgid "The :mod:`!csv` module defines the following classes:" -msgstr "" +msgstr ":mod:`!csv` モジュールは以下のクラスを定義しています。" #: ../../library/csv.rst:166 msgid "" @@ -251,7 +281,6 @@ msgstr "" "るオブジェクトを生成します。マップのキーは省略可能な *fieldnames* パラメータ" "で与えられます。" -#: ../../library/csv.rst:170 msgid "" "The *fieldnames* parameter is a :term:`sequence`. If *fieldnames* is " "omitted, the values in the first row of file *f* will be used as the " @@ -260,6 +289,12 @@ msgid "" "results. Regardless of how the fieldnames are determined, the dictionary " "preserves their original ordering." msgstr "" +"*fieldnames* 引数は :term:`sequence` です。\n" +"*fieldnames* を省略すると、ファイル *f* の最初の行の値をフィールド名として使" +"い、その行を結果から除外します。\n" +"*fieldnames* を指定すると、それをフィールド名として使い、最初の行も結果に含め" +"ます。\n" +"フィールド名の決め方にかかわらず、辞書はその元の順序を保持します。" #: ../../library/csv.rst:177 msgid "" @@ -299,7 +334,6 @@ msgstr "返される行の型は :class:`OrderedDict` になりました。" msgid "Returned rows are now of type :class:`dict`." msgstr "返される行の型は :class:`dict` になりました。" -#: ../../library/csv.rst:196 msgid "" ">>> import csv\n" ">>> with open('names.csv', newline='') as csvfile:\n" @@ -313,19 +347,30 @@ msgid "" ">>> print(row)\n" "{'first_name': 'John', 'last_name': 'Cleese'}" msgstr "" +">>> import csv\n" +">>> with open('names.csv', newline='') as csvfile:\n" +"... reader = csv.DictReader(csvfile)\n" +"... for row in reader:\n" +"... print(row['first_name'], row['last_name'])\n" +"...\n" +"Eric Idle\n" +"John Cleese\n" +"\n" +">>> print(row)\n" +"{'first_name': 'John', 'last_name': 'Cleese'}" -#: ../../library/csv.rst:208 msgid "where :file:`names.csv` contains:" -msgstr "" +msgstr ":file:`names.csv` の内容は次のとおりです:" -#: ../../library/csv.rst:210 msgid "" "first_name,last_name\n" "Eric,Idle\n" "John,Cleese" msgstr "" +"first_name,last_name\n" +"Eric,Idle\n" +"John,Cleese" -#: ../../library/csv.rst:220 msgid "" "Create an object which operates like a regular writer but maps dictionaries " "onto output rows. The *fieldnames* parameter is a :mod:`sequence " @@ -341,15 +386,20 @@ msgid "" "to the underlying :class:`writer` instance." msgstr "" "通常の writer のように動作しますが、辞書を出力行にマップするオブジェクトを生" -"成します。 *fieldnames* パラメータは、:meth:`~csvwriter.writerow` メソッドに" -"渡された辞書の値がどのような順番でファイル *f* に書かれるかを指定するキーの :" -"mod:`sequence ` です。 :meth:`~csvwriter.writerow` メソッド" -"に渡された辞書に *fieldnames* には存在しないキーが含まれている場合、オプショ" -"ンの *extrasaction* パラメータによってどんな動作を行うかが指定されます。この" -"値がデフォルト値である ``'raise'`` に設定されている場合、 :exc:`ValueError` " -"が送出されます。 ``'ignore'`` に設定されている場合、辞書の余分な値は無視され" -"ます。その他のパラメータはベースになっている :class:`writer` インスタンスに渡" -"されます。" +"成します。\n" +"*fieldnames* パラメータは、:meth:`~csvwriter.writerow` メソッドに渡された辞書" +"の値がどのような順番でファイル *f* に書かれるかを指定するキーの :mod:" +"`sequence ` です。\n" +"省略可能な *restval* パラメータは、辞書に *fieldnames* のキーがない場合に書き" +"込む値を指定します。\n" +":meth:`~csvwriter.writerow` メソッドに渡された辞書に *fieldnames* には存在し" +"ないキーが含まれている場合、オプションの *extrasaction* パラメータによってど" +"んな動作を行うかが指定されます。\n" +"この値がデフォルト値である ``'raise'`` に設定されている場合、 :exc:" +"`ValueError` が送出されます。\n" +"``'ignore'`` に設定されている場合、辞書の余分な値は無視されます。\n" +"その他のパラメータはベースになっている :class:`writer` インスタンスに渡されま" +"す。" #: ../../library/csv.rst:235 msgid "" @@ -359,7 +409,6 @@ msgstr "" ":class:`DictReader` クラスとは異なり、 :class:`DictWriter` の *fieldnames* パ" "ラメータは省略可能ではありません。" -#: ../../library/csv.rst:242 msgid "" "import csv\n" "\n" @@ -372,18 +421,30 @@ msgid "" " writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})\n" " writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})" msgstr "" +"import csv\n" +"\n" +"with open('names.csv', 'w', newline='') as csvfile:\n" +" fieldnames = ['first_name', 'last_name']\n" +" writer = csv.DictWriter(csvfile, fieldnames=fieldnames)\n" +"\n" +" writer.writeheader()\n" +" writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'})\n" +" writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})\n" +" writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})" -#: ../../library/csv.rst:253 msgid "which writes :file:`names.csv` containing:" -msgstr "" +msgstr "これは、次の内容の :file:`names.csv` を書き出します:" -#: ../../library/csv.rst:255 msgid "" "first_name,last_name\n" "Baked,Beans\n" "Lovely,Spam\n" "Wonderful,Spam" msgstr "" +"first_name,last_name\n" +"Baked,Beans\n" +"Lovely,Spam\n" +"Wonderful,Spam" #: ../../library/csv.rst:265 msgid "" @@ -399,20 +460,26 @@ msgstr "" "す。 :class:`Dialect` クラスのインスタンスは :class:`reader` と :class:" "`writer` のインスタンスの挙動を定義します。" -#: ../../library/csv.rst:271 msgid "" "All available :class:`Dialect` names are returned by :func:`list_dialects`, " "and they can be registered with specific :class:`reader` and :class:`writer` " "classes through their initializer (``__init__``) functions like this::" msgstr "" +"利用可能な :class:`Dialect` の名前はすべて :func:`list_dialects` で取得できま" +"す。\n" +"次のように初期化関数 (``__init__``) を通じて、個々の :class:`reader` クラス" +"や :class:`writer` クラスに表現形式を指定できます。 ::" -#: ../../library/csv.rst:275 msgid "" "import csv\n" "\n" "with open('students.csv', 'w', newline='') as csvfile:\n" " writer = csv.writer(csvfile, dialect='unix')" msgstr "" +"import csv\n" +"\n" +"with open('students.csv', 'w', newline='') as csvfile:\n" +" writer = csv.writer(csvfile, dialect='unix')" #: ../../library/csv.rst:283 msgid "" @@ -463,21 +530,26 @@ msgstr "" "`Dialect` サブクラスを返します。オプションの *delimiters* パラメータを与えた" "場合、有効なデリミタ文字を含んでいるはずの文字列として解釈されます。" -#: ../../library/csv.rst:315 msgid "" "If several delimiters fit the sample equally well --- for example if both " "``','`` and ``';'`` split every row consistently --- the delimiters listed " "in the :attr:`~Sniffer.preferred` attribute are preferred, in that order, no " "matter how many times each of them occurs." msgstr "" +"複数のデリミタがサンプルに同じ程度に適合する場合 (例えば、``','`` と ``';'`` " +"のどちらでもすべての行を一貫して分割できる場合)、各デリミタの出現回数にかかわ" +"らず、:attr:`~Sniffer.preferred` 属性に並んだ順に優先されます。" -#: ../../library/csv.rst:323 msgid "" "Analyze the sample text (presumed to be in CSV format) and return :const:" "`True` if the first row appears to be a series of column headers. Inspecting " "each column, one of two key criteria will be considered to estimate if the " "sample contains a header:" msgstr "" +"CSV 形式であると想定したサンプルテキストを解析し、最初の行が列見出しの並びと" +"思われる場合に :const:`True` を返します。\n" +"各列を調べ、次の 2 つの主要な基準のいずれかに基づいて、サンプルに見出しが含ま" +"れるかを推定します:" #: ../../library/csv.rst:328 msgid "the second through n-th rows contain numeric values" @@ -503,22 +575,23 @@ msgstr "" "このメソッドは大雑把なヒューリスティックであり、結果が偽陽性や偽陰性である可" "能性があります。" -#: ../../library/csv.rst:340 msgid "The :class:`Sniffer` class has the following attribute:" -msgstr "" +msgstr ":class:`Sniffer` クラスには以下の属性があります:" -#: ../../library/csv.rst:344 msgid "" "The list of the delimiters preferred for breaking ties, in the order of " "preference. It can be modified. Its initial value is ``[',', '\\t', ';', ' " "', ':']``." msgstr "" +"同程度に適合する候補がある場合に優先するデリミタを、優先順に並べたリストで" +"す。\n" +"変更できます。\n" +"初期値は ``[',', '\\t', ';', ' ', ':']`` です。" #: ../../library/csv.rst:349 msgid "An example for :class:`Sniffer` use::" msgstr ":class:`Sniffer` の利用例::" -#: ../../library/csv.rst:351 msgid "" "with open('example.csv', newline='') as csvfile:\n" " dialect = csv.Sniffer().sniff(csvfile.read(1024))\n" @@ -526,10 +599,14 @@ msgid "" " reader = csv.reader(csvfile, dialect)\n" " # ... process CSV file contents here ..." msgstr "" +"with open('example.csv', newline='') as csvfile:\n" +" dialect = csv.Sniffer().sniff(csvfile.read(1024))\n" +" csvfile.seek(0)\n" +" reader = csv.reader(csvfile, dialect)\n" +" # ... ここで CSV ファイルの内容を処理します ..." -#: ../../library/csv.rst:360 msgid "The :mod:`!csv` module defines the following constants:" -msgstr "" +msgstr ":mod:`!csv` モジュールは以下の定数を定義しています。" #: ../../library/csv.rst:364 msgid "Instructs :class:`writer` objects to quote all fields." @@ -537,7 +614,6 @@ msgstr "" ":class:`writer` オブジェクトに対し、全てのフィールドをクオートするように指示" "します。" -#: ../../library/csv.rst:369 msgid "" "Instructs :class:`writer` objects to only quote those fields which contain " "special characters such as *delimiter*, *quotechar*, ``'\\r'``, ``'\\n'`` or " @@ -545,6 +621,12 @@ msgid "" "`False` and *escapechar* is set, the *quotechar* is escaped instead of " "causing the field to be quoted." msgstr "" +":class:`writer` オブジェクトに、*delimiter*、*quotechar*、``'\\r'``、" +"``'\\n'``、*lineterminator* に含まれる文字などの特殊文字を含むフィールドだけ" +"をクォートするよう指示します。\n" +"*doublequote* が :const:`False` で *escapechar* が設定されている場合、" +"*quotechar* はエスケープされ、その文字を理由としてフィールドがクォートされる" +"ことはありません。" #: ../../library/csv.rst:378 msgid "Instructs :class:`writer` objects to quote all non-numeric fields." @@ -568,7 +650,6 @@ msgid "" "data:`QUOTE_STRINGS` modes." msgstr "" -#: ../../library/csv.rst:391 msgid "" "Instructs :class:`writer` objects to never quote fields. When the current " "*delimiter*, *quotechar*, *escapechar*, ``'\\r'``, ``'\\n'`` or any of the " @@ -577,6 +658,14 @@ msgid "" "raise :exc:`Error` if any characters that require escaping are encountered. " "Set *quotechar* to ``None`` to prevent its escaping." msgstr "" +":class:`writer` オブジェクトに、フィールドを一切クォートしないよう指示しま" +"す。\n" +"出力データに現在の *delimiter*、*quotechar*、*escapechar*、``'\\r'``、" +"``'\\n'``、または *lineterminator* に含まれる文字が現れると、その直前に現在" +"の *escapechar* 文字を付けます。\n" +"*escapechar* が設定されていない場合、エスケープが必要な文字が見つかると " +"writer は :exc:`Error` を送出します。\n" +"*quotechar* のエスケープを避けるには、それを ``None`` に設定してください。" #: ../../library/csv.rst:399 msgid "" @@ -586,45 +675,51 @@ msgstr "" ":class:`reader` オブジェクトに、クオート文字に対する特殊処理を行わないよう指" "示します。" -#: ../../library/csv.rst:403 msgid "" "Instructs :class:`writer` objects to quote all fields which are not " "``None``. This is similar to :data:`QUOTE_ALL`, except that if a field " "value is ``None`` an empty (unquoted) string is written." msgstr "" +":class:`writer` オブジェクトに、``None`` ではないすべてのフィールドをクォート" +"するよう指示します。\n" +":data:`QUOTE_ALL` に似ていますが、フィールドの値が ``None`` の場合は、クォー" +"トされていない空文字列を書き込みます。" -#: ../../library/csv.rst:407 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) field as " "``None`` and to otherwise behave as :data:`QUOTE_ALL`." msgstr "" +":class:`reader` オブジェクトに、クォートされていない空のフィールドを " +"``None`` と解釈し、それ以外は :data:`QUOTE_ALL` と同様に動作するよう指示しま" +"す。" -#: ../../library/csv.rst:414 msgid "" "Instructs :class:`writer` objects to always place quotes around fields which " "are strings. This is similar to :data:`QUOTE_NONNUMERIC`, except that if a " "field value is ``None`` an empty (unquoted) string is written." msgstr "" +":class:`writer` オブジェクトに、文字列のフィールドを常にクォートするよう指示" +"します。\n" +":data:`QUOTE_NONNUMERIC` に似ていますが、フィールドの値が ``None`` の場合は、" +"クォートされていない空文字列を書き込みます。" -#: ../../library/csv.rst:418 msgid "" "Instructs :class:`reader` objects to interpret an empty (unquoted) string as " "``None`` and to otherwise behave as :data:`QUOTE_NONNUMERIC`." msgstr "" +":class:`reader` オブジェクトに、クォートされていない空文字列を ``None`` と解" +"釈し、それ以外は :data:`QUOTE_NONNUMERIC` と同様に動作するよう指示します。" -#: ../../library/csv.rst:423 msgid "The :mod:`!csv` module defines the following exception:" -msgstr "" +msgstr ":mod:`!csv` モジュールは以下の例外を定義しています。" #: ../../library/csv.rst:428 msgid "Raised by any of the functions when an error is detected." msgstr "全ての関数において、エラーが検出された際に送出される例外です。" -#: ../../library/csv.rst:433 msgid "Dialects and formatting parameters" -msgstr "" +msgstr "表現形式と書式パラメータ" -#: ../../library/csv.rst:435 msgid "" "To make it easier to specify the format of input and output records, " "specific formatting parameters are grouped together into dialects. A " @@ -636,6 +731,17 @@ msgid "" "specify individual formatting parameters, which have the same names as the " "attributes defined below for the :class:`Dialect` class." msgstr "" +"入出力レコードの形式を簡単に指定できるように、書式パラメータを表現形式 " +"(dialect) としてまとめています。\n" +"表現形式は :class:`Dialect` クラスのサブクラスであり、CSV ファイルの形式を記" +"述するさまざまな属性を持ちます。\n" +":class:`reader` オブジェクトや :class:`writer` オブジェクトを作成する際、" +"``dialect`` 引数には文字列か :class:`Dialect` クラスのサブクラスを指定できま" +"す。\n" +"*dialect* 引数に加えて、またはその代わりに、書式パラメータを個別に指定するこ" +"ともできます。\n" +"各パラメータの名前は、以下で定義する :class:`Dialect` クラスの属性名と同じで" +"す。" #: ../../library/csv.rst:445 msgid "Dialects support the following attributes:" @@ -670,37 +776,38 @@ msgstr "" "ていない場合、フィールド内に *quotechar* が現れると :exc:`Error` が送出されま" "す。" -#: ../../library/csv.rst:466 msgid "" "A one-character string used by the writer to escape characters that require " "escaping:" msgstr "" +"writer がエスケープを要する以下の文字をエスケープするために使う、1 文字の文字" +"列です:" -#: ../../library/csv.rst:469 msgid "" "the *delimiter*, the *quotechar*, ``'\\r'``, ``'\\n'`` and any of the " "characters in *lineterminator* are escaped if *quoting* is set to :const:" "`QUOTE_NONE`;" msgstr "" +"*quoting* が :const:`QUOTE_NONE` の場合は、*delimiter*、*quotechar*、" +"``'\\r'``、``'\\n'``、および *lineterminator* に含まれる文字。" -#: ../../library/csv.rst:472 msgid "the *quotechar* is escaped if *doublequote* is :const:`False`;" -msgstr "" +msgstr "*doublequote* が :const:`False` の場合は *quotechar*。" -#: ../../library/csv.rst:473 msgid "the *escapechar* itself." -msgstr "" +msgstr "*escapechar* 自身。" -#: ../../library/csv.rst:475 msgid "" "On reading, the *escapechar* removes any special meaning from the following " "character. It defaults to :const:`None`, which disables escaping." msgstr "" +"読み込み時には、*escapechar* は直後の文字の特殊な意味を取り除きます。\n" +"デフォルトは :const:`None` で、この場合エスケープは無効です。" -#: ../../library/csv.rst:478 msgid "" "Previously the *escapechar* itself was not escaped, which lost it on reading." msgstr "" +"以前は *escapechar* 自身がエスケープされず、読み込み時に失われていました。" #: ../../library/csv.rst:482 msgid "An empty *escapechar* is not allowed." @@ -724,7 +831,6 @@ msgstr "" "にハードコードされており、 *lineterminator* を無視します。この振る舞いは将来" "変更されるかもしれません。" -#: ../../library/csv.rst:499 msgid "" "A one-character string used to quote fields containing special characters, " "such as the *delimiter* or the *quotechar*, or which contain new-line " @@ -732,25 +838,38 @@ msgid "" "*lineterminator*). It defaults to ``'\"'``. Can be set to ``None`` to " "prevent escaping ``'\"'`` if *quoting* is set to :const:`QUOTE_NONE`." msgstr "" +"*delimiter* や *quotechar* などの特殊文字、または改行文字 (``'\\r'``、" +"``'\\n'``、*lineterminator* に含まれる文字) を含むフィールドをクォートするた" +"めの、1 文字の文字列です。\n" +"デフォルトは ``'\"'`` です。\n" +"*quoting* が :const:`QUOTE_NONE` の場合に ``'\"'`` がエスケープされないように" +"するには、``None`` に設定できます。" #: ../../library/csv.rst:506 msgid "An empty *quotechar* is not allowed." msgstr "空の *quotechar* は許可されていません。" -#: ../../library/csv.rst:511 msgid "" "Controls when quotes should be generated by the writer and recognised by the " "reader. It can take on any of the :ref:`QUOTE_\\* constants ` and defaults to :const:`QUOTE_MINIMAL` if *quotechar* is not " "``None``, and :const:`QUOTE_NONE` otherwise." msgstr "" +"writer がクォートを生成する条件と、reader がクォートを認識する条件を制御しま" +"す。\n" +":ref:`QUOTE_\\* 定数 ` のいずれかを指定できます。\n" +"デフォルトは、*quotechar* が ``None`` でなければ :const:`QUOTE_MINIMAL`、そう" +"でなければ :const:`QUOTE_NONE` です。" -#: ../../library/csv.rst:519 msgid "" "When :const:`True`, spaces immediately following the *delimiter* are " "ignored. The default is :const:`False`. When combining ``delimiter=' '`` " "with ``skipinitialspace=True``, unquoted empty fields are not allowed." msgstr "" +":const:`True` の場合、*delimiter* の直後の空白は無視されます。\n" +"デフォルトは :const:`False` です。\n" +"``delimiter=' '`` と ``skipinitialspace=True`` を組み合わせる場合、クォートさ" +"れていない空のフィールドは許可されません。" #: ../../library/csv.rst:526 msgid "" @@ -760,9 +879,8 @@ msgstr "" "``True`` の場合、 不正な CSV 入力に対して :exc:`Error` を送出します。デフォル" "トでは ``False`` です。" -#: ../../library/csv.rst:532 msgid "Reader objects" -msgstr "" +msgstr "reader オブジェクト" #: ../../library/csv.rst:534 msgid "" @@ -812,9 +930,8 @@ msgstr "" "オブジェクトを生成するときに渡されなかった場合、この属性は最初のアクセス時" "か、ファイルから最初のレコードを読み出したときに初期化されます。" -#: ../../library/csv.rst:569 msgid "Writer objects" -msgstr "" +msgstr "writer オブジェクト" #: ../../library/csv.rst:571 msgid "" @@ -871,12 +988,14 @@ msgstr "writer で使われる表現形式の読み出し専用の記述です msgid "DictWriter objects have the following public method:" msgstr "DictWriter のオブジェクトは以下の public メソッドを持っています:" -#: ../../library/csv.rst:608 msgid "" "Write a row with the field names (as specified in the constructor) to the " "writer's file object, formatted according to the current dialect. Return the " "return value of the :meth:`csvwriter.writerow` call used internally." msgstr "" +"コンストラクタで指定したフィールド名を、現在の表現形式に従って整形し、writer " +"のファイルオブジェクトに 1 行書き込みます。\n" +"内部で呼び出す :meth:`csvwriter.writerow` の戻り値を返します。" #: ../../library/csv.rst:613 msgid "" @@ -894,7 +1013,6 @@ msgstr "使用例" msgid "The simplest example of reading a CSV file::" msgstr "最も簡単な CSV ファイル読み込みの例です::" -#: ../../library/csv.rst:625 msgid "" "import csv\n" "with open('some.csv', newline='') as f:\n" @@ -902,12 +1020,16 @@ msgid "" " for row in reader:\n" " print(row)" msgstr "" +"import csv\n" +"with open('some.csv', newline='') as f:\n" +" reader = csv.reader(f)\n" +" for row in reader:\n" +" print(row)" #: ../../library/csv.rst:631 msgid "Reading a file with an alternate format::" msgstr "別の書式での読み込み::" -#: ../../library/csv.rst:633 msgid "" "import csv\n" "with open('passwd', newline='') as f:\n" @@ -915,27 +1037,37 @@ msgid "" " for row in reader:\n" " print(row)" msgstr "" +"import csv\n" +"with open('passwd', newline='') as f:\n" +" reader = csv.reader(f, delimiter=':', quoting=csv.QUOTE_NONE)\n" +" for row in reader:\n" +" print(row)" #: ../../library/csv.rst:639 msgid "The corresponding simplest possible writing example is::" msgstr "上に対して、単純な書き込みのプログラム例は以下のようになります。 ::" -#: ../../library/csv.rst:641 msgid "" "import csv\n" "with open('some.csv', 'w', newline='') as f:\n" " writer = csv.writer(f)\n" " writer.writerows(someiterable)" msgstr "" +"import csv\n" +"with open('some.csv', 'w', newline='') as f:\n" +" writer = csv.writer(f)\n" +" writer.writerows(someiterable)" -#: ../../library/csv.rst:646 msgid "" "Since :func:`open` is used to open a CSV file for reading, the file will by " "default be decoded into Unicode using UTF-8. To decode a file using a " "different encoding, use the ``encoding`` argument of open::" msgstr "" +"CSV ファイルを読み込み用に開くには :func:`open` を使うため、デフォルトでは " +"UTF-8 を使用してファイルを Unicode にデコードします。\n" +"別のエンコーディングでデコードするには、``open()`` の ``encoding`` 引数を使っ" +"てください。 ::" -#: ../../library/csv.rst:650 msgid "" "import csv\n" "with open('some.csv', newline='', encoding='latin-1') as f:\n" @@ -943,24 +1075,33 @@ msgid "" " for row in reader:\n" " print(row)" msgstr "" +"import csv\n" +"with open('some.csv', newline='', encoding='latin-1') as f:\n" +" reader = csv.reader(f)\n" +" for row in reader:\n" +" print(row)" -#: ../../library/csv.rst:656 msgid "" "The same applies to writing in something other than the default encoding: " "specify the encoding argument when opening the output file." msgstr "" +"デフォルト以外のエンコーディングで書き込む場合も同様です。\n" +"出力ファイルを開く際に ``encoding`` 引数を指定してください。" #: ../../library/csv.rst:659 msgid "Registering a new dialect::" msgstr "新しい表現形式の登録::" -#: ../../library/csv.rst:661 msgid "" "import csv\n" "csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" "with open('passwd', newline='') as f:\n" " reader = csv.reader(f, 'unixpwd')" msgstr "" +"import csv\n" +"csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)\n" +"with open('passwd', newline='') as f:\n" +" reader = csv.reader(f, 'unixpwd')" #: ../../library/csv.rst:666 msgid "" @@ -969,7 +1110,6 @@ msgid "" msgstr "" "もう少し手の込んだ reader の使い方 --- エラーを捉えてレポートします。 ::" -#: ../../library/csv.rst:668 msgid "" "import csv, sys\n" "filename = 'some.csv'\n" @@ -981,6 +1121,15 @@ msgid "" " except csv.Error as e:\n" " sys.exit(f'file {filename}, line {reader.line_num}: {e}')" msgstr "" +"import csv, sys\n" +"filename = 'some.csv'\n" +"with open(filename, newline='') as f:\n" +" reader = csv.reader(f)\n" +" try:\n" +" for row in reader:\n" +" print(row)\n" +" except csv.Error as e:\n" +" sys.exit(f'file {filename}, line {reader.line_num}: {e}')" #: ../../library/csv.rst:678 msgid "" @@ -989,18 +1138,19 @@ msgid "" msgstr "" "このモジュールは文字列の解析は直接サポートしませんが、簡単にできます。 ::" -#: ../../library/csv.rst:681 msgid "" "import csv\n" "for row in csv.reader(['one,two,three']):\n" " print(row)" msgstr "" +"import csv\n" +"for row in csv.reader(['one,two,three']):\n" +" print(row)" #: ../../library/csv.rst:687 msgid "Footnotes" msgstr "脚注" -#: ../../library/csv.rst:688 msgid "" "If ``newline=''`` is not specified, newlines embedded inside quoted fields " "will not be interpreted correctly, and on platforms that use ``\\r\\n`` line " @@ -1008,6 +1158,12 @@ msgid "" "to specify ``newline=''``, since the csv module does its own (:term:" "`universal `) newline handling." msgstr "" +"``newline=''`` を指定しないと、クォートされたフィールド内の改行を正しく解釈で" +"きません。\n" +"また、書き込み時の改行に ``\\r\\n`` を使うプラットフォームでは、余分な " +"``\\r`` が追加されます。\n" +"csv モジュール自身が (:term:`ユニバーサル `) 改行処理を行" +"うので、``newline=''`` は常に指定して差し支えありません。" #: ../../library/csv.rst:9 msgid "csv" diff --git a/library/ctypes.po b/library/ctypes.po index 6fc3dfa7d..10d37dba5 100644 --- a/library/ctypes.po +++ b/library/ctypes.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/ctypes.rst:2 @@ -31,22 +31,27 @@ msgstr ":mod:`!ctypes` --- Python 用の外部関数ライブラリ" msgid "**Source code:** :source:`Lib/ctypes`" msgstr "**ソースコード:** :source:`Lib/ctypes`" -#: ../../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` は Python 用の外部関数ライブラリです。\n" +"C と互換性のあるデータ型を提供し、DLL や共有ライブラリの関数を呼び出せま" +"す。\n" +"これらのライブラリを純粋な Python でラップするために使えます。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" -#: ../../library/ctypes.rst:19 msgid "" ":mod:`!ctypes` provides low-level access to native libraries and the " "process's memory, bypassing Python's safety mechanisms and allowing " @@ -54,6 +59,11 @@ msgid "" "objects, reveal sensitive information, cause crashes, or otherwise " "compromise the running process." msgstr "" +":mod:`!ctypes` は、Python の安全機構を迂回してネイティブライブラリやプロセス" +"のメモリに低水準でアクセスし、任意のネイティブコードを実行できるようにしま" +"す。\n" +"使い方を誤ると、データやオブジェクトの破損、機密情報の漏えい、クラッシュな" +"ど、実行中のプロセスの安全性を損なう事態を引き起こす可能性があります。" #: ../../library/ctypes.rst:29 msgid "ctypes tutorial" @@ -76,14 +86,16 @@ msgstr "" msgid "Loading dynamic link libraries" msgstr "動的リンクライブラリをロードする" -#: ../../library/ctypes.rst:41 msgid "" ":mod:`!ctypes` exports the :py:data:`~ctypes.cdll`, and on Windows :py:data:" "`~ctypes.windll` and :py:data:`~ctypes.oledll` objects, for loading dynamic " "link libraries." msgstr "" +":mod:`!ctypes` は、動的リンクライブラリをロードするための :py:data:`~ctypes." +"cdll` オブジェクトをエクスポートします。\n" +"Windows では :py:data:`~ctypes.windll` と :py:data:`~ctypes.oledll` オブジェ" +"クトもエクスポートします。" -#: ../../library/ctypes.rst:45 msgid "" "You load libraries by accessing them as attributes of these objects. :py:" "data:`!cdll` loads libraries which export functions using the standard " @@ -94,6 +106,14 @@ msgid "" "automatically raise an :class:`OSError` exception when the function call " "fails." msgstr "" +"これらのオブジェクトの属性にアクセスすると、ライブラリをロードできます。\n" +":py:data:`!cdll` は標準の ``cdecl`` 呼び出し規約で関数をエクスポートするライ" +"ブラリをロードし、:py:data:`!windll` のライブラリは ``stdcall`` 呼び出し規約" +"で関数を呼び出します。\n" +":py:data:`~oledll` も ``stdcall`` 呼び出し規約を使用し、関数が Windows の :c:" +"type:`!HRESULT` エラーコードを返すと仮定します。\n" +"関数呼び出しが失敗した場合は、このエラーコードを使って :class:`OSError` 例外" +"を自動的に送出します。" #: ../../library/ctypes.rst:55 msgid "" @@ -103,14 +123,15 @@ msgstr "" "Windows エラーは以前は :exc:`WindowsError` を送出していましたが、これは現在で" "は :exc:`OSError` の別名になっています。" -#: ../../library/ctypes.rst:60 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 "" +"Windows での例を示します。\n" +"``msvcrt`` は、標準 C 関数の大半を含む MS 標準 C ライブラリで、``cdecl`` 呼び" +"出し規約を使用します。 ::" -#: ../../library/ctypes.rst:64 msgid "" ">>> from ctypes import *\n" ">>> print(windll.kernel32)\n" @@ -120,6 +141,13 @@ msgid "" ">>> libc = cdll.msvcrt\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> print(windll.kernel32)\n" +"\n" +">>> print(cdll.msvcrt)\n" +"\n" +">>> libc = cdll.msvcrt\n" +">>>" #: ../../library/ctypes.rst:72 msgid "Windows appends the usual ``.dll`` file suffix automatically." @@ -137,7 +165,6 @@ msgstr "" "れます。可能な場合には、ネイティブ Python の機能を使用するか、``msvcrt`` モ" "ジュールをインポートして使用してください。" -#: ../../library/ctypes.rst:80 msgid "" "Other systems require the filename *including* the extension to load a " "library, so attribute access can not be used to load libraries. Either the :" @@ -145,12 +172,15 @@ msgid "" "or you should load the library by creating an instance of :py:class:`CDLL` " "by calling the constructor." msgstr "" +"ほかのシステムでは、ライブラリのロードに拡張子を *含む* ファイル名が必要なた" +"め、属性へのアクセスではロードできません。\n" +"DLL ローダーの :meth:`~LibraryLoader.LoadLibrary` メソッドを使うか、コンスト" +"ラクタを呼び出して :py:class:`CDLL` インスタンスを作成し、ライブラリをロード" +"してください。" -#: ../../library/ctypes.rst:86 msgid "For example, on Linux::" -msgstr "" +msgstr "例えば、Linux では次のようにします。 ::" -#: ../../library/ctypes.rst:88 msgid "" ">>> cdll.LoadLibrary(\"libc.so.6\")\n" "\n" @@ -159,12 +189,16 @@ msgid "" "\n" ">>>" msgstr "" +">>> cdll.LoadLibrary(\"libc.so.6\")\n" +"\n" +">>> libc = CDLL(\"libc.so.6\")\n" +">>> libc\n" +"\n" +">>>" -#: ../../library/ctypes.rst:95 msgid "On macOS::" -msgstr "" +msgstr "macOS では次のようにします。 ::" -#: ../../library/ctypes.rst:97 msgid "" ">>> cdll.LoadLibrary(\"libc.dylib\")\n" "\n" @@ -172,6 +206,11 @@ msgid "" ">>> libc\n" "" msgstr "" +">>> cdll.LoadLibrary(\"libc.dylib\")\n" +"\n" +">>> libc = CDLL(\"libc.dylib\")\n" +">>> libc\n" +"" #: ../../library/ctypes.rst:108 msgid "Accessing functions from loaded dlls" @@ -181,7 +220,6 @@ msgstr "ロードしたdllから関数にアクセスする" msgid "Functions are accessed as attributes of dll objects::" msgstr "dll オブジェクトの属性として関数にアクセスします::" -#: ../../library/ctypes.rst:112 msgid "" ">>> libc.printf\n" "<_FuncPtr object at 0x...>\n" @@ -195,8 +233,18 @@ msgid "" "AttributeError: function 'MyOwnFunction' not found\n" ">>>" msgstr "" +">>> libc.printf\n" +"<_FuncPtr object at 0x...>\n" +">>> print(windll.kernel32.GetModuleHandleA)\n" +"<_FuncPtr object at 0x...>\n" +">>> print(windll.kernel32.MyOwnFunction)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"ctypes.py\", line 239, in __getattr__\n" +" func = _StdcallFuncPtr(name, self)\n" +"AttributeError: function 'MyOwnFunction' not found\n" +">>>" -#: ../../library/ctypes.rst:124 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 " @@ -206,14 +254,25 @@ msgid "" "following C prototype, and a macro is used to expose one of them as " "``GetModuleHandle`` depending on whether UNICODE is defined or not::" msgstr "" +"``kernel32`` や ``user32`` などの win32 システム DLL は、関数の ANSI 版と " +"UNICODE 版を両方エクスポートすることがよくあります。\n" +"UNICODE 版は名前の末尾に ``W``、ANSI 版は ``A`` を付けてエクスポートされま" +"す。\n" +"指定したモジュール名の *モジュールハンドル* を返す win32 の " +"``GetModuleHandle`` 関数には、以下の C プロトタイプがあります。\n" +"UNICODE が定義されているかどうかに応じて、マクロが一方を ``GetModuleHandle`` " +"として公開します。 ::" -#: ../../library/ctypes.rst:132 msgid "" "/* ANSI version */\n" "HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n" "/* UNICODE version */\n" "HMODULE GetModuleHandleW(LPCWSTR lpModuleName);" msgstr "" +"/* ANSI 版 */\n" +"HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n" +"/* UNICODE 版 */\n" +"HMODULE GetModuleHandleW(LPCWSTR lpModuleName);" #: ../../library/ctypes.rst:137 msgid "" @@ -236,12 +295,14 @@ msgstr "" "ない名前でエクスポートすることがあります。このような場合に関数を取り出すに" "は、 :func:`getattr` を使わなければなりません。::" -#: ../../library/ctypes.rst:145 msgid "" ">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" "<_FuncPtr object at 0x...>\n" ">>>" msgstr "" +">>> getattr(cdll.msvcrt, \"??2@YAPAXI@Z\")\n" +"<_FuncPtr object at 0x...>\n" +">>>" #: ../../library/ctypes.rst:149 msgid "" @@ -253,7 +314,6 @@ msgstr "" "こうした関数には序数を使って dll オブジェクトにインデックス指定することでアク" "セスします::" -#: ../../library/ctypes.rst:152 msgid "" ">>> cdll.kernel32[1]\n" "<_FuncPtr object at 0x...>\n" @@ -265,37 +325,53 @@ msgid "" "AttributeError: function ordinal 0 not found\n" ">>>" msgstr "" +">>> cdll.kernel32[1]\n" +"<_FuncPtr object at 0x...>\n" +">>> cdll.kernel32[0]\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"ctypes.py\", line 310, in __getitem__\n" +" func = _StdcallFuncPtr(name, self)\n" +"AttributeError: function ordinal 0 not found\n" +">>>" #: ../../library/ctypes.rst:166 msgid "Calling functions" msgstr "関数を呼び出す" -#: ../../library/ctypes.rst:168 msgid "" "You can call these functions like any other Python callable. This example " "uses the ``rand()`` function, which takes no arguments and returns a pseudo-" "random integer::" msgstr "" +"これらの関数は、ほかの Python の呼び出し可能オブジェクトと同じように呼び出せ" +"ます。\n" +"この例では、引数を取らず疑似乱数の整数を返す ``rand()`` 関数を使います。 ::" -#: ../../library/ctypes.rst:171 msgid "" ">>> print(libc.rand())\n" "1804289383" msgstr "" +">>> print(libc.rand())\n" +"1804289383" -#: ../../library/ctypes.rst:174 msgid "" "On Windows, you can call the ``GetModuleHandleA()`` function, which returns " "a win32 module handle (passing ``None`` as single argument to call it with a " "``NULL`` pointer)::" msgstr "" +"Windows では、win32 モジュールハンドルを返す ``GetModuleHandleA()`` 関数を呼" +"び出せます (唯一の引数に ``None`` を渡すと、``NULL`` ポインタを渡して呼び出せ" +"ます)。 ::" -#: ../../library/ctypes.rst:177 msgid "" ">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" "0x1d000000\n" ">>>" msgstr "" +">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n" +"0x1d000000\n" +">>>" #: ../../library/ctypes.rst:181 msgid "" @@ -330,14 +406,14 @@ msgstr "" "正しい呼び出し規約を知るためには、呼び出したい関数についての C ヘッダファイル" "もしくはドキュメントを見なければなりません。" -#: ../../library/ctypes.rst:199 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 "" +"Windows では、:mod:`!ctypes` は win32 の構造化例外処理を使い、無効な引数の値" +"で関数を呼び出した際の一般保護違反によるクラッシュを防ぎます。 ::" -#: ../../library/ctypes.rst:203 msgid "" ">>> windll.kernel32.GetModuleHandleA(32)\n" "Traceback (most recent call last):\n" @@ -345,14 +421,19 @@ msgid "" "OSError: exception: access violation reading 0x00000020\n" ">>>" msgstr "" +">>> windll.kernel32.GetModuleHandleA(32)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"OSError: exception: access violation reading 0x00000020\n" +">>>" -#: ../../library/ctypes.rst:209 msgid "" "The :mod:`faulthandler` module can help debug crashes, such as segmentation " "faults produced by erroneous C library calls." msgstr "" +":mod:`faulthandler` モジュールは、C ライブラリの誤った呼び出しによるセグメン" +"テーション違反などのクラッシュのデバッグに役立ちます。" -#: ../../library/ctypes.rst:212 msgid "" "``None``, integers, bytes objects and (unicode) strings are the only native " "Python objects that can directly be used as parameters in these function " @@ -362,20 +443,28 @@ msgid "" "platform's default C :c:expr:`int` type, their value is masked to fit into " "the C type." msgstr "" +"これらの関数呼び出しに引数として直接渡せる Python 標準のオブジェクトは、" +"``None``、整数、バイト列オブジェクト、(Unicode) 文字列だけです。\n" +"``None`` は C の ``NULL`` ポインタとして渡され、バイト列オブジェクトと文字列" +"は、データを格納するメモリブロックへのポインタ (:c:expr:`char *` または :c:" +"expr:`wchar_t *`) として渡されます。\n" +"Python の整数は、プラットフォームのデフォルトの C :c:expr:`int` 型として渡さ" +"れ、その C 型に収まるよう値がマスクされます。" -#: ../../library/ctypes.rst:219 msgid "" "Before we move on calling functions with other parameter types, we have to " "learn more about :mod:`!ctypes` data types." msgstr "" +"ほかの型の引数を使って関数を呼び出す前に、:mod:`!ctypes` のデータ型を詳しく見" +"ておく必要があります。" #: ../../library/ctypes.rst:226 ../../library/ctypes.rst:2569 msgid "Fundamental data types" msgstr "基本データ型" -#: ../../library/ctypes.rst:228 msgid ":mod:`!ctypes` defines a number of primitive C compatible data types:" msgstr "" +":mod:`!ctypes` は、C と互換性のある基本データ型をいくつも定義しています:" #: ../../library/ctypes.rst:233 ../../library/ctypes.rst:372 msgid "ctypes type" @@ -389,9 +478,8 @@ msgstr "C の型" msgid "Python type" msgstr "Python の型" -#: ../../library/ctypes.rst:236 ../../library/ctypes.rst:375 msgid ":py:attr:`~_SimpleCData._type_`" -msgstr "" +msgstr ":py:attr:`~_SimpleCData._type_`" #: ../../library/ctypes.rst:237 msgid ":class:`c_bool`" @@ -401,13 +489,11 @@ msgstr ":class:`c_bool`" msgid ":c:expr:`_Bool`" msgstr ":c:expr:`_Bool`" -#: ../../library/ctypes.rst:239 ../../library/ctypes.rst:363 msgid ":py:class:`bool`" -msgstr "" +msgstr ":py:class:`bool`" -#: ../../library/ctypes.rst:240 msgid "``'?'``" -msgstr "" +msgstr "``'?'``" #: ../../library/ctypes.rst:241 msgid ":class:`c_char`" @@ -417,9 +503,8 @@ msgstr ":class:`c_char`" msgid ":c:expr:`char`" msgstr ":c:expr:`char`" -#: ../../library/ctypes.rst:243 msgid "1-character :py:class:`bytes`" -msgstr "" +msgstr "1 文字の :py:class:`bytes`" #: ../../library/ctypes.rst:244 msgid "``'c'``" @@ -433,9 +518,8 @@ msgstr ":class:`c_wchar`" msgid ":c:type:`wchar_t`" msgstr ":c:type:`wchar_t`" -#: ../../library/ctypes.rst:247 msgid "1-character :py:class:`str`" -msgstr "" +msgstr "1 文字の :py:class:`str`" #: ../../library/ctypes.rst:248 msgid "``'u'``" @@ -445,19 +529,8 @@ msgstr "``'u'``" msgid ":class:`c_byte`" msgstr ":class:`c_byte`" -#: ../../library/ctypes.rst:251 ../../library/ctypes.rst:255 -#: ../../library/ctypes.rst:259 ../../library/ctypes.rst:263 -#: ../../library/ctypes.rst:267 ../../library/ctypes.rst:271 -#: ../../library/ctypes.rst:275 ../../library/ctypes.rst:279 -#: ../../library/ctypes.rst:283 ../../library/ctypes.rst:287 -#: ../../library/ctypes.rst:291 ../../library/ctypes.rst:295 -#: ../../library/ctypes.rst:299 ../../library/ctypes.rst:303 -#: ../../library/ctypes.rst:307 ../../library/ctypes.rst:311 -#: ../../library/ctypes.rst:315 ../../library/ctypes.rst:319 -#: ../../library/ctypes.rst:323 ../../library/ctypes.rst:327 -#: ../../library/ctypes.rst:331 msgid ":py:class:`int`" -msgstr "" +msgstr ":py:class:`int`" #: ../../library/ctypes.rst:252 msgid "``'b'``" @@ -507,50 +580,35 @@ msgstr ":class:`c_int`" msgid ":c:expr:`int`" msgstr ":c:expr:`int`" -#: ../../library/ctypes.rst:268 msgid "``'i'`` \\*" -msgstr "" +msgstr "``'i'`` \\*" -#: ../../library/ctypes.rst:269 msgid ":class:`c_int8`" -msgstr "" +msgstr ":class:`c_int8`" -#: ../../library/ctypes.rst:270 msgid ":c:type:`int8_t`" -msgstr "" +msgstr ":c:type:`int8_t`" -#: ../../library/ctypes.rst:272 ../../library/ctypes.rst:276 -#: ../../library/ctypes.rst:280 ../../library/ctypes.rst:284 -#: ../../library/ctypes.rst:292 ../../library/ctypes.rst:296 -#: ../../library/ctypes.rst:300 ../../library/ctypes.rst:304 -#: ../../library/ctypes.rst:324 ../../library/ctypes.rst:328 -#: ../../library/ctypes.rst:332 msgid "\\*" -msgstr "" +msgstr "\\*" -#: ../../library/ctypes.rst:273 msgid ":class:`c_int16`" -msgstr "" +msgstr ":class:`c_int16`" -#: ../../library/ctypes.rst:274 msgid ":c:type:`int16_t`" -msgstr "" +msgstr ":c:type:`int16_t`" -#: ../../library/ctypes.rst:277 msgid ":class:`c_int32`" -msgstr "" +msgstr ":class:`c_int32`" -#: ../../library/ctypes.rst:278 msgid ":c:type:`int32_t`" -msgstr "" +msgstr ":c:type:`int32_t`" -#: ../../library/ctypes.rst:281 msgid ":class:`c_int64`" -msgstr "" +msgstr ":class:`c_int64`" -#: ../../library/ctypes.rst:282 msgid ":c:type:`int64_t`" -msgstr "" +msgstr ":c:type:`int64_t`" #: ../../library/ctypes.rst:285 msgid ":class:`c_uint`" @@ -560,41 +618,32 @@ msgstr ":class:`c_uint`" msgid ":c:expr:`unsigned int`" msgstr ":c:expr:`unsigned int`" -#: ../../library/ctypes.rst:288 msgid "``'I'`` \\*" -msgstr "" +msgstr "``'I'`` \\*" -#: ../../library/ctypes.rst:289 msgid ":class:`c_uint8`" -msgstr "" +msgstr ":class:`c_uint8`" -#: ../../library/ctypes.rst:290 msgid ":c:type:`uint8_t`" -msgstr "" +msgstr ":c:type:`uint8_t`" -#: ../../library/ctypes.rst:293 msgid ":class:`c_uint16`" -msgstr "" +msgstr ":class:`c_uint16`" -#: ../../library/ctypes.rst:294 msgid ":c:type:`uint16_t`" -msgstr "" +msgstr ":c:type:`uint16_t`" -#: ../../library/ctypes.rst:297 msgid ":class:`c_uint32`" -msgstr "" +msgstr ":class:`c_uint32`" -#: ../../library/ctypes.rst:298 msgid ":c:type:`uint32_t`" -msgstr "" +msgstr ":c:type:`uint32_t`" -#: ../../library/ctypes.rst:301 msgid ":class:`c_uint64`" -msgstr "" +msgstr ":class:`c_uint64`" -#: ../../library/ctypes.rst:302 msgid ":c:type:`uint64_t`" -msgstr "" +msgstr ":c:type:`uint64_t`" #: ../../library/ctypes.rst:305 msgid ":class:`c_long`" @@ -624,25 +673,21 @@ msgstr "``'L'``" msgid ":class:`c_longlong`" msgstr ":class:`c_longlong`" -#: ../../library/ctypes.rst:314 msgid ":c:expr:`long long`" -msgstr "" +msgstr ":c:expr:`long long`" -#: ../../library/ctypes.rst:316 msgid "``'q'`` \\*" -msgstr "" +msgstr "``'q'`` \\*" #: ../../library/ctypes.rst:317 msgid ":class:`c_ulonglong`" msgstr ":class:`c_ulonglong`" -#: ../../library/ctypes.rst:318 msgid ":c:expr:`unsigned long long`" -msgstr "" +msgstr ":c:expr:`unsigned long long`" -#: ../../library/ctypes.rst:320 msgid "``'Q'`` \\*" -msgstr "" +msgstr "``'Q'`` \\*" #: ../../library/ctypes.rst:321 msgid ":class:`c_size_t`" @@ -660,13 +705,11 @@ msgstr ":class:`c_ssize_t`" msgid ":c:type:`Py_ssize_t`" msgstr ":c:type:`Py_ssize_t`" -#: ../../library/ctypes.rst:329 msgid ":class:`c_time_t`" -msgstr "" +msgstr ":class:`c_time_t`" -#: ../../library/ctypes.rst:330 msgid ":c:type:`time_t`" -msgstr "" +msgstr ":c:type:`time_t`" #: ../../library/ctypes.rst:333 msgid ":class:`c_float`" @@ -676,10 +719,8 @@ msgstr ":class:`c_float`" msgid ":c:expr:`float`" msgstr ":c:expr:`float`" -#: ../../library/ctypes.rst:335 ../../library/ctypes.rst:339 -#: ../../library/ctypes.rst:343 msgid ":py:class:`float`" -msgstr "" +msgstr ":py:class:`float`" #: ../../library/ctypes.rst:336 msgid "``'f'``" @@ -705,9 +746,8 @@ msgstr ":class:`c_longdouble`" msgid ":c:expr:`long double`" msgstr ":c:expr:`long double`" -#: ../../library/ctypes.rst:344 msgid "``'g'`` \\*" -msgstr "" +msgstr "``'g'`` \\*" #: ../../library/ctypes.rst:345 msgid ":class:`c_char_p`" @@ -717,9 +757,8 @@ msgstr ":class:`c_char_p`" msgid ":c:expr:`char *` (NUL terminated)" msgstr ":c:expr:`char *` (NUL 終端)" -#: ../../library/ctypes.rst:347 msgid ":py:class:`bytes` or ``None``" -msgstr "" +msgstr ":py:class:`bytes` または ``None``" #: ../../library/ctypes.rst:348 msgid "``'z'``" @@ -733,9 +772,8 @@ msgstr ":class:`c_wchar_p`" msgid ":c:expr:`wchar_t *` (NUL terminated)" msgstr ":c:expr:`wchar_t *` (NUL 終端)" -#: ../../library/ctypes.rst:351 msgid ":py:class:`str` or ``None``" -msgstr "" +msgstr ":py:class:`str` または ``None``" #: ../../library/ctypes.rst:352 msgid "``'Z'``" @@ -749,95 +787,78 @@ msgstr ":class:`c_void_p`" msgid ":c:expr:`void *`" msgstr ":c:expr:`void *`" -#: ../../library/ctypes.rst:355 msgid ":py:class:`int` or ``None``" -msgstr "" +msgstr ":py:class:`int` または ``None``" -#: ../../library/ctypes.rst:356 msgid "``'P'``" -msgstr "" +msgstr "``'P'``" -#: ../../library/ctypes.rst:357 msgid ":class:`py_object`" -msgstr "" +msgstr ":class:`py_object`" -#: ../../library/ctypes.rst:358 msgid ":c:expr:`PyObject *`" -msgstr "" +msgstr ":c:expr:`PyObject *`" -#: ../../library/ctypes.rst:359 msgid ":py:class:`object`" -msgstr "" +msgstr ":py:class:`object`" #: ../../library/ctypes.rst:360 msgid "``'O'``" msgstr "``'O'``" -#: ../../library/ctypes.rst:361 msgid ":ref:`VARIANT_BOOL `" -msgstr "" +msgstr ":ref:`VARIANT_BOOL `" -#: ../../library/ctypes.rst:362 msgid ":c:expr:`short int`" -msgstr "" +msgstr ":c:expr:`short int`" -#: ../../library/ctypes.rst:364 msgid "``'v'``" -msgstr "" +msgstr "``'v'``" -#: ../../library/ctypes.rst:366 msgid "" "Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is " "supported in both C and ``libffi``, the following complex types are " "available:" msgstr "" +"さらに、C と ``libffi`` の両方が IEC 60559 に準拠した複素数演算 (附属書 G) を" +"サポートする場合、以下の複素数型を利用できます:" -#: ../../library/ctypes.rst:376 msgid ":class:`c_float_complex`" -msgstr "" +msgstr ":class:`c_float_complex`" -#: ../../library/ctypes.rst:377 msgid ":c:expr:`float complex`" -msgstr "" +msgstr ":c:expr:`float complex`" -#: ../../library/ctypes.rst:378 ../../library/ctypes.rst:382 -#: ../../library/ctypes.rst:386 msgid ":py:class:`complex`" -msgstr "" +msgstr ":py:class:`complex`" -#: ../../library/ctypes.rst:379 msgid "``'Zf'``" -msgstr "" +msgstr "``'Zf'``" -#: ../../library/ctypes.rst:380 msgid ":class:`c_double_complex`" -msgstr "" +msgstr ":class:`c_double_complex`" -#: ../../library/ctypes.rst:381 msgid ":c:expr:`double complex`" -msgstr "" +msgstr ":c:expr:`double complex`" -#: ../../library/ctypes.rst:383 msgid "``'Zd'``" -msgstr "" +msgstr "``'Zd'``" -#: ../../library/ctypes.rst:384 msgid ":class:`c_longdouble_complex`" -msgstr "" +msgstr ":class:`c_longdouble_complex`" -#: ../../library/ctypes.rst:385 msgid ":c:expr:`long double complex`" -msgstr "" +msgstr ":c:expr:`long double complex`" -#: ../../library/ctypes.rst:387 msgid "``'Zg'``" -msgstr "" +msgstr "``'Zg'``" -#: ../../library/ctypes.rst:389 msgid "" "The :py:attr:`~_SimpleCData._type_` types ``F``, ``D`` and ``G`` have been " "replaced with ``Zf``, ``Zd`` and ``Zg``." msgstr "" +":py:attr:`~_SimpleCData._type_` の型 ``F``、``D``、``G`` は、``Zf``、``Zd``、" +"``Zg`` に置き換えられました。" #: ../../library/ctypes.rst:394 msgid "" @@ -847,7 +868,6 @@ msgstr "" "これら全ての型はその型を呼び出すことによって作成でき、オプションとして型と値" "が合っている初期化子を指定することができます::" -#: ../../library/ctypes.rst:397 msgid "" ">>> c_int()\n" "c_long(0)\n" @@ -857,28 +877,40 @@ msgid "" "c_ushort(65533)\n" ">>>" msgstr "" +">>> c_int()\n" +"c_long(0)\n" +">>> c_wchar_p(\"Hello, World\")\n" +"c_wchar_p(140018365411392)\n" +">>> c_ushort(-3)\n" +"c_ushort(65533)\n" +">>>" -#: ../../library/ctypes.rst:405 msgid "" "The constructors for numeric types will convert input using :py:meth:" "`~object.__bool__`, :py:meth:`~object.__index__` (for ``int``), :py:meth:" "`~object.__float__` or :py:meth:`~object.__complex__`. This means :py:class:" "`~ctypes.c_bool` accepts any object with a truth value::" msgstr "" +"数値型のコンストラクタは、:py:meth:`~object.__bool__`、:py:meth:`~object." +"__index__` (``int`` の場合)、:py:meth:`~object.__float__`、:py:meth:`~object." +"__complex__` を使って入力を変換します。\n" +"したがって、:py:class:`~ctypes.c_bool` は真偽値を持つ任意のオブジェクトを受け" +"付けます。 ::" -#: ../../library/ctypes.rst:411 msgid "" ">>> empty_list = []\n" ">>> c_bool(empty_list)\n" "c_bool(False)" msgstr "" +">>> empty_list = []\n" +">>> c_bool(empty_list)\n" +"c_bool(False)" #: ../../library/ctypes.rst:415 msgid "" "Since these types are mutable, their value can also be changed afterwards::" msgstr "これらの型は変更可能であり、値を後で変更することもできます::" -#: ../../library/ctypes.rst:417 msgid "" ">>> i = c_int(42)\n" ">>> print(i)\n" @@ -890,14 +922,26 @@ msgid "" "-99\n" ">>>" msgstr "" +">>> i = c_int(42)\n" +">>> print(i)\n" +"c_long(42)\n" +">>> print(i.value)\n" +"42\n" +">>> i.value = -99\n" +">>> print(i.value)\n" +"-99\n" +">>>" -#: ../../library/ctypes.rst:427 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 string objects are immutable)::" msgstr "" +"ポインタ型 :class:`c_char_p`、:class:`c_wchar_p`、:class:`c_void_p` のインス" +"タンスに新しい値を代入すると、そのポインタが指す *メモリ位置* が変わり、メモ" +"リブロックの *内容は変わりません* (Python の文字列オブジェクトは不変なので、" +"当然の動作です)。 ::" #: ../../library/ctypes.rst:432 msgid "" @@ -933,7 +977,6 @@ msgstr "" "ス (あるいは変更) することができます。もし現在のメモリブロックに NUL 終端文字" "列としてアクセスしたいなら、 ``value`` プロパティを使ってください::" -#: ../../library/ctypes.rst:454 msgid "" ">>> from ctypes import *\n" ">>> p = create_string_buffer(3) # create a 3 byte buffer, " @@ -954,14 +997,36 @@ msgid "" "10 b'Hi\\x00lo\\x00\\x00\\x00\\x00\\x00'\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> p = create_string_buffer(3) # NUL バイトで初期化した 3 バイト" +"のバッファを作成します\n" +">>> print(sizeof(p), repr(p.raw))\n" +"3 b'\\x00\\x00\\x00'\n" +">>> p = create_string_buffer(b\"Hello\") # NUL 終端文字列を含むバッファを" +"作成します\n" +">>> print(sizeof(p), repr(p.raw))\n" +"6 b'Hello\\x00'\n" +">>> print(repr(p.value))\n" +"b'Hello'\n" +">>> p = create_string_buffer(b\"Hello\", 10) # 10 バイトのバッファを作成しま" +"す\n" +">>> print(sizeof(p), repr(p.raw))\n" +"10 b'Hello\\x00\\x00\\x00\\x00\\x00'\n" +">>> p.value = b\"Hi\"\n" +">>> print(sizeof(p), repr(p.raw))\n" +"10 b'Hi\\x00lo\\x00\\x00\\x00\\x00\\x00'\n" +">>>" -#: ../../library/ctypes.rst:471 msgid "" "The :func:`create_string_buffer` function replaces the old :func:`!c_buffer` " "function (which is still available as an alias). 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 "" +":func:`create_string_buffer` 関数は、古い :func:`!c_buffer` 関数を置き換える" +"ものです (後者は別名として引き続き利用できます)。\n" +"C の :c:type:`wchar_t` 型の Unicode 文字を格納する変更可能なメモリブロックを" +"作成するには、:func:`create_unicode_buffer` 関数を使ってください。" #: ../../library/ctypes.rst:480 msgid "Calling functions, continued" @@ -977,7 +1042,6 @@ msgstr "" "することに注意してください。したがって、これらの例はコンソールプロンプトでの" "み動作し、 *IDLE* や *PythonWin* では動作しません。::" -#: ../../library/ctypes.rst:486 msgid "" ">>> printf = libc.printf\n" ">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" @@ -996,27 +1060,46 @@ msgid "" "parameter 2\n" ">>>" msgstr "" +">>> printf = libc.printf\n" +">>> printf(b\"Hello, %s\\n\", b\"World!\")\n" +"Hello, World!\n" +"14\n" +">>> printf(b\"Hello, %S\\n\", \"World!\")\n" +"Hello, World!\n" +"14\n" +">>> printf(b\"%d bottles of beer\\n\", 42)\n" +"42 bottles of beer\n" +"19\n" +">>> printf(b\"%f bottles of beer\\n\", 42.5)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert " +"parameter 2\n" +">>>" -#: ../../library/ctypes.rst:502 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 "" +"前述のとおり、整数、文字列、バイト列オブジェクト以外の Python の型は、必要な " +"C のデータ型に変換できるよう、対応する :mod:`!ctypes` の型でラップする必要が" +"あります。 ::" -#: ../../library/ctypes.rst:506 msgid "" ">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" "An int 1234, a double 3.140000\n" "31\n" ">>>" msgstr "" +">>> printf(b\"An int %d, a double %f\\n\", 1234, c_double(3.14))\n" +"An int 1234, a double 3.140000\n" +"31\n" +">>>" -#: ../../library/ctypes.rst:514 msgid "Calling variadic functions" -msgstr "" +msgstr "可変長引数関数の呼び出し" -#: ../../library/ctypes.rst:516 msgid "" "On a lot of platforms calling variadic functions through ctypes is exactly " "the same as calling functions with a fixed number of parameters. On some " @@ -1024,28 +1107,32 @@ msgid "" "convention for variadic functions is different than that for regular " "functions." msgstr "" +"多くのプラットフォームでは、ctypes を使った可変長引数関数の呼び出し方は、引数" +"の数が固定の関数とまったく同じです。\n" +"一部のプラットフォーム、特に Apple プラットフォームの ARM64 では、可変長引数" +"関数の呼び出し規約が通常の関数とは異なります。" -#: ../../library/ctypes.rst:521 msgid "" "On those platforms it is required to specify the :attr:`~_CFuncPtr.argtypes` " "attribute for the regular, non-variadic, function arguments:" msgstr "" +"それらのプラットフォームでは、可変長ではない通常の引数について :attr:" +"`~_CFuncPtr.argtypes` 属性を指定する必要があります:" -#: ../../library/ctypes.rst:524 msgid "libc.printf.argtypes = [ctypes.c_char_p]" -msgstr "" +msgstr "libc.printf.argtypes = [ctypes.c_char_p]" -#: ../../library/ctypes.rst:528 msgid "" "Because specifying the attribute does not inhibit portability it is advised " "to always specify :attr:`~_CFuncPtr.argtypes` for all variadic functions." msgstr "" +"この属性の指定は移植性を損なわないため、すべての可変長引数関数について常に :" +"attr:`~_CFuncPtr.argtypes` を指定することを推奨します。" #: ../../library/ctypes.rst:535 msgid "Calling functions with your own custom data types" msgstr "自作のデータ型とともに関数を呼び出す" -#: ../../library/ctypes.rst:537 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 " @@ -1053,8 +1140,13 @@ msgid "" "The attribute must be an integer, string, bytes, a :mod:`!ctypes` instance, " "or an object with an :attr:`!_as_parameter_` attribute::" msgstr "" +":mod:`!ctypes` の引数変換をカスタマイズして、自作クラスのインスタンスを関数の" +"引数として使うこともできます。\n" +":mod:`!ctypes` は :attr:`!_as_parameter_` 属性を探し、その値を関数の引数とし" +"て使用します。\n" +"この属性は、整数、文字列、バイト列、:mod:`!ctypes` のインスタンス、または :" +"attr:`!_as_parameter_` 属性を持つオブジェクトでなければなりません。 ::" -#: ../../library/ctypes.rst:543 msgid "" ">>> class Bottles:\n" "... def __init__(self, number):\n" @@ -1066,25 +1158,35 @@ msgid "" "19\n" ">>>" msgstr "" +">>> class Bottles:\n" +"... def __init__(self, number):\n" +"... self._as_parameter_ = number\n" +"...\n" +">>> bottles = Bottles(42)\n" +">>> printf(b\"%d bottles of beer\\n\", bottles)\n" +"42 bottles of beer\n" +"19\n" +">>>" -#: ../../library/ctypes.rst:553 msgid "" "If you don't want to store the instance's data in the :attr:`!" "_as_parameter_` instance variable, you could define a :deco:`property` which " "makes the attribute available on request." msgstr "" +"インスタンスのデータを :attr:`!_as_parameter_` インスタンス変数に保存したくな" +"い場合は、アクセス時に属性値を提供する :deco:`property` を定義できます。" #: ../../library/ctypes.rst:561 msgid "Specifying the required argument types (function prototypes)" msgstr "要求される引数の型を指定する (関数プロトタイプ)" -#: ../../library/ctypes.rst:563 msgid "" "It is possible to specify the required argument types of functions exported " "from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute." msgstr "" +"DLL がエクスポートする関数の引数に必要な型は、:attr:`~_CFuncPtr.argtypes` 属" +"性を設定して指定できます。" -#: ../../library/ctypes.rst:566 msgid "" ":attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!" "printf` function is probably not a good example here, because it takes a " @@ -1092,8 +1194,10 @@ msgid "" "string, on the other hand this is quite handy to experiment with this " "feature)::" msgstr "" +":attr:`~_CFuncPtr.argtypes` は C のデータ型のシーケンスでなければなりません " +"(:func:`!printf` 関数は、書式文字列に応じて引数の数や型が変わるので、ここでは" +"良い例とはいえませんが、この機能を試すには便利です)。 ::" -#: ../../library/ctypes.rst:571 msgid "" ">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" ">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" @@ -1101,6 +1205,11 @@ msgid "" "37\n" ">>>" msgstr "" +">>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]\n" +">>> printf(b\"String '%s', Int %d, Double %f\\n\", b\"Hi\", 10, 2.2)\n" +"String 'Hi', Int 10, Double 2.200000\n" +"37\n" +">>>" #: ../../library/ctypes.rst:577 msgid "" @@ -1111,7 +1220,6 @@ msgstr "" "(C の関数のプロトタイプのように) 書式を指定すると互換性のない引数型になるのを" "防ぎ、引数を有効な型へ変換しようとします。::" -#: ../../library/ctypes.rst:580 msgid "" ">>> printf(b\"%d %d %d\", 1, 2, 3)\n" "Traceback (most recent call last):\n" @@ -1123,8 +1231,16 @@ msgid "" "13\n" ">>>" msgstr "" +">>> printf(b\"%d %d %d\", 1, 2, 3)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be " +"interpreted as ctypes.c_char_p\n" +">>> printf(b\"%s %d %f\\n\", b\"X\", 2, 3)\n" +"X 2 3.000000\n" +"13\n" +">>>" -#: ../../library/ctypes.rst:589 msgid "" "If you have defined your own classes which you pass to function calls, you " "have to implement a :meth:`~_CData.from_param` class method for them to be " @@ -1137,56 +1253,69 @@ msgid "" "bytes, a :mod:`!ctypes` instance, or an object with an :attr:`!" "_as_parameter_` attribute." msgstr "" +"関数呼び出しに渡すための独自クラスを定義した場合、そのクラスを :attr:" +"`~_CFuncPtr.argtypes` シーケンスで使うには :meth:`~_CData.from_param` クラス" +"メソッドを実装する必要があります。\n" +":meth:`~_CData.from_param` クラスメソッドは、関数呼び出しに渡された Python オ" +"ブジェクトを受け取ります。\n" +"型検査など、オブジェクトを受け付けられることを確認するための処理を行い、オブ" +"ジェクト自身、その :attr:`!_as_parameter_` 属性、または C 関数の引数として渡" +"したい値を返してください。\n" +"この場合も、戻り値は整数、文字列、バイト列、:mod:`!ctypes` のインスタンス、ま" +"たは :attr:`!_as_parameter_` 属性を持つオブジェクトである必要があります。" #: ../../library/ctypes.rst:603 msgid "Return types" msgstr "戻り値の型" -#: ../../library/ctypes.rst:613 msgid "" "By default functions are assumed to return the C :c:expr:`int` type. Other " "return types can be specified by setting the :attr:`~_CFuncPtr.restype` " "attribute of the function object." msgstr "" +"デフォルトでは、関数は C の :c:expr:`int` 型を返すと仮定します。\n" +"関数オブジェクトの :attr:`~_CFuncPtr.restype` 属性を設定すれば、ほかの戻り値" +"の型を指定できます。" -#: ../../library/ctypes.rst:617 msgid "" "The C prototype of :c:func:`time` is ``time_t time(time_t *)``. Because :c:" "type:`time_t` might be of a different type than the default return type :c:" "expr:`int`, you should specify the :attr:`!restype` attribute::" msgstr "" +":c:func:`time` の C プロトタイプは ``time_t time(time_t *)`` です。\n" +":c:type:`time_t` は、デフォルトの戻り値の型 :c:expr:`int` と異なる場合がある" +"ため、:attr:`!restype` 属性を指定する必要があります。 ::" -#: ../../library/ctypes.rst:621 msgid ">>> libc.time.restype = c_time_t" -msgstr "" +msgstr ">>> libc.time.restype = c_time_t" -#: ../../library/ctypes.rst:623 msgid "The argument types can be specified using :attr:`~_CFuncPtr.argtypes`::" -msgstr "" +msgstr "引数の型は :attr:`~_CFuncPtr.argtypes` を使って指定できます。 ::" -#: ../../library/ctypes.rst:625 msgid ">>> libc.time.argtypes = (POINTER(c_time_t),)" -msgstr "" +msgstr ">>> libc.time.argtypes = (POINTER(c_time_t),)" -#: ../../library/ctypes.rst:627 msgid "" "To call the function with a ``NULL`` pointer as first argument, use " "``None``::" msgstr "" +"第 1 引数に ``NULL`` ポインタを渡して関数を呼び出すには、``None`` を使いま" +"す。 ::" -#: ../../library/ctypes.rst:629 msgid "" ">>> print(libc.time(None))\n" "1150640792" msgstr "" +">>> print(libc.time(None))\n" +"1150640792" -#: ../../library/ctypes.rst:632 msgid "" "Here is a more advanced example, it uses the :func:`!strchr` function, which " "expects a string pointer and a char, and returns a pointer to a string::" msgstr "" +"もう少し高度な例として、文字列へのポインタと char を受け取り、文字列へのポイ" +"ンタを返す :func:`!strchr` 関数を使います。 ::" -#: ../../library/ctypes.rst:635 msgid "" ">>> strchr = libc.strchr\n" ">>> strchr(b\"abcdef\", ord(\"d\"))\n" @@ -1198,15 +1327,26 @@ msgid "" "None\n" ">>>" msgstr "" +">>> strchr = libc.strchr\n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" +"8059983\n" +">>> strchr.restype = c_char_p # c_char_p は文字列へのポインタです\n" +">>> strchr(b\"abcdef\", ord(\"d\"))\n" +"b'def'\n" +">>> print(strchr(b\"abcdef\", ord(\"x\")))\n" +"None\n" +">>>" -#: ../../library/ctypes.rst:645 msgid "" "If you want to avoid the :func:`ord(\"x\") ` calls above, you can set " "the :attr:`~_CFuncPtr.argtypes` attribute, and the second argument will be " "converted from a single character Python bytes object into a C char:" msgstr "" +"上の例の :func:`ord(\"x\") ` の呼び出しを省くには、:attr:`~_CFuncPtr." +"argtypes` 属性を設定します。\n" +"これにより、第 2 引数が 1 文字の Python バイト列オブジェクトから C の char に" +"変換されます:" -#: ../../library/ctypes.rst:649 msgid "" ">>> strchr.restype = c_char_p\n" ">>> strchr.argtypes = [c_char_p, c_char]\n" @@ -1222,8 +1362,20 @@ msgid "" "b'def'\n" ">>>" msgstr "" +">>> strchr.restype = c_char_p\n" +">>> strchr.argtypes = [c_char_p, c_char]\n" +">>> strchr(b\"abcdef\", b\"d\")\n" +"b'def'\n" +">>> strchr(b\"abcdef\", b\"def\")\n" +"Traceback (most recent call last):\n" +"ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray " +"or integer expected\n" +">>> print(strchr(b\"abcdef\", b\"x\"))\n" +"None\n" +">>> strchr(b\"abcdef\", b\"d\")\n" +"b'def'\n" +">>>" -#: ../../library/ctypes.rst:664 msgid "" "You can also use a callable Python object (a function or a class for " "example) as the :attr:`~_CFuncPtr.restype` attribute, if the foreign " @@ -1232,8 +1384,12 @@ msgid "" "result of your function call. This is useful to check for error return " "values and automatically raise an exception::" msgstr "" +"外部関数が整数を返す場合、:attr:`~_CFuncPtr.restype` 属性に、関数やクラスなど" +"の Python の呼び出し可能オブジェクトを使うこともできます。\n" +"C 関数が返した *整数* を引数としてそのオブジェクトが呼び出され、その結果が関" +"数呼び出しの結果として使われます。\n" +"これは、戻り値のエラーを検査して例外を自動的に送出するのに役立ちます。 ::" -#: ../../library/ctypes.rst:670 msgid "" ">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" ">>> def ValidHandle(value):\n" @@ -1252,6 +1408,22 @@ msgid "" "OSError: [Errno 126] The specified module could not be found.\n" ">>>" msgstr "" +">>> GetModuleHandle = windll.kernel32.GetModuleHandleA\n" +">>> def ValidHandle(value):\n" +"... if value == 0:\n" +"... raise WinError()\n" +"... return value\n" +"...\n" +">>>\n" +">>> GetModuleHandle.restype = ValidHandle\n" +">>> GetModuleHandle(None)\n" +"486539264\n" +">>> GetModuleHandle(\"something silly\")\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"\", line 3, in ValidHandle\n" +"OSError: [Errno 126] The specified module could not be found.\n" +">>>" #: ../../library/ctypes.rst:687 msgid "" @@ -1265,12 +1437,14 @@ msgstr "" "オプションでエラーコードパラメータを取ります。このパラメータが使われない場合" "は、エラーコードを取り出すために :func:`GetLastError` を呼び出します。" -#: ../../library/ctypes.rst:692 msgid "" "Please note that a much more powerful error checking mechanism is available " "through the :attr:`~_CFuncPtr.errcheck` attribute; see the reference manual " "for details." msgstr "" +":attr:`~_CFuncPtr.errcheck` 属性を使うと、さらに強力なエラー検査の仕組みを利" +"用できます。\n" +"詳細はリファレンスマニュアルを参照してください。" #: ../../library/ctypes.rst:700 msgid "Passing pointers (or: passing parameters by reference)" @@ -1288,7 +1462,6 @@ msgstr "" "タが大きすぎて値渡しできない場合です。これは *パラメータの参照渡し* としても" "知られています。" -#: ../../library/ctypes.rst:706 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:" @@ -1296,8 +1469,13 @@ msgid "" "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` は、引数を参照渡しするための :func:`byref` 関数をエクスポート" +"します。\n" +":func:`pointer` 関数でも同じ効果を得られますが、:func:`pointer` は実際のポイ" +"ンタオブジェクトを構築するため、より多くの処理を行います。\n" +"Python 側でポインタオブジェクト自体が必要なければ、:func:`byref` の方が高速で" +"す。 ::" -#: ../../library/ctypes.rst:712 msgid "" ">>> i = c_int()\n" ">>> f = c_float()\n" @@ -1311,12 +1489,22 @@ msgid "" "1 3.1400001049 b'Hello'\n" ">>>" msgstr "" +">>> i = c_int()\n" +">>> f = c_float()\n" +">>> s = create_string_buffer(b'\\000' * 32)\n" +">>> print(i.value, f.value, repr(s.value))\n" +"0 0.0 b''\n" +">>> libc.sscanf(b\"1 3.14 Hello\", b\"%d %f %s\",\n" +"... byref(i), byref(f), s)\n" +"3\n" +">>> print(i.value, f.value, repr(s.value))\n" +"1 3.1400001049 b'Hello'\n" +">>>" #: ../../library/ctypes.rst:728 msgid "Structures and unions" msgstr "構造体と共用体" -#: ../../library/ctypes.rst:730 msgid "" "Structures and unions must derive from the :class:`Structure` and :class:" "`Union` base classes which are defined in the :mod:`!ctypes` module. Each " @@ -1324,12 +1512,19 @@ msgid "" "_fields_` must be a list of *2-tuples*, containing a *field name* and a " "*field type*." msgstr "" +"構造体と共用体は、:mod:`!ctypes` モジュールが定義する :class:`Structure` と :" +"class:`Union` の基底クラスから派生させる必要があります。\n" +"各サブクラスには :attr:`~Structure._fields_` 属性を定義する必要があります。\n" +":attr:`!_fields_` は、*フィールド名* と *フィールドの型* を含む *2 要素のタプ" +"ル* のリストでなければなりません。" -#: ../../library/ctypes.rst:735 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 "" +"フィールドの型は、:class:`c_int` などの :mod:`!ctypes` の型、または構造体、共" +"用体、配列、ポインタなど、ほかの派生した :mod:`!ctypes` の型でなければなりま" +"せん。" #: ../../library/ctypes.rst:738 msgid "" @@ -1340,7 +1535,6 @@ msgstr "" "以下は、 *x* と *y* という名前の二つの整数からなる簡単な POINT 構造体の例で" "す。コンストラクタで構造体を初期化する方法も説明しています::" -#: ../../library/ctypes.rst:741 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1359,6 +1553,22 @@ msgid "" "TypeError: too many initializers\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = [(\"x\", c_int),\n" +"... (\"y\", c_int)]\n" +"...\n" +">>> point = POINT(10, 20)\n" +">>> print(point.x, point.y)\n" +"10 20\n" +">>> point = POINT(y=5)\n" +">>> print(point.x, point.y)\n" +"0 5\n" +">>> POINT(1, 2, 3)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: too many initializers\n" +">>>" #: ../../library/ctypes.rst:758 msgid "" @@ -1376,7 +1586,6 @@ msgstr "" "*upperleft* と *lowerright* という名前の二つの POINT を持つ RECT 構造体で" "す。::" -#: ../../library/ctypes.rst:764 msgid "" ">>> class RECT(Structure):\n" "... _fields_ = [(\"upperleft\", POINT),\n" @@ -1389,6 +1598,16 @@ msgid "" "0 0\n" ">>>" msgstr "" +">>> class RECT(Structure):\n" +"... _fields_ = [(\"upperleft\", POINT),\n" +"... (\"lowerright\", POINT)]\n" +"...\n" +">>> rc = RECT(point)\n" +">>> print(rc.upperleft.x, rc.upperleft.y)\n" +"0 5\n" +">>> print(rc.lowerright.x, rc.lowerright.y)\n" +"0 0\n" +">>>" #: ../../library/ctypes.rst:775 msgid "" @@ -1398,20 +1617,22 @@ msgstr "" "入れ子になった構造体はいくつかの方法を用いてコンストラクタで初期化することが" "できます。::" -#: ../../library/ctypes.rst:777 msgid "" ">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" ">>> r = RECT((1, 2), (3, 4))" msgstr "" +">>> r = RECT(POINT(1, 2), POINT(3, 4))\n" +">>> r = RECT((1, 2), (3, 4))" -#: ../../library/ctypes.rst:780 msgid "" "Field :term:`descriptor`\\s can be retrieved from the *class*, they are " "useful for debugging because they can provide useful information. See :class:" "`CField`::" msgstr "" +"フィールドの :term:`descriptor` は *クラス* から取得でき、有用な情報を提供す" +"るためデバッグに役立ちます。\n" +":class:`CField` を参照してください。 ::" -#: ../../library/ctypes.rst:784 msgid "" ">>> POINT.x\n" "\n" @@ -1419,26 +1640,39 @@ msgid "" "\n" ">>>" msgstr "" +">>> POINT.x\n" +"\n" +">>> POINT.y\n" +"\n" +">>>" -#: ../../library/ctypes.rst:795 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` は、共用体やビットフィールドを持つ構造体を関数に値渡しすること" +"をサポートしていません。\n" +"32 ビットの x86 では動作することもありますが、一般に動作することはライブラリ" +"では保証していません。\n" +"共用体やビットフィールドを持つ構造体は、常にポインタとして関数に渡してくださ" +"い。" -#: ../../library/ctypes.rst:801 msgid "Structure/union layout, alignment and byte order" -msgstr "" +msgstr "構造体と共用体のレイアウト、アラインメント、バイト順序" -#: ../../library/ctypes.rst:803 msgid "" "By default, Structure and Union fields are laid out in the same way the C " "compiler does it. It is possible to override this behavior entirely by " "specifying a :attr:`~Structure._layout_` class attribute in the subclass " "definition; see the attribute documentation for details." msgstr "" +"デフォルトでは、``Structure`` と ``Union`` のフィールドは C コンパイラと同じ" +"方法で配置されます。\n" +"サブクラス定義で :attr:`~Structure._layout_` クラス属性を指定すれば、この動作" +"を完全に上書きできます。\n" +"詳細はこの属性のドキュメントを参照してください。" #: ../../library/ctypes.rst:808 msgid "" @@ -1448,7 +1682,6 @@ msgid "" "documentation for details." msgstr "" -#: ../../library/ctypes.rst:813 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:" @@ -1456,19 +1689,25 @@ msgid "" "`BigEndianUnion`, and :class:`LittleEndianUnion` base classes. These " "classes cannot contain pointer fields." msgstr "" +":mod:`!ctypes` は、構造体と共用体にネイティブのバイト順序を使用します。\n" +"ネイティブでないバイト順序の構造体を作るには、:class:`BigEndianStructure`、:" +"class:`LittleEndianStructure`、:class:`BigEndianUnion`、:class:" +"`LittleEndianUnion` のいずれかを基底クラスとして使えます。\n" +"これらのクラスにはポインタフィールドを含められません。" #: ../../library/ctypes.rst:823 msgid "Bit fields in structures and unions" msgstr "構造体と共用体におけるビットフィールド" -#: ../../library/ctypes.rst:825 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:`~Structure._fields_` tuples::" msgstr "" +"ビットフィールドを含む構造体や共用体も作成できます。\n" +"ビットフィールドにできるのは整数フィールドだけで、ビット幅は :attr:" +"`~Structure._fields_` のタプルの第 3 要素として指定します。 ::" -#: ../../library/ctypes.rst:829 msgid "" ">>> class Int(Structure):\n" "... _fields_ = [(\"first_16\", c_int, 16),\n" @@ -1479,8 +1718,15 @@ msgid "" ">>> print(Int.second_16)\n" "" msgstr "" +">>> class Int(Structure):\n" +"... _fields_ = [(\"first_16\", c_int, 16),\n" +"... (\"second_16\", c_int, 16)]\n" +"...\n" +">>> print(Int.first_16)\n" +"\n" +">>> print(Int.second_16)\n" +"" -#: ../../library/ctypes.rst:838 msgid "" "It is important to note that bit field allocation and layout in memory are " "not defined as a C standard; their implementation is compiler-specific. By " @@ -1488,6 +1734,12 @@ msgid "" "for the current platform. See the :attr:`~Structure._layout_` attribute for " "details on the default behavior and how to change it." msgstr "" +"ビットフィールドのメモリ内での割り当てやレイアウトは C 標準では定義されておら" +"ず、コンパイラ固有の実装であることに注意してください。\n" +"デフォルトでは、Python は現在のプラットフォームの「ネイティブ」コンパイラの動" +"作に合わせようとします。\n" +"デフォルトの動作とその変更方法については、:attr:`~Structure._layout_` 属性を" +"参照してください。" #: ../../library/ctypes.rst:849 msgid "Arrays" @@ -1506,9 +1758,8 @@ msgid "" "a positive integer::" msgstr "推奨されている配列の作成方法はデータ型に正の整数を掛けることです。::" -#: ../../library/ctypes.rst:856 msgid "TenPointsArrayType = POINT * 10" -msgstr "" +msgstr "TenPointsArrayType = POINT * 10" #: ../../library/ctypes.rst:858 msgid "" @@ -1518,7 +1769,6 @@ msgstr "" "ややわざとらしいデータ型の例になりますが、他のものに混ざって 4 個の POINT が" "ある構造体です::" -#: ../../library/ctypes.rst:861 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -1533,17 +1783,31 @@ msgid "" "4\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = (\"x\", c_int), (\"y\", c_int)\n" +"...\n" +">>> class MyStruct(Structure):\n" +"... _fields_ = [(\"a\", c_int),\n" +"... (\"b\", c_float),\n" +"... (\"point_array\", POINT * 4)]\n" +">>>\n" +">>> print(len(MyStruct().point_array))\n" +"4\n" +">>>" #: ../../library/ctypes.rst:874 msgid "Instances are created in the usual way, by calling the class::" msgstr "インスタンスはクラスを呼び出す通常の方法で作成します。::" -#: ../../library/ctypes.rst:876 msgid "" "arr = TenPointsArrayType()\n" "for pt in arr:\n" " print(pt.x, pt.y)" msgstr "" +"arr = TenPointsArrayType()\n" +"for pt in arr:\n" +" print(pt.x, pt.y)" #: ../../library/ctypes.rst:880 msgid "" @@ -1557,7 +1821,6 @@ msgstr "" msgid "Initializers of the correct type can also be specified::" msgstr "正しい型の初期化子を指定することもできます。::" -#: ../../library/ctypes.rst:885 msgid "" ">>> from ctypes import *\n" ">>> TenIntegers = c_int * 10\n" @@ -1569,24 +1832,37 @@ msgid "" "1 2 3 4 5 6 7 8 9 10\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> TenIntegers = c_int * 10\n" +">>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n" +">>> print(ii)\n" +"\n" +">>> for i in ii: print(i, end=\" \")\n" +"...\n" +"1 2 3 4 5 6 7 8 9 10\n" +">>>" #: ../../library/ctypes.rst:899 msgid "Pointers" msgstr "ポインタ" -#: ../../library/ctypes.rst:901 msgid "" "Pointer instances are created by calling the :func:`pointer` function on a :" "mod:`!ctypes` type::" msgstr "" +":mod:`!ctypes` の型のオブジェクトに対して :func:`pointer` 関数を呼び出すと、" +"ポインタインスタンスが作成されます。 ::" -#: ../../library/ctypes.rst:904 msgid "" ">>> from ctypes import *\n" ">>> i = c_int(42)\n" ">>> pi = pointer(i)\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> i = c_int(42)\n" +">>> pi = pointer(i)\n" +">>>" #: ../../library/ctypes.rst:909 msgid "" @@ -1596,20 +1872,22 @@ msgstr "" "次のように、ポインタインスタンスは、ポインタが指すオブジェクト (上の例では " "``i``) を返す :attr:`~_Pointer.contents` 属性を持ちます::" -#: ../../library/ctypes.rst:912 msgid "" ">>> pi.contents\n" "c_long(42)\n" ">>>" msgstr "" +">>> pi.contents\n" +"c_long(42)\n" +">>>" -#: ../../library/ctypes.rst:916 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 "" +":mod:`!ctypes` は OOR (元のオブジェクトを返すこと) を行いません。\n" +"属性を取得するたびに、同等の新しいオブジェクトを構築します。 ::" -#: ../../library/ctypes.rst:919 msgid "" ">>> pi.contents is i\n" "False\n" @@ -1617,6 +1895,11 @@ msgid "" "False\n" ">>>" msgstr "" +">>> pi.contents is i\n" +"False\n" +">>> pi.contents is pi.contents\n" +"False\n" +">>>" #: ../../library/ctypes.rst:925 msgid "" @@ -1627,7 +1910,6 @@ msgstr "" "別の :class:`c_int` インスタンスがポインタの contents 属性に代入されると、こ" "れが記憶されているメモリ位置を指すポインタに変化します。::" -#: ../../library/ctypes.rst:928 msgid "" ">>> i = c_int(99)\n" ">>> pi.contents = i\n" @@ -1635,23 +1917,29 @@ msgid "" "c_long(99)\n" ">>>" msgstr "" +">>> i = c_int(99)\n" +">>> pi.contents = i\n" +">>> pi.contents\n" +"c_long(99)\n" +">>>" #: ../../library/ctypes.rst:937 msgid "Pointer instances can also be indexed with integers::" msgstr "ポインタインスタンスは整数でインデックス指定することもできます。::" -#: ../../library/ctypes.rst:939 msgid "" ">>> pi[0]\n" "99\n" ">>>" msgstr "" +">>> pi[0]\n" +"99\n" +">>>" #: ../../library/ctypes.rst:943 msgid "Assigning to an integer index changes the pointed to value::" msgstr "整数インデックスへ代入するとポインタが指す値が変更されます。::" -#: ../../library/ctypes.rst:945 msgid "" ">>> print(i)\n" "c_long(99)\n" @@ -1660,6 +1948,12 @@ msgid "" "c_long(22)\n" ">>>" msgstr "" +">>> print(i)\n" +"c_long(99)\n" +">>> pi[0] = 22\n" +">>> print(i)\n" +"c_long(22)\n" +">>>" #: ../../library/ctypes.rst:952 msgid "" @@ -1675,7 +1969,6 @@ msgstr "" "のポインタが単一の要素ではなく実際に配列を指していると *分かっている* 場合だ" "けです。" -#: ../../library/ctypes.rst:960 msgid "" "Because pointer objects support subscription, they implicitly support :term:" "`iteration `. Unless doing this in a controlled manner, such as by " @@ -1684,16 +1977,24 @@ msgid "" "knowing when to stop iteration. In other words, a ``pointer`` iterator will " "infinitely yield arbitrary memory." msgstr "" +"ポインタオブジェクトは添字付けをサポートするため、暗黙に :term:`反復 " +"` もサポートします。\n" +"ただし、:func:`pointer` のイテレータに対して :func:`next` を手動で呼び出すな" +"ど、制御しながら使わないと、通常は無限ループやクラッシュを引き起こします。\n" +"ctypes には反復をどこで終了すればよいか判断する方法がないためです。\n" +"つまり、``pointer`` のイテレータは任意のメモリの内容を際限なく yield します。" -#: ../../library/ctypes.rst:967 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 "" +":func:`pointer` 関数は、内部では単にポインタインスタンスを作るだけでなく、ま" +"ずポインタの *型* を作る必要があります。\n" +"これには、任意の :mod:`!ctypes` の型を受け取り、新しい型を返す :func:" +"`POINTER` 関数を使います。 ::" -#: ../../library/ctypes.rst:972 msgid "" ">>> PI = POINTER(c_int)\n" ">>> PI\n" @@ -1706,6 +2007,16 @@ msgid "" "\n" ">>>" msgstr "" +">>> PI = POINTER(c_int)\n" +">>> PI\n" +"\n" +">>> PI(42)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: expected c_long instead of int\n" +">>> PI(c_int(42))\n" +"\n" +">>>" #: ../../library/ctypes.rst:983 msgid "" @@ -1715,21 +2026,25 @@ msgstr "" "ポインタ型を引数なしで呼び出すと ``NULL`` ポインタを作成します。 ``NULL`` ポ" "インタは ``False`` ブール値を持っています。::" -#: ../../library/ctypes.rst:986 msgid "" ">>> null_ptr = POINTER(c_int)()\n" ">>> print(bool(null_ptr))\n" "False\n" ">>>" msgstr "" +">>> null_ptr = POINTER(c_int)()\n" +">>> print(bool(null_ptr))\n" +"False\n" +">>>" -#: ../../library/ctypes.rst:991 msgid "" ":mod:`!ctypes` checks for ``NULL`` when dereferencing pointers (but " "dereferencing invalid non-\\ ``NULL`` pointers would crash Python)::" msgstr "" +":mod:`!ctypes` は、ポインタを参照外しする際に ``NULL`` かどうかを検査します " +"(ただし、``NULL`` でない無効なポインタを参照外しすると Python はクラッシュし" +"ます)。 ::" -#: ../../library/ctypes.rst:994 msgid "" ">>> null_ptr[0]\n" "Traceback (most recent call last):\n" @@ -1743,26 +2058,40 @@ msgid "" "ValueError: NULL pointer access\n" ">>>" msgstr "" +">>> null_ptr[0]\n" +"Traceback (most recent call last):\n" +" ....\n" +"ValueError: NULL pointer access\n" +">>>\n" +"\n" +">>> null_ptr[0] = 1234\n" +"Traceback (most recent call last):\n" +" ....\n" +"ValueError: NULL pointer access\n" +">>>" -#: ../../library/ctypes.rst:1009 msgid "Thread safety without the GIL" -msgstr "" +msgstr "GIL のない環境でのスレッド安全性" -#: ../../library/ctypes.rst:1011 msgid "" "From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-" "threaded build`. In ctypes, reads and writes to a single object concurrently " "is safe, but not across multiple objects:" msgstr "" +"Python 3.13 以降では、:term:`free-threaded build` で :term:`GIL` を無効にでき" +"ます。\n" +"ctypes では、単一のオブジェクトに対する並行した読み書きは安全ですが、複数のオ" +"ブジェクトを通じた並行した読み書きは安全ではありません:" -#: ../../library/ctypes.rst:1014 msgid "" ">>> number = c_int(42)\n" ">>> pointer_a = pointer(number)\n" ">>> pointer_b = pointer(number)" msgstr "" +">>> number = c_int(42)\n" +">>> pointer_a = pointer(number)\n" +">>> pointer_b = pointer(number)" -#: ../../library/ctypes.rst:1020 msgid "" "In the above, it's only safe for one object to read and write to the address " "at once if the GIL is disabled. So, ``pointer_a`` can be shared and written " @@ -1770,6 +2099,12 @@ msgid "" "to do the same. If this is an issue, consider using a :class:`threading." "Lock` to synchronize access to memory:" msgstr "" +"上の例で GIL が無効の場合、同じアドレスに対して一度に安全に読み書きできるの" +"は、1 つのオブジェクトだけです。\n" +"したがって、複数のスレッドで ``pointer_a`` を共有して書き込むことはできます" +"が、``pointer_b`` が同じことをしようとしていない場合に限られます。\n" +"これが問題になる場合は、:class:`threading.Lock` を使ってメモリへのアクセスを" +"同期することを検討してください:" #: ../../library/ctypes.rst:1025 msgid "" @@ -1787,7 +2122,6 @@ msgstr "" msgid "Type conversions" msgstr "型変換" -#: ../../library/ctypes.rst:1042 msgid "" "Usually, ctypes does strict type checking. This means, if you have " "``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or " @@ -1797,8 +2131,16 @@ msgid "" "array instances instead of pointer types. So, for ``POINTER(c_int)``, " "ctypes accepts an array of c_int::" msgstr "" +"通常、ctypes は厳密な型検査を行います。\n" +"例えば、関数の :attr:`~_CFuncPtr.argtypes` リストや構造体定義のメンバーフィー" +"ルドの型に ``POINTER(c_int)`` を指定した場合、まったく同じ型のインスタンスし" +"か受け付けません。\n" +"ただし、この規則には例外があり、ctypes がほかのオブジェクトを受け付ける場合も" +"あります。\n" +"例えば、ポインタ型の代わりに、互換性のある配列インスタンスを渡せます。\n" +"そのため、``POINTER(c_int)`` に対しては、ctypes は c_int の配列を受け付けま" +"す。 ::" -#: ../../library/ctypes.rst:1049 msgid "" ">>> class Bar(Structure):\n" "... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" @@ -1814,8 +2156,20 @@ msgid "" "3\n" ">>>" msgstr "" +">>> class Bar(Structure):\n" +"... _fields_ = [(\"count\", c_int), (\"values\", POINTER(c_int))]\n" +"...\n" +">>> bar = Bar()\n" +">>> bar.values = (c_int * 3)(1, 2, 3)\n" +">>> bar.count = 3\n" +">>> for i in range(bar.count):\n" +"... print(bar.values[i])\n" +"...\n" +"1\n" +"2\n" +"3\n" +">>>" -#: ../../library/ctypes.rst:1063 msgid "" "In addition, if a function argument is explicitly declared to be a pointer " "type (such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object " @@ -1823,6 +2177,10 @@ msgid "" "ctypes will apply the required :func:`byref` conversion in this case " "automatically." msgstr "" +"さらに、:attr:`~_CFuncPtr.argtypes` で関数の引数を ``POINTER(c_int)`` などの" +"ポインタ型として明示的に宣言した場合、参照先の型 (この場合は ``c_int``) のオ" +"ブジェクトを関数に渡せます。\n" +"この場合、ctypes は必要な :func:`byref` 変換を自動的に適用します。" #: ../../library/ctypes.rst:1068 msgid "To set a POINTER type field to ``NULL``, you can assign ``None``::" @@ -1830,13 +2188,13 @@ msgstr "" "POINTER型フィールドを ``NULL`` に設定するために、 ``None`` を代入してもかまい" "ません。::" -#: ../../library/ctypes.rst:1070 msgid "" ">>> bar.values = None\n" ">>>" msgstr "" +">>> bar.values = None\n" +">>>" -#: ../../library/ctypes.rst:1075 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 " @@ -1844,8 +2202,13 @@ msgid "" "accepts ``POINTER(c_int)`` pointers or :class:`c_int` arrays for its " "``values`` field, but not instances of other types::" msgstr "" +"互換性のない型のインスタンスを扱うこともあります。\n" +"C では、ある型を別の型にキャストできます。\n" +":mod:`!ctypes` には、同じように使える :func:`cast` 関数があります。\n" +"上で定義した ``Bar`` 構造体の ``values`` フィールドは、``POINTER(c_int)`` ポ" +"インタや :class:`c_int` 配列を受け付けますが、ほかの型のインスタンスは受け付" +"けません。 ::" -#: ../../library/ctypes.rst:1081 msgid "" ">>> bar.values = (c_byte * 4)()\n" "Traceback (most recent call last):\n" @@ -1854,6 +2217,12 @@ msgid "" "instance\n" ">>>" msgstr "" +">>> bar.values = (c_byte * 4)()\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long " +"instance\n" +">>>" #: ../../library/ctypes.rst:1087 msgid "For these cases, the :func:`cast` function is handy." @@ -1873,13 +2242,16 @@ msgstr "" "ります。そして、第二引数のインスタンスを返します。このインスタンスは第一引数" "と同じメモリブロックを参照しています::" -#: ../../library/ctypes.rst:1095 msgid "" ">>> a = (c_byte * 4)()\n" ">>> cast(a, POINTER(c_int))\n" "\n" ">>>" msgstr "" +">>> a = (c_byte * 4)()\n" +">>> cast(a, POINTER(c_int))\n" +"\n" +">>>" #: ../../library/ctypes.rst:1100 msgid "" @@ -1889,7 +2261,6 @@ msgstr "" "したがって、 :func:`cast` を ``Bar`` 構造体の ``values`` フィールドへ代入する" "ために使うことができます::" -#: ../../library/ctypes.rst:1103 msgid "" ">>> bar = Bar()\n" ">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" @@ -1897,6 +2268,11 @@ msgid "" "0\n" ">>>" msgstr "" +">>> bar = Bar()\n" +">>> bar.values = cast((c_byte * 4)(), POINTER(c_int))\n" +">>> print(bar.values[0])\n" +"0\n" +">>>" #: ../../library/ctypes.rst:1113 msgid "Incomplete Types" @@ -1911,7 +2287,6 @@ msgstr "" "*不完全型* はメンバーがまだ指定されていない構造体、共用体もしくは配列です。 " "C では、前方宣言により指定され、後で定義されます。::" -#: ../../library/ctypes.rst:1119 msgid "" "struct cell; /* forward declaration */\n" "\n" @@ -1920,6 +2295,12 @@ msgid "" " struct cell *next;\n" "};" msgstr "" +"struct cell; /* 前方宣言 */\n" +"\n" +"struct cell {\n" +" char *name;\n" +" struct cell *next;\n" +"};" #: ../../library/ctypes.rst:1126 msgid "" @@ -1928,7 +2309,6 @@ msgid "" msgstr "" "ctypes コードへの直接的な変換ではこうなるでしょう。しかし、動作しません::" -#: ../../library/ctypes.rst:1129 msgid "" ">>> class cell(Structure):\n" "... _fields_ = [(\"name\", c_char_p),\n" @@ -1940,15 +2320,26 @@ msgid "" "NameError: name 'cell' is not defined\n" ">>>" msgstr "" +">>> class cell(Structure):\n" +"... _fields_ = [(\"name\", c_char_p),\n" +"... (\"next\", POINTER(cell))]\n" +"...\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" File \"\", line 2, in cell\n" +"NameError: name 'cell' is not defined\n" +">>>" -#: ../../library/ctypes.rst:1139 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:`~Structure._fields_` attribute later, after the class statement::" msgstr "" +"これは、新しい ``class cell`` が、そのクラス文の内部ではまだ利用できないため" +"です。\n" +":mod:`!ctypes` では、まず ``cell`` クラスを定義し、クラス文の後で :attr:" +"`~Structure._fields_` 属性を設定できます。 ::" -#: ../../library/ctypes.rst:1143 msgid "" ">>> from ctypes import *\n" ">>> class cell(Structure):\n" @@ -1958,6 +2349,13 @@ msgid "" "... (\"next\", POINTER(cell))]\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> class cell(Structure):\n" +"... pass\n" +"...\n" +">>> cell._fields_ = [(\"name\", c_char_p),\n" +"... (\"next\", POINTER(cell))]\n" +">>>" #: ../../library/ctypes.rst:1151 msgid "" @@ -1988,11 +2386,13 @@ msgstr "" msgid "Callback functions" msgstr "コールバック関数" -#: ../../library/ctypes.rst:1174 msgid "" ":mod:`!ctypes` allows creating C callable function pointers from Python " "callables. These are sometimes called *callback functions*." msgstr "" +":mod:`!ctypes` を使うと、Python の呼び出し可能オブジェクトから、C で呼び出せ" +"る関数ポインタを作成できます。\n" +"これらは *コールバック関数* と呼ばれることもあります。" #: ../../library/ctypes.rst:1177 msgid "" @@ -2024,14 +2424,15 @@ msgstr "" "これらのファクトリ関数はともに最初の引数に戻り値の型、残りの引数としてコール" "バック関数が想定する引数の型を渡して呼び出されます。" -#: ../../library/ctypes.rst:1190 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 "" +"ここでは、標準 C ライブラリの :c:func:`!qsort` 関数を使う例を示します。\n" +"この関数は、コールバック関数を使って要素をソートします。\n" +":c:func:`!qsort` で整数の配列をソートしてみます。 ::" -#: ../../library/ctypes.rst:1194 msgid "" ">>> IntArray5 = c_int * 5\n" ">>> ia = IntArray5(5, 1, 7, 33, 99)\n" @@ -2039,8 +2440,12 @@ msgid "" ">>> qsort.restype = None\n" ">>>" msgstr "" +">>> IntArray5 = c_int * 5\n" +">>> ia = IntArray5(5, 1, 7, 33, 99)\n" +">>> qsort = libc.qsort\n" +">>> qsort.restype = None\n" +">>>" -#: ../../library/ctypes.rst:1200 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 " @@ -2049,6 +2454,12 @@ msgid "" "is smaller than the second, a zero if they are equal, and a positive integer " "otherwise." msgstr "" +":func:`!qsort` は、ソートするデータへのポインタ、データ配列の要素数、1 要素の" +"サイズ、比較関数であるコールバックへのポインタを渡して呼び出す必要がありま" +"す。\n" +"コールバックは、要素への 2 つのポインタを引数として呼び出されます。\n" +"最初の要素が 2 番目より小さければ負の整数、等しければゼロ、それ以外なら正の整" +"数を返す必要があります。" #: ../../library/ctypes.rst:1206 msgid "" @@ -2058,11 +2469,12 @@ msgstr "" "コールバック関数は整数へのポインタを受け取り、整数を返す必要があります。ま" "ず、コールバック関数のための ``type`` を作成します。::" -#: ../../library/ctypes.rst:1209 msgid "" ">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" ">>>" msgstr "" +">>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" +">>>" #: ../../library/ctypes.rst:1212 msgid "" @@ -2071,7 +2483,6 @@ msgid "" msgstr "" "まず初めに、これが受け取った変数を表示するだけのシンプルなコールバックです::" -#: ../../library/ctypes.rst:1215 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2079,13 +2490,18 @@ msgid "" "...\n" ">>> cmp_func = CMPFUNC(py_cmp_func)\n" ">>>" -msgstr "" +msgstr "" +">>> def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return 0\n" +"...\n" +">>> cmp_func = CMPFUNC(py_cmp_func)\n" +">>>" #: ../../library/ctypes.rst:1222 msgid "The result::" msgstr "結果は以下の通りです::" -#: ../../library/ctypes.rst:1224 msgid "" ">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" "py_cmp_func 5 1\n" @@ -2095,12 +2511,18 @@ msgid "" "py_cmp_func 1 7\n" ">>>" msgstr "" +">>> qsort(ia, len(ia), sizeof(c_int), cmp_func)\n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 5 7\n" +"py_cmp_func 1 7\n" +">>>" #: ../../library/ctypes.rst:1232 msgid "Now we can actually compare the two items and return a useful result::" msgstr "ここで 2 つの要素を実際に比較し、役に立つ結果を返します::" -#: ../../library/ctypes.rst:1234 msgid "" ">>> def py_cmp_func(a, b):\n" "... print(\"py_cmp_func\", a[0], b[0])\n" @@ -2115,18 +2537,33 @@ msgid "" "py_cmp_func 5 7\n" ">>>" msgstr "" +">>> def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return a[0] - b[0]\n" +"...\n" +">>>\n" +">>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))\n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 1 7\n" +"py_cmp_func 5 7\n" +">>>" #: ../../library/ctypes.rst:1247 msgid "As we can easily check, our array is sorted now::" msgstr "簡単に確認できるように、配列を次のようにソートしました::" -#: ../../library/ctypes.rst:1249 msgid "" ">>> for i in ia: print(i, end=\" \")\n" "...\n" "1 5 7 33 99\n" ">>>" msgstr "" +">>> for i in ia: print(i, end=\" \")\n" +"...\n" +"1 5 7 33 99\n" +">>>" #: ../../library/ctypes.rst:1254 msgid "" @@ -2136,7 +2573,6 @@ msgstr "" "関数ファクトリはデコレータファクトリとしても使えるので、次のようにも書けま" "す::" -#: ../../library/ctypes.rst:1257 msgid "" ">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" "... def py_cmp_func(a, b):\n" @@ -2151,13 +2587,29 @@ msgid "" "py_cmp_func 5 7\n" ">>>" msgstr "" +">>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))\n" +"... def py_cmp_func(a, b):\n" +"... print(\"py_cmp_func\", a[0], b[0])\n" +"... return a[0] - b[0]\n" +"...\n" +">>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)\n" +"py_cmp_func 5 1\n" +"py_cmp_func 33 99\n" +"py_cmp_func 7 33\n" +"py_cmp_func 1 7\n" +"py_cmp_func 5 7\n" +">>>" -#: ../../library/ctypes.rst:1272 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 "" +"C コードで使用されている間は、必ず :func:`CFUNCTYPE` オブジェクトへの参照を保" +"持してください。\n" +":mod:`!ctypes` 自身は参照を保持しないため、参照を保持しないとオブジェクトがガ" +"ベージコレクションされ、コールバックの呼び出し時にプログラムがクラッシュする" +"可能性があります。" #: ../../library/ctypes.rst:1276 msgid "" @@ -2179,26 +2631,33 @@ msgstr "" msgid "Accessing values exported from dlls" msgstr "dllからエクスポートされた値へアクセスする" -#: ../../library/ctypes.rst:1288 msgid "" "Some shared libraries not only export functions, they also export variables. " "An example in the Python library itself is the :c:data:`Py_Version`, Python " "runtime version number encoded in a single constant integer." msgstr "" +"共有ライブラリには、関数だけでなく変数もエクスポートするものがあります。\n" +"Python ライブラリ自体にも例があり、:c:data:`Py_Version` は Python ランタイム" +"のバージョン番号を単一の定数の整数に符号化したものです。" -#: ../../library/ctypes.rst:1292 msgid "" ":mod:`!ctypes` can access values like this with the :meth:`~_CData.in_dll` " "class methods of the type. *pythonapi* is a predefined symbol giving access " "to the Python C api::" msgstr "" +":mod:`!ctypes` は、型の :meth:`~_CData.in_dll` クラスメソッドを使って、このよ" +"うな値にアクセスできます。\n" +"*pythonapi* は、Python C API へのアクセスを提供する定義済みのシンボルで" +"す。 ::" -#: ../../library/ctypes.rst:1296 msgid "" ">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" ">>> print(hex(version.value))\n" "0x30c00a0" msgstr "" +">>> version = ctypes.c_int.in_dll(ctypes.pythonapi, \"Py_Version\")\n" +">>> print(hex(version.value))\n" +"0x30c00a0" #: ../../library/ctypes.rst:1300 msgid "" @@ -2226,11 +2685,13 @@ msgstr "" "サードパーティ製のコードからこのポインタに仕掛けを講じて、動的に生成されたフ" "リーズ化モジュールの集合を提供するようにできます。" -#: ../../library/ctypes.rst:1310 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 "" +"したがって、このポインタの操作は役立つこともあります。\n" +"例を短くするため、ここでは :mod:`!ctypes` を使ってこのテーブルを読み取る方法" +"だけを示します。 ::" #: ../../library/ctypes.rst:1313 msgid "" @@ -2302,17 +2763,17 @@ msgstr "" msgid "Surprises" msgstr "びっくり仰天" -#: ../../library/ctypes.rst:1357 msgid "" "There are some edges in :mod:`!ctypes` where you might expect something " "other than what actually happens." msgstr "" +":mod:`!ctypes` には、実際とは異なる動作を期待してしまいがちな部分がいくつかあ" +"ります。" #: ../../library/ctypes.rst:1360 msgid "Consider the following example::" msgstr "次に示す例について考えてみてください。::" -#: ../../library/ctypes.rst:1362 msgid "" ">>> from ctypes import *\n" ">>> class POINT(Structure):\n" @@ -2332,6 +2793,23 @@ msgid "" "3 4 3 4\n" ">>>" msgstr "" +">>> from ctypes import *\n" +">>> class POINT(Structure):\n" +"... _fields_ = (\"x\", c_int), (\"y\", c_int)\n" +"...\n" +">>> class RECT(Structure):\n" +"... _fields_ = (\"a\", POINT), (\"b\", POINT)\n" +"...\n" +">>> p1 = POINT(1, 2)\n" +">>> p2 = POINT(3, 4)\n" +">>> rc = RECT(p1, p2)\n" +">>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)\n" +"1 2 3 4\n" +">>> # 2 つの点を交換します\n" +">>> rc.a, rc.b = rc.b, rc.a\n" +">>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)\n" +"3 4 3 4\n" +">>>" #: ../../library/ctypes.rst:1380 msgid "" @@ -2342,15 +2820,17 @@ msgstr "" "きたのでしょうか? 上の行の ``rc.a, rc.b = rc.b, rc.a`` の各段階はこのようにな" "ります。::" -#: ../../library/ctypes.rst:1383 msgid "" ">>> temp0, temp1 = rc.b, rc.a\n" ">>> rc.a = temp0\n" ">>> rc.b = temp1\n" ">>>" msgstr "" +">>> temp0, temp1 = rc.b, rc.a\n" +">>> rc.a = temp0\n" +">>> rc.b = temp1\n" +">>>" -#: ../../library/ctypes.rst:1388 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 " @@ -2358,11 +2838,12 @@ msgid "" "the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't " "have the expected effect." msgstr "" -"``temp0`` と ``temp1`` は前記の ``rc`` オブジェクトの内部バッファでまだ使われ" -"ているオブジェクトです。したがって、 ``rc.a = temp0`` を実行すると ``temp0`` " -"のバッファ内容が ``rc`` のバッファへコピーされます。さらに、これは ``temp1`` " -"の内容を変更します。そのため、最後の代入 ``rc.b = temp1`` は、期待する結果に" -"はならないのです。" +"``temp0`` と ``temp1`` は前記の ``rc`` オブジェクトの内部バッファを引き続き使" +"用しているオブジェクトです。\n" +"したがって、 ``rc.a = temp0`` を実行すると ``temp0`` のバッファ内容が ``rc`` " +"のバッファへコピーされます。\n" +"さらに、これは ``temp1`` の内容を変更します。\n" +"そのため、最後の代入 ``rc.b = temp1`` は、期待する結果にはならないのです。" #: ../../library/ctypes.rst:1394 msgid "" @@ -2380,7 +2861,6 @@ msgid "" "this::" msgstr "期待とは違う振る舞いをする別の例はこれです::" -#: ../../library/ctypes.rst:1400 msgid "" ">>> s = c_char_p()\n" ">>> s.value = b\"abc def ghi\"\n" @@ -2390,6 +2870,13 @@ msgid "" "False\n" ">>>" msgstr "" +">>> s = c_char_p()\n" +">>> s.value = b\"abc def ghi\"\n" +">>> s.value\n" +"b'abc def ghi'\n" +">>> s.value is s.value\n" +"False\n" +">>>" #: ../../library/ctypes.rst:1410 msgid "" @@ -2417,11 +2904,11 @@ msgstr "" msgid "Variable-sized data types" msgstr "可変サイズのデータ型" -#: ../../library/ctypes.rst:1425 msgid "" ":mod:`!ctypes` provides some support for variable-sized arrays and " "structures." msgstr "" +":mod:`!ctypes` は、可変サイズの配列や構造体をある程度サポートしています。" #: ../../library/ctypes.rst:1427 msgid "" @@ -2437,7 +2924,6 @@ msgstr "" "常のメモリブロックより小さくすることはできません。これをやろうとすると、 :" "exc:`ValueError` が送出されます。::" -#: ../../library/ctypes.rst:1433 msgid "" ">>> short_array = (c_short * 4)()\n" ">>> print(sizeof(short_array))\n" @@ -2453,6 +2939,19 @@ msgid "" "8\n" ">>>" msgstr "" +">>> short_array = (c_short * 4)()\n" +">>> print(sizeof(short_array))\n" +"8\n" +">>> resize(short_array, 4)\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: minimum size is 8\n" +">>> resize(short_array, 32)\n" +">>> sizeof(short_array)\n" +"32\n" +">>> sizeof(type(short_array))\n" +"8\n" +">>>" #: ../../library/ctypes.rst:1447 msgid "" @@ -2464,7 +2963,6 @@ msgstr "" "するのでしょうか? この型は要素の数が 4 個であるとまだ認識しているので、他の要" "素にアクセスするとエラーになります。::" -#: ../../library/ctypes.rst:1451 msgid "" ">>> short_array[:]\n" "[0, 0, 0, 0]\n" @@ -2474,13 +2972,22 @@ msgid "" "IndexError: invalid index\n" ">>>" msgstr "" +">>> short_array[:]\n" +"[0, 0, 0, 0]\n" +">>> short_array[7]\n" +"Traceback (most recent call last):\n" +" ...\n" +"IndexError: invalid index\n" +">>>" -#: ../../library/ctypes.rst:1459 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 "" +":mod:`!ctypes` で可変サイズのデータ型を使うもう 1 つの方法は、Python の動的な" +"性質を利用し、必要なサイズがわかった後で、場合に応じてデータ型を定義または再" +"定義することです。" #: ../../library/ctypes.rst:1467 msgid "ctypes reference" @@ -2490,17 +2997,17 @@ msgstr "ctypesリファレンス" msgid "Loading shared libraries" msgstr "共有ライブラリをロードする" -#: ../../library/ctypes.rst:1474 msgid "" "There are several ways to load shared libraries into the Python process. " "One way is to instantiate :py:class:`CDLL` or one of its subclasses:" msgstr "" +"共有ライブラリを Python プロセスにロードする方法はいくつかあります。\n" +"その 1 つは、:py:class:`CDLL` またはそのサブクラスのインスタンスを作成する方" +"法です:" -#: ../../library/ctypes.rst:1480 msgid "Represents a loaded shared library." -msgstr "" +msgstr "ロード済みの共有ライブラリを表します。" -#: ../../library/ctypes.rst:1482 msgid "" "Functions in this library use the standard C calling convention, and are " "assumed to return :c:expr:`int`. The Python :term:`global interpreter lock` " @@ -2509,8 +3016,13 @@ msgid "" "class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes." "PyDLL`." msgstr "" +"このライブラリの関数は標準の C 呼び出し規約を使用し、:c:expr:`int` を返すと仮" +"定されます。\n" +"これらのライブラリがエクスポートする関数を呼び出す前に、Python の :term:" +"`global interpreter lock` を解放し、呼び出し後に再取得します。\n" +"関数の動作を変えるには、サブクラス :py:class:`~ctypes.OleDLL`、:py:class:" +"`~ctypes.WinDLL`、:py:class:`~ctypes.PyDLL` を使用してください。" -#: ../../library/ctypes.rst:1489 msgid "" "If you have an existing :py:attr:`handle ` to an " "already loaded shared library, it can be passed as the *handle* argument to " @@ -2518,21 +3030,29 @@ msgid "" "*name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but " "it may be adjusted and/or validated." msgstr "" +"すでにロードした共有ライブラリの :py:attr:`ハンドル ` が" +"ある場合、それを *handle* 引数に渡すと、開いているライブラリを新しい :py:" +"class:`!CDLL` オブジェクトでラップできます。\n" +"この場合、*name* は :py:attr:`~ctypes.CDLL._name` 属性の設定にのみ使われます" +"が、調整や検証が行われることもあります。" -#: ../../library/ctypes.rst:1495 msgid "" "If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or " "`LoadLibraryExW`_ function is used to load the library into the process, and " "to get a handle to it." msgstr "" +"*handle* が ``None`` の場合、プラットフォームの :manpage:`dlopen(3)` または " +"`LoadLibraryExW`_ 関数を使って、ライブラリをプロセスにロードし、そのハンドル" +"を取得します。" -#: ../../library/ctypes.rst:1499 msgid "" "*name* is the pathname of the shared library to open. If *name* does not " "contain a path separator, the library is found in a platform-specific way." msgstr "" +"*name* は開く共有ライブラリのパス名です。\n" +"*name* にパスの区切り文字が含まれない場合、プラットフォーム固有の方法でライブ" +"ラリを探します。" -#: ../../library/ctypes.rst:1503 msgid "" "On Windows, the ``.DLL`` suffix may be missing. (For details, see " "`LoadLibraryExW`_ documentation.) Other platform-specific prefixes and " @@ -2540,6 +3060,12 @@ msgid "" "must be present in *name*; they are not added automatically. See :ref:" "`ctypes-finding-shared-libraries` for more information." msgstr "" +"Windows では、``.DLL`` 接尾辞を省略できます (詳細は `LoadLibraryExW`_ のド" +"キュメントを参照してください)。\n" +"ほかのプラットフォーム固有の接頭辞や接尾辞 (``lib``、``.so``、``.dylib``、" +"バージョン番号など) は *name* に含める必要があり、自動的には追加されませ" +"ん。\n" +"詳しくは :ref:`ctypes-finding-shared-libraries` を参照してください。" #: ../../library/ctypes.rst:1510 msgid "" @@ -2549,17 +3075,16 @@ msgid "" "is more portable.)" msgstr "" -#: ../../library/ctypes.rst:1516 msgid "CPython implementation detail" -msgstr "" +msgstr "CPython の実装の詳細" -#: ../../library/ctypes.rst:1518 msgid "" "Since CPython is linked to ``libc``, a ``None`` *name* is often used to " "access the C standard library::" msgstr "" +"CPython は ``libc`` にリンクされるため、C 標準ライブラリへのアクセスには " +"*name* に ``None`` を指定する方法がよく使われます。 ::" -#: ../../library/ctypes.rst:1521 msgid "" ">>> printf = ctypes.CDLL(None).printf\n" ">>> printf.argtypes = [ctypes.c_char_p]\n" @@ -2567,27 +3092,31 @@ msgid "" "hello\n" "6" msgstr "" +">>> printf = ctypes.CDLL(None).printf\n" +">>> printf.argtypes = [ctypes.c_char_p]\n" +">>> printf(b\"hello\\n\")\n" +"hello\n" +"6" -#: ../../library/ctypes.rst:1527 msgid "" "To access the Python C API, prefer :py:data:`ctypes.pythonapi` which works " "across platforms." msgstr "" +"Python C API にアクセスする場合は、各プラットフォームで動作する :py:data:" +"`ctypes.pythonapi` を優先してください。" -#: ../../library/ctypes.rst:1530 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 "" -"*mode* パラメータを使うと、ライブラリがどうやってロードされたかを特定できま" +"*mode* パラメータを使うと、ライブラリをどのようにロードするかを指定できま" "す。\n" "詳細は :manpage:`dlopen(3)` マニュアルページを参考にしてください。\n" "Windows では *mode* は無視されます。\n" "POSIX システムでは RTLD_NOW が常に追加され、設定変更はできません。" -#: ../../library/ctypes.rst:1535 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:`!" @@ -2600,6 +3129,17 @@ msgid "" "example, a different CRT on Windows) has its own :data:`errno`, which :mod:`!" "ctypes` cannot observe." msgstr "" +"*use_errno* 引数を真に設定すると、システムのエラー番号 :data:`errno` に安全に" +"アクセスする ctypes の仕組みが有効になります。\n" +":mod:`!ctypes` は、システムの :data:`errno` 変数のコピーをスレッドローカルに" +"保持します。\n" +"``use_errno=True`` で作成した外部関数を呼び出すと、呼び出し前の :data:" +"`errno` 値を ctypes 内部のコピーと交換し、呼び出し直後にも同じ交換を行いま" +"す。\n" +"この仕組みは、インタープリタ自体と同じ C ランタイムライブラリを使うライブラリ" +"に対してのみ機能します。\n" +"別の C ランタイム (例えば Windows 上の別の CRT) にリンクされたライブラリは、" +"独自の :data:`errno` を持ち、:mod:`!ctypes` からは参照できません。" #: ../../library/ctypes.rst:1545 msgid "" @@ -2611,7 +3151,6 @@ msgstr "" "して、 :func:`ctypes.set_errno` 関数は ctypes のプライベートコピーを置き換" "え、以前の値を返します。" -#: ../../library/ctypes.rst:1549 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 :" @@ -2619,8 +3158,12 @@ msgid "" "and :func:`ctypes.set_last_error` are used to request and change the ctypes " "private copy of the windows error code." msgstr "" +"*use_last_error* 引数を真に設定すると、Windows API 関数の :func:" +"`GetLastError` と :func:`!SetLastError` が管理する Windows エラーコードについ" +"て同じ仕組みが有効になります。\n" +"ctypes 内部にある Windows エラーコードのコピーの取得と変更には、:func:" +"`ctypes.get_last_error` と :func:`ctypes.set_last_error` を使います。" -#: ../../library/ctypes.rst:1555 msgid "" "The *winmode* parameter is used on Windows to specify how the library is " "loaded (since *mode* is ignored). It takes any value that is valid for the " @@ -2629,8 +3172,14 @@ msgid "" "such as DLL hijacking. Passing the full path to the DLL is the safest way to " "ensure the correct library and dependencies are loaded." msgstr "" +"Windows では *mode* が無視されるため、*winmode* 引数でライブラリのロード方法" +"を指定します。\n" +"Win32 API の `LoadLibraryExW`_ の flags 引数として有効な値を指定できます。\n" +"省略時には、DLL ハイジャックなどの問題を避けるため、最も安全に DLL をロードす" +"るフラグが使われます。\n" +"正しいライブラリと依存ライブラリがロードされることを確実にする最も安全な方法" +"は、DLL のフルパスを渡すことです。" -#: ../../library/ctypes.rst:1562 msgid "" "On Windows creating a :class:`CDLL` instance may fail even if the DLL name " "exists. When a dependent DLL of the loaded DLL is not found, a :exc:" @@ -2641,23 +3190,33 @@ msgid "" "which DLL is not found, you need to find the list of dependent DLLs and " "determine which one is not found using Windows debugging and tracing tools." msgstr "" +"Windows では、DLL の名前が存在していても :class:`CDLL` インスタンスの作成が失" +"敗することがあります。\n" +"ロードする DLL の依存先 DLL が見つからない場合、*\"[WinError 126] The " +"specified module could not be found\"* というメッセージで :exc:`OSError` が送" +"出されます。\n" +"Windows API がこの情報を返さないため、エラーメッセージには見つからない DLL の" +"名前が含まれず、原因の特定が難しくなります。\n" +"このエラーを解決し、見つからない DLL を特定するには、依存先 DLL の一覧を調" +"べ、Windows のデバッグツールやトレースツールで、どれが見つからないのかを判定" +"する必要があります。" -#: ../../library/ctypes.rst:1574 msgid "" "`Microsoft DUMPBIN tool `_ -- A tool to find DLL " "dependents." msgstr "" +"`Microsoft の DUMPBIN ツール `_ -- 依存先 DLL を調べるツールで" +"す。" #: ../../library/ctypes.rst:1577 msgid "Added *winmode* parameter." msgstr "*winmode* 引数が追加されました。" -#: ../../library/ctypes.rst:1582 msgid "The *name* parameter can now be a :term:`path-like object`." -msgstr "" +msgstr "*name* 引数に :term:`path-like object` を指定できるようになりました。" -#: ../../library/ctypes.rst:1584 msgid "" "Instances of this class have no public methods. Functions exported by the " "shared library can be accessed as attributes or by index. Please note that " @@ -2665,8 +3224,14 @@ msgid "" "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 "" +"このクラスのインスタンスには公開メソッドがありません。\n" +"共有ライブラリがエクスポートする関数には、属性やインデックスを使ってアクセス" +"できます。\n" +"属性を通じてアクセスすると結果がキャッシュされ、繰り返しアクセスしても毎回同" +"じオブジェクトを返します。\n" +"一方、インデックスを通じてアクセスすると、毎回新しいオブジェクトを返しま" +"す。 ::" -#: ../../library/ctypes.rst:1590 msgid "" ">>> from ctypes import CDLL\n" ">>> libc = CDLL(\"libc.so.6\") # On Linux\n" @@ -2675,12 +3240,19 @@ msgid "" ">>> libc['time'] == libc['time']\n" "False" msgstr "" +">>> from ctypes import CDLL\n" +">>> libc = CDLL(\"libc.so.6\") # Linux の場合\n" +">>> libc.time == libc.time\n" +"True\n" +">>> libc['time'] == libc['time']\n" +"False" -#: ../../library/ctypes.rst:1597 msgid "" "The following public attributes are available. Their name starts with an " "underscore to not clash with exported function names:" msgstr "" +"以下の公開属性を利用できます。\n" +"エクスポートされた関数名と衝突しないよう、名前はアンダースコアで始まります:" #: ../../library/ctypes.rst:1602 msgid "The system handle used to access the library." @@ -2690,12 +3262,11 @@ msgstr "ライブラリへのアクセスに用いられるシステムハンド msgid "The name of the library passed in the constructor." msgstr "コンストラクタに渡されたライブラリの名前。" -#: ../../library/ctypes.rst:1612 ../../library/ctypes.rst:1629 -#: ../../library/ctypes.rst:1638 msgid "See :py:class:`~ctypes.CDLL`, the superclass, for common information." msgstr "" +"共通の情報については、スーパークラス :py:class:`~ctypes.CDLL` を参照してくだ" +"さい。" -#: ../../library/ctypes.rst:1614 msgid "" "Functions in this library use the ``stdcall`` calling convention, and are " "assumed to return the windows specific :class:`HRESULT` code. :class:" @@ -2703,41 +3274,41 @@ msgid "" "failed or succeeded, together with additional error code. If the return " "value signals a failure, an :class:`OSError` is automatically raised." msgstr "" +"このライブラリの関数は ``stdcall`` 呼び出し規約を使用し、Windows 固有の :" +"class:`HRESULT` コードを返すと仮定されます。\n" +":class:`HRESULT` の値には、関数呼び出しの成功または失敗を示す情報と、追加のエ" +"ラーコードが含まれます。\n" +"戻り値が失敗を示す場合、:class:`OSError` を自動的に送出します。" -#: ../../library/ctypes.rst:1620 ../../library/ctypes.rst:1634 -#: ../../library/ctypes.rst:1697 ../../library/ctypes.rst:1704 -#: ../../library/ctypes.rst:1844 ../../library/ctypes.rst:2003 -#: ../../library/ctypes.rst:2055 ../../library/ctypes.rst:2207 -#: ../../library/ctypes.rst:2279 ../../library/ctypes.rst:2288 -#: ../../library/ctypes.rst:2302 ../../library/ctypes.rst:2311 -#: ../../library/ctypes.rst:2320 ../../library/ctypes.rst:2335 -#: ../../library/ctypes.rst:2402 ../../library/ctypes.rst:2429 -#: ../../library/ctypes.rst:2861 ../../library/ctypes.rst:3284 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/ctypes.rst:1622 msgid "" ":exc:`WindowsError` used to be raised, which is now an alias of :exc:" "`OSError`." msgstr "" +"以前は :exc:`WindowsError` を送出していましたが、現在は :exc:`OSError` の別名" +"になっています。" -#: ../../library/ctypes.rst:1631 msgid "" "Functions in these libraries use the ``stdcall`` calling convention, and are " "assumed to return :c:expr:`int` by default." msgstr "" +"これらのライブラリの関数は ``stdcall`` 呼び出し規約を使用し、デフォルトでは :" +"c:expr:`int` を返すと仮定されます。" -#: ../../library/ctypes.rst:1640 msgid "" "When functions in this library are called, 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 "" +"このライブラリの関数を呼び出す場合、呼び出し中に Python の GIL は解放 *されず" +"*、関数の実行後に Python のエラーフラグを検査します。\n" +"エラーフラグが設定されている場合は、Python の例外を送出します。" -#: ../../library/ctypes.rst:1645 msgid "Thus, this is only useful to call Python C API functions directly." msgstr "" +"したがって、これは Python C API 関数を直接呼び出す場合にのみ役立ちます。" #: ../../library/ctypes.rst:1650 msgid "" @@ -2763,13 +3334,16 @@ msgstr "" "共有ライブラリをロードするために使われるデフォルトモード。 OSX 10.3 では " "*RTLD_GLOBAL* であり、そうでなければ *RTLD_LOCAL* と同じです。" -#: ../../library/ctypes.rst:1666 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:`~LibraryLoader.LoadLibrary` method, or by retrieving the " "library as attribute of the loader instance." msgstr "" +"あらかじめ作成されている :class:`LibraryLoader` クラスのインスタンスを使っ" +"て、共有ライブラリをロードすることもできます。\n" +":meth:`~LibraryLoader.LoadLibrary` メソッドを呼び出すか、ローダーインスタンス" +"の属性としてライブラリを取得します。" #: ../../library/ctypes.rst:1673 msgid "" @@ -2779,13 +3353,17 @@ msgstr "" "共有ライブラリをロードするクラス。 *dlltype* は :class:`CDLL` 、 :class:" "`PyDLL` 、 :class:`WinDLL` もしくは :class:`OleDLL` 型の一つであるべきです。" -#: ../../library/ctypes.rst:1676 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 "" +":meth:`!__getattr__` には特別な動作があります。\n" +"ライブラリローダーインスタンスの属性にアクセスすると、共有ライブラリをロード" +"できます。\n" +"結果はキャッシュされるため、属性へのアクセスを繰り返しても毎回同じライブラリ" +"を返します。" #: ../../library/ctypes.rst:1682 msgid "" @@ -2803,56 +3381,64 @@ msgstr "これらの前もって作られたライブラリローダーを利用 msgid "Creates :class:`CDLL` instances." msgstr ":class:`CDLL` インスタンスを作ります。" -#: ../../library/ctypes.rst:1695 msgid "Creates :class:`WinDLL` instances." -msgstr "" +msgstr ":class:`WinDLL` インスタンスを作成します。" -#: ../../library/ctypes.rst:1702 msgid "Creates :class:`OleDLL` instances." -msgstr "" +msgstr ":class:`OleDLL` インスタンスを作成します。" #: ../../library/ctypes.rst:1709 msgid "Creates :class:`PyDLL` instances." msgstr ":class:`PyDLL` インスタンスを作ります。" -#: ../../library/ctypes.rst:1714 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:expr:" "`int`, which is of course not always the truth, so you have to assign the " "correct :attr:`!restype` attribute to use these functions." msgstr "" +"Python C API 関数を属性として公開する :class:`PyDLL` のインスタンスです。\n" +"すべての関数が C の :c:expr:`int` を返すと仮定していますが、実際には常にそう" +"とは限りません。\n" +"これらの関数を使うには、:attr:`!restype` 属性に正しい型を設定する必要がありま" +"す。" -#: ../../library/ctypes.rst:1721 msgid "If the Python interpreter is statically linked, this may be ``None``." msgstr "" +"Python インタープリタが静的にリンクされている場合、これは ``None`` になること" +"があります。" -#: ../../library/ctypes.rst:1723 ../../library/ctypes.rst:1725 msgid "" "Loading a library through any of these objects raises an :ref:`auditing " "event ` ``ctypes.dlopen`` with string argument ``name``, the name " "used to load the library." msgstr "" +"これらのオブジェクトを通じてライブラリをロードすると、ロードに使うライブラリ" +"名を文字列引数 ``name`` とする :ref:`監査イベント ` ``ctypes." +"dlopen`` が発生します。" -#: ../../library/ctypes.rst:1729 ../../library/ctypes.rst:1731 msgid "" "Accessing a function on a loaded library raises an auditing event ``ctypes." "dlsym`` with arguments ``library`` (the library object) and ``name`` (the " "symbol's name as a string or integer)." msgstr "" +"ロード済みライブラリの関数にアクセスすると、引数 ``library`` (ライブラリオブ" +"ジェクト) と ``name`` (文字列または整数のシンボル名) を持つ監査イベント " +"``ctypes.dlsym`` が発生します。" -#: ../../library/ctypes.rst:1735 ../../library/ctypes.rst:1737 msgid "" "In cases when only the library handle is available rather than the object, " "accessing a function raises an auditing event ``ctypes.dlsym/handle`` with " "arguments ``handle`` (the raw library handle) and ``name``." msgstr "" +"ライブラリオブジェクトではなくハンドルだけが利用できる場合、関数にアクセスす" +"ると、引数 ``handle`` (生のライブラリハンドル) と ``name`` を持つ監査イベン" +"ト ``ctypes.dlsym/handle`` が発生します。" #: ../../library/ctypes.rst:1745 msgid "Finding shared libraries" msgstr "共有ライブラリを見つける" -#: ../../library/ctypes.rst:1747 msgid "" "When programming in a compiled language, shared libraries are accessed when " "compiling/linking a program, and when the program is run. The programmer " @@ -2860,8 +3446,12 @@ msgid "" "loader then interact in system-specific ways to find the filename of the " "library to load." msgstr "" +"コンパイル型の言語でプログラミングする場合、共有ライブラリには、プログラムの" +"コンパイルやリンクの際と、プログラムの実行時にアクセスします。\n" +"プログラマーが短い名前を指定すると、C コンパイラ、リンカー、実行時の動的ライ" +"ブラリローダーがシステム固有の方法で連携し、ロードするライブラリのファイル名" +"を探します。" -#: ../../library/ctypes.rst:1753 msgid "" "While the mapping from short names to filenames is not consistently exposed " "by platforms, the :mod:`!ctypes.util` module provides a function, :func:`!" @@ -2869,8 +3459,12 @@ msgid "" "compatibility concerns make it difficult to adjust its behavior for new " "platforms and configurations, the function is :term:`soft deprecated`." msgstr "" +"短い名前とファイル名の対応は、プラットフォーム間で一貫した形では公開されてい" +"ませんが、:mod:`!ctypes.util` モジュールは、その対応を求めようとする :func:`!" +"find_library` 関数を提供します。\n" +"ただし、後方互換性の問題から新しいプラットフォームや設定に合わせて動作を調整" +"するのは難しいため、この関数は :term:`soft deprecated` です。" -#: ../../library/ctypes.rst:1760 msgid "" "If wrapping a shared library with :mod:`!ctypes`, consider determining the " "shared library name at development time, and hardcoding it into the wrapper " @@ -2879,43 +3473,56 @@ msgid "" "to let users select a library to use, and then perhaps use :func:`!" "find_library` as a default or fallback." msgstr "" +":mod:`!ctypes` で共有ライブラリをラップする場合、実行時に :func:`!" +"find_library` で探す代わりに、開発時に共有ライブラリ名を決めてラッパーモ" +"ジュールに直接記述することを検討してください。\n" +"また、利用するライブラリをユーザーが選べる設定オプションや環境変数を追加し、:" +"func:`!find_library` はデフォルトや代替手段として使うことも検討してください。" -#: ../../library/ctypes.rst:1771 msgid "Try to find a library and return a pathname." -msgstr "" +msgstr "ライブラリを探し、そのパス名を返します。" -#: ../../library/ctypes.rst:1773 msgid "" "*name* is the \"short\" 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`.) The result is in a format suitable for " "passing to :py:class:`~ctypes.CDLL`." msgstr "" +"*name* は、``lib`` などの接頭辞や、``.so``、``.dylib``、バージョン番号などの" +"接尾辞を含まない、ライブラリの「短い」名前です (POSIX リンカーの :option:`!-" +"l` オプションで使う形式です)。\n" +"結果は :py:class:`~ctypes.CDLL` に渡せる形式になります。" -#: ../../library/ctypes.rst:1778 msgid "If no library can be found, return ``None``." -msgstr "" +msgstr "ライブラリが見つからない場合は ``None`` を返します。" -#: ../../library/ctypes.rst:1780 msgid "" "The exact functionality is system dependent, and is *not guaranteed* to " "match the behavior of the compiler, linker, and loader used for (or by) " "Python. It is recommended to only use this function as a default or fallback," msgstr "" +"厳密な動作はシステムに依存し、Python のために、または Python が使用するコンパ" +"イラ、リンカー、ローダーの動作と一致する *保証はありません*。\n" +"この関数はデフォルトや代替手段としてのみ使うことを推奨します。" -#: ../../library/ctypes.rst:1787 msgid "" "This function is kept for use in cases where it works, but not expected to " "be updated for additional platforms and configurations." msgstr "" +"この関数は、現在動作する環境での使用のために維持されますが、追加のプラット" +"フォームや設定に対応する更新は予定されていません。" -#: ../../library/ctypes.rst:1790 msgid "" "On Linux, :func:`!find_library` tries to run external programs (``/sbin/" "ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library file. If " "the output of these programs does not correspond to the dynamic linker used " "by Python, the result of this function may be misleading." msgstr "" +"Linux では、:func:`!find_library` は外部プログラム (``/sbin/ldconfig``、" +"``gcc``、``objdump``、``ld``) を実行してライブラリファイルを探そうとしま" +"す。\n" +"これらのプログラムの出力が Python の使う動的リンカーに対応していない場合、こ" +"の関数の結果は誤解を招くことがあります。" #: ../../library/ctypes.rst:1796 msgid "" @@ -2930,7 +3537,6 @@ msgstr "" msgid "Here are some examples::" msgstr "ここに例があります::" -#: ../../library/ctypes.rst:1802 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"m\")\n" @@ -2941,15 +3547,23 @@ msgid "" "'libbz2.so.1.0'\n" ">>>" msgstr "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"m\")\n" +"'libm.so.6'\n" +">>> find_library(\"c\")\n" +"'libc.so.6'\n" +">>> find_library(\"bz2\")\n" +"'libbz2.so.1.0'\n" +">>>" -#: ../../library/ctypes.rst:1811 msgid "" "On macOS and Android, :func:`!find_library` uses the system's standard " "naming schemes and paths to locate the library, and returns a full pathname " "if successful::" msgstr "" +"macOS と Android では、:func:`!find_library` はシステム標準の命名規則とパスを" +"使ってライブラリを探し、成功するとフルパス名を返します。 ::" -#: ../../library/ctypes.rst:1815 msgid "" ">>> from ctypes.util import find_library\n" ">>> find_library(\"c\")\n" @@ -2962,26 +3576,42 @@ msgid "" "'/System/Library/Frameworks/AGL.framework/AGL'\n" ">>>" msgstr "" +">>> from ctypes.util import find_library\n" +">>> find_library(\"c\")\n" +"'/usr/lib/libc.dylib'\n" +">>> find_library(\"m\")\n" +"'/usr/lib/libm.dylib'\n" +">>> find_library(\"bz2\")\n" +"'/usr/lib/libbz2.dylib'\n" +">>> find_library(\"AGL\")\n" +"'/System/Library/Frameworks/AGL.framework/AGL'\n" +">>>" -#: ../../library/ctypes.rst:1826 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 "" +"Windows では、:func:`!find_library` はシステムの検索パスに沿って探し、フルパ" +"ス名を返します。\n" +"ただし、定義済みの命名規則がないため、``find_library(\"c\")`` のような呼び出" +"しは失敗して ``None`` を返します。" -#: ../../library/ctypes.rst:1833 msgid "" "Returns the filename of the VC runtime library used by Python, and by the " "extension modules." msgstr "" +"Python と拡張モジュールが使用する VC ランタイムライブラリのファイル名を返しま" +"す。" -#: ../../library/ctypes.rst:1836 msgid "" "If the name of the library cannot be determined, ``None`` is returned. " "Notably, this will happen for recent versions of the VC runtime library, " "which are not directly loadable." msgstr "" +"ライブラリ名を判定できない場合は ``None`` を返します。\n" +"特に、最近のバージョンの VC ランタイムライブラリは直接ロードできないため、こ" +"の結果になります。" #: ../../library/ctypes.rst:1840 msgid "" @@ -2993,46 +3623,53 @@ msgstr "" "放する必要があるなら、メモリ割り付けを行ったのと同じライブラリの関数を使うこ" "とが重要です。" -#: ../../library/ctypes.rst:1850 msgid "Listing loaded shared libraries" -msgstr "" +msgstr "ロード済み共有ライブラリの一覧取得" -#: ../../library/ctypes.rst:1852 msgid "" "When writing code that relies on code loaded from shared libraries, it can " "be useful to know which shared libraries have already been loaded into the " "current process." msgstr "" +"共有ライブラリからロードしたコードに依存するコードを書く場合、現在のプロセス" +"にどの共有ライブラリがすでにロードされているかを知ると役立つことがあります。" -#: ../../library/ctypes.rst:1856 msgid "" "The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` " "function, which calls the different APIs provided by the various platforms " "to help determine which shared libraries have already been loaded into the " "current process." msgstr "" +":mod:`!ctypes.util` モジュールの :func:`~ctypes.util.dllist` 関数は、各プラッ" +"トフォームが提供する異なる API を呼び出して、現在のプロセスにすでにロードされ" +"た共有ライブラリを調べます。" -#: ../../library/ctypes.rst:1860 msgid "" "The exact output of this function will be system dependent. On most " "platforms, the first entry of this list represents the current process " "itself, which may be an empty string. For example, on glibc-based Linux, the " "return may look like::" msgstr "" +"この関数の具体的な出力はシステムに依存します。\n" +"ほとんどのプラットフォームでは、リストの最初の要素は現在のプロセス自体を表" +"し、空文字列の場合もあります。\n" +"例えば、glibc を使う Linux では次のような結果を返すことがあります。 ::" -#: ../../library/ctypes.rst:1865 msgid "" ">>> from ctypes.util import dllist\n" ">>> dllist()\n" "['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" "linux-gnu/libc.so.6', ... ]" msgstr "" +">>> from ctypes.util import dllist\n" +">>> dllist()\n" +"['', 'linux-vdso.so.1', '/lib/x86_64-linux-gnu/libm.so.6', '/lib/x86_64-" +"linux-gnu/libc.so.6', ... ]" #: ../../library/ctypes.rst:1872 msgid "Foreign functions" msgstr "外部関数" -#: ../../library/ctypes.rst:1874 msgid "" "As explained in the previous section, foreign functions can be accessed as " "attributes of loaded shared libraries. The function objects created in this " @@ -3040,14 +3677,20 @@ msgid "" "instances as arguments, and return the default result type specified by the " "library loader." msgstr "" +"前の節で説明したとおり、外部関数にはロード済み共有ライブラリの属性としてアク" +"セスできます。\n" +"この方法で作成した関数オブジェクトは、デフォルトで任意の数の引数を受け付け、" +"任意の ctypes データインスタンスを引数に取ります。\n" +"戻り値の型は、ライブラリローダーが指定するデフォルトの型になります。" -#: ../../library/ctypes.rst:1879 msgid "" "They are instances of a private local class :class:`!_FuncPtr` (not exposed " "in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:" msgstr "" +"これらは、非公開の :class:`_CFuncPtr` クラスを継承する、非公開のローカルクラ" +"ス :class:`!_FuncPtr` のインスタンスです (:mod:`!ctypes` では公開されていませ" +"ん)。" -#: ../../library/ctypes.rst:1882 msgid "" ">>> import ctypes\n" ">>> lib = ctypes.CDLL(None)\n" @@ -3056,6 +3699,12 @@ msgid "" ">>> lib._FuncPtr is ctypes._CFuncPtr\n" "False" msgstr "" +">>> import ctypes\n" +">>> lib = ctypes.CDLL(None)\n" +">>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)\n" +"True\n" +">>> lib._FuncPtr is ctypes._CFuncPtr\n" +"False" #: ../../library/ctypes.rst:1893 msgid "Base class for C callable foreign functions." @@ -3085,7 +3734,6 @@ msgstr "" "外部関数の結果の型を指定するために ctypes 型を代入する。何も返さない関数を表" "す :c:expr:`void` に対しては ``None`` を使います。" -#: ../../library/ctypes.rst:1906 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:expr:`int`, and the " @@ -3094,6 +3742,13 @@ msgid "" "or error checking use a ctypes data type as :attr:`!restype` and assign a " "callable to the :attr:`errcheck` attribute." msgstr "" +"ctypes の型以外の、Python の呼び出し可能オブジェクトを代入することもできま" +"す。\n" +"この場合、関数は C の :c:expr:`int` を返すと仮定され、その整数を渡して呼び出" +"し可能オブジェクトを呼び出すことで、追加の処理やエラー検査を行えます。\n" +"この使い方は非推奨です。\n" +"より柔軟な後処理やエラー検査を行うには、:attr:`!restype` に ctypes のデータ型" +"を設定し、:attr:`errcheck` 属性に呼び出し可能オブジェクトを代入してください。" #: ../../library/ctypes.rst:1915 msgid "" @@ -3117,13 +3772,17 @@ msgid "" "object using ctypes conversion rules." msgstr "" -#: ../../library/ctypes.rst:1928 msgid "" "New: It is now possible to put items in argtypes which are not ctypes types, " "but each item must have a :meth:`~_CData.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 "" +"新機能: ``argtypes`` に ctypes の型以外の要素も指定できるようになりました。\n" +"ただし、各要素には、引数として使える値 (整数、文字列、ctypes インスタンス) を" +"返す :meth:`~_CData.from_param` メソッドが必要です。\n" +"これにより、独自のオブジェクトを関数の引数に適合させるアダプターを定義できま" +"す。" #: ../../library/ctypes.rst:1935 msgid "" @@ -3133,11 +3792,11 @@ msgstr "" "Python 関数または他の呼び出し可能オブジェクトをこの属性に代入します。呼び出し" "可能オブジェクトは三つ以上の引数とともに呼び出されます。" -#: ../../library/ctypes.rst:1942 msgid "" "*result* is what the foreign function returns, as specified by the :attr:`!" "restype` attribute." msgstr "" +"*result* は、:attr:`!restype` 属性で指定された型で外部関数が返す値です。" #: ../../library/ctypes.rst:1945 msgid "" @@ -3167,7 +3826,6 @@ msgstr "" "戻り値をチェックして、外部関数呼び出しが失敗しているなら例外を送出させること" "もできます。" -#: ../../library/ctypes.rst:1958 ../../library/ctypes.rst:1960 msgid "" "On Windows, when a foreign function call raises a system exception (for " "example, due to an access violation), it will be captured and replaced with " @@ -3175,13 +3833,19 @@ msgid "" "set_exception`` with argument ``code`` will be raised, allowing an audit " "hook to replace the exception with its own." msgstr "" +"Windows では、外部関数呼び出しがアクセス違反などのシステム例外を発生させる" +"と、それを捕捉して適切な Python 例外に置き換えます。\n" +"さらに、引数 ``code`` を持つ監査イベント ``ctypes.set_exception`` が発生し、" +"監査フックが独自の例外に置き換えられるようになります。" -#: ../../library/ctypes.rst:1966 ../../library/ctypes.rst:1968 msgid "" "Some ways to invoke foreign function calls as well as some of the functions " "in this module may raise an auditing event ``ctypes.call_function`` with " "arguments ``function pointer`` and ``arguments``." msgstr "" +"外部関数の呼び出し方によっては、またこのモジュールの一部の関数では、引数 " +"``function pointer`` と ``arguments`` を持つ監査イベント ``ctypes." +"call_function`` が発生する場合があります。" #: ../../library/ctypes.rst:1975 msgid "Function prototypes" @@ -3219,12 +3883,15 @@ msgstr "" "data:`errno` の値と交換されます。 *use_last_error* も Windows エラーコードに" "対するのと同様です。" -#: ../../library/ctypes.rst:1998 msgid "" "The returned function prototype creates functions that use the ``stdcall`` " "calling convention. The function will release the GIL during the call. " "*use_errno* and *use_last_error* have the same meaning as above." msgstr "" +"返された関数プロトタイプは、``stdcall`` 呼び出し規約を使う関数を作成しま" +"す。\n" +"関数は呼び出し中に GIL を解放します。\n" +"*use_errno* と *use_last_error* の意味は上記と同じです。" #: ../../library/ctypes.rst:2008 msgid "" @@ -3279,19 +3946,23 @@ msgstr "" "*iid* はオプションのインターフェイス識別子へのポインタで、拡張されたエラー情" "報の提供のために使われます。" -#: ../../library/ctypes.rst:2047 msgid "" "If *iid* is not specified, an :exc:`OSError` is raised if the COM method " "call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised " "instead." msgstr "" +"*iid* を指定しない場合、COM メソッドの呼び出しが失敗すると :exc:`OSError` を" +"送出します。\n" +"*iid* を指定した場合は、代わりに :exc:`~ctypes.COMError` を送出します。" -#: ../../library/ctypes.rst:2051 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 "" +"COM メソッドは特別な呼び出し規約を使います。\n" +":attr:`!argtypes` タプルで指定した引数に加えて、第 1 引数として COM インター" +"フェースへのポインタが必要です。" #: ../../library/ctypes.rst:2058 msgid "" @@ -3301,11 +3972,12 @@ msgstr "" "オプションの *paramflags* パラメータは上述した機能より多機能な外部関数ラッ" "パーを作成します。" -#: ../../library/ctypes.rst:2061 msgid "" "*paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr." "argtypes`." msgstr "" +"*paramflags* は、:attr:`~_CFuncPtr.argtypes` と同じ長さのタプルでなければなり" +"ません。" #: ../../library/ctypes.rst:2063 msgid "" @@ -3357,14 +4029,15 @@ msgstr "" msgid "The optional third item is the default value for this parameter." msgstr "オプションの第三要素はこのパラメータのデフォルト値です。" -#: ../../library/ctypes.rst:2084 msgid "" "The following 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 "" +"次の例では、Windows の ``MessageBoxW`` 関数をラップして、引数のデフォルト値と" +"名前付き引数をサポートする方法を示します。\n" +"Windows ヘッダーファイルの C 宣言は次のとおりです。 ::" -#: ../../library/ctypes.rst:2088 msgid "" "WINUSERAPI int WINAPI\n" "MessageBoxW(\n" @@ -3373,12 +4046,16 @@ msgid "" " LPCWSTR lpCaption,\n" " UINT uType);" msgstr "" +"WINUSERAPI int WINAPI\n" +"MessageBoxW(\n" +" HWND hWnd,\n" +" LPCWSTR lpText,\n" +" LPCWSTR lpCaption,\n" +" UINT uType);" -#: ../../library/ctypes.rst:2095 ../../library/ctypes.rst:2118 msgid "Here is the wrapping with :mod:`!ctypes`::" -msgstr "" +msgstr ":mod:`!ctypes` を使ったラップは次のようになります。 ::" -#: ../../library/ctypes.rst:2097 msgid "" ">>> from ctypes import c_int, WINFUNCTYPE, windll\n" ">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" @@ -3387,6 +4064,12 @@ msgid "" "\"Hello from ctypes\"), (1, \"flags\", 0)\n" ">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" msgstr "" +">>> from ctypes import c_int, WINFUNCTYPE, windll\n" +">>> from ctypes.wintypes import HWND, LPCWSTR, UINT\n" +">>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)\n" +">>> paramflags = (1, \"hwnd\", 0), (1, \"text\", \"Hi\"), (1, \"caption\", " +"\"Hello from ctypes\"), (1, \"flags\", 0)\n" +">>> MessageBox = prototype((\"MessageBoxW\", windll.user32), paramflags)" #: ../../library/ctypes.rst:2103 msgid "The ``MessageBox`` foreign function can now be called in these ways::" @@ -3394,12 +4077,14 @@ msgstr "" "これで外部関数の ``MessageBox`` を次のような方法で呼び出すことができるように" "なりました::" -#: ../../library/ctypes.rst:2105 msgid "" ">>> MessageBox()\n" ">>> MessageBox(text=\"Spam, spam, spam\")\n" ">>> MessageBox(flags=2, text=\"foo bar\")" msgstr "" +">>> MessageBox()\n" +">>> MessageBox(text=\"Spam, spam, spam\")\n" +">>> MessageBox(flags=2, text=\"foo bar\")" #: ../../library/ctypes.rst:2109 msgid "" @@ -3412,15 +4097,17 @@ msgstr "" "数は、指定されたウィンドウの大きさを呼び出し側が与える ``RECT`` 構造体へコ" "ピーすることで取り出します。 C の宣言はこうです。::" -#: ../../library/ctypes.rst:2113 msgid "" "WINUSERAPI BOOL WINAPI\n" "GetWindowRect(\n" " HWND hWnd,\n" " LPRECT lpRect);" msgstr "" +"WINUSERAPI BOOL WINAPI\n" +"GetWindowRect(\n" +" HWND hWnd,\n" +" LPRECT lpRect);" -#: ../../library/ctypes.rst:2120 msgid "" ">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" ">>> from ctypes.wintypes import BOOL, HWND, RECT\n" @@ -3430,6 +4117,13 @@ msgid "" "paramflags)\n" ">>>" msgstr "" +">>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError\n" +">>> from ctypes.wintypes import BOOL, HWND, RECT\n" +">>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))\n" +">>> paramflags = (1, \"hwnd\"), (2, \"lprect\")\n" +">>> GetWindowRect = prototype((\"GetWindowRect\", windll.user32), " +"paramflags)\n" +">>>" #: ../../library/ctypes.rst:2127 msgid "" @@ -3443,7 +4137,6 @@ msgstr "" "れ自動的に返します。そのため、GetWindowRect 関数は呼び出されると RECT インス" "タンスを返します。" -#: ../../library/ctypes.rst:2132 msgid "" "Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` " "protocol to do further output processing and error checking. The win32 " @@ -3451,8 +4144,11 @@ msgid "" "failure, so this function could do the error checking, and raises an " "exception when the api call failed::" msgstr "" +"出力引数は :attr:`~_CFuncPtr.errcheck` プロトコルと組み合わせて、出力の追加処" +"理やエラー検査を行えます。\n" +"win32 API の ``GetWindowRect`` 関数は成功か失敗かを ``BOOL`` で返すので、次の" +"関数でエラーを検査し、API 呼び出しが失敗した場合に例外を送出できます。 ::" -#: ../../library/ctypes.rst:2137 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3462,8 +4158,14 @@ msgid "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" msgstr "" +">>> def errcheck(result, func, args):\n" +"... if not result:\n" +"... raise WinError()\n" +"... return args\n" +"...\n" +">>> GetWindowRect.errcheck = errcheck\n" +">>>" -#: ../../library/ctypes.rst:2145 msgid "" "If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it " "receives unchanged, :mod:`!ctypes` continues the normal processing it does " @@ -3472,8 +4174,12 @@ msgid "" "the function and return them instead, the normal processing will no longer " "take place::" msgstr "" +":attr:`~_CFuncPtr.errcheck` 関数が受け取った引数タプルをそのまま返すと、:mod:" +"`!ctypes` は出力引数に対する通常の処理を続けます。\n" +"``RECT`` インスタンスの代わりにウィンドウ座標のタプルを返したい場合は、関数内" +"でフィールドを取得してそれらを返せます。\n" +"この場合、通常の処理は行われなくなります。 ::" -#: ../../library/ctypes.rst:2151 msgid "" ">>> def errcheck(result, func, args):\n" "... if not result:\n" @@ -3484,6 +4190,14 @@ msgid "" ">>> GetWindowRect.errcheck = errcheck\n" ">>>" msgstr "" +">>> def errcheck(result, func, args):\n" +"... if not result:\n" +"... raise WinError()\n" +"... rc = args[1]\n" +"... return rc.left, rc.top, rc.bottom, rc.right\n" +"...\n" +">>> GetWindowRect.errcheck = errcheck\n" +">>>" #: ../../library/ctypes.rst:2164 msgid "Utility functions" @@ -3497,13 +4211,12 @@ msgstr "" "メモリバッファのアドレスを示す整数を返します。 *obj* は ctypes 型のインスタン" "スでなければなりません。" -#: ../../library/ctypes.rst:2171 msgid "" "Raises an :ref:`auditing event ` ``ctypes.addressof`` with " "argument ``obj``." msgstr "" "引数 ``obj`` を指定して :ref:`監査イベント ` ``ctypes.addressof`` " -"を送出します。 " +"を送出します。" #: ../../library/ctypes.rst:2176 msgid "" @@ -3527,9 +4240,8 @@ msgid "``byref(obj, offset)`` corresponds to this C code::" msgstr "" "``byref(obj, offset)`` は、 C コードとしては、以下のようにみなされます。::" -#: ../../library/ctypes.rst:2188 msgid "(((char *)&obj) + offset)" -msgstr "" +msgstr "(((char *)&obj) + offset)" #: ../../library/ctypes.rst:2190 msgid "" @@ -3539,25 +4251,29 @@ msgstr "" "返されるオブジェクトは外部関数呼び出しのパラメータとしてのみ使用できます。" "``pointer(obj)`` と似たふるまいをしますが、作成が非常に速く行えます。" -#: ../../library/ctypes.rst:2196 msgid "" "Copies a COM pointer from *src* to *dst* and returns the Windows specific :c:" "type:`!HRESULT` value." msgstr "" +"COM ポインタを *src* から *dst* にコピーし、Windows 固有の :c:type:`!" +"HRESULT` 値を返します。" -#: ../../library/ctypes.rst:2199 msgid "" "If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the " "reference count." msgstr "" +"*src* が ``NULL`` でない場合、その ``AddRef`` メソッドを呼び出して参照カウン" +"トを増やします。" -#: ../../library/ctypes.rst:2202 msgid "" "In contrast, the reference count of *dst* will not be decremented before " "assigning the new value. Unless *dst* is ``NULL``, the caller is responsible " "for decrementing the reference count by calling its ``Release`` method when " "necessary." msgstr "" +"一方、新しい値を代入する前に *dst* の参照カウントを減らすことはありません。\n" +"*dst* が ``NULL`` でなければ、呼び出し側が必要に応じてその ``Release`` メソッ" +"ドを呼び出し、参照カウントを減らす責任を持ちます。" #: ../../library/ctypes.rst:2214 msgid "" @@ -3578,41 +4294,46 @@ msgstr "" "この関数は変更可能な文字バッファを作成します。返されるオブジェクトは :class:" "`c_char` の ctypes 配列です。" -#: ../../library/ctypes.rst:2226 msgid "" "If *size* is given (and not ``None``), it must be an :class:`int`. It " "specifies the size of the returned array." msgstr "" +"*size* を指定する場合 (``None`` 以外の場合)、:class:`int` でなければなりませ" +"ん。\n" +"返す配列のサイズを指定します。" -#: ../../library/ctypes.rst:2229 msgid "" "If the *init* argument is given, it must be :class:`bytes`. It is used to " "initialize the array items. Bytes not initialized this way are set to zero " "(NUL)." msgstr "" +"*init* 引数を指定する場合、:class:`bytes` でなければなりません。\n" +"配列の要素の初期化に使います。\n" +"この方法で初期化されないバイトは、ゼロ (NUL) に設定されます。" -#: ../../library/ctypes.rst:2233 msgid "" "If *size* is not given (or if it is ``None``), the buffer is made one " "element larger than *init*, effectively adding a NUL terminator." msgstr "" +"*size* を省略した場合 (または ``None`` の場合)、バッファを *init* より 1 要素" +"分大きくすることで、実質的に NUL 終端文字を追加します。" -#: ../../library/ctypes.rst:2236 msgid "" "If both arguments are given, *size* must not be less than ``len(init)``." msgstr "" +"両方の引数を指定する場合、*size* は ``len(init)`` 以上でなければなりません。" -#: ../../library/ctypes.rst:2240 msgid "" "If *size* is equal to ``len(init)``, a NUL terminator is not added. Do not " "treat such a buffer as a C string." msgstr "" +"*size* が ``len(init)`` と等しい場合、NUL 終端文字は追加されません。\n" +"そのようなバッファを C 文字列として扱わないでください。" #: ../../library/ctypes.rst:2243 msgid "For example::" msgstr "例えば::" -#: ../../library/ctypes.rst:2245 msgid "" ">>> bytes(create_string_buffer(2))\n" "b'\\x00\\x00'\n" @@ -3627,14 +4348,25 @@ msgid "" " ...\n" "ValueError: byte string too long" msgstr "" +">>> bytes(create_string_buffer(2))\n" +"b'\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'ab'))\n" +"b'ab\\x00'\n" +">>> bytes(create_string_buffer(b'ab', 2))\n" +"b'ab'\n" +">>> bytes(create_string_buffer(b'ab', 4))\n" +"b'ab\\x00\\x00'\n" +">>> bytes(create_string_buffer(b'abcdef', 2))\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: byte string too long" -#: ../../library/ctypes.rst:2258 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_string_buffer`` " "with arguments ``init``, ``size``." msgstr "" "引数 ``init``, ``size`` を指定して :ref:`監査イベント ` ``ctypes." -"create_string_buffer`` を送出します。 " +"create_string_buffer`` を送出します。" #: ../../library/ctypes.rst:2264 msgid "" @@ -3644,61 +4376,76 @@ msgstr "" "この関数は変更可能な Unicode 文字バッファを作成します。返されるオブジェクト" "は :class:`c_wchar` の ctypes 配列です。" -#: ../../library/ctypes.rst:2267 msgid "" "The function takes the same arguments as :func:`~create_string_buffer` " "except *init* must be a string and *size* counts :class:`c_wchar`." msgstr "" +"この関数は :func:`~create_string_buffer` と同じ引数を取りますが、*init* は文" +"字列である必要があり、*size* は :class:`c_wchar` の個数を表します。" -#: ../../library/ctypes.rst:2270 msgid "" "Raises an :ref:`auditing event ` ``ctypes.create_unicode_buffer`` " "with arguments ``init``, ``size``." msgstr "" "引数 ``init``, ``size`` を指定して :ref:`監査イベント ` ``ctypes." -"create_unicode_buffer`` を送出します。 " +"create_unicode_buffer`` を送出します。" -#: ../../library/ctypes.rst:2275 msgid "" "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 "" +"この関数は、ctypes でプロセス内 COM サーバーを実装するためのフックです。\n" +"``_ctypes`` 拡張 DLL がエクスポートする ``DllCanUnloadNow()`` 関数から呼び出" +"されます。" -#: ../../library/ctypes.rst:2284 msgid "" "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 "" +"この関数は、ctypes でプロセス内 COM サーバーを実装するためのフックです。\n" +"``_ctypes`` 拡張 DLL がエクスポートする ``DllGetClassObject()`` 関数から呼び" +"出されます。" -#: ../../library/ctypes.rst:2294 msgid "" "Try to provide a list of paths of the shared libraries loaded into the " "current process. These paths are not normalized or processed in any way. " "The function can raise :exc:`OSError` if the underlying platform APIs fail. " "The exact functionality is system dependent." msgstr "" +"現在のプロセスにロードされた共有ライブラリのパスの一覧を取得しようとしま" +"す。\n" +"これらのパスには正規化などの処理は一切行いません。\n" +"基盤となるプラットフォーム API が失敗した場合、:exc:`OSError` を送出すること" +"があります。\n" +"厳密な動作はシステムに依存します。" -#: ../../library/ctypes.rst:2299 msgid "" "On most platforms, the first element of the list represents the current " "executable file. It may be an empty string." msgstr "" +"ほとんどのプラットフォームでは、リストの最初の要素は現在の実行ファイルを表し" +"ます。\n" +"空文字列の場合もあります。" -#: ../../library/ctypes.rst:2307 msgid "" "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 :" "func:`GetLastError`." msgstr "" +"エラーコード *code* の説明文を返します。\n" +"エラーコードを指定しない場合は、Windows API 関数 :func:`GetLastError` を呼び" +"出して最後のエラーコードを取得し、それを使用します。" -#: ../../library/ctypes.rst:2316 msgid "" "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 "" +"呼び出し元スレッドで Windows が設定した最後のエラーコードを返します。\n" +"Windows の ``GetLastError()`` 関数を直接呼び出し、ctypes 内部のエラーコードの" +"コピーは返しません。" #: ../../library/ctypes.rst:2325 msgid "" @@ -3708,27 +4455,25 @@ msgstr "" "システムの :data:`errno` 変数の、スレッドローカルなプライベートコピーを返しま" "す。" -#: ../../library/ctypes.rst:2328 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_errno`` with no " "arguments." msgstr "" -"引数無しで :ref:`監査イベント ` ``ctypes.get_errno`` を送出しま" -"す。 " +"引数無しで :ref:`監査イベント ` ``ctypes.get_errno`` を送出します。" -#: ../../library/ctypes.rst:2332 msgid "" "Returns the current value of the ctypes-private copy of the system :data:`!" "LastError` variable in the calling thread." msgstr "" +"呼び出し元スレッドにある、システムの :data:`!LastError` 変数の ctypes 内部の" +"コピーの現在値を返します。" -#: ../../library/ctypes.rst:2337 msgid "" "Raises an :ref:`auditing event ` ``ctypes.get_last_error`` with no " "arguments." msgstr "" "引数無しで :ref:`監査イベント ` ``ctypes.get_last_error`` を送出し" -"ます。 " +"ます。" #: ../../library/ctypes.rst:2342 msgid "" @@ -3750,14 +4495,16 @@ msgstr "" "ロックを値 *c* を *count* バイト分書き込みます。 *dst* はアドレスを指定する整" "数または ctypes インスタンスである必要があります。" -#: ../../library/ctypes.rst:2356 msgid "" "Create or return a ctypes pointer type. Pointer types are cached and reused " "internally, so calling this function repeatedly is cheap. *type* must be a " "ctypes type." msgstr "" +"ctypes のポインタ型を作成するか、既存の型を返します。\n" +"ポインタ型は内部でキャッシュされて再利用されるため、繰り返し呼び出しても負荷" +"は小さくなります。\n" +"*type* は ctypes の型でなければなりません。" -#: ../../library/ctypes.rst:2362 msgid "" "The resulting pointer type is cached in the ``__pointer_type__`` attribute " "of *type*. It is possible to set this attribute before the first call to " @@ -3765,12 +4512,20 @@ msgid "" "discouraged: manually creating a suitable pointer type is difficult without " "relying on implementation details that may change in future Python versions." msgstr "" +"結果のポインタ型は、*type* の ``__pointer_type__`` 属性にキャッシュされま" +"す。\n" +"最初に ``POINTER`` を呼び出す前にこの属性を設定すれば、独自のポインタ型を指定" +"できます。\n" +"ただし、この方法は推奨しません。\n" +"将来の Python バージョンで変わりうる実装の詳細に依存せず、適切なポインタ型を" +"手動で作成することは難しいためです。" -#: ../../library/ctypes.rst:2373 msgid "" "Create a new pointer instance, pointing to *obj*. The returned object is of " "the type ``POINTER(type(obj))``." msgstr "" +"*obj* を指す新しいポインタインスタンスを作成します。\n" +"返されるオブジェクトの型は ``POINTER(type(obj))`` です。" #: ../../library/ctypes.rst:2376 msgid "" @@ -3800,28 +4555,27 @@ msgstr "" "システム変数 :data:`errno` の、呼び出し元スレッドでの ctypes のプライベートコ" "ピーの現在値を *value* に設定し、前の値を返します。" -#: ../../library/ctypes.rst:2393 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_errno`` with " "argument ``errno``." msgstr "" "引数 ``errno`` を指定して :ref:`監査イベント ` ``ctypes." -"set_errno`` を送出します。 " +"set_errno`` を送出します。" -#: ../../library/ctypes.rst:2398 msgid "" "Sets 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 "" +"呼び出し元スレッドにある、システムの :data:`!LastError` 変数の ctypes 内部の" +"コピーの現在値を *value* に設定し、以前の値を返します。" -#: ../../library/ctypes.rst:2404 msgid "" "Raises an :ref:`auditing event ` ``ctypes.set_last_error`` with " "argument ``error``." msgstr "" "引数 ``error`` を指定して :ref:`監査イベント ` ``ctypes." -"set_last_error`` を送出します。 " +"set_last_error`` を送出します。" #: ../../library/ctypes.rst:2409 msgid "" @@ -3831,59 +4585,72 @@ msgstr "" "ctypes の型やインスタンスのメモリバッファのサイズをバイト数で返します。C の " "``sizeof`` 演算子と同様の動きをします。" -#: ../../library/ctypes.rst:2415 msgid "" "Return the byte string at *void \\*ptr*. If *size* is specified, it is used " "as size, otherwise the string is assumed to be zero-terminated." msgstr "" +"*void \\*ptr* にあるバイト文字列を返します。\n" +"*size* を指定した場合はそのサイズを使い、省略した場合はゼロ終端文字列と仮定し" +"ます。" -#: ../../library/ctypes.rst:2419 msgid "" "Raises an :ref:`auditing event ` ``ctypes.string_at`` with " "arguments ``ptr``, ``size``." msgstr "" +"引数 ``ptr``、``size`` を持つ :ref:`監査イベント ` ``ctypes." +"string_at`` が発生します。" -#: ../../library/ctypes.rst:2424 msgid "" "Creates an instance of :exc:`OSError`. If *code* is not specified, :func:" "`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 "" +":exc:`OSError` のインスタンスを作成します。\n" +"*code* を指定しない場合は、:func:`GetLastError` を呼び出してエラーコードを取" +"得します。\n" +"*descr* を指定しない場合は、:func:`FormatError` を呼び出してエラーの説明文を" +"取得します。" -#: ../../library/ctypes.rst:2431 msgid "" "An instance of :exc:`WindowsError` used to be created, which is now an alias " "of :exc:`OSError`." msgstr "" +"以前は :exc:`WindowsError` のインスタンスを作成していましたが、現在は :exc:" +"`OSError` の別名になっています。" -#: ../../library/ctypes.rst:2438 msgid "" "Return the wide-character string at *void \\*ptr*. 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 "" +"*void \\*ptr* にあるワイド文字列を返します。\n" +"*size* を指定した場合は文字数として使い、省略した場合はゼロ終端文字列と仮定し" +"ます。" -#: ../../library/ctypes.rst:2443 msgid "" "Raises an :ref:`auditing event ` ``ctypes.wstring_at`` with " "arguments ``ptr``, ``size``." msgstr "" +"引数 ``ptr``、``size`` を持つ :ref:`監査イベント ` ``ctypes." +"wstring_at`` が発生します。" -#: ../../library/ctypes.rst:2448 msgid "" "Return a :class:`memoryview` object of length *size* that references memory " "starting at *void \\*ptr*." msgstr "" +"*void \\*ptr* から始まるメモリを参照する、長さ *size* の :class:`memoryview` " +"オブジェクトを返します。" -#: ../../library/ctypes.rst:2451 msgid "" "If *readonly* is true, the returned :class:`!memoryview` object can not be " "used to modify the underlying memory. (Changes made by other means will " "still be reflected in the returned object.)" msgstr "" +"*readonly* が真の場合、返される :class:`!memoryview` オブジェクトを使って参照" +"先のメモリを変更することはできません (ほかの方法で行った変更は、返されたオブ" +"ジェクトにも反映されます)。" -#: ../../library/ctypes.rst:2456 msgid "" "This function is similar to :func:`string_at` with the key difference of not " "making a copy of the specified memory. It is a semantically equivalent (but " @@ -3892,12 +4659,19 @@ msgid "" "integers, *ptr* can also be given as a :class:`ctypes.POINTER` or a :func:" "`~ctypes.byref` object.)" msgstr "" +"この関数は :func:`string_at` に似ていますが、指定したメモリのコピーを作成しな" +"い点が大きく異なります。\n" +"``memoryview((c_byte * size).from_address(ptr))`` と意味的に同等で、より効率" +"的な代替手段です。\n" +":meth:`~_CData.from_address` は整数のみを受け付けますが、*ptr* には :class:" +"`ctypes.POINTER` や :func:`~ctypes.byref` のオブジェクトも指定できます。" -#: ../../library/ctypes.rst:2463 msgid "" "Raises an :ref:`auditing event ` ``ctypes.memoryview_at`` with " "arguments ``address``, ``size``, ``readonly``." msgstr "" +"引数 ``address``、``size``、``readonly`` を持つ :ref:`監査イベント " +"` ``ctypes.memoryview_at`` が発生します。" #: ../../library/ctypes.rst:2471 msgid "Data types" @@ -3919,13 +4693,13 @@ msgstr "" "す。これはメモリブロックがポインタを含む場合に存続し続ける必要のある他の " "Python オブジェクトを含んでいます。" -#: ../../library/ctypes.rst:2483 msgid "" "Common methods of ctypes data types, these are all class methods (to be " "exact, they are methods of the :term:`metaclass`):" msgstr "" -"ctypes データ型の共通メソッド、すべてのクラスメソッドが存在します (正確に" -"は、 :term:`メタクラス ` のメソッドです):" +"ctypes データ型に共通のメソッドです。\n" +"すべてクラスメソッドです (正確には :term:`メタクラス ` のメソッド" +"です):" #: ../../library/ctypes.rst:2488 msgid "" @@ -3941,13 +4715,12 @@ msgstr "" "ファのオフセットをバイト単位で指定します。デフォルトではゼロです。もし " "*source* バッファが十分に大きくなければ、 :exc:`ValueError` が送出されます。" -#: ../../library/ctypes.rst:2494 ../../library/ctypes.rst:2504 msgid "" "Raises an :ref:`auditing event ` ``ctypes.cdata/buffer`` with " "arguments ``pointer``, ``size``, ``offset``." msgstr "" "引数 ``pointer``, ``size``, ``offset`` を指定して :ref:`監査イベント " -"` ``ctypes.cdata/buffer`` を送出します。 " +"` ``ctypes.cdata/buffer`` を送出します。" #: ../../library/ctypes.rst:2498 msgid "" @@ -3970,19 +4743,23 @@ msgstr "" "このメソッドは *address* で指定されたメモリを使って ctypes 型のインスタンスを" "返します。 *address* は整数でなければなりません。" -#: ../../library/ctypes.rst:2511 ../../library/ctypes.rst:2513 msgid "" "This method, and others that indirectly call this method, raises an :ref:" "`auditing event ` ``ctypes.cdata`` with argument ``address``." msgstr "" +"このメソッドと、それを間接的に呼び出すメソッドは、引数 ``address`` を持つ :" +"ref:`監査イベント ` ``ctypes.cdata`` を発生させます。" -#: ../../library/ctypes.rst:2519 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:`~_CFuncPtr.argtypes` tuple; it must return an " "object that can be used as a function call parameter." msgstr "" +"*obj* を ctypes の型に適合させるメソッドです。\n" +"外部関数の :attr:`~_CFuncPtr.argtypes` タプルにその型が含まれている場合、実際" +"の関数呼び出しで使われるオブジェクトを渡して呼び出されます。\n" +"関数呼び出しの引数として使えるオブジェクトを返す必要があります。" #: ../../library/ctypes.rst:2524 msgid "" @@ -4004,16 +4781,17 @@ msgstr "" "ンスを返します。 *name* はエクスポートされたデータの名前で、 *library* はロー" "ドされた共有ライブラリです。" -#: ../../library/ctypes.rst:2534 msgid "Common class variables of ctypes data types:" -msgstr "" +msgstr "ctypes データ型に共通のクラス変数:" -#: ../../library/ctypes.rst:2538 msgid "" "The pointer type that was created by calling :func:`POINTER` for " "corresponding ctypes data type. If a pointer type was not yet created, the " "attribute is missing." msgstr "" +"対応する ctypes データ型に対して :func:`POINTER` を呼び出して作成したポインタ" +"型です。\n" +"まだポインタ型を作成していない場合、この属性は存在しません。" #: ../../library/ctypes.rst:2544 msgid "Common instance variables of ctypes data types:" @@ -4051,7 +4829,6 @@ msgstr "" "オブジェクトはデバッグでのみ使われます。決してディクショナリの内容を変更しな" "いで下さい。" -#: ../../library/ctypes.rst:2573 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 " @@ -4059,38 +4836,42 @@ msgid "" "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 "" -"この非公開クラスは、全ての基本的な ctypes データ型の基底クラスです。これは基" -"本的な ctypes データ型に共通の属性を持っているので、ここで触れておきます。 :" -"class:`_SimpleCData` は :class:`_CData` の子クラスなので、そのメソッドと属性" -"を継承しています。ポインタでないかポインタを含まない ctypes データ型は、現在" -"は pickle 化できます。" +"この非公開クラスは、全ての基本的な ctypes データ型の基底クラスです。\n" +"これは基本的な ctypes データ型に共通の属性を持っているので、ここで触れておき" +"ます。\n" +":class:`_SimpleCData` は :class:`_CData` の子クラスなので、そのメソッドと属性" +"を継承しています。\n" +"ポインタそのものではなく、ポインタも含まない ctypes データ型は、現在は " +"pickle 化できます。" #: ../../library/ctypes.rst:2579 msgid "Instances have a single attribute:" msgstr "インスタンスは一つだけ属性を持ちます:" -#: ../../library/ctypes.rst:2583 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 "" -"この属性は、インスタンスの実際の値を持ちます。整数型とポインタ型に対しては整" -"数型、文字型に対しては一文字のバイト列オブジェクト、文字へのポインタに対して" -"は Python のバイト列オブジェクトもしくは文字列となります。" +"この属性はインスタンスの実際の値を保持します。\n" +"整数型とポインタ型では整数、文字型では一文字の bytes オブジェクトまたは文字" +"列、文字へのポインタ型では Python の bytes オブジェクトまたは文字列です。" -#: ../../library/ctypes.rst:2588 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 "" +"ctypes インスタンスから ``value`` 属性を取得すると、通常は毎回新しいオブジェ" +"クトが返されます。\n" +":mod:`!ctypes` は元のオブジェクトを返す機能を実装 *しておらず*、常に新しいオ" +"ブジェクトを構築します。\n" +"これは、ほかのすべての ctypes オブジェクトのインスタンスにも当てはまります。" -#: ../../library/ctypes.rst:2593 msgid "Each subclass has a class attribute:" -msgstr "" +msgstr "各サブクラスには、以下のクラス属性があります:" #: ../../library/ctypes.rst:2597 msgid "" @@ -4109,13 +4890,16 @@ msgid "" "code will be unused." msgstr "" -#: ../../library/ctypes.rst:2612 msgid "" "The :mod:`array` and :ref:`struct ` modules, as well as " "third-party modules like `numpy `__, use similar -- but " "slightly different -- type codes." msgstr "" +":mod:`array` モジュールや :ref:`struct ` モジュール、" +"`numpy `__ などのサードパーティー製モジュールでも、似てはいるも" +"のの少し異なる型コードを使用しています。" #: ../../library/ctypes.rst:2617 msgid "" @@ -4127,13 +4911,16 @@ msgid "" "instance." msgstr "" -#: ../../library/ctypes.rst:2625 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 "" +"基本データ型のサブクラスは、この動作を継承 *しません*。\n" +"したがって、外部関数の :attr:`!restype` が :class:`c_void_p` のサブクラスの場" +"合、関数呼び出しからそのサブクラスのインスタンスを受け取ります。\n" +"もちろん、``value`` 属性にアクセスすればポインタの値を取得できます。" #: ../../library/ctypes.rst:2630 msgid "These are the fundamental ctypes data types:" @@ -4197,23 +4984,26 @@ msgstr "" "C :c:expr:`float` データ型を表します。コンストラクタはオプションの浮動小数点" "数初期化子を受け取ります。" -#: ../../library/ctypes.rst:2674 msgid "" "Represents the C :c:expr:`double complex` datatype, if available. The " "constructor accepts an optional :class:`complex` initializer." msgstr "" +"利用可能な場合に、C の :c:expr:`double complex` データ型を表します。\n" +"コンストラクタは省略可能な :class:`complex` の初期値を受け付けます。" -#: ../../library/ctypes.rst:2682 msgid "" "Represents the C :c:expr:`float complex` datatype, if available. The " "constructor accepts an optional :class:`complex` initializer." msgstr "" +"利用可能な場合に、C の :c:expr:`float complex` データ型を表します。\n" +"コンストラクタは省略可能な :class:`complex` の初期値を受け付けます。" -#: ../../library/ctypes.rst:2690 msgid "" "Represents the C :c:expr:`long double complex` datatype, if available. The " "constructor accepts an optional :class:`complex` initializer." msgstr "" +"利用可能な場合に、C の :c:expr:`long double complex` データ型を表します。\n" +"コンストラクタは省略可能な :class:`complex` の初期値を受け付けます。" #: ../../library/ctypes.rst:2698 msgid "" @@ -4225,11 +5015,12 @@ msgstr "" "期化子を受け取ります。オーバーフローのチェックは行われません。 ``sizeof(int) " "== sizeof(long)`` であるプラットフォームでは、 :class:`c_long` の別名です。" -#: ../../library/ctypes.rst:2705 msgid "" "Represents the C 8-bit :c:expr:`signed int` datatype. It is an alias for :" "class:`c_byte`." msgstr "" +"C の 8 ビットの :c:expr:`signed int` データ型を表します。\n" +":class:`c_byte` の別名です。" #: ../../library/ctypes.rst:2711 msgid "" @@ -4263,13 +5054,17 @@ msgstr "" "C :c:expr:`signed long` データ型を表します。コンストラクタはオプションの整数" "初期化子を受け取ります。オーバーフローのチェックは行われません。" -#: ../../library/ctypes.rst:2735 msgid "" "Represents the C :c:expr:`signed long long` datatype. The constructor " "accepts an optional integer initializer; no overflow checking is done. On " "platforms where ``sizeof(long long) == sizeof(long)`` it is an alias to :" "class:`c_long`." msgstr "" +"C の :c:expr:`signed long long` データ型を表します。\n" +"コンストラクタは省略可能な整数の初期値を受け付けますが、オーバーフローの検査" +"は行いません。\n" +"``sizeof(long long) == sizeof(long)`` となるプラットフォームでは、:class:" +"`c_long` の別名です。" #: ../../library/ctypes.rst:2743 msgid "" @@ -4279,24 +5074,29 @@ msgstr "" "C :c:expr:`signed short` データ型を表します。コンストラクタはオプションの整数" "初期化子を受け取ります。オーバーフローのチェックは行われません。" -#: ../../library/ctypes.rst:2749 msgid "" "Represents the C :c:type:`size_t` datatype. Usually an alias for another " "unsigned integer type." msgstr "" +"C の :c:type:`size_t` データ型を表します。\n" +"通常は、ほかの符号なし整数型の別名です。" -#: ../../library/ctypes.rst:2755 msgid "" "Represents the :c:type:`Py_ssize_t` datatype. This is a signed version of :c:" "type:`size_t`; that is, the POSIX :c:type:`ssize_t` type. Usually an alias " "for another integer type." msgstr "" +":c:type:`Py_ssize_t` データ型を表します。\n" +"これは :c:type:`size_t` の符号付き版、すなわち POSIX の :c:type:`ssize_t` 型" +"です。\n" +"通常は、ほかの整数型の別名です。" -#: ../../library/ctypes.rst:2765 msgid "" "Represents the C :c:type:`time_t` datatype. Usually an alias for another " "integer type." msgstr "" +"C の :c:type:`time_t` データ型を表します。\n" +"通常は、ほかの整数型の別名です。" #: ../../library/ctypes.rst:2773 msgid "" @@ -4319,11 +5119,12 @@ msgstr "" "``sizeof(int) == sizeof(long)`` であるプラットフォームでは :class:`c_ulong` " "の別名です。" -#: ../../library/ctypes.rst:2787 msgid "" "Represents the C 8-bit :c:expr:`unsigned int` datatype. It is an alias for :" "class:`c_ubyte`." msgstr "" +"C の 8 ビットの :c:expr:`unsigned int` データ型を表します。\n" +":class:`c_ubyte` の別名です。" #: ../../library/ctypes.rst:2793 msgid "" @@ -4410,11 +5211,12 @@ msgstr "" "表します。 ``True`` または ``False`` の値を持ち、コンストラクタは真偽値と解釈" "できるオブジェクトを受け取ります。" -#: ../../library/ctypes.rst:2858 msgid "" "Represents a :c:type:`!HRESULT` value, which contains success or error " "information for a function or method call." msgstr "" +"関数やメソッドの呼び出しの成功またはエラーに関する情報を含む :c:type:`!" +"HRESULT` 値を表します。" #: ../../library/ctypes.rst:2866 msgid "" @@ -4424,9 +5226,8 @@ msgstr "" "C :c:expr:`PyObject *` データ型を表します。引数なしでこれを呼び出すと " "``NULL`` :c:expr:`PyObject *` ポインタを作成します。" -#: ../../library/ctypes.rst:2869 msgid ":class:`!py_object` is now a :term:`generic type`." -msgstr "" +msgstr ":class:`!py_object` が :term:`generic type` になりました。" #: ../../library/ctypes.rst:2874 msgid "" @@ -4444,11 +5245,12 @@ msgstr "構造化データ型" msgid "Abstract base class for unions in native byte order." msgstr "ネイティブのバイトオーダーでの共用体のための抽象ベースクラス。" -#: ../../library/ctypes.rst:2890 msgid "" "Unions share common attributes and behavior with structures; see :class:" "`Structure` documentation for details." msgstr "" +"共用体は構造体と共通の属性と動作を持ちます。\n" +"詳細は :class:`Structure` のドキュメントを参照してください。" #: ../../library/ctypes.rst:2895 msgid "Abstract base class for unions in *big endian* byte order." @@ -4529,7 +5331,6 @@ msgstr "" "数を定義することができます。これにより、次のように自身を直接または間接的に参" "照するデータ型を作成できるようになります::" -#: ../../library/ctypes.rst:2945 msgid "" "class List(Structure):\n" " pass\n" @@ -4537,12 +5338,18 @@ msgid "" " ...\n" " ]" msgstr "" +"class List(Structure):\n" +" pass\n" +"List._fields_ = [(\"pnext\", POINTER(List)),\n" +" ...\n" +" ]" -#: ../../library/ctypes.rst:2951 msgid "" "The :attr:`!_fields_` class variable can only be set once. Later assignments " "will raise an :exc:`AttributeError`." msgstr "" +":attr:`!_fields_` クラス変数は 1 回だけ設定できます。\n" +"その後の代入では :exc:`AttributeError` を送出します。" #: ../../library/ctypes.rst:2954 msgid "" @@ -4554,123 +5361,155 @@ msgid "" "fields, as if :attr:`!_fields_` was empty." msgstr "" -#: ../../library/ctypes.rst:2962 msgid "" "Sub-subclasses of structure types inherit the fields of the base class plus " "the :attr:`_fields_` defined in the sub-subclass, if any." msgstr "" +"構造体型のサブクラスのサブクラスは、基底クラスのフィールドを継承し、さらに自" +"身で :attr:`_fields_` を定義していれば、そのフィールドも持ちます。" -#: ../../library/ctypes.rst:2968 msgid "" "An optional small integer that allows overriding the alignment of structure " "fields in the instance." msgstr "" +"インスタンス内の構造体フィールドのアラインメントを上書きするための、省略可能" +"な小さな整数です。" -#: ../../library/ctypes.rst:2971 msgid "" "This is only implemented for the MSVC-compatible memory layout (see :attr:" "`_layout_`)." msgstr "" +"これは MSVC 互換のメモリレイアウトでのみ実装されています (:attr:`_layout_` を" +"参照)。" -#: ../../library/ctypes.rst:2974 msgid "" "Setting :attr:`!_pack_` to 0 is the same as not setting it at all. " "Otherwise, the value must be a positive power of two. The effect is " "equivalent to ``#pragma pack(N)`` in C, except :mod:`!ctypes` may allow " "larger *n* than what the compiler accepts." msgstr "" +":attr:`!_pack_` に 0 を設定することは、設定しないことと同じです。\n" +"それ以外の場合、値は 2 のべき乗の正の整数でなければなりません。\n" +"効果は C の ``#pragma pack(N)`` と同じですが、:mod:`!ctypes` はコンパイラが受" +"け付けるより大きな *n* を許可する場合があります。" -#: ../../library/ctypes.rst:2979 msgid "" ":attr:`!_pack_` must already be defined when :attr:`_fields_` is assigned, " "otherwise it will have no effect." msgstr "" +":attr:`_fields_` に代入する時点で :attr:`!_pack_` が定義されていないと、効果" +"はありません。" -#: ../../library/ctypes.rst:2984 msgid "" "For historical reasons, if :attr:`!_pack_` is non-zero, the MSVC-compatible " "layout will be used by default. On non-Windows platforms, this default is " "deprecated and is slated to become an error in Python 3.19. If it is " "intended, set :attr:`~Structure._layout_` to ``'ms'`` explicitly." msgstr "" +"歴史的な理由から、:attr:`!_pack_` がゼロ以外の場合、デフォルトで MSVC 互換の" +"レイアウトを使用します。\n" +"Windows 以外のプラットフォームでは、このデフォルトの動作は非推奨であり、" +"Python 3.19 ではエラーになる予定です。\n" +"このレイアウトを意図している場合は、:attr:`~Structure._layout_` に ``'ms'`` " +"を明示的に設定してください。" -#: ../../library/ctypes.rst:2993 msgid "" "An optional small integer that allows increasing the alignment of the " "structure when being packed or unpacked to/from memory." msgstr "" +"構造体をメモリへパックしたりメモリからアンパックしたりするときのアラインメン" +"トを大きくする、省略可能な小さな整数です。" -#: ../../library/ctypes.rst:2996 msgid "" "The value must not be negative. The effect is equivalent to " "``__attribute__((aligned(N)))`` on GCC or ``#pragma align(N)`` on MSVC, " "except :mod:`!ctypes` may allow values that the compiler would reject." msgstr "" +"値は負であってはなりません。\n" +"効果は GCC の ``__attribute__((aligned(N)))`` や MSVC の ``#pragma " +"align(N)`` と同じですが、:mod:`!ctypes` はコンパイラが拒否する値を許可する場" +"合があります。" -#: ../../library/ctypes.rst:3001 msgid "" ":attr:`!_align_` can only *increase* a structure's alignment requirements. " "Setting it to 0 or 1 has no effect." msgstr "" +":attr:`!_align_` は、構造体のアラインメント要件を *大きくする* ことしかできま" +"せん。\n" +"0 や 1 に設定しても効果はありません。" -#: ../../library/ctypes.rst:3004 msgid "" "Using values that are not powers of two is discouraged and may lead to " "surprising behavior." msgstr "" +"2 のべき乗でない値の使用は推奨されず、予想外の動作を引き起こす場合がありま" +"す。" -#: ../../library/ctypes.rst:3007 msgid "" ":attr:`!_align_` must already be defined when :attr:`_fields_` is assigned, " "otherwise it will have no effect." msgstr "" +":attr:`_fields_` に代入する時点で :attr:`!_align_` が定義されていないと、効果" +"はありません。" -#: ../../library/ctypes.rst:3014 msgid "" "An optional string naming the struct/union layout. It can currently be set " "to:" msgstr "" +"構造体や共用体のレイアウト名を指定する、省略可能な文字列です。\n" +"現在は以下の値を指定できます:" -#: ../../library/ctypes.rst:3017 msgid "" "``\"ms\"``: the layout used by the Microsoft compiler (MSVC). On GCC and " "Clang, this layout can be selected with ``__attribute__((ms_struct))``." msgstr "" +"``\"ms\"``: Microsoft コンパイラ (MSVC) が使うレイアウトです。\n" +"GCC と Clang では、``__attribute__((ms_struct))`` でこのレイアウトを選べま" +"す。" -#: ../../library/ctypes.rst:3020 msgid "" "``\"gcc-sysv\"``: the layout used by GCC with the System V or “SysV-like” " "data model, as used on Linux and macOS. With this layout, :attr:`~Structure." "_pack_` must be unset or zero." msgstr "" +"``\"gcc-sysv\"``: Linux や macOS で使われる、System V または「SysV に似た」" +"データモデルで GCC が使うレイアウトです。\n" +"このレイアウトでは、:attr:`~Structure._pack_` を設定しないか、ゼロにする必要" +"があります。" -#: ../../library/ctypes.rst:3024 msgid "" "If not set explicitly, ``ctypes`` will use a default that matches the " "platform conventions. This default may change in future Python releases (for " "example, when a new platform gains official support, or when a difference " "between similar platforms is found). Currently the default will be:" msgstr "" +"明示的に設定しない場合、``ctypes`` はプラットフォームの慣例に合うデフォルト値" +"を使います。\n" +"このデフォルト値は、例えば新しいプラットフォームが正式にサポートされたり、似" +"たプラットフォーム間の違いが見つかったりした場合など、将来の Python リリース" +"で変わる可能性があります。\n" +"現在のデフォルト値は次のとおりです:" -#: ../../library/ctypes.rst:3030 msgid "On Windows: ``\"ms\"``" -msgstr "" +msgstr "Windows の場合: ``\"ms\"``" -#: ../../library/ctypes.rst:3031 msgid "" "When :attr:`~Structure._pack_` is specified: ``\"ms\"``. (This is " "deprecated; see :attr:`~Structure._pack_` documentation.)" msgstr "" +":attr:`~Structure._pack_` を指定した場合: ``\"ms\"`` (この動作は非推奨で" +"す。\n" +":attr:`~Structure._pack_` のドキュメントを参照してください)。" -#: ../../library/ctypes.rst:3033 msgid "Otherwise: ``\"gcc-sysv\"``" -msgstr "" +msgstr "それ以外の場合: ``\"gcc-sysv\"``" -#: ../../library/ctypes.rst:3035 msgid "" ":attr:`!_layout_` must already be defined when :attr:`~Structure._fields_` " "is assigned, otherwise it will have no effect." msgstr "" +":attr:`~Structure._fields_` に代入する時点で :attr:`!_layout_` が定義されてい" +"ないと、効果はありません。" #: ../../library/ctypes.rst:3042 msgid "" @@ -4682,19 +5521,21 @@ msgstr "" "`_fields_` が代入されたとき、 :attr:`_anonymous_` がすでに定義されていなけれ" "ばなりません。そうでなければ、何ら影響はありません。" -#: ../../library/ctypes.rst:3046 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 "" +"この変数に列挙するフィールドは、構造体型または共用体型のフィールドでなければ" +"なりません。\n" +":mod:`!ctypes` は、構造体型にデスクリプタを作成し、構造体や共用体のフィールド" +"を作成せずに、入れ子のフィールドへ直接アクセスできるようにします。" #: ../../library/ctypes.rst:3051 msgid "Here is an example type (Windows)::" msgstr "型の例です (Windows)::" -#: ../../library/ctypes.rst:3053 msgid "" "class _U(Union):\n" " _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" @@ -4706,8 +5547,16 @@ msgid "" " _fields_ = [(\"u\", _U),\n" " (\"vt\", VARTYPE)]" msgstr "" +"class _U(Union):\n" +" _fields_ = [(\"lptdesc\", POINTER(TYPEDESC)),\n" +" (\"lpadesc\", POINTER(ARRAYDESC)),\n" +" (\"hreftype\", HREFTYPE)]\n" +"\n" +"class TYPEDESC(Structure):\n" +" _anonymous_ = (\"u\",)\n" +" _fields_ = [(\"u\", _U),\n" +" (\"vt\", VARTYPE)]" -#: ../../library/ctypes.rst:3064 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 " @@ -4717,11 +5566,11 @@ msgid "" "temporary union instance::" msgstr "" "``TYPEDESC`` 構造体はCOMデータ型を表現しており、 ``vt`` フィールドは共用体" -"フィールドのどれが有効であるかを指定します。 ``u`` フィールドは匿名フィールド" -"として定義されているため、 TYPEDESC インスタンスから取り除かれてそのメンバー" -"へ直接アクセスできます。 ``td.lptdesc`` と ``td.u.lptdesc`` は同等ですが、前" -"者がより高速です。なぜなら一時的な共用体インスタンスを作る必要がないためで" -"す。::" +"フィールドのどれが有効であるかを指定します。\n" +"``u`` フィールドは匿名フィールドとして定義されているため、 ``TYPEDESC`` イン" +"スタンスからそのメンバーに直接アクセスできます。\n" +"``td.lptdesc`` と ``td.u.lptdesc`` は同等ですが、前者がより高速です。\n" +"なぜなら一時的な共用体インスタンスを作る必要がないためです。 ::" #: ../../library/ctypes.rst:3071 msgid "" @@ -4758,13 +5607,13 @@ msgstr "" "解釈され、そのため、同じ名前をもつ :attr:`_fields_` を初期化するか、 :attr:" "`_fields_` に存在しない名前に対しては新しい属性を作ります。" -#: ../../library/ctypes.rst:3091 msgid "" "Descriptor for fields of a :class:`Structure` and :class:`Union`. For " "example::" msgstr "" +":class:`Structure` と :class:`Union` のフィールドのデスクリプタです。\n" +"例えば次のように使います。 ::" -#: ../../library/ctypes.rst:3094 msgid "" ">>> class Color(Structure):\n" "... _fields_ = (\n" @@ -4786,72 +5635,95 @@ msgid "" ">>> Color.blinking.bit_offset\n" "1" msgstr "" +">>> class Color(Structure):\n" +"... _fields_ = (\n" +"... ('red', c_uint8),\n" +"... ('green', c_uint8),\n" +"... ('blue', c_uint8),\n" +"... ('intense', c_bool, 1),\n" +"... ('blinking', c_bool, 1),\n" +"... )\n" +"...\n" +">>> Color.red\n" +"\n" +">>> Color.green.type\n" +"\n" +">>> Color.blue.byte_offset\n" +"2\n" +">>> Color.intense\n" +"\n" +">>> Color.blinking.bit_offset\n" +"1" -#: ../../library/ctypes.rst:3114 msgid "All attributes are read-only." -msgstr "" +msgstr "すべての属性は読み出し専用です。" -#: ../../library/ctypes.rst:3116 msgid "" ":class:`!CField` objects are created via :attr:`~Structure._fields_`; do not " "instantiate the class directly." msgstr "" +":class:`!CField` オブジェクトは :attr:`~Structure._fields_` を通じて作成され" +"ます。\n" +"このクラスを直接インスタンス化しないでください。" -#: ../../library/ctypes.rst:3121 msgid "" "Previously, descriptors only had ``offset`` and ``size`` attributes and a " "readable string representation; the :class:`!CField` class was not available " "directly." msgstr "" +"以前のデスクリプタは ``offset`` と ``size`` 属性、および読みやすい文字列表現" +"だけを持ち、:class:`!CField` クラスは直接利用できませんでした。" -#: ../../library/ctypes.rst:3127 msgid "Name of the field, as a string." -msgstr "" +msgstr "文字列で表したフィールド名です。" -#: ../../library/ctypes.rst:3131 msgid "Type of the field, as a :ref:`ctypes class `." msgstr "" +":ref:`ctypes のクラス ` で表したフィールドの型です。" -#: ../../library/ctypes.rst:3136 msgid "Offset of the field, in bytes." -msgstr "" +msgstr "フィールドのオフセット (バイト単位) です。" -#: ../../library/ctypes.rst:3138 msgid "" "For bitfields, this is the offset of the underlying byte-aligned *storage " "unit*; see :attr:`~CField.bit_offset`." msgstr "" +"ビットフィールドでは、これはバイト境界に整列した、元になる *格納単位* のオフ" +"セットです。\n" +":attr:`~CField.bit_offset` を参照してください。" -#: ../../library/ctypes.rst:3143 msgid "Size of the field, in bytes." -msgstr "" +msgstr "フィールドのサイズ (バイト単位) です。" -#: ../../library/ctypes.rst:3145 msgid "" "For bitfields, this is the size of the underlying *storage unit*. Typically, " "it has the same size as the bitfield's type." msgstr "" +"ビットフィールドでは、これは元になる *格納単位* のサイズです。\n" +"通常はビットフィールドの型と同じサイズです。" -#: ../../library/ctypes.rst:3150 msgid "For non-bitfields, equivalent to :attr:`~CField.byte_size`." -msgstr "" +msgstr "ビットフィールドでない場合は、:attr:`~CField.byte_size` と同じです。" -#: ../../library/ctypes.rst:3152 msgid "" "For bitfields, this contains a backwards-compatible bit-packed value that " "combines :attr:`~CField.bit_size` and :attr:`~CField.bit_offset`. Prefer " "using the explicit attributes instead." msgstr "" +"ビットフィールドでは、:attr:`~CField.bit_size` と :attr:`~CField.bit_offset` " +"をビット単位でまとめた、後方互換性のための値を格納します。\n" +"代わりに、これらの明示的な属性を使ってください。" -#: ../../library/ctypes.rst:3159 msgid "True if this is a bitfield." -msgstr "" +msgstr "ビットフィールドであれば真です。" -#: ../../library/ctypes.rst:3164 msgid "" "The location of a bitfield within its *storage unit*, that is, within :attr:" "`~CField.byte_size` bytes of memory starting at :attr:`~CField.byte_offset`." msgstr "" +"ビットフィールドの *格納単位* 内での位置です。\n" +"つまり、:attr:`~CField.byte_offset` から始まる :attr:`~CField.byte_size` バイ" +"トのメモリ内での位置です。" #: ../../library/ctypes.rst:3168 msgid "" @@ -4860,17 +5732,20 @@ msgid "" "significant bits." msgstr "" -#: ../../library/ctypes.rst:3172 msgid "" "For non-bitfields, :attr:`!bit_offset` is zero and :attr:`!bit_size` is " "equal to ``byte_size * 8``." msgstr "" +"ビットフィールドでない場合、:attr:`!bit_offset` はゼロで、:attr:`!bit_size` " +"は ``byte_size * 8`` に等しくなります。" -#: ../../library/ctypes.rst:3177 msgid "" "True if this field is anonymous, that is, it contains nested sub-fields that " "should be merged into a containing structure or union." msgstr "" +"このフィールドが匿名であれば真です。\n" +"つまり、外側の構造体や共用体に統合される入れ子のサブフィールドを含む場合で" +"す。" #: ../../library/ctypes.rst:3184 msgid "Arrays and pointers" @@ -4880,7 +5755,6 @@ msgstr "配列とポインタ" msgid "Abstract base class for arrays." msgstr "配列のための抽象基底クラスです。" -#: ../../library/ctypes.rst:3190 msgid "" "The recommended way to create concrete array types is by multiplying any :" "mod:`!ctypes` data type with a non-negative integer. Alternatively, you can " @@ -4889,10 +5763,16 @@ msgid "" "and slice accesses; for slice reads, the resulting object is *not* itself " "an :class:`Array`." msgstr "" +"具体的な配列型を作成する推奨の方法は、任意の :mod:`!ctypes` データ型に非負の" +"整数を掛けることです。\n" +"この型をサブクラス化し、:attr:`_length_` と :attr:`_type_` クラス変数を定義す" +"る方法もあります。\n" +"配列の要素は、通常の添字やスライスによるアクセスで読み書きできます。\n" +"スライスを読み出した場合、結果のオブジェクト自体は :class:`Array` では *あり" +"ません*。" -#: ../../library/ctypes.rst:3197 msgid "Arrays are :ref:`generic ` over the type of their elements." -msgstr "" +msgstr "配列は、要素の型について :ref:`ジェネリック ` です。" #: ../../library/ctypes.rst:3202 msgid "" @@ -4915,15 +5795,16 @@ msgstr "" "配列のサブクラスのコンストラクタは、位置引数を受け付けて、配列を順番に初期化" "するために使用します。" -#: ../../library/ctypes.rst:3217 msgid "" "Create an array. Equivalent to ``type * length``, where *type* is a :mod:`!" "ctypes` data type and *length* an integer." msgstr "" +"配列を作成します。\n" +"*type* を :mod:`!ctypes` のデータ型、*length* を整数とした ``type * length`` " +"と同じです。" -#: ../../library/ctypes.rst:3221 msgid "In favor of multiplication." -msgstr "" +msgstr "代わりに乗算を使用してください。" #: ../../library/ctypes.rst:3227 msgid "Private, abstract base class for pointers." @@ -4975,23 +5856,19 @@ msgstr "" "この例外は外部関数呼び出しが渡された引数を変換できなかったときに送出されま" "す。" -#: ../../library/ctypes.rst:3264 msgid "This exception is raised when a COM method call failed." -msgstr "" +msgstr "COM メソッドの呼び出しが失敗した場合に送出される例外です。" -#: ../../library/ctypes.rst:3268 msgid "The integer value representing the error code." -msgstr "" +msgstr "エラーコードを表す整数値です。" -#: ../../library/ctypes.rst:3272 msgid "The error message." -msgstr "" +msgstr "エラーメッセージ。" -#: ../../library/ctypes.rst:3276 msgid "The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``." msgstr "" +"5 要素のタプル ``(descr, source, helpfile, helpcontext, progid)`` です。" -#: ../../library/ctypes.rst:3278 msgid "" "*descr* is the textual description. *source* is the language-dependent " "``ProgID`` for the class or application that raised the error. *helpfile* " @@ -4999,3 +5876,9 @@ msgid "" "identifier. *progid* is the ``ProgID`` of the interface that defined the " "error." msgstr "" +"*descr* は説明文です。\n" +"*source* は、エラーを発生させたクラスやアプリケーションの、言語に依存する " +"``ProgID`` です。\n" +"*helpfile* はヘルプファイルのパスです。\n" +"*helpcontext* はヘルプコンテキスト識別子です。\n" +"*progid* は、エラーを定義したインターフェースの ``ProgID`` です。" diff --git a/library/curses.ascii.po b/library/curses.ascii.po index 6947fc6a7..3dcc44651 100644 --- a/library/curses.ascii.po +++ b/library/curses.ascii.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/curses.ascii.rst:2 @@ -30,12 +30,14 @@ msgstr ":mod:`!curses.ascii` --- ASCII 文字のユーティリティー" msgid "**Source code:** :source:`Lib/curses/ascii.py`" msgstr "**ソースコード:** :source:`Lib/curses/ascii.py`" -#: ../../library/curses.ascii.rst:11 msgid "" "The :mod:`!curses.ascii` module supplies name constants for ASCII characters " "and functions to test membership in various ASCII character classes. The " "constants supplied are names for control characters as follows:" msgstr "" +":mod:`!curses.ascii` モジュールは、ASCII 文字の名前を表す定数と、文字がさまざ" +"まな ASCII 文字クラスに属するかどうかを調べる関数を提供します。\n" +"提供する定数は、以下の制御文字の名前です:" #: ../../library/curses.ascii.rst:16 msgid "Name" @@ -153,9 +155,8 @@ msgstr "キャンセル (Cancel)" msgid "End of medium" msgstr "媒体終端" -#: ../../library/curses.ascii.rst:74 msgid "Substitute" -msgstr "代入文字" +msgstr "置換文字" #: ../../library/curses.ascii.rst:76 msgid "Escape" @@ -222,9 +223,8 @@ msgstr "" msgid "Checks for a character value that fits in the 7-bit ASCII set." msgstr "文字が 7 ビット ASCII 文字に合致するかどうかを調べます。" -#: ../../library/curses.ascii.rst:117 msgid "Checks for an ASCII blank character; space or horizontal tab." -msgstr "" +msgstr "ASCII の空白文字 (空白または水平タブ) かどうかを調べます。" #: ../../library/curses.ascii.rst:122 msgid "" @@ -239,9 +239,8 @@ msgstr "" "ASCII 10 進数字、すなわち ``'0'`` から ``'9'`` までの文字かどうかを調べます。" "``c in string.digits`` と等価です。" -#: ../../library/curses.ascii.rst:133 msgid "Checks for any ASCII printable character except space." -msgstr "" +msgstr "空白以外の ASCII 印字可能文字かどうかを調べます。" #: ../../library/curses.ascii.rst:138 msgid "Checks for an ASCII lower-case character." @@ -251,11 +250,10 @@ msgstr "ASCII 小文字かどうかを調べます。" msgid "Checks for any ASCII printable character including space." msgstr "空白文字を含め、ASCII 印字可能文字かどうかを調べます。" -#: ../../library/curses.ascii.rst:148 msgid "" "Checks for any ASCII printable character which is not a space or an " "alphanumeric character." -msgstr "" +msgstr "空白でも英数字でもない ASCII 印字可能文字かどうかを調べます。" #: ../../library/curses.ascii.rst:154 msgid "" @@ -276,11 +274,12 @@ msgid "" msgstr "" "ASCII 16 進数字かどうかを調べます。``c in string.hexdigits`` と等価です。" -#: ../../library/curses.ascii.rst:171 msgid "" "Checks for an ASCII control character (ordinal values 0 to 31). Unlike :" "func:`iscntrl`, this does not include the delete character (0x7f)." msgstr "" +"ASCII 制御文字 (文字コード 0 から 31) かどうかを調べます。\n" +":func:`iscntrl` とは異なり、削除文字 (0x7f) は含みません。" #: ../../library/curses.ascii.rst:177 msgid "Checks for a non-ASCII character (ordinal values 0x80 and above)." diff --git a/library/curses.panel.po b/library/curses.panel.po index 0cf53897b..2bcfa2e00 100644 --- a/library/curses.panel.po +++ b/library/curses.panel.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/curses.panel.rst:2 @@ -41,29 +41,32 @@ msgstr "" msgid "Functions" msgstr "関数" -#: ../../library/curses.panel.rst:19 msgid "The module :mod:`!curses.panel` defines the following exception:" -msgstr "" +msgstr ":mod:`!curses.panel` モジュールは以下の例外を定義します:" -#: ../../library/curses.panel.rst:24 msgid "Exception raised when a curses panel library function returns an error." msgstr "" +"curses のパネルライブラリの関数がエラーを返した際に送出される例外です。" -#: ../../library/curses.panel.rst:27 msgid "The module :mod:`!curses.panel` defines the following functions:" -msgstr "" +msgstr ":mod:`!curses.panel` モジュールは以下の関数を定義します:" #: ../../library/curses.panel.rst:32 msgid "Returns the bottom panel in the panel stack." msgstr "パネルスタックの最下層のパネルを返します。" -#: ../../library/curses.panel.rst:37 msgid "" "Returns a panel object, associating it with the given window *win* and " "placing the new panel on top of the panel stack. Be aware that you need to " "keep the returned panel object referenced explicitly. If you don't, the " "panel object is garbage collected and removed from the panel stack." msgstr "" +"指定したウィンドウ *win* に関連付けた新しいパネルをパネルスタックの最上層に配" +"置し、パネルオブジェクトを返します。\n" +"返されたパネルオブジェクトへの参照を明示的に保持しておく必要があることに注意" +"してください。\n" +"そうしなければ、パネルオブジェクトはガベージコレクションの対象となり、パネル" +"スタックから取り除かれます。" #: ../../library/curses.panel.rst:45 msgid "Returns the top panel in the panel stack." @@ -77,17 +80,19 @@ msgstr "" "仮想スクリーンをパネルスタック変更後の状態に更新します。この関数では :func:" "`curses.doupdate` を呼ばないので、ユーザは自分で呼び出す必要があります。" -#: ../../library/curses.panel.rst:57 msgid "Panel objects" -msgstr "" +msgstr "パネルオブジェクト" -#: ../../library/curses.panel.rst:77 msgid "" "Panel objects, as returned by :func:`new_panel` above, are windows with a " "stacking order. There's always a window associated with a panel which " "determines the content, while the panel methods are responsible for the " "window's depth in the panel stack." msgstr "" +"上の :func:`new_panel` が返すパネルオブジェクトは、重なり順のあるウィンドウで" +"す。\n" +"パネルには常に、その内容を決めるウィンドウが関連付けられており、パネルのメ" +"ソッドはパネルスタック内でのウィンドウの深さを制御します。" #: ../../library/curses.panel.rst:82 msgid "Panel objects have the following methods:" @@ -136,11 +141,12 @@ msgstr "" "パネルのユーザポインタを *obj* に設定します。このメソッドは任意のデータをパネ" "ルに関連付けるために使われ、任意の Python オブジェクトにすることができます。" -#: ../../library/curses.panel.rst:129 msgid "" "Display the panel (which might have been hidden), placing it on top of the " "panel stack." msgstr "" +"パネル (隠れている場合もあります) をパネルスタックの最上層に配置して表示しま" +"す。" #: ../../library/curses.panel.rst:135 msgid "Push panel to the top of the stack." diff --git a/library/curses.po b/library/curses.po index a1ceb7dec..9f1dc9f01 100644 --- a/library/curses.po +++ b/library/curses.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/curses.rst:2 @@ -31,11 +31,12 @@ msgstr ":mod:`!curses` --- 文字セル表示のターミナル処理" msgid "**Source code:** :source:`Lib/curses`" msgstr "**ソースコード:** :source:`Lib/curses`" -#: ../../library/curses.rst:12 msgid "" "The :mod:`!curses` module provides an interface to the curses library, the " "de-facto standard for portable advanced terminal handling." msgstr "" +":mod:`!curses` モジュールは、移植可能な高度な端末処理の事実上の標準である " +"curses ライブラリへのインターフェースを提供します。" #: ../../library/curses.rst:15 msgid "" @@ -49,9 +50,8 @@ msgstr "" "の拡張モジュールは Linux および BSD 系の Unixで動作するオープンソースの " "curses ライブラリである ncurses の API に合致するように設計されています。" -#: ../../library/curses.rst:24 ../../includes/wasm-mobile-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-mobile-notavail.rst:5 msgid "" @@ -61,29 +61,35 @@ msgstr "" "このモジュールは :ref:`モバイルプラットフォーム ` と :" "ref:`WebAssemblyプラットフォーム ` をサポートしません。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" -#: ../../library/curses.rst:28 msgid "" "Whenever the documentation mentions a *character* it can be specified as an " "integer, a one-character Unicode string or a one-byte byte string. An " "integer is the code of a single encoded byte, optionally combined with " "attributes and a color pair, as returned by :meth:`window.inch`." msgstr "" +"このドキュメントで *文字* と記されている箇所では、整数、1 文字の Unicode 文字" +"列、または 1 バイトのバイト文字列を指定できます。\n" +"整数はエンコードされた 1 バイトのコードであり、:meth:`window.inch` の返り値の" +"ように、属性や色ペアを組み合わせたものでも構いません。" -#: ../../library/curses.rst:33 msgid "" "Whenever the documentation mentions a *character string* it can be specified " "as a Unicode string or a byte string." msgstr "" +"このドキュメントで *文字列* と記されている箇所では、Unicode 文字列またはバイ" +"ト文字列を指定できます。" -#: ../../library/curses.rst:38 msgid "" "Whether curses may be used from several threads depends on the underlying " "library and how it was built. In many implementations, including the default " @@ -92,6 +98,14 @@ msgid "" "`~window.refresh`) release the :term:`GIL`, unsynchronized use from several " "threads can then crash the interpreter. Serialize the calls." msgstr "" +"複数のスレッドから curses を使用できるかどうかは、基盤となるライブラリとその" +"ビルド方法に依存します。\n" +"ncurses のデフォルトビルドを含む多くの実装では、スクリーンの状態が共有され、" +"スレッドセーフではありません。\n" +"ブロックや更新を行うメソッド (:meth:`~window.getch` や :meth:`~window." +"refresh` など) は :term:`GIL` を解放するため、複数のスレッドから同期せずに使" +"用するとインタープリタがクラッシュする可能性があります。\n" +"呼び出しを直列化してください。" #: ../../library/curses.rst:50 msgid "Module :mod:`curses.ascii`" @@ -139,9 +153,8 @@ msgstr "" msgid "Functions" msgstr "関数" -#: ../../library/curses.rst:69 msgid "The module :mod:`!curses` defines the following exception:" -msgstr "" +msgstr ":mod:`!curses` モジュールは以下の例外を定義します:" #: ../../library/curses.rst:74 msgid "Exception raised when a curses library function returns an error." @@ -157,31 +170,32 @@ msgstr "" "値は常に現在のカーソルになります。オプションの *attr* がある場合、デフォルト" "値は :const:`A_NORMAL` です。" -#: ../../library/curses.rst:82 msgid "The module :mod:`!curses` defines the following functions:" -msgstr "" +msgstr ":mod:`!curses` モジュールは以下の関数を定義します:" -#: ../../library/curses.rst:87 msgid "" "Allow use of default values for colors on terminals supporting this feature. " "Use this to support transparency in your application." msgstr "" +"この機能をサポートする端末で、色のデフォルト値を使用できるようにします。\n" +"アプリケーションで透過表示をサポートするには、この関数を使用してください。" -#: ../../library/curses.rst:90 msgid "" "Assign terminal default foreground/background colors to color number ``-1``. " "So ``init_pair(x, COLOR_RED, -1)`` will initialize pair *x* as red on " "default background and ``init_pair(x, -1, COLOR_BLUE)`` will initialize pair " "*x* as default foreground on blue." msgstr "" +"端末のデフォルトの前景色と背景色を色番号 ``-1`` に割り当てます。\n" +"したがって、``init_pair(x, COLOR_RED, -1)`` はペア *x* をデフォルトの背景色に" +"赤の前景色として初期化し、``init_pair(x, -1, COLOR_BLUE)`` はペア *x* を青の" +"背景色にデフォルトの前景色として初期化します。" -#: ../../library/curses.rst:95 msgid "Change the definition of the color-pair ``0`` to ``(fg, bg)``." -msgstr "" +msgstr "色ペア ``0`` の定義を ``(fg, bg)`` に変更します。" -#: ../../library/curses.rst:97 msgid "This is an ncurses extension." -msgstr "" +msgstr "これは ncurses の拡張機能です。" #: ../../library/curses.rst:104 msgid "" @@ -224,7 +238,6 @@ msgstr "" "出し側のプログラムに対する通常の効果をもっています。まず :func:`raw` を呼び出" "し、次いで :func:`cbreak` を呼び出すと、端末を cbreak モードにします。" -#: ../../library/curses.rst:132 msgid "" "Return the intensity of the red, green, and blue (RGB) components in the " "color *color_number*, which must be between ``0`` and ``COLORS - 1``. " @@ -232,8 +245,12 @@ msgid "" "will be between ``0`` (no component) and ``1000`` (maximum amount of " "component). Raise an exception if the color is not supported." msgstr "" +"色 *color_number* の赤、緑、青 (RGB) 成分の強度を返します。\n" +"*color_number* は ``0`` から ``COLORS - 1`` の範囲でなければなりません。\n" +"指定した色の R、G、B の値を含む 3 要素のタプルを返します。\n" +"各値は ``0`` (成分なし) から ``1000`` (成分の最大量) の範囲です。\n" +"その色がサポートされていない場合は例外を送出します。" -#: ../../library/curses.rst:141 msgid "" "Return the attribute value for displaying text in the specified color pair. " "Only the first 256 color pairs are supported. This attribute value can be " @@ -241,8 +258,12 @@ msgid "" "`!A_\\*` attributes. :func:`pair_number` is the counterpart to this " "function." msgstr "" +"指定した色ペアでテキストを表示するための属性値を返します。\n" +"最初の 256 個の色ペアだけがサポートされています。\n" +"この属性値は :const:`A_STANDOUT`、:const:`A_REVERSE`、その他の :const:`!" +"A_\\*` 属性と組み合わせることができます。\n" +":func:`pair_number` はこの関数と逆の処理を行います。" -#: ../../library/curses.rst:150 msgid "" "Set the cursor state. *visibility* can be set to ``0``, ``1``, or ``2``, " "for invisible, normal, or very visible. If the terminal supports the " @@ -250,10 +271,10 @@ msgid "" "exception. On many terminals, the \"visible\" mode is an underline cursor " "and the \"very visible\" mode is a block cursor." msgstr "" -"カーソルの状態を設定します。*visibility* は ``0`` 、 ``1``または ``2`` に設定" -"され、それぞれ不可視、通常、または非常に可視、を意味します。要求された可視属" -"性を端末がサポートしている場合、以前のカーソル状態が返されます; そうでなけれ" -"ば例外が送出されます。多くの端末では、\"可視 (通常)\" モードは下線カーソル" +"カーソルの状態を設定します。*visibility* は ``0`` 、 ``1`` または ``2`` に設" +"定され、それぞれ不可視、通常、または非常に可視、を意味します。要求された可視" +"属性を端末がサポートしている場合、以前のカーソル状態が返されます; そうでなけ" +"れば例外が送出されます。多くの端末では、\"可視 (通常)\" モードは下線カーソル" "で、\"非常に可視\" モードはブロックカーソルです。" #: ../../library/curses.rst:159 @@ -284,13 +305,17 @@ msgstr "" msgid "Insert an *ms* millisecond pause in output." msgstr "出力に *ms* ミリ秒の一時停止を入れます。" -#: ../../library/curses.rst:180 msgid "" "Update the physical screen. The curses library keeps two data structures, " "one representing the current physical screen contents and a virtual screen " "representing the desired next state. The :func:`doupdate` function updates " "the physical screen to match the virtual screen." msgstr "" +"物理スクリーンを更新します。\n" +"curses ライブラリは、現在の物理スクリーンの内容を表すものと、次に表示したい状" +"態を表す仮想スクリーンという 2 つのデータ構造を保持しています。\n" +":func:`doupdate` 関数は、仮想スクリーンに一致するように物理スクリーンを更新し" +"ます。" #: ../../library/curses.rst:185 msgid "" @@ -304,11 +329,11 @@ msgid "" msgstr "" "仮想スクリーンは :meth:`~window.addstr` のような書き込み操作をウィンドウに" "行った後に :meth:`~window.noutrefresh` を呼び出して更新することができます。通" -"常の:meth:`~window.refresh` 呼び出しは、単に :meth:`!noutrefresh` を呼んだ後" -"に :func:`!doupdate`を呼ぶだけです; 複数のウィンドウを更新しなければならない" -"場合、すべてのウィンドウに対して :meth:`!noutrefresh` を呼び出した後、一度だ" -"け :func:`!doupdate` を呼ぶことで、パフォーマンスを向上させることができ、おそ" -"らくスクリーンのちらつきも押さえることができます。" +"常の :meth:`~window.refresh` 呼び出しは、単に :meth:`!noutrefresh` を呼んだ" +"後に :func:`!doupdate` を呼ぶだけです; 複数のウィンドウを更新しなければならな" +"い場合、すべてのウィンドウに対して :meth:`!noutrefresh` を呼び出した後、一度" +"だけ :func:`!doupdate` を呼ぶことで、パフォーマンスを向上させることができ、お" +"そらくスクリーンのちらつきも押さえることができます。" #: ../../library/curses.rst:195 msgid "" @@ -332,7 +357,6 @@ msgstr "" "ます。Unix オペレーティングシステムでは、この値は curses プログラムが制御して" "いる端末の属性であり、curses ライブラリ自体では設定されません。" -#: ../../library/curses.rst:213 msgid "" "The :func:`.filter` routine, if used, must be called before :func:`initscr` " "is called. The effect is that, during the initialization, :envvar:`LINES` " @@ -342,6 +366,14 @@ msgid "" "current line, and so are screen updates. This may be used for enabling " "character-at-a-time line editing without touching the rest of the screen." msgstr "" +":func:`.filter` ルーチンを使用する場合は、:func:`initscr` より前に呼び出す必" +"要があります。\n" +"これにより、初期化時に :envvar:`LINES` が ``1`` に設定され、機能 ``clear``、" +"``cup``、``cud``、``cud1``、``cuu1``、``cuu``、``vpa`` が無効になり、" +"``home`` 文字列が ``cr`` の値に設定されます。\n" +"その結果、カーソルもスクリーンの更新も現在の行に限定されます。\n" +"これを利用すると、スクリーンの他の部分に触れずに、1 文字ずつ行を編集できるよ" +"うになります。" #: ../../library/curses.rst:223 msgid "" @@ -388,11 +420,12 @@ msgstr "" "`BUTTONn_DOUBLE_CLICKED`, :const:`BUTTONn_TRIPLE_CLICKED`, :const:" "`BUTTON_SHIFT`, :const:`BUTTON_CTRL`, :const:`BUTTON_ALT`。" -#: ../../library/curses.rst:247 ../../library/curses.rst:1920 msgid "" "The ``BUTTON5_*`` constants are now exposed if they are provided by the " "underlying curses library." msgstr "" +"基盤となる curses ライブラリが ``BUTTON5_*`` 定数を提供する場合に、それらが公" +"開されるようになりました。" #: ../../library/curses.rst:254 msgid "" @@ -403,13 +436,18 @@ msgstr "" "仮想スクリーンにおける現在のカーソル位置をタプル ``(y, x)`` で返します。 :" "meth:`leaveok` が ``True`` に設定されていれば、 ``(-1, -1)`` が返されます。" -#: ../../library/curses.rst:260 msgid "" "Read window-related data stored in the file by an earlier :meth:`window." "putwin` call. The routine then creates and initializes a new window using " "that data, returning the new window object. The *file* argument must be a " "file object opened for reading in binary mode." msgstr "" +"以前の :meth:`window.putwin` 呼び出しでファイルに保存したウィンドウ関連のデー" +"タを読み込みます。\n" +"続いて、そのデータを使用して新しいウィンドウを作成して初期化し、新しいウィン" +"ドウオブジェクトを返します。\n" +"*file* 引数は、バイナリモードで読み込み用に開いたファイルオブジェクトでなけれ" +"ばなりません。" #: ../../library/curses.rst:268 msgid "" @@ -419,16 +457,18 @@ msgstr "" "端末が色表示を行える場合には ``True`` を返します。そうでない場合には " "``False`` を返します。" -#: ../../library/curses.rst:272 msgid "" "Return ``True`` if the module supports extended colors; otherwise, return " "``False``. Extended color support allows more than 256 color pairs for " "terminals that support more than 16 colors (for example, xterm-256color)." msgstr "" +"モジュールが拡張カラーをサポートしている場合は ``True`` を、そうでない場合は " +"``False`` を返します。\n" +"拡張カラーのサポートにより、16 色を超える色をサポートする端末 (例えば " +"xterm-256color) で 256 個を超える色ペアを使用できます。" -#: ../../library/curses.rst:276 msgid "Extended color support requires ncurses version 6.1 or later." -msgstr "" +msgstr "拡張カラーのサポートには ncurses バージョン 6.1 以降が必要です。" #: ../../library/curses.rst:282 msgid "" @@ -492,7 +532,6 @@ msgstr "" "で何も行いません; :func:`can_change_color` が ``True`` を返す場合にのみ動作し" "ます。" -#: ../../library/curses.rst:323 msgid "" "Change the definition of a color-pair. It takes three arguments: the number " "of the color-pair to be changed, the foreground color number, and the " @@ -505,6 +544,17 @@ msgid "" "refreshed and all occurrences of that color-pair are changed to the new " "definition." msgstr "" +"色ペアの定義を変更します。\n" +"変更する色ペアの番号、前景色の番号、背景色の番号という 3 つの引数を取りま" +"す。\n" +"*pair_number* の値は ``1`` から ``COLOR_PAIRS - 1`` の範囲でなければなりませ" +"ん (色ペア ``0`` は :func:`use_default_colors` と :func:" +"`assume_default_colors` でのみ変更できます)。\n" +"引数 *fg* と *bg* の値は ``0`` から ``COLORS - 1`` の範囲か、:func:`!" +"use_default_colors` または :func:`!assume_default_colors` を呼び出した後であ" +"れば ``-1`` でなければなりません。\n" +"色ペアが以前に初期化されていた場合、スクリーンが更新され、その色ペアを使用し" +"ているすべての箇所が新しい定義に変わります。" #: ../../library/curses.rst:338 msgid "" @@ -514,10 +564,11 @@ msgstr "" "ライブラリを初期化します。スクリーン全体をあらわす :ref:`ウィンドウ ` オブジェクトを返します。" -#: ../../library/curses.rst:341 msgid "" "See :func:`setupterm` for a caveat about calling it before this function." msgstr "" +"この関数より先に :func:`setupterm` を呼び出す際の注意事項は、その関数の説明を" +"参照してください。" #: ../../library/curses.rst:345 msgid "" @@ -527,20 +578,21 @@ msgstr "" "端末のオープン時にエラーが発生した場合、curses ライブラリによってインタープリ" "タが終了される場合があります。" -#: ../../library/curses.rst:351 msgid "" "If *flag* is ``True``, pressing an interrupt key (interrupt, break, or quit) " "will flush all output in the terminal driver queue. If *flag* is ``False``, " "no flushing is done." msgstr "" +"*flag* が ``True`` の場合、割り込みキー (interrupt、break、quit) を押すと端末" +"ドライバのキュー内の出力がすべてフラッシュされます。\n" +"*flag* が ``False`` の場合、フラッシュは行われません。" -#: ../../library/curses.rst:358 msgid "" "Return ``True`` if :func:`resize_term` would modify the window structure, " "``False`` otherwise." msgstr "" -":func:`resize_term` によってウィンドウ構造が変更されている場合に ``True`` " -"を、そうでない場合は ``False`` を返します。" +":func:`resize_term` を呼び出した場合にウィンドウ構造が変更されるなら " +"``True`` を、そうでなければ ``False`` を返します。" #: ../../library/curses.rst:364 msgid "" @@ -550,7 +602,6 @@ msgstr "" ":func:`endwin` がすでに呼び出されている (すなわち、curses ライブラリが非初期" "化されてしまっている) 場合に ``True`` を返します。" -#: ../../library/curses.rst:370 msgid "" "Return the name of the key numbered *k* as a bytes object. The name of a " "key generating printable ASCII character is the key's character. The name " @@ -560,23 +611,24 @@ msgid "" "of the prefix ``b'M-'`` followed by the name of the corresponding ASCII " "character." msgstr "" -"bytes オブジェクト *k* に番号付けされているキーの名前を返します。\n" +"番号 *k* のキーの名前を bytes オブジェクトで返します。\n" "印字可能な ASCII 文字を生成するキーの名前はそのキーの文字自体になります。\n" "コントロールキーと組み合わせたキーの名前は、キャレット(``b'^'``)の後に対応す" "る ASCII 文字が続く 2 バイトの bytes オブジェクトになります。\n" "Alt キーと組み合わせたキー (128--255) の名前は、先頭に ``b'M-'`` が付き、その" -"後に対応する ASCII 文字が続く bytes オブジェクトになります。" +"後に対応する ASCII 文字の名前が続く bytes オブジェクトになります。" -#: ../../library/curses.rst:377 msgid "Raise a :exc:`ValueError` if *k* is negative." -msgstr "" +msgstr "*k* が負の場合は :exc:`ValueError` を送出します。" -#: ../../library/curses.rst:382 msgid "" "Return the user's current line kill character as a one-byte bytes object. " "Under Unix operating systems this is a property of the controlling tty of " "the curses program, and is not set by the curses library itself." msgstr "" +"ユーザの現在の行消去文字を、1 バイトの bytes オブジェクトとして返します。\n" +"Unix オペレーティングシステムでは、これは curses プログラムの制御端末の属性で" +"あり、curses ライブラリ自体が設定するものではありません。" #: ../../library/curses.rst:389 msgid "" @@ -596,7 +648,6 @@ msgstr "" "*flag* が ``True`` の場合、8 ビット文字の入力を許可します。*flag* が " "``False`` の場合、7 ビット文字だけを許可します。" -#: ../../library/curses.rst:402 msgid "" "Set the maximum time in milliseconds that can elapse between press and " "release events in order for them to be recognized as a click, and return the " @@ -604,8 +655,11 @@ msgid "" "sixth of a second. Use a negative *interval* to obtain the interval value " "without changing it." msgstr "" +"ボタンを押してから離すまでのイベントをクリックと認識する最大時間をミリ秒で設" +"定し、以前の時間間隔を返します。\n" +"デフォルト値は 166 ミリ秒、すなわち 6 分の 1 秒です。\n" +"時間間隔を変更せずに取得するには、負の *interval* を使用してください。" -#: ../../library/curses.rst:410 msgid "" "Set the mouse events to be reported, and return a tuple ``(availmask, " "oldmask)``. *availmask* indicates which of the specified mouse events can " @@ -613,6 +667,12 @@ msgid "" "previous value of the mouse event mask. If this function is never called, " "no mouse events are ever reported." msgstr "" +"通知するマウスイベントを設定し、タプル ``(availmask, oldmask)`` を返しま" +"す。\n" +"*availmask* は、指定したマウスイベントのうち通知可能なものを示し、完全に失敗" +"した場合は ``0`` になります。\n" +"*oldmask* は以前のマウスイベントマスクの値です。\n" +"この関数を一度も呼び出さない場合、マウスイベントは一切通知されません。" #: ../../library/curses.rst:419 msgid "Sleep for *ms* milliseconds." @@ -626,7 +686,6 @@ msgstr "" "与えられた行とカラム数を持つパッド (pad) データ構造を生成し、そのポインタを返" "します。パッドはウィンドウオブジェクトとして返されます。" -#: ../../library/curses.rst:427 msgid "" "A pad is like a window, except that it is not restricted by the screen size, " "and is not necessarily associated with a particular part of the screen. " @@ -641,6 +700,19 @@ msgid "" "arguments define a clipping box on the screen within which the pad region is " "to be displayed." msgstr "" +"パッドはウィンドウに似ていますが、スクリーンの大きさによる制限がなく、スク" +"リーンの特定の部分に関連付けられるとは限りません。\n" +"大きなウィンドウが必要で、一度にスクリーンに表示するのはその一部だけという場" +"合にパッドを使用できます。\n" +"パッドでは、スクロールや入力のエコーバックなどによる自動更新は行われませ" +"ん。\n" +"パッドの :meth:`~window.refresh` と :meth:`~window.noutrefresh` メソッドに" +"は、表示するパッドの部分とスクリーン上の表示位置を指定する 6 つの引数が必要で" +"す。\n" +"これらの引数は *pminrow*、*pmincol*、*sminrow*、*smincol*、*smaxrow*、" +"*smaxcol* です。\n" +"*p* で始まる引数は表示するパッド領域の左上隅を示し、*s* で始まる引数はパッド" +"領域を表示するスクリーン上の切り取り矩形を定義します。" #: ../../library/curses.rst:443 msgid "" @@ -668,9 +740,9 @@ msgstr "" "し、出力時に改行文字を復帰 (return) と改行 (line-feed) に変換します。newline " "モードは初期化時にはオンになっています。" -#: ../../library/curses.rst:456 msgid "If *flag* is ``False``, the effect is the same as calling :func:`nonl`." msgstr "" +"*flag* が ``False`` の場合、:func:`nonl` の呼び出しと同じ効果があります。" #: ../../library/curses.rst:461 msgid "" @@ -683,7 +755,6 @@ msgstr "" msgid "Leave echo mode. Echoing of input characters is turned off." msgstr "echo モードを終了します。入力のエコーバックはオフにされます。" -#: ../../library/curses.rst:471 msgid "" "Leave newline mode. Disable translation of return into newline on input, " "and disable low-level translation of newline into newline/return on output " @@ -692,12 +763,12 @@ msgid "" "translation off, curses can sometimes speed up vertical motion a little; " "also, it will be able to detect the return key on input." msgstr "" -"newline モードを終了します。入力時のリターンキーから改行への変換、および出力" -"時の改行から復帰/改行への低レベル変換を無効化します (ただし、" -"``addch('\\n')`` の振る舞いは変更せず、仮想スクリーン上では常に復帰と改行に等" -"しくなります)。変換をオフにすることで、curses は水平方向の動きを少しだけ高速" -"化できることがあります; また、入力中のリターンキーの検出ができるようになりま" -"す。" +"newline モードを終了します。\n" +"入力時のリターンキーから改行への変換、および出力時の改行から復帰/改行への低レ" +"ベル変換を無効化します (ただし、``addch('\\n')`` の振る舞いは変更せず、仮想ス" +"クリーン上では常に復帰と改行に等しくなります)。\n" +"変換をオフにすることで、curses は垂直方向の動きを少しだけ高速化できることがあ" +"ります; また、入力中のリターンキーの検出ができるようになります。" #: ../../library/curses.rst:481 msgid "" @@ -735,18 +806,19 @@ msgstr "" "*attr* に対する色ペアセットの番号を返します。:func:`color_pair` はこの関数の" "逆に相当します。" -#: ../../library/curses.rst:506 msgid "" "Equivalent to ``tputs(str, 1, putchar)``; emit the value of a specified " "terminfo capability, a bytes object, for the current terminal. Note that the " "output of :func:`putp` always goes to standard output." msgstr "" +"``tputs(str, 1, putchar)`` と等価です。\n" +"現在の端末に対し、指定した terminfo 機能の値である bytes オブジェクトを出力し" +"ます。\n" +":func:`putp` の出力先は常に標準出力であることに注意してください。" -#: ../../library/curses.rst:510 ../../library/curses.rst:653 -#: ../../library/curses.rst:663 ../../library/curses.rst:673 -#: ../../library/curses.rst:683 msgid ":func:`setupterm` (or :func:`initscr`) must be called first." msgstr "" +"先に :func:`setupterm` (または :func:`initscr`) を呼び出す必要があります。" #: ../../library/curses.rst:515 msgid "" @@ -824,34 +896,34 @@ msgstr "" ":func:`resetty` で使用される、バッファ内の端末モードの現在の状態を保存しま" "す。" -#: ../../library/curses.rst:569 msgid "Retrieves the value set by :func:`set_escdelay`." -msgstr "" +msgstr ":func:`set_escdelay` で設定した値を取得します。" -#: ../../library/curses.rst:575 msgid "" "Sets the number of milliseconds to wait after reading an escape character, " "to distinguish between an individual escape character entered on the " "keyboard from escape sequences sent by cursor and function keys." msgstr "" +"キーボードで入力した単独のエスケープ文字と、カーソルキーやファンクションキー" +"が送信するエスケープシーケンスを区別するため、エスケープ文字を読み込んだ後に" +"待機する時間をミリ秒で設定します。" -#: ../../library/curses.rst:583 msgid "Retrieves the value set by :func:`set_tabsize`." -msgstr "" +msgstr ":func:`set_tabsize` で設定した値を取得します。" -#: ../../library/curses.rst:589 msgid "" "Sets the number of columns used by the curses library when converting a tab " "character to spaces as it adds the tab to a window." msgstr "" +"curses ライブラリがウィンドウにタブ文字を追加する際、タブ文字を空白に変換する" +"ために使用する桁数を設定します。" -#: ../../library/curses.rst:596 msgid "" "Set the virtual screen cursor to *y*, *x*. If *y* and *x* are both ``-1``, " "then :meth:`leaveok ` is set ``True``." msgstr "" "仮想スクリーンのカーソルを *y*, *x* に設定します。*y* および *x* がどちらも " -"``-1`` の場合、 :meth:`leaveok` が に``True``に設定されます。" +"``-1`` の場合、 :meth:`leaveok` が に ``True`` に設定されます。" #: ../../library/curses.rst:602 msgid "" @@ -866,19 +938,24 @@ msgstr "" "れる初期化シーケンスへのファイル記述子です。指定されないまたは ``-1`` の場" "合、``sys.stdout`` のファイル記述子が使用されます。" -#: ../../library/curses.rst:608 msgid "" "Raise a :exc:`curses.error` if the terminal could not be found or its " "terminfo database entry could not be read. If the terminal has already been " "initialized, this function has no effect." msgstr "" +"端末が見つからないか、その terminfo データベースのエントリーを読み込めない場" +"合、:exc:`curses.error` を送出します。\n" +"端末がすでに初期化されている場合、この関数は何もしません。" -#: ../../library/curses.rst:614 msgid "" "Calling :func:`initscr` after :func:`setupterm` leaks the terminal that :" "func:`setupterm` allocated: the curses library keeps only a single current " "terminal and does not free the previously allocated one." msgstr "" +":func:`setupterm` の後に :func:`initscr` を呼び出すと、:func:`setupterm` が確" +"保した端末がリークします。\n" +"curses ライブラリは現在の端末を 1 つだけ保持し、それまでに確保した端末を解放" +"しないためです。" #: ../../library/curses.rst:622 msgid "" @@ -890,7 +967,6 @@ msgstr "" "び出す前に呼び出さなくてはなりません。この関数は :func:`initscr` を呼んだ直後" "に呼ぶようにしておくとよいでしょう。" -#: ../../library/curses.rst:626 msgid "" ":func:`start_color` initializes eight basic colors (black, red, green, " "yellow, blue, magenta, cyan, and white), and two global variables in the :" @@ -899,6 +975,11 @@ msgid "" "also restores the colors on the terminal to the values they had when the " "terminal was just turned on." msgstr "" +":func:`start_color` は 8 つの基本色 (黒、赤、緑、黄、青、マゼンタ、シアン、" +"白) と、:mod:`!curses` モジュールの 2 つのグローバル変数 :const:`COLORS` およ" +"び :const:`COLOR_PAIRS` を初期化します。\n" +"これらの変数には、端末がサポートできる色と色ペアの最大数が格納されます。\n" +"また、端末の色を端末の電源投入直後の値に戻します。" #: ../../library/curses.rst:635 msgid "" @@ -940,15 +1021,17 @@ msgstr "" "が数値で表せる機能値でない場合 ``-2`` を返し、機能がキャンセルされているか、" "端末記述上に見つからない場合 ``-1`` を返します。" -#: ../../library/curses.rst:668 msgid "" "Return the value of the string capability corresponding to the terminfo " "capability name *capname* as a bytes object. Return ``None`` if *capname* " "is not a terminfo \"string capability\", or is canceled or absent from the " "terminal description." msgstr "" +"terminfo の機能名 *capname* に対応する文字列機能の値を bytes オブジェクトとし" +"て返します。\n" +"*capname* が terminfo の「文字列機能」でない場合や、端末の記述で取り消されて" +"いるか存在しない場合は、``None`` を返します。" -#: ../../library/curses.rst:678 msgid "" "Instantiate the bytes object *str* with the supplied parameters, where *str* " "should be a parameterized byte string obtained from the terminfo database. " @@ -956,6 +1039,12 @@ msgid "" "``b'\\033[6;4H'``, the exact result depending on terminal type. Up to nine " "integer parameters may be supplied." msgstr "" +"bytes オブジェクト *str* に指定したパラメータを適用します。\n" +"*str* は terminfo データベースから取得した、パラメータを含むバイト文字列でな" +"ければなりません。\n" +"例えば、``tparm(tigetstr(\"cup\"), 5, 3)`` は ``b'\\033[6;4H'`` を返すことが" +"ありますが、正確な結果は端末の種類によって異なります。\n" +"整数のパラメータを最大 9 個指定できます。" #: ../../library/curses.rst:688 msgid "" @@ -980,13 +1069,16 @@ msgstr "" "や doupdate を再度呼び出すまで先送りにします。この関数は異なるファイル記述子" "で先読みチェックを行うように指定することができます。" -#: ../../library/curses.rst:700 msgid "" "Return a bytes object which is a printable representation of the character " "*ch*; any attributes and color pair are ignored. Control characters are " "represented as a caret followed by the character, for example as ``b'^C'``. " "Printing characters are left as they are." msgstr "" +"文字 *ch* の印字可能な表現を bytes オブジェクトとして返します。\n" +"属性と色ペアは無視されます。\n" +"制御文字は、``b'^C'`` のようにキャレットの後に文字を続けた形で表されます。\n" +"印字可能な文字はそのままです。" #: ../../library/curses.rst:708 msgid "Push *ch* so the next :meth:`~window.getch` will return it." @@ -994,21 +1086,23 @@ msgstr "" "*ch* をプッシュし、次に :meth:`~window.getch` を呼び出した時にその値が返るよ" "うにします。" -#: ../../library/curses.rst:710 msgid "" "*ch* may be an integer (a key code or the code of an encoded byte), a byte, " "or a string of length 1 which encodes to a single byte." msgstr "" +"*ch* には、整数 (キーコードまたはエンコードされたバイトのコード)、1 バイト、" +"またはエンコードすると 1 バイトになる長さ 1 の文字列を指定できます。" #: ../../library/curses.rst:715 msgid "Only one *ch* can be pushed before :meth:`!getch` is called." msgstr ":meth:`!getch` を呼び出すまでは *ch* は一つしかプッシュできません。" -#: ../../library/curses.rst:720 msgid "" "Update the :const:`LINES` and :const:`COLS` module variables. Useful for " "detecting manual screen resize." msgstr "" +"モジュール変数 :const:`LINES` と :const:`COLS` を更新します。\n" +"手動によるスクリーンのサイズ変更を検出する際に役立ちます。" #: ../../library/curses.rst:728 msgid "Push *ch* so the next :meth:`~window.get_wch` will return it." @@ -1016,11 +1110,12 @@ msgstr "" "*ch* をプッシュし、次に :meth:`~window.get_wch` を呼び出した時にその値が返る" "ようにします。" -#: ../../library/curses.rst:730 msgid "" "*ch* may be an integer (a character code, not a key code) or a string of " "length 1." msgstr "" +"*ch* には、整数 (キーコードではなく文字コード) または長さ 1 の文字列を指定で" +"きます。" #: ../../library/curses.rst:735 msgid "Only one *ch* can be pushed before :meth:`!get_wch` is called." @@ -1050,9 +1145,8 @@ msgstr "" "`COLUMNS` が設定されていないとウィンドウのサイズを使います) いても、" "terminfo データベースに指定された lines および columns の値を使います。" -#: ../../library/curses.rst:758 msgid "Equivalent to ``assume_default_colors(-1, -1)``." -msgstr "" +msgstr "``assume_default_colors(-1, -1)`` と等価です。" #: ../../library/curses.rst:763 msgid "" @@ -1077,9 +1171,8 @@ msgstr "" "期化します。終了時 (通常終了、例外による終了のどちらでも)、cooked モードに戻" "し、エコーをオンにし、端末キーパッドを無効にします。" -#: ../../library/curses.rst:777 msgid "Window objects" -msgstr "" +msgstr "ウィンドウオブジェクト" #: ../../library/curses.rst:781 msgid "" @@ -1099,12 +1192,15 @@ msgstr "" "描画された文字は上書きされます。デフォルトでは、文字の位置および属性はウィン" "ドウオブジェクトにおける現在の設定になります。" -#: ../../library/curses.rst:794 msgid "" "Writing outside the window, subwindow, or pad raises a :exc:`curses.error`. " "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the character is printed." msgstr "" +"ウィンドウ、サブウィンドウ、パッドの外側に書き込むと :exc:`curses.error` が送" +"出されます。\n" +"ウィンドウ、サブウィンドウ、パッドの右下隅に書き込もうとすると、文字を表示し" +"た後に例外が送出されます。" #: ../../library/curses.rst:802 msgid "" @@ -1122,14 +1218,16 @@ msgstr "" "``(y, x)`` に文字列 *str* を属性 *attr* で描画します。以前ディスプレイにあっ" "た内容はすべて上書きされます。" -#: ../../library/curses.rst:815 msgid "" "Writing outside the window, subwindow, or pad raises :exc:`curses.error`. " "Attempting to write to the lower-right corner of a window, subwindow, or pad " "will cause an exception to be raised after the string is printed." msgstr "" +"ウィンドウ、サブウィンドウ、パッドの外側に書き込むと :exc:`curses.error` が送" +"出されます。\n" +"ウィンドウ、サブウィンドウ、パッドの右下隅に書き込もうとすると、文字列を表示" +"した後に例外が送出されます。" -#: ../../library/curses.rst:819 msgid "" "A bug in ncurses, the backend for this Python module, could cause segfaults " "when resizing windows. This was fixed in ncurses-6.1-20190511. If you are " @@ -1137,20 +1235,26 @@ msgid "" "meth:`!addstr` with a *str* that has embedded newlines; instead, call :meth:" "`!addstr` separately for each line." msgstr "" +"この Python モジュールのバックエンドである ncurses のバグにより、ウィンドウの" +"サイズ変更時にセグメンテーション違反が発生することがありました。\n" +"このバグは ncurses-6.1-20190511 で修正されました。\n" +"それ以前の ncurses を使用せざるを得ない場合は、改行を含む *str* で :meth:`!" +"addstr` を呼び出さず、代わりに各行に対して個別に :meth:`!addstr` を呼び出すこ" +"とで回避できます。" -#: ../../library/curses.rst:828 msgid "" "Remove attribute *attr* from the \"background\" set applied to all writes to " "the current window." msgstr "" -"現在のウィンドウに書き込まれたすべての内容に対し \"バックグラウンド\" に設定" -"された属性 *attr* を除去します。" +"現在のウィンドウへのすべての書き込みに適用される \"バックグラウンド\" の属性" +"セットから *attr* を取り除きます。" -#: ../../library/curses.rst:834 msgid "" "Add attribute *attr* to the \"background\" set applied to all writes to the " "current window." msgstr "" +"現在のウィンドウへのすべての書き込みに適用される「背景」の属性の集合に、属性 " +"*attr* を追加します。" #: ../../library/curses.rst:840 msgid "" @@ -1326,7 +1430,6 @@ msgstr "" "び *bs* は共に *horch* です。この関数では、角に使われるデフォルト文字が常に使" "用されます。" -#: ../../library/curses.rst:911 msgid "" "Set the attributes of *num* characters at the current cursor position, or at " "position ``(y, x)`` if supplied. If *num* is not given or is ``-1``, the " @@ -1335,14 +1438,20 @@ msgid "" "will be touched using the :meth:`touchline` method so that the contents will " "be redisplayed by the next window refresh." msgstr "" +"現在のカーソル位置、または指定した位置 ``(y, x)`` にある *num* 文字の属性を設" +"定します。\n" +"*num* を指定しないか ``-1`` にした場合は、行末までのすべての文字に属性が設定" +"されます。\n" +"``(y, x)`` を指定した場合、この関数はカーソルをその位置に移動します。\n" +"変更した行は :meth:`touchline` メソッドで変更済みと記録され、次回のウィンドウ" +"更新時に内容が再表示されます。" -#: ../../library/curses.rst:921 msgid "" "Like :meth:`erase`, but also cause the whole window to be repainted upon " "next call to :meth:`refresh`." msgstr "" -":meth:`erase` に似ていますが、次に :meth:`refresh` が呼び出された際にすべての" -"ウィンドウを再描画するようにします。" +":meth:`erase` に似ていますが、次に :meth:`refresh` が呼び出された際にウィンド" +"ウ全体を再描画するようにします。" #: ../../library/curses.rst:927 msgid "" @@ -1352,13 +1461,13 @@ msgstr "" "*flag* が ``True`` ならば、次の :meth:`refresh` はウィンドウを完全に消去しま" "す。" -#: ../../library/curses.rst:933 msgid "" "Erase from cursor to the end of the window: all lines below the cursor are " "deleted, and then the equivalent of :meth:`clrtoeol` is performed." msgstr "" -"カーソルの位置からウィンドウの端までを消去します: カーソル以降のすべての行が" -"削除されるため、:meth:`clrtoeol` と等価です。" +"カーソル位置からウィンドウの末尾までを消去します。\n" +"まずカーソルのある行より下のすべての行を消去し、次に :meth:`clrtoeol` と同等" +"の処理を行います。" #: ../../library/curses.rst:939 msgid "Erase from cursor to the end of the line." @@ -1372,11 +1481,12 @@ msgstr "" "ウィンドウのすべての親ウィンドウについて、現在のカーソル位置を反映するよう更" "新します。" -#: ../../library/curses.rst:950 msgid "" "Delete the character under the cursor, or at ``(y, x)`` if specified. All " "characters to the right on the same line are shifted one position left." msgstr "" +"カーソルの下、または指定した ``(y, x)`` の位置の文字を削除します。\n" +"同じ行の右側にある文字はすべて 1 文字分左に移動します。" #: ../../library/curses.rst:956 msgid "" @@ -1397,13 +1507,12 @@ msgstr "" "ではなく、ウィンドウの原点からの相対位置です。派生したウィンドウオブジェクト" "が返されます。" -#: ../../library/curses.rst:970 msgid "" "Add character *ch* with attribute *attr*, and immediately call :meth:" "`refresh` on the window." msgstr "" -"文字 *ch* に属性 *attr* を付与し、即座に :meth:`refresh` をウィンドウに対して" -"呼び出します。" +"属性 *attr* を持つ文字 *ch* を追加し、すぐにウィンドウの :meth:`refresh` を呼" +"び出します。" #: ../../library/curses.rst:976 msgid "" @@ -1416,11 +1525,11 @@ msgstr "" "含まれるかを調べて、``True`` または ``False`` を返します。スクリーン上のウィ" "ンドウの一部がマウスイベントの発生場所を含むかどうかを調べる上で便利です。" -#: ../../library/curses.rst:981 msgid "Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``." msgstr "" +"以前は ``True`` または ``False`` ではなく、``1`` または ``0`` を返していまし" +"た。" -#: ../../library/curses.rst:987 msgid "" "Encoding used to encode the string arguments of the methods and to decode " "their results on a build without wide-character support. The encoding " @@ -1428,22 +1537,27 @@ msgid "" "for example with :meth:`window.subwin`. By default, current locale encoding " "is used (see :func:`locale.getencoding`)." msgstr "" +"メソッドの文字列の引数をエンコードする際、およびワイド文字をサポートしないビ" +"ルドで結果をデコードする際に使用するエンコーディングです。\n" +"例えば :meth:`window.subwin` でサブウィンドウを作成すると、encoding 属性は親" +"ウィンドウから継承されます。\n" +"デフォルトでは現在のロケールのエンコーディングが使用されます (:func:`locale." +"getencoding` を参照)。" #: ../../library/curses.rst:998 msgid "Clear the window." msgstr "ウィンドウをクリアします。" -#: ../../library/curses.rst:1003 msgid "Return a tuple ``(y, x)`` of coordinates of upper-left corner." -msgstr "" +msgstr "左上隅の座標をタプル ``(y, x)`` として返します。" -#: ../../library/curses.rst:1008 msgid "" "Return the given window's current background character/attribute pair. Its " "components can be extracted like those of :meth:`inch`." msgstr "" +"指定したウィンドウの現在の背景の文字と属性のペアを返します。\n" +"各成分は :meth:`inch` の返り値と同様に取り出せます。" -#: ../../library/curses.rst:1014 msgid "" "Read a key press, after moving the cursor to *y*, *x* if specified, and " "return it as an integer. The window is refreshed first if it is not a pad " @@ -1451,16 +1565,26 @@ msgid "" "return ``-1`` if the read is non-blocking or times out (see :meth:`nodelay` " "and :meth:`timeout`)." msgstr "" +"*y*、*x* が指定されていればカーソルをそこに移動してからキー入力を読み取り、整" +"数として返します。\n" +"ウィンドウがパッドではなく、前回の更新以降に変更されていれば、まず更新しま" +"す。\n" +"キーが押されるまで待機しますが、読み取りが非ブロッキングの場合やタイムアウト" +"した場合は ``-1`` を返します (:meth:`nodelay` と :meth:`timeout` を参照)。" -#: ../../library/curses.rst:1021 msgid "" "An ordinary key is returned as the code of a single byte of its encoding in " "the current locale, so a character encoded with several bytes takes several " "calls. For example, in a UTF-8 locale ``'é'`` is read as ``195``, then " "``169``. Use :meth:`get_wch` to read it as a single character." msgstr "" +"通常のキーは、現在のロケールのエンコーディングで表した 1 バイトのコードとして" +"返されるため、複数バイトでエンコードされる文字を読み取るには複数回の呼び出し" +"が必要です。\n" +"例えば UTF-8 ロケールでは、``'é'`` は ``195``、続いて ``169`` として読み取ら" +"れます。\n" +"1 文字として読み取るには :meth:`get_wch` を使用してください。" -#: ../../library/curses.rst:1027 msgid "" "In keypad mode (see :meth:`keypad`) function keys and other special keys are " "returned as one of the :ref:`KEY_* constants `, which " @@ -1468,14 +1592,21 @@ msgid "" "sequence does not arrive in time (see :meth:`notimeout` and :func:" "`set_escdelay`), their bytes are returned one at a time." msgstr "" +"キーパッドモード (:meth:`keypad` を参照) では、ファンクションキーやその他の特" +"殊キーは、通常のキーと区別できる :ref:`KEY_* 定数 ` の" +"いずれかとして返されます。\n" +"それ以外の場合、またはエスケープシーケンスが時間内に到着しなかった場合 (:" +"meth:`notimeout` と :func:`set_escdelay` を参照)、バイトが 1 つずつ返されま" +"す。" -#: ../../library/curses.rst:1034 ../../library/curses.rst:1054 msgid "" "In echo mode (see :func:`echo`) the key is added to the window as by :meth:" "`addch`; special keys are not echoed." msgstr "" +"echo モード (:func:`echo` を参照) では、:meth:`addch` と同様にキーがウィンド" +"ウに追加されます。\n" +"特殊キーはエコーバックされません。" -#: ../../library/curses.rst:1040 msgid "" "Read a key press, after moving the cursor to *y*, *x* if specified, and " "return it as a one-character :class:`str`. The window is refreshed first if " @@ -1483,8 +1614,14 @@ msgid "" "pressed, or raise :exc:`error` if the read is non-blocking or times out " "(see :meth:`nodelay` and :meth:`timeout`)." msgstr "" +"*y*、*x* が指定されていればカーソルをそこに移動してからキー入力を読み取り、1 " +"文字の :class:`str` として返します。\n" +"ウィンドウがパッドではなく、前回の更新以降に変更されていれば、まず更新しま" +"す。\n" +"キーが押されるまで待機しますが、読み取りが非ブロッキングの場合やタイムアウト" +"した場合は :exc:`error` を送出します (:meth:`nodelay` と :meth:`timeout` を参" +"照)。" -#: ../../library/curses.rst:1047 msgid "" "In keypad mode (see :meth:`keypad`) function keys and other special keys are " "returned as one of the :ref:`KEY_* constants `, an " @@ -1492,14 +1629,23 @@ msgid "" "(see :meth:`notimeout` and :func:`set_escdelay`), their characters are " "returned one at a time." msgstr "" +"キーパッドモード (:meth:`keypad` を参照) では、ファンクションキーやその他の特" +"殊キーは、整数である :ref:`KEY_* 定数 ` のいずれかとし" +"て返されます。\n" +"それ以外の場合、またはエスケープシーケンスが時間内に到着しなかった場合 (:" +"meth:`notimeout` と :func:`set_escdelay` を参照)、文字が 1 つずつ返されます。" -#: ../../library/curses.rst:1062 msgid "" "Read a key press as :meth:`getch` does, but return it as a :class:`str`: an " "ordinary key as a one-character string, the byte decoded as Latin-1, and a " "special key as its name, such as ``'KEY_UP'`` (see :func:`keyname`). Raise :" "exc:`error` instead of returning ``-1`` if there is no input." msgstr "" +":meth:`getch` と同様にキー入力を読み取りますが、:class:`str` として返しま" +"す。\n" +"通常のキーはバイトを Latin-1 でデコードした 1 文字の文字列として、特殊キーは " +"``'KEY_UP'`` のような名前として返します (:func:`keyname` を参照)。\n" +"入力がない場合、``-1`` を返す代わりに :exc:`error` を送出します。" #: ../../library/curses.rst:1070 msgid "Return a tuple ``(y, x)`` of the height and width of the window." @@ -1514,17 +1660,21 @@ msgstr "" "親ウィンドウ中におけるウィンドウの開始位置をタプル ``(y, x)`` で返します。" "ウィンドウに親ウィンドウがない場合 ``(-1, -1)`` を返します。" -#: ../../library/curses.rst:1085 msgid "" "Read a line of input from the user, with primitive line editing capacity, " "after moving the cursor to *y*, *x* if specified. Return it as a bytes " "object, in the encoding of the current locale and without the terminating " "newline. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" +"*y*、*x* が指定されていればカーソルをそこに移動してから、基本的な行編集機能を" +"使ってユーザの入力を 1 行読み取ります。\n" +"末尾の改行を除き、現在のロケールのエンコーディングの bytes オブジェクトとして" +"返します。\n" +"最大 *n* バイトを読み取ります。\n" +"*n* のデフォルト値は 2047 で、この値を超えることはできません。" -#: ../../library/curses.rst:1092 ../../library/curses.rst:1197 msgid "The maximum value for *n* was increased from 1023 to 2047." -msgstr "" +msgstr "*n* の最大値が 1023 から 2047 に増えました。" #: ../../library/curses.rst:1098 msgid "" @@ -1534,12 +1684,14 @@ msgstr "" "ウィンドウの左上角からの相対で表した現在のカーソル位置をタプル ``(y, x)`` で" "返します。" -#: ../../library/curses.rst:1105 msgid "" "Display a horizontal line starting at ``(y, x)`` with length *n* consisting " "of the character *ch* with attributes *attr*. The line stops at the right " "edge of the window if fewer than *n* cells are available." msgstr "" +"``(y, x)`` を始点として、属性 *attr* の文字 *ch* からなる長さ *n* の水平線を" +"表示します。\n" +"使用できるセルが *n* 個に満たない場合、線はウィンドウの右端で止まります。" #: ../../library/curses.rst:1112 msgid "" @@ -1553,11 +1705,13 @@ msgstr "" "されます。curses が最初に初期化された際には文字挿入/削除はデフォルトで有効に" "なっています。" -#: ../../library/curses.rst:1120 msgid "" "If *flag* is ``True``, :mod:`!curses` will try to use hardware line editing " "facilities. Otherwise, curses will not use them." msgstr "" +"*flag* が ``True`` の場合、:mod:`!curses` はハードウェアの行編集機能を使用し" +"ようとします。\n" +"それ以外の場合、curses はその機能を使用しません。" #: ../../library/curses.rst:1126 msgid "" @@ -1571,7 +1725,6 @@ msgstr "" "くても良くなります。とはいえ、wrefresh を繰り返し呼び出すことになるため、この" "操作はかなりパフォーマンスを低下させます。デフォルトでは無効になっています。" -#: ../../library/curses.rst:1134 msgid "" "Return the character at the given position in the window. The bottom 8 bits " "are the character proper and the upper bits are the attributes; extract them " @@ -1582,6 +1735,15 @@ msgid "" "current locale has a character byte of ``0``; use :meth:`instr` to read such " "characters." msgstr "" +"ウィンドウ内の指定した位置の文字を返します。\n" +"下位 8 ビットが文字自体で、上位ビットが属性です。\n" +":data:`A_CHARTEXT` と :data:`A_ATTRIBUTES` のビットマスクでそれぞれを取り出" +"し、:func:`pair_number` で色ペアを取り出せます。\n" +"文字のバイトは、:meth:`instr` と同様に、セルの文字をロケールのエンコーディン" +"グで表したバイトです。\n" +"ワイド文字をサポートするビルドでは、現在のロケールで 1 バイトに収まらない文字" +"の文字バイトは ``0`` になります。\n" +"そのような文字を読み取るには :meth:`instr` を使用してください。" #: ../../library/curses.rst:1148 msgid "" @@ -1591,7 +1753,6 @@ msgid "" "line being lost. The cursor position does not change." msgstr "" -#: ../../library/curses.rst:1156 msgid "" "Insert *nlines* lines into the specified window above the current line. The " "*nlines* bottom lines are lost. For negative *nlines*, delete *nlines* " @@ -1599,10 +1760,12 @@ msgid "" "up. The bottom *nlines* lines are cleared. The current cursor position " "remains the same." msgstr "" -"*nlines* 行を指定されたウィンドウの現在の行の上に挿入します。その下にある " -"*nlines* 行は失われます。負の *nlines* を指定すると、カーソルのある行以降の " -"*nlines* を削除し、削除された行の後ろに続く内容が上に来ます。その下にある " -"*nlines* は消去されます。現在のカーソル位置はそのままです。" +"指定されたウィンドウの現在の行の上に *nlines* 行を挿入します。\n" +"最下部の *nlines* 行は失われます。\n" +"*nlines* が負の場合は、カーソルのある行からその絶対値に相当する行数を削除し、" +"残りの行を上に移動します。\n" +"最下部の同じ行数分は消去されます。\n" +"現在のカーソル位置は変わりません。" #: ../../library/curses.rst:1165 msgid "" @@ -1637,13 +1800,18 @@ msgstr "" "側にある文字はすべて右にシフトし、行の右端の文字は失われます。カーソル位置は " "(*y*, *x* が指定されていた場合はそこに移動しますが、その後は) 変化しません。" -#: ../../library/curses.rst:1191 msgid "" "Read the text of the window from the current cursor position, or from *y*, " "*x* if specified, to the end of the line, and return it as a bytes object, " "in the encoding of the current locale. Attributes and color pairs are " "stripped. At most *n* bytes are read; *n* defaults to and cannot exceed 2047." msgstr "" +"現在のカーソル位置、または指定した *y*、*x* から行末までのウィンドウ内のテキ" +"ストを読み取り、現在のロケールのエンコーディングの bytes オブジェクトとして返" +"します。\n" +"属性と色ペアは取り除かれます。\n" +"最大 *n* バイトを読み取ります。\n" +"*n* のデフォルト値は 2047 で、この値を超えることはできません。" #: ../../library/curses.rst:1203 msgid "" @@ -1663,7 +1831,6 @@ msgstr "" "指定したウィンドウが、最後に :meth:`refresh` を呼んだ時から変更されている場合" "に ``True`` を返します; そうでない場合には ``False`` を返します。" -#: ../../library/curses.rst:1216 msgid "" "If *flag* is ``True``, escape sequences generated by some keys (keypad, " "function keys) will be interpreted by :mod:`!curses`. If *flag* is " @@ -1671,12 +1838,20 @@ msgid "" "mode is disabled by default, but :func:`wrapper` enables it for the main " "window." msgstr "" +"*flag* が ``True`` の場合、一部のキー (キーパッド、ファンクションキー) が生成" +"するエスケープシーケンスを :mod:`!curses` が解釈します。\n" +"*flag* が ``False`` の場合、エスケープシーケンスは入力ストリーム内にそのまま" +"残されます。\n" +"キーパッドモードはデフォルトでは無効ですが、:func:`wrapper` はメインウィンド" +"ウに対して有効にします。" -#: ../../library/curses.rst:1225 msgid "" "If *flag* is ``True``, cursor is left where it is on update, instead of " "being at \"cursor position.\" This reduces cursor movement where possible." msgstr "" +"*flag* が ``True`` の場合、更新時にカーソルを「カーソル位置」に移動せず、その" +"ままの位置に残します。\n" +"これにより、可能な限りカーソルの移動を減らします。" #: ../../library/curses.rst:1228 msgid "" @@ -1704,11 +1879,12 @@ msgstr "" msgid "Move the window so its upper-left corner is at ``(new_y, new_x)``." msgstr "ウィンドウの左上角が ``(new_y, new_x)`` になるように移動します。" -#: ../../library/curses.rst:1247 msgid "" "Moving the window so that any part of it would be off the screen is an " "error: the window is not moved and :exc:`curses.error` is raised." msgstr "" +"ウィンドウの一部でもスクリーンの外に出る位置への移動はエラーです。\n" +"ウィンドウは移動せず、:exc:`curses.error` が送出されます。" #: ../../library/curses.rst:1253 msgid "If *flag* is ``True``, :meth:`getch` will be non-blocking." @@ -1737,12 +1913,14 @@ msgstr "" "い内容を反映するように更新しますが、物理スクリーン上に反映させるための強制更" "新を行いません。更新を行うためには :func:`doupdate` を呼び出します。" -#: ../../library/curses.rst:1271 msgid "" "The 6 arguments can only be specified, and are then required, when the " "window is a pad created with :func:`newpad`; they have the same meaning as " "for :meth:`refresh`." msgstr "" +"6 つの引数を指定できるのは、ウィンドウが :func:`newpad` で作成されたパッドで" +"ある場合だけで、その場合はすべて必須です。\n" +"意味は :meth:`refresh` のものと同じです。" #: ../../library/curses.rst:1278 msgid "" @@ -1821,7 +1999,6 @@ msgstr "" "ディスプレイを即時更新し (実際のウィンドウとこれまでの描画/削除メソッドの内容" "とを同期し) ます。" -#: ../../library/curses.rst:1325 msgid "" "The 6 arguments can only be specified, and are then required, when the " "window is a pad created with :func:`newpad`. The additional parameters are " @@ -1835,6 +2012,17 @@ msgid "" "Negative values of *pminrow*, *pmincol*, *sminrow*, or *smincol* are treated " "as if they were zero." msgstr "" +"6 つの引数を指定できるのは、ウィンドウが :func:`newpad` で作成されたパッドで" +"ある場合だけで、その場合はすべて必須です。\n" +"これらの追加のパラメータは、パッドとスクリーンのどの部分を使用するかを示すた" +"めに必要です。\n" +"*pminrow* と *pmincol* はパッド内の表示する矩形の左上隅を指定します。\n" +"*sminrow*、*smincol*、*smaxrow*、*smaxcol* はスクリーン上に表示する矩形の端を" +"指定します。\n" +"両方の矩形は同じ大きさでなければならないため、パッド内の表示する矩形の右下隅" +"はスクリーン座標から計算されます。\n" +"両方の矩形は、それぞれの構造の内部に完全に収まっていなければなりません。\n" +"*pminrow*、*pmincol*、*sminrow*、*smincol* の負の値はゼロとして扱われます。" #: ../../library/curses.rst:1339 msgid "" @@ -1890,20 +2078,25 @@ msgstr "" msgid "Turn on attribute *A_STANDOUT*." msgstr "*A_STANDOUT* 属性をオンにします。" -#: ../../library/curses.rst:1382 msgid "" "Return a sub-pad, whose upper-left corner is at ``(begin_y, begin_x)``, and " "whose width/height is *ncols*/*nlines*. The coordinates are relative to the " "parent pad (unlike :meth:`subwin`, which uses screen coordinates). This " "method is only available for pads created with :func:`newpad`." msgstr "" +"左上隅が ``(begin_y, begin_x)`` にあり、幅が *ncols*、高さが *nlines* のサブ" +"パッドを返します。\n" +"座標は親パッドからの相対座標です (スクリーン座標を使う :meth:`subwin` とは異" +"なります)。\n" +"このメソッドは :func:`newpad` で作成したパッドでのみ利用できます。" -#: ../../library/curses.rst:1391 msgid "" "Return a sub-window, whose upper-left corner is at the screen-relative " "coordinates ``(begin_y, begin_x)``, and whose width/height is *ncols*/" "*nlines*." msgstr "" +"左上隅がスクリーンからの相対座標 ``(begin_y, begin_x)`` にあり、幅が " +"*ncols*、高さが *nlines* のサブウィンドウを返します。" #: ../../library/curses.rst:1394 msgid "" @@ -1954,24 +2147,21 @@ msgstr "" "``-1`` を返します。*delay* が正の値であれば、:meth:`getch` は *delay* ミリ秒" "間ブロックし、ブロック後の時点で入力がない場合には ``-1`` を返します。" -#: ../../library/curses.rst:1429 msgid "" "Pretend *count* lines have been changed, starting with line *start*. If " "*changed* is supplied, it specifies whether the affected lines are marked as " "having been changed (*changed*\\ ``=True``) or unchanged (*changed*\\ " "``=False``)." msgstr "" -"*start* から始まる *count* 行が変更されたかのように振舞わせます。もし " -"*changed* が与えられた場合、その引数は指定された行が変更された(*changed*\\ " -"``=True``)か、変更されていないか(*changed*\\ )を指定します。" +"*start* 行から *count* 行が変更されたものとして扱います。\n" +"*changed* を指定した場合は、対象の行を変更済み (*changed*\\ ``=True``) とする" +"か、未変更 (*changed*\\ ``=False``) とするかを指定します。" -#: ../../library/curses.rst:1436 msgid "" "Pretend the whole window has been changed, for purposes of drawing " "optimizations." msgstr "" -"描画を最適化するために、すべてのウィンドウが変更されたかのように振舞わせま" -"す。" +"描画を最適化するために、ウィンドウ全体が変更されたかのように振舞わせます。" #: ../../library/curses.rst:1442 msgid "" @@ -1981,19 +2171,19 @@ msgstr "" "ウィンドウ内のすべての行を、最後に :meth:`refresh` を呼んだ際から変更されてい" "ないものとしてマークします。" -#: ../../library/curses.rst:1449 msgid "" "Display a vertical line starting at ``(y, x)`` with length *n* consisting of " "the character *ch* with attributes *attr*." msgstr "" +"``(y, x)`` を始点として、属性 *attr* の文字 *ch* からなる長さ *n* の垂直線を" +"表示します。" #: ../../library/curses.rst:1454 msgid "Constants" msgstr "定数" -#: ../../library/curses.rst:1456 msgid "The :mod:`!curses` module defines the following data members:" -msgstr "" +msgstr ":mod:`!curses` モジュールは以下のデータメンバを定義します:" #: ../../library/curses.rst:1461 msgid "" @@ -2011,53 +2201,64 @@ msgstr "" ":func:`napms` のような整数を返す curses ルーチンのいくつかは、成功した際に :" "const:`OK` を返します。" -#: ../../library/curses.rst:1473 msgid "A bytes object representing the current version of the module." -msgstr "" +msgstr "モジュールの現在のバージョンを表す bytes オブジェクトです。" -#: ../../library/curses.rst:1478 msgid "" "A named tuple containing the three components of the ncurses library " "version: *major*, *minor*, and *patch*. All values are integers. The " "components can also be accessed by name, so ``curses.ncurses_version[0]`` " "is equivalent to ``curses.ncurses_version.major`` and so on." msgstr "" +"ncurses ライブラリのバージョンの 3 つの成分 *major*、*minor*、*patch* を含む" +"名前付きタプルです。\n" +"値はすべて整数です。\n" +"各成分には名前でもアクセスできるため、例えば ``curses.ncurses_version[0]`` " +"は ``curses.ncurses_version.major`` と等価です。" -#: ../../library/curses.rst:1483 msgid "Availability: if the ncurses library is used." -msgstr "" +msgstr "利用可能な環境: ncurses ライブラリが使用されている場合。" -#: ../../library/curses.rst:1489 msgid "" "The maximum number of colors the terminal can support. It is defined only " "after the call to :func:`start_color`." msgstr "" +"端末がサポートできる色の最大数です。\n" +":func:`start_color` の呼び出し後にのみ定義されます。" -#: ../../library/curses.rst:1494 msgid "" "The maximum number of color pairs the terminal can support. It is defined " "only after the call to :func:`start_color`." msgstr "" +"端末がサポートできる色ペアの最大数です。\n" +":func:`start_color` の呼び出し後にのみ定義されます。" -#: ../../library/curses.rst:1499 msgid "" "The width of the screen, that is, the number of columns. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" +"スクリーンの幅、すなわち列数です。\n" +":func:`initscr` の呼び出し後にのみ定義されます。\n" +":func:`update_lines_cols`、:func:`resizeterm`、:func:`resize_term` により更新" +"されます。" -#: ../../library/curses.rst:1506 msgid "" "The height of the screen, that is, the number of lines. It is defined only " "after the call to :func:`initscr`. Updated by :func:`update_lines_cols`, :" "func:`resizeterm` and :func:`resize_term`." msgstr "" +"スクリーンの高さ、すなわち行数です。\n" +":func:`initscr` の呼び出し後にのみ定義されます。\n" +":func:`update_lines_cols`、:func:`resizeterm`、:func:`resize_term` により更新" +"されます。" -#: ../../library/curses.rst:1512 msgid "" "Some constants are available to specify character cell attributes. The exact " "constants available are system dependent." msgstr "" +"文字セルの属性を指定するための定数が用意されています。\n" +"実際に利用できる定数はシステムによって異なります。" #: ../../library/curses.rst:1516 msgid "Attribute" @@ -2084,9 +2285,8 @@ msgstr "太字モード" msgid "Dim mode" msgstr "低輝度モード" -#: ../../library/curses.rst:1526 msgid "Invisible or blank mode" -msgstr "" +msgstr "非表示または空白モード" #: ../../library/curses.rst:1528 msgid "Italic mode" @@ -2096,13 +2296,11 @@ msgstr "イタリックモード" msgid "Normal attribute" msgstr "通常の属性" -#: ../../library/curses.rst:1532 msgid "Protected mode" -msgstr "" +msgstr "保護モード" -#: ../../library/curses.rst:1534 msgid "Reverse background and foreground colors" -msgstr "" +msgstr "背景色と前景色を反転" #: ../../library/curses.rst:1537 msgid "Standout mode" @@ -2112,55 +2310,46 @@ msgstr "強調モード" msgid "Underline mode" msgstr "下線モード" -#: ../../library/curses.rst:1541 msgid "Horizontal highlight" -msgstr "" +msgstr "水平強調" -#: ../../library/curses.rst:1543 msgid "Left highlight" -msgstr "" +msgstr "左強調" -#: ../../library/curses.rst:1545 msgid "Low highlight" -msgstr "" +msgstr "下強調" -#: ../../library/curses.rst:1547 msgid "Right highlight" -msgstr "" +msgstr "右強調" -#: ../../library/curses.rst:1549 msgid "Top highlight" -msgstr "" +msgstr "上強調" -#: ../../library/curses.rst:1551 msgid "Vertical highlight" -msgstr "" +msgstr "垂直強調" #: ../../library/curses.rst:1554 msgid "``A_ITALIC`` was added." msgstr "``A_ITALIC`` が追加されました。" -#: ../../library/curses.rst:1557 msgid "" "Several constants are available to extract corresponding attributes returned " "by some methods." msgstr "" +"一部のメソッドが返す値から対応する属性を取り出すための定数が用意されていま" +"す。" -#: ../../library/curses.rst:1561 msgid "Bit-mask" -msgstr "" +msgstr "ビットマスク" -#: ../../library/curses.rst:1563 msgid "Bit-mask to extract attributes" -msgstr "" +msgstr "属性を取り出すビットマスク" -#: ../../library/curses.rst:1566 msgid "Bit-mask to extract a character" -msgstr "" +msgstr "文字を取り出すビットマスク" -#: ../../library/curses.rst:1569 msgid "Bit-mask to extract color-pair field information" -msgstr "" +msgstr "色ペアフィールドの情報を取り出すビットマスク" #: ../../library/curses.rst:1575 msgid "" @@ -2554,7 +2743,6 @@ msgstr "端末リサイズイベント" msgid "Maximum key value" msgstr "最大キー値" -#: ../../library/curses.rst:1773 msgid "" "On VT100s and their software emulations, such as X terminal emulators, there " "are normally at least four function keys (:const:`KEY_F1 `, :const:" @@ -2565,6 +2753,15 @@ msgid "" "(older PC keyboards may have only ten function keys); also, the following " "keypad mappings are standard:" msgstr "" +"VT100 とそのソフトウェアエミュレーション (X 端末エミュレータなど) では、通常" +"は少なくとも 4 つのファンクションキー (:const:`KEY_F1 `、:const:" +"`KEY_F2 `、:const:`KEY_F3 `、:const:`KEY_F4 `) が利用" +"でき、矢印キーはそれぞれ :const:`KEY_UP`、:const:`KEY_DOWN`、:const:" +"`KEY_LEFT`、:const:`KEY_RIGHT` に対応付けられています。\n" +"PC キーボードのあるマシンでは、矢印キーと 12 個のファンクションキーがあると考" +"えてよいでしょう (古い PC キーボードにはファンクションキーが 10 個しかない場" +"合もあります)。\n" +"また、以下のキーパッドの対応付けが標準です:" #: ../../library/curses.rst:1782 msgid "Keycap" @@ -2643,9 +2840,8 @@ msgstr "これらは :func:`initscr` が呼び出された後でしか利用で msgid "ACS code" msgstr "ACS コード" -#: ../../library/curses.rst:1811 msgid "alternate name for upper-right corner" -msgstr "" +msgstr "右上隅の別名" #: ../../library/curses.rst:1813 msgid "solid square block" @@ -2659,9 +2855,8 @@ msgstr "白四角ブロック" msgid "alternate name for horizontal line" msgstr "水平線の別名" -#: ../../library/curses.rst:1819 msgid "alternate name for upper-left corner" -msgstr "" +msgstr "左上隅の別名" #: ../../library/curses.rst:1821 msgid "alternate name for top tee" @@ -2711,13 +2906,11 @@ msgstr "左向き矢印" msgid "less-than-or-equal-to" msgstr "小なりイコール" -#: ../../library/curses.rst:1845 msgid "lower-left corner" -msgstr "" +msgstr "左下隅" -#: ../../library/curses.rst:1847 msgid "lower-right corner" -msgstr "" +msgstr "右下隅" #: ../../library/curses.rst:1849 msgid "left tee" @@ -2763,9 +2956,8 @@ msgstr "スキャンライン 7" msgid "scan line 9" msgstr "スキャンライン 9" -#: ../../library/curses.rst:1871 msgid "alternate name for lower-right corner" -msgstr "" +msgstr "右下隅の別名" #: ../../library/curses.rst:1873 msgid "alternate name for vertical line" @@ -2775,9 +2967,8 @@ msgstr "垂直線の別名" msgid "alternate name for right tee" msgstr "右向き T 字罫線の別名" -#: ../../library/curses.rst:1877 msgid "alternate name for lower-left corner" -msgstr "" +msgstr "左下隅の別名" #: ../../library/curses.rst:1879 msgid "alternate name for bottom tee" @@ -2803,58 +2994,46 @@ msgstr "上向き T 字罫線" msgid "up arrow" msgstr "上向き矢印" -#: ../../library/curses.rst:1891 msgid "upper-left corner" -msgstr "" +msgstr "左上隅" -#: ../../library/curses.rst:1893 msgid "upper-right corner" -msgstr "" +msgstr "右上隅" #: ../../library/curses.rst:1895 msgid "vertical line" msgstr "垂直線" -#: ../../library/curses.rst:1898 msgid "" "The following table lists mouse button constants used by :meth:`getmouse`:" -msgstr "" +msgstr ":meth:`getmouse` で使用するマウスボタン定数を以下の表に示します:" -#: ../../library/curses.rst:1901 msgid "Mouse button constant" -msgstr "" +msgstr "マウスボタン定数" -#: ../../library/curses.rst:1903 msgid "Mouse button *n* pressed" -msgstr "" +msgstr "マウスボタン *n* が押された" -#: ../../library/curses.rst:1905 msgid "Mouse button *n* released" -msgstr "" +msgstr "マウスボタン *n* が離された" -#: ../../library/curses.rst:1907 msgid "Mouse button *n* clicked" -msgstr "" +msgstr "マウスボタン *n* がクリックされた" -#: ../../library/curses.rst:1909 msgid "Mouse button *n* double clicked" -msgstr "" +msgstr "マウスボタン *n* がダブルクリックされた" -#: ../../library/curses.rst:1911 msgid "Mouse button *n* triple clicked" -msgstr "" +msgstr "マウスボタン *n* がトリプルクリックされた" -#: ../../library/curses.rst:1913 msgid "Shift was down during button state change" -msgstr "" +msgstr "ボタンの状態変更時に Shift が押されていた" -#: ../../library/curses.rst:1915 msgid "Control was down during button state change" -msgstr "" +msgstr "ボタンの状態変更時に Control が押されていた" -#: ../../library/curses.rst:1917 msgid "Alt was down during button state change" -msgstr "" +msgstr "ボタンの状態変更時に Alt が押されていた" #: ../../library/curses.rst:1924 msgid "The following table lists the predefined colors:" @@ -2896,11 +3075,10 @@ msgstr "白" msgid "Yellow" msgstr "黄色" -#: ../../library/curses.rst:1948 msgid ":mod:`!curses.textpad` --- Text input widget for curses programs" msgstr "" +":mod:`!curses.textpad` --- curses プログラム用のテキスト入力ウィジェット" -#: ../../library/curses.rst:1953 msgid "" "The :mod:`!curses.textpad` module provides a :class:`Textbox` class that " "handles elementary text editing in a curses window, supporting a set of " @@ -2909,12 +3087,16 @@ msgid "" "a rectangle-drawing function useful for framing text boxes or for other " "purposes." msgstr "" +":mod:`!curses.textpad` モジュールは、curses ウィンドウで基本的なテキスト編集" +"を行う :class:`Textbox` クラスを提供します。\n" +"このクラスは Emacs (したがって Netscape Navigator、BBedit 6.x、FrameMaker、そ" +"の他多くのプログラム) に似たキーバインディングをサポートします。\n" +"このモジュールは、テキストボックスの枠を描く場合などに役立つ、矩形を描画する" +"関数も提供します。" -#: ../../library/curses.rst:1959 msgid "The module :mod:`!curses.textpad` defines the following function:" -msgstr "" +msgstr ":mod:`!curses.textpad` モジュールは以下の関数を定義します:" -#: ../../library/curses.rst:1964 msgid "" "Draw a rectangle. The first argument must be a window object; the remaining " "arguments are coordinates relative to that window. The second and third " @@ -2925,6 +3107,14 @@ msgid "" "(including xterm and most other software terminal emulators). Otherwise it " "will be drawn with ASCII dashes, vertical bars, and plus signs." msgstr "" +"矩形を描画します。\n" +"最初の引数はウィンドウオブジェクトでなければならず、残りの引数はそのウィンド" +"ウからの相対座標です。\n" +"2 番目と 3 番目の引数は描画する矩形の左上隅の y 座標と x 座標、4 番目と 5 番" +"目は右下隅の y 座標と x 座標です。\n" +"対応する端末 (xterm やその他の大半のソフトウェア端末エミュレータを含む) で" +"は、VT100/IBM PC の罫線文字を使用して矩形を描画します。\n" +"それ以外の場合は、ASCII のダッシュ、縦棒、プラス記号で描画します。" #: ../../library/curses.rst:1977 msgid "Textbox objects" @@ -2936,7 +3126,6 @@ msgstr "" "以下のような :class:`Textbox` オブジェクトをインスタンス生成することができま" "す:" -#: ../../library/curses.rst:1984 msgid "" "Return a textbox widget object. The *win* argument should be a curses :ref:" "`window ` object in which the textbox is to be " @@ -2946,12 +3135,19 @@ msgid "" "containing window, with coordinates ``(0, 0)``. The instance's :attr:" "`stripspaces` flag is initially on." msgstr "" +"テキストボックスウィジェットオブジェクトを返します。\n" +"*win* 引数には、テキストボックスを配置する curses の :ref:`ウィンドウ " +"` オブジェクトを指定する必要があります。\n" +"*insert_mode* が真の場合、テキストボックスは入力した文字で既存のテキストを上" +"書きせず、右にずらして挿入します。\n" +"テキストボックスの編集カーソルは、初期状態では配置先のウィンドウの左上隅、座" +"標 ``(0, 0)`` にあります。\n" +"インスタンスの :attr:`stripspaces` フラグは、初期状態ではオンです。" #: ../../library/curses.rst:1992 msgid ":class:`Textbox` objects have the following methods:" msgstr ":class:`Textbox` オブジェクトは以下のメソッドを持ちます:" -#: ../../library/curses.rst:1997 msgid "" "This is the entry point you will normally use. It accepts editing " "keystrokes until one of the termination keystrokes is entered. If " @@ -2961,13 +3157,24 @@ msgid "" "This method returns the window contents as a string; whether blanks in the " "window are included is affected by the :attr:`stripspaces` attribute." msgstr "" +"これは通常使用するエントリーポイントです。\n" +"終了用のキー操作が入力されるまで、編集のキー操作を受け付けます。\n" +"*validate* を指定する場合は関数でなければなりません。\n" +"入力されたキー操作ごとに、そのキー操作をパラメータとしてこの関数を呼び出し、" +"結果に基づいて実行するコマンドを決めます。\n" +"関数が偽の値を返した場合、そのキー操作は無視されます。\n" +"このメソッドはウィンドウの内容を文字列として返します。\n" +"ウィンドウ内の空白を含むかどうかは :attr:`stripspaces` 属性に左右されます。" -#: ../../library/curses.rst:2009 msgid "" "Process a single command keystroke. Returns ``1`` to continue editing, or " "``0`` if a termination keystroke was processed. Here are the supported " "special keystrokes:" msgstr "" +"コマンドのキー操作を 1 つ処理します。\n" +"編集を継続する場合は ``1`` を、終了用のキー操作を処理した場合は ``0`` を返し" +"ます。\n" +"サポートする特殊なキー操作は以下のとおりです:" #: ../../library/curses.rst:2014 ../../library/curses.rst:2053 msgid "Keystroke" @@ -3039,11 +3246,11 @@ msgstr "逆方向に文字を削除します。" msgid ":kbd:`Control-J`" msgstr ":kbd:`Control-J`" -#: ../../library/curses.rst:2033 msgid "" "Terminate if the window is 1 line, otherwise move to the start of the next " "line." msgstr "" +"ウィンドウが 1 行の場合は終了し、それ以外の場合は次の行の先頭に移動します。" #: ../../library/curses.rst:2037 msgid ":kbd:`Control-K`" @@ -3095,25 +3302,20 @@ msgstr "" "移動操作は、カーソルがウィンドウの縁にあって移動ができない場合には何も行いま" "せん。場合によっては、以下のような同義のキーストロークがサポートされています:" -#: ../../library/curses.rst:2055 msgid ":const:`~curses.KEY_LEFT`" -msgstr "" +msgstr ":const:`~curses.KEY_LEFT`" -#: ../../library/curses.rst:2057 msgid ":const:`~curses.KEY_RIGHT`" -msgstr "" +msgstr ":const:`~curses.KEY_RIGHT`" -#: ../../library/curses.rst:2059 msgid ":const:`~curses.KEY_UP`" -msgstr "" +msgstr ":const:`~curses.KEY_UP`" -#: ../../library/curses.rst:2061 msgid ":const:`~curses.KEY_DOWN`" -msgstr "" +msgstr ":const:`~curses.KEY_DOWN`" -#: ../../library/curses.rst:2063 msgid ":const:`~curses.KEY_BACKSPACE`" -msgstr "" +msgstr ":const:`~curses.KEY_BACKSPACE`" #: ../../library/curses.rst:2063 msgid ":kbd:`Control-h`" diff --git a/library/custominterp.po b/library/custominterp.po index 3600d9f68..3b6553b85 100644 --- a/library/custominterp.po +++ b/library/custominterp.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/custominterp.rst:5 diff --git a/library/dataclasses.po b/library/dataclasses.po index 1d4497a9a..56ec933a0 100644 --- a/library/dataclasses.po +++ b/library/dataclasses.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/dataclasses.rst:2 @@ -50,7 +50,6 @@ msgstr "" "これらの生成されたメソッドで利用されるメンバー変数は :pep:`526` 型アノテー" "ションを用いて定義されます。例えば、このコードでは::" -#: ../../library/dataclasses.rst:19 msgid "" "from dataclasses import dataclass\n" "\n" @@ -64,12 +63,22 @@ msgid "" " def total_cost(self) -> float:\n" " return self.unit_price * self.quantity_on_hand" msgstr "" +"from dataclasses import dataclass\n" +"\n" +"@dataclass\n" +"class InventoryItem:\n" +" \"\"\"在庫内の品目を管理するクラス。\"\"\"\n" +" name: str\n" +" unit_price: float\n" +" quantity_on_hand: int = 0\n" +"\n" +" def total_cost(self) -> float:\n" +" return self.unit_price * self.quantity_on_hand" #: ../../library/dataclasses.rst:31 msgid "will add, among other things, a :meth:`!__init__` that looks like::" msgstr "とりわけ、以下のような :meth:`!__init__` が追加されます::" -#: ../../library/dataclasses.rst:33 msgid "" "def __init__(self, name: str, unit_price: float, quantity_on_hand: int = " "0):\n" @@ -77,6 +86,11 @@ msgid "" " self.unit_price = unit_price\n" " self.quantity_on_hand = quantity_on_hand" msgstr "" +"def __init__(self, name: str, unit_price: float, quantity_on_hand: int = " +"0):\n" +" self.name = name\n" +" self.unit_price = unit_price\n" +" self.quantity_on_hand = quantity_on_hand" #: ../../library/dataclasses.rst:38 msgid "" @@ -133,14 +147,15 @@ msgstr "" "合の動作は、後述する引数によって異なります。デコレータは呼び出した際に指定し" "たクラスと同じクラスを返します。新しいクラスは生成されません。" -#: ../../library/dataclasses.rst:66 msgid "" "If ``@dataclass`` is used just as a simple decorator with no parameters, it " "acts as if it has the default values documented in this signature. That is, " "these three uses of ``@dataclass`` are equivalent::" msgstr "" +"``@dataclass`` をパラメータなしの単純なデコレータとして使用すると、このシグネ" +"チャに記載されたデフォルト値を指定した場合と同じ動作になります。\n" +"つまり、以下の 3 通りの ``@dataclass`` の使い方は等価です。 ::" -#: ../../library/dataclasses.rst:71 msgid "" "@dataclass\n" "class C:\n" @@ -156,23 +171,36 @@ msgid "" "class C:\n" " ..." msgstr "" +"@dataclass\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass()\n" +"class C:\n" +" ...\n" +"\n" +"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, " +"frozen=False,\n" +" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n" +"class C:\n" +" ..." -#: ../../library/dataclasses.rst:84 msgid "The parameters to ``@dataclass`` are:" -msgstr "" +msgstr "``@dataclass`` のパラメータは以下のとおりです:" -#: ../../library/dataclasses.rst:86 msgid "" "*init*: If true (the default), a :meth:`~object.__init__` method will be " "generated." msgstr "" +"*init*: 真の場合 (デフォルト)、:meth:`~object.__init__` メソッドを生成しま" +"す。" -#: ../../library/dataclasses.rst:89 msgid "" "If the class already defines :meth:`!__init__`, this parameter is ignored." msgstr "" +"クラスがすでに :meth:`!__init__` を定義している場合、このパラメータは無視され" +"ます。" -#: ../../library/dataclasses.rst:92 msgid "" "*repr*: If true (the default), a :meth:`~object.__repr__` method will be " "generated. The generated repr string will have the class name and the name " @@ -181,51 +209,65 @@ msgid "" "example: ``InventoryItem(name='widget', unit_price=3.0, " "quantity_on_hand=10)``." msgstr "" +"*repr*: 真の場合 (デフォルト)、:meth:`~object.__repr__` メソッドを生成しま" +"す。\n" +"生成される repr 文字列にはクラス名と、クラスで定義した順に各フィールドの名前" +"と repr が含まれます。\n" +"repr から除外すると指定されたフィールドは含まれません。\n" +"例えば、``InventoryItem(name='widget', unit_price=3.0, " +"quantity_on_hand=10)`` となります。" -#: ../../library/dataclasses.rst:99 msgid "" "If the class already defines :meth:`!__repr__`, this parameter is ignored." msgstr "" +"クラスがすでに :meth:`!__repr__` を定義している場合、このパラメータは無視され" +"ます。" -#: ../../library/dataclasses.rst:102 msgid "" "*eq*: If true (the default), an :meth:`~object.__eq__` method will be " "generated." msgstr "" +"*eq*: 真の場合 (デフォルト)、:meth:`~object.__eq__` メソッドを生成します。" -#: ../../library/dataclasses.rst:105 msgid "" "This method compares the class by comparing each field in order. Both " "instances in the comparison must be of the identical type." msgstr "" +"このメソッドは各フィールドを順に比較することでこのクラスのインスタンスを比較" +"します。\n" +"比較する両方のインスタンスは、まったく同じ型でなければなりません。" -#: ../../library/dataclasses.rst:108 msgid "" "If the class already defines :meth:`!__eq__`, this parameter is ignored." msgstr "" +"クラスがすでに :meth:`!__eq__` を定義している場合、このパラメータは無視されま" +"す。" -#: ../../library/dataclasses.rst:110 msgid "" "The generated ``__eq__`` method now compares each field individually (for " "example, ``self.a == other.a and self.b == other.b``), rather than comparing " "tuples of fields as in previous versions." msgstr "" +"生成される ``__eq__`` メソッドは、以前のバージョンのようにフィールドのタプル" +"を比較する代わりに、各フィールドを個別に比較するようになりました (例えば " +"``self.a == other.a and self.b == other.b``)。" -#: ../../library/dataclasses.rst:115 msgid "" "This change makes the comparison faster but it may alter results in cases " "where attributes compare equal by identity but not by value (such as " "``float('nan')``)." msgstr "" +"この変更によって比較が高速になりますが、属性が同一性では等しくても値では等し" +"くない場合 (``float('nan')`` など)、結果が変わる可能性があります。" -#: ../../library/dataclasses.rst:119 msgid "" "In Python 3.12 and earlier, the comparison was performed by creating tuples " "of the fields and comparing them (for example, ``(self.a, self.b) == (other." "a, other.b)``)." msgstr "" +"Python 3.12 以前では、フィールドのタプルを作成し、それらを比較していました " +"(例えば ``(self.a, self.b) == (other.a, other.b)``)。" -#: ../../library/dataclasses.rst:123 msgid "" "*order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:" "`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods " @@ -233,22 +275,33 @@ msgid "" "fields, in order. Both instances in the comparison must be of the identical " "type. If *order* is true and *eq* is false, a :exc:`ValueError` is raised." msgstr "" +"*order*: 真の場合 (デフォルトは ``False``)、:meth:`~object.__lt__`、:meth:" +"`~object.__le__`、:meth:`~object.__gt__`、:meth:`~object.__ge__` メソッドを生" +"成します。\n" +"これらのメソッドは、フィールドを順に並べたタプルのようにこのクラスのインスタ" +"ンスを比較します。\n" +"比較する両方のインスタンスは、まったく同じ型でなければなりません。\n" +"*order* が真で *eq* が偽の場合は、:exc:`ValueError` を送出します。" -#: ../../library/dataclasses.rst:130 msgid "" "If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:" "`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised." msgstr "" +"クラスがすでに :meth:`!__lt__`、:meth:`!__le__`、:meth:`!__gt__`、:meth:`!" +"__ge__` のいずれかを定義している場合は、:exc:`TypeError` を送出します。" -#: ../../library/dataclasses.rst:134 msgid "" "*unsafe_hash*: If true, force ``dataclasses`` to create a :meth:`~object." "__hash__` method, even though it may not be safe to do so. Otherwise, " "generate a :meth:`~object.__hash__` method according to how *eq* and " "*frozen* are set. The default value is ``False``." msgstr "" +"*unsafe_hash*: 真の場合、安全でない可能性があっても、``dataclasses`` に :" +"meth:`~object.__hash__` メソッドを強制的に作成させます。\n" +"それ以外の場合、*eq* と *frozen* の設定に従って :meth:`~object.__hash__` メ" +"ソッドを生成します。\n" +"デフォルト値は ``False`` です。" -#: ../../library/dataclasses.rst:140 msgid "" ":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are " "added to hashed collections such as dictionaries and sets. Having a :meth:`!" @@ -257,8 +310,14 @@ msgid "" "and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* " "flags in the ``@dataclass`` decorator." msgstr "" +":meth:`!__hash__` は組み込みの :meth:`hash` で使用されるほか、辞書や集合のよ" +"うなハッシュを使用するコレクションにオブジェクトを追加する際にも使用されま" +"す。\n" +":meth:`!__hash__` があることは、そのクラスのインスタンスが不変であることを示" +"唆します。\n" +"可変性は複雑な性質で、プログラマの意図、:meth:`!__eq__` の有無と動作、" +"``@dataclass`` デコレータの *eq* と *frozen* フラグの値に依存します。" -#: ../../library/dataclasses.rst:147 msgid "" "By default, ``@dataclass`` will not implicitly add a :meth:`~object." "__hash__` method unless it is safe to do so. Neither will it add or change " @@ -266,8 +325,13 @@ msgid "" "attribute ``__hash__ = None`` has a specific meaning to Python, as described " "in the :meth:`!__hash__` documentation." msgstr "" +"デフォルトでは、安全な場合を除き、``@dataclass`` は :meth:`~object.__hash__` " +"メソッドを暗黙的に追加しません。\n" +"また、明示的に定義済みの :meth:`!__hash__` メソッドを追加したり変更したりしま" +"せん。\n" +"クラス属性を ``__hash__ = None`` に設定することには、:meth:`!__hash__` のド" +"キュメントで説明されているように、Python における特定の意味があります。" -#: ../../library/dataclasses.rst:153 msgid "" "If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, " "then ``@dataclass`` *may* add an implicit :meth:`!__hash__` method. Although " @@ -276,16 +340,26 @@ msgid "" "logically immutable but can still be mutated. This is a specialized use case " "and should be considered carefully." msgstr "" +":meth:`!__hash__` が明示的に定義されていないか、``None`` に設定されている場" +"合、``@dataclass`` は暗黙的な :meth:`!__hash__` メソッドを追加する *ことがあ" +"ります*。\n" +"推奨されませんが、``unsafe_hash=True`` を指定して、``@dataclass`` に :meth:`!" +"__hash__` メソッドを強制的に作成させることができます。\n" +"論理的には不変でも変更可能なクラスの場合に、この方法を使うことが考えられま" +"す。\n" +"これは特殊な用途であり、慎重に検討する必要があります。" -#: ../../library/dataclasses.rst:160 msgid "" "Here are the rules governing implicit creation of a :meth:`!__hash__` " "method. Note that you cannot both have an explicit :meth:`!__hash__` method " "in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:" "`TypeError`." msgstr "" +":meth:`!__hash__` メソッドの暗黙的な作成には、以下の規則が適用されます。\n" +"データクラスに明示的な :meth:`!__hash__` メソッドを定義し、同時に " +"``unsafe_hash=True`` を設定することはできません。\n" +"この場合は :exc:`TypeError` が発生します。" -#: ../../library/dataclasses.rst:165 msgid "" "If *eq* and *frozen* are both true, by default ``@dataclass`` will generate " "a :meth:`!__hash__` method for you. If *eq* is true and *frozen* is false, :" @@ -295,21 +369,31 @@ msgid "" "used (if the superclass is :class:`object`, this means it will fall back to " "id-based hashing)." msgstr "" +"*eq* と *frozen* がともに真の場合、デフォルトでは ``@dataclass`` は :meth:`!" +"__hash__` メソッドを生成します。\n" +"*eq* が真で *frozen* が偽の場合、:meth:`!__hash__` は ``None`` に設定され、" +"ハッシュ不可能であることを示します (可変なので実際にハッシュ不可能です)。\n" +"*eq* が偽の場合、:meth:`!__hash__` は変更されないため、スーパークラスの :" +"meth:`!__hash__` メソッドが使用されます (スーパークラスが :class:`object` の" +"場合、id に基づくハッシュが使われます)。" -#: ../../library/dataclasses.rst:173 msgid "" "*frozen*: If true (the default is ``False``), assigning to fields will " "generate an exception. This emulates read-only frozen instances. See the :" "ref:`discussion ` below." msgstr "" +"*frozen*: 真の場合 (デフォルトは ``False``)、フィールドへの代入で例外が発生し" +"ます。\n" +"これにより、読み取り専用の凍結されたインスタンスをエミュレートします。\n" +"後述の :ref:`説明 ` を参照してください。" -#: ../../library/dataclasses.rst:177 msgid "" "If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in " "the class and *frozen* is true, then :exc:`TypeError` is raised." msgstr "" +"クラスで :meth:`~object.__setattr__` または :meth:`~object.__delattr__` が定" +"義されており、*frozen* が真の場合、:exc:`TypeError` を送出します。" -#: ../../library/dataclasses.rst:180 msgid "" "*match_args*: If true (the default is ``True``), the :attr:`~object." "__match_args__` tuple will be created from the list of non keyword-only " @@ -318,8 +402,14 @@ msgid "" "__match_args__` is already defined in the class, then :attr:`!" "__match_args__` will not be generated." msgstr "" +"*match_args*: 真の場合 (デフォルトは ``True``)、生成される :meth:`~object." +"__init__` メソッドのキーワード専用でないパラメータのリストから :attr:" +"`~object.__match_args__` タプルを作成します (:meth:`!__init__` が生成されない" +"場合も同様です。\n" +"上記を参照)。\n" +"偽の場合、またはクラスに :attr:`!__match_args__` がすでに定義されている場合" +"は、:attr:`!__match_args__` を生成しません。" -#: ../../library/dataclasses.rst:189 msgid "" "*kw_only*: If true (the default value is ``False``), then all fields will be " "marked as keyword-only. If a field is marked as keyword-only, then the only " @@ -328,28 +418,40 @@ msgid "" "is called. See the :term:`parameter` glossary entry for details. Also see " "the :const:`KW_ONLY` section." msgstr "" +"*kw_only*: 真の場合 (デフォルト値は ``False``)、すべてのフィールドをキーワー" +"ド専用に指定します。\n" +"フィールドをキーワード専用にすることの唯一の効果は、そのフィールドから生成さ" +"れる :meth:`~object.__init__` のパラメータを、:meth:`!__init__` の呼び出し時" +"にキーワードで指定する必要があるという点です。\n" +"詳細は用語集の :term:`parameter` を参照してください。\n" +":const:`KW_ONLY` の節も参照してください。" -#: ../../library/dataclasses.rst:197 msgid "Keyword-only fields are not included in :attr:`!__match_args__`." -msgstr "" +msgstr "キーワード専用フィールドは :attr:`!__match_args__` に含まれません。" -#: ../../library/dataclasses.rst:201 msgid "" "*slots*: If true (the default is ``False``), :attr:`~object.__slots__` " "attribute will be generated and new class will be returned instead of the " "original one. If :attr:`!__slots__` is already defined in the class, then :" "exc:`TypeError` is raised." msgstr "" +"*slots*: 真の場合 (デフォルトは ``False``)、:attr:`~object.__slots__` 属性を" +"生成し、元のクラスの代わりに新しいクラスを返します。\n" +"クラスに :attr:`!__slots__` がすでに定義されている場合は、:exc:`TypeError` を" +"送出します。" -#: ../../library/dataclasses.rst:207 msgid "" "Passing parameters to a base class :meth:`~object.__init_subclass__` when " "using ``slots=True`` will result in a :exc:`TypeError`. Either use " "``__init_subclass__`` with no parameters or use default values as a " "workaround. See :gh:`91126` for full details." msgstr "" +"``slots=True`` を使用する際に基底クラスの :meth:`~object.__init_subclass__` " +"にパラメータを渡すと、:exc:`TypeError` が発生します。\n" +"回避するには、パラメータなしの ``__init_subclass__`` を使用するか、デフォルト" +"値を使用してください。\n" +"詳細は :gh:`91126` を参照してください。" -#: ../../library/dataclasses.rst:215 msgid "" "If a field name is already included in the :attr:`!__slots__` of a base " "class, it will not be included in the generated :attr:`!__slots__` to " @@ -358,14 +460,26 @@ msgid "" "`fields` instead. To be able to determine inherited slots, base class :attr:" "`!__slots__` may be any iterable, but *not* an iterator." msgstr "" +"基底クラスの :attr:`!__slots__` にフィールド名がすでに含まれている場合、:ref:" +"`オーバーライド ` を防ぐため、生成される :attr:`!" +"__slots__` には含まれません。\n" +"したがって、データクラスのフィールド名を取得するために :attr:`!__slots__` を" +"使用しないでください。\n" +"代わりに :func:`fields` を使用してください。\n" +"継承するスロットを判定できるように、基底クラスの :attr:`!__slots__` には任意" +"のイテラブルを使用できますが、イテレータは使用 *できません*。" -#: ../../library/dataclasses.rst:225 msgid "" "*weakref_slot*: If true (the default is ``False``), add a slot named " "\"__weakref__\", which is required to make an instance :func:`weakref-able " "`. It is an error to specify ``weakref_slot=True`` without also " "specifying ``slots=True``." msgstr "" +"*weakref_slot*: 真の場合 (デフォルトは ``False``)、インスタンスを :func:`弱参" +"照可能 ` にするために必要な \"__weakref__\" という名前のスロット" +"を追加します。\n" +"``slots=True`` を指定せずに ``weakref_slot=True`` を指定するとエラーになりま" +"す。" #: ../../library/dataclasses.rst:233 msgid "" @@ -374,23 +488,26 @@ msgid "" msgstr "" "``フィールド`` には、通常の Python の文法でデフォルト値を指定できます。" -#: ../../library/dataclasses.rst:236 msgid "" "@dataclass\n" "class C:\n" " a: int # 'a' has no default value\n" " b: int = 0 # assign a default value for 'b'" msgstr "" +"@dataclass\n" +"class C:\n" +" a: int # 'a' にはデフォルト値がない\n" +" b: int = 0 # 'b' にデフォルト値を割り当てる" -#: ../../library/dataclasses.rst:241 msgid "" "In this example, both :attr:`!a` and :attr:`!b` will be included in the " "added :meth:`~object.__init__` method, which will be defined as::" msgstr "" +"この例では、:attr:`!a` と :attr:`!b` の両方が、次のように定義される :meth:" +"`~object.__init__` メソッドに含まれます。 ::" -#: ../../library/dataclasses.rst:244 msgid "def __init__(self, a: int, b: int = 0):" -msgstr "" +msgstr "def __init__(self, a: int, b: int = 0):" #: ../../library/dataclasses.rst:246 msgid "" @@ -402,7 +519,6 @@ msgstr "" "に定義すると、 :exc:`TypeError` が送出されます。これは、単一のクラスであって" "も、クラス継承の結果でも起きえます。" -#: ../../library/dataclasses.rst:252 msgid "" "For common and simple use cases, no other functionality is required. There " "are, however, some dataclass features that require additional per-field " @@ -410,8 +526,13 @@ msgid "" "replace the default field value with a call to the provided :func:`!field` " "function. For example::" msgstr "" +"一般的で単純な用途では、これ以外の機能は必要ありません。\n" +"ただし、データクラスの機能には、フィールドごとの追加情報を必要とするものもあ" +"ります。\n" +"追加情報を指定するために、フィールドのデフォルト値を、提供されている :func:`!" +"field` 関数の呼び出しに置き換えられます。\n" +"例えば次のようにします。 ::" -#: ../../library/dataclasses.rst:258 msgid "" "@dataclass\n" "class C:\n" @@ -420,27 +541,37 @@ msgid "" "c = C()\n" "c.mylist += [1, 2, 3]" msgstr "" +"@dataclass\n" +"class C:\n" +" mylist: list[int] = field(default_factory=list)\n" +"\n" +"c = C()\n" +"c.mylist += [1, 2, 3]" -#: ../../library/dataclasses.rst:265 msgid "" "As shown above, the :const:`MISSING` value is a :class:`sentinel` object " "used to detect if some parameters are provided by the user. This sentinel is " "used because ``None`` is a valid value for some parameters with a distinct " "meaning. No code should directly use the :const:`MISSING` value." msgstr "" +"上記の :const:`MISSING` 値は、ユーザーが一部のパラメータを指定したかどうかを" +"検出するための :class:`sentinel` オブジェクトです。\n" +"一部のパラメータでは ``None`` が固有の意味を持つ有効な値なので、このセンチネ" +"ルを使用しています。\n" +":const:`MISSING` 値を直接使用するコードを書いてはいけません。" -#: ../../library/dataclasses.rst:270 msgid "The parameters to :func:`!field` are:" -msgstr "" +msgstr ":func:`!field` のパラメータは以下のとおりです:" -#: ../../library/dataclasses.rst:272 msgid "" "*default*: If provided, this will be the default value for this field. This " "is needed because the :func:`!field` call itself replaces the normal " "position of the default value." msgstr "" +"*default*: 指定した場合、このフィールドのデフォルト値になります。\n" +"通常デフォルト値を指定する位置が :func:`!field` 呼び出しで置き換わるため、こ" +"のパラメータが必要になります。" -#: ../../library/dataclasses.rst:276 msgid "" "*default_factory*: If provided, it must be a zero-argument callable that " "will be called when a default value is needed for this field. Among other " @@ -448,20 +579,27 @@ msgid "" "discussed below. It is an error to specify both *default* and " "*default_factory*." msgstr "" +"*default_factory*: 指定する場合、引数を取らない呼び出し可能オブジェクトでなけ" +"ればなりません。\n" +"このフィールドのデフォルト値が必要なときに呼び出されます。\n" +"用途の一例として、後述するように、可変なデフォルト値を持つフィールドの指定に" +"使用できます。\n" +"*default* と *default_factory* を両方指定するとエラーになります。" -#: ../../library/dataclasses.rst:282 msgid "" "*init*: If true (the default), this field is included as a parameter to the " "generated :meth:`~object.__init__` method." msgstr "" +"*init*: 真の場合 (デフォルト)、このフィールドを、生成される :meth:`~object." +"__init__` メソッドのパラメータに含めます。" -#: ../../library/dataclasses.rst:285 msgid "" "*repr*: If true (the default), this field is included in the string returned " "by the generated :meth:`~object.__repr__` method." msgstr "" +"*repr*: 真の場合 (デフォルト)、このフィールドを、生成される :meth:`~object." +"__repr__` メソッドが返す文字列に含めます。" -#: ../../library/dataclasses.rst:288 msgid "" "*hash*: This can be a bool or ``None``. If true, this field is included in " "the generated :meth:`~object.__hash__` method. If false, this field is " @@ -471,6 +609,15 @@ msgid "" "comparisons. Setting this value to anything other than ``None`` is " "discouraged." msgstr "" +"*hash*: bool または ``None`` を指定できます。\n" +"真の場合、このフィールドを、生成される :meth:`~object.__hash__` メソッドに含" +"めます。\n" +"偽の場合、このフィールドを、生成される :meth:`~object.__hash__` から除外しま" +"す。\n" +"``None`` の場合 (デフォルト)、*compare* の値を使用します。\n" +"比較に使用するフィールドはハッシュにも含めるべきなので、通常はこれが期待され" +"る動作です。\n" +"この値を ``None`` 以外に設定することは推奨されません。" #: ../../library/dataclasses.rst:296 msgid "" @@ -485,14 +632,15 @@ msgstr "" "要かつ、その型のハッシュ値を計算するのに他のフィールドも使われることです。\n" "フィールドがハッシュから除外されていたとしても、比較には使えます。" -#: ../../library/dataclasses.rst:302 msgid "" "*compare*: If true (the default), this field is included in the generated " "equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object." "__gt__`, et al.)." msgstr "" +"*compare*: 真の場合 (デフォルト)、このフィールドを、生成される等価比較および" +"順序比較のメソッド (:meth:`~object.__eq__`、:meth:`~object.__gt__` など) に含" +"めます。" -#: ../../library/dataclasses.rst:306 msgid "" "*metadata*: This can be a mapping or ``None``. ``None`` is treated as an " "empty dict. This value is wrapped in :func:`~types.MappingProxyType` to " @@ -501,22 +649,29 @@ msgid "" "mechanism. Multiple third-parties can each have their own key, to use as a " "namespace in the metadata." msgstr "" +"*metadata*: マッピングまたは ``None`` を指定できます。\n" +"``None`` は空の辞書として扱われます。\n" +"この値は :func:`~types.MappingProxyType` でラップして読み取り専用にし、:" +"class:`Field` オブジェクト上で公開します。\n" +"データクラス自体はこの値を一切使用せず、サードパーティの拡張機構として提供し" +"ています。\n" +"複数のサードパーティがそれぞれ独自のキーを持ち、メタデータ内の名前空間として" +"使用できます。" -#: ../../library/dataclasses.rst:314 msgid "" "*kw_only*: If true, this field will be marked as keyword-only. This is used " "when the generated :meth:`~object.__init__` method's parameters are computed." msgstr "" +"*kw_only*: 真の場合、このフィールドをキーワード専用に指定します。\n" +"これは、生成される :meth:`~object.__init__` メソッドのパラメータを算出する際" +"に使用されます。" -#: ../../library/dataclasses.rst:318 msgid "Keyword-only fields are also not included in :attr:`!__match_args__`." -msgstr "" +msgstr "キーワード専用フィールドは :attr:`!__match_args__` にも含まれません。" -#: ../../library/dataclasses.rst:322 msgid "*doc*: optional docstring for this field." -msgstr "" +msgstr "*doc*: このフィールドの省略可能な docstring です。" -#: ../../library/dataclasses.rst:326 msgid "" "If the default value of a field is specified by a call to :func:`!field`, " "then the class attribute for this field will be replaced by the specified " @@ -526,8 +681,14 @@ msgid "" "fields, just as if the default value itself were specified. For example, " "after::" msgstr "" +"フィールドのデフォルト値を :func:`!field` の呼び出しで指定した場合、その" +"フィールドのクラス属性は、指定した *default* 値で置き換えられます。\n" +"*default* を指定しなかった場合、クラス属性は削除されます。\n" +"これは、:deco:`dataclass` デコレータの実行後、デフォルト値そのものを指定した" +"場合と同じように、クラス属性がすべてフィールドのデフォルト値を持つようにする" +"ためです。\n" +"例えば、次のコードを実行すると、 ::" -#: ../../library/dataclasses.rst:335 msgid "" "@dataclass\n" "class C:\n" @@ -536,42 +697,56 @@ msgid "" " z: int = field(repr=False, default=10)\n" " t: int = 20" msgstr "" +"@dataclass\n" +"class C:\n" +" x: int\n" +" y: int = field(repr=False)\n" +" z: int = field(repr=False, default=10)\n" +" t: int = 20" -#: ../../library/dataclasses.rst:342 msgid "" "The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!" "C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` " "will not be set." msgstr "" +"クラス属性 :attr:`!C.z` は ``10``、クラス属性 :attr:`!C.t` は ``20`` になり、" +"クラス属性 :attr:`!C.x` と :attr:`!C.y` は設定されません。" -#: ../../library/dataclasses.rst:346 msgid "" "If *metadata* is ``None``, use an empty :class:`frozendict`, instead of a :" "func:`~types.MappingProxyType` of an empty :class:`dict`." msgstr "" +"*metadata* が ``None`` の場合、空の :class:`dict` を包んだ :func:`~types." +"MappingProxyType` の代わりに、空の :class:`frozendict` を使用するようになりま" +"した。" -#: ../../library/dataclasses.rst:352 msgid "" ":class:`!Field` objects describe each defined field. These objects are " "created internally, and are returned by the :func:`fields` module-level " "method (see below). Users should never instantiate a :class:`!Field` object " "directly. Its documented attributes are:" msgstr "" +":class:`!Field` オブジェクトは、定義された各フィールドを記述します。\n" +"これらのオブジェクトは内部で作成され、モジュールレベルの :func:`fields` 関数 " +"(後述) から返されます。\n" +"ユーザーが :class:`!Field` オブジェクトを直接インスタンス化してはいけませ" +"ん。\n" +"公開されている属性は以下のとおりです:" -#: ../../library/dataclasses.rst:357 msgid ":attr:`!name`: The name of the field." -msgstr "" +msgstr ":attr:`!name`: フィールドの名前。" -#: ../../library/dataclasses.rst:358 msgid ":attr:`!type`: The type of the field." -msgstr "" +msgstr ":attr:`!type`: フィールドの型。" -#: ../../library/dataclasses.rst:359 msgid "" ":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :" "attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have " "the identical meaning and values as they do in the :func:`field` function." msgstr "" +":attr:`!default`、:attr:`!default_factory`、:attr:`!init`、:attr:`!repr`、:" +"attr:`!hash`、:attr:`!compare`、:attr:`!metadata`、:attr:`!kw_only` の意味と" +"値は、:func:`field` 関数のものと同じです。" #: ../../library/dataclasses.rst:363 msgid "" @@ -581,7 +756,6 @@ msgstr "" "他の属性があることもありますが、それらはプライベートであり、調べたり、依存し" "たりしてはなりません。" -#: ../../library/dataclasses.rst:368 msgid "" "``InitVar[T]`` type annotations describe variables that are :ref:`init-only " "`. Fields annotated with :class:`!InitVar` " @@ -589,6 +763,13 @@ msgid "" "`fields` function nor used in any way except adding them as parameters to :" "meth:`~object.__init__` and an optional :meth:`__post_init__`." msgstr "" +"``InitVar[T]`` 型アノテーションは、:ref:`初期化限定 ` の変数を記述します。\n" +":class:`!InitVar` でアノテーションされたフィールドは疑似フィールドとみなされ" +"ます。\n" +"そのため、:func:`fields` 関数から返されず、:meth:`~object.__init__` および存" +"在する場合は :meth:`__post_init__` のパラメータとして追加する以外の用途には使" +"われません。" #: ../../library/dataclasses.rst:377 msgid "" @@ -604,19 +785,23 @@ msgstr "" "`TypeError` を送出します。\n" "``ClassVar`` や ``InitVar`` といった疑似フィールドは返しません。" -#: ../../library/dataclasses.rst:384 msgid "" "Converts the dataclass *obj* to a dict (by using the factory function " "*dict_factory*). Each dataclass is converted to a dict of its fields, as " "``name: value`` pairs. dataclasses, dicts, frozendicts, lists, and tuples " "are recursed into. Other objects are copied with :func:`copy.deepcopy`." msgstr "" +"データクラス *obj* を (ファクトリ関数 *dict_factory* を使用して) 辞書に変換し" +"ます。\n" +"各データクラスは、フィールドを ``name: value`` のペアとする辞書に変換されま" +"す。\n" +"データクラス、辞書、frozendict、リスト、タプルの内部は再帰的に処理されま" +"す。\n" +"その他のオブジェクトは :func:`copy.deepcopy` でコピーされます。" -#: ../../library/dataclasses.rst:390 msgid "Example of using :func:`!asdict` on nested dataclasses::" -msgstr "" +msgstr "入れ子になったデータクラスに :func:`!asdict` を使用する例です。 ::" -#: ../../library/dataclasses.rst:392 msgid "" "@dataclass\n" "class Point:\n" @@ -633,49 +818,67 @@ msgid "" "c = C([Point(0, 0), Point(10, 4)])\n" "assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" msgstr "" +"@dataclass\n" +"class Point:\n" +" x: int\n" +" y: int\n" +"\n" +"@dataclass\n" +"class C:\n" +" mylist: list[Point]\n" +"\n" +"p = Point(10, 20)\n" +"assert asdict(p) == {'x': 10, 'y': 20}\n" +"\n" +"c = C([Point(0, 0), Point(10, 4)])\n" +"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}" -#: ../../library/dataclasses.rst:407 ../../library/dataclasses.rst:427 msgid "To create a shallow copy, the following workaround may be used::" -msgstr "" +msgstr "浅いコピーを作成するには、以下の方法が使えます。 ::" -#: ../../library/dataclasses.rst:409 msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}" -msgstr "" +msgstr "{field.name: getattr(obj, field.name) for field in fields(obj)}" -#: ../../library/dataclasses.rst:411 msgid "" ":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance." msgstr "" +"*obj* がデータクラスのインスタンスでない場合、:func:`!asdict` は :exc:" +"`TypeError` を送出します。" -#: ../../library/dataclasses.rst:416 msgid "" "Converts the dataclass *obj* to a tuple (by using the factory function " "*tuple_factory*). Each dataclass is converted to a tuple of its field " "values. dataclasses, dicts, frozendicts, lists, and tuples are recursed " "into. Other objects are copied with :func:`copy.deepcopy`." msgstr "" +"データクラス *obj* を (ファクトリ関数 *tuple_factory* を使用して) タプルに変" +"換します。\n" +"各データクラスは、そのフィールドの値からなるタプルに変換されます。\n" +"データクラス、辞書、frozendict、リスト、タプルの内部は再帰的に処理されま" +"す。\n" +"その他のオブジェクトは :func:`copy.deepcopy` でコピーされます。" #: ../../library/dataclasses.rst:422 msgid "Continuing from the previous example::" msgstr "1つ前の例の続きです::" -#: ../../library/dataclasses.rst:424 msgid "" "assert astuple(p) == (10, 20)\n" "assert astuple(c) == ([(0, 0), (10, 4)],)" msgstr "" +"assert astuple(p) == (10, 20)\n" +"assert astuple(c) == ([(0, 0), (10, 4)],)" -#: ../../library/dataclasses.rst:429 msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -msgstr "" +msgstr "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))" -#: ../../library/dataclasses.rst:431 msgid "" ":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass " "instance." msgstr "" +"*obj* がデータクラスのインスタンスでない場合、:func:`!astuple` は :exc:" +"`TypeError` を送出します。" -#: ../../library/dataclasses.rst:436 msgid "" "Creates a new dataclass with name *cls_name*, fields as defined in *fields*, " "base classes as given in *bases*, and initialized with a namespace as given " @@ -686,30 +889,49 @@ msgid "" "*slots*, and *weakref_slot* have the same meaning as they do in :deco:" "`dataclass`." msgstr "" +"名前を *cls_name*、フィールドを *fields* の定義、基底クラスを *bases* に指定" +"したものとする新しいデータクラスを作成し、*namespace* に指定した名前空間で初" +"期化します。\n" +"*fields* は、各要素が ``name``、``(name, type)``、``(name, type, Field)`` の" +"いずれかであるイテラブルです。\n" +"``name`` だけを指定した場合、``type`` には :data:`typing.Any` が使用されま" +"す。\n" +"*init*、*repr*、*eq*、*order*、*unsafe_hash*、*frozen*、*match_args*、" +"*kw_only*、*slots*、*weakref_slot* の値の意味は :deco:`dataclass` のものと同" +"じです。" -#: ../../library/dataclasses.rst:446 msgid "" "If *module* is defined, the :attr:`!__module__` attribute of the dataclass " "is set to that value. By default, it is set to the module name of the caller." msgstr "" +"*module* を指定した場合、データクラスの :attr:`!__module__` 属性はその値に設" +"定されます。\n" +"デフォルトでは、呼び出し元のモジュール名に設定されます。" -#: ../../library/dataclasses.rst:450 msgid "" "The *decorator* parameter is a callable that will be used to create the " "dataclass. It should take the class object as a first argument and the same " "keyword arguments as :deco:`dataclass`. By default, the :deco:`dataclass` " "function is used." msgstr "" +"*decorator* パラメータは、データクラスの作成に使用する呼び出し可能オブジェク" +"トです。\n" +"最初の引数としてクラスオブジェクトを取り、:deco:`dataclass` と同じキーワード" +"引数を受け付ける必要があります。\n" +"デフォルトでは :deco:`dataclass` 関数を使用します。" -#: ../../library/dataclasses.rst:455 msgid "" "This function is not strictly required, because any Python mechanism for " "creating a new class with :attr:`~object.__annotations__` can then apply " "the :deco:`dataclass` function to convert that class to a dataclass. This " "function is provided as a convenience. For example::" msgstr "" +":attr:`~object.__annotations__` を持つ新しいクラスを作成する Python の機構で" +"あれば、どれでもその後 :deco:`dataclass` 関数を適用してデータクラスに変換でき" +"るため、この関数は必須ではありません。\n" +"利便性のために提供されています。\n" +"例えば、次のコードは、 ::" -#: ../../library/dataclasses.rst:461 msgid "" "C = make_dataclass('C',\n" " [('x', int),\n" @@ -717,12 +939,16 @@ msgid "" " ('z', int, field(default=5))],\n" " namespace={'add_one': lambda self: self.x + 1})" msgstr "" +"C = make_dataclass('C',\n" +" [('x', int),\n" +" 'y',\n" +" ('z', int, field(default=5))],\n" +" namespace={'add_one': lambda self: self.x + 1})" #: ../../library/dataclasses.rst:467 msgid "Is equivalent to::" msgstr "は、次のコードと等しいです::" -#: ../../library/dataclasses.rst:469 msgid "" "@dataclass\n" "class C:\n" @@ -733,38 +959,56 @@ msgid "" " def add_one(self):\n" " return self.x + 1" msgstr "" +"@dataclass\n" +"class C:\n" +" x: int\n" +" y: 'typing.Any'\n" +" z: int = 5\n" +"\n" +" def add_one(self):\n" +" return self.x + 1" -#: ../../library/dataclasses.rst:478 msgid "Added the *decorator* parameter." -msgstr "" +msgstr "*decorator* パラメータを追加しました。" -#: ../../library/dataclasses.rst:483 msgid "" "Creates a new object of the same type as *obj*, replacing fields with values " "from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If " "keys in *changes* are not field names of the given dataclass, raises :exc:" "`TypeError`." msgstr "" +"*obj* と同じ型の新しいオブジェクトを作成し、フィールドを *changes* の値で置き" +"換えます。\n" +"*obj* がデータクラスでない場合は :exc:`TypeError` を送出します。\n" +"*changes* のキーが指定したデータクラスのフィールド名でない場合は :exc:" +"`TypeError` を送出します。" -#: ../../library/dataclasses.rst:488 msgid "" "The newly returned object is created by calling the :meth:`~object.__init__` " "method of the dataclass. This ensures that :meth:`__post_init__`, if " "present, is also called." msgstr "" +"新たに返すオブジェクトは、データクラスの :meth:`~object.__init__` メソッドを" +"呼び出して作成します。\n" +"これにより、:meth:`__post_init__` が存在する場合は、それも確実に呼び出されま" +"す。" -#: ../../library/dataclasses.rst:492 msgid "" "Init-only variables without default values, if any exist, must be specified " "on the call to :func:`!replace` so that they can be passed to :meth:`!" "__init__` and :meth:`__post_init__`." msgstr "" +"デフォルト値を持たない初期化限定変数がある場合は、:meth:`!__init__` と :meth:" +"`__post_init__` に渡せるように、:func:`!replace` の呼び出し時に指定する必要が" +"あります。" -#: ../../library/dataclasses.rst:496 msgid "" "It is an error for *changes* to contain any fields that are defined as " "having ``init=False``. A :exc:`ValueError` will be raised in this case." msgstr "" +"*changes* に ``init=False`` で定義されたフィールドが含まれているとエラーにな" +"ります。\n" +"この場合は :exc:`ValueError` を送出します。" #: ../../library/dataclasses.rst:500 msgid "" @@ -777,18 +1021,21 @@ msgid "" "instance copying." msgstr "" -#: ../../library/dataclasses.rst:509 msgid "" "Dataclass instances are also supported by generic function :func:`copy." "replace`." msgstr "" +"データクラスのインスタンスは、汎用関数 :func:`copy.replace` でもサポートされ" +"ています。" -#: ../../library/dataclasses.rst:513 msgid "" "Return ``True`` if its parameter is a dataclass (including subclasses of a " "dataclass, but not including :ref:`generic aliases `) or " "an instance of one, otherwise return ``False``." msgstr "" +"パラメータがデータクラス (データクラスのサブクラスを含みますが、:ref:`ジェネ" +"リックエイリアス ` は含みません) またはそのインスタンスで" +"あれば ``True`` を、そうでなければ ``False`` を返します。" #: ../../library/dataclasses.rst:517 msgid "" @@ -800,22 +1047,22 @@ msgstr "" "い) かどうかを知る必要がある場合は、 ``not isinstance(obj, type)`` で追加の" "チェックをしてください::" -#: ../../library/dataclasses.rst:521 msgid "" "def is_dataclass_instance(obj):\n" " return is_dataclass(obj) and not isinstance(obj, type)" msgstr "" +"def is_dataclass_instance(obj):\n" +" return is_dataclass(obj) and not isinstance(obj, type)" -#: ../../library/dataclasses.rst:526 msgid "" "A :class:`sentinel` object signifying a missing default or *default_factory*." msgstr "" +"デフォルト値または *default_factory* が指定されていないことを示す :class:" +"`sentinel` オブジェクトです。" -#: ../../library/dataclasses.rst:528 msgid ":const:`!MISSING` is now a :class:`sentinel` object." -msgstr "" +msgstr ":const:`!MISSING` は :class:`sentinel` オブジェクトになりました。" -#: ../../library/dataclasses.rst:533 msgid "" "A :class:`sentinel` object used as a type annotation. Any fields after a " "pseudo-field with the type of :const:`!KW_ONLY` are marked as keyword-only " @@ -825,6 +1072,15 @@ msgid "" "signify :meth:`~object.__init__` parameters that must be specified as " "keywords when the class is instantiated." msgstr "" +"型アノテーションとして使用する :class:`sentinel` オブジェクトです。\n" +"型が :const:`!KW_ONLY` の疑似フィールドより後のフィールドは、すべてキーワード" +"専用フィールドとして指定されます。\n" +"型が :const:`!KW_ONLY` の疑似フィールドは、それ以外の点では完全に無視されま" +"す。\n" +"そのフィールドの名前も無視されます。\n" +"慣例では、:const:`!KW_ONLY` フィールドの名前に ``_`` を使用します。\n" +"キーワード専用フィールドは、クラスのインスタンス化時にキーワードで指定する必" +"要がある :meth:`~object.__init__` パラメータを表します。" #: ../../library/dataclasses.rst:542 msgid "" @@ -832,7 +1088,6 @@ msgid "" "fields::" msgstr "このサンプルでは ``y`` と ``z`` がキーワード専用フィールドとなります::" -#: ../../library/dataclasses.rst:544 msgid "" "@dataclass\n" "class Point:\n" @@ -843,16 +1098,24 @@ msgid "" "\n" "p = Point(0, y=1.5, z=2.0)" msgstr "" +"@dataclass\n" +"class Point:\n" +" x: float\n" +" _: KW_ONLY\n" +" y: float\n" +" z: float\n" +"\n" +"p = Point(0, y=1.5, z=2.0)" -#: ../../library/dataclasses.rst:553 msgid "" "In a single dataclass, it is an error to specify more than one field whose " "type is :const:`!KW_ONLY`." msgstr "" +"単一のデータクラス内で、型が :const:`!KW_ONLY` のフィールドを複数指定するとエ" +"ラーになります。" -#: ../../library/dataclasses.rst:558 msgid ":const:`!KW_ONLY` is now a :class:`sentinel` object." -msgstr "" +msgstr ":const:`!KW_ONLY` は :class:`sentinel` オブジェクトになりました。" #: ../../library/dataclasses.rst:563 msgid "" @@ -868,7 +1131,6 @@ msgstr "" msgid "Post-init processing" msgstr "初期化後の処理" -#: ../../library/dataclasses.rst:574 msgid "" "When defined on the class, it will be called by the generated :meth:`~object." "__init__`, normally as :meth:`!self.__post_init__`. However, if any " @@ -877,17 +1139,21 @@ msgid "" "__init__` method is generated, then :meth:`!__post_init__` will not " "automatically be called." msgstr "" +"クラスに定義されている場合、生成された :meth:`~object.__init__` から、通常" +"は :meth:`!self.__post_init__` として呼び出されます。\n" +"ただし、``InitVar`` フィールドが定義されている場合、それらもクラスで定義され" +"た順に :meth:`!__post_init__` に渡されます。\n" +":meth:`!__init__` メソッドが生成されない場合、:meth:`!__post_init__` は自動的" +"には呼び出されません。" -#: ../../library/dataclasses.rst:581 msgid "" "Among other uses, this allows for initializing field values that depend on " "one or more other fields. For example::" msgstr "" -"他の機能と組み合わせることで、他の 1 つ以上のフィールドに依存しているフィール" -"ドが初期化できます。\n" -"例えば次のようにできます::" +"用途の一例として、他の一つ以上のフィールドに依存するフィールドの値を初期化で" +"きます。\n" +"例えば次のようにできます。 ::" -#: ../../library/dataclasses.rst:584 msgid "" "@dataclass\n" "class C:\n" @@ -898,16 +1164,26 @@ msgid "" " def __post_init__(self):\n" " self.c = self.a + self.b" msgstr "" +"@dataclass\n" +"class C:\n" +" a: float\n" +" b: float\n" +" c: float = field(init=False)\n" +"\n" +" def __post_init__(self):\n" +" self.c = self.a + self.b" -#: ../../library/dataclasses.rst:593 msgid "" "The :meth:`~object.__init__` method generated by :deco:`dataclass` does not " "call base class :meth:`!__init__` methods. If the base class has an :meth:`!" "__init__` method that has to be called, it is common to call this method in " "a :meth:`__post_init__` method::" msgstr "" +":deco:`dataclass` が生成する :meth:`~object.__init__` メソッドは、基底クラス" +"の :meth:`!__init__` メソッドを呼び出しません。\n" +"基底クラスに呼び出す必要のある :meth:`!__init__` メソッドがある場合、通常は :" +"meth:`__post_init__` メソッド内で呼び出します。 ::" -#: ../../library/dataclasses.rst:598 msgid "" "class Rectangle:\n" " def __init__(self, height, width):\n" @@ -921,13 +1197,26 @@ msgid "" " def __post_init__(self):\n" " super().__init__(self.side, self.side)" msgstr "" +"class Rectangle:\n" +" def __init__(self, height, width):\n" +" self.height = height\n" +" self.width = width\n" +"\n" +"@dataclass\n" +"class Square(Rectangle):\n" +" side: float\n" +"\n" +" def __post_init__(self):\n" +" super().__init__(self.side, self.side)" -#: ../../library/dataclasses.rst:610 msgid "" "Note, however, that in general the dataclass-generated :meth:`!__init__` " "methods don't need to be called, since the derived dataclass will take care " "of initializing all fields of any base class that is a dataclass itself." msgstr "" +"ただし、基底クラス自体がデータクラスであれば、派生データクラスがそのすべての" +"フィールドを初期化するため、一般にデータクラスが生成した :meth:`!__init__` メ" +"ソッドを呼び出す必要はありません。" #: ../../library/dataclasses.rst:614 msgid "" @@ -944,7 +1233,6 @@ msgstr "" msgid "Class variables" msgstr "クラス変数" -#: ../../library/dataclasses.rst:623 msgid "" "One of the few places where :deco:`dataclass` actually inspects the type of " "a field is to determine if a field is a class variable as defined in :pep:" @@ -953,12 +1241,18 @@ msgid "" "as a field and is ignored by the dataclass mechanisms. Such ``ClassVar`` " "pseudo-fields are not returned by the module-level :func:`fields` function." msgstr "" +":deco:`dataclass` が実際にフィールドの型を調べる数少ない場面の 1 つは、フィー" +"ルドが :pep:`526` で定義されるクラス変数かどうかを判定する場合です。\n" +"これは、フィールドの型が :data:`typing.ClassVar` かどうかを調べて行います。\n" +"``ClassVar`` であれば、フィールドとしての処理から除外され、データクラスの機構" +"では無視されます。\n" +"このような ``ClassVar`` 疑似フィールドは、モジュールレベルの :func:`fields` " +"関数から返されません。" #: ../../library/dataclasses.rst:634 msgid "Init-only variables" msgstr "初期化限定変数" -#: ../../library/dataclasses.rst:636 msgid "" "Another place where :deco:`dataclass` inspects a type annotation is to " "determine if a field is an init-only variable. It does this by seeing if " @@ -969,16 +1263,25 @@ msgid "" "`~object.__init__` method, and are passed to the optional :meth:" "`__post_init__` method. They are not otherwise used by dataclasses." msgstr "" +":deco:`dataclass` が型アノテーションを調べるもう 1 つの場面は、フィールドが初" +"期化限定変数かどうかを判定する場合です。\n" +"これは、フィールドの型が :class:`InitVar` かどうかを調べて行います。\n" +":class:`InitVar` であれば、初期化限定フィールドという疑似フィールドとみなされ" +"ます。\n" +"本当のフィールドではないため、モジュールレベルの :func:`fields` 関数から返さ" +"れません。\n" +"初期化限定フィールドは、生成される :meth:`~object.__init__` メソッドのパラ" +"メータとして追加され、:meth:`__post_init__` メソッドがあればそこに渡されま" +"す。\n" +"データクラスは、それ以外の用途には使用しません。" -#: ../../library/dataclasses.rst:646 msgid "" "For example, suppose a field will be initialized from a database, if a value " "is not provided when creating the class::" msgstr "" -"例えば、あるフィールドがデータベースから初期化されると仮定して、クラスを作成" -"するときには値が与えられない次の場合を考えます::" +"例えば、インスタンスの作成時に値が渡されなかった場合に、フィールドをデータ" +"ベースから初期化するものとします。 ::" -#: ../../library/dataclasses.rst:649 msgid "" "@dataclass\n" "class C:\n" @@ -992,18 +1295,29 @@ msgid "" "\n" "c = C(10, database=my_database)" msgstr "" +"@dataclass\n" +"class C:\n" +" i: int\n" +" j: int | None = None\n" +" database: InitVar[DatabaseType | None] = None\n" +"\n" +" def __post_init__(self, database):\n" +" if self.j is None and database is not None:\n" +" self.j = database.lookup('j')\n" +"\n" +"c = C(10, database=my_database)" -#: ../../library/dataclasses.rst:661 msgid "" "In this case, :func:`fields` will return :class:`Field` objects for :attr:`!" "i` and :attr:`!j`, but not for :attr:`!database`." msgstr "" +"この場合、:func:`fields` は :attr:`!i` と :attr:`!j` の :class:`Field` オブ" +"ジェクトを返しますが、:attr:`!database` のものは返しません。" #: ../../library/dataclasses.rst:667 msgid "Frozen instances" msgstr "凍結されたインスタンス" -#: ../../library/dataclasses.rst:669 msgid "" "It is not possible to create truly immutable Python objects. However, by " "passing ``frozen=True`` to the :deco:`dataclass` decorator you can emulate " @@ -1011,19 +1325,26 @@ msgid "" "__setattr__` and :meth:`~object.__delattr__` methods to the class. These " "methods will raise a :exc:`FrozenInstanceError` when invoked." msgstr "" +"真に不変な Python オブジェクトを作成することはできません。\n" +"ただし、:deco:`dataclass` デコレータに ``frozen=True`` を渡すことで、不変性を" +"エミュレートできます。\n" +"この場合、データクラスは :meth:`~object.__setattr__` と :meth:`~object." +"__delattr__` メソッドをクラスに追加します。\n" +"これらのメソッドは呼び出されると :exc:`FrozenInstanceError` を送出します。" -#: ../../library/dataclasses.rst:675 msgid "" "There is a tiny performance penalty when using ``frozen=True``: :meth:" "`~object.__init__` cannot use simple assignment to initialize fields, and " "must use :meth:`!object.__setattr__`." msgstr "" +"``frozen=True`` を使用すると、パフォーマンスがわずかに低下します。\n" +":meth:`~object.__init__` がフィールドの初期化に単純な代入を使えず、:meth:`!" +"object.__setattr__` を使用しなければならないためです。" #: ../../library/dataclasses.rst:684 msgid "Inheritance" msgstr "継承" -#: ../../library/dataclasses.rst:686 msgid "" "When the dataclass is being created by the :deco:`dataclass` decorator, it " "looks through all of the class's base classes in reverse MRO (that is, " @@ -1034,8 +1355,18 @@ msgid "" "ordered mapping of fields. Because the fields are in insertion order, " "derived classes override base classes. An example::" msgstr "" +":deco:`dataclass` デコレータによるデータクラスの作成時には、クラスのすべての" +"基底クラスを MRO の逆順 (つまり :class:`object` から始まる順序) に調べ、見つ" +"かった各データクラスのフィールドを、順序付きのフィールドのマッピングに追加し" +"ます。\n" +"すべての基底クラスのフィールドを追加した後、自身のフィールドをその順序付き" +"マッピングに追加します。\n" +"生成されるすべてのメソッドは、このように計算して統合した順序付きのフィールド" +"のマッピングを使用します。\n" +"フィールドは挿入順に並ぶため、派生クラスが基底クラスをオーバーライドしま" +"す。\n" +"例えば次のようになります。 ::" -#: ../../library/dataclasses.rst:696 msgid "" "@dataclass\n" "class Base:\n" @@ -1047,27 +1378,38 @@ msgid "" " z: int = 10\n" " x: int = 15" msgstr "" +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" y: int = 0\n" +"\n" +"@dataclass\n" +"class C(Base):\n" +" z: int = 10\n" +" x: int = 15" -#: ../../library/dataclasses.rst:706 msgid "" "The final list of fields is, in order, :attr:`!x`, :attr:`!y`, :attr:`!z`. " "The final type of :attr:`!x` is :class:`int`, as specified in class :class:`!" "C`." msgstr "" +"最終的なフィールドのリストは、順に :attr:`!x`、:attr:`!y`、:attr:`!z` となり" +"ます。\n" +":attr:`!x` の最終的な型は、クラス :class:`!C` で指定された :class:`int` で" +"す。" -#: ../../library/dataclasses.rst:709 msgid "" "The generated :meth:`~object.__init__` method for :class:`!C` will look " "like::" msgstr "" +":class:`!C` に生成される :meth:`~object.__init__` メソッドは、次のようになり" +"ます。 ::" -#: ../../library/dataclasses.rst:711 msgid "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -msgstr "" +msgstr "def __init__(self, x: int = 15, y: int = 0, z: int = 10):" -#: ../../library/dataclasses.rst:714 msgid "Re-ordering of keyword-only parameters in :meth:`!__init__`" -msgstr "" +msgstr ":meth:`!__init__` のキーワード専用パラメータの並べ替え" #: ../../library/dataclasses.rst:716 msgid "" @@ -1081,14 +1423,14 @@ msgstr "" "のキーワード専用引数は、非キーワード専用パラメータの末尾にこなければならない" "という、キーワード専用パラメータのPythonの実装の都合で必要なことです。" -#: ../../library/dataclasses.rst:722 msgid "" "In this example, :attr:`!Base.y`, :attr:`!Base.w`, and :attr:`!D.t` are " "keyword-only fields, and :attr:`!Base.x` and :attr:`!D.z` are regular " "fields::" msgstr "" +"この例では、:attr:`!Base.y`、:attr:`!Base.w`、:attr:`!D.t` はキーワード専用" +"フィールドで、:attr:`!Base.x` と :attr:`!D.z` は通常のフィールドです。 ::" -#: ../../library/dataclasses.rst:725 msgid "" "@dataclass\n" "class Base:\n" @@ -1102,49 +1444,62 @@ msgid "" " z: int = 10\n" " t: int = field(kw_only=True, default=0)" msgstr "" +"@dataclass\n" +"class Base:\n" +" x: Any = 15.0\n" +" _: KW_ONLY\n" +" y: int = 0\n" +" w: int = 1\n" +"\n" +"@dataclass\n" +"class D(Base):\n" +" z: int = 10\n" +" t: int = field(kw_only=True, default=0)" -#: ../../library/dataclasses.rst:737 msgid "The generated :meth:`!__init__` method for :class:`!D` will look like::" msgstr "" +":class:`!D` に生成される :meth:`!__init__` メソッドは、次のようになりま" +"す。 ::" -#: ../../library/dataclasses.rst:739 msgid "" "def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " "int = 0):" msgstr "" +"def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: " +"int = 0):" -#: ../../library/dataclasses.rst:741 msgid "" "Note that the parameters have been re-ordered from how they appear in the " "list of fields: parameters derived from regular fields are followed by " "parameters derived from keyword-only fields." msgstr "" -"パラメータは、フィールドのリストの表示方法によって並べ替えられます。通常の" -"フィールドから派生したパラメータの後に、キーワードのみのフィールドから派生し" -"たパラメータが続きます。" +"引数の順序はフィールドのリストに現れる順序から変更されています。\n" +"通常のフィールドに対応する引数の後に、キーワード専用フィールドに対応する引数" +"が続きます。" -#: ../../library/dataclasses.rst:745 msgid "" "The relative ordering of keyword-only parameters is maintained in the re-" "ordered :meth:`!__init__` parameter list." msgstr "" +"並べ替え後の :meth:`!__init__` のパラメータリストでは、キーワード専用パラメー" +"タ同士の相対的な順序は保持されます。" #: ../../library/dataclasses.rst:750 msgid "Default factory functions" msgstr "デフォルトファクトリ関数" -#: ../../library/dataclasses.rst:752 msgid "" "If a :func:`field` specifies a *default_factory*, it is called with zero " "arguments when a default value for the field is needed. For example, to " "create a new instance of a list, use::" msgstr "" +":func:`field` に *default_factory* が指定されている場合、フィールドのデフォル" +"ト値が必要になると、引数なしで呼び出されます。\n" +"例えば、リストの新しいインスタンスを作成するには、次のようにします。 ::" -#: ../../library/dataclasses.rst:756 msgid "mylist: list = field(default_factory=list)" -msgstr "" +msgstr "mylist: list = field(default_factory=list)" -#: ../../library/dataclasses.rst:758 msgid "" "If a field is excluded from :meth:`~object.__init__` (using ``init=False``) " "and the field also specifies *default_factory*, then the default factory " @@ -1152,6 +1507,10 @@ msgid "" "function. This happens because there is no other way to give the field an " "initial value." msgstr "" +"フィールドが (``init=False`` によって) :meth:`~object.__init__` から除外され" +"ており、そのフィールドに *default_factory* も指定されている場合、生成された :" +"meth:`!__init__` 関数からデフォルトファクトリ関数が常に呼び出されます。\n" +"これは、フィールドに初期値を与える方法が他にないためです。" #: ../../library/dataclasses.rst:765 msgid "Mutable default values" @@ -1165,7 +1524,6 @@ msgstr "" "Python はメンバ変数のデフォルト値をクラス属性に保持します。\n" "データクラスを使っていない、この例を考えてみましょう::" -#: ../../library/dataclasses.rst:770 msgid "" "class C:\n" " x = []\n" @@ -1179,18 +1537,29 @@ msgid "" "assert o1.x == [1, 2]\n" "assert o1.x is o2.x" msgstr "" +"class C:\n" +" x = []\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"o1 = C()\n" +"o2 = C()\n" +"o1.add(1)\n" +"o2.add(2)\n" +"assert o1.x == [1, 2]\n" +"assert o1.x is o2.x" -#: ../../library/dataclasses.rst:782 msgid "" "Note that the two instances of class :class:`!C` share the same class " "variable :attr:`!x`, as expected." msgstr "" +"想定どおり、クラス :class:`!C` の 2 つのインスタンスが同じクラス変数 :attr:`!" +"x` を共有していることに注意してください。" #: ../../library/dataclasses.rst:785 msgid "Using dataclasses, *if* this code was valid::" msgstr "データクラスを使っているこのコードが *もし仮に* 有効なものだとしたら::" -#: ../../library/dataclasses.rst:787 msgid "" "@dataclass\n" "class D:\n" @@ -1198,12 +1567,16 @@ msgid "" " def add(self, element):\n" " self.x.append(element)" msgstr "" +"@dataclass\n" +"class D:\n" +" x: list = [] # このコードは ValueError を送出する\n" +" def add(self, element):\n" +" self.x.append(element)" #: ../../library/dataclasses.rst:793 msgid "it would generate code similar to::" msgstr "データクラスは次のようなコードを生成するでしょう::" -#: ../../library/dataclasses.rst:795 msgid "" "class D:\n" " x = []\n" @@ -1214,8 +1587,15 @@ msgid "" "\n" "assert D().x is D().x" msgstr "" +"class D:\n" +" x = []\n" +" def __init__(self, x=x):\n" +" self.x = x\n" +" def add(self, element):\n" +" self.x.append(element)\n" +"\n" +"assert D().x is D().x" -#: ../../library/dataclasses.rst:804 msgid "" "This has the same issue as the original example using class :class:`!C`. " "That is, two instances of class :class:`!D` that do not specify a value for :" @@ -1227,6 +1607,16 @@ msgid "" "is that if a value is unhashable, it is mutable. This is a partial " "solution, but it does protect against many common errors." msgstr "" +"これには、クラス :class:`!C` を使用した最初の例と同じ問題があります。\n" +"つまり、クラスインスタンスを作成する際に :attr:`!x` の値を指定しなかったクラ" +"ス :class:`!D` の 2 つのインスタンスは、同じ :attr:`!x` を共有します。\n" +"データクラスも通常の Python のクラス作成を使用するだけなので、この動作を共有" +"します。\n" +"データクラスがこの状況を検出する一般的な方法はありません。\n" +"代わりに、:deco:`dataclass` デコレータは、ハッシュ不可能なデフォルトのパラ" +"メータを検出すると :exc:`ValueError` を送出します。\n" +"これは、ハッシュ不可能な値は可変であるという仮定に基づきます。\n" +"部分的な解決策ですが、よくある多くの誤りを防げます。" #: ../../library/dataclasses.rst:815 msgid "" @@ -1236,7 +1626,6 @@ msgstr "" "デフォルトファクトリ関数を使うのが、フィールドのデフォルト値として可変な型の" "新しいインスタンスを作成する手段です::" -#: ../../library/dataclasses.rst:818 msgid "" "@dataclass\n" "class D:\n" @@ -1244,39 +1633,50 @@ msgid "" "\n" "assert D().x is not D().x" msgstr "" +"@dataclass\n" +"class D:\n" +" x: list = field(default_factory=list)\n" +"\n" +"assert D().x is not D().x" -#: ../../library/dataclasses.rst:824 msgid "" "Instead of looking for and disallowing objects of type :class:`list`, :class:" "`dict`, or :class:`set`, unhashable objects are now not allowed as default " "values. Unhashability is used to approximate mutability." msgstr "" +":class:`list`、:class:`dict`、:class:`set` 型のオブジェクトを検出して禁止する" +"代わりに、ハッシュ不可能なオブジェクトをデフォルト値として禁止するようになり" +"ました。\n" +"ハッシュ不可能かどうかを、可変かどうかの近似的な判定に使用しています。" -#: ../../library/dataclasses.rst:831 msgid "Descriptor-typed fields" -msgstr "" +msgstr "デスクリプタ型のフィールド" -#: ../../library/dataclasses.rst:833 msgid "" "Fields that are assigned :ref:`descriptor objects ` as their " "default value have the following special behaviors:" msgstr "" +"デフォルト値として :ref:`デスクリプタオブジェクト ` が代入された" +"フィールドは、以下のような特別な動作をします:" -#: ../../library/dataclasses.rst:836 msgid "" "The value for the field passed to the dataclass's :meth:`~object.__init__` " "method is passed to the descriptor's :meth:`~object.__set__` method rather " "than overwriting the descriptor object." msgstr "" +"データクラスの :meth:`~object.__init__` メソッドに渡されたフィールドの値は、" +"デスクリプタオブジェクトを上書きするのではなく、デスクリプタの :meth:" +"`~object.__set__` メソッドに渡されます。" -#: ../../library/dataclasses.rst:840 msgid "" "Similarly, when getting or setting the field, the descriptor's :meth:" "`~object.__get__` or :meth:`!__set__` method is called rather than returning " "or overwriting the descriptor object." msgstr "" +"同様に、フィールドを取得または設定すると、デスクリプタオブジェクトを返したり" +"上書きしたりする代わりに、デスクリプタの :meth:`~object.__get__` または :" +"meth:`!__set__` メソッドを呼び出します。" -#: ../../library/dataclasses.rst:844 msgid "" "To determine whether a field contains a default value, :deco:`dataclass` " "will call the descriptor's :meth:`!__get__` method using its class access " @@ -1285,8 +1685,14 @@ msgid "" "hand, if the descriptor raises :exc:`AttributeError` in this situation, no " "default value will be provided for the field." msgstr "" +"フィールドがデフォルト値を持つかどうかを判定するため、:deco:`dataclass` はデ" +"スクリプタの :meth:`!__get__` メソッドを、クラスからアクセスする形式 " +"``descriptor.__get__(obj=None, type=cls)`` で呼び出します。\n" +"この場合にデスクリプタが値を返せば、その値をフィールドのデフォルト値として使" +"用します。\n" +"一方、この状況でデスクリプタが :exc:`AttributeError` を送出した場合、フィール" +"ドにはデフォルト値が設定されません。" -#: ../../library/dataclasses.rst:854 msgid "" "class IntConversionDescriptor:\n" " def __init__(self, *, default):\n" @@ -1314,10 +1720,37 @@ msgid "" "i.quantity_on_hand = 2.5 # calls __set__ with 2.5\n" "print(i.quantity_on_hand) # 2" msgstr "" +"class IntConversionDescriptor:\n" +" def __init__(self, *, default):\n" +" self._default = default\n" +"\n" +" def __set_name__(self, owner, name):\n" +" self._name = \"_\" + name\n" +"\n" +" def __get__(self, obj, type):\n" +" if obj is None:\n" +" return self._default\n" +"\n" +" return getattr(obj, self._name, self._default)\n" +"\n" +" def __set__(self, obj, value):\n" +" setattr(obj, self._name, int(value))\n" +"\n" +"@dataclass\n" +"class InventoryItem:\n" +" quantity_on_hand: IntConversionDescriptor = " +"IntConversionDescriptor(default=100)\n" +"\n" +"i = InventoryItem()\n" +"print(i.quantity_on_hand) # 100\n" +"i.quantity_on_hand = 2.5 # 2.5 を渡して __set__ を呼び出す\n" +"print(i.quantity_on_hand) # 2" -#: ../../library/dataclasses.rst:879 msgid "" "Note that if a field is annotated with a descriptor type, but is not " "assigned a descriptor object as its default value, the field will act like a " "normal field." msgstr "" +"フィールドにデスクリプタ型のアノテーションが付いていても、デフォルト値として" +"デスクリプタオブジェクトが代入されていなければ、通常のフィールドと同じように" +"動作することに注意してください。" diff --git a/library/datatypes.po b/library/datatypes.po index 5b6034eec..3573da9b0 100644 --- a/library/datatypes.po +++ b/library/datatypes.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/datatypes.rst:5 @@ -35,7 +35,6 @@ msgstr "" "この章で解説されるモジュールは日付や時間、型が固定された配列、ヒープキュー、" "両端キュー、列挙型のような種々の特殊なデータ型を提供します。" -#: ../../library/datatypes.rst:11 msgid "" "Python also provides :ref:`some built-in data types `, in " "particular, :class:`list`, :class:`tuple`, :class:`dict`, :class:" @@ -43,6 +42,11 @@ msgid "" "is used to hold Unicode strings, and the :class:`bytes` and :class:" "`bytearray` classes are used to hold binary data." msgstr "" +"Python は :ref:`組み込みデータ型 ` も提供しており、主なものに" +"は :class:`list`、:class:`tuple`、:class:`dict`、:class:`frozendict`、:class:" +"`set`、:class:`frozenset` があります。\n" +":class:`str` クラスは Unicode 文字列を保持するために、:class:`bytes` と :" +"class:`bytearray` クラスはバイナリデータを保持するために使用されます。" #: ../../library/datatypes.rst:18 msgid "The following modules are documented in this chapter:" diff --git a/library/datetime.po b/library/datetime.po index b590502df..4b98b7b70 100644 --- a/library/datetime.po +++ b/library/datetime.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/datetime.rst:2 @@ -87,16 +87,17 @@ msgstr "拡張タイムゾーンと構文解析サポートのあるサードパ msgid "Package :pypi:`DateType`" msgstr ":pypi:`DateType` パッケージ" -#: ../../library/datetime.rst:35 msgid "" "Third-party library that introduces distinct static types to for example, " "allow :term:`static type checkers ` to differentiate " "between naive and aware datetimes." msgstr "" +"異なる静的な型を導入するサードパーティライブラリです。\n" +"例えば、:term:`静的型チェッカー ` が naive な日時と " +"aware な日時を区別できるようになります。" -#: ../../library/datetime.rst:43 msgid "Aware and naive objects" -msgstr "" +msgstr "aware オブジェクトと naive オブジェクト" #: ../../library/datetime.rst:45 msgid "" @@ -137,7 +138,6 @@ msgstr "" "を無視してしまうというコストを無視すれば、簡単に理解でき、うまく利用すること" "ができます。" -#: ../../library/datetime.rst:61 msgid "" "For applications requiring aware objects, :class:`.datetime` and :class:`." "time` objects have an optional time zone information attribute, :attr:`!" @@ -146,8 +146,14 @@ msgid "" "offset from UTC time, the time zone name, and whether daylight saving time " "is in effect." msgstr "" +"aware オブジェクトが必要なアプリケーションのために、:class:`.datetime` と :" +"class:`.time` オブジェクトには、省略可能なタイムゾーン情報の属性 :attr:`!" +"tzinfo` があります。\n" +"この属性には、抽象クラス :class:`!tzinfo` のサブクラスのインスタンスを設定で" +"きます。\n" +"これらの :class:`tzinfo` オブジェクトは、UTC 時刻からのオフセット、タイムゾー" +"ン名、夏時間が適用されているかどうかの情報を保持します。" -#: ../../library/datetime.rst:67 msgid "" "Only one concrete :class:`tzinfo` class, the :class:`timezone` class, is " "supplied by the :mod:`!datetime` module. The :class:`!timezone` class can " @@ -157,14 +163,14 @@ msgid "" "across the world are more political than rational, change frequently, and " "there is no standard suitable for every application aside from UTC." msgstr "" -"ただ一つの具象 :class:`tzinfo` クラスである :class:`timezone` クラスが :mod:" -"`!datetime` モジュールで提供されています。 :class:`!timezone` クラスは、UTCか" -"らのオフセットが固定である単純なタイムゾーン(例えばUTCそれ自体)、および北ア" -"メリカにおける東部標準時(EST)/東部夏時間(EDT)のような単純ではないタイム" -"ゾーンの両方を表現できます。より深く詳細までタイムゾーンをサポートするかはア" -"プリケーションに依存します。世界中の時刻の調整を決めるルールは合理的というよ" -"りかは政治的なもので、頻繁に変わり、UTC を除くと都合のよい基準というものはあ" -"りません。" +":mod:`!datetime` モジュールが提供する具象 :class:`tzinfo` クラスは :class:" +"`timezone` だけです。\n" +":class:`!timezone` クラスは、UTC 自体や北米の EST、EDT など、UTC からのオフ" +"セットが固定された単純なタイムゾーンを表現できます。\n" +"より詳細なタイムゾーンの扱いはアプリケーションに任されています。\n" +"世界各地の時刻調整のルールは合理的というより政治的なもので、頻繁に変更されま" +"す。\n" +"UTC を除けば、あらゆるアプリケーションに適した標準はありません。" #: ../../library/datetime.rst:77 msgid "Constants" @@ -194,9 +200,8 @@ msgstr "" msgid "Alias for the UTC time zone singleton :attr:`datetime.timezone.utc`." msgstr "UTCタイムゾーンシングルトン :attr:`datetime.timezone.utc` の別名。" -#: ../../library/datetime.rst:101 msgid "Available types" -msgstr "" +msgstr "利用可能な型" #: ../../library/datetime.rst:106 msgid "" @@ -261,19 +266,18 @@ msgstr "" msgid "Objects of these types are immutable." msgstr "これらの型のオブジェクトは変更不可能 (immutable) です。" -#: ../../library/datetime.rst:155 msgid "Subclass relationships:" -msgstr "" +msgstr "サブクラスの関係:" -#: ../../library/datetime.rst:157 msgid "" "timedelta, tzinfo, time, and date inherit from object; timezone inherits\n" "from tzinfo; and datetime inherits from date." msgstr "" +"timedelta、tzinfo、time、date は object を継承し、timezone は tzinfo を継承" +"し、datetime は date を継承します。" -#: ../../library/datetime.rst:165 msgid "Common properties" -msgstr "" +msgstr "共通の性質" #: ../../library/datetime.rst:167 msgid "" @@ -299,9 +303,8 @@ msgstr "" "これらの型のオブジェクトは :mod:`pickle` モジュールを利用して効率的な pickle " "化をサポートしています。" -#: ../../library/datetime.rst:177 msgid "Determining if an object is aware or naive" -msgstr "" +msgstr "オブジェクトが aware か naive かの判定" #: ../../library/datetime.rst:179 msgid "Objects of the :class:`date` type are always naive." @@ -359,9 +362,8 @@ msgstr "" "aware なオブジェクトと naive なオブジェクトの区別は :class:`timedelta` オブ" "ジェクトにはあてはまりません。" -#: ../../library/datetime.rst:204 msgid ":class:`!timedelta` objects" -msgstr "" +msgstr ":class:`!timedelta` オブジェクト" #: ../../library/datetime.rst:206 msgid "" @@ -432,7 +434,6 @@ msgstr "" "次の例は、 *days*, *seconds*, *microseconds* に加えて任意の引数がどう \"集約" "\" され、最終的に3つの属性に正規化されるかの説明をしています::" -#: ../../library/datetime.rst:233 msgid "" ">>> import datetime as dt\n" ">>> delta = dt.timedelta(\n" @@ -448,16 +449,31 @@ msgid "" ">>> delta\n" "datetime.timedelta(days=64, seconds=29156, microseconds=10)" msgstr "" +">>> import datetime as dt\n" +">>> delta = dt.timedelta(\n" +"... days=50,\n" +"... seconds=27,\n" +"... microseconds=10,\n" +"... milliseconds=29000,\n" +"... minutes=5,\n" +"... hours=8,\n" +"... weeks=2\n" +"... )\n" +">>> # days、seconds、microseconds だけが残る\n" +">>> delta\n" +"datetime.timedelta(days=64, seconds=29156, microseconds=10)" -#: ../../library/datetime.rst:248 msgid "" "``import datetime as dt`` instead of ``import datetime`` or ``from datetime " "import datetime`` to avoid confusion between the module and the class. See " "`How I Import Python’s datetime Module `__." msgstr "" +"モジュールとクラスの混同を避けるため、``import datetime`` や ``from datetime " +"import datetime`` ではなく ``import datetime as dt`` を使用します。\n" +"`How I Import Python’s datetime Module `__ を参照してください。" -#: ../../library/datetime.rst:253 msgid "" "If any argument is a float and there are fractional microseconds, the " "fractional microseconds left over from all arguments are combined and their " @@ -465,10 +481,11 @@ msgid "" "tiebreaker. If no argument is a float, the conversion and normalization " "processes are exact (no information is lost)." msgstr "" -"引数のいずれかが浮動小数点であり、小数のマイクロ秒が存在する場合、小数のマイ" -"クロ秒は全ての引数から一度取り置かれ、それらの和は最近接偶数のマイクロ秒に丸" -"められます。浮動小数点の引数がない場合、値の変換と正規化の過程は厳密な (失わ" -"れる情報がない) ものとなります。" +"引数に浮動小数点数があり、マイクロ秒未満の端数が生じる場合は、すべての引数の" +"端数を合計し、最も近いマイクロ秒に丸めます。\n" +"ちょうど中間の値は偶数側に丸めます。\n" +"浮動小数点数の引数がなければ、変換と正規化は厳密に行われ、情報は失われませ" +"ん。" #: ../../library/datetime.rst:260 msgid "" @@ -484,21 +501,24 @@ msgid "" "example::" msgstr "負の値を正規化すると、最初は混乱するような値になります。例えば::" -#: ../../library/datetime.rst:266 msgid "" ">>> import datetime as dt\n" ">>> d = dt.timedelta(microseconds=-1)\n" ">>> (d.days, d.seconds, d.microseconds)\n" "(-1, 86399, 999999)" msgstr "" +">>> import datetime as dt\n" +">>> d = dt.timedelta(microseconds=-1)\n" +">>> (d.days, d.seconds, d.microseconds)\n" +"(-1, 86399, 999999)" -#: ../../library/datetime.rst:271 msgid "" "Since the string representation of :class:`!timedelta` objects can be " "confusing, use the following recipe to produce a more readable format:" msgstr "" +":class:`!timedelta` オブジェクトの文字列表現は分かりにくいことがあるため、以" +"下のレシピで読みやすい形式にできます:" -#: ../../library/datetime.rst:274 msgid "" ">>> def pretty_timedelta(td):\n" "... if td.days >= 0:\n" @@ -511,6 +531,16 @@ msgid "" ">>> pretty_timedelta(d)\n" "'-(1:00:00)'" msgstr "" +">>> def pretty_timedelta(td):\n" +"... if td.days >= 0:\n" +"... return str(td)\n" +"... return f'-({-td!s})'\n" +"...\n" +">>> d = timedelta(hours=-1)\n" +">>> str(d) # 人には分かりにくい\n" +"'-1 day, 23:00:00'\n" +">>> pretty_timedelta(d)\n" +"'-(1:00:00)'" #: ../../library/datetime.rst:288 ../../library/datetime.rst:628 #: ../../library/datetime.rst:1201 ../../library/datetime.rst:1850 @@ -564,14 +594,14 @@ msgstr "両端値を含む-999,999,999 から 999,999,999 の間" msgid "Between 0 and 86,399 inclusive." msgstr "両端値を含む 0 から 86,399 の間" -#: ../../library/datetime.rst:324 msgid "" "It is a somewhat common bug for code to unintentionally use this attribute " "when it is actually intended to get a :meth:`~timedelta.total_seconds` value " "instead:" msgstr "" +"本来は :meth:`~timedelta.total_seconds` の値を取得するつもりで、誤ってこの属" +"性を使用してしまうバグは比較的よくあります:" -#: ../../library/datetime.rst:328 msgid "" ">>> import datetime as dt\n" ">>> duration = dt.timedelta(seconds=11235813)\n" @@ -580,6 +610,12 @@ msgid "" ">>> duration.total_seconds()\n" "11235813.0" msgstr "" +">>> import datetime as dt\n" +">>> duration = dt.timedelta(seconds=11235813)\n" +">>> duration.days, duration.seconds\n" +"(130, 3813)\n" +">>> duration.total_seconds()\n" +"11235813.0" #: ../../library/datetime.rst:340 msgid "Between 0 and 999,999 inclusive." @@ -795,13 +831,16 @@ msgstr "" ":class:`timedelta` オブジェクトの文字列表現は内部表現に類似した形に正規化され" "ます。そのため負の timedelta は少し変な結果になります。例えば::" -#: ../../library/datetime.rst:425 msgid "" ">>> timedelta(hours=-5)\n" "datetime.timedelta(days=-1, seconds=68400)\n" ">>> print(_)\n" "-1 day, 19:00:00" msgstr "" +">>> timedelta(hours=-5)\n" +"datetime.timedelta(days=-1, seconds=68400)\n" +">>> print(_)\n" +"-1 day, 19:00:00" #: ../../library/datetime.rst:431 msgid "" @@ -823,13 +862,17 @@ msgstr "" "び :class:`.datetime` オブジェクトとの間で加減算をサポートしています (下を参" "照してください)。" -#: ../../library/datetime.rst:439 msgid "" "Floor division and true division of a :class:`timedelta` object by another :" "class:`!timedelta` object are now supported, as are remainder operations and " "the :func:`divmod` function. True division and multiplication of a :class:`!" "timedelta` object by a :class:`float` object are now supported." msgstr "" +":class:`timedelta` オブジェクトを別の :class:`!timedelta` オブジェクトで割る" +"切り捨て除算と真の除算、および剰余演算と :func:`divmod` 関数がサポートされる" +"ようになりました。\n" +":class:`!timedelta` オブジェクトと :class:`float` オブジェクトの真の除算およ" +"び乗算もサポートされるようになりました。" #: ../../library/datetime.rst:445 msgid ":class:`timedelta` objects support equality and order comparisons." @@ -848,12 +891,15 @@ msgstr "" msgid "Instance methods:" msgstr "インスタンスメソッド:" -#: ../../library/datetime.rst:454 msgid "" "Return the total number of seconds contained in the duration. Equivalent to " "``td / timedelta(seconds=1)``. For interval units other than seconds, use " "the division form directly (for example, ``td / timedelta(microseconds=1)``)." msgstr "" +"経過時間に含まれる秒数の合計を返します。\n" +"``td / timedelta(seconds=1)`` と等価です。\n" +"秒以外の時間単位には、除算の形式を直接使用してください (例えば ``td / " +"timedelta(microseconds=1)``)。" #: ../../library/datetime.rst:458 msgid "" @@ -863,15 +909,13 @@ msgstr "" "非常に長い期間 (多くのプラットフォームでは270年以上) については、このメソッド" "はマイクロ秒の精度を失うことがあることに注意してください。" -#: ../../library/datetime.rst:465 msgid "Examples of usage: :class:`!timedelta`" -msgstr "" +msgstr "使用例: :class:`!timedelta`" #: ../../library/datetime.rst:467 msgid "An additional example of normalization::" msgstr "正規化の追加の例です::" -#: ../../library/datetime.rst:469 msgid "" ">>> # Components of another_year add up to exactly 365 days\n" ">>> import datetime as dt\n" @@ -883,12 +927,20 @@ msgid "" ">>> year.total_seconds()\n" "31536000.0" msgstr "" +">>> # another_year の各成分の合計はちょうど 365 日になる\n" +">>> import datetime as dt\n" +">>> year = dt.timedelta(days=365)\n" +">>> another_year = dt.timedelta(weeks=40, days=84, hours=23,\n" +"... minutes=50, seconds=600)\n" +">>> year == another_year\n" +"True\n" +">>> year.total_seconds()\n" +"31536000.0" #: ../../library/datetime.rst:479 msgid "Examples of :class:`timedelta` arithmetic::" msgstr ":class:`timedelta` の計算の例です::" -#: ../../library/datetime.rst:481 msgid "" ">>> import datetime as dt\n" ">>> year = dt.timedelta(days=365)\n" @@ -904,10 +956,22 @@ msgid "" ">>> three_years, three_years.days // 365\n" "(datetime.timedelta(days=1095), 3)" msgstr "" +">>> import datetime as dt\n" +">>> year = dt.timedelta(days=365)\n" +">>> ten_years = 10 * year\n" +">>> ten_years\n" +"datetime.timedelta(days=3650)\n" +">>> ten_years.days // 365\n" +"10\n" +">>> nine_years = ten_years - year\n" +">>> nine_years\n" +"datetime.timedelta(days=3285)\n" +">>> three_years = nine_years // 3\n" +">>> three_years, three_years.days // 365\n" +"(datetime.timedelta(days=1095), 3)" -#: ../../library/datetime.rst:499 msgid ":class:`!date` objects" -msgstr "" +msgstr ":class:`!date` オブジェクト" #: ../../library/datetime.rst:501 msgid "" @@ -951,9 +1015,8 @@ msgid "" "If an argument outside those ranges is given, :exc:`ValueError` is raised." msgstr "範囲を超えた引数を与えた場合、 :exc:`ValueError` が送出されます。" -#: ../../library/datetime.rst:520 ../../library/datetime.rst:954 msgid "Other constructors, all class methods:" -msgstr "他のコンストラクタ、および全てのクラスメソッドを以下に示します:" +msgstr "その他のコンストラクタ (すべてクラスメソッド):" #: ../../library/datetime.rst:524 msgid "Return the current local date." @@ -963,11 +1026,12 @@ msgstr "現在のローカルな日付を返します。" msgid "This is equivalent to ``date.fromtimestamp(time.time())``." msgstr "``date.fromtimestamp(time.time())`` と等価です。" -#: ../../library/datetime.rst:531 msgid "" "Return the local date corresponding to the POSIX *timestamp*, such as is " "returned by :func:`time.time`." msgstr "" +":func:`time.time` の返り値などの POSIX *timestamp* に対応するローカルな日付を" +"返します。" #: ../../library/datetime.rst:534 msgid "" @@ -997,16 +1061,17 @@ msgstr "" "出するようになりました。 :c:func:`localtime` の呼び出し失敗で :exc:" "`ValueError` ではなく :exc:`OSError` を送出するようになりました。" -#: ../../library/datetime.rst:547 ../../library/datetime.rst:1042 -#: ../../library/datetime.rst:1082 msgid "Accepts any real number as *timestamp*, not only integer or float." msgstr "" +"*timestamp* として、整数や浮動小数点数だけでなく任意の実数を受け付けるように" +"なりました。" -#: ../../library/datetime.rst:553 msgid "" "Return the date corresponding to the proleptic Gregorian *ordinal*, where " "January 1 of year 1 has ordinal 1." msgstr "" +"先発グレゴリオ暦の序数 *ordinal* に対応する日付を返します。\n" +"1 年 1 月 1 日の序数を 1 とします。" #: ../../library/datetime.rst:556 msgid "" @@ -1046,7 +1111,6 @@ msgstr "序数の日付は現在サポートされていません(``YYYY-OOO``) msgid "Examples::" msgstr "例::" -#: ../../library/datetime.rst:574 msgid "" ">>> import datetime as dt\n" ">>> dt.date.fromisoformat('2019-12-04')\n" @@ -1056,24 +1120,35 @@ msgid "" ">>> dt.date.fromisoformat('2021-W01-1')\n" "datetime.date(2021, 1, 4)" msgstr "" +">>> import datetime as dt\n" +">>> dt.date.fromisoformat('2019-12-04')\n" +"datetime.date(2019, 12, 4)\n" +">>> dt.date.fromisoformat('20191204')\n" +"datetime.date(2019, 12, 4)\n" +">>> dt.date.fromisoformat('2021-W01-1')\n" +"datetime.date(2021, 1, 4)" #: ../../library/datetime.rst:583 msgid "Previously, this method only supported the format ``YYYY-MM-DD``." msgstr "" "以前はこのメソッドは ``YYYY-MM-DD`` フォーマットのみをサポートしていました。" -#: ../../library/datetime.rst:589 msgid "" "Return a :class:`date` corresponding to the ISO calendar date specified by " "*year*, *week* and *day*. This is the inverse of the function :meth:`date." "isocalendar`." msgstr "" +"*year*、*week*、*day* で指定した ISO 暦の日付に対応する :class:`date` を返し" +"ます。\n" +"これは :meth:`date.isocalendar` 関数の逆操作です。" -#: ../../library/datetime.rst:597 msgid "" "Return a :class:`.date` corresponding to *date_string*, parsed according to " "*format*. This is equivalent to::" msgstr "" +"*format* に従って *date_string* を解析し、対応する :class:`.date` を返しま" +"す。\n" +"次の式と等価です。 ::" #: ../../library/datetime.rst:600 msgid "date(*(time.strptime(date_string, format)[0:3]))" @@ -1090,7 +1165,6 @@ msgstr "" "`strftime-strptime-behavior` および :meth:`date.fromisoformat` も参照してくだ" "さい。" -#: ../../library/datetime.rst:609 ../../library/datetime.rst:1184 msgid "" "If *format* specifies a day of month (``%d``) without a year, :exc:" "`ValueError` is raised. This is to avoid a quadrennial leap year bug in " @@ -1099,8 +1173,16 @@ msgid "" "include a year in your *format*. If parsing *date_string* values that do " "not have a year, explicitly add a year that is a leap year before parsing:" msgstr "" +"*format* が年を指定せずに日 (``%d``) を指定している場合、:exc:`ValueError` を" +"送出します。\n" +"これは、月と日だけを解析しようとするコードで 4 年ごとに起きるうるう年のバグを" +"避けるためです。\n" +"書式に年がない場合に使用するデフォルトの年が、うるう年ではないことが原因で" +"す。\n" +"回避するには、*format* に常に年を含めてください。\n" +"年を持たない *date_string* の値を解析する場合は、解析する前にうるう年の年を明" +"示的に追加してください:" -#: ../../library/datetime.rst:617 msgid "" ">>> import datetime as dt\n" ">>> date_string = \"02/29\"\n" @@ -1109,6 +1191,12 @@ msgid "" ">>> when.strftime(\"%B %d\")\n" "'February 29'" msgstr "" +">>> import datetime as dt\n" +">>> date_string = \"02/29\"\n" +">>> when = dt.date.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # うるう" +"年のバグを回避する。\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" #: ../../library/datetime.rst:632 msgid "The earliest representable date, ``date(MINYEAR, 1, 1)``." @@ -1193,7 +1281,6 @@ msgstr "``date1 >= date2``" msgid "Order comparison. (5)" msgstr "順序の比較。(5)" -#: ../../library/datetime.rst:688 msgid "" "*date2* is moved forward in time if ``timedelta.days > 0``, or backward if " "``timedelta.days < 0``. Afterward ``date2 - date1 == timedelta.days``. " @@ -1205,7 +1292,7 @@ msgstr "" "0`` の場合は戻る方向に移動します。\n" "演算後は ``date2 - date1 == timedelta.days`` が成立します。\n" "``timedelta.seconds`` および ``timedelta.microseconds`` は無視されます。\n" -"``date2.year`` が :const:`MINYEAR` になってしまったり、 :const:`MAXYEAR` より" +"``date2.year`` が :const:`MINYEAR` より小さくなったり、 :const:`MAXYEAR` より" "大きくなってしまう場合には :exc:`OverflowError` が送出されます。" #: ../../library/datetime.rst:695 @@ -1235,18 +1322,22 @@ msgstr "" "日を表していても、:class:`!datetime` オブジェクトとは決して等価にはなりませ" "ん。" -#: ../../library/datetime.rst:709 msgid "" "*date1* is considered less than *date2* when *date1* precedes *date2* in " "time. In other words, ``date1 < date2`` if and only if ``date1.toordinal() < " "date2.toordinal()``." msgstr "" +"*date1* が時間的に *date2* より前にある場合、*date1* は *date2* より小さいと" +"みなされます。\n" +"言い換えると、``date1.toordinal() < date2.toordinal()`` の場合に限り ``date1 " +"< date2`` となります。" -#: ../../library/datetime.rst:713 msgid "" "Order comparison between a :class:`date` object that is not also a :class:`." "datetime` instance and a :class:`!datetime` object raises :exc:`TypeError`." msgstr "" +":class:`.datetime` のインスタンスではない :class:`date` オブジェクトと、:" +"class:`!datetime` オブジェクトとの順序比較は、:exc:`TypeError` を送出します。" #: ../../library/datetime.rst:717 ../../library/datetime.rst:1357 msgid "" @@ -1257,36 +1348,39 @@ msgid "" "in subclasses." msgstr "" -#: ../../library/datetime.rst:725 msgid "" "In Boolean contexts, all :class:`date` objects are considered to be true." msgstr "" -"ブール演算コンテキストでは、全ての :class:`.time` オブジェクトは真とみなされ" -"ます。" +"ブール値の文脈では、すべての :class:`date` オブジェクトは真とみなされます。" -#: ../../library/datetime.rst:731 msgid "" "Return a new :class:`date` object with the same values, but with specified " "parameters updated." msgstr "" +"指定したパラメータだけを更新し、それ以外は同じ値を持つ新しい :class:`date` オ" +"ブジェクトを返します。" #: ../../library/datetime.rst:734 ../../library/datetime.rst:2041 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/datetime.rst:736 msgid "" ">>> import datetime as dt\n" ">>> d = dt.date(2002, 12, 31)\n" ">>> d.replace(day=26)\n" "datetime.date(2002, 12, 26)" msgstr "" +">>> import datetime as dt\n" +">>> d = dt.date(2002, 12, 31)\n" +">>> d.replace(day=26)\n" +"datetime.date(2002, 12, 26)" -#: ../../library/datetime.rst:741 msgid "" "The generic function :func:`copy.replace` also supports :class:`date` " "objects." msgstr "" +"汎用関数 :func:`copy.replace` も :class:`date` オブジェクトをサポートしていま" +"す。" #: ../../library/datetime.rst:747 ../../library/datetime.rst:1482 msgid "" @@ -1303,10 +1397,10 @@ msgstr "時分秒が 0 で、 DST フラグが -1 です。" msgid "``d.timetuple()`` is equivalent to::" msgstr "``d.timetuple()`` は次の式と等価です::" -#: ../../library/datetime.rst:753 msgid "" "time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" msgstr "" +"time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))" #: ../../library/datetime.rst:755 msgid "" @@ -1380,7 +1474,6 @@ msgstr "" "例えば、2004 年は木曜日から始まるため、ISO 年の最初の週は 2003 年 12 月 29 " "日、月曜日から始まり、2004 年 1 月 4 日、日曜日に終わります ::" -#: ../../library/datetime.rst:795 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2003, 12, 29).isocalendar()\n" @@ -1388,6 +1481,11 @@ msgid "" ">>> dt.date(2004, 1, 4).isocalendar()\n" "datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" msgstr "" +">>> import datetime as dt\n" +">>> dt.date(2003, 12, 29).isocalendar()\n" +"datetime.IsoCalendarDate(year=2004, week=1, weekday=1)\n" +">>> dt.date(2004, 1, 4).isocalendar()\n" +"datetime.IsoCalendarDate(year=2004, week=1, weekday=7)" #: ../../library/datetime.rst:801 msgid "Result changed from a tuple to a :term:`named tuple`." @@ -1398,37 +1496,40 @@ msgid "" "Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``::" msgstr "日付を ISO 8601 書式の ``YYYY-MM-DD`` で表した文字列を返します::" -#: ../../library/datetime.rst:809 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2002, 12, 4).isoformat()\n" "'2002-12-04'" msgstr "" +">>> import datetime as dt\n" +">>> dt.date(2002, 12, 4).isoformat()\n" +"'2002-12-04'" #: ../../library/datetime.rst:816 msgid "For a date ``d``, ``str(d)`` is equivalent to ``d.isoformat()``." msgstr "" -":class:`date` オブジェクト ``d`` において、``str(d)`` は ``d.isoformat()`` と" -"等価です。" +"``date`` オブジェクト ``d`` において、``str(d)`` は ``d.isoformat()`` と等価" +"です。" #: ../../library/datetime.rst:821 msgid "Return a string representing the date::" msgstr "日付を表す文字列を返します::" -#: ../../library/datetime.rst:823 msgid "" ">>> import datetime as dt\n" ">>> dt.date(2002, 12, 4).ctime()\n" "'Wed Dec 4 00:00:00 2002'" msgstr "" +">>> import datetime as dt\n" +">>> dt.date(2002, 12, 4).ctime()\n" +"'Wed Dec 4 00:00:00 2002'" #: ../../library/datetime.rst:827 ../../library/datetime.rst:1675 msgid "``d.ctime()`` is equivalent to::" msgstr "``d.ctime()`` は次の式と等価です::" -#: ../../library/datetime.rst:829 ../../library/datetime.rst:1677 msgid "time.ctime(time.mktime(d.timetuple()))" -msgstr "" +msgstr "time.ctime(time.mktime(d.timetuple()))" #: ../../library/datetime.rst:831 msgid "" @@ -1466,15 +1567,13 @@ msgstr "" ":ref:`strftime-strptime-behavior` および :meth:`date.isoformat` も参照してく" "ださい。" -#: ../../library/datetime.rst:852 msgid "Examples of usage: :class:`!date`" -msgstr "" +msgstr "使用例: :class:`!date`" #: ../../library/datetime.rst:854 msgid "Example of counting days to an event::" msgstr "イベントまでの日数を数える例を示します::" -#: ../../library/datetime.rst:856 msgid "" ">>> import time\n" ">>> import datetime as dt\n" @@ -1493,12 +1592,27 @@ msgid "" ">>> time_to_birthday.days\n" "202" msgstr "" +">>> import time\n" +">>> import datetime as dt\n" +">>> today = dt.date.today()\n" +">>> today\n" +"datetime.date(2007, 12, 5)\n" +">>> today == dt.date.fromtimestamp(time.time())\n" +"True\n" +">>> my_birthday = dt.date(today.year, 6, 24)\n" +">>> if my_birthday < today:\n" +"... my_birthday = my_birthday.replace(year=today.year + 1)\n" +"...\n" +">>> my_birthday\n" +"datetime.date(2008, 6, 24)\n" +">>> time_to_birthday = abs(my_birthday - today)\n" +">>> time_to_birthday.days\n" +"202" #: ../../library/datetime.rst:873 msgid "More examples of working with :class:`date`:" msgstr "さらなる :class:`date` を使う例:" -#: ../../library/datetime.rst:875 msgid "" ">>> import datetime as dt\n" ">>> d = dt.date.fromordinal(730920) # 730920th day after 1. 1. 0001\n" @@ -1541,10 +1655,51 @@ msgid "" ">>> d.replace(year=2005)\n" "datetime.date(2005, 3, 11)" msgstr "" +">>> import datetime as dt\n" +">>> d = dt.date.fromordinal(730920) # 0001 年 1 月 1 日から数えて 730920 日" +"目\n" +">>> d\n" +"datetime.date(2002, 3, 11)\n" +"\n" +">>> # 文字列出力の書式に関するメソッド\n" +">>> d.isoformat()\n" +"'2002-03-11'\n" +">>> d.strftime(\"%d/%m/%y\")\n" +"'11/03/02'\n" +">>> d.strftime(\"%A %d. %B %Y\")\n" +"'Monday 11. March 2002'\n" +">>> d.ctime()\n" +"'Mon Mar 11 00:00:00 2002'\n" +">>> 'The {1} is {0:%d}, the {2} is {0:%B}.'.format(d, \"day\", \"month\")\n" +"'The day is 11, the month is March.'\n" +"\n" +">>> # さまざまな暦の「成分」を取り出すメソッド\n" +">>> t = d.timetuple()\n" +">>> for i in t:\n" +"... print(i)\n" +"2002 # 年\n" +"3 # 月\n" +"11 # 日\n" +"0\n" +"0\n" +"0\n" +"0 # 曜日 (0 = 月曜日)\n" +"70 # 年内の 70 日目\n" +"-1\n" +">>> ic = d.isocalendar()\n" +">>> for i in ic:\n" +"... print(i)\n" +"2002 # ISO の年\n" +"11 # ISO の週番号\n" +"1 # ISO の曜日番号 (1 = 月曜日)\n" +"\n" +">>> # date オブジェクトは不変であり、すべての操作は新しいオブジェクトを生成す" +"る\n" +">>> d.replace(year=2005)\n" +"datetime.date(2005, 3, 11)" -#: ../../library/datetime.rst:922 msgid ":class:`!datetime` objects" -msgstr "" +msgstr ":class:`!datetime` オブジェクト" #: ../../library/datetime.rst:924 msgid "" @@ -1554,13 +1709,16 @@ msgstr "" ":class:`.datetime` オブジェクトは :class:`date` オブジェクトおよび :class:`." "time` オブジェクトの全ての情報が入っている単一のオブジェクトです。" -#: ../../library/datetime.rst:927 msgid "" "Like a :class:`date` object, :class:`.datetime` assumes the current " "Gregorian calendar extended in both directions; like a :class:`.time` " "object, :class:`!datetime` assumes there are exactly 3600\\*24 seconds in " "every day." msgstr "" +":class:`date` オブジェクトと同様に、:class:`.datetime` は現在のグレゴリオ暦を" +"過去と未来の両方向に拡張した暦を仮定します。\n" +"また、:class:`.time` オブジェクトと同様に、:class:`!datetime` は毎日が厳密に " +"3600\\*24 秒であると仮定します。" #: ../../library/datetime.rst:931 msgid "Constructor:" @@ -1622,9 +1780,8 @@ msgstr "" msgid "Equivalent to::" msgstr "次と等価です::" -#: ../../library/datetime.rst:962 msgid "datetime.fromtimestamp(time.time())" -msgstr "" +msgstr "datetime.fromtimestamp(time.time())" #: ../../library/datetime.rst:964 msgid "See also :meth:`now`, :meth:`fromtimestamp`." @@ -1641,18 +1798,18 @@ msgstr "" msgid "Return the current local date and time." msgstr "現在のローカルな日時を返します。" -#: ../../library/datetime.rst:974 msgid "" "If optional argument *tz* is ``None`` or not specified, this is like :meth:" "`today`, but, if possible, supplies more precision than can be gotten from " "going through a :func:`time.time` timestamp (for example, this may be " "possible on platforms supplying the C :c:func:`gettimeofday` function)." msgstr "" -"オプションの引数 *tz* が ``None`` であるか指定されていない場合、このメソッド" -"は :meth:`today` と同様ですが、可能ならば :func:`time.time` タイムスタンプを" -"通じて得ることができる、より高い精度で時刻を提供します (例えば、プラット" -"フォームが C 関数 :c:func:`gettimeofday` をサポートする場合には可能なことが" -"あります)。" +"省略可能な引数 *tz* が ``None`` または未指定の場合、このメソッドは :meth:" +"`today` と同様に動作します。\n" +"ただし可能であれば、:func:`time.time` のタイムスタンプ経由で得られる精度より" +"も高い精度で時刻を返します\n" +"(例えば、C 関数 :c:func:`gettimeofday` を提供するプラットフォームでは可能な場" +"合があります)。" #: ../../library/datetime.rst:980 msgid "" @@ -1668,11 +1825,12 @@ msgid "This function is preferred over :meth:`today` and :meth:`utcnow`." msgstr "" ":meth:`today` および :meth:`utcnow` よりもこの関数を使う方が好ましいです。" -#: ../../library/datetime.rst:987 msgid "" "Subsequent calls to :meth:`!datetime.now` may return the same instant " "depending on the precision of the underlying clock." msgstr "" +"基盤となる時計の精度によっては、:meth:`!datetime.now` を続けて呼び出しても同" +"じ時点を返すことがあります。" #: ../../library/datetime.rst:993 msgid "Return the current UTC date and time, with :attr:`.tzinfo` ``None``." @@ -1704,9 +1862,9 @@ msgstr "" "そのため、 UTC での現在の時刻を表すオブジェクトの作成では ``datetime." "now(timezone.utc)`` を呼び出す方法が推奨されます。" -#: ../../library/datetime.rst:1008 msgid "Use :meth:`datetime.now` with :const:`UTC` instead." msgstr "" +"代わりに :const:`UTC` を指定して :meth:`datetime.now` を使用してください。" #: ../../library/datetime.rst:1013 msgid "" @@ -1765,10 +1923,10 @@ msgstr "" "くは :c:func:`gmtime` の呼び出し失敗で :exc:`ValueError` ではなく :exc:" "`OSError` を送出するようになりました。" -#: ../../library/datetime.rst:1039 msgid ":meth:`fromtimestamp` may return instances with :attr:`.fold` set to 1." msgstr "" -":meth:`fromtimestamp` は :attr:`.fold` を1にしてインスタンスを返します。" +":meth:`fromtimestamp` は :attr:`.fold` が 1 に設定されたインスタンスを返すこ" +"とがあります。" #: ../../library/datetime.rst:1048 msgid "" @@ -1778,16 +1936,15 @@ msgstr "" "POSIX タイムスタンプに対応する、:attr:`tzinfo` が ``None`` の UTC での :" "class:`.datetime` を返します。(返されるオブジェクトは naive です。)" -#: ../../library/datetime.rst:1051 msgid "" "This may raise :exc:`OverflowError`, if the timestamp is out of the range of " "values supported by the platform C :c:func:`gmtime` function, and :exc:" "`OSError` on :c:func:`gmtime` failure. It's common for this to be restricted " "to years in 1970 through 2038." msgstr "" -"タイムスタンプがプラットフォームにおける C 関数 :c:func:`localtime` でサポー" -"トされている範囲を超えている場合には :exc:`OverflowError` を、:c:func:" -"`gmtime` が失敗した場合には :exc:`OSError` を送出します。\n" +"タイムスタンプがプラットフォームにおける C 関数 :c:func:`gmtime` でサポートさ" +"れている範囲を超えている場合には :exc:`OverflowError` を、:c:func:`gmtime` が" +"失敗した場合には :exc:`OSError` を送出します。\n" "これはたいてい 1970 年から 2038 年に制限されています。" #: ../../library/datetime.rst:1056 @@ -1796,9 +1953,8 @@ msgstr "" "aware な :class:`.datetime` オブジェクトを得るには :meth:`fromtimestamp` を呼" "んでください::" -#: ../../library/datetime.rst:1058 msgid "datetime.fromtimestamp(timestamp, timezone.utc)" -msgstr "" +msgstr "datetime.fromtimestamp(timestamp, timezone.utc)" #: ../../library/datetime.rst:1060 msgid "" @@ -1806,18 +1962,17 @@ msgid "" "expression::" msgstr "POSIX 互換プラットフォームでは、これは以下の表現と等価です::" -#: ../../library/datetime.rst:1063 msgid "" "datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" msgstr "" +"datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)" -#: ../../library/datetime.rst:1065 msgid "" "except the latter formula always supports the full years range: between :" "const:`MINYEAR` and :const:`MAXYEAR` inclusive." msgstr "" -"後者を除き、式は常に年の全範囲 (:const:`MINYEAR` から :const:`MAXYEAR` を含み" -"ます) をサポートします。" +"ただし、後者の式は常に年の全範囲 (:const:`MINYEAR` から :const:`MAXYEAR` ま" +"で、両端を含む) をサポートするという違いがあります。" #: ../../library/datetime.rst:1070 msgid "" @@ -1846,9 +2001,10 @@ msgstr "" "るようになりました。 :c:func:`gmtime` の呼び出し失敗で :exc:`ValueError` では" "なく :exc:`OSError` を送出するようになりました。" -#: ../../library/datetime.rst:1087 msgid "Use :meth:`datetime.fromtimestamp` with :const:`UTC` instead." msgstr "" +"代わりに :const:`UTC` を指定して :meth:`datetime.fromtimestamp` を使用してく" +"ださい。" #: ../../library/datetime.rst:1092 msgid "" @@ -1865,7 +2021,6 @@ msgstr "" "返されるオブジェクトの時間、分、秒、およびマイクロ秒はすべて 0 で、 :attr:" "`tzinfo` は ``None`` となっています。" -#: ../../library/datetime.rst:1100 msgid "" "Return a new :class:`.datetime` object whose date components are equal to " "the given :class:`date` object's, and whose time components are equal to the " @@ -1875,12 +2030,21 @@ msgid "" "*date* argument is a :class:`!datetime` object, its time components and :" "attr:`.tzinfo` attributes are ignored." msgstr "" +"日付の各成分が指定した :class:`date` オブジェクトと等しく、時刻の各成分が指定" +"した :class:`.time` オブジェクトと等しい、新しい :class:`.datetime` オブジェ" +"クトを返します。\n" +"*tzinfo* 引数が指定されていれば、その値を結果の :attr:`.tzinfo` 属性に設定し" +"ます。\n" +"それ以外の場合、*time* 引数の :attr:`~.time.tzinfo` 属性を使用します。\n" +"*date* 引数が :class:`!datetime` オブジェクトの場合、その時刻の各成分と :" +"attr:`.tzinfo` 属性は無視されます。" -#: ../../library/datetime.rst:1108 msgid "" "For any :class:`.datetime` object ``d``, ``d == datetime.combine(d.date(), d." "time(), d.tzinfo)``." msgstr "" +"任意の :class:`.datetime` オブジェクト ``d`` について、``d == datetime." +"combine(d.date(), d.time(), d.tzinfo)`` となります。" #: ../../library/datetime.rst:1111 msgid "Added the *tzinfo* argument." @@ -1906,7 +2070,6 @@ msgstr "``T`` セパレーターを他の1文字のユニコードに置き換 msgid "Fractional hours and minutes are not supported." msgstr "少数の時と分はサポートされていません。" -#: ../../library/datetime.rst:1131 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.fromisoformat('2011-11-04')\n" @@ -1930,20 +2093,45 @@ msgid "" "datetime.datetime(2011, 11, 4, 0, 5, 23,\n" " tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" msgstr "" +">>> import datetime as dt\n" +">>> dt.datetime.fromisoformat('2011-11-04')\n" +"datetime.datetime(2011, 11, 4, 0, 0)\n" +">>> dt.datetime.fromisoformat('20111104')\n" +"datetime.datetime(2011, 11, 4, 0, 0)\n" +">>> dt.datetime.fromisoformat('2011-11-04T00:05:23')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23)\n" +">>> dt.datetime.fromisoformat('2011-11-04T00:05:23Z')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, tzinfo=datetime.timezone.utc)\n" +">>> dt.datetime.fromisoformat('20111104T000523')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23)\n" +">>> dt.datetime.fromisoformat('2011-W01-2T00:05:23.283')\n" +"datetime.datetime(2011, 1, 4, 0, 5, 23, 283000)\n" +">>> dt.datetime.fromisoformat('2011-11-04 00:05:23.283')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, 283000)\n" +">>> dt.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone." +"utc)\n" +">>> dt.datetime.fromisoformat('2011-11-04T00:05:23+04:00')\n" +"datetime.datetime(2011, 11, 4, 0, 5, 23,\n" +" tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))" -#: ../../library/datetime.rst:1153 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`date.isoformat` or :meth:`datetime.isoformat`." msgstr "" +"以前は、このメソッドは :meth:`date.isoformat` または :meth:`datetime." +"isoformat` が出力できる形式だけをサポートしていました。" -#: ../../library/datetime.rst:1160 msgid "" "Return a :class:`.datetime` corresponding to the ISO calendar date specified " "by *year*, *week* and *day*. The non-date components of the datetime are " "populated with their normal default values. This is the inverse of the " "function :meth:`datetime.isocalendar`." msgstr "" +"*year*、*week*、*day* で指定した ISO 暦の日付に対応する :class:`.datetime` を" +"返します。\n" +"日時の日付以外の成分には、通常のデフォルト値が設定されます。\n" +"これは :meth:`datetime.isocalendar` 関数の逆操作です。" #: ../../library/datetime.rst:1170 msgid "" @@ -1960,9 +2148,8 @@ msgid "" msgstr "" "*format* がマイクロ秒やタイムゾーン情報を含まない場合は、以下と等価です::" -#: ../../library/datetime.rst:1175 ../../library/datetime.rst:2776 msgid "datetime(*(time.strptime(date_string, format)[0:6]))" -msgstr "" +msgstr "datetime(*(time.strptime(date_string, format)[0:6]))" #: ../../library/datetime.rst:1177 msgid "" @@ -1976,7 +2163,6 @@ msgstr "" "`strftime-strptime-behavior` および :meth:`datetime.fromisoformat` も参照して" "ください。" -#: ../../library/datetime.rst:1192 msgid "" ">>> import datetime as dt\n" ">>> date_string = \"02/29\"\n" @@ -1985,6 +2171,12 @@ msgid "" ">>> when.strftime(\"%B %d\")\n" "'February 29'" msgstr "" +">>> import datetime as dt\n" +">>> date_string = \"02/29\"\n" +">>> when = dt.datetime.strptime(f\"{date_string};1984\", \"%m/%d;%Y\") # う" +"るう年のバグを回避する。\n" +">>> when.strftime(\"%B %d\")\n" +"'February 29'" #: ../../library/datetime.rst:1205 msgid "" @@ -2125,22 +2317,26 @@ msgstr "" "ちなみに、結果は入力の datetime と同じ :attr:`~.datetime.tzinfo` 属性を持ち、" "入力が aware だとしてもタイムゾーン修正は全く行われません。" -#: ../../library/datetime.rst:1310 msgid "" "Subtraction of a :class:`.datetime` from a :class:`!datetime` is defined " "only if both operands are naive, or if both are aware. If one is aware and " "the other is naive, :exc:`TypeError` is raised." msgstr "" +":class:`!datetime` から :class:`.datetime` を引く減算は、両方のオペランドが " +"naive であるか、両方が aware である場合にのみ定義されます。\n" +"一方が aware で他方が naive の場合は、:exc:`TypeError` を送出します。" -#: ../../library/datetime.rst:1314 msgid "" "If both are naive, or both are aware and have the same :attr:`~.datetime." "tzinfo` attribute, the :attr:`~.datetime.tzinfo` attributes are ignored, and " "the result is a :class:`timedelta` object ``t`` such that ``datetime2 + t == " "datetime1``. No time zone adjustments are done in this case." msgstr "" +"両方が naive の場合、または両方が aware で同じ :attr:`~.datetime.tzinfo` 属性" +"を持つ場合、:attr:`~.datetime.tzinfo` 属性は無視され、結果は ``datetime2 + t " +"== datetime1`` を満たす :class:`timedelta` オブジェクト ``t`` となります。\n" +"この場合、タイムゾーンの調整は行われません。" -#: ../../library/datetime.rst:1319 msgid "" "If both are aware and have different :attr:`~.datetime.tzinfo` attributes, " "``a-b`` acts as if ``a`` and ``b`` were first converted to naive UTC " @@ -2148,6 +2344,11 @@ msgid "" "replace(tzinfo=None) - b.utcoffset())`` except that the implementation never " "overflows." msgstr "" +"両方が aware で異なる :attr:`~.datetime.tzinfo` 属性を持つ場合、``a-b`` は、" +"先に ``a`` と ``b`` を naive な UTC の日時に変換したかのように動作します。\n" +"結果は ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None) " +"- b.utcoffset())`` となりますが、実装ではオーバーフローが起きない点が異なりま" +"す。" #: ../../library/datetime.rst:1325 msgid "" @@ -2157,11 +2358,11 @@ msgstr "" ":class:`.datetime` オブジェクトはタイムゾーンを考慮して同じ日付と時刻を表す場" "合、等しいです。" -#: ../../library/datetime.rst:1328 msgid "Naive and aware :class:`.datetime` objects are never equal." msgstr "" +"naive な :class:`.datetime` オブジェクトと aware なものが等しくなることはあり" +"ません。" -#: ../../library/datetime.rst:1330 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -2171,6 +2372,13 @@ msgid "" "implementation never overflows. :class:`.datetime` instances in a repeated " "interval are never equal to :class:`!datetime` instances in other time zone." msgstr "" +"比較対象が両方とも aware で同じ :attr:`!tzinfo` 属性を持つ場合、:attr:`!" +"tzinfo` と :attr:`~.datetime.fold` 属性を無視して、元の日時を比較します。\n" +"比較対象が両方とも aware で異なる :attr:`~.datetime.tzinfo` 属性を持つ場合、" +"先に UTC の日時に変換したかのように比較しますが、実装ではオーバーフローが起き" +"ない点が異なります。\n" +"繰り返される時間帯にある :class:`.datetime` インスタンスが、別のタイムゾーン" +"の :class:`!datetime` インスタンスと等しくなることはありません。" #: ../../library/datetime.rst:1340 msgid "" @@ -2180,13 +2388,13 @@ msgstr "" "タイムゾーンを考慮して、*datetime1* が時刻として *datetime2* よりも前を表す場" "合に、*datetime1* は *datetime2* よりも小さいと見なされます。" -#: ../../library/datetime.rst:1343 msgid "" "Order comparison between naive and aware :class:`.datetime` objects raises :" "exc:`TypeError`." msgstr "" +"naive な :class:`.datetime` オブジェクトと aware なものの順序比較は、:exc:" +"`TypeError` を送出します。" -#: ../../library/datetime.rst:1346 msgid "" "If both comparands are aware, and have the same :attr:`!tzinfo` attribute, " "the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and " @@ -2195,14 +2403,19 @@ msgid "" "comparands were first converted to UTC datetimes except that the " "implementation never overflows." msgstr "" +"比較対象が両方とも aware で同じ :attr:`!tzinfo` 属性を持つ場合、:attr:`!" +"tzinfo` と :attr:`~.datetime.fold` 属性を無視して、元の日時を比較します。\n" +"比較対象が両方とも aware で異なる :attr:`~.datetime.tzinfo` 属性を持つ場合、" +"先に UTC の日時に変換したかのように比較しますが、実装ではオーバーフローが起き" +"ない点が異なります。" #: ../../library/datetime.rst:1353 msgid "" "Equality comparisons between aware and naive :class:`.datetime` instances " "don't raise :exc:`TypeError`." msgstr "" -"aware な :class:`datetime` インスタンスと naive な :class:`datetime` インスタ" -"ンスの等価比較では :exc:`TypeError` は送出されません。" +"aware な :class:`datetime` インスタンスと naive な ``datetime`` インスタンス" +"の等価比較では :exc:`TypeError` は送出されません。" #: ../../library/datetime.rst:1370 msgid "Return :class:`date` object with same year, month and day." @@ -2229,13 +2442,16 @@ msgstr "" "同じhour、minute、second、microsecond、fold および tzinfo 属性を持つ :class:" "`.time` オブジェクトを返します。 :meth:`time` メソッドも参照してください。" -#: ../../library/datetime.rst:1395 msgid "" "Return a new :class:`datetime` object with the same attributes, but with " "specified parameters updated. Note that ``tzinfo=None`` can be specified to " "create a naive datetime from an aware datetime with no conversion of date " "and time data." msgstr "" +"指定したパラメータだけを更新し、それ以外は同じ属性を持つ新しい :class:" +"`datetime` オブジェクトを返します。\n" +"``tzinfo=None`` を指定すると、日付と時刻のデータを変換せずに、aware な日時か" +"ら naive な日時を作成できます。" #: ../../library/datetime.rst:1400 msgid "" @@ -2256,7 +2472,6 @@ msgstr "" "日付および時刻データを調整して、返り値が *self* と同じ UTC 時刻を持ち、 *tz* " "におけるローカルな時刻を表すようにします。" -#: ../../library/datetime.rst:1413 msgid "" "If provided, *tz* must be an instance of a :class:`tzinfo` subclass, and " "its :meth:`utcoffset` and :meth:`dst` methods must not return ``None``. If " @@ -2264,8 +2479,9 @@ msgid "" msgstr "" "もし与えられた場合、 *tz* は :class:`tzinfo` のサブクラスのインスタンスでなけ" "ればならず、 インスタンスの :meth:`utcoffset` および :meth:`dst` メソッドは " -"``None`` を返してはなりません。もし *self* が naive ならば、おそらくシステム" -"のタイムゾーンで時間を表現します。" +"``None`` を返してはなりません。\n" +"*self* が naive の場合は、システムのタイムゾーンの時刻を表すものとして扱われ" +"ます。" #: ../../library/datetime.rst:1417 msgid "" @@ -2302,12 +2518,11 @@ msgid "" "object from an aware datetime *dt* without conversion of date and time data, " "use ``dt.replace(tzinfo=None)``." msgstr "" -"単に :class:`timezone` オブジェクト *tz* を :class:`datetime` オブジェクト " -"*dt* に追加したいだけで、日付や時刻データへの調整を行わないのなら、``dt." -"replace(tzinfo=tz)`` を使ってください。単に aware な :class:`datetime` オブ" -"ジェクト *dt* から :class:`!timezone` オブジェクトを除去したいだけで、日付や" -"時刻データの変換を行わないのなら、``dt.replace(tzinfo=None)`` を使ってくださ" -"い。" +"単に :class:`timezone` オブジェクト *tz* を ``datetime`` オブジェクト *dt* に" +"追加したいだけで、日付や時刻データへの調整を行わないのなら、``dt." +"replace(tzinfo=tz)`` を使ってください。単に aware な ``datetime`` オブジェク" +"ト *dt* から :class:`!timezone` オブジェクトを除去したいだけで、日付や時刻" +"データの変換を行わないのなら、``dt.replace(tzinfo=None)`` を使ってください。" #: ../../library/datetime.rst:1433 msgid "" @@ -2319,7 +2534,6 @@ msgstr "" "上書きして, :meth:`astimezone` が返す結果に影響を及ぼすことができます。エラー" "の場合を無視すると、 :meth:`astimezone` は以下のように動作します::" -#: ../../library/datetime.rst:1437 msgid "" "def astimezone(self, tz):\n" " if self.tzinfo is tz:\n" @@ -2329,6 +2543,13 @@ msgid "" " # Convert from UTC to tz's local time.\n" " return tz.fromutc(utc)" msgstr "" +"def astimezone(self, tz):\n" +" if self.tzinfo is tz:\n" +" return self\n" +" # self を UTC に変換し、新しい timezone オブジェクトを設定する。\n" +" utc = (self - self.utcoffset()).replace(tzinfo=tz)\n" +" # UTC から tz のローカル時刻に変換する。\n" +" return tz.fromutc(utc)" #: ../../library/datetime.rst:1445 msgid "*tz* now can be omitted." @@ -2343,7 +2564,6 @@ msgstr "" "呼び出せるようになりました。これは、システムのローカルな時間を表現していると" "想定されます。" -#: ../../library/datetime.rst:1455 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "utcoffset(self)``, and raises an exception if the latter doesn't return " @@ -2351,7 +2571,7 @@ msgid "" msgstr "" ":attr:`.tzinfo` が ``None`` の場合、 ``None`` を返し、そうでない場合には " "``self.tzinfo.utcoffset(self)`` を返します。\n" -"後者の式が ``None`` あるいは 1 日以下の大きさを持つ :class:`timedelta` オブ" +"後者の式が ``None`` あるいは 1 日未満の大きさを持つ :class:`timedelta` オブ" "ジェクトのいずれかを返さない場合には例外を送出します。" #: ../../library/datetime.rst:1459 ../../library/datetime.rst:2081 @@ -2387,12 +2607,14 @@ msgstr "" "後者の式が ``None`` か文字列オブジェクトのいずれかを返さない場合には例外を送" "出します。" -#: ../../library/datetime.rst:1486 msgid "" "time.struct_time((d.year, d.month, d.day,\n" " d.hour, d.minute, d.second,\n" " d.weekday(), yday, dst))" msgstr "" +"time.struct_time((d.year, d.month, d.day,\n" +" d.hour, d.minute, d.second,\n" +" d.weekday(), yday, dst))" #: ../../library/datetime.rst:1490 msgid "" @@ -2412,15 +2634,17 @@ msgstr "" "場合、 :meth:`dst` がゼロでない値を返すと :attr:`!tm_isdst` は1となります; そ" "れ以外の場合には :attr:`!tm_isdst` は0に設定されます。" -#: ../../library/datetime.rst:1501 msgid "" "If :class:`.datetime` instance ``d`` is naive, this is the same as ``d." "timetuple()`` except that :attr:`~.time.struct_time.tm_isdst` is forced to 0 " "regardless of what ``d.dst()`` returns. DST is never in effect for a UTC " "time." msgstr "" +":class:`.datetime` インスタンス ``d`` が naive の場合、``d.dst()`` の返り値に" +"関係なく :attr:`~.time.struct_time.tm_isdst` が強制的に 0 になる点を除き、" +"``d.timetuple()`` と同じです。\n" +"UTC 時刻に DST が適用されることはありません。" -#: ../../library/datetime.rst:1505 msgid "" "If ``d`` is aware, ``d`` is normalized to UTC time, by subtracting ``d." "utcoffset()``, and a :class:`time.struct_time` for the normalized time is " @@ -2428,8 +2652,12 @@ msgid "" "`OverflowError` may be raised if ``d.year`` was ``MINYEAR`` or ``MAXYEAR`` " "and UTC adjustment spills over a year boundary." msgstr "" +"``d`` が aware の場合、``d.utcoffset()`` を引いて ``d`` を UTC 時刻に正規化" +"し、その時刻の :class:`time.struct_time` を返します。\n" +":attr:`!tm_isdst` は強制的に 0 になります。\n" +"``d.year`` が ``MINYEAR`` または ``MAXYEAR`` で、UTC への調整が年の境界を越え" +"る場合、:exc:`OverflowError` を送出することがあります。" -#: ../../library/datetime.rst:1514 msgid "" "Because naive ``datetime`` objects are treated by many ``datetime`` methods " "as local times, it is preferred to use aware datetimes to represent times in " @@ -2440,11 +2668,12 @@ msgid "" msgstr "" "naive な ``datetime`` オブジェクトは多くの ``datetime`` メソッドでローカルな" "時間として扱われるため、 aware な datetime を使って UTC の時刻を表すのが好ま" -"しいです。結果として、 :meth:`datetime.utctimetuple` は誤解を招きやすい返り値" -"を返すかもしれません。\n" -"UTC を表す naive な ``datetime`` があった場合、 :meth:`.datetime.timetuple` " -"が使えるところでは ``datetime.replace(tzinfo=timezone.utc)`` で aware にしま" -"す。" +"しいです。\n" +"結果として、 :meth:`datetime.utctimetuple` は誤解を招きやすい返り値を返すかも" +"しれません。\n" +"UTC を表す naive な ``datetime`` があった場合、 ``datetime." +"replace(tzinfo=timezone.utc)`` で aware にしてから :meth:`.datetime." +"timetuple` を使えます。" #: ../../library/datetime.rst:1524 msgid "" @@ -2454,16 +2683,14 @@ msgstr "" "先発グレゴリオ暦における日付序数を返します。``self.date().toordinal()`` と同" "じです。" -#: ../../library/datetime.rst:1530 msgid "" "Return POSIX timestamp corresponding to the :class:`.datetime` instance. The " "return value is a :class:`float` similar to that returned by :func:`time." "time`." msgstr "" ":class:`.datetime` インスタンスに対応する POSIX タイムスタンプを返します。\n" -"返り値は :func:`time.time` で返される値に近い :class:`float` です。" +":func:`time.time` の返り値と同様に、返り値は :class:`float` です。" -#: ../../library/datetime.rst:1534 msgid "" "Naive :class:`.datetime` instances are assumed to represent local time and " "this method relies on platform C functions to perform the conversion. Since :" @@ -2471,6 +2698,11 @@ msgid "" "functions on many platforms, this method may raise :exc:`OverflowError` or :" "exc:`OSError` for times far in the past or far in the future." msgstr "" +"naive な :class:`.datetime` インスタンスはローカル時刻を表すものとみなされ、" +"このメソッドはプラットフォームの C 関数を使用して変換を行います。\n" +"多くのプラットフォームでは、:class:`!datetime` はプラットフォームの C 関数よ" +"り広い範囲の値をサポートするため、遠い過去や未来の時刻に対して、このメソッド" +"は :exc:`OverflowError` または :exc:`OSError` を送出することがあります。" #: ../../library/datetime.rst:1541 msgid "" @@ -2479,9 +2711,8 @@ msgstr "" "aware な :class:`.datetime` インスタンスに対しては以下のように返り値が計算さ" "れます::" -#: ../../library/datetime.rst:1544 msgid "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" -msgstr "" +msgstr "(dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()" #: ../../library/datetime.rst:1548 msgid "" @@ -2496,17 +2727,15 @@ msgstr "" "れていなかった場合、 ``tzinfo=timezone.utc`` を引数に与えることで POSIX タイ" "ムスタンプを取得できます::" -#: ../../library/datetime.rst:1554 msgid "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" -msgstr "" +msgstr "timestamp = dt.replace(tzinfo=timezone.utc).timestamp()" #: ../../library/datetime.rst:1556 msgid "or by calculating the timestamp directly::" msgstr "もしくは直接タイムスタンプを計算することもできます::" -#: ../../library/datetime.rst:1558 msgid "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" -msgstr "" +msgstr "timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)" #: ../../library/datetime.rst:1562 msgid "" @@ -2516,11 +2745,12 @@ msgstr "" " :meth:`timestamp` メソッドは :attr:`.fold` 属性を繰り返し時間での曖昧さ回避" "に使用します。" -#: ../../library/datetime.rst:1566 msgid "" "This method no longer relies on the platform C :c:func:`mktime` function to " "perform conversions." msgstr "" +"このメソッドは、変換にプラットフォームの C 関数 :c:func:`mktime` を使用しなく" +"なりました。" #: ../../library/datetime.rst:1573 msgid "" @@ -2582,7 +2812,6 @@ msgid "" msgstr "" ":attr:`microsecond` が 0 の場合は ``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]``" -#: ../../library/datetime.rst:1606 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" @@ -2590,6 +2819,11 @@ msgid "" ">>> dt.datetime(2019, 5, 18, 15, 17, tzinfo=dt.timezone.utc).isoformat()\n" "'2019-05-18T15:17:00+00:00'" msgstr "" +">>> import datetime as dt\n" +">>> dt.datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()\n" +"'2019-05-18T15:17:08.132263'\n" +">>> dt.datetime(2019, 5, 18, 15, 17, tzinfo=dt.timezone.utc).isoformat()\n" +"'2019-05-18T15:17:00+00:00'" #: ../../library/datetime.rst:1612 msgid "" @@ -2599,7 +2833,6 @@ msgstr "" "オプションの引数 *sep* (デフォルトでは ``'T'`` です) は 1 文字のセパレータ" "で、結果の文字列の日付と時刻の間に置かれます。例えば::" -#: ../../library/datetime.rst:1615 msgid "" ">>> import datetime as dt\n" ">>> class TZ(dt.tzinfo):\n" @@ -2612,6 +2845,16 @@ msgid "" ">>> dt.datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" "'2009-11-27T00:00:00.000100-06:39'" msgstr "" +">>> import datetime as dt\n" +">>> class TZ(dt.tzinfo):\n" +"... \"\"\"任意の固定オフセット -06:39 を持つタイムゾーン。\"\"\"\n" +"... def utcoffset(self, when):\n" +"... return dt.timedelta(hours=-6, minutes=-39)\n" +"...\n" +">>> dt.datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')\n" +"'2002-12-25 00:00:00-06:39'\n" +">>> dt.datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()\n" +"'2009-11-27T00:00:00.000100-06:39'" #: ../../library/datetime.rst:1626 ../../library/datetime.rst:2021 msgid "" @@ -2649,19 +2892,17 @@ msgstr "" "``'seconds'``: :attr:`hour` 、 :attr:`minute` 、 :attr:`second` を ``HH:MM:" "SS`` の書式で含めます。" -#: ../../library/datetime.rst:1636 ../../library/datetime.rst:2031 msgid "" "``'milliseconds'``: Include full time, but truncate fractional second part " "to milliseconds. ``HH:MM:SS.sss`` format." msgstr "" -"``'milliseconds'``: 全ての時刻を含みますが、小数第二位をミリ秒に切り捨てま" -"す。\n" -"``HH:MM:SS.sss`` の書式で表現します。" +"``'milliseconds'``: 時刻全体を含めますが、秒の小数部分はミリ秒単位で切り捨て" +"ます。\n" +"``HH:MM:SS.sss`` 形式になります。" -#: ../../library/datetime.rst:1638 ../../library/datetime.rst:2033 msgid "``'microseconds'``: Include full time in ``HH:MM:SS.ffffff`` format." msgstr "" -"``'microseconds'``: 全ての時刻を ``HH:MM:SS.mmmmmm`` の書式で含めます。" +"``'microseconds'``: 全ての時刻を ``HH:MM:SS.ffffff`` の書式で含めます。" #: ../../library/datetime.rst:1642 ../../library/datetime.rst:2037 msgid "Excluded time components are truncated, not rounded." @@ -2671,7 +2912,6 @@ msgstr "除外された要素は丸め込みではなく、切り捨てされま msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument::" msgstr "不正な *timespec* 引数には :exc:`ValueError` があげられます::" -#: ../../library/datetime.rst:1647 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.now().isoformat(timespec='minutes')\n" @@ -2680,27 +2920,36 @@ msgid "" ">>> my_datetime.isoformat(timespec='microseconds')\n" "'2015-01-01T12:30:59.000000'" msgstr "" +">>> import datetime as dt\n" +">>> dt.datetime.now().isoformat(timespec='minutes')\n" +"'2002-12-25T00:00'\n" +">>> my_datetime = dt.datetime(2015, 1, 1, 12, 30, 59, 0)\n" +">>> my_datetime.isoformat(timespec='microseconds')\n" +"'2015-01-01T12:30:59.000000'" #: ../../library/datetime.rst:1654 ../../library/datetime.rst:2052 msgid "Added the *timespec* parameter." msgstr "*timespec* パラメータを追加しました." -#: ../../library/datetime.rst:1660 msgid "" "For a :class:`.datetime` instance ``d``, ``str(d)`` is equivalent to ``d." "isoformat(' ')``." msgstr "" +":class:`.datetime` インスタンス ``d`` について、``str(d)`` は ``d." +"isoformat(' ')`` と等価です。" #: ../../library/datetime.rst:1666 msgid "Return a string representing the date and time::" msgstr "日付および時刻を表す文字列を返します::" -#: ../../library/datetime.rst:1668 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime(2002, 12, 4, 20, 30, 40).ctime()\n" "'Wed Dec 4 20:30:40 2002'" msgstr "" +">>> import datetime as dt\n" +">>> dt.datetime(2002, 12, 4, 20, 30, 40).ctime()\n" +"'Wed Dec 4 20:30:40 2002'" #: ../../library/datetime.rst:1672 msgid "" @@ -2744,15 +2993,13 @@ msgstr "" ":ref:`strftime-strptime-behavior` および :meth:`datetime.isoformat` も参照し" "てください。" -#: ../../library/datetime.rst:1700 msgid "Examples of usage: :class:`!datetime`" -msgstr "" +msgstr "使用例: :class:`!datetime`" #: ../../library/datetime.rst:1702 msgid "Examples of working with :class:`.datetime` objects:" msgstr ":class:`.datetime` オブジェクトを使う例::" -#: ../../library/datetime.rst:1704 msgid "" ">>> import datetime as dt\n" "\n" @@ -2806,6 +3053,57 @@ msgid "" "format(my_datetime, \"day\", \"month\", \"time\")\n" "'The day is 21, the month is November, the time is 04:30PM.'" msgstr "" +">>> import datetime as dt\n" +"\n" +">>> # datetime.combine() の使用\n" +">>> d = dt.date(2005, 7, 14)\n" +">>> t = dt.time(12, 30)\n" +">>> dt.datetime.combine(d, t)\n" +"datetime.datetime(2005, 7, 14, 12, 30)\n" +"\n" +">>> # datetime.now() の使用\n" +">>> dt.datetime.now()\n" +"datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1\n" +">>> dt.datetime.now(dt.timezone.utc)\n" +"datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, tzinfo=datetime.timezone." +"utc)\n" +"\n" +">>> # datetime.strptime() の使用\n" +">>> my_datetime = dt.datetime.strptime(\"21/11/06 16:30\", \"%d/%m/%y %H:" +"%M\")\n" +">>> my_datetime\n" +"datetime.datetime(2006, 11, 21, 16, 30)\n" +"\n" +">>> # datetime.timetuple() で全属性のタプルを取得する\n" +">>> tt = my_datetime.timetuple()\n" +">>> for it in tt:\n" +"... print(it)\n" +"...\n" +"2006 # 年\n" +"11 # 月\n" +"21 # 日\n" +"16 # 時\n" +"30 # 分\n" +"0 # 秒\n" +"1 # 曜日 (0 = 月曜日)\n" +"325 # 1 月 1 日から数えた日数\n" +"-1 # dst - メソッド tzinfo.dst() が None を返した\n" +"\n" +">>> # ISO 形式の日付\n" +">>> ic = my_datetime.isocalendar()\n" +">>> for it in ic:\n" +"... print(it)\n" +"...\n" +"2006 # ISO の年\n" +"47 # ISO の週\n" +"2 # ISO の曜日\n" +"\n" +">>> # datetime の書式設定\n" +">>> my_datetime.strftime(\"%A, %d. %B %Y %I:%M%p\")\n" +"'Tuesday, 21. November 2006 04:30PM'\n" +">>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.'." +"format(my_datetime, \"day\", \"month\", \"time\")\n" +"'The day is 21, the month is November, the time is 04:30PM.'" #: ../../library/datetime.rst:1755 msgid "" @@ -2868,7 +3166,6 @@ msgstr "" msgid "Usage of ``KabulTz`` from above::" msgstr "上に出てきた ``KabulTz`` の使い方::" -#: ../../library/datetime.rst:1804 msgid "" ">>> tz1 = KabulTz()\n" "\n" @@ -2891,11 +3188,30 @@ msgid "" ">>> dt2 == dt3\n" "True" msgstr "" +">>> tz1 = KabulTz()\n" +"\n" +">>> # 変更前の日時\n" +">>> dt1 = dt.datetime(1900, 11, 21, 16, 30, tzinfo=tz1)\n" +">>> print(dt1.utcoffset())\n" +"4:00:00\n" +"\n" +">>> # 変更後の日時\n" +">>> dt2 = dt.datetime(2006, 6, 14, 13, 0, tzinfo=tz1)\n" +">>> print(dt2.utcoffset())\n" +"4:30:00\n" +"\n" +">>> # 日時を別のタイムゾーンに変換する\n" +">>> dt3 = dt2.astimezone(dt.timezone.utc)\n" +">>> dt3\n" +"datetime.datetime(2006, 6, 14, 8, 30, tzinfo=datetime.timezone.utc)\n" +">>> dt2\n" +"datetime.datetime(2006, 6, 14, 13, 0, tzinfo=KabulTz())\n" +">>> dt2 == dt3\n" +"True" + +msgid ":class:`!time` objects" +msgstr ":class:`!time` オブジェクト" -#: ../../library/datetime.rst:1829 -msgid ":class:`!time` objects" -msgstr "" - #: ../../library/datetime.rst:1831 msgid "" "A :class:`.time` object represents a (local) time of day, independent of any " @@ -2950,17 +3266,22 @@ msgstr "" ":class:`.time` コンストラクタに *tzinfo* 引数として与えられたオブジェクトにな" "り、何も渡されなかった場合には ``None`` になります。" -#: ../../library/datetime.rst:1909 msgid "" ":class:`.time` objects support equality and order comparisons, where ``a`` " "is considered less than ``b`` when ``a`` precedes ``b`` in time." msgstr "" +":class:`.time` オブジェクトは等価比較と順序比較をサポートします。\n" +"``a`` が時刻として ``b`` より前を表す場合、``a`` は ``b`` より小さいとみなさ" +"れます。" -#: ../../library/datetime.rst:1912 msgid "" "Naive and aware :class:`!time` objects are never equal. Order comparison " "between naive and aware :class:`!time` objects raises :exc:`TypeError`." msgstr "" +"naive な :class:`!time` オブジェクトと aware なものが等しくなることはありませ" +"ん。\n" +"naive な :class:`!time` オブジェクトと aware なものの順序比較は、:exc:" +"`TypeError` を送出します。" #: ../../library/datetime.rst:1916 msgid "" @@ -2990,17 +3311,20 @@ msgid "" msgstr "" "ブール値の文脈では、 :class:`.time` オブジェクトは常に真とみなされます。" -#: ../../library/datetime.rst:1928 msgid "" "Before Python 3.5, a :class:`.time` object was considered to be false if it " "represented midnight in UTC. This behavior was considered obscure and error-" "prone and has been removed in Python 3.5. See :issue:`13936` for more " "information." msgstr "" +"Python 3.5 より前では、:class:`.time` オブジェクトが UTC の午前 0 時を表す場" +"合、偽とみなされていました。\n" +"この動作は分かりにくく誤りを招きやすいと判断され、Python 3.5 で削除されまし" +"た。\n" +"詳細は :issue:`13936` を参照してください。" -#: ../../library/datetime.rst:1935 msgid "Other constructors:" -msgstr "" +msgstr "その他のコンストラクタ:" #: ../../library/datetime.rst:1939 msgid "" @@ -3010,23 +3334,22 @@ msgstr "" "以下の例外を除く、有効な ISO 8601 フォーマットで与えられた *time_string* に対" "応する :class:`.time` を返します :" -#: ../../library/datetime.rst:1943 msgid "" "The leading ``T``, normally required in cases where there may be ambiguity " "between a date and a time, is not required." msgstr "" +"日付と時刻の区別が曖昧になる可能性がある場合に通常必要となる、先頭の ``T`` は" +"必須ではありません。" -#: ../../library/datetime.rst:1945 msgid "" "Fractional seconds may have any number of digits (anything beyond 6 will be " "truncated)." -msgstr "" +msgstr "秒の小数部分の桁数は任意です (6 桁を超える部分は切り捨てられます)。" #: ../../library/datetime.rst:1949 msgid "Examples:" msgstr "例:" -#: ../../library/datetime.rst:1951 msgid "" ">>> import datetime as dt\n" ">>> dt.time.fromisoformat('04:23:01')\n" @@ -3047,18 +3370,38 @@ msgid "" ">>> dt.time.fromisoformat('04:23:01+00:00')\n" "datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" msgstr "" +">>> import datetime as dt\n" +">>> dt.time.fromisoformat('04:23:01')\n" +"datetime.time(4, 23, 1)\n" +">>> dt.time.fromisoformat('T04:23:01')\n" +"datetime.time(4, 23, 1)\n" +">>> dt.time.fromisoformat('T042301')\n" +"datetime.time(4, 23, 1)\n" +">>> dt.time.fromisoformat('04:23:01.000384')\n" +"datetime.time(4, 23, 1, 384)\n" +">>> dt.time.fromisoformat('04:23:01,000384')\n" +"datetime.time(4, 23, 1, 384)\n" +">>> dt.time.fromisoformat('04:23:01+04:00')\n" +"datetime.time(4, 23, 1, tzinfo=datetime.timezone(datetime." +"timedelta(seconds=14400)))\n" +">>> dt.time.fromisoformat('04:23:01Z')\n" +"datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)\n" +">>> dt.time.fromisoformat('04:23:01+00:00')\n" +"datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)" -#: ../../library/datetime.rst:1973 msgid "" "Previously, this method only supported formats that could be emitted by :" "meth:`time.isoformat`." msgstr "" +"以前は、このメソッドは :meth:`time.isoformat` が出力できる形式だけをサポート" +"していました。" -#: ../../library/datetime.rst:1980 msgid "" "Return a :class:`.time` corresponding to *date_string*, parsed according to " "*format*." msgstr "" +"*format* に従って *date_string* を解析し、対応する :class:`.time` を返しま" +"す。" #: ../../library/datetime.rst:1983 msgid "" @@ -3067,25 +3410,30 @@ msgid "" msgstr "" "*format* がマイクロ秒やタイムゾーン情報を含まない場合は、以下と等価です::" -#: ../../library/datetime.rst:1985 msgid "time(*(time.strptime(date_string, format)[3:6]))" -msgstr "" +msgstr "time(*(time.strptime(date_string, format)[3:6]))" -#: ../../library/datetime.rst:1987 msgid "" ":exc:`ValueError` is raised if the *date_string* and *format* cannot be " "parsed by :func:`time.strptime` or if it returns a value which is not a time " "tuple. See also :ref:`strftime-strptime-behavior` and :meth:`time." "fromisoformat`." msgstr "" +"*date_string* と *format* を :func:`time.strptime` で解析できない場合、または" +"その返り値が時刻タプルでない場合、:exc:`ValueError` を送出します。\n" +":ref:`strftime-strptime-behavior` と :meth:`time.fromisoformat` も参照してく" +"ださい。" -#: ../../library/datetime.rst:2000 msgid "" "Return a new :class:`.time` with the same values, but with specified " "parameters updated. Note that ``tzinfo=None`` can be specified to create a " "naive :class:`!time` from an aware :class:`!time`, without conversion of the " "time data." msgstr "" +"指定したパラメータだけを更新し、それ以外は同じ値を持つ新しい :class:`.time` " +"を返します。\n" +"``tzinfo=None`` を指定すると、時刻のデータを変換せずに、aware な :class:`!" +"time` から naive な :class:`!time` を作成できます。" #: ../../library/datetime.rst:2005 msgid "" @@ -3127,7 +3475,6 @@ msgstr "" msgid ":exc:`ValueError` will be raised on an invalid *timespec* argument." msgstr "不正な *timespec* 引数には :exc:`ValueError` があげられます。" -#: ../../library/datetime.rst:2043 msgid "" ">>> import datetime as dt\n" ">>> dt.time(hour=12, minute=34, second=56, microsecond=123456)." @@ -3139,10 +3486,18 @@ msgid "" ">>> my_time.isoformat(timespec='auto')\n" "'12:34:56'" msgstr "" +">>> import datetime as dt\n" +">>> dt.time(hour=12, minute=34, second=56, microsecond=123456)." +"isoformat(timespec='minutes')\n" +"'12:34'\n" +">>> my_time = dt.time(hour=12, minute=34, second=56, microsecond=0)\n" +">>> my_time.isoformat(timespec='microseconds')\n" +"'12:34:56.000000'\n" +">>> my_time.isoformat(timespec='auto')\n" +"'12:34:56'" -#: ../../library/datetime.rst:2058 msgid "For a time ``t``, ``str(t)`` is equivalent to ``t.isoformat()``." -msgstr "" +msgstr "時刻 ``t`` について、``str(t)`` は ``t.isoformat()`` と等価です。" #: ../../library/datetime.rst:2063 msgid "" @@ -3168,7 +3523,6 @@ msgstr "" ":ref:`strftime-strptime-behavior` および :meth:`time.isoformat` も参照してく" "ださい。" -#: ../../library/datetime.rst:2077 msgid "" "If :attr:`.tzinfo` is ``None``, returns ``None``, else returns ``self.tzinfo." "utcoffset(None)``, and raises an exception if the latter doesn't return " @@ -3176,7 +3530,7 @@ msgid "" msgstr "" ":attr:`.tzinfo` が ``None`` の場合、 ``None`` を返し、そうでない場合には " "``self.tzinfo.utcoffset(None)`` を返します。\n" -"後者の式が ``None`` あるいは 1 日以下の大きさを持つ :class:`timedelta` オブ" +"後者の式が ``None`` あるいは 1 日未満の大きさを持つ :class:`timedelta` オブ" "ジェクトのいずれかを返さない場合には例外を送出します。" #: ../../library/datetime.rst:2087 @@ -3201,15 +3555,13 @@ msgstr "" "後者の式が ``None`` か文字列オブジェクトのいずれかを返さない場合には例外を送" "出します。" -#: ../../library/datetime.rst:2103 msgid "Examples of usage: :class:`!time`" -msgstr "" +msgstr "使用例: :class:`!time`" #: ../../library/datetime.rst:2105 msgid "Examples of working with a :class:`.time` object::" msgstr ":class:`.time` オブジェクトを使う例::" -#: ../../library/datetime.rst:2107 msgid "" ">>> import datetime as dt\n" ">>> class TZ1(dt.tzinfo):\n" @@ -3236,19 +3588,44 @@ msgid "" ">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" "'The time is 12:10.'" msgstr "" +">>> import datetime as dt\n" +">>> class TZ1(dt.tzinfo):\n" +"... def utcoffset(self, when):\n" +"... return dt.timedelta(hours=1)\n" +"... def dst(self, when):\n" +"... return dt.timedelta(0)\n" +"... def tzname(self, when):\n" +"... return \"+01:00\"\n" +"... def __repr__(self):\n" +"... return f\"{self.__class__.__name__}()\"\n" +"...\n" +">>> t = dt.time(12, 10, 30, tzinfo=TZ1())\n" +">>> t\n" +"datetime.time(12, 10, 30, tzinfo=TZ1())\n" +">>> t.isoformat()\n" +"'12:10:30+01:00'\n" +">>> t.dst()\n" +"datetime.timedelta(0)\n" +">>> t.tzname()\n" +"'+01:00'\n" +">>> t.strftime(\"%H:%M:%S %Z\")\n" +"'12:10:30 +01:00'\n" +">>> 'The {} is {:%H:%M}.'.format(\"time\", t)\n" +"'The time is 12:10.'" -#: ../../library/datetime.rst:2136 msgid ":class:`!tzinfo` objects" -msgstr "" +msgstr ":class:`!tzinfo` オブジェクト" -#: ../../library/datetime.rst:2140 msgid "" "This is an :term:`abstract base class`, meaning that this class should not " "be instantiated directly. Define a subclass of :class:`tzinfo` to capture " "information about a particular time zone." msgstr "" +"これは :term:`abstract base class` であり、直接インスタンス化すべきではないク" +"ラスです。\n" +"特定のタイムゾーンについての情報を保持するには、:class:`tzinfo` のサブクラス" +"を定義してください。" -#: ../../library/datetime.rst:2144 msgid "" "An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the " "constructors for :class:`.datetime` and :class:`.time` objects. The latter " @@ -3257,8 +3634,13 @@ msgid "" "name of the time zone, and DST offset, all relative to a date or time object " "passed to them." msgstr "" +":class:`tzinfo` (の具象サブクラス) のインスタンスは、:class:`.datetime` と :" +"class:`.time` オブジェクトのコンストラクタに渡せます。\n" +"これらの日時オブジェクトは自分の属性をローカル時刻とみなします。\n" +":class:`!tzinfo` オブジェクトは、渡された日付または時刻オブジェクトに応じて、" +"ローカル時刻の UTC からのオフセット、タイムゾーン名、DST オフセットを返すメ" +"ソッドをサポートします。" -#: ../../library/datetime.rst:2150 msgid "" "You need to derive a concrete subclass, and (at least) supply " "implementations of the standard :class:`tzinfo` methods needed by the :class:" @@ -3267,6 +3649,12 @@ msgid "" "represent time zones with fixed offset from UTC such as UTC itself or North " "American EST and EDT." msgstr "" +"具象サブクラスを派生させ、少なくとも使用する :class:`.datetime` のメソッドが" +"必要とする標準の :class:`tzinfo` メソッドを実装する必要があります。\n" +":mod:`!datetime` モジュールは、:class:`!tzinfo` の単純な具象サブクラス :" +"class:`timezone` を提供します。\n" +"これは UTC 自体や北米の EST と EDT など、UTC からのオフセットが固定されたタイ" +"ムゾーンを表現できます。" #: ../../library/datetime.rst:2157 msgid "" @@ -3322,11 +3710,12 @@ msgstr "" "ほとんどの :meth:`utcoffset` 実装は、おそらく以下の二つのうちの一つに似たもの" "になるでしょう::" -#: ../../library/datetime.rst:2181 msgid "" "return CONSTANT # fixed-offset class\n" "return CONSTANT + self.dst(dt) # daylight-aware class" msgstr "" +"return CONSTANT # 固定オフセットのクラス\n" +"return CONSTANT + self.dst(dt) # 夏時間を考慮するクラス" #: ../../library/datetime.rst:2184 msgid "" @@ -3352,7 +3741,6 @@ msgstr "" "夏時間 (DST) 修正を、 :class:`timedelta` オブジェクトで返します。\n" "DST 情報が未知の場合、 ``None`` が返されます。" -#: ../../library/datetime.rst:2200 msgid "" "Return ``timedelta(0)`` if DST is not in effect. If DST is in effect, return " "the offset as a :class:`timedelta` object (see :meth:`utcoffset` for " @@ -3364,16 +3752,17 @@ msgid "" "tm_isdst` flag should be set, and :meth:`tzinfo.fromutc` calls :meth:`dst` " "to account for DST changes when crossing time zones." msgstr "" -"DST が有効でない場合には ``timedelta(0)`` を返します。\n" -"DST が有効の場合、オフセットは :class:`timedelta` オブジェクトで返します (詳" -"細は :meth:`utcoffset` を参照してください)。\n" -"DST オフセットが利用可能な場合、この値は :meth:`utcoffset` が返す UTC からの" -"オフセットには既に加算されているため、 DST を個別に取得する必要がない限り :" -"meth:`dst` を使って問い合わせる必要はないので注意してください。\n" -"例えば、 :meth:`datetime.timetuple` は :attr:`~.datetime.tzinfo` 属性の :" -"meth:`dst` メソッドを呼んで :attr:`~time.struct_time.tm_isdst` フラグがセット" -"されているかどうか判断し、 :meth:`tzinfo.fromutc` は :meth:`dst` タイムゾーン" -"を移動する際に DST による変更があるかどうかを調べます。" +"DST が適用されない場合は ``timedelta(0)`` を返します。\n" +"適用される場合は、調整量を :class:`timedelta` オブジェクトで返します (詳細" +"は :meth:`utcoffset` を参照してください)。\n" +"DST の調整量は :meth:`utcoffset` が返す UTC オフセットにすでに加算されている" +"ため、DST 情報を個別に取得したい場合を除き、:meth:`dst` を呼び出す必要はあり" +"ません。\n" +"例えば、:meth:`datetime.timetuple` は :attr:`~.datetime.tzinfo` 属性の :meth:" +"`dst` メソッドを呼び出して、:attr:`~time.struct_time.tm_isdst` フラグに設定す" +"る値を決定します。\n" +"また :meth:`tzinfo.fromutc` は :meth:`dst` を呼び出し、タイムゾーンをまたぐ際" +"の DST の変化を考慮します。" #: ../../library/datetime.rst:2210 msgid "" @@ -3387,7 +3776,6 @@ msgstr "" msgid "``tz.utcoffset(dt) - tz.dst(dt)``" msgstr "``tz.utcoffset(dt) - tz.dst(dt)``" -#: ../../library/datetime.rst:2215 msgid "" "must return the same result for every :class:`.datetime` *dt* with ``dt." "tzinfo == tz``. For sane :class:`!tzinfo` subclasses, this expression yields " @@ -3399,6 +3787,16 @@ msgid "" "of :meth:`tzinfo.fromutc` to work correctly with :meth:`~.datetime." "astimezone` regardless." msgstr "" +"が ``dt.tzinfo == tz`` を満たすすべての :class:`.datetime` *dt* に対して同じ" +"結果を返す、という意味で一貫している必要があります。\n" +"適切な :class:`!tzinfo` サブクラスでは、この式はタイムゾーンの「標準オフセッ" +"ト」を返します。\n" +"これは日時には依存せず、地理的な位置のみに依存するべきです。\n" +":meth:`datetime.astimezone` の実装はこの性質に依存しますが、違反を検出できな" +"いため、保証するのはプログラマの責任です。\n" +":class:`!tzinfo` サブクラスがこの性質を保証できない場合でも、:meth:`tzinfo." +"fromutc` のデフォルト実装をオーバーライドすれば、:meth:`~.datetime." +"astimezone` と正しく動作できる場合があります。" #: ../../library/datetime.rst:2224 msgid "" @@ -3408,7 +3806,6 @@ msgstr "" "ほとんどの :meth:`dst` 実装は、おそらく以下の二つのうちの一つに似たものになる" "でしょう::" -#: ../../library/datetime.rst:2226 msgid "" "import datetime as dt\n" "\n" @@ -3416,12 +3813,16 @@ msgid "" " # a fixed-offset class: doesn't account for DST\n" " return dt.timedelta(0)" msgstr "" +"import datetime as dt\n" +"\n" +"def dst(self, when):\n" +" # 固定オフセットのクラス: DST を考慮しない\n" +" return dt.timedelta(0)" #: ../../library/datetime.rst:2232 msgid "or::" msgstr "もしくは::" -#: ../../library/datetime.rst:2234 msgid "" "import datetime as dt\n" "\n" @@ -3435,6 +3836,17 @@ msgid "" " else:\n" " return dt.timedelta(0)" msgstr "" +"import datetime as dt\n" +"\n" +"def dst(self, when):\n" +" # 入力の when.year に基づいて、そのタイムゾーンの DST の\n" +" # 開始時刻と終了時刻を標準のローカル時刻で表し、\n" +" # dston と dstoff に設定するコード。\n" +"\n" +" if dston <= when.replace(tzinfo=None) < dstoff:\n" +" return dt.timedelta(hours=1)\n" +" else:\n" +" return dt.timedelta(0)" #: ../../library/datetime.rst:2246 msgid "" @@ -3442,7 +3854,6 @@ msgid "" msgstr "" "デフォルトの :meth:`dst` 実装は :exc:`NotImplementedError` を送出します。" -#: ../../library/datetime.rst:2254 msgid "" "Return the time zone name corresponding to the :class:`.datetime` object " "*dt*, as a string. Nothing about string names is defined by the :mod:`!" @@ -3455,6 +3866,17 @@ msgid "" "specific value of *dt* passed, especially if the :class:`!tzinfo` class is " "accounting for daylight time." msgstr "" +":class:`.datetime` オブジェクト *dt* に対応するタイムゾーン名を文字列として返" +"します。\n" +":mod:`!datetime` モジュールは名前の文字列について何も定義しておらず、特定の意" +"味を持つ必要もありません。\n" +"例えば、``\"GMT\"``、``\"UTC\"``、``\"-500\"``、``\"-5:00\"``、``\"EDT\"``、" +"``\"US/Eastern\"``、``\"America/New York\"`` はすべて有効な返り値です。\n" +"名前の文字列が不明な場合は ``None`` を返します。\n" +"固定文字列ではなくメソッドになっている主な理由は、一部の :class:`tzinfo` サブ" +"クラスが、渡された *dt* の具体的な値に応じて異なる名前を返したい場合があるた" +"めです。\n" +"特に、:class:`!tzinfo` クラスが夏時間を考慮する場合が当てはまります。" #: ../../library/datetime.rst:2264 msgid "" @@ -3463,7 +3885,6 @@ msgid "" msgstr "" "デフォルトの :meth:`tzname` 実装は :exc:`NotImplementedError` を送出します。" -#: ../../library/datetime.rst:2267 msgid "" "These methods are called by a :class:`.datetime` or :class:`.time` object, " "in response to their methods of the same names. A :class:`!datetime` object " @@ -3472,8 +3893,14 @@ msgid "" "prepared to accept a *dt* argument of ``None``, or of class :class:`!" "datetime`." msgstr "" +"これらのメソッドは、:class:`.datetime` または :class:`.time` オブジェクトの同" +"名のメソッドに応じて呼び出されます。\n" +":class:`!datetime` オブジェクトは引数として自身を渡し、:class:`!time` オブ" +"ジェクトは ``None`` を渡します。\n" +"したがって、:class:`tzinfo` サブクラスのメソッドは、*dt* 引数として ``None`` " +"または :class:`!datetime` クラスのオブジェクトを受け付けられるようにする必要" +"があります。" -#: ../../library/datetime.rst:2273 msgid "" "When ``None`` is passed, it's up to the class designer to decide the best " "response. For example, returning ``None`` is appropriate if the class wishes " @@ -3481,13 +3908,12 @@ msgid "" "It may be more useful for ``utcoffset(None)`` to return the standard UTC " "offset, as there is no other convention for discovering the standard offset." msgstr "" -"``None`` が渡された場合、最良の応答方法を決めるのはクラス設計者次第です。例え" -"ば、このクラスが :class:`tzinfo` プロトコルと関係をもたないということを表明さ" -"せたければ、 ``None`` が適切です。標準時のオフセットを見つける他の手段がない" -"場合には、標準 UTC オフセットを返すために ``utcoffset(None)`` を使うともっと" -"便利かもしれません。" +"``None`` が渡された場合、最良の応答方法を決めるのはクラス設計者です。\n" +"例えば、時刻オブジェクトが :class:`tzinfo` プロトコルに関与しないことを表した" +"い場合は、``None`` を返すのが適切です。\n" +"標準オフセットを調べる方法は他に定められていないため、``utcoffset(None)`` が" +"標準の UTC オフセットを返す方が便利な場合もあります。" -#: ../../library/datetime.rst:2279 msgid "" "When a :class:`.datetime` object is passed in response to a :class:`!" "datetime` method, ``dt.tzinfo`` is the same object as *self*. :class:" @@ -3496,6 +3922,12 @@ msgid "" "*dt* as being in local time, and not need worry about objects in other time " "zones." msgstr "" +":class:`!datetime` のメソッドに応じて :class:`.datetime` オブジェクトが渡され" +"る場合、``dt.tzinfo`` は *self* と同じオブジェクトです。\n" +"ユーザーコードが :class:`!tzinfo` メソッドを直接呼び出さない限り、:class:" +"`tzinfo` メソッドはこの性質に依存できます。\n" +"これは、:class:`!tzinfo` メソッドが *dt* をローカル時刻と解釈し、他のタイム" +"ゾーンのオブジェクトを気にする必要がないようにするためです。" #: ../../library/datetime.rst:2285 msgid "" @@ -3505,7 +3937,6 @@ msgstr "" "サブクラスでオーバーライドすると良い、もう 1 つの :class:`tzinfo` のメソッド" "があります:" -#: ../../library/datetime.rst:2290 msgid "" "This is called from the default :meth:`datetime.astimezone` implementation. " "When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time " @@ -3513,11 +3944,11 @@ msgid "" "`fromutc` is to adjust the date and time data, returning an equivalent " "datetime in *self*'s local time." msgstr "" -"デフォルトの 実装で呼び出されます。 :meth:`datetime.astimezone` から呼ばれた" -"場合、 ``dt.tzinfo`` は *self* であり、 *dt* の日付および時刻データは UTC 時" -"刻を表しているものとして見えます。 :meth:`fromutc` の目的は、 *self* のローカ" -"ル時刻に等しい :class:`datetime` オブジェクトを返すことにより日付と時刻データ" -"メンバを修正することにあります。" +"デフォルトの :meth:`datetime.astimezone` 実装から呼び出されます。\n" +"その場合、``dt.tzinfo`` は *self* であり、*dt* の日付と時刻は UTC を表すもの" +"として解釈します。\n" +":meth:`fromutc` は日付と時刻を調整し、同じ時点を *self* のローカル時刻で表す " +"datetime を返すためのメソッドです。" #: ../../library/datetime.rst:2296 msgid "" @@ -3552,7 +3983,6 @@ msgstr "" "エラーの場合のためのコードを除き、デフォルトの :meth:`fromutc` の実装は以下の" "ように動作します::" -#: ../../library/datetime.rst:2310 msgid "" "import datetime as dt\n" "\n" @@ -3571,6 +4001,22 @@ msgid "" " else:\n" " return when" msgstr "" +"import datetime as dt\n" +"\n" +"def fromutc(self, when):\n" +" # when.tzinfo is not self の場合は ValueError を送出する\n" +" dtoff = when.utcoffset()\n" +" dtdst = when.dst()\n" +" # dtoff is None または dtdst is None の場合は ValueError を送出する\n" +" delta = dtoff - dtdst # これは self の標準オフセット\n" +" if delta:\n" +" when += delta # 標準のローカル時刻に変換する\n" +" dtdst = when.dst()\n" +" # dtdst is None の場合は ValueError を送出する\n" +" if dtdst:\n" +" return when + dtdst\n" +" else:\n" +" return when" #: ../../library/datetime.rst:2327 msgid "" @@ -3580,7 +4026,6 @@ msgstr "" "次の :download:`tzinfo_examples.py <../includes/tzinfo_examples.py>` ファイル" "には、 :class:`tzinfo` クラスの例がいくつか載っています:" -#: ../../library/datetime.rst:2331 msgid "" "import datetime as dt\n" "\n" @@ -3762,8 +4207,186 @@ msgid "" "Mountain = USTimeZone(-7, \"Mountain\", \"MST\", \"MDT\")\n" "Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" msgstr "" +"import datetime as dt\n" +"\n" +"# プラットフォームが認識するローカル時刻を表すクラス。\n" +"# (UTC オフセットや DST の規則が過去に変更された\n" +"# タイムゾーンでは、過去の時刻に対して\n" +"# 誤った値になる場合がある。)\n" +"import time\n" +"\n" +"ZERO = dt.timedelta(0)\n" +"HOUR = dt.timedelta(hours=1)\n" +"SECOND = dt.timedelta(seconds=1)\n" +"\n" +"STDOFFSET = dt.timedelta(seconds=-time.timezone)\n" +"if time.daylight:\n" +" DSTOFFSET = dt.timedelta(seconds=-time.altzone)\n" +"else:\n" +" DSTOFFSET = STDOFFSET\n" +"\n" +"DSTDIFF = DSTOFFSET - STDOFFSET\n" +"\n" +"\n" +"class LocalTimezone(dt.tzinfo):\n" +"\n" +" def fromutc(self, when):\n" +" assert when.tzinfo is self\n" +" stamp = (when - dt.datetime(1970, 1, 1, tzinfo=self)) // SECOND\n" +" args = time.localtime(stamp)[:6]\n" +" dst_diff = DSTDIFF // SECOND\n" +" # 折り返しを検出する\n" +" fold = (args == time.localtime(stamp - dst_diff))\n" +" return dt.datetime(*args, microsecond=when.microsecond,\n" +" tzinfo=self, fold=fold)\n" +"\n" +" def utcoffset(self, when):\n" +" if self._isdst(when):\n" +" return DSTOFFSET\n" +" else:\n" +" return STDOFFSET\n" +"\n" +" def dst(self, when):\n" +" if self._isdst(when):\n" +" return DSTDIFF\n" +" else:\n" +" return ZERO\n" +"\n" +" def tzname(self, when):\n" +" return time.tzname[self._isdst(when)]\n" +"\n" +" def _isdst(self, when):\n" +" tt = (when.year, when.month, when.day,\n" +" when.hour, when.minute, when.second,\n" +" when.weekday(), 0, 0)\n" +" stamp = time.mktime(tt)\n" +" tt = time.localtime(stamp)\n" +" return tt.tm_isdst > 0\n" +"\n" +"\n" +"Local = LocalTimezone()\n" +"\n" +"\n" +"# 米国の主要なタイムゾーンについて、現在の DST 規則を完全に実装する。\n" +"\n" +"def first_sunday_on_or_after(when):\n" +" days_to_go = 6 - when.weekday()\n" +" if days_to_go:\n" +" when += dt.timedelta(days_to_go)\n" +" return when\n" +"\n" +"\n" +"# 米国の DST 規則\n" +"#\n" +"# これは米国の DST の開始時刻と終了時刻について簡略化した\n" +"# (つまり一部のケースでは誤った) 規則である。完全で最新の DST 規則と\n" +"# タイムゾーン定義は Olson Database を参照 (または pytz を試すこと):\n" +"# http://www.twinsun.com/tz/tz-link.htm\n" +"# https://sourceforge.net/projects/pytz/ (最新でない場合がある)\n" +"#\n" +"# 米国では 2007 年以降、DST は 3 月の第 2 日曜日、\n" +"# つまり 3 月 8 日以降の最初の日曜日の午前 2 時 (標準時) に始まる。\n" +"DSTSTART_2007 = dt.datetime(1, 3, 8, 2)\n" +"# 11 月の第 1 日曜日の午前 2 時 (夏時間) に終わる。\n" +"DSTEND_2007 = dt.datetime(1, 11, 1, 2)\n" +"# 1987 年から 2006 年まで、DST は 4 月の第 1 日曜日の午前 2 時 (標準時)\n" +"# に始まり、10 月の最後の日曜日、つまり 10 月 25 日以降の\n" +"# 最初の日曜日の午前 2 時 (夏時間) に終わっていた。\n" +"DSTSTART_1987_2006 = dt.datetime(1, 4, 1, 2)\n" +"DSTEND_1987_2006 = dt.datetime(1, 10, 25, 2)\n" +"# 1967 年から 1986 年まで、DST は 4 月の最後の日曜日 (4 月 24 日以降の\n" +"# 日曜日) の午前 2 時 (標準時) に始まり、10 月の最後の日曜日、\n" +"# つまり 10 月 25 日以降の最初の日曜日の\n" +"# 午前 2 時 (夏時間) に終わっていた。\n" +"DSTSTART_1967_1986 = dt.datetime(1, 4, 24, 2)\n" +"DSTEND_1967_1986 = DSTEND_1987_2006\n" +"\n" +"\n" +"def us_dst_range(year):\n" +" # 米国の DST の開始時刻と終了時刻を求める。1967 年より前の年は\n" +" # DST がないため start = end を返す。\n" +" if 2006 < year:\n" +" dststart, dstend = DSTSTART_2007, DSTEND_2007\n" +" elif 1986 < year < 2007:\n" +" dststart, dstend = DSTSTART_1987_2006, DSTEND_1987_2006\n" +" elif 1966 < year < 1987:\n" +" dststart, dstend = DSTSTART_1967_1986, DSTEND_1967_1986\n" +" else:\n" +" return (dt.datetime(year, 1, 1), ) * 2\n" +"\n" +" start = first_sunday_on_or_after(dststart.replace(year=year))\n" +" end = first_sunday_on_or_after(dstend.replace(year=year))\n" +" return start, end\n" +"\n" +"\n" +"class USTimeZone(dt.tzinfo):\n" +"\n" +" def __init__(self, hours, reprname, stdname, dstname):\n" +" self.stdoffset = dt.timedelta(hours=hours)\n" +" self.reprname = reprname\n" +" self.stdname = stdname\n" +" self.dstname = dstname\n" +"\n" +" def __repr__(self):\n" +" return self.reprname\n" +"\n" +" def tzname(self, when):\n" +" if self.dst(when):\n" +" return self.dstname\n" +" else:\n" +" return self.stdname\n" +"\n" +" def utcoffset(self, when):\n" +" return self.stdoffset + self.dst(when)\n" +"\n" +" def dst(self, when):\n" +" if when is None or when.tzinfo is None:\n" +" # ここでは、一方または両方の場合に例外を送出するのが妥当かもしれ" +"ない。\n" +" # どのように扱いたいかによる。デフォルトの fromutc() の実装\n" +" # (デフォルトの astimezone() の実装から呼び出される) は、\n" +" # when.tzinfo is self である datetime を渡す。\n" +" return ZERO\n" +" assert when.tzinfo is self\n" +" start, end = us_dst_range(when.year)\n" +" # naive と aware のオブジェクトは比較できないため、先に when から\n" +" # タイムゾーンを取り除く。\n" +" when = when.replace(tzinfo=None)\n" +" if start + HOUR <= when < end - HOUR:\n" +" # DST が適用されている。\n" +" return HOUR\n" +" if end - HOUR <= when < end:\n" +" # 折り返し (曖昧な 1 時間): when.fold で曖昧さを解消する。\n" +" return ZERO if when.fold else HOUR\n" +" if start <= when < start + HOUR:\n" +" # 欠落 (存在しない 1 時間): 折り返しの規則を逆にする。\n" +" return HOUR if when.fold else ZERO\n" +" # DST は適用されていない。\n" +" return ZERO\n" +"\n" +" def fromutc(self, when):\n" +" assert when.tzinfo is self\n" +" start, end = us_dst_range(when.year)\n" +" start = start.replace(tzinfo=self)\n" +" end = end.replace(tzinfo=self)\n" +" std_time = when + self.stdoffset\n" +" dst_time = std_time + HOUR\n" +" if end <= dst_time < end + HOUR:\n" +" # 繰り返される 1 時間\n" +" return std_time.replace(fold=1)\n" +" if std_time < start or dst_time >= end:\n" +" # 標準時\n" +" return std_time\n" +" if start <= std_time < end - HOUR:\n" +" # 夏時間\n" +" return dst_time\n" +"\n" +"\n" +"Eastern = USTimeZone(-5, \"Eastern\", \"EST\", \"EDT\")\n" +"Central = USTimeZone(-6, \"Central\", \"CST\", \"CDT\")\n" +"Mountain = USTimeZone(-7, \"Mountain\", \"MST\", \"MDT\")\n" +"Pacific = USTimeZone(-8, \"Pacific\", \"PST\", \"PDT\")\n" -#: ../../library/datetime.rst:2333 msgid "" "Note that there are unavoidable subtleties twice per year in a :class:" "`tzinfo` subclass accounting for both standard and daylight time, at the DST " @@ -3775,9 +4398,8 @@ msgstr "" "間の移行のときに、回避不能の難解な問題が年に 2 度あるので注意してください。\n" "具体的な例として、東部アメリカ時刻 (US Eastern, UTC -0500) を考えます。\n" "EDT は 3 月の第二日曜日の 1:59 (EST) の 1 分後に開始し、11 月の最初の日曜日" -"の (EDTの) 1:59 に終了します::" +"の 1:59 (EDT) の 1 分後に終了します。 ::" -#: ../../library/datetime.rst:2339 msgid "" " UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM\n" " EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM\n" @@ -3787,6 +4409,13 @@ msgid "" "\n" " end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" msgstr "" +" UTC 3:MM 4:MM 5:MM 6:MM 7:MM 8:MM\n" +" EST 22:MM 23:MM 0:MM 1:MM 2:MM 3:MM\n" +" EDT 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM\n" +"\n" +"start 22:MM 23:MM 0:MM 1:MM 3:MM 4:MM\n" +"\n" +" end 23:MM 0:MM 1:MM 1:MM 2:MM 3:MM" #: ../../library/datetime.rst:2347 msgid "" @@ -3803,7 +4432,6 @@ msgstr "" "ん。\n" "例として、 2016 年の春方向の移行では、次のような結果になります::" -#: ../../library/datetime.rst:2352 msgid "" ">>> import datetime as dt\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3818,6 +4446,18 @@ msgid "" "07:00:00 UTC = 03:00:00 EDT\n" "08:00:00 UTC = 04:00:00 EDT" msgstr "" +">>> import datetime as dt\n" +">>> from tzinfo_examples import HOUR, Eastern\n" +">>> u0 = dt.datetime(2016, 3, 13, 5, tzinfo=dt.timezone.utc)\n" +">>> for i in range(4):\n" +"... u = u0 + i*HOUR\n" +"... t = u.astimezone(Eastern)\n" +"... print(u.time(), 'UTC =', t.time(), t.tzname())\n" +"...\n" +"05:00:00 UTC = 00:00:00 EST\n" +"06:00:00 UTC = 01:00:00 EST\n" +"07:00:00 UTC = 03:00:00 EDT\n" +"08:00:00 UTC = 04:00:00 EDT" #: ../../library/datetime.rst:2366 msgid "" @@ -3847,7 +4487,6 @@ msgstr "" "fold` 属性を 0 にし、以降の時間では 1 にします。例えば、 2016 年での秋方向の" "移行では、次のような結果になります::" -#: ../../library/datetime.rst:2377 msgid "" ">>> import datetime as dt\n" ">>> from tzinfo_examples import HOUR, Eastern\n" @@ -3862,6 +4501,18 @@ msgid "" "06:00:00 UTC = 01:00:00 EST 1\n" "07:00:00 UTC = 02:00:00 EST 0" msgstr "" +">>> import datetime as dt\n" +">>> from tzinfo_examples import HOUR, Eastern\n" +">>> u0 = dt.datetime(2016, 11, 6, 4, tzinfo=dt.timezone.utc)\n" +">>> for i in range(4):\n" +"... u = u0 + i*HOUR\n" +"... t = u.astimezone(Eastern)\n" +"... print(u.time(), 'UTC =', t.time(), t.tzname(), t.fold)\n" +"...\n" +"04:00:00 UTC = 00:00:00 EDT 0\n" +"05:00:00 UTC = 01:00:00 EDT 0\n" +"06:00:00 UTC = 01:00:00 EST 1\n" +"07:00:00 UTC = 02:00:00 EST 0" #: ../../library/datetime.rst:2390 msgid "" @@ -3871,7 +4522,6 @@ msgstr "" ":attr:`~.datetime.fold` 属性が異なるだけの :class:`.datetime` インスタンスは" "比較において等しいとみなされることに注意してください。" -#: ../../library/datetime.rst:2393 msgid "" "Applications that can't bear wall-time ambiguities should explicitly check " "the value of the :attr:`~.datetime.fold` attribute or avoid using hybrid :" @@ -3880,6 +4530,12 @@ msgid "" "class representing only EST (fixed offset -5 hours), or only EDT (fixed " "offset -4 hours))." msgstr "" +"時計が示す時刻の曖昧さを許容できないアプリケーションは、:attr:`~.datetime." +"fold` 属性の値を明示的に調べるか、標準時と夏時間を組み合わせた :class:" +"`tzinfo` サブクラスの使用を避けるべきです。\n" +":class:`timezone` や、その他の固定オフセットの :class:`!tzinfo` サブクラス " +"(EST だけを表すクラス (固定オフセット -5 時間) や、EDT だけを表すクラス (固定" +"オフセット -4 時間) など) を使用する場合、曖昧さはありません。" #: ../../library/datetime.rst:2401 msgid ":mod:`zoneinfo`" @@ -3921,9 +4577,8 @@ msgstr "" "時刻の履歴を表しています。政治団体によるタイムゾーンの境界、UTC オフセット、" "夏時間のルールの変更を反映するため、定期的にデータベースが更新されます。" -#: ../../library/datetime.rst:2420 msgid ":class:`!timezone` objects" -msgstr "" +msgstr ":class:`!timezone` オブジェクト" #: ../../library/datetime.rst:2422 msgid "" @@ -3979,7 +4634,6 @@ msgstr "" "返り値は、ローカル時刻と UTC の差分に等しい :class:`timedelta` インスタンスで" "す。" -#: ../../library/datetime.rst:2464 msgid "" "If *name* is not provided in the constructor, the name returned by " "``tzname(dt)`` is generated from the value of the ``offset`` as follows. If " @@ -3990,9 +4644,9 @@ msgstr "" "*name* が構築時に与えられなかった場合、 ``tzname(dt)`` によって返される name " "は以下の様に ``offset`` の値から生成されます。\n" "*offset* が ``timedelta(0)`` であった場合、 name は \"UTC\"になります。\n" -"それ以外の場合、 'UTC±HH:MM' という書式の文字列になり、± は ``offset`` を、" -"HH と MM はそれぞれ二桁の ``offset.hours`` と ``offset.minutes`` を表現しま" -"す。" +"それ以外の場合、 'UTC±HH:MM' という書式の文字列になり、± は ``offset`` の符号" +"を、HH と MM はそれぞれ二桁の ``offset.hours`` と ``offset.minutes`` を表現し" +"ます。" #: ../../library/datetime.rst:2470 msgid "" @@ -4018,9 +4672,8 @@ msgstr "" msgid "The UTC time zone, ``timezone(timedelta(0))``." msgstr "UTC タイムゾーン ``timezone(timedelta(0))`` です。" -#: ../../library/datetime.rst:2499 msgid ":meth:`!strftime` and :meth:`!strptime` behavior" -msgstr "" +msgstr ":meth:`!strftime` と :meth:`!strptime` の動作" #: ../../library/datetime.rst:2501 msgid "" @@ -4032,12 +4685,14 @@ msgstr "" "``strftime(format)`` メソッドをサポートし、時刻を表現する文字列を明示的な書式" "文字列で統制して作成しています。" -#: ../../library/datetime.rst:2505 msgid "" "Conversely, the :meth:`date.strptime`, :meth:`datetime.strptime` and :meth:" "`time.strptime` class methods create an object from a string representing " "the time and a corresponding format string." msgstr "" +"逆に、クラスメソッド :meth:`date.strptime`、:meth:`datetime.strptime`、:meth:" +"`time.strptime` は、時刻を表す文字列と対応する書式文字列からオブジェクトを作" +"成します。" #: ../../library/datetime.rst:2509 msgid "" @@ -4063,9 +4718,8 @@ msgstr "使用法" msgid "Convert object to a string according to a given format" msgstr "オブジェクトを与えられた書式に従って文字列に変換する" -#: ../../library/datetime.rst:2515 msgid "Parse a string into an object given a corresponding format" -msgstr "" +msgstr "対応する書式を指定して文字列を解析し、オブジェクトに変換する" #: ../../library/datetime.rst:2517 msgid "Type of method" @@ -4091,17 +4745,16 @@ msgstr "``strftime(format)``" msgid "``strptime(date_string, format)``" msgstr "``strptime(date_string, format)``" -#: ../../library/datetime.rst:2526 msgid ":meth:`!strftime` and :meth:`!strptime` format codes" -msgstr "" +msgstr ":meth:`!strftime` と :meth:`!strptime` の書式コード" -#: ../../library/datetime.rst:2528 msgid "" "These methods accept format codes that can be used to parse and format " "dates::" msgstr "" +"これらのメソッドは、日付の解析と書式設定に使用できる書式コードを受け付けま" +"す。 ::" -#: ../../library/datetime.rst:2530 msgid "" ">>> import datetime as dt\n" ">>> dt.datetime.strptime('31/01/22 23:59:59.999999',\n" @@ -4110,12 +4763,19 @@ msgid "" ">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" "'Mon 31 Jan 2022, 11:59PM'" msgstr "" +">>> import datetime as dt\n" +">>> dt.datetime.strptime('31/01/22 23:59:59.999999',\n" +"... '%d/%m/%y %H:%M:%S.%f')\n" +"datetime.datetime(2022, 1, 31, 23, 59, 59, 999999)\n" +">>> _.strftime('%a %d %b %Y, %I:%M%p')\n" +"'Mon 31 Jan 2022, 11:59PM'" -#: ../../library/datetime.rst:2537 msgid "" "The following is a list of all the format codes that the 2011 C standard " "requires, and these work on all supported platforms." msgstr "" +"以下は、2011 年の C 標準で必須とされるすべての書式コードの一覧であり、サポー" +"トされるすべてのプラットフォームで動作します。" #: ../../library/datetime.rst:2541 ../../library/datetime.rst:2696 msgid "Directive" @@ -4213,24 +4873,19 @@ msgstr "Tue Aug 16 21:30:00 1988 (en_US);" msgid "Di 16 Aug 21:30:00 1988 (de_DE)" msgstr "Di 16 Aug 21:30:00 1988 (de_DE)" -#: ../../library/datetime.rst:2569 msgid "``%C``" -msgstr "" +msgstr "``%C``" -#: ../../library/datetime.rst:2569 msgid "" "The year divided by 100 and truncated to an integer as a zero-padded decimal " "number." -msgstr "" +msgstr "年を 100 で割り、小数部分を切り捨てた整数をゼロ埋めした 10 進数。" -#: ../../library/datetime.rst:2569 msgid "01, 02, ..., 99" -msgstr "" +msgstr "01, 02, ..., 99" -#: ../../library/datetime.rst:2569 ../../library/datetime.rst:2585 -#: ../../library/datetime.rst:2595 msgid "\\(0)" -msgstr "" +msgstr "\\(0)" #: ../../library/datetime.rst:2573 msgid "``%d``" @@ -4244,21 +4899,17 @@ msgstr "0埋めした10進数で表記した月中の日にち。" msgid "01, 02, ..., 31" msgstr "01, 02, ..., 31" -#: ../../library/datetime.rst:2573 msgid "\\(9), \\(10)" -msgstr "" +msgstr "\\(9), \\(10)" -#: ../../library/datetime.rst:2576 msgid "``%D``" -msgstr "" +msgstr "``%D``" -#: ../../library/datetime.rst:2576 msgid "Equivalent to ``%m/%d/%y``." -msgstr "" +msgstr "``%m/%d/%y`` と等価。" -#: ../../library/datetime.rst:2576 msgid "11/28/25" -msgstr "" +msgstr "11/28/25" #: ../../library/datetime.rst:2576 ../../library/datetime.rst:2597 #: ../../library/datetime.rst:2600 ../../library/datetime.rst:2603 @@ -4267,43 +4918,36 @@ msgstr "" msgid "\\(9)" msgstr "\\(9)" -#: ../../library/datetime.rst:2579 msgid "``%e``" -msgstr "" +msgstr "``%e``" -#: ../../library/datetime.rst:2579 msgid "The day of the month as a space-padded decimal number." -msgstr "" +msgstr "月内の日を空白埋めした 10 進数。" -#: ../../library/datetime.rst:2579 msgid "␣1, ␣2, ..., 31" -msgstr "" +msgstr "␣1, ␣2, ..., 31" -#: ../../library/datetime.rst:2579 msgid "\\(10)" -msgstr "" +msgstr "\\(10)" #: ../../library/datetime.rst:2582 msgid "``%F``" msgstr "``%F``" -#: ../../library/datetime.rst:2582 msgid "Equivalent to ``%Y-%m-%d``, the ISO 8601 format." -msgstr "" +msgstr "ISO 8601 形式の ``%Y-%m-%d`` と等価。" -#: ../../library/datetime.rst:2582 msgid "2025-10-11, 1001-12-30" -msgstr "" +msgstr "2025-10-11, 1001-12-30" #: ../../library/datetime.rst:2585 msgid "``%g``" msgstr "``%g``" -#: ../../library/datetime.rst:2585 msgid "" "Last 2 digits of ISO 8601 year representing the year that contains the " "greater part of the ISO week (``%V``)." -msgstr "" +msgstr "ISO 週 (``%V``) の大半が属する年を表す ISO 8601 年の下 2 桁。" #: ../../library/datetime.rst:2585 ../../library/datetime.rst:2671 msgid "00, 01, ..., 99" @@ -4327,17 +4971,14 @@ msgstr "0001, 0002, ..., 2013, 2014, ..., 9998, 9999" msgid "\\(8)" msgstr "\\(8)" -#: ../../library/datetime.rst:2595 msgid "``%h``" -msgstr "" +msgstr "``%h``" -#: ../../library/datetime.rst:2595 msgid "Equivalent to ``%b``." -msgstr "" +msgstr "``%b`` と等価。" -#: ../../library/datetime.rst:2595 msgid "See ``%b``." -msgstr "" +msgstr "``%b`` を参照。" #: ../../library/datetime.rst:2597 msgid "``%H``" @@ -4395,15 +5036,15 @@ msgstr "0埋めした10進数で表記した分。" msgid "00, 01, ..., 59" msgstr "00, 01, ..., 59" -#: ../../library/datetime.rst:2612 msgid "``%n``" -msgstr "" +msgstr "``%n``" -#: ../../library/datetime.rst:2612 msgid "" "The newline character (``'\\n'``). For :meth:`!strptime`, zero or more " "whitespace." msgstr "" +"改行文字 (``'\\n'``)。\n" +":meth:`!strptime` では 0 個以上の空白文字。" #: ../../library/datetime.rst:2612 msgid "``\\n``" @@ -4429,33 +5070,26 @@ msgstr "am, pm (de_DE)" msgid "\\(1), \\(3)" msgstr "\\(1), \\(3)" -#: ../../library/datetime.rst:2620 msgid "``%r``" -msgstr "" +msgstr "``%r``" -#: ../../library/datetime.rst:2620 msgid "Locale's 12-hour clock time." -msgstr "" +msgstr "ロケールの 12 時間制の時刻。" -#: ../../library/datetime.rst:2620 msgid "12:00:00 AM" -msgstr "" +msgstr "12:00:00 AM" -#: ../../library/datetime.rst:2620 msgid "\\(1), \\(0)" -msgstr "" +msgstr "\\(1), \\(0)" -#: ../../library/datetime.rst:2623 msgid "``%R``" -msgstr "" +msgstr "``%R``" -#: ../../library/datetime.rst:2623 msgid "Equivalent to ``%H:%M``." -msgstr "" +msgstr "``%H:%M`` と等価。" -#: ../../library/datetime.rst:2623 msgid "10:01" -msgstr "" +msgstr "10:01" #: ../../library/datetime.rst:2625 msgid "``%S``" @@ -4469,31 +5103,28 @@ msgstr "0埋めした10進数で表記した秒。" msgid "\\(4), \\(9)" msgstr "\\(4), \\(9)" -#: ../../library/datetime.rst:2628 msgid "``%t``" -msgstr "" +msgstr "``%t``" -#: ../../library/datetime.rst:2628 msgid "" "The tab character (``'\\t'``). For :meth:`!strptime`, zero or more " "whitespace." msgstr "" +"タブ文字 (``'\\t'``)。\n" +":meth:`!strptime` では 0 個以上の空白文字。" #: ../../library/datetime.rst:2628 msgid "``\\t``" msgstr "``\\t``" -#: ../../library/datetime.rst:2632 msgid "``%T``" -msgstr "" +msgstr "``%T``" -#: ../../library/datetime.rst:2632 msgid "ISO 8601 time format, equivalent to ``%H:%M:%S``." -msgstr "" +msgstr "ISO 8601 の時刻形式で、``%H:%M:%S`` と等価。" -#: ../../library/datetime.rst:2632 msgid "10:01:59" -msgstr "" +msgstr "10:01:59" #: ../../library/datetime.rst:2635 msgid "``%u``" @@ -4671,19 +5302,23 @@ msgstr "文字 ``'%'`` を表します。" msgid "%" msgstr "%" -#: ../../library/datetime.rst:2688 msgid "" "The ISO 8601 year and ISO 8601 week directives are not interchangeable with " "the year and week number directives above. Calling :meth:`~.datetime." "strptime` with incomplete or ambiguous ISO 8601 directives will raise a :exc:" "`ValueError`." msgstr "" +"ISO 8601 の年と週の指定子は、上記の年と週番号の指定子と交換可能ではありませ" +"ん。\n" +"不完全または曖昧な ISO 8601 指定子を指定して :meth:`~.datetime.strptime` を呼" +"び出すと、:exc:`ValueError` を送出します。" -#: ../../library/datetime.rst:2692 msgid "" "Several additional directives not required by the C11 standard are included " "for convenience." msgstr "" +"利便性のために、C11 標準で必須とされていない追加の指定子もいくつか含まれてい" +"ます。" #: ../../library/datetime.rst:2698 msgid "``%f``" @@ -4738,19 +5373,18 @@ msgstr "" msgid "``%G``, ``%u`` and ``%V`` were added." msgstr "``%G``, ``%u`` および ``%V`` が追加されました。" -#: ../../library/datetime.rst:2717 msgid "``%:z`` was added for :meth:`~.datetime.strftime`." -msgstr "" +msgstr ":meth:`~.datetime.strftime` に ``%:z`` が追加されました。" -#: ../../library/datetime.rst:2720 msgid "" "``%D``, ``%F``, ``%n``, ``%t``, and ``%:z`` were added for :meth:`~.datetime." "strptime`." msgstr "" +":meth:`~.datetime.strptime` に ``%D``、``%F``、``%n``、``%t``、``%:z`` が追加" +"されました。" -#: ../../library/datetime.rst:2726 msgid "Technical detail" -msgstr "" +msgstr "技術的な詳細" #: ../../library/datetime.rst:2728 msgid "" @@ -4762,30 +5396,38 @@ msgstr "" "strftime(fmt, d.timetuple())`` のように動作します。ただし全てのオブジェクト" "が :meth:`~date.timetuple` メソッドをサポートしているわけではありません。" -#: ../../library/datetime.rst:2732 msgid "" "For the :meth:`.datetime.strptime` and :meth:`.date.strptime` class methods, " "the default value is ``1900-01-01T00:00:00.000``: any components not " "specified in the format string will be pulled from the default value." msgstr "" +"クラスメソッド :meth:`.datetime.strptime` と :meth:`.date.strptime` のデフォ" +"ルト値は ``1900-01-01T00:00:00.000`` です。\n" +"書式文字列で指定されていない成分には、このデフォルト値が使われます。" -#: ../../library/datetime.rst:2737 msgid "" "Format strings without separators can be ambiguous for parsing. For example, " "with ``%Y%m%d``, the string ``2026111`` may be parsed either as " "``2026-11-01`` or as ``2026-01-11``. Use separators to ensure the input is " "parsed as intended." msgstr "" +"区切り文字を含まない書式文字列は、解析時に曖昧になる場合があります。\n" +"例えば、``%Y%m%d`` を使うと、文字列 ``2026111`` は ``2026-11-01`` とも " +"``2026-01-11`` とも解析できます。\n" +"入力が意図どおりに解析されるよう、区切り文字を使用してください。" -#: ../../library/datetime.rst:2743 msgid "" "When used to parse partial dates lacking a year, :meth:`.datetime.strptime` " "and :meth:`.date.strptime` will raise when encountering February 29 because " "the default year of 1900 is *not* a leap year. Always add a default leap " "year to partial date strings before parsing." msgstr "" +"年を欠いた日付の一部を解析する際、:meth:`.datetime.strptime` と :meth:`.date." +"strptime` は 2 月 29 日に対して例外を送出します。\n" +"デフォルトの年である 1900 年がうるう年 *ではない* ためです。\n" +"日付の一部を表す文字列には、解析する前に必ずデフォルトのうるう年を追加してく" +"ださい。" -#: ../../library/datetime.rst:2763 msgid "" ">>> import datetime as dt\n" ">>> value = \"2/29\"\n" @@ -4796,30 +5438,38 @@ msgid "" ">>> dt.datetime.strptime(f\"1904 {value}\", \"%Y %m/%d\")\n" "datetime.datetime(1904, 2, 29, 0, 0)" msgstr "" +">>> import datetime as dt\n" +">>> value = \"2/29\"\n" +">>> dt.datetime.strptime(value, \"%m/%d\")\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: day 29 must be in range 1..28 for month 2 in year 1900\n" +">>> dt.datetime.strptime(f\"1904 {value}\", \"%Y %m/%d\")\n" +"datetime.datetime(1904, 2, 29, 0, 0)" #: ../../library/datetime.rst:2774 msgid "Using ``datetime.strptime(date_string, format)`` is equivalent to::" msgstr "``datetime.strptime(date_string, format)`` は次の式と等価です::" -#: ../../library/datetime.rst:2778 msgid "" "except when the format includes sub-second components or time zone offset " "information, which are supported in ``datetime.strptime`` but are discarded " "by ``time.strptime``." msgstr "" -"ただし、 ``datetime.strptime`` はサポートしているが ``time.strptime`` には無" -"い、秒未満の単位やタイムゾーンオフセットの情報が format に 含まれているときは" -"除きます。" +"ただし、書式 ``format`` に秒未満の成分やタイムゾーンオフセットの情報が含まれ" +"る場合は除きます。\n" +"これらの情報は ``datetime.strptime`` ではサポートされますが、``time." +"strptime`` では破棄されます。" -#: ../../library/datetime.rst:2782 msgid "" "For :class:`.time` objects, the format codes for year, month, and day should " "not be used, as :class:`!time` objects have no such values. If they're used " "anyway, 1900 is substituted for the year, and 1 for the month and day." msgstr "" -":class:`.time` オブジェクトには、年、月、日の値がないため、それらを書式コード" -"を使うことができません。\n" -"無理矢理使った場合、年は1900に置き換えられ、月と日は1に置き換えられます。" +":class:`.time` オブジェクトでは、年、月、日の書式コードは使用すべきではありま" +"せん。\n" +":class:`!time` オブジェクトはこれらの値を持たないためです。\n" +"使用した場合、年には 1900、月と日には 1 が代入されます。" #: ../../library/datetime.rst:2786 msgid "" @@ -4827,9 +5477,9 @@ msgid "" "microseconds should not be used, as :class:`date` objects have no such " "values. If they're used anyway, 0 is substituted for them." msgstr "" -":class:`date` オブジェクトには、時、分、秒、マイクロ秒の値がないため、それら" -"の書式コードを使うことができません。\n" -"無理矢理使った場合、これらの値は0に置き換えられます。" +":class:`date` オブジェクトに時、分、秒、マイクロ秒の書式コードを使うべきでは" +"ありません。:class:`date` オブジェクトはこれらの値を持たないためです。使用し" +"た場合は、これらの値に 0 が代入されます。" #: ../../library/datetime.rst:2790 msgid "" @@ -4845,18 +5495,22 @@ msgstr "" "方、他のプラットフォームでは ``strftime`` が :exc:`UnicodeError` を送出した" "り、その代わりに空文字列を返したりするかもしれません。" -#: ../../library/datetime.rst:2799 msgid "" "This format code is currently unsupported by :meth:`~.datetime.strptime`." msgstr "" +"この書式コードは、現在 :meth:`~.datetime.strptime` ではサポートされていませ" +"ん。" -#: ../../library/datetime.rst:2802 msgid "" "Because the format depends on the current locale, care should be taken when " "making assumptions about the output value. Field orderings will vary (for " "example, \"month/day/year\" versus \"day/month/year\"), and the output may " "contain non-ASCII characters." msgstr "" +"書式は現在のロケールに依存するため、出力値について仮定する際は注意してくださ" +"い。\n" +"フィールドの順序は (例えば「月/日/年」と「日/月/年」のように) 異なり、出力に" +"非 ASCII 文字が含まれる場合があります。" #: ../../library/datetime.rst:2808 msgid "" @@ -4883,15 +5537,13 @@ msgstr "" "バージョン 3.2 では、 :meth:`~.datetime.strftime` メソッドは years >= 1000 の" "範囲の年数しか扱えませんでした。" -#: ../../library/datetime.rst:2820 msgid "" "When used with the :meth:`~.datetime.strptime` method, the ``%p`` directive " "only affects the output hour field if the ``%I`` directive is used to parse " "the hour." msgstr "" -":meth:`~.datetime.strptime` メソッドと共に使われた場合、 ``%p`` 指定子は出力" -"の時間フィールドのみに影響し、 ``%I`` 指定子が使われたかのように振る舞いま" -"す。" +":meth:`~.datetime.strptime` メソッドで ``%p`` 指定子が出力の時フィールドに影" +"響するのは、時の解析に ``%I`` 指定子を使う場合だけです。" #: ../../library/datetime.rst:2824 msgid "" @@ -4948,7 +5600,6 @@ msgstr "" "例えば、 :meth:`~.datetime.utcoffset` が ``timedelta(hours=-3, " "minutes=-30)`` を返す場合、 ``%z`` は文字列 ``'-0330'`` に置き換えられます。" -#: ../../library/datetime.rst:2855 msgid "" "When the ``%z`` directive is provided to the :meth:`~.datetime.strptime` " "method, the UTC offsets can have a colon as a separator between hours, " @@ -4956,20 +5607,30 @@ msgid "" "will be parsed as an offset of one hour. In addition, providing ``'Z'`` is " "identical to ``'+00:00'``." msgstr "" +":meth:`~.datetime.strptime` メソッドに ``%z`` 指定子を指定した場合、UTC オフ" +"セットの時、分、秒の区切りにコロンを使えるようになりました。\n" +"例えば、``'+010000'`` と ``'+01:00:00'`` はどちらも 1 時間のオフセットとして" +"解析されます。\n" +"また、``'Z'`` の指定は ``'+00:00'`` と等価です。" -#: ../../library/datetime.rst:2863 msgid "" "When used with :meth:`~.datetime.strftime`, behaves exactly as ``%z``, " "except that a colon separator is added between hours, minutes and seconds." msgstr "" +":meth:`~.datetime.strftime` で使用すると、時、分、秒の間にコロン区切りが追加" +"される点を除き、``%z`` とまったく同じように動作します。" -#: ../../library/datetime.rst:2866 msgid "" "When used with :meth:`~.datetime.strptime`, the UTC offset is *required* to " "have a colon as a separator between hours, minutes and seconds. For example, " "``'+01:00:00'`` (but *not* ``'+010000'``) will be parsed as an offset of one " "hour. In addition, providing ``'Z'`` is identical to ``'+00:00'``." msgstr "" +":meth:`~.datetime.strptime` で使用する場合、UTC オフセットの時、分、秒の区切" +"りにはコロンが *必須* です。\n" +"例えば、``'+01:00:00'`` は 1 時間のオフセットとして解析されますが、" +"``'+010000'`` は解析 *されません*。\n" +"また、``'Z'`` の指定は ``'+00:00'`` と等価です。" #: ../../library/datetime.rst:2873 msgid "" @@ -5045,7 +5706,6 @@ msgstr "" "任意です。\n" "書式 ``%y`` では先行ゼロは必須です。" -#: ../../library/datetime.rst:2908 msgid "" "When parsing a month and day using :meth:`~.datetime.strptime`, always " "include a year in the format. If the value you need to parse lacks a year, " @@ -5053,32 +5713,41 @@ msgid "" "exception when it encounters leap day because the default year used by the " "parser (1900) is not a leap year. Users run into that bug every leap year." msgstr "" +":meth:`~.datetime.strptime` で月と日を解析する場合は、常に書式に年を含めてく" +"ださい。\n" +"解析する値に年がない場合は、ダミーのうるう年を明示的に追加してください。\n" +"そうしないと、パーサが使用するデフォルトの年 (1900 年) はうるう年ではないた" +"め、コードがうるう日に対して例外を送出します。\n" +"ユーザーはうるう年ごとにこのバグに遭遇します。" -#: ../../library/datetime.rst:2914 msgid "" ">>> month_day = \"02/29\"\n" ">>> dt.datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # No leap " "year bug.\n" "datetime.datetime(1984, 2, 29, 0, 0)" msgstr "" +">>> month_day = \"02/29\"\n" +">>> dt.datetime.strptime(f\"{month_day};1984\", \"%m/%d;%Y\") # うるう年のバ" +"グは起きない。\n" +"datetime.datetime(1984, 2, 29, 0, 0)" -#: ../../library/datetime.rst:2920 msgid "Using ``%d`` without a year now raises :exc:`ValueError`." msgstr "" +"年なしで ``%d`` を使用すると、:exc:`ValueError` を送出するようになりました。" -#: ../../library/datetime.rst:2923 msgid "" ":meth:`~.datetime.strptime` calls using a format string containing ``%e`` " "without a year now emit a :exc:`DeprecationWarning`." msgstr "" +"年なしで ``%e`` を含む書式文字列を使用して :meth:`~.datetime.strptime` を呼び" +"出すと、:exc:`DeprecationWarning` を出すようになりました。" #: ../../library/datetime.rst:2928 msgid "Footnotes" msgstr "脚注" -#: ../../library/datetime.rst:2929 msgid "If, that is, we ignore the effects of relativity." -msgstr "" +msgstr "ただし、相対論の効果を無視した場合です。" #: ../../library/datetime.rst:2931 msgid "" @@ -5108,6 +5777,5 @@ msgstr "" msgid "% (percent)" msgstr "% (パーセント)" -#: ../../library/datetime.rst:2493 msgid "datetime format" -msgstr "" +msgstr "日時の書式" diff --git a/library/dbm.po b/library/dbm.po index 8f7b50b92..fc8e283d2 100644 --- a/library/dbm.po +++ b/library/dbm.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/dbm.rst:2 @@ -31,36 +31,39 @@ msgstr ":mod:`!dbm` --- Unix \"データベース\" へのインターフェー msgid "**Source code:** :source:`Lib/dbm/__init__.py`" msgstr "**ソースコード:** :source:`Lib/dbm/__init__.py`" -#: ../../library/dbm.rst:11 msgid ":mod:`!dbm` is a generic interface to variants of the DBM database:" msgstr "" +":mod:`!dbm` は DBM データベースの各種実装に対する汎用インターフェースです:" -#: ../../library/dbm.rst:13 msgid ":mod:`dbm.sqlite3`" -msgstr "" +msgstr ":mod:`dbm.sqlite3`" -#: ../../library/dbm.rst:14 msgid ":mod:`dbm.gnu`" -msgstr "" +msgstr ":mod:`dbm.gnu`" -#: ../../library/dbm.rst:15 msgid ":mod:`dbm.ndbm`" -msgstr "" +msgstr ":mod:`dbm.ndbm`" -#: ../../library/dbm.rst:17 msgid "" "If none of these modules are installed, the slow-but-simple implementation " "in module :mod:`dbm.dumb` will be used. There is a `third party interface " "`_ to the Oracle Berkeley DB." msgstr "" +"これらのモジュールがどれもインストールされていない場合は、低速ながら単純な :" +"mod:`dbm.dumb` モジュールの実装を使います。\n" +"Oracle Berkeley DB には `サードパーティー製インターフェース `_ があります。" -#: ../../library/dbm.rst:23 msgid "" "None of the underlying modules will automatically shrink the disk space used " "by the database file. However, :mod:`dbm.sqlite3`, :mod:`dbm.gnu` and :mod:" "`dbm.dumb` provide a :meth:`!reorganize` method that can be used for this " "purpose." msgstr "" +"内部で使うモジュールはどれも、データベースファイルが使うディスク領域を自動で" +"は縮小しません。\n" +"ただし :mod:`dbm.sqlite3`、:mod:`dbm.gnu`、:mod:`dbm.dumb` には、領域の縮小に" +"使える :meth:`!reorganize` メソッドがあります。" #: ../../library/dbm.rst:30 msgid "" @@ -71,101 +74,92 @@ msgstr "" "サポートされているモジュールそれぞれによって送出される可能性のある例外を含む" "タプル。これにはユニークな例外があり、最初の要素として同じく :exc:`dbm." "error` という名前の例外が含まれます --- :exc:`dbm.error` が送出される場合、後" -"者(訳注:タプルの ``dbm.error`` ではなく例外 :exc:`dbm.error`)が使用されます。" +"者(訳注:タプルの ``dbm.error`` ではなく例外 ``dbm.error``)が使用されます。" -#: ../../library/dbm.rst:37 msgid "" "This function attempts to guess which of the several simple database modules " "available --- :mod:`dbm.sqlite3`, :mod:`dbm.gnu`, :mod:`dbm.ndbm`, or :mod:" "`dbm.dumb` --- should be used to open a given file." msgstr "" +"指定されたファイルを開くために、利用可能な単純なデータベースモジュール :mod:" +"`dbm.sqlite3`、:mod:`dbm.gnu`、:mod:`dbm.ndbm`、:mod:`dbm.dumb` のどれを使う" +"べきか推測します。" -#: ../../library/dbm.rst:41 msgid "Return one of the following values:" -msgstr "" +msgstr "次のいずれかの値を返します:" -#: ../../library/dbm.rst:43 msgid "" "``None`` if the file can't be opened because it's unreadable or doesn't exist" -msgstr "" +msgstr "ファイルが読み取り不能か存在しないため開けない場合は ``None``" -#: ../../library/dbm.rst:44 msgid "the empty string (``''``) if the file's format can't be guessed" -msgstr "" +msgstr "ファイル形式を推測できない場合は空文字列 (``''``)" -#: ../../library/dbm.rst:45 msgid "" "a string containing the required module name, such as ``'dbm.ndbm'`` or " "``'dbm.gnu'``" -msgstr "" +msgstr "``'dbm.ndbm'`` や ``'dbm.gnu'`` など、必要なモジュール名の文字列" -#: ../../library/dbm.rst:47 ../../library/dbm.rst:288 ../../library/dbm.rst:499 msgid "*filename* accepts a :term:`path-like object`." -msgstr "" +msgstr "*filename* に :term:`path-like object` を渡せるようになりました。" -#: ../../library/dbm.rst:71 msgid "Open a database and return the corresponding database object." -msgstr "" +msgstr "データベースを開き、対応するデータベースオブジェクトを返します。" #: ../../library/dbm.rst:0 msgid "Parameters" msgstr "パラメーター" -#: ../../library/dbm.rst:73 msgid "" "The database file to open. If the database file already exists, the :func:" "`whichdb` function is used to determine its type and the appropriate module " "is used; if it does not exist, the first submodule listed above that can be " "imported is used." msgstr "" +"開くデータベースファイル。\n" +"データベースファイルがすでに存在する場合は :func:`whichdb` 関数で種類を判定" +"し、適切なモジュールを使います。\n" +"存在しない場合は、上に挙げたサブモジュールのうち最初にインポートできたものを" +"使います。" -#: ../../library/dbm.rst:74 ../../library/dbm.rst:260 msgid "The database file to open." -msgstr "" +msgstr "開くデータベースファイル。" -#: ../../library/dbm.rst:76 msgid "" "If the database file already exists, the :func:`whichdb` function is used to " "determine its type and the appropriate module is used; if it does not exist, " "the first submodule listed above that can be imported is used." msgstr "" +"データベースファイルがすでに存在する場合は :func:`whichdb` 関数で種類を判定" +"し、適切なモジュールを使います。\n" +"存在しない場合は、上に挙げたサブモジュールのうち最初にインポートできたものを" +"使います。" -#: ../../library/dbm.rst:81 ../../library/dbm.rst:187 ../../library/dbm.rst:397 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n|" msgstr "" +"* ``'r'`` (デフォルト): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " +"``'n'``: |flag_n|" -#: ../../library/dbm.rst:82 ../../library/dbm.rst:189 ../../library/dbm.rst:265 -#: ../../library/dbm.rst:398 msgid "``'r'`` (default): |flag_r|" -msgstr "" +msgstr "``'r'`` (デフォルト): |flag_r|" -#: ../../library/dbm.rst:83 ../../library/dbm.rst:190 ../../library/dbm.rst:266 -#: ../../library/dbm.rst:399 ../../library/dbm.rst:475 msgid "``'w'``: |flag_w|" -msgstr "" +msgstr "``'w'``: |flag_w|" -#: ../../library/dbm.rst:84 ../../library/dbm.rst:191 ../../library/dbm.rst:267 -#: ../../library/dbm.rst:400 msgid "``'c'``: |flag_c|" -msgstr "" +msgstr "``'c'``: |flag_c|" -#: ../../library/dbm.rst:85 ../../library/dbm.rst:192 ../../library/dbm.rst:268 -#: ../../library/dbm.rst:401 ../../library/dbm.rst:477 msgid "``'n'``: |flag_n|" -msgstr "" +msgstr "``'n'``: |flag_n|" -#: ../../library/dbm.rst:87 ../../library/dbm.rst:282 ../../library/dbm.rst:403 -#: ../../library/dbm.rst:479 msgid "|mode_param_doc|" -msgstr "" +msgstr "|mode_param_doc|" -#: ../../library/dbm.rst:90 msgid "*file* accepts a :term:`path-like object`." -msgstr "" +msgstr "*file* に :term:`path-like object` を渡せるようになりました。" -#: ../../library/dbm.rst:93 msgid "" "The object returned by :func:`~dbm.open` supports the basic functionality of " "mutable :term:`mappings `; keys and their corresponding values can " @@ -174,6 +168,13 @@ msgid "" "clear` are available. The :meth:`!keys` method returns a list instead of a " "view object. The :meth:`!setdefault` method requires two arguments." msgstr "" +":func:`~dbm.open` が返すオブジェクトは、ミュータブルな :term:`マッピング " +"` の基本的な機能に対応しています。\n" +"キーとそれに対応する値の保存、取得、削除に加え、イテレーション、:keyword:" +"`in` 演算子、:meth:`!keys`、:meth:`!get`、:meth:`!setdefault`、:meth:`!" +"clear` メソッドを利用できます。\n" +":meth:`!keys` メソッドはビューオブジェクトではなくリストを返します。\n" +":meth:`!setdefault` メソッドには引数が 2 つ必要です。" #: ../../library/dbm.rst:101 msgid "" @@ -190,27 +191,31 @@ msgstr "" "これらのオブジェクトは、 :keyword:`with` 文での使用にも対応しています。with " "文を使用した場合、終了時に自動的に閉じられます。" -#: ../../library/dbm.rst:108 msgid "" ":meth:`!get` and :meth:`!setdefault` methods are now available for all :mod:" "`!dbm` backends." msgstr "" +"すべての :mod:`!dbm` バックエンドで :meth:`!get` と :meth:`!setdefault` メ" +"ソッドが使えるようになりました。" -#: ../../library/dbm.rst:112 msgid "" "Added native support for the context management protocol to the objects " "returned by :func:`~dbm.open`." msgstr "" +":func:`~dbm.open` が返すオブジェクトに、コンテキスト管理プロトコルのネイティ" +"ブサポートを追加しました。" -#: ../../library/dbm.rst:116 msgid "" "Deleting a key from a read-only database raises a database module specific " "exception instead of :exc:`KeyError`." msgstr "" +"読み取り専用データベースからキーを削除すると、:exc:`KeyError` ではなくデータ" +"ベースモジュール固有の例外を送出するようになりました。" -#: ../../library/dbm.rst:120 msgid ":meth:`!clear` methods are now available for all :mod:`!dbm` backends." msgstr "" +"すべての :mod:`!dbm` バックエンドで :meth:`!clear` メソッドが使えるようになり" +"ました。" #: ../../library/dbm.rst:124 msgid "" @@ -259,26 +264,25 @@ msgstr "非文字列データを記録する永続化モジュール。" msgid "The individual submodules are described in the following sections." msgstr "個々のサブモジュールは以降の節で説明されます。" -#: ../../library/dbm.rst:161 msgid ":mod:`!dbm.sqlite3` --- SQLite backend for dbm" -msgstr "" +msgstr ":mod:`!dbm.sqlite3` --- dbm の SQLite バックエンド" -#: ../../library/dbm.rst:168 msgid "**Source code:** :source:`Lib/dbm/sqlite3.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/dbm/sqlite3.py`" -#: ../../library/dbm.rst:172 msgid "" "This module uses the standard library :mod:`sqlite3` module to provide an " "SQLite backend for the :mod:`!dbm` module. The files created by :mod:`!dbm." "sqlite3` can thus be opened by :mod:`sqlite3`, or any other SQLite browser, " "including the SQLite CLI." msgstr "" +"このモジュールは標準ライブラリの :mod:`sqlite3` モジュールを使い、:mod:`!" +"dbm` モジュール用の SQLite バックエンドを提供します。\n" +"したがって :mod:`!dbm.sqlite3` で作成したファイルは :mod:`sqlite3` や、" +"SQLite CLI を含む他の SQLite ブラウザーで開けます。" -#: ../../library/dbm.rst:243 ../../library/dbm.rst:375 -#: ../../includes/wasm-mobile-notavail.rst:3 ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -288,72 +292,80 @@ msgstr "" "このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、:ref:" "`wasm-availability` を見てください。" -#: ../../library/dbm.rst:181 msgid "Open an SQLite database." -msgstr "" +msgstr "SQLite データベースを開きます。" -#: ../../library/dbm.rst:183 msgid "The path to the database to be opened." -msgstr "" +msgstr "開くデータベースのパス。" -#: ../../library/dbm.rst:194 msgid "" "The Unix file access mode of the file (default: octal ``0o666``), used only " "when the database has to be created." msgstr "" +"ファイルの Unix アクセスモード (デフォルトは 8 進数の ``0o666``)。\n" +"データベースを新規作成する必要がある場合にのみ使います。" -#: ../../library/dbm.rst:198 msgid "" "The returned database object behaves similar to a mutable :term:`mapping`, " "but the :meth:`!keys` method returns a list, and the :meth:`!setdefault` " "method requires two arguments. It also supports a \"closing\" context " "manager via the :keyword:`with` keyword." msgstr "" +"返されるデータベースオブジェクトはミュータブルな :term:`mapping` に似ています" +"が、:meth:`!keys` メソッドはリストを返し、:meth:`!setdefault` メソッドには引" +"数が 2 つ必要です。\n" +"また :keyword:`with` キーワードによって、終了時にデータベースを閉じるコンテキ" +"ストマネージャとして使えます。" -#: ../../library/dbm.rst:203 ../../library/dbm.rst:304 -#: ../../library/dbm.rst:507 msgid "The following methods are also provided:" -msgstr "" +msgstr "次のメソッドも提供します:" -#: ../../library/dbm.rst:207 msgid "Close the SQLite database." -msgstr "" +msgstr "SQLite データベースを閉じます。" -#: ../../library/dbm.rst:211 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used on disk, this method will reorganize the database; otherwise, " "deleted file space will be kept and reused as new (key, value) pairs are " "added." msgstr "" +"多数の削除を行った後、ディスク上の使用領域を縮小したい場合に、このメソッドで" +"データベースを再編成できます。\n" +"再編成しない場合、削除されたファイル領域はそのまま残り、新しい (key, value) " +"ペアを追加したときに再利用されます。" -#: ../../library/dbm.rst:216 msgid "" "While reorganizing, as much as two times the size of the original database " "is required in free disk space. However, be aware that this factor changes " "for each :mod:`!dbm` submodule." msgstr "" +"再編成中は、元のデータベースのサイズの最大 2 倍の空きディスク領域が必要で" +"す。\n" +"ただし、この倍率は :mod:`!dbm` のサブモジュールごとに異なります。" -#: ../../library/dbm.rst:223 msgid ":mod:`!dbm.gnu` --- GNU database manager" -msgstr "" +msgstr ":mod:`!dbm.gnu` --- GNU データベースマネージャ" #: ../../library/dbm.rst:228 msgid "**Source code:** :source:`Lib/dbm/gnu.py`" msgstr "**ソースコード:** :source:`Lib/dbm/gnu.py`" -#: ../../library/dbm.rst:232 msgid "" "The :mod:`!dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU " "dbm)` library, similar to the :mod:`dbm.ndbm` module, but with additional " "functionality like crash tolerance." msgstr "" +":mod:`!dbm.gnu` モジュールは :abbr:`GDBM (GNU dbm)` ライブラリへのインター" +"フェースを提供します。\n" +":mod:`dbm.ndbm` モジュールに似ていますが、クラッシュへの耐性などの機能が追加" +"されています。" -#: ../../library/dbm.rst:238 msgid "" "The file formats created by :mod:`!dbm.gnu` and :mod:`dbm.ndbm` are " "incompatible and can not be used interchangeably." msgstr "" +":mod:`!dbm.gnu` と :mod:`dbm.ndbm` が作成するファイル形式には互換性がなく、相" +"互に利用できません。" #: ../../includes/wasm-mobile-notavail.rst:5 msgid "" @@ -363,24 +375,24 @@ msgstr "" "このモジュールは :ref:`モバイルプラットフォーム ` と :" "ref:`WebAssemblyプラットフォーム ` をサポートしません。" -#: ../../library/dbm.rst:247 msgid "" "Raised on :mod:`!dbm.gnu`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" +"I/O エラーなど、:mod:`!dbm.gnu` 固有のエラーで送出されます。\n" +"不正なキーの指定など、一般的なマッピングのエラーでは :exc:`KeyError` を送出し" +"ます。" -#: ../../library/dbm.rst:253 msgid "" "A string of characters the *flag* parameter of :meth:`~dbm.gnu.open` " "supports." msgstr "" +":meth:`~dbm.gnu.open` の *flag* パラメーターが受け付ける文字を並べた文字列。" -#: ../../library/dbm.rst:258 msgid "Open a GDBM database and return a :class:`!gdbm` object." -msgstr "" +msgstr "GDBM データベースを開き、:class:`!gdbm` オブジェクトを返します。" -#: ../../library/dbm.rst:264 msgid "" "* ``'r'`` (default): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " "``'n'``: |flag_n| The following additional characters may be appended to " @@ -391,44 +403,57 @@ msgid "" "versions of GDBM. See the :data:`open_flags` member for a list of supported " "flag characters." msgstr "" +"* ``'r'`` (デフォルト): |flag_r| * ``'w'``: |flag_w| * ``'c'``: |flag_c| * " +"``'n'``: |flag_n|\n" +"\n" +"次の文字を追加して、データベースを開く方法を制御できます:\n" +"\n" +"* ``'f'``: 高速モードでデータベースを開きます。\n" +" データベースへの書き込みは同期されません。\n" +"* ``'s'``: 同期モード。\n" +" データベースへの変更は直ちにファイルに書き込まれます。\n" +"* ``'u'``: データベースをロックしません。\n" +"\n" +"すべてのフラグが GDBM のすべてのバージョンで有効とは限りません。\n" +"サポートするフラグ文字の一覧は :data:`open_flags` メンバーを参照してくださ" +"い。" -#: ../../library/dbm.rst:270 msgid "" "The following additional characters may be appended to control how the " "database is opened:" -msgstr "" +msgstr "次の文字を追加して、データベースを開く方法を制御できます:" -#: ../../library/dbm.rst:273 msgid "" "``'f'``: Open the database in fast mode. Writes to the database will not be " "synchronized." msgstr "" +"``'f'``: 高速モードでデータベースを開きます。\n" +"データベースへの書き込みは同期されません。" -#: ../../library/dbm.rst:275 msgid "" "``'s'``: Synchronized mode. Changes to the database will be written " "immediately to the file." msgstr "" +"``'s'``: 同期モード。\n" +"データベースへの変更は直ちにファイルに書き込まれます。" -#: ../../library/dbm.rst:277 msgid "``'u'``: Do not lock database." -msgstr "" +msgstr "``'u'``: データベースをロックしません。" -#: ../../library/dbm.rst:279 msgid "" "Not all flags are valid for all versions of GDBM. See the :data:`open_flags` " "member for a list of supported flag characters." msgstr "" +"すべてのフラグが GDBM のすべてのバージョンで有効とは限りません。\n" +"サポートするフラグ文字の一覧は :data:`open_flags` メンバーを参照してくださ" +"い。" -#: ../../library/dbm.rst:0 msgid "Raises" -msgstr "" +msgstr "送出される例外" -#: ../../library/dbm.rst:285 msgid "If an invalid *flag* argument is passed." -msgstr "" +msgstr "不正な *flag* 引数が渡された場合。" -#: ../../library/dbm.rst:291 msgid "" ":class:`!gdbm` objects behave similar to mutable :term:`mappings `, " "but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " @@ -436,26 +461,33 @@ msgid "" "list, and the :meth:`!setdefault` method requires two arguments. It also " "supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" +":class:`!gdbm` オブジェクトはミュータブルな :term:`マッピング ` に似" +"ていますが、:meth:`!items`、:meth:`!values`、:meth:`!pop`、:meth:`!" +"popitem`、:meth:`!update` メソッドはサポートしていません。\n" +":meth:`!keys` メソッドはリストを返し、:meth:`!setdefault` メソッドには引数が " +"2 つ必要です。\n" +"また :keyword:`with` キーワードによって、終了時にデータベースを閉じるコンテキ" +"ストマネージャとして使えます。" -#: ../../library/dbm.rst:298 ../../library/dbm.rst:416 msgid "Added the :meth:`!get` and :meth:`!setdefault` methods." -msgstr "" +msgstr ":meth:`!get` と :meth:`!setdefault` メソッドを追加しました。" -#: ../../library/dbm.rst:301 ../../library/dbm.rst:419 msgid "Added the :meth:`!clear` method." -msgstr "" +msgstr ":meth:`!clear` メソッドを追加しました。" -#: ../../library/dbm.rst:308 msgid "Close the GDBM database." -msgstr "" +msgstr "GDBM データベースを閉じます。" -#: ../../library/dbm.rst:312 msgid "" "It's possible to loop over every key in the database using this method and " "the :meth:`nextkey` method. The traversal is ordered by GDBM's internal " "hash values, and won't be sorted by the key values. This method returns the " "starting key." msgstr "" +"このメソッドと :meth:`nextkey` メソッドを使って、データベースのすべてのキーを" +"順にたどれます。\n" +"走査の順序は GDBM 内部のハッシュ値に基づき、キーの値の順には並びません。\n" +"このメソッドは最初のキーを返します。" #: ../../library/dbm.rst:319 msgid "" @@ -467,15 +499,17 @@ msgstr "" "コードはデータベース ``db`` について、キー全てを含むリストをメモリ上に生成す" "ることなく全てのキーを出力します::" -#: ../../library/dbm.rst:323 msgid "" "k = db.firstkey()\n" "while k is not None:\n" " print(k)\n" " k = db.nextkey(k)" msgstr "" +"k = db.firstkey()\n" +"while k is not None:\n" +" print(k)\n" +" k = db.nextkey(k)" -#: ../../library/dbm.rst:330 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used by the GDBM file, this routine will reorganize the database. :" @@ -483,13 +517,21 @@ msgid "" "by using this reorganization; otherwise, deleted file space will be kept and " "reused as new (key, value) pairs are added." msgstr "" +"多数の削除を行った後、GDBM ファイルの使用領域を縮小したい場合に、このルーチン" +"でデータベースを再編成できます。\n" +":class:`!gdbm` オブジェクトは、この再編成以外の方法ではデータベースファイルの" +"長さを縮めません。\n" +"再編成しない場合、削除されたファイル領域はそのまま残り、新しい (key, value) " +"ペアを追加したときに再利用されます。" -#: ../../library/dbm.rst:337 msgid "" "While reorganizing, as much as one time the size of the original database is " "required in free disk space. However, be aware that this factor changes for " "each :mod:`!dbm` submodule." msgstr "" +"再編成中は、元のデータベースと同じサイズの空きディスク領域が必要になる場合が" +"あります。\n" +"ただし、この倍率は :mod:`!dbm` のサブモジュールごとに異なります。" #: ../../library/dbm.rst:342 msgid "" @@ -499,61 +541,69 @@ msgstr "" "データベースが高速モードで開かれていた場合、このメソッドはディスクにまだ書き" "込まれていないデータを全て書き込ませます。" -#: ../../library/dbm.rst:347 msgid ":mod:`!dbm.ndbm` --- New Database Manager" -msgstr "" +msgstr ":mod:`!dbm.ndbm` --- New Database Manager" #: ../../library/dbm.rst:352 msgid "**Source code:** :source:`Lib/dbm/ndbm.py`" msgstr "**ソースコード:** :source:`Lib/dbm/ndbm.py`" -#: ../../library/dbm.rst:356 msgid "" "The :mod:`!dbm.ndbm` module provides an interface to the :abbr:`NDBM (New " "Database Manager)` library. This module can be used with the \"classic\" " "NDBM interface or the :abbr:`GDBM (GNU dbm)` compatibility interface." msgstr "" +":mod:`!dbm.ndbm` モジュールは :abbr:`NDBM (New Database Manager)` ライブラリ" +"へのインターフェースを提供します。\n" +"このモジュールは「従来の」NDBM インターフェースでも :abbr:`GDBM (GNU dbm)` の" +"互換インターフェースでも利用できます。" -#: ../../library/dbm.rst:363 msgid "" "The file formats created by :mod:`dbm.gnu` and :mod:`!dbm.ndbm` are " "incompatible and can not be used interchangeably." msgstr "" +":mod:`dbm.gnu` と :mod:`!dbm.ndbm` が作成するファイル形式には互換性がなく、相" +"互に利用できません。" -#: ../../library/dbm.rst:368 msgid "" "The NDBM library shipped as part of macOS has an undocumented limitation on " "the size of values, which can result in corrupted database files when " "storing values larger than this limit. Reading such corrupted files can " "result in a hard crash (segmentation fault)." msgstr "" +"macOS に付属する NDBM ライブラリには、値のサイズに関する文書化されていない制" +"限があります。\n" +"この制限より大きな値を保存すると、データベースファイルが破損することがありま" +"す。\n" +"破損したファイルを読み取ると、プログラムがクラッシュ (セグメンテーション" +"フォールト) することがあります。" -#: ../../library/dbm.rst:379 msgid "" "Raised on :mod:`!dbm.ndbm`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" +"I/O エラーなど、:mod:`!dbm.ndbm` 固有のエラーで送出されます。\n" +"不正なキーの指定など、一般的なマッピングのエラーでは :exc:`KeyError` を送出し" +"ます。" -#: ../../library/dbm.rst:385 msgid "Name of the NDBM implementation library used." -msgstr "" +msgstr "使用している NDBM 実装ライブラリの名前。" -#: ../../library/dbm.rst:390 msgid "Open an NDBM database and return an :class:`!ndbm` object." -msgstr "" +msgstr "NDBM データベースを開き、:class:`!ndbm` オブジェクトを返します。" -#: ../../library/dbm.rst:392 msgid "" "The basename of the database file (without the :file:`.dir` or :file:`.pag` " "extensions)." msgstr "" +"データベースファイルのベース名 (:file:`.dir` や :file:`.pag` 拡張子は含めませ" +"ん)。" -#: ../../library/dbm.rst:406 msgid "Accepts :term:`path-like object` for filename." msgstr "" +"ファイル名として :term:`path-like object` を受け付けるようになりました。" -#: ../../library/dbm.rst:409 msgid "" ":class:`!ndbm` objects behave similar to mutable :term:`mappings `, " "but methods :meth:`!items`, :meth:`!values`, :meth:`!pop`, :meth:`!popitem`, " @@ -561,87 +611,100 @@ msgid "" "list, and the :meth:`!setdefault` method requires two arguments. It also " "supports a \"closing\" context manager via the :keyword:`with` keyword." msgstr "" +":class:`!ndbm` オブジェクトはミュータブルな :term:`マッピング ` に似" +"ていますが、:meth:`!items`、:meth:`!values`、:meth:`!pop`、:meth:`!" +"popitem`、:meth:`!update` メソッドはサポートしていません。\n" +":meth:`!keys` メソッドはリストを返し、:meth:`!setdefault` メソッドには引数が " +"2 つ必要です。\n" +"また :keyword:`with` キーワードによって、終了時にデータベースを閉じるコンテキ" +"ストマネージャとして使えます。" #: ../../library/dbm.rst:422 msgid "The following method is also provided:" msgstr "次のメソッドを提供しています:" -#: ../../library/dbm.rst:426 msgid "Close the NDBM database." -msgstr "" +msgstr "NDBM データベースを閉じます。" -#: ../../library/dbm.rst:430 msgid ":mod:`!dbm.dumb` --- Portable DBM implementation" -msgstr "" +msgstr ":mod:`!dbm.dumb` --- 移植性のある DBM 実装" #: ../../library/dbm.rst:435 msgid "**Source code:** :source:`Lib/dbm/dumb.py`" msgstr "**ソースコード:** :source:`Lib/dbm/dumb.py`" -#: ../../library/dbm.rst:441 msgid "" "The :mod:`!dbm.dumb` module is intended as a last resort fallback for the :" "mod:`!dbm` module when a more robust module is not available. The :mod:`!dbm." "dumb` module is not written for speed and is not nearly as heavily used as " "the other database modules." msgstr "" +":mod:`!dbm.dumb` モジュールは、より堅牢なモジュールを利用できないときに :mod:" +"`!dbm` モジュールが最後の手段として使うためのものです。\n" +":mod:`!dbm.dumb` モジュールは速度を重視しておらず、他のデータベースモジュール" +"ほど広く利用されていません。" -#: ../../library/dbm.rst:448 msgid "" "The :mod:`!dbm.dumb` module provides a persistent :class:`dict`-like " "interface which is written entirely in Python. Unlike other :mod:`!dbm` " "backends, such as :mod:`dbm.gnu`, no external library is required." msgstr "" +":mod:`!dbm.dumb` モジュールは、すべて Python で書かれた、永続的な :class:" +"`dict` に似たインターフェースを提供します。\n" +":mod:`dbm.gnu` などの他の :mod:`!dbm` バックエンドとは異なり、外部ライブラリ" +"は不要です。" -#: ../../library/dbm.rst:453 msgid "The :mod:`!dbm.dumb` module defines the following:" -msgstr "" +msgstr ":mod:`!dbm.dumb` モジュールは以下を定義しています:" -#: ../../library/dbm.rst:457 msgid "" "Raised on :mod:`!dbm.dumb`-specific errors, such as I/O errors. :exc:" "`KeyError` is raised for general mapping errors like specifying an incorrect " "key." msgstr "" +"I/O エラーなど、:mod:`!dbm.dumb` 固有のエラーで送出されます。\n" +"不正なキーの指定など、一般的なマッピングのエラーでは :exc:`KeyError` を送出し" +"ます。" -#: ../../library/dbm.rst:463 msgid "Open a :mod:`!dbm.dumb` database." -msgstr "" +msgstr ":mod:`!dbm.dumb` データベースを開きます。" -#: ../../library/dbm.rst:465 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files: - :file:`{filename}.dat` - :file:`{filename}." "dir`" msgstr "" +"データベースファイルのベース名 (拡張子は含めません)。\n" +"新しいデータベースを作ると、次のファイルが作成されます:\n" +"\n" +"- :file:`{filename}.dat`\n" +"- :file:`{filename}.dir`" -#: ../../library/dbm.rst:466 msgid "" "The basename of the database file (without extensions). A new database " "creates the following files:" msgstr "" +"データベースファイルのベース名 (拡張子は含めません)。\n" +"新しいデータベースを作ると、次のファイルが作成されます:" -#: ../../library/dbm.rst:469 msgid ":file:`{filename}.dat`" -msgstr "" +msgstr ":file:`{filename}.dat`" -#: ../../library/dbm.rst:470 msgid ":file:`{filename}.dir`" -msgstr "" +msgstr ":file:`{filename}.dir`" -#: ../../library/dbm.rst:473 msgid "" "* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (default): |flag_c| * " "``'n'``: |flag_n|" msgstr "" +"* ``'r'``: |flag_r| * ``'w'``: |flag_w| * ``'c'`` (デフォルト): |flag_c| * " +"``'n'``: |flag_n|" -#: ../../library/dbm.rst:474 msgid "``'r'``: |flag_r|" -msgstr "" +msgstr "``'r'``: |flag_r|" -#: ../../library/dbm.rst:476 msgid "``'c'`` (default): |flag_c|" -msgstr "" +msgstr "``'c'`` (デフォルト): |flag_c|" #: ../../library/dbm.rst:483 msgid "" @@ -653,54 +716,67 @@ msgstr "" "るときに、 Python の抽象構文木コンパイラのスタックの深さの限界を越えるせい" "で、 Python インタプリタをクラッシュさせることができます。" -#: ../../library/dbm.rst:488 msgid "" ":mod:`!dbm.dumb` does not support concurrent read/write access. (Multiple " "simultaneous read accesses are safe.) When a program has the database open " "for writing, no other program should have it open for reading or writing." msgstr "" +":mod:`!dbm.dumb` は読み書きの同時アクセスをサポートしていません (複数の読み取" +"りアクセスを同時に行うのは安全です)。\n" +"あるプログラムが書き込み用にデータベースを開いている間は、他のプログラムでそ" +"のデータベースを読み取り用にも書き込み用にも開かないでください。" -#: ../../library/dbm.rst:492 msgid "" ":func:`~dbm.dumb.open` always creates a new database when *flag* is ``'n'``." msgstr "" +"*flag* が ``'n'`` の場合、:func:`~dbm.dumb.open` は常に新しいデータベースを作" +"成するようになりました。" -#: ../../library/dbm.rst:495 msgid "" "A database opened read-only if *flag* is ``'r'``. A database is not created " "if it does not exist if *flag* is ``'r'`` or ``'w'``." msgstr "" +"*flag* が ``'r'`` の場合は読み取り専用でデータベースを開きます。\n" +"*flag* が ``'r'`` または ``'w'`` でデータベースが存在しない場合、新規作成しな" +"くなりました。" -#: ../../library/dbm.rst:502 msgid "" "The returned database object behaves similar to a mutable :term:`mapping`, " "but the :meth:`!keys` and :meth:`!items` methods return lists, and the :meth:" "`!setdefault` method requires two arguments. It also supports a \"closing\" " "context manager via the :keyword:`with` keyword." msgstr "" +"返されるデータベースオブジェクトはミュータブルな :term:`mapping` に似ています" +"が、:meth:`!keys` と :meth:`!items` メソッドはリストを返し、:meth:`!" +"setdefault` メソッドには引数が 2 つ必要です。\n" +"また :keyword:`with` キーワードによって、終了時にデータベースを閉じるコンテキ" +"ストマネージャとして使えます。" -#: ../../library/dbm.rst:511 msgid "Close the database." -msgstr "" +msgstr "データベースを閉じます。" -#: ../../library/dbm.rst:515 msgid "" "If you have carried out a lot of deletions and would like to shrink the " "space used on disk, this method will reorganize the database; otherwise, " "deleted file space will not be reused." msgstr "" +"多数の削除を行った後、ディスク上の使用領域を縮小したい場合に、このメソッドで" +"データベースを再編成できます。\n" +"再編成しない場合、削除されたファイル領域は再利用されません。" -#: ../../library/dbm.rst:520 msgid "" "While reorganizing, no additional free disk space is required. However, be " "aware that this factor changes for each :mod:`!dbm` submodule." msgstr "" +"再編成中も追加の空きディスク領域は不要です。\n" +"ただし、この条件は :mod:`!dbm` のサブモジュールごとに異なります。" -#: ../../library/dbm.rst:527 msgid "" "Synchronize the on-disk directory and data files. This method is called by " "the :meth:`shelve.Shelf.sync` method." msgstr "" +"ディスク上のディレクトリファイルとデータファイルを同期します。\n" +"このメソッドは :meth:`shelve.Shelf.sync` メソッドから呼び出されます。" #: ../../library/dbm.rst:437 msgid "databases" diff --git a/library/debug.po b/library/debug.po index bcc5b1afd..201acab37 100644 --- a/library/debug.po +++ b/library/debug.po @@ -16,17 +16,15 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/debug.rst:3 msgid "Debugging and profiling" -msgstr "" +msgstr "デバッグとプロファイリング" -#: ../../library/debug.rst:5 msgid "" "These libraries help you with Python development: the debugger enables you " "to step through code, analyze stack frames and set breakpoints etc., and the " @@ -35,7 +33,10 @@ msgid "" "provide visibility into runtime behaviors that would otherwise require " "intrusive debugging or patching." msgstr "" -"ここに含まれるライブラリは Python での開発を手助けするものです。デバッガを使" -"うと、コードのステップ実行や、スタックフレームの解析、ブレークポイントの設定" -"などができます。プロファイラはコードを実行して実行時間の詳細を提供し、プログ" -"ラムのボトルネックを特定できるようにします。" +"ここに含まれるライブラリは Python での開発を手助けします。\n" +"デバッガを使うと、コードのステップ実行やスタックフレームの解析、ブレークポイ" +"ントの設定などができます。\n" +"プロファイラはコードを実行して実行時間の詳しい内訳を示すので、プログラムのボ" +"トルネックを特定できます。\n" +"監査イベントを使うと、通常ならプログラムに手を加えるデバッグやパッチ適用が必" +"要な実行時の振る舞いを把握できます。" diff --git a/library/decimal.po b/library/decimal.po index 9a65a224e..b5409752a 100644 --- a/library/decimal.po +++ b/library/decimal.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/decimal.rst:2 @@ -30,14 +30,15 @@ msgstr ":mod:`!decimal` --- 10進固定小数点と浮動小数点の演算" msgid "**Source code:** :source:`Lib/decimal.py`" msgstr "**ソースコード:** :source:`Lib/decimal.py`" -#: ../../library/decimal.rst:25 msgid "" "The :mod:`!decimal` module provides support for fast correctly rounded " "decimal floating-point arithmetic. It offers several advantages over the :" "class:`float` datatype:" msgstr "" +":mod:`!decimal` モジュールは、高速で正しく丸められる 10 進浮動小数点演算をサ" +"ポートします。\n" +":class:`float` データ型に比べて次のような利点があります:" -#: ../../library/decimal.rst:29 msgid "" "Decimal \"is based on a `floating-point model `__ which was designed with people in mind, " @@ -45,6 +46,11 @@ msgid "" "an arithmetic that works in the same way as the arithmetic that people learn " "at school.\" -- excerpt from the decimal arithmetic specification." msgstr "" +"Decimal は「人間を念頭に設計された `浮動小数点モデル `__ に基づいており、当然ながら次の最重要の" +"指針に従っています。\n" +"コンピューターは、人間が学校で習う算術と同じように動作する算術を提供しなけれ" +"ばならない」— 十進数演算仕様からの抜粋。" #: ../../library/decimal.rst:36 msgid "" @@ -84,22 +90,21 @@ msgid "" "multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 * " "1.20`` gives ``1.5600``." msgstr "" -":mod:`decimal` モジュールでは、有効桁数の表記が取り入れられており、例えば " +"``decimal`` モジュールでは、有効桁数の表記が取り入れられており、例えば " "``1.30 + 1.20`` は ``2.50`` になります。すなわち、末尾のゼロは有効数字を示す" "ために残されます。こうした仕様は通貨計算を行うアプリケーションでは慣例です。" "乗算の場合、「教科書的な」アプローチでは、乗算の被演算子すべての桁数を使いま" "す。例えば、 ``1.3 * 1.2`` は ``1.56`` になり、 ``1.30 * 1.20`` は " "``1.5600`` になります。" -#: ../../library/decimal.rst:55 msgid "" "Unlike hardware based binary floating point, the decimal module has a user " "alterable precision (defaulting to 28 places) which can be as large as " "needed for a given problem:" msgstr "" -"ハードウェアによる 2 進浮動小数点表現と違い、:mod:`decimal` モジュールでは計" -"算精度をユーザが変更できます(デフォルトでは 28 桁です)。この桁数はほとんどの" -"問題解決に十分な大きさです:" +"ハードウェアによる 2 進浮動小数点演算と違い、``decimal`` モジュールではユー" +"ザーが精度を変更できます (デフォルトは 28 桁です)。\n" +"問題に応じて必要なだけ精度を高くできます:" #: ../../library/decimal.rst:67 msgid "" @@ -112,10 +117,10 @@ msgid "" msgstr "" "二進と十進の浮動小数点は、いずれも広く公開されている標準仕様のもとに実装され" "ています。組み込みの浮動小数点型では、標準仕様で提唱されている機能のほんのさ" -"さやかな部分を利用できるにすぎませんが、:mod:`decimal` では標準仕様が要求して" -"いる全ての機能を利用できます。必要に応じて、プログラマは値の丸めやシグナル処" -"理を完全に制御できます。この中には全ての不正確な操作を例外でブロックして正確" -"な算術を遵守させるオプションもあります。" +"さやかな部分を利用できるにすぎませんが、 ``decimal`` では標準仕様が要求してい" +"る全ての機能を利用できます。必要に応じて、プログラマは値の丸めやシグナル処理" +"を完全に制御できます。この中には全ての不正確な操作を例外でブロックして正確な" +"算術を遵守させるオプションもあります。" #: ../../library/decimal.rst:74 msgid "" @@ -145,9 +150,9 @@ msgid "" "``+0``." msgstr "" "十進数型は変更不能です。これは符号、係数部、そして指数を持ちます。有効桁数を" -"残すために、仮数部の末尾にあるゼロは切り詰められません。 :mod:`decimal` で" -"は、 ``Infinity``, ``-Infinity``, および ``NaN`` といった特殊な値も定義されて" -"います。標準仕様では ``-0`` と ``+0`` も区別します。" +"残すために、仮数部の末尾にあるゼロは切り詰められません。 ``decimal`` では、 " +"``Infinity``, ``-Infinity``, および ``NaN`` といった特殊な値も定義されていま" +"す。標準仕様では ``-0`` と ``+0`` も区別します。" #: ../../library/decimal.rst:88 msgid "" @@ -177,8 +182,8 @@ msgid "" msgstr "" "シグナルとは、演算の過程で生じる例外的条件です。個々のシグナルは、アプリケー" "ションそれぞれの要求に従って、無視されたり、単なる情報とみなされたり、例外と" -"して扱われたりします。 :mod:`decimal` モジュールには、 :const:`Clamped`, :" -"const:`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:" +"して扱われたりします。 ``decimal`` モジュールには、 :const:`Clamped`, :const:" +"`InvalidOperation`, :const:`DivisionByZero`, :const:`Inexact`, :const:" "`Rounded`, :const:`Subnormal`, :const:`Overflow`, :const:`Underflow`, およ" "び :const:`FloatOperation` といったシグナルがあります。" @@ -203,9 +208,8 @@ msgstr "" "IBM による汎用十進演算仕様、`The General Decimal Arithmetic Specification " "`_。" -#: ../../library/decimal.rst:119 msgid "Quick-start tutorial" -msgstr "" +msgstr "入門チュートリアル" #: ../../library/decimal.rst:121 msgid "" @@ -213,11 +217,10 @@ msgid "" "current context with :func:`getcontext` and, if necessary, setting new " "values for precision, rounding, or enabled traps::" msgstr "" -"普通、 :mod:`decimal` を使うときには、モジュールをインポートし、現在の演算コ" -"ンテキストを :func:`getcontext` で調べ、必要なら、精度、丸め、有効なトラップ" -"を設定します::" +"普通、 ``decimal`` を使うときには、モジュールをインポートし、現在の演算コンテ" +"キストを :func:`getcontext` で調べ、必要なら、精度、丸め、有効なトラップを設" +"定します::" -#: ../../library/decimal.rst:125 msgid "" ">>> from decimal import *\n" ">>> getcontext()\n" @@ -227,6 +230,13 @@ msgid "" "\n" ">>> getcontext().prec = 7 # Set a new precision" msgstr "" +">>> from decimal import *\n" +">>> getcontext()\n" +"Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[], traps=[Overflow, DivisionByZero,\n" +" InvalidOperation])\n" +"\n" +">>> getcontext().prec = 7 # 新しい精度を設定します" #: ../../library/decimal.rst:133 msgid "" @@ -236,12 +246,11 @@ msgid "" "values such as ``NaN`` which stands for \"Not a number\", positive and " "negative ``Infinity``, and ``-0``::" msgstr "" -":class:`Decimal` インスタンスは、整数、文字列、浮動小数点数、またはタプルから" -"構成できます。整数や浮動小数点数からの構成は、整数や浮動小数点数の値を正確に" -"変換します。 :class:`Decimal` は \"非数 (Not a Number)\" を表す ``NaN`` や正" -"負の ``Infinity`` (無限大)、 ``-0`` といった特殊な値も表現できます::" +"``Decimal`` インスタンスは、整数、文字列、浮動小数点数、またはタプルから構成" +"できます。整数や浮動小数点数からの構成は、整数や浮動小数点数の値を正確に変換" +"します。 ``Decimal`` は \"非数 (Not a Number)\" を表す ``NaN`` や正負の " +"``Infinity`` (無限大)、 ``-0`` といった特殊な値も表現できます::" -#: ../../library/decimal.rst:139 msgid "" ">>> getcontext().prec = 28\n" ">>> Decimal(10)\n" @@ -261,6 +270,23 @@ msgid "" ">>> Decimal('-Infinity')\n" "Decimal('-Infinity')" msgstr "" +">>> getcontext().prec = 28\n" +">>> Decimal(10)\n" +"Decimal('10')\n" +">>> Decimal('3.14')\n" +"Decimal('3.14')\n" +">>> Decimal(3.14)\n" +"Decimal('3.140000000000000124344978758017532527446746826171875')\n" +">>> Decimal((0, (3, 1, 4), -2))\n" +"Decimal('3.14')\n" +">>> Decimal(str(2.0 ** 0.5))\n" +"Decimal('1.4142135623730951')\n" +">>> Decimal(2) ** Decimal('0.5')\n" +"Decimal('1.414213562373095048801688724')\n" +">>> Decimal('NaN')\n" +"Decimal('NaN')\n" +">>> Decimal('-Infinity')\n" +"Decimal('-Infinity')" #: ../../library/decimal.rst:157 msgid "" @@ -271,7 +297,6 @@ msgstr "" ":exc:`FloatOperation` シグナルがトラップされる場合、コンストラクタや順序比較" "において誤って decimal と float が混ざると、例外が送出されます::" -#: ../../library/decimal.rst:161 msgid "" ">>> c = getcontext()\n" ">>> c.traps[FloatOperation] = True\n" @@ -286,6 +311,18 @@ msgid "" ">>> Decimal('3.5') == 3.5\n" "True" msgstr "" +">>> c = getcontext()\n" +">>> c.traps[FloatOperation] = True\n" +">>> Decimal(3.14)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.FloatOperation: []\n" +">>> Decimal('3.5') < 3.7\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.FloatOperation: []\n" +">>> Decimal('3.5') == 3.5\n" +"True" #: ../../library/decimal.rst:176 msgid "" @@ -293,10 +330,9 @@ msgid "" "digits input. Context precision and rounding only come into play during " "arithmetic operations." msgstr "" -"新たな :class:`Decimal` の有効桁数は入力の桁数だけで決まります。演算コンテキ" -"ストにおける精度や値丸めの設定が影響するのは算術演算の間だけです。" +"新たな ``Decimal`` の有効桁数は入力の桁数だけで決まります。演算コンテキストに" +"おける精度や値丸めの設定が影響するのは算術演算の間だけです。" -#: ../../library/decimal.rst:180 msgid "" ">>> getcontext().prec = 6\n" ">>> Decimal('3.0')\n" @@ -309,6 +345,16 @@ msgid "" ">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" "Decimal('5.85988')" msgstr "" +">>> getcontext().prec = 6\n" +">>> Decimal('3.0')\n" +"Decimal('3.0')\n" +">>> Decimal('3.1415926535')\n" +"Decimal('3.1415926535')\n" +">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" +"Decimal('5.85987')\n" +">>> getcontext().rounding = ROUND_UP\n" +">>> Decimal('3.1415926535') + Decimal('2.7182818285')\n" +"Decimal('5.85988')" #: ../../library/decimal.rst:193 msgid "" @@ -318,21 +364,24 @@ msgstr "" "C バージョンの内部制限を超えた場合、decimal の構成は :class:" "`InvalidOperation` を送出します::" -#: ../../library/decimal.rst:196 msgid "" ">>> Decimal(\"1e9999999999999999999\")\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "decimal.InvalidOperation: []" msgstr "" +">>> Decimal(\"1e9999999999999999999\")\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"decimal.InvalidOperation: []" -#: ../../library/decimal.rst:203 msgid "" "Decimals interact well with much of the rest of Python. Here is a small " "decimal floating-point flying circus:" msgstr "" +"Decimal は Python の他の多くの機能とうまく連携します。\n" +"10 進浮動小数点数を使った、ちょっとした実演を見てみましょう:" -#: ../../library/decimal.rst:206 msgid "" ">>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))\n" ">>> max(data)\n" @@ -360,15 +409,42 @@ msgid "" ">>> c % a\n" "Decimal('0.77')" msgstr "" +">>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))\n" +">>> max(data)\n" +"Decimal('9.25')\n" +">>> min(data)\n" +"Decimal('0.03')\n" +">>> sorted(data)\n" +"[Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'),\n" +" Decimal('2.35'), Decimal('3.45'), Decimal('9.25')]\n" +">>> sum(data)\n" +"Decimal('19.29')\n" +">>> a,b,c = data[:3]\n" +">>> str(a)\n" +"'1.34'\n" +">>> float(a)\n" +"1.34\n" +">>> round(a, 1)\n" +"Decimal('1.3')\n" +">>> int(a)\n" +"1\n" +">>> a * 5\n" +"Decimal('6.70')\n" +">>> a * b\n" +"Decimal('2.5058')\n" +">>> c % a\n" +"Decimal('0.77')" -#: ../../library/decimal.rst:235 msgid "" "Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) " "in fixed-point or scientific notation, using the same formatting syntax " "(see :ref:`formatspec`) as builtin :class:`float` type:" msgstr "" +"Decimal は、組み込みの :func:`format` や :ref:`f-strings` を使って、固定小数" +"点表記や科学表記に書式化できます。\n" +"書式指定の構文 (:ref:`formatspec` を参照) は組み込みの :class:`float` 型と同" +"じです:" -#: ../../library/decimal.rst:239 msgid "" ">>> format(Decimal('2.675'), \"f\")\n" "'2.675'\n" @@ -384,6 +460,19 @@ msgid "" "...\n" "2.67" msgstr "" +">>> format(Decimal('2.675'), \"f\")\n" +"'2.675'\n" +">>> format(Decimal('2.675'), \".2f\")\n" +"'2.68'\n" +">>> f\"{Decimal('2.675'):.2f}\"\n" +"'2.68'\n" +">>> format(Decimal('2.675'), \".2e\")\n" +"'2.68e+0'\n" +">>> with localcontext() as ctx:\n" +"... ctx.rounding = ROUND_DOWN\n" +"... print(format(Decimal('2.675'), \".2f\"))\n" +"...\n" +"2.67" #: ../../library/decimal.rst:255 msgid "And some mathematical functions are also available to Decimal:" @@ -408,22 +497,25 @@ msgstr "" "スでき、設定を変更できます。ほとんどのアプリケーションはこのアプローチで十分" "です。" -#: ../../library/decimal.rst:280 msgid "" "For more advanced work, it may be useful to create alternate contexts using " "the :meth:`Context` constructor. To make an alternate active, use the :func:" "`setcontext` function." msgstr "" +"より高度な処理では、:meth:`Context` コンストラクタで別のコンテキストを作ると" +"便利な場合があります。\n" +"別のコンテキストを有効にするには :func:`setcontext` 関数を使います。" -#: ../../library/decimal.rst:284 msgid "" "In accordance with the standard, the :mod:`!decimal` module provides two " "ready to use standard contexts, :const:`BasicContext` and :const:" "`ExtendedContext`. The former is especially useful for debugging because " "many of the traps are enabled:" msgstr "" +":mod:`!decimal` モジュールは仕様に従い、そのまま使える 2 つの標準コンテキス" +"ト :const:`BasicContext` と :const:`ExtendedContext` を提供します。\n" +"前者は多くのトラップが有効になっているので、特にデバッグに便利です:" -#: ../../library/decimal.rst:289 msgid "" ">>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)\n" ">>> setcontext(myothercontext)\n" @@ -446,6 +538,26 @@ msgid "" " Decimal(42) / Decimal(0)\n" "DivisionByZero: x / 0" msgstr "" +">>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)\n" +">>> setcontext(myothercontext)\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857142857142857142857142857142857142857142857142857142857')\n" +"\n" +">>> ExtendedContext\n" +"Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[], traps=[])\n" +">>> setcontext(ExtendedContext)\n" +">>> Decimal(1) / Decimal(7)\n" +"Decimal('0.142857143')\n" +">>> Decimal(42) / Decimal(0)\n" +"Decimal('Infinity')\n" +"\n" +">>> setcontext(BasicContext)\n" +">>> Decimal(42) / Decimal(0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" Decimal(42) / Decimal(0)\n" +"DivisionByZero: x / 0" #: ../../library/decimal.rst:313 msgid "" @@ -459,7 +571,6 @@ msgstr "" "す。そのため、フラグのモニタを行いたいような演算の前には :meth:`~Context." "clear_flags` メソッドでフラグをクリアしておくのがベストです。 ::" -#: ../../library/decimal.rst:318 msgid "" ">>> setcontext(ExtendedContext)\n" ">>> getcontext().clear_flags()\n" @@ -469,6 +580,13 @@ msgid "" "Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" " capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])" msgstr "" +">>> setcontext(ExtendedContext)\n" +">>> getcontext().clear_flags()\n" +">>> Decimal(355) / Decimal(113)\n" +"Decimal('3.14159292')\n" +">>> getcontext()\n" +"Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,\n" +" capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])" #: ../../library/decimal.rst:326 msgid "" @@ -488,7 +606,6 @@ msgstr "" "コンテキストの :attr:`~Context.traps` 属性に入っている辞書を使うと、個々のト" "ラップをセットできます:" -#: ../../library/decimal.rst:333 msgid "" ">>> setcontext(ExtendedContext)\n" ">>> Decimal(1) / Decimal(0)\n" @@ -500,6 +617,15 @@ msgid "" " Decimal(1) / Decimal(0)\n" "DivisionByZero: x / 0" msgstr "" +">>> setcontext(ExtendedContext)\n" +">>> Decimal(1) / Decimal(0)\n" +"Decimal('Infinity')\n" +">>> getcontext().traps[DivisionByZero] = 1\n" +">>> Decimal(1) / Decimal(0)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in -toplevel-\n" +" Decimal(1) / Decimal(0)\n" +"DivisionByZero: x / 0" #: ../../library/decimal.rst:345 msgid "" @@ -511,9 +637,9 @@ msgid "" msgstr "" "ほとんどのプログラムでは、開始時に一度だけ現在の演算コンテキストを修正しま" "す。また、多くのアプリケーションでは、データから :class:`Decimal` への変換は" -"ループ内で一度だけキャストして行います。コンテキストを設定し、 :class:" -"`Decimal` オブジェクトを生成できたら、ほとんどのプログラムは他の Python 数値" -"型と全く変わらないかのように :class:`Decimal` を操作できます。" +"ループ内で一度だけキャストして行います。コンテキストを設定し、 ``Decimal`` オ" +"ブジェクトを生成できたら、ほとんどのプログラムは他の Python 数値型と全く変わ" +"らないかのように ``Decimal`` を操作できます。" #: ../../library/decimal.rst:357 msgid "Decimal objects" @@ -536,7 +662,6 @@ msgstr "" "す。 *value* が文字列の場合、先頭と末尾の空白および全てのアンダースコアを取り" "除いた後には以下の 10進数文字列の文法に従わなければなりません::" -#: ../../library/decimal.rst:369 msgid "" "sign ::= '+' | '-'\n" "digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | " @@ -550,8 +675,18 @@ msgid "" "numeric-value ::= decimal-part [exponent-part] | infinity\n" "numeric-string ::= [sign] numeric-value | [sign] nan" msgstr "" +"sign ::= '+' | '-'\n" +"digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | " +"'9'\n" +"indicator ::= 'e' | 'E'\n" +"digits ::= digit [digit]...\n" +"decimal-part ::= digits '.' [digits] | ['.'] digits\n" +"exponent-part ::= indicator [sign] digits\n" +"infinity ::= 'Infinity' | 'Inf'\n" +"nan ::= 'NaN' [digits] | 'sNaN' [digits]\n" +"numeric-value ::= decimal-part [exponent-part] | infinity\n" +"numeric-string ::= [sign] numeric-value | [sign] nan" -#: ../../library/decimal.rst:380 msgid "" "Other Unicode decimal digits are also permitted where ``digit`` appears " "above. These include decimal digits from various other alphabets (for " @@ -560,6 +695,11 @@ msgid "" "example, ``inf``, ``Inf``, ``INFINITY``, and ``iNfINity`` are all acceptable " "spellings for positive infinity." msgstr "" +"上記の ``digit`` には、他の Unicode の 10 進数字も使えます。\n" +"例えばアラビア・インド数字やデーヴァナーガリー数字など、さまざまな文字体系の " +"10 進数字や、全角数字 ``'\\uff10'`` から ``'\\uff19'`` が含まれます。\n" +"大文字・小文字は区別しないので、例えば ``inf``、``Inf``、``INFINITY``、" +"``iNfINity`` はすべて正の無限大を表す表記として使えます。" #: ../../library/decimal.rst:387 msgid "" @@ -573,7 +713,6 @@ msgstr "" "を表す整数でなければなりません。例えば、 ``Decimal((0, (1, 4, 1, 4), -3))`` " "は ``Decimal('1.414')`` を返します。" -#: ../../library/decimal.rst:392 msgid "" "If *value* is a :class:`float`, the binary floating-point value is " "losslessly converted to its exact decimal equivalent. This conversion can " @@ -581,6 +720,12 @@ msgid "" "``Decimal(float('1.1'))`` converts to " "``Decimal('1.100000000000000088817841970012523233890533447265625')``." msgstr "" +"*value* が :class:`float` の場合、その 2 進浮動小数点数の値を、損失なく正確に" +"対応する 10 進数へ変換します。\n" +"この変換には 53 桁以上の精度が必要になることもよくあります。\n" +"例えば ``Decimal(float('1.1'))`` は " +"``Decimal('1.100000000000000088817841970012523233890533447265625')`` に変換さ" +"れます。" #: ../../library/decimal.rst:398 msgid "" @@ -604,7 +749,7 @@ msgstr "" "*context* 引数の目的は、 *value* が正しくない形式の文字列であった場合に行う処" "理を決めることにあります; 演算コンテキストが :const:`InvalidOperation` をト" "ラップするようになっていれば、例外を送出します。それ以外の場合には、コンスト" -"ラクタは値が ``NaN`` の :class:`Decimal` を返します。" +"ラクタは値が ``NaN`` の ``Decimal`` を返します。" #: ../../library/decimal.rst:408 msgid "Once constructed, :class:`Decimal` objects are immutable." @@ -636,7 +781,6 @@ msgstr "" "コード中の整数リテラルや浮動小数点リテラルと同様に、アンダースコアを用いて桁" "をグルーピングできます。" -#: ../../library/decimal.rst:422 msgid "" "Decimal floating-point objects share many properties with the other built-in " "numeric types such as :class:`float` and :class:`int`. All of the usual " @@ -645,6 +789,11 @@ msgid "" "compared, sorted, and coerced to another type (such as :class:`float` or :" "class:`int`)." msgstr "" +"10 進浮動小数点オブジェクトは、:class:`float` や :class:`int` などの他の組み" +"込み数値型と多くの性質を共有しています。\n" +"通常の数学演算や特殊メソッドはすべて利用できます。\n" +"また、コピー、pickle 化、表示、辞書のキーや集合の要素としての利用、比較、ソー" +"ト、他の型 (:class:`float` や :class:`int` など) への変換もできます。" #: ../../library/decimal.rst:429 msgid "" @@ -657,13 +806,16 @@ msgstr "" "す。十進オブジェクトに対して剰余演算を適用すると、計算結果の符号は除数の符号" "ではなく *被除数* の符号と一致します::" -#: ../../library/decimal.rst:434 msgid "" ">>> (-7) % 4\n" "1\n" ">>> Decimal(-7) % Decimal(4)\n" "Decimal('-3')" msgstr "" +">>> (-7) % 4\n" +"1\n" +">>> Decimal(-7) % Decimal(4)\n" +"Decimal('-3')" #: ../../library/decimal.rst:439 msgid "" @@ -675,13 +827,16 @@ msgstr "" "めた) 整数部分を返します。そのため通常の恒等式 ``x == (x // y) * y + x % y`` " "が維持されます::" -#: ../../library/decimal.rst:443 msgid "" ">>> -7 // 4\n" "-2\n" ">>> Decimal(-7) // Decimal(4)\n" "Decimal('-1')" msgstr "" +">>> -7 // 4\n" +"-2\n" +">>> Decimal(-7) // Decimal(4)\n" +"Decimal('-1')" #: ../../library/decimal.rst:448 msgid "" @@ -716,11 +871,12 @@ msgstr "" ":class:`Decimal` インスタンスと他の数値型が混在する比較が完全にサポートされる" "ようになりました。" -#: ../../library/decimal.rst:464 msgid "" "In addition to the standard numeric properties, decimal floating-point " "objects also have a number of specialized methods:" msgstr "" +"10 進浮動小数点オブジェクトには、標準的な数値の性質に加えて、次のような専用メ" +"ソッドがあります:" #: ../../library/decimal.rst:470 msgid "" @@ -742,11 +898,12 @@ msgstr "" "与えられた :class:`Decimal` インスタンスを、既約分数で分母が正数の分数として" "表現した整数のペア ``(n, d)`` を返します。" -#: ../../library/decimal.rst:481 msgid "" ">>> Decimal('-3.14').as_integer_ratio()\n" "(-157, 50)" msgstr "" +">>> Decimal('-3.14').as_integer_ratio()\n" +"(-157, 50)" #: ../../library/decimal.rst:484 msgid "" @@ -756,13 +913,12 @@ msgstr "" "変換は正確に行われます。無限大に対してはOverflowErrorを、NaNに対しては" "ValueError を送出します。" -#: ../../library/decimal.rst:491 msgid "" "Return a :term:`named tuple` representation of the number: " "``DecimalTuple(sign, digits, exponent)``." msgstr "" "数値を表現するための :term:`名前付きタプル `: " -"``DecimalTuple(sign, digittuple, exponent)`` を返します。" +"``DecimalTuple(sign, digits, exponent)`` を返します。" #: ../../library/decimal.rst:497 msgid "" @@ -782,13 +938,16 @@ msgstr "" "二つの Decimal インスタンスの値を比較します。 :meth:`compare` は Decimal イン" "スタンスを返し、被演算子のどちらかが NaN ならば結果は NaN です::" -#: ../../library/decimal.rst:507 msgid "" "a or b is a NaN ==> Decimal('NaN')\n" "a < b ==> Decimal('-1')\n" "a == b ==> Decimal('0')\n" "a > b ==> Decimal('1')" msgstr "" +"a または b が NaN ==> Decimal('NaN')\n" +"a < b ==> Decimal('-1')\n" +"a == b ==> Decimal('0')\n" +"a > b ==> Decimal('1')" #: ../../library/decimal.rst:514 msgid "" @@ -888,13 +1047,13 @@ msgstr "" "与えられた数での(自然)指数関数 ``e**x`` の値を返します。結果は :const:" "`ROUND_HALF_EVEN` 丸めモードで正しく丸められます。" -#: ../../library/decimal.rst:592 msgid "" "Alternative constructor that only accepts instances of :class:`float` or :" "class:`int`." msgstr "" +":class:`float` または :class:`int` のインスタンスだけを受け付ける、別形式のコ" +"ンストラクタです。" -#: ../../library/decimal.rst:595 msgid "" "Note ``Decimal.from_float(0.1)`` is not the same as ``Decimal('0.1')``. " "Since 0.1 is not exactly representable in binary floating point, the value " @@ -903,8 +1062,10 @@ msgid "" "``0.1000000000000000055511151231257827021181583404541015625``." msgstr "" "なお、``Decimal.from_float(0.1)`` は ``Decimal('0.1')`` と同じではありませ" -"ん。0.1 は二進浮動小数点数で正確に表せないので、その値は表現できる最も近い" -"値、``0x1.999999999999ap-4`` として記憶されます。浮動小数点数での等価な値は " +"ん。\n" +"0.1 は二進浮動小数点数で正確に表せないので、その値は表現できる最も近い値、" +"``0x1.999999999999ap-4`` として記憶されます。\n" +"同じ値を十進数で表すと " "``0.1000000000000000055511151231257827021181583404541015625`` です。" #: ../../library/decimal.rst:601 @@ -915,7 +1076,6 @@ msgstr "" "Python 3.2 以降では、 :class:`Decimal` インスタンスは :class:`float` から直接" "構成できるようになりました。" -#: ../../library/decimal.rst:604 msgid "" ">>> Decimal.from_float(0.1)\n" "Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" @@ -926,14 +1086,22 @@ msgid "" ">>> Decimal.from_float(float('-inf'))\n" "Decimal('-Infinity')" msgstr "" +">>> Decimal.from_float(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +">>> Decimal.from_float(float('nan'))\n" +"Decimal('NaN')\n" +">>> Decimal.from_float(float('inf'))\n" +"Decimal('Infinity')\n" +">>> Decimal.from_float(float('-inf'))\n" +"Decimal('-Infinity')" -#: ../../library/decimal.rst:619 msgid "" "Alternative constructor that only accepts instances of :class:`float`, :" "class:`int` or :class:`Decimal`, but not strings or tuples." msgstr "" +":class:`float`、:class:`int`、:class:`Decimal` のインスタンスだけを受け付け、" +"文字列やタプルは受け付けない、別形式のコンストラクタです。" -#: ../../library/decimal.rst:623 msgid "" ">>> Decimal.from_number(314)\n" "Decimal('314')\n" @@ -942,6 +1110,12 @@ msgid "" ">>> Decimal.from_number(Decimal('3.14'))\n" "Decimal('3.14')" msgstr "" +">>> Decimal.from_number(314)\n" +"Decimal('314')\n" +">>> Decimal.from_number(0.1)\n" +"Decimal('0.1000000000000000055511151231257827021181583404541015625')\n" +">>> Decimal.from_number(Decimal('3.14'))\n" +"Decimal('3.14')" #: ../../library/decimal.rst:636 msgid "" @@ -1049,7 +1223,6 @@ msgstr "" "演算対象の底 10 の対数を返します。結果は :const:`ROUND_HALF_EVEN` 丸めモード" "で正しく丸められます。" -#: ../../library/decimal.rst:705 msgid "" "For a nonzero number, return the adjusted exponent of its operand as a :" "class:`Decimal` instance. If the operand is a zero then ``Decimal('-" @@ -1057,9 +1230,10 @@ msgid "" "the operand is an infinity then ``Decimal('Infinity')`` is returned." msgstr "" "非零の数値については、 :class:`Decimal` インスタンスとして調整された指数を返" -"します。演算対象がゼロだった場合、 ``Decimal('-Infinity')`` が返され :const:" -"`DivisionByZero` フラグが送出されます。演算対象が無限大だった場合、 " -"``Decimal('Infinity')`` が返されます。" +"します。\n" +"演算対象がゼロだった場合、 ``Decimal('-Infinity')`` が返され :const:" +"`DivisionByZero` フラグがセットされます。\n" +"演算対象が無限大だった場合、 ``Decimal('Infinity')`` が返されます。" #: ../../library/decimal.rst:713 msgid "" @@ -1156,13 +1330,13 @@ msgstr "" "向の数を返します。もし両者が数値的に等しければ、二つめの対象の符号を採った一" "つめの対象のコピーを返します。" -#: ../../library/decimal.rst:779 msgid "" "Used for producing canonical values of an equivalence class within either " "the current context or the specified context." msgstr "" +"現在のコンテキストまたは指定したコンテキスト内で、同値類の標準形となる値を生" +"成するために使います。" -#: ../../library/decimal.rst:782 msgid "" "This has the same semantics as the unary plus operation, except that if the " "final result is finite it is reduced to its simplest form, with all trailing " @@ -1171,22 +1345,27 @@ msgid "" "exponent is incremented by 1. Otherwise (the coefficient is zero) the " "exponent is set to 0. In all cases the sign is unchanged." msgstr "" +"単項プラス演算と同じ意味を持ちますが、最終結果が有限の場合は、末尾のゼロをす" +"べて取り除き、符号を保ったまま最も単純な形にします。\n" +"具体的には、係数がゼロでない 10 の倍数である間、係数を 10 で割って指数を 1 増" +"やします。\n" +"それ以外 (係数がゼロ) の場合は指数を 0 にします。\n" +"いずれの場合も符号は変わりません。" -#: ../../library/decimal.rst:789 msgid "" "For example, ``Decimal('32.100')`` and ``Decimal('0.321000e+2')`` both " "normalize to the equivalent value ``Decimal('32.1')``." msgstr "" +"例えば ``Decimal('32.100')`` と ``Decimal('0.321000e+2')`` は、どちらも同じ値" +"を持つ ``Decimal('32.1')`` に正規化されます。" -#: ../../library/decimal.rst:792 msgid "Note that rounding is applied *before* reducing to simplest form." -msgstr "" +msgstr "最も単純な形にする *前に* 丸めが適用されます。" -#: ../../library/decimal.rst:794 msgid "" "In the latest versions of the specification, this operation is also known as " "``reduce``." -msgstr "" +msgstr "この演算は、新しい版の仕様では ``reduce`` とも呼ばれています。" #: ../../library/decimal.rst:799 msgid "" @@ -1315,7 +1494,6 @@ msgstr "" msgid "If the result is zero then its sign will be the sign of *self*." msgstr "結果が0になる場合の符号は *self* の符号と同じになります。" -#: ../../library/decimal.rst:865 msgid "" "Return the result of rotating the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1326,12 +1504,15 @@ msgid "" "length precision if necessary. The sign and exponent of the first operand " "are unchanged." msgstr "" -"一つ目の演算対象の数字を二つ目で指定された量だけ巡回(rotate)した結果を返しま" -"す。二つめの演算対象は -precision から precision までの範囲の整数でなければな" -"りません。この二つ目の演算対象の絶対値を何桁ずらすかを決めます。そしてもし正" -"の数ならば巡回の方向は左に、そうでなければ右になります。一つ目の演算対象の仮" -"数部は必要ならば精度いっぱいまでゼロで埋められます。符号と指数は変えられませ" -"ん。" +"1 つ目の演算対象の数字を、2 つ目の演算対象で指定した桁数だけ巡回させた結果を" +"返します。\n" +"2 つ目の演算対象は -precision から precision までの整数でなければなりませ" +"ん。\n" +"その絶対値が巡回させる桁数を表し、正なら左へ、それ以外なら右へ巡回させま" +"す。\n" +"必要に応じて 1 つ目の演算対象の係数の左側をゼロで埋め、長さを precision に揃" +"えます。\n" +"1 つ目の演算対象の符号と指数は変わりません。" #: ../../library/decimal.rst:876 msgid "" @@ -1351,7 +1532,6 @@ msgstr "" "が、一つめの演算対象を ``10**other`` 倍したものを返します。二つ目の演算対象は" "整数でなければなりません。" -#: ../../library/decimal.rst:891 msgid "" "Return the result of shifting the digits of the first operand by an amount " "specified by the second operand. The second operand must be an integer in " @@ -1361,11 +1541,14 @@ msgid "" "right. Digits shifted into the coefficient are zeros. The sign and " "exponent of the first operand are unchanged." msgstr "" -"一つ目の演算対象の数字を二つ目で指定された量だけシフトした結果を返します。二" -"つ目の演算対象は -precision から precision までの範囲の整数でなければなりませ" -"ん。この二つ目の演算対象の絶対値が何桁ずらすかを決めます。そしてもし正の数な" -"らばシフトの方向は左に、そうでなければ右になります。一つ目の演算対象の係数は" -"必要ならば精度いっぱいまでゼロで埋められます。符号と指数は変えられません。" +"1 つ目の演算対象の数字を、2 つ目の演算対象で指定した桁数だけシフトした結果を" +"返します。\n" +"2 つ目の演算対象は -precision から precision までの整数でなければなりませ" +"ん。\n" +"その絶対値がシフトする桁数を表し、正なら左へ、それ以外なら右へシフトしま" +"す。\n" +"シフトによって係数に入る数字はゼロです。\n" +"1 つ目の演算対象の符号と指数は変わりません。" #: ../../library/decimal.rst:901 msgid "Return the square root of the argument to full precision." @@ -1376,15 +1559,14 @@ msgid "" "Convert to a string, using engineering notation if an exponent is needed." msgstr "文字列に変換します。指数が必要なら工学表記が使われます。" -#: ../../library/decimal.rst:908 ../../library/decimal.rst:1565 msgid "" "Engineering notation has an exponent which is a multiple of 3. This can " "leave up to 3 digits to the left of the decimal place and may require the " "addition of either one or two trailing zeros." msgstr "" -"工学表記法では指数は 3 の倍数になります。これにより、基数の小数部には最大で " -"3 桁までの数字が残されるとともに、末尾に 1 つまたは 2 つの 0 の付加が必要とさ" -"れるかもしれません。" +"工学表記法では指数が 3 の倍数になります。\n" +"そのため、小数点の左側には最大 3 桁の数字が残り、末尾にゼロを 1 つまたは 2 つ" +"追加する必要が生じることがあります。" #: ../../library/decimal.rst:912 msgid "" @@ -1423,17 +1605,21 @@ msgstr "" "値を丸めます。 *rounding* が指定されていれば適用されます; それ以外の場合、値" "丸めの方法は *context* の設定か現在のコンテキストの設定になります。" -#: ../../library/decimal.rst:933 msgid "Decimal numbers can be rounded using the :func:`.round` function:" -msgstr "" +msgstr "Decimal の数値は :func:`.round` 関数で丸められます:" -#: ../../library/decimal.rst:938 msgid "" "If *ndigits* is not given or ``None``, returns the nearest :class:`int` to " "*number*, rounding ties to even, and ignoring the rounding mode of the :" "class:`Decimal` context. Raises :exc:`OverflowError` if *number* is an " "infinity or :exc:`ValueError` if it is a (quiet or signaling) NaN." msgstr "" +"*ndigits* を指定しないか ``None`` にすると、*number* に最も近い :class:`int` " +"を返します。\n" +"ちょうど中間なら偶数に丸め、:class:`Decimal` のコンテキストの丸めモードは無視" +"します。\n" +"*number* が無限大なら :exc:`OverflowError` を、無言 NaN または発信 NaN なら :" +"exc:`ValueError` を送出します。" #: ../../library/decimal.rst:944 msgid "" @@ -1447,27 +1633,26 @@ msgid "" "the current context's precision. In other words, for the non-corner cases:" msgstr "" -#: ../../library/decimal.rst:954 msgid "" "if *ndigits* is positive, return *number* rounded to *ndigits* decimal " "places;" msgstr "" +"*ndigits* が正なら、*number* を小数点以下 *ndigits* 桁に丸めて返します。" -#: ../../library/decimal.rst:956 msgid "if *ndigits* is zero, return *number* rounded to the nearest integer;" -msgstr "" +msgstr "*ndigits* がゼロなら、*number* を最も近い整数に丸めて返します。" -#: ../../library/decimal.rst:957 msgid "" "if *ndigits* is negative, return *number* rounded to the nearest multiple of " "``10**abs(ndigits)``." msgstr "" +"*ndigits* が負なら、*number* を最も近い ``10**abs(ndigits)`` の倍数に丸めて返" +"します。" #: ../../library/decimal.rst:960 msgid "For example::" msgstr "例えば::" -#: ../../library/decimal.rst:962 msgid "" ">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" ">>> getcontext().rounding = ROUND_DOWN\n" @@ -1482,6 +1667,18 @@ msgid "" ">>> round(Decimal('3.75'), -1)\n" "Decimal('0E+1')" msgstr "" +">>> from decimal import Decimal, getcontext, ROUND_DOWN\n" +">>> getcontext().rounding = ROUND_DOWN\n" +">>> round(Decimal('3.75')) # コンテキストの丸めモードは無視します\n" +"4\n" +">>> round(Decimal('3.5')) # 中間値は偶数に丸めます\n" +"4\n" +">>> round(Decimal('3.75'), 0) # コンテキストの丸めモードを使います\n" +"Decimal('3')\n" +">>> round(Decimal('3.75'), 1)\n" +"Decimal('3.7')\n" +">>> round(Decimal('3.75'), -1)\n" +"Decimal('0E+1')" #: ../../library/decimal.rst:979 msgid "Logical operands" @@ -1562,7 +1759,6 @@ msgstr "" "たとえば、以下のコードでは精度を42桁に設定し、計算を実行し、そして元のコンテ" "キストに復帰します::" -#: ../../library/decimal.rst:1026 msgid "" "from decimal import localcontext\n" "\n" @@ -1571,12 +1767,16 @@ msgid "" " s = calculate_something()\n" "s = +s # Round the final result back to the default precision" msgstr "" +"from decimal import localcontext\n" +"\n" +"with localcontext() as ctx:\n" +" ctx.prec = 42 # 高精度で計算します\n" +" s = calculate_something()\n" +"s = +s # 最終結果をデフォルトの精度に丸めます" -#: ../../library/decimal.rst:1033 msgid "Using keyword arguments, the code would be the following::" -msgstr "" +msgstr "キーワード引数を使うと、次のように書けます。 ::" -#: ../../library/decimal.rst:1035 msgid "" "from decimal import localcontext\n" "\n" @@ -1584,35 +1784,45 @@ msgid "" " s = calculate_something()\n" "s = +s" msgstr "" +"from decimal import localcontext\n" +"\n" +"with localcontext(prec=42) as ctx:\n" +" s = calculate_something()\n" +"s = +s" -#: ../../library/decimal.rst:1041 msgid "" "Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:" "`Context` doesn't support. Raises either :exc:`TypeError` or :exc:" "`ValueError` if *kwargs* supplies an invalid value for an attribute." msgstr "" +"*kwargs* に :class:`Context` がサポートしない属性を渡すと :exc:`TypeError` を" +"送出します。\n" +"*kwargs* に属性の不正な値を渡すと :exc:`TypeError` または :exc:`ValueError` " +"を送出します。" -#: ../../library/decimal.rst:1045 msgid "" ":meth:`localcontext` now supports setting context attributes through the use " "of keyword arguments." msgstr "" +":meth:`localcontext` でキーワード引数を使ってコンテキストの属性を設定できるよ" +"うになりました。" -#: ../../library/decimal.rst:1050 msgid "" "Return a context object initialized to the proper values for one of the IEEE " "interchange formats. The argument must be a multiple of 32 and less than :" "const:`IEEE_CONTEXT_MAX_BITS`." msgstr "" +"IEEE の交換形式のいずれかに適した値で初期化したコンテキストオブジェクトを返し" +"ます。\n" +"引数は 32 の倍数で、:const:`IEEE_CONTEXT_MAX_BITS` 未満でなければなりません。" -#: ../../library/decimal.rst:1056 msgid "" "New contexts can also be created using the :class:`Context` constructor " "described below. In addition, the module provides three pre-made contexts:" msgstr "" "新たなコンテキストは、以下で説明する :class:`Context` コンストラクタを使って" -"生成できます。その他にも、 :mod:`decimal` モジュールでは作成済みのコンテキス" -"トを提供しています:" +"作成できます。\n" +"このほか、モジュールは作成済みのコンテキストを 3 つ提供しています。" #: ../../library/decimal.rst:1062 msgid "" @@ -1709,48 +1919,53 @@ msgstr "" "上に挙げた三つのコンテキストに加え、 :class:`Context` コンストラクタを使って" "新たなコンテキストを生成できます。" -#: ../../library/decimal.rst:1109 msgid "" "Creates a new context. If a field is not specified or is :const:`None`, the " "default values are copied from the :const:`DefaultContext`. If the *flags* " "field is not specified or is :const:`None`, all flags are cleared." msgstr "" -"新たなコンテキストを生成します。あるフィールドが定義されていないか :const:" -"`None` であれば、 :const:`DefaultContext` からデフォルト値をコピーします。 " -"*flags* フィールドが設定されていいか :const:`None` の場合には、全てのフラグが" -"クリアされます。" +"新たなコンテキストを生成します。\n" +"あるフィールドが定義されていないか :const:`None` であれば、 :const:" +"`DefaultContext` からデフォルト値をコピーします。\n" +"*flags* フィールドが指定されていないか :const:`None` の場合には、全てのフラグ" +"がクリアされます。" -#: ../../library/decimal.rst:1115 msgid "" "An integer in the range [``1``, :const:`MAX_PREC`] that sets the precision " "for arithmetic operations in the context." msgstr "" +"コンテキスト内の算術演算の精度を設定する、[``1``, :const:`MAX_PREC`] の範囲の" +"整数。" -#: ../../library/decimal.rst:1120 msgid "One of the constants listed in the section `Rounding Modes`_." -msgstr "" +msgstr "`Rounding Modes`_ 節に挙げられた定数のいずれか。" -#: ../../library/decimal.rst:1125 msgid "" "Lists of any signals to be set. Generally, new contexts should only set " "traps and leave the flags clear." msgstr "" +"設定するシグナルのリスト。\n" +"通常、新しいコンテキストではトラップだけを設定し、フラグはクリアしたままにし" +"てください。" -#: ../../library/decimal.rst:1131 msgid "" "Integers specifying the outer limits allowable for exponents. *Emin* must be " "in the range [:const:`MIN_EMIN`, ``0``], *Emax* in the range [``0``, :const:" "`MAX_EMAX`]." msgstr "" +"指数に許される範囲の上下限を指定する整数。\n" +"*Emin* は [:const:`MIN_EMIN`, ``0``]、*Emax* は [``0``, :const:`MAX_EMAX`] の" +"範囲でなければなりません。" -#: ../../library/decimal.rst:1137 msgid "" "Either ``0`` or ``1`` (the default). If set to ``1``, exponents are printed " "with a capital ``E``; otherwise, a lowercase ``e`` is used: " "``Decimal('6.02e+23')``." msgstr "" +"``0`` または ``1`` (デフォルト)。\n" +"``1`` にすると指数を大文字の ``E`` で表示し、それ以外では小文字の ``e`` を使" +"います: ``Decimal('6.02e+23')``。" -#: ../../library/decimal.rst:1143 msgid "" "Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` of " "a :class:`Decimal` instance representable in this context is strictly " @@ -1762,12 +1977,24 @@ msgid "" "exponent constraints; this preserves the value of the number but loses " "information about significant trailing zeros. For example::" msgstr "" +":class:`Decimal` インスタンスをこのコンテキストで表現するときの指数の制約を指" +"定する、``0`` (デフォルト) または ``1``。\n" +"``1`` にすると指数 ``e`` は ``Emin - prec + 1 <= e <= Emax - prec + 1`` の範" +"囲に厳しく制限されます。\n" +"*clamp* が ``0`` の場合は制約が緩く、:class:`Decimal` インスタンスの調整済み" +"指数が :attr:`~Context.Emax` 以下であればよいことになります。\n" +"*clamp* が ``1`` のときは、指数の制約を満たすよう、大きな正規数の指数を可能な" +"限り減らし、その分のゼロを係数に追加します。\n" +"この変換で数値は保たれますが、末尾のゼロの有効桁数に関する情報は失われま" +"す。\n" +"例えば次のようになります。 ::" -#: ../../library/decimal.rst:1154 msgid "" ">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" "Decimal('1.23000E+999')" msgstr "" +">>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')\n" +"Decimal('1.23000E+999')" #: ../../library/decimal.rst:1157 msgid "" @@ -1777,7 +2004,6 @@ msgstr "" "*clamp* の値 ``1`` は、IEEE 754 で規定された固定幅十進交換形式と互換にできま" "す。" -#: ../../library/decimal.rst:1160 msgid "" "The :class:`Context` class defines several general purpose methods as well " "as a large number of methods for doing arithmetic directly in a given " @@ -1789,15 +2015,16 @@ msgid "" "exp(context=C)``. Each :class:`Context` method accepts a Python integer (an " "instance of :class:`int`) anywhere that a Decimal instance is accepted." msgstr "" -":class:`Context` クラスでは、いくつかの汎用のメソッドの他、現在のコンテキスト" -"で算術演算を直接行うためのメソッドを数多く定義しています。加えて、 :class:" -"`Decimal` の各メソッドについて(:meth:`~Decimal.adjusted` および :meth:" -"`~Decimal.as_tuple` メソッドを例外として)対応する :class:`Context` のメソッド" -"が存在します。たとえば、 :class:`Context` インスタンス ``C`` と :class:" -"`Decimal` インスタンス ``x`` に対して、 ``C.exp(x)`` は ``x.exp(context=C)`` " -"と等価です。それぞれの :class:`Context` メソッドは、Decimal インスタンスが受" -"け付けられるところならどこでも、Python の整数 (:class:`int` のインスタンス) " -"を受け付けます。" +":class:`Context` クラスでは、いくつかの汎用のメソッドの他、指定されたコンテキ" +"ストで算術演算を直接行うためのメソッドを数多く定義しています。\n" +"加えて、 :class:`Decimal` の各メソッドについて(:meth:`~Decimal.adjusted` およ" +"び :meth:`~Decimal.as_tuple` メソッドを例外として)対応する :class:`Context` " +"のメソッドが存在します。\n" +"たとえば、 :class:`Context` インスタンス ``C`` と :class:`Decimal` インスタ" +"ンス ``x`` に対して、 ``C.exp(x)`` は ``x.exp(context=C)`` と等価です。\n" +"それぞれの :class:`Context` メソッドは、Decimal インスタンスが受け付けられる" +"ところならどこでも、Python の整数 (:class:`int` のインスタンス) を受け付けま" +"す。" #: ../../library/decimal.rst:1173 msgid "Resets all of the flags to ``0``." @@ -1840,7 +2067,6 @@ msgstr "" "もあります。以下の例は、丸められていない入力を使うということは和にゼロを加え" "ると結果が変わり得るという見本です:" -#: ../../library/decimal.rst:1201 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.4445') + Decimal('1.0023')\n" @@ -1848,6 +2074,11 @@ msgid "" ">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" "Decimal('4.44')" msgstr "" +">>> getcontext().prec = 3\n" +">>> Decimal('3.4445') + Decimal('1.0023')\n" +"Decimal('4.45')\n" +">>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')\n" +"Decimal('4.44')" #: ../../library/decimal.rst:1209 msgid "" @@ -1871,7 +2102,6 @@ msgstr "" "い、変換にコンテキストの精度、丸めメソッド、フラグ、そしてトラップが適用され" "ます。" -#: ../../library/decimal.rst:1220 msgid "" ">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" ">>> context.create_decimal_from_float(math.pi)\n" @@ -1882,15 +2112,22 @@ msgid "" " ...\n" "decimal.Inexact: None" msgstr "" +">>> context = Context(prec=5, rounding=ROUND_DOWN)\n" +">>> context.create_decimal_from_float(math.pi)\n" +"Decimal('3.1415')\n" +">>> context = Context(prec=5, traps=[Inexact])\n" +">>> context.create_decimal_from_float(math.pi)\n" +"Traceback (most recent call last):\n" +" ...\n" +"decimal.Inexact: None" -#: ../../library/decimal.rst:1235 msgid "" "Returns a value equal to ``Emin - prec + 1`` which is the minimum exponent " "value for subnormal results. When underflow occurs, the exponent is set to :" "const:`Etiny`." msgstr "" -"``Emin - prec + 1`` に等しい値を返します。演算結果の劣化が起こる桁の最小値で" -"す。アンダーフローが起きた場合、指数は :const:`Etiny` に設定されます。" +"非正規数の演算結果で取り得る最小の指数 ``Emin - prec + 1`` を返します。\n" +"アンダーフローが起きた場合、指数は :const:`Etiny` に設定されます。" #: ../../library/decimal.rst:1241 msgid "Returns a value equal to ``Emax - prec + 1``." @@ -1909,8 +2146,8 @@ msgstr "" "を生成して、算術演算を適用するというアプローチをとります。演算はアクティブな" "スレッドにおける現在のコンテキストの下で行われます。もう一つのアプローチは、" "コンテキストのメソッドを使った特定のコンテキスト下での計算です。コンテキスト" -"のメソッドは :class:`Decimal` クラスのメソッドに似ているので、ここでは簡単な" -"説明にとどめます。" +"のメソッドは ``Decimal`` クラスのメソッドに似ているので、ここでは簡単な説明に" +"とどめます。" #: ../../library/decimal.rst:1253 msgid "Returns the absolute value of *x*." @@ -2122,11 +2359,12 @@ msgstr "" "ンテキストの丸めモードを使って丸められます。結果は常に、Python バージョンにお" "いて正しく丸められます。" -#: ../../library/decimal.rst:1483 msgid "" "``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if " "``InvalidOperation`` is not trapped, then results in ``Decimal('NaN')``." msgstr "" +"``Decimal(0) ** Decimal(0)`` は ``InvalidOperation`` を発生させます。\n" +"``InvalidOperation`` をトラップしない場合は ``Decimal('NaN')`` になります。" #: ../../library/decimal.rst:1486 msgid "" @@ -2217,17 +2455,15 @@ msgstr "一つめの演算対象の指数部に二つめの値を加えたもの msgid "Returns a shifted copy of *x*, *y* times." msgstr "*x* を *y* 回シフトしたコピーを返します。" -#: ../../library/decimal.rst:1553 msgid "Square root of a non-negative number to context precision." -msgstr "*x* の平方根を精度いっぱいまで求めます。" +msgstr "非負の数の平方根をコンテキストの精度で求めます。" #: ../../library/decimal.rst:1558 msgid "Return the difference between *x* and *y*." msgstr "*x* と *y* の間の差を返します。" -#: ../../library/decimal.rst:1572 msgid "Rounds to an integer." -msgstr "最近傍の整数に値を丸めます。" +msgstr "整数に丸めます。" #: ../../library/decimal.rst:1577 msgid "Converts a number to a string using scientific notation." @@ -2237,18 +2473,20 @@ msgstr "数値を科学表記で文字列に変換します。" msgid "Constants" msgstr "定数" -#: ../../library/decimal.rst:1588 msgid "" "The highest version of the General Decimal Arithmetic Specification that " "this implementation complies with. See https://speleotrove.com/decimal/" "decarith.html for the specification." msgstr "" +"この実装が準拠する汎用十進演算仕様の最新のバージョン。\n" +"仕様は https://speleotrove.com/decimal/decarith.html を参照してください。" -#: ../../library/decimal.rst:1595 msgid "" "The following constants are only relevant for the C module. They are also " "included in the pure Python version for compatibility." msgstr "" +"次の定数は C モジュールにのみ関係します。\n" +"互換性のため、純 Python 版にも含まれています。" #: ../../library/decimal.rst:1599 msgid "32-bit" @@ -2282,13 +2520,11 @@ msgstr "``-849999999``" msgid "``-1999999999999999997``" msgstr "``-1999999999999999997``" -#: ../../library/decimal.rst:1609 msgid "``256``" -msgstr "" +msgstr "``256``" -#: ../../library/decimal.rst:1609 msgid "``512``" -msgstr "" +msgstr "``512``" #: ../../library/decimal.rst:1614 msgid "" @@ -2297,7 +2533,6 @@ msgstr "" "値は ``True`` です。現在のPythonは常にスレッドを持っているので、非推奨になり" "ました。" -#: ../../library/decimal.rst:1620 msgid "" "The default value is ``True``. If Python is :option:`configured using the --" "without-decimal-contextvar option <--without-decimal-contextvar>`, the C " @@ -2305,6 +2540,11 @@ msgid "" "value is ``False``. This is slightly faster in some nested context " "scenarios." msgstr "" +"デフォルト値は ``True`` です。\n" +"Python を :option:`--without-decimal-contextvar オプションで構成 <--without-" +"decimal-contextvar>` した場合、C 版はコルーチンローカルではなくスレッドローカ" +"ルのコンテキストを使い、値は ``False`` になります。\n" +"コンテキストを入れ子にする一部の状況では、こちらの方がわずかに高速です。" #: ../../library/decimal.rst:1629 msgid "Rounding modes" @@ -2548,7 +2788,6 @@ msgstr "" msgid "The following table summarizes the hierarchy of signals::" msgstr "これらのシグナルの階層構造をまとめると、以下の表のようになります::" -#: ../../library/decimal.rst:1789 msgid "" "exceptions.ArithmeticError(exceptions.Exception)\n" " DecimalException\n" @@ -2562,10 +2801,20 @@ msgid "" " Subnormal\n" " FloatOperation(DecimalException, exceptions.TypeError)" msgstr "" +"exceptions.ArithmeticError(exceptions.Exception)\n" +" DecimalException\n" +" Clamped\n" +" DivisionByZero(DecimalException, exceptions.ZeroDivisionError)\n" +" Inexact\n" +" Overflow(Inexact, Rounded)\n" +" Underflow(Inexact, Rounded, Subnormal)\n" +" InvalidOperation\n" +" Rounded\n" +" Subnormal\n" +" FloatOperation(DecimalException, exceptions.TypeError)" -#: ../../library/decimal.rst:1808 msgid "Floating-point notes" -msgstr "" +msgstr "浮動小数点に関する注意点" #: ../../library/decimal.rst:1812 msgid "Mitigating round-off error with increased precision" @@ -2582,7 +2831,6 @@ msgstr "" "に表現できるようになります); しかし、ゼロでない桁が一定の精度を越えている場合" "には、演算によっては依然として値丸めによる誤差を引き起こします。" -#: ../../library/decimal.rst:1818 msgid "" "The effects of round-off error can be amplified by the addition or " "subtraction of nearly offsetting quantities resulting in loss of " @@ -2590,8 +2838,11 @@ msgid "" "floating-point arithmetic with insufficient precision causes the breakdown " "of the associative and distributive properties of addition:" msgstr "" +"ほぼ相殺する量を加減算すると、丸め誤差の影響が増幅され、桁落ちが生じることが" +"あります。\n" +"Knuth は、精度の足りない浮動小数点演算の丸めによって、加算の結合法則や分配法" +"則が成り立たなくなる 2 つの示唆に富む例を挙げています:" -#: ../../library/decimal.rst:1824 msgid "" "# Examples from Seminumerical Algorithms, Section 4.2.2.\n" ">>> from decimal import Decimal, getcontext\n" @@ -2609,14 +2860,29 @@ msgid "" ">>> u * (v+w)\n" "Decimal('0.0060000')" msgstr "" +"# Seminumerical Algorithms の 4.2.2 節の例。\n" +">>> from decimal import Decimal, getcontext\n" +">>> getcontext().prec = 8\n" +"\n" +">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" +">>> (u + v) + w\n" +"Decimal('9.5111111')\n" +">>> u + (v + w)\n" +"Decimal('10')\n" +"\n" +">>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')\n" +">>> (u*v) + (u*w)\n" +"Decimal('0.01')\n" +">>> u * (v+w)\n" +"Decimal('0.0060000')" -#: ../../library/decimal.rst:1842 msgid "" "The :mod:`!decimal` module makes it possible to restore the identities by " "expanding the precision sufficiently to avoid loss of significance:" msgstr "" +":mod:`!decimal` モジュールでは、桁落ちを避けるのに十分な精度まで拡張すること" +"で、これらの等式を成り立たせることができます:" -#: ../../library/decimal.rst:1845 msgid "" ">>> getcontext().prec = 20\n" ">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" @@ -2631,17 +2897,30 @@ msgid "" ">>> u * (v+w)\n" "Decimal('0.0060000')" msgstr "" +">>> getcontext().prec = 20\n" +">>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')\n" +">>> (u + v) + w\n" +"Decimal('9.51111111')\n" +">>> u + (v + w)\n" +"Decimal('9.51111111')\n" +">>>\n" +">>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')\n" +">>> (u*v) + (u*w)\n" +"Decimal('0.0060000')\n" +">>> u * (v+w)\n" +"Decimal('0.0060000')" #: ../../library/decimal.rst:1862 msgid "Special values" msgstr "特殊値" -#: ../../library/decimal.rst:1864 msgid "" "The number system for the :mod:`!decimal` module provides special values " "including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``, and two zeros, " "``+0`` and ``-0``." msgstr "" +":mod:`!decimal` モジュールの数体系には、``NaN``、``sNaN``、``-Infinity``、" +"``Infinity``、そして 2 つのゼロ ``+0`` と ``-0`` という特殊な値があります。" #: ../../library/decimal.rst:1868 msgid "" @@ -2735,7 +3014,6 @@ msgstr "" "ロの大きさはやはりゼロなので、正のゼロと負のゼロは等しいとみなされ、符号は単" "なる参考にすぎません。" -#: ../../library/decimal.rst:1907 msgid "" "In addition to the two signed zeros which are distinct yet equal, there are " "various representations of zero with differing precisions yet equivalent in " @@ -2743,6 +3021,11 @@ msgid "" "normalized floating-point representations, it is not immediately obvious " "that the following calculation returns a value equal to zero:" msgstr "" +"表現が異なっても値が等しいこの 2 つの符号付きゼロに加え、精度は異なっても値は" +"等しいゼロの表現がさまざまにあります。\n" +"これには少し慣れが必要です。\n" +"正規化された浮動小数点表現に慣れていると、次の計算がゼロに等しい値を返すこと" +"は一見して分からないかもしれません:" #: ../../library/decimal.rst:1922 msgid "Working with threads" @@ -2768,15 +3051,17 @@ msgstr "" "同様に、:func:`setcontext` 関数は自動的に引数のコンテキストを現在のスレッドの" "コンテキストに設定します。" -#: ../../library/decimal.rst:1931 msgid "" "If :func:`setcontext` has not been called before :func:`getcontext`, then :" "func:`getcontext` will automatically create a new context for use in the " "current thread. New context objects have default values set from the :data:" "`decimal.DefaultContext` object." msgstr "" +":func:`setcontext` を呼ばずに :func:`getcontext` を呼ぶと、:func:" +"`getcontext` は現在のスレッドで使う新しいコンテキストを自動的に作成します。\n" +"新しいコンテキストオブジェクトのデフォルト値は :data:`decimal." +"DefaultContext` オブジェクトから設定されます。" -#: ../../library/decimal.rst:1936 msgid "" "The :data:`sys.flags.thread_inherit_context` flag affects the context for " "new threads. If the flag is false, new threads will start with an empty " @@ -2785,16 +3070,26 @@ msgid "" "is true, new threads will start with a copy of context from the caller of :" "meth:`threading.Thread.start`." msgstr "" +":data:`sys.flags.thread_inherit_context` フラグは、新しいスレッドのコンテキス" +"トに影響します。\n" +"フラグが偽なら、新しいスレッドは空のコンテキストで開始します。\n" +"この場合、:func:`getcontext` を呼ぶと新しいコンテキストオブジェクトを作成し、" +"*DefaultContext* のデフォルト値を使います。\n" +"フラグが真なら、新しいスレッドは :meth:`threading.Thread.start` の呼び出し元" +"のコンテキストのコピーで開始します。" -#: ../../library/decimal.rst:1943 msgid "" "To control the defaults so that each thread will use the same values " "throughout the application, directly modify the *DefaultContext* object. " "This should be done *before* any threads are started so that there won't be " "a race condition between threads calling :func:`getcontext`. For example::" msgstr "" +"アプリケーション全体で各スレッドが同じデフォルト値を使うようにするには、" +"*DefaultContext* オブジェクトを直接変更してください。\n" +"スレッド間で :func:`getcontext` の呼び出しが競合しないように、どのスレッドも" +"開始する *前に* 変更してください。\n" +"例えば次のようにします。 ::" -#: ../../library/decimal.rst:1948 msgid "" "# Set applicationwide defaults for all threads about to be launched\n" "DefaultContext.prec = 12\n" @@ -2809,6 +3104,19 @@ msgid "" "t3.start()\n" " . . ." msgstr "" +"# これから起動する全スレッドに対するアプリケーション共通のデフォルト値を設定" +"します\n" +"DefaultContext.prec = 12\n" +"DefaultContext.rounding = ROUND_DOWN\n" +"DefaultContext.traps = ExtendedContext.traps.copy()\n" +"DefaultContext.traps[InvalidOperation] = 1\n" +"setcontext(DefaultContext)\n" +"\n" +"# その後、スレッドを開始できます\n" +"t1.start()\n" +"t2.start()\n" +"t3.start()\n" +" . . ." #: ../../library/decimal.rst:1967 msgid "Recipes" @@ -2975,43 +3283,50 @@ msgstr "" msgid "Decimal FAQ" msgstr "Decimal FAQ" -#: ../../library/decimal.rst:2126 msgid "" "Q: It is cumbersome to type ``decimal.Decimal('1234.5')``. Is there a way " "to minimize typing when using the interactive interpreter?" msgstr "" +"Q: ``decimal.Decimal('1234.5')`` と入力するのは面倒です。\n" +"対話型インタープリタを使うときに入力を減らす方法はありますか?" -#: ../../library/decimal.rst:2129 msgid "A: Some users abbreviate the constructor to just a single letter:" -msgstr "" +msgstr "A: コンストラクタを 1 文字に省略して使う人もいます:" -#: ../../library/decimal.rst:2135 msgid "" "Q: In a fixed-point application with two decimal places, some inputs have " "many places and need to be rounded. Others are not supposed to have excess " "digits and need to be validated. What methods should be used?" msgstr "" +"Q: 小数点以下 2 桁を扱う固定小数点のアプリケーションで、桁数が多くて丸める必" +"要がある入力があります。\n" +"一方、余分な桁がないはずなので検証が必要な入力もあります。\n" +"どのメソッドを使えばよいですか?" -#: ../../library/decimal.rst:2139 msgid "" "A: The :meth:`~Decimal.quantize` method rounds to a fixed number of decimal " "places. If the :const:`Inexact` trap is set, it is also useful for " "validation:" msgstr "" +"A: :meth:`~Decimal.quantize` メソッドは小数点以下の桁数を固定して丸めます。\n" +":const:`Inexact` トラップを設定すれば、検証にも使えます:" -#: ../../library/decimal.rst:2157 msgid "" "Q: Once I have valid two place inputs, how do I maintain that invariant " "throughout an application?" msgstr "" +"Q: 小数点以下 2 桁の有効な入力を得た後、アプリケーション全体でこの条件を保つ" +"にはどうすればよいですか?" -#: ../../library/decimal.rst:2160 msgid "" "A: Some operations like addition, subtraction, and multiplication by an " "integer will automatically preserve fixed point. Others operations, like " "division and non-integer multiplication, will change the number of decimal " "places and need to be followed-up with a :meth:`~Decimal.quantize` step:" msgstr "" +"A: 加算、減算、整数との乗算などは、自動的に小数点の位置を保ちます。\n" +"除算や整数以外との乗算などは小数点以下の桁数を変えるので、その後に :meth:" +"`~Decimal.quantize` を適用する必要があります:" #: ../../library/decimal.rst:2178 msgid "" @@ -3021,25 +3336,27 @@ msgstr "" "固定小数点のアプリケーションを開発する際は、 :meth:`~Decimal.quantize` の段階" "を扱う関数を定義しておくと便利です:" -#: ../../library/decimal.rst:2192 msgid "" "Q: There are many ways to express the same value. The numbers ``200``, " "``200.000``, ``2E2``, and ``.02E+4`` all have the same value at various " "precisions. Is there a way to transform them to a single recognizable " "canonical value?" msgstr "" +"Q: 同じ値を表す方法がたくさんあります。\n" +"``200``、``200.000``、``2E2``、``.02E+4`` はすべて、精度は異なりますが同じ値" +"です。\n" +"これらを 1 つの分かりやすい標準形に変換する方法はありますか?" -#: ../../library/decimal.rst:2197 msgid "" "A: The :meth:`~Decimal.normalize` method maps all equivalent values to a " "single representative:" msgstr "" +"A: :meth:`~Decimal.normalize` メソッドは、等しい値をすべて 1 つの代表値に変換" +"します:" -#: ../../library/decimal.rst:2204 msgid "Q: When does rounding occur in a computation?" -msgstr "" +msgstr "Q: 計算のどの段階で丸めが行われますか?" -#: ../../library/decimal.rst:2206 msgid "" "A: It occurs *after* the computation. The philosophy of the decimal " "specification is that numbers are considered exact and are created " @@ -3048,6 +3365,12 @@ msgid "" "rounding (or other context operations) is applied to the *result* of the " "computation::" msgstr "" +"A: 計算の *後に* 行われます。\n" +"十進演算仕様の考え方では、数値は正確なものとみなし、現在のコンテキストとは無" +"関係に作成します。\n" +"現在のコンテキストより高い精度を持つこともあります。\n" +"計算はこれらの正確な入力を使って行い、その *結果* に丸めなどのコンテキストの" +"操作を適用します。 ::" #: ../../library/decimal.rst:2213 msgid "" @@ -3063,19 +3386,22 @@ msgid "" "Decimal('3.1416')" msgstr "" -#: ../../library/decimal.rst:2224 msgid "" "Q: Some decimal values always print with exponential notation. Is there a " "way to get a non-exponential representation?" msgstr "" +"Q: 10 進数の中には常に指数表記で表示される値があります。\n" +"指数を使わない表現にする方法はありますか?" -#: ../../library/decimal.rst:2227 msgid "" "A: For some values, exponential notation is the only way to express the " "number of significant places in the coefficient. For example, expressing " "``5.0E+3`` as ``5000`` keeps the value constant but cannot show the " "original's two-place significance." msgstr "" +"A: 値によっては、係数の有効桁数を表現するには指数表記が必要です。\n" +"例えば ``5.0E+3`` を ``5000`` と表しても値は変わりませんが、元の数値の有効桁" +"数が 2 桁であることは示せません。" #: ../../library/decimal.rst:2232 msgid "" @@ -3086,45 +3412,52 @@ msgstr "" "もしアプリケーションが有効数字の追跡を等閑視するならば、指数部や末尾のゼロを" "取り除き、有効数字を忘れ、しかし値を変えずにおくことは容易です:" -#: ../../library/decimal.rst:2242 msgid "Q: Is there a way to convert a regular float to a :class:`Decimal`?" -msgstr "" +msgstr "Q: 通常の float を :class:`Decimal` に変換する方法はありますか?" -#: ../../library/decimal.rst:2244 msgid "" "A: Yes, any binary floating-point number can be exactly expressed as a " "Decimal though an exact conversion may take more precision than intuition " "would suggest:" msgstr "" +"A: はい。\n" +"どの 2 進浮動小数点数も Decimal で正確に表現できます。\n" +"ただし、正確な変換には直感的に思う以上の精度が必要になることがあります:" -#: ../../library/decimal.rst:2248 msgid "" ">>> Decimal(math.pi)\n" "Decimal('3.141592653589793115997963468544185161590576171875')" msgstr "" +">>> Decimal(math.pi)\n" +"Decimal('3.141592653589793115997963468544185161590576171875')" -#: ../../library/decimal.rst:2253 msgid "" "Q: Within a complex calculation, how can I make sure that I haven't gotten a " "spurious result because of insufficient precision or rounding anomalies." msgstr "" +"Q: 複雑な計算で、精度不足や丸めの異常によって誤った結果が出ていないかを確認す" +"るにはどうすればよいですか?" -#: ../../library/decimal.rst:2256 msgid "" "A: The decimal module makes it easy to test results. A best practice is to " "re-run calculations using greater precision and with various rounding modes. " "Widely differing results indicate insufficient precision, rounding mode " "issues, ill-conditioned inputs, or a numerically unstable algorithm." msgstr "" +"A: decimal モジュールを使うと、結果を簡単に検証できます。\n" +"より高い精度とさまざまな丸めモードで再計算するのがよい方法です。\n" +"結果が大きく異なる場合は、精度の不足、丸めモードの問題、条件の悪い入力、また" +"は数値的に不安定なアルゴリズムが疑われます。" -#: ../../library/decimal.rst:2261 msgid "" "Q: I noticed that context precision is applied to the results of operations " "but not to the inputs. Is there anything to watch out for when mixing " "values of different precisions?" msgstr "" +"Q: コンテキストの精度は演算結果に適用され、入力には適用されないことが分かりま" +"した。\n" +"精度の異なる値を混ぜて使うときに、注意することはありますか?" -#: ../../library/decimal.rst:2265 msgid "" "A: Yes. The principle is that all values are considered to be exact and so " "is the arithmetic on those values. Only the results are rounded. The " @@ -3132,8 +3465,14 @@ msgid "" "disadvantage is that the results can look odd if you forget that the inputs " "haven't been rounded:" msgstr "" +"A: はい。\n" +"原則としてすべての値は正確なものとみなし、それらに対する算術演算も正確に行い" +"ます。\n" +"丸めるのは結果だけです。\n" +"入力については、入力したとおりの値が得られるという利点があります。\n" +"一方、入力が丸められていないことを忘れると、結果が奇妙に見えるという欠点があ" +"ります:" -#: ../../library/decimal.rst:2270 msgid "" ">>> getcontext().prec = 3\n" ">>> Decimal('3.104') + Decimal('2.104')\n" @@ -3141,6 +3480,11 @@ msgid "" ">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" "Decimal('5.20')" msgstr "" +">>> getcontext().prec = 3\n" +">>> Decimal('3.104') + Decimal('2.104')\n" +"Decimal('5.21')\n" +">>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')\n" +"Decimal('5.20')" #: ../../library/decimal.rst:2278 msgid "" @@ -3150,12 +3494,14 @@ msgstr "" "解決策は、精度を増やすか、単項プラス演算子を使って入力の丸めを強制することで" "す:" -#: ../../library/decimal.rst:2281 msgid "" ">>> getcontext().prec = 3\n" ">>> +Decimal('1.23456789') # unary plus triggers rounding\n" "Decimal('1.23')" msgstr "" +">>> getcontext().prec = 3\n" +">>> +Decimal('1.23456789') # 単項プラスで丸めます\n" +"Decimal('1.23')" #: ../../library/decimal.rst:2287 msgid "" @@ -3165,11 +3511,9 @@ msgstr "" "もしくは、入力を :meth:`Context.create_decimal` を使って生成時に丸めてしまう" "こともできます:" -#: ../../library/decimal.rst:2293 msgid "Q: Is the CPython implementation fast for large numbers?" -msgstr "" +msgstr "Q: CPython の実装は大きな数でも高速ですか?" -#: ../../library/decimal.rst:2295 msgid "" "A: Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of " "the decimal module integrate the high speed `libmpdec `_ for very " "large numbers." msgstr "" +"A: はい。\n" +"CPython と PyPy3 の実装では、decimal モジュールの C/CFFI 版に、任意精度で正し" +"く丸められる 10 進浮動小数点演算の高速ライブラリ `libmpdec `_ を組み込んでいます [#]_。\n" +"``libmpdec`` は中程度の大きさの数に `Karatsuba 法による乗算 `_ を、非常に大きな数に `数論変換 " +"`_ を使います。" -#: ../../library/decimal.rst:2305 msgid "" "The context must be adapted for exact arbitrary precision arithmetic. :attr:" "`~Context.Emin` and :attr:`~Context.Emax` should always be set to the " "maximum values, :attr:`~Context.clamp` should always be 0 (the default). " "Setting :attr:`~Context.prec` requires some care." msgstr "" +"正確な任意精度演算を行うには、コンテキストを調整する必要があります。\n" +":attr:`~Context.Emin` と :attr:`~Context.Emax` は常に範囲が最大になる値に設定" +"し、:attr:`~Context.clamp` は常に 0 (デフォルト) にしてください。\n" +":attr:`~Context.prec` の設定には少し注意が必要です。" -#: ../../library/decimal.rst:2309 msgid "" "The easiest approach for trying out bignum arithmetic is to use the maximum " "value for :attr:`~Context.prec` as well [#]_::" msgstr "" +"多倍長整数の演算を試す最も簡単な方法は、:attr:`~Context.prec` にも最大値を使" +"うことです [#]_。 ::" -#: ../../library/decimal.rst:2312 msgid "" ">>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" ">>> x = Decimal(2) ** 256\n" ">>> x / 128\n" "Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" msgstr "" +">>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))\n" +">>> x = Decimal(2) ** 256\n" +">>> x / 128\n" +"Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')" -#: ../../library/decimal.rst:2318 msgid "" "For inexact results, :const:`MAX_PREC` is far too large on 64-bit platforms " "and the available memory will be insufficient::" msgstr "" +"結果が不正確な場合、64 ビットプラットフォームでは :const:`MAX_PREC` が大きす" +"ぎるため、利用可能なメモリが足りなくなります。 ::" -#: ../../library/decimal.rst:2321 msgid "" ">>> Decimal(1) / 3\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "MemoryError" msgstr "" +">>> Decimal(1) / 3\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"MemoryError" -#: ../../library/decimal.rst:2326 msgid "" "On systems with overallocation (e.g. Linux), a more sophisticated approach " "is to adjust :attr:`~Context.prec` to the amount of available RAM. Suppose " "that you have 8GB of RAM and expect 10 simultaneous operands using a maximum " "of 500MB each::" msgstr "" +"メモリの過剰割り当てを行うシステム (Linux など) では、利用可能な RAM の容量に" +"合わせて :attr:`~Context.prec` を調整する方が適切です。\n" +"RAM が 8 GB あり、それぞれ最大 500 MB の演算対象を同時に 10 個使うことを想定" +"しているとします。 ::" -#: ../../library/decimal.rst:2330 msgid "" ">>> import sys\n" ">>>\n" @@ -3249,15 +3614,37 @@ msgid "" " File \"\", line 1, in \n" " decimal.Inexact: []" msgstr "" +">>> import sys\n" +">>>\n" +">>> # 1 つの演算対象が 8 バイトのワード単位で 500 MB を使う場合の最大桁数\n" +">>> # 1 ワードは 19 桁 (32 ビットビルドでは 4 バイトで 9 桁):\n" +">>> maxdigits = 19 * ((500 * 1024**2) // 8)\n" +">>>\n" +">>> # 動作を確認します:\n" +">>> c = Context(prec=maxdigits, Emax=MAX_EMAX, Emin=MIN_EMIN)\n" +">>> c.traps[Inexact] = True\n" +">>> setcontext(c)\n" +">>>\n" +">>> # 利用可能な精度を 9 で埋めます:\n" +">>> x = Decimal(0).logical_invert() * 9\n" +">>> sys.getsizeof(x)\n" +"524288112\n" +">>> x + 2\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +" decimal.Inexact: []" -#: ../../library/decimal.rst:2350 msgid "" "In general (and especially on systems without overallocation), it is " "recommended to estimate even tighter bounds and set the :attr:`Inexact` trap " "if all calculations are expected to be exact." msgstr "" +"すべての計算が正確になるはずなら、一般に (特に過剰割り当てを行わないシステム" +"では)、さらに厳密な上限を見積もり、:attr:`Inexact` トラップを設定することを推" +"奨します。" -#: ../../library/decimal.rst:2359 msgid "" "This approach now works for all exact results except for non-integer powers." msgstr "" +"この方法は、指数が整数でないべき乗を除くすべての正確な結果で使えるようになり" +"ました。" diff --git a/library/development.po b/library/development.po index 3348ddd46..f494f50e2 100644 --- a/library/development.po +++ b/library/development.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/development.rst:5 diff --git a/library/devmode.po b/library/devmode.po index eaccb4ece..df1e7aeaa 100644 --- a/library/devmode.po +++ b/library/devmode.po @@ -17,33 +17,37 @@ msgstr "" "Last-Translator: b785ccb154ea7c5e4722f287fb17d327_f3b4082, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/devmode.rst:4 msgid "Python Development Mode" msgstr "Python 開発モード" -#: ../../library/devmode.rst:8 msgid "" "The Python Development Mode introduces additional runtime checks that are " "too expensive to be enabled by default. It should not be more verbose than " "the default if the code is correct; new warnings are only emitted when an " "issue is detected." msgstr "" +"Python 開発モードは、コストが高すぎてデフォルトでは有効にできない追加の実行時" +"チェックを行います。\n" +"コードが正しければ、デフォルトより多くのメッセージが表示されることはないはず" +"です。\n" +"問題を検出したときだけ新たな警告を出します。" -#: ../../library/devmode.rst:13 msgid "" "It can be enabled using the :option:`-X dev <-X>` command line option or by " "setting the :envvar:`PYTHONDEVMODE` environment variable to ``1``." msgstr "" +":option:`-X dev <-X>` コマンドラインオプションを使うか、:envvar:" +"`PYTHONDEVMODE` 環境変数を ``1`` に設定すると有効にできます。" -#: ../../library/devmode.rst:16 msgid "See also :ref:`Python debug build `." -msgstr "" +msgstr ":ref:`Python のデバッグビルド ` も参照してください。" #: ../../library/devmode.rst:19 msgid "Effects of the Python Development Mode" @@ -99,107 +103,117 @@ msgstr "" "通常、上記の警告は デフォルトの :ref:`警告フィルタ ` によりフィルタリングされます。" -#: ../../library/devmode.rst:39 msgid "" "It behaves as if the :option:`-W default <-W>` command line option is used." msgstr "" +":option:`-W default <-W>` コマンドラインオプションを使った場合と同じ動作にな" +"ります。" -#: ../../library/devmode.rst:41 msgid "" "Use the :option:`-W error <-W>` command line option or set the :envvar:" "`PYTHONWARNINGS` environment variable to ``error`` to treat warnings as " "errors." msgstr "" +"警告をエラーとして扱うには、:option:`-W error <-W>` コマンドラインオプション" +"を使うか、:envvar:`PYTHONWARNINGS` 環境変数を ``error`` に設定してください。" -#: ../../library/devmode.rst:45 msgid "Install debug hooks on memory allocators to check for:" -msgstr "" +msgstr "メモリアロケーターにデバッグフックを設定し、次の問題をチェックします:" -#: ../../library/devmode.rst:47 msgid "Buffer underflow" -msgstr "" +msgstr "バッファーアンダーフロー" -#: ../../library/devmode.rst:48 msgid "Buffer overflow" -msgstr "" +msgstr "バッファーオーバーフロー" -#: ../../library/devmode.rst:49 msgid "Memory allocator API violation" -msgstr "" +msgstr "メモリアロケーター API の規則違反" -#: ../../library/devmode.rst:50 msgid "Unsafe usage of the GIL" -msgstr "" +msgstr "GIL の安全でない使用" -#: ../../library/devmode.rst:52 msgid "See the :c:func:`PyMem_SetupDebugHooks` C function." -msgstr "" +msgstr "C 関数 :c:func:`PyMem_SetupDebugHooks` を参照してください。" -#: ../../library/devmode.rst:54 msgid "" "It behaves as if the :envvar:`PYTHONMALLOC` environment variable is set to " "``debug``." msgstr "" +":envvar:`PYTHONMALLOC` 環境変数を ``debug`` に設定した場合と同じ動作になりま" +"す。" -#: ../../library/devmode.rst:57 msgid "" "To enable the Python Development Mode without installing debug hooks on " "memory allocators, set the :envvar:`PYTHONMALLOC` environment variable to " "``default``." msgstr "" +"メモリアロケーターにデバッグフックを設定せずに Python 開発モードを有効にする" +"には、:envvar:`PYTHONMALLOC` 環境変数を ``default`` に設定してください。" -#: ../../library/devmode.rst:61 msgid "" "Call :func:`faulthandler.enable` at Python startup to install handlers for " "the :const:`~signal.SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal." "SIGABRT`, :const:`~signal.SIGBUS` and :const:`~signal.SIGILL` signals to " "dump the Python traceback on a crash." msgstr "" +"Python 起動時に :func:`faulthandler.enable` を呼び、:const:`~signal." +"SIGSEGV`、:const:`~signal.SIGFPE`、:const:`~signal.SIGABRT`、:const:`~signal." +"SIGBUS`、:const:`~signal.SIGILL` シグナルのハンドラーを設定して、クラッシュ時" +"に Python のトレースバックを出力します。" -#: ../../library/devmode.rst:66 msgid "" "It behaves as if the :option:`-X faulthandler <-X>` command line option is " "used or if the :envvar:`PYTHONFAULTHANDLER` environment variable is set to " "``1``." msgstr "" +":option:`-X faulthandler <-X>` コマンドラインオプションを使うか、:envvar:" +"`PYTHONFAULTHANDLER` 環境変数を ``1`` に設定した場合と同じ動作になります。" -#: ../../library/devmode.rst:70 msgid "" "Enable :ref:`asyncio debug mode `. For example, :mod:" "`asyncio` checks for coroutines that were not awaited and logs them." msgstr "" +":ref:`asyncio のデバッグモード ` を有効にします。\n" +"例えば :mod:`asyncio` は await されなかったコルーチンを検出してログに記録しま" +"す。" -#: ../../library/devmode.rst:73 msgid "" "It behaves as if the :envvar:`PYTHONASYNCIODEBUG` environment variable is " "set to ``1``." msgstr "" +":envvar:`PYTHONASYNCIODEBUG` 環境変数を ``1`` に設定した場合と同じ動作になり" +"ます。" -#: ../../library/devmode.rst:76 msgid "" "Check the *encoding* and *errors* arguments for string encoding and decoding " "operations. Examples: :func:`open`, :meth:`str.encode` and :meth:`bytes." "decode`." msgstr "" +"文字列のエンコードとデコードで *encoding* と *errors* 引数をチェックしま" +"す。\n" +"対象の例として :func:`open`、:meth:`str.encode`、:meth:`bytes.decode` があり" +"ます。" -#: ../../library/devmode.rst:80 msgid "" "By default, for best performance, the *errors* argument is only checked at " "the first encoding/decoding error and the *encoding* argument is sometimes " "ignored for empty strings." msgstr "" +"デフォルトでは性能を優先するため、*errors* 引数は最初のエンコードまたはデコー" +"ドのエラー時にだけチェックし、空文字列では *encoding* 引数を無視する場合があ" +"ります。" -#: ../../library/devmode.rst:84 msgid "The :class:`io.IOBase` destructor logs ``close()`` exceptions." msgstr "" +":class:`io.IOBase` のデストラクタが ``close()`` の例外をログに記録します。" -#: ../../library/devmode.rst:85 msgid "" "Set the :attr:`~sys.flags.dev_mode` attribute of :data:`sys.flags` to " "``True``." msgstr "" +":data:`sys.flags` の :attr:`~sys.flags.dev_mode` 属性を ``True`` に設定しま" +"す。" -#: ../../library/devmode.rst:88 msgid "" "The Python Development Mode does not enable the :mod:`tracemalloc` module by " "default, because the overhead cost (to performance and memory) would be too " @@ -209,39 +223,51 @@ msgid "" "buffer overflow error logs the traceback where the memory block was " "allocated." msgstr "" +"Python 開発モードでは、性能とメモリのオーバーヘッドが大きすぎるため、:mod:" +"`tracemalloc` モジュールをデフォルトでは有効にしません。\n" +":mod:`tracemalloc` モジュールを有効にすると、一部のエラーの発生元に関する追加" +"情報が得られます。\n" +"例えば :exc:`ResourceWarning` はリソース割り当て時のトレースバックを記録し、" +"バッファーオーバーフローのエラーはメモリブロック割り当て時のトレースバックを" +"記録します。" -#: ../../library/devmode.rst:95 msgid "" "The Python Development Mode does not prevent the :option:`-O` command line " "option from removing :keyword:`assert` statements nor from setting :const:" "`__debug__` to ``False``." msgstr "" +"Python 開発モードを有効にしても、:option:`-O` コマンドラインオプションによ" +"る :keyword:`assert` 文の削除や、:const:`__debug__` の ``False`` への設定は妨" +"げられません。" -#: ../../library/devmode.rst:99 msgid "" "The Python Development Mode can only be enabled at the Python startup. Its " "value can be read from :data:`sys.flags.dev_mode `." msgstr "" +"Python 開発モードは Python 起動時にのみ有効にできます。\n" +"その値は :data:`sys.flags.dev_mode ` から取得できます。" -#: ../../library/devmode.rst:102 msgid "The :class:`io.IOBase` destructor now logs ``close()`` exceptions." msgstr "" +":class:`io.IOBase` のデストラクタが ``close()`` の例外をログに記録するように" +"なりました。" -#: ../../library/devmode.rst:105 msgid "" "The *encoding* and *errors* arguments are now checked for string encoding " "and decoding operations." msgstr "" +"文字列のエンコードとデコードで *encoding* と *errors* 引数をチェックするよう" +"になりました。" #: ../../library/devmode.rst:111 msgid "ResourceWarning Example" msgstr "ResourceWarning の例" -#: ../../library/devmode.rst:113 msgid "" "Example of a script counting the number of lines of the text file specified " "in the command line::" msgstr "" +"コマンドラインで指定したテキストファイルの行数を数えるスクリプトの例です。 ::" #: ../../library/devmode.rst:116 msgid "" @@ -267,11 +293,13 @@ msgstr "" "if __name__ == \"__main__\":\n" " main()" -#: ../../library/devmode.rst:127 msgid "" "The script does not close the file explicitly. By default, Python does not " "emit any warning. Example using README.txt, which has 269 lines:" msgstr "" +"このスクリプトはファイルを明示的に閉じていません。\n" +"デフォルトでは Python は警告を出しません。\n" +"269 行の README.txt を使った例です:" #: ../../library/devmode.rst:130 msgid "" @@ -281,11 +309,11 @@ msgstr "" "$ python script.py README.txt\n" "269" -#: ../../library/devmode.rst:135 msgid "" "Enabling the Python Development Mode displays a :exc:`ResourceWarning` " "warning:" msgstr "" +"Python 開発モードを有効にすると :exc:`ResourceWarning` 警告が表示されます:" #: ../../library/devmode.rst:137 msgid "" @@ -303,11 +331,11 @@ msgstr "" " main()\n" "ResourceWarning: Enable tracemalloc to get the object allocation traceback" -#: ../../library/devmode.rst:145 msgid "" "In addition, enabling :mod:`tracemalloc` shows the line where the file was " "opened:" msgstr "" +"さらに :mod:`tracemalloc` を有効にすると、ファイルを開いた行が表示されます:" #: ../../library/devmode.rst:148 msgid "" @@ -333,10 +361,11 @@ msgstr "" " File \"script.py\", lineno 4\n" " fp = open(sys.argv[1])" -#: ../../library/devmode.rst:160 msgid "" "The fix is to close explicitly the file. Example using a context manager::" msgstr "" +"ファイルを明示的に閉じれば修正できます。\n" +"コンテキストマネージャを使った例です。 ::" #: ../../library/devmode.rst:162 msgid "" @@ -352,21 +381,23 @@ msgstr "" " nlines = len(fp.readlines())\n" " print(nlines)" -#: ../../library/devmode.rst:168 msgid "" "Not closing a resource explicitly can leave a resource open for way longer " "than expected; it can cause severe issues upon exiting Python. It is bad in " "CPython, but it is even worse in PyPy. Closing resources explicitly makes an " "application more deterministic and more reliable." msgstr "" +"リソースを明示的に閉じないと、予想よりずっと長い間開いたままになり、Python 終" +"了時に重大な問題を起こすことがあります。\n" +"CPython でも問題ですが、PyPy ではさらに深刻です。\n" +"リソースを明示的に閉じることで、アプリケーションの動作がより確定的になり、信" +"頼性も高まります。" -#: ../../library/devmode.rst:175 msgid "Bad file descriptor error example" -msgstr "" +msgstr "Bad file descriptor エラーの例" -#: ../../library/devmode.rst:177 msgid "Script displaying the first line of itself::" -msgstr "" +msgstr "自分自身の最初の行を表示するスクリプトです。 ::" #: ../../library/devmode.rst:179 msgid "" @@ -392,9 +423,8 @@ msgstr "" "\n" "main()" -#: ../../library/devmode.rst:190 msgid "By default, Python does not emit any warning:" -msgstr "" +msgstr "デフォルトでは Python は警告を出しません:" #: ../../library/devmode.rst:192 msgid "" @@ -404,11 +434,12 @@ msgstr "" "$ python script.py\n" "import os" -#: ../../library/devmode.rst:197 msgid "" "The Python Development Mode shows a :exc:`ResourceWarning` and logs a \"Bad " "file descriptor\" error when finalizing the file object:" msgstr "" +"Python 開発モードでは :exc:`ResourceWarning` が表示され、ファイルオブジェクト" +"のファイナライズ時に \"Bad file descriptor\" エラーがログに記録されます:" #: ../../library/devmode.rst:200 msgid "" @@ -438,7 +469,6 @@ msgstr "" " main()\n" "OSError: [Errno 9] Bad file descriptor" -#: ../../library/devmode.rst:213 msgid "" "``os.close(fp.fileno())`` closes the file descriptor. When the file object " "finalizer tries to close the file descriptor again, it fails with the ``Bad " @@ -446,9 +476,16 @@ msgid "" "worst case scenario, closing it twice can lead to a crash (see :issue:" "`18748` for an example)." msgstr "" +"``os.close(fp.fileno())`` はファイル記述子を閉じます。\n" +"ファイルオブジェクトのファイナライザーがそのファイル記述子を再度閉じようとす" +"ると、``Bad file descriptor`` エラーで失敗します。\n" +"ファイル記述子は 1 回だけ閉じなければなりません。\n" +"2 回閉じると、最悪の場合クラッシュすることがあります (例として :issue:" +"`18748` を参照してください)。" -#: ../../library/devmode.rst:219 msgid "" "The fix is to remove the ``os.close(fp.fileno())`` line, or open the file " "with ``closefd=False``." msgstr "" +"``os.close(fp.fileno())`` の行を削除するか、``closefd=False`` を指定してファ" +"イルを開けば修正できます。" diff --git a/library/dialog.po b/library/dialog.po index c57f1dda6..a058e3ef5 100644 --- a/library/dialog.po +++ b/library/dialog.po @@ -16,37 +16,36 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/dialog.rst:2 msgid "Tkinter dialogs" -msgstr "" +msgstr "Tkinter のダイアログ" -#: ../../library/dialog.rst:5 msgid ":mod:`!tkinter.simpledialog` --- Standard Tkinter input dialogs" -msgstr "" +msgstr ":mod:`!tkinter.simpledialog` --- Tkinter の標準入力ダイアログ" #: ../../library/dialog.rst:10 msgid "**Source code:** :source:`Lib/tkinter/simpledialog.py`" msgstr "**ソースコード:** :source:`Lib/tkinter/simpledialog.py`" -#: ../../library/dialog.rst:14 msgid "" "The :mod:`!tkinter.simpledialog` module contains convenience classes and " "functions for creating simple modal dialogs to get a value from the user." msgstr "" +":mod:`!tkinter.simpledialog` モジュールには、ユーザーから値を受け取るための単" +"純なモーダルダイアログを作る便利なクラスと関数があります。" -#: ../../library/dialog.rst:22 msgid "" "Prompt the user to enter a value of the desired type and return it, or " "``None`` if the dialog is cancelled." msgstr "" +"指定した型の値を入力するようユーザーに促し、その値を返します。\n" +"ダイアログをキャンセルした場合は ``None`` を返します。" -#: ../../library/dialog.rst:25 msgid "" "*title* is the dialog title and *prompt* the message shown above the entry. " "*initialvalue* is the value initially placed in the entry. *parent* is the " @@ -55,26 +54,38 @@ msgid "" "value. :func:`askstring` also accepts *show*, a character used to mask the " "entered text, for example ``'*'`` to hide a password." msgstr "" +"*title* はダイアログのタイトル、*prompt* は入力欄の上に表示するメッセージで" +"す。\n" +"*initialvalue* は入力欄の初期値です。\n" +"*parent* はダイアログの背後に置くウィンドウです。\n" +":func:`askinteger` と :func:`askfloat` は、入力値の範囲を制限する *minvalue* " +"と *maxvalue* も受け付けます。\n" +":func:`askstring` は、入力されたテキストを隠す文字を指定する *show* も受け付" +"けます。\n" +"例えばパスワードを隠すには ``'*'`` を指定します。" -#: ../../library/dialog.rst:35 msgid "" "The base class for custom dialogs. Instantiating it shows the dialog modally " "and returns once the user closes it; the entered value is then available in " "the :attr:`!result` attribute." msgstr "" +"独自のダイアログの基底クラスです。\n" +"インスタンス化するとダイアログをモーダルに表示し、ユーザーが閉じると戻りま" +"す。\n" +"入力された値は :attr:`!result` 属性から取得できます。" -#: ../../library/dialog.rst:41 msgid "" "The value produced by :meth:`apply`, or ``None`` if the dialog was cancelled." msgstr "" +":meth:`apply` が生成した値、またはダイアログがキャンセルされた場合は " +"``None``。" -#: ../../library/dialog.rst:46 msgid "" "Override to construct the dialog's interface and return the widget that " "should have initial focus." msgstr "" -"ダイアログインターフェースの構築をオーバーライドし、初期フォーカスを持つべき" -"ウィジットを返します。" +"このメソッドをオーバーライドしてダイアログのインターフェースを構築し、初期" +"フォーカスを持たせるウィジェットを返してください。" #: ../../library/dialog.rst:51 msgid "" @@ -84,29 +95,37 @@ msgstr "" "デフォルト動作はOKとCancelボタンを追加します。カスタムのボタンレイアウトが必" "要であればオーバーライドします。" -#: ../../library/dialog.rst:56 msgid "" "Validate the data entered by the user. Return true if it is valid, in which " "case the dialog proceeds to :meth:`apply`; return false to keep the dialog " "open. The default implementation always returns true; override it to check " "the input." msgstr "" +"ユーザーが入力したデータを検証します。\n" +"有効なら真を返し、ダイアログは :meth:`apply` の処理に進みます。\n" +"偽を返すとダイアログを開いたままにします。\n" +"デフォルトの実装は常に真を返します。\n" +"入力をチェックするにはオーバーライドしてください。" -#: ../../library/dialog.rst:64 msgid "" "Process the data entered by the user, for example by storing it in the :attr:" "`!result` attribute. Called after :meth:`validate` succeeds and just before " "the dialog is destroyed. The default implementation does nothing; override " "it to act on or store the result." msgstr "" +"ユーザーが入力したデータを、例えば :attr:`!result` 属性に保存するなどして処理" +"します。\n" +":meth:`validate` が成功した後、ダイアログが破棄される直前に呼ばれます。\n" +"デフォルトの実装は何もしません。\n" +"結果を使って処理したり保存したりするにはオーバーライドしてください。" -#: ../../library/dialog.rst:73 msgid "" "Destroy the dialog window, clearing the reference to the widget that had the " "initial focus." msgstr "" +"ダイアログウィンドウを破棄し、初期フォーカスを持っていたウィジェットへの参照" +"をクリアします。" -#: ../../library/dialog.rst:79 msgid "" "A simple modal dialog that displays the message *text* above a row of push " "buttons whose labels are given by *buttons*, and returns the index of the " @@ -115,30 +134,36 @@ msgid "" "through the window manager, *title* the window title, and *class_* the Tk " "class name of the window." msgstr "" +"*buttons* でラベルを指定したボタンを横に並べ、その上にメッセージ *text* を表" +"示する単純なモーダルダイアログです。\n" +"ユーザーが押したボタンのインデックスを返します。\n" +"*default* は Return キーで作動するボタンのインデックス、*cancel* はウィンドウ" +"マネージャからウィンドウを閉じたときに返すインデックス、*title* はウィンドウ" +"のタイトル、*class_* はウィンドウの Tk クラス名です。" -#: ../../library/dialog.rst:88 msgid "" "Display the dialog, wait until the user presses a button or closes the " "window, and return the index of the chosen button." msgstr "" +"ダイアログを表示し、ユーザーがボタンを押すかウィンドウを閉じるまで待って、選" +"択されたボタンのインデックスを返します。" -#: ../../library/dialog.rst:94 msgid ":mod:`!tkinter.filedialog` --- File selection dialogs" -msgstr "" +msgstr ":mod:`!tkinter.filedialog` --- ファイル選択ダイアログ" #: ../../library/dialog.rst:99 msgid "**Source code:** :source:`Lib/tkinter/filedialog.py`" msgstr "**ソースコード:** :source:`Lib/tkinter/filedialog.py`" -#: ../../library/dialog.rst:103 msgid "" "The :mod:`!tkinter.filedialog` module provides classes and factory functions " "for creating file/directory selection windows." msgstr "" +":mod:`!tkinter.filedialog` モジュールは、ファイルやディレクトリの選択ウィンド" +"ウを作るクラスとファクトリ関数を提供します。" -#: ../../library/dialog.rst:107 msgid "Native load/save dialogs" -msgstr "" +msgstr "ネイティブの読み込み・保存ダイアログ" #: ../../library/dialog.rst:109 msgid "" @@ -188,7 +213,6 @@ msgstr "*multiple* - 真の場合、複数要素の選択を許可します" msgid "**Static factory functions**" msgstr "**静的なファクトリ関数**" -#: ../../library/dialog.rst:131 msgid "" "The below functions when called create a modal, native look-and-feel dialog, " "wait for the user's selection, and return it. The exact return value depends " @@ -197,192 +221,208 @@ msgid "" "vary between platforms and Tk versions, so test the result for truth rather " "than comparing it with a specific value." msgstr "" +"以下の関数を呼ぶと、ネイティブのルックアンドフィールを持つモーダルダイアログ" +"を作り、ユーザーの選択を待って、その結果を返します。\n" +"具体的な返り値は関数によって異なります (以下を参照)。\n" +"ダイアログをキャンセルした場合は空文字列、空タプル、または ``None`` になりま" +"す。\n" +"この空の値の型はプラットフォームや Tk のバージョンによって異なる場合があるた" +"め、特定の値と比較するのではなく、結果の真偽値を調べてください。" -#: ../../library/dialog.rst:142 msgid "" "Create an :class:`Open` dialog. :func:`askopenfile` returns the opened file " "object, or ``None`` if the dialog is cancelled. :func:`askopenfiles` returns " "a list of the opened file objects, or an empty tuple if cancelled. The files " "are opened in mode *mode* (read-only ``'r'`` by default)." msgstr "" +":class:`Open` ダイアログを作ります。\n" +":func:`askopenfile` は開いたファイルオブジェクトを返し、ダイアログをキャンセ" +"ルした場合は ``None`` を返します。\n" +":func:`askopenfiles` は開いたファイルオブジェクトのリストを返し、キャンセルし" +"た場合は空タプルを返します。\n" +"ファイルは *mode* で指定したモード (デフォルトは読み取り専用の ``'r'``) で開" +"きます。" -#: ../../library/dialog.rst:151 msgid "" "Create a :class:`SaveAs` dialog and return the opened file object, or " "``None`` if the dialog is cancelled. The file is opened in mode *mode* " "(``'w'`` by default)." msgstr "" +":class:`SaveAs` ダイアログを作り、開いたファイルオブジェクトを返します。\n" +"ダイアログをキャンセルした場合は ``None`` を返します。\n" +"ファイルは *mode* で指定したモード (デフォルトは ``'w'``) で開きます。" -#: ../../library/dialog.rst:158 msgid "" "Create an :class:`Open` dialog. :func:`askopenfilename` returns the selected " "filename as a string, or an empty string if the dialog is cancelled. :func:" "`askopenfilenames` returns a tuple of the selected filenames, or an empty " "tuple if cancelled." msgstr "" +":class:`Open` ダイアログを作ります。\n" +":func:`askopenfilename` は選択したファイル名を文字列として返し、ダイアログを" +"キャンセルした場合は空文字列を返します。\n" +":func:`askopenfilenames` は選択したファイル名のタプルを返し、キャンセルした場" +"合は空タプルを返します。" -#: ../../library/dialog.rst:166 msgid "" "Create a :class:`SaveAs` dialog and return the selected filename as a " "string, or an empty string if the dialog is cancelled." msgstr "" +":class:`SaveAs` ダイアログを作り、選択したファイル名を文字列として返しま" +"す。\n" +"ダイアログをキャンセルした場合は空文字列を返します。" -#: ../../library/dialog.rst:171 msgid "" "Prompt the user to select a directory, and return its path as a string, or " "an empty string if the dialog is cancelled. Additional keyword option: " "*mustexist* - if true, the user may only select an existing directory (false " "by default)." msgstr "" +"ユーザーにディレクトリを選択するよう促し、そのパスを文字列として返します。\n" +"ダイアログをキャンセルした場合は空文字列を返します。\n" +"追加のキーワードオプション *mustexist* を真にすると、ユーザーは既存のディレク" +"トリだけを選択できます (デフォルトは偽)。" -#: ../../library/dialog.rst:180 msgid "" "The above three classes provide native dialog windows for loading and saving " "files and for selecting a directory." msgstr "" +"上記の 3 つのクラスは、ファイルの読み込み・保存とディレクトリの選択に使うネイ" +"ティブのダイアログウィンドウを提供します。" #: ../../library/dialog.rst:183 msgid "**Convenience classes**" msgstr "**便利なクラス**" -#: ../../library/dialog.rst:185 msgid "" "The below classes are used for creating file/directory windows from scratch. " "These do not emulate the native look-and-feel of the platform." msgstr "" +"以下のクラスは、ファイルやディレクトリのウィンドウを一から作るために使いま" +"す。\n" +"プラットフォームのネイティブのルックアンドフィールは再現しません。" -#: ../../library/dialog.rst:188 msgid "" "The *FileDialog* class should be subclassed for custom event handling and " "behaviour." msgstr "" +"イベント処理や動作をカスタマイズするには、*FileDialog* クラスをサブクラス化し" +"てください。" -#: ../../library/dialog.rst:193 msgid "Create a basic file selection dialog." -msgstr "" +msgstr "基本的なファイル選択ダイアログを作ります。" -#: ../../library/dialog.rst:197 msgid "Trigger the termination of the dialog window." -msgstr "" +msgstr "ダイアログウィンドウの終了を開始します。" -#: ../../library/dialog.rst:201 msgid "Event handler for double-click event on directory." -msgstr "" +msgstr "ディレクトリのダブルクリックイベントのハンドラー。" -#: ../../library/dialog.rst:205 msgid "Event handler for click event on directory." -msgstr "" +msgstr "ディレクトリのクリックイベントのハンドラー。" -#: ../../library/dialog.rst:209 msgid "Event handler for double-click event on file." -msgstr "" +msgstr "ファイルのダブルクリックイベントのハンドラー。" -#: ../../library/dialog.rst:213 msgid "Event handler for single-click event on file." -msgstr "" +msgstr "ファイルのシングルクリックイベントのハンドラー。" -#: ../../library/dialog.rst:217 msgid "Filter the files by directory." -msgstr "" +msgstr "ディレクトリでファイルを絞り込みます。" -#: ../../library/dialog.rst:221 msgid "Retrieve the file filter currently in use." -msgstr "" +msgstr "現在使っているファイルフィルターを取得します。" -#: ../../library/dialog.rst:225 msgid "Retrieve the currently selected item." -msgstr "" +msgstr "現在選択されている項目を取得します。" -#: ../../library/dialog.rst:229 msgid "Render dialog and start event loop." -msgstr "" +msgstr "ダイアログを表示し、イベントループを開始します。" -#: ../../library/dialog.rst:233 msgid "Exit dialog returning current selection." -msgstr "" +msgstr "現在の選択を返してダイアログを終了します。" -#: ../../library/dialog.rst:237 msgid "" "Called when the user confirms the current selection. The base implementation " "accepts the selection and closes the dialog; :class:`LoadFileDialog` and :" "class:`SaveFileDialog` override it to check the selection first." msgstr "" +"ユーザーが現在の選択を確定したときに呼ばれます。\n" +"基底クラスの実装は選択を受け入れてダイアログを閉じます。\n" +":class:`LoadFileDialog` と :class:`SaveFileDialog` はこれをオーバーライドし、" +"先に選択をチェックします。" -#: ../../library/dialog.rst:244 msgid "Exit dialog returning filename, if any." -msgstr "" +msgstr "ダイアログを終了し、ファイル名があれば返します。" -#: ../../library/dialog.rst:248 msgid "Set the file filter." -msgstr "" +msgstr "ファイルフィルターを設定します。" -#: ../../library/dialog.rst:252 msgid "Update the current file selection to *file*." -msgstr "" +msgstr "現在のファイルの選択を *file* に更新します。" -#: ../../library/dialog.rst:257 msgid "" "A subclass of FileDialog that creates a dialog window for selecting an " "existing file." msgstr "" +"既存のファイルを選択するダイアログウィンドウを作る FileDialog のサブクラスで" +"す。" -#: ../../library/dialog.rst:262 msgid "" "Test that a file is provided and that the selection indicates an already " "existing file." msgstr "" +"ファイルが指定されていて、選択が既存のファイルを指していることを確認します。" -#: ../../library/dialog.rst:267 msgid "" "A subclass of FileDialog that creates a dialog window for selecting a " "destination file." msgstr "" +"保存先のファイルを選択するダイアログウィンドウを作る FileDialog のサブクラス" +"です。" -#: ../../library/dialog.rst:272 msgid "" "Test whether or not the selection points to a valid file that is not a " "directory. Confirmation is required if an already existing file is selected." msgstr "" +"選択がディレクトリではなく、有効なファイルを指しているかを確認します。\n" +"既存のファイルを選択した場合は確認を求めます。" -#: ../../library/dialog.rst:277 msgid ":mod:`!tkinter.commondialog` --- Dialog window templates" -msgstr "" +msgstr ":mod:`!tkinter.commondialog` --- ダイアログウィンドウのテンプレート" -#: ../../library/dialog.rst:282 msgid "**Source code:** :source:`Lib/tkinter/commondialog.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/tkinter/commondialog.py`" -#: ../../library/dialog.rst:286 msgid "" "The :mod:`!tkinter.commondialog` module provides the :class:`Dialog` class " "that is the base class for dialogs defined in other supporting modules." msgstr "" +":mod:`!tkinter.commondialog` モジュールは、他の関連モジュールで定義するダイア" +"ログの基底クラスとなる :class:`Dialog` クラスを提供します。" -#: ../../library/dialog.rst:293 msgid "Render the Dialog window." -msgstr "" +msgstr "Dialog ウィンドウを表示します。" -#: ../../library/dialog.rst:297 msgid ":mod:`!tkinter.dialog` --- Classic Tk dialog boxes" -msgstr "" +msgstr ":mod:`!tkinter.dialog` --- 従来の Tk ダイアログボックス" -#: ../../library/dialog.rst:302 msgid "**Source code:** :source:`Lib/tkinter/dialog.py`" -msgstr "" +msgstr "**ソースコード:** :source:`Lib/tkinter/dialog.py`" -#: ../../library/dialog.rst:306 msgid "" "The :mod:`!tkinter.dialog` module provides a simple modal dialog box built " "on the classic (non-themed) Tk widgets." msgstr "" +":mod:`!tkinter.dialog` モジュールは、従来の (テーマを使わない) Tk ウィジェッ" +"トで作った単純なモーダルダイアログボックスを提供します。" -#: ../../library/dialog.rst:311 msgid "" "The name of a bitmap (``'questhead'``) suitable for use as the *bitmap* of " "a :class:`Dialog`." msgstr "" +":class:`Dialog` の *bitmap* に適したビットマップの名前 (``'questhead'``)。" -#: ../../library/dialog.rst:316 msgid "" "Display a modal dialog box built from the classic (non-themed) Tk widgets " "and wait for the user to press one of its buttons. The options, given " @@ -392,13 +432,21 @@ msgid "" "*strings* (the sequence of button labels). After construction, the :attr:`!" "num` attribute holds the index of the button the user pressed." msgstr "" +"従来の (テーマを使わない) Tk ウィジェットで作ったモーダルダイアログボックスを" +"表示し、ユーザーがいずれかのボタンを押すまで待ちます。\n" +"*cnf* またはキーワード引数で渡すオプションはすべて必須です。\n" +"*title* (ウィンドウのタイトル)、*text* (メッセージ)、*bitmap* (:data:" +"`DIALOG_ICON` などのビットマップアイコンの名前)、*default* (デフォルトのボタ" +"ンのインデックス)、*strings* (ボタンのラベルのシーケンス) を指定します。\n" +"構築後、:attr:`!num` 属性にユーザーが押したボタンのインデックスが入ります。" -#: ../../library/dialog.rst:327 msgid "" "Do nothing. The dialog window is destroyed automatically before the " "constructor returns, so there is nothing left for this method to do." msgstr "" +"何もしません。\n" +"コンストラクタから戻る前にダイアログウィンドウは自動的に破棄されるため、この" +"メソッドが行うことは残っていません。" -#: ../../library/dialog.rst:334 msgid "Modules :mod:`tkinter.messagebox`, :ref:`tut-files`" -msgstr "" +msgstr ":mod:`tkinter.messagebox` モジュール、:ref:`tut-files`" diff --git a/library/difflib.po b/library/difflib.po index 8b30e9d51..cd3bf627e 100644 --- a/library/difflib.po +++ b/library/difflib.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/difflib.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!difflib` --- 差分の計算の補助" msgid "**Source code:** :source:`Lib/difflib.py`" msgstr "**ソースコード:** :source:`Lib/difflib.py`" -#: ../../library/difflib.rst:16 msgid "" "This module provides classes and functions for comparing sequences. Most of " "them compare sequences of text lines (for example lists of strings, or :term:" @@ -39,46 +38,64 @@ msgid "" "context and unified diffs -- formats produced by tools like :manpage:`diff " "` and :manpage:`git diff `." msgstr "" +"このモジュールはシーケンスを比較するクラスと関数を提供します。\n" +"その多くは、テキスト行のシーケンス (文字列のリストや :term:`ファイルオブジェ" +"クト ` など) を比較し、相違点を報告する :dfn:`差分 (diff)` を生" +"成します。\n" +"HTML のほか、:manpage:`diff ` や :manpage:`git diff ` " +"などのツールが生成するコンテキスト形式やユニファイド形式など、さまざまな形式" +"の差分を生成できます。" -#: ../../library/difflib.rst:24 msgid "" "Comparisons are done using a matching algorithm implemented in :class:" "`SequenceMatcher` -- a flexible class for comparing pairs of sequences of " "any type, not just text, so long as the sequence elements are :term:" "`hashable`." msgstr "" +"比較には :class:`SequenceMatcher` に実装されたマッチングアルゴリズムを使いま" +"す。\n" +"この柔軟なクラスは、要素が :term:`hashable` であれば、テキストに限らず任意の" +"型のシーケンスのペアを比較できます。" -#: ../../library/difflib.rst:33 msgid "Junk heuristic" -msgstr "" +msgstr "junk ヒューリスティック" -#: ../../library/difflib.rst:35 msgid "" ":mod:`!difflib` uses a :dfn:`junk` heuristic: some items are deemed to be :" "dfn:`junk`, and ignored when searching for similarities. Ideally, these are " "uninteresting or common items, such as blank lines or whitespace." msgstr "" +":mod:`!difflib` は :dfn:`junk` ヒューリスティックを使います。\n" +"一部の要素を :dfn:`junk` とみなし、共通部分を探す際に無視します。\n" +"理想的には、空行や空白など、重要でない要素や頻出する要素がこれに当たります。" -#: ../../library/difflib.rst:40 msgid "" "This heuristic can speed the algorithm up (because it reduces the number of " "possible combinations) and it can produce results that are more " "understandable for humans (typically breaking on whitespace). But it can " "also cause pathological cases:" msgstr "" +"このヒューリスティックは、組み合わせの候補を減らすためアルゴリズムを高速化で" +"き、人間に理解しやすい結果を生成することもあります (通常は空白で区切りま" +"す)。\n" +"ただし、次のような不都合が起きる場合もあります:" -#: ../../library/difflib.rst:45 msgid "" "Inappropriately chosen junk items can cause an unexpectedly **large** (but " "still correct) result." msgstr "" +"junk とする要素を不適切に選ぶと、正しいものの予想外に **大きな** 差分になる場" +"合があります。" -#: ../../library/difflib.rst:47 msgid "" "The default heuristic is **asymmetric**: only the second sequence is " "inspected when determining what is considered junk, so comparing A to B can " "give different results than comparing B to A and reversing the result." msgstr "" +"デフォルトのヒューリスティックは **非対称** です。\n" +"junk とみなす要素を決めるときは、2 つ目のシーケンスだけを調べます。\n" +"そのため、A を B と比較した結果と、B を A と比較した結果を反転したものが異な" +"る場合があります。" #: ../../library/difflib.rst:51 msgid "" @@ -86,19 +103,21 @@ msgid "" "that account for more than 1% it are considered *junk*." msgstr "" -#: ../../library/difflib.rst:54 msgid "" "Depending on your data, you should consider turning this heuristic off " "(setting :class:`~difflib.SequenceMatcher`'s *autojunk* argument to " "``False``) or tuning it (using the *isjunk* argument, perhaps to one of the :" "ref:`predefined functions `)." msgstr "" +"データによっては、このヒューリスティックを無効にする (:class:`~difflib." +"SequenceMatcher` の *autojunk* 引数を ``False`` にする) か、*isjunk* 引数で調" +"整することを検討してください。\n" +"*isjunk* には :ref:`定義済みの関数 ` のいずれかを指" +"定することもできます。" -#: ../../library/difflib.rst:61 msgid "The :mod:`!difflib` algorithm" -msgstr "" +msgstr ":mod:`!difflib` のアルゴリズム" -#: ../../library/difflib.rst:63 msgid "" "The algorithm used in :class:`SequenceMatcher` predates, and is a little " "fancier than, an algorithm published in the late 1980s by Ratcliff and " @@ -107,31 +126,38 @@ msgid "" "recursively handle the pieces of the sequences to the left and to the right " "of the matching subsequence." msgstr "" +":class:`SequenceMatcher` のアルゴリズムは、Ratcliff と Obershelp が 1980 年代" +"後半に「ゲシュタルトパターンマッチング」という大げさな名前で発表したアルゴリ" +"ズムよりも古く、少し高度なものです。\n" +"両方の入力に共通する最長の連続部分シーケンスを見つけ、その左右に残ったシーケ" +"ンスを再帰的に処理するという考え方です。" -#: ../../library/difflib.rst:72 msgid "" "`Pattern Matching: The Gestalt Approach `_" msgstr "" +"`Pattern Matching: The Gestalt Approach `_" -#: ../../library/difflib.rst:73 msgid "" "Discussion of a similar algorithm by John W. Ratcliff and D. E. Metzener. " "This was published in Dr. Dobb's Journal in July, 1988." msgstr "" +"John W. Ratcliff と D. E. Metzener による、類似のアルゴリズムの解説です。\n" +"1988 年 7 月の Dr. Dobb's Journal に掲載されました。" -#: ../../library/difflib.rst:76 msgid "" "As an extension to the Ratcliff and Obershelp algorithm, :mod:`!difflib` " "searches for the longest *junk-free* contiguous subsequence. See the :ref:" "`difflib-junk` section for details." msgstr "" +"Ratcliff と Obershelp のアルゴリズムを拡張し、:mod:`!difflib` は *junk を含ま" +"ない* 最長の連続部分シーケンスを探します。\n" +"詳しくは :ref:`difflib-junk` 節を参照してください。" -#: ../../library/difflib.rst:80 msgid "Timing" -msgstr "" +msgstr "時間計算量" -#: ../../library/difflib.rst:82 msgid "" "The basic Ratcliff-Obershelp algorithm is cubic time in the worst case and " "quadratic time in the expected case. :mod:`difflib`'s algorithm is quadratic " @@ -139,10 +165,14 @@ msgid "" "complicated way on how many elements the sequences have in common; best case " "time is linear." msgstr "" +"基本的な Ratcliff-Obershelp アルゴリズムの時間計算量は、最悪の場合は 3 次、期" +"待される場合は 2 次です。\n" +":mod:`difflib` のアルゴリズムは最悪の場合が 2 次で、期待される場合の振る舞い" +"は、シーケンスの共通要素数に複雑に依存します。\n" +"最良の場合の時間計算量は線形です。" -#: ../../library/difflib.rst:93 msgid "Diff generation" -msgstr "" +msgstr "差分の生成" #: ../../library/difflib.rst:99 msgid "" @@ -199,15 +229,17 @@ msgstr "``'? '``" msgid "line not present in either input sequence" msgstr "行は入力シーケンスのどちらにも存在しない" -#: ../../library/difflib.rst:118 msgid "" "Lines beginning with '``?``' attempt to guide the eye to intraline " "differences, and were not present in either input sequence. These lines can " "be confusing if the sequences contain whitespace characters, such as spaces, " "tabs or line breaks." msgstr "" +"'``?``' で始まる行は、行内の相違点を見つけやすくするためのもので、どちらの入" +"力シーケンスにも存在しません。\n" +"シーケンスにスペース、タブ、改行などの空白文字が含まれる場合、これらの行は分" +"かりにくくなることがあります。" -#: ../../library/difflib.rst:122 msgid "" "Note that :class:`Differ`\\ -generated deltas make no claim to be " "**minimal** diffs. To the contrary, minimal diffs are often counter-" @@ -216,6 +248,11 @@ msgid "" "matches preserves some notion of locality, at the occasional cost of " "producing a longer diff." msgstr "" +":class:`Differ` が生成する差分は、**最小** の差分であることを保証しません。\n" +"むしろ最小の差分は、100 ページ離れた偶然の一致など、対応付けられるところをす" +"べて対応付けるため、人間の直感に反することがよくあります。\n" +"対応付ける箇所を連続する一致部分に限ると、差分が長くなる場合はありますが、位" +"置的な近さをある程度保てます。" #: ../../library/difflib.rst:129 msgid "The :class:`Differ` class has this constructor:" @@ -249,17 +286,16 @@ msgstr "" "あるときに真を返します。デフォルトは ``None`` であり、どんな文字も junk とは" "見なされません。" -#: ../../library/difflib.rst:144 msgid "" "These junk-filtering functions speed up matching to find differences and do " "not cause any differing lines or characters to be ignored. Read the " "description of the :meth:`~SequenceMatcher.find_longest_match` method's " "*isjunk* parameter for an explanation." msgstr "" -"これらの junk フィルター関数により、差分を発見するマッチングが高速化し、差分" -"の行や文字が無視されることがなくなります。説明については、 :meth:" -"`~SequenceMatcher.find_longest_match` メソッドの *isjunk* 引数の説明をご覧く" -"ださい。" +"これらの junk フィルター関数は、相違点を探すマッチングを高速化しますが、相違" +"のある行や文字そのものを無視するわけではありません。\n" +"詳しくは :meth:`~SequenceMatcher.find_longest_match` メソッドの *isjunk* パラ" +"メーターの説明を参照してください。" #: ../../library/difflib.rst:150 msgid "" @@ -275,7 +311,6 @@ msgstr "" "文字列からなる2つのシーケンスを比較し、差分(を表す文字列からなるシーケンス)" "を生成します。" -#: ../../library/difflib.rst:157 msgid "" "Each sequence must contain individual single-line strings ending with " "newlines. Such sequences can be obtained from the :meth:`~io.IOBase." @@ -283,6 +318,12 @@ msgid "" "of newline-terminated strings, ready to be printed as-is via the :meth:`~io." "IOBase.writelines` method of a file-like object." msgstr "" +"各シーケンスは、末尾に改行のある 1 行ずつの文字列で構成されていなければなりま" +"せん。\n" +"このようなシーケンスは、ファイル類似オブジェクトの :meth:`~io.IOBase." +"readlines` メソッドで取得できます。\n" +"生成される差分も末尾に改行のある文字列で構成され、ファイル類似オブジェクト" +"の :meth:`~io.IOBase.writelines` メソッドでそのまま出力できます。" #: ../../library/difflib.rst:166 msgid "" @@ -296,11 +337,12 @@ msgstr "" "イル) を生成するために使います。テーブルは完全差分モード、コンテキスト差分" "モードのいずれでも生成できます。" -#: ../../library/difflib.rst:173 msgid "" "The trailing newlines get stripped before the diff, so the result can be " "incomplete. See :gh:`71896` for details." msgstr "" +"差分の計算前に末尾の改行を取り除くため、結果が不完全になる場合があります。\n" +"詳しくは :gh:`71896` を参照してください。" #: ../../library/difflib.rst:176 msgid "The constructor for this class is:" @@ -522,7 +564,6 @@ msgstr "" "オプションのキーワード引数 *linejunk* と *charjunk* には、フィルタ関数 (また" "は ``None``) を渡します。" -#: ../../library/difflib.rst:315 msgid "" "*linejunk*: A function that accepts a single string argument, and returns " "true if the string is junk, or false if not. The default is ``None``. There " @@ -532,6 +573,14 @@ msgid "" "dynamic analysis of which lines are so frequent as to constitute noise, and " "this usually works better than using this function." msgstr "" +"*linejunk*: 文字列を 1 つ受け取り、その文字列が junk なら真、それ以外なら偽を" +"返す関数です。\n" +"デフォルトは ``None`` です。\n" +"モジュールレベルの :func:`IS_LINE_JUNK` 関数もあり、最大 1 つのハッシュ文字 " +"(``'#'``) を除いて可視文字のない行を除外します。\n" +"ただし、内部で使う :class:`SequenceMatcher` クラスは、どの行がノイズとなるほ" +"ど頻出するかを動的に分析するため、通常はこの関数を使うよりよい結果が得られま" +"す。" #: ../../library/difflib.rst:323 msgid "" @@ -597,14 +646,15 @@ msgstr "" "writelines` で扱うのに適した diff になるので (なぜなら入力と出力の両方が改行" "付きのため) 、これは有用です。" -#: ../../library/difflib.rst:384 msgid "" "Set *color* to ``True`` to enable output in color, similar to :program:`git " "diff --color`. Even if enabled, it can be :ref:`controlled using environment " "variables `." msgstr "" +"*color* を ``True`` にすると、:program:`git diff --color` と同様に色付きで出" +"力します。\n" +"有効にしても :ref:`環境変数で制御できます `。" -#: ../../library/difflib.rst:388 msgid "" "The unified diff format normally has a header for filenames and modification " "times. Any or all of these may be specified using strings for *fromfile*, " @@ -612,10 +662,14 @@ msgid "" "normally expressed in the ISO 8601 format. If not specified, the strings " "default to blanks." msgstr "" +"ユニファイド形式の差分は、通常、ファイル名と更新日時のヘッダーを持ちます。\n" +"これらは *fromfile*、*tofile*、*fromfiledate*、*tofiledate* に文字列を渡し" +"て、必要なものだけでもすべてでも指定できます。\n" +"更新日時は通常 ISO 8601 形式で表します。\n" +"指定しない場合は空文字列になります。" -#: ../../library/difflib.rst:410 msgid "Added the *color* parameter." -msgstr "" +msgstr "*color* パラメーターを追加しました。" #: ../../library/difflib.rst:416 msgid "" @@ -645,9 +699,8 @@ msgstr "" "行のエンコーディングは、*a* と *b* の未知または一貫性のないエンコーディングと" "同一になります。" -#: ../../library/difflib.rst:434 msgid "Junk definition functions" -msgstr "" +msgstr "junk を定義する関数" #: ../../library/difflib.rst:438 msgid "" @@ -669,9 +722,8 @@ msgstr "" "ときには無視できます。それ以外の時には無視できません。 :func:`ndiff` の引数 " "*charjunk* としてデフォルトで使用されます。" -#: ../../library/difflib.rst:453 msgid "SequenceMatcher objects" -msgstr "" +msgstr "SequenceMatcher オブジェクト" #: ../../library/difflib.rst:457 msgid "" @@ -688,25 +740,25 @@ msgstr "" "じになります; すなわち、いかなる要素も無視しなくなります。例えば以下のような" "引数を渡すと::" -#: ../../library/difflib.rst:463 msgid "lambda x: x in \" \\t\"" -msgstr "" +msgstr "lambda x: x in \" \\t\"" -#: ../../library/difflib.rst:465 msgid "" "if you're comparing lines as sequences of characters, and don't want to " "synch up on blanks or hard tabs." -msgstr "空白とタブ文字を無視して文字のシーケンスを比較します。" +msgstr "" +"これは、行を文字のシーケンスとして比較する際に、空白やタブ文字を対応付けの基" +"点にしたくない場合の例です。" -#: ../../library/difflib.rst:468 msgid "" "The optional arguments *a* and *b* are sequences to be compared; both " "default to empty strings. The elements of both sequences must be :term:" "`hashable`." msgstr "" -"オプションの引数 *a* と *b* は、比較される文字列で、デフォルトでは空の文字列" -"です。両方のシーケンスの要素は、 :term:`ハッシュ可能 ` である必要が" -"あります。" +"省略可能な引数 *a* と *b* は比較するシーケンスで、どちらもデフォルトは空文字" +"列です。\n" +"両方のシーケンスの要素は :term:`ハッシュ可能 ` でなければなりませ" +"ん。" #: ../../library/difflib.rst:471 msgid "" @@ -716,9 +768,8 @@ msgstr "" "オプションの引数 *autojunk* は、自動 junk ヒューリスティックを無効にするため" "に使えます。" -#: ../../library/difflib.rst:474 msgid "Added the *autojunk* parameter." -msgstr "" +msgstr "*autojunk* パラメーターを追加しました。" #: ../../library/difflib.rst:477 msgid "" @@ -744,21 +795,20 @@ msgstr "*bjunk* および *bpopular* 属性。" msgid ":class:`SequenceMatcher` objects have the following methods:" msgstr ":class:`SequenceMatcher` オブジェクトは以下のメソッドを持ちます:" -#: ../../library/difflib.rst:491 msgid "Set the two sequences to be compared." -msgstr "比較される2つの文字列を設定します。" +msgstr "比較する 2 つのシーケンスを設定します。" -#: ../../library/difflib.rst:493 msgid "" ":class:`SequenceMatcher` computes and caches detailed information about the " "second sequence, so if you want to compare one sequence against many " "sequences, use :meth:`set_seq2` to set the commonly used sequence once and " "call :meth:`set_seq1` repeatedly, once for each of the other sequences." msgstr "" -":class:`SequenceMatcher` オブジェクトは、2つ目のシーケンスについての詳細な情" -"報を計算し、キャッシュします。 1つのシーケンスをいくつものシーケンスと比較す" -"る場合、まず :meth:`set_seq2` を使って文字列を設定しておき、別の文字列を1つず" -"つ比較するために、繰り返し :meth:`set_seq1` を呼び出します。" +":class:`SequenceMatcher` は 2 つ目のシーケンスの詳細な情報を計算してキャッ" +"シュします。\n" +"1 つのシーケンスを多数のシーケンスと比較するには、:meth:`set_seq2` で共通の" +"シーケンスを一度設定し、比較相手のシーケンスごとに :meth:`set_seq1` を呼び出" +"します。" #: ../../library/difflib.rst:501 msgid "" @@ -780,7 +830,6 @@ msgstr "" msgid "Find longest matching block in ``a[alo:ahi]`` and ``b[blo:bhi]``." msgstr "``a[alo:ahi]`` と ``b[blo:bhi]`` の中から、最長のマッチ列を探します。" -#: ../../library/difflib.rst:515 msgid "" "If *isjunk* was omitted or ``None``, :meth:`find_longest_match` returns " "``(i, j, k)`` such that ``a[i:i+k]`` is equal to ``b[j:j+k]``, where ``alo " @@ -791,15 +840,14 @@ msgid "" "all those maximal matching blocks that start earliest in *a*, return the one " "that starts earliest in *b*." msgstr "" -"*isjunk* が省略されたか ``None`` の時、 :meth:`find_longest_match` は ``a[i:" -"i+k]`` が ``b[j:j+k]`` と等しいような ``(i, j, k)`` を返します。その値は " -"``alo <= i <= i+k <= ahi`` かつ ``blo <= j <= j+k <= bhi`` となります。 " -"``(i', j', k')`` でも、同じようになります。さらに ``k >= k'``, ``i <= i'`` " -"が ``i == i'``, ``j <= j'`` でも同様です。言い換えると、いくつものマッチ列す" -"べてのうち、 *a* 内で最初に始まるものを返します。そしてその *a* 内で最初の" -"マッチ列すべてのうち *b* 内で最初に始まるものを返します。" +"*isjunk* が省略されたか ``None`` の場合、:meth:`find_longest_match` は ``a[i:" +"i+k]`` が ``b[j:j+k]`` に等しくなる ``(i, j, k)`` を返します。\n" +"ここで ``alo <= i <= i+k <= ahi`` かつ ``blo <= j <= j+k <= bhi`` です。\n" +"これらの条件を満たす任意の ``(i', j', k')`` に対して、さらに ``k >= k'``、" +"``i <= i'``、および ``i == i'`` ならば ``j <= j'`` という条件も満たします。\n" +"つまり、最長の一致ブロックのうち *a* 内で最も早く始まるものを返します。\n" +"そのようなブロックが複数あれば、*b* 内で最も早く始まるものを返します。" -#: ../../library/difflib.rst:528 msgid "" "If *isjunk* was provided, first the longest matching block is determined as " "above, but with the additional restriction that no junk element appears in " @@ -807,11 +855,12 @@ msgid "" "(only) junk elements on both sides. So the resulting block never matches on " "junk except as identical junk happens to be adjacent to an interesting match." msgstr "" -"引数 *isjunk* が与えられている場合、上記の通り、はじめに最長のマッチ列を判定" -"します。ブロック内に junk 要素が見当たらないような追加条件の際はこれに該当し" -"ません。次にそのマッチ列を、その両側の junk 要素にマッチするよう、できる限り" -"広げていきます。そのため結果となる列は、探している列のたまたま直前にあった同" -"一の junk 以外の junk にはマッチしません。" +"引数 *isjunk* が与えられている場合、まず上記のように最長のマッチ列を判定しま" +"すが、列に junk 要素を含めないという制約が加わります。\n" +"次に、その列の両側にある junk 要素だけをマッチさせて、列をできる限り広げま" +"す。\n" +"したがって、junk 以外の要素のマッチ列に同一の junk 要素が隣接している場合を除" +"き、結果の列で junk 要素がマッチすることはありません。" #: ../../library/difflib.rst:535 msgid "" @@ -837,15 +886,14 @@ msgstr "このメソッドは :term:`named tuple` ``Match(a, b, size)`` を返 msgid "Added default arguments." msgstr "デフォルト引数が追加されました。" -#: ../../library/difflib.rst:554 msgid "" "Return list of triples describing non-overlapping matching subsequences. " "Each triple is of the form ``(i, j, n)``, and means that ``a[i:i+n] == b[j:" "j+n]``. The triples are monotonically increasing in *i* and *j*." msgstr "" -"マッチした互いに重複の無いシーケンスを表す、3つ組の値のリストを返します。\n" -"それぞれの値は ``(i, j, n)`` という形式で表され、``a[i:i+n] == b[j:j+n]`` と" -"いう関係を意味します。3つの値は *i* と *j* の間で単調に増加します。" +"重複しない一致部分シーケンスを表す 3 要素タプルのリストを返します。\n" +"各タプルは ``(i, j, n)`` の形式で、``a[i:i+n] == b[j:j+n]`` を意味します。\n" +"タプルの並びでは *i* と *j* がそれぞれ単調に増加します。" #: ../../library/difflib.rst:559 msgid "" @@ -861,24 +909,26 @@ msgstr "" "``j+n < j'`` です。言い換えると並んでいる3つ組は常に隣接していない同じブロッ" "クを表しています。" -#: ../../library/difflib.rst:567 msgid "" ">>> s = SequenceMatcher(None, \"abxcd\", \"abcd\")\n" ">>> s.get_matching_blocks()\n" "[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]" msgstr "" +">>> s = SequenceMatcher(None, \"abxcd\", \"abcd\")\n" +">>> s.get_matching_blocks()\n" +"[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]" -#: ../../library/difflib.rst:576 msgid "" "Return list of 5-tuples describing how to turn *a* into *b*. Each tuple is " "of the form ``(tag, i1, i2, j1, j2)``. The first tuple has ``i1 == j1 == " "0``, and remaining tuples have *i1* equal to the *i2* from the preceding " "tuple, and, likewise, *j1* equal to the previous *j2*." msgstr "" -"*a* を *b* にするための方法を記述する5つのタプルを返します。それぞれのタプル" -"は ``(tag, i1, i2, j1, j2)`` という形式であらわされます。最初のタプルは ``i1 " -"== j1 == 0`` であり、*i1* はその前にあるタプルの *i2* と同じ値です。同様に " -"*j1* は前の *j2* と同じ値になります。" +"*a* を *b* にするための方法を記述する、5 要素のタプルのリストを返します。\n" +"それぞれのタプルは ``(tag, i1, i2, j1, j2)`` という形式です。\n" +"最初のタプルでは ``i1 == j1 == 0`` であり、残りのタプルでは *i1* が直前のタプ" +"ルの *i2* と同じ値になります。\n" +"同様に、*j1* は直前のタプルの *j2* と同じ値になります。" #: ../../library/difflib.rst:581 msgid "The *tag* values are strings, with these meanings:" @@ -927,7 +977,6 @@ msgstr "``a[i1:i2] == b[j1:j2]`` (サブシーケンスは等しい)." msgid "For example::" msgstr "例えば::" -#: ../../library/difflib.rst:602 msgid "" ">>> a = \"qabxcd\"\n" ">>> b = \"abycdf\"\n" @@ -941,6 +990,17 @@ msgid "" "equal a[4:6] --> b[3:5] 'cd' --> 'cd'\n" "insert a[6:6] --> b[5:6] '' --> 'f'" msgstr "" +">>> a = \"qabxcd\"\n" +">>> b = \"abycdf\"\n" +">>> s = SequenceMatcher(None, a, b)\n" +">>> for tag, i1, i2, j1, j2 in s.get_opcodes():\n" +"... print('{:7} a[{}:{}] --> b[{}:{}] {!r:>8} --> {!r}'.format(\n" +"... tag, i1, i2, j1, j2, a[i1:i2], b[j1:j2]))\n" +"delete a[0:1] --> b[0:0] 'q' --> ''\n" +"equal a[1:3] --> b[0:2] 'ab' --> 'ab'\n" +"replace a[3:4] --> b[2:3] 'x' --> 'y'\n" +"equal a[4:6] --> b[3:5] 'cd' --> 'cd'\n" +"insert a[6:6] --> b[5:6] '' --> 'f'" #: ../../library/difflib.rst:617 msgid "Return a :term:`generator` of groups with up to *n* lines of context." @@ -948,14 +1008,13 @@ msgstr "" "最大 *n* 行までのコンテキストを含むグループを生成するような、 :term:`ジェネ" "レータ ` を返します。" -#: ../../library/difflib.rst:619 msgid "" "Starting with the groups returned by :meth:`get_opcodes`, this method splits " "out smaller change clusters and eliminates intervening ranges which have no " "changes." msgstr "" -"このメソッドは、 :meth:`get_opcodes` で返されるグループの中から、似たような差" -"異のかたまりに分け、間に挟まっている変更の無い部分を省きます。" +":meth:`get_opcodes` が返すグループをもとに、変更箇所をより小さなまとまりに分" +"割し、間に挟まる変更のない範囲を除きます。" #: ../../library/difflib.rst:623 msgid "The groups are returned in the same format as :meth:`get_opcodes`." @@ -995,7 +1054,6 @@ msgstr ":meth:`ratio` の上界を、より高速に計算します。" msgid "Return an upper bound on :meth:`ratio` very quickly." msgstr ":meth:`ratio` の上界を、非常に高速に計算します。" -#: ../../library/difflib.rst:651 msgid "" "The three methods that return the ratio of matching to total characters can " "give different results due to differing levels of approximation, although :" @@ -1003,45 +1061,55 @@ msgid "" "real_quick_ratio` are always at least as large as :meth:`~SequenceMatcher." "ratio`:" msgstr "" +"一致した文字数の総文字数に対する比率を返す 3 つのメソッドは、近似の程度が異な" +"るため、結果も異なる場合があります。\n" +"ただし :meth:`~SequenceMatcher.quick_ratio` と :meth:`~SequenceMatcher." +"real_quick_ratio` の結果は、常に :meth:`~SequenceMatcher.ratio` 以上です:" #: ../../library/difflib.rst:666 msgid "Examples" msgstr "使用例" -#: ../../library/difflib.rst:671 msgid "SequenceMatcher examples" -msgstr "" +msgstr "SequenceMatcher の例" #: ../../library/difflib.rst:673 msgid "This example compares two strings, considering blanks to be \"junk\":" msgstr "この例は2つの文字列を比較します。空白を \"junk\" とします:" -#: ../../library/difflib.rst:679 msgid "" ":meth:`~SequenceMatcher.ratio` returns a float in [0, 1], measuring the " "similarity of the sequences. As a rule of thumb, a :meth:`~SequenceMatcher." "ratio` value over 0.6 means the sequences are close matches:" msgstr "" +":meth:`~SequenceMatcher.ratio` は [0, 1] の範囲の浮動小数点数を返し、シーケン" +"スの類似度を示します。\n" +"目安として、:meth:`~SequenceMatcher.ratio` の値が 0.6 を超えていれば、シーケ" +"ンスはよく似ています:" -#: ../../library/difflib.rst:686 msgid "" "If you're only interested in where the sequences match, :meth:" "`~SequenceMatcher.get_matching_blocks` is handy:" msgstr "" +"シーケンスのどこが一致するかだけを知りたい場合は、:meth:`~SequenceMatcher." +"get_matching_blocks` が便利です:" -#: ../../library/difflib.rst:695 msgid "" "Note that the last tuple returned by :meth:`~SequenceMatcher." "get_matching_blocks` is always a dummy, ``(len(a), len(b), 0)``, and this is " "the only case in which the last tuple element (number of elements matched) " "is ``0``." msgstr "" +":meth:`~SequenceMatcher.get_matching_blocks` が返す最後のタプルは、常にダミー" +"の ``(len(a), len(b), 0)`` です。\n" +"タプルの最後の要素 (一致した要素数) が ``0`` になるのは、このタプルだけです。" -#: ../../library/difflib.rst:699 msgid "" "If you want to know how to change the first sequence into the second, use :" "meth:`~SequenceMatcher.get_opcodes`:" msgstr "" +"最初のシーケンスを 2 つ目に変える方法を知るには、:meth:`~SequenceMatcher." +"get_opcodes` を使います:" #: ../../library/difflib.rst:710 msgid "" @@ -1051,24 +1119,28 @@ msgstr "" ":class:`SequenceMatcher` を使った、シンプルで使えるコードを知るには、このモ" "ジュールの関数 :func:`get_close_matches` を参照してください。" -#: ../../library/difflib.rst:714 msgid "" "`Simple version control recipe `_ for a small application built with :class:" "`SequenceMatcher`." msgstr "" +":class:`SequenceMatcher` で作った小さなアプリケーションについては、`簡単な" +"バージョン管理のレシピ `_ を参照してください。" -#: ../../library/difflib.rst:722 msgid "Differ example" -msgstr "" +msgstr "Differ の例" -#: ../../library/difflib.rst:724 msgid "" "This example compares two texts. First we set up the texts, sequences of " "individual single-line strings ending with newlines (such sequences can also " "be obtained from the :meth:`~io.IOBase.readlines` method of file-like " "objects):" msgstr "" +"この例では 2 つのテキストを比較します。\n" +"まず、末尾に改行のある 1 行ずつの文字列のシーケンスとしてテキストを用意しま" +"す (ファイル類似オブジェクトの :meth:`~io.IOBase.readlines` メソッドでも取得" +"できます):" #: ../../library/difflib.rst:743 msgid "Next we instantiate a Differ object:" @@ -1100,12 +1172,12 @@ msgstr "これは、複数行の文字列として、次のように出力され msgid "A command-line interface to difflib" msgstr "difflib のコマンドラインインターフェース" -#: ../../library/difflib.rst:791 msgid "" "This example shows how to use difflib to create a ``diff``-like utility." msgstr "" +"この例では、difflib を使って ``diff`` のようなユーティリティを作る方法を示し" +"ます。" -#: ../../library/difflib.rst:793 msgid "" "\"\"\" Command-line interface to difflib.py providing diffs in four " "formats:\n" @@ -1171,14 +1243,75 @@ msgid "" "if __name__ == '__main__':\n" " main()\n" msgstr "" +"\"\"\" 4 つの形式の差分を提供する difflib.py のコマンドラインインターフェー" +"ス:\n" +"\n" +"* ndiff: 全行を列挙し、行間の変更を強調表示します。\n" +"* context: まとまった変更を変更前/変更後の形式で強調表示します。\n" +"* unified: まとまった変更をインライン形式で強調表示します。\n" +"* html: 左右に並べた比較を生成し、変更点を強調表示します。\n" +"\n" +"\"\"\"\n" +"\n" +"import sys, os, difflib, argparse\n" +"import datetime as dt\n" +"\n" +"def file_mtime(path):\n" +" t = dt.datetime.fromtimestamp(os.stat(path).st_mtime,\n" +" dt.timezone.utc)\n" +" return t.astimezone().isoformat()\n" +"\n" +"def main():\n" +"\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-c', action='store_true', default=False,\n" +" help='Produce a context format diff (default)')\n" +" parser.add_argument('-u', action='store_true', default=False,\n" +" help='Produce a unified format diff')\n" +" parser.add_argument('-m', action='store_true', default=False,\n" +" help='Produce HTML side by side diff '\n" +" '(can use -c and -l in conjunction)')\n" +" parser.add_argument('-n', action='store_true', default=False,\n" +" help='Produce a ndiff format diff')\n" +" parser.add_argument('-l', '--lines', type=int, default=3,\n" +" help='Set number of context lines (default 3)')\n" +" parser.add_argument('fromfile')\n" +" parser.add_argument('tofile')\n" +" options = parser.parse_args()\n" +"\n" +" n = options.lines\n" +" fromfile = options.fromfile\n" +" tofile = options.tofile\n" +"\n" +" fromdate = file_mtime(fromfile)\n" +" todate = file_mtime(tofile)\n" +" with open(fromfile) as ff:\n" +" fromlines = ff.readlines()\n" +" with open(tofile) as tf:\n" +" tolines = tf.readlines()\n" +"\n" +" if options.u:\n" +" diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +" elif options.n:\n" +" diff = difflib.ndiff(fromlines, tolines)\n" +" elif options.m:\n" +" diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile," +"tofile,context=options.c,numlines=n)\n" +" else:\n" +" diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, " +"fromdate, todate, n=n)\n" +"\n" +" sys.stdout.writelines(diff)\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" -#: ../../library/difflib.rst:796 msgid "ndiff example" -msgstr "" +msgstr "ndiff の例" -#: ../../library/difflib.rst:798 msgid "This example shows how to use :func:`difflib.ndiff`." -msgstr "" +msgstr "この例では :func:`difflib.ndiff` の使い方を示します。" #: ../../library/difflib.rst:800 msgid "" diff --git a/library/dis.po b/library/dis.po index 8e703ece8..054cabeca 100644 --- a/library/dis.po +++ b/library/dis.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/dis.rst:2 @@ -30,13 +30,16 @@ msgstr ":mod:`!dis` --- Python バイトコードの逆アセンブラー" msgid "**Source code:** :source:`Lib/dis.py`" msgstr "**ソースコード:** :source:`Lib/dis.py`" -#: ../../library/dis.rst:17 msgid "" "The :mod:`!dis` module supports the analysis of CPython :term:`bytecode` by " "disassembling it. The CPython bytecode which this module takes as an input " "is defined in the file :file:`Include/opcode.h` and used by the compiler and " "the interpreter." msgstr "" +":mod:`!dis` モジュールは、CPython の :term:`bytecode` を逆アセンブルして解析" +"するためのものです。\n" +"このモジュールが入力として受け取る CPython のバイトコードは :file:`Include/" +"opcode.h` で定義され、コンパイラとインタープリタで使われます。" #: ../../library/dis.rst:24 msgid "" @@ -58,13 +61,13 @@ msgstr "" "従来は使用されるバイト数は命令ごとに異なりましたが、このモジュールでは各々一" "つの命令につき2バイト使用することとなっています。" -#: ../../library/dis.rst:33 msgid "" "The argument of jump, exception handling and loop instructions is now the " "instruction offset rather than the byte offset." msgstr "" +"ジャンプ、例外処理、ループ命令の引数が、バイトオフセットではなく命令のオフ" +"セットになりました。" -#: ../../library/dis.rst:37 msgid "" "Some instructions are accompanied by one or more inline cache entries, which " "take the form of :opcode:`CACHE` instructions. These instructions are hidden " @@ -73,55 +76,65 @@ msgid "" "specialize it for different runtime conditions. The adaptive bytecode can be " "shown by passing ``adaptive=True``." msgstr "" +"一部の命令には、:opcode:`CACHE` 命令の形をした 1 つ以上のインラインキャッシュ" +"エントリーが付随するようになりました。\n" +"これらの命令はデフォルトでは非表示ですが、:mod:`!dis` の各ユーティリティに " +"``show_caches=True`` を渡すと表示できます。\n" +"また、インタープリタは実行時の状況に応じてバイトコードを特殊化するようになり" +"ました。\n" +"この適応的なバイトコードは ``adaptive=True`` を渡すと表示できます。" -#: ../../library/dis.rst:45 msgid "" "The argument of a jump is the offset of the target instruction relative to " "the instruction that appears immediately after the jump instruction's :" "opcode:`CACHE` entries." msgstr "" +"ジャンプの引数は、ジャンプ命令の :opcode:`CACHE` エントリーの直後にある命令を" +"基準とした、ジャンプ先の命令への相対オフセットになりました。" -#: ../../library/dis.rst:50 msgid "" "As a consequence, the presence of the :opcode:`CACHE` instructions is " "transparent for forward jumps but needs to be taken into account when " "reasoning about backward jumps." msgstr "" +"このため、前方ジャンプでは :opcode:`CACHE` 命令の存在を意識する必要はありませ" +"んが、後方ジャンプを考える際は考慮する必要があります。" -#: ../../library/dis.rst:54 msgid "" "The output shows logical labels rather than instruction offsets for jump " "targets and exception handlers. The ``-O`` command line option and the " "``show_offsets`` argument were added." msgstr "" +"ジャンプ先と例外ハンドラーの出力に、命令オフセットではなく論理ラベルを表示す" +"るようになりました。\n" +"``-O`` コマンドラインオプションと ``show_offsets`` 引数を追加しました。" -#: ../../library/dis.rst:59 msgid "" "The :option:`-P ` command-line option and the " "``show_positions`` argument were added." msgstr "" +":option:`-P ` コマンドラインオプションと " +"``show_positions`` 引数を追加しました。" -#: ../../library/dis.rst:63 msgid "The :option:`-S ` command-line option is added." msgstr "" +":option:`-S ` コマンドラインオプションを追加しました。" -#: ../../library/dis.rst:65 msgid "Example: Given the function :func:`!myfunc`::" -msgstr "" +msgstr "例として、次の :func:`!myfunc` 関数があるとします。 ::" -#: ../../library/dis.rst:67 msgid "" "def myfunc(alist):\n" " return len(alist)" msgstr "" +"def myfunc(alist):\n" +" return len(alist)" -#: ../../library/dis.rst:70 msgid "" "the following command can be used to display the disassembly of :func:`!" "myfunc`:" -msgstr "" +msgstr "次のコマンドで :func:`!myfunc` の逆アセンブル結果を表示できます:" -#: ../../library/dis.rst:73 msgid "" ">>> dis.dis(myfunc)\n" " 2 RESUME 0\n" @@ -131,6 +144,13 @@ msgid "" " CALL 1\n" " RETURN_VALUE" msgstr "" +">>> dis.dis(myfunc)\n" +" 2 RESUME 0\n" +"\n" +" 3 LOAD_GLOBAL 1 (len + NULL)\n" +" LOAD_FAST_BORROW 0 (alist)\n" +" CALL 1\n" +" RETURN_VALUE" #: ../../library/dis.rst:83 msgid "(The \"2\" is a line number)." @@ -140,14 +160,13 @@ msgstr "(\"2\" は行番号です)。" msgid "Command-line interface" msgstr "コマンドライン・インターフェース" -#: ../../library/dis.rst:90 msgid "" "The :mod:`!dis` module can be invoked as a script from the command line:" msgstr "" +":mod:`!dis` モジュールはコマンドラインからスクリプトとして実行できます:" -#: ../../library/dis.rst:92 msgid "python -m dis [-h] [-C] [-O] [-P] [-S] [infile]" -msgstr "" +msgstr "python -m dis [-h] [-C] [-O] [-P] [-S] [infile]" #: ../../library/dis.rst:96 msgid "The following options are accepted:" @@ -157,28 +176,26 @@ msgstr "以下のオプションが使用できます:" msgid "Display usage and exit." msgstr "使い方を表示して終了します。" -#: ../../library/dis.rst:106 msgid "Show inline caches." -msgstr "" +msgstr "インラインキャッシュを表示します。" -#: ../../library/dis.rst:112 msgid "Show offsets of instructions." -msgstr "" +msgstr "命令のオフセットを表示します。" -#: ../../library/dis.rst:118 msgid "Show positions of instructions in the source code." -msgstr "" +msgstr "ソースコード内の命令の位置を表示します。" -#: ../../library/dis.rst:124 msgid "Show specialized bytecode." -msgstr "" +msgstr "特殊化されたバイトコードを表示します。" -#: ../../library/dis.rst:128 msgid "" "If :file:`infile` is specified, its disassembled code will be written to " "stdout. Otherwise, disassembly is performed on compiled source code received " "from stdin." msgstr "" +":file:`infile` を指定すると、その逆アセンブル結果を標準出力に書き出します。\n" +"指定しなければ、標準入力から受け取ったソースコードをコンパイルして逆アセンブ" +"ルします。" #: ../../library/dis.rst:132 msgid "Bytecode analysis" @@ -238,29 +255,34 @@ msgstr "" "これを設定すると、 :meth:`.dis` の出力において、指定された命令コード " "(opcode) に \"現在の命令 (instruction)\" を表す印が表示されます。" -#: ../../library/dis.rst:161 msgid "" "If *show_caches* is ``True``, :meth:`.dis` will display inline cache entries " "used by the interpreter to specialize the bytecode." msgstr "" +"*show_caches* が ``True`` なら、:meth:`.dis` はインタープリタがバイトコードの" +"特殊化に使うインラインキャッシュエントリーを表示します。" -#: ../../library/dis.rst:164 msgid "" "If *adaptive* is ``True``, :meth:`.dis` will display specialized bytecode " "that may be different from the original bytecode." msgstr "" +"*adaptive* が ``True`` なら、:meth:`.dis` は特殊化されたバイトコードを表示し" +"ます。\n" +"これは元のバイトコードと異なる場合があります。" -#: ../../library/dis.rst:167 msgid "" "If *show_offsets* is ``True``, :meth:`.dis` will include instruction offsets " "in the output." msgstr "" +"*show_offsets* が ``True`` なら、:meth:`.dis` の出力に命令オフセットを含めま" +"す。" -#: ../../library/dis.rst:170 msgid "" "If *show_positions* is ``True``, :meth:`.dis` will include instruction " "source code positions in the output." msgstr "" +"*show_positions* が ``True`` なら、:meth:`.dis` の出力にソースコード内の命令" +"の位置を含めます。" #: ../../library/dis.rst:175 msgid "" @@ -294,31 +316,24 @@ msgstr "" ":func:`code_info` のようなコードオブジェクトの詳細を含んだ整形された複数行文" "字列を返します。" -#: ../../library/dis.rst:196 ../../library/dis.rst:242 -#: ../../library/dis.rst:295 msgid "This can now handle coroutine and asynchronous generator objects." msgstr "" +"コルーチンオブジェクトと非同期ジェネレーターオブジェクトも扱えるようになりま" +"した。" -#: ../../library/dis.rst:199 ../../library/dis.rst:298 -#: ../../library/dis.rst:320 ../../library/dis.rst:356 -#: ../../library/dis.rst:382 msgid "Added the *show_caches* and *adaptive* parameters." -msgstr "" +msgstr "*show_caches* と *adaptive* パラメーターを追加しました。" -#: ../../library/dis.rst:202 msgid "Added the *show_offsets* parameter" -msgstr "" +msgstr "*show_offsets* パラメーターを追加しました。" -#: ../../library/dis.rst:205 ../../library/dis.rst:304 -#: ../../library/dis.rst:326 ../../library/dis.rst:362 msgid "Added the *show_positions* parameter." -msgstr "" +msgstr "*show_positions* パラメーターを追加しました。" #: ../../library/dis.rst:208 msgid "Example:" msgstr "例:" -#: ../../library/dis.rst:210 msgid "" ">>> bytecode = dis.Bytecode(myfunc)\n" ">>> for instr in bytecode:\n" @@ -330,18 +345,29 @@ msgid "" "CALL\n" "RETURN_VALUE" msgstr "" +">>> bytecode = dis.Bytecode(myfunc)\n" +">>> for instr in bytecode:\n" +"... print(instr.opname)\n" +"...\n" +"RESUME\n" +"LOAD_GLOBAL\n" +"LOAD_FAST_BORROW\n" +"CALL\n" +"RETURN_VALUE" #: ../../library/dis.rst:224 msgid "Analysis functions" msgstr "解析関数" -#: ../../library/dis.rst:226 msgid "" "The :mod:`!dis` module also defines the following analysis functions that " "convert the input directly to the desired output. They can be useful if only " "a single operation is being performed, so the intermediate analysis object " "isn't useful:" msgstr "" +":mod:`!dis` モジュールは、入力を目的の出力に直接変換する、次の解析関数も定義" +"しています。\n" +"1 つの操作だけを行うなど、中間の解析オブジェクトが不要な場合に便利です:" #: ../../library/dis.rst:232 msgid "" @@ -385,7 +411,6 @@ msgstr "" msgid "Added *file* parameter." msgstr "*file* 引数が追加されました。" -#: ../../library/dis.rst:264 msgid "" "Disassemble the *x* object. *x* can denote either a module, a class, a " "method, a function, a generator, an asynchronous generator, a coroutine, a " @@ -400,6 +425,20 @@ msgid "" "before being disassembled. If no object is provided, this function " "disassembles the last traceback." msgstr "" +"オブジェクト *x* を逆アセンブルします。\n" +"*x* にはモジュール、クラス、メソッド、関数、ジェネレーター、非同期ジェネレー" +"ター、コルーチン、コードオブジェクト、ソースコード文字列、生のバイトコードの" +"バイト列を指定できます。\n" +"モジュールの場合はすべての関数を、クラスの場合はクラスメソッドと静的メソッド" +"を含むすべてのメソッドを逆アセンブルします。\n" +"コードオブジェクトや生のバイトコードの列の場合は、バイトコード命令ごとに 1 行" +"を表示します。\n" +"入れ子のコードオブジェクトも再帰的に逆アセンブルします。\n" +"これには、ジェネレーター式、入れ子の関数やクラスの本体、:ref:`アノテーション" +"スコープ ` で使うコードオブジェクトなどが含まれます。\n" +"文字列は、組み込み関数 :func:`compile` でコードオブジェクトにコンパイルしてか" +"ら逆アセンブルします。\n" +"オブジェクトを指定しない場合は、最後のトレースバックを逆アセンブルします。" #: ../../library/dis.rst:277 ../../library/dis.rst:314 #: ../../library/dis.rst:350 @@ -410,32 +449,32 @@ msgstr "" "*file* 引数が渡された場合は、アセンブリをそこに書き込みます。\n" "そうでない場合は ``sys.stdout`` に出力します。" -#: ../../library/dis.rst:280 msgid "" "The maximal depth of recursion is limited by *depth* unless it is ``None``. " "``depth=0`` means no recursion." msgstr "" +"*depth* が ``None`` でなければ、再帰の最大の深さをその値に制限します。\n" +"``depth=0`` は再帰しないことを意味します。" -#: ../../library/dis.rst:283 msgid "" "If *show_caches* is ``True``, this function will display inline cache " "entries used by the interpreter to specialize the bytecode." msgstr "" +"*show_caches* が ``True`` なら、インタープリタがバイトコードの特殊化に使うイ" +"ンラインキャッシュエントリーを表示します。" -#: ../../library/dis.rst:286 msgid "" "If *adaptive* is ``True``, this function will display specialized bytecode " "that may be different from the original bytecode." msgstr "" +"*adaptive* が ``True`` なら、特殊化されたバイトコードを表示します。\n" +"これは元のバイトコードと異なる場合があります。" -#: ../../library/dis.rst:292 msgid "Implemented recursive disassembling and added *depth* parameter." -msgstr "" +msgstr "再帰的な逆アセンブルを実装し、*depth* パラメーターを追加しました。" -#: ../../library/dis.rst:301 ../../library/dis.rst:323 -#: ../../library/dis.rst:359 msgid "Added the *show_offsets* parameter." -msgstr "" +msgstr "*show_offsets* パラメーターを追加しました。" #: ../../library/dis.rst:310 msgid "" @@ -454,12 +493,14 @@ msgstr "" "コードオブジェクトを逆アセンブルします。*lasti* が与えられた場合は、最後の命" "令を示します。出力は次のようなカラムに分割されます:" -#: ../../library/dis.rst:337 msgid "" "the source code location of the instruction. Complete location information " "is shown if *show_positions* is true. Otherwise (the default) only the line " "number is displayed." msgstr "" +"ソースコード内の命令の位置。\n" +"*show_positions* が真なら完全な位置情報を表示します。\n" +"それ以外 (デフォルト) では行番号だけを表示します。" #: ../../library/dis.rst:340 msgid "the current instruction, indicated as ``-->``," @@ -509,71 +550,87 @@ msgstr "" "イテレータは、与えられたコードの各命令の詳細情報を保持する名前付きタプル :" "class:`Instruction` からなる列を生成します。" -#: ../../library/dis.rst:378 msgid "The *adaptive* parameter works as it does in :func:`dis`." -msgstr "" +msgstr "*adaptive* パラメーターは :func:`dis` のものと同じように動作します。" -#: ../../library/dis.rst:385 msgid "" "The *show_caches* parameter is deprecated and has no effect. The iterator " "generates the :class:`Instruction` instances with the *cache_info* field " "populated (regardless of the value of *show_caches*) and it no longer " "generates separate items for the cache entries." msgstr "" +"*show_caches* パラメーターは非推奨となり、効果がなくなりました。\n" +"イテレーターは、*show_caches* の値にかかわらず *cache_info* フィールドを設定" +"した :class:`Instruction` インスタンスを生成し、キャッシュエントリーを個別の" +"項目として生成しなくなりました。" -#: ../../library/dis.rst:393 msgid "" "This generator function uses the :meth:`~codeobject.co_lines` method of the :" "ref:`code object ` *code* to find the offsets which are starts " "of lines in the source code. They are generated as ``(offset, lineno)`` " "pairs." msgstr "" +"このジェネレーター関数は、:ref:`コードオブジェクト ` *code* " +"の :meth:`~codeobject.co_lines` メソッドを使い、ソースコードの各行が始まるオ" +"フセットを調べます。\n" +"結果は ``(offset, lineno)`` ペアとして生成されます。" -#: ../../library/dis.rst:398 msgid "Line numbers can be decreasing. Before, they were always increasing." msgstr "" +"行番号が減少する場合もあるようになりました。\n" +"以前は常に増加していました。" -#: ../../library/dis.rst:401 msgid "" "The :pep:`626` :meth:`~codeobject.co_lines` method is used instead of the :" "attr:`~codeobject.co_firstlineno` and :attr:`!codeobject.co_lnotab` " "attributes of the :ref:`code object `." msgstr "" +":ref:`コードオブジェクト ` の :attr:`~codeobject." +"co_firstlineno` と :attr:`!codeobject.co_lnotab` 属性に代わり、:pep:`626` " +"の :meth:`~codeobject.co_lines` メソッドを使うようになりました。" -#: ../../library/dis.rst:406 msgid "" "Line numbers can be ``None`` for bytecode that does not map to source lines." msgstr "" +"ソース行に対応しないバイトコードでは、行番号が ``None`` になる場合がありま" +"す。" -#: ../../library/dis.rst:412 msgid "" "Detect all offsets in the raw compiled bytecode string *code* which are jump " "targets, and return a list of these offsets." msgstr "" +"生のコンパイル済みバイトコード文字列 *code* 内でジャンプ先となるすべてのオフ" +"セットを検出し、そのリストを返します。" #: ../../library/dis.rst:418 msgid "Compute the stack effect of *opcode* with argument *oparg*." msgstr "*opcode* と引数 *oparg* がスタックに与える影響を計算します。" -#: ../../library/dis.rst:420 msgid "" "If the code has a jump target and *jump* is ``True``, :func:`~stack_effect` " "will return the stack effect of jumping. If *jump* is ``False``, it will " "return the stack effect of not jumping. And if *jump* is ``None`` (default), " "it will return the maximal stack effect of both cases." msgstr "" +"命令にジャンプ先があり、*jump* が ``True`` なら、:func:`~stack_effect` はジャ" +"ンプした場合のスタックへの影響を返します。\n" +"*jump* が ``False`` なら、ジャンプしない場合の影響を返します。\n" +"*jump* が ``None`` (デフォルト) なら、両者のうち大きい方を返します。" -#: ../../library/dis.rst:427 msgid "Added *jump* parameter." -msgstr "" +msgstr "*jump* パラメーターを追加しました。" -#: ../../library/dis.rst:430 msgid "" "If ``oparg`` is omitted (or ``None``), the stack effect is now returned for " "``oparg=0``. Previously this was an error for opcodes that use their arg. It " "is also no longer an error to pass an integer ``oparg`` when the ``opcode`` " "does not use it; the ``oparg`` in this case is ignored." msgstr "" +"``oparg`` を省略するか ``None`` にすると、``oparg=0`` の場合のスタックへの影" +"響を返すようになりました。\n" +"以前は、引数を使うオペコードに対してはエラーでした。\n" +"また、``opcode`` が引数を使わない場合に整数の ``oparg`` を渡してもエラーにな" +"らず、``oparg`` を無視するようになりました。" #: ../../library/dis.rst:440 msgid "Python Bytecode Instructions" @@ -603,107 +660,116 @@ msgstr "" msgid "human readable name for operation" msgstr "人間が読むための命令名" -#: ../../library/dis.rst:462 msgid "" "numeric code for the base operation if operation is specialized; otherwise " "equal to :data:`opcode`" msgstr "" +"特殊化された命令の場合は基となる命令の数値コード。\n" +"それ以外は :data:`opcode` と同じです。" -#: ../../library/dis.rst:468 msgid "" "human readable name for the base operation if operation is specialized; " "otherwise equal to :data:`opname`" msgstr "" +"特殊化された命令の場合は基となる命令の、人間が読める名前。\n" +"それ以外は :data:`opname` と同じです。" #: ../../library/dis.rst:474 msgid "numeric argument to operation (if any), otherwise ``None``" msgstr "(ある場合は) 命令の数値引数、無ければ ``None``" -#: ../../library/dis.rst:478 msgid "alias for :data:`arg`" -msgstr "" +msgstr ":data:`arg` の別名" -#: ../../library/dis.rst:482 msgid "resolved arg value (if any), otherwise ``None``" msgstr "" +"解決済みの引数値 (ある場合)。\n" +"ない場合は ``None``" -#: ../../library/dis.rst:487 msgid "" "human readable description of operation argument (if any), otherwise an " "empty string." msgstr "" +"命令の引数の、人間が読める説明 (ある場合)。\n" +"ない場合は空文字列。" #: ../../library/dis.rst:493 msgid "start index of operation within bytecode sequence" msgstr "バイトコード列の中での命令の開始位置" -#: ../../library/dis.rst:498 msgid "" "start index of operation within bytecode sequence, including prefixed " "``EXTENDED_ARG`` operations if present; otherwise equal to :data:`offset`" msgstr "" +"バイトコード列内で命令が始まるインデックス。\n" +"前に ``EXTENDED_ARG`` 命令が付く場合はそれを含め、付かない場合は :data:" +"`offset` と同じです。" -#: ../../library/dis.rst:504 msgid "start index of the cache entries following the operation" -msgstr "" +msgstr "命令に続くキャッシュエントリーの開始インデックス" -#: ../../library/dis.rst:509 msgid "end index of the cache entries following the operation" -msgstr "" +msgstr "命令に続くキャッシュエントリーの終了インデックス" -#: ../../library/dis.rst:514 msgid "``True`` if this opcode starts a source line, otherwise ``False``" -msgstr "" +msgstr "このオペコードがソース行の先頭なら ``True``、それ以外なら ``False``" -#: ../../library/dis.rst:519 msgid "" "source line number associated with this opcode (if any), otherwise ``None``" msgstr "" +"このオペコードに対応するソースの行番号 (ある場合)。\n" +"ない場合は ``None``" #: ../../library/dis.rst:524 msgid "``True`` if other code jumps to here, otherwise ``False``" msgstr "" "他のコードからここへジャンプする場合は ``True`` 、そうでない場合は ``False``" -#: ../../library/dis.rst:529 msgid "" "bytecode index of the jump target if this is a jump operation, otherwise " "``None``" msgstr "" +"ジャンプ命令の場合はジャンプ先のバイトコードのインデックス。\n" +"それ以外は ``None``" -#: ../../library/dis.rst:535 msgid "" ":class:`dis.Positions` object holding the start and end locations that are " "covered by this instruction." msgstr "" +"この命令が対応する範囲の開始位置と終了位置を保持する :class:`dis.Positions` " +"オブジェクト。" -#: ../../library/dis.rst:540 msgid "" "Information about the cache entries of this instruction, as triplets of the " "form ``(name, size, data)``, where the ``name`` and ``size`` describe the " "cache format and data is the contents of the cache. ``cache_info`` is " "``None`` if the instruction does not have caches." msgstr "" +"``(name, size, data)`` 形式の 3 要素タプルで表した、この命令のキャッシュエン" +"トリーの情報。\n" +"``name`` と ``size`` はキャッシュの形式を表し、``data`` はキャッシュの内容で" +"す。\n" +"命令にキャッシュがなければ ``cache_info`` は ``None`` です。" -#: ../../library/dis.rst:550 msgid "Field ``positions`` is added." -msgstr "" +msgstr "``positions`` フィールドを追加しました。" -#: ../../library/dis.rst:554 msgid "Changed field ``starts_line``." -msgstr "" +msgstr "``starts_line`` フィールドを変更しました。" -#: ../../library/dis.rst:556 msgid "" "Added fields ``start_offset``, ``cache_offset``, ``end_offset``, " "``baseopname``, ``baseopcode``, ``jump_target``, ``oparg``, ``line_number`` " "and ``cache_info``." msgstr "" +"``start_offset``、``cache_offset``、``end_offset``、``baseopname``、" +"``baseopcode``、``jump_target``、``oparg``、``line_number``、``cache_info`` " +"フィールドを追加しました。" -#: ../../library/dis.rst:563 msgid "" "In case the information is not available, some fields might be ``None``." msgstr "" +"情報が取得できない場合、一部のフィールドは ``None`` になることがあります。" #: ../../library/dis.rst:573 msgid "" @@ -714,89 +780,102 @@ msgstr "現在 Python コンパイラは次のバイトコード命令を生成 msgid "**General instructions**" msgstr "**一般的な命令**" -#: ../../library/dis.rst:578 msgid "" "In the following, We will refer to the interpreter stack as ``STACK`` and " "describe operations on it as if it was a Python list. The top of the stack " "corresponds to ``STACK[-1]`` in this language." msgstr "" +"以下ではインタープリタのスタックを ``STACK`` と呼び、Python のリストのように" +"扱って操作を説明します。\n" +"この表記ではスタックの先頭は ``STACK[-1]`` に相当します。" -#: ../../library/dis.rst:584 msgid "" "Do nothing code. Used as a placeholder by the bytecode optimizer, and to " "generate line tracing events." msgstr "" +"何もしない命令です。\n" +"バイトコード最適化器のプレースホルダーや、行トレースイベントの生成に使いま" +"す。" -#: ../../library/dis.rst:590 msgid "" "Do nothing code. Used by the interpreter to record :monitoring-event:" "`BRANCH_LEFT` and :monitoring-event:`BRANCH_RIGHT` events for :mod:`sys." "monitoring`." msgstr "" +"何もしない命令です。\n" +"インタープリタが :mod:`sys.monitoring` の :monitoring-event:`BRANCH_LEFT` " +"と :monitoring-event:`BRANCH_RIGHT` イベントを記録するために使います。" -#: ../../library/dis.rst:599 msgid "Removes the iterator from the top of the stack." -msgstr "" +msgstr "スタックの先頭からイテレーターを取り除きます。" -#: ../../library/dis.rst:606 msgid "Removes the top-of-stack item::" -msgstr "" +msgstr "スタックの先頭の要素を取り除きます。 ::" -#: ../../library/dis.rst:608 msgid "STACK.pop()" -msgstr "" +msgstr "STACK.pop()" -#: ../../library/dis.rst:613 msgid "" "Removes the top-of-stack item. Equivalent to ``POP_TOP``. Used to clean up " "at the end of loops, hence the name." msgstr "" +"スタックの先頭の要素を取り除きます。\n" +"``POP_TOP`` と同じです。\n" +"ループの終わりの後始末に使うことが名前の由来です。" -#: ../../library/dis.rst:622 msgid "Implements ``del STACK[-2]``. Used to clean up when a generator exits." msgstr "" +"``del STACK[-2]`` を実行します。\n" +"ジェネレーターの終了時の後始末に使います。" -#: ../../library/dis.rst:630 msgid "" "Push the i-th item to the top of the stack without removing it from its " "original location::" msgstr "" +"先頭から ``i`` 番目の要素を元の位置から取り除かず、スタックの先頭にプッシュし" +"ます。 ::" -#: ../../library/dis.rst:633 msgid "" "assert i > 0\n" "STACK.append(STACK[-i])" msgstr "" +"assert i > 0\n" +"STACK.append(STACK[-i])" -#: ../../library/dis.rst:641 msgid "Swap the top of the stack with the i-th element::" -msgstr "" +msgstr "スタックの先頭と、先頭から ``i`` 番目の要素を交換します。 ::" -#: ../../library/dis.rst:643 msgid "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" -msgstr "" +msgstr "STACK[-i], STACK[-1] = STACK[-1], STACK[-i]" -#: ../../library/dis.rst:650 msgid "" "Rather than being an actual instruction, this opcode is used to mark extra " "space for the interpreter to cache useful data directly in the bytecode " "itself. It is automatically hidden by all ``dis`` utilities, but can be " "viewed with ``show_caches=True``." msgstr "" +"このオペコードは実際の命令ではなく、インタープリタが有用なデータをバイトコー" +"ド自体にキャッシュするための追加領域を示します。\n" +"すべての ``dis`` ユーティリティで自動的に非表示になりますが、" +"``show_caches=True`` にすると表示できます。" -#: ../../library/dis.rst:655 msgid "" "Logically, this space is part of the preceding instruction. Many opcodes " "expect to be followed by an exact number of caches, and will instruct the " "interpreter to skip over them at runtime." msgstr "" +"論理的には、この領域は直前の命令の一部です。\n" +"多くのオペコードは決まった数のキャッシュが後続することを想定し、実行時にはイ" +"ンタープリタにそれらを読み飛ばさせます。" -#: ../../library/dis.rst:659 msgid "" "Populated caches can look like arbitrary instructions, so great care should " "be taken when reading or modifying raw, adaptive bytecode containing " "quickened data." msgstr "" +"データの入ったキャッシュは任意の命令に見えることがあるため、高速化用データを" +"含む生の適応的バイトコードを読み取ったり変更したりするときは、十分な注意が必" +"要です。" #: ../../library/dis.rst:666 msgid "**Unary operations**" @@ -810,107 +889,110 @@ msgstr "" "1オペランド命令はスタックの先頭を取り出して操作を適用し、結果をスタックへプッ" "シュし戻します。" -#: ../../library/dis.rst:674 msgid "Implements ``STACK[-1] = -STACK[-1]``." -msgstr "" +msgstr "``STACK[-1] = -STACK[-1]`` を実行します。" -#: ../../library/dis.rst:679 msgid "Implements ``STACK[-1] = not STACK[-1]``." -msgstr "" +msgstr "``STACK[-1] = not STACK[-1]`` を実行します。" -#: ../../library/dis.rst:681 ../../library/dis.rst:1383 -#: ../../library/dis.rst:1399 msgid "This instruction now requires an exact :class:`bool` operand." msgstr "" +"この命令は、厳密に :class:`bool` 型の演算対象を要求するようになりました。" -#: ../../library/dis.rst:687 msgid "Implements ``STACK[-1] = ~STACK[-1]``." -msgstr "" +msgstr "``STACK[-1] = ~STACK[-1]`` を実行します。" -#: ../../library/dis.rst:692 msgid "Implements ``STACK[-1] = iter(STACK[-1])``." -msgstr "" +msgstr "``STACK[-1] = iter(STACK[-1])`` を実行します。" -#: ../../library/dis.rst:697 msgid "" "If ``STACK[-1]`` is a :term:`generator iterator` or :term:`coroutine` object " "it is left as is. Otherwise, implements ``STACK[-1] = iter(STACK[-1])``." msgstr "" +"``STACK[-1]`` が :term:`generator iterator` または :term:`coroutine` オブジェ" +"クトなら、そのままにします。\n" +"それ以外は ``STACK[-1] = iter(STACK[-1])`` を実行します。" -#: ../../library/dis.rst:705 msgid "Implements ``STACK[-1] = bool(STACK[-1])``." -msgstr "" +msgstr "``STACK[-1] = bool(STACK[-1])`` を実行します。" -#: ../../library/dis.rst:710 msgid "**Binary and in-place operations**" -msgstr "" +msgstr "**2 オペランド命令とインプレース命令**" -#: ../../library/dis.rst:712 msgid "" "Binary operations remove the top two items from the stack (``STACK[-1]`` and " "``STACK[-2]``). They perform the operation, then put the result back on the " "stack." msgstr "" +"2 オペランド命令は、スタックの先頭 2 要素 (``STACK[-1]`` と ``STACK[-2]``) を" +"取り出し、演算を行って結果をスタックに戻します。" -#: ../../library/dis.rst:715 msgid "" "In-place operations are like binary operations, but the operation is done in-" "place when ``STACK[-2]`` supports it, and the resulting ``STACK[-1]`` may be " "(but does not have to be) the original ``STACK[-2]``." msgstr "" +"インプレース命令は 2 オペランド命令に似ていますが、``STACK[-2]`` が対応してい" +"る場合はその場で演算を行います。\n" +"結果の ``STACK[-1]`` は元の ``STACK[-2]`` と同じオブジェクトになる場合があり" +"ますが、必ずそうなるわけではありません。" -#: ../../library/dis.rst:722 msgid "" "Implements the binary and in-place operators (depending on the value of " "*op*)::" msgstr "" +"*op* の値に応じた 2 オペランド演算子またはインプレース演算子を実装します。 ::" -#: ../../library/dis.rst:725 msgid "" "rhs = STACK.pop()\n" "lhs = STACK.pop()\n" "STACK.append(lhs op rhs)" msgstr "" +"rhs = STACK.pop()\n" +"lhs = STACK.pop()\n" +"STACK.append(lhs op rhs)" -#: ../../library/dis.rst:730 msgid "" "With oparg :``NB_SUBSCR``, implements binary subscript (replaces opcode " "``BINARY_SUBSCR``)" msgstr "" +"``oparg`` が ``NB_SUBSCR`` の場合は、2 オペランドの添字参照を実行します (オペ" +"コード ``BINARY_SUBSCR`` に代わるものです)。" -#: ../../library/dis.rst:736 ../../library/dis.rst:746 -#: ../../library/dis.rst:754 ../../library/dis.rst:766 -#: ../../library/dis.rst:844 ../../library/dis.rst:854 -#: ../../library/dis.rst:864 ../../library/dis.rst:1070 -#: ../../library/dis.rst:1081 ../../library/dis.rst:1226 -#: ../../library/dis.rst:1238 ../../library/dis.rst:1250 msgid "Implements::" -msgstr "" +msgstr "次の処理を実行します。 ::" -#: ../../library/dis.rst:738 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" "value = STACK.pop()\n" "container[key] = value" msgstr "" +"key = STACK.pop()\n" +"container = STACK.pop()\n" +"value = STACK.pop()\n" +"container[key] = value" -#: ../../library/dis.rst:748 msgid "" "key = STACK.pop()\n" "container = STACK.pop()\n" "del container[key]" msgstr "" +"key = STACK.pop()\n" +"container = STACK.pop()\n" +"del container[key]" -#: ../../library/dis.rst:756 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" "container = STACK.pop()\n" "STACK.append(container[start:end])" msgstr "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"container = STACK.pop()\n" +"STACK.append(container[start:end])" -#: ../../library/dis.rst:768 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" @@ -918,113 +1000,127 @@ msgid "" "value = STACK.pop()\n" "container[start:end] = value" msgstr "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"container = STACK.pop()\n" +"value = STACK.pop()\n" +"container[start:end] = value" #: ../../library/dis.rst:777 msgid "**Coroutine opcodes**" msgstr "**コルーチン命令コード**" -#: ../../library/dis.rst:781 msgid "" "Implements ``STACK[-1] = get_awaitable(STACK[-1])``, where " "``get_awaitable(o)`` returns ``o`` if ``o`` is a coroutine object or a " "generator object with the :data:`~inspect.CO_ITERABLE_COROUTINE` flag, or " "resolves ``o.__await__``." msgstr "" +"``STACK[-1] = get_awaitable(STACK[-1])`` を実行します。\n" +"ここで ``get_awaitable(o)`` は、``o`` がコルーチンオブジェクトか :data:" +"`~inspect.CO_ITERABLE_COROUTINE` フラグのあるジェネレーターオブジェクトなら " +"``o`` を返し、それ以外は ``o.__await__`` を解決します。" -#: ../../library/dis.rst:786 msgid "" "If the ``where`` operand is nonzero, it indicates where the instruction " "occurs:" -msgstr "" +msgstr "``where`` オペランドがゼロでなければ、命令が現れる場所を示します:" -#: ../../library/dis.rst:789 msgid "``1``: After a call to ``__aenter__``" -msgstr "" +msgstr "``1``: ``__aenter__`` の呼び出しの後" -#: ../../library/dis.rst:790 msgid "``2``: After a call to ``__aexit__``" -msgstr "" +msgstr "``2``: ``__aexit__`` の呼び出しの後" -#: ../../library/dis.rst:794 msgid "Previously, this instruction did not have an oparg." -msgstr "" +msgstr "以前は、この命令に ``oparg`` はありませんでした。" -#: ../../library/dis.rst:800 msgid "Implements ``STACK[-1] = STACK[-1].__aiter__()``." -msgstr "" +msgstr "``STACK[-1] = STACK[-1].__aiter__()`` を実行します。" -#: ../../library/dis.rst:803 msgid "Returning awaitable objects from ``__aiter__`` is no longer supported." msgstr "" +"``__aiter__`` から awaitable オブジェクトを返すことは、サポートされなくなりま" +"した。" -#: ../../library/dis.rst:810 msgid "" "Implement ``STACK.append(get_awaitable(STACK[-1].__anext__()))`` to the " "stack. See ``GET_AWAITABLE`` for details about ``get_awaitable``." msgstr "" +"``STACK.append(get_awaitable(STACK[-1].__anext__()))`` を実行してスタックに追" +"加します。\n" +"``get_awaitable`` の詳細は ``GET_AWAITABLE`` を参照してください。" -#: ../../library/dis.rst:818 msgid "" "Terminates an :keyword:`async for` loop. Handles an exception raised when " "awaiting a next item. The stack contains the async iterable in ``STACK[-2]`` " "and the raised exception in ``STACK[-1]``. Both are popped. If the exception " "is not :exc:`StopAsyncIteration`, it is re-raised." msgstr "" +":keyword:`async for` ループを終了します。\n" +"次の要素を await するときに送出された例外を処理します。\n" +"スタックの ``STACK[-2]`` には非同期イテラブル、``STACK[-1]`` には送出された例" +"外があり、両方をポップします。\n" +"例外が :exc:`StopAsyncIteration` でなければ再送出します。" -#: ../../library/dis.rst:825 ../../library/dis.rst:916 -#: ../../library/dis.rst:927 msgid "" "Exception representation on the stack now consist of one, not three, items." -msgstr "" +msgstr "スタック上の例外の表現が、3 要素ではなく 1 要素になりました。" -#: ../../library/dis.rst:831 msgid "" "Handles an exception raised during a :meth:`~generator.throw` or :meth:" "`~generator.close` call through the current frame. If ``STACK[-1]`` is an " "instance of :exc:`StopIteration`, pop three values from the stack and push " "its ``value`` member. Otherwise, re-raise ``STACK[-1]``." msgstr "" +"現在のフレームを通じた :meth:`~generator.throw` または :meth:`~generator." +"close` の呼び出し中に送出された例外を処理します。\n" +"``STACK[-1]`` が :exc:`StopIteration` のインスタンスなら、スタックから 3 つの" +"値をポップして、その ``value`` メンバーをプッシュします。\n" +"それ以外は ``STACK[-1]`` を再送出します。" #: ../../library/dis.rst:840 msgid "**Miscellaneous opcodes**" msgstr "**その他の命令コード**" -#: ../../library/dis.rst:846 msgid "" "item = STACK.pop()\n" "set.add(STACK[-i], item)" msgstr "" +"item = STACK.pop()\n" +"set.add(STACK[-i], item)" -#: ../../library/dis.rst:849 msgid "Used to implement set comprehensions." -msgstr "" +msgstr "集合内包表記の実装に使います。" -#: ../../library/dis.rst:856 msgid "" "item = STACK.pop()\n" "list.append(STACK[-i], item)" msgstr "" +"item = STACK.pop()\n" +"list.append(STACK[-i], item)" -#: ../../library/dis.rst:859 msgid "Used to implement list comprehensions." -msgstr "" +msgstr "リスト内包表記の実装に使います。" -#: ../../library/dis.rst:866 msgid "" "value = STACK.pop()\n" "key = STACK.pop()\n" "dict.__setitem__(STACK[-i], key, value)" msgstr "" +"value = STACK.pop()\n" +"key = STACK.pop()\n" +"dict.__setitem__(STACK[-i], key, value)" -#: ../../library/dis.rst:870 msgid "Used to implement dict comprehensions." -msgstr "" +msgstr "辞書内包表記の実装に使います。" -#: ../../library/dis.rst:873 msgid "" "Map value is ``STACK[-1]`` and map key is ``STACK[-2]``. Before, those were " "reversed." msgstr "" +"マッピングの値が ``STACK[-1]``、キーが ``STACK[-2]`` になりました。\n" +"以前は逆でした。" #: ../../library/dis.rst:877 msgid "" @@ -1037,120 +1133,142 @@ msgstr "" "たは key/value ペアをスタックから取り除きますが、コンテナオブジェクトはループ" "の次のイテレーションで利用できるようにスタックに残しておきます。" -#: ../../library/dis.rst:885 msgid "Returns with ``STACK[-1]`` to the caller of the function." -msgstr "" +msgstr "``STACK[-1]`` を返り値として、関数の呼び出し元に戻ります。" -#: ../../library/dis.rst:890 msgid "Yields ``STACK.pop()`` from a :term:`generator`." -msgstr "" +msgstr ":term:`generator` から ``STACK.pop()`` を yield します。" -#: ../../library/dis.rst:892 msgid "oparg set to be the stack depth." -msgstr "" +msgstr "``oparg`` にスタックの深さを設定するようになりました。" -#: ../../library/dis.rst:895 msgid "" "oparg set to be the exception block depth, for efficient closing of " "generators." msgstr "" +"ジェネレーターを効率よく閉じるため、``oparg`` に例外ブロックの深さを設定する" +"ようになりました。" -#: ../../library/dis.rst:898 msgid "" "oparg is ``1`` if this instruction is part of a yield-from or await, and " "``0`` otherwise." msgstr "" +"``oparg`` は、この命令が yield from または await の一部なら ``1``、それ以外" +"は ``0`` になりました。" -#: ../../library/dis.rst:904 msgid "" "Checks whether ``__annotations__`` is defined in ``locals()``, if not it is " "set up to an empty ``dict``. This opcode is only emitted if a class or " "module body contains :term:`variable annotations ` " "statically." msgstr "" +"``locals()`` に ``__annotations__`` が定義されているかを確認し、なければ空の " +"``dict`` に設定します。\n" +"このオペコードは、クラスやモジュールの本体に :term:`変数アノテーション " +"` が静的に含まれる場合にのみ生成されます。" -#: ../../library/dis.rst:914 msgid "" "Pops a value from the stack, which is used to restore the exception state." -msgstr "" +msgstr "スタックから値をポップし、例外の状態を復元するために使います。" -#: ../../library/dis.rst:921 msgid "" "Re-raises the exception currently on top of the stack. If oparg is non-zero, " "pops an additional value from the stack which is used to set :attr:`~frame." "f_lasti` of the current frame." msgstr "" +"現在スタックの先頭にある例外を再送出します。\n" +"``oparg`` がゼロでなければ、さらに値を 1 つポップし、現在のフレームの :attr:" +"`~frame.f_lasti` を設定するために使います。" -#: ../../library/dis.rst:932 msgid "" "Pops a value from the stack. Pushes the current exception to the top of the " "stack. Pushes the value originally popped back to the stack. Used in " "exception handlers." msgstr "" +"スタックから値を 1 つポップします。\n" +"現在の例外をスタックの先頭にプッシュし、最初にポップした値をスタックに戻しま" +"す。\n" +"例外ハンドラーで使います。" -#: ../../library/dis.rst:940 msgid "" "Performs exception matching for ``except``. Tests whether the ``STACK[-2]`` " "is an exception matching ``STACK[-1]``. Pops ``STACK[-1]`` and pushes the " "boolean result of the test." msgstr "" +"``except`` の例外の照合を行います。\n" +"``STACK[-2]`` が ``STACK[-1]`` に一致する例外かを調べます。\n" +"``STACK[-1]`` をポップし、照合結果の真偽値をプッシュします。" -#: ../../library/dis.rst:948 msgid "" "Performs exception matching for ``except*``. Applies ``split(STACK[-1])`` on " "the exception group representing ``STACK[-2]``." msgstr "" +"``except*`` の例外の照合を行います。\n" +"``STACK[-2]`` が表す例外グループに ``split(STACK[-1])`` を適用します。" -#: ../../library/dis.rst:951 msgid "" "In case of a match, pops two items from the stack and pushes the non-" "matching subgroup (``None`` in case of full match) followed by the matching " "subgroup. When there is no match, pops one item (the match type) and pushes " "``None``." msgstr "" +"一致した場合は、スタックから 2 要素をポップし、一致しないサブグループ (すべて" +"一致した場合は ``None``)、一致するサブグループの順にプッシュします。\n" +"一致しない場合は、1 要素 (照合する型) をポップし、``None`` をプッシュします。" -#: ../../library/dis.rst:960 msgid "" "Calls the function in position 4 on the stack with arguments (type, val, tb) " "representing the exception at the top of the stack. Used to implement the " "call ``context_manager.__exit__(*exc_info())`` when an exception has " "occurred in a :keyword:`with` statement." msgstr "" +"スタックの先頭から 4 番目にある関数を、先頭の例外を表す引数 (type, val, tb) " +"で呼び出します。\n" +":keyword:`with` 文で例外が起きたときの ``context_manager." +"__exit__(*exc_info())`` の呼び出しを実装するために使います。" -#: ../../library/dis.rst:967 msgid "" "The ``__exit__`` function is in position 4 of the stack rather than 7. " "Exception representation on the stack now consist of one, not three, items." msgstr "" +"``__exit__`` 関数の位置が、スタックの先頭から 7 番目ではなく 4 番目になりまし" +"た。\n" +"スタック上の例外の表現が、3 要素ではなく 1 要素になりました。" -#: ../../library/dis.rst:974 msgid "" "Pushes a common constant onto the stack. The interpreter contains a " "hardcoded list of constants supported by this instruction. Used by the :" "keyword:`assert` statement to load :exc:`AssertionError`." msgstr "" +"よく使う定数をスタックにプッシュします。\n" +"インタープリタには、この命令がサポートする定数の固定のリストがあります。\n" +":keyword:`assert` 文で :exc:`AssertionError` をロードするために使います。" -#: ../../library/dis.rst:983 msgid "" "Pushes :func:`!builtins.__build_class__` onto the stack. It is later called " "to construct a class." msgstr "" +":func:`!builtins.__build_class__` をスタックにプッシュします。\n" +"これは後でクラスを構築するために呼び出されます。" -#: ../../library/dis.rst:988 msgid "" "Perform ``STACK.append(len(STACK[-1]))``. Used in :keyword:`match` " "statements where comparison with structure of pattern is needed." msgstr "" +"``STACK.append(len(STACK[-1]))`` を実行します。\n" +"パターンの構造との比較が必要な :keyword:`match` 文で使います。" -#: ../../library/dis.rst:996 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Mapping` (or, " "more technically: if it has the :c:macro:`Py_TPFLAGS_MAPPING` flag set in " "its :c:member:`~PyTypeObject.tp_flags`), push ``True`` onto the stack. " "Otherwise, push ``False``." msgstr "" +"``STACK[-1]`` が :class:`collections.abc.Mapping` のインスタンスなら (より厳" +"密には、:c:member:`~PyTypeObject.tp_flags` に :c:macro:`Py_TPFLAGS_MAPPING` " +"フラグが設定されていれば)、スタックに ``True`` をプッシュします。\n" +"それ以外は ``False`` をプッシュします。" -#: ../../library/dis.rst:1006 msgid "" "If ``STACK[-1]`` is an instance of :class:`collections.abc.Sequence` and is " "*not* an instance of :class:`str`/:class:`bytes`/:class:`bytearray` (or, " @@ -1158,59 +1276,80 @@ msgid "" "its :c:member:`~PyTypeObject.tp_flags`), push ``True`` onto the stack. " "Otherwise, push ``False``." msgstr "" +"``STACK[-1]`` が :class:`collections.abc.Sequence` のインスタンスで、:class:" +"`str`/:class:`bytes`/:class:`bytearray` のインスタンスでは *ない* 場合 (より" +"厳密には、:c:member:`~PyTypeObject.tp_flags` に :c:macro:" +"`Py_TPFLAGS_SEQUENCE` フラグが設定されていれば)、スタックに ``True`` をプッ" +"シュします。\n" +"それ以外は ``False`` をプッシュします。" -#: ../../library/dis.rst:1016 msgid "" "``STACK[-1]`` is a tuple of mapping keys, and ``STACK[-2]`` is the match " "subject. If ``STACK[-2]`` contains all of the keys in ``STACK[-1]``, push a :" "class:`tuple` containing the corresponding values. Otherwise, push ``None``." msgstr "" +"``STACK[-1]`` はマッピングのキーのタプル、``STACK[-2]`` は照合対象です。\n" +"``STACK[-2]`` が ``STACK[-1]`` のすべてのキーを含んでいれば、対応する値を含" +"む :class:`tuple` をプッシュします。\n" +"それ以外は ``None`` をプッシュします。" -#: ../../library/dis.rst:1022 ../../library/dis.rst:1768 msgid "" "Previously, this instruction also pushed a boolean value indicating success " "(``True``) or failure (``False``)." msgstr "" +"以前は、成功 (``True``) または失敗 (``False``) を示す真偽値もプッシュしていま" +"した。" -#: ../../library/dis.rst:1029 msgid "" "Implements ``name = STACK.pop()``. *namei* is the index of *name* in the " "attribute :attr:`~codeobject.co_names` of the :ref:`code object `. The compiler tries to use :opcode:`STORE_FAST` or :opcode:" "`STORE_GLOBAL` if possible." msgstr "" +"``name = STACK.pop()`` を実行します。\n" +"*namei* は、:ref:`コードオブジェクト ` の :attr:`~codeobject." +"co_names` 属性内の ``name`` のインデックスです。\n" +"コンパイラは、可能なら :opcode:`STORE_FAST` または :opcode:`STORE_GLOBAL` を" +"使おうとします。" -#: ../../library/dis.rst:1036 msgid "" "Implements ``del name``, where *namei* is the index into :attr:`~codeobject." "co_names` attribute of the :ref:`code object `." msgstr "" +"``del name`` を実行します。\n" +"*namei* は :ref:`コードオブジェクト ` の :attr:`~codeobject." +"co_names` 属性内のインデックスです。" -#: ../../library/dis.rst:1042 msgid "" "Unpacks ``STACK[-1]`` into *count* individual values, which are put onto the " "stack right-to-left. Require there to be exactly *count* values.::" msgstr "" +"``STACK[-1]`` を *count* 個の値にアンパックし、右から左の順にスタックに置きま" +"す。\n" +"値はちょうど *count* 個でなければなりません。 ::" -#: ../../library/dis.rst:1045 msgid "" "assert(len(STACK[-1]) == count)\n" "STACK.extend(STACK.pop()[:-count-1:-1])" msgstr "" +"assert(len(STACK[-1]) == count)\n" +"STACK.extend(STACK.pop()[:-count-1:-1])" -#: ../../library/dis.rst:1051 msgid "" "Implements assignment with a starred target: Unpacks an iterable in " "``STACK[-1]`` into individual values, where the total number of values can " "be smaller than the number of items in the iterable: one of the new values " "will be a list of all leftover items." msgstr "" +"星付きの代入先への代入を実装します。\n" +"``STACK[-1]`` のイテラブルを個別の値にアンパックしますが、値の総数はイテラブ" +"ルの要素数より少なくてもかまいません。\n" +"新しい値の 1 つは、残りの要素をすべて含むリストになります。" -#: ../../library/dis.rst:1056 msgid "The number of values before and after the list value is limited to 255." msgstr "" +"リストとなる値の前後の値の数は、それぞれ 255 個までに制限されています。" -#: ../../library/dis.rst:1058 msgid "" "The number of values before the list value is encoded in the argument of the " "opcode. The number of values after the list if any is encoded using an " @@ -1218,6 +1357,12 @@ msgid "" "values where the low byte of *counts* is the number of values before the " "list value, the high byte of *counts* the number of values after it." msgstr "" +"リストとなる値より前の値の数はオペコードの引数に符号化されます。\n" +"リストより後にも値がある場合、その数は ``EXTENDED_ARG`` を使って符号化されま" +"す。\n" +"したがって、引数は 2 バイトの値とみなせます。\n" +"*counts* の下位バイトがリストより前の値の数、上位バイトがリストより後の値の数" +"です。" #: ../../library/dis.rst:1064 msgid "" @@ -1225,30 +1370,35 @@ msgid "" "d`` will be stored after execution as ``STACK.extend((a, b, c))``." msgstr "" -#: ../../library/dis.rst:1072 msgid "" "obj = STACK.pop()\n" "value = STACK.pop()\n" "obj.name = value" msgstr "" +"obj = STACK.pop()\n" +"value = STACK.pop()\n" +"obj.name = value" -#: ../../library/dis.rst:1076 msgid "" "where *namei* is the index of name in :attr:`~codeobject.co_names` of the :" "ref:`code object `." msgstr "" +"ここで *namei* は :ref:`コードオブジェクト ` の :attr:" +"`~codeobject.co_names` 内の ``name`` のインデックスです。" -#: ../../library/dis.rst:1083 msgid "" "obj = STACK.pop()\n" "del obj.name" msgstr "" +"obj = STACK.pop()\n" +"del obj.name" -#: ../../library/dis.rst:1086 msgid "" "where *namei* is the index of name into :attr:`~codeobject.co_names` of the :" "ref:`code object `." msgstr "" +"ここで *namei* は :ref:`コードオブジェクト ` の :attr:" +"`~codeobject.co_names` 内の ``name`` のインデックスです。" #: ../../library/dis.rst:1092 msgid "Works as :opcode:`STORE_NAME`, but stores the name as a global." @@ -1266,25 +1416,28 @@ msgstr "" msgid "Pushes ``co_consts[consti]`` onto the stack." msgstr "``co_consts[consti]`` をスタックにプッシュします。" -#: ../../library/dis.rst:1107 msgid "" "Pushes the integer ``i`` onto the stack. ``i`` must be in ``range(256)``" msgstr "" +"整数 ``i`` をスタックにプッシュします。\n" +"``i`` は ``range(256)`` の範囲内でなければなりません。" -#: ../../library/dis.rst:1115 msgid "" "Pushes the value associated with ``co_names[namei]`` onto the stack. The " "name is looked up within the locals, then the globals, then the builtins." msgstr "" +"``co_names[namei]`` に対応する値をスタックにプッシュします。\n" +"名前はローカル、グローバル、組み込みの順に探します。" -#: ../../library/dis.rst:1121 msgid "" "Pushes a reference to the locals dictionary onto the stack. This is used to " "prepare namespace dictionaries for :opcode:`LOAD_FROM_DICT_OR_DEREF` and :" "opcode:`LOAD_FROM_DICT_OR_GLOBALS`." msgstr "" +"ローカル変数の辞書への参照をスタックにプッシュします。\n" +":opcode:`LOAD_FROM_DICT_OR_DEREF` と :opcode:`LOAD_FROM_DICT_OR_GLOBALS` に渡" +"す名前空間の辞書を準備するために使います。" -#: ../../library/dis.rst:1130 msgid "" "Pops a mapping off the stack and looks up the value for ``co_names[namei]``. " "If the name is not found there, looks it up in the globals and then the " @@ -1292,48 +1445,59 @@ msgid "" "variables in :ref:`annotation scopes ` within class " "bodies." msgstr "" +"スタックからマッピングをポップし、``co_names[namei]`` の値を探します。\n" +"そこに名前がなければ、:opcode:`LOAD_GLOBAL` と同様にグローバル、組み込みの順" +"に探します。\n" +"クラス本体の :ref:`アノテーションスコープ ` でグローバル変" +"数をロードするために使います。" -#: ../../library/dis.rst:1141 msgid "" "Constructs a new :class:`~string.templatelib.Template` instance from a tuple " "of strings and a tuple of interpolations and pushes the resulting object " "onto the stack::" msgstr "" +"文字列のタプルと補間のタプルから、新しい :class:`~string.templatelib." +"Template` インスタンスを構築し、結果のオブジェクトをスタックにプッシュしま" +"す。 ::" -#: ../../library/dis.rst:1145 msgid "" "interpolations = STACK.pop()\n" "strings = STACK.pop()\n" "STACK.append(_build_template(strings, interpolations))" msgstr "" +"interpolations = STACK.pop()\n" +"strings = STACK.pop()\n" +"STACK.append(_build_template(strings, interpolations))" -#: ../../library/dis.rst:1154 msgid "" "Constructs a new :class:`~string.templatelib.Interpolation` instance from a " "value and its source expression and pushes the resulting object onto the " "stack." msgstr "" +"値とそのソースの式から新しい :class:`~string.templatelib.Interpolation` イン" +"スタンスを構築し、結果のオブジェクトをスタックにプッシュします。" -#: ../../library/dis.rst:1158 msgid "" "If no conversion or format specification is present, ``format`` is set to " "``2``." -msgstr "" +msgstr "変換も書式指定もなければ、``format`` は ``2`` に設定されます。" -#: ../../library/dis.rst:1161 msgid "" "If the low bit of ``format`` is set, it indicates that the interpolation " "contains a format specification." msgstr "" +"``format`` の最下位ビットが立っていれば、補間に書式指定が含まれることを示しま" +"す。" -#: ../../library/dis.rst:1164 msgid "" "If ``format >> 2`` is non-zero, it indicates that the interpolation contains " "a conversion. The value of ``format >> 2`` is the conversion type (``0`` for " "no conversion, ``1`` for ``!s``, ``2`` for ``!r``, and ``3`` for ``!a``)::" msgstr "" +"``format >> 2`` がゼロでなければ、補間に変換が含まれることを示します。\n" +"``format >> 2`` の値は変換の種類を表します (``0`` は変換なし、``1`` は ``!" +"s``、``2`` は ``!r``、``3`` は ``!a``)。 ::" -#: ../../library/dis.rst:1169 msgid "" "conversion = format >> 2\n" "if format & 1:\n" @@ -1345,14 +1509,23 @@ msgid "" "STACK.append(_build_interpolation(value, expression, conversion, " "format_spec))" msgstr "" +"conversion = format >> 2\n" +"if format & 1:\n" +" format_spec = STACK.pop()\n" +"else:\n" +" format_spec = None\n" +"expression = STACK.pop()\n" +"value = STACK.pop()\n" +"STACK.append(_build_interpolation(value, expression, conversion, " +"format_spec))" -#: ../../library/dis.rst:1183 msgid "" "Creates a tuple consuming *count* items from the stack, and pushes the " "resulting tuple onto the stack::" msgstr "" +"スタックから *count* 個の要素を取り出してタプルを作り、そのタプルをスタックに" +"プッシュします。 ::" -#: ../../library/dis.rst:1186 msgid "" "if count == 0:\n" " value = ()\n" @@ -1362,6 +1535,13 @@ msgid "" "\n" "STACK.append(value)" msgstr "" +"if count == 0:\n" +" value = ()\n" +"else:\n" +" value = tuple(STACK[-count:])\n" +" STACK = STACK[:-count]\n" +"\n" +"STACK.append(value)" #: ../../library/dis.rst:1197 msgid "Works as :opcode:`BUILD_TUPLE`, but creates a list." @@ -1375,64 +1555,68 @@ msgstr "" ":opcode:`BUILD_TUPLE` と同じように動作しますが、この命令は set を作り出しま" "す。" -#: ../../library/dis.rst:1207 msgid "" "Pushes a new dictionary object onto the stack. Pops ``2 * count`` items so " "that the dictionary holds *count* entries: ``{..., STACK[-4]: STACK[-3], " "STACK[-2]: STACK[-1]}``." msgstr "" +"新しい辞書オブジェクトをスタックにプッシュします。\n" +"辞書が ``{..., STACK[-4]: STACK[-3], STACK[-2]: STACK[-1]}`` という *count* " +"個のエントリーを持つように、``2 * count`` 個の要素をポップします。" -#: ../../library/dis.rst:1211 msgid "" "The dictionary is created from stack items instead of creating an empty " "dictionary pre-sized to hold *count* items." msgstr "" +"*count* 個の要素を収容するサイズの空の辞書を作るのではなく、スタックの要素か" +"ら辞書を作るようになりました。" -#: ../../library/dis.rst:1218 msgid "" "Concatenates *count* strings from the stack and pushes the resulting string " "onto the stack." msgstr "" +"スタックから *count* 個の文字列を連結し、結果の文字列をスタックにプッシュしま" +"す。" -#: ../../library/dis.rst:1228 msgid "" "seq = STACK.pop()\n" "list.extend(STACK[-i], seq)" msgstr "" +"seq = STACK.pop()\n" +"list.extend(STACK[-i], seq)" -#: ../../library/dis.rst:1231 msgid "Used to build lists." -msgstr "" +msgstr "リストの構築に使います。" -#: ../../library/dis.rst:1240 msgid "" "seq = STACK.pop()\n" "set.update(STACK[-i], seq)" msgstr "" +"seq = STACK.pop()\n" +"set.update(STACK[-i], seq)" -#: ../../library/dis.rst:1243 msgid "Used to build sets." -msgstr "" +msgstr "集合の構築に使います。" -#: ../../library/dis.rst:1252 msgid "" "map = STACK.pop()\n" "dict.update(STACK[-i], map)" msgstr "" +"map = STACK.pop()\n" +"dict.update(STACK[-i], map)" -#: ../../library/dis.rst:1255 msgid "Used to build dicts." -msgstr "" +msgstr "辞書の構築に使います。" -#: ../../library/dis.rst:1262 msgid "Like :opcode:`DICT_UPDATE` but raises an exception for duplicate keys." -msgstr "" +msgstr ":opcode:`DICT_UPDATE` と同じですが、キーが重複すると例外を送出します。" -#: ../../library/dis.rst:1269 msgid "" "If the low bit of ``namei`` is not set, this replaces ``STACK[-1]`` with " "``getattr(STACK[-1], co_names[namei>>1])``." msgstr "" +"``namei`` の最下位ビットが立っていなければ、``STACK[-1]`` を " +"``getattr(STACK[-1], co_names[namei>>1])`` に置き換えます。" #: ../../library/dis.rst:1272 msgid "" @@ -1446,34 +1630,33 @@ msgid "" "pushed." msgstr "" -#: ../../library/dis.rst:1281 msgid "" "If the low bit of ``namei`` is set, then a ``NULL`` or ``self`` is pushed to " "the stack before the attribute or unbound method respectively." msgstr "" +"``namei`` の最下位ビットが立っている場合、属性または非束縛メソッドより先に、" +"それぞれ ``NULL`` または ``self`` をスタックにプッシュするようになりました。" -#: ../../library/dis.rst:1288 msgid "" "This opcode implements :func:`super`, both in its zero-argument and two-" "argument forms (e.g. ``super().method()``, ``super().attr`` and ``super(cls, " "self).method()``, ``super(cls, self).attr``)." msgstr "" +"このオペコードは、引数なしと引数 2 つの両方の :func:`super` を実装します (例" +"えば ``super().method()``、``super().attr``、``super(cls, self).method()``、" +"``super(cls, self).attr``)。" -#: ../../library/dis.rst:1292 msgid "It pops three values from the stack (from top of stack down):" -msgstr "" +msgstr "スタックの先頭から順に、次の 3 つの値をポップします:" -#: ../../library/dis.rst:1294 msgid "``self``: the first argument to the current method" -msgstr "" +msgstr "``self``: 現在のメソッドの最初の引数" -#: ../../library/dis.rst:1295 msgid "``cls``: the class within which the current method was defined" -msgstr "" +msgstr "``cls``: 現在のメソッドを定義したクラス" -#: ../../library/dis.rst:1296 msgid "the global ``super``" -msgstr "" +msgstr "グローバルの ``super``" #: ../../library/dis.rst:1298 msgid "" @@ -1488,11 +1671,12 @@ msgid "" "it is unset a single value is pushed to the stack." msgstr "" -#: ../../library/dis.rst:1305 msgid "" "The second-low bit of ``namei``, if set, means that this was a two-argument " "call to :func:`super` (unset means zero-argument)." msgstr "" +"``namei`` の下から 2 番目のビットが立っていれば、引数 2 つの :func:`super` 呼" +"び出しであることを示します (立っていなければ引数なしです)。" #: ../../library/dis.rst:1313 msgid "" @@ -1501,21 +1685,23 @@ msgid "" "(``opname & 16``), the result should be coerced to ``bool``." msgstr "" -#: ../../library/dis.rst:1317 msgid "" "The fifth-lowest bit of the oparg now indicates a forced conversion to :" "class:`bool`." msgstr "" +"``oparg`` の下から 5 番目のビットが、:class:`bool` への強制変換を表すようにな" +"りました。" -#: ../../library/dis.rst:1324 msgid "Performs ``is`` comparison, or ``is not`` if ``invert`` is 1." msgstr "" +"``is`` による比較を行います。\n" +"``invert`` が 1 なら ``is not`` による比較を行います。" -#: ../../library/dis.rst:1331 msgid "Performs ``in`` comparison, or ``not in`` if ``invert`` is 1." msgstr "" +"``in`` による比較を行います。\n" +"``invert`` が 1 なら ``not in`` による比較を行います。" -#: ../../library/dis.rst:1338 msgid "" "Imports the module ``co_names[namei]``. ``STACK[-1]`` and ``STACK[-2]`` are " "popped and provide the *fromlist* and *level* arguments of :func:" @@ -1523,73 +1709,94 @@ msgid "" "namespace is not affected: for a proper import statement, a subsequent :" "opcode:`STORE_FAST` instruction modifies the namespace." msgstr "" +"モジュール ``co_names[namei]`` をインポートします。\n" +"``STACK[-1]`` と ``STACK[-2]`` をポップし、:func:`__import__` の *fromlist* " +"と *level* 引数として使います。\n" +"モジュールオブジェクトをスタックにプッシュします。\n" +"現在の名前空間は変わりません。\n" +"通常の import 文では、後続の :opcode:`STORE_FAST` 命令が名前空間を変更しま" +"す。" -#: ../../library/dis.rst:1346 msgid "" "Loads the attribute ``co_names[namei]`` from the module found in " "``STACK[-1]``. The resulting object is pushed onto the stack, to be " "subsequently stored by a :opcode:`STORE_FAST` instruction." msgstr "" +"``STACK[-1]`` にあるモジュールから属性 ``co_names[namei]`` をロードします。\n" +"結果のオブジェクトをスタックにプッシュし、その後の :opcode:`STORE_FAST` 命令" +"で保存できるようにします。" #: ../../library/dis.rst:1353 msgid "Increments bytecode counter by *delta*." msgstr "バイトコードカウンタを *delta* だけ増加させます。" -#: ../../library/dis.rst:1358 msgid "Decrements bytecode counter by *delta*. Checks for interrupts." msgstr "" +"バイトコードカウンターを *delta* だけ減らします。\n" +"割り込みをチェックします。" -#: ../../library/dis.rst:1365 msgid "Decrements bytecode counter by *delta*. Does not check for interrupts." msgstr "" +"バイトコードカウンターを *delta* だけ減らします。\n" +"割り込みはチェックしません。" -#: ../../library/dis.rst:1372 msgid "" "If ``STACK[-1]`` is true, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" +"``STACK[-1]`` が真なら、バイトコードカウンターを *delta* だけ増やします。\n" +"``STACK[-1]`` はポップします。" -#: ../../library/dis.rst:1375 ../../library/dis.rst:1391 msgid "" "The oparg is now a relative delta rather than an absolute target. This " "opcode is a pseudo-instruction, replaced in final bytecode by the directed " "versions (forward/backward)." msgstr "" +"``oparg`` は絶対位置のジャンプ先ではなく、相対的な差分になりました。\n" +"このオペコードは疑似命令となり、最終的なバイトコードでは方向 (前方/後方) ごと" +"の命令に置き換えられます。" -#: ../../library/dis.rst:1380 ../../library/dis.rst:1396 -#: ../../library/dis.rst:1409 ../../library/dis.rst:1420 msgid "This is no longer a pseudo-instruction." -msgstr "" +msgstr "疑似命令ではなくなりました。" -#: ../../library/dis.rst:1388 msgid "" "If ``STACK[-1]`` is false, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" +"``STACK[-1]`` が偽なら、バイトコードカウンターを *delta* だけ増やします。\n" +"``STACK[-1]`` はポップします。" -#: ../../library/dis.rst:1404 msgid "" "If ``STACK[-1]`` is not ``None``, increments the bytecode counter by " "*delta*. ``STACK[-1]`` is popped." msgstr "" +"``STACK[-1]`` が ``None`` でなければ、バイトコードカウンターを *delta* だけ増" +"やします。\n" +"``STACK[-1]`` はポップします。" -#: ../../library/dis.rst:1415 msgid "" "If ``STACK[-1]`` is ``None``, increments the bytecode counter by *delta*. " "``STACK[-1]`` is popped." msgstr "" +"``STACK[-1]`` が ``None`` なら、バイトコードカウンターを *delta* だけ増やしま" +"す。\n" +"``STACK[-1]`` はポップします。" -#: ../../library/dis.rst:1425 msgid "" "``STACK[-1]`` is an :term:`iterator`. Call its :meth:`~iterator.__next__` " "method. If this yields a new value, push it on the stack (leaving the " "iterator below it). If the iterator indicates it is :term:`exhausted` then " "the byte code counter is incremented by *delta*." msgstr "" +"``STACK[-1]`` は :term:`iterator` です。\n" +"その :meth:`~iterator.__next__` メソッドを呼び出します。\n" +"新しい値が得られれば、イテレーターを下に残したまま値をスタックにプッシュしま" +"す。\n" +"イテレーターが :term:`exhausted` になったことを示した場合は、バイトコードカウ" +"ンターを *delta* だけ増やします。" -#: ../../library/dis.rst:1430 msgid "Up until 3.11 the iterator was popped when it was exhausted." -msgstr "" +msgstr "3.11 までは、要素を使い切るとイテレーターをポップしていました。" #: ../../library/dis.rst:1435 msgid "Loads the global named ``co_names[namei>>1]`` onto the stack." @@ -1608,84 +1815,94 @@ msgid "" msgstr "" "ローカルな ``co_varnames[var_num]`` への参照をスタックにプッシュします。" -#: ../../library/dis.rst:1445 msgid "" "This opcode is now only used in situations where the local variable is " "guaranteed to be initialized. It cannot raise :exc:`UnboundLocalError`." msgstr "" +"このオペコードは、ローカル変数が初期化されていることが保証される場合にのみ使" +"うようになりました。\n" +":exc:`UnboundLocalError` を送出することはありません。" -#: ../../library/dis.rst:1451 msgid "" "Pushes a borrowed reference to the local ``co_varnames[var_num]`` onto the " "stack." msgstr "" +"ローカル変数 ``co_varnames[var_num]`` への借用参照をスタックにプッシュしま" +"す。" -#: ../../library/dis.rst:1458 msgid "" "Pushes references to ``co_varnames[var_nums >> 4]`` and " "``co_varnames[var_nums & 15]`` onto the stack." msgstr "" +"``co_varnames[var_nums >> 4]`` と ``co_varnames[var_nums & 15]`` への参照をス" +"タックにプッシュします。" -#: ../../library/dis.rst:1466 msgid "" "Pushes borrowed references to ``co_varnames[var_nums >> 4]`` and " "``co_varnames[var_nums & 15]`` onto the stack." msgstr "" +"``co_varnames[var_nums >> 4]`` と ``co_varnames[var_nums & 15]`` への借用参照" +"をスタックにプッシュします。" -#: ../../library/dis.rst:1473 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack, " "raising an :exc:`UnboundLocalError` if the local variable has not been " "initialized." msgstr "" +"ローカル変数 ``co_varnames[var_num]`` への参照をスタックにプッシュします。\n" +"変数が初期化されていなければ :exc:`UnboundLocalError` を送出します。" -#: ../../library/dis.rst:1481 msgid "" "Pushes a reference to the local ``co_varnames[var_num]`` onto the stack (or " "pushes ``NULL`` onto the stack if the local variable has not been " "initialized) and sets ``co_varnames[var_num]`` to ``NULL``." msgstr "" +"ローカル変数 ``co_varnames[var_num]`` への参照をスタックにプッシュします (変" +"数が初期化されていなければ ``NULL`` をプッシュします)。\n" +"そして ``co_varnames[var_num]`` を ``NULL`` に設定します。" -#: ../../library/dis.rst:1489 msgid "Stores ``STACK.pop()`` into the local ``co_varnames[var_num]``." -msgstr "" +msgstr "``STACK.pop()`` をローカル変数 ``co_varnames[var_num]`` に保存します。" -#: ../../library/dis.rst:1493 msgid "" "Stores ``STACK[-1]`` into ``co_varnames[var_nums >> 4]`` and ``STACK[-2]`` " "into ``co_varnames[var_nums & 15]``." msgstr "" +"``STACK[-1]`` を ``co_varnames[var_nums >> 4]`` に、``STACK[-2]`` を " +"``co_varnames[var_nums & 15]`` に保存します。" -#: ../../library/dis.rst:1500 msgid "" "Stores ``STACK.pop()`` into the local ``co_varnames[var_nums >> 4]`` and " "pushes a reference to the local ``co_varnames[var_nums & 15]`` onto the " "stack." msgstr "" +"``STACK.pop()`` をローカル変数 ``co_varnames[var_nums >> 4]`` に保存し、ロー" +"カル変数 ``co_varnames[var_nums & 15]`` への参照をスタックにプッシュします。" #: ../../library/dis.rst:1508 msgid "Deletes local ``co_varnames[var_num]``." msgstr "ローカルな ``co_varnames[var_num]`` を削除します。" -#: ../../library/dis.rst:1513 msgid "" "Creates a new cell in slot ``i``. If that slot is nonempty then that value " "is stored into the new cell." msgstr "" +"スロット ``i`` に新しいセルを作ります。\n" +"スロットが空でなければ、その値を新しいセルに保存します。" -#: ../../library/dis.rst:1521 msgid "" "Loads the cell contained in slot ``i`` of the \"fast locals\" storage. " "Pushes a reference to the object the cell contains on the stack." msgstr "" +"\"fast locals\" 領域のスロット ``i`` にあるセルをロードします。\n" +"セルに入っているオブジェクトへの参照をスタックにプッシュします。" -#: ../../library/dis.rst:1524 ../../library/dis.rst:1546 -#: ../../library/dis.rst:1557 msgid "" "``i`` is no longer offset by the length of :attr:`~codeobject.co_varnames`." msgstr "" +"``i`` に :attr:`~codeobject.co_varnames` の長さをオフセットとして加えなくなり" +"ました。" -#: ../../library/dis.rst:1530 msgid "" "Pops a mapping off the stack and looks up the name associated with slot " "``i`` of the \"fast locals\" storage in this mapping. If the name is not " @@ -1695,113 +1912,126 @@ msgid "" "LOAD_CLASSDEREF`) and in :ref:`annotation scopes ` within " "class bodies." msgstr "" +"スタックからマッピングをポップし、その中で \"fast locals\" 領域のスロット " +"``i`` に対応する名前を探します。\n" +"名前がなければ、:opcode:`LOAD_DEREF` と同様にスロット ``i`` のセルからロード" +"します。\n" +"クラス本体 (以前は :opcode:`!LOAD_CLASSDEREF` を使用) や、クラス本体の :ref:`" +"アノテーションスコープ ` で :term:`クロージャ変数 " +"` をロードするために使います。" -#: ../../library/dis.rst:1543 msgid "" "Stores ``STACK.pop()`` into the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" +"``STACK.pop()`` を \"fast locals\" 領域のスロット ``i`` にあるセルに保存しま" +"す。" -#: ../../library/dis.rst:1552 msgid "" "Empties the cell contained in slot ``i`` of the \"fast locals\" storage. " "Used by the :keyword:`del` statement." msgstr "" +"\"fast locals\" 領域のスロット ``i`` にあるセルを空にします。\n" +":keyword:`del` 文で使います。" -#: ../../library/dis.rst:1563 msgid "" "Copies the ``n`` :term:`free (closure) variables ` from " "the closure into the frame. Removes the need for special code on the " "caller's side when calling closures." msgstr "" +"クロージャからフレームへ、``n`` 個の :term:`自由 (クロージャ) 変数 ` をコピーします。\n" +"これにより、クロージャの呼び出し元で特別なコードを用意する必要がなくなりま" +"す。" -#: ../../library/dis.rst:1572 msgid "" "Raises an exception using one of the 3 forms of the ``raise`` statement, " "depending on the value of *argc*:" msgstr "" +"*argc* の値に応じて、``raise`` 文の 3 つの形式のいずれかで例外を送出します:" -#: ../../library/dis.rst:1575 msgid "0: ``raise`` (re-raise previous exception)" -msgstr "" +msgstr "0: ``raise`` (直前の例外を再送出)" -#: ../../library/dis.rst:1576 msgid "" "1: ``raise STACK[-1]`` (raise exception instance or type at ``STACK[-1]``)" msgstr "" +"1: ``raise STACK[-1]`` (``STACK[-1]`` の例外インスタンスまたは例外型を送出)" -#: ../../library/dis.rst:1577 msgid "" "2: ``raise STACK[-2] from STACK[-1]`` (raise exception instance or type at " "``STACK[-2]`` with ``__cause__`` set to ``STACK[-1]``)" msgstr "" +"2: ``raise STACK[-2] from STACK[-1]`` (``__cause__`` を ``STACK[-1]`` に設定" +"し、``STACK[-2]`` の例外インスタンスまたは例外型を送出)" -#: ../../library/dis.rst:1583 msgid "" "Calls a callable object with the number of arguments specified by ``argc``. " "On the stack are (in ascending order):" msgstr "" +"``argc`` で指定した数の引数で呼び出し可能オブジェクトを呼び出します。\n" +"スタックには下から上の順に次のものがあります:" -#: ../../library/dis.rst:1586 ../../library/dis.rst:1610 msgid "The callable" -msgstr "" +msgstr "呼び出し可能オブジェクト" -#: ../../library/dis.rst:1587 ../../library/dis.rst:1611 msgid "``self`` or ``NULL``" -msgstr "" +msgstr "``self`` または ``NULL``" -#: ../../library/dis.rst:1588 ../../library/dis.rst:1612 msgid "The remaining positional arguments" -msgstr "" +msgstr "残りの位置引数" -#: ../../library/dis.rst:1590 msgid "``argc`` is the total of the positional arguments, excluding ``self``." -msgstr "" +msgstr "``argc`` は ``self`` を除いた位置引数の総数です。" -#: ../../library/dis.rst:1592 msgid "" "``CALL`` pops all arguments and the callable object off the stack, calls the " "callable object with those arguments, and pushes the return value returned " "by the callable object." msgstr "" +"``CALL`` はすべての引数と呼び出し可能オブジェクトをスタックからポップし、それ" +"らの引数でオブジェクトを呼び出して、その返り値をスタックにプッシュします。" -#: ../../library/dis.rst:1598 msgid "The callable now always appears at the same position on the stack." msgstr "" +"呼び出し可能オブジェクトが、常にスタック上の同じ位置に現れるようになりまし" +"た。" -#: ../../library/dis.rst:1601 msgid "Calls with keyword arguments are now handled by :opcode:`CALL_KW`." msgstr "" +"キーワード引数のある呼び出しは :opcode:`CALL_KW` で処理するようになりました。" -#: ../../library/dis.rst:1607 msgid "" "Calls a callable object with the number of arguments specified by ``argc``, " "including one or more named arguments. On the stack are (in ascending order):" msgstr "" +"1 つ以上の名前付き引数を含む、``argc`` で指定した数の引数で呼び出し可能オブ" +"ジェクトを呼び出します。\n" +"スタックには下から上の順に次のものがあります:" -#: ../../library/dis.rst:1613 msgid "The named arguments" -msgstr "" +msgstr "名前付き引数" -#: ../../library/dis.rst:1614 msgid "A :class:`tuple` of keyword argument names" -msgstr "" +msgstr "キーワード引数名の :class:`tuple`" -#: ../../library/dis.rst:1616 msgid "" "``argc`` is the total of the positional and named arguments, excluding " "``self``. The length of the tuple of keyword argument names is the number of " "named arguments." msgstr "" +"``argc`` は ``self`` を除いた位置引数と名前付き引数の総数です。\n" +"キーワード引数名のタプルの長さが、名前付き引数の数です。" -#: ../../library/dis.rst:1619 msgid "" "``CALL_KW`` pops all arguments, the keyword names, and the callable object " "off the stack, calls the callable object with those arguments, and pushes " "the return value returned by the callable object." msgstr "" +"``CALL_KW`` はすべての引数、キーワード名、呼び出し可能オブジェクトをスタック" +"からポップし、それらの引数でオブジェクトを呼び出して、その返り値をスタックに" +"プッシュします。" -#: ../../library/dis.rst:1628 msgid "" "Calls a callable object with variable set of positional and keyword " "arguments. If the lowest bit of *flags* is set, the top of the stack " @@ -1812,454 +2042,474 @@ msgid "" "callable object off the stack, calls the callable object with those " "arguments, and pushes the return value returned by the callable object." msgstr "" +"可変個の位置引数とキーワード引数で呼び出し可能オブジェクトを呼び出します。\n" +"*flags* の最下位ビットが立っている場合、スタックの先頭には追加のキーワード引" +"数を含むマッピングオブジェクトがあります。\n" +"呼び出し前に、マッピングオブジェクトとイテラブルをそれぞれアンパックし、内容" +"をキーワード引数と位置引数として渡します。\n" +"``CALL_FUNCTION_EX`` はすべての引数と呼び出し可能オブジェクトをスタックから" +"ポップし、それらの引数でオブジェクトを呼び出して、その返り値をスタックにプッ" +"シュします。" -#: ../../library/dis.rst:1643 msgid "" "Pushes a ``NULL`` to the stack. Used in the call sequence to match the " "``NULL`` pushed by :opcode:`LOAD_ATTR` for non-method calls." msgstr "" +"スタックに ``NULL`` をプッシュします。\n" +"メソッド以外の呼び出しで :opcode:`LOAD_ATTR` がプッシュする ``NULL`` と呼び出" +"し手順を揃えるために使います。" -#: ../../library/dis.rst:1652 msgid "" "Pushes a new function object on the stack built from the code object at " "``STACK[-1]``." msgstr "" +"``STACK[-1]`` にあるコードオブジェクトから新しい関数オブジェクトを作り、ス" +"タックにプッシュします。" -#: ../../library/dis.rst:1654 msgid "Flag value ``0x04`` is a tuple of strings instead of dictionary" -msgstr "" +msgstr "フラグ値 ``0x04`` は、辞書ではなく文字列のタプルになりました。" -#: ../../library/dis.rst:1657 msgid "Qualified name at ``STACK[-1]`` was removed." -msgstr "" +msgstr "``STACK[-1]`` にあった修飾名を取り除きました。" -#: ../../library/dis.rst:1660 msgid "" "Extra function attributes on the stack, signaled by oparg flags, were " "removed. They now use :opcode:`SET_FUNCTION_ATTRIBUTE`." msgstr "" +"``oparg`` のフラグで指定していた、スタック上の追加の関数属性を取り除きまし" +"た。\n" +"これらには :opcode:`SET_FUNCTION_ATTRIBUTE` を使うようになりました。" -#: ../../library/dis.rst:1667 msgid "" "Sets an attribute on a function object. Expects the function at " "``STACK[-1]`` and the attribute value to set at ``STACK[-2]``; consumes both " "and leaves the function at ``STACK[-1]``. The flag determines which " "attribute to set:" msgstr "" +"関数オブジェクトの属性を設定します。\n" +"``STACK[-1]`` に関数、``STACK[-2]`` に設定する属性値があることを想定し、両方" +"を取り出して関数を ``STACK[-1]`` に残します。\n" +"設定する属性はフラグで決まります:" -#: ../../library/dis.rst:1671 msgid "" "``0x01`` a tuple of default values for positional-only and positional-or-" "keyword parameters in positional order" msgstr "" +"``0x01`` 位置専用パラメーターと位置またはキーワードのパラメーターのデフォルト" +"値を、位置の順に並べたタプル" -#: ../../library/dis.rst:1673 msgid "``0x02`` a dictionary of keyword-only parameters' default values" -msgstr "" +msgstr "``0x02`` キーワード専用パラメーターのデフォルト値の辞書" #: ../../library/dis.rst:1674 msgid "``0x04`` a tuple of strings containing parameters' annotations" msgstr "" -#: ../../library/dis.rst:1675 msgid "``0x08`` a tuple containing cells for free variables, making a closure" -msgstr "" +msgstr "``0x08`` 自由変数のセルを含み、クロージャを構成するタプル" -#: ../../library/dis.rst:1676 msgid "``0x10`` the :term:`annotate function` for the function object" -msgstr "" +msgstr "``0x10`` 関数オブジェクトの :term:`annotate function`" -#: ../../library/dis.rst:1680 msgid "" "Added ``0x10`` to indicate the annotate function for the function object." -msgstr "" +msgstr "関数オブジェクトのアノテーション関数を示す ``0x10`` を追加しました。" -#: ../../library/dis.rst:1688 msgid "" "Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, " "implements::" msgstr "" +"スライスオブジェクトをスタックにプッシュします。\n" +"*argc* は 2 または 3 でなければなりません。\n" +"2 の場合は次の処理を行います。 ::" -#: ../../library/dis.rst:1690 msgid "" "end = STACK.pop()\n" "start = STACK.pop()\n" "STACK.append(slice(start, end))" msgstr "" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"STACK.append(slice(start, end))" -#: ../../library/dis.rst:1694 msgid "if it is 3, implements::" -msgstr "" +msgstr "3 の場合は次の処理を行います。 ::" -#: ../../library/dis.rst:1696 msgid "" "step = STACK.pop()\n" "end = STACK.pop()\n" "start = STACK.pop()\n" "STACK.append(slice(start, end, step))" msgstr "" +"step = STACK.pop()\n" +"end = STACK.pop()\n" +"start = STACK.pop()\n" +"STACK.append(slice(start, end, step))" -#: ../../library/dis.rst:1701 msgid "See the :func:`slice` built-in function for more information." -msgstr "" +msgstr "詳しくは組み込み関数 :func:`slice` を参照してください。" -#: ../../library/dis.rst:1706 msgid "" "Prefixes any opcode which has an argument too big to fit into the default " "one byte. *ext* holds an additional byte which act as higher bits in the " "argument. For each opcode, at most three prefixal ``EXTENDED_ARG`` are " "allowed, forming an argument from two-byte to four-byte." msgstr "" +"デフォルトの 1 バイトに収まらない大きさの引数を持つオペコードの前に付けま" +"す。\n" +"*ext* は、引数の上位ビットとなる追加の 1 バイトを保持します。\n" +"各オペコードの前には最大 3 つの ``EXTENDED_ARG`` を付けられ、2 バイトから 4 " +"バイトの引数を構成できます。" -#: ../../library/dis.rst:1714 msgid "Convert value to a string, depending on ``oparg``::" -msgstr "" +msgstr "``oparg`` に応じて値を文字列に変換します。 ::" -#: ../../library/dis.rst:1716 msgid "" "value = STACK.pop()\n" "result = func(value)\n" "STACK.append(result)" msgstr "" +"value = STACK.pop()\n" +"result = func(value)\n" +"STACK.append(result)" -#: ../../library/dis.rst:1720 msgid "``oparg == 1``: call :func:`str` on *value*" -msgstr "" +msgstr "``oparg == 1``: *value* に :func:`str` を適用します" -#: ../../library/dis.rst:1721 msgid "``oparg == 2``: call :func:`repr` on *value*" -msgstr "" +msgstr "``oparg == 2``: *value* に :func:`repr` を適用します" -#: ../../library/dis.rst:1722 msgid "``oparg == 3``: call :func:`ascii` on *value*" -msgstr "" +msgstr "``oparg == 3``: *value* に :func:`ascii` を適用します" -#: ../../library/dis.rst:1724 ../../library/dis.rst:1737 -#: ../../library/dis.rst:1750 msgid "Used for implementing formatted string literals (f-strings)." -msgstr "" +msgstr "フォーマット済み文字列リテラル (f-string) の実装に使います。" -#: ../../library/dis.rst:1731 msgid "Formats the value on top of stack::" -msgstr "" +msgstr "スタックの先頭の値を書式化します。 ::" -#: ../../library/dis.rst:1733 msgid "" "value = STACK.pop()\n" "result = value.__format__(\"\")\n" "STACK.append(result)" msgstr "" +"value = STACK.pop()\n" +"result = value.__format__(\"\")\n" +"STACK.append(result)" -#: ../../library/dis.rst:1743 msgid "Formats the given value with the given format spec::" -msgstr "" +msgstr "指定された値を、指定された書式指定で書式化します。 ::" -#: ../../library/dis.rst:1745 msgid "" "spec = STACK.pop()\n" "value = STACK.pop()\n" "result = value.__format__(spec)\n" "STACK.append(result)" msgstr "" +"spec = STACK.pop()\n" +"value = STACK.pop()\n" +"result = value.__format__(spec)\n" +"STACK.append(result)" -#: ../../library/dis.rst:1757 msgid "" "``STACK[-1]`` is a tuple of keyword attribute names, ``STACK[-2]`` is the " "class being matched against, and ``STACK[-3]`` is the match subject. " "*count* is the number of positional sub-patterns." msgstr "" +"``STACK[-1]`` はキーワード属性名のタプル、``STACK[-2]`` は照合に使うクラス、" +"``STACK[-3]`` は照合対象です。\n" +"*count* は位置によるサブパターンの数です。" -#: ../../library/dis.rst:1761 msgid "" "Pop ``STACK[-1]``, ``STACK[-2]``, and ``STACK[-3]``. If ``STACK[-3]`` is an " "instance of ``STACK[-2]`` and has the positional and keyword attributes " "required by *count* and ``STACK[-1]``, push a tuple of extracted attributes. " "Otherwise, push ``None``." msgstr "" +"``STACK[-1]``、``STACK[-2]``、``STACK[-3]`` をポップします。\n" +"``STACK[-3]`` が ``STACK[-2]`` のインスタンスで、*count* と ``STACK[-1]`` が" +"要求する位置属性とキーワード属性を持っていれば、取り出した属性のタプルをプッ" +"シュします。\n" +"それ以外は ``None`` をプッシュします。" -#: ../../library/dis.rst:1775 msgid "A no-op. Performs internal tracing, debugging and optimization checks." msgstr "" +"何もしない命令です。\n" +"内部のトレース、デバッグ、最適化のためのチェックを行います。" -#: ../../library/dis.rst:1777 msgid "" "The ``context`` operand consists of two parts. The lowest two bits indicate " "where the ``RESUME`` occurs:" msgstr "" +"``context`` オペランドは 2 つの部分で構成されます。\n" +"下位 2 ビットは ``RESUME`` が現れる位置を示します:" -#: ../../library/dis.rst:1780 msgid "" "``0`` The start of a function, which is neither a generator, coroutine nor " "an async generator" msgstr "" +"``0`` ジェネレーター、コルーチン、非同期ジェネレーターのいずれでもない関数の" +"開始位置" -#: ../../library/dis.rst:1782 msgid "``1`` After a ``yield`` expression" -msgstr "" +msgstr "``1`` ``yield`` 式の後" -#: ../../library/dis.rst:1783 msgid "``2`` After a ``yield from`` expression" -msgstr "" +msgstr "``2`` ``yield from`` 式の後" -#: ../../library/dis.rst:1784 msgid "``3`` After an ``await`` expression" -msgstr "" +msgstr "``3`` ``await`` 式の後" -#: ../../library/dis.rst:1786 msgid "" "The next bit is ``1`` if the RESUME is at except-depth ``1``, and ``0`` " "otherwise." msgstr "" +"その次のビットは、RESUME の例外処理の深さが ``1`` なら ``1``、それ以外なら " +"``0`` です。" -#: ../../library/dis.rst:1791 msgid "The oparg value changed to include information about except-depth" -msgstr "" +msgstr "``oparg`` の値に例外処理の深さの情報を含めるようになりました。" -#: ../../library/dis.rst:1797 msgid "" "Create a generator, coroutine, or async generator from the current frame. " "Used as first opcode of in code object for the above mentioned callables. " "Clear the current frame and return the newly created generator." msgstr "" +"現在のフレームからジェネレーター、コルーチン、非同期ジェネレーターを作成しま" +"す。\n" +"これらの呼び出し可能オブジェクトのコードオブジェクトで、最初のオペコードとし" +"て使います。\n" +"現在のフレームをクリアし、新しく作ったジェネレーターを返します。" -#: ../../library/dis.rst:1806 msgid "" "Equivalent to ``STACK[-1] = STACK[-2].send(STACK[-1])``. Used in ``yield " "from`` and ``await`` statements." msgstr "" +"``STACK[-1] = STACK[-2].send(STACK[-1])`` と同じです。\n" +"``yield from`` と ``await`` 文で使います。" -#: ../../library/dis.rst:1809 msgid "" "If the call raises :exc:`StopIteration`, pop the top value from the stack, " "push the exception's ``value`` attribute, and increment the bytecode counter " "by *delta*." msgstr "" +"呼び出しが :exc:`StopIteration` を送出した場合、スタックの先頭の値をポップ" +"し、例外の ``value`` 属性をプッシュして、バイトコードカウンターを *delta* だ" +"け増やします。" -#: ../../library/dis.rst:1818 msgid "" "This is not really an opcode. It identifies the dividing line between " "opcodes in the range [0,255] which don't use their argument and those that " "do (``< HAVE_ARGUMENT`` and ``>= HAVE_ARGUMENT``, respectively)." msgstr "" +"これは実際にはオペコードではありません。\n" +"[0,255] の範囲のオペコードについて、引数を使わないもの (``< HAVE_ARGUMENT``) " +"と使うもの (``>= HAVE_ARGUMENT``) の境界を示します。" -#: ../../library/dis.rst:1822 msgid "" "If your application uses pseudo instructions or specialized instructions, " "use the :data:`hasarg` collection instead." msgstr "" +"アプリケーションで疑似命令や特殊化された命令を扱う場合は、代わりに :data:" +"`hasarg` コレクションを使ってください。" -#: ../../library/dis.rst:1825 msgid "" "Now every instruction has an argument, but opcodes ``< HAVE_ARGUMENT`` " "ignore it. Before, only opcodes ``>= HAVE_ARGUMENT`` had an argument." msgstr "" +"すべての命令が引数を持つようになりましたが、``< HAVE_ARGUMENT`` のオペコード" +"は引数を無視します。\n" +"以前は ``>= HAVE_ARGUMENT`` のオペコードだけが引数を持っていました。" -#: ../../library/dis.rst:1829 msgid "" "Pseudo instructions were added to the :mod:`!dis` module, and for them it is " "not true that comparison with ``HAVE_ARGUMENT`` indicates whether they use " "their arg." msgstr "" +":mod:`!dis` モジュールに疑似命令を追加しました。\n" +"疑似命令では、``HAVE_ARGUMENT`` との比較で引数を使うかどうかを判定することは" +"できません。" -#: ../../library/dis.rst:1834 msgid "Use :data:`hasarg` instead." -msgstr "" +msgstr "代わりに :data:`hasarg` を使ってください。" -#: ../../library/dis.rst:1839 msgid "" "Calls an intrinsic function with one argument. Passes ``STACK[-1]`` as the " "argument and sets ``STACK[-1]`` to the result. Used to implement " "functionality that is not performance critical." msgstr "" +"引数を 1 つ取る内部関数を呼び出します。\n" +"``STACK[-1]`` を引数として渡し、結果を ``STACK[-1]`` に設定します。\n" +"性能が重要ではない機能の実装に使います。" -#: ../../library/dis.rst:1843 ../../library/dis.rst:1897 msgid "The operand determines which intrinsic function is called:" -msgstr "" +msgstr "どの内部関数を呼び出すかはオペランドで決まります:" -#: ../../library/dis.rst:1846 ../../library/dis.rst:1900 msgid "Operand" -msgstr "" +msgstr "オペランド" #: ../../library/dis.rst:1846 ../../library/dis.rst:1900 msgid "Description" msgstr "説明" -#: ../../library/dis.rst:1848 msgid "``INTRINSIC_1_INVALID``" -msgstr "" +msgstr "``INTRINSIC_1_INVALID``" -#: ../../library/dis.rst:1848 ../../library/dis.rst:1902 msgid "Not valid" -msgstr "" +msgstr "無効" -#: ../../library/dis.rst:1850 msgid "``INTRINSIC_PRINT``" -msgstr "" +msgstr "``INTRINSIC_PRINT``" -#: ../../library/dis.rst:1850 msgid "Prints the argument to standard out. Used in the REPL." msgstr "" +"引数を標準出力に表示します。\n" +"REPL で使います。" -#: ../../library/dis.rst:1853 msgid "``INTRINSIC_IMPORT_STAR``" -msgstr "" +msgstr "``INTRINSIC_IMPORT_STAR``" -#: ../../library/dis.rst:1853 msgid "Performs ``import *`` for the named module." -msgstr "" +msgstr "指定された名前のモジュールに対して ``import *`` を実行します。" -#: ../../library/dis.rst:1856 msgid "``INTRINSIC_STOPITERATION_ERROR``" -msgstr "" +msgstr "``INTRINSIC_STOPITERATION_ERROR``" #: ../../library/dis.rst:1856 msgid "Extracts the return value from a ``StopIteration`` exception." msgstr "" -#: ../../library/dis.rst:1859 msgid "``INTRINSIC_ASYNC_GEN_WRAP``" -msgstr "" +msgstr "``INTRINSIC_ASYNC_GEN_WRAP``" -#: ../../library/dis.rst:1859 msgid "Wraps an async generator value" -msgstr "" +msgstr "非同期ジェネレーターの値をラップします" -#: ../../library/dis.rst:1861 msgid "``INTRINSIC_UNARY_POSITIVE``" -msgstr "" +msgstr "``INTRINSIC_UNARY_POSITIVE``" -#: ../../library/dis.rst:1861 msgid "Performs the unary ``+`` operation" -msgstr "" +msgstr "単項 ``+`` 演算を行います" -#: ../../library/dis.rst:1864 msgid "``INTRINSIC_LIST_TO_TUPLE``" -msgstr "" +msgstr "``INTRINSIC_LIST_TO_TUPLE``" -#: ../../library/dis.rst:1864 msgid "Converts a list to a tuple" -msgstr "" +msgstr "リストをタプルに変換します" -#: ../../library/dis.rst:1866 msgid "``INTRINSIC_TYPEVAR``" -msgstr "" +msgstr "``INTRINSIC_TYPEVAR``" -#: ../../library/dis.rst:1866 msgid "Creates a :class:`typing.TypeVar`" -msgstr "" +msgstr ":class:`typing.TypeVar` を作成します" -#: ../../library/dis.rst:1868 msgid "``INTRINSIC_PARAMSPEC``" -msgstr "" +msgstr "``INTRINSIC_PARAMSPEC``" -#: ../../library/dis.rst:1868 msgid "Creates a :class:`typing.ParamSpec`" -msgstr "" +msgstr ":class:`typing.ParamSpec` を作成します" -#: ../../library/dis.rst:1871 msgid "``INTRINSIC_TYPEVARTUPLE``" -msgstr "" +msgstr "``INTRINSIC_TYPEVARTUPLE``" -#: ../../library/dis.rst:1871 msgid "Creates a :class:`typing.TypeVarTuple`" -msgstr "" +msgstr ":class:`typing.TypeVarTuple` を作成します" -#: ../../library/dis.rst:1874 msgid "``INTRINSIC_SUBSCRIPT_GENERIC``" -msgstr "" +msgstr "``INTRINSIC_SUBSCRIPT_GENERIC``" -#: ../../library/dis.rst:1874 msgid "Returns :class:`typing.Generic` subscripted with the argument" -msgstr "" +msgstr "引数を添字とした :class:`typing.Generic` を返します" -#: ../../library/dis.rst:1877 msgid "``INTRINSIC_TYPEALIAS``" -msgstr "" +msgstr "``INTRINSIC_TYPEALIAS``" -#: ../../library/dis.rst:1877 msgid "" "Creates a :class:`typing.TypeAliasType`; used in the :keyword:`type` " "statement. The argument is a tuple of the type alias's name, type " "parameters, and value." msgstr "" +":class:`typing.TypeAliasType` を作成します。\n" +":keyword:`type` 文で使います。\n" +"引数は、型エイリアスの名前、型パラメーター、値のタプルです。" -#: ../../library/dis.rst:1889 msgid "" "Calls an intrinsic function with two arguments. Used to implement " "functionality that is not performance critical::" msgstr "" +"引数を 2 つ取る内部関数を呼び出します。\n" +"性能が重要ではない機能の実装に使います。 ::" -#: ../../library/dis.rst:1892 msgid "" "arg2 = STACK.pop()\n" "arg1 = STACK.pop()\n" "result = intrinsic2(arg1, arg2)\n" "STACK.append(result)" msgstr "" +"arg2 = STACK.pop()\n" +"arg1 = STACK.pop()\n" +"result = intrinsic2(arg1, arg2)\n" +"STACK.append(result)" -#: ../../library/dis.rst:1902 msgid "``INTRINSIC_2_INVALID``" -msgstr "" +msgstr "``INTRINSIC_2_INVALID``" -#: ../../library/dis.rst:1904 msgid "``INTRINSIC_PREP_RERAISE_STAR``" -msgstr "" +msgstr "``INTRINSIC_PREP_RERAISE_STAR``" -#: ../../library/dis.rst:1904 msgid "Calculates the :exc:`ExceptionGroup` to raise from a ``try-except*``." -msgstr "" +msgstr "``try-except*`` から送出する :exc:`ExceptionGroup` を計算します。" -#: ../../library/dis.rst:1908 msgid "``INTRINSIC_TYPEVAR_WITH_BOUND``" -msgstr "" +msgstr "``INTRINSIC_TYPEVAR_WITH_BOUND``" -#: ../../library/dis.rst:1908 msgid "Creates a :class:`typing.TypeVar` with a bound." -msgstr "" +msgstr "上限付きの :class:`typing.TypeVar` を作成します。" -#: ../../library/dis.rst:1911 msgid "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" -msgstr "" +msgstr "``INTRINSIC_TYPEVAR_WITH_CONSTRAINTS``" -#: ../../library/dis.rst:1911 msgid "Creates a :class:`typing.TypeVar` with constraints." -msgstr "" +msgstr "制約付きの :class:`typing.TypeVar` を作成します。" -#: ../../library/dis.rst:1915 msgid "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" -msgstr "" +msgstr "``INTRINSIC_SET_FUNCTION_TYPE_PARAMS``" -#: ../../library/dis.rst:1915 msgid "Sets the ``__type_params__`` attribute of a function." -msgstr "" +msgstr "関数の ``__type_params__`` 属性を設定します。" -#: ../../library/dis.rst:1924 msgid "" "Performs special method lookup on ``STACK[-1]``. If ``type(STACK[-1])." "__xxx__`` is a method, leave ``type(STACK[-1]).__xxx__; STACK[-1]`` on the " "stack. If ``type(STACK[-1]).__xxx__`` is not a method, leave ``STACK[-1]." "__xxx__; NULL`` on the stack." msgstr "" +"``STACK[-1]`` の特殊メソッドを検索します。\n" +"``type(STACK[-1]).__xxx__`` がメソッドなら、``type(STACK[-1]).__xxx__; " +"STACK[-1]`` をスタックに残します。\n" +"メソッドでなければ、``STACK[-1].__xxx__; NULL`` をスタックに残します。" -#: ../../library/dis.rst:1933 msgid "**Pseudo-instructions**" -msgstr "" +msgstr "**疑似命令**" -#: ../../library/dis.rst:1935 msgid "" "These opcodes do not appear in Python bytecode. They are used by the " "compiler but are replaced by real opcodes or removed before bytecode is " "generated." msgstr "" +"これらのオペコードは Python のバイトコードには現れません。\n" +"コンパイラが使用しますが、バイトコードを生成する前に実際のオペコードに置き換" +"えられるか、取り除かれます。" -#: ../../library/dis.rst:1940 msgid "" "Set up an exception handler for the following code block. If an exception " "occurs, the value stack level is restored to its current state and control " "is transferred to the exception handler at ``target``." msgstr "" +"後続のコードブロックの例外ハンドラーを設定します。\n" +"例外が発生すると、値スタックの深さを現在の状態に戻し、``target`` の例外ハンド" +"ラーに制御を移します。" -#: ../../library/dis.rst:1947 msgid "" "Like ``SETUP_FINALLY``, but in case of an exception also pushes the last " "instruction (``lasti``) to the stack so that ``RERAISE`` can restore it. If " @@ -2267,53 +2517,62 @@ msgid "" "frame are restored to their current state, and control is transferred to the " "exception handler at ``target``." msgstr "" +"``SETUP_FINALLY`` と同じですが、例外発生時に最後の命令 (``lasti``) もスタック" +"にプッシュし、``RERAISE`` で復元できるようにします。\n" +"例外が発生すると、値スタックの深さとフレーム内の最後の命令を現在の状態に戻" +"し、``target`` の例外ハンドラーに制御を移します。" -#: ../../library/dis.rst:1956 msgid "" "Like ``SETUP_CLEANUP``, but in case of an exception one more item is popped " "from the stack before control is transferred to the exception handler at " "``target``." msgstr "" +"``SETUP_CLEANUP`` と同じですが、例外発生時にスタックからさらに 1 要素をポップ" +"してから、``target`` の例外ハンドラーに制御を移します。" -#: ../../library/dis.rst:1960 msgid "" "This variant is used in :keyword:`with` and :keyword:`async with` " "constructs, which push the return value of the context manager's :meth:" "`~object.__enter__` or :meth:`~object.__aenter__` to the stack." msgstr "" +"この変種は :keyword:`with` と :keyword:`async with` で使います。\n" +"これらの構文は、コンテキストマネージャの :meth:`~object.__enter__` または :" +"meth:`~object.__aenter__` の返り値をスタックにプッシュします。" -#: ../../library/dis.rst:1967 msgid "" "Marks the end of the code block associated with the last ``SETUP_FINALLY``, " "``SETUP_CLEANUP`` or ``SETUP_WITH``." msgstr "" +"直前の ``SETUP_FINALLY``、``SETUP_CLEANUP``、``SETUP_WITH`` に対応するコード" +"ブロックの終わりを示します。" -#: ../../library/dis.rst:1974 msgid "" "Undirected relative jump instructions which are replaced by their directed " "(forward/backward) counterparts by the assembler." msgstr "" +"方向の指定のない相対ジャンプ命令です。\n" +"アセンブラーが、対応する方向 (前方/後方) の命令に置き換えます。" -#: ../../library/dis.rst:1980 msgid "" "Conditional jumps which do not impact the stack. Replaced by the sequence " "``COPY 1``, ``TO_BOOL``, ``POP_JUMP_IF_TRUE/FALSE``." msgstr "" +"スタックを変更しない条件付きジャンプです。\n" +"``COPY 1``、``TO_BOOL``、``POP_JUMP_IF_TRUE/FALSE`` の並びに置き換えます。" -#: ../../library/dis.rst:1985 msgid "" "Pushes a reference to the cell contained in slot ``i`` of the \"fast " "locals\" storage." msgstr "" +"\"fast locals\" 領域のスロット ``i`` にあるセルへの参照をスタックにプッシュし" +"ます。" -#: ../../library/dis.rst:1988 msgid "" "Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler." -msgstr "" +msgstr "``LOAD_CLOSURE`` はアセンブラーで ``LOAD_FAST`` に置き換えられます。" -#: ../../library/dis.rst:1990 msgid "This opcode is now a pseudo-instruction." -msgstr "" +msgstr "このオペコードは疑似命令になりました。" #: ../../library/dis.rst:1997 msgid "Opcode collections" @@ -2327,12 +2586,14 @@ msgstr "" "これらのコレクションは、自動でバイトコード命令を解析するために提供されていま" "す:" -#: ../../library/dis.rst:2002 msgid "" "The collections now contain pseudo instructions and instrumented " "instructions as well. These are opcodes with values ``>= MIN_PSEUDO_OPCODE`` " "and ``>= MIN_INSTRUMENTED_OPCODE``." msgstr "" +"これらのコレクションは、疑似命令と計測用命令も含むようになりました。\n" +"これらは、それぞれ ``>= MIN_PSEUDO_OPCODE`` と ``>= " +"MIN_INSTRUMENTED_OPCODE`` の値を持つオペコードです。" #: ../../library/dis.rst:2009 msgid "Sequence of operation names, indexable using the bytecode." @@ -2348,15 +2609,13 @@ msgstr "命令コード名をバイトコードに対応づける辞書。" msgid "Sequence of all compare operation names." msgstr "すべての比較命令の名前のリスト。" -#: ../../library/dis.rst:2024 msgid "Sequence of bytecodes that use their argument." -msgstr "" +msgstr "引数を使うバイトコードのシーケンス。" #: ../../library/dis.rst:2031 msgid "Sequence of bytecodes that access a constant." msgstr "定数にアクセスするバイトコードのリスト。" -#: ../../library/dis.rst:2036 msgid "" "Sequence of bytecodes that access a :term:`free (closure) variable `. 'free' in this context refers to names in the current scope that " @@ -2364,14 +2623,20 @@ msgid "" "from this scope. It does *not* include references to global or builtin " "scopes." msgstr "" +":term:`自由 (クロージャ) 変数 ` にアクセスするバイトコード" +"のシーケンス。\n" +"ここで「自由」とは、内側のスコープから参照される現在のスコープの名前、または" +"現在のスコープから参照される外側のスコープの名前を指します。\n" +"グローバルや組み込みのスコープへの参照は *含みません*。" #: ../../library/dis.rst:2044 msgid "Sequence of bytecodes that access an attribute by name." msgstr "名前によって属性にアクセスするバイトコードのリスト。" -#: ../../library/dis.rst:2049 msgid "Sequence of bytecodes that have a jump target. All jumps are relative." msgstr "" +"ジャンプ先を持つバイトコードのシーケンス。\n" +"ジャンプはすべて相対ジャンプです。" #: ../../library/dis.rst:2056 msgid "Sequence of bytecodes that access a local variable." @@ -2381,25 +2646,26 @@ msgstr "ローカル変数にアクセスするバイトコードのリスト。 msgid "Sequence of bytecodes of Boolean operations." msgstr "ブール命令のバイトコードのリスト。" -#: ../../library/dis.rst:2065 msgid "Sequence of bytecodes that set an exception handler." -msgstr "" +msgstr "例外ハンドラーを設定するバイトコードのシーケンス。" #: ../../library/dis.rst:2072 msgid "Sequence of bytecodes that have a relative jump target." msgstr "相対ジャンプ先を持つバイトコードのリスト。" -#: ../../library/dis.rst:2074 msgid "All jumps are now relative. Use :data:`hasjump`." msgstr "" +"すべてのジャンプが相対ジャンプになりました。\n" +":data:`hasjump` を使ってください。" #: ../../library/dis.rst:2080 msgid "Sequence of bytecodes that have an absolute jump target." msgstr "絶対ジャンプ先を持つバイトコードのリスト。" -#: ../../library/dis.rst:2082 msgid "All jumps are now relative. This list is empty." msgstr "" +"すべてのジャンプが相対ジャンプになりました。\n" +"このリストは空です。" #: ../../library/dis.rst:1686 msgid "built-in function" diff --git a/library/distribution.po b/library/distribution.po index 91bfe1341..606d09aa9 100644 --- a/library/distribution.po +++ b/library/distribution.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/distribution.rst:3 diff --git a/library/distutils.po b/library/distutils.po index 0a0932822..f61f86d25 100644 --- a/library/distutils.po +++ b/library/distutils.po @@ -12,26 +12,30 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:01+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/distutils.rst:2 msgid ":mod:`!distutils` --- Building and installing Python modules" -msgstr "" +msgstr ":mod:`!distutils` --- Python モジュールのビルドとインストール" -#: ../../library/distutils.rst:10 msgid "" "This module is no longer part of the Python standard library. It was :ref:" "`removed in Python 3.12 ` after being " "deprecated in Python 3.10. The removal was decided in :pep:`632`, which has " "`migration advice `_." msgstr "" +"このモジュールは Python 標準ライブラリから削除されました。\n" +"Python 3.10 で非推奨となった後、:ref:`Python 3.12 で削除されました " +"`。\n" +"削除は :pep:`632` で決定され、この PEP には `移行に関する助言 `_ も記載されています。" -#: ../../library/distutils.rst:16 msgid "" "The last version of Python that provided the :mod:`!distutils` module was " "`Python 3.11 `_." msgstr "" +":mod:`!distutils` モジュールを提供していた最後の Python バージョンは `Python " +"3.11 `_ です。" diff --git a/library/doctest.po b/library/doctest.po index 1cf235b74..7b6291543 100644 --- a/library/doctest.po +++ b/library/doctest.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/doctest.rst:2 @@ -31,12 +31,14 @@ msgstr ":mod:`!doctest` --- 対話型の Python の例をテストする" msgid "**Source code:** :source:`Lib/doctest.py`" msgstr "**ソースコード:** :source:`Lib/doctest.py`" -#: ../../library/doctest.rst:11 msgid "" "The :mod:`!doctest` module searches for pieces of text that look like " "interactive Python sessions, and then executes those sessions to verify that " "they work exactly as shown. There are several common ways to use doctest:" msgstr "" +":mod:`!doctest` モジュールは Python の対話セッションに見えるテキストを探し、" +"そのセッションを実行して記載どおりに動作するか検証します。\n" +"主な使い方は次のとおりです。" #: ../../library/doctest.rst:15 msgid "" @@ -70,7 +72,6 @@ msgstr "" msgid "Here's a complete but small example module::" msgstr "以下に完全かつ短い実行例を示します::" -#: ../../library/doctest.rst:28 msgid "" "\"\"\"\n" "This is the \"example\" module.\n" @@ -127,12 +128,69 @@ msgid "" " import doctest\n" " doctest.testmod()" msgstr "" +"\"\"\"\n" +"これは \"example\" モジュールです。\n" +"\n" +"example モジュールは factorial() という関数を一つ提供します。\n" +"例えば、\n" +"\n" +">>> factorial(5)\n" +"120\n" +"\"\"\"\n" +"\n" +"def factorial(n):\n" +" \"\"\"0 以上の整数 n の階乗を返します。\n" +"\n" +" >>> [factorial(n) for n in range(6)]\n" +" [1, 1, 2, 6, 24, 120]\n" +" >>> factorial(30)\n" +" 265252859812191058636308480000000\n" +" >>> factorial(-1)\n" +" Traceback (most recent call last):\n" +" ...\n" +" ValueError: n must be >= 0\n" +"\n" +" 浮動小数点数でも階乗を求められますが、その値は厳密に整数でなければなりま" +"せん:\n" +" >>> factorial(30.1)\n" +" Traceback (most recent call last):\n" +" ...\n" +" ValueError: n must be exact integer\n" +" >>> factorial(30.0)\n" +" 265252859812191058636308480000000\n" +"\n" +" また、極端に大きな値も使えません:\n" +" >>> factorial(1e100)\n" +" Traceback (most recent call last):\n" +" ...\n" +" OverflowError: n too large\n" +" \"\"\"\n" +"\n" +" import math\n" +" if not n >= 0:\n" +" raise ValueError(\"n must be >= 0\")\n" +" if math.floor(n) != n:\n" +" raise ValueError(\"n must be exact integer\")\n" +" if n+1 == n: # 1e300 のような値を検出\n" +" raise OverflowError(\"n too large\")\n" +" result = 1\n" +" factor = 2\n" +" while factor <= n:\n" +" result *= factor\n" +" factor += 1\n" +" return result\n" +"\n" +"\n" +"if __name__ == \"__main__\":\n" +" import doctest\n" +" doctest.testmod()" -#: ../../library/doctest.rst:83 msgid "" "If you run :file:`example.py` directly from the command line, :mod:`!" "doctest` works its magic:" msgstr "" +":file:`example.py` をコマンドラインから直接実行すると、:mod:`!doctest` が働き" +"ます。" #: ../../library/doctest.rst:86 msgid "" @@ -142,14 +200,16 @@ msgstr "" "$ python example.py\n" "$" -#: ../../library/doctest.rst:91 msgid "" "There's no output! That's normal, and it means all the examples worked. " "Pass ``-v`` to the script, and :mod:`!doctest` prints a detailed log of what " "it's trying, and prints a summary at the end:" msgstr "" +"何も出力されません!これは正常で、すべての実行例が動作したことを意味しま" +"す。\n" +"スクリプトに ``-v`` を渡すと、:mod:`!doctest` は試している内容の詳細なログを" +"出力し、最後に結果をまとめて表示します。" -#: ../../library/doctest.rst:95 msgid "" "$ python example.py -v\n" "Trying:\n" @@ -163,12 +223,22 @@ msgid "" " [1, 1, 2, 6, 24, 120]\n" "ok" msgstr "" +"$ python example.py -v\n" +"Trying:\n" +" factorial(5)\n" +"Expecting:\n" +" 120\n" +"ok\n" +"Trying:\n" +" [factorial(n) for n in range(6)]\n" +"Expecting:\n" +" [1, 1, 2, 6, 24, 120]\n" +"ok" #: ../../library/doctest.rst:109 msgid "And so on, eventually ending with:" msgstr "といった具合で、最後には:" -#: ../../library/doctest.rst:111 msgid "" "Trying:\n" " factorial(1e100)\n" @@ -185,8 +255,21 @@ msgid "" "Test passed.\n" "$" msgstr "" +"Trying:\n" +" factorial(1e100)\n" +"Expecting:\n" +" Traceback (most recent call last):\n" +" ...\n" +" OverflowError: n too large\n" +"ok\n" +"2 items passed all tests:\n" +" 1 test in __main__\n" +" 6 tests in __main__.factorial\n" +"7 tests in 2 items.\n" +"7 passed.\n" +"Test passed.\n" +"$" -#: ../../library/doctest.rst:128 msgid "" "That's all you need to know to start making productive use of :mod:`!" "doctest`! Jump in. The following sections provide full details. Note that " @@ -194,12 +277,19 @@ msgid "" "libraries. Especially useful examples can be found in the standard test " "file :file:`Lib/test/test_doctest/test_doctest.py`." msgstr "" +":mod:`!doctest` を役立てるには、これだけ知っていれば十分です!さっそく使って" +"みましょう。\n" +"以下の節では詳細を説明します。\n" +"Python 標準のテストスイートやライブラリには、doctest の例が数多くあります。\n" +"特に参考になる例は、標準のテストファイル :file:`Lib/test/test_doctest/" +"test_doctest.py` にあります。" -#: ../../library/doctest.rst:134 msgid "" "Output is colorized by default and can be :ref:`controlled using environment " "variables `." msgstr "" +"出力はデフォルトで色付きになり、:ref:`環境変数で制御できます `。" #: ../../library/doctest.rst:142 msgid "Simple Usage: Checking Examples in Docstrings" @@ -213,12 +303,14 @@ msgstr "" "doctest を試す簡単な方法 (とはいえ、いつもそうする必要はないのですが) は、各" "モジュール :mod:`!M` の最後を、以下のようにして締めくくることです::" -#: ../../library/doctest.rst:147 msgid "" "if __name__ == \"__main__\":\n" " import doctest\n" " doctest.testmod()" msgstr "" +"if __name__ == \"__main__\":\n" +" import doctest\n" +" doctest.testmod()" #: ../../library/doctest.rst:151 msgid ":mod:`!doctest` then examines docstrings in module :mod:`!M`." @@ -277,11 +369,12 @@ msgstr "" "func:`testmod` は :data:`sys.argv` 上のスイッチを調べません。(したがって、 " "``-v`` をつけても効果はありません)。" -#: ../../library/doctest.rst:175 msgid "" "There is also a command line shortcut for running :func:`testmod`, see " "section :ref:`doctest-cli`." msgstr "" +":func:`testmod` をコマンドラインから簡単に実行する方法もあります。\n" +":ref:`doctest-cli` 節を参照してください。" #: ../../library/doctest.rst:178 msgid "" @@ -324,7 +417,6 @@ msgstr "" "ラムである必要はありません!例えば、 :file:`example.txt` には以下のような内容" "が入っているとします:" -#: ../../library/doctest.rst:197 msgid "" "The ``example`` module\n" "======================\n" @@ -342,6 +434,21 @@ msgid "" " >>> factorial(6)\n" " 120" msgstr "" +"``example`` モジュール\n" +"=====================\n" +"\n" +"``factorial`` の使い方\n" +"---------------------\n" +"\n" +"これは reStructuredText 形式のテキストファイルの例です。\n" +"まず ``example`` モジュールから ``factorial`` をインポートします:\n" +"\n" +" >>> from example import factorial\n" +"\n" +"次に、使ってみましょう:\n" +"\n" +" >>> factorial(6)\n" +" 120" #: ../../library/doctest.rst:215 msgid "" @@ -351,7 +458,6 @@ msgstr "" "``doctest.testfile(\"example.txt\")`` を実行すると、このドキュメント内のエ" "ラーを見つけ出します::" -#: ../../library/doctest.rst:218 msgid "" "File \"./example.txt\", line 14, in example.txt\n" "Failed example:\n" @@ -361,6 +467,13 @@ msgid "" "Got:\n" " 720" msgstr "" +"File \"./example.txt\", line 14, in example.txt\n" +"Failed example:\n" +" factorial(6)\n" +"Expected:\n" +" 120\n" +"Got:\n" +" 720" #: ../../library/doctest.rst:226 msgid "" @@ -381,8 +494,8 @@ msgid "" "locations." msgstr "" "デフォルトでは、 :func:`testfile` は自分自身を呼び出したモジュールのあるディ" -"レクトリを探します。その他の場所にあるファイルを見に行くように :func:" -"`testfile` に指示するためのオプション引数についての説明は :ref:`doctest-" +"レクトリを探します。その他の場所にあるファイルを見に行くように " +"``testfile()`` に指示するためのオプション引数についての説明は :ref:`doctest-" "basic-api` 節を参照してください。" #: ../../library/doctest.rst:235 @@ -394,11 +507,12 @@ msgstr "" "ンスイッチ ``-v`` またはオプションのキーワード引数 *verbose* によって指定でき" "ます。" -#: ../../library/doctest.rst:239 msgid "" "There is also a command line shortcut for running :func:`testfile`, see " "section :ref:`doctest-cli`." msgstr "" +":func:`testfile` をコマンドラインから簡単に実行する方法もあります。\n" +":ref:`doctest-cli` 節を参照してください。" #: ../../library/doctest.rst:242 msgid "" @@ -411,20 +525,21 @@ msgstr "" msgid "Command-line Usage" msgstr "コマンドラインでの使用" -#: ../../library/doctest.rst:250 msgid "" "The :mod:`!doctest` module can be invoked as a script from the command line:" msgstr "" +":mod:`!doctest` モジュールはコマンドラインからスクリプトとして実行できます。" #: ../../library/doctest.rst:252 msgid "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" msgstr "python -m doctest [-v] [-o OPTION] [-f] file [file ...]" -#: ../../library/doctest.rst:260 msgid "" "Detailed report of all examples tried is printed to standard output, along " "with assorted summaries at the end::" msgstr "" +"試したすべての実行例の詳細な報告を標準出力に表示し、最後に各種の結果をまとめ" +"ます。 ::" #: ../../library/doctest.rst:263 msgid "python -m doctest -v example.py" @@ -441,25 +556,26 @@ msgstr "" "ジュールをそのパッケージからインポートしている場合はうまく動かないことに注意" "してください。" -#: ../../library/doctest.rst:269 msgid "" "If the file name does not end with :file:`.py`, :mod:`!doctest` infers that " "it must be run with :func:`testfile` instead::" msgstr "" +"ファイル名が :file:`.py` で終わっていない場合、:mod:`!doctest` は代わりに :" +"func:`testfile` で実行すべきだと判断します。 ::" #: ../../library/doctest.rst:272 msgid "python -m doctest -v example.txt" msgstr "python -m doctest -v example.txt" -#: ../../library/doctest.rst:276 msgid "" "Option flags control various aspects of doctest's behavior, see section :ref:" "`doctest-options`." msgstr "" +"オプションフラグで doctest のさまざまな動作を制御できます。\n" +":ref:`doctest-options` 節を参照してください。" -#: ../../library/doctest.rst:283 msgid "This is shorthand for ``-o FAIL_FAST``." -msgstr "" +msgstr "``-o FAIL_FAST`` の短縮形です。" #: ../../library/doctest.rst:291 msgid "How It Works" @@ -493,7 +609,6 @@ msgstr "" "モジュールの docstring と、すべての関数、クラスおよびメソッドの docstring が" "検索されます。モジュールに import されたオブジェクトは検索されません。" -#: ../../library/doctest.rst:316 msgid "" "In addition, there are cases when you want tests to be part of a module but " "not part of the help text, which requires that the tests not be included in " @@ -505,12 +620,21 @@ msgid "" "docstrings. In output, a key ``K`` in ``M.__test__`` appears with name ``M." "__test__.K``." msgstr "" +"テストをモジュールに含めつつ、ヘルプテキストには表示したくない場合もありま" +"す。\n" +"その場合、テストを docstring に含めることはできません。\n" +"Doctest はモジュールレベルの変数 ``__test__`` を探し、それを使って他のテスト" +"を見つけます。\n" +"``M.__test__`` が存在する場合、その値は辞書でなければならず、各項目は名前 (文" +"字列) を関数オブジェクト、クラスオブジェクト、または文字列に対応付けます。\n" +"``M.__test__`` から見つかった関数やクラスの docstring が検索され、文字列は " +"docstring として扱われます。\n" +"出力では、``M.__test__`` のキー ``K`` は ``M.__test__.K`` という名前で表示さ" +"れます。" -#: ../../library/doctest.rst:325 msgid "For example, place this block of code at the top of :file:`example.py`:" -msgstr "" +msgstr "例えば、次のコードブロックを :file:`example.py` の先頭に置きます。" -#: ../../library/doctest.rst:327 msgid "" "__test__ = {\n" " 'numbers': \"\"\"\n" @@ -522,8 +646,16 @@ msgid "" "\"\"\"\n" "}" msgstr "" +"__test__ = {\n" +" 'numbers': \"\"\"\n" +">>> factorial(6)\n" +"720\n" +"\n" +">>> [factorial(n) for n in range(6)]\n" +"[1, 1, 2, 6, 24, 120]\n" +"\"\"\"\n" +"}" -#: ../../library/doctest.rst:339 msgid "" "The value of ``example.__test__[\"numbers\"]`` will be treated as a " "docstring and all the tests inside it will be run. It is important to note " @@ -531,6 +663,11 @@ msgid "" "mod:`!doctest` searches them recursively for docstrings, which are then " "scanned for tests." msgstr "" +"``example.__test__[\"numbers\"]`` の値は docstring として扱われ、その中のテス" +"トがすべて実行されます。\n" +"辞書の値には関数、クラスオブジェクト、モジュールを指定することもできます。\n" +"その場合、:mod:`!doctest` はそれらから docstring を再帰的に探し、見つかった " +"docstring からテストを検索します。" #: ../../library/doctest.rst:345 msgid "" @@ -540,17 +677,20 @@ msgstr "" "検索中に見つかったクラスも同様に再帰的に検索が行われ、クラスに含まれているメ" "ソッドおよびネストされたクラスについて docstring のテストが行われます。" -#: ../../library/doctest.rst:350 msgid "" "``doctest`` can only automatically discover classes and functions that are " "defined at the module level or inside other classes." msgstr "" +"``doctest`` が自動的に見つけられるのは、モジュールレベルまたは他のクラス内で" +"定義されたクラスと関数だけです。" -#: ../../library/doctest.rst:353 msgid "" "Since nested classes and functions only exist when an outer function is " "called, they cannot be discovered. Define them outside to make them visible." msgstr "" +"関数内にネストされたクラスや関数は、外側の関数が呼ばれたときにしか存在しない" +"ため、見つけることができません。\n" +"見つけられるようにするには、関数の外で定義してください。" #: ../../library/doctest.rst:359 msgid "How are Docstring Examples Recognized?" @@ -563,10 +703,9 @@ msgid "" "shell." msgstr "" "ほとんどの場合、対話コンソールセッション上でのコピー/ペーストはうまく動作し" -"ます。とはいえ、:mod:`doctest` は特定の Python シェルの振る舞いを正確にエミュ" +"ます。とはいえ、 ``doctest`` は特定の Python シェルの振る舞いを正確にエミュ" "レーションしようとするわけではありません。" -#: ../../library/doctest.rst:366 msgid "" ">>> # comments are ignored\n" ">>> x = 12\n" @@ -584,6 +723,21 @@ msgid "" "NO!!!\n" ">>>" msgstr "" +">>> # コメントは無視されます\n" +">>> x = 12\n" +">>> x\n" +"12\n" +">>> if x == 13:\n" +"... print(\"yes\")\n" +"... else:\n" +"... print(\"no\")\n" +"... print(\"NO\")\n" +"... print(\"NO!!!\")\n" +"...\n" +"no\n" +"NO\n" +"NO!!!\n" +">>>" #: ../../library/doctest.rst:386 msgid "" @@ -654,7 +808,6 @@ msgstr "" "の理由でバックスラッシュを用いる場合、raw docstring を使ってバックスラッシュ" "を入力どおりに扱わせるようにしなければなりません::" -#: ../../library/doctest.rst:416 msgid "" ">>> def f(x):\n" "... r'''Backslashes in a raw docstring: m\\n'''\n" @@ -662,6 +815,11 @@ msgid "" ">>> print(f.__doc__)\n" "Backslashes in a raw docstring: m\\n" msgstr "" +">>> def f(x):\n" +"... r'''Backslashes in a raw docstring: m\\n'''\n" +"...\n" +">>> print(f.__doc__)\n" +"Backslashes in a raw docstring: m\\n" #: ../../library/doctest.rst:422 msgid "" @@ -675,7 +833,6 @@ msgstr "" "doctest にあるバックスラッシュを二重にする (そして raw string を使わない) と" "いう方法もあります::" -#: ../../library/doctest.rst:426 msgid "" ">>> def f(x):\n" "... '''Backslashes in a raw docstring: m\\\\n'''\n" @@ -683,18 +840,26 @@ msgid "" ">>> print(f.__doc__)\n" "Backslashes in a raw docstring: m\\n" msgstr "" +">>> def f(x):\n" +"... '''Backslashes in a raw docstring: m\\\\n'''\n" +"...\n" +">>> print(f.__doc__)\n" +"Backslashes in a raw docstring: m\\n" #: ../../library/doctest.rst:432 msgid "The starting column doesn't matter::" msgstr "開始カラムはどこでもかまいません::" -#: ../../library/doctest.rst:434 msgid "" ">>> assert \"Easy!\"\n" " >>> import math\n" " >>> math.floor(1.9)\n" " 1" msgstr "" +">>> assert \"Easy!\"\n" +" >>> import math\n" +" >>> math.floor(1.9)\n" +" 1" #: ../../library/doctest.rst:439 msgid "" @@ -708,7 +873,6 @@ msgstr "" msgid "What's the Execution Context?" msgstr "実行コンテキストとは何か?" -#: ../../library/doctest.rst:448 msgid "" "By default, each time :mod:`!doctest` finds a docstring to test, it uses a " "*shallow copy* of :mod:`!M`'s globals, so that running tests doesn't change " @@ -718,6 +882,14 @@ msgid "" "names defined earlier in the docstring being run. Examples cannot see names " "defined in other docstrings." msgstr "" +"デフォルトでは、:mod:`!doctest` はテストする docstring を見つけるたびに :mod:" +"`!M` のグローバル変数の *浅いコピー* を使います。\n" +"これにより、テストの実行でモジュールの実際のグローバル変数が変更されるのを防" +"ぐとともに、:mod:`!M` のあるテストが残した状態によって別のテストが偶然成功す" +"るのを防ぎます。\n" +"したがって、実行例では :mod:`!M` のトップレベルで定義された名前や、実行中の " +"docstring 内でそれ以前に定義された名前を自由に使えます。\n" +"他の docstring 内で定義された名前は参照できません。" #: ../../library/doctest.rst:456 msgid "" @@ -748,13 +920,16 @@ msgstr "" msgid "Simple example::" msgstr "簡単な例を示しましょう::" -#: ../../library/doctest.rst:473 msgid "" ">>> [1, 2, 3].remove(42)\n" "Traceback (most recent call last):\n" " File \"\", line 1, in \n" "ValueError: list.remove(x): x not in list" msgstr "" +">>> [1, 2, 3].remove(42)\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: list.remove(x): x not in list" #: ../../library/doctest.rst:478 msgid "" @@ -774,11 +949,12 @@ msgstr "" "なりません。トレースバックの形式は以下の二通りの行のいずれかで、実行例の最初" "の行と同じインデントでなければりません::" -#: ../../library/doctest.rst:485 msgid "" "Traceback (most recent call last):\n" "Traceback (innermost last):" msgstr "" +"Traceback (most recent call last):\n" +"Traceback (innermost last):" #: ../../library/doctest.rst:488 msgid "" @@ -801,7 +977,6 @@ msgstr "" "入った行があります。これは通常トレースバックの最後の行ですが、例外が複数行の" "詳細情報を持っている場合、複数の行にわたることもあります::" -#: ../../library/doctest.rst:497 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -810,6 +985,12 @@ msgid "" " line\n" "detail" msgstr "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" File \"\", line 1, in \n" +"ValueError: multi\n" +" line\n" +"detail" #: ../../library/doctest.rst:504 msgid "" @@ -829,7 +1010,6 @@ msgstr "" "ない限り、トレースバックスタックは省略する、ということです。したがって、先ほ" "どの例は以下のように書くべきでしょう::" -#: ../../library/doctest.rst:510 msgid "" ">>> raise ValueError('multi\\n line\\ndetail')\n" "Traceback (most recent call last):\n" @@ -838,8 +1018,13 @@ msgid "" " line\n" "detail" msgstr "" +">>> raise ValueError('multi\\n line\\ndetail')\n" +"Traceback (most recent call last):\n" +" ...\n" +"ValueError: multi\n" +" line\n" +"detail" -#: ../../library/doctest.rst:517 msgid "" "Note that tracebacks are treated very specially. In particular, in the " "rewritten example, the use of ``...`` is independent of doctest's :const:" @@ -847,11 +1032,12 @@ msgid "" "just as well be three (or three hundred) commas or digits, or an indented " "transcript of a Monty Python skit." msgstr "" -"トレースバックの扱いは非常に特殊なので注意してください。特に、上の書き直した" -"実行例では、 ``...`` の扱いは doctest の :const:`ELLIPSIS` オプションとは独立" -"しています。この例での省略記号は何かの省略を表しているかもしれませんし、コン" -"マや数字が 3 個 (または 300 個) かもしれませんし、 Monty Python のスキットを" -"インデントして書き写したものかもしれません。" +"トレースバックは特別な方法で扱われる点に注意してください。\n" +"特に、上の書き直した実行例での ``...`` の使用は doctest の :const:`ELLIPSIS` " +"オプションとは無関係です。\n" +"この例の省略記号は省いてもかまいませんし、代わりにコンマや数字を 3 個 (また" +"は 300 個) 並べたり、Monty Python の寸劇をインデントして書き写したりしてもか" +"まいません。" #: ../../library/doctest.rst:523 msgid "Some details you should read once, but won't need to remember:" @@ -911,13 +1097,13 @@ msgstr "" "な :exc:`!SyntaxError` をテストする必要があるというごく稀なケースでは、実行例" "にトレースバックヘッダを手作業で追加する必要があるでしょう。" -#: ../../library/doctest.rst:550 msgid "" "For some exceptions, Python displays the position of the error using ``^`` " "markers and tildes::" msgstr "" +"一部の例外では、Python は ``^`` マーカとチルダを使ってエラーの位置を示しま" +"す。 ::" -#: ../../library/doctest.rst:553 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -925,6 +1111,11 @@ msgid "" " ~~^~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" msgstr "" +">>> 1 + None\n" +" File \"\", line 1\n" +" 1 + None\n" +" ~~^~~~~~\n" +"TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" #: ../../library/doctest.rst:559 msgid "" @@ -937,7 +1128,6 @@ msgstr "" "ません。例えば、以下の例では、間違った場所に ``^`` マーカを入れても成功してし" "まいます::" -#: ../../library/doctest.rst:563 msgid "" ">>> 1 + None\n" " File \"\", line 1\n" @@ -945,6 +1135,11 @@ msgid "" " ^~~~~~~~\n" "TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" msgstr "" +">>> 1 + None\n" +" File \"\", line 1\n" +" 1 + None\n" +" ^~~~~~~~\n" +"TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'" #: ../../library/doctest.rst:574 msgid "Option Flags" @@ -1039,14 +1234,15 @@ msgstr "" "ように \"しまった、マッチしすぎた! (match too much!)\" と驚くことになりかね" "ません。" -#: ../../library/doctest.rst:629 msgid "" "When specified, doctests expecting exceptions pass so long as an exception " "of the expected type is raised, even if the details (message and fully " "qualified exception name) don't match." msgstr "" +"このフラグを指定すると、例外を期待する doctest は、期待した型の例外が送出され" +"れば成功します。\n" +"詳細 (メッセージと例外の完全修飾名) が一致していなくてもかまいません。" -#: ../../library/doctest.rst:633 msgid "" "For example, an example expecting ``ValueError: 42`` will pass if the actual " "exception raised is ``ValueError: 3*14``, but will fail if, say, a :exc:" @@ -1055,8 +1251,14 @@ msgid "" "and versions of Python and the code/libraries in use. Hence, all three of " "these variations will work with the flag specified:" msgstr "" +"例えば、``ValueError: 42`` を期待する実行例は、実際に送出された例外が " +"``ValueError: 3*14`` でも成功しますが、代わりに :exc:`TypeError` などが送出さ" +"れると失敗します。\n" +"例外クラスの前に付いた完全修飾名も無視します。\n" +"この部分は Python の実装やバージョン、使用するコードやライブラリによって異な" +"ることがあります。\n" +"したがって、このフラグを指定すると、次の 3 通りはいずれも成功します。" -#: ../../library/doctest.rst:641 msgid "" ">>> raise Exception('message')\n" "Traceback (most recent call last):\n" @@ -1070,21 +1272,34 @@ msgid "" "Traceback (most recent call last):\n" "__main__.Exception: message" msgstr "" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"Exception: message\n" +"\n" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"builtins.Exception: message\n" +"\n" +">>> raise Exception('message')\n" +"Traceback (most recent call last):\n" +"__main__.Exception: message" -#: ../../library/doctest.rst:655 msgid "" "Note that :const:`ELLIPSIS` can also be used to ignore the details of the " "exception message, but such a test may still fail based on whether the " "module name is present or matches exactly." msgstr "" +":const:`ELLIPSIS` を使って例外メッセージの詳細を無視することもできますが、そ" +"の場合はモジュール名の有無や完全一致するかどうかによってテストが失敗する可能" +"性があります。" #: ../../library/doctest.rst:659 msgid "" ":const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating " "to the module containing the exception under test." msgstr "" -":mod:`doctest` モジュールの :const:`IGNORE_EXCEPTION_DETAIL` フラグが、 テス" -"トされている例外を含むモジュールの名前を無視するようになりました。" +"``doctest`` モジュールの :const:`IGNORE_EXCEPTION_DETAIL` フラグが、 テストさ" +"れている例外を含むモジュールの名前を無視するようになりました。" #: ../../library/doctest.rst:666 msgid "" @@ -1180,11 +1395,12 @@ msgstr "" msgid "A bitmask or'ing together all the reporting flags above." msgstr "上記のエラー報告に関するフラグすべての論理和をとったビットマスクです。" -#: ../../library/doctest.rst:727 msgid "" "There is also a way to register new option flag names, though this isn't " "useful unless you intend to extend :mod:`!doctest` internals via subclassing:" msgstr "" +"新しいオプションフラグ名を登録する方法もありますが、サブクラス化によって :" +"mod:`!doctest` の内部機能を拡張する場合以外には役立ちません。" #: ../../library/doctest.rst:733 msgid "" @@ -1200,23 +1416,22 @@ msgstr "" "トさせる際に使います。 :func:`register_optionflag` は以下のような定形文で呼び" "出さなければなりません::" -#: ../../library/doctest.rst:739 msgid "MY_FLAG = register_optionflag('MY_FLAG')" -msgstr "" +msgstr "MY_FLAG = register_optionflag('MY_FLAG')" #: ../../library/doctest.rst:749 msgid "Directives" msgstr "ディレクティブ (Directives)" -#: ../../library/doctest.rst:751 msgid "" "Doctest directives may be used to modify the :ref:`option flags ` for an individual example. Doctest directives are special Python " "comments following an example's source code:" msgstr "" -"doctest ディレクティブは個々の実行例の :ref:`オプションフラグ ` を操作するために使われます。 doctest ディレクティブは後のソースコー" -"ド例にあるような特殊な Python コメントです:" +"doctest ディレクティブを使うと、個々の実行例の :ref:`オプションフラグ " +"` を変更できます。\n" +"doctest ディレクティブは、実行例のソースコードの後ろに置く特殊な Python コメ" +"ントです:" #: ../../library/doctest.rst:762 msgid "" @@ -1240,29 +1455,31 @@ msgstr "" msgid "For example, this test passes:" msgstr "例えば、以下のテストは成功します:" -#: ../../library/doctest.rst:771 msgid "" ">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" "10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" msgstr "" +">>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n" +"10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" -#: ../../library/doctest.rst:778 msgid "" "Without the directive it would fail, both because the actual output doesn't " "have two blanks before the single-digit list elements, and because the " "actual output is on a single line. This test also passes, and also requires " "a directive to do so:" msgstr "" -"ディレクティブがない場合、実際の出力には一桁の数字の間に二つスペースが入って" -"いないこと、実際の出力は 1 行になることから、テストは成功しないはずです。別の" -"ディレクティブを使って、このテストを成功させることもできます:" +"ディレクティブがない場合、実際の出力では 1 桁のリスト要素の前に空白が 2 つ入" +"らず、出力全体が 1 行になるため、テストは失敗します。\n" +"次のテストも成功しますが、やはりディレクティブが必要です。" -#: ../../library/doctest.rst:783 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "[0, 1, ..., 18, 19]" msgstr "" +">>> print(list(range(20))) # doctest: +ELLIPSIS\n" +"[0, 1, ..., 18, 19]" #: ../../library/doctest.rst:789 msgid "" @@ -1271,11 +1488,12 @@ msgid "" msgstr "" "複数のディレクティブは、一つの物理行の中にコンマで区切って指定できます:" -#: ../../library/doctest.rst:792 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" msgstr "" +">>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n" +"[0, 1, ..., 18, 19]" #: ../../library/doctest.rst:798 msgid "" @@ -1285,12 +1503,14 @@ msgstr "" "一つの実行例中で複数のディレクティブコメントを使った場合、それらは組み合わさ" "れます:" -#: ../../library/doctest.rst:801 msgid "" ">>> print(list(range(20))) # doctest: +ELLIPSIS\n" "... # doctest: +NORMALIZE_WHITESPACE\n" "[0, 1, ..., 18, 19]" msgstr "" +">>> print(list(range(20))) # doctest: +ELLIPSIS\n" +"... # doctest: +NORMALIZE_WHITESPACE\n" +"[0, 1, ..., 18, 19]" #: ../../library/doctest.rst:808 msgid "" @@ -1302,12 +1522,14 @@ msgstr "" "することができます。この書きかたは、実行例が長すぎるためにディレクティブを同" "じ行に入れると収まりが悪い場合に便利です:" -#: ../../library/doctest.rst:812 msgid "" ">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" "... # doctest: +ELLIPSIS\n" "[0, ..., 4, 10, ..., 19, 30, ..., 39]" msgstr "" +">>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))\n" +"... # doctest: +ELLIPSIS\n" +"[0, ..., 4, 10, ..., 19, 30, ..., 39]" #: ../../library/doctest.rst:819 msgid "" @@ -1328,7 +1550,6 @@ msgstr "" msgid "Warnings" msgstr "警告" -#: ../../library/doctest.rst:831 msgid "" ":mod:`!doctest` is serious about requiring exact matches in expected " "output. If even a single character doesn't match, the test fails. This " @@ -1337,33 +1558,43 @@ msgid "" "Python doesn't guarantee that the element is printed in any particular " "order, so a test like ::" msgstr "" +":mod:`!doctest` は期待する出力との厳密な一致を求めます。\n" +"1 文字でも一致しなければテストは失敗します。\n" +"Python が出力について何を保証し、何を保証しないのかを知るにつれて、意外に思う" +"こともあるでしょう。\n" +"例えば、集合を表示するときに要素が特定の順序で表示されることは保証されていな" +"いため、次のようなテストは ::" -#: ../../library/doctest.rst:837 msgid "" ">>> foo()\n" "{\"spam\", \"eggs\"}" msgstr "" +">>> foo()\n" +"{\"spam\", \"eggs\"}" #: ../../library/doctest.rst:840 msgid "is vulnerable! One workaround is to do ::" msgstr "は失敗するかもしれないのです! 回避するには ::" -#: ../../library/doctest.rst:842 msgid "" ">>> foo() == {\"spam\", \"eggs\"}\n" "True" msgstr "" +">>> foo() == {\"spam\", \"eggs\"}\n" +"True" #: ../../library/doctest.rst:845 msgid "instead. Another is to do ::" msgstr "とするのが一つのやり方です。別のやり方は ::" -#: ../../library/doctest.rst:847 msgid "" ">>> d = sorted(foo())\n" ">>> d\n" "['eggs', 'spam']" msgstr "" +">>> d = sorted(foo())\n" +">>> d\n" +"['eggs', 'spam']" #: ../../library/doctest.rst:851 msgid "There are others, but you get the idea." @@ -1375,7 +1606,6 @@ msgstr "" "以下のように、オブジェクトアドレスを埋め込むような結果を print するのもよくあ" "りません :" -#: ../../library/doctest.rst:855 msgid "" ">>> id(1.0) # certain to fail some of the time\n" "7948648\n" @@ -1383,6 +1613,11 @@ msgid "" ">>> C() # the default repr() for instances embeds an address\n" "" msgstr "" +">>> id(1.0) # いつか必ず失敗します\n" +"7948648\n" +">>> class C: pass\n" +">>> C() # インスタンスのデフォルトの repr() にはアドレスが含まれます\n" +"" #: ../../library/doctest.rst:863 msgid "" @@ -1390,20 +1625,23 @@ msgid "" msgstr "" ":const:`ELLIPSIS` ディレクティブを使うと、上のような例をうまく解決できます:" -#: ../../library/doctest.rst:865 msgid "" ">>> C() # doctest: +ELLIPSIS\n" "" msgstr "" +">>> C() # doctest: +ELLIPSIS\n" +"" -#: ../../library/doctest.rst:871 msgid "" "Floating-point numbers are also subject to small output variations across " "platforms, because Python defers to the platform C library for some floating-" "point calculations, and C libraries vary widely in quality here. ::" msgstr "" +"浮動小数点数も、プラットフォームによって出力がわずかに変わることがありま" +"す。\n" +"Python は一部の浮動小数点演算をプラットフォームの C ライブラリに任せており、" +"その品質には大きな違いがあるためです。 ::" -#: ../../library/doctest.rst:875 msgid "" ">>> 1000**0.1 # risky\n" "1.9952623149688797\n" @@ -1412,6 +1650,12 @@ msgid "" ">>> print(f'{1000**0.1:.4f}') # much safer\n" "1.9953" msgstr "" +">>> 1000**0.1 # 危険\n" +"1.9952623149688797\n" +">>> round(1000**0.1, 9) # より安全\n" +"1.995262315\n" +">>> print(f'{1000**0.1:.4f}') # さらに安全\n" +"1.9953" #: ../../library/doctest.rst:882 msgid "" @@ -1421,11 +1665,12 @@ msgstr "" "``I/2.**J`` の形式になる数値はどのプラットフォームでもうまく動作するので、私" "はこの形式の数値を生成するように doctest の実行例を工夫しています::" -#: ../../library/doctest.rst:885 msgid "" ">>> 3./4 # utterly safe\n" "0.75" msgstr "" +">>> 3./4 # 完全に安全\n" +"0.75" #: ../../library/doctest.rst:888 msgid "" @@ -1439,17 +1684,16 @@ msgstr "" msgid "Basic API" msgstr "基本 API" -#: ../../library/doctest.rst:897 msgid "" "The functions :func:`testmod` and :func:`testfile` provide a simple " "interface to doctest that should be sufficient for most basic uses. For a " "less formal introduction to these two functions, see sections :ref:`doctest-" "simple-testmod` and :ref:`doctest-simple-testfile`." msgstr "" -"数 :func:`testmod` と :func:`testfile` は、ほとんどの基本的な用途に十分な " -"doctest インターフェースを提供しています。これら二つの関数についてあまり形式" -"的でない入門が読みたければ、 :ref:`doctest-simple-testmod` 節や :ref:" -"`doctest-simple-testfile` 節を参照してください。" +"関数 :func:`testmod` と :func:`testfile` は、基本的な用途の大半に十分な、" +"doctest の簡単なインターフェースを提供します。\n" +"この 2 つの関数の平易な入門については、:ref:`doctest-simple-testmod` 節と :" +"ref:`doctest-simple-testfile` 節を参照してください。" #: ../../library/doctest.rst:905 msgid "" @@ -1485,8 +1729,8 @@ msgid "" "absolute path (i.e., it may not begin with ``/``)." msgstr "" "*module_relative* が ``True`` (デフォルト) の場合、*filename* は OS に依存し" -"ないモジュールの相対パスになります。デフォルトでは、このパスは関数 :func:" -"`testfile` を呼び出しているモジュールからの相対パスになります; ただし、" +"ないモジュールの相対パスになります。デフォルトでは、このパスは関数 " +"``testfile()`` を呼び出しているモジュールからの相対パスになります; ただし、" "*package* 引数を指定した場合には、パッケージからの相対になります。OS への依存" "性を除くため、*filename* ではパスを分割する文字に ``/`` を使わなければなら" "ず、絶対パスにしてはなりません (パス文字列を ``/`` で始めてはなりません)。" @@ -1635,13 +1879,17 @@ msgstr "" "から到達可能な関数およびクラスの docstring 内にある実行例をテストします。 " "``m.__doc__`` 内の実行例からテストを開始します。" -#: ../../library/doctest.rst:982 msgid "" "Also test examples reachable from dict ``m.__test__``, if it exists. ``m." "__test__`` maps names (strings) to functions, classes and strings; function " "and class docstrings are searched for examples; strings are searched " "directly, as if they were docstrings." msgstr "" +"辞書 ``m.__test__`` が存在する場合、そこから到達可能な実行例もテストしま" +"す。\n" +"``m.__test__`` は名前 (文字列) を関数、クラス、文字列に対応付けます。\n" +"関数やクラスでは docstring から実行例を検索し、文字列は docstring とみなして" +"直接検索します。" #: ../../library/doctest.rst:987 msgid "" @@ -1743,7 +1991,6 @@ msgstr "" msgid "Unittest API" msgstr "単体テスト API" -#: ../../library/doctest.rst:1032 msgid "" "As your collection of doctest'ed modules grows, you'll want a way to run all " "their doctests systematically. :mod:`!doctest` provides two functions that " @@ -1752,8 +1999,13 @@ msgid "" "discovery, include a :ref:`load_tests ` function in " "your test module::" msgstr "" +"doctest を使うモジュールが増えると、すべての doctest を体系的に実行したくなる" +"でしょう。\n" +":mod:`!doctest` は、doctest を含むモジュールやテキストファイルから :mod:" +"`unittest` のテストスイートを作成するための関数を 2 つ提供します。\n" +":mod:`unittest` のテストディスカバリと統合するには、テストモジュールに :ref:" +"`load_tests ` 関数を含めます。 ::" -#: ../../library/doctest.rst:1038 msgid "" "import unittest\n" "import doctest\n" @@ -1763,6 +2015,13 @@ msgid "" " tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" " return tests" msgstr "" +"import unittest\n" +"import doctest\n" +"import my_module_with_doctests\n" +"\n" +"def load_tests(loader, tests, ignore):\n" +" tests.addTests(doctest.DocTestSuite(my_module_with_doctests))\n" +" return tests" #: ../../library/doctest.rst:1046 msgid "" @@ -1780,7 +2039,6 @@ msgstr "" "単一または複数のテキストファイルに入っている doctest 形式のテストを、 :class:" "`unittest.TestSuite` インスタンスに変換します。" -#: ../../library/doctest.rst:1055 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs the interactive examples in each file. Each file is run " @@ -1791,6 +2049,15 @@ msgid "" "the examples in a file are skipped, then the synthesized unit test is also " "marked as skipped." msgstr "" +"返された :class:`unittest.TestSuite` は unittest フレームワークで実行するもの" +"で、各ファイルの対話実行例を実行します。\n" +"各ファイルが個別の単体テストとして実行され、ファイル内の各実行例が :ref:`サブ" +"テスト ` として実行されます。\n" +"ファイル内の実行例が一つでも失敗すると、生成された単体テストも失敗します。\n" +"失敗やエラーのトレースバックには、テストを含むファイルの名前と行番号 (おおよ" +"その行番号になることもあります) が含まれます。\n" +"ファイル内の実行例がすべてスキップされると、生成された単体テストもスキップと" +"して扱われます。" #: ../../library/doctest.rst:1065 msgid "Pass one or more paths (as strings) to text files to be examined." @@ -1800,7 +2067,7 @@ msgstr "" #: ../../library/doctest.rst:1067 msgid "Options may be provided as keyword arguments:" -msgstr ":func:`DocFileSuite` には、キーワード引数でオプションを指定できます:" +msgstr "``DocFileSuite()`` には、キーワード引数でオプションを指定できます:" #: ../../library/doctest.rst:1069 msgid "" @@ -1827,15 +2094,15 @@ msgstr "" "め、各ファイル名はパスを分割するのに ``/`` 文字を使わなければならず、絶対パス" "にしてはなりません (パス文字列を ``/`` で始めてはなりません)。" -#: ../../library/doctest.rst:1080 msgid "" "If *module_relative* is ``False``, then each filename in *paths* specifies " "an OS-specific path. The path may be absolute or relative; relative paths " "are resolved with respect to the current working directory." msgstr "" -"*module_relative* が ``False`` の場合、*filename* は OS 依存のパスを示しま" -"す。パスは絶対パスでも相対パスでもかまいません; 相対パスにした場合、現在の作" -"業ディレクトリを基準に解決します。" +"*module_relative* が ``False`` の場合、*paths* 内の各ファイル名は OS 依存のパ" +"スを示します。\n" +"パスは絶対パスでも相対パスでもかまいません; 相対パスにした場合、現在の作業" +"ディレクトリを基準に解決します。" #: ../../library/doctest.rst:1084 msgid "" @@ -1852,19 +2119,18 @@ msgstr "" "レクトリを相対の基準ディレクトリとして使います。*module_relative* を " "``False`` に指定している場合、*package* を指定するとエラーになります。" -#: ../../library/doctest.rst:1091 msgid "" "Optional argument *setUp* specifies a set-up function for the test suite. " "This is called before running the tests in each file. The *setUp* function " "will be passed a :class:`DocTest` object. The *setUp* function can access " "the test globals as the :attr:`~DocTest.globs` attribute of the test passed." msgstr "" -"オプション引数 *setUp* には、テストスイートのセットアップに使う関数を指定しま" -"す。この関数は、各ファイルのテストを実行する前に呼び出されます。 setUp 関数" -"は :class:`DocTest` オブジェクトに引き渡されます。 *setUp* は :attr:" -"`~DocTest.globs` 属性を介してテストのグローバル変数にアクセスできます。" +"省略可能な引数 *setUp* には、テストスイートの準備を行う関数を指定します。\n" +"この関数は各ファイルのテストを実行する前に呼び出されます。\n" +"*setUp* 関数には :class:`DocTest` オブジェクトが渡されます。\n" +"渡されたテストの :attr:`~DocTest.globs` 属性を使うと、テストのグローバル変数" +"にアクセスできます。" -#: ../../library/doctest.rst:1096 msgid "" "Optional argument *tearDown* specifies a tear-down function for the test " "suite. This is called after running the tests in each file. The *tearDown* " @@ -1872,11 +2138,12 @@ msgid "" "can access the test globals as the :attr:`~DocTest.globs` attribute of the " "test passed." msgstr "" -"オプション引数 *tearDown* には、テストを解体 (tear-down) するための関数を指定" -"します。この関数は、各ファイルのテストの実行を終了するたびに呼び出されます。 " -"*tearDown* 関数は :class:`DocTest` オブジェクトに引き渡されます。 " -"*tearDown* は :attr:`~DocTest.globs` 属性を介してテストのグローバル変数にアク" -"セスできます。" +"省略可能な引数 *tearDown* には、テストスイートの後片付けを行う関数を指定しま" +"す。\n" +"この関数は各ファイルのテストを実行した後に呼び出されます。\n" +"*tearDown* 関数には :class:`DocTest` オブジェクトが渡されます。\n" +"渡されたテストの :attr:`~DocTest.globs` 属性を使うと、テストのグローバル変数" +"にアクセスできます。" #: ../../library/doctest.rst:1102 msgid "" @@ -1908,15 +2175,13 @@ msgstr "" ":func:`DocFileSuite` を使用してテキストファイルからロードされた doctests に提" "供される globals に、グローバル変数 ``__file__`` が追加されます。" -#: ../../library/doctest.rst:1121 ../../library/doctest.rst:1162 msgid "Run each example as a :ref:`subtest `." -msgstr "" +msgstr "各実行例を :ref:`サブテスト ` として実行します。" #: ../../library/doctest.rst:1127 msgid "Convert doctest tests for a module to a :class:`unittest.TestSuite`." msgstr "doctest のテストを :class:`unittest.TestSuite` に変換します。" -#: ../../library/doctest.rst:1129 msgid "" "The returned :class:`unittest.TestSuite` is to be run by the unittest " "framework and runs each doctest in the module. Each docstring is run as a " @@ -1927,6 +2192,15 @@ msgid "" "examples in a docstring are skipped, then the synthesized unit test is also " "marked as skipped." msgstr "" +"返された :class:`unittest.TestSuite` は unittest フレームワークで実行するもの" +"で、モジュール内の各 doctest を実行します。\n" +"各 docstring が個別の単体テストとして実行され、docstring 内の各実行例が :ref:" +"`サブテスト ` として実行されます。\n" +"doctest が一つでも失敗すると、生成された単体テストも失敗します。\n" +"失敗やエラーのトレースバックには、テストを含むファイルの名前と行番号 (おおよ" +"その行番号になることもあります) が含まれます。\n" +"docstring 内の実行例がすべてスキップされると、生成された単体テストもスキップ" +"として扱われます。" #: ../../library/doctest.rst:1139 msgid "" @@ -1939,12 +2213,14 @@ msgstr "" "きます。*module* を指定しない場合、この関数を呼び出しているモジュールになりま" "す。" -#: ../../library/doctest.rst:1143 msgid "" "Optional argument *globs* is a dictionary containing the initial global " "variables for the tests. A new copy of this dictionary is created for each " "test. By default, *globs* is the module's :attr:`~module.__dict__`." msgstr "" +"オプション引数 *globs* は、テスト用のグローバル変数の初期値を含む辞書です。\n" +"各テストに対してこの辞書の新しいコピーが作成されます。\n" +"デフォルトでは、*globs* はモジュールの :attr:`~module.__dict__` です。" #: ../../library/doctest.rst:1147 msgid "" @@ -1963,12 +2239,14 @@ msgstr "" "オプション引数 *test_finder* は、モジュールから doctest を抽出するための :" "class:`DocTestFinder` オブジェクト (またはその代替となるオブジェクト) です。" -#: ../../library/doctest.rst:1153 msgid "" "Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as " "for function :func:`DocFileSuite` above, but they are called for each " "docstring." msgstr "" +"オプション引数 *setUp*、*tearDown*、*optionflags* は上記の :func:" +"`DocFileSuite` と同じですが、準備と後片付けの関数は docstring ごとに呼び出さ" +"れます。" #: ../../library/doctest.rst:1156 msgid "This function uses the same search technique as :func:`testmod`." @@ -1983,7 +2261,6 @@ msgstr "" "`DocTestSuite` は :exc:`ValueError` を送出するのではなく空の :class:" "`unittest.TestSuite` を返します。" -#: ../../library/doctest.rst:1165 msgid "" "Under the covers, :func:`DocTestSuite` creates a :class:`unittest.TestSuite` " "out of :class:`!doctest.DocTestCase` instances, and :class:`!DocTestCase` is " @@ -1991,15 +2268,21 @@ msgid "" "documented here (it's an internal detail), but studying its code can answer " "questions about the exact details of :mod:`unittest` integration." msgstr "" +"内部では、:func:`DocTestSuite` は :class:`!doctest.DocTestCase` インスタンス" +"から :class:`unittest.TestSuite` を作成します。\n" +":class:`!DocTestCase` は :class:`unittest.TestCase` のサブクラスです。\n" +":class:`!DocTestCase` は実装の詳細にあたるため、ここでは説明しませんが、その" +"コードを読むと :mod:`unittest` との統合の詳しい仕組みが分かります。" -#: ../../library/doctest.rst:1171 msgid "" "Similarly, :func:`DocFileSuite` creates a :class:`unittest.TestSuite` out " "of :class:`!doctest.DocFileCase` instances, and :class:`!DocFileCase` is a " "subclass of :class:`!DocTestCase`." msgstr "" +"同様に、:func:`DocFileSuite` は :class:`!doctest.DocFileCase` インスタンスか" +"ら :class:`unittest.TestSuite` を作成します。\n" +":class:`!DocFileCase` は :class:`!DocTestCase` のサブクラスです。" -#: ../../library/doctest.rst:1175 msgid "" "So both ways of creating a :class:`unittest.TestSuite` run instances of :" "class:`!DocTestCase`. This is important for a subtle reason: when you run :" @@ -2011,16 +2294,27 @@ msgid "" "(perhaps, e.g., specified by command line options), but there's no way to " "pass options through :mod:`!unittest` to :mod:`!doctest` test runners." msgstr "" +"したがって、どちらの方法で :class:`unittest.TestSuite` を作成しても、:class:" +"`!DocTestCase` のインスタンスが実行されます。\n" +"この点が重要なのには、少し分かりにくい理由があります。\n" +"自分で :mod:`!doctest` の関数を実行するときは、:mod:`!doctest` の関数にオプ" +"ションフラグを渡すことで、使う :mod:`!doctest` のオプションを直接制御できま" +"す。\n" +"しかし、:mod:`unittest` のフレームワークを書く場合、テストをいつどのように実" +"行するかは最終的に :mod:`!unittest` が制御します。\n" +"フレームワークの作者は通常、例えばコマンドラインオプションによって :mod:`!" +"doctest` の報告オプションを制御したいと考えますが、:mod:`!unittest` を通し" +"て :mod:`!doctest` のテストランナーにオプションを渡す方法はありません。" -#: ../../library/doctest.rst:1185 msgid "" "For this reason, :mod:`!doctest` also supports a notion of :mod:`!doctest` " "reporting flags specific to :mod:`unittest` support, via this function:" msgstr "" +"このため、:mod:`!doctest` は次の関数によって、:mod:`unittest` との連携専用" +"の :mod:`!doctest` 報告フラグも提供します。" -#: ../../library/doctest.rst:1191 msgid "Set the :mod:`!doctest` reporting flags to use." -msgstr "" +msgstr "使用する :mod:`!doctest` の報告フラグを設定します。" #: ../../library/doctest.rst:1193 msgid "" @@ -2031,7 +2325,6 @@ msgstr "" "す。 :ref:`doctest-options` 節を参照してください。「レポートフラグ」しか使え" "ません。" -#: ../../library/doctest.rst:1196 msgid "" "This is a module-global setting, and affects all future doctests run by " "module :mod:`unittest`: the :meth:`!runTest` method of :class:`!" @@ -2044,6 +2337,17 @@ msgid "" "were specified when the :class:`!DocTestCase` instance was constructed, :mod:" "`!doctest`'s :mod:`!unittest` reporting flags are ignored." msgstr "" +"これはモジュール全体の設定で、以後 :mod:`unittest` モジュールで実行するすべて" +"の doctest に影響します。\n" +":class:`!DocTestCase` の :meth:`!runTest` メソッドは、:class:`!DocTestCase` " +"インスタンスの作成時にそのテストケースに指定されたオプションフラグを調べま" +"す。\n" +"報告フラグが指定されていない場合 (通常はこの使い方を想定しています)、:mod:`!" +"doctest` の :mod:`!unittest` 用報告フラグをオプションフラグに :ref:`ビット単" +"位論理和で加え `、doctest の実行用に作成した :class:`DocTestRunner` " +"インスタンスに渡します。\n" +":class:`!DocTestCase` インスタンスの作成時に報告フラグが一つでも指定されてい" +"る場合、:mod:`!doctest` の :mod:`!unittest` 用報告フラグは無視されます。" #: ../../library/doctest.rst:1207 msgid "" @@ -2141,7 +2445,6 @@ msgid "" "following diagram::" msgstr "これらの処理クラスの関係を図にまとめると、以下のようになります::" -#: ../../library/doctest.rst:1249 msgid "" " list of:\n" "+------+ +---------+\n" @@ -2152,6 +2455,14 @@ msgid "" " DocTestParser | Example | OutputChecker\n" " +---------+" msgstr "" +" list of:\n" +"+------+ +---------+\n" +"|module| --DocTestFinder-> | DocTest | --DocTestRunner-> results\n" +"+------+ | ^ +---------+ | ^ (printed)\n" +" | | | Example | | |\n" +" v | | ... | v |\n" +" DocTestParser | Example | OutputChecker\n" +" +---------+" #: ../../library/doctest.rst:1262 msgid "DocTest Objects" @@ -2164,7 +2475,7 @@ msgid "" "names." msgstr "" "単一の名前空間内で実行される doctest 実行例の集まりです。コンストラクタの引数" -"は :class:`DocTest` インスタンス中の同名の属性の初期化に使われます。" +"は ``DocTest`` インスタンス中の同名の属性の初期化に使われます。" #: ../../library/doctest.rst:1271 msgid "" @@ -2202,12 +2513,14 @@ msgstr "" ":class:`DocTest` を識別する名前の文字列です。通常、この値はテストを取り出した" "オブジェクトかファイルの名前になります。" -#: ../../library/doctest.rst:1297 msgid "" "The name of the file that this :class:`DocTest` was extracted from; or " "``None`` if the filename is unknown, or if the :class:`!DocTest` was not " "extracted from a file." msgstr "" +"この :class:`DocTest` の抽出元のファイル名です。\n" +"ファイル名が不明な場合、または :class:`!DocTest` をファイルから抽出したのでは" +"ない場合は ``None`` です。" #: ../../library/doctest.rst:1304 msgid "" @@ -2239,8 +2552,8 @@ msgid "" "attributes of the same names." msgstr "" "ひとつの Python 文と、それに対する期待する出力からなる、単一の対話的モードの" -"実行例です。コンストラクタの引数は :class:`Example` インスタンス中の同名の属" -"性の初期化に使われます。" +"実行例です。コンストラクタの引数は ``Example`` インスタンス中の同名の属性の初" +"期化に使われます。" #: ../../library/doctest.rst:1328 msgid "" @@ -2250,14 +2563,14 @@ msgstr "" ":class:`Example` では、以下の属性を定義しています。これらの変数はコンストラク" "タで初期化されます。直接変更してはなりません。" -#: ../../library/doctest.rst:1334 msgid "" "A string containing the example's source code. This source code consists of " "a single Python statement, and always ends with a newline; the constructor " "adds a newline when necessary." msgstr "" -"実行例のソースコードが入った文字列です。ソースコードは単一の Python で、末尾" -"は常に改行です。コンストラクタは必要に応じて改行を追加します。" +"実行例のソースコードを含む文字列です。\n" +"ソースコードは単一の Python 文で、末尾は常に改行です。\n" +"コンストラクタは必要に応じて改行を追加します。" #: ../../library/doctest.rst:1341 msgid "" @@ -2302,7 +2615,6 @@ msgstr "" "実行例の入っている文字列のインデント、すなわち実行例の最初のプロンプトより前" "にある空白文字の数です。" -#: ../../library/doctest.rst:1371 msgid "" "A dictionary mapping from option flags to ``True`` or ``False``, which is " "used to override default options for this example. Any option flags not " @@ -2310,6 +2622,11 @@ msgid "" "by the :class:`DocTestRunner`'s :ref:`optionflags `). By " "default, no options are set." msgstr "" +"オプションフラグを ``True`` または ``False`` に対応付ける辞書で、この実行例の" +"デフォルトのオプションを上書きするために使われます。\n" +"この辞書に含まれないオプションフラグは、:class:`DocTestRunner` の :ref:" +"`optionflags ` で指定されたデフォルト値のままになります。\n" +"デフォルトではオプションは設定されていません。" #: ../../library/doctest.rst:1381 msgid "DocTestFinder objects" @@ -2340,9 +2657,9 @@ msgid "" "The optional argument *parser* specifies the :class:`DocTestParser` object " "(or a drop-in replacement) that is used to extract doctests from docstrings." msgstr "" -"オプション引数 *parser* には、 docstring から :class:`DocTest` を抽出するのに" -"使う :class:`DocTestParser` オブジェクト (またはその代替となるオブジェクト) " -"を指定します。" +"オプション引数 *parser* には、 docstring から ``DocTest`` を抽出するのに使" +"う :class:`DocTestParser` オブジェクト (またはその代替となるオブジェクト) を" +"指定します。" #: ../../library/doctest.rst:1397 msgid "" @@ -2373,15 +2690,14 @@ msgstr "" "*obj* または *obj* 内に入っているオブジェクトの docstring 中で定義されてい" "る :class:`DocTest` のリストを返します。" -#: ../../library/doctest.rst:1412 msgid "" "The optional argument *name* specifies the object's name; this name will be " "used to construct names for the returned :class:`DocTest`\\ s. If *name* is " "not specified, then ``obj.__name__`` is used." msgstr "" -"オプション引数 *name* には、オブジェクトの名前を指定します。この名前は、関数" -"が返す :class:`DocTest` の名前になります。 *name* を指定しない場合、 ``obj." -"__name__`` を使います。" +"オプション引数 *name* には、オブジェクトの名前を指定します。\n" +"この名前は、返される :class:`DocTest` の名前を組み立てるために使われます。\n" +"*name* を指定しない場合、 ``obj.__name__`` を使います。" #: ../../library/doctest.rst:1416 msgid "" @@ -2408,9 +2724,9 @@ msgid "" "imported from other modules. (Contained objects with modules other than " "*module* are ignored.)" msgstr "" -"他のモジュールから import されたオブジェクトに対して :class:`DocTestFinder` " -"が :class:`DocTest` を抽出するのを避けるために使います。 (*module* 由来でない" -"オブジェクトを無視します。)" +"他のモジュールから import されたオブジェクトに対して ``DocTestFinder`` が " +"``DocTest`` を抽出するのを避けるために使います。 (*module* 由来でないオブジェ" +"クトを無視します。)" #: ../../library/doctest.rst:1426 msgid "To find the name of the file containing the object." @@ -2420,7 +2736,6 @@ msgstr "オブジェクトの入っているファイル名を調べるために msgid "To help find the line number of the object within its file." msgstr "オブジェクトがファイル内の何行目にあるかを調べる手助けにします。" -#: ../../library/doctest.rst:1430 msgid "" "If *module* is ``False``, no attempt to find the module will be made. This " "is obscure, of use mostly in testing doctest itself: if *module* is " @@ -2428,14 +2743,13 @@ msgid "" "objects are considered to belong to the (non-existent) module, so all " "contained objects will (recursively) be searched for doctests." msgstr "" -"*module* が ``False`` の場合には、モジュールの検索を試みません。これは正確さ" -"を欠くような使い方で、通常 doctest 自体のテストにしか使いません。*module* が " -"``False`` の場合、または *module* が ``None`` で自動的に的確なモジュールを見" -"つけ出せない場合には、すべてのオブジェクトは ``(non-existent)`` モジュールに" -"属するとみなされ、そのオブジェクト内のすべてのオブジェクトに対して (再帰的" -"に) doctest の検索を行います。" +"*module* が ``False`` の場合、モジュールを検索しません。\n" +"これは主に doctest 自体のテストで使う特殊な機能です。\n" +"*module* が ``False`` の場合、または ``None`` でモジュールを自動的に見つけら" +"れなかった場合、すべてのオブジェクトがその (実在しない) モジュールに属すると" +"みなします。\n" +"そのため、内部のすべてのオブジェクトから doctest を再帰的に検索します。" -#: ../../library/doctest.rst:1436 msgid "" "The globals for each :class:`DocTest` is formed by combining *globs* and " "*extraglobs* (bindings in *extraglobs* override bindings in *globs*). A new " @@ -2444,6 +2758,13 @@ msgid "" "attr:`~module.__dict__`, if specified, or ``{}`` otherwise. If *extraglobs* " "is not specified, then it defaults to ``{}``." msgstr "" +"各 :class:`DocTest` のグローバル変数は、*globs* と *extraglobs* を組み合わせ" +"て作られます (*extraglobs* の束縛が *globs* の束縛を上書きします)。\n" +"各 :class:`!DocTest` に対して、グローバル変数の辞書の新しい浅いコピーが作成さ" +"れます。\n" +"*globs* を指定しない場合、モジュールが指定されていればその :attr:`~module." +"__dict__` を、そうでなければ ``{}`` を使います。\n" +"*extraglobs* を指定しない場合のデフォルトは ``{}`` です。" #: ../../library/doctest.rst:1447 msgid "DocTestParser objects" @@ -2469,12 +2790,14 @@ msgstr "" "指定した文字列からすべての doctest 実行例を抽出し、 :class:`DocTest` オブジェ" "クト内に集めます。" -#: ../../library/doctest.rst:1464 msgid "" "*globs*, *name*, *filename*, and *lineno* are attributes for the new :class:" "`!DocTest` object. See the documentation for :class:`DocTest` for more " "information." msgstr "" +"*globs*、*name*、*filename*、*lineno* は、新しい :class:`!DocTest` オブジェク" +"トの属性です。\n" +"詳しくは :class:`DocTest` のドキュメントを参照してください。" #: ../../library/doctest.rst:1471 msgid "" @@ -2484,33 +2807,33 @@ msgid "" "error messages." msgstr "" "指定した文字列からすべての doctest 実行例を抽出し、 :class:`Example` オブジェ" -"クトからなるリストにして返します。各 :class:`Example` の行番号は 0 から数えま" -"す。オプション引数 *name* はこの文字列につける名前で、エラーメッセージにしか" -"使われません。" +"クトからなるリストにして返します。各 ``Example`` の行番号は 0 から数えます。" +"オプション引数 *name* はこの文字列につける名前で、エラーメッセージにしか使わ" +"れません。" -#: ../../library/doctest.rst:1478 msgid "" "Divide the given string into examples and intervening text, and return them " "as a list of alternating :class:`Example`\\ s and strings. Line numbers for " "the :class:`!Example`\\ s are 0-based. The optional argument *name* is a " "name identifying this string, and is only used for error messages." msgstr "" +"指定した文字列を実行例とその間のテキストに分割し、:class:`Example` と文字列が" +"交互に並ぶリストとして返します。\n" +":class:`!Example` の行番号は 0 から数えます。\n" +"オプション引数 *name* はこの文字列を識別する名前で、エラーメッセージにのみ使" +"われます。" -#: ../../library/doctest.rst:1485 msgid "TestResults objects" -msgstr "" +msgstr "TestResults オブジェクト" -#: ../../library/doctest.rst:1492 msgid "Number of failed tests." -msgstr "" +msgstr "失敗したテストの数。" -#: ../../library/doctest.rst:1496 msgid "Number of attempted tests." -msgstr "" +msgstr "実行を試みたテストの数。" -#: ../../library/doctest.rst:1500 msgid "Number of skipped tests." -msgstr "" +msgstr "スキップしたテストの数。" #: ../../library/doctest.rst:1508 msgid "DocTestRunner objects" @@ -2524,7 +2847,6 @@ msgstr "" ":class:`DocTest` 内の対話モード実行例を実行し、検証する際に用いられる処理クラ" "スです。" -#: ../../library/doctest.rst:1516 msgid "" "The comparison between expected outputs and actual outputs is done by an :" "class:`OutputChecker`. This comparison may be customized with a number of " @@ -2533,8 +2855,12 @@ msgid "" "customized by passing a subclass of :class:`!OutputChecker` to the " "constructor." msgstr "" +"期待する出力と実際の出力は :class:`OutputChecker` が比較します。\n" +"この比較はさまざまなオプションフラグでカスタマイズできます。\n" +"詳しくは :ref:`doctest-options` 節を参照してください。\n" +"オプションフラグだけでは不十分な場合、コンストラクタに :class:`!" +"OutputChecker` のサブクラスを渡して比較をカスタマイズすることもできます。" -#: ../../library/doctest.rst:1522 msgid "" "The test runner's display output can be controlled in two ways. First, an " "output function can be passed to :meth:`run`; this function will be called " @@ -2544,6 +2870,14 @@ msgid "" "methods :meth:`report_skip`, :meth:`report_start`, :meth:`report_success`, :" "meth:`report_unexpected_exception`, and :meth:`report_failure`." msgstr "" +"テストランナーの表示出力は 2 通りの方法で制御できます。\n" +"まず、:meth:`run` に出力用の関数を渡せます。\n" +"この関数には、表示する文字列が渡されます。\n" +"デフォルトは ``sys.stdout.write`` です。\n" +"出力を取り込むだけでは不十分な場合、``DocTestRunner`` のサブクラスを作り、:" +"meth:`report_skip`、:meth:`report_start`、:meth:`report_success`、:meth:" +"`report_unexpected_exception`、:meth:`report_failure` メソッドをオーバーライ" +"ドして、表示出力をカスタマイズすることもできます。" #: ../../library/doctest.rst:1530 msgid "" @@ -2580,31 +2914,39 @@ msgstr "" "出力と実際の出力を比較する方法や、テストの失敗を表示する方法を制御できます。" "詳しくは :ref:`doctest-options` 節を参照してください。" -#: ../../library/doctest.rst:1544 msgid "" "The test runner accumulates statistics. The aggregated number of attempted, " "failed and skipped examples is also available via the :attr:`tries`, :attr:" "`failures` and :attr:`skips` attributes. The :meth:`run` and :meth:" "`summarize` methods return a :class:`TestResults` instance." msgstr "" +"テストランナーは統計情報を蓄積します。\n" +"実行を試みた実行例、失敗した実行例、スキップした実行例の累計は、それぞれ :" +"attr:`tries`、:attr:`failures`、:attr:`skips` 属性でも参照できます。\n" +":meth:`run` と :meth:`summarize` メソッドは :class:`TestResults` インスタンス" +"を返します。" -#: ../../library/doctest.rst:1549 msgid ":class:`DocTestRunner` defines the following methods:" -msgstr "" +msgstr ":class:`DocTestRunner` は以下のメソッドを定義しています。" -#: ../../library/doctest.rst:1554 msgid "" "Report that the given example was skipped. This method is provided to allow " "subclasses of :class:`DocTestRunner` to customize their output; it should " "not be called directly." msgstr "" +"指定した実行例がスキップされたことを報告します。\n" +"このメソッドは :class:`DocTestRunner` のサブクラスで出力をカスタマイズするた" +"めに提供されています。\n" +"直接呼び出さないでください。" -#: ../../library/doctest.rst:1558 ../../library/doctest.rst:1571 msgid "" "*example* is the example about to be processed. *test* is the test " "containing *example*. *out* is the output function that was passed to :meth:" "`DocTestRunner.run`." msgstr "" +"*example* は処理しようとしている実行例です。\n" +"*test* は *example* を含むテストです。\n" +"*out* は :meth:`DocTestRunner.run` に渡された出力用の関数です。" #: ../../library/doctest.rst:1567 msgid "" @@ -2668,12 +3010,14 @@ msgstr "" "*example* の入っているテストです。 *out* は出力用の関数で、 :meth:" "`DocTestRunner.run` に渡されます。" -#: ../../library/doctest.rst:1612 msgid "" "Run the examples in *test* (a :class:`DocTest` object), and display the " "results using the writer function *out*. Return a :class:`TestResults` " "instance." msgstr "" +"*test* (:class:`DocTest` オブジェクト) 内の実行例を実行し、書き込み用の関数 " +"*out* で結果を表示します。\n" +":class:`TestResults` インスタンスを返します。" #: ../../library/doctest.rst:1616 msgid "" @@ -2697,18 +3041,20 @@ msgstr "" "セットを指定します。*compileflags* を指定しない場合、デフォルト値は *globs* " "で適用されている future-import フラグセットになります。" -#: ../../library/doctest.rst:1625 msgid "" "The output of each example is checked using the :class:`DocTestRunner`'s " "output checker, and the results are formatted by the :meth:`!DocTestRunner." "report_\\*` methods." msgstr "" +"各実行例の出力は :class:`DocTestRunner` の出力チェッカーで検証され、結果は :" +"meth:`!DocTestRunner.report_\\*` メソッドで書式化されます。" -#: ../../library/doctest.rst:1632 msgid "" "Print a summary of all the test cases that have been run by this " "DocTestRunner, and return a :class:`TestResults` instance." msgstr "" +"この ``DocTestRunner`` が実行したすべてのテストケースの結果をまとめて表示" +"し、:class:`TestResults` インスタンスを返します。" #: ../../library/doctest.rst:1635 msgid "" @@ -2724,17 +3070,14 @@ msgstr "" msgid ":class:`DocTestParser` has the following attributes:" msgstr "" -#: ../../library/doctest.rst:1643 msgid "Number of attempted examples." -msgstr "" +msgstr "実行を試みた実行例の数。" -#: ../../library/doctest.rst:1647 msgid "Number of failed examples." -msgstr "" +msgstr "失敗した実行例の数。" -#: ../../library/doctest.rst:1651 msgid "Number of skipped examples." -msgstr "" +msgstr "スキップした実行例の数。" #: ../../library/doctest.rst:1659 msgid "OutputChecker objects" @@ -2789,8 +3132,8 @@ msgstr "デバッグ" #: ../../library/doctest.rst:1694 msgid "Doctest provides several mechanisms for debugging doctest examples:" msgstr "" -":mod:`doctest` では、doctest 実行例をデバッグするメカニズムをいくつか提供して" -"います:" +"``doctest`` では、doctest 実行例をデバッグするメカニズムをいくつか提供してい" +"ます:" #: ../../library/doctest.rst:1696 msgid "" @@ -2817,7 +3160,7 @@ msgid "" "meth:`debug` method defined by :class:`unittest.TestCase`." msgstr "" ":func:`DocTestSuite` の生成する :mod:`unittest` テストケースは、 :meth:" -"`debug` メソッドをサポートしています。 :meth:`debug` は :class:`unittest." +"`debug` メソッドをサポートしています。 ``debug()`` は :class:`unittest." "TestCase` で定義されています。" #: ../../library/doctest.rst:1707 @@ -2832,7 +3175,6 @@ msgstr "" "の現在の値などを調べられます。たとえば、以下のようなモジュールレベルの " "docstring の入ったファイル :file:`a.py` があるとします::" -#: ../../library/doctest.rst:1712 msgid "" "\"\"\"\n" ">>> def f(x):\n" @@ -2844,12 +3186,20 @@ msgid "" "9\n" "\"\"\"" msgstr "" +"\"\"\"\n" +">>> def f(x):\n" +"... g(x*2)\n" +">>> def g(x):\n" +"... print(x+3)\n" +"... import pdb; pdb.set_trace()\n" +">>> f(3)\n" +"9\n" +"\"\"\"" #: ../../library/doctest.rst:1722 msgid "Then an interactive Python session may look like this::" msgstr "対話セッションは以下のようになるでしょう::" -#: ../../library/doctest.rst:1724 msgid "" ">>> import a, doctest\n" ">>> doctest.testmod(a)\n" @@ -2881,6 +3231,35 @@ msgid "" "(0, 3)\n" ">>>" msgstr "" +">>> import a, doctest\n" +">>> doctest.testmod(a)\n" +"--Return--\n" +"> (3)g()->None\n" +"-> import pdb; pdb.set_trace()\n" +"(Pdb) list\n" +" 1 def g(x):\n" +" 2 print(x+3)\n" +" 3 -> import pdb; pdb.set_trace()\n" +"[EOF]\n" +"(Pdb) p x\n" +"6\n" +"(Pdb) step\n" +"--Return--\n" +"> (2)f()->None\n" +"-> g(x*2)\n" +"(Pdb) list\n" +" 1 def f(x):\n" +" 2 -> g(x*2)\n" +"[EOF]\n" +"(Pdb) p x\n" +"3\n" +"(Pdb) step\n" +"--Return--\n" +"> (1)?()->None\n" +"-> f(3)\n" +"(Pdb) cont\n" +"(0, 3)\n" +">>>" #: ../../library/doctest.rst:1755 msgid "" @@ -2906,7 +3285,6 @@ msgstr "" "Python のコメント文になります。生成したスクリプトを文字列で返します。例え" "ば、 ::" -#: ../../library/doctest.rst:1768 msgid "" "import doctest\n" "print(doctest.script_from_examples(r\"\"\"\n" @@ -2918,12 +3296,20 @@ msgid "" " 3\n" "\"\"\"))" msgstr "" +"import doctest\n" +"print(doctest.script_from_examples(r\"\"\"\n" +" Set x and y to 1 and 2.\n" +" >>> x, y = 1, 2\n" +"\n" +" Print their sum:\n" +" >>> print(x+y)\n" +" 3\n" +"\"\"\"))" #: ../../library/doctest.rst:1778 msgid "displays::" msgstr "は::" -#: ../../library/doctest.rst:1780 msgid "" "# Set x and y to 1 and 2.\n" "x, y = 1, 2\n" @@ -2933,6 +3319,13 @@ msgid "" "# Expected:\n" "## 3" msgstr "" +"# Set x and y to 1 and 2.\n" +"x, y = 1, 2\n" +"#\n" +"# Print their sum:\n" +"print(x+y)\n" +"# Expected:\n" +"## 3" #: ../../library/doctest.rst:1788 msgid "" @@ -2947,7 +3340,6 @@ msgstr "" msgid "Convert the doctest for an object to a script." msgstr "あるオブジェクトの doctest をスクリプトに変換します。" -#: ../../library/doctest.rst:1797 msgid "" "Argument *module* is a module object, or dotted name of a module, containing " "the object whose doctests are of interest. Argument *name* is the name " @@ -2956,18 +3348,28 @@ msgid "" "as described for :func:`script_from_examples` above. For example, if " "module :file:`a.py` contains a top-level function :func:`!f`, then ::" msgstr "" +"引数 *module* は、対象の doctest を持つオブジェクトを含むモジュールのオブジェ" +"クト、またはドット区切りのモジュール名です。\n" +"引数 *name* は、対象の doctest を持つオブジェクトのモジュール内での名前で" +"す。\n" +"戻り値は、上記の :func:`script_from_examples` と同じ方法で、オブジェクトの " +"docstring を Python スクリプトに変換した文字列です。\n" +"例えば、モジュール :file:`a.py` のトップレベルに関数 :func:`!f` がある場合、" +"次のコードは ::" -#: ../../library/doctest.rst:1804 msgid "" "import a, doctest\n" "print(doctest.testsource(a, \"a.f\"))" msgstr "" +"import a, doctest\n" +"print(doctest.testsource(a, \"a.f\"))" -#: ../../library/doctest.rst:1807 msgid "" "prints a script version of function :func:`!f`'s docstring, with doctests " "converted to code, and the rest placed in comments." msgstr "" +"関数 :func:`!f` の docstring をスクリプトに変換して表示します。\n" +"doctest はコードに変換され、残りはコメントになります。" #: ../../library/doctest.rst:1813 msgid "Debug the doctests for an object." @@ -3049,8 +3451,8 @@ msgid "" msgstr "" ":class:`DebugRunner` クラス自体や :class:`DebugRunner` クラスが送出する特殊な" "例外は、テストフレームワークの作者にとって非常に興味のあるところですが、ここ" -"では概要しか述べられません。詳しくはソースコード、とりわけ :class:" -"`DebugRunner` の docstring (それ自体 doctest です!) を参照してください:" +"では概要しか述べられません。詳しくはソースコード、とりわけ ``DebugRunner`` " +"の docstring (それ自体 doctest です!) を参照してください:" #: ../../library/doctest.rst:1854 msgid "" @@ -3136,11 +3538,12 @@ msgstr "" msgid "Soapbox" msgstr "アドバイス" -#: ../../library/doctest.rst:1921 msgid "" "As mentioned in the introduction, :mod:`!doctest` has grown to have three " "primary uses:" msgstr "" +"導入で述べたように、:mod:`!doctest` は主に次の 3 つの用途で使われるようになり" +"ました。" #: ../../library/doctest.rst:1924 msgid "Checking examples in docstrings." @@ -3164,7 +3567,6 @@ msgstr "" "に、docstring を曖昧なテストケースに埋もれさせてしまうとドキュメントとしては" "最悪です。" -#: ../../library/doctest.rst:1934 msgid "" "When writing a docstring, choose docstring examples with care. There's an " "art to this that needs to be learned---it may not be natural at first. " @@ -3175,8 +3577,15 @@ msgid "" "at how often one of my :mod:`!doctest` examples stops working after a " "\"harmless\" change." msgstr "" +"docstring を書くときは、そこに載せる実行例を慎重に選んでください。\n" +"これには身につけるべきこつがあり、最初は自然にはできないかもしれません。\n" +"実行例はドキュメントに確かな価値を加えるものであるべきです。\n" +"よい実行例は、多くの言葉による説明に匹敵することがあります。\n" +"注意深く作れば、実行例はユーザーにとって非常に役立ち、年月が過ぎて物事が変" +"わっても、集めるのにかけた時間に何倍もの価値を返してくれるでしょう。\n" +"「無害な」はずの変更の後で自分の :mod:`!doctest` の実行例が動かなくなること" +"が、今でも驚くほどよくあります。" -#: ../../library/doctest.rst:1942 msgid "" "Doctest also makes an excellent tool for regression testing, especially if " "you don't skimp on explanatory text. By interleaving prose and examples, it " @@ -3196,21 +3605,27 @@ msgid "" "functionality seemingly at random. It's a different attitude, and produces " "different results, blurring the distinction between testing and explaining." msgstr "" -"説明テキストの作成をけちらなければ、:mod:`doctest` は回帰テストの優れたツール" -"にもなり得ます。説明文と実行例を交互に記述していけば、実際に何をどうしてテス" -"トしているのかもっと簡単に把握できるようになるでしょう。もちろん、コードベー" -"スのテストに詳しくコメントを入れるのも手ですが、そんなことをするプログラマは" -"ほとんどいません。多くの人々が、:mod:`doctest` のアプローチをとった方がきれい" -"にテストを書けると気づいています。おそらく、これは単にコード中にコメントを書" -"くのが少し面倒だからという理由でしょう。私はもう少し穿った見方もしています。" -"doctest ベースのテストを書くときの自然な態度は、自分のソフトウェアのよい点を" -"説明しようとして、実行例を使って説明しようとするときの態度そのものだからだ、" -"という理由です。それゆえに、テストファイルは自然と単純な機能の解説から始め、" -"論理的により複雑で境界条件的なケースに進むような形になります。結果的に、一見" -"ランダムに見えるような個別の機能をテストしている個別の関数の集まりではなく、" -"首尾一貫した説明ができるようになるのです。:mod:`doctest` によるテストの作成は" -"まったく別の取り組み方であり、テストと説明の区別をなくして、まったく違う結果" -"を生み出すのです。" +"Doctest は回帰テストの優れたツールにもなります。\n" +"説明文を惜しまず書けば、特に役立ちます。\n" +"説明文と実行例を交互に記述すると、実際に何を、なぜテストしているのかを把握し" +"やすくなります。\n" +"テストが失敗したときにも、よい説明文があれば問題と修正方法が分かりやすくなり" +"ます。\n" +"確かに、コードで書くテストにも詳しいコメントを付けられますが、そうするプログ" +"ラマーは少数です。\n" +"代わりに doctest を使うと、はるかに分かりやすいテストになると感じる人は多くい" +"ます。\n" +"単に、doctest ではコードよりも説明文が少し書きやすく、コード中ではコメントが" +"少し書きにくいからかもしれません。\n" +"私はそれよりも深い理由があると考えています。\n" +"doctest ベースのテストを書くときは、ソフトウェアの細かな点を説明し、実行例で" +"示そうという姿勢に自然となります。\n" +"すると、最も単純な機能から始まり、複雑な場合や境界条件へと論理的に進むテスト" +"ファイルになります。\n" +"結果として、個々の機能の断片をばらばらにテストする関数の集まりではなく、筋の" +"通った説明ができます。\n" +"取り組む姿勢が違うため、テストと説明の区別が薄れるという違った結果を生むので" +"す。" #: ../../library/doctest.rst:1960 msgid "" @@ -3244,26 +3659,25 @@ msgstr "" "ジュールと同じファイルの中にも置けますし、別のテストファイルに分けてもかまい" "ません。" -#: ../../library/doctest.rst:1972 msgid "" "Define a :attr:`~module.__test__` dictionary mapping from regression test " "topics to docstrings containing test cases." msgstr "" +"回帰テストのトピックを、テストケースを含む docstring に対応付ける :attr:" +"`~module.__test__` 辞書を定義します。" -#: ../../library/doctest.rst:1975 msgid "" "When you have placed your tests in a module, the module can itself be the " "test runner. When a test fails, you can arrange for your test runner to re-" "run only the failing doctest while you debug the problem. Here is a minimal " "example of such a test runner::" msgstr "" -"テストコードをモジュールに組み込むことで、そのモジュールは、モジュール自身が" -"テストランナーになることができます。テストが失敗した場合には、問題箇所をデ" -"バッグする際に、失敗したdoctestだけを再度実行することで、作成したテストラン" -"ナーを修正することができます。これがこのようなテストランナーの最小例となりま" -"す。" +"テストをモジュール内に置くと、そのモジュール自体をテストランナーにできま" +"す。\n" +"テストが失敗したときは、問題をデバッグする間、失敗した doctest だけを再実行す" +"るようにテストランナーを設定できます。\n" +"次に、そのようなテストランナーの最小限の例を示します。 ::" -#: ../../library/doctest.rst:1980 msgid "" "if __name__ == '__main__':\n" " import doctest\n" @@ -3280,6 +3694,20 @@ msgid "" " fail, total = doctest.testmod(optionflags=flags)\n" " print(f\"{fail} failures out of {total} tests\")" msgstr "" +"if __name__ == '__main__':\n" +" import doctest\n" +" flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST\n" +" if len(sys.argv) > 1:\n" +" name = sys.argv[1]\n" +" if name in globals():\n" +" obj = globals()[name]\n" +" else:\n" +" obj = __test__[name]\n" +" doctest.run_docstring_examples(obj, globals(), name=name,\n" +" optionflags=flags)\n" +" else:\n" +" fail, total = doctest.testmod(optionflags=flags)\n" +" print(f\"{fail} failures out of {total} tests\")" #: ../../library/doctest.rst:1997 msgid "Footnotes" @@ -3299,9 +3727,8 @@ msgstr "" msgid ">>>" msgstr ">>>" -#: ../../library/doctest.rst:382 msgid "interpreter prompt" -msgstr "" +msgstr "インタープリタのプロンプト" #: ../../library/doctest.rst:382 ../../library/doctest.rst:617 msgid "..." @@ -3311,17 +3738,14 @@ msgstr "..." msgid "^ (caret)" msgstr "^ (キャレット)" -#: ../../library/doctest.rst:548 msgid "marker" -msgstr "" +msgstr "マーカー" -#: ../../library/doctest.rst:597 msgid "" -msgstr "" +msgstr "" -#: ../../library/doctest.rst:617 ../../library/doctest.rst:742 msgid "in doctests" -msgstr "" +msgstr "doctest 内" #: ../../library/doctest.rst:742 msgid "# (hash)" diff --git a/library/email.charset.po b/library/email.charset.po index 381d6eec0..8590a7985 100644 --- a/library/email.charset.po +++ b/library/email.charset.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.charset.rst:2 @@ -58,9 +58,9 @@ msgstr "" ":class:`Charset` インスタンスは :mod:`email` パッケージ中にある他のいくつかの" "モジュールで使用されます。" -#: ../../library/email.charset.rst:22 msgid "Import this class from the :mod:`!email.charset` module." msgstr "" +"このクラスは :mod:`!email.charset` モジュールからインポートしてください。" #: ../../library/email.charset.rst:27 msgid "Map character sets to their email properties." @@ -172,15 +172,13 @@ msgstr "" "*input_charset* を Unicode に変換するための Python 用コーデック名です。変換用" "のコーデックが必要ないときは、この値は ``None`` になります。" -#: ../../library/email.charset.rst:91 msgid "" "The name of the Python codec used to convert Unicode to the " "*output_charset*. If no conversion codec is necessary, this attribute will " "have the same value as the *input_codec*." msgstr "" -"Unicode を *output_charset* に変換するための Python 用コーデック名です。変換" -"用のコーデックが必要ないときは、この値は ``None`` になります。この属性は " -"*input_codec* と同じ値を持つことになるでしょう。" +"Unicode を *output_charset* に変換するための Python コーデック名です。\n" +"変換用のコーデックが不要な場合、この属性は *input_codec* と同じ値になります。" #: ../../library/email.charset.rst:96 msgid ":class:`Charset` instances also have the following methods:" @@ -192,7 +190,6 @@ msgstr "" "メッセージ本体のエンコードに使われる content-transfer-encoding の値を返しま" "す。" -#: ../../library/email.charset.rst:102 msgid "" "This is either the string ``quoted-printable`` or ``base64`` depending on " "the encoding used, or it is a function, in which case you should call the " @@ -200,11 +197,12 @@ msgid "" "function should then set the :mailheader:`Content-Transfer-Encoding` header " "itself to whatever is appropriate." msgstr "" -"この値は使用しているエンコーディングの文字列 ``quoted-printable`` または " -"``base64`` か、あるいは関数のいずれかです。後者の場合、これはエンコードされ" -"る Message オブジェクトを単一の引数として取るような関数である必要があります。" -"この関数は変換後 :mailheader:`Content-Transfer-Encoding` ヘッダ自体を、なんで" -"あれ適切な値に設定する必要があります。" +"使用するエンコーディングに応じて、文字列 ``quoted-printable`` または " +"``base64``、あるいは関数を返します。\n" +"関数の場合は、エンコードする Message オブジェクトを唯一の引数としてその関数を" +"呼び出してください。\n" +"その関数が :mailheader:`Content-Transfer-Encoding` ヘッダーを適切な値に設定し" +"ます。" #: ../../library/email.charset.rst:108 msgid "" @@ -300,11 +298,12 @@ msgstr "" "このメソッドは、2つの :class:`Charset` インスタンスが異なるかどうかをチェック" "するのに使います。" -#: ../../library/email.charset.rst:167 msgid "" "The :mod:`!email.charset` module also provides the following functions for " "adding new entries to the global character set, alias, and codec registries:" msgstr "" +":mod:`!email.charset` モジュールは、文字集合、別名、コーデックのグローバルレ" +"ジストリに新しい項目を追加するための以下の関数も提供します。" #: ../../library/email.charset.rst:173 msgid "Add character properties to the global registry." diff --git a/library/email.compat32-message.po b/library/email.compat32-message.po index 84d4606ee..42ae59d7a 100644 --- a/library/email.compat32-message.po +++ b/library/email.compat32-message.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.compat32-message.rst:4 @@ -30,7 +30,6 @@ msgstr "" ":mod:`email.message.Message`: :data:`~email.policy.compat32` API を使用した電" "子メールメッセージの表現" -#: ../../library/email.compat32-message.rst:13 msgid "" "The :class:`Message` class is very similar to the :class:`~email.message." "EmailMessage` class, without the methods added by that class, and with the " @@ -39,20 +38,26 @@ msgid "" "message.EmailMessage` class, are not recommended unless you are dealing with " "legacy code." msgstr "" +":class:`Message` クラスは :class:`~email.message.EmailMessage` クラスによく似" +"ていますが、後者で追加されたメソッドはなく、一部の他のメソッドでもデフォルト" +"の動作が少し異なります。\n" +"ここでは、:class:`~email.message.EmailMessage` クラスでもサポートされているも" +"のの、従来のコードを扱う場合以外には推奨されないメソッドも説明します。" -#: ../../library/email.compat32-message.rst:20 msgid "The philosophy and structure of the two classes is otherwise the same." -msgstr "" +msgstr "それ以外の点では、両クラスの設計思想と構造は同じです。" -#: ../../library/email.compat32-message.rst:22 msgid "" "This document describes the behavior under the default (for :class:" "`Message`) policy :attr:`~email.policy.Compat32`. If you are going to use " "another policy, you should be using the :class:`~email.message.EmailMessage` " "class instead." msgstr "" +"このドキュメントは、:class:`Message` のデフォルトのポリシーである :attr:" +"`~email.policy.Compat32` での動作を説明します。\n" +"別のポリシーを使う場合は、代わりに :class:`~email.message.EmailMessage` クラ" +"スを使ってください。" -#: ../../library/email.compat32-message.rst:26 msgid "" "An email message consists of *headers* and a *payload*. Headers must be :" "rfc:`5322` style names and values, where the field name and value are " @@ -63,8 +68,16 @@ msgid "" "message having a MIME type such as :mimetype:`multipart/\\*` or :mimetype:" "`message/rfc822`." msgstr "" +"電子メールメッセージは *ヘッダー* と *ペイロード* からなります。\n" +"ヘッダーの名前と値は :rfc:`5322` の形式に従い、フィールド名と値をコロンで区切" +"る必要があります。\n" +"コロンはフィールド名にも値にも含まれません。\n" +"ペイロードには、単純なテキストメッセージ、バイナリオブジェクト、または各々が" +"独自のヘッダーとペイロードを持つサブメッセージを構造化して並べたものを使えま" +"す。\n" +"最後の形式のペイロードは、メッセージの MIME 型が :mimetype:`multipart/\\*` " +"や :mimetype:`message/rfc822` などの場合に使われます。" -#: ../../library/email.compat32-message.rst:35 msgid "" "The conceptual model provided by a :class:`Message` object is that of an " "ordered dictionary of headers with additional methods for accessing both " @@ -73,8 +86,12 @@ msgid "" "over the object tree. Note that duplicate headers are supported but special " "methods must be used to access them." msgstr "" +":class:`Message` オブジェクトは概念的にはヘッダーの順序付き辞書であり、ヘッ" +"ダーの特定の情報やペイロードへのアクセス、メッセージの直列化、オブジェクトツ" +"リーの再帰的な巡回のためのメソッドが追加されています。\n" +"同名のヘッダーを複数持てますが、それらへのアクセスには専用のメソッドが必要で" +"す。" -#: ../../library/email.compat32-message.rst:42 msgid "" "The :class:`Message` pseudo-dictionary is indexed by the header names, which " "must be ASCII values. The values of the dictionary are strings that are " @@ -87,12 +104,23 @@ msgid "" "list of :class:`Message` objects, for MIME container documents (e.g. :" "mimetype:`multipart/\\*` and :mimetype:`message/rfc822`)." msgstr "" +":class:`Message` は辞書に似たインターフェースを持ち、ASCII 値でなければならな" +"いヘッダー名をキーとします。\n" +"辞書の値は文字列で、ASCII 文字だけを含むことを想定しています。\n" +"非 ASCII 入力には特別な処理がありますが、常に正しい結果になるとは限りませ" +"ん。\n" +"ヘッダーの格納時と取得時には大文字・小文字が保持されますが、フィールド名の照" +"合では区別されません。\n" +"*Unix-From* ヘッダーまたは ``From_`` ヘッダーとも呼ばれるエンベロープヘッダー" +"を一つ持つこともできます。\n" +"*ペイロード* は、単純なメッセージオブジェクトでは文字列またはバイト列であり、" +"MIME コンテナ文書 (:mimetype:`multipart/\\*` や :mimetype:`message/rfc822` な" +"ど) では :class:`Message` オブジェクトのリストです。" #: ../../library/email.compat32-message.rst:53 msgid "Here are the methods of the :class:`Message` class:" msgstr ":class:`Message` クラスのメソッドは以下のとおりです:" -#: ../../library/email.compat32-message.rst:58 msgid "" "If *policy* is specified (it must be an instance of a :mod:`~email.policy` " "class) use the rules it specifies to update and serialize the representation " @@ -101,12 +129,16 @@ msgid "" "Python 3.2 version of the email package. For more information see the :mod:" "`~email.policy` documentation." msgstr "" +"*policy* を指定した場合 (:mod:`~email.policy` のクラスのインスタンスでなけれ" +"ばなりません)、その規則に従ってメッセージの表現を更新し、直列化します。\n" +"*policy* を指定しない場合、Python 3.2 版の email パッケージとの後方互換性を維" +"持する :class:`compat32 ` ポリシーを使います。\n" +"詳しくは :mod:`~email.policy` のドキュメントを参照してください。" #: ../../library/email.compat32-message.rst:65 msgid "The *policy* keyword argument was added." msgstr "キーワード引数 *policy* が追加されました。" -#: ../../library/email.compat32-message.rst:70 msgid "" "Return the entire message flattened as a string. When optional *unixfrom* " "is true, the envelope header is included in the returned string. *unixfrom* " @@ -118,6 +150,17 @@ msgid "" "control some of the formatting produced by the method, since the specified " "*policy* will be passed to the ``Generator``." msgstr "" +"メッセージ全体をフラット化した文字列を返します。\n" +"オプションの *unixfrom* が真の場合、戻り値にはエンベロープヘッダーが含まれま" +"す。\n" +"*unixfrom* のデフォルトは ``False`` です。\n" +"後方互換性のため *maxheaderlen* のデフォルトは ``0`` なので、別の値を使うには" +"明示的に指定する必要があります (このメソッドはポリシーの *max_line_length* を" +"無視します)。\n" +"*policy* 引数で、メッセージインスタンスから取得するデフォルトのポリシーを上書" +"きできます。\n" +"指定した *policy* は ``Generator`` に渡されるため、メソッドが生成する書式の一" +"部を制御できます。" #: ../../library/email.compat32-message.rst:80 #: ../../library/email.compat32-message.rst:122 @@ -130,7 +173,6 @@ msgstr "" "メッセージのフラット化は :class:`Message` の変更を引き起こす可能性があります " "(例えば、MIME の境界が生成される、変更される等)。" -#: ../../library/email.compat32-message.rst:84 msgid "" "Note that this method is provided as a convenience and may not always format " "the message the way you want. For example, by default it does not do the " @@ -139,8 +181,15 @@ msgid "" "Generator` instance and use its :meth:`~email.generator.Generator.flatten` " "method directly. For example::" msgstr "" +"このメソッドは便利な補助機能として提供されており、常に希望どおりの書式になる" +"とは限りません。\n" +"例えば、デフォルトでは Unix mbox 形式に必要な、``From`` で始まる行の書き換え" +"を行いません。\n" +"より柔軟に制御するには、:class:`~email.generator.Generator` のインスタンスを" +"作成し、その :meth:`~email.generator.Generator.flatten` メソッドを直接使って" +"ください。\n" +"例えば次のようにします。 ::" -#: ../../library/email.compat32-message.rst:91 msgid "" "from io import StringIO\n" "from email.generator import Generator\n" @@ -149,26 +198,36 @@ msgid "" "g.flatten(msg)\n" "text = fp.getvalue()" msgstr "" +"from io import StringIO\n" +"from email.generator import Generator\n" +"fp = StringIO()\n" +"g = Generator(fp, mangle_from_=True, maxheaderlen=60)\n" +"g.flatten(msg)\n" +"text = fp.getvalue()" -#: ../../library/email.compat32-message.rst:98 msgid "" "If the message object contains binary data that is not encoded according to " "RFC standards, the non-compliant data will be replaced by Unicode \"unknown " "character\" code points. (See also :meth:`.as_bytes` and :class:`~email." "generator.BytesGenerator`.)" msgstr "" +"メッセージオブジェクトに RFC の規定どおりにエンコードされていないバイナリデー" +"タが含まれる場合、そのデータは Unicode の「不明な文字」を示すコードポイントに" +"置き換えられます。\n" +"(:meth:`.as_bytes` と :class:`~email.generator.BytesGenerator` も参照してくだ" +"さい。)" #: ../../library/email.compat32-message.rst:103 msgid "the *policy* keyword argument was added." msgstr "*policy* キーワード引数が追加されました。" -#: ../../library/email.compat32-message.rst:108 msgid "" "Equivalent to :meth:`.as_string`. Allows ``str(msg)`` to produce a string " "containing the formatted message." msgstr "" +":meth:`.as_string` と同じです。\n" +"``str(msg)`` で、書式化されたメッセージを含む文字列を生成できるようにします。" -#: ../../library/email.compat32-message.rst:114 msgid "" "Return the entire message flattened as a bytes object. When optional " "*unixfrom* is true, the envelope header is included in the returned string. " @@ -177,8 +236,15 @@ msgid "" "used to control some of the formatting produced by the method, since the " "specified *policy* will be passed to the ``BytesGenerator``." msgstr "" +"メッセージ全体をフラット化した bytes オブジェクトを返します。\n" +"オプションの *unixfrom* が真の場合、戻り値にはエンベロープヘッダーが含まれま" +"す。\n" +"*unixfrom* のデフォルトは ``False`` です。\n" +"*policy* 引数で、メッセージインスタンスから取得するデフォルトのポリシーを上書" +"きできます。\n" +"指定した *policy* は ``BytesGenerator`` に渡されるため、メソッドが生成する書" +"式の一部を制御できます。" -#: ../../library/email.compat32-message.rst:126 msgid "" "Note that this method is provided as a convenience and may not always format " "the message the way you want. For example, by default it does not do the " @@ -187,8 +253,15 @@ msgid "" "BytesGenerator` instance and use its :meth:`~email.generator.BytesGenerator." "flatten` method directly. For example::" msgstr "" +"このメソッドは便利な補助機能として提供されており、常に希望どおりの書式になる" +"とは限りません。\n" +"例えば、デフォルトでは Unix mbox 形式に必要な、``From`` で始まる行の書き換え" +"を行いません。\n" +"より柔軟に制御するには、:class:`~email.generator.BytesGenerator` のインスタン" +"スを作成し、その :meth:`~email.generator.BytesGenerator.flatten` メソッドを直" +"接使ってください。\n" +"例えば次のようにします。 ::" -#: ../../library/email.compat32-message.rst:134 msgid "" "from io import BytesIO\n" "from email.generator import BytesGenerator\n" @@ -197,14 +270,21 @@ msgid "" "g.flatten(msg)\n" "text = fp.getvalue()" msgstr "" +"from io import BytesIO\n" +"from email.generator import BytesGenerator\n" +"fp = BytesIO()\n" +"g = BytesGenerator(fp, mangle_from_=True, maxheaderlen=60)\n" +"g.flatten(msg)\n" +"text = fp.getvalue()" -#: ../../library/email.compat32-message.rst:146 msgid "" "Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a bytes " "object containing the formatted message." msgstr "" +":meth:`.as_bytes` と同じです。\n" +"``bytes(msg)`` で、書式化されたメッセージを含む bytes オブジェクトを生成でき" +"るようにします。" -#: ../../library/email.compat32-message.rst:154 msgid "" "Return ``True`` if the message's payload is a list of sub-\\ :class:" "`Message` objects, otherwise return ``False``. When :meth:`is_multipart` " @@ -214,6 +294,14 @@ msgid "" "'multipart'\" will return the ``True``. For example, ``is_multipart`` will " "return ``True`` when the :class:`Message` is of type ``message/rfc822``.)" msgstr "" +"メッセージのペイロードがサブメッセージの :class:`Message` オブジェクトのリス" +"トなら ``True`` を、それ以外なら ``False`` を返します。\n" +":meth:`is_multipart` が ``False`` を返す場合、ペイロードは文字列オブジェクト" +"のはずです (CTE でエンコードされたバイナリのペイロードの場合もあります)。\n" +":meth:`is_multipart` が ``True`` を返しても、``msg.get_content_maintype() == " +"'multipart'`` が ``True`` を返すとは限りません。\n" +"例えば、:class:`Message` の型が ``message/rfc822`` の場合も " +"``is_multipart()`` は ``True`` を返します。" #: ../../library/email.compat32-message.rst:166 msgid "" @@ -244,12 +332,15 @@ msgstr "" "のリストになります。ペイロードにスカラーオブジェクト (文字列など) を格納した" "い場合は、かわりに :meth:`set_payload` を使ってください。" -#: ../../library/email.compat32-message.rst:183 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by :meth:`~email.message.EmailMessage." "set_content` and the related ``make`` and ``add`` methods." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、:meth:`~email.message." +"EmailMessage.set_content` と関連する ``make`` および ``add`` メソッドがこの機" +"能を置き換えています。" #: ../../library/email.compat32-message.rst:191 msgid "" @@ -279,7 +370,6 @@ msgstr "" "が ``False``) にもかかわらず *i* が与えられたときは :exc:`TypeError` が発生し" "ます。" -#: ../../library/email.compat32-message.rst:203 msgid "" "Optional *decode* is a flag indicating whether the payload should be decoded " "or not, according to the :mailheader:`Content-Transfer-Encoding` header. " @@ -294,8 +384,20 @@ msgid "" "message's defect property (:class:`~email.errors.InvalidBase64PaddingDefect` " "or :class:`~email.errors.InvalidBase64CharactersDefect`, respectively)." msgstr "" +"オプションの *decode* は、:mailheader:`Content-Transfer-Encoding` ヘッダーに" +"従ってペイロードをデコードするかどうかを指定するフラグです。\n" +"``True`` で、メッセージがマルチパートでない場合、このヘッダーの値が ``quoted-" +"printable`` または ``base64`` ならペイロードをデコードします。\n" +"別のエンコーディングを使っている場合や :mailheader:`Content-Transfer-" +"Encoding` ヘッダーがない場合は、ペイロードをデコードせずそのまま返します。\n" +"いずれの場合も戻り値はバイナリデータです。\n" +"メッセージがマルチパートで *decode* が ``True`` の場合は ``None`` を返しま" +"す。\n" +"base64 のペイロードにパディングの欠落や base64 の文字集合にない文字がある場合" +"は、それぞれ :class:`~email.errors.InvalidBase64PaddingDefect` または :class:" +"`~email.errors.InvalidBase64CharactersDefect` がメッセージの欠陥を記録するプ" +"ロパティに追加されます。" -#: ../../library/email.compat32-message.rst:217 msgid "" "When *decode* is ``False`` (the default) the body is returned as a string " "without decoding the :mailheader:`Content-Transfer-Encoding`. However, for " @@ -305,31 +407,42 @@ msgid "" "``charset`` is specified, or if the ``charset`` given is not recognized by " "the email package, the body is decoded using the default ASCII charset." msgstr "" +"*decode* が ``False`` (デフォルト) の場合、:mailheader:`Content-Transfer-" +"Encoding` をデコードせず、本体を文字列として返します。\n" +"ただし、:mailheader:`Content-Transfer-Encoding` が 8bit の場合は、:" +"mailheader:`Content-Type` ヘッダーで指定された ``charset`` と ``replace`` エ" +"ラーハンドラーを使って、元のバイト列のデコードを試みます。\n" +"``charset`` が指定されていない場合、または email パッケージが認識できない場合" +"は、デフォルトの ASCII 文字セットで本体をデコードします。" -#: ../../library/email.compat32-message.rst:226 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by :meth:`~email.message.EmailMessage." "get_content` and :meth:`~email.message.EmailMessage.iter_parts`." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、:meth:`~email.message." +"EmailMessage.get_content` と :meth:`~email.message.EmailMessage.iter_parts` " +"がこの機能を置き換えています。" -#: ../../library/email.compat32-message.rst:234 msgid "" "Set the entire message object's payload to *payload*. It is the client's " "responsibility to ensure the payload invariants. Optional *charset* sets " "the message's default character set; see :meth:`set_charset` for details." msgstr "" -"メッセージオブジェクト全体のペイロードを *payload* に設定します。クライアント" -"はペイロードを変更してはいけません。オプションの *charset* はメッセージのデ" -"フォルト文字セットを設定します。詳しくは :meth:`set_charset` を参照してくださ" -"い。" +"メッセージオブジェクトのペイロード全体を *payload* に設定します。\n" +"ペイロードが満たすべき条件を維持する責任は呼び出し側にあります。\n" +"省略可能な *charset* はメッセージのデフォルトの文字セットを設定します。\n" +"詳しくは :meth:`set_charset` を参照してください。" -#: ../../library/email.compat32-message.rst:238 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by :meth:`~email.message.EmailMessage." "set_content`." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、:meth:`~email.message." +"EmailMessage.set_content` がこの機能を置き換えています。" #: ../../library/email.compat32-message.rst:245 msgid "" @@ -377,12 +490,15 @@ msgstr "" "ば、ペイロードはすでにその :mailheader:`Content-Transfer-Encoding` によって正" "しくエンコードされたものと見なされ、変形されません。" -#: ../../library/email.compat32-message.rst:267 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by the *charset* parameter of the :meth:`email." "message.EmailMessage.set_content` method." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、:meth:`email.message." +"EmailMessage.set_content` メソッドの *charset* 引数がこの機能を置き換えていま" +"す。" #: ../../library/email.compat32-message.rst:275 msgid "" @@ -392,11 +508,12 @@ msgstr "" "そのメッセージ中のペイロードの :class:`~email.charset.Charset` インスタンスを" "返します。" -#: ../../library/email.compat32-message.rst:278 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "it always returns ``None``." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは常に ``None`` を返します。" #: ../../library/email.compat32-message.rst:283 msgid "" @@ -436,13 +553,15 @@ msgstr "" "注意: どんな場合も、メッセージ中のエンベロープヘッダはこのマップ形式のインタ" "フェイスには含まれません。" -#: ../../library/email.compat32-message.rst:299 msgid "" "In a model generated from bytes, any header values that (in contravention of " "the RFCs) contain non-ASCII bytes will, when retrieved through this " "interface, be represented as :class:`~email.header.Header` objects with a " "charset of ``unknown-8bit``." msgstr "" +"バイト列から生成されたモデルでは、RFC に反して非 ASCII バイトを含むヘッダー値" +"をこのインターフェースから取得すると、文字セットが ``unknown-8bit`` の :" +"class:`~email.header.Header` オブジェクトとして返されます。" #: ../../library/email.compat32-message.rst:307 msgid "Return the total number of headers, including duplicates." @@ -459,11 +578,12 @@ msgstr "" "は最後にコロンをふくんでいてはいけません。このメソッドは以下のように ``in`` " "演算子で使われます::" -#: ../../library/email.compat32-message.rst:316 msgid "" "if 'message-id' in myMessage:\n" " print('Message-ID:', myMessage['message-id'])" msgstr "" +"if 'message-id' in myMessage:\n" +" print('Message-ID:', myMessage['message-id'])" #: ../../library/email.compat32-message.rst:322 msgid "" @@ -505,11 +625,12 @@ msgstr "" "せん*。もしメッセージが名前 *name* をもつフィールドをひとつしか持たないように" "したければ、最初にそれを除去してください。たとえば::" -#: ../../library/email.compat32-message.rst:341 msgid "" "del msg['subject']\n" "msg['subject'] = 'Python roolz!'" msgstr "" +"del msg['subject']\n" +"msg['subject'] = 'Python roolz!'" #: ../../library/email.compat32-message.rst:347 msgid "" @@ -536,12 +657,14 @@ msgstr "" "メッセージ中にあるすべてのヘッダのフィールド名とその値を 2-タプルのリストとし" "て返します。" -#: ../../library/email.compat32-message.rst:370 msgid "" "Return the value of the named header field. This is identical to :meth:" "`~object.__getitem__` except that optional *failobj* is returned if the " "named header is missing (defaults to ``None``)." msgstr "" +"指定した名前のヘッダーフィールドの値を返します。\n" +":meth:`~object.__getitem__` と同じですが、ヘッダーがない場合にオプションの " +"*failobj* (デフォルトは ``None``) を返す点が異なります。" #: ../../library/email.compat32-message.rst:374 msgid "Here are some additional useful methods:" @@ -557,16 +680,17 @@ msgstr "" "前のヘッダがメッセージ中に含まれていない場合は *failobj* (デフォルトでは " "``None``) が返されます。" -#: ../../library/email.compat32-message.rst:386 msgid "" "Extended header setting. This method is similar to :meth:`__setitem__` " "except that additional header parameters can be provided as keyword " "arguments. *_name* is the header field to add and *_value* is the *primary* " "value for the header." msgstr "" -"拡張ヘッダ設定。このメソッドは :meth:`__setitem__` と似ていますが、追加のヘッ" -"ダ・パラメータをキーワード引数で指定できるところが違っています。 *_name* に追" -"加するヘッダフィールドを、 *_value* にそのヘッダの *最初の* 値を渡します。" +"拡張ヘッダ設定。\n" +"このメソッドは :meth:`__setitem__` と似ていますが、追加のヘッダ・パラメータを" +"キーワード引数で指定できるところが違っています。\n" +"*_name* に追加するヘッダフィールドを、 *_value* にそのヘッダの *主たる* 値を" +"渡します。" #: ../../library/email.compat32-message.rst:391 msgid "" @@ -601,36 +725,36 @@ msgstr "" msgid "Here's an example::" msgstr "以下はこの使用例です::" -#: ../../library/email.compat32-message.rst:407 msgid "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" msgstr "" +"msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" #: ../../library/email.compat32-message.rst:409 msgid "This will add a header that looks like ::" msgstr "こうするとヘッダには以下のように追加されます ::" -#: ../../library/email.compat32-message.rst:411 msgid "Content-Disposition: attachment; filename=\"bud.gif\"" -msgstr "" +msgstr "Content-Disposition: attachment; filename=\"bud.gif\"" #: ../../library/email.compat32-message.rst:413 msgid "An example with non-ASCII characters::" msgstr "非 ASCII 文字を使った例::" -#: ../../library/email.compat32-message.rst:415 msgid "" "msg.add_header('Content-Disposition', 'attachment',\n" " filename=('iso-8859-1', '', 'Fußballer.ppt'))" msgstr "" +"msg.add_header('Content-Disposition', 'attachment',\n" +" filename=('iso-8859-1', '', 'Fußballer.ppt'))" #: ../../library/email.compat32-message.rst:418 msgid "Which produces ::" msgstr "は、以下のようになります ::" -#: ../../library/email.compat32-message.rst:420 msgid "" "Content-Disposition: attachment; filename*=\"iso-8859-1''Fu%DFballer.ppt\"" msgstr "" +"Content-Disposition: attachment; filename*=\"iso-8859-1''Fu%DFballer.ppt\"" #: ../../library/email.compat32-message.rst:425 msgid "" @@ -741,24 +865,26 @@ msgstr "" "た場合に返すオブジェクトです。オプション引数 *header* には :mailheader:" "`Content-Type` のかわりに検索すべきヘッダを指定します。" -#: ../../library/email.compat32-message.rst:488 -#: ../../library/email.compat32-message.rst:526 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by the *params* property of the individual " "header objects returned by the header access methods." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、ヘッダーへのアクセス用メソッ" +"ドが返す個々のヘッダーオブジェクトの *params* プロパティがこの機能を置き換え" +"ています。" -#: ../../library/email.compat32-message.rst:496 msgid "" "Return the value of the :mailheader:`Content-Type` header's parameter " "*param* as a string. If the message has no :mailheader:`Content-Type` " "header or if there is no such parameter, then *failobj* is returned " "(defaults to ``None``)." msgstr "" -"メッセージの :mailheader:`Content-Type` ヘッダ中のパラメータ *param* を文字列" -"として返します。そのメッセージ中に :mailheader:`Content-Type` ヘッダが存在し" -"なかった場合、 *failobj* (デフォルトは ``None``) が返されます。" +":mailheader:`Content-Type` ヘッダーのパラメータ *param* の値を文字列で返しま" +"す。\n" +"メッセージに :mailheader:`Content-Type` ヘッダーがない場合、または指定された" +"パラメータがない場合は *failobj* (デフォルトは ``None``) を返します。" #: ../../library/email.compat32-message.rst:501 msgid "" @@ -768,7 +894,6 @@ msgstr "" "オプション引数 *header* が与えられた場合、 :mailheader:`Content-Type` のかわ" "りにそのヘッダが使用されます。" -#: ../../library/email.compat32-message.rst:504 msgid "" "Parameter keys are always compared case insensitively. The return value can " "either be a string, or a 3-tuple if the parameter was :rfc:`2231` encoded. " @@ -777,12 +902,15 @@ msgid "" "``None``, in which case you should consider ``VALUE`` to be encoded in the " "``us-ascii`` charset. You can usually ignore ``LANGUAGE``." msgstr "" -"パラメータのキー比較は常に大文字小文字を区別しません。返り値は文字列か 3 要素" -"のタプルで、タプルになるのはパラメータが :rfc:`2231` エンコードされている場合" -"です。3 要素タプルの場合、各要素の値は ``(CHARSET, LANGUAGE, VALUE)`` の形式" -"になっています。 ``CHARSET`` と ``LAGUAGE`` は ``None`` になることがあり、そ" -"の場合 ``VALUE`` は ``us-ascii`` 文字セットでエンコードされているとみなさなけ" -"ればならないので注意してください。普段は ``LANGUAGE`` を無視できます。" +"パラメータのキー比較は常に大文字小文字を区別しません。\n" +"返り値は文字列か 3 要素のタプルで、タプルになるのはパラメータが :rfc:`2231` " +"エンコードされている場合です。\n" +"3 要素タプルの場合、各要素の値は ``(CHARSET, LANGUAGE, VALUE)`` の形式になっ" +"ています。\n" +"``CHARSET`` と ``LANGUAGE`` は ``None`` になることがあり、その場合 ``VALUE`` " +"は ``us-ascii`` 文字セットでエンコードされているとみなさなければならないので" +"注意してください。\n" +"普段は ``LANGUAGE`` を無視できます。" #: ../../library/email.compat32-message.rst:512 msgid "" @@ -799,11 +927,12 @@ msgstr "" "は適切にデコードされた Unicode 文字列を返し、そうでない場合は unquote された" "元の文字列を返します。たとえば::" -#: ../../library/email.compat32-message.rst:519 msgid "" "rawparam = msg.get_param('foo')\n" "param = email.utils.collapse_rfc2231_value(rawparam)" msgstr "" +"rawparam = msg.get_param('foo')\n" +"param = email.utils.collapse_rfc2231_value(rawparam)" #: ../../library/email.compat32-message.rst:522 msgid "" @@ -829,15 +958,15 @@ msgstr "" "合、 :rfc:`2045` にしたがいこの値には :mimetype:`text/plain` が設定され、新し" "いパラメータ値が末尾に追加されます。" -#: ../../library/email.compat32-message.rst:541 msgid "" "Optional *header* specifies an alternative header to :mailheader:`Content-" "Type`, and all parameters will be quoted as necessary unless optional " "*requote* is ``False`` (the default is ``True``)." msgstr "" -"オプション引数 *header* が与えられた場合、 :mailheader:`Content-Type` のかわ" -"りにそのヘッダが使用されます。オプション引数 *requote* が ``False`` でない限" -"り、この値は quote されます (デフォルトは ``True``)。" +"オプションの *header* は、:mailheader:`Content-Type` の代わりに使うヘッダーを" +"指定します。\n" +"オプションの *requote* が ``False`` でない限り、すべてのパラメータは必要に応" +"じて引用符で囲まれます (*requote* のデフォルトは ``True`` です)。" #: ../../library/email.compat32-message.rst:545 msgid "" @@ -851,12 +980,14 @@ msgstr "" "すが、デフォルトではこれは空文字列となります。 *charset* と *language* はどち" "らも文字列である必要があります。" -#: ../../library/email.compat32-message.rst:550 msgid "" "If *replace* is ``False`` (the default) the header is moved to the end of " "the list of headers. If *replace* is ``True``, the header will be updated " "in place." msgstr "" +"*replace* が ``False`` (デフォルト) の場合、ヘッダーはヘッダー一覧の末尾に移" +"動します。\n" +"*replace* が ``True`` の場合は、元の位置で更新されます。" #: ../../library/email.compat32-message.rst:554 msgid "``replace`` keyword was added." @@ -908,11 +1039,13 @@ msgstr "" "りにそのヘッダが使用されます。 :mailheader:`Content-Type` ヘッダが設定される" "場合には、 :mailheader:`MIME-Version` ヘッダも同時に付加されます。" -#: ../../library/email.compat32-message.rst:581 msgid "" "This is a legacy method. On the :class:`~email.message.EmailMessage` class " "its functionality is replaced by the ``make_`` and ``add_`` methods." msgstr "" +"これは従来の API のメソッドです。\n" +":class:`~email.message.EmailMessage` クラスでは、``make_`` と ``add_`` メソッ" +"ドがこの機能を置き換えています。" #: ../../library/email.compat32-message.rst:588 msgid "" @@ -953,7 +1086,6 @@ msgstr "" "quote します。そのメッセージが :mailheader:`Content-Type` ヘッダを含んでいな" "い場合、 :exc:`~email.errors.HeaderParseError` が発生します。" -#: ../../library/email.compat32-message.rst:612 msgid "" "Note that using this method is subtly different than deleting the old :" "mailheader:`Content-Type` header and adding a new one with the new boundary " @@ -964,20 +1096,22 @@ msgid "" msgstr "" "注意: このメソッドを使うのは、古い :mailheader:`Content-Type` ヘッダを削除し" "て新しい boundary をもったヘッダを :meth:`add_header` で足すのとは少し違いま" -"す。 :meth:`set_boundary` は一連のヘッダ中での :mailheader:`Content-Type` " -"ヘッダの位置を保つからです。しかし、これは元の :mailheader:`Content-Type` " -"ヘッダ中に存在していた連続する行の順番までは *保ちません* 。" +"す。\n" +":meth:`set_boundary` は一連のヘッダ中での :mailheader:`Content-Type` ヘッダの" +"位置を保つからです。\n" +"しかし、これは元の :mailheader:`Content-Type` ヘッダ中に存在していた継続行は " +"*保持しません* 。" -#: ../../library/email.compat32-message.rst:622 msgid "" "Return the ``charset`` parameter of the :mailheader:`Content-Type` header, " "coerced to lower case. If there is no :mailheader:`Content-Type` header, or " "if that header has no ``charset`` parameter, *failobj* is returned." msgstr "" "そのメッセージ中の :mailheader:`Content-Type` ヘッダにある、 ``charset`` パラ" -"メータの値を返します。値はすべて小文字に変換されます。メッセージ中に :" -"mailheader:`Content-Type` がなかったり、このヘッダ中に ``charaset`` パラメー" -"タがない場合には *failobj* が返されます。" +"メータの値を返します。\n" +"値はすべて小文字に変換されます。\n" +"メッセージ中に :mailheader:`Content-Type` がなかったり、このヘッダ中に " +"``charset`` パラメータがない場合には *failobj* が返されます。" #: ../../library/email.compat32-message.rst:626 msgid "" @@ -1014,13 +1148,16 @@ msgstr "" "あるいは MIME maintype が :mimetype:`text` でないいずれかの場合には、リストの" "要素として *failobj* が返されます。" -#: ../../library/email.compat32-message.rst:646 msgid "" "Return the lowercased value (without parameters) of the message's :" "mailheader:`Content-Disposition` header if it has one, or ``None``. The " "possible values for this method are *inline*, *attachment* or ``None`` if " "the message follows :rfc:`2183`." msgstr "" +"メッセージに :mailheader:`Content-Disposition` ヘッダーがあれば、パラメータを" +"除いた値を小文字で返し、なければ ``None`` を返します。\n" +"メッセージが :rfc:`2183` に準拠していれば、戻り値は *inline*、*attachment*、" +"``None`` のいずれかです。" #: ../../library/email.compat32-message.rst:655 msgid "" @@ -1043,7 +1180,6 @@ msgstr "" "以下の例は、 multipart メッセージのすべての part において、その MIME タイプを" "表示していくものです。 :" -#: ../../library/email.compat32-message.rst:674 msgid "" ">>> for part in msg.walk():\n" "... print(part.get_content_type())\n" @@ -1055,16 +1191,29 @@ msgid "" "message/rfc822\n" "text/plain" msgstr "" +">>> for part in msg.walk():\n" +"... print(part.get_content_type())\n" +"multipart/report\n" +"text/plain\n" +"message/delivery-status\n" +"text/plain\n" +"text/plain\n" +"message/rfc822\n" +"text/plain" -#: ../../library/email.compat32-message.rst:686 msgid "" "``walk`` iterates over the subparts of any part where :meth:`is_multipart` " "returns ``True``, even though ``msg.get_content_maintype() == 'multipart'`` " "may return ``False``. We can see this in our example by making use of the " "``_structure`` debug helper function:" msgstr "" +"``walk()`` は、:meth:`is_multipart` が ``True`` を返すパートのサブパートを反" +"復処理します。\n" +"``msg.get_content_maintype() == 'multipart'`` が ``False`` を返す場合も同様で" +"す。\n" +"デバッグ用の補助関数 ``_structure()`` を使うと、この例でその様子を確認できま" +"す。" -#: ../../library/email.compat32-message.rst:692 msgid "" ">>> for part in msg.walk():\n" "... print(part.get_content_maintype() == 'multipart',\n" @@ -1085,13 +1234,34 @@ msgid "" " message/rfc822\n" " text/plain" msgstr "" +">>> for part in msg.walk():\n" +"... print(part.get_content_maintype() == 'multipart',\n" +"... part.is_multipart())\n" +"True True\n" +"False False\n" +"False True\n" +"False False\n" +"False False\n" +"False True\n" +"False False\n" +">>> _structure(msg)\n" +"multipart/report\n" +" text/plain\n" +" message/delivery-status\n" +" text/plain\n" +" text/plain\n" +" message/rfc822\n" +" text/plain" -#: ../../library/email.compat32-message.rst:713 msgid "" "Here the ``message`` parts are not ``multiparts``, but they do contain " "subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends into the " "subparts." msgstr "" +"ここでは ``message`` パートは ``multipart`` ではありませんが、サブパートを含" +"んでいます。\n" +"``is_multipart()`` は ``True`` を返し、``walk()`` はサブパートの中へ進みま" +"す。" #: ../../library/email.compat32-message.rst:718 msgid "" diff --git a/library/email.contentmanager.po b/library/email.contentmanager.po index c9a5615c2..a796e9cd9 100644 --- a/library/email.contentmanager.po +++ b/library/email.contentmanager.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.contentmanager.rst:2 msgid ":mod:`!email.contentmanager`: Managing MIME Content" -msgstr "" +msgstr ":mod:`!email.contentmanager`: MIME コンテンツの管理" #: ../../library/email.contentmanager.rst:7 msgid "**Source code:** :source:`Lib/email/contentmanager.py`" @@ -34,26 +33,32 @@ msgstr "**ソースコード:** :source:`Lib/email/contentmanager.py`" msgid "[1]_" msgstr "[1]_" -#: ../../library/email.contentmanager.rst:16 msgid "" "Base class for content managers. Provides the standard registry mechanisms " "to register converters between MIME content and other representations, as " "well as the ``get_content`` and ``set_content`` dispatch methods." msgstr "" +"コンテンツマネージャーの基底クラスです。\n" +"MIME コンテンツと他の表現との変換処理を登録する標準のレジストリ機構と、処理を" +"振り分ける ``get_content()``、``set_content()`` メソッドを提供します。" -#: ../../library/email.contentmanager.rst:23 msgid "" "Look up a handler function based on the ``mimetype`` of *msg* (see next " "paragraph), call it, passing through all arguments, and return the result of " "the call. The expectation is that the handler will extract the payload from " "*msg* and return an object that encodes information about the extracted data." msgstr "" +"*msg* の ``mimetype`` に基づいてハンドラー関数を探し (次の段落を参照)、すべて" +"の引数をそのまま渡して呼び出し、その結果を返します。\n" +"ハンドラーは *msg* からペイロードを抽出し、抽出したデータの情報を表すオブジェ" +"クトを返すことを想定しています。" -#: ../../library/email.contentmanager.rst:29 msgid "" "To find the handler, look for the following keys in the registry, stopping " "with the first one found:" msgstr "" +"ハンドラーを見つけるには、レジストリで次のキーを順に探し、最初に見つかったも" +"のを使います。" #: ../../library/email.contentmanager.rst:32 msgid "the string representing the full MIME type (``maintype/subtype``)" @@ -67,13 +72,13 @@ msgstr "``maintype`` を表す文字列" msgid "the empty string" msgstr "空の文字列" -#: ../../library/email.contentmanager.rst:36 msgid "" "If none of these keys produce a handler, raise a :exc:`KeyError` for the " "full MIME type." msgstr "" +"どのキーでもハンドラーが見つからない場合、完全な MIME 型を示す :exc:" +"`KeyError` を送出します。" -#: ../../library/email.contentmanager.rst:42 msgid "" "If the ``maintype`` is ``multipart``, raise a :exc:`TypeError`; otherwise " "look up a handler function based on the type of *obj* (see next paragraph), " @@ -83,13 +88,21 @@ msgid "" "making other changes to *msg* as well, such as adding various MIME headers " "to encode information needed to interpret the stored data." msgstr "" +"``maintype`` が ``multipart`` の場合は :exc:`TypeError` を送出します。\n" +"そうでなければ、*obj* の型に基づいてハンドラー関数を探し (次の段落を参照)、" +"*msg* の :meth:`~email.message.EmailMessage.clear_content` を呼び出してから、" +"すべての引数をそのまま渡してハンドラー関数を呼び出します。\n" +"ハンドラーは *obj* を変換して *msg* に格納することを想定しています。\n" +"格納したデータの解釈に必要な情報を表す MIME ヘッダーを追加するなど、*msg* に" +"他の変更を加えることもあります。" -#: ../../library/email.contentmanager.rst:51 msgid "" "To find the handler, obtain the type of *obj* (``typ = type(obj)``), and " "look for the following keys in the registry, stopping with the first one " "found:" msgstr "" +"ハンドラーを見つけるには、*obj* の型を取得し (``typ = type(obj)``)、レジスト" +"リで次のキーを順に探して最初に見つかったものを使います。" #: ../../library/email.contentmanager.rst:55 msgid "the type itself (``typ``)" @@ -101,15 +114,12 @@ msgid "" "__qualname__``)." msgstr "型の完全修飾名 (``typ.__module__ + '.' + typ.__qualname__``)." -#: ../../library/email.contentmanager.rst:58 msgid "the type's :attr:`qualname ` (``typ.__qualname__``)" -msgstr "" +msgstr "型の :attr:`qualname ` (``typ.__qualname__``)" -#: ../../library/email.contentmanager.rst:59 msgid "the type's :attr:`name ` (``typ.__name__``)." -msgstr "" +msgstr "型の :attr:`name ` (``typ.__name__``)。" -#: ../../library/email.contentmanager.rst:61 msgid "" "If none of the above match, repeat all of the checks above for each of the " "types in the :term:`MRO` (:attr:`typ.__mro__ `). Finally, if " @@ -117,6 +127,12 @@ msgid "" "there is no handler for ``None``, raise a :exc:`KeyError` for the fully " "qualified name of the type." msgstr "" +"いずれも一致しない場合、:term:`MRO` (:attr:`typ.__mro__ `) 内の" +"各型について、上記の確認をすべて繰り返します。\n" +"それでもハンドラーが見つからない場合、最後にキー ``None`` のハンドラーを探し" +"ます。\n" +"``None`` のハンドラーもなければ、型の完全修飾名を示す :exc:`KeyError` を送出" +"します。" #: ../../library/email.contentmanager.rst:68 msgid "" @@ -124,32 +140,36 @@ msgid "" "also :class:`.MIMEPart`)." msgstr "" -#: ../../library/email.contentmanager.rst:74 msgid "" "Record the function *handler* as the handler for *key*. For the possible " "values of *key*, see :meth:`get_content`." msgstr "" +"関数 *handler* を *key* のハンドラーとして登録します。\n" +"*key* に指定できる値は :meth:`get_content` を参照してください。" -#: ../../library/email.contentmanager.rst:80 msgid "" "Record *handler* as the function to call when an object of a type matching " "*typekey* is passed to :meth:`set_content`. For the possible values of " "*typekey*, see :meth:`set_content`." msgstr "" +"*typekey* に一致する型のオブジェクトが :meth:`set_content` に渡されたときに呼" +"び出す関数として、*handler* を登録します。\n" +"*typekey* に指定できる値は :meth:`set_content` を参照してください。" -#: ../../library/email.contentmanager.rst:86 msgid "Content Manager Instances" -msgstr "" +msgstr "コンテンツマネージャーのインスタンス" -#: ../../library/email.contentmanager.rst:88 msgid "" "Currently the email package provides only one concrete content manager, :" "data:`raw_data_manager`, although more may be added in the future. :data:" "`raw_data_manager` is the :attr:`~email.policy.EmailPolicy.content_manager` " "provided by :attr:`~email.policy.EmailPolicy` and its derivatives." msgstr "" +"現在、email パッケージが提供する具体的なコンテンツマネージャーは :data:" +"`raw_data_manager` だけですが、将来さらに追加される可能性があります。\n" +":data:`raw_data_manager` は :attr:`~email.policy.EmailPolicy` とその派生クラ" +"スが提供する :attr:`~email.policy.EmailPolicy.content_manager` です。" -#: ../../library/email.contentmanager.rst:97 msgid "" "This content manager provides only a minimum interface beyond that provided " "by :class:`~email.message.Message` itself: it deals only with text, raw " @@ -161,6 +181,16 @@ msgid "" "and it enables the use of the various ``add_`` methods, thereby simplifying " "the creation of multipart messages." msgstr "" +"このコンテンツマネージャーが :class:`~email.message.Message` 自体に加えて提供" +"するインターフェースは最小限で、テキスト、生のバイト列、:class:`~email." +"message.Message` オブジェクトだけを扱います。\n" +"それでも、基本の API と比べて大きな利点があります。\n" +"テキストパートの ``get_content()`` は文字列を返すため、アプリケーションで手動" +"デコードする必要がありません。\n" +"``set_content()`` には、パートに追加するヘッダーやコンテンツ転送エンコーディ" +"ングを制御する豊富なオプションがあります。\n" +"また、各種の ``add_`` メソッドを利用でき、マルチパートメッセージを簡単に作成" +"できます。" #: ../../library/email.contentmanager.rst:109 msgid "" @@ -172,44 +202,55 @@ msgid "" "to a string. The default error handler is ``replace``." msgstr "" -#: ../../library/email.contentmanager.rst:128 msgid "Add headers and payload to *msg*:" -msgstr "" +msgstr "*msg* にヘッダーとペイロードを追加します。" -#: ../../library/email.contentmanager.rst:130 msgid "" "Add a :mailheader:`Content-Type` header with a ``maintype/subtype`` value." msgstr "" +"``maintype/subtype`` の値を持つ :mailheader:`Content-Type` ヘッダーを追加しま" +"す。" -#: ../../library/email.contentmanager.rst:133 msgid "" "For ``str``, set the MIME ``maintype`` to ``text``, and set the subtype to " "*subtype* if it is specified, or ``plain`` if it is not." msgstr "" +"``str`` の場合、MIME の ``maintype`` を ``text`` に設定します。\n" +"サブタイプは *subtype* が指定されていればその値に、そうでなければ ``plain`` " +"に設定します。" -#: ../../library/email.contentmanager.rst:135 msgid "" "For ``bytes``, use the specified *maintype* and *subtype*, or raise a :exc:" "`TypeError` if they are not specified." msgstr "" +"``bytes`` の場合、指定された *maintype* と *subtype* を使います。\n" +"指定されていなければ :exc:`TypeError` を送出します。" -#: ../../library/email.contentmanager.rst:137 msgid "" "For :class:`~email.message.EmailMessage` objects, set the maintype to " "``message``, and set the subtype to *subtype* if it is specified or " "``rfc822`` if it is not. If *subtype* is ``partial``, raise an error " "(``bytes`` objects must be used to construct ``message/partial`` parts)." msgstr "" +":class:`~email.message.EmailMessage` オブジェクトの場合、メインタイプを " +"``message`` に設定します。\n" +"サブタイプは *subtype* が指定されていればその値に、そうでなければ ``rfc822`` " +"に設定します。\n" +"*subtype* が ``partial`` の場合はエラーを送出します (``message/partial`` パー" +"トの作成には ``bytes`` オブジェクトを使う必要があります)。" -#: ../../library/email.contentmanager.rst:143 msgid "" "If *charset* is provided (which is valid only for ``str``), encode the " "string to bytes using the specified character set. The default is " "``utf-8``. If the specified *charset* is a known alias for a standard MIME " "charset name, use the standard charset instead." msgstr "" +"*charset* が指定されている場合 (``str`` でのみ有効)、指定された文字セットで文" +"字列をバイト列にエンコードします。\n" +"デフォルトは ``utf-8`` です。\n" +"指定された *charset* が標準の MIME 文字セット名の既知の別名であれば、標準の文" +"字セット名を使います。" -#: ../../library/email.contentmanager.rst:148 msgid "" "If *cte* is set, encode the payload using the specified content transfer " "encoding, and set the :mailheader:`Content-Transfer-Encoding` header to that " @@ -218,8 +259,14 @@ msgid "" "specified encoding (for example, specifying a *cte* of ``7bit`` for an input " "that contains non-ASCII values), raise a :exc:`ValueError`." msgstr "" +"*cte* が設定されている場合、指定されたコンテンツ転送エンコーディングでペイ" +"ロードをエンコードし、:mailheader:`Content-Transfer-Encoding` ヘッダーをその" +"値に設定します。\n" +"*cte* に指定できる値は ``quoted-printable``、``base64``、``7bit``、``8bit``、" +"``binary`` です。\n" +"非 ASCII 値を含む入力に *cte* として ``7bit`` を指定するなど、入力を指定され" +"た形式でエンコードできない場合は :exc:`ValueError` を送出します。" -#: ../../library/email.contentmanager.rst:156 msgid "" "For ``str`` objects, if *cte* is not set use heuristics to determine the " "most compact encoding. Prior to encoding, :meth:`str.splitlines` is used to " @@ -227,14 +274,19 @@ msgid "" "terminated by the current policy's :data:`~email.policy.Policy.linesep` " "property (even if the original string did not end with one)." msgstr "" +"``str`` オブジェクトで *cte* を設定していない場合、ヒューリスティックによって" +"最もコンパクトなエンコーディングを決めます。\n" +"エンコード前に :meth:`str.splitlines` ですべての行境界を正規化し、ペイロード" +"の各行が現在のポリシーの :data:`~email.policy.Policy.linesep` プロパティで終" +"わるようにします (元の文字列が改行で終わっていなくても同様です)。" -#: ../../library/email.contentmanager.rst:162 msgid "" "For ``bytes`` objects, *cte* is taken to be base64 if not set, and the " "aforementioned newline translation is not performed." msgstr "" +"``bytes`` オブジェクトの場合、*cte* を設定していなければ base64 とみなし、上" +"記の改行変換は行いません。" -#: ../../library/email.contentmanager.rst:164 msgid "" "For :class:`~email.message.EmailMessage`, per :rfc:`2046`, raise an error if " "a *cte* of ``quoted-printable`` or ``base64`` is requested for *subtype* " @@ -242,15 +294,22 @@ msgid "" "body``. For ``message/rfc822``, use ``8bit`` if *cte* is not specified. " "For all other values of *subtype*, use ``7bit``." msgstr "" +":class:`~email.message.EmailMessage` の場合、:rfc:`2046` に従い、*subtype* " +"が ``rfc822`` で *cte* に ``quoted-printable`` または ``base64`` を指定した場" +"合と、*subtype* が ``external-body`` で *cte* に ``7bit`` 以外を指定した場合" +"にはエラーを送出します。\n" +"``message/rfc822`` で *cte* が指定されていなければ ``8bit`` を使います。\n" +"それ以外の *subtype* では ``7bit`` を使います。" -#: ../../library/email.contentmanager.rst:171 msgid "" "A *cte* of ``binary`` does not actually work correctly yet. The " "``EmailMessage`` object as modified by ``set_content`` is correct, but :" "class:`~email.generator.BytesGenerator` does not serialize it correctly." msgstr "" +"*cte* の ``binary`` は、まだ正しく動作しません。\n" +"``set_content()`` によって変更された ``EmailMessage`` オブジェクトは正しいも" +"のの、:class:`~email.generator.BytesGenerator` が正しく直列化しません。" -#: ../../library/email.contentmanager.rst:176 msgid "" "If *disposition* is set, use it as the value of the :mailheader:`Content-" "Disposition` header. If not specified, and *filename* is specified, add the " @@ -258,38 +317,52 @@ msgid "" "*filename* is also not specified, do not add the header. The only valid " "values for *disposition* are ``attachment`` and ``inline``." msgstr "" +"*disposition* が設定されていれば、:mailheader:`Content-Disposition` ヘッダー" +"の値として使います。\n" +"指定されておらず、*filename* が指定されている場合は、値を ``attachment`` とし" +"てヘッダーを追加します。\n" +"*disposition* も *filename* も指定されていなければ、ヘッダーは追加しませ" +"ん。\n" +"*disposition* に有効な値は ``attachment`` と ``inline`` だけです。" -#: ../../library/email.contentmanager.rst:183 msgid "" "If *filename* is specified, use it as the value of the ``filename`` " "parameter of the :mailheader:`Content-Disposition` header." msgstr "" +"*filename* が指定されている場合、:mailheader:`Content-Disposition` ヘッダー" +"の ``filename`` パラメータの値として使います。" -#: ../../library/email.contentmanager.rst:186 msgid "" "If *cid* is specified, add a :mailheader:`Content-ID` header with *cid* as " "its value." msgstr "" +"*cid* が指定されている場合、その値を持つ :mailheader:`Content-ID` ヘッダーを" +"追加します。" -#: ../../library/email.contentmanager.rst:189 msgid "" "If *params* is specified, iterate its ``items`` method and use the resulting " "``(key, value)`` pairs to set additional parameters on the :mailheader:" "`Content-Type` header." msgstr "" +"*params* が指定されている場合、その ``items()`` メソッドの結果を反復処理し、" +"得られた ``(key, value)`` ペアを使って :mailheader:`Content-Type` ヘッダーに" +"追加のパラメータを設定します。" -#: ../../library/email.contentmanager.rst:193 msgid "" "If *headers* is specified and is a list of strings of the form ``headername: " "headervalue`` or a list of ``header`` objects (distinguished from strings by " "having a ``name`` attribute), add the headers to *msg*." msgstr "" +"*headers* が指定されていて、``headername: headervalue`` 形式の文字列のリス" +"ト、または ``header`` オブジェクトのリスト (``name`` 属性を持つことで文字列と" +"区別します) である場合、そのヘッダーを *msg* に追加します。" #: ../../library/email.contentmanager.rst:200 msgid "Footnotes" msgstr "脚注" -#: ../../library/email.contentmanager.rst:201 msgid "" "Originally added in 3.4 as a :term:`provisional module `" msgstr "" +"当初は 3.4 で :term:`暫定モジュール ` として追加されまし" +"た。" diff --git a/library/email.encoders.po b/library/email.encoders.po index 554a506ab..9adc5bb49 100644 --- a/library/email.encoders.po +++ b/library/email.encoders.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.encoders.rst:2 @@ -70,7 +70,6 @@ msgstr "" "はとくにバイナリデータを含んだ :mimetype:`image/\\*` や :mimetype:`text/\\*` " "タイプのメッセージで必要です。" -#: ../../library/email.encoders.rst:27 msgid "" "The :mod:`email` package provides some convenient encoders in its :mod:`!" "encoders` module. These encoders are actually used by the :class:`~email." @@ -81,6 +80,17 @@ msgid "" "They should also set the :mailheader:`Content-Transfer-Encoding` header as " "appropriate." msgstr "" +":mod:`email` パッケージは :mod:`!encoders` モジュールで便利なエンコーダーをい" +"くつか提供しています。\n" +"これらは :class:`~email.mime.audio.MIMEAudio` と :class:`~email.mime.image." +"MIMEImage` のコンストラクタでも、デフォルトのエンコーディングを行うために使わ" +"れています。\n" +"すべてのエンコーダー関数は、エンコードするメッセージオブジェクトを唯一の引数" +"として受け取ります。\n" +"通常はペイロードを取り出してエンコードし、その新しい値をペイロードに設定し直" +"します。\n" +"また、:mailheader:`Content-Transfer-Encoding` ヘッダーも適切に設定する必要が" +"あります。" #: ../../library/email.encoders.rst:35 msgid "" diff --git a/library/email.errors.po b/library/email.errors.po index 750dea8fa..e3d8c0f0d 100644 --- a/library/email.errors.po +++ b/library/email.errors.po @@ -16,25 +16,24 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.errors.rst:2 msgid ":mod:`!email.errors`: Exception and Defect classes" -msgstr "" +msgstr ":mod:`!email.errors`: 例外クラスと障害クラス" #: ../../library/email.errors.rst:7 msgid "**Source code:** :source:`Lib/email/errors.py`" msgstr "**ソースコード:** :source:`Lib/email/errors.py`" -#: ../../library/email.errors.rst:11 msgid "" "The following exception classes are defined in the :mod:`!email.errors` " "module:" msgstr "" +":mod:`!email.errors` モジュールでは、以下の例外クラスが定義されています。" #: ../../library/email.errors.rst:16 msgid "" @@ -46,14 +45,15 @@ msgstr "" "は標準の :exc:`Exception` クラスから派生しており、追加のメソッドは定義されて" "いません。" -#: ../../library/email.errors.rst:23 msgid "" "This is the base class for exceptions raised by the :class:`~email.parser." "Parser` class. It is derived from :exc:`MessageError`. This class is also " "used internally by the parser used by :mod:`~email.headerregistry`." msgstr "" +":class:`~email.parser.Parser` クラスが送出する例外の基底クラスで、:exc:" +"`MessageError` から派生しています。\n" +":mod:`~email.headerregistry` のパーサーでも内部的に使われています。" -#: ../../library/email.errors.rst:31 msgid "" "Raised under some error conditions when parsing the :rfc:`5322` headers of a " "message, this class is derived from :exc:`MessageParseError`. The :meth:" @@ -64,12 +64,19 @@ msgid "" "header (that is, there is what is supposed to be a continuation line that " "has no leading whitespace and looks like a header)." msgstr "" +"メッセージの :rfc:`5322` ヘッダーを解析する際の、一部のエラー条件で送出されま" +"す。\n" +"このクラスは :exc:`MessageParseError` から派生しています。\n" +":meth:`~email.message.EmailMessage.set_boundary` は、呼び出し時にコンテントタ" +"イプが不明な場合にこのエラーを送出します。\n" +":class:`~email.header.Header` は、一部の base64 デコードエラーや、別のヘッ" +"ダーが埋め込まれているように見えるヘッダーを作成しようとした場合にこのエラー" +"を送出することがあります (継続行のはずの行の先頭に空白がなく、ヘッダーのよう" +"に見える場合です)。" -#: ../../library/email.errors.rst:43 msgid "Deprecated and no longer used." -msgstr "" +msgstr "非推奨となっており、現在は使われていません。" -#: ../../library/email.errors.rst:48 msgid "" "Raised if the :meth:`~email.message.Message.attach` method is called on an " "instance of a class derived from :class:`~email.mime.nonmultipart." @@ -77,23 +84,31 @@ msgid "" "`MultipartConversionError` multiply inherits from :exc:`MessageError` and " "the built-in :exc:`TypeError`." msgstr "" +":class:`~email.mime.nonmultipart.MIMENonMultipart` から派生したクラス (:" +"class:`~email.mime.image.MIMEImage` など) のインスタンスで :meth:`~email." +"message.Message.attach` を呼び出すと送出されます。\n" +":exc:`MultipartConversionError` は :exc:`MessageError` と組み込みの :exc:" +"`TypeError` を多重継承しています。" -#: ../../library/email.errors.rst:58 msgid "" "Raised when an error occurs when the :mod:`~email.generator` outputs headers." msgstr "" +":mod:`~email.generator` がヘッダーを出力するときにエラーが発生すると送出され" +"ます。" -#: ../../library/email.errors.rst:64 msgid "" "This is the base class for all defects found when parsing email messages. It " "is derived from :exc:`ValueError`." msgstr "" +"電子メールメッセージの解析中に見つかったすべての障害の基底クラスです。\n" +":exc:`ValueError` から派生しています。" -#: ../../library/email.errors.rst:69 msgid "" "This is the base class for all defects found when parsing email headers. It " "is derived from :exc:`MessageDefect`." msgstr "" +"電子メールヘッダーの解析中に見つかったすべての障害の基底クラスです。\n" +":exc:`MessageDefect` から派生しています。" #: ../../library/email.errors.rst:72 msgid "" @@ -116,79 +131,90 @@ msgid "" msgstr "" "すべての障害クラスは :class:`email.errors.MessageDefect` のサブクラスです。" -#: ../../library/email.errors.rst:82 msgid "" "A message claimed to be a multipart, but had no :mimetype:`boundary` " "parameter." msgstr "" +"メッセージはマルチパートと宣言されていますが、:mimetype:`boundary` パラメータ" +"がありません。" -#: ../../library/email.errors.rst:87 msgid "" "The start boundary claimed in the :mailheader:`Content-Type` header was " "never found." msgstr "" +":mailheader:`Content-Type` ヘッダーで宣言された開始境界が見つかりませんでし" +"た。" -#: ../../library/email.errors.rst:92 msgid "" "A start boundary was found, but no corresponding close boundary was ever " "found." -msgstr "" +msgstr "開始境界は見つかりましたが、対応する終了境界が見つかりませんでした。" -#: ../../library/email.errors.rst:99 msgid "The message had a continuation line as its first header line." -msgstr "" +msgstr "メッセージの最初のヘッダー行が継続行になっています。" -#: ../../library/email.errors.rst:103 msgid "A \"Unix From\" header was found in the middle of a header block." -msgstr "" +msgstr "ヘッダーブロックの途中に \"Unix From\" ヘッダーが見つかりました。" -#: ../../library/email.errors.rst:107 msgid "" "A line was found while parsing headers that had no leading white space but " "contained no ':'. Parsing continues assuming that the line represents the " "first line of the body." msgstr "" +"ヘッダーの解析中に、先頭に空白がなく、コロンも含まない行が見つかりました。\n" +"その行を本文の最初の行とみなして解析を続けます。" -#: ../../library/email.errors.rst:115 msgid "" "A header was found that was missing a colon, or was otherwise malformed." -msgstr "" +msgstr "コロンがないなど、形式が不正なヘッダーが見つかりました。" -#: ../../library/email.errors.rst:117 msgid "This defect has not been used for several Python versions." -msgstr "この欠陥が使われていないPythonバージョンがいくつかあります。" +msgstr "この障害は、ここ数バージョンの Python では使われていません。" -#: ../../library/email.errors.rst:122 msgid "" "A message claimed to be a :mimetype:`multipart`, but no subparts were found. " "Note that when a message has this defect, its :meth:`~email.message.Message." "is_multipart` method may return ``False`` even though its content type " "claims to be :mimetype:`multipart`." msgstr "" +"メッセージは :mimetype:`multipart` と宣言されていますが、サブパートが見つかり" +"ませんでした。\n" +"この障害があるメッセージでは、コンテントタイプが :mimetype:`multipart` であっ" +"ても :meth:`~email.message.Message.is_multipart` が ``False`` を返すことがあ" +"ります。" -#: ../../library/email.errors.rst:129 msgid "" "When decoding a block of base64 encoded bytes, the padding was not correct. " "Enough padding is added to perform the decode, but the resulting decoded " "bytes may be invalid." msgstr "" +"base64 でエンコードされたバイト列のブロックをデコードするときに、パディングの" +"不正が見つかりました。\n" +"デコードに必要なパディングは補われますが、結果のバイト列が不正になる可能性が" +"あります。" -#: ../../library/email.errors.rst:135 msgid "" "When decoding a block of base64 encoded bytes, characters outside the base64 " "alphabet were encountered. The characters are ignored, but the resulting " "decoded bytes may be invalid." msgstr "" +"base64 でエンコードされたバイト列のブロックをデコードするときに、base64 の文" +"字集合にない文字が見つかりました。\n" +"その文字は無視されますが、結果のバイト列が不正になる可能性があります。" -#: ../../library/email.errors.rst:141 msgid "" "When decoding a block of base64 encoded bytes, the number of non-padding " "base64 characters was invalid (1 more than a multiple of 4). The encoded " "block was kept as-is." msgstr "" +"base64 でエンコードされたバイト列のブロックをデコードするときに、パディングを" +"除く base64 文字の数が不正でした (4 の倍数より 1 多い数でした)。\n" +"エンコードされたブロックはそのまま保持されます。" -#: ../../library/email.errors.rst:147 msgid "" "When decoding an invalid or unparsable date field. The original value is " "kept as-is." msgstr "" +"不正な日付フィールド、または解析できない日付フィールドをデコードするときに発" +"生します。\n" +"元の値はそのまま保持されます。" diff --git a/library/email.examples.po b/library/email.examples.po index ce9f28bb4..3eee3e3b7 100644 --- a/library/email.examples.po +++ b/library/email.examples.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.examples.rst:4 @@ -35,13 +35,13 @@ msgstr "" "信するいくつかの例を紹介します。より複雑な MIME メッセージについても扱いま" "す。" -#: ../../library/email.examples.rst:9 msgid "" "First, let's see how to create and send a simple text message (both the text " "content and the addresses may contain Unicode characters):" msgstr "" +"まず、単純なテキストメッセージを作成して送信する方法を見てみましょう (テキス" +"トの内容にもアドレスにも Unicode 文字を含められます)。" -#: ../../library/email.examples.rst:12 msgid "" "# Import smtplib for the actual sending function\n" "import smtplib\n" @@ -66,6 +66,29 @@ msgid "" "s.send_message(msg)\n" "s.quit()\n" msgstr "" +"# 実際の送信に使う smtplib をインポートします\n" +"import smtplib\n" +"\n" +"# 必要な email モジュールをインポートします\n" +"from email.message import EmailMessage\n" +"\n" +"# textfile に名前が入っているプレーンテキストファイルを読み込み用に開きま" +"す。\n" +"with open(textfile) as fp:\n" +" # text/plain メッセージを作成します\n" +" msg = EmailMessage()\n" +" msg.set_content(fp.read())\n" +"\n" +"# me == 送信者のメールアドレス\n" +"# you == 受信者のメールアドレス\n" +"msg['Subject'] = f'The contents of {textfile}'\n" +"msg['From'] = me\n" +"msg['To'] = you\n" +"\n" +"# 自分の SMTP サーバー経由でメッセージを送信します。\n" +"s = smtplib.SMTP('localhost')\n" +"s.send_message(msg)\n" +"s.quit()\n" #: ../../library/email.examples.rst:15 msgid "" @@ -75,7 +98,6 @@ msgstr "" ":rfc:`822` ヘッダーの解析は、 :mod:`~email.parser` モジュールにあるクラスを使" "用することにより、簡単に実現できます:" -#: ../../library/email.examples.rst:18 msgid "" "# Import the email modules we'll need\n" "#from email.parser import BytesParser\n" @@ -103,6 +125,32 @@ msgid "" "print('Recipient username: {}'.format(headers['to'].addresses[0].username))\n" "print('Sender name: {}'.format(headers['from'].addresses[0].display_name))\n" msgstr "" +"# 必要な email モジュールをインポートします\n" +"#from email.parser import BytesParser\n" +"from email.parser import Parser\n" +"from email.policy import default\n" +"\n" +"# 電子メールのヘッダーがファイルにある場合、次の 2 行のコメントを外します:\n" +"# with open(messagefile, 'rb') as fp:\n" +"# headers = BytesParser(policy=default).parse(fp)\n" +"\n" +"# 文字列中のヘッダーを解析する場合 (一般的ではありません) は、次のようにしま" +"す:\n" +"headers = Parser(policy=default).parsestr(\n" +" 'From: Foo Bar \\n'\n" +" 'To: \\n'\n" +" 'Subject: Test message\\n'\n" +" '\\n'\n" +" 'Body would go here\\n')\n" +"\n" +"# これで、辞書としてヘッダーの各項目にアクセスできます:\n" +"print('To: {}'.format(headers['to']))\n" +"print('From: {}'.format(headers['from']))\n" +"print('Subject: {}'.format(headers['subject']))\n" +"\n" +"# アドレスの各部分にもアクセスできます:\n" +"print('Recipient username: {}'.format(headers['to'].addresses[0].username))\n" +"print('Sender name: {}'.format(headers['from'].addresses[0].display_name))\n" #: ../../library/email.examples.rst:21 msgid "" @@ -150,7 +198,6 @@ msgstr "" "つぎはあるディレクトリに含まれている内容全体をひとつの電子メールメッセージと" "して送信するやり方です: [1]_" -#: ../../library/email.examples.rst:30 msgid "" "#!/usr/bin/env python3\n" "\n" @@ -237,6 +284,90 @@ msgid "" "if __name__ == '__main__':\n" " main()\n" msgstr "" +"#!/usr/bin/env python3\n" +"\n" +"\"\"\"ディレクトリの内容を MIME メッセージとして送信します。\"\"\"\n" +"\n" +"import os\n" +"import smtplib\n" +"# ファイル名の拡張子から MIME 型を推測するために使います\n" +"import mimetypes\n" +"\n" +"from argparse import ArgumentParser\n" +"\n" +"from email.message import EmailMessage\n" +"from email.policy import SMTP\n" +"\n" +"\n" +"def main():\n" +" parser = ArgumentParser(description=\"\"\"\\\n" +"Send the contents of a directory as a MIME message.\n" +"Unless the -o option is given, the email is sent by forwarding to your " +"local\n" +"SMTP server, which then does the normal delivery process. Your local " +"machine\n" +"must be running an SMTP server.\n" +"\"\"\")\n" +" parser.add_argument('-d', '--directory',\n" +" help=\"\"\"Mail the contents of the specified " +"directory,\n" +" otherwise use the current directory. Only the " +"regular\n" +" files in the directory are sent, and we don't " +"recurse to\n" +" subdirectories.\"\"\")\n" +" parser.add_argument('-o', '--output',\n" +" metavar='FILE',\n" +" help=\"\"\"Print the composed message to FILE " +"instead of\n" +" sending the message to the SMTP server.\"\"\")\n" +" parser.add_argument('-s', '--sender', required=True,\n" +" help='The value of the From: header (required)')\n" +" parser.add_argument('-r', '--recipient', required=True,\n" +" action='append', metavar='RECIPIENT',\n" +" default=[], dest='recipients',\n" +" help='A To: header value (at least one required)')\n" +" args = parser.parse_args()\n" +" directory = args.directory\n" +" if not directory:\n" +" directory = '.'\n" +" # メッセージを作成します\n" +" msg = EmailMessage()\n" +" msg['Subject'] = f'Contents of directory {os.path.abspath(directory)}'\n" +" msg['To'] = ', '.join(args.recipients)\n" +" msg['From'] = args.sender\n" +" msg.preamble = 'You will not see this in a MIME-aware mail reader.\\n'\n" +"\n" +" for filename in os.listdir(directory):\n" +" path = os.path.join(directory, filename)\n" +" if not os.path.isfile(path):\n" +" continue\n" +" # ファイルの拡張子からコンテントタイプを推測します。\n" +" # エンコーディングは無視しますが、本来は gzip などで圧縮された\n" +" # ファイルのような単純なケースを確認する必要があります。\n" +" ctype, encoding = mimetypes.guess_file_type(path)\n" +" if ctype is None or encoding is not None:\n" +" # 推測できなかったか、ファイルがエンコード (圧縮) されているの" +"で、\n" +" # 汎用のバイナリデータ型を使います。\n" +" ctype = 'application/octet-stream'\n" +" maintype, subtype = ctype.split('/', 1)\n" +" with open(path, 'rb') as fp:\n" +" msg.add_attachment(fp.read(),\n" +" maintype=maintype,\n" +" subtype=subtype,\n" +" filename=filename)\n" +" # メッセージを送信または保存します\n" +" if args.output:\n" +" with open(args.output, 'wb') as fp:\n" +" fp.write(msg.as_bytes(policy=SMTP))\n" +" else:\n" +" with smtplib.SMTP('localhost') as s:\n" +" s.send_message(msg)\n" +"\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" #: ../../library/email.examples.rst:33 msgid "" @@ -246,7 +377,6 @@ msgstr "" "つぎに、上のような MIME メッセージをどうやって展開してひとつのディレクトリ上" "の複数ファイルにするかを示します:" -#: ../../library/email.examples.rst:36 msgid "" "#!/usr/bin/env python3\n" "\n" @@ -303,6 +433,61 @@ msgid "" "if __name__ == '__main__':\n" " main()\n" msgstr "" +"#!/usr/bin/env python3\n" +"\n" +"\"\"\"MIME メッセージをディレクトリ内のファイルに展開します。\"\"\"\n" +"\n" +"import os\n" +"import email\n" +"import mimetypes\n" +"\n" +"from email.policy import default\n" +"\n" +"from argparse import ArgumentParser\n" +"\n" +"\n" +"def main():\n" +" parser = ArgumentParser(description=\"\"\"\\\n" +"Unpack a MIME message into a directory of files.\n" +"\"\"\")\n" +" parser.add_argument('-d', '--directory', required=True,\n" +" help=\"\"\"Unpack the MIME message into the named\n" +" directory, which will be created if it doesn't " +"already\n" +" exist.\"\"\")\n" +" parser.add_argument('msgfile')\n" +" args = parser.parse_args()\n" +"\n" +" with open(args.msgfile, 'rb') as fp:\n" +" msg = email.message_from_binary_file(fp, policy=default)\n" +"\n" +" try:\n" +" os.mkdir(args.directory)\n" +" except FileExistsError:\n" +" pass\n" +"\n" +" counter = 1\n" +" for part in msg.walk():\n" +" # multipart/* は単なるコンテナです\n" +" if part.get_content_maintype() == 'multipart':\n" +" continue\n" +" # メールメッセージによって重要なファイルが上書きされないように、\n" +" # 実際のアプリケーションではファイル名を安全なものにする必要がありま" +"す\n" +" filename = part.get_filename()\n" +" if not filename:\n" +" ext = mimetypes.guess_extension(part.get_content_type())\n" +" if not ext:\n" +" # 汎用のバイナリデータ用拡張子を使います\n" +" ext = '.bin'\n" +" filename = f'part-{counter:03d}{ext}'\n" +" counter += 1\n" +" with open(os.path.join(args.directory, filename), 'wb') as fp:\n" +" fp.write(part.get_payload(decode=True))\n" +"\n" +"\n" +"if __name__ == '__main__':\n" +" main()\n" #: ../../library/email.examples.rst:39 msgid "" @@ -315,7 +500,6 @@ msgstr "" "す。もう少し面白くするために、 HTML 部分に関連する画像を追加し、さらに送信だ" "けでなく、送信しようとしているもののコピーをディスクにも保存してみます。" -#: ../../library/email.examples.rst:44 msgid "" "#!/usr/bin/env python3\n" "\n" @@ -377,6 +561,65 @@ msgid "" "with smtplib.SMTP('localhost') as s:\n" " s.send_message(msg)\n" msgstr "" +"#!/usr/bin/env python3\n" +"\n" +"import smtplib\n" +"\n" +"from email.message import EmailMessage\n" +"from email.headerregistry import Address\n" +"from email.utils import make_msgid\n" +"\n" +"# 基本のテキストメッセージを作成します。\n" +"msg = EmailMessage()\n" +"msg['Subject'] = \"Pourquoi pas des asperges pour ce midi ?\"\n" +"msg['From'] = Address(\"Pepé Le Pew\", \"pepe\", \"example.com\")\n" +"msg['To'] = (Address(\"Penelope Pussycat\", \"penelope\", \"example.com\"),\n" +" Address(\"Fabrette Pussycat\", \"fabrette\", \"example.com\"))\n" +"msg.set_content(\"\"\"\\\n" +"Salut!\n" +"\n" +"Cette recette [1] sera sûrement un très bon repas.\n" +"\n" +"[1] http://www.yummly.com/recipe/Roasted-Asparagus-Epicurious-203718\n" +"\n" +"--Pepé\n" +"\"\"\")\n" +"\n" +"# HTML 版を追加します。\n" +"# メッセージは multipart/alternative コンテナになり、\n" +"# 最初のパートが元のテキストメッセージ、\n" +"# 2 番目のパートが新しい HTML メッセージになります。\n" +"asparagus_cid = make_msgid()\n" +"msg.add_alternative(\"\"\"\\\n" +"\n" +" \n" +" \n" +"

Salut!

\n" +"

Cette\n" +" \n" +" recette\n" +" sera sûrement un très bon repas.\n" +"

\n" +" \n" +" \n" +"\n" +"\"\"\".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')\n" +"# HTML で使うために msgid から <> を取り除く必要がある点に注意してくださ" +"い。\n" +"\n" +"# HTML パートに関連する画像を追加します。\n" +"with open(\"roasted-asparagus.jpg\", 'rb') as img:\n" +" msg.get_payload()[1].add_related(img.read(), 'image', 'jpeg',\n" +" cid=asparagus_cid)\n" +"\n" +"# 送信する内容のローカルコピーを作成します。\n" +"with open('outgoing.msg', 'wb') as f:\n" +" f.write(bytes(msg))\n" +"\n" +"# ローカル SMTP サーバー経由でメッセージを送信します。\n" +"with smtplib.SMTP('localhost') as s:\n" +" s.send_message(msg)\n" #: ../../library/email.examples.rst:47 msgid "" @@ -386,7 +629,6 @@ msgstr "" "前の例のメッセージが送信されてきたら、これを処理する方法の一つは次のようなも" "のです:" -#: ../../library/email.examples.rst:50 msgid "" "import os\n" "import sys\n" @@ -476,12 +718,95 @@ msgid "" "# Of course, there are lots of email messages that could break this simple\n" "# minded program, but it will handle the most common ones.\n" msgstr "" +"import os\n" +"import sys\n" +"import tempfile\n" +"import mimetypes\n" +"import webbrowser\n" +"\n" +"# 必要な email モジュールをインポートします\n" +"from email import policy\n" +"from email.parser import BytesParser\n" +"\n" +"\n" +"def magic_html_parser(html_text, partfiles):\n" +" \"\"\"安全性に配慮して処理し、partfiles にリンクする HTML を返します。\n" +"\n" +" href=\"cid:....\" 属性を書き換え、partfiles 内のファイル名を指すようにし" +"ます。\n" +" 簡単ではありませんが、html.parser を使えば実現できるはずです。\n" +" \"\"\"\n" +" raise NotImplementedError(\"Add the magic needed\")\n" +"\n" +"\n" +"# 実際のプログラムでは、引数からファイル名を取得します。\n" +"with open('outgoing.msg', 'rb') as fp:\n" +" msg = BytesParser(policy=policy.default).parse(fp)\n" +"\n" +"# これでヘッダーの各項目に辞書としてアクセスでき、\n" +"# 非 ASCII 文字は Unicode に変換されます:\n" +"print('To:', msg['to'])\n" +"print('From:', msg['from'])\n" +"print('Subject:', msg['subject'])\n" +"\n" +"# メッセージ内容のプレビューを表示するには、最も書式の少ないペイロードを\n" +"# 取り出して最初の 3 行を表示できます。\n" +"# もちろん、プレーンテキストのパートが\n" +"# なければ HTML の最初の 3 行を表示してもあまり役に立ちませんが、\n" +"# ここでは考え方を示すための例としています。\n" +"simplest = msg.get_body(preferencelist=('plain', 'html'))\n" +"print()\n" +"print(''.join(simplest.get_content().splitlines(keepends=True)[:3]))\n" +"\n" +"ans = input(\"View full message?\")\n" +"if ans.lower()[0] == 'n':\n" +" sys.exit()\n" +"\n" +"# 表示のために最も情報の豊かな代替パートを取り出せます:\n" +"richest = msg.get_body()\n" +"partfiles = {}\n" +"if richest['content-type'].maintype == 'text':\n" +" if richest['content-type'].subtype == 'plain':\n" +" for line in richest.get_content().splitlines():\n" +" print(line)\n" +" sys.exit()\n" +" elif richest['content-type'].subtype == 'html':\n" +" body = richest\n" +" else:\n" +" print(\"Don't know how to display {}\".format(richest." +"get_content_type()))\n" +" sys.exit()\n" +"elif richest['content-type'].content_type == 'multipart/related':\n" +" body = richest.get_body(preferencelist=('html'))\n" +" for part in richest.iter_attachments():\n" +" fn = part.get_filename()\n" +" if fn:\n" +" extension = os.path.splitext(part.get_filename())[1]\n" +" else:\n" +" extension = mimetypes.guess_extension(part.get_content_type())\n" +" with tempfile.NamedTemporaryFile(suffix=extension, delete=False) as " +"f:\n" +" f.write(part.get_content())\n" +" # ここでも <> を除いて、メール形式の cid を HTML 形式にします。\n" +" partfiles[part['content-id'][1:-1]] = f.name\n" +"else:\n" +" print(\"Don't know how to display {}\".format(richest." +"get_content_type()))\n" +" sys.exit()\n" +"with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:\n" +" f.write(magic_html_parser(body.get_content(), partfiles))\n" +"webbrowser.open(f.name)\n" +"os.remove(f.name)\n" +"for fn in partfiles.values():\n" +" os.remove(fn)\n" +"\n" +"# もちろん、この単純なプログラムでは扱えないメッセージも数多くありますが、\n" +"# よくあるメッセージには対応できます。\n" #: ../../library/email.examples.rst:52 msgid "Up to the prompt, the output from the above is:" msgstr "プロンプトまでの、上記のプログラムの出力はこうなります:" -#: ../../library/email.examples.rst:54 msgid "" "To: Penelope Pussycat , Fabrette Pussycat " "\n" @@ -492,6 +817,14 @@ msgid "" "\n" "Cette recette [1] sera sûrement un très bon repas." msgstr "" +"To: Penelope Pussycat , Fabrette Pussycat " +"\n" +"From: Pepé Le Pew \n" +"Subject: Pourquoi pas des asperges pour ce midi ?\n" +"\n" +"Salut!\n" +"\n" +"Cette recette [1] sera sûrement un très bon repas." #: ../../library/email.examples.rst:66 msgid "Footnotes" diff --git a/library/email.generator.po b/library/email.generator.po index 9575d6c58..9b6d80516 100644 --- a/library/email.generator.po +++ b/library/email.generator.po @@ -16,21 +16,19 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.generator.rst:2 msgid ":mod:`!email.generator`: Generating MIME documents" -msgstr "" +msgstr ":mod:`!email.generator`: MIME 文書の生成" #: ../../library/email.generator.rst:7 msgid "**Source code:** :source:`Lib/email/generator.py`" msgstr "**ソースコード:** :source:`Lib/email/generator.py`" -#: ../../library/email.generator.rst:11 msgid "" "One of the most common tasks is to generate the flat (serialized) version of " "the email message represented by a message object structure. You will need " @@ -39,8 +37,13 @@ msgid "" "structure and producing a serialized representation is the job of the " "generator classes." msgstr "" +"メッセージオブジェクトの構造で表された電子メールメッセージから、フラットな " +"(直列化された) 表現を生成することは、よく行う処理の一つです。\n" +":meth:`smtplib.SMTP.sendmail` で送信したり、コンソールに表示したりするには、" +"この処理が必要です。\n" +"メッセージオブジェクトの構造を受け取り、直列化された表現を作成するのがジェネ" +"レータークラスの役割です。" -#: ../../library/email.generator.rst:18 msgid "" "As with the :mod:`email.parser` module, you aren't limited to the " "functionality of the bundled generator; you could write one from scratch " @@ -56,8 +59,19 @@ msgid "" "changes to the :class:`~email.message.EmailMessage` object as defaults are " "filled in.)" msgstr "" +":mod:`email.parser` モジュールと同様に、付属のジェネレーターの機能だけを使う" +"必要はなく、自分で一から実装することもできます。\n" +"ただし、付属のジェネレーターはほとんどの電子メールを標準に準拠して生成でき、" +"MIME メッセージも非 MIME メッセージも適切に扱えるはずです。\n" +"また、変換を行わない同じ :mod:`~email.policy` を両方に使えば、バイト列の解析" +"と生成が互いに逆の操作になるよう設計されています。\n" +"つまり、直列化されたバイトストリームを :class:`~email.parser.BytesParser` で" +"解析し、:class:`BytesGenerator` で再生成すると、入力と同じ出力が得られるはず" +"です [#]_。\n" +"(一方、プログラムで構築した :class:`~email.message.EmailMessage` にジェネレー" +"ターを使うと、デフォルト値が補われる際に :class:`~email.message." +"EmailMessage` オブジェクトが変更されることがあります。)" -#: ../../library/email.generator.rst:32 msgid "" "The :class:`Generator` class can be used to flatten a message into a text " "(as opposed to binary) serialized representation, but since Unicode cannot " @@ -66,23 +80,36 @@ msgid "" "Content Transfer Encoding techniques for encoding email messages for " "transport over channels that are not \"8 bit clean\"." msgstr "" +":class:`Generator` クラスを使うと、メッセージをバイナリではなくテキストの直列" +"化表現にフラット化できます。\n" +"ただし、Unicode はバイナリデータを直接表現できないため、メッセージを ASCII 文" +"字だけからなる形式に変換する必要があります。\n" +"そのために、8 ビットデータをそのまま通せない経路で電子メールを送信するため" +"の、標準の電子メール RFC に定められたコンテンツ転送エンコーディングを使いま" +"す。" -#: ../../library/email.generator.rst:39 msgid "" "To accommodate reproducible processing of SMIME-signed messages :class:" "`Generator` disables header folding for message parts of type ``multipart/" "signed`` and all subparts." msgstr "" +"SMIME で署名されたメッセージを再現可能な形で処理できるよう、:class:" +"`Generator` は ``multipart/signed`` 型のパートとそのすべてのサブパートで、" +"ヘッダーの折り返しを無効にします。" -#: ../../library/email.generator.rst:47 msgid "" "Return a :class:`BytesGenerator` object that will write any message provided " "to the :meth:`flatten` method, or any surrogateescape encoded text provided " "to the :meth:`write` method, to the :term:`file-like object` *outfp*. " "*outfp* must support a ``write`` method that accepts binary data." msgstr "" +":meth:`flatten` に渡されたメッセージ、または :meth:`write` に渡された " +"surrogateescape でエンコードされたテキストを、:term:`ファイルライクオブジェク" +"ト ` *outfp* に書き込む :class:`BytesGenerator` オブジェク" +"トを返します。\n" +"*outfp* は、バイナリデータを受け取る ``write()`` メソッドを持つ必要がありま" +"す。" -#: ../../library/email.generator.rst:52 ../../library/email.generator.rst:153 msgid "" "If optional *mangle_from_* is ``True``, put a ``>`` character in front of " "any line in the body that starts with the exact string ``\"From \"``, that " @@ -94,6 +121,15 @@ msgid "" "`WHY THE CONTENT-LENGTH FORMAT IS BAD `_)." msgstr "" +"オプションの *mangle_from_* が ``True`` の場合、本体中で正確に文字列 " +"``\"From \"`` から始まる行、つまり行頭の ``From`` の後に空白がある行の先頭に " +"``>`` を追加します。\n" +"*mangle_from_* のデフォルトは、*policy* の :attr:`~email.policy.Policy." +"mangle_from_` 設定の値です (:data:`~email.policy.compat32` ポリシーでは " +"``True``、それ以外では ``False`` です)。\n" +"*mangle_from_* は、メッセージを Unix mbox 形式で保存する場合を想定しています " +"(:mod:`mailbox` と `WHY THE CONTENT-LENGTH FORMAT IS BAD `_ を参照してください)。" #: ../../library/email.generator.rst:62 ../../library/email.generator.rst:163 msgid "" @@ -103,7 +139,6 @@ msgid "" "lines according to the *policy* settings." msgstr "" -#: ../../library/email.generator.rst:67 ../../library/email.generator.rst:168 msgid "" "If *policy* is specified, use that policy to control message generation. If " "*policy* is ``None`` (the default), use the policy associated with the :" @@ -111,16 +146,22 @@ msgid "" "object passed to ``flatten`` to control the message generation. See :mod:" "`email.policy` for details on what *policy* controls." msgstr "" +"*policy* が指定されていれば、そのポリシーでメッセージの生成を制御します。\n" +"*policy* が ``None`` (デフォルト) であれば、``flatten()`` に渡された :class:" +"`~email.message.Message` または :class:`~email.message.EmailMessage` オブジェ" +"クトに関連付けられたポリシーを使います。\n" +"*policy* が制御する内容については :mod:`email.policy` を参照してください。" #: ../../library/email.generator.rst:75 ../../library/email.generator.rst:174 msgid "Added the *policy* keyword." msgstr "キーワード引数 *policy* が追加されました。" -#: ../../library/email.generator.rst:77 ../../library/email.generator.rst:176 msgid "" "The default behavior of the *mangle_from_* and *maxheaderlen* parameters is " "to follow the policy." msgstr "" +"*mangle_from_* と *maxheaderlen* 引数のデフォルトの動作が、ポリシーに従うよう" +"になりました。" #: ../../library/email.generator.rst:83 msgid "" @@ -132,7 +173,6 @@ msgstr "" "のファイルにはこの :class:`BytesGenerator` インスタンスが作成されたときに指定" "されたものが使われます。" -#: ../../library/email.generator.rst:87 msgid "" "If the :mod:`~email.policy` option :attr:`~email.policy.Policy.cte_type` is " "``8bit`` (the default), copy any headers in the original parsed message that " @@ -147,8 +187,21 @@ msgid "" "bytes in headers using the MIME ``unknown-8bit`` character set, thus " "rendering them RFC-compliant." msgstr "" +":mod:`~email.policy` の :attr:`~email.policy.Policy.cte_type` が ``8bit`` (デ" +"フォルト) の場合、解析した元のメッセージのうち変更されていないヘッダーを出力" +"へコピーします。\n" +"その際、最上位ビットが立っているバイトも元どおりに再現し、非 ASCII の :" +"mailheader:`Content-Transfer-Encoding` を持つ本文パートではそれを保持しま" +"す。\n" +"``cte_type`` が ``7bit`` の場合は、ASCII 互換の :mailheader:`Content-" +"Transfer-Encoding` を使い、最上位ビットが立っているバイトを必要に応じて変換し" +"ます。\n" +"つまり、非 ASCII の :mailheader:`Content-Transfer-Encoding` (:mailheader:" +"`Content-Transfer-Encoding: 8bit`) を持つパートを ASCII 互換の :mailheader:" +"`Content-Transfer-Encoding` に変換し、ヘッダー中の RFC に反する非 ASCII バイ" +"トを MIME の ``unknown-8bit`` 文字セットでエンコードして、RFC に準拠させま" +"す。" -#: ../../library/email.generator.rst:104 ../../library/email.generator.rst:197 msgid "" "If *unixfrom* is ``True``, print the envelope header delimiter used by the " "Unix mailbox format (see :mod:`mailbox`) before the first of the :rfc:`5322` " @@ -156,28 +209,40 @@ msgid "" "header, craft a standard one. The default is ``False``. Note that for " "subparts, no envelope header is ever printed." msgstr "" +"*unixfrom* が ``True`` の場合、最上位のメッセージオブジェクトの最初の :rfc:" +"`5322` ヘッダーより前に、Unix メールボックス形式で使うエンベロープヘッダーの" +"区切りを出力します (:mod:`mailbox` を参照)。\n" +"最上位のオブジェクトにエンベロープヘッダーがなければ、標準的なものを作成しま" +"す。\n" +"デフォルトは ``False`` です。\n" +"サブパートではエンベロープヘッダーは出力されません。" -#: ../../library/email.generator.rst:110 ../../library/email.generator.rst:203 msgid "" "If *linesep* is not ``None``, use it as the separator character between all " "the lines of the flattened message. If *linesep* is ``None`` (the default), " "use the value specified in the *policy*." msgstr "" +"*linesep* が ``None`` でない場合、フラット化されたメッセージのすべての行を区" +"切る文字として使います。\n" +"*linesep* が ``None`` (デフォルト) の場合、*policy* で指定された値を使いま" +"す。" -#: ../../library/email.generator.rst:119 msgid "" "Return an independent clone of this :class:`BytesGenerator` instance with " "the exact same option settings, and *fp* as the new *outfp*." msgstr "" +"この :class:`BytesGenerator` インスタンスとまったく同じオプション設定で、新し" +"い *outfp* を *fp* とした、独立した複製を返します。" -#: ../../library/email.generator.rst:125 msgid "" "Encode *s* using the ``ASCII`` codec and the ``surrogateescape`` error " "handler, and pass it to the *write* method of the *outfp* passed to the :" "class:`BytesGenerator`'s constructor." msgstr "" +"*s* を ``ASCII`` コーデックと ``surrogateescape`` エラーハンドラーでエンコー" +"ドし、:class:`BytesGenerator` のコンストラクタに渡された *outfp* の " +"``write()`` メソッドに渡します。" -#: ../../library/email.generator.rst:130 msgid "" "As a convenience, :class:`~email.message.EmailMessage` provides the methods :" "meth:`~email.message.EmailMessage.as_bytes` and ``bytes(aMessage)`` (a.k.a. :" @@ -185,6 +250,11 @@ msgid "" "of a serialized binary representation of a message object. For more detail, " "see :mod:`email.message`." msgstr "" +":class:`~email.message.EmailMessage` には、メッセージオブジェクトを直列化した" +"バイナリ表現を簡単に生成するための :meth:`~email.message.EmailMessage." +"as_bytes` と ``bytes(aMessage)`` (すなわち :meth:`~email.message." +"EmailMessage.__bytes__`) が用意されています。\n" +"詳しくは :mod:`email.message` を参照してください。" #: ../../library/email.generator.rst:137 msgid "" @@ -197,13 +267,16 @@ msgid "" "using :class:`BytesGenerator`, and not :class:`Generator`." msgstr "" -#: ../../library/email.generator.rst:148 msgid "" "Return a :class:`Generator` object that will write any message provided to " "the :meth:`flatten` method, or any text provided to the :meth:`write` " "method, to the :term:`file-like object` *outfp*. *outfp* must support a " "``write`` method that accepts string data." msgstr "" +":meth:`flatten` に渡されたメッセージ、または :meth:`write` に渡されたテキスト" +"を、:term:`ファイルライクオブジェクト ` *outfp* に書き込" +"む :class:`Generator` オブジェクトを返します。\n" +"*outfp* は、文字列データを受け取る ``write()`` メソッドを持つ必要があります。" #: ../../library/email.generator.rst:182 msgid "" @@ -215,7 +288,6 @@ msgstr "" "のファイルにはこの :class:`Generator` インスタンスが作成されたときに指定され" "たものが使われます。" -#: ../../library/email.generator.rst:186 msgid "" "If the :mod:`~email.policy` option :attr:`~email.policy.Policy.cte_type` is " "``8bit``, generate the message as if the option were set to ``7bit``. (This " @@ -227,6 +299,16 @@ msgid "" "Encoding`, and encode RFC-invalid non-ASCII bytes in headers using the MIME " "``unknown-8bit`` character set, thus rendering them RFC-compliant." msgstr "" +":mod:`~email.policy` の :attr:`~email.policy.Policy.cte_type` が ``8bit`` の" +"場合、``7bit`` に設定されているものとしてメッセージを生成します。\n" +"(文字列では非 ASCII バイトを表せないため、この処理が必要です。)\n" +"最上位ビットが立っているバイトは、ASCII 互換の :mailheader:`Content-Transfer-" +"Encoding` を使って必要に応じて変換します。\n" +"つまり、非 ASCII の :mailheader:`Content-Transfer-Encoding` (:mailheader:" +"`Content-Transfer-Encoding: 8bit`) を持つパートを ASCII 互換の :mailheader:" +"`Content-Transfer-Encoding` に変換し、ヘッダー中の RFC に反する非 ASCII バイ" +"トを MIME の ``unknown-8bit`` 文字セットでエンコードして、RFC に準拠させま" +"す。" #: ../../library/email.generator.rst:209 msgid "" @@ -236,20 +318,23 @@ msgstr "" "``8bit`` メッセージ本体の再エンコードがサポートされました。*linesep* 引数が追" "加されました。" -#: ../../library/email.generator.rst:216 msgid "" "Return an independent clone of this :class:`Generator` instance with the " "exact same options, and *fp* as the new *outfp*." msgstr "" +"この :class:`Generator` インスタンスとまったく同じオプションで、新しい " +"*outfp* を *fp* とした、独立した複製を返します。" -#: ../../library/email.generator.rst:222 msgid "" "Write *s* to the *write* method of the *outfp* passed to the :class:" "`Generator`'s constructor. This provides just enough file-like API for :" "class:`Generator` instances to be used in the :func:`print` function." msgstr "" +":class:`Generator` のコンストラクタに渡された *outfp* の ``write()`` メソッド" +"に *s* を書き込みます。\n" +"これにより、:class:`Generator` インスタンスを :func:`print` 関数で使うために" +"必要な、最小限のファイルライク API を提供します。" -#: ../../library/email.generator.rst:228 msgid "" "As a convenience, :class:`~email.message.EmailMessage` provides the methods :" "meth:`~email.message.EmailMessage.as_string` and ``str(aMessage)`` (a.k.a. :" @@ -257,8 +342,12 @@ msgid "" "of a formatted string representation of a message object. For more detail, " "see :mod:`email.message`." msgstr "" +":class:`~email.message.EmailMessage` には、メッセージオブジェクトの書式化され" +"た文字列表現を簡単に生成するための :meth:`~email.message.EmailMessage." +"as_string` と ``str(aMessage)`` (すなわち :meth:`~email.message.EmailMessage." +"__str__`) が用意されています。\n" +"詳しくは :mod:`email.message` を参照してください。" -#: ../../library/email.generator.rst:235 msgid "" "The :mod:`!email.generator` module also provides a derived class, :class:" "`DecodedGenerator`, which is like the :class:`Generator` base class, except " @@ -266,8 +355,12 @@ msgid "" "represented in the output stream by a string derived from a template filled " "in with information about the part." msgstr "" +":mod:`!email.generator` モジュールは派生クラス :class:`DecodedGenerator` も提" +"供します。\n" +"基底クラスの :class:`Generator` と似ていますが、:mimetype:`text` 以外のパート" +"は直列化せず、そのパートの情報をテンプレートに埋め込んだ文字列として出力スト" +"リームに表す点が異なります。" -#: ../../library/email.generator.rst:244 msgid "" "Act like :class:`Generator`, except that for any subpart of the message " "passed to :meth:`Generator.flatten`, if the subpart is of main type :" @@ -276,12 +369,18 @@ msgid "" "*fmt* using information from the part and print the resulting filled-in " "string." msgstr "" +":class:`Generator` と同様に動作しますが、:meth:`Generator.flatten` に渡された" +"メッセージのサブパートについて、メインタイプが :mimetype:`text` ならデコード" +"したペイロードを出力します。\n" +"メインタイプが :mimetype:`text` でなければ、パートをそのまま出力する代わり" +"に、その情報を文字列 *fmt* に埋め込み、結果の文字列を出力します。" -#: ../../library/email.generator.rst:251 msgid "" "To fill in *fmt*, execute ``fmt % part_info``, where ``part_info`` is a " "dictionary composed of the following keys and values:" msgstr "" +"*fmt* への埋め込みには ``fmt % part_info`` を使います。\n" +"``part_info`` は以下のキーと値からなる辞書です。" #: ../../library/email.generator.rst:254 msgid "``type`` -- Full MIME type of the non-\\ :mimetype:`text` part" @@ -313,14 +412,13 @@ msgid "" msgstr "" "``encoding`` -- 非 :mimetype:`text` 型 subpart の Content-transfer-encoding" -#: ../../library/email.generator.rst:266 msgid "If *fmt* is ``None``, use the following default *fmt*:" -msgstr "" +msgstr "*fmt* が ``None`` の場合、次のデフォルトの *fmt* を使います。" -#: ../../library/email.generator.rst:268 msgid "" "\"[Non-text (%(type)s) part of message omitted, filename %(filename)s]\"" msgstr "" +"\"[Non-text (%(type)s) part of message omitted, filename %(filename)s]\"" #: ../../library/email.generator.rst:270 msgid "" @@ -332,7 +430,6 @@ msgstr "" msgid "Footnotes" msgstr "脚注" -#: ../../library/email.generator.rst:276 msgid "" "This statement assumes that you use the appropriate setting for " "``unixfrom``, and that there are no :mod:`email.policy` settings calling for " @@ -343,3 +440,10 @@ msgid "" "parsing error recovery. It is a goal to fix these latter edge cases when " "possible." msgstr "" +"この説明は、``unixfrom`` が適切に設定され、:mod:`email.policy` に自動調整を要" +"求する設定がないことを前提としています (例えば :attr:`~email.policy." +"EmailPolicy.refold_source` は ``none`` でなければなりませんが、これはデフォル" +"トでは *ありません*)。\n" +"また、メッセージが RFC に準拠していないと、解析エラーからの回復中に元のテキス" +"トの正確な情報が失われることがあるため、常に成り立つわけでもありません。\n" +"このような例外的な場合は、可能な限り修正していくことを目指しています。" diff --git a/library/email.header.po b/library/email.header.po index 9f3ef66a1..12e6f8705 100644 --- a/library/email.header.po +++ b/library/email.header.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.header.rst:2 @@ -64,7 +64,6 @@ msgstr "" "ら発展したものです。 :rfc:`2822` は電子メールがすべて 7-bit ASCII 文字のみか" "ら構成されていると仮定して作られた仕様です。" -#: ../../library/email.header.rst:24 msgid "" "Of course, as email has been deployed worldwide, it has become " "internationalized, such that language specific character sets can now be " @@ -75,8 +74,16 @@ msgid "" "`2046`, :rfc:`2047`, and :rfc:`2231`. The :mod:`email` package supports " "these standards in its :mod:`!email.header` and :mod:`email.charset` modules." msgstr "" +"電子メールが世界中に普及するにつれ、国際化が進み、各言語固有の文字集合を電子" +"メールメッセージで使えるようになりました。\n" +"基本規格では今も 7 ビットの ASCII 文字だけでの転送が求められるため、非 ASCII " +"文字を含む電子メールを :rfc:`2822` に準拠する形式にエンコードする方法を定め" +"た RFC が多数書かれています。\n" +"これには :rfc:`2045`、:rfc:`2046`、:rfc:`2047`、:rfc:`2231` などがありま" +"す。\n" +":mod:`email` パッケージは :mod:`!email.header` と :mod:`email.charset` モ" +"ジュールでこれらの規格をサポートします。" -#: ../../library/email.header.rst:33 msgid "" "If you want to include non-ASCII characters in your email headers, say in " "the :mailheader:`Subject` or :mailheader:`To` fields, you should use the :" @@ -85,8 +92,14 @@ msgid "" "for the header value. Import the :class:`Header` class from the :mod:`!" "email.header` module. For example::" msgstr "" +":mailheader:`Subject` や :mailheader:`To` などの電子メールヘッダーに非 ASCII " +"文字を含めたい場合は、:class:`Header` クラスを使ってください。\n" +":class:`~email.message.Message` オブジェクトのフィールドには、文字列ではな" +"く :class:`Header` インスタンスをヘッダー値として代入します。\n" +":class:`Header` クラスは :mod:`!email.header` モジュールからインポートしてく" +"ださい。\n" +"例えば次のようにします。 ::" -#: ../../library/email.header.rst:40 msgid "" ">>> from email.message import Message\n" ">>> from email.header import Header\n" @@ -96,8 +109,14 @@ msgid "" ">>> msg.as_string()\n" "'Subject: =?iso-8859-1?q?p=F6stal?=\\n\\n'" msgstr "" +">>> from email.message import Message\n" +">>> from email.header import Header\n" +">>> msg = Message()\n" +">>> h = Header('p\\xf6stal', 'iso-8859-1')\n" +">>> msg['Subject'] = h\n" +">>> msg.as_string()\n" +"'Subject: =?iso-8859-1?q?p=F6stal?=\\n\\n'" -#: ../../library/email.header.rst:50 msgid "" "Notice here how we wanted the :mailheader:`Subject` field to contain a non-" "ASCII character? We did this by creating a :class:`Header` instance and " @@ -106,6 +125,13 @@ msgid "" "`Subject` field was properly :rfc:`2047` encoded. MIME-aware mail readers " "would show this header using the embedded ISO-8859-1 character." msgstr "" +"ここでは :mailheader:`Subject` フィールドに非 ASCII 文字を含めています。\n" +":class:`Header` インスタンスを作成し、エンコードに使う文字集合を渡すことで実" +"現しました。\n" +"その後 :class:`~email.message.Message` インスタンスをフラット化すると、:" +"mailheader:`Subject` フィールドは正しく :rfc:`2047` でエンコードされます。\n" +"MIME 対応のメールソフトでは、埋め込まれた ISO-8859-1 の文字を使ってこのヘッ" +"ダーが表示されます。" #: ../../library/email.header.rst:57 msgid "Here is the :class:`Header` class description:" @@ -146,7 +172,6 @@ msgstr "" "場合 (デフォルト)、初期値の *s* および以後の :meth:`append` 呼び出しにおける" "文字集合として ``us-ascii`` が使われます。" -#: ../../library/email.header.rst:77 msgid "" "The maximum line length can be specified explicitly via *maxlinelen*. For " "splitting the first line to a shorter value (to account for the field header " @@ -155,12 +180,12 @@ msgid "" "value for *header_name* is ``None``, meaning it is not taken into account " "for the first line of a long, split header." msgstr "" -"行の最大長は *maxlinelen* によって明示的に指定できます。最初の行を (:" -"mailheader:`Subject` などの *s* に含まれないフィールドヘッダの責任をとるた" -"め) 短く切りとる場合、 *header_name* にそのフィールド名を指定してください。 " -"*maxlinelen* のデフォルト値は 78 であり、 *header_name* のデフォルト値は " -"``None`` です。これはその最初の行を長い、切りとられたヘッダとして扱わないこと" -"を意味します。" +"行の最大長は *maxlinelen* で明示的に指定できます。\n" +":mailheader:`Subject` など、*s* に含まれないフィールド名の長さを考慮して最初" +"の行を短くするには、*header_name* にフィールド名を渡してください。\n" +"*maxlinelen* のデフォルトは 78 です。\n" +"*header_name* のデフォルトは ``None`` で、この場合は長いヘッダーを折り返す" +"際、最初の行でフィールド名の長さを考慮しません。" #: ../../library/email.header.rst:84 msgid "" @@ -226,8 +251,8 @@ msgid "" msgstr "" "いずれの場合でも、 :rfc:`2822` 準拠のヘッダを :rfc:`2047` の規則を用いて生成" "する際、文字列は指定された文字セットの出力コーデックを用いてエンコードされま" -"す。出力コーデックを用いて文字列がエンコードできないときは :exc:" -"`UnicodeError` が発生します。" +"す。出力コーデックを用いて文字列がエンコードできないときは ``UnicodeError`` " +"が発生します。" #: ../../library/email.header.rst:115 msgid "" @@ -247,7 +272,6 @@ msgstr "" "返され、非 ASCII 部分は base64 または quoted-printable エンコーディングで包含" "されるでしょう。" -#: ../../library/email.header.rst:125 msgid "" "Optional *splitchars* is a string containing characters which should be " "given extra weight by the splitting algorithm during normal header " @@ -259,14 +283,16 @@ msgid "" "point when other split chars do not appear in the line being split. " "Splitchars does not affect :RFC:`2047` encoded lines." msgstr "" -"オプション引数 *splitchars* は、通常のヘッダーの折り返し処理の間に分割アルゴ" -"リズムによって特別な重みが与えられるべき文字を含む文字列です。これは、 :RFC:" -"`2822` の 'higher level syntactic breaks' の非常に荒いサポートです: " -"splitchar の後の分割点は、行分割において優先されます。 分割文字は文字列中での" -"出現順に優先されます。スペースとタブは、分割しようとする行に他の分割文字が出" -"現しない時に、分割点として他の文字と比べてどのような優先順位が与えられるべき" -"かを示すために、文字列に含めることができます。 Splitchars は :RFC:`2047` エン" -"コードされた行には影響しません。" +"省略可能な *splitchars* は、通常のヘッダーの折り返しで分割位置を決める際に優" +"先する文字を含む文字列です。\n" +"これは :RFC:`2822` の「上位の構文上の区切り」を大まかにサポートするもので" +"す。\n" +"指定された文字の直後を分割位置として優先し、その優先順位は文字列内での並び順" +"に従います。\n" +"スペースとタブもこの文字列に含められます。\n" +"これにより、分割する行に他の分割文字がない場合、スペースとタブのどちらを分割" +"位置として優先するかを指定できます。\n" +"``splitchars`` は :RFC:`2047` でエンコードされた行には影響しません。" #: ../../library/email.header.rst:135 msgid "" @@ -275,7 +301,6 @@ msgid "" msgstr "" "与えられた場合、*maxlinelen* はインスタンスの最大行長の値を上書きします。" -#: ../../library/email.header.rst:138 msgid "" "*linesep* specifies the characters used to separate the lines of the folded " "header. It defaults to the most useful value for Python application code " @@ -284,7 +309,7 @@ msgid "" msgstr "" "*linesep* は、折り返しヘッダの行を区切る文字を指定します。デフォルトでは" "Pythonアプリケーションコードに最も有用な値(``\\n``)になりますが、RFC準拠の行" -"区切り文字でヘッダを生成するために``\\r\\n``を指定することができます。" +"区切り文字でヘッダを生成するために ``\\r\\n`` を指定することができます。" #: ../../library/email.header.rst:143 msgid "Added the *linesep* argument." @@ -298,7 +323,6 @@ msgstr "" ":class:`Header` クラスは、標準の演算子や組み込み関数をサポートするためのメ" "ソッドもいくつか提供しています。" -#: ../../library/email.header.rst:152 msgid "" "Returns an approximation of the :class:`Header` as a string, using an " "unlimited line length. All pieces are decoded using the specified encoding " @@ -306,6 +330,10 @@ msgid "" "``'unknown-8bit'`` are decoded as ASCII using the ``'replace'`` error " "handler." msgstr "" +":class:`Header` の内容に近い文字列を、行長の制限なしで返します。\n" +"すべての部分を指定されたエンコーディングでデコードし、適切に結合します。\n" +"文字セットが ``'unknown-8bit'`` の部分は、``'replace'`` エラーハンドラーを" +"使って ASCII としてデコードします。" #: ../../library/email.header.rst:158 msgid "Added handling for the ``'unknown-8bit'`` charset." @@ -326,11 +354,10 @@ msgstr "" "このメソッドは、ふたつの :class:`Header` インスタンスどうしが異なっているかど" "うかを判定するのに使えます。" -#: ../../library/email.header.rst:173 msgid "" "The :mod:`!email.header` module also provides the following convenient " "functions." -msgstr "" +msgstr ":mod:`!email.header` モジュールは、以下の便利な関数も提供します。" #: ../../library/email.header.rst:178 msgid "" @@ -340,46 +367,49 @@ msgstr "" "文字集合を変換せずにメッセージのヘッダをデコードします。ヘッダの値は " "*header* にあります。" -#: ../../library/email.header.rst:181 msgid "For historical reasons, this function may return either:" -msgstr "" +msgstr "歴史的な理由から、この関数は次のいずれかを返します。" -#: ../../library/email.header.rst:183 msgid "" "A list of pairs containing each of the decoded parts of the header, " "``(decoded_bytes, charset)``, where *decoded_bytes* is always an instance " "of :class:`bytes`, and *charset* is either:" msgstr "" +"ヘッダーの各部分をデコードした結果を含む ``(decoded_bytes, charset)`` ペアの" +"リスト。\n" +"*decoded_bytes* は常に :class:`bytes` インスタンスで、*charset* は次のいずれ" +"かです。" -#: ../../library/email.header.rst:187 msgid "A lower case string containing the name of the character set specified." -msgstr "" +msgstr "指定された文字集合の名前を含む小文字の文字列。" -#: ../../library/email.header.rst:189 msgid "``None`` for non-encoded parts of the header." -msgstr "" +msgstr "エンコードされていないヘッダー部分では ``None``。" -#: ../../library/email.header.rst:191 msgid "" "A list of length 1 containing a pair ``(string, None)``, where *string* is " "always an instance of :class:`str`." msgstr "" +"``(string, None)`` ペアを一つ含む長さ 1 のリスト。\n" +"*string* は常に :class:`str` インスタンスです。" -#: ../../library/email.header.rst:194 msgid "" "An :exc:`email.errors.HeaderParseError` may be raised when certain decoding " "errors occur (e.g. a base64 decoding exception)." msgstr "" +"一部のデコードエラー (base64 のデコード例外など) が起きると、:exc:`email." +"errors.HeaderParseError` が送出されることがあります。" -#: ../../library/email.header.rst:197 msgid "Here are examples:" -msgstr "" +msgstr "以下に例を示します。" -#: ../../library/email.header.rst:209 msgid "" "This function exists for backwards compatibility only. For new code, we " "recommend using :class:`email.headerregistry.HeaderRegistry`." msgstr "" +"この関数は後方互換性のためだけに存在します。\n" +"新しいコードでは :class:`email.headerregistry.HeaderRegistry` の使用を推奨し" +"ます。" #: ../../library/email.header.rst:215 msgid "" @@ -399,18 +429,18 @@ msgstr "" "charset)`` という形式の 2要素タプルからなるリストを返します。ここで " "*decoded_string* はデコードされた文字列、 *charset* はその文字集合です。" -#: ../../library/email.header.rst:222 msgid "" "This function takes one of those sequence of pairs and returns a :class:" "`Header` instance. Optional *maxlinelen*, *header_name*, and " "*continuation_ws* are as in the :class:`Header` constructor." msgstr "" -"この関数はこれらのリストの項目から、 :class:`Header` インスタンスを返します。" -"オプション引数 *maxlinelen* 、 *header_name* および *continuation_ws* は :" -"class:`Header` コンストラクタに与えるものと同じです。" +"この関数は、そのようなペアのシーケンスを受け取り、:class:`Header` インスタン" +"スを返します。\n" +"省略可能な *maxlinelen*、*header_name*、*continuation_ws* は :class:`Header` " +"コンストラクタと同じです。" -#: ../../library/email.header.rst:228 msgid "" "This function exists for backwards compatibility only, and is not " "recommended for use in new code." msgstr "" +"この関数は後方互換性のためだけに存在し、新しいコードでの使用は推奨しません。" diff --git a/library/email.headerregistry.po b/library/email.headerregistry.po index 2f461df4b..e4dada936 100644 --- a/library/email.headerregistry.po +++ b/library/email.headerregistry.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.headerregistry.rst:2 msgid ":mod:`!email.headerregistry`: Custom Header Objects" -msgstr "" +msgstr ":mod:`!email.headerregistry`: カスタムヘッダーオブジェクト" #: ../../library/email.headerregistry.rst:7 msgid "**Source code:** :source:`Lib/email/headerregistry.py`" @@ -90,12 +89,15 @@ msgstr "" "class:`.HeaderRegistry` の動作を変更するための API、そして最後に構造化ヘッ" "ダーからパースされたデータを表現するためのサポートクラスについて説明します。" -#: ../../library/email.headerregistry.rst:41 msgid "" "*name* and *value* are passed to ``BaseHeader`` from the :attr:`~email." "policy.EmailPolicy.header_factory` call. The string value of any header " "object is the *value* fully decoded to a string." msgstr "" +"*name* と *value* は、:attr:`~email.policy.EmailPolicy.header_factory` の呼び" +"出しから ``BaseHeader`` に渡されます。\n" +"ヘッダーオブジェクトの文字列としての値は、*value* を完全にデコードした文字列" +"です。" #: ../../library/email.headerregistry.rst:45 msgid "This base class defines the following read-only properties:" @@ -175,11 +177,9 @@ msgstr "" "``parse`` という名前の :func:`classmethod` を特殊化されたクラスが提供すること" "を要求しています。このメソッドは以下のように呼び出されます::" -#: ../../library/email.headerregistry.rst:91 msgid "parse(string, kwds)" -msgstr "" +msgstr "parse(string, kwds)" -#: ../../library/email.headerregistry.rst:93 msgid "" "``kwds`` is a dictionary containing one pre-initialized key, ``defects``. " "``defects`` is an empty list. The parse method should append any detected " @@ -192,8 +192,18 @@ msgid "" "handle all valid Unicode characters as well so that it can parse un-encoded " "header values." msgstr "" +"``kwds`` は、あらかじめ初期化されたキー ``defects`` を一つ含む辞書です。\n" +"``defects`` の値は空のリストです。\n" +"``parse()`` メソッドは、検出した欠陥をこのリストに追加する必要があります。\n" +"戻る際には、``kwds`` 辞書に少なくとも ``decoded``、``defects``、" +"``parse_tree`` の各キーの値が *なければなりません*。\n" +"``decoded`` はヘッダーの文字列値、つまりヘッダー値を完全にデコードした文字列" +"にします。\n" +"``parse_tree`` には、ヘッダーを解析して得た構文木を設定します。\n" +"``parse()`` メソッドは、*string* にコンテンツ転送エンコーディングが適用された" +"部分が含まれる可能性を考慮するとともに、エンコードされていないヘッダー値も解" +"析できるよう、すべての有効な Unicode 文字を正しく扱う必要があります。" -#: ../../library/email.headerregistry.rst:103 msgid "" "``BaseHeader``'s ``__new__`` then creates the header instance, and calls its " "``init`` method. The specialized class only needs to provide an ``init`` " @@ -201,26 +211,28 @@ msgid "" "``BaseHeader`` itself. Such an ``init`` method should look like this::" msgstr "" "その後、 ``BaseHeader`` の ``__new__`` がヘッダのインスタンスを生成し、 " -"``init`` メソッドを呼び出します。 特殊クラスは、 ``BaseHeader`` が提供しない" -"属性を設定したい場合にのみ ``init`` メソッドを提供する必要があります。 このよ" -"うな``init`` メソッドは以下のようなものです:" +"``init`` メソッドを呼び出します。\n" +"特殊クラスは、 ``BaseHeader`` が提供しない属性を設定したい場合にのみ " +"``init`` メソッドを提供する必要があります。\n" +"このような ``init`` メソッドは以下のようなものです。 ::" -#: ../../library/email.headerregistry.rst:108 msgid "" "def init(self, /, *args, **kw):\n" " self._myattr = kw.pop('myattr')\n" " super().init(*args, **kw)" msgstr "" +"def init(self, /, *args, **kw):\n" +" self._myattr = kw.pop('myattr')\n" +" super().init(*args, **kw)" -#: ../../library/email.headerregistry.rst:112 msgid "" "That is, anything extra that the specialized class puts in to the ``kwds`` " "dictionary should be removed and handled, and the remaining contents of " "``kw`` (and ``args``) passed to the ``BaseHeader`` ``init`` method." msgstr "" "つまり、特殊クラスが ``kwds`` の辞書に追加したものはすべて削除して処理し、 " -"``kw``の残りの内容 (と ``args``) は``BaseHeader`` の``init`` メソッドに渡す必" -"要があるのです。" +"``kw`` の残りの内容 (と ``args``) は ``BaseHeader`` の ``init`` メソッドに渡" +"す必要があるのです。" #: ../../library/email.headerregistry.rst:119 msgid "" @@ -233,7 +245,6 @@ msgstr "" "す。指定された構文を持たないすべてのヘッダは、unstructuredとして扱われます。 " "構造化されていないヘッダの典型的な例は :mailheader:`Subject` ヘッダです。" -#: ../../library/email.headerregistry.rst:124 msgid "" "In :rfc:`5322`, an unstructured header is a run of arbitrary text in the " "ASCII character set. :rfc:`2047`, however, has an :rfc:`5322` compatible " @@ -245,29 +256,39 @@ msgid "" "words. Defects are registered in such cases, as well as defects for issues " "such as invalid characters within the encoded words or the non-encoded text." msgstr "" +":rfc:`5322` では、非構造化ヘッダーは ASCII 文字集合による任意のテキストの並び" +"です。\n" +"ただし、:rfc:`2047` は、ヘッダー値の中で非 ASCII テキストを ASCII 文字にエン" +"コードする、:rfc:`5322` と互換性のある仕組みを定めています。\n" +"エンコードされた語を含む *value* がコンストラクタに渡されると、" +"``UnstructuredHeader`` のパーサーは、非構造化テキストに関する :rfc:`2047` の" +"規則に従ってそれらを文字列に変換します。\n" +"パーサーは、一部の規格に準拠しないエンコードされた語についても、ヒューリス" +"ティックによってデコードを試みます。\n" +"その場合には欠陥が記録されます。\n" +"エンコードされた語やエンコードされていないテキストに不正な文字がある場合など" +"も同様です。" #: ../../library/email.headerregistry.rst:134 msgid "This header type provides no additional attributes." msgstr "このヘッダ型には追加の属性はありません。" -#: ../../library/email.headerregistry.rst:139 msgid "" ":rfc:`5322` specifies a very specific format for dates within email headers. " "The ``DateHeader`` parser recognizes that date format, as well as " "recognizing a number of variant forms that are sometimes found \"in the " "wild\"." msgstr "" -":rfc:`5322` specifies a very specific format for dates within email headers. " -"The ``DateHeader`` parser recognizes that date format, as well as " -"recognizing a number of variant forms that are sometimes found \"in the " -"wild\"." +":rfc:`5322` は、電子メールヘッダー内の日付について厳密な形式を定めていま" +"す。\n" +"``DateHeader`` のパーサーはその形式に加え、実際のメールで見かけるさまざまな変" +"形も認識します。" #: ../../library/email.headerregistry.rst:144 #: ../../library/email.headerregistry.rst:186 msgid "This header type provides the following additional attributes:" msgstr "このヘッダ型は以下の属性も提供しています:" -#: ../../library/email.headerregistry.rst:148 msgid "" "If the header value can be recognized as a valid date of one form or " "another, this attribute will contain a :class:`~datetime.datetime` instance " @@ -278,18 +299,25 @@ msgid "" "then :attr:`.datetime` will contain an aware ``datetime`` that uses :class:" "`datetime.timezone` to record the timezone offset." msgstr "" +"ヘッダー値を何らかの有効な日付形式として認識できた場合、この属性にはその日時" +"を表す :class:`~datetime.datetime` インスタンスが入ります。\n" +"入力のタイムゾーンが ``-0000`` (UTC だが送信元のタイムゾーン情報はないことを" +"示します) の場合、:attr:`.datetime` は naive な :class:`~datetime.datetime` " +"になります。\n" +"``+0000`` を含む特定のタイムゾーンオフセットが見つかった場合、:attr:`." +"datetime` は :class:`datetime.timezone` でオフセットを記録した aware な " +"``datetime`` になります。" -#: ../../library/email.headerregistry.rst:158 msgid "" "The ``decoded`` value of the header is determined by formatting the " "``datetime`` according to the :rfc:`5322` rules; that is, it is set to::" msgstr "" -"ヘッダーの ``decoded`` 値は、 ``datetime`` を :rfc:`5322` のルールに従って" -"フォーマットすることで決定されます。" +"ヘッダーの ``decoded`` 値は、``datetime`` を :rfc:`5322` の規則に従って書式化" +"したものです。\n" +"つまり、次のように設定されます。 ::" -#: ../../library/email.headerregistry.rst:161 msgid "email.utils.format_datetime(self.datetime)" -msgstr "" +msgstr "email.utils.format_datetime(self.datetime)" #: ../../library/email.headerregistry.rst:163 msgid "" @@ -301,25 +329,22 @@ msgstr "" "タンスである可能性があります。 これは、例えば、次のようなコードは有効であり、" "期待通りの動作をすることを意味します::" -#: ../../library/email.headerregistry.rst:167 msgid "msg['Date'] = datetime(2011, 7, 15, 21)" -msgstr "" +msgstr "msg['Date'] = datetime(2011, 7, 15, 21)" -#: ../../library/email.headerregistry.rst:169 msgid "" "Because this is a naive ``datetime`` it will be interpreted as a UTC " "timestamp, and the resulting value will have a timezone of ``-0000``. Much " "more useful is to use the :func:`~email.utils.localtime` function from the :" "mod:`~email.utils` module::" msgstr "" -"これは単純な ``datetime`` であるため、UTC タイムスタンプとして解釈され、結果" -"として ``-0000`` というタイムゾーンを持つ値になります。 もっと便利なのは :" -"mod:`~email.utils` モジュールの :func:`~email.utils.localtime` 関数を使用する" -"ことです::" +"これはnaive な ``datetime`` であるため、UTC タイムスタンプとして解釈され、結" +"果として ``-0000`` というタイムゾーンを持つ値になります。\n" +"もっと便利なのは :mod:`~email.utils` モジュールの :func:`~email.utils." +"localtime` 関数を使用することです。 ::" -#: ../../library/email.headerregistry.rst:174 msgid "msg['Date'] = utils.localtime()" -msgstr "" +msgstr "msg['Date'] = utils.localtime()" #: ../../library/email.headerregistry.rst:176 msgid "" @@ -370,7 +395,6 @@ msgid "" "class:`str` value of the elements of the ``groups`` attribute with ``', '``." msgstr "" -#: ../../library/email.headerregistry.rst:211 msgid "" "A list of :class:`.Address` and :class:`.Group` objects in any combination " "may be used to set the value of an address header. ``Group`` objects whose " @@ -378,28 +402,38 @@ msgid "" "allows an address list to be copied with groups intact by using the list " "obtained from the ``groups`` attribute of the source header." msgstr "" +"アドレスヘッダーの値の設定には、:class:`.Address` と :class:`.Group` オブジェ" +"クトを自由に組み合わせたリストを使えます。\n" +"``display_name`` が ``None`` の ``Group`` オブジェクトは単独のアドレスとして" +"解釈されます。\n" +"このため、元のヘッダーの ``groups`` 属性から得たリストを使えば、グループを保" +"持したままアドレス一覧をコピーできます。" #: ../../library/email.headerregistry.rst:220 msgid "" "A subclass of :class:`.AddressHeader` that adds one additional attribute:" msgstr "追加の属性を 1 つ持つ、:class:`.AddressHeader` の派生クラスです:" -#: ../../library/email.headerregistry.rst:226 msgid "" "The single address encoded by the header value. If the header value " "actually contains more than one address (which would be a violation of the " "RFC under the default :mod:`~email.policy`), accessing this attribute will " "result in a :exc:`ValueError`." msgstr "" +"ヘッダー値で表された単一のアドレスです。\n" +"ヘッダー値に複数のアドレスが含まれる場合 (デフォルトの :mod:`~email.policy` " +"では RFC 違反です)、この属性にアクセスすると :exc:`ValueError` が発生します。" -#: ../../library/email.headerregistry.rst:232 msgid "" "Many of the above classes also have a ``Unique`` variant (for example, " "``UniqueUnstructuredHeader``). The only difference is that in the " "``Unique`` variant, :attr:`~.BaseHeader.max_count` is set to 1." msgstr "" +"上記のクラスの多くには、``Unique`` 版もあります (例えば " +"``UniqueUnstructuredHeader``)。\n" +"違いは、``Unique`` 版では :attr:`~.BaseHeader.max_count` が 1 に設定されるこ" +"とだけです。" -#: ../../library/email.headerregistry.rst:239 msgid "" "There is really only one valid value for the :mailheader:`MIME-Version` " "header, and that is ``1.0``. For future proofing, this header class " @@ -407,6 +441,10 @@ msgid "" "per :rfc:`2045`, then the header object will have non-``None`` values for " "the following attributes:" msgstr "" +":mailheader:`MIME-Version` ヘッダーの有効な値は実際には ``1.0`` だけです。\n" +"将来に備え、このヘッダークラスは他の有効なバージョン番号もサポートします。\n" +"バージョン番号が :rfc:`2045` に照らして有効であれば、ヘッダーオブジェクトの以" +"下の属性は ``None`` 以外の値になります。" #: ../../library/email.headerregistry.rst:247 msgid "" @@ -421,22 +459,24 @@ msgstr "メジャーバージョン番号 (整数)" msgid "The minor version number as an integer" msgstr "マイナーバージョン番号 (整数)" -#: ../../library/email.headerregistry.rst:261 msgid "" "MIME headers all start with the prefix 'Content-'. Each specific header has " "a certain value, described under the class for that header. Some can also " "take a list of supplemental parameters, which have a common format. This " "class serves as a base for all the MIME headers that take parameters." msgstr "" +"MIME ヘッダーはすべて接頭辞 ``Content-`` で始まります。\n" +"各ヘッダーにはそれぞれの値があり、対応するクラスの説明に記載されています。\n" +"また、共通形式の補助パラメータの一覧を持てるものもあります。\n" +"このクラスは、パラメータを持つすべての MIME ヘッダーの基底クラスです。" -#: ../../library/email.headerregistry.rst:268 msgid "A dictionary mapping parameter names to parameter values." -msgstr "" +msgstr "パラメータ名をパラメータ値に対応付ける辞書です。" -#: ../../library/email.headerregistry.rst:270 msgid "" "It is now a :class:`frozendict` instead of a :class:`types.MappingProxyType`." msgstr "" +":class:`types.MappingProxyType` ではなく :class:`frozendict` になりました。" #: ../../library/email.headerregistry.rst:277 msgid "" @@ -446,9 +486,8 @@ msgstr "" ":mailheader:`Content-Type` ヘッダを扱う :class:`ParameterizedMIMEHeader` クラ" "スです。" -#: ../../library/email.headerregistry.rst:282 msgid "The content type string, in the form ``maintype/subtype``." -msgstr "" +msgstr "``maintype/subtype`` 形式のコンテントタイプ文字列。" #: ../../library/email.headerregistry.rst:291 msgid "" @@ -458,9 +497,8 @@ msgstr "" ":mailheader:`Content-Disposition` ヘッダを扱う :class:" "`ParameterizedMIMEHeader` クラスです。" -#: ../../library/email.headerregistry.rst:296 msgid "``inline`` and ``attachment`` are the only valid values in common use." -msgstr "" +msgstr "一般的に使われる有効な値は ``inline`` と ``attachment`` だけです。" #: ../../library/email.headerregistry.rst:301 msgid "Handles the :mailheader:`Content-Transfer-Encoding` header." @@ -474,7 +512,6 @@ msgstr "" "有効な値は ``7bit``、``8bit``、``base64``、``quoted-printable`` です。詳細に" "ついては :rfc:`2045` を参照してください。" -#: ../../library/email.headerregistry.rst:314 msgid "" "This is the factory used by :class:`~email.policy.EmailPolicy` by default. " "``HeaderRegistry`` builds the class used to create a header instance " @@ -486,6 +523,16 @@ msgid "" "initialization. *base_class* is always the last class in the generated " "class's :class:`~type.__bases__` list." msgstr "" +"これは :class:`~email.policy.EmailPolicy` がデフォルトで使うファクトリで" +"す。\n" +"``HeaderRegistry`` は、*base_class* と自身のレジストリから取得した専用クラス" +"を使って、ヘッダーインスタンスを作成するためのクラスを動的に構築します。\n" +"ヘッダー名がレジストリにない場合、*default_class* で指定されたクラスを専用ク" +"ラスとして使います。\n" +"*use_default_map* が ``True`` (デフォルト) の場合、初期化時にヘッダー名からク" +"ラスへの標準の対応付けをレジストリにコピーします。\n" +"*base_class* は常に、生成されたクラスの :class:`~type.__bases__` 一覧の最後の" +"クラスになります。" #: ../../library/email.headerregistry.rst:324 msgid "The default mappings are:" @@ -528,9 +575,8 @@ msgstr "sender" msgid "UniqueSingleAddressHeader" msgstr "UniqueSingleAddressHeader" -#: ../../library/email.headerregistry.rst:0 msgid "resent-sender" -msgstr "" +msgstr "resent-sender" #: ../../library/email.headerregistry.rst:331 msgid "SingleAddressHeader" @@ -567,13 +613,11 @@ msgstr "cc" msgid "resent-cc" msgstr "resent-cc" -#: ../../library/email.headerregistry.rst:0 msgid "bcc" -msgstr "" +msgstr "bcc" -#: ../../library/email.headerregistry.rst:0 msgid "resent-bcc" -msgstr "" +msgstr "resent-bcc" #: ../../library/email.headerregistry.rst:0 msgid "from" @@ -587,63 +631,54 @@ msgstr "resent-from" msgid "reply-to" msgstr "reply-to" -#: ../../library/email.headerregistry.rst:0 msgid "mime-version" -msgstr "" +msgstr "mime-version" -#: ../../library/email.headerregistry.rst:341 msgid "MIMEVersionHeader" -msgstr "" +msgstr "MIMEVersionHeader" -#: ../../library/email.headerregistry.rst:0 msgid "content-type" -msgstr "" +msgstr "content-type" -#: ../../library/email.headerregistry.rst:342 msgid "ContentTypeHeader" -msgstr "" +msgstr "ContentTypeHeader" -#: ../../library/email.headerregistry.rst:0 msgid "content-disposition" -msgstr "" +msgstr "content-disposition" -#: ../../library/email.headerregistry.rst:343 msgid "ContentDispositionHeader" -msgstr "" +msgstr "ContentDispositionHeader" -#: ../../library/email.headerregistry.rst:0 msgid "content-transfer-encoding" -msgstr "" +msgstr "content-transfer-encoding" -#: ../../library/email.headerregistry.rst:344 msgid "ContentTransferEncodingHeader" -msgstr "" +msgstr "ContentTransferEncodingHeader" -#: ../../library/email.headerregistry.rst:0 msgid "message-id" -msgstr "" +msgstr "message-id" -#: ../../library/email.headerregistry.rst:345 msgid "MessageIDHeader" -msgstr "" +msgstr "MessageIDHeader" #: ../../library/email.headerregistry.rst:347 msgid "``HeaderRegistry`` has the following methods:" msgstr "``HeaderRegistry`` には以下のメソッドがあります:" -#: ../../library/email.headerregistry.rst:352 msgid "" "*name* is the name of the header to be mapped. It will be converted to " "lower case in the registry. *cls* is the specialized class to be used, " "along with *base_class*, to create the class used to instantiate headers " "that match *name*." msgstr "" +"*name* は対応付けるヘッダーの名前です。\n" +"レジストリ内では小文字に変換されます。\n" +"*cls* は専用クラスで、*base_class* と組み合わせて、*name* に一致するヘッダー" +"をインスタンス化するクラスの作成に使われます。" -#: ../../library/email.headerregistry.rst:360 msgid "Construct and return a class to handle creating a *name* header." -msgstr "" +msgstr "*name* ヘッダーの作成を担当するクラスを構築して返します。" -#: ../../library/email.headerregistry.rst:365 msgid "" "Retrieves the specialized header associated with *name* from the registry " "(using *default_class* if *name* does not appear in the registry) and " @@ -651,13 +686,19 @@ msgid "" "class's constructor, passing it the same argument list, and finally returns " "the class instance created thereby." msgstr "" +"*name* に関連付けられた専用ヘッダークラスをレジストリから取得します (*name* " +"がレジストリになければ *default_class* を使います)。\n" +"それを *base_class* と組み合わせてクラスを作成し、同じ引数リストを渡してその" +"コンストラクタを呼び出し、生成されたインスタンスを返します。" -#: ../../library/email.headerregistry.rst:372 msgid "" "The following classes are the classes used to represent data parsed from " "structured headers and can, in general, be used by an application program to " "construct structured values to assign to specific headers." msgstr "" +"以下のクラスは、構造化ヘッダーから解析したデータの表現に使われます。\n" +"通常、アプリケーションからも、特定のヘッダーに代入する構造化された値の作成に" +"使えます。" #: ../../library/email.headerregistry.rst:379 msgid "" @@ -667,25 +708,21 @@ msgstr "" "このクラスは電子メールのアドレスを表すのに使われます。アドレスの一般的な形式" "は::" -#: ../../library/email.headerregistry.rst:382 msgid "[display_name] " -msgstr "" +msgstr "[display_name] " #: ../../library/email.headerregistry.rst:384 msgid "or::" msgstr "もしくは::" -#: ../../library/email.headerregistry.rst:386 msgid "username@domain" -msgstr "" +msgstr "username@domain" -#: ../../library/email.headerregistry.rst:388 msgid "" "where each part must conform to specific syntax rules spelled out in :rfc:" "`5322`." -msgstr "" +msgstr "各部分は :rfc:`5322` で定められた構文規則に従う必要があります。" -#: ../../library/email.headerregistry.rst:391 msgid "" "As a convenience *addr_spec* can be specified instead of *username* and " "*domain*, in which case *username* and *domain* will be parsed from the " @@ -694,13 +731,22 @@ msgid "" "will be property encoded when serialized. However, per the RFCs, Unicode is " "*not* allowed in the username portion of the address." msgstr "" +"便利な方法として、*username* と *domain* の代わりに *addr_spec* を指定できま" +"す。\n" +"この場合、*username* と *domain* は *addr_spec* から解析されます。\n" +"*addr_spec* は RFC に従って正しく引用符を付けた文字列でなければならず、そうで" +"なければ ``Address`` はエラーを送出します。\n" +"Unicode 文字も使用でき、直列化時に適切にエンコードされます。\n" +"ただし、RFC に従い、アドレスのユーザー名部分では Unicode は許可 *されません" +"*。" -#: ../../library/email.headerregistry.rst:400 msgid "" "The display name portion of the address, if any, with all quoting removed. " "If the address does not have a display name, this attribute will be an empty " "string." msgstr "" +"アドレスの表示名部分で、引用符はすべて取り除かれます。\n" +"アドレスに表示名がなければ、空文字列になります。" #: ../../library/email.headerregistry.rst:406 msgid "The ``username`` portion of the address, with all quoting removed." @@ -710,25 +756,31 @@ msgstr "アドレスの ``username`` 部分、クォートは取り除かれま msgid "The ``domain`` portion of the address." msgstr "アドレスの ``domain`` 部分。" -#: ../../library/email.headerregistry.rst:414 msgid "" "The ``username@domain`` portion of the address, correctly quoted for use as " "a bare address (the second form shown above). This attribute is not mutable." msgstr "" +"アドレスの ``username@domain`` 部分で、表示名のないアドレス (上記の 2 番目の" +"形式) として使えるよう正しく引用符が付けられます。\n" +"この属性は変更できません。" -#: ../../library/email.headerregistry.rst:420 msgid "" "The ``str`` value of the object is the address quoted according to :rfc:" "`5322` rules, but with no Content Transfer Encoding of any non-ASCII " "characters." msgstr "" +"オブジェクトの ``str`` 値は、:rfc:`5322` の規則に従って引用符を付けたアドレス" +"ですが、非 ASCII 文字にコンテンツ転送エンコーディングは適用されません。" -#: ../../library/email.headerregistry.rst:424 msgid "" "To support SMTP (:rfc:`5321`), ``Address`` handles one special case: if " "``username`` and ``domain`` are both the empty string (or ``None``), then " "the string value of the ``Address`` is ``<>``." msgstr "" +"SMTP (:rfc:`5321`) をサポートするため、``Address`` は一つの特殊な場合を扱いま" +"す。\n" +"``username`` と ``domain`` が両方とも空文字列 (または ``None``) の場合、" +"``Address`` の文字列値は ``<>`` になります。" #: ../../library/email.headerregistry.rst:431 msgid "" @@ -738,32 +790,36 @@ msgstr "" "このクラスはアドレスグループを表すのに使われます。アドレスグループの一般的な" "形式は::" -#: ../../library/email.headerregistry.rst:434 msgid "display_name: [address-list];" -msgstr "" +msgstr "display_name: [address-list];" -#: ../../library/email.headerregistry.rst:436 msgid "" "As a convenience for processing lists of addresses that consist of a mixture " "of groups and single addresses, a ``Group`` may also be used to represent " "single addresses that are not part of a group by setting *display_name* to " "``None`` and providing a list of the single address as *addresses*." msgstr "" +"グループと単独のアドレスが混在する一覧を扱いやすくするため、``Group`` でグ" +"ループに属さない単独のアドレスを表すこともできます。\n" +"その場合、*display_name* を ``None`` にし、*addresses* にそのアドレスだけを含" +"むリストを渡します。" -#: ../../library/email.headerregistry.rst:443 msgid "" "The ``display_name`` of the group. If it is ``None`` and there is exactly " "one ``Address`` in ``addresses``, then the ``Group`` represents a single " "address that is not in a group." msgstr "" +"グループの ``display_name`` です。\n" +"値が ``None`` で、``addresses`` に ``Address`` がちょうど一つある場合、その " +"``Group`` はグループに属さない単独のアドレスを表します。" -#: ../../library/email.headerregistry.rst:449 msgid "" "A possibly empty tuple of :class:`.Address` objects representing the " "addresses in the group." msgstr "" +"グループ内のアドレスを表す :class:`.Address` オブジェクトのタプルです。\n" +"空の場合もあります。" -#: ../../library/email.headerregistry.rst:454 msgid "" "The ``str`` value of a ``Group`` is formatted according to :rfc:`5322`, but " "with no Content Transfer Encoding of any non-ASCII characters. If " @@ -771,12 +827,17 @@ msgid "" "``addresses`` list, the ``str`` value will be the same as the ``str`` of " "that single ``Address``." msgstr "" +"``Group`` の ``str`` 値は :rfc:`5322` に従って書式化されますが、非 ASCII 文字" +"にコンテンツ転送エンコーディングは適用されません。\n" +"``display_name`` が ``None`` で、``addresses`` リストに ``Address`` が一つだ" +"けある場合、``str`` 値はその ``Address`` の ``str`` 値と同じになります。" #: ../../library/email.headerregistry.rst:462 msgid "Footnotes" msgstr "脚注" -#: ../../library/email.headerregistry.rst:463 msgid "" "Originally added in 3.3 as a :term:`provisional module `" msgstr "" +"当初は 3.3 で :term:`暫定モジュール ` として追加されまし" +"た。" diff --git a/library/email.iterators.po b/library/email.iterators.po index 144d16b01..d760b27bf 100644 --- a/library/email.iterators.po +++ b/library/email.iterators.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.iterators.rst:2 @@ -30,13 +30,16 @@ msgstr ":mod:`!email.iterators`: イテレータ" msgid "**Source code:** :source:`Lib/email/iterators.py`" msgstr "**ソースコード:** :source:`Lib/email/iterators.py`" -#: ../../library/email.iterators.rst:11 msgid "" "Iterating over a message object tree is fairly easy with the :meth:`Message." "walk ` method. The :mod:`!email.iterators` " "module provides some useful higher level iterations over message object " "trees." msgstr "" +":meth:`Message.walk ` を使うと、メッセージオブ" +"ジェクトのツリーを簡単に反復処理できます。\n" +":mod:`!email.iterators` モジュールは、メッセージオブジェクトのツリーに対する" +"便利な高水準の反復処理を提供します。" #: ../../library/email.iterators.rst:19 msgid "" @@ -104,7 +107,6 @@ msgstr "" "そのメッセージオブジェクト構造の content-type をインデントつきで表示します。" "例えば:" -#: ../../library/email.iterators.rst:57 msgid "" ">>> msg = email.message_from_file(somefile)\n" ">>> _structure(msg)\n" @@ -124,6 +126,23 @@ msgid "" " text/plain\n" " text/plain" msgstr "" +">>> msg = email.message_from_file(somefile)\n" +">>> _structure(msg)\n" +"multipart/mixed\n" +" text/plain\n" +" text/plain\n" +" multipart/digest\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" message/rfc822\n" +" text/plain\n" +" text/plain" #: ../../library/email.iterators.rst:81 msgid "" diff --git a/library/email.message.po b/library/email.message.po index 826144f99..51fc9e214 100644 --- a/library/email.message.po +++ b/library/email.message.po @@ -16,15 +16,14 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.message.rst:2 msgid ":mod:`!email.message`: Representing an email message" -msgstr "" +msgstr ":mod:`!email.message`: 電子メールメッセージの表現" #: ../../library/email.message.rst:7 msgid "**Source code:** :source:`Lib/email/message.py`" @@ -34,7 +33,6 @@ msgstr "**ソースコード:** :source:`Lib/email/message.py`" msgid "[1]_" msgstr "[1]_" -#: ../../library/email.message.rst:13 msgid "" "The central class in the :mod:`email` package is the :class:`EmailMessage` " "class, imported from the :mod:`!email.message` module. It is the base class " @@ -42,8 +40,12 @@ msgid "" "functionality for setting and querying header fields, for accessing message " "bodies, and for creating or modifying structured messages." msgstr "" +":mod:`email` パッケージの中心となるクラスは、:mod:`!email.message` モジュール" +"からインポートする :class:`EmailMessage` です。\n" +"これは :mod:`email` のオブジェクトモデルの基底クラスです。\n" +":class:`EmailMessage` は、ヘッダーフィールドの設定と参照、メッセージ本体への" +"アクセス、構造化されたメッセージの作成や変更に関する中核の機能を提供します。" -#: ../../library/email.message.rst:19 msgid "" "An email message consists of *headers* and a *payload* (which is also " "referred to as the *content*). Headers are :rfc:`5322` or :rfc:`6532` style " @@ -55,8 +57,17 @@ msgid "" "having a MIME type such as :mimetype:`multipart/\\*` or :mimetype:`message/" "rfc822`." msgstr "" +"電子メールメッセージは *ヘッダー* と *ペイロード* (*コンテンツ* とも呼ばれま" +"す) からなります。\n" +"ヘッダーは :rfc:`5322` または :rfc:`6532` 形式のフィールド名と値で、両者はコ" +"ロンで区切られます。\n" +"コロンはフィールド名にも値にも含まれません。\n" +"ペイロードには、単純なテキストメッセージ、バイナリオブジェクト、または各々が" +"独自のヘッダーとペイロードを持つサブメッセージを構造化して並べたものを使えま" +"す。\n" +"最後の形式のペイロードは、メッセージの MIME 型が :mimetype:`multipart/\\*` " +"や :mimetype:`message/rfc822` などの場合に使われます。" -#: ../../library/email.message.rst:28 msgid "" "The conceptual model provided by an :class:`EmailMessage` object is that of " "an ordered dictionary of headers coupled with a *payload* that represents " @@ -67,8 +78,14 @@ msgid "" "type), for operating on the payload, for generating a serialized version of " "the message, and for recursively walking over the object tree." msgstr "" +":class:`EmailMessage` オブジェクトは概念的には、ヘッダーの順序付き辞書と、:" +"rfc:`5322` のメッセージ本体を表す *ペイロード* を組み合わせたものです。\n" +"ペイロードはサブメッセージの ``EmailMessage`` オブジェクトのリストになること" +"もあります。\n" +"ヘッダーの名前と値にアクセスする通常の辞書メソッドに加え、MIME コンテントタイ" +"プなどのヘッダーの特定の情報へのアクセス、ペイロードの操作、メッセージの直列" +"化、オブジェクトツリーの再帰的な巡回のためのメソッドがあります。" -#: ../../library/email.message.rst:37 msgid "" "The :class:`EmailMessage` dictionary-like interface is indexed by the header " "names, which must be ASCII values. The values of the dictionary are strings " @@ -77,16 +94,25 @@ msgid "" "but unlike a real dict, there can be duplicates. Additional methods are " "provided for working with headers that have duplicate keys." msgstr "" +":class:`EmailMessage` の辞書に似たインターフェースは、ASCII 値でなければなら" +"ないヘッダー名をキーとします。\n" +"辞書の値は、追加のメソッドを持つ文字列です。\n" +"ヘッダーの格納時と取得時には大文字・小文字が保持されますが、フィールド名の照" +"合では区別されません。\n" +"キーには順序がありますが、通常の辞書と異なり重複できます。\n" +"キーが重複するヘッダーを扱うための追加のメソッドも用意されています。" -#: ../../library/email.message.rst:44 msgid "" "The *payload* is either a string or bytes object, in the case of simple " "message objects, or a list of :class:`EmailMessage` objects, for MIME " "container documents such as :mimetype:`multipart/\\*` and :mimetype:`message/" "rfc822` message objects." msgstr "" +"*ペイロード* は、単純なメッセージオブジェクトでは文字列または bytes オブジェ" +"クトです。\n" +":mimetype:`multipart/\\*` や :mimetype:`message/rfc822` などの MIME コンテナ" +"文書では、:class:`EmailMessage` オブジェクトのリストです。" -#: ../../library/email.message.rst:52 msgid "" "If *policy* is specified use the rules it specifies to update and serialize " "the representation of the message. If *policy* is not set, use the :class:" @@ -95,8 +121,13 @@ msgid "" "Python standard ``\\n`` line endings). For more information see the :mod:" "`~email.policy` documentation. [2]_" msgstr "" +"*policy* が指定されていれば、その規則に従ってメッセージの表現を更新し、直列化" +"します。\n" +"指定されていなければ :class:`~email.policy.default` ポリシーを使います。\n" +"このポリシーは電子メールの RFC の規則に従いますが、行末だけは RFC が要求する " +"``\\r\\n`` の代わりに Python 標準の ``\\n`` を使います。\n" +"詳しくは :mod:`~email.policy` のドキュメントを参照してください。[2]_" -#: ../../library/email.message.rst:61 msgid "" "Return the entire message flattened as a string. When optional *unixfrom* " "is true, the envelope header is included in the returned string. *unixfrom* " @@ -109,6 +140,18 @@ msgid "" "produced by the method, since the specified *policy* will be passed to the :" "class:`~email.generator.Generator`." msgstr "" +"メッセージ全体をフラット化した文字列を返します。\n" +"オプションの *unixfrom* が真の場合、戻り値にはエンベロープヘッダーが含まれま" +"す。\n" +"*unixfrom* のデフォルトは ``False`` です。\n" +"基底クラス :class:`~email.message.Message` との後方互換性のため " +"*maxheaderlen* を受け取りますが、デフォルトは ``None`` です。\n" +"したがって、デフォルトではポリシーの :attr:`~email.policy.Policy." +"max_line_length` が行長を制御します。\n" +"*policy* 引数で、メッセージインスタンスから取得するデフォルトのポリシーを上書" +"きできます。\n" +"指定した *policy* は :class:`~email.generator.Generator` に渡されるため、メ" +"ソッドが生成する書式の一部を制御できます。" #: ../../library/email.message.rst:73 ../../library/email.message.rst:111 msgid "" @@ -120,7 +163,6 @@ msgstr "" "メッセージのフラット化は :class:`EmailMessage` の変更を引き起こす可能性があり" "ます (例えば、MIME の境界が生成される、変更される等)。" -#: ../../library/email.message.rst:77 msgid "" "Note that this method is provided as a convenience and may not be the most " "useful way to serialize messages in your application, especially if you are " @@ -129,29 +171,39 @@ msgid "" "restricted to producing messages serialized as \"7 bit clean\" when :attr:" "`~email.policy.EmailPolicy.utf8` is ``False``, which is the default." msgstr "" +"このメソッドは便利な補助機能として提供されており、特に複数のメッセージを扱う" +"場合には、アプリケーションに最適な直列化方法とは限りません。\n" +"より柔軟な直列化 API については :class:`email.generator.Generator` を参照して" +"ください。\n" +"また、:attr:`~email.policy.EmailPolicy.utf8` が ``False`` (デフォルト) の場" +"合、このメソッドが生成できるのは 7 ビットだけを使う形式に直列化されたメッセー" +"ジに限られます。" -#: ../../library/email.message.rst:85 msgid "" "the default behavior when *maxheaderlen* is not specified was changed from " "defaulting to 0 to defaulting to the value of *max_line_length* from the " "policy." msgstr "" +"*maxheaderlen* を指定しない場合のデフォルトの動作が、値 0 を使う動作から、ポ" +"リシーの *max_line_length* の値を使う動作に変わりました。" -#: ../../library/email.message.rst:92 msgid "" "Equivalent to ``as_string(policy=self.policy.clone(utf8=True))``. Allows " "``str(msg)`` to produce a string containing the serialized message in a " "readable format." msgstr "" +"``as_string(policy=self.policy.clone(utf8=True))`` と同じです。\n" +"``str(msg)`` で、読みやすい形式に直列化されたメッセージを含む文字列を生成でき" +"るようにします。" -#: ../../library/email.message.rst:96 msgid "" "the method was changed to use ``utf8=True``, thus producing an :rfc:`6531`-" "like message representation, instead of being a direct alias for :meth:" "`as_string`." msgstr "" +":meth:`as_string` の単なる別名ではなく、``utf8=True`` を使って :rfc:`6531` に" +"似たメッセージ表現を生成するように変わりました。" -#: ../../library/email.message.rst:103 msgid "" "Return the entire message flattened as a bytes object. When optional " "*unixfrom* is true, the envelope header is included in the returned string. " @@ -161,22 +213,34 @@ msgid "" "specified *policy* will be passed to the :class:`~email.generator." "BytesGenerator`." msgstr "" +"メッセージ全体をフラット化した bytes オブジェクトを返します。\n" +"オプションの *unixfrom* が真の場合、戻り値にはエンベロープヘッダーが含まれま" +"す。\n" +"*unixfrom* のデフォルトは ``False`` です。\n" +"*policy* 引数で、メッセージインスタンスから取得するデフォルトのポリシーを上書" +"きできます。\n" +"指定した *policy* は :class:`~email.generator.BytesGenerator` に渡されるた" +"め、メソッドが生成する書式の一部を制御できます。" -#: ../../library/email.message.rst:115 msgid "" "Note that this method is provided as a convenience and may not be the most " "useful way to serialize messages in your application, especially if you are " "dealing with multiple messages. See :class:`email.generator.BytesGenerator` " "for a more flexible API for serializing messages." msgstr "" +"このメソッドは便利な補助機能として提供されており、特に複数のメッセージを扱う" +"場合には、アプリケーションに最適な直列化方法とは限りません。\n" +"より柔軟な直列化 API については :class:`email.generator.BytesGenerator` を参" +"照してください。" -#: ../../library/email.message.rst:124 msgid "" "Equivalent to :meth:`.as_bytes`. Allows ``bytes(msg)`` to produce a bytes " "object containing the serialized message." msgstr "" +":meth:`.as_bytes` と同じです。\n" +"``bytes(msg)`` で、直列化されたメッセージを含む bytes オブジェクトを生成でき" +"るようにします。" -#: ../../library/email.message.rst:130 msgid "" "Return ``True`` if the message's payload is a list of sub-\\ :class:" "`EmailMessage` objects, otherwise return ``False``. When :meth:" @@ -187,12 +251,23 @@ msgid "" "example, ``is_multipart`` will return ``True`` when the :class:" "`EmailMessage` is of type ``message/rfc822``." msgstr "" +"メッセージのペイロードがサブメッセージの :class:`EmailMessage` オブジェクトの" +"リストなら ``True`` を、それ以外なら ``False`` を返します。\n" +":meth:`is_multipart` が ``False`` を返す場合、ペイロードは文字列オブジェクト" +"のはずです (CTE でエンコードされたバイナリのペイロードの場合もあります)。\n" +":meth:`is_multipart` が ``True`` を返しても、``msg.get_content_maintype() == " +"'multipart'`` が ``True`` を返すとは限りません。\n" +"例えば、:class:`EmailMessage` の型が ``message/rfc822`` の場合も " +"``is_multipart()`` は ``True`` を返します。" -#: ../../library/email.message.rst:142 msgid "" "Set the message's envelope header to *unixfrom*, which should be a string. " "(See :class:`~mailbox.mboxMessage` for a brief description of this header.)" msgstr "" +"メッセージのエンベロープヘッダーを *unixfrom* に設定します。\n" +"*unixfrom* は文字列でなければなりません。\n" +"(このヘッダーの簡単な説明は :class:`~mailbox.mboxMessage` を参照してくださ" +"い。)" #: ../../library/email.message.rst:149 msgid "" @@ -216,11 +291,12 @@ msgid "" "list." msgstr "" -#: ../../library/email.message.rst:164 msgid "" "These semantic differences are intentional and are biased toward convenience " "in the most common use cases." msgstr "" +"このような意味の違いは意図的なもので、一般的な用途で便利になるように設計され" +"ています。" #: ../../library/email.message.rst:167 msgid "" @@ -234,39 +310,50 @@ msgstr "" msgid "Return the total number of headers, including duplicates." msgstr "複製されたものもふくめてヘッダ数の合計を返します。" -#: ../../library/email.message.rst:178 msgid "" "Return ``True`` if the message object has a field named *name*. Matching is " "done without regard to case and *name* does not include the trailing colon. " "Used for the ``in`` operator. For example::" msgstr "" +"メッセージオブジェクトに *name* という名前のフィールドがあれば ``True`` を返" +"します。\n" +"照合では大文字・小文字を区別せず、*name* に末尾のコロンは含めません。\n" +"``in`` 演算子で使われます。\n" +"例えば次のようにします。 ::" -#: ../../library/email.message.rst:182 msgid "" "if 'message-id' in myMessage:\n" " print('Message-ID:', myMessage['message-id'])" msgstr "" +"if 'message-id' in myMessage:\n" +" print('Message-ID:', myMessage['message-id'])" -#: ../../library/email.message.rst:188 msgid "" "Return the value of the named header field. *name* does not include the " "colon field separator. If the header is missing, ``None`` is returned; a :" "exc:`KeyError` is never raised." msgstr "" +"指定した名前のヘッダーフィールドの値を返します。\n" +"*name* にフィールド区切りのコロンは含めません。\n" +"ヘッダーがなければ ``None`` を返し、:exc:`KeyError` は送出しません。" -#: ../../library/email.message.rst:192 msgid "" "Note that if the named field appears more than once in the message's " "headers, exactly which of those field values will be returned is undefined. " "Use the :meth:`get_all` method to get the values of all the extant headers " "named *name*." msgstr "" +"指定した名前のフィールドがメッセージのヘッダーに複数ある場合、どの値を返すか" +"は未定義です。\n" +"*name* という名前の既存のヘッダーの値をすべて取得するには、:meth:`get_all` を" +"使ってください。" -#: ../../library/email.message.rst:197 msgid "" "Using the standard (non-``compat32``) policies, the returned value is an " "instance of a subclass of :class:`email.headerregistry.BaseHeader`." msgstr "" +"標準の (``compat32`` 以外の) ポリシーでは、戻り値は :class:`email." +"headerregistry.BaseHeader` のサブクラスのインスタンスです。" #: ../../library/email.message.rst:203 msgid "" @@ -287,13 +374,13 @@ msgstr "" "せん*。もしメッセージが名前 *name* をもつフィールドをひとつしか持たないように" "したければ、最初にそれを除去してください。たとえば::" -#: ../../library/email.message.rst:210 msgid "" "del msg['subject']\n" "msg['subject'] = 'Python roolz!'" msgstr "" +"del msg['subject']\n" +"msg['subject'] = 'Python roolz!'" -#: ../../library/email.message.rst:213 msgid "" "If the :mod:`policy ` defines certain headers to be unique (as " "the standard policies do), this method may raise a :exc:`ValueError` when an " @@ -302,6 +389,12 @@ msgid "" "as we may choose to make such assignments do an automatic deletion of the " "existing header in the future." msgstr "" +"標準のポリシーのように、:mod:`ポリシー ` が特定のヘッダーを一つ" +"しか許さないと定めている場合、そのヘッダーがすでにある状態で値を代入しようと" +"すると、このメソッドは :exc:`ValueError` を送出することがあります。\n" +"一貫性を保つための意図的な動作ですが、将来はこのような代入で既存のヘッダーを" +"自動的に削除するよう変更する可能性があるため、この動作に依存しないでくださ" +"い。" #: ../../library/email.message.rst:223 msgid "" @@ -328,16 +421,17 @@ msgstr "" "メッセージ中にあるすべてのヘッダのフィールド名とその値を 2-タプルのリストとし" "て返します。" -#: ../../library/email.message.rst:246 msgid "" "Return the value of the named header field. This is identical to :meth:" "`~object.__getitem__` except that optional *failobj* is returned if the " "named header is missing (*failobj* defaults to ``None``)." msgstr "" +"指定した名前のヘッダーフィールドの値を返します。\n" +":meth:`~object.__getitem__` と同じですが、ヘッダーがない場合にオプションの " +"*failobj* (デフォルトは ``None``) を返す点が異なります。" -#: ../../library/email.message.rst:251 msgid "Here are some additional useful header related methods:" -msgstr "" +msgstr "ヘッダーに関する便利な追加のメソッドを以下に示します。" #: ../../library/email.message.rst:256 msgid "" @@ -349,18 +443,18 @@ msgstr "" "前のヘッダがメッセージ中に含まれていない場合は *failobj* (デフォルトでは " "``None``) が返されます。" -#: ../../library/email.message.rst:263 msgid "" "Extended header setting. This method is similar to :meth:`__setitem__` " "except that additional header parameters can be provided as keyword " "arguments. *_name* is the header field to add and *_value* is the *primary* " "value for the header." msgstr "" -"拡張ヘッダ設定。このメソッドは :meth:`__setitem__` と似ていますが、追加のヘッ" -"ダ・パラメータをキーワード引数で指定できるところが違っています。 *_name* に追" -"加するヘッダフィールドを、 *_value* にそのヘッダの *最初の* 値を渡します。" +"拡張ヘッダ設定。\n" +"このメソッドは :meth:`__setitem__` と似ていますが、追加のヘッダ・パラメータを" +"キーワード引数で指定できるところが違っています。\n" +"*_name* に追加するヘッダフィールドを、 *_value* にそのヘッダの *主たる* 値を" +"渡します。" -#: ../../library/email.message.rst:268 msgid "" "For each item in the keyword argument dictionary *_params*, the key is taken " "as the parameter name, with underscores converted to dashes (since dashes " @@ -368,8 +462,12 @@ msgid "" "as ``key=\"value\"`` unless the value is ``None``, in which case only the " "key will be added." msgstr "" +"キーワード引数の辞書 *_params* の各項目では、キーをパラメータ名として使い、ア" +"ンダースコアをハイフンに変換します (Python の識別子ではハイフンを使えないため" +"です)。\n" +"通常は ``key=\"value\"`` の形式でパラメータを追加しますが、値が ``None`` の場" +"合はキーだけを追加します。" -#: ../../library/email.message.rst:274 msgid "" "If the value contains non-ASCII characters, the charset and language may be " "explicitly controlled by specifying the value as a three tuple in the format " @@ -381,41 +479,51 @@ msgid "" "automatically encoded in :rfc:`2231` format using a ``CHARSET`` of ``utf-8`` " "and a ``LANGUAGE`` of ``None``." msgstr "" +"値に非 ASCII 文字が含まれる場合、``(CHARSET, LANGUAGE, VALUE)`` 形式の 3 要素" +"タプルを指定することで、文字セットと言語を明示的に制御できます。\n" +"``CHARSET`` は値のエンコードに使う文字セットの名前です。\n" +"``LANGUAGE`` は通常 ``None`` または空文字列にできます (他の指定については :" +"rfc:`2231` を参照してください)。\n" +"``VALUE`` は非 ASCII コードポイントを含む文字列値です。\n" +"3 要素タプルを渡さず、値に非 ASCII 文字が含まれている場合は、``CHARSET`` を " +"``utf-8``、``LANGUAGE`` を ``None`` として :rfc:`2231` 形式で自動的にエンコー" +"ドされます。" #: ../../library/email.message.rst:284 msgid "Here is an example::" msgstr "以下に例を示します。::" -#: ../../library/email.message.rst:286 msgid "msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" msgstr "" +"msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')" #: ../../library/email.message.rst:288 msgid "This will add a header that looks like ::" msgstr "こうするとヘッダには以下のように追加されます ::" -#: ../../library/email.message.rst:290 msgid "Content-Disposition: attachment; filename=\"bud.gif\"" -msgstr "" +msgstr "Content-Disposition: attachment; filename=\"bud.gif\"" -#: ../../library/email.message.rst:292 msgid "An example of the extended interface with non-ASCII characters::" -msgstr "" +msgstr "拡張インターフェースで非 ASCII 文字を使う例です。 ::" -#: ../../library/email.message.rst:294 msgid "" "msg.add_header('Content-Disposition', 'attachment',\n" " filename=('iso-8859-1', '', 'Fußballer.ppt'))" msgstr "" +"msg.add_header('Content-Disposition', 'attachment',\n" +" filename=('iso-8859-1', '', 'Fußballer.ppt'))" -#: ../../library/email.message.rst:300 msgid "" "Replace a header. Replace the first header found in the message that " "matches *_name*, retaining header order and field name case of the original " "header. If no matching header is found, raise a :exc:`KeyError`." msgstr "" +"ヘッダーを置き換えます。\n" +"*_name* に一致する最初のヘッダーを、元のヘッダーの順序とフィールド名の大文" +"字・小文字を保ったまま置き換えます。\n" +"一致するヘッダーがなければ :exc:`KeyError` を送出します。" -#: ../../library/email.message.rst:308 msgid "" "Return the message's content type, coerced to lower case of the form :" "mimetype:`maintype/subtype`. If there is no :mailheader:`Content-Type` " @@ -423,8 +531,12 @@ msgid "" "`get_default_type`. If the :mailheader:`Content-Type` header is invalid, " "return ``text/plain``." msgstr "" +"メッセージのコンテントタイプを、小文字の :mimetype:`maintype/subtype` 形式で" +"返します。\n" +"メッセージに :mailheader:`Content-Type` ヘッダーがない場合は、:meth:" +"`get_default_type` の戻り値を返します。\n" +":mailheader:`Content-Type` ヘッダーが不正な場合は ``text/plain`` を返します。" -#: ../../library/email.message.rst:314 msgid "" "(According to :rfc:`2045`, messages always have a default type, :meth:" "`get_content_type` will always return a value. :rfc:`2045` defines a " @@ -434,6 +546,13 @@ msgid "" "invalid type specification, :rfc:`2045` mandates that the default type be :" "mimetype:`text/plain`.)" msgstr "" +"(:rfc:`2045` によると、メッセージは常にデフォルトの型を持つため、:meth:" +"`get_content_type` は常に値を返します。\n" +":rfc:`2045` はデフォルトの型を :mimetype:`text/plain` と定めていますが、:" +"mimetype:`multipart/digest` コンテナ内では :mimetype:`message/rfc822` と定め" +"ています。\n" +":mailheader:`Content-Type` ヘッダーの型指定が不正な場合、:rfc:`2045` はデフォ" +"ルトの型を :mimetype:`text/plain` とするよう要求しています。)" #: ../../library/email.message.rst:325 msgid "" @@ -464,7 +583,6 @@ msgstr "" "`multipart/digest` コンテナに含まれているときだけ例外的に :mimetype:`message/" "rfc822` になります。" -#: ../../library/email.message.rst:345 msgid "" "Set the default content type. *ctype* should either be :mimetype:`text/" "plain` or :mimetype:`message/rfc822`, although this is not enforced. The " @@ -472,8 +590,13 @@ msgid "" "so it only affects the return value of the ``get_content_type`` methods when " "no :mailheader:`Content-Type` header is present in the message." msgstr "" +"デフォルトのコンテントタイプを設定します。\n" +"強制はされませんが、*ctype* は :mimetype:`text/plain` または :mimetype:" +"`message/rfc822` にしてください。\n" +"デフォルトのコンテントタイプは :mailheader:`Content-Type` ヘッダーには格納さ" +"れないため、メッセージに :mailheader:`Content-Type` ヘッダーがない場合の " +"``get_content_type()`` の戻り値にだけ影響します。" -#: ../../library/email.message.rst:356 msgid "" "Set a parameter in the :mailheader:`Content-Type` header. If the parameter " "already exists in the header, replace its value with *value*. When *header* " @@ -482,6 +605,13 @@ msgid "" "parameter value. Optional *header* specifies an alternative header to :" "mailheader:`Content-Type`." msgstr "" +":mailheader:`Content-Type` ヘッダーにパラメータを設定します。\n" +"パラメータがすでにあれば、その値を *value* に置き換えます。\n" +"*header* が ``Content-Type`` (デフォルト) で、そのヘッダーがメッセージにまだ" +"ない場合、値を :mimetype:`text/plain` としてヘッダーを追加し、新しいパラメー" +"タ値を付け加えます。\n" +"オプションの *header* は、:mailheader:`Content-Type` の代わりに使うヘッダーを" +"指定します。" #: ../../library/email.message.rst:363 msgid "" @@ -493,25 +623,29 @@ msgid "" "*language*." msgstr "" -#: ../../library/email.message.rst:370 msgid "" "If *replace* is ``False`` (the default) the header is moved to the end of " "the list of headers. If *replace* is ``True``, the header will be updated " "in place." msgstr "" +"*replace* が ``False`` (デフォルト) の場合、ヘッダーはヘッダー一覧の末尾に移" +"動します。\n" +"*replace* が ``True`` の場合は、元の位置で更新されます。" -#: ../../library/email.message.rst:374 ../../library/email.message.rst:391 msgid "" "Use of the *requote* parameter with :class:`EmailMessage` objects is " "deprecated." msgstr "" +":class:`EmailMessage` オブジェクトでの *requote* 引数の使用は非推奨です。" -#: ../../library/email.message.rst:377 msgid "" "Note that existing parameter values of headers may be accessed through the :" "attr:`~email.headerregistry.ParameterizedMIMEHeader.params` attribute of the " "header value (for example, ``msg['Content-Type'].params['charset']``)." msgstr "" +"ヘッダーの既存のパラメータ値には、ヘッダー値の :attr:`~email.headerregistry." +"ParameterizedMIMEHeader.params` 属性からアクセスできます (例えば " +"``msg['Content-Type'].params['charset']``)。" #: ../../library/email.message.rst:381 msgid "``replace`` keyword was added." @@ -568,24 +702,27 @@ msgstr "" "quote します。そのメッセージが :mailheader:`Content-Type` ヘッダを含んでいな" "い場合、 :exc:`~email.errors.HeaderParseError` が発生します。" -#: ../../library/email.message.rst:421 msgid "" "Note that using this method is subtly different from deleting the old :" "mailheader:`Content-Type` header and adding a new one with the new boundary " "via :meth:`add_header`, because :meth:`set_boundary` preserves the order of " "the :mailheader:`Content-Type` header in the list of headers." msgstr "" +":meth:`set_boundary` は、ヘッダー一覧内の :mailheader:`Content-Type` ヘッダー" +"の順序を保持します。\n" +"そのため、古い :mailheader:`Content-Type` ヘッダーを削除し、:meth:" +"`add_header` で新しい境界を持つヘッダーを追加する方法とは少し異なります。" -#: ../../library/email.message.rst:430 msgid "" "Return the ``charset`` parameter of the :mailheader:`Content-Type` header, " "coerced to lower case. If there is no :mailheader:`Content-Type` header, or " "if that header has no ``charset`` parameter, *failobj* is returned." msgstr "" "そのメッセージ中の :mailheader:`Content-Type` ヘッダにある、 ``charset`` パラ" -"メータの値を返します。値はすべて小文字に変換されます。メッセージ中に :" -"mailheader:`Content-Type` がなかったり、このヘッダ中に ``charaset`` パラメー" -"タがない場合には *failobj* が返されます。" +"メータの値を返します。\n" +"値はすべて小文字に変換されます。\n" +"メッセージ中に :mailheader:`Content-Type` がなかったり、このヘッダ中に " +"``charset`` パラメータがない場合には *failobj* が返されます。" #: ../../library/email.message.rst:437 msgid "" @@ -629,19 +766,23 @@ msgstr "" ":meth:`~email.message.Message.is_multipart` との一貫性のために、" "is_attachment が属性からメソッドになりました。" -#: ../../library/email.message.rst:460 msgid "" "Return the lowercased value (without parameters) of the message's :" "mailheader:`Content-Disposition` header if it has one, or ``None``. The " "possible values for this method are *inline*, *attachment* or ``None`` if " "the message follows :rfc:`2183`." msgstr "" +"メッセージに :mailheader:`Content-Disposition` ヘッダーがあれば、パラメータを" +"除いた値を小文字で返し、なければ ``None`` を返します。\n" +"メッセージが :rfc:`2183` に準拠していれば、戻り値は *inline*、*attachment*、" +"``None`` のいずれかです。" -#: ../../library/email.message.rst:468 msgid "" "The following methods relate to interrogating and manipulating the content " "(payload) of the message." msgstr "" +"以下のメソッドは、メッセージのコンテンツ (ペイロード) の情報取得と操作に関す" +"るものです。" #: ../../library/email.message.rst:474 msgid "" @@ -664,7 +805,6 @@ msgstr "" "以下の例は、 multipart メッセージのすべての part において、その MIME タイプを" "表示していくものです。 :" -#: ../../library/email.message.rst:488 msgid "" ">>> for part in msg.walk():\n" "... print(part.get_content_type())\n" @@ -676,16 +816,29 @@ msgid "" "message/rfc822\n" "text/plain" msgstr "" +">>> for part in msg.walk():\n" +"... print(part.get_content_type())\n" +"multipart/report\n" +"text/plain\n" +"message/delivery-status\n" +"text/plain\n" +"text/plain\n" +"message/rfc822\n" +"text/plain" -#: ../../library/email.message.rst:500 msgid "" "``walk`` iterates over the subparts of any part where :meth:`is_multipart` " "returns ``True``, even though ``msg.get_content_maintype() == 'multipart'`` " "may return ``False``. We can see this in our example by making use of the " "``_structure`` debug helper function:" msgstr "" +"``walk()`` は、:meth:`is_multipart` が ``True`` を返すパートのサブパートを反" +"復処理します。\n" +"``msg.get_content_maintype() == 'multipart'`` が ``False`` を返す場合も同様で" +"す。\n" +"デバッグ用の補助関数 ``_structure()`` を使うと、この例でその様子を確認できま" +"す。" -#: ../../library/email.message.rst:506 msgid "" ">>> from email.iterators import _structure\n" ">>> for part in msg.walk():\n" @@ -707,13 +860,35 @@ msgid "" " message/rfc822\n" " text/plain" msgstr "" +">>> from email.iterators import _structure\n" +">>> for part in msg.walk():\n" +"... print(part.get_content_maintype() == 'multipart',\n" +"... part.is_multipart())\n" +"True True\n" +"False False\n" +"False True\n" +"False False\n" +"False False\n" +"False True\n" +"False False\n" +">>> _structure(msg)\n" +"multipart/report\n" +" text/plain\n" +" message/delivery-status\n" +" text/plain\n" +" text/plain\n" +" message/rfc822\n" +" text/plain" -#: ../../library/email.message.rst:528 msgid "" "Here the ``message`` parts are not ``multiparts``, but they do contain " "subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends into the " "subparts." msgstr "" +"ここでは ``message`` パートは ``multipart`` ではありませんが、サブパートを含" +"んでいます。\n" +"``is_multipart()`` は ``True`` を返し、``walk()`` はサブパートの中へ進みま" +"す。" #: ../../library/email.message.rst:535 msgid "" @@ -721,47 +896,56 @@ msgid "" "message." msgstr "メッセージの \"本体\" の最有力候補となる MIME 部を返します。" -#: ../../library/email.message.rst:538 msgid "" "*preferencelist* must be a sequence of strings from the set ``related``, " "``html``, and ``plain``, and indicates the order of preference for the " "content type of the part returned." msgstr "" +"*preferencelist* は ``related``、``html``、``plain`` の中から選んだ文字列の" +"シーケンスでなければならず、返されるパートのコンテントタイプの優先順位を示し" +"ます。" -#: ../../library/email.message.rst:542 msgid "" "Start looking for candidate matches with the object on which the " "``get_body`` method is called." msgstr "" +"``get_body()`` を呼び出したオブジェクトから、一致する候補の検索を始めます。" -#: ../../library/email.message.rst:545 msgid "" "If ``related`` is not included in *preferencelist*, consider the root part " "(or subpart of the root part) of any related encountered as a candidate if " "the (sub-)part matches a preference." msgstr "" +"*preferencelist* に ``related`` が含まれていない場合、見つかった related パー" +"トのルートパート (またはそのサブパート) が優先候補のいずれかに一致すれば、候" +"補として扱います。" -#: ../../library/email.message.rst:549 msgid "" "When encountering a ``multipart/related``, check the ``start`` parameter and " "if a part with a matching :mailheader:`Content-ID` is found, consider only " "it when looking for candidate matches. Otherwise consider only the first " "(default root) part of the ``multipart/related``." msgstr "" +"``multipart/related`` を見つけると ``start`` パラメータを調べ、:mailheader:" +"`Content-ID` が一致するパートがあれば、それだけを一致候補の検索対象としま" +"す。\n" +"なければ、``multipart/related`` の最初のパート (デフォルトのルート) だけを対" +"象とします。" -#: ../../library/email.message.rst:554 msgid "" "If a part has a :mailheader:`Content-Disposition` header, only consider the " "part a candidate match if the value of the header is ``inline``." msgstr "" +"パートに :mailheader:`Content-Disposition` ヘッダーがある場合、その値が " +"``inline`` のときだけ一致候補とします。" -#: ../../library/email.message.rst:557 msgid "" "If none of the candidates matches any of the preferences in " "*preferencelist*, return ``None``." msgstr "" +"どの候補も *preferencelist* のいずれの優先候補にも一致しなければ、``None`` を" +"返します。" -#: ../../library/email.message.rst:560 msgid "" "Notes: (1) For most applications the only *preferencelist* combinations that " "really make sense are ``('plain',)``, ``('html', 'plain')``, and the default " @@ -773,8 +957,17 @@ msgid "" "invalid will be treated as if they are of type ``text/plain``, which may " "occasionally cause ``get_body`` to return unexpected results." msgstr "" +"注意: (1) ほとんどのアプリケーションで意味のある *preferencelist* の組み合わ" +"せは、``('plain',)``、``('html', 'plain')``、デフォルトの ``('related', " +"'html', 'plain')`` だけです。\n" +"(2) 一致の検索は ``get_body()`` を呼び出したオブジェクトから始まるため、" +"``multipart/related`` に対する ``get_body()`` は、*preferencelist* がデフォル" +"ト以外の値でない限り、そのオブジェクト自身を返します。\n" +"(3) :mailheader:`Content-Type` が指定されていないメッセージ (またはパート) " +"や、:mailheader:`Content-Type` ヘッダーが不正なものは、``text/plain`` とみな" +"されます。\n" +"そのため、``get_body()`` が予想外の結果を返すことがあります。" -#: ../../library/email.message.rst:574 msgid "" "Return an iterator over all of the immediate sub-parts of the message that " "are not candidate \"body\" parts. That is, skip the first occurrence of " @@ -788,15 +981,28 @@ msgid "" "ID` of any of the parts). When applied directly to a ``multipart/" "alternative`` or a non-``multipart``, return an empty iterator." msgstr "" +"メッセージの直下のサブパートのうち、「本体」の候補でないものすべてを反復処理" +"するイテレーターを返します。\n" +"つまり、``text/plain``、``text/html``、``multipart/related``、``multipart/" +"alternative`` のそれぞれ最初のパートを除き、残りのパートをすべて返します。\n" +"ただし、:mailheader:`Content-Disposition: attachment` で明示的に添付ファイル" +"とされているパートは除きません。\n" +"``multipart/related`` に直接適用した場合、ルートパート以外の関連パートすべて" +"を反復処理するイテレーターを返します。\n" +"ルートパートは ``start`` パラメータが指すパートで、``start`` がない場合や、ど" +"のパートの :mailheader:`Content-ID` にも一致しない場合は最初のパートです。\n" +"``multipart/alternative`` または ``multipart`` 以外に直接適用すると、空のイテ" +"レーターを返します。" -#: ../../library/email.message.rst:590 msgid "" "Return an iterator over all of the immediate sub-parts of the message, which " "will be empty for a non-``multipart``. (See also :meth:`~email.message." "EmailMessage.walk`.)" msgstr "" +"メッセージの直下のサブパートすべてを反復処理するイテレーターを返します。\n" +"``multipart`` でなければ空になります。\n" +"(:meth:`~email.message.EmailMessage.walk` も参照してください。)" -#: ../../library/email.message.rst:597 msgid "" "Call the :meth:`~email.contentmanager.ContentManager.get_content` method of " "the *content_manager*, passing self as the message object, and passing along " @@ -804,8 +1010,13 @@ msgid "" "*content_manager* is not specified, use the ``content_manager`` specified by " "the current :mod:`~email.policy`." msgstr "" +"*content_manager* の :meth:`~email.contentmanager.ContentManager." +"get_content` を呼び出します。\n" +"メッセージオブジェクトとして ``self`` を渡し、他の引数やキーワード引数も追加" +"の引数としてそのまま渡します。\n" +"*content_manager* が指定されていなければ、現在の :mod:`~email.policy` で指定" +"された ``content_manager`` を使います。" -#: ../../library/email.message.rst:606 msgid "" "Call the :meth:`~email.contentmanager.ContentManager.set_content` method of " "the *content_manager*, passing self as the message object, and passing along " @@ -813,8 +1024,13 @@ msgid "" "*content_manager* is not specified, use the ``content_manager`` specified by " "the current :mod:`~email.policy`." msgstr "" +"*content_manager* の :meth:`~email.contentmanager.ContentManager." +"set_content` を呼び出します。\n" +"メッセージオブジェクトとして ``self`` を渡し、他の引数やキーワード引数も追加" +"の引数としてそのまま渡します。\n" +"*content_manager* が指定されていなければ、現在の :mod:`~email.policy` で指定" +"された ``content_manager`` を使います。" -#: ../../library/email.message.rst:615 msgid "" "Convert a non-``multipart`` message into a ``multipart/related`` message, " "moving any existing :mailheader:`Content-` headers and payload into a (new) " @@ -823,8 +1039,13 @@ msgid "" "automatically created when it is needed (for example, when the message is " "serialized)." msgstr "" +"``multipart`` でないメッセージを ``multipart/related`` に変換し、既存の :" +"mailheader:`Content-` ヘッダーとペイロードを、``multipart`` の新しい最初の" +"パートに移します。\n" +"*boundary* が指定されていれば、マルチパートの境界文字列として使います。\n" +"指定されていなければ、直列化時など、必要になったときに自動的に生成されるよう" +"にします。" -#: ../../library/email.message.rst:625 msgid "" "Convert a non-``multipart`` or a ``multipart/related`` into a ``multipart/" "alternative``, moving any existing :mailheader:`Content-` headers and " @@ -833,6 +1054,12 @@ msgid "" "the boundary to be automatically created when it is needed (for example, " "when the message is serialized)." msgstr "" +"``multipart`` でないメッセージ、または ``multipart/related`` を ``multipart/" +"alternative`` に変換し、既存の :mailheader:`Content-` ヘッダーとペイロード" +"を、``multipart`` の新しい最初のパートに移します。\n" +"*boundary* が指定されていれば、マルチパートの境界文字列として使います。\n" +"指定されていなければ、直列化時など、必要になったときに自動的に生成されるよう" +"にします。" #: ../../library/email.message.rst:635 msgid "" @@ -844,7 +1071,6 @@ msgid "" "it is needed (for example, when the message is serialized)." msgstr "" -#: ../../library/email.message.rst:645 msgid "" "If the message is a ``multipart/related``, create a new message object, pass " "all of the arguments to its :meth:`set_content` method, and :meth:`~email." @@ -855,8 +1081,17 @@ msgid "" "the current :mod:`~email.policy`. If the added part has no :mailheader:" "`Content-Disposition` header, add one with the value ``inline``." msgstr "" +"メッセージが ``multipart/related`` の場合、新しいメッセージオブジェクトを作成" +"し、すべての引数をその :meth:`set_content` に渡して、:meth:`~email.message." +"Message.attach` で ``multipart`` に追加します。\n" +"メッセージが ``multipart`` でなければ、:meth:`make_related` を呼び出してから" +"同じ処理を行います。\n" +"他の型の ``multipart`` の場合は :exc:`TypeError` を送出します。\n" +"*content_manager* が指定されていなければ、現在の :mod:`~email.policy` で指定" +"された ``content_manager`` を使います。\n" +"追加したパートに :mailheader:`Content-Disposition` ヘッダーがなければ、値を " +"``inline`` として追加します。" -#: ../../library/email.message.rst:658 msgid "" "If the message is a ``multipart/alternative``, create a new message object, " "pass all of the arguments to its :meth:`set_content` method, and :meth:" @@ -867,8 +1102,15 @@ msgid "" "specified, use the ``content_manager`` specified by the current :mod:`~email." "policy`." msgstr "" +"メッセージが ``multipart/alternative`` の場合、新しいメッセージオブジェクトを" +"作成し、すべての引数をその :meth:`set_content` に渡して、:meth:`~email." +"message.Message.attach` で ``multipart`` に追加します。\n" +"メッセージが ``multipart`` でない場合、または ``multipart/related`` の場合" +"は、:meth:`make_alternative` を呼び出してから同じ処理を行います。\n" +"他の型の ``multipart`` の場合は :exc:`TypeError` を送出します。\n" +"*content_manager* が指定されていなければ、現在の :mod:`~email.policy` で指定" +"された ``content_manager`` を使います。" -#: ../../library/email.message.rst:670 msgid "" "If the message is a ``multipart/mixed``, create a new message object, pass " "all of the arguments to its :meth:`set_content` method, and :meth:`~email." @@ -882,16 +1124,30 @@ msgid "" "``inline`` attachments (:mailheader:`Content-Disposition: inline`), by " "passing appropriate options to the ``content_manager``." msgstr "" +"メッセージが ``multipart/mixed`` の場合、新しいメッセージオブジェクトを作成" +"し、すべての引数をその :meth:`set_content` に渡して、:meth:`~email.message." +"Message.attach` で ``multipart`` に追加します。\n" +"メッセージが ``multipart`` でない場合、または ``multipart/related`` や " +"``multipart/alternative`` の場合は、:meth:`make_mixed` を呼び出してから同じ処" +"理を行います。\n" +"*content_manager* が指定されていなければ、現在の :mod:`~email.policy` で指定" +"された ``content_manager`` を使います。\n" +"追加したパートに :mailheader:`Content-Disposition` ヘッダーがなければ、値を " +"``attachment`` として追加します。\n" +"``content_manager`` に適切なオプションを渡すことで、明示的な添付ファイル (:" +"mailheader:`Content-Disposition: attachment`) にも、``inline`` の添付ファイ" +"ル (:mailheader:`Content-Disposition: inline`) にも使えます。" #: ../../library/email.message.rst:686 msgid "Remove the payload and all of the headers." msgstr "ペイロードとヘッダの全てを削除します。" -#: ../../library/email.message.rst:691 msgid "" "Remove the payload and all of the :mailheader:`!Content-` headers, leaving " "all other headers intact and in their original order." msgstr "" +"ペイロードとすべての :mailheader:`!Content-` ヘッダーを削除し、他のヘッダーは" +"内容も順序もそのまま残します。" #: ../../library/email.message.rst:695 msgid ":class:`EmailMessage` objects have the following instance attributes:" @@ -942,13 +1198,16 @@ msgstr "" "注意: そのメッセージに preamble がない場合、*preamble* 属性には ``None`` が格" "納されます。" -#: ../../library/email.message.rst:723 msgid "" "The *epilogue* attribute acts the same way as the *preamble* attribute, " "except that it contains text that appears between the last boundary and the " "end of the message. As with the :attr:`~EmailMessage.preamble`, if there is " "no epilog text this attribute will be ``None``." msgstr "" +"*epilogue* 属性は *preamble* 属性と同様に働きますが、最後の境界からメッセージ" +"の末尾までのテキストを含む点が異なります。\n" +":attr:`~EmailMessage.preamble` と同様に、末尾のテキストがなければ ``None`` に" +"なります。" #: ../../library/email.message.rst:731 msgid "" @@ -960,25 +1219,30 @@ msgstr "" "障害) のリストを保持しています。解析中に発見されうる障害についてのより詳細な" "説明は :mod:`email.errors` を参照してください。" -#: ../../library/email.message.rst:738 msgid "" "This class represents a subpart of a MIME message. It is identical to :" "class:`EmailMessage`, except that no :mailheader:`MIME-Version` headers are " "added when :meth:`~EmailMessage.set_content` is called, since sub-parts do " "not need their own :mailheader:`MIME-Version` headers." msgstr "" +"このクラスは MIME メッセージのサブパートを表します。\n" +":class:`EmailMessage` と同じですが、サブパートには独自の :mailheader:`MIME-" +"Version` ヘッダーが不要なため、:meth:`~EmailMessage.set_content` を呼び出して" +"も :mailheader:`MIME-Version` ヘッダーが追加されない点が異なります。" #: ../../library/email.message.rst:745 msgid "Footnotes" msgstr "脚注" -#: ../../library/email.message.rst:746 msgid "" "Originally added in 3.4 as a :term:`provisional module `. Docs for legacy message class moved to :ref:`compat32_message`." msgstr "" +"当初は 3.4 で :term:`暫定モジュール ` として追加されまし" +"た。\n" +"従来のメッセージクラスのドキュメントは :ref:`compat32_message` に移動しまし" +"た。" -#: ../../library/email.message.rst:750 msgid "" "The :class:`EmailMessage` class requires a policy that provides a " "``content_manager`` attribute for content management methods like " @@ -986,3 +1250,8 @@ msgid "" "policy.compat32` policy does not support these methods and should not be " "used with :class:`EmailMessage`." msgstr "" +":class:`EmailMessage` の ``set_content()`` や ``get_content()`` などのコンテ" +"ンツ管理メソッドを動作させるには、``content_manager`` 属性を提供するポリシー" +"が必要です。\n" +"従来の :const:`~email.policy.compat32` ポリシーはこれらのメソッドをサポートし" +"ていないため、:class:`EmailMessage` では使わないでください。" diff --git a/library/email.mime.po b/library/email.mime.po index e6341cac1..485141050 100644 --- a/library/email.mime.po +++ b/library/email.mime.po @@ -16,27 +16,28 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.mime.rst:2 msgid ":mod:`!email.mime`: Creating email and MIME objects from scratch" -msgstr "" +msgstr ":mod:`!email.mime`: 電子メールと MIME オブジェクトを一から作成する" #: ../../library/email.mime.rst:7 msgid "**Source code:** :source:`Lib/email/mime/`" msgstr "**ソースコード:** :source:`Lib/email/mime/`" -#: ../../library/email.mime.rst:11 msgid "" "This module is part of the legacy (``Compat32``) email API. Its " "functionality is partially replaced by the :mod:`~email.contentmanager` in " "the new API, but in certain applications these classes may still be useful, " "even in non-legacy code." msgstr "" +"このモジュールは従来の (``Compat32``) email API の一部です。\n" +"新しい API では機能の一部が :mod:`~email.contentmanager` に置き換えられていま" +"すが、用途によっては新しいコードでもこれらのクラスが役立ちます。" #: ../../library/email.mime.rst:16 msgid "" @@ -58,18 +59,16 @@ msgstr "" "す。これは MIME メッセージを切ったりおろしたりするために非常に便利なインター" "フェイスを提供します。" -#: ../../library/email.mime.rst:24 msgid "" "You can create a new object structure by creating :class:`~email.message." "Message` instances, adding attachments and all the appropriate headers " "manually. For MIME messages though, the :mod:`email` package provides some " "convenient subclasses to make things easier." msgstr "" -"新しいメッセージオブジェクト構造は :class:`~email.message.Message` インスタン" -"スを作成することにより作れます。ここに添付ファイルやその他適切なものをすべて" -"手で加えてやればよいのです。MIME メッセージの場合、 :mod:`email` パッケージは" -"これらを簡単におこなえるようにするためにいくつかの便利なサブクラスを提供して" -"います。" +"新しいオブジェクト構造は :class:`~email.message.Message` インスタンスを作成" +"し、添付ファイルと必要なヘッダをすべて手動で追加することで作れます。\n" +"ただし MIME メッセージについては、:mod:`email` パッケージにこの作業を簡単にす" +"る便利なサブクラスが用意されています。" #: ../../library/email.mime.rst:29 msgid "Here are the classes:" @@ -106,11 +105,12 @@ msgstr "" "など)。 *_params* は各パラメータのキーと値を格納した辞書であり、これは直接 :" "meth:`Message.add_header ` に渡されます。" -#: ../../library/email.mime.rst:49 msgid "" "If *policy* is specified, (defaults to the :class:`compat32 ` policy) it will be passed to :class:`~email.message.Message`." msgstr "" +"*policy* を指定すると :class:`~email.message.Message` に渡されます (デフォル" +"トは :class:`compat32 ` ポリシーです)。" #: ../../library/email.mime.rst:53 msgid "" @@ -192,13 +192,12 @@ msgstr "" "はつねに :meth:`Message.attach ` メソッドを使っ" "てそのメッセージに追加できるようになっています。" -#: ../../library/email.mime.rst:98 ../../library/email.mime.rst:131 -#: ../../library/email.mime.rst:165 ../../library/email.mime.rst:200 -#: ../../library/email.mime.rst:223 ../../library/email.mime.rst:254 msgid "" "Optional *policy* argument defaults to :class:`compat32 `." msgstr "" +"オプション引数 *policy* のデフォルトは :class:`compat32 ` です。" #: ../../library/email.mime.rst:100 msgid "" @@ -214,7 +213,6 @@ msgstr "" msgid "Module: :mod:`email.mime.application`" msgstr "モジュール: :mod:`email.mime.application`" -#: ../../library/email.mime.rst:115 msgid "" "A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" "`MIMEApplication` class is used to represent MIME message objects of major " @@ -222,6 +220,12 @@ msgid "" "application data. Optional *_subtype* specifies the MIME subtype and " "defaults to :mimetype:`octet-stream`." msgstr "" +":class:`MIMEApplication` クラスは :class:`~email.mime.nonmultipart." +"MIMENonMultipart` のサブクラスで、主形式が :mimetype:`application` の MIME " +"メッセージオブジェクトを表します。\n" +"*_data* は未加工のアプリケーションデータのバイト列です。\n" +"オプション引数 *_subtype* は MIME の副形式を指定し、デフォルトは :mimetype:" +"`octet-stream` です。" #: ../../library/email.mime.rst:121 msgid "" @@ -251,7 +255,6 @@ msgstr "*_params* は基底クラスのコンストラクタにそのまま渡 msgid "Module: :mod:`email.mime.audio`" msgstr "モジュール: :mod:`email.mime.audio`" -#: ../../library/email.mime.rst:146 msgid "" "A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" "`MIMEAudio` class is used to create MIME message objects of major type :" @@ -262,6 +265,15 @@ msgid "" "argument. If the minor type could not be guessed and *_subtype* was not " "given, then :exc:`TypeError` is raised." msgstr "" +":class:`MIMEAudio` クラスは :class:`~email.mime.nonmultipart." +"MIMENonMultipart` のサブクラスで、主形式が :mimetype:`audio` の MIME メッセー" +"ジオブジェクトを作成します。\n" +"*_audiodata* は未加工の音声データのバイト列です。\n" +"このデータを au、wav、aiff、aifc としてデコードできる場合、副形式は自動的に :" +"mailheader:`Content-Type` ヘッダに含められます。\n" +"それ以外の場合は *_subtype* 引数で音声の副形式を明示的に指定できます。\n" +"副形式を推測できず、*_subtype* も指定されていない場合は :exc:`TypeError` が送" +"出されます。" #: ../../library/email.mime.rst:155 msgid "" @@ -287,7 +299,6 @@ msgstr "" msgid "Module: :mod:`email.mime.image`" msgstr "モジュール: :mod:`email.mime.image`" -#: ../../library/email.mime.rst:180 msgid "" "A subclass of :class:`~email.mime.nonmultipart.MIMENonMultipart`, the :class:" "`MIMEImage` class is used to create MIME message objects of major type :" @@ -299,6 +310,16 @@ msgid "" "the minor type could not be guessed and *_subtype* was not given, then :exc:" "`TypeError` is raised." msgstr "" +":class:`MIMEImage` クラスは :class:`~email.mime.nonmultipart." +"MIMENonMultipart` のサブクラスで、主形式が :mimetype:`image` の MIME メッセー" +"ジオブジェクトを作成します。\n" +"*_imagedata* は未加工の画像データのバイト列です。\n" +"このデータの形式を検出できる場合 (jpeg、png、gif、tiff、rgb、pbm、pgm、ppm、" +"rast、xbm、bmp、webp、exr の検出を試みます)、副形式は自動的に :mailheader:" +"`Content-Type` ヘッダに含められます。\n" +"それ以外の場合は *_subtype* 引数で画像の副形式を明示的に指定できます。\n" +"副形式を推測できず、*_subtype* も指定されていない場合は :exc:`TypeError` が送" +"出されます。" #: ../../library/email.mime.rst:190 msgid "" @@ -381,7 +402,6 @@ msgstr "" "は ``utf-8`` がデフォルトになっています。 *_charset* パラメータは、文字列と :" "class:`~email.charset.Charset` インスタンスの両方を受け付けます。" -#: ../../library/email.mime.rst:244 msgid "" "Unless the *_charset* argument is explicitly set to ``None``, the MIMEText " "object created will have both a :mailheader:`Content-Type` header with a " @@ -395,13 +415,13 @@ msgid "" msgstr "" "``_charset`` 引数に明示的に ``None`` をセットしない限りは、作成される " "MIMEText オブジェクトは ``charset`` の付いた :mailheader:`Content-Type` ヘッ" -"ダと :mailheader:`Content-Transfer-Endcoding` ヘッダの両方を持ちます。これは" -"後続の ``set_payload`` 呼び出しが、 ``set_payload`` コマンドに charset が渡し" -"たとしてもエンコードされたペイロードにはならないことを意味します。 ``Content-" -"Transfer-Encoding`` ヘッダを削除することでこの振る舞いを「リセット」出来ま" -"す。これにより ``set_payload`` 呼び出しが新たなペイロードを自動的にエンコー" -"ド (そして新たな :mailheader:`Content-Transfer-Encoding` ヘッダを追加) しま" -"す。" +"ダと :mailheader:`Content-Transfer-Encoding` ヘッダの両方を持ちます。\n" +"これは後続の ``set_payload`` 呼び出しが、 ``set_payload`` コマンドに charset " +"を渡したとしてもエンコードされたペイロードにはならないことを意味します。\n" +"``Content-Transfer-Encoding`` ヘッダを削除することでこの振る舞いを「リセッ" +"ト」出来ます。\n" +"これにより ``set_payload`` 呼び出しが新たなペイロードを自動的にエンコード (そ" +"して新たな :mailheader:`Content-Transfer-Encoding` ヘッダを追加) します。" #: ../../library/email.mime.rst:256 msgid "*_charset* also accepts :class:`~email.charset.Charset` instances." diff --git a/library/email.parser.po b/library/email.parser.po index 00ad0ad4e..ea1e32e02 100644 --- a/library/email.parser.po +++ b/library/email.parser.po @@ -16,21 +16,19 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.parser.rst:2 msgid ":mod:`!email.parser`: Parsing email messages" -msgstr "" +msgstr ":mod:`!email.parser`: 電子メールメッセージの解析" #: ../../library/email.parser.rst:7 msgid "**Source code:** :source:`Lib/email/parser.py`" msgstr "**ソースコード:** :source:`Lib/email/parser.py`" -#: ../../library/email.parser.rst:11 msgid "" "Message object structures can be created in one of two ways: they can be " "created from whole cloth by creating an :class:`~email.message.EmailMessage` " @@ -39,8 +37,12 @@ msgid "" "or they can be created by parsing a serialized representation of the email " "message." msgstr "" +"メッセージオブジェクトの構造を作成する方法は 2 つあります。\n" +":class:`~email.message.EmailMessage` オブジェクトを作成し、辞書インターフェイ" +"スでヘッダを追加し、:meth:`~email.message.EmailMessage.set_content` や関連メ" +"ソッドでペイロードを追加して一から組み立てる方法と、シリアライズされた電子" +"メールメッセージを解析する方法です。" -#: ../../library/email.parser.rst:18 msgid "" "The :mod:`email` package provides a standard parser that understands most " "email document structures, including MIME documents. You can pass the " @@ -54,8 +56,19 @@ msgid "" "meth:`~email.message.EmailMessage.iter_parts`, and :meth:`~email.message." "EmailMessage.walk`." msgstr "" +":mod:`email` パッケージには、MIME 文書を含むほとんどの電子メール文書の構造を" +"解釈できる標準のパーザがあります。\n" +"パーザにバイト列、文字列、またはファイルオブジェクトを渡すと、オブジェクト構" +"造のルートに当たる :class:`~email.message.EmailMessage` インスタンスが返され" +"ます。\n" +"MIME 形式でない単純なメッセージでは、通常、このルートオブジェクトのペイロード" +"はメッセージのテキストを含む文字列になります。\n" +"MIME メッセージではルートオブジェクトの :meth:`~email.message.EmailMessage." +"is_multipart` メソッドが ``True`` を返し、:meth:`~email.message.EmailMessage." +"get_body`、:meth:`~email.message.EmailMessage.iter_parts`、:meth:`~email." +"message.EmailMessage.walk` などのペイロード操作用メソッドで各部分にアクセスで" +"きます。" -#: ../../library/email.parser.rst:30 msgid "" "There are actually two parser interfaces available for use, the :class:" "`Parser` API and the incremental :class:`FeedParser` API. The :class:" @@ -67,8 +80,17 @@ msgid "" "message incrementally, and only returns the root object when you close the " "parser." msgstr "" +"利用できるパーザインターフェイスは、:class:`Parser` API と逐次解析を行う :" +"class:`FeedParser` API の 2 つです。\n" +":class:`Parser` API は、メッセージ全体のテキストがメモリ内にある場合や、メッ" +"セージ全体がファイルシステム上のファイルに格納されている場合に適していま" +"す。\n" +"追加の入力を待ってブロックする可能性があるストリームからメッセージを読む場合 " +"(例えばソケットから電子メールメッセージを読む場合) は、:class:`FeedParser` の" +"方が適しています。\n" +":class:`FeedParser` はメッセージを少しずつ取り込んで解析でき、パーザを閉じた" +"ときに初めてルートオブジェクトを返します。" -#: ../../library/email.parser.rst:39 msgid "" "Note that the parser can be extended in limited ways, and of course you can " "implement your own parser completely from scratch. All of the logic that " @@ -78,12 +100,18 @@ msgid "" "necessary by implementing custom versions of the appropriate :class:`!" "Policy` methods." msgstr "" +"パーザは限られた範囲で拡張でき、もちろん独自のパーザを一から実装することもで" +"きます。\n" +":mod:`email` パッケージに付属するパーザと :class:`~email.message." +"EmailMessage` クラスを結び付けるロジックはすべて :class:`~email.policy." +"Policy` クラスにまとめられています。\n" +"そのため独自のパーザは、適切な :class:`!Policy` メソッドを独自に実装すること" +"で、必要な方法でメッセージオブジェクトのツリーを作成できます。" #: ../../library/email.parser.rst:49 msgid "FeedParser API" msgstr "FeedParser API" -#: ../../library/email.parser.rst:51 msgid "" "The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` " "module, provides an API that is conducive to incremental parsing of email " @@ -94,8 +122,16 @@ msgid "" "`BytesParser` API may be more convenient for such use cases. The semantics " "and results of the two parser APIs are identical." msgstr "" +":mod:`email.feedparser` モジュールからインポートする :class:" +"`BytesFeedParser` は、電子メールメッセージを逐次解析するための API を提供しま" +"す。\n" +"これはソケットなど、ブロックする可能性がある入力元から電子メールメッセージの" +"テキストを読む場合に必要になるものです。\n" +":class:`BytesFeedParser` はもちろん、全体が :term:`bytes-like object`、文字" +"列、またはファイルに格納されている電子メールメッセージも解析できますが、その" +"場合は :class:`BytesParser` API の方が便利かもしれません。\n" +"この 2 つのパーザ API の意味と解析結果は同じです。" -#: ../../library/email.parser.rst:60 msgid "" "The :class:`BytesFeedParser`'s API is simple; you create an instance, feed " "it a bunch of bytes until there's no more to feed it, then close the parser " @@ -107,29 +143,36 @@ msgid "" "it found in a message. See the :mod:`email.errors` module for the list of " "defects that it can find." msgstr "" -":class:`BytesFeedParser` API は簡単です。まずインスタンスをつくり、それに " -"bytes を (それ以上 bytes が必要なくなるまで) 流しこみます。その後パーザを " -"close すると根っこ (root) のメッセージオブジェクトが返されます。標準に従った" -"メッセージを解析する場合、 :class:`BytesFeedParser` は非常に正確であり、標準" -"に従っていないメッセージでもちゃんと動きます。そのさい、これはメッセージがど" -"のように壊れていると認識されたかについての情報を残します。これはメッセージオ" -"ブジェクトの :attr:`~email.message.EmailMessage.defects` 属性にリストとして現" -"れ、メッセージ中に発見された問題が記録されます。パーザが検出できる障害 " -"(defect) については :mod:`email.errors` モジュールを参照してください。" +":class:`BytesFeedParser` API は簡単です。\n" +"まずインスタンスをつくり、それに bytes を (渡す bytes がなくなるまで) 流しこ" +"みます。\n" +"その後パーザを close すると根っこ (root) のメッセージオブジェクトが返されま" +"す。\n" +"標準に従ったメッセージを解析する場合、 :class:`BytesFeedParser` は非常に正確" +"であり、標準に従っていないメッセージでもちゃんと動きます。\n" +"そのさい、これはメッセージがどのように壊れていると認識されたかについての情報" +"を残します。\n" +"これはメッセージオブジェクトの :attr:`~email.message.EmailMessage.defects` 属" +"性にリストとして現れ、メッセージ中に発見された問題が記録されます。\n" +"パーザが検出できる障害 (defect) については :mod:`email.errors` モジュールを参" +"照してください。" #: ../../library/email.parser.rst:70 msgid "Here is the API for the :class:`BytesFeedParser`:" msgstr "以下は :class:`BytesFeedParser` の API です:" -#: ../../library/email.parser.rst:75 msgid "" "Create a :class:`BytesFeedParser` instance. Optional *_factory* is a no-" "argument callable; if not specified use the :attr:`~email.policy.Policy." "message_factory` from the *policy*. Call *_factory* whenever a new message " "object is needed." msgstr "" +":class:`BytesFeedParser` インスタンスを作成します。\n" +"オプション引数 *_factory* は引数を取らない呼び出し可能オブジェクトです。\n" +"指定しなければ *policy* の :attr:`~email.policy.Policy.message_factory` を使" +"います。\n" +"新しいメッセージオブジェクトが必要になるたびに *_factory* を呼び出します。" -#: ../../library/email.parser.rst:80 msgid "" "If *policy* is specified use the rules it specifies to update the " "representation of the message. If *policy* is not set, use the :class:" @@ -140,20 +183,30 @@ msgid "" "more information on what else *policy* controls, see the :mod:`~email." "policy` documentation." msgstr "" +"*policy* を指定した場合、そのルールに従ってメッセージの表現を更新します。\n" +"指定しない場合は :class:`compat32 ` ポリシーを使いま" +"す。\n" +"このポリシーは Python 3.2 の email パッケージとの後方互換性を維持し、デフォル" +"トのファクトリとして :class:`~email.message.Message` を提供します。\n" +"その他のポリシーはすべて、デフォルトの *_factory* として :class:`~email." +"message.EmailMessage` を提供します。\n" +"*policy* が制御するその他の内容は :mod:`~email.policy` のドキュメントを参照し" +"てください。" -#: ../../library/email.parser.rst:89 ../../library/email.parser.rst:145 msgid "" "Note: **The policy keyword should always be specified**; The default will " "change to :data:`email.policy.default` in a future version of Python." msgstr "" +"注意: キーワード引数 ``policy`` は **常に指定してください**。\n" +"将来の Python バージョンでは、デフォルトが :data:`email.policy.default` に変" +"更されます。" #: ../../library/email.parser.rst:94 ../../library/email.parser.rst:122 msgid "Added the *policy* keyword." msgstr "キーワード引数 *policy* が追加されました。" -#: ../../library/email.parser.rst:95 msgid "*_factory* defaults to the policy ``message_factory``." -msgstr "" +msgstr "*_factory* のデフォルトがポリシーの ``message_factory`` になりました。" #: ../../library/email.parser.rst:100 msgid "" @@ -169,14 +222,16 @@ msgstr "" "(復帰 CR、改行 LF、または CR+LF) どれかの組み合わせでよく、これらが混在しても" "かまいません。" -#: ../../library/email.parser.rst:109 msgid "" "Complete the parsing of all previously fed data and return the root message " "object. It is undefined what happens if :meth:`~feed` is called after this " "method has been called." msgstr "" +"それまでに渡されたすべてのデータの解析を完了し、ルートのメッセージオブジェク" +"トを返します。\n" +"このメソッドを呼び出した後で :meth:`~feed` を呼び出した場合の動作は未定義で" +"す。" -#: ../../library/email.parser.rst:116 msgid "" "Works like :class:`BytesFeedParser` except that the input to the :meth:" "`~BytesFeedParser.feed` method must be a string. This is of limited " @@ -184,12 +239,15 @@ msgid "" "contain only ASCII text or, if :attr:`~email.policy.EmailPolicy.utf8` is " "``True``, no binary attachments." msgstr "" +":class:`BytesFeedParser` と同様に動作しますが、:meth:`~BytesFeedParser.feed` " +"メソッドへの入力は文字列でなければなりません。\n" +"このようなメッセージが有効となるのは、ASCII テキストのみを含む場合、または :" +"attr:`~email.policy.EmailPolicy.utf8` が ``True`` でバイナリの添付ファイルを" +"含まない場合に限られるため、用途は限定されます。" -#: ../../library/email.parser.rst:126 msgid "Parser API" -msgstr "" +msgstr "Parser API" -#: ../../library/email.parser.rst:128 msgid "" "The :class:`BytesParser` class, imported from the :mod:`!email.parser` " "module, provides an API that can be used to parse a message when the " @@ -202,13 +260,24 @@ msgid "" "do not attempt to parse the message body, instead setting the payload to the " "raw body." msgstr "" +":mod:`!email.parser` モジュールからインポートする :class:`BytesParser` クラス" +"は、メッセージ全体が :term:`bytes-like object` やファイルに格納されている場合" +"に解析するための API を提供します。\n" +":mod:`!email.parser` モジュールには、文字列を解析する :class:`Parser` と、" +"メッセージのヘッダだけが必要な場合に使えるヘッダ専用パーザ :class:" +"`BytesHeaderParser` および :class:`HeaderParser` もあります。\n" +":class:`BytesHeaderParser` と :class:`HeaderParser` はメッセージ本体を解析せ" +"ず、そのままペイロードに設定するため、このような場合には大幅に高速になること" +"があります。" -#: ../../library/email.parser.rst:141 msgid "" "Create a :class:`BytesParser` instance. The *_class* and *policy* arguments " "have the same meaning and semantics as the *_factory* and *policy* arguments " "of :class:`BytesFeedParser`." msgstr "" +":class:`BytesParser` インスタンスを作成します。\n" +"*_class* 引数と *policy* 引数の意味と動作は、:class:`BytesFeedParser` の " +"*_factory* 引数と *policy* 引数と同じです。" #: ../../library/email.parser.rst:148 msgid "" @@ -217,19 +286,19 @@ msgid "" msgstr "" "2.4 で非推奨になった *strict* 引数の削除。キーワード引数 *policy* の追加。" -#: ../../library/email.parser.rst:151 ../../library/email.parser.rst:200 -#: ../../library/email.parser.rst:280 msgid "*_class* defaults to the policy ``message_factory``." -msgstr "" +msgstr "*_class* のデフォルトがポリシーの ``message_factory`` になりました。" -#: ../../library/email.parser.rst:156 msgid "" "Read all the data from the binary file-like object *fp*, parse the resulting " "bytes, and return the message object. *fp* must support both the :meth:`~io." "IOBase.readline` and the :meth:`~io.BufferedIOBase.read` methods." msgstr "" +"バイナリのファイル類似オブジェクト *fp* からすべてのデータを読み込み、得られ" +"たバイト列を解析してメッセージオブジェクトを返します。\n" +"*fp* は :meth:`~io.IOBase.readline` と :meth:`~io.BufferedIOBase.read` の両方" +"のメソッドをサポートしなければなりません。" -#: ../../library/email.parser.rst:161 msgid "" "The bytes contained in *fp* must be formatted as a block of :rfc:`5322` (or, " "if :attr:`~email.policy.EmailPolicy.utf8` is ``True``, :rfc:`6532`) style " @@ -239,6 +308,14 @@ msgid "" "may contain MIME-encoded subparts, including subparts with a :mailheader:" "`Content-Transfer-Encoding` of ``8bit``)." msgstr "" +"*fp* 内のバイト列は、:rfc:`5322` (または :attr:`~email.policy.EmailPolicy." +"utf8` が ``True`` の場合は :rfc:`6532`) 形式のヘッダとヘッダの継続行からなる" +"ブロックで始まらなければなりません。\n" +"その前にエンベロープヘッダがあってもかまいません。\n" +"ヘッダブロックはデータの終端または空行で終わります。\n" +"ヘッダブロックの後にはメッセージ本体が続きます (本体には、:mailheader:" +"`Content-Transfer-Encoding` が ``8bit`` の部分を含め、MIME エンコードされた部" +"分が含まれていることがあります)。" #: ../../library/email.parser.rst:169 msgid "" @@ -249,28 +326,32 @@ msgstr "" "オプション引数 *headersonly* はヘッダを読み終えた後にパースを止めるかを指定す" "るフラグです。デフォルトは ``False`` で、ファイルの内容全体をパースします。" -#: ../../library/email.parser.rst:176 msgid "" "Similar to the :meth:`parse` method, except it takes a :term:`bytes-like " "object` instead of a file-like object. Calling this method on a :term:" "`bytes-like object` is equivalent to wrapping *bytes* in a :class:`~io." "BytesIO` instance first and calling :meth:`parse`." msgstr "" +":meth:`parse` メソッドと似ていますが、ファイル類似オブジェクトではなく :term:" +"`bytes-like object` を受け取ります。\n" +":term:`bytes-like object` に対してこのメソッドを呼び出すことは、*bytes* を :" +"class:`~io.BytesIO` インスタンスに包んで :meth:`parse` を呼び出すことと同じで" +"す。" #: ../../library/email.parser.rst:181 ../../library/email.parser.rst:221 msgid "Optional *headersonly* is as with the :meth:`parse` method." msgstr "オプション引数 *headersonly* は :meth:`parse` メソッドと同じです。" -#: ../../library/email.parser.rst:188 msgid "" "Exactly like :class:`BytesParser`, except that *headersonly* defaults to " "``True``." msgstr "" +"*headersonly* のデフォルトが ``True`` である点を除き、:class:`BytesParser` と" +"まったく同じです。" -#: ../../library/email.parser.rst:196 msgid "" "This class is parallel to :class:`BytesParser`, but handles string input." -msgstr "" +msgstr ":class:`BytesParser` に対応するクラスですが、文字列の入力を扱います。" #: ../../library/email.parser.rst:198 ../../library/email.parser.rst:245 #: ../../library/email.parser.rst:258 ../../library/email.parser.rst:268 @@ -291,11 +372,12 @@ msgstr "" "`~io.TextIOBase.readline` および :meth:`~io.TextIOBase.read` 両方のメソッドを" "サポートしている必要があります。" -#: ../../library/email.parser.rst:210 msgid "" "Other than the text mode requirement, this method operates like :meth:" "`BytesParser.parse`." msgstr "" +"テキストモードが必要な点を除き、このメソッドは :meth:`BytesParser.parse` と同" +"様に動作します。" #: ../../library/email.parser.rst:216 msgid "" @@ -309,10 +391,11 @@ msgstr "" "は、 *text* を :class:`~io.StringIO` インスタンスとして作成して :meth:" "`parse` を適用するのと同じです。" -#: ../../library/email.parser.rst:226 msgid "" "Exactly like :class:`Parser`, except that *headersonly* defaults to ``True``." msgstr "" +"*headersonly* のデフォルトが ``True`` である点を除き、:class:`Parser` とまっ" +"たく同じです。" #: ../../library/email.parser.rst:230 msgid "" @@ -376,11 +459,12 @@ msgstr "" "対話的な Python プロンプトで :func:`message_from_bytes` を使用するとすれば、" "このようになります::" -#: ../../library/email.parser.rst:286 msgid "" ">>> import email\n" ">>> msg = email.message_from_bytes(myBytes)" msgstr "" +">>> import email\n" +">>> msg = email.message_from_bytes(myBytes)" #: ../../library/email.parser.rst:291 msgid "Additional notes" diff --git a/library/email.po b/library/email.po index 662937d58..47844856f 100644 --- a/library/email.po +++ b/library/email.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/email.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!email` --- 電子メールと MIME 処理のためのパッケー msgid "**Source code:** :source:`Lib/email/__init__.py`" msgstr "**ソースコード:** :source:`Lib/email/__init__.py`" -#: ../../library/email.rst:12 msgid "" "The :mod:`!email` package is a library for managing email messages. It is " "specifically *not* designed to do any sending of email messages to SMTP (:" @@ -40,15 +39,22 @@ msgid "" "related RFCs as :rfc:`2045`, :rfc:`2046`, :rfc:`2047`, :rfc:`2183`, and :rfc:" "`2231`." msgstr "" +":mod:`!email` パッケージは電子メールメッセージを管理するライブラリです。\n" +"SMTP (:rfc:`2821`)、NNTP などのサーバーへ電子メールを送信するためのものでは *" +"ありません*。\n" +"送信は :mod:`smtplib` などのモジュールが担当します。\n" +":mod:`!email` パッケージは、:rfc:`5322` と :rfc:`6532` に加え、:rfc:`2045`、:" +"rfc:`2046`、:rfc:`2047`、:rfc:`2183`、:rfc:`2231` などの MIME 関連 RFC をサ" +"ポートし、できる限り RFC に準拠することを目指しています。" -#: ../../library/email.rst:20 msgid "" "The overall structure of the email package can be divided into three major " "components, plus a fourth component that controls the behavior of the other " "components." msgstr "" +"email パッケージの全体構造は、主要な 3 つの構成要素と、それらの動作を制御す" +"る 4 つ目の構成要素に分けられます。" -#: ../../library/email.rst:24 msgid "" "The central component of the package is an \"object model\" that represents " "email messages. An application interacts with the package primarily through " @@ -60,8 +66,17 @@ msgid "" "model is a tree structure of objects that all provide the :class:`~email." "message.EmailMessage` API." msgstr "" +"パッケージの中心となる構成要素は、電子メールメッセージを表現する「オブジェク" +"トモデル」です。\n" +"アプリケーションは主に :mod:`~email.message` サブモジュールで定義されたオブ" +"ジェクトモデルのインターフェースを通じて、このパッケージを利用します。\n" +"この API で、既存の電子メールの情報を調べたり、新しい電子メールを作成したり、" +"同じオブジェクトモデルのインターフェースを持つ構成部分を追加・削除したりでき" +"ます。\n" +"つまり、電子メールメッセージとその MIME 構成部分の性質に合わせて、email のオ" +"ブジェクトモデルは、すべてのオブジェクトが :class:`~email.message." +"EmailMessage` API を提供するツリー構造になっています。" -#: ../../library/email.rst:34 msgid "" "The other two major components of the package are the :mod:`~email.parser` " "and the :mod:`~email.generator`. The parser takes the serialized version of " @@ -72,8 +87,15 @@ msgid "" "but this usage is discouraged as it is too easy to end up with messages that " "are not valid in one way or another.)" msgstr "" +"他の 2 つの主要な構成要素は :mod:`~email.parser` と :mod:`~email.generator` " +"です。\n" +"パーサーは、直列化された電子メールメッセージ (バイトストリーム) を受け取り、:" +"class:`~email.message.EmailMessage` オブジェクトのツリーに変換します。\n" +"ジェネレーターは :class:`~email.message.EmailMessage` を受け取り、直列化され" +"たバイトストリームに戻します。\n" +"(パーサーとジェネレーターはテキストの文字ストリームも扱えますが、何らかの点で" +"不正なメッセージができてしまいやすいため、この使い方は推奨しません。)" -#: ../../library/email.rst:43 msgid "" "The control component is the :mod:`~email.policy` module. Every :class:" "`~email.message.EmailMessage`, every :mod:`~email.generator`, and every :mod:" @@ -87,8 +109,20 @@ msgid "" "from disk, but to serialize it using standard SMTP settings when sending it " "to an email server." msgstr "" +"制御を担当する構成要素は :mod:`~email.policy` モジュールです。\n" +"各 :class:`~email.message.EmailMessage`、:mod:`~email.generator`、:mod:" +"`~email.parser` には、それぞれの動作を制御する :mod:`~email.policy` オブジェ" +"クトが関連付けられています。\n" +"通常、アプリケーションがポリシーを指定する必要があるのは :class:`~email." +"message.EmailMessage` の作成時だけです。\n" +"これには、新しい電子メールのために :class:`~email.message.EmailMessage` を直" +"接インスタンス化する場合と、:mod:`~email.parser` で入力ストリームを解析する場" +"合があります。\n" +"ただし、:mod:`~email.generator` でメッセージを直列化するときにポリシーを変更" +"することもできます。\n" +"例えば、ディスク上の一般的な電子メールメッセージを解析し、メールサーバーへ送" +"信するときは標準の SMTP 設定で直列化できます。" -#: ../../library/email.rst:55 msgid "" "The email package does its best to hide the details of the various governing " "RFCs from the application. Conceptually the application should be able to " @@ -104,8 +138,20 @@ msgid "" "modern internet software (not just email), this will be a familiar concept " "to many programmers." msgstr "" +"email パッケージは、関連する各種 RFC の詳細をできるだけアプリケーションから隠" +"します。\n" +"概念的には、アプリケーションは直列化時の表現を気にせず、電子メールメッセージ" +"を Unicode テキストとバイナリ添付ファイルのツリー構造として扱えるはずです。\n" +"しかし実際には、MIME メッセージとその構造を定める規則の少なくとも一部を知って" +"おく必要がよくあります。\n" +"特に、MIME の「コンテントタイプ」の名前や性質と、それによってマルチパート文書" +"を識別する方法です。\n" +"この知識が必要になるのは主に複雑なアプリケーションであり、その場合でも必要な" +"のは通常、構造の大枠についての知識であって、構造の表現方法の詳細ではありませ" +"ん。\n" +"MIME コンテントタイプは、現在のインターネットソフトウェアで電子メール以外にも" +"広く使われているため、多くのプログラマーにはなじみのある概念でしょう。" -#: ../../library/email.rst:68 msgid "" "The following sections describe the functionality of the :mod:`!email` " "package. We start with the :mod:`~email.message` object model, which is the " @@ -114,8 +160,13 @@ msgid "" "mod:`~email.policy` controls, which completes the treatment of the main " "components of the library." msgstr "" +"以下の節では :mod:`!email` パッケージの機能を説明します。\n" +"まず、アプリケーションが主に使うインターフェースである :mod:`~email.message` " +"オブジェクトモデルを説明し、続いて :mod:`~email.parser` と :mod:`~email." +"generator` を取り上げます。\n" +"その後、:mod:`~email.policy` による制御を説明し、ライブラリの主要な構成要素の" +"説明を終えます。" -#: ../../library/email.rst:75 msgid "" "The next three sections cover the exceptions the package may raise and the " "defects (non-compliance with the RFCs) that the :mod:`~email.parser` may " @@ -126,14 +177,18 @@ msgid "" "messages, but also document their extensibility APIs, which will be of " "interest to advanced applications." msgstr "" +"続く 3 つの節では、パッケージが送出する可能性のある例外と、:mod:`~email." +"parser` が検出する可能性のある欠陥 (RFC に準拠していない点) を説明します。\n" +"その後、ヘッダーとペイロードをそれぞれより細かく操作するための :mod:`~email." +"headerregistry` と :mod:`~email.contentmanager` を取り上げます。\n" +"どちらにも複雑なメッセージの処理や作成に役立つ機能がありますが、高度なアプリ" +"ケーション向けの拡張用 API についても説明します。" -#: ../../library/email.rst:84 msgid "" "Following those is a set of examples of using the fundamental parts of the " "APIs covered in the preceding sections." -msgstr "" +msgstr "続いて、それまでの節で説明した API の基本部分を使う例を示します。" -#: ../../library/email.rst:87 msgid "" "The foregoing represent the modern (Unicode friendly) API of the email " "package. The remaining sections, starting with the :class:`~email.message." @@ -145,16 +200,24 @@ msgid "" "relevant for applications that are still using the :mod:`~email.policy." "compat32` API for backward compatibility reasons." msgstr "" +"ここまでが、email パッケージの現代的な、Unicode を扱いやすい API です。\n" +":class:`~email.message.Message` クラスから始まる残りの節では、電子メールメッ" +"セージの表現方法の詳細をより直接的に扱う、従来の :data:`~email.policy." +"compat32` API を説明します。\n" +":data:`~email.policy.compat32` API は RFC の詳細をアプリケーションから隠し *" +"ません* が、その水準で操作する必要があるアプリケーションには役立ちます。\n" +"この説明は、後方互換性のために引き続き :mod:`~email.policy.compat32` API を使" +"用しているアプリケーションにも関係します。" -#: ../../library/email.rst:97 msgid "" "Docs reorganized and rewritten to promote the new :class:`~email.message." "EmailMessage`/:class:`~email.policy.EmailPolicy` API." msgstr "" +"新しい :class:`~email.message.EmailMessage`/:class:`~email.policy." +"EmailPolicy` API の利用を促すため、ドキュメントを再構成し、書き直しました。" -#: ../../library/email.rst:102 msgid "Contents of the :mod:`!email` package documentation:" -msgstr "" +msgstr ":mod:`!email` パッケージのドキュメントの目次:" #: ../../library/email.rst:117 msgid "Legacy API:" @@ -188,8 +251,9 @@ msgstr "IMAP (Internet Message Access Protocol) クライアント" msgid "Module :mod:`mailbox`" msgstr ":mod:`mailbox` モジュール" -#: ../../library/email.rst:142 msgid "" "Tools for creating, reading, and managing collections of messages on disk " "using a variety standard formats." msgstr "" +"さまざまな標準形式でディスク上のメッセージの集まりを作成、読み込み、管理する" +"ためのツール。" diff --git a/library/email.policy.po b/library/email.policy.po index f2464c559..8ff76113b 100644 --- a/library/email.policy.po +++ b/library/email.policy.po @@ -16,21 +16,19 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.policy.rst:2 msgid ":mod:`!email.policy`: Policy Objects" -msgstr "" +msgstr ":mod:`!email.policy`: ポリシーオブジェクト" #: ../../library/email.policy.rst:9 msgid "**Source code:** :source:`Lib/email/policy.py`" msgstr "**ソースコード:** :source:`Lib/email/policy.py`" -#: ../../library/email.policy.rst:13 msgid "" "The :mod:`email` package's prime focus is the handling of email messages as " "described by the various email and MIME RFCs. However, the general format " @@ -44,15 +42,17 @@ msgid "" "the standards, or that implement extensions you want to use in ways that " "violate the standards." msgstr "" -":mod:`email` パッケージの主要な目的は様々なEメールやMIMEのRFCで記述されたE" -"メールメッセージを取り扱うことにあります。しかし、Eメールメッセージの一般的な" -"フォーマット(名前の後にコロンが続き、コロンの後に値が続くという構成の複数の" -"ヘッダーフィールドのブロック、空白行、任意の 'body')はEメールの分野外での用途" -"が見いだされたフォーマットです。これらの用途には主となるEメールのRFCに厳密に" -"従っているものもあれば、そうでないものもあります。Eメールを使ったworkingのと" -"きでさえも、厳密なRFC準拠にしないのが望ましいことがあります。たとえば、基準に" -"従わないEメールサーバーと相互運用するEメールを作成するときや、基準に違反する" -"方法で使用したい拡張機能を実装するEメールを作成するときです。" +":mod:`email` パッケージの主な目的は、メールや MIME に関する各種 RFC に従って" +"メールメッセージを扱うことです。\n" +"しかし、メールの一般的な形式はメール以外の用途でも使われています。\n" +"この形式は、名前、コロン、値からなるヘッダーフィールドを並べたブロックと、そ" +"の後に続く空行、任意の「本文」で構成されます。\n" +"メール以外の用途には、主要なメールの RFC にほぼ準拠するものもあれば、そうでな" +"いものもあります。\n" +"メールを扱う場合でも、RFC への厳密な準拠を避けたいことがあります。\n" +"例えば、規格に従わないメールサーバーとやり取りするメールを生成する場合や、利" +"用したい拡張機能を規格に反する方法で実装しているサーバーとやり取りする場合で" +"す。" #: ../../library/email.policy.rst:25 msgid "" @@ -62,7 +62,6 @@ msgstr "" "これらのばらばらな用途に対応するためPolicyオブジェクトはEメールパッケージに対" "して柔軟性を提供します。" -#: ../../library/email.policy.rst:28 msgid "" "A :class:`Policy` object encapsulates a set of attributes and methods that " "control the behavior of various components of the email package during use. :" @@ -70,8 +69,12 @@ msgid "" "email package to alter the default behavior. The settable values and their " "defaults are described below." msgstr "" +":class:`Policy` オブジェクトは、email パッケージの各部の動作を制御する属性と" +"メソッドをまとめたものです。\n" +"email パッケージの各種クラスやメソッドに :class:`Policy` インスタンスを渡すこ" +"とで、デフォルトの動作を変更できます。\n" +"設定できる値とそのデフォルト値を以下で説明します。" -#: ../../library/email.policy.rst:34 msgid "" "There is a default policy used by all classes in the email package. For all " "of the :mod:`~email.parser` classes and the related convenience functions, " @@ -81,15 +84,22 @@ msgid "" "some cases, including bug compatibility) with the pre-Python3.3 version of " "the email package." msgstr "" +"email パッケージの各クラスにはデフォルトのポリシーがあります。\n" +":mod:`~email.parser` のすべてのクラスと関連する便利な関数、および :class:" +"`~email.message.Message` クラスでは、:class:`Compat32` ポリシーの定義済みイン" +"スタンス :const:`compat32` が使われます。\n" +"このポリシーは Python 3.3 より前の email パッケージと完全な後方互換性を提供し" +"ます (場合によってはバグとの互換性も含みます)。" -#: ../../library/email.policy.rst:41 msgid "" "This default value for the *policy* keyword to :class:`~email.message." "EmailMessage` is the :class:`EmailPolicy` policy, via its pre-defined " "instance :data:`~default`." msgstr "" +":class:`~email.message.EmailMessage` のキーワード引数 *policy* のデフォルト" +"は、:class:`EmailPolicy` ポリシーの定義済みインスタンス :data:`~default` で" +"す。" -#: ../../library/email.policy.rst:45 msgid "" "When a :class:`~email.message.Message` or :class:`~email.message." "EmailMessage` object is created, it acquires a policy. If the message is " @@ -100,8 +110,15 @@ msgid "" "policy from the message by default, but you can also pass a specific policy " "to the generator that will override the one stored on the message object." msgstr "" +":class:`~email.message.Message` または :class:`~email.message.EmailMessage` " +"オブジェクトには、作成時にポリシーが設定されます。\n" +":mod:`~email.parser` でメッセージを作成する場合は、パーザに渡したポリシーがそ" +"のメッセージに使われます。\n" +"プログラムでメッセージを作成する場合は、作成時にポリシーを指定できます。\n" +"メッセージを :mod:`~email.generator` に渡すと、デフォルトではメッセージのポリ" +"シーが使われますが、ジェネレータに特定のポリシーを渡してメッセージオブジェク" +"トに格納されたポリシーの代わりに使うこともできます。" -#: ../../library/email.policy.rst:54 msgid "" "The default value for the *policy* keyword for the :mod:`email.parser` " "classes and the parser convenience functions **will be changing** in a " @@ -109,8 +126,11 @@ msgid "" "which policy you want to use** when calling any of the classes and functions " "described in the :mod:`~email.parser` module." msgstr "" +":mod:`email.parser` のクラスとパーザ用の便利な関数のキーワード引数 *policy* " +"のデフォルト値は、将来の Python バージョンで **変更される予定です**。\n" +"このため :mod:`~email.parser` モジュールで説明するクラスや関数を呼び出すとき" +"は、**使用するポリシーを常に明示的に指定してください**。" -#: ../../library/email.policy.rst:60 msgid "" "The first part of this documentation covers the features of :class:`Policy`, " "an :term:`abstract base class` that defines the features that are common to " @@ -121,21 +141,33 @@ msgid "" "which implement the hooks that provide the standard behavior and the " "backward compatible behavior and features, respectively." msgstr "" +"このドキュメントの前半では、:const:`compat32` を含むすべてのポリシーオブジェ" +"クトに共通の機能を定義する :term:`抽象基底クラス `、:" +"class:`Policy` の機能を説明します。\n" +"これには email パッケージが内部で呼び出すフックメソッドも含まれ、独自のポリ" +"シーでオーバーライドすると動作を変更できます。\n" +"後半では具象クラス :class:`EmailPolicy` と :class:`Compat32` を説明します。\n" +"これらはそれぞれ、標準の動作を提供するフックと、後方互換の動作や機能を提供す" +"るフックを実装します。" -#: ../../library/email.policy.rst:69 msgid "" ":class:`Policy` instances are immutable, but they can be cloned, accepting " "the same keyword arguments as the class constructor and returning a new :" "class:`Policy` instance that is a copy of the original but with the " "specified attributes values changed." msgstr "" +":class:`Policy` インスタンスはイミュータブルですが、複製できます。\n" +"クラスのコンストラクタと同じキーワード引数を受け取り、元のインスタンスをコ" +"ピーして指定された属性の値を変更した新しい :class:`Policy` インスタンスを返し" +"ます。" -#: ../../library/email.policy.rst:74 msgid "" "As an example, the following code could be used to read an email message " "from a file on disk and pass it to the system ``sendmail`` program on a Unix " "system:" msgstr "" +"例えば次のコードは、ディスク上のファイルから電子メールメッセージを読み込み、" +"Unix システムの ``sendmail`` プログラムに渡します:" #: ../../library/email.policy.rst:89 msgid "" @@ -153,15 +185,17 @@ msgid "" ">>> rc = p.wait()" msgstr "" -#: ../../library/email.policy.rst:111 msgid "" "Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC " "correct line separator characters when creating the binary string to feed " "into ``sendmail's`` ``stdin``, where the default policy would use ``\\n`` " "line separators." msgstr "" +"ここでは、``sendmail`` の ``stdin`` に渡すバイナリ文字列を作成するときに、" +"RFC に従った改行文字を使うよう :class:`~email.generator.BytesGenerator` に指" +"定しています。\n" +"デフォルトのポリシーでは改行文字に ``\\n`` を使います。" -#: ../../library/email.policy.rst:116 msgid "" "Some email package methods accept a *policy* keyword argument, allowing the " "policy to be overridden for that method. For example, the following code " @@ -169,14 +203,22 @@ msgid "" "from the previous example and writes the message to a file using the native " "line separators for the platform on which it is running::" msgstr "" +"email パッケージの一部のメソッドはキーワード引数 *policy* を受け取り、そのメ" +"ソッドで使うポリシーを変更できます。\n" +"例えば次のコードは、前の例の *msg* オブジェクトの :meth:`~email.message." +"Message.as_bytes` メソッドを使い、実行しているプラットフォーム固有の改行文字" +"でメッセージをファイルに書き込みます。 ::" -#: ../../library/email.policy.rst:122 msgid "" ">>> import os\n" ">>> with open('converted.txt', 'wb') as f:\n" "... f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))\n" "17" msgstr "" +">>> import os\n" +">>> with open('converted.txt', 'wb') as f:\n" +"... f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))\n" +"17" #: ../../library/email.policy.rst:127 msgid "" @@ -188,12 +230,14 @@ msgstr "" "のオブジェクトの非デフォルト値を組み合わせた設定を持つPolicyオブジェクトを生" "成します::" -#: ../../library/email.policy.rst:131 msgid "" ">>> compat_SMTP = policy.compat32.clone(linesep='\\r\\n')\n" ">>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n" ">>> compat_strict_SMTP = compat_SMTP + compat_strict" msgstr "" +">>> compat_SMTP = policy.compat32.clone(linesep='\\r\\n')\n" +">>> compat_strict = policy.compat32.clone(raise_on_defect=True)\n" +">>> compat_strict_SMTP = compat_SMTP + compat_strict" #: ../../library/email.policy.rst:135 msgid "" @@ -203,7 +247,6 @@ msgstr "" "この操作には交換法則が成り立ちません。つまり、オブジェクトを加える順番に結果" "が依存します。次のように説明できます::" -#: ../../library/email.policy.rst:138 msgid "" ">>> policy100 = policy.compat32.clone(max_line_length=100)\n" ">>> policy80 = policy.compat32.clone(max_line_length=80)\n" @@ -214,16 +257,26 @@ msgid "" ">>> apolicy.max_line_length\n" "100" msgstr "" +">>> policy100 = policy.compat32.clone(max_line_length=100)\n" +">>> policy80 = policy.compat32.clone(max_line_length=80)\n" +">>> apolicy = policy100 + policy80\n" +">>> apolicy.max_line_length\n" +"80\n" +">>> apolicy = policy80 + policy100\n" +">>> apolicy.max_line_length\n" +"100" -#: ../../library/email.policy.rst:150 msgid "" "This is the :term:`abstract base class` for all policy classes. It provides " "default implementations for a couple of trivial methods, as well as the " "implementation of the immutability property, the :meth:`clone` method, and " "the constructor semantics." msgstr "" +"すべてのポリシークラスの :term:`抽象基底クラス ` で" +"す。\n" +"いくつかの単純なメソッドのデフォルト実装に加え、イミュータブルにする仕組み、:" +"meth:`clone` メソッド、コンストラクタの動作を実装しています。" -#: ../../library/email.policy.rst:155 msgid "" "The constructor of a policy class can be passed various keyword arguments. " "The arguments that may be specified are any non-method properties on this " @@ -231,12 +284,18 @@ msgid "" "value specified in the constructor will override the default value for the " "corresponding attribute." msgstr "" +"ポリシークラスのコンストラクタには、さまざまなキーワード引数を渡せます。\n" +"指定できる引数は、このクラスと具象クラスにあるメソッド以外のすべてのプロパ" +"ティです。\n" +"コンストラクタに値を指定すると、対応する属性のデフォルト値が置き換えられま" +"す。" -#: ../../library/email.policy.rst:161 msgid "" "This class defines the following properties, and thus values for the " "following may be passed in the constructor of any policy class:" msgstr "" +"このクラスは以下のプロパティを定義しているため、どのポリシークラスのコンスト" +"ラクタでもこれらの値を指定できます:" #: ../../library/email.policy.rst:167 msgid "" @@ -248,72 +307,91 @@ msgstr "" "トは :rfc:`5322` に従い78となっています。値が ``0`` または :const:`None` の場" "合は行の折り返しを全くしないべきであるということを示します。" -#: ../../library/email.policy.rst:175 msgid "" "The string to be used to terminate lines in serialized output. The default " "is ``\\n`` because that's the internal end-of-line discipline used by " "Python, though ``\\r\\n`` is required by the RFCs." msgstr "" +"シリアライズした出力の行末に使う文字列です。\n" +"RFC では ``\\r\\n`` が必要ですが、Python が内部で使う改行規則に合わせ、デフォ" +"ルトは ``\\n`` です。" -#: ../../library/email.policy.rst:182 msgid "" "Controls the type of Content Transfer Encodings that may be or are required " "to be used. The possible values are:" msgstr "" +"使用可能な、または使用が必要な Content Transfer Encoding の種類を制御しま" +"す。\n" +"指定できる値は次のとおりです:" #: ../../library/email.policy.rst:188 msgid "``7bit``" msgstr "``7bit``" -#: ../../library/email.policy.rst:188 msgid "" "all data must be \"7 bit clean\" (ASCII-only). This means that where " "necessary data will be encoded using either quoted-printable or base64 " "encoding." msgstr "" +"すべてのデータを「7 ビットクリーン」(ASCII のみ) にする必要があります。\n" +"このため必要に応じて quoted-printable または base64 でデータをエンコードしま" +"す。" #: ../../library/email.policy.rst:192 msgid "``8bit``" msgstr "``8bit``" -#: ../../library/email.policy.rst:192 msgid "" "data is not constrained to be 7 bit clean. Data in headers is still " "required to be ASCII-only and so will be encoded (see :meth:`fold_binary` " "and :attr:`~EmailPolicy.utf8` below for exceptions), but body parts may use " "the ``8bit`` CTE." msgstr "" +"データを 7 ビットクリーンにする必要はありません。\n" +"ヘッダ内のデータは依然として ASCII のみに制限されるためエンコードされますが " +"(例外については以下の :meth:`fold_binary` と :attr:`~EmailPolicy.utf8` を参" +"照)、本体の各部分では ``8bit`` の CTE を使えます。" -#: ../../library/email.policy.rst:198 msgid "" "A ``cte_type`` value of ``8bit`` only works with ``BytesGenerator``, not " "``Generator``, because strings cannot contain binary data. If a " "``Generator`` is operating under a policy that specifies ``cte_type=8bit``, " "it will act as if ``cte_type`` is ``7bit``." msgstr "" +"文字列はバイナリデータを含められないため、``cte_type`` の値 ``8bit`` は " +"``BytesGenerator`` でのみ機能し、``Generator`` では機能しません。\n" +"``Generator`` が ``cte_type=8bit`` を指定したポリシーで動作する場合は、" +"``cte_type`` が ``7bit`` であるかのように動作します。" -#: ../../library/email.policy.rst:206 msgid "" "If :const:`True`, any defects encountered will be raised as errors. If :" "const:`False` (the default), defects will be passed to the :meth:" "`register_defect` method." msgstr "" +":const:`True` の場合、見つかった不具合はすべてエラーとして送出されます。\n" +":const:`False` (デフォルト) の場合、不具合は :meth:`register_defect` メソッド" +"に渡されます。" -#: ../../library/email.policy.rst:213 msgid "" "If :const:`True`, lines starting with *\"From \"* in the body are escaped by " "putting a ``>`` in front of them. This parameter is used when the message is " "being serialized by a generator. Default: :const:`False`." msgstr "" +":const:`True` の場合、本体内で *\"From \"* で始まる行は先頭に ``>`` を付けて" +"エスケープされます。\n" +"このパラメータはジェネレータがメッセージをシリアライズするときに使います。\n" +"デフォルトは :const:`False` です。" -#: ../../library/email.policy.rst:223 msgid "" "A factory function for constructing a new empty message object. Used by the " "parser when building messages. Defaults to ``None``, in which case :class:" "`~email.message.Message` is used." msgstr "" +"新しい空のメッセージオブジェクトを作成するファクトリ関数です。\n" +"パーザがメッセージを組み立てるときに使います。\n" +"デフォルトは ``None`` で、この場合は :class:`~email.message.Message` を使いま" +"す。" -#: ../../library/email.policy.rst:232 msgid "" "If ``True`` (the default), the generator will raise :exc:`~email.errors." "HeaderWriteError` instead of writing a header that is improperly folded or " @@ -321,33 +399,47 @@ msgid "" "adjacent data. Such headers can be generated by custom header classes or " "bugs in the ``email`` module." msgstr "" +"``True`` (デフォルト) の場合、折り返しや区切りが不適切で、複数のヘッダとして" +"解析されたり隣接するデータと結合されたりするヘッダを書き込む代わりに、ジェネ" +"レータは :exc:`~email.errors.HeaderWriteError` を送出します。\n" +"このようなヘッダは独自のヘッダクラスや ``email`` モジュールのバグによって生成" +"される可能性があります。" -#: ../../library/email.policy.rst:239 msgid "" "As it's a security feature, this defaults to ``True`` even in the :class:" "`~email.policy.Compat32` policy. For backwards compatible, but unsafe, " "behavior, it must be set to ``False`` explicitly." msgstr "" +"セキュリティ機能であるため、:class:`~email.policy.Compat32` ポリシーでもデ" +"フォルトは ``True`` です。\n" +"安全ではありませんが後方互換の動作にするには、明示的に ``False`` に設定しなけ" +"ればなりません。" -#: ../../library/email.policy.rst:247 msgid "" "The following :class:`Policy` method is intended to be called by code using " "the email library to create policy instances with custom settings:" msgstr "" +"次の :class:`Policy` メソッドは、email ライブラリを使うコードから呼び出して、" +"設定を変更したポリシーのインスタンスを作成するためのものです:" -#: ../../library/email.policy.rst:253 msgid "" "Return a new :class:`Policy` instance whose attributes have the same values " "as the current instance, except where those attributes are given new values " "by the keyword arguments." msgstr "" +"現在のインスタンスと同じ属性値を持つ新しい :class:`Policy` インスタンスを返し" +"ます。\n" +"ただし、キーワード引数で指定された属性は新しい値になります。" -#: ../../library/email.policy.rst:258 msgid "" "The remaining :class:`Policy` methods are called by the email package code, " "and are not intended to be called by an application using the email package. " "A custom policy must implement all of these methods." msgstr "" +"残りの :class:`Policy` メソッドは email パッケージのコードから呼び出すもの" +"で、email パッケージを使うアプリケーションから呼び出すためのものではありませ" +"ん。\n" +"独自のポリシーはこれらのメソッドをすべて実装しなければなりません。" #: ../../library/email.policy.rst:265 msgid "" @@ -355,12 +447,15 @@ msgid "" "*defect* will always be a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: ../../library/email.policy.rst:269 msgid "" "The default implementation checks the :attr:`raise_on_defect` flag. If it " "is ``True``, *defect* is raised as an exception. If it is ``False`` (the " "default), *obj* and *defect* are passed to :meth:`register_defect`." msgstr "" +"デフォルトの実装は :attr:`raise_on_defect` フラグを調べます。\n" +"``True`` の場合、*defect* を例外として送出します。\n" +"``False`` (デフォルト) の場合、*obj* と *defect* を :meth:`register_defect` " +"に渡します。" #: ../../library/email.policy.rst:276 msgid "" @@ -368,7 +463,6 @@ msgid "" "a subclass of :class:`~email.errors.MessageDefect`." msgstr "" -#: ../../library/email.policy.rst:279 msgid "" "The default implementation calls the ``append`` method of the ``defects`` " "attribute of *obj*. When the email package calls :attr:`handle_defect`, " @@ -377,20 +471,29 @@ msgid "" "custom ``Message`` objects) should also provide such an attribute, otherwise " "defects in parsed messages will raise unexpected errors." msgstr "" +"デフォルトの実装は、*obj* の ``defects`` 属性の ``append`` メソッドを呼び出し" +"ます。\n" +"email パッケージが :attr:`handle_defect` を呼び出すとき、通常 *obj* には " +"``append`` メソッドを持つ ``defects`` 属性があります。\n" +"email パッケージとともに使う独自のオブジェクト型 (例えば独自の ``Message`` オ" +"ブジェクト) もこの属性を提供する必要があります。\n" +"そうしないと、解析したメッセージの不具合が予期しないエラーを引き起こします。" #: ../../library/email.policy.rst:289 msgid "Return the maximum allowed number of headers named *name*." msgstr "*name* というヘッダに許される最大の数を返します。" -#: ../../library/email.policy.rst:291 msgid "" "Called when a header is added to an :class:`~email.message.EmailMessage` or :" "class:`~email.message.Message` object. If the returned value is not ``0`` " "or ``None``, and there are already a number of headers with the name *name* " "greater than or equal to the value returned, a :exc:`ValueError` is raised." msgstr "" +":class:`~email.message.EmailMessage` または :class:`~email.message.Message` " +"オブジェクトにヘッダを追加するときに呼び出されます。\n" +"返り値が ``0`` でも ``None`` でもなく、*name* という名前のヘッダがすでに返り" +"値以上の個数存在する場合、:exc:`ValueError` が送出されます。" -#: ../../library/email.policy.rst:297 msgid "" "Because the default behavior of ``Message.__setitem__`` is to append the " "value to the list of headers, it is easy to create duplicate headers without " @@ -399,12 +502,17 @@ msgid "" "programmatically. (The limit is not observed by the parser, which will " "faithfully produce as many headers as exist in the message being parsed.)" msgstr "" +"``Message.__setitem__`` のデフォルトの動作はヘッダのリストへの追加であるた" +"め、気付かないうちにヘッダを重複させてしまいがちです。\n" +"このメソッドを使うと、特定のヘッダについて、プログラムから ``Message`` に追加" +"できる個数を制限できます。\n" +"(パーザはこの制限に従わず、解析対象のメッセージにあるヘッダをその個数のまま忠" +"実に生成します。)" #: ../../library/email.policy.rst:305 msgid "The default implementation returns ``None`` for all header names." msgstr "デフォルトの実装は全てのヘッダ名に ``None`` を返します。" -#: ../../library/email.policy.rst:310 msgid "" "The email package calls this method with a list of strings, each string " "ending with the line separation characters found in the source being " @@ -413,8 +521,13 @@ msgid "" "``(name, value)`` tuple that is to be stored in the ``Message`` to represent " "the parsed header." msgstr "" +"email パッケージは文字列のリストを渡してこのメソッドを呼び出します。\n" +"各文字列は解析対象の入力にあった改行文字で終わります。\n" +"最初の行にはヘッダのフィールド名と区切り文字が含まれます。\n" +"入力中の空白文字はすべて保持されます。\n" +"このメソッドは、解析したヘッダを表すために ``Message`` に格納する ``(name, " +"value)`` タプルを返す必要があります。" -#: ../../library/email.policy.rst:317 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, *name* should be the case preserved name (all characters " @@ -422,6 +535,11 @@ msgid "" "(all line separator characters removed, but whitespace kept intact), " "stripped of leading whitespace." msgstr "" +"既存の email パッケージのポリシーとの互換性を維持するには、*name* は大文字・" +"小文字を保持した名前 (区切り文字「``:``」より前のすべての文字) にしてくださ" +"い。\n" +"*value* は折り返しを解除した値 (すべての改行文字を削除し、空白文字は保持した" +"もの) から先頭の空白文字を取り除いたものにしてください。" #: ../../library/email.policy.rst:323 msgid "*sourcelines* may contain surrogateescaped binary data." @@ -434,7 +552,6 @@ msgstr "" msgid "There is no default implementation" msgstr "デフォルトの実装はありません。" -#: ../../library/email.policy.rst:330 msgid "" "The email package calls this method with the name and value provided by the " "application program when the application program is modifying a ``Message`` " @@ -442,15 +559,21 @@ msgid "" "method should return the ``(name, value)`` tuple that is to be stored in the " "``Message`` to represent the header." msgstr "" +"アプリケーションプログラムが ``Message`` をプログラムで変更する場合 (パーザに" +"よる作成とは異なります)、email パッケージはそのプログラムが指定した名前と値を" +"渡してこのメソッドを呼び出します。\n" +"このメソッドは、ヘッダを表すために ``Message`` に格納する ``(name, value)`` " +"タプルを返す必要があります。" -#: ../../library/email.policy.rst:336 msgid "" "If an implementation wishes to retain compatibility with the existing email " "package policies, the *name* and *value* should be strings or string " "subclasses that do not change the content of the passed in arguments." msgstr "" +"既存の email パッケージのポリシーとの互換性を維持するには、*name* と *value* " +"は文字列または文字列のサブクラスで、渡された引数の内容を変更しないものにして" +"ください。" -#: ../../library/email.policy.rst:346 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` when that header is requested by the application " @@ -460,6 +583,13 @@ msgid "" "method is passed the specific name and value of the header destined to be " "returned to the application." msgstr "" +"アプリケーションプログラムがヘッダを要求すると、email パッケージは現在 " +"``Message`` に格納されている *name* と *value* を渡してこのメソッドを呼び出し" +"ます。\n" +"このメソッドの返り値が、取得するヘッダの値としてアプリケーションに渡されま" +"す。\n" +"``Message`` には同名のヘッダが複数格納されていることがあります。\n" +"このメソッドには、アプリケーションに返す対象のヘッダの名前と値が渡されます。" #: ../../library/email.policy.rst:354 msgid "" @@ -470,7 +600,6 @@ msgstr "" "のメソッドの返り値にはサロゲートエスケープされたバイナリーデータはありませ" "ん。" -#: ../../library/email.policy.rst:362 msgid "" "The email package calls this method with the *name* and *value* currently " "stored in the ``Message`` for a given header. The method should return a " @@ -479,6 +608,12 @@ msgid "" "attr:`linesep` characters at the appropriate places. See :rfc:`5322` for a " "discussion of the rules for folding email headers." msgstr "" +"email パッケージは、対象のヘッダについて現在 ``Message`` に格納されている " +"*name* と *value* を渡してこのメソッドを呼び出します。\n" +"このメソッドは *name* と *value* を組み合わせ、適切な位置に :attr:`linesep` " +"の文字を挿入して、ポリシーの設定に従って正しく「折り返した」ヘッダを表す文字" +"列を返す必要があります。\n" +"電子メールのヘッダの折り返し規則については :rfc:`5322` を参照してください。" #: ../../library/email.policy.rst:369 msgid "" @@ -505,38 +640,45 @@ msgstr "" "*value* はサロゲートエスケープされたバイナリデータを持つことがあります。これ" "らは返されたbytesオブジェクト内でバイナリデータに変換されることがあります。" -#: ../../library/email.policy.rst:385 msgid "" "This concrete :class:`Policy` provides behavior that is intended to be fully " "compliant with the current email RFCs. These include (but are not limited " "to) :rfc:`5322`, :rfc:`2047`, and the current MIME RFCs." msgstr "" +"この具象 :class:`Policy` は、現行の電子メールの RFC に完全に準拠することを意" +"図した動作を提供します。\n" +"対象には :rfc:`5322`、:rfc:`2047`、現行の MIME の RFC などが含まれます。" -#: ../../library/email.policy.rst:389 msgid "" "This policy adds new header parsing and folding algorithms. Instead of " "simple strings, headers are ``str`` subclasses with attributes that depend " "on the type of the field. The parsing and folding algorithm fully " "implement :rfc:`2047` and :rfc:`5322`." msgstr "" +"このポリシーはヘッダの解析と折り返しに新しいアルゴリズムを導入します。\n" +"ヘッダは単純な文字列ではなく、フィールドの種類に応じた属性を持つ ``str`` のサ" +"ブクラスになります。\n" +"解析と折り返しのアルゴリズムは :rfc:`2047` と :rfc:`5322` を完全に実装してい" +"ます。" -#: ../../library/email.policy.rst:394 msgid "" "The default value for the :attr:`~email.policy.Policy.message_factory` " "attribute is :class:`~email.message.EmailMessage`." msgstr "" +":attr:`~email.policy.Policy.message_factory` 属性のデフォルト値は :class:" +"`~email.message.EmailMessage` です。" -#: ../../library/email.policy.rst:397 msgid "" "In addition to the settable attributes listed above that apply to all " "policies, this policy adds the following additional attributes:" msgstr "" +"すべてのポリシーに適用される、上記の設定可能な属性に加え、このポリシーには以" +"下の属性があります:" #: ../../library/email.policy.rst:400 msgid "[1]_" msgstr "[1]_" -#: ../../library/email.policy.rst:405 msgid "" "If ``False``, follow :rfc:`5322`, supporting non-ASCII characters in headers " "by encoding them as :rfc:`2047` \"encoded words\". If ``True``, follow :rfc:" @@ -544,8 +686,13 @@ msgid "" "way may be passed to SMTP servers that support the ``SMTPUTF8`` extension (:" "rfc:`6531`)." msgstr "" +"``False`` の場合は :rfc:`5322` に従い、ヘッダ内の非 ASCII 文字を :rfc:`2047` " +"の \"encoded words\" としてエンコードします。\n" +"``True`` の場合は :rfc:`6532` に従い、ヘッダに ``utf-8`` エンコーディングを使" +"います。\n" +"この形式のメッセージは ``SMTPUTF8`` 拡張 (:rfc:`6531`) をサポートする SMTP " +"サーバーに渡せます。" -#: ../../library/email.policy.rst:411 msgid "" "When ``False``, the generator will raise :exc:`~email.errors." "HeaderWriteError` if any header includes non-ASCII characters in a context " @@ -557,53 +704,66 @@ msgid "" "idna`. It is not possible to use a non-ASCII username (\"local-part\") in a " "mailbox when ``utf8=False``." msgstr "" +"``False`` の場合、:rfc:`2047` で encoded words が許可されていない位置に非 " +"ASCII 文字を含むヘッダがあると、ジェネレータは :exc:`~email.errors." +"HeaderWriteError` を送出します。\n" +"特に、:class:`~email.headerregistry.Address` で作成できる、非 ASCII 文字を含" +"むメールボックス (\"addr-spec\") がこれに該当します。\n" +"``utf8=False`` で非 ASCII のドメイン名を持つメールボックスを使うには、まず" +"サードパーティーの :pypi:`idna` や :pypi:`uts46` モジュール、または :mod:" +"`encodings.idna` でドメイン名をエンコードしてください。\n" +"``utf8=False`` の場合、メールボックスに非 ASCII のユーザー名 (\"local-" +"part\") は使えません。" -#: ../../library/email.policy.rst:422 msgid "" "Can trigger the raising of :exc:`~email.errors.HeaderWriteError`. (Earlier " "versions incorrectly applied :rfc:`2047` in certain contexts, mostly notably " "in addr-specs.)" msgstr "" +":exc:`~email.errors.HeaderWriteError` が送出されることがあります。\n" +"(以前のバージョンでは、特に addr-spec などの一部の位置で :rfc:`2047` が誤って" +"適用されていました。)" -#: ../../library/email.policy.rst:429 msgid "" "If the value for a header in the ``Message`` object originated from a :mod:" "`~email.parser` (as opposed to being set by a program), this attribute " "indicates whether or not a generator should refold that value when " "transforming the message back into serialized form. The possible values are:" msgstr "" +"``Message`` オブジェクト内のヘッダの値が、プログラムによる設定ではなく :mod:" +"`~email.parser` による解析で得られた場合、この属性はメッセージをシリアライズ" +"された形式に戻す際にジェネレータがその値を折り返し直すかどうかを示します。\n" +"指定できる値は次のとおりです:" #: ../../library/email.policy.rst:436 msgid "``none``" msgstr "``none``" -#: ../../library/email.policy.rst:436 msgid "all source values use original folding" -msgstr "" +msgstr "入力から得られたすべての値について、元の折り返しを使います。" #: ../../library/email.policy.rst:438 msgid "``long``" msgstr "``long``" -#: ../../library/email.policy.rst:438 msgid "" "source values that have any line that is longer than ``max_line_length`` " "will be refolded" msgstr "" +"入力から得られた値に ``max_line_length`` を超える長さの行がある場合、その値を" +"折り返し直します。" #: ../../library/email.policy.rst:441 msgid "``all``" msgstr "``all``" -#: ../../library/email.policy.rst:441 msgid "all values are refolded." -msgstr "" +msgstr "すべての値を折り返し直します。" #: ../../library/email.policy.rst:444 msgid "The default is ``long``." msgstr "デフォルトは ``long`` です。" -#: ../../library/email.policy.rst:449 msgid "" "A callable that takes two arguments, ``name`` and ``value``, where ``name`` " "is a header field name and ``value`` is an unfolded header field value, and " @@ -613,8 +773,14 @@ msgid "" "field types, and the major MIME header field stypes. Support for additional " "custom parsing will be added in the future." msgstr "" +"ヘッダのフィールド名 ``name`` と折り返しを解除したフィールド値 ``value`` の " +"2 つの引数を取り、そのヘッダを表す文字列のサブクラスを返す呼び出し可能オブ" +"ジェクトです。\n" +"デフォルトの ``header_factory`` (:mod:`~email.headerregistry` を参照) は、:" +"RFC:`5322` の各種アドレス・日付ヘッダフィールドと、主要な MIME ヘッダフィール" +"ドに応じた解析をサポートしています。\n" +"今後、さらに独自の解析への対応が追加される予定です。" -#: ../../library/email.policy.rst:460 msgid "" "An object with at least two methods: get_content and set_content. When the :" "meth:`~email.message.EmailMessage.get_content` or :meth:`~email.message." @@ -624,6 +790,16 @@ msgid "" "that were passed to it as additional arguments. By default " "``content_manager`` is set to :data:`~email.contentmanager.raw_data_manager`." msgstr "" +"少なくとも ``get_content`` と ``set_content`` の 2 つのメソッドを持つオブジェ" +"クトです。\n" +":class:`~email.message.EmailMessage` オブジェクトの :meth:`~email.message." +"EmailMessage.get_content` または :meth:`~email.message.EmailMessage." +"set_content` メソッドが呼び出されると、このオブジェクトの対応するメソッドを呼" +"び出します。\n" +"その際、最初の引数としてメッセージオブジェクトを渡し、元の呼び出しで渡された" +"引数やキーワード引数を追加の引数として渡します。\n" +"デフォルトでは ``content_manager`` は :data:`~email.contentmanager." +"raw_data_manager` に設定されています。" #: ../../library/email.policy.rst:472 ../../library/email.policy.rst:630 msgid "" @@ -631,22 +807,24 @@ msgid "" "methods of :class:`Policy`:" msgstr "このクラスは :class:`Policy` の抽象メソッドの具象実装を提供します:" -#: ../../library/email.policy.rst:478 msgid "" "Returns the value of the :attr:`~email.headerregistry.BaseHeader.max_count` " "attribute of the specialized class used to represent the header with the " "given name." msgstr "" +"指定された名前のヘッダを表す専用クラスの :attr:`~email.headerregistry." +"BaseHeader.max_count` 属性の値を返します。" -#: ../../library/email.policy.rst:486 ../../library/email.policy.rst:636 msgid "" "The name is parsed as everything up to the '``:``' and returned unmodified. " "The value is determined by stripping leading whitespace off the remainder of " "the first line, joining all subsequent lines together, and stripping any " "trailing carriage return or linefeed characters." msgstr "" +"名前は「``:``」より前のすべての文字として解析され、そのまま返されます。\n" +"値は、最初の行の残りから先頭の空白文字を取り除き、その後のすべての行を連結" +"し、末尾の復帰文字や改行文字を取り除いて求めます。" -#: ../../library/email.policy.rst:494 msgid "" "The name is returned unchanged. If the input value has a ``name`` attribute " "and it matches *name* ignoring case, the value is returned unchanged. " @@ -654,8 +832,14 @@ msgid "" "resulting header object is returned as the value. In this case a " "``ValueError`` is raised if the input value contains CR or LF characters." msgstr "" +"名前は変更せずに返します。\n" +"入力値に ``name`` 属性があり、大文字・小文字を区別せずに *name* と一致する場" +"合、値はそのまま返します。\n" +"それ以外の場合は *name* と *value* を ``header_factory`` に渡し、得られたヘッ" +"ダオブジェクトを値として返します。\n" +"この場合、入力値に CR または LF 文字が含まれていると ``ValueError`` を送出し" +"ます。" -#: ../../library/email.policy.rst:504 msgid "" "If the value has a ``name`` attribute, it is returned to unmodified. " "Otherwise the *name*, and the *value* with any CR or LF characters removed, " @@ -663,8 +847,12 @@ msgid "" "returned. Any surrogateescaped bytes get turned into the Unicode unknown-" "character glyph." msgstr "" +"値に ``name`` 属性がある場合は、そのまま返します。\n" +"それ以外の場合は、*name* と、CR や LF 文字を取り除いた *value* を " +"``header_factory`` に渡し、得られたヘッダオブジェクトを返します。\n" +"サロゲートエスケープされたバイトは Unicode の不明な文字を表す記号に置き換えら" +"れます。" -#: ../../library/email.policy.rst:513 msgid "" "Header folding is controlled by the :attr:`refold_source` policy setting. A " "value is considered to be a 'source value' if and only if it does not have a " @@ -675,8 +863,15 @@ msgid "" "Folding of a header object is done by calling its ``fold`` method with the " "current policy." msgstr "" +"ヘッダの折り返しはポリシーの :attr:`refold_source` 設定で制御します。\n" +"``name`` 属性を持たない値だけを「入力から得られた値」とみなします (``name`` " +"属性がある場合は何らかのヘッダオブジェクトです)。\n" +"ポリシーに従って入力から得られた値を折り返し直す必要がある場合は、*name* と、" +"CR や LF 文字を取り除いた *value* を ``header_factory`` に渡し、ヘッダオブ" +"ジェクトに変換します。\n" +"ヘッダオブジェクトの折り返しは、現在のポリシーを渡してその ``fold`` メソッド" +"を呼び出すことで行います。" -#: ../../library/email.policy.rst:522 msgid "" "Source values are split into lines using :meth:`~str.splitlines`. If the " "value is not to be refolded, the lines are rejoined using the ``linesep`` " @@ -685,6 +880,12 @@ msgid "" "``refold_source`` setting, which causes the binary data to be CTE encoded " "using the ``unknown-8bit`` charset." msgstr "" +"入力から得られた値は :meth:`~str.splitlines` で行に分割されます。\n" +"折り返し直さない場合は、ポリシーの ``linesep`` を使って行を再び連結し、返しま" +"す。\n" +"ただし非 ASCII のバイナリデータを含む行は例外です。\n" +"この場合は ``refold_source`` の設定にかかわらず値を折り返し直し、" +"``unknown-8bit`` 文字セットを使ってバイナリデータを CTE エンコードします。" #: ../../library/email.policy.rst:532 msgid "" @@ -702,13 +903,16 @@ msgid "" "binary data consists of single byte characters or multibyte characters." msgstr "" -#: ../../library/email.policy.rst:542 msgid "" "The following instances of :class:`EmailPolicy` provide defaults suitable " "for specific application domains. Note that in the future the behavior of " "these instances (in particular the ``HTTP`` instance) may be adjusted to " "conform even more closely to the RFCs relevant to their domains." msgstr "" +"以下の :class:`EmailPolicy` インスタンスは、特定の用途に適したデフォルト値を" +"提供します。\n" +"今後、各用途に関係する RFC にさらに厳密に準拠するよう、これらのインスタンス " +"(特に ``HTTP`` インスタンス) の動作が調整される可能性があります。" #: ../../library/email.policy.rst:550 msgid "" @@ -719,13 +923,14 @@ msgstr "" "デフォルト値を変更していない ``EmailPolicy`` のインスタンスです。このポリシー" "の行末は、 RFC で正しい ``\\r\\n`` ではなく Python の標準の ``\\n`` です。" -#: ../../library/email.policy.rst:557 msgid "" "Suitable for serializing messages in conformance with the email RFCs. Like " "``default``, but with ``linesep`` set to ``\\r\\n``, which is RFC compliant." msgstr "" +"電子メールの RFC に準拠してメッセージをシリアライズするのに適しています。\n" +"``default`` と同様ですが、``linesep`` は RFC に準拠した ``\\r\\n`` に設定され" +"ています。" -#: ../../library/email.policy.rst:564 msgid "" "The same as ``SMTP`` except that :attr:`~EmailPolicy.utf8` is ``True``. " "Useful for serializing messages to a message store without using encoded " @@ -733,51 +938,65 @@ msgid "" "sender or recipient addresses have non-ASCII characters (the :meth:`smtplib." "SMTP.send_message` method handles this automatically)." msgstr "" +":attr:`~EmailPolicy.utf8` が ``True`` である点を除き、``SMTP`` と同じです。\n" +"ヘッダに encoded words を使わず、メッセージの保存先にシリアライズするのに便利" +"です。\n" +"SMTP 送信では、送信者または受信者のアドレスに非 ASCII 文字が含まれる場合だけ" +"使ってください (:meth:`smtplib.SMTP.send_message` メソッドはこれを自動的に処" +"理します)。" -#: ../../library/email.policy.rst:573 msgid "" "Suitable for serializing headers with for use in HTTP traffic. Like " "``SMTP`` except that ``max_line_length`` is set to ``None`` (unlimited)." msgstr "" +"HTTP 通信で使うヘッダのシリアライズに適しています。\n" +"``SMTP`` と同様ですが、``max_line_length`` は ``None`` (無制限) に設定されて" +"います。" -#: ../../library/email.policy.rst:579 msgid "" "Convenience instance. The same as ``default`` except that " "``raise_on_defect`` is set to ``True``. This allows any policy to be made " "strict by writing::" msgstr "" +"便宜的に用意されたインスタンスです。\n" +"``raise_on_defect`` が ``True`` に設定されている点を除き、``default`` と同じ" +"です。\n" +"次のように書くと、任意のポリシーを厳格にできます。 ::" -#: ../../library/email.policy.rst:583 msgid "somepolicy + policy.strict" -msgstr "" +msgstr "somepolicy + policy.strict" -#: ../../library/email.policy.rst:586 msgid "" "With all of these :class:`EmailPolicies <.EmailPolicy>`, the effective API " "of the email package is changed from the Python 3.2 API in the following " "ways:" msgstr "" +"これらの :class:`EmailPolicy <.EmailPolicy>` では、email パッケージの実際の " +"API は Python 3.2 の API から以下のように変わります:" -#: ../../library/email.policy.rst:589 msgid "" "Setting a header on a :class:`~email.message.Message` results in that header " "being parsed and a header object created." msgstr "" +":class:`~email.message.Message` にヘッダを設定すると、そのヘッダが解析されて" +"ヘッダオブジェクトが作成されます。" -#: ../../library/email.policy.rst:592 msgid "" "Fetching a header value from a :class:`~email.message.Message` results in " "that header being parsed and a header object created and returned." msgstr "" +":class:`~email.message.Message` からヘッダの値を取得すると、そのヘッダが解析" +"されてヘッダオブジェクトが作成され、返されます。" -#: ../../library/email.policy.rst:596 msgid "" "Any header object, or any header that is refolded due to the policy " "settings, is folded using an algorithm that fully implements the RFC folding " "algorithms, including knowing where encoded words are required and allowed." msgstr "" +"すべてのヘッダオブジェクトと、ポリシー設定によって折り返し直されるヘッダに" +"は、RFC の折り返しアルゴリズムを完全に実装したアルゴリズムが使われます。\n" +"このアルゴリズムは encoded words が必要な位置と許可される位置も判断します。" -#: ../../library/email.policy.rst:601 msgid "" "From the application view, this means that any header obtained through the :" "class:`~email.message.EmailMessage` is a header object with extra " @@ -786,6 +1005,12 @@ msgid "" "using a string, and the policy will take care of converting the string into " "the correct RFC encoded form." msgstr "" +"アプリケーション側から見ると、:class:`~email.message.EmailMessage` から取得す" +"るヘッダはすべて追加の属性を持つヘッダオブジェクトになり、その文字列の値は完" +"全にデコードされたヘッダの値になります。\n" +"同様に、文字列を使ってヘッダに新しい値を代入したり、新しいヘッダを作成したり" +"できます。\n" +"ポリシーがその文字列を RFC に従う正しいエンコード形式に変換します。" #: ../../library/email.policy.rst:608 msgid "" @@ -795,7 +1020,6 @@ msgstr "" "ヘッダオブジェクトとその属性は :mod:`~email.headerregistry` で述べられていま" "す。" -#: ../../library/email.policy.rst:615 msgid "" "This concrete :class:`Policy` is the backward compatibility policy. It " "replicates the behavior of the email package in Python 3.2. The :mod:`!" @@ -803,6 +1027,12 @@ msgid "" "that is used as the default policy. Thus the default behavior of the email " "package is to maintain compatibility with Python 3.2." msgstr "" +"この具象 :class:`Policy` は後方互換性のためのポリシーです。\n" +"Python 3.2 の email パッケージの動作を再現します。\n" +":mod:`!policy` モジュールには、このクラスのインスタンス :const:`compat32` も" +"定義されており、デフォルトのポリシーとして使われます。\n" +"このため email パッケージはデフォルトでは Python 3.2 との互換性を維持するよう" +"に動作します。" #: ../../library/email.policy.rst:621 msgid "" @@ -818,22 +1048,28 @@ msgstr "デフォルトは ``True`` です。" msgid "The name and value are returned unmodified." msgstr "名前と値は変更されずに返されます。" -#: ../../library/email.policy.rst:649 msgid "" "If the value contains binary data, it is converted into a :class:`~email." "header.Header` object using the ``unknown-8bit`` charset. Otherwise it is " "returned unmodified." msgstr "" +"値にバイナリデータが含まれる場合、``unknown-8bit`` 文字セットを使って :class:" +"`~email.header.Header` オブジェクトに変換します。\n" +"それ以外の場合はそのまま返します。" -#: ../../library/email.policy.rst:656 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " "resulting line to the ``max_line_length``. Non-ASCII binary data are CTE " "encoded using the ``unknown-8bit`` charset." msgstr "" +"ヘッダは :class:`~email.header.Header` の折り返しアルゴリズムで折り返しま" +"す。\n" +"このアルゴリズムは値に含まれる既存の改行を保持し、各行を ``max_line_length`` " +"に収まるように折り返します。\n" +"非 ASCII のバイナリデータは ``unknown-8bit`` 文字セットを使って CTE エンコー" +"ドされます。" -#: ../../library/email.policy.rst:664 msgid "" "Headers are folded using the :class:`~email.header.Header` folding " "algorithm, which preserves existing line breaks in the value, and wraps each " @@ -842,6 +1078,14 @@ msgid "" "Otherwise the original source header is used, with its existing line breaks " "and any (RFC invalid) binary data it may contain." msgstr "" +"ヘッダは :class:`~email.header.Header` の折り返しアルゴリズムで折り返しま" +"す。\n" +"このアルゴリズムは値に含まれる既存の改行を保持し、各行を ``max_line_length`` " +"に収まるように折り返します。\n" +"``cte_type`` が ``7bit`` の場合、非 ASCII のバイナリデータは " +"``unknown-8bit`` 文字セットを使って CTE エンコードされます。\n" +"それ以外の場合は入力のヘッダをそのまま使い、既存の改行と、含まれていればバイ" +"ナリデータ (RFC では無効です) を保持します。" #: ../../library/email.policy.rst:674 msgid "" @@ -851,19 +1095,23 @@ msgstr "" ":class:`Compat32` のインスタンスで、Python 3.2 の email パッケージの挙動との" "後方互換性を提供します。" -#: ../../library/email.policy.rst:679 msgid "" "The :const:`compat32` policy should not be used as a policy for :class:" "`~email.message.EmailMessage` objects, and should only be used to serialize " "messages that were created using the :const:`compat32` policy." msgstr "" +":const:`compat32` ポリシーは :class:`~email.message.EmailMessage` オブジェク" +"トのポリシーとして使わないでください。\n" +":const:`compat32` ポリシーで作成されたメッセージをシリアライズする場合だけ" +"使ってください。" #: ../../library/email.policy.rst:686 msgid "Footnotes" msgstr "脚注" -#: ../../library/email.policy.rst:687 msgid "" "Originally added in 3.3 as a :term:`provisional feature `." msgstr "" +"当初は 3.3 で :term:`暫定的な機能 ` として追加されまし" +"た。" diff --git a/library/email.utils.po b/library/email.utils.po index 927b22696..88c5d493f 100644 --- a/library/email.utils.po +++ b/library/email.utils.po @@ -16,25 +16,24 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/email.utils.rst:2 msgid ":mod:`!email.utils`: Miscellaneous utilities" -msgstr "" +msgstr ":mod:`!email.utils`: 各種ユーティリティ" #: ../../library/email.utils.rst:7 msgid "**Source code:** :source:`Lib/email/utils.py`" msgstr "**ソースコード:** :source:`Lib/email/utils.py`" -#: ../../library/email.utils.rst:11 msgid "" "There are a couple of useful utilities provided in the :mod:`!email.utils` " "module:" msgstr "" +":mod:`!email.utils` モジュールには、いくつかの便利なユーティリティがあります:" #: ../../library/email.utils.rst:16 msgid "" @@ -45,9 +44,8 @@ msgid "" "``None``), it is assumed to be in local time." msgstr "" -#: ../../library/email.utils.rst:24 msgid "The *isdst* parameter." -msgstr "" +msgstr "*isdst* パラメータ。" #: ../../library/email.utils.rst:29 msgid "" @@ -64,13 +62,15 @@ msgstr "" msgid "Added the *domain* keyword." msgstr "*domain* キーワードが追加されました。" -#: ../../library/email.utils.rst:41 msgid "" "The remaining functions are part of the legacy (``Compat32``) email API. " "There is no need to directly use these with the new API, since the parsing " "and formatting they provide is done automatically by the header parsing " "machinery of the new API." msgstr "" +"以下の関数は従来の (``Compat32``) email API の一部です。\n" +"新しい API ではヘッダの解析機構がこれらの解析や書式化を自動的に行うため、直接" +"使う必要はありません。" #: ../../library/email.utils.rst:49 msgid "" @@ -91,26 +91,27 @@ msgstr "" "がダブルクォートだった場合、それらは取り除かれます。同様に *str* の先頭と末尾" "が角ブラケット (<、>) だった場合もそれらは取り除かれます。" -#: ../../library/email.utils.rst:62 msgid "" "Parse address -- which should be the value of some address-containing field " "such as :mailheader:`To` or :mailheader:`Cc` -- into its constituent " "*realname* and *email address* parts. Returns a tuple of that information, " "unless the parse fails, in which case a 2-tuple of ``('', '')`` is returned." msgstr "" -":mailheader:`To` や :mailheader:`Cc` のようなフィールドを持つアドレスをパース" -"して、構成要素の *実名* と *電子メールアドレス* を取り出します。 パースに成功" -"した場合、これらの情報持つタプルを返します。失敗した場合は 2 要素のタプル " +"アドレスを解析して、構成要素である *実名* と *電子メールアドレス* に分けま" +"す。\n" +"渡すアドレスは :mailheader:`To` や :mailheader:`Cc` など、アドレスを含む" +"フィールドの値です。\n" +"解析に成功した場合はこれらの情報をタプルで返し、失敗した場合は 2 要素タプル " "``('', '')`` を返します。" -#: ../../library/email.utils.rst:67 ../../library/email.utils.rst:95 msgid "" "If *strict* is true, use a strict parser which rejects malformed inputs." -msgstr "" +msgstr "*strict* が真の場合、不正な入力を拒否する厳格なパーザを使います。" -#: ../../library/email.utils.rst:69 ../../library/email.utils.rst:107 msgid "Add *strict* optional parameter and reject malformed inputs by default." msgstr "" +"オプションのパラメータ *strict* が追加され、デフォルトで不正な入力を拒否する" +"ようになりました。" #: ../../library/email.utils.rst:75 msgid "" @@ -145,11 +146,9 @@ msgid "" "be returned by :meth:`Message.get_all `." msgstr "" -#: ../../library/email.utils.rst:97 msgid "Here's a simple example that gets all the recipients of a message::" -msgstr "" +msgstr "メッセージのすべての受信者を取得する簡単な例を示します。 ::" -#: ../../library/email.utils.rst:99 msgid "" "from email.utils import getaddresses\n" "\n" @@ -159,6 +158,13 @@ msgid "" "resent_ccs = msg.get_all('resent-cc', [])\n" "all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)" msgstr "" +"from email.utils import getaddresses\n" +"\n" +"tos = msg.get_all('to', [])\n" +"ccs = msg.get_all('cc', [])\n" +"resent_tos = msg.get_all('resent-to', [])\n" +"resent_ccs = msg.get_all('resent-cc', [])\n" +"all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)" #: ../../library/email.utils.rst:113 msgid "" @@ -180,7 +186,6 @@ msgstr "" "失敗した場合は ``None`` を返します。\n" "返されるタプルの 6、7、8番目の添字は使用不可なので注意してください。" -#: ../../library/email.utils.rst:124 msgid "" "Performs the same function as :func:`parsedate`, but returns either ``None`` " "or a 10-tuple; the first 9 elements make up a tuple that can be passed " @@ -190,6 +195,15 @@ msgid "" "returned is ``0``, which represents UTC. Note that indexes 6, 7, and 8 of " "the result tuple are not usable." msgstr "" +":func:`parsedate` と同じ処理を行いますが、``None`` または 10 要素タプルを返し" +"ます。\n" +"最初の 9 要素は :func:`time.mktime` に直接渡せるタプルを構成し、10 番目の要素" +"は日付のタイムゾーンの UTC (グリニッジ標準時の正式名称) からのオフセットです " +"[#]_。\n" +"入力文字列にタイムゾーンがなければ、返されるタプルの最後の要素は UTC を表す " +"``0`` です。\n" +"返されたタプルのインデックス 6、7、8 の要素は使用できないことに注意してくださ" +"い。" #: ../../library/email.utils.rst:134 msgid "" @@ -219,9 +233,8 @@ msgstr "" msgid "Returns a date string as per :rfc:`2822`, e.g.::" msgstr "日付を :rfc:`2822` 形式の文字列で返します。例::" -#: ../../library/email.utils.rst:159 msgid "Fri, 09 Nov 2001 01:08:47 -0000" -msgstr "" +msgstr "Fri, 09 Nov 2001 01:08:47 -0000" #: ../../library/email.utils.rst:161 msgid "" @@ -305,13 +318,13 @@ msgstr "" "場合には、これは文字列でなければなりません。その場合にはクォートを除いた文字" "列を返します。" -#: ../../library/email.utils.rst:220 msgid "" "Decode parameters list according to :rfc:`2231`. *params* is a sequence of " "2-tuples containing elements of the form ``(content-type, string-value)``." msgstr "" -":rfc:`2231` に従って引数のリストをデコードします。 *params* は ``(content-" -"type, string-value)`` のような形式の 2 要素タプルです。" +":rfc:`2231` に従ってパラメータのリストをデコードします。\n" +"*params* は ``(content-type, string-value)`` 形式の 2 要素タプルからなるシー" +"ケンスです。" #: ../../library/email.utils.rst:225 msgid "Footnotes" diff --git a/library/ensurepip.po b/library/ensurepip.po index 2b9992442..56f5e16bb 100644 --- a/library/ensurepip.po +++ b/library/ensurepip.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/ensurepip.rst:2 @@ -31,7 +31,6 @@ msgstr ":mod:`!ensurepip` --- ``pip`` インストーラーのブートストラ msgid "**Source code:** :source:`Lib/ensurepip`" msgstr "**ソースコード:** :source:`Lib/ensurepip`" -#: ../../library/ensurepip.rst:14 msgid "" "The :mod:`!ensurepip` package provides support for bootstrapping the ``pip`` " "installer into an existing Python installation or virtual environment. This " @@ -40,19 +39,24 @@ msgid "" "is bundled with maintenance and feature releases of the CPython reference " "interpreter." msgstr "" +":mod:`!ensurepip` パッケージは、既存の Python 環境や仮想環境に ``pip`` インス" +"トーラーをブートストラップする機能を提供します。\n" +"この方式は、``pip`` が独自のリリース周期を持つ独立したプロジェクトであること" +"を反映しています。\n" +"CPython 参照インタープリターのメンテナンスリリースと機能リリースには、利用可" +"能な最新の安定版が同梱されます。" -#: ../../library/ensurepip.rst:21 msgid "" "In most cases, end users of Python shouldn't need to invoke this module " "directly (as ``pip`` should be bootstrapped by default), but it may be " "needed if installing ``pip`` was skipped when installing Python (or when " "creating a virtual environment) or after explicitly uninstalling ``pip``." msgstr "" -"ほとんどの場合、Python のエンドユーザーがこのモジュールを直接呼び出す必要はな" -"いでしょう(``pip`` はデフォルトでブートストラップされるからです)。しかし、も" -"し Python のインストール時に ``pip`` のインストールをスキップしたり、仮想環境" -"を構築したり、明示的に ``pip`` をアンインストールした場合、直接呼び出す必要が" -"あるかもしれません。" +"通常、``pip`` はデフォルトでブートストラップされるため、Python のエンドユー" +"ザーがこのモジュールを直接呼び出す必要はありません。\n" +"ただし、Python のインストール時や仮想環境の作成時に ``pip`` のインストールを" +"省略した場合や、``pip`` を明示的にアンインストールした場合には、必要になるこ" +"とがあります。" #: ../../library/ensurepip.rst:29 msgid "" @@ -62,13 +66,16 @@ msgstr "" "このモジュールはインターネットに *アクセスしません*。``pip`` のブートストラッ" "プに必要な全てはこのパッケージの一部として含まれています。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" #: ../../library/ensurepip.rst:37 msgid ":ref:`installing-index`" @@ -86,9 +93,8 @@ msgstr ":pep:`453`: Python インストールの際の明示的なpipのブー msgid "The original rationale and specification for this module." msgstr "このモジュールのもともとの論拠と仕様。" -#: ../../includes/wasm-mobile-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-mobile-notavail.rst:5 msgid "" @@ -113,25 +119,22 @@ msgstr "" msgid "The simplest possible invocation is::" msgstr "最も簡単な起動方法は::" -#: ../../library/ensurepip.rst:56 msgid "python -m ensurepip" -msgstr "" +msgstr "python -m ensurepip" -#: ../../library/ensurepip.rst:58 msgid "" "This invocation will install ``pip`` if it is not already installed, but " "otherwise does nothing. To ensure the installed version of ``pip`` is at " "least as recent as the one available in ``ensurepip``, pass the ``--" "upgrade`` option::" msgstr "" -"この起動方法は ``pip`` をインストールします。既にインストールされていた場合は" -"何もしません。インストールされた ``pip`` のバージョンを ``ensurepip`` で利用" -"できるもののうち、できるだけ新しいものにするためには、``--upgrade`` オプショ" -"ンを追加して::" +"この方法で起動すると、``pip`` が未インストールならインストールし、インストー" +"ル済みなら何もしません。\n" +"インストールされている ``pip`` を、``ensurepip`` に同梱されたものと同じかそれ" +"より新しいバージョンにするには、``--upgrade`` オプションを指定します。 ::" -#: ../../library/ensurepip.rst:63 msgid "python -m ensurepip --upgrade" -msgstr "" +msgstr "python -m ensurepip --upgrade" #: ../../library/ensurepip.rst:65 msgid "" @@ -144,19 +147,23 @@ msgstr "" "イトパッケージ(もしアクティブな仮想環境がなければ)にインストールされます。イ" "ンストール先は2つの追加コマンドラインオプションで制御できます:" -#: ../../library/ensurepip.rst:72 msgid "" "Installs ``pip`` relative to the given root directory rather than the root " "of the currently active virtual environment (if any) or the default root for " "the current Python installation." msgstr "" +"現在有効な仮想環境があればそのルート、なければ現在の Python のデフォルトの" +"ルートではなく、指定されたルートディレクトリを基準に ``pip`` をインストールし" +"ます。" -#: ../../library/ensurepip.rst:78 msgid "" "Installs ``pip`` into the user site packages directory rather than globally " "for the current Python installation (this option is not permitted inside an " "active virtual environment)." msgstr "" +"現在の Python 環境全体ではなく、ユーザーの site-packages ディレクトリに " +"``pip`` をインストールします (有効な仮想環境内ではこのオプションは使えませ" +"ん)。" #: ../../library/ensurepip.rst:82 msgid "" @@ -168,17 +175,19 @@ msgstr "" "``ensurepip`` を起動したPythonのバージョン)。インストールされるスクリプトは2" "つの追加コマンドラインオプションで制御できます:" -#: ../../library/ensurepip.rst:89 msgid "" "If an alternate installation is requested, the ``pipX`` script will *not* be " "installed." msgstr "" +"代替インストールを指定すると、``pipX`` スクリプトはインストール *されません" +"*。" -#: ../../library/ensurepip.rst:94 msgid "" "If a \"default pip\" installation is requested, the ``pip`` script will be " "installed in addition to the two regular scripts." msgstr "" +"「デフォルトの pip」のインストールを指定すると、通常の 2 つのスクリプトに加え" +"て ``pip`` スクリプトもインストールされます。" #: ../../library/ensurepip.rst:97 msgid "" @@ -189,9 +198,8 @@ msgstr "2つのスクリプト選択オプションを指定すると例外が msgid "Module API" msgstr "モジュール API" -#: ../../library/ensurepip.rst:102 msgid ":mod:`!ensurepip` exposes two functions for programmatic use:" -msgstr "" +msgstr ":mod:`!ensurepip` には、プログラムから使うための関数が 2 つあります:" #: ../../library/ensurepip.rst:106 msgid "" diff --git a/library/enum.po b/library/enum.po index 3cc545005..4936b07b5 100644 --- a/library/enum.po +++ b/library/enum.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Masahiro Ito, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/enum.rst:2 @@ -82,7 +82,6 @@ msgstr "" "列挙型は、:keyword:`class` 構文を使用するか、関数呼び出し構文を使用して作成さ" "れます::" -#: ../../library/enum.rst:33 msgid "" ">>> from enum import Enum\n" "\n" @@ -95,6 +94,16 @@ msgid "" ">>> # functional syntax\n" ">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" msgstr "" +">>> from enum import Enum\n" +"\n" +">>> # class 構文\n" +">>> class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"\n" +">>> # 関数呼び出し構文\n" +">>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])" #: ../../library/enum.rst:44 msgid "" @@ -239,13 +248,13 @@ msgstr "" " ``STRICT``、``CONFORM``、``EJECT``、``KEEP`` の値を持つ列挙型です。列挙型で" "の無効な値の扱いについて、より細かい制御が可能です。" -#: ../../library/enum.rst:108 msgid ":class:`EnumDict`" -msgstr "" +msgstr ":class:`EnumDict`" -#: ../../library/enum.rst:110 msgid "A subclass of :class:`dict` for use when subclassing :class:`EnumType`." msgstr "" +":class:`EnumType` のサブクラスを作成するときに使う :class:`dict` のサブクラス" +"です。" #: ../../library/enum.rst:112 msgid ":class:`auto`" @@ -261,9 +270,8 @@ msgstr "" "ではデフォルトの値がメンバー名を小文字にしたものですが、その他の列挙型のデ" "フォルトは1から連番で増加する値となります。" -#: ../../library/enum.rst:118 msgid ":deco:`~enum.property`" -msgstr "" +msgstr ":deco:`~enum.property`" #: ../../library/enum.rst:120 msgid "" @@ -274,9 +282,8 @@ msgstr "" "メンバー名との競合を避けながら :class:`Enum` メンバーに属性を持たせます。" "``value`` 属性と ``name`` 属性はこの方法で実装されます。" -#: ../../library/enum.rst:124 msgid ":deco:`unique`" -msgstr "" +msgstr ":deco:`unique`" #: ../../library/enum.rst:126 msgid "" @@ -285,42 +292,41 @@ msgstr "" "一つの名前だけがひとつの値に束縛されていることを保証する Enum クラスのデコ" "レーターです。" -#: ../../library/enum.rst:128 msgid ":deco:`verify`" -msgstr "" +msgstr ":deco:`verify`" -#: ../../library/enum.rst:130 msgid "" "Enum class decorator that checks user-selectable constraints on an " "enumeration." msgstr "" +"列挙型が、利用者の選択した制約を満たすか確認する Enum クラスのデコレータで" +"す。" -#: ../../library/enum.rst:133 msgid ":deco:`member`" -msgstr "" +msgstr ":deco:`member`" #: ../../library/enum.rst:135 msgid "Make ``obj`` a member. Can be used as a decorator." msgstr "``obj`` をメンバーにします。デコレータとして使用できます。" -#: ../../library/enum.rst:137 msgid ":deco:`nonmember`" -msgstr "" +msgstr ":deco:`nonmember`" #: ../../library/enum.rst:139 msgid "Do not make ``obj`` a member. Can be used as a decorator." msgstr "``obj`` をメンバーにしません。デコレータとして使用できます。" -#: ../../library/enum.rst:141 msgid ":deco:`global_enum`" -msgstr "" +msgstr ":deco:`global_enum`" -#: ../../library/enum.rst:143 msgid "" "Modify the :class:`str() ` and :func:`repr` of an enum to show its " "members as belonging to the module instead of its class, and export the enum " "members to the global namespace." msgstr "" +"列挙型の :class:`str() ` と :func:`repr` を変更し、メンバーがクラスでは" +"なくモジュールに属するように表示します。\n" +"また、列挙型のメンバーをグローバル名前空間に公開します。" #: ../../library/enum.rst:147 msgid ":func:`show_flag_values`" @@ -330,16 +336,16 @@ msgstr ":func:`show_flag_values`" msgid "Return a list of all power-of-two integers contained in a flag." msgstr "フラグに含まれる、全ての2の累乗の整数のリストを返します。" -#: ../../library/enum.rst:151 msgid ":func:`enum.bin`" -msgstr "" +msgstr ":func:`enum.bin`" -#: ../../library/enum.rst:153 ../../library/enum.rst:1076 msgid "" "Like built-in :func:`bin`, except negative values are represented in two's " "complement, and the leading bit always indicates sign (``0`` implies " "positive, ``1`` implies negative)." msgstr "" +"組み込みの :func:`bin` と似ていますが、負の値は 2 の補数で表し、先頭のビット" +"は常に符号を示します (``0`` は正、``1`` は負を示します)。" #: ../../library/enum.rst:158 msgid "``Flag``, ``IntFlag``, ``auto``" @@ -353,9 +359,8 @@ msgstr "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" -#: ../../library/enum.rst:160 msgid "``EnumDict``" -msgstr "" +msgstr "``EnumDict``" #: ../../library/enum.rst:165 msgid "Data types" @@ -371,19 +376,23 @@ msgstr "" "*EnumType* のサブクラスを作成することが可能です -- 詳細は :ref:`EnumTypeのサ" "ブクラスを作る ` を参照してください。" -#: ../../library/enum.rst:174 msgid "" "``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" "`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the " "final *enum*, as well as creating the enum members, properly handling " "duplicates, providing iteration over the enum class, etc." msgstr "" +"``EnumType`` は、最終的な *enum* に正しい :meth:`!__repr__`、:meth:`!" +"__str__`、:meth:`!__format__`、:meth:`!__reduce__` メソッドを設定します。\n" +"また、列挙型のメンバーの作成、重複の適切な処理、列挙型クラスの反復処理の提供" +"なども担当します。" -#: ../../library/enum.rst:181 msgid "" "Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " "as an alias." msgstr "" +"3.11 より前は ``EnumType`` は ``EnumMeta`` と呼ばれていました。\n" +"この名前は現在もエイリアスとして使えます。" #: ../../library/enum.rst:185 msgid "This method is called in two different ways:" @@ -423,7 +432,7 @@ msgstr "新しく作成するEnumの名前。" #: ../../library/enum.rst:0 msgid "names" -msgstr "names" +msgstr "名前" #: ../../library/enum.rst:197 msgid "The names/values of the members for the new Enum." @@ -441,9 +450,8 @@ msgstr "新しく作成するEnumの属するモジュール名。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:199 msgid "The actual location in the module where this Enum can be found." -msgstr "" +msgstr "この Enum がモジュール内にある実際の位置。" #: ../../library/enum.rst:0 msgid "type" @@ -474,7 +482,6 @@ msgstr "bit演算での範囲外の値の扱い方(:class:`Flag` のみ)。" msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "メンバーが ``cls`` に属している場合は ``True`` を返します::" -#: ../../library/enum.rst:208 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -482,14 +489,18 @@ msgid "" ">>> Color.RED.value in Color\n" "True" msgstr "" +">>> some_var = Color.RED\n" +">>> some_var in Color\n" +"True\n" +">>> Color.RED.value in Color\n" +"True" -#: ../../library/enum.rst:216 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." msgstr "" -"Python 3.12 以前では、非Enumメンバーの包含判定が行われた場合、``TypeError`` " -"が送出されます。" +"Python 3.12 より前では、非Enumメンバーの包含判定が行われた場合、" +"``TypeError`` が送出されます。" #: ../../library/enum.rst:221 msgid "" @@ -499,59 +510,66 @@ msgstr "" "``['__class__', '__doc__', '__members__', '__module__']`` と、 *cls* に属する" "メンバー名を返します::" -#: ../../library/enum.rst:224 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" msgstr "" +">>> dir(Color)\n" +"['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " +"'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " +"'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:229 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" -msgstr "*cls* 内の一致するメンバーを返すか、:exc:`KeyError` を送出します::" +msgstr "" +"*cls* 内で *name* に一致する Enum メンバーを返します。\n" +"見つからなければ :exc:`KeyError` を送出します。 ::" -#: ../../library/enum.rst:231 msgid "" ">>> Color['BLUE']\n" "" msgstr "" +">>> Color['BLUE']\n" +"" -#: ../../library/enum.rst:236 msgid "Returns each member in *cls* in definition order::" -msgstr " *cls* 内の各メンバー を定義順に返します::" +msgstr "*cls* 内の各メンバー を定義順に返します::" -#: ../../library/enum.rst:238 msgid "" ">>> list(Color)\n" "[, , ]" msgstr "" +">>> list(Color)\n" +"[, , ]" -#: ../../library/enum.rst:243 msgid "Returns the number of members in *cls*::" -msgstr "" +msgstr "*cls* のメンバー数を返します。 ::" -#: ../../library/enum.rst:245 msgid "" ">>> len(Color)\n" "3" msgstr "" +">>> len(Color)\n" +"3" -#: ../../library/enum.rst:250 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "" +"エイリアスも含め、列挙型のすべての名前を対応するメンバーに結び付けるマッピン" +"グを返します。" #: ../../library/enum.rst:254 msgid "Returns each member in *cls* in reverse definition order::" msgstr "*cls* 内の各メンバー を定義順の逆順で返します::" -#: ../../library/enum.rst:256 msgid "" ">>> list(reversed(Color))\n" "[, , ]" msgstr "" +">>> list(reversed(Color))\n" +"[, , ]" #: ../../library/enum.rst:262 msgid "*Enum* is the base class for all *enum* enumerations." @@ -561,25 +579,28 @@ msgstr "*Enum* は全ての *enum* 列挙型の基底クラスです。" msgid "The name used to define the ``Enum`` member::" msgstr "``Enum`` メンバーを定義するために使用される名前::" -#: ../../library/enum.rst:268 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" msgstr "" +">>> Color.BLUE.name\n" +"'BLUE'" #: ../../library/enum.rst:273 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` メンバーに与えられた値::" -#: ../../library/enum.rst:275 msgid "" ">>> Color.RED.value\n" "1" msgstr "" +">>> Color.RED.value\n" +"1" -#: ../../library/enum.rst:278 ../../library/enum.rst:298 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "" +"メンバーの値です。\n" +":meth:`~Enum.__new__` で設定できます。" #: ../../library/enum.rst:280 msgid "Enum member values" @@ -596,17 +617,19 @@ msgstr "" "値が選ばれます。\n" "詳細は :class:`auto` を参照してください。" -#: ../../library/enum.rst:287 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " "quadratic performance impact during creation relative to the total number of " "mutable/unhashable values in the enum." msgstr "" +":class:`dict`、:class:`list`、ミュータブルな :class:`~dataclasses.dataclass` " +"など、ミュータブルまたはハッシュ不可能な値も使えます。\n" +"ただし作成時の処理時間には、列挙型内のそのような値の総数に対して二次的に増大" +"する影響があります。" -#: ../../library/enum.rst:294 msgid "Name of the member." -msgstr "" +msgstr "メンバーの名前。" #: ../../library/enum.rst:302 msgid "" @@ -614,14 +637,15 @@ msgid "" "during class creation)." msgstr "" -#: ../../library/enum.rst:305 msgid "" "The :attr:`~Enum._order_` attribute can be provided to help keep Python 2 / " "Python 3 code in sync. It will be checked against the actual order of the " "enumeration and raise an error if the two do not match::" msgstr "" +":attr:`~Enum._order_` 属性を指定すると、Python 2 と Python 3 のコードを揃えて" +"おくのに役立ちます。\n" +"この属性を列挙型の実際の順序と照合し、一致しない場合はエラーを送出します。 ::" -#: ../../library/enum.rst:308 msgid "" ">>> class Color(Enum):\n" "... _order_ = 'RED GREEN BLUE'\n" @@ -635,12 +659,24 @@ msgid "" " ['RED', 'BLUE', 'GREEN']\n" " ['RED', 'GREEN', 'BLUE']" msgstr "" +">>> class Color(Enum):\n" +"... _order_ = 'RED GREEN BLUE'\n" +"... RED = 1\n" +"... BLUE = 3\n" +"... GREEN = 2\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"TypeError: member order does not match _order_:\n" +" ['RED', 'BLUE', 'GREEN']\n" +" ['RED', 'GREEN', 'BLUE']" -#: ../../library/enum.rst:322 msgid "" "In Python 2 code the :attr:`~Enum._order_` attribute is necessary as " "definition order is lost before it can be recorded." msgstr "" +"Python 2 では、記録する前に定義の順序が失われるため、:attr:`~Enum._order_` 属" +"性が必要です。" #: ../../library/enum.rst:329 msgid "" @@ -666,7 +702,6 @@ msgstr "" " ``['__class__', '__doc__', '__module__', 'name', 'value']`` と *self." "__class__* に定義されたpublicなメソッドを返します::" -#: ../../library/enum.rst:343 msgid "" ">>> from enum import Enum\n" ">>> import datetime as dt\n" @@ -686,6 +721,23 @@ msgid "" "['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', " "'today', 'value']" msgstr "" +">>> from enum import Enum\n" +">>> import datetime as dt\n" +">>> class Weekday(Enum):\n" +"... MONDAY = 1\n" +"... TUESDAY = 2\n" +"... WEDNESDAY = 3\n" +"... THURSDAY = 4\n" +"... FRIDAY = 5\n" +"... SATURDAY = 6\n" +"... SUNDAY = 7\n" +"... @classmethod\n" +"... def today(cls):\n" +"... print(f'today is {cls(dt.date.today().isoweekday()).name}')\n" +"...\n" +">>> dir(Weekday.SATURDAY)\n" +"['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', " +"'today', 'value']" #: ../../library/enum.rst:0 msgid "name" @@ -715,11 +767,10 @@ msgstr "last_values" msgid "A list of the previous values." msgstr "定義済みの値のリスト。" -#: ../../library/enum.rst:367 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`." -msgstr "" +msgstr ":class:`auto` が次に返す値を決めるための *staticmethod* です。" #: ../../library/enum.rst:371 msgid "" @@ -736,11 +787,11 @@ msgid "" msgstr "" ":class:`Flag` クラスでは、次に選ばれる値は、次の最大の2のべき乗となります。" -#: ../../library/enum.rst:377 msgid "This method may be overridden, e.g.::" msgstr "" +"このメソッドはオーバーライドできます。\n" +"例えば次のようにします。 ::" -#: ../../library/enum.rst:379 msgid "" ">>> from enum import auto, Enum\n" ">>> class PowersOfThree(Enum):\n" @@ -753,6 +804,16 @@ msgid "" ">>> PowersOfThree.SECOND.value\n" "9" msgstr "" +">>> from enum import auto, Enum\n" +">>> class PowersOfThree(Enum):\n" +"... @staticmethod\n" +"... def _generate_next_value_(name, start, count, last_values):\n" +"... return 3 ** (count + 1)\n" +"... FIRST = auto()\n" +"... SECOND = auto()\n" +"...\n" +">>> PowersOfThree.SECOND.value\n" +"9" #: ../../library/enum.rst:391 msgid "" @@ -793,7 +854,6 @@ msgstr "" "しませんが、カスタムの検索の振る舞いを実装するためにオーバーライドすることが" "できます::" -#: ../../library/enum.rst:415 msgid "" ">>> from enum import auto, StrEnum\n" ">>> class Build(StrEnum):\n" @@ -812,6 +872,22 @@ msgid "" ">>> Build('deBUG')\n" "" msgstr "" +">>> from enum import auto, StrEnum\n" +">>> class Build(StrEnum):\n" +"... DEBUG = auto()\n" +"... OPTIMIZED = auto()\n" +"... @classmethod\n" +"... def _missing_(cls, value):\n" +"... value = value.lower()\n" +"... for member in cls:\n" +"... if member.value == value:\n" +"... return member\n" +"... return None\n" +"...\n" +">>> Build.DEBUG.value\n" +"'debug'\n" +">>> Build('deBUG')\n" +"" #: ../../library/enum.rst:436 msgid "" @@ -823,16 +899,17 @@ msgstr "" "ラス(例えば ``int`` など)のいずれかで、メンバーに代入されたすべての値が渡さ" "れます。例::" -#: ../../library/enum.rst:444 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "" +"この場合は ``int('1a', 16)`` が呼び出され、メンバーの値は ``26`` になります。" -#: ../../library/enum.rst:448 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." msgstr "" +"独自の ``__new__`` を書く場合、``super().__new__`` を使わず、適切な " +"``__new__`` を直接呼び出してください。" #: ../../library/enum.rst:453 msgid "" @@ -842,7 +919,6 @@ msgstr "" "*repr()* の呼び出しに使用される文字列を返します。デフォルトでは、 *Enum* 名、" "メンバー名、および値を返しますが、オーバーライドすることもできます::" -#: ../../library/enum.rst:456 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -857,6 +933,18 @@ msgid "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __repr__(self):\n" +"... cls_name = self.__class__.__name__\n" +"... return f'{cls_name}.{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle." +"ALTERNATE}\"\n" +"(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" #: ../../library/enum.rst:470 msgid "" @@ -866,7 +954,6 @@ msgstr "" "*str()* の呼び出しに使用される文字列を返します。デフォルトでは、 *Enum* の名" "前とメンバーの名前を返しますが、オーバーライドすることもできます::" -#: ../../library/enum.rst:473 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -880,6 +967,17 @@ msgid "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __str__(self):\n" +"... return f'{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle." +"ALTERNATE}\"\n" +"(, 'ALTERNATE', 'ALTERNATE')" #: ../../library/enum.rst:486 msgid "" @@ -890,7 +988,6 @@ msgstr "" "トでは、:meth:`__str__` の戻り値を返しますが、オーバーライドすることもできま" "す。::" -#: ../../library/enum.rst:489 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -904,6 +1001,17 @@ msgid "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" msgstr "" +">>> from enum import auto, Enum\n" +">>> class OtherStyle(Enum):\n" +"... ALTERNATE = auto()\n" +"... OTHER = auto()\n" +"... SOMETHING_ELSE = auto()\n" +"... def __format__(self, spec):\n" +"... return f'{self.name}'\n" +"...\n" +">>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f\"{OtherStyle." +"ALTERNATE}\"\n" +"(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" #: ../../library/enum.rst:502 msgid "" @@ -913,55 +1021,60 @@ msgstr "" ":class:`Enum` で :class:`auto` を使用すると、 ``1`` から始まりインクリメント" "する整数が値となります。" -#: ../../library/enum.rst:505 msgid "Added :ref:`enum-dataclass-support`." -msgstr "" +msgstr ":ref:`enum-dataclass-support` が追加されました。" -#: ../../library/enum.rst:509 msgid "Adds a new name as an alias to an existing member::" -msgstr "" +msgstr "既存のメンバーのエイリアスとして新しい名前を追加します。 ::" -#: ../../library/enum.rst:511 msgid "" ">>> Color.RED._add_alias_(\"ERROR\")\n" ">>> Color.ERROR\n" "" msgstr "" +">>> Color.RED._add_alias_(\"ERROR\")\n" +">>> Color.ERROR\n" +"" -#: ../../library/enum.rst:515 msgid "" "Raises a :exc:`NameError` if the name is already assigned to a different " "member." msgstr "" +"その名前がすでに別のメンバーに割り当てられている場合、:exc:`NameError` を送出" +"します。" -#: ../../library/enum.rst:521 msgid "Adds a new value as an alias to an existing member::" -msgstr "" +msgstr "既存のメンバーのエイリアスとして新しい値を追加します。 ::" -#: ../../library/enum.rst:523 msgid "" ">>> Color.RED._add_value_alias_(42)\n" ">>> Color(42)\n" "" msgstr "" +">>> Color.RED._add_value_alias_(42)\n" +">>> Color(42)\n" +"" -#: ../../library/enum.rst:527 msgid "" "Raises a :exc:`ValueError` if the value is already linked with a different " "member." msgstr "" +"その値がすでに別のメンバーに結び付けられている場合、:exc:`ValueError` を送出" +"します。" -#: ../../library/enum.rst:528 msgid "See :ref:`multi-value-enum` for an example." -msgstr "" +msgstr "例は :ref:`multi-value-enum` を参照してください。" -#: ../../library/enum.rst:535 msgid "" "*IntEnum* is the same as :class:`Enum`, but its members are also integers " "and can be used anywhere that an integer can be used. If any integer " "operation is performed with an *IntEnum* member, the resulting value loses " "its enumeration status." msgstr "" +"*IntEnum* は :class:`Enum` と同様ですが、メンバーは整数でもあり、整数が使える" +"場所ならどこでも使えます。\n" +"*IntEnum* のメンバーを使って整数演算を行うと、結果の値は列挙型ではなくなりま" +"す。" #: ../../library/enum.rst:556 msgid "" @@ -981,21 +1094,27 @@ msgstr "" "ポートするために :meth:`!int.__str__` に変更されました。同じ理由で、:meth:" "`~object.__format__` は既に :meth:`!int.__format__` に変更されています。" -#: ../../library/enum.rst:566 msgid "" "*StrEnum* is the same as :class:`Enum`, but its members are also strings and " "can be used in most of the same places that a string can be used. The result " "of any string operation performed on or with a *StrEnum* member is not part " "of the enumeration." msgstr "" +"*StrEnum* は :class:`Enum` と同様ですが、メンバーは文字列でもあり、文字列が使" +"える場所のほとんどで使えます。\n" +"*StrEnum* のメンバーに対して、またはそれを使って文字列操作を行った結果は、列" +"挙型のメンバーにはなりません。" -#: ../../library/enum.rst:587 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " "``isinstance(unknown, str)``), and in those locations you will need to use " "``str(MyStrEnum.MY_MEMBER)``." msgstr "" +"標準ライブラリには :class:`str` のサブクラスを受け付けず、型が厳密に :class:" +"`str` かどうかを調べる箇所があります (つまり ``isinstance(unknown, str)`` で" +"はなく ``type(unknown) == str`` を使います)。\n" +"そのような箇所では ``str(MyStrEnum.MY_MEMBER)`` を使う必要があります。" #: ../../library/enum.rst:594 msgid "" @@ -1015,18 +1134,19 @@ msgstr "" "するために :meth:`!str.__str__` となりました。 :meth:`~object.__format__` も" "同様に、同じ理由で :meth:`!str.__format__` となりました。" -#: ../../library/enum.rst:607 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " "the results of those operations are (aliases of) members of the enumeration." msgstr "" +"``Flag`` は :class:`Enum` と同様ですが、メンバーはビット演算子 ``&`` " +"(*AND*)、``|`` (*OR*)、``^`` (*XOR*)、``~`` (*INVERT*) をサポートします。\n" +"これらの演算結果は列挙型のメンバー (のエイリアス) になります。" #: ../../library/enum.rst:613 msgid "Returns *True* if value is in self::" msgstr "値を含む場合に *True* を返します::" -#: ../../library/enum.rst:615 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1045,30 +1165,52 @@ msgid "" ">>> white in purple\n" "False" msgstr "" +">>> from enum import Flag, auto\n" +">>> class Color(Flag):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> purple = Color.RED | Color.BLUE\n" +">>> white = Color.RED | Color.GREEN | Color.BLUE\n" +">>> Color.GREEN in purple\n" +"False\n" +">>> Color.GREEN in white\n" +"True\n" +">>> purple in white\n" +"True\n" +">>> white in purple\n" +"False" -#: ../../library/enum.rst:634 msgid "Returns all contained non-alias members::" -msgstr "エイリアスでない、全てのメンバーを返します::" +msgstr "" +"このフラグに含まれるメンバーのうち、エイリアスでないものをすべて返します。 ::" -#: ../../library/enum.rst:636 msgid "" ">>> list(Color.RED)\n" "[]\n" ">>> list(purple)\n" "[, ]" msgstr "" +">>> list(Color.RED)\n" +"[]\n" +">>> list(purple)\n" +"[, ]" #: ../../library/enum.rst:645 msgid "Returns number of members in flag::" msgstr "flag 内のメンバーの数を返します::" -#: ../../library/enum.rst:647 msgid "" ">>> len(Color.GREEN)\n" "1\n" ">>> len(white)\n" "3" msgstr "" +">>> len(Color.GREEN)\n" +"1\n" +">>> len(white)\n" +"3" #: ../../library/enum.rst:656 msgid "Returns *True* if any members in flag, *False* otherwise::" @@ -1076,7 +1218,6 @@ msgstr "" "メンバーがflagに含まれている場合は *True* を返し、それ以外の場合は *False* を" "返します::" -#: ../../library/enum.rst:658 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1086,46 +1227,60 @@ msgid "" ">>> bool(black)\n" "False" msgstr "" +">>> bool(Color.GREEN)\n" +"True\n" +">>> bool(white)\n" +"True\n" +">>> black = Color(0)\n" +">>> bool(black)\n" +"False" #: ../../library/enum.rst:668 msgid "Returns current flag binary or'ed with other::" msgstr "現在のフラグと他のフラグの論理和となるフラグを返します::" -#: ../../library/enum.rst:670 msgid "" ">>> Color.RED | Color.GREEN\n" "" msgstr "" +">>> Color.RED | Color.GREEN\n" +"" #: ../../library/enum.rst:675 msgid "Returns current flag binary and'ed with other::" msgstr "現在のフラグと他のフラグの論理積となるフラグを返します::" -#: ../../library/enum.rst:677 msgid "" ">>> purple & white\n" "\n" ">>> purple & Color.GREEN\n" "" msgstr "" +">>> purple & white\n" +"\n" +">>> purple & Color.GREEN\n" +"" #: ../../library/enum.rst:684 msgid "Returns current flag binary xor'ed with other::" msgstr "現在のフラグと他のフラグの排他的論理和となるフラグを返します::" -#: ../../library/enum.rst:686 msgid "" ">>> purple ^ white\n" "\n" ">>> purple ^ Color.GREEN\n" "" msgstr "" +">>> purple ^ white\n" +"\n" +">>> purple ^ Color.GREEN\n" +"" -#: ../../library/enum.rst:693 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "" +"*type(self)* に含まれるフラグのうち、*self* に含まれないものをすべて返しま" +"す。 ::" -#: ../../library/enum.rst:695 msgid "" ">>> ~white\n" "\n" @@ -1134,12 +1289,20 @@ msgid "" ">>> ~Color.RED\n" "" msgstr "" +">>> ~white\n" +"\n" +">>> ~purple\n" +"\n" +">>> ~Color.RED\n" +"" -#: ../../library/enum.rst:704 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." msgstr "" +"名前のない残りの数値を書式化する関数です。\n" +"デフォルトは値の ``repr()`` 結果です。\n" +"よく使われる選択肢は :func:`hex` と :func:`oct` です。" #: ../../library/enum.rst:709 msgid "" @@ -1149,15 +1312,17 @@ msgstr "" ":class:`auto` と :class:`Flag` を一緒に使うと、``1`` から始まる2の累乗の整数" "になります。" -#: ../../library/enum.rst:712 msgid "The *repr()* of zero-valued flags has changed. It is now:" msgstr "" +"値がゼロのフラグの *repr()* が変更されました。\n" +"現在は次のようになります:" -#: ../../library/enum.rst:720 msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " "and can be used anywhere that an integer can be used." msgstr "" +"``IntFlag`` は :class:`Flag` と同様ですが、メンバーは整数でもあり、整数が使え" +"る場所ならどこでも使えます。" #: ../../library/enum.rst:734 msgid "" @@ -1167,35 +1332,38 @@ msgstr "" "*IntFlag* のメンバーと整数の演算が行われた場合、結果は *IntFlag* ではありませ" "ん::" -#: ../../library/enum.rst:737 msgid "" ">>> Color.RED + 2\n" "3" msgstr "" +">>> Color.RED + 2\n" +"3" -#: ../../library/enum.rst:740 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" -msgstr "" +msgstr "*IntFlag* のメンバーに対して :class:`Flag` の演算を行うと:" #: ../../library/enum.rst:742 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果が有効な *IntFlag*: *IntFlag* が返されます" -#: ../../library/enum.rst:743 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "" +"結果が有効な *IntFlag* でない場合、結果は :class:`FlagBoundary` の設定によっ" +"て決まります。" -#: ../../library/enum.rst:745 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now::" msgstr "" +"名前がなく値がゼロのフラグの :func:`repr` が変更されました。\n" +"現在は次のようになります。 ::" -#: ../../library/enum.rst:747 msgid "" ">>> Color(0)\n" "" msgstr "" +">>> Color(0)\n" +"" #: ../../library/enum.rst:752 msgid "" @@ -1225,19 +1393,18 @@ msgstr "" "正の値を返すようになりました。これは既存の :class:`Flag` の振る舞いに一致しま" "す。" -#: ../../library/enum.rst:767 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" msgstr "" +":class:`!ReprEnum` は :class:`Enum` の :meth:`repr() ` を使い" +"ますが、:class:`str() ` には混ぜ込まれたデータ型のものを使います:" -#: ../../library/enum.rst:770 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" -msgstr "" +msgstr ":class:`IntEnum` と :class:`IntFlag` では :meth:`!int.__str__`" -#: ../../library/enum.rst:771 msgid ":meth:`!str.__str__` for :class:`StrEnum`" -msgstr "" +msgstr ":class:`StrEnum` では :meth:`!str.__str__`" #: ../../library/enum.rst:773 msgid "" @@ -1249,20 +1416,18 @@ msgstr "" "` を使用する代わりに、mix-inされたデータ型の :class:`str() " "` / :func:`format` を使用します。" -#: ../../library/enum.rst:782 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." msgstr "" -"*EnumCheck* には :func:`verify` デコレータやさまざまな制約を保証するために使" -"用されるオプションが含まれています。制約に違反すると :exc:`ValueError` が発生" -"します。" +"*EnumCheck* には、:func:`verify` デコレータが各種の制約を確認するために使うオ" +"プションが含まれています。\n" +"制約を満たさない場合は :exc:`ValueError` が送出されます。" #: ../../library/enum.rst:787 msgid "Ensure that each value has only one name::" msgstr "それぞれの値が1つの名前しか持たないことを確認します::" -#: ../../library/enum.rst:789 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1275,6 +1440,16 @@ msgid "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" msgstr "" +">>> from enum import Enum, verify, UNIQUE\n" +">>> @verify(UNIQUE)\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 3\n" +"... CRIMSON = 1\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: aliases found in : CRIMSON -> RED" #: ../../library/enum.rst:803 msgid "" @@ -1282,7 +1457,6 @@ msgid "" "the highest-valued member::" msgstr "最小値のメンバーと最大値のメンバーの間に欠損値がないことを確認します::" -#: ../../library/enum.rst:806 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1294,16 +1468,24 @@ msgid "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" msgstr "" +">>> from enum import Enum, verify, CONTINUOUS\n" +">>> @verify(CONTINUOUS)\n" +"... class Color(Enum):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 5\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:818 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" msgstr "" -"任意のフラググループ/マスクが、名前付きフラグのみを含むことを確認します -- 値" -"を指定するのではなく、:func:`auto` によって生成される場合に便利です::" +"フラグのグループやマスクに、名前付きのフラグだけが含まれることを確認しま" +"す。\n" +":func:`auto` で値を生成する代わりに、値を直接指定する場合に便利です。 ::" -#: ../../library/enum.rst:821 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1318,6 +1500,18 @@ msgid "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" msgstr "" +">>> from enum import Flag, verify, NAMED_FLAGS\n" +">>> @verify(NAMED_FLAGS)\n" +"... class Color(Flag):\n" +"... RED = 1\n" +"... GREEN = 2\n" +"... BLUE = 4\n" +"... WHITE = 15\n" +"... NEON = 31\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " +"combined values of 0x18 [use enum.show_flag_values(value) for details]" #: ../../library/enum.rst:835 msgid "" @@ -1326,11 +1520,12 @@ msgstr "" "CONTINUOUSとNAMED_FLAGSは整数値のメンバーとともに動作するように設計されていま" "す。" -#: ../../library/enum.rst:841 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "" +"``FlagBoundary`` は :class:`Flag` とそのサブクラスで範囲外の値をどう扱うかを" +"制御します。" #: ../../library/enum.rst:846 msgid "" @@ -1340,7 +1535,6 @@ msgstr "" "範囲外の値は :exc:`ValueError` を送出します。これは :class:`Flag` のデフォル" "トです::" -#: ../../library/enum.rst:849 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1355,14 +1549,25 @@ msgid "" " given 0b0 10100\n" " allowed 0b0 00111" msgstr "" +">>> from enum import Flag, STRICT, auto\n" +">>> class StrictFlag(Flag, boundary=STRICT):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> StrictFlag(2**2 + 2**4)\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: invalid value 20\n" +" given 0b0 10100\n" +" allowed 0b0 00111" -#: ../../library/enum.rst:864 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "" +"範囲外の値から無効な部分を取り除き、有効な :class:`Flag` の値を残します。 ::" -#: ../../library/enum.rst:867 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1373,20 +1578,29 @@ msgid "" ">>> ConformFlag(2**2 + 2**4)\n" "" msgstr "" +">>> from enum import Flag, CONFORM, auto\n" +">>> class ConformFlag(Flag, boundary=CONFORM):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> ConformFlag(2**2 + 2**4)\n" +"" -#: ../../library/enum.rst:878 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "" +"範囲外の値は :class:`Flag` のメンバーではなくなり、:class:`int` に戻ります。" -#: ../../library/enum.rst:891 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" msgstr "" +"範囲外の値をそのまま保持し、:class:`Flag` のメンバーであることも維持しま" +"す。\n" +"これは :class:`IntFlag` のデフォルトです。 ::" -#: ../../library/enum.rst:894 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1397,8 +1611,15 @@ msgid "" ">>> KeepFlag(2**2 + 2**4)\n" "" msgstr "" +">>> from enum import Flag, KEEP, auto\n" +">>> class KeepFlag(Flag, boundary=KEEP):\n" +"... RED = auto()\n" +"... GREEN = auto()\n" +"... BLUE = auto()\n" +"...\n" +">>> KeepFlag(2**2 + 2**4)\n" +"" -#: ../../library/enum.rst:907 msgid "" "*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " "defining enum classes (see :ref:`prepare`). It is exposed to allow " @@ -1407,18 +1628,27 @@ msgid "" "created, otherwise private names and internal classes will not be handled " "correctly." msgstr "" +"*EnumDict* は :class:`dict` のサブクラスで、列挙型クラスを定義する名前空間と" +"して使います (:ref:`prepare` を参照)。\n" +"メンバーごとに複数の値を持たせるなど、高度な動作を持つ :class:`EnumType` のサ" +"ブクラスを作成できるように公開されています。\n" +"作成する列挙型クラスの名前を渡して呼び出してください。\n" +"そうしないと、プライベートな名前や内部クラスが正しく処理されません。" -#: ../../library/enum.rst:914 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " "possible to bypass the checks using other :class:`!dict` operations like :" "meth:`|= `." msgstr "" +"オーバーライドされているのは :class:`~collections.abc.MutableMapping` のイン" +"ターフェイス (:meth:`~object.__setitem__` と :meth:`~dict.update`) だけである" +"ことに注意してください。\n" +":meth:`|= ` など、ほかの :class:`!dict` の操作では検査を回避" +"できる場合があります。" -#: ../../library/enum.rst:921 msgid "A list of member names." -msgstr "" +msgstr "メンバー名のリスト。" #: ../../library/enum.rst:930 msgid "Supported ``__dunder__`` names" @@ -1432,13 +1662,16 @@ msgstr "" ":attr:`~EnumType.__members__` は読み込み専用の、 ``member_name``:``member`` " "を要素とする順序付きマッピングです。これはクラスでのみ利用可能です。" -#: ../../library/enum.rst:935 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`~Enum." "_value_` appropriately. Once all the members are created it is no longer " "used." msgstr "" +":meth:`~Enum.__new__` を指定する場合は、列挙型のメンバーを作成して返す必要が" +"あります。\n" +"メンバーの :attr:`~Enum._value_` を適切に設定することも強く推奨します。\n" +"すべてのメンバーの作成が終わると、このメソッドは使われなくなります。" #: ../../library/enum.rst:941 msgid "Supported ``_sunder_`` names" @@ -1452,13 +1685,12 @@ msgstr ":attr:`~Enum._name_` -- メンバー名" msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- メンバーの値; ``__new__`` で設定できます" -#: ../../library/enum.rst:945 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 値が見付からなかったときに使われる検索関数; オー" -"バーライドされていることがあります" +"バーライドできます" #: ../../library/enum.rst:947 msgid "" @@ -1476,36 +1708,40 @@ msgid "" "(class attribute, removed during class creation)" msgstr "" -#: ../../library/enum.rst:953 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 列挙型のメンバーの適切な値を取得するの" -"に使われます。オーバーライドされます。" +"に使われます。\n" +"オーバーライドできます。" -#: ../../library/enum.rst:956 msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr "" +":meth:`~Enum._add_alias_` -- 既存のメンバーのエイリアスとして新しい名前を追加" +"します。" -#: ../../library/enum.rst:958 msgid "" ":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member." msgstr "" +":meth:`~Enum._add_value_alias_` -- 既存のメンバーのエイリアスとして新しい値を" +"追加します。" -#: ../../library/enum.rst:961 msgid "" "While ``_sunder_`` names are generally reserved for the further development " "of the :class:`Enum` class and can not be used, some are explicitly allowed:" msgstr "" +"``_sunder_`` 名は通常、:class:`Enum` クラスの今後の開発のために予約されており" +"使えませんが、明示的に許可されているものもあります:" -#: ../../library/enum.rst:964 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" +"`IPython のリッチな表示機能 `_ で使われる " +"``_repr_*`` (``_repr_html_`` など)" #: ../../library/enum.rst:966 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" @@ -1515,15 +1751,12 @@ msgstr "``_missing_``, ``_order_``, ``_generate_next_value_``" msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:968 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" -msgstr "" +msgstr "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" -#: ../../library/enum.rst:974 msgid "Utilities and decorators" -msgstr "" +msgstr "ユーティリティとデコレータ" -#: ../../library/enum.rst:978 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " @@ -1534,12 +1767,22 @@ msgid "" "member's name. Care must be taken if mixing *auto()* with manually " "specified values." msgstr "" +"値の代わりに *auto* を使えます。\n" +"使った場合、*Enum* の仕組みが :class:`Enum` の :meth:`~Enum." +"_generate_next_value_` を呼び出し、適切な値を取得します。\n" +":class:`Enum` と :class:`IntEnum` では、それまでの最大値に 1 を加えた値になり" +"ます。\n" +":class:`Flag` と :class:`IntFlag` では、それまでの最大値を超える最小の 2 の累" +"乗になります。\n" +":class:`StrEnum` ではメンバー名を小文字にした値になります。\n" +"*auto()* と手動で指定した値を混在させる場合は注意が必要です。" -#: ../../library/enum.rst:986 msgid "" "*auto* instances are only resolved when at the top level of an assignment, " "either by itself or as part of a tuple:" msgstr "" +"*auto* インスタンスが値に置き換えられるのは、代入の最上位に単独で置くか、タプ" +"ルの要素として置く場合だけです:" #: ../../library/enum.rst:989 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" @@ -1553,11 +1796,12 @@ msgstr "" "``SECOND = auto(), -2`` は動作します(auto は ``2`` に置き換えられるため、 " "``SECOND`` 列挙型のメンバーには ``2, -2`` が使用されます)" -#: ../../library/enum.rst:992 msgid "" "``THIRD = [auto(), -3]`` will *not* work (``[, -3]`` is used " "to create the ``THIRD`` enum member)" msgstr "" +"``THIRD = [auto(), -3]`` は意図どおりには動作 *しません* (``[, -3]`` を使って列挙型のメンバー ``THIRD`` が作成されます)。" #: ../../library/enum.rst:997 msgid "" @@ -1582,20 +1826,23 @@ msgid "" "incompatible type." msgstr "" -#: ../../library/enum.rst:1009 msgid "" "A decorator similar to the built-in :deco:`property`, but specifically for " "enumerations. It allows member attributes to have the same names as members " "themselves." msgstr "" +"組み込みの :deco:`property` に似ていますが、列挙型専用のデコレータです。\n" +"メンバーの属性に、メンバー自体と同じ名前を使えるようにします。" -#: ../../library/enum.rst:1013 msgid "" "The *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " "and *Enum* subclasses can define members with the names ``value`` and " "``name``." msgstr "" +"*property* とメンバーは別々のクラスで定義する必要があります。\n" +"例えば *value* と *name* 属性は *Enum* クラスで定義されていますが、*Enum* の" +"サブクラスでは ``value`` や ``name`` という名前のメンバーを定義できます。" #: ../../library/enum.rst:1022 msgid "" @@ -1607,7 +1854,6 @@ msgstr "" "__members__` に別名がないかどうか検索します; 見つかった場合、:exc:" "`ValueError` が詳細情報とともに送出されます::" -#: ../../library/enum.rst:1026 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1621,6 +1867,17 @@ msgid "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" msgstr "" +">>> from enum import Enum, unique\n" +">>> @unique\n" +"... class Mistake(Enum):\n" +"... ONE = 1\n" +"... TWO = 2\n" +"... THREE = 3\n" +"... FOUR = 3\n" +"...\n" +"Traceback (most recent call last):\n" +"...\n" +"ValueError: duplicate values found in : FOUR -> THREE" #: ../../library/enum.rst:1040 msgid "" @@ -1639,13 +1896,16 @@ msgstr "列挙型で使用するデコレータ: 対象は列挙型のメンバ msgid "A decorator for use in enums: its target will not become a member." msgstr "列挙型で使用するデコレータ: 対象は列挙型のメンバー になりません。" -#: ../../library/enum.rst:1060 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " "only be used when the enum members are exported to the module global " "namespace (see :class:`re.RegexFlag` for an example)." msgstr "" +"列挙型の :class:`str() ` と :func:`repr` を変更して、メンバーがクラスで" +"はなくモジュールに属するように表示するデコレータです。\n" +"列挙型のメンバーをモジュールのグローバル名前空間に公開している場合だけ使って" +"ください (例は :class:`re.RegexFlag` を参照)。" #: ../../library/enum.rst:1070 msgid "Return a list of all power-of-two integers contained in a flag *value*." @@ -1687,20 +1947,24 @@ msgstr "" "もし、そのような制限が必要でない/望まない場合は、``int`` または ``str`` タイ" "プを継承して、カスタムの基底クラスを作成することができます::" -#: ../../library/enum.rst:1106 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" "... pass" msgstr "" +">>> from enum import Enum\n" +">>> class MyIntEnum(int, Enum):\n" +"... pass" #: ../../library/enum.rst:1110 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "または列挙型の中で適切な :meth:`str` などを再代入することもできます::" -#: ../../library/enum.rst:1112 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" "... __str__ = Enum.__str__" msgstr "" +">>> from enum import Enum, IntEnum\n" +">>> class MyIntEnum(IntEnum):\n" +"... __str__ = Enum.__str__" diff --git a/library/errno.po b/library/errno.po index ff89a8551..64a807294 100644 --- a/library/errno.po +++ b/library/errno.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/errno.rst:2 @@ -65,29 +65,33 @@ msgstr "" "errorcode.keys()`` として取得することができます。取得できるシンボルには以下の" "ようなものがあります:" -#: ../../library/errno.rst:30 msgid "" "Operation not permitted. This error is mapped to the exception :exc:" "`PermissionError`." msgstr "" +"操作が許可されていません (Operation not permitted)。\n" +"このエラーは例外 :exc:`PermissionError` に対応します。" -#: ../../library/errno.rst:36 msgid "" "No such file or directory. This error is mapped to the exception :exc:" "`FileNotFoundError`." msgstr "" +"そのようなファイルやディレクトリはありません (No such file or directory)。\n" +"このエラーは例外 :exc:`FileNotFoundError` に対応します。" -#: ../../library/errno.rst:42 msgid "" "No such process. This error is mapped to the exception :exc:" "`ProcessLookupError`." msgstr "" +"そのようなプロセスはありません (No such process)。\n" +"このエラーは例外 :exc:`ProcessLookupError` に対応します。" -#: ../../library/errno.rst:48 msgid "" "Interrupted system call. This error is mapped to the exception :exc:" "`InterruptedError`." msgstr "" +"システムコールが割り込まれました (Interrupted system call)。\n" +"このエラーは例外 :exc:`InterruptedError` に対応します。" #: ../../library/errno.rst:54 msgid "I/O error" @@ -110,26 +114,29 @@ msgstr "実行形式にエラーがあります (Exec format error)" msgid "Bad file number" msgstr "ファイル番号が間違っています (Bad file number)" -#: ../../library/errno.rst:79 msgid "" "No child processes. This error is mapped to the exception :exc:" "`ChildProcessError`." msgstr "" +"子プロセスがありません (No child processes)。\n" +"このエラーは例外 :exc:`ChildProcessError` に対応します。" -#: ../../library/errno.rst:85 msgid "" "Try again. This error is mapped to the exception :exc:`BlockingIOError`." msgstr "" +"再試行してください (Try again)。\n" +"このエラーは例外 :exc:`BlockingIOError` に対応します。" #: ../../library/errno.rst:90 msgid "Out of memory" msgstr "空きメモリがありません (Out of memory)" -#: ../../library/errno.rst:95 msgid "" "Permission denied. This error is mapped to the exception :exc:" "`PermissionError`." msgstr "" +"アクセスが拒否されました (Permission denied)。\n" +"このエラーは例外 :exc:`PermissionError` に対応します。" #: ../../library/errno.rst:101 msgid "Bad address" @@ -143,10 +150,11 @@ msgstr "ブロックデバイスが必要です (Block device required)" msgid "Device or resource busy" msgstr "そのデバイスまたはリソースは使用中です (Device or resource busy)" -#: ../../library/errno.rst:116 msgid "" "File exists. This error is mapped to the exception :exc:`FileExistsError`." msgstr "" +"ファイルが存在します (File exists)。\n" +"このエラーは例外 :exc:`FileExistsError` に対応します。" #: ../../library/errno.rst:122 msgid "Cross-device link" @@ -156,17 +164,19 @@ msgstr "デバイスをまたいだリンクです (Cross-device link)" msgid "No such device" msgstr "そのようなデバイスはありません (No such device)" -#: ../../library/errno.rst:132 msgid "" "Not a directory. This error is mapped to the exception :exc:" "`NotADirectoryError`." msgstr "" +"ディレクトリではありません (Not a directory)。\n" +"このエラーは例外 :exc:`NotADirectoryError` に対応します。" -#: ../../library/errno.rst:138 msgid "" "Is a directory. This error is mapped to the exception :exc:" "`IsADirectoryError`." msgstr "" +"ディレクトリです (Is a directory)。\n" +"このエラーは例外 :exc:`IsADirectoryError` に対応します。" #: ../../library/errno.rst:144 msgid "Invalid argument" @@ -208,10 +218,11 @@ msgstr "リードオンリーのファイルシステムです (Read-only file s msgid "Too many links" msgstr "リンクが多すぎます (Too many links)" -#: ../../library/errno.rst:194 msgid "" "Broken pipe. This error is mapped to the exception :exc:`BrokenPipeError`." msgstr "" +"パイプが壊れています (Broken pipe)。\n" +"このエラーは例外 :exc:`BrokenPipeError` に対応します。" #: ../../library/errno.rst:200 msgid "Math argument out of domain of func" @@ -248,11 +259,12 @@ msgstr "" "これ以上シンボリックリンクを追跡できません (Too many symbolic links " "encountered)" -#: ../../library/errno.rst:240 msgid "" "Operation would block. This error is mapped to the exception :exc:" "`BlockingIOError`." msgstr "" +"操作を進めるにはブロックする必要があります (Operation would block)。\n" +"このエラーは例外 :exc:`BlockingIOError` に対応します。" #: ../../library/errno.rst:246 msgid "No message of desired type" @@ -306,9 +318,8 @@ msgstr "無効な要求記述子です (Invalid request descriptor)" msgid "Exchange full" msgstr "変換テーブルが一杯です (Exchange full)" -#: ../../library/errno.rst:311 msgid "No anode" -msgstr "陰極がありません (No anode)" +msgstr "anode がありません (No anode)。" #: ../../library/errno.rst:316 msgid "Invalid request code" @@ -438,11 +449,10 @@ msgstr "" msgid "Illegal byte sequence" msgstr "不正なバイト列です (Illegal byte sequence)" -#: ../../library/errno.rst:461 msgid "Interrupted system call should be restarted" msgstr "" -"割り込みシステムコールを復帰しなければなりません (Interrupted system call " -"should be restarted)" +"割り込まれたシステムコールを再実行する必要があります (Interrupted system " +"call should be restarted)" #: ../../library/errno.rst:466 msgid "Streams pipe error" @@ -487,9 +497,8 @@ msgstr "" "通信端点に対してサポートされていない操作です (Operation not supported on " "transport endpoint)" -#: ../../library/errno.rst:516 msgid "Operation not supported" -msgstr "" +msgstr "操作がサポートされていません (Operation not supported)。" #: ../../library/errno.rst:523 msgid "Protocol family not supported" @@ -525,17 +534,20 @@ msgstr "" "リセットによってネットワーク接続が切られました (Network dropped connection " "because of reset)" -#: ../../library/errno.rst:558 msgid "" "Software caused connection abort. This error is mapped to the exception :exc:" "`ConnectionAbortedError`." msgstr "" +"ソフトウェアによって接続が中断されました (Software caused connection " +"abort)。\n" +"このエラーは例外 :exc:`ConnectionAbortedError` に対応します。" -#: ../../library/errno.rst:564 msgid "" "Connection reset by peer. This error is mapped to the exception :exc:" "`ConnectionResetError`." msgstr "" +"接続相手によって接続がリセットされました (Connection reset by peer)。\n" +"このエラーは例外 :exc:`ConnectionResetError` に対応します。" #: ../../library/errno.rst:570 msgid "No buffer space available" @@ -550,27 +562,31 @@ msgstr "" msgid "Transport endpoint is not connected" msgstr "通信端点が接続されていません (Transport endpoint is not connected)" -#: ../../library/errno.rst:585 msgid "" "Cannot send after transport endpoint shutdown. This error is mapped to the " "exception :exc:`BrokenPipeError`." msgstr "" +"通信端点をシャットダウンした後は送信できません (Cannot send after transport " +"endpoint shutdown)。\n" +"このエラーは例外 :exc:`BrokenPipeError` に対応します。" #: ../../library/errno.rst:591 msgid "Too many references: cannot splice" msgstr "参照が多すぎます: 接続できません (Too many references: cannot splice)" -#: ../../library/errno.rst:596 msgid "" "Connection timed out. This error is mapped to the exception :exc:" "`TimeoutError`." msgstr "" +"接続がタイムアウトしました (Connection timed out)。\n" +"このエラーは例外 :exc:`TimeoutError` に対応します。" -#: ../../library/errno.rst:602 msgid "" "Connection refused. This error is mapped to the exception :exc:" "`ConnectionRefusedError`." msgstr "" +"接続が拒否されました (Connection refused)。\n" +"このエラーは例外 :exc:`ConnectionRefusedError` に対応します。" #: ../../library/errno.rst:608 msgid "Host is down" @@ -580,21 +596,23 @@ msgstr "ホストはシステムダウンしています (Host is down)" msgid "No route to host" msgstr "ホストへの経路がありません (No route to host)" -#: ../../library/errno.rst:618 msgid "Memory page has hardware error." msgstr "" +"メモリページにハードウェアエラーがあります (Memory page has hardware error)。" -#: ../../library/errno.rst:625 msgid "" "Operation already in progress. This error is mapped to the exception :exc:" "`BlockingIOError`." msgstr "" +"操作はすでに進行中です (Operation already in progress)。\n" +"このエラーは例外 :exc:`BlockingIOError` に対応します。" -#: ../../library/errno.rst:631 msgid "" "Operation now in progress. This error is mapped to the exception :exc:" "`BlockingIOError`." msgstr "" +"操作は現在進行中です (Operation now in progress)。\n" +"このエラーは例外 :exc:`BlockingIOError` に対応します。" #: ../../library/errno.rst:637 msgid "Stale NFS file handle" @@ -624,132 +642,109 @@ msgstr "遠隔側の I/O エラーです (Remote I/O error)" msgid "Quota exceeded" msgstr "ディスククオータを超えました (Quota exceeded)" -#: ../../library/errno.rst:671 msgid "Interface output queue is full" msgstr "" +"インターフェイスの出力キューがいっぱいです (Interface output queue is full)。" -#: ../../library/errno.rst:678 msgid "No medium found" -msgstr "" +msgstr "媒体が見つかりません (No medium found)。" -#: ../../library/errno.rst:683 msgid "Wrong medium type" -msgstr "" +msgstr "媒体の種類が違います (Wrong medium type)。" -#: ../../library/errno.rst:688 msgid "Required key not available" -msgstr "" +msgstr "必要な鍵が利用できません (Required key not available)。" -#: ../../library/errno.rst:693 msgid "Key has expired" -msgstr "" +msgstr "鍵の有効期限が切れています (Key has expired)。" -#: ../../library/errno.rst:698 msgid "Key has been revoked" -msgstr "" +msgstr "鍵が取り消されています (Key has been revoked)。" -#: ../../library/errno.rst:703 msgid "Key was rejected by service" -msgstr "" +msgstr "サービスが鍵を拒否しました (Key was rejected by service)。" -#: ../../library/errno.rst:708 msgid "Operation not possible due to RF-kill" msgstr "" +"RF-kill によって操作できません (Operation not possible due to RF-kill)。" -#: ../../library/errno.rst:713 msgid "Locked lock was unmapped" msgstr "" +"ロック中のロックがマッピング解除されました (Locked lock was unmapped)。" -#: ../../library/errno.rst:718 msgid "Facility is not active" -msgstr "" +msgstr "機能が有効ではありません (Facility is not active)。" -#: ../../library/errno.rst:723 msgid "Authentication error" -msgstr "" +msgstr "認証エラーです (Authentication error)。" -#: ../../library/errno.rst:730 msgid "Bad CPU type in executable" -msgstr "" +msgstr "実行可能ファイルの CPU 型が不正です (Bad CPU type in executable)。" -#: ../../library/errno.rst:737 msgid "Bad executable (or shared library)" msgstr "" +"実行可能ファイルまたは共有ライブラリが不正です (Bad executable (or shared " +"library))。" -#: ../../library/errno.rst:744 msgid "Malformed Mach-o file" -msgstr "" +msgstr "Mach-o ファイルの形式が不正です (Malformed Mach-o file)。" -#: ../../library/errno.rst:751 msgid "Device error" -msgstr "" +msgstr "デバイスエラーです (Device error)。" -#: ../../library/errno.rst:758 msgid "Inappropriate file type or format" msgstr "" +"ファイルの種類または形式が不適切です (Inappropriate file type or format)。" -#: ../../library/errno.rst:765 msgid "Need authenticator" -msgstr "" +msgstr "認証機構が必要です (Need authenticator)。" -#: ../../library/errno.rst:772 msgid "Attribute not found" -msgstr "" +msgstr "属性が見つかりません (Attribute not found)。" -#: ../../library/errno.rst:779 msgid "Policy not found" -msgstr "" +msgstr "ポリシーが見つかりません (Policy not found)。" -#: ../../library/errno.rst:786 msgid "Too many processes" -msgstr "" +msgstr "プロセスが多すぎます (Too many processes)。" -#: ../../library/errno.rst:793 msgid "Bad procedure for program" -msgstr "" +msgstr "プログラムに対する手続きが不正です (Bad procedure for program)。" -#: ../../library/errno.rst:800 msgid "Program version wrong" -msgstr "" +msgstr "プログラムのバージョンが違います (Program version wrong)。" -#: ../../library/errno.rst:807 msgid "RPC prog. not avail" -msgstr "" +msgstr "RPC プログラムが利用できません (RPC prog. not avail)。" -#: ../../library/errno.rst:814 msgid "Device power is off" -msgstr "" +msgstr "デバイスの電源が切れています (Device power is off)。" -#: ../../library/errno.rst:821 msgid "RPC struct is bad" -msgstr "" +msgstr "RPC 構造体が不正です (RPC struct is bad)。" -#: ../../library/errno.rst:828 msgid "RPC version wrong" -msgstr "" +msgstr "RPC のバージョンが違います (RPC version wrong)。" -#: ../../library/errno.rst:835 msgid "Shared library version mismatch" msgstr "" +"共有ライブラリのバージョンが一致しません (Shared library version mismatch)。" -#: ../../library/errno.rst:842 msgid "" "Capabilities insufficient. This error is mapped to the exception :exc:" "`PermissionError`." msgstr "" +"ケーパビリティが不足しています (Capabilities insufficient)。\n" +"このエラーは例外 :exc:`PermissionError` に対応します。" -#: ../../library/errno.rst:845 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" -#: ../../library/errno.rst:852 msgid "Operation canceled" -msgstr "" +msgstr "操作がキャンセルされました (Operation canceled)。" -#: ../../library/errno.rst:859 msgid "Owner died" -msgstr "" +msgstr "所有者が終了しました (Owner died)。" -#: ../../library/errno.rst:866 msgid "State not recoverable" -msgstr "" +msgstr "状態を回復できません (State not recoverable)。" diff --git a/library/exceptions.po b/library/exceptions.po index 74027514b..fb9497c49 100644 --- a/library/exceptions.po +++ b/library/exceptions.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/exceptions.rst:4 @@ -88,14 +88,12 @@ msgstr "" msgid "Exception context" msgstr "例外コンテキスト" -#: ../../library/exceptions.rst:46 msgid "" "Three attributes on exception objects provide information about the context " "in which the exception was raised:" msgstr "" -"例外オブジェクトの3つの属性は、例外が送出された常用に関する情報を提供します:" +"例外オブジェクトの3つの属性は、例外が送出された状況に関する情報を提供します:" -#: ../../library/exceptions.rst:53 msgid "" "When raising a new exception while another exception is already being " "handled, the new exception's :attr:`!__context__` attribute is automatically " @@ -103,18 +101,21 @@ msgid "" "`except` or :keyword:`finally` clause, or a :keyword:`with` statement, is " "used." msgstr "" +"別の例外の処理中に新しい例外を送出すると、新しい例外の :attr:`!__context__` " +"属性には、処理中の例外が自動的に設定されます。\n" +"例外の処理は、:keyword:`except` 節、:keyword:`finally` 節、:keyword:`with` 文" +"を使うときに行われることがあります。" -#: ../../library/exceptions.rst:59 msgid "" "This implicit exception context can be supplemented with an explicit cause " "by using :keyword:`!from` with :keyword:`raise`::" msgstr "" +":keyword:`raise` とともに :keyword:`!from` を使うと、この暗黙の例外コンテキス" +"トに明示的な原因を付け加えられます。 ::" -#: ../../library/exceptions.rst:63 msgid "raise new_exc from original_exc" -msgstr "" +msgstr "raise new_exc from original_exc" -#: ../../library/exceptions.rst:65 msgid "" "The expression following :keyword:`from` must be an exception or " "``None``. It will be set as :attr:`!__cause__` on the raised exception. " @@ -125,13 +126,14 @@ msgid "" "while leaving the old exception available in :attr:`!__context__` for " "introspection when debugging." msgstr "" -":keyword:`from ` に続く式は例外か ``None`` でなくてはなりません。\n" -"式は送出される例外の :attr:`!__cause__` として設定されます。\n" -":attr:`!__cause__` を設定することは、 :attr:`!__suppress_context__` 属性を暗" -"黙的に ``True`` に設定することにもなるので、 ``raise new_exc from None`` を使" -"うことで効率的に古い例外を新しいもので置き換えて表示する (例えば、 :exc:" -"`KeyError` を :exc:`AttributeError` に置き換え)、古い例外はデバッグ時の調査で" -"使えるよう :attr:`!__context__` に残すことができます。" +":keyword:`from` に続く式は、例外か ``None`` でなければなりません。\n" +"送出される例外の :attr:`!__cause__` には、その値が設定されます。\n" +":attr:`!__cause__` を設定すると、:attr:`!__suppress_context__` 属性も暗黙的" +"に ``True`` に設定されます。\n" +"そのため、``raise new_exc from None`` を使うと、表示上は古い例外を新しい例外" +"で置き換えられます (例えば :exc:`KeyError` から :exc:`AttributeError` への変" +"換)。\n" +"古い例外はデバッグ時に調べられるよう :attr:`!__context__` に残ります。" #: ../../library/exceptions.rst:74 msgid "" @@ -160,15 +162,17 @@ msgstr "" msgid "Inheriting from built-in exceptions" msgstr "組み込み例外から継承する" -#: ../../library/exceptions.rst:88 msgid "" "User code can create subclasses that inherit from an exception type. It's " "recommended to only subclass one exception type at a time to avoid any " "possible conflicts between how the bases handle the ``args`` attribute, as " "well as due to possible memory layout incompatibilities." msgstr "" +"ユーザコードでは、例外型を継承したサブクラスを作成できます。\n" +"基底クラス間で ``args`` 属性の扱いが衝突したり、メモリレイアウトの互換性に問" +"題が生じたりする可能性があるため、\n" +"一度に継承する例外型は一つだけにすることを推奨します。" -#: ../../library/exceptions.rst:95 msgid "" "Most built-in exceptions are implemented in C for efficiency, see: :source:" "`Objects/exceptions.c`. Some have custom memory layouts which makes it " @@ -177,6 +181,13 @@ msgid "" "between Python versions, leading to new conflicts in the future. Therefore, " "it's recommended to avoid subclassing multiple exception types altogether." msgstr "" +"ほとんどの組み込み例外は効率のために C で実装されています (:source:`Objects/" +"exceptions.c` を参照してください)。\n" +"一部の例外は独自のメモリレイアウトを持つため、そうした例外型の組み合わせでは" +"多重継承できません。\n" +"型のメモリレイアウトは実装の詳細であり、Python のバージョンによって変わり、将" +"来新たな衝突が生じる可能性があります。\n" +"そのため、複数の例外型からの継承は避けることを推奨します。" #: ../../library/exceptions.rst:105 msgid "Base classes" @@ -213,7 +224,6 @@ msgstr "" "`OSError` など) いくつかの引数を必要とし、このタプルの要素に特別な意味を込め" "るものもあります。" -#: ../../library/exceptions.rst:126 msgid "" "This method sets *tb* as the new traceback for the exception and returns the " "exception object. It was more commonly used before the exception chaining " @@ -224,8 +234,17 @@ msgid "" "happened to the traceback of the original ``SomeException`` had we allowed " "it to propagate to the caller. ::" msgstr "" +"このメソッドは、例外の新しいトレースバックに *tb* を設定し、その例外オブジェ" +"クトを返します。\n" +":pep:`3134` の例外連鎖機能が使えるようになる前は、より広く使われていまし" +"た。\n" +"次の例は、トレースバックを保持しながら ``SomeException`` のインスタンスを " +"``OtherException`` のインスタンスに変換する方法を示します。\n" +"``OtherException`` を送出すると、そのトレースバックに現在のフレームが追加され" +"ます。\n" +"元の ``SomeException`` を呼び出し元に伝播させた場合にも、そのトレースバックに" +"同じようにフレームが追加されます。 ::" -#: ../../library/exceptions.rst:135 msgid "" "try:\n" " ...\n" @@ -233,12 +252,19 @@ msgid "" " tb = sys.exception().__traceback__\n" " raise OtherException(...).with_traceback(tb)" msgstr "" +"try:\n" +" ...\n" +"except SomeException:\n" +" tb = sys.exception().__traceback__\n" +" raise OtherException(...).with_traceback(tb)" -#: ../../library/exceptions.rst:143 msgid "" "A writable field that holds the :ref:`traceback object ` " "associated with this exception. See also: :ref:`raise`." msgstr "" +"この例外に関連付けられた :ref:`トレースバックオブジェクト ` を保持する、書き込み可能なフィールドです。\n" +":ref:`raise` も参照してください。" #: ../../library/exceptions.rst:149 msgid "" @@ -315,30 +341,32 @@ msgstr "" "ます (オブジェクトが属性の参照や属性の代入をまったくサポートしていない場合に" "は :exc:`TypeError` が送出されます)。" -#: ../../library/exceptions.rst:207 msgid "" "The optional *name* and *obj* keyword-only arguments set the corresponding " "attributes:" msgstr "" +"オプションのキーワード専用引数 *name* と *obj* は、対応する属性に値を設定しま" +"す:" -#: ../../library/exceptions.rst:212 msgid "The name of the attribute that was attempted to be accessed." -msgstr "" +msgstr "アクセスしようとした属性の名前。" -#: ../../library/exceptions.rst:216 msgid "The object that was accessed for the named attribute." -msgstr "" +msgstr "指定した名前の属性にアクセスしようとした対象のオブジェクト。" #: ../../library/exceptions.rst:218 msgid "Added the :attr:`name` and :attr:`obj` attributes." msgstr ":attr:`name` および :attr:`obj` 属性が追加されました。" -#: ../../library/exceptions.rst:223 msgid "" "Raised when the :func:`input` function hits an end-of-file condition (EOF) " "without reading any data. (Note: the :meth:`io.TextIOBase.read` and :meth:" "`io.IOBase.readline` methods return an empty string when they hit EOF.)" msgstr "" +":func:`input` 関数がデータを何も読み込まずにファイル終端 (EOF) に達した場合に" +"送出されます。\n" +"(注: :meth:`io.TextIOBase.read` メソッドと :meth:`io.IOBase.readline` メソッ" +"ドは、EOF に達すると空文字列を返します。)" #: ../../library/exceptions.rst:230 msgid "Not currently used." @@ -356,7 +384,6 @@ msgstr "" "参照してください。この例外は厳密に言えばエラーではないので、 :exc:" "`Exception` ではなく :exc:`BaseException` を直接継承しています。" -#: ../../library/exceptions.rst:243 msgid "" "Raised when the :keyword:`import` statement has troubles trying to load a " "module. Also raised when the \"from list\" in ``from ... import`` has a " @@ -364,8 +391,8 @@ msgid "" msgstr "" ":keyword:`import` 文でモジュールをロードしようとして問題が発生すると送出され" "ます。\n" -"``from ... import`` の中の\"from list\" (訳注:``...`` の部分)の名前が見つか" -"らないときにも送出されます。" +"``from ... import`` の \"from list\" に、見つからない名前が含まれている場合に" +"も送出されます。" #: ../../library/exceptions.rst:247 msgid "" @@ -397,11 +424,12 @@ msgstr "" "ない場合に送出されます。また、 :data:`sys.modules` に ``None`` が含まれる場合" "にも送出されます。" -#: ../../library/exceptions.rst:271 msgid "" "A subclass of :exc:`ImportError` which is raised when a lazy import fails " "because it (directly or indirectly) tries to import itself." msgstr "" +":exc:`ImportError` のサブクラスで、遅延インポートが自身を直接または間接的にイ" +"ンポートしようとして失敗した場合に送出されます。" #: ../../library/exceptions.rst:278 msgid "" @@ -434,7 +462,6 @@ msgstr "" "を捕捉するコードに誤って捕捉されてインタプリタの終了が阻害されないように、こ" "の例外は :exc:`BaseException` を継承しています。" -#: ../../library/exceptions.rst:302 msgid "" "Catching a :exc:`KeyboardInterrupt` requires special consideration. Because " "it can be raised at unpredictable points, it may, in some circumstances, " @@ -442,6 +469,13 @@ msgid "" "allow :exc:`KeyboardInterrupt` to end the program as quickly as possible or " "avoid raising it entirely. (See :ref:`handlers-and-exceptions`.)" msgstr "" +":exc:`KeyboardInterrupt` の捕捉には特別な配慮が必要です。\n" +"この例外は予測できない箇所で送出される可能性があるため、状況によっては、実行" +"中のプログラムが不整合な状態になることがあります。\n" +"一般には、:exc:`KeyboardInterrupt` によってできるだけ速やかにプログラムを終了" +"させるか、\n" +"この例外の送出自体を避けるのが最善です (:ref:`handlers-and-exceptions` を参照" +"してください)。" #: ../../library/exceptions.rst:312 msgid "" @@ -471,46 +505,48 @@ msgstr "" "修飾の (訳注: ``spam.egg`` ではなく単に ``egg`` のような) 名前のみに適用され" "ます。関連値は見つからなかった名前を含むエラーメッセージです。" -#: ../../library/exceptions.rst:327 msgid "The optional *name* keyword-only argument sets the attribute:" -msgstr "" +msgstr "オプションのキーワード専用引数 *name* は、次の属性に値を設定します:" -#: ../../library/exceptions.rst:331 msgid "The name of the variable that was attempted to be accessed." -msgstr "" +msgstr "アクセスしようとした変数の名前。" #: ../../library/exceptions.rst:333 msgid "Added the :attr:`name` attribute." msgstr ":attr:`name` 属性が追加されました。" -#: ../../library/exceptions.rst:339 msgid "" "This exception is derived from :exc:`RuntimeError`. In user defined base " "classes, abstract methods should raise this exception when they require " "derived classes to override the method, or while the class is being " "developed to indicate that the real implementation still needs to be added." msgstr "" -"この例外は :exc:`RuntimeError` から派生しています。ユーザ定義の基底クラスにお" -"いて、抽象メソッドが派生クラスでオーバライドされることを要求する場合にこの例" -"外を送出しなくてはなりません。またはクラスは実装中であり本来の実装を追加する" -"必要があることを示します。" +"この例外は :exc:`RuntimeError` から派生しています。\n" +"ユーザ定義の基底クラスでは、派生クラスにメソッドのオーバーライドを求める場合" +"に、抽象メソッドからこの例外を送出するべきです。\n" +"また、クラスの開発中に、実際の実装をまだ追加する必要があることを示すためにも" +"送出するべきです。" -#: ../../library/exceptions.rst:346 msgid "" "It should not be used to indicate that an operator or method is not meant to " "be supported at all -- in that case either leave the operator / method " "undefined or, if a subclass, set it to :data:`None`." msgstr "" -"演算子やメソッドがサポートされていないことを示す目的でこの例外を使用するべき" -"ではありません。そのようなケースではオペレータやメソッドを未定義のままとする" -"か、サブクラスの場合は :data:`None` を設定してください。" +"演算子やメソッドをそもそもサポートする意図がないことを示すために、この例外を" +"使うべきではありません。\n" +"その場合は演算子やメソッドを未定義のままにするか、サブクラスであれば :data:" +"`None` を設定してください。" -#: ../../library/exceptions.rst:352 msgid "" ":exc:`!NotImplementedError` and :data:`!NotImplemented` are not " "interchangeable. This exception should only be used as described above; see :" "data:`NotImplemented` for details on correct usage of the built-in constant." msgstr "" +":exc:`!NotImplementedError` と :data:`!NotImplemented` は互いに置き換えられま" +"せん。\n" +"この例外は、上で説明した用途にのみ使ってください。\n" +"組み込み定数の正しい使い方については :data:`NotImplemented` を参照してくださ" +"い。" #: ../../library/exceptions.rst:363 msgid "" @@ -535,7 +571,6 @@ msgstr "" "れた場合、:attr:`~BaseException.args` 属性は最初の2つの要素のみからなるタプル" "を持ちます。" -#: ../../library/exceptions.rst:373 msgid "" "The constructor often actually returns a subclass of :exc:`OSError`, as " "described in `OS exceptions`_ below. The particular subclass depends on the " @@ -543,23 +578,24 @@ msgid "" "exc:`OSError` directly or via an alias, and is not inherited when " "subclassing." msgstr "" -"コンストラクタは実際には、 `OS exceptions`_ で述べられている :exc:`OSError` " -"のサブクラスを返すことがよくあります。特定のサブクラスは最終的な :attr:`." -"errno` 値によります。この挙動は :exc:`OSError` を直接またはエイリアスで構築" -"し、サブクラス化時に継承されなかった場合にのみ発生します。" +"コンストラクタは、下の `OS exceptions`_ で説明する :exc:`OSError` のサブクラ" +"スを実際に返すことがよくあります。\n" +"どのサブクラスを返すかは、最終的な :attr:`.errno` の値によって決まります。\n" +"この挙動は、:exc:`OSError` を直接またはエイリアスを通して構築した場合にのみ発" +"生し、サブクラスには継承されません。" #: ../../library/exceptions.rst:381 msgid "A numeric error code from the C variable :c:data:`errno`." msgstr "C 変数 :c:data:`errno` に由来する数値エラーコードです。" -#: ../../library/exceptions.rst:385 msgid "" "Under Windows, this gives you the native Windows error code. The :attr:`." "errno` attribute is then an approximate translation, in POSIX terms, of that " "native error code." msgstr "" -"Windows において、ネイティブ Windows エラーコードを与えます。そして :attr:" -"`errno` 属性は POSIX でいうネイティブエラーコードへのおよその翻訳です。" +"Windows では、ネイティブの Windows エラーコードを表します。\n" +"この場合、:attr:`.errno` 属性は、そのネイティブエラーコードを POSIX のエラー" +"コードにおおよそ変換した値です。" #: ../../library/exceptions.rst:389 msgid "" @@ -593,24 +629,26 @@ msgstr "" "ファイルシステムパスが2つ関与する関数 (例えば :func:`os.rename`) の場合、:" "attr:`filename2` は関数に渡された2つ目のファイル名です。" -#: ../../library/exceptions.rst:412 msgid "" ":exc:`EnvironmentError`, :exc:`IOError`, :exc:`WindowsError`, :exc:`socket." "error`, :exc:`select.error` and :exc:`!mmap.error` have been merged into :" "exc:`OSError`, and the constructor may return a subclass." msgstr "" +":exc:`EnvironmentError`、:exc:`IOError`、:exc:`WindowsError`、:exc:`socket." +"error`、:exc:`select.error`、:exc:`!mmap.error` は :exc:`OSError` に統合さ" +"れ、\n" +"コンストラクタはサブクラスを返すことがあります。" -#: ../../library/exceptions.rst:418 msgid "" "The :attr:`filename` attribute is now the original file name passed to the " "function, instead of the name encoded to or decoded from the :term:" "`filesystem encoding and error handler`. Also, the *filename2* constructor " "argument and attribute was added." msgstr "" -":attr:`filename` 属性が :term:`filesystem encoding and error handler` のエン" -"コーディングでエンコードやデコードされた名前から、関数に渡された元々のファイ" -"ル名になりました。\n" -"また、*filename2* コンストラクタ引数が追加されました。" +":attr:`filename` 属性は、:term:`filesystem encoding and error handler` に従っ" +"てエンコードまたはデコードされた名前ではなく、関数に渡された元のファイル名に" +"なりました。\n" +"また、コンストラクタ引数と属性の *filename2* が追加されました。" #: ../../library/exceptions.rst:427 msgid "" @@ -627,36 +665,37 @@ msgstr "" "出されることがあります。C の浮動小数点演算の例外処理は標準化されていないの" "で、ほとんどの浮動小数点演算もチェックされません。" -#: ../../library/exceptions.rst:437 msgid "" "This exception is derived from :exc:`RuntimeError`. It is raised when an " "operation is blocked during interpreter shutdown also known as :term:`Python " "finalization `." msgstr "" +"この例外は :exc:`RuntimeError` から派生しています。\n" +":term:`Python の終了処理 ` とも呼ばれるインタープリタの" +"シャットダウン中に、操作が阻止された場合に送出されます。" -#: ../../library/exceptions.rst:441 msgid "" "Examples of operations which can be blocked with a :exc:" "`PythonFinalizationError` during the Python finalization:" msgstr "" +"Python の終了処理中に :exc:`PythonFinalizationError` によって阻止されることが" +"ある操作の例:" -#: ../../library/exceptions.rst:444 msgid "Creating a new Python thread." -msgstr "" +msgstr "新しい Python スレッドの作成。" -#: ../../library/exceptions.rst:445 msgid ":meth:`Joining ` a running daemon thread." -msgstr "" +msgstr "実行中のデーモンスレッドの :meth:`終了待機 `。" -#: ../../library/exceptions.rst:446 msgid ":func:`os.fork`," -msgstr "" +msgstr ":func:`os.fork` の呼び出し。" -#: ../../library/exceptions.rst:447 msgid "" "acquiring a lock such as :class:`threading.Lock`, when it is known that the " "operation would otherwise deadlock." msgstr "" +"そのまま操作を進めるとデッドロックすると分かっている場合の、:class:" +"`threading.Lock` などのロックの獲得。" #: ../../library/exceptions.rst:450 msgid "See also the :func:`sys.is_finalizing` function." @@ -666,9 +705,10 @@ msgstr ":func:`sys.is_finalizing` 関数も参照してください。" msgid "Previously, a plain :exc:`RuntimeError` was raised." msgstr "以前は :exc:`RuntimeError` をそのまま送出していました。" -#: ../../library/exceptions.rst:457 msgid ":meth:`threading.Thread.join` can now raise this exception." msgstr "" +":meth:`threading.Thread.join` がこの例外を送出することがあるようになりまし" +"た。" #: ../../library/exceptions.rst:461 msgid "" @@ -769,24 +809,24 @@ msgstr "" ":pep:`479` が全てのコードでデフォルトで有効化されました: ジェネレータから送出" "された :exc:`StopIteration` は :exc:`RuntimeError` に変換されます。" -#: ../../library/exceptions.rst:524 msgid "" "Must be raised by :meth:`~object.__anext__` method of an :term:`asynchronous " "iterator` object to stop the iteration." msgstr "" -"イテレーションを停止するために、 :term:`asynchronous iterator` オブジェクト" -"の :meth:`~object.__anext__` メソッドによって返される必要があります。" +"イテレーションを停止するために、:term:`asynchronous iterator` オブジェクト" +"の :meth:`~object.__anext__` メソッドから送出しなければなりません。" -#: ../../library/exceptions.rst:531 msgid "" "Raised when the parser encounters a syntax error. This may occur in an :" "keyword:`import` statement, in a call to the built-in functions :func:" "`compile`, :func:`exec`, or :func:`eval`, or when reading the initial script " "or standard input (also interactively)." msgstr "" -"パーザが構文エラーに遭遇した場合に送出されます。この例外は :keyword:`import` " -"文、組み込み関数 :func:`compile`、:func:`exec` や :func:`eval` 、初期化スクリ" -"プトの読み込みや標準入力で (対話的な実行時にも) 起こる可能性があります。" +"パーザが構文エラーに遭遇した場合に送出されます。\n" +"この例外は、:keyword:`import` 文、組み込み関数 :func:`compile`、:func:" +"`exec`、:func:`eval` の呼び出し、\n" +"最初に実行するスクリプトや標準入力の読み込み時 (対話的な実行時も含みます) に" +"起こる可能性があります。" #: ../../library/exceptions.rst:537 msgid "" @@ -864,7 +904,6 @@ msgstr "" "タブとスペースを一貫しない方法でインデントに使っているときに送出されます。こ" "れは :exc:`IndentationError` のサブクラスです。" -#: ../../library/exceptions.rst:590 msgid "" "Raised when the interpreter finds an internal error, but the situation does " "not look so serious to cause it to abandon all hope. The associated value is " @@ -872,8 +911,12 @@ msgid "" "`CPython`, this could be raised by incorrectly using Python's C API, such as " "returning a ``NULL`` value without an exception set." msgstr "" +"インタープリタが内部エラーを検出したものの、実行の継続を断念するほど深刻な状" +"況ではない場合に送出されます。\n" +"関連値は、何が問題だったのかを低水準の用語で示す文字列です。\n" +":term:`CPython` では、例外を設定せずに ``NULL`` 値を返すなど、Python の C " +"API を誤って使うと送出されることがあります。" -#: ../../library/exceptions.rst:596 msgid "" "If you're confident that this exception wasn't your fault, or the fault of a " "package you're using, you should report this to the author or maintainer of " @@ -883,8 +926,14 @@ msgid "" "associated value) and if possible the source of the program that triggered " "the error." msgstr "" +"この例外の原因が自分のコードにも使用中のパッケージにもないと確信できる場合" +"は、\n" +"使用している Python インタープリタの作者やメンテナに報告してください。\n" +"Python インタープリタのバージョン (``sys.version`` の値で、対話型 Python セッ" +"ションの開始時にも表示されます)、\n" +"正確なエラーメッセージ (例外の関連値)、可能であればエラーを引き起こしたプログ" +"ラムのソースを必ず報告してください。" -#: ../../library/exceptions.rst:607 msgid "" "This exception is raised by the :func:`sys.exit` function. It inherits " "from :exc:`BaseException` instead of :exc:`Exception` so that it is not " @@ -897,6 +946,18 @@ msgid "" "is zero; if it has another type (such as a string), the object's value is " "printed and the exit status is one." msgstr "" +"この例外は :func:`sys.exit` 関数によって送出されます。\n" +":exc:`Exception` を捕捉するコードに誤って捕捉されないように、:exc:" +"`Exception` ではなく :exc:`BaseException` を継承しています。\n" +"これにより、例外が適切に伝播し、インタープリタを終了できます。\n" +"この例外が処理されない場合、Python インタープリタは終了し、スタックトレース" +"バックは表示されません。\n" +"コンストラクタには、:func:`sys.exit` と同じオプションの引数を渡せます。\n" +"値が整数の場合は、システムの終了ステータスを指定します (C の :c:func:`!exit` " +"関数に渡されます)。\n" +"``None`` の場合、終了ステータスはゼロです。\n" +"それ以外の型 (文字列など) の場合、オブジェクトの値が表示され、終了ステータス" +"は1になります。" #: ../../library/exceptions.rst:618 msgid "" @@ -921,26 +982,25 @@ msgstr "" "コンストラクタに渡された終了ステータス又はエラーメッセージ。(デフォルトは " "``None``)" -#: ../../library/exceptions.rst:633 msgid "" "Raised when an operation or function is applied to an object of " "inappropriate type. The associated value is a string giving details about " "the type mismatch." msgstr "" -"組み込み演算または関数が適切でない型のオブジェクトに対して適用された際に送出" -"されます。関連値は型の不整合に関して詳細を述べた文字列です。" +"演算や関数を適切でない型のオブジェクトに適用した場合に送出されます。\n" +"関連値は、型の不整合の詳細を示す文字列です。" -#: ../../library/exceptions.rst:636 msgid "" "This exception may be raised by user code to indicate that an attempted " "operation on an object is not supported, and is not meant to be. If an " "object is meant to support a given operation but has not yet provided an " "implementation, :exc:`NotImplementedError` is the proper exception to raise." msgstr "" -"この例外は、そのオブジェクトで実行しようとした操作がサポートされておらず、そ" -"の予定もない場合にユーザーコードから送出されるかもしれません。オブジェクトで" -"その操作をサポートするつもりだが、まだ実装を提供していないのであれば、送出す" -"る適切な例外は :exc:`NotImplementedError` です。" +"そのオブジェクトで実行しようとした操作がサポートされておらず、サポートする意" +"図もないことを示すために、\n" +"ユーザコードからこの例外を送出することもできます。\n" +"操作をサポートする意図はあるものの、まだ実装していない場合には、:exc:" +"`NotImplementedError` を送出するのが適切です。" #: ../../library/exceptions.rst:641 msgid "" @@ -997,11 +1057,12 @@ msgstr "コーデックがエンコードまたはデコードしようとした msgid "The first index of invalid data in :attr:`object`." msgstr ":attr:`object` の最初の無効なデータのインデクスです。" -#: ../../library/exceptions.rst:678 ../../library/exceptions.rst:685 msgid "" "This value should not be negative as it is interpreted as an absolute offset " "but this constraint is not enforced at runtime." msgstr "" +"この値は絶対オフセットとして解釈されるため、負の値にすべきではありませんが、" +"この制約は実行時には強制されません。" #: ../../library/exceptions.rst:683 msgid "The index after the last invalid data in :attr:`object`." @@ -1031,23 +1092,22 @@ msgstr "" "Unicode 関連のエラーが変換中に発生した際に送出されます。 :exc:`UnicodeError` " "のサブクラスです。" -#: ../../library/exceptions.rst:709 msgid "" "Raised when an operation or function receives an argument that has the right " "type but an inappropriate value, and the situation is not described by a " "more precise exception such as :exc:`IndexError`." msgstr "" -"演算子や関数が、正しい型だが適切でない値を持つ引数を受け取ったときや、 :exc:" -"`IndexError` のようなより詳細な例外では記述できない状況で送出されます。" +"演算や関数が、型は正しいものの値が適切でない実引数を受け取り、\n" +"かつ、その状況を :exc:`IndexError` などのより具体的な例外で表せない場合に送出" +"されます。" -#: ../../library/exceptions.rst:716 msgid "" "Raised when the second argument of a division or modulo operation is zero. " "The associated value is a string indicating the type of the operands and the " "operation." msgstr "" -"除算や剰余演算の第二引数が 0 であった場合に送出されます。関連値は文字列で、そ" -"の演算における被演算子と演算子の型を示します。" +"除算や剰余演算の第2引数がゼロの場合に送出されます。\n" +"関連値は、被演算子の型と演算の種類を示す文字列です。" #: ../../library/exceptions.rst:721 msgid "" @@ -1073,17 +1133,16 @@ msgstr "" "以下の例外は :exc:`OSError` のサブクラスで、システムエラーコードに依存して送" "出されます。" -#: ../../library/exceptions.rst:741 msgid "" "Raised when an operation would block on an object (e.g. socket) set for non-" "blocking operation. Corresponds to :c:data:`errno` :py:const:`~errno." "EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` and :py:" "const:`~errno.EINPROGRESS`." msgstr "" -"ある操作が、ノンブロッキング操作に設定されたオブジェクト (例えばソケット) を" -"ブロックしそうになった場合に送出されます。:c:data:`errno` :py:const:`~errno." -"EAGAIN`, :py:const:`~errno.EALREADY`, :py:const:`~errno.EWOULDBLOCK` および :" -"py:const:`~errno.EINPROGRESS` に対応します。" +"ノンブロッキング操作に設定されたオブジェクト (例えばソケット) に対する操作を" +"すぐに完了できず、待機が必要な場合に送出されます。\n" +":c:data:`errno` :py:const:`~errno.EAGAIN`、:py:const:`~errno.EALREADY`、:py:" +"const:`~errno.EWOULDBLOCK`、:py:const:`~errno.EINPROGRESS` に対応します。" #: ../../library/exceptions.rst:746 msgid "" @@ -1093,12 +1152,14 @@ msgstr "" ":exc:`BlockingIOError` は、 :exc:`OSError` の属性に加えて一つの属性を持ちま" "す:" -#: ../../library/exceptions.rst:751 msgid "" "An integer containing the number of **bytes** written to the stream before " "it blocked. This attribute is available when using the buffered I/O classes " "from the :mod:`io` module." msgstr "" +"ブロックするまでにストリームへ書き込まれた **バイト数** を表す整数です。\n" +"この属性は、:mod:`io` モジュールのバッファ付き I/O クラスを使う場合に利用でき" +"ます。" #: ../../library/exceptions.rst:757 msgid "" @@ -1120,17 +1181,18 @@ msgstr "" "サブクラスは :exc:`BrokenPipeError`, :exc:`ConnectionAbortedError`, :exc:" "`ConnectionRefusedError`, :exc:`ConnectionResetError` です。" -#: ../../library/exceptions.rst:769 msgid "" "A subclass of :exc:`ConnectionError`, raised when trying to write on a pipe " "while the other end has been closed, or trying to write on a socket which " "has been shutdown for writing. Corresponds to :c:data:`errno` :py:const:" "`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`." msgstr "" -":exc:`ConnectionError` のサブクラスで、もう一方の端が閉じられたパイプに書き込" -"こもうとするか、書き込みのためにシャットダウンされたソケットに書き込こもうと" -"した場合に発生します。 :c:data:`errno` :py:const:`~errno.EPIPE` と :py:" -"const:`~errno.ESHUTDOWN` に対応します。" +":exc:`ConnectionError` のサブクラスです。\n" +"もう一方の端が閉じられたパイプに書き込もうとした場合や、\n" +"書き込み側がシャットダウンされたソケットに書き込もうとした場合に送出されま" +"す。\n" +":c:data:`errno` :py:const:`~errno.EPIPE` と :py:const:`~errno.ESHUTDOWN` に対" +"応します。" #: ../../library/exceptions.rst:776 msgid "" @@ -1176,13 +1238,12 @@ msgstr "" "要求されたファイルやディレクトリが存在しない場合に送出されます。:c:data:" "`errno` :py:const:`~errno.ENOENT` に対応します。" -#: ../../library/exceptions.rst:804 msgid "" "Raised when a system call is interrupted by an incoming signal. Corresponds " "to :c:data:`errno` :py:const:`~errno.EINTR`." msgstr "" -"システムコールが入力信号によって中断された場合に送出されます。:c:data:" -"`errno` :py:const:`~errno.EINTR` に対応します。" +"システムコールが受信したシグナルによって中断された場合に送出されます。\n" +":c:data:`errno` :py:const:`~errno.EINTR` に対応します。" #: ../../library/exceptions.rst:807 msgid "" @@ -1202,7 +1263,6 @@ msgstr "" "ディレクトリに (:func:`os.remove` などの) ファイル操作が要求された場合に送出" "されます。:c:data:`errno` :py:const:`~errno.EISDIR` に対応します。" -#: ../../library/exceptions.rst:820 msgid "" "Raised when a directory operation (such as :func:`os.listdir`) is requested " "on something which is not a directory. On most POSIX platforms, it may also " @@ -1210,10 +1270,12 @@ msgid "" "as if it were a directory. Corresponds to :c:data:`errno` :py:const:`~errno." "ENOTDIR`." msgstr "" -"ディレクトリへの操作(たとえば :func:`os.listdir`)をディレクトリ以外に対して要" -"求された場合に送出されます。多くのPOSIXプラットフォームではディレクトリではな" -"いファイルをディレクトリとして開いたり移動するときにも発生する場合がありま" -"す。:c:data:`errno` :py:const:`~errno.ENOTDIR` に対応します。" +"ディレクトリに対する操作 (例えば :func:`os.listdir`) がディレクトリ以外の対象" +"に要求された場合に送出されます。\n" +"ほとんどの POSIX プラットフォームでは、ディレクトリでないファイルをディレクト" +"リとして開いたり、\n" +"パスをたどろうとしたりした場合にも送出されることがあります。\n" +":c:data:`errno` :py:const:`~errno.ENOTDIR` に対応します。" #: ../../library/exceptions.rst:828 msgid "" @@ -1278,13 +1340,11 @@ msgstr "警告カテゴリの基底クラスです。" msgid "Base class for warnings generated by user code." msgstr "ユーザコードによって生成される警告の基底クラスです。" -#: ../../library/exceptions.rst:876 msgid "" "Base class for warnings about deprecated features when those warnings are " "intended for other Python developers." msgstr "" -"他の Python 開発者へ向けて警告を発するときの、廃止予定の機能についての警告の" -"基底クラスです。" +"非推奨の機能について、他の Python 開発者に向けて発する警告の基底クラスです。" #: ../../library/exceptions.rst:879 msgid "" @@ -1296,27 +1356,24 @@ msgstr "" "化されています。:ref:`Python Development Mode ` を有効にするとこの警" "告が表示されます。" -#: ../../library/exceptions.rst:883 ../../library/exceptions.rst:899 msgid "The deprecation policy is described in :pep:`387`." -msgstr "" +msgstr "非推奨化の方針は :pep:`387` で説明されています。" -#: ../../library/exceptions.rst:888 msgid "" "Base class for warnings about features which are obsolete and expected to be " "deprecated in the future, but are not deprecated at the moment." msgstr "" -"古くなって将来的に廃止される予定だが、今のところは廃止されていない機能につい" -"ての警告の基底クラスです。" +"古くなっており、将来は非推奨になる見込みですが、現時点では非推奨ではない機能" +"についての警告の基底クラスです。" -#: ../../library/exceptions.rst:892 msgid "" "This class is rarely used as emitting a warning about a possible upcoming " "deprecation is unusual, and :exc:`DeprecationWarning` is preferred for " "already active deprecations." msgstr "" -"近々起こる可能性のある機能廃止について警告を発することはまれなので、このクラ" -"スはめったに使われず、既に決まっている廃止については :exc:" -"`DeprecationWarning` が望ましいです。" +"将来、非推奨になる可能性を事前に警告することは一般的ではないため、このクラス" +"はめったに使われません。\n" +"すでに非推奨となっている機能には :exc:`DeprecationWarning` が推奨されます。" #: ../../library/exceptions.rst:896 ../../library/exceptions.rst:925 #: ../../library/exceptions.rst:952 @@ -1327,19 +1384,18 @@ msgstr "" "デフォルトの警告フィルターで無効化されています。:ref:`Python Development " "Mode ` を有効にするとこの警告が表示されます。" -#: ../../library/exceptions.rst:904 msgid "Base class for warnings about dubious syntax." -msgstr "曖昧な構文に対する警告の基底クラスです。" +msgstr "疑わしい構文についての警告の基底クラスです。" -#: ../../library/exceptions.rst:906 msgid "" "This warning is typically emitted when compiling Python source code, and " "usually won't be reported when running already compiled code." msgstr "" +"この警告は通常、Python ソースコードのコンパイル時に発生し、コンパイル済みの" +"コードの実行時には通常は報告されません。" -#: ../../library/exceptions.rst:912 msgid "Base class for warnings about dubious runtime behavior." -msgstr "あいまいなランタイム挙動に対する警告の基底クラスです。" +msgstr "疑わしい実行時の動作についての警告の基底クラスです。" #: ../../library/exceptions.rst:917 msgid "" @@ -1391,7 +1447,6 @@ msgstr "" "す。また、:keyword:`except*` によって判別でき、例外グループに含" "まれている例外の型に基づいてサブグループにマッチします。" -#: ../../library/exceptions.rst:972 msgid "" "Both of these exception types wrap the exceptions in the sequence ``excs``. " "The ``msg`` parameter must be a string. The difference between the two " @@ -1401,15 +1456,15 @@ msgid "" "is so that ``except Exception`` catches an :exc:`ExceptionGroup` but not :" "exc:`BaseExceptionGroup`." msgstr "" -"この2つの例外型は一連の例外 ``excs`` を包含します。``msg`` 引数は文字列の必要" -"があります。2つのクラスの異なる点は、:exc:`BaseException` は :exc:" -"`BaseExceptionGroup` を拡張して任意の例外を含められますが、:exc:" -"`ExceptionGroup` は :exc:`Exception` を拡張して :exc:`Exception` のサブクラス" -"のみを含められます。この設計により ``except Exception`` は :exc:" -"`ExceptionGroup` をキャッチしますが、:exc:`BaseExceptionGroup` はキャッチしま" -"せん。" +"どちらの例外型も、シーケンス ``excs`` に含まれる例外をまとめて保持します。\n" +"``msg`` パラメータは文字列でなければなりません。\n" +"2つのクラスの違いは、:exc:`BaseExceptionGroup` が :exc:`BaseException` を拡張" +"して任意の例外を保持できるのに対し、\n" +":exc:`ExceptionGroup` は :exc:`Exception` を拡張し、:exc:`Exception` のサブク" +"ラスの例外のみを保持できることです。\n" +"この設計により、``except Exception`` は :exc:`ExceptionGroup` を捕捉します" +"が、:exc:`BaseExceptionGroup` は捕捉しません。" -#: ../../library/exceptions.rst:980 msgid "" "The :exc:`BaseExceptionGroup` constructor returns an :exc:`ExceptionGroup` " "rather than a :exc:`BaseExceptionGroup` if all contained exceptions are :exc:" @@ -1417,24 +1472,29 @@ msgid "" "The :exc:`ExceptionGroup` constructor, on the other hand, raises a :exc:" "`TypeError` if any contained exception is not an :exc:`Exception` subclass." msgstr "" -":exc:`BaseExceptionGroup` のコンストラクターは含まれる例外がすべて :exc:" -"`Exception` の場合は :exc:`BaseExceptionGroup` ではなく :exc:" -"`ExceptionGroup` を返すように自動的に選択されます。一方 :exc:" -"`ExceptionGroup` コンストラクタは、:exc:`Exception` サブクラス以外の例外を含" -"む場合は :exc:`TypeError` を送出します。" +":exc:`BaseExceptionGroup` のコンストラクタは、保持する例外がすべて :exc:" +"`Exception` のインスタンスである場合、\n" +":exc:`BaseExceptionGroup` ではなく :exc:`ExceptionGroup` を返すので、クラスの" +"選択を自動化するために利用できます。\n" +"一方、:exc:`ExceptionGroup` のコンストラクタは、:exc:`Exception` のサブクラス" +"のインスタンスでない例外が一つでも含まれていると :exc:`TypeError` を送出しま" +"す。" -#: ../../library/exceptions.rst:987 msgid "" "Exception groups are :ref:`generic ` over the type of their " "contained exceptions." msgstr "" +"例外グループは、保持する例外の型をパラメータとする :ref:`ジェネリック型 " +"` です。" -#: ../../library/exceptions.rst:992 msgid "" "The ``excs`` parameter may be any sequence, but lists and tuples are " "specifically processed more efficiently here. For optimal performance, pass " "a tuple as ``excs``." msgstr "" +"``excs`` パラメータには任意のシーケンスを指定できますが、リストとタプルは特に" +"効率よく処理されます。\n" +"最適なパフォーマンスを得るには、``excs`` にタプルを渡してください。" #: ../../library/exceptions.rst:998 msgid "The ``msg`` argument to the constructor. This is a read-only attribute." @@ -1448,15 +1508,14 @@ msgstr "" "コンストラクタに渡された一連の ``excs`` に含まれる例外のタプルです。この属性" "は読み込み専用です。" -#: ../../library/exceptions.rst:1007 msgid "" "Returns an exception group that contains only the exceptions from the " "current group that match *condition*, or ``None`` if the result is empty." msgstr "" -"現在のグループで *条件* にマッチする礼儀のみを含む例外グループを返します。結" -"果が空の場合は ``None`` を返します。" +"現在のグループの例外のうち、*condition* にマッチするものだけを含む例外グルー" +"プを返します。\n" +"結果が空の場合は ``None`` を返します。" -#: ../../library/exceptions.rst:1010 msgid "" "The condition can be an exception type or tuple of exception types, in which " "case each exception is checked for a match using the same check that is used " @@ -1464,8 +1523,11 @@ msgid "" "type object) that accepts an exception as its single argument and returns " "true for the exceptions that should be in the subgroup." msgstr "" +"条件には例外型または例外型のタプルを指定でき、\n" +"その場合は ``except`` 節と同じ判定方法で各例外がマッチするかを調べます。\n" +"また、例外を唯一の引数として受け取り、サブグループに含めるべき例外に対して真" +"を返す呼び出し可能オブジェクト (型オブジェクトを除く) も指定できます。" -#: ../../library/exceptions.rst:1016 msgid "" "The nesting structure of the current exception is preserved in the result, " "as are the values of its :attr:`message`, :attr:`~BaseException." @@ -1473,17 +1535,25 @@ msgid "" "__context__` and :attr:`~BaseException.__notes__` fields. Empty nested " "groups are omitted from the result." msgstr "" +"結果には、現在の例外の入れ子構造と、:attr:`message`、:attr:`~BaseException." +"__traceback__`、:attr:`~BaseException.__cause__`、:attr:`~BaseException." +"__context__`、:attr:`~BaseException.__notes__` の各フィールドの値が保持されま" +"す。\n" +"入れ子になった空のグループは結果から除かれます。" -#: ../../library/exceptions.rst:1023 msgid "" "The condition is checked for all exceptions in the nested exception group, " "including the top-level and any nested exception groups. If the condition is " "true for such an exception group, it is included in the result in full." msgstr "" +"条件は、最上位の例外グループと入れ子になったすべての例外グループも含め、\n" +"入れ子の例外グループ内のすべての例外に対して調べられます。\n" +"例外グループに対して条件が真となる場合、そのグループ全体が結果に含まれます。" -#: ../../library/exceptions.rst:1027 msgid "``condition`` can be any callable which is not a type object." msgstr "" +"``condition`` に、型オブジェクト以外の任意の呼び出し可能オブジェクトを指定で" +"きるようになりました。" #: ../../library/exceptions.rst:1032 msgid "" @@ -1502,13 +1572,17 @@ msgstr "" "同じ :attr:`message` の例外グループを返しますが、``excs`` の例外を含んでいま" "す。" -#: ../../library/exceptions.rst:1041 msgid "" "This method is used by :meth:`subgroup` and :meth:`split`, which are used in " "various contexts to break up an exception group. A subclass needs to " "override it in order to make :meth:`subgroup` and :meth:`split` return " "instances of the subclass rather than :exc:`ExceptionGroup`." msgstr "" +"このメソッドは、さまざまな状況で例外グループを分割するために使われる :meth:" +"`subgroup` と :meth:`split` から呼び出されます。\n" +"サブクラスで :meth:`subgroup` と :meth:`split` が :exc:`ExceptionGroup` では" +"なくそのサブクラスのインスタンスを返すようにするには、\n" +"このメソッドをオーバーライドする必要があります。" #: ../../library/exceptions.rst:1047 msgid "" @@ -1524,7 +1598,6 @@ msgstr "" "返す例外グループにコピーするため、:meth:`derive` ではこれらのフィールドを更新" "する必要がありません。" -#: ../../library/exceptions.rst:1054 msgid "" ">>> class MyGroup(ExceptionGroup):\n" "... def derive(self, excs):\n" @@ -1552,8 +1625,32 @@ msgid "" ">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" "True" msgstr "" +">>> class MyGroup(ExceptionGroup):\n" +"... def derive(self, excs):\n" +"... return MyGroup(self.message, excs)\n" +"...\n" +">>> e = MyGroup(\"eg\", [ValueError(1), TypeError(2)])\n" +">>> e.add_note(\"a note\")\n" +">>> e.__context__ = Exception(\"context\")\n" +">>> e.__cause__ = Exception(\"cause\")\n" +">>> try:\n" +"... raise e\n" +"... except Exception as e:\n" +"... exc = e\n" +"...\n" +">>> match, rest = exc.split(ValueError)\n" +">>> exc, exc.__context__, exc.__cause__, exc.__notes__\n" +"(MyGroup('eg', [ValueError(1), TypeError(2)]), Exception('context'), " +"Exception('cause'), ['a note'])\n" +">>> match, match.__context__, match.__cause__, match.__notes__\n" +"(MyGroup('eg', [ValueError(1)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> rest, rest.__context__, rest.__cause__, rest.__notes__\n" +"(MyGroup('eg', [TypeError(2)]), Exception('context'), Exception('cause'), " +"['a note'])\n" +">>> exc.__traceback__ is match.__traceback__ is rest.__traceback__\n" +"True" -#: ../../library/exceptions.rst:1080 msgid "" "Note that :exc:`BaseExceptionGroup` defines :meth:`~object.__new__`, so " "subclasses that need a different constructor signature need to override that " @@ -1561,8 +1658,12 @@ msgid "" "exception group subclass which accepts an exit_code and constructs the " "group's message from it. ::" msgstr "" +":exc:`BaseExceptionGroup` は :meth:`~object.__new__` を定義しているため、\n" +"異なるコンストラクタシグネチャが必要なサブクラスでは、:meth:`~object." +"__init__` ではなく ``__new__()`` をオーバーライドする必要があります。\n" +"例えば、次のコードでは ``exit_code`` を受け取り、そこからグループのメッセージ" +"を作成する例外グループのサブクラスを定義しています。 ::" -#: ../../library/exceptions.rst:1086 msgid "" "class Errors(ExceptionGroup):\n" " def __new__(cls, errors, exit_code):\n" @@ -1573,13 +1674,24 @@ msgid "" " def derive(self, excs):\n" " return Errors(excs, self.exit_code)" msgstr "" +"class Errors(ExceptionGroup):\n" +" def __new__(cls, errors, exit_code):\n" +" self = super().__new__(Errors, f\"exit code: {exit_code}\", errors)\n" +" self.exit_code = exit_code\n" +" return self\n" +"\n" +" def derive(self, excs):\n" +" return Errors(excs, self.exit_code)" -#: ../../library/exceptions.rst:1095 msgid "" "Like :exc:`ExceptionGroup`, any subclass of :exc:`BaseExceptionGroup` which " "is also a subclass of :exc:`Exception` can only wrap instances of :exc:" "`Exception`." msgstr "" +":exc:`ExceptionGroup` と同様に、:exc:`BaseExceptionGroup` のサブクラスであ" +"り、\n" +"かつ :exc:`Exception` のサブクラスでもあるクラスは、:exc:`Exception` のインス" +"タンスのみを保持できます。" #: ../../library/exceptions.rst:1103 msgid "Exception hierarchy" diff --git a/library/faulthandler.po b/library/faulthandler.po index 1d7cec121..716b19874 100644 --- a/library/faulthandler.po +++ b/library/faulthandler.po @@ -17,17 +17,16 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/faulthandler.rst:2 msgid ":mod:`!faulthandler` --- Dump the Python traceback" msgstr ":mod:`!faulthandler` --- Python トレースバックをダンプする" -#: ../../library/faulthandler.rst:11 msgid "" "This module contains functions to dump Python tracebacks explicitly, on a " "fault, after a timeout, or on a user signal. Call :func:`faulthandler." @@ -37,14 +36,16 @@ msgid "" "setting the :envvar:`PYTHONFAULTHANDLER` environment variable or by using " "the :option:`-X` ``faulthandler`` command line option." msgstr "" -"このモジュールは、例外発生時、タイムアウト時、ユーザシグナルの発生時などのタ" -"イミングでpython tracebackを明示的にダンプするための関数を含んでいます。これ" -"らのシグナル、:const:`~signal.SIGSEGV`、:const:`~signal.SIGFPE`、:const:" -"`~signal.SIGABRT`、:const:`~signal.SIGBUS`、:const:`~signal.SIGILL` に対する" -"フォールトハンドラをインストールするには :func:`faulthandler.enable` を実行し" -"てください。python起動時に有効にするには環境変数 :envvar:" -"`PYTHONFAULTHANDLER` を設定するか、コマンドライン引数に :option:`-X` " -"``faulthandler`` を指定してください。" +"このモジュールには、Python のトレースバックを明示的にダンプしたり、フォールト" +"の発生時、タイムアウト後、ユーザーシグナルの受信時にダンプしたりする関数があ" +"ります。\n" +":const:`~signal.SIGSEGV`、:const:`~signal.SIGFPE`、:const:`~signal." +"SIGABRT`、:const:`~signal.SIGBUS`、:const:`~signal.SIGILL` シグナルに対する" +"フォールトハンドラを登録するには、:func:`faulthandler.enable` を呼び出してく" +"ださい。\n" +"環境変数 :envvar:`PYTHONFAULTHANDLER` を設定するか、コマンドラインオプショ" +"ン :option:`-X` ``faulthandler`` を指定すると、起動時に有効にすることもできま" +"す。" #: ../../library/faulthandler.rst:19 msgid "" @@ -83,22 +84,21 @@ msgstr "" msgid "Each string is limited to 500 characters." msgstr "すべての文字列は500文字以内に制限されています。" -#: ../../library/faulthandler.rst:32 msgid "" "Only the filename, the function name and the line number are displayed. (no " "source code)" msgstr "" -"ファイル名、関数名、行数のみ表示します。(ソースコードの表示はありません)" +"ファイル名、関数名、行番号だけを表示します (ソースコードは表示しません)。" -#: ../../library/faulthandler.rst:34 msgid "" "It is limited to 100 frames per thread, and 100 threads (configurable via " "*max_threads*)." msgstr "" +"1 スレッドあたり 100 フレーム、合計 100 スレッドに制限されています (スレッド" +"数は *max_threads* で設定できます)。" -#: ../../library/faulthandler.rst:36 msgid "The order is reversed: the most recent call is shown first." -msgstr "順番は保持されます: 最新の呼び出しが最初に表示されます。" +msgstr "順序は逆で、最も新しい呼び出しから表示します。" #: ../../library/faulthandler.rst:38 msgid "" @@ -119,101 +119,102 @@ msgstr "" "モジュールはC言語で実装されているので、アプリのクラッシュ時でもPythonがデッド" "ロックした場合でもダンプができます。" -#: ../../library/faulthandler.rst:45 msgid "" "The :ref:`Python Development Mode ` calls :func:`faulthandler." "enable` at Python startup." msgstr "" +":ref:`Python 開発モード ` は Python の起動時に :func:`faulthandler." +"enable` を呼び出します。" #: ../../library/faulthandler.rst:50 msgid "Module :mod:`pdb`" msgstr ":mod:`pdb` モジュール" -#: ../../library/faulthandler.rst:51 msgid "Interactive source code debugger for Python programs." -msgstr "" +msgstr "Python プログラム用の対話的なソースコードデバッガです。" #: ../../library/faulthandler.rst:53 msgid "Module :mod:`traceback`" msgstr ":mod:`traceback` モジュール" -#: ../../library/faulthandler.rst:54 msgid "" "Standard interface to extract, format and print stack traces of Python " "programs." msgstr "" +"Python プログラムのスタックトレースを抽出・整形・表示する標準インターフェー" +"ス。" #: ../../library/faulthandler.rst:57 msgid "Dumping the traceback" msgstr "tracebackのダンプ" -#: ../../library/faulthandler.rst:61 msgid "" "Dump the tracebacks of all threads into *file*. If *all_threads* is " "``False``, dump only the current thread. *max_threads* caps the number of " "threads dumped." msgstr "" +"すべてのスレッドのトレースバックを *file* にダンプします。\n" +"*all_threads* が ``False`` の場合は現在のスレッドだけをダンプします。\n" +"*max_threads* はダンプするスレッド数の上限です。" -#: ../../library/faulthandler.rst:65 msgid "" ":func:`traceback.print_tb`, which can be used to print a traceback object." -msgstr "" +msgstr "トレースバックオブジェクトの表示に使える :func:`traceback.print_tb`。" -#: ../../library/faulthandler.rst:67 ../../library/faulthandler.rst:126 -#: ../../library/faulthandler.rst:175 ../../library/faulthandler.rst:204 msgid "Added support for passing file descriptor to this function." -msgstr "" +msgstr "この関数にファイル記述子を渡せるようになりました。" -#: ../../library/faulthandler.rst:70 ../../library/faulthandler.rst:143 -#: ../../library/faulthandler.rst:181 ../../library/faulthandler.rst:207 msgid "Added the *max_threads* keyword argument." -msgstr "" +msgstr "キーワード引数 *max_threads* が追加されました。" -#: ../../library/faulthandler.rst:75 msgid "Dumping the C stack" -msgstr "" +msgstr "C スタックのダンプ" -#: ../../library/faulthandler.rst:81 msgid "Dump the C stack trace of the current thread into *file*." -msgstr "" +msgstr "現在のスレッドの C スタックトレースを *file* にダンプします。" -#: ../../library/faulthandler.rst:83 msgid "" "If the Python build does not support it or the operating system does not " "provide a stack trace, then this prints an error in place of a dumped C " "stack." msgstr "" +"Python のビルドが対応していない場合や、OS がスタックトレースを提供しない場合" +"は、C スタックのダンプの代わりにエラーを表示します。" -#: ../../library/faulthandler.rst:90 msgid "C Stack Compatibility" -msgstr "" +msgstr "C スタックの互換性" -#: ../../library/faulthandler.rst:92 msgid "" "If the system does not support the C-level :manpage:`backtrace(3)` or :" "manpage:`dladdr1(3)`, then C stack dumps will not work. An error will be " "printed instead of the stack." msgstr "" +"システムが C レベルの :manpage:`backtrace(3)` または :manpage:`dladdr1(3)` を" +"サポートしない場合、C スタックのダンプは機能しません。\n" +"スタックの代わりにエラーを表示します。" -#: ../../library/faulthandler.rst:96 msgid "" "Additionally, some compilers do not support :term:`CPython's ` " "implementation of C stack dumps. As a result, a different error may be " "printed instead of the stack, even if the operating system supports dumping " "stacks." msgstr "" +"また、一部のコンパイラは :term:`CPython` の C スタックのダンプ実装をサポート" +"しません。\n" +"そのため OS がスタックのダンプをサポートしていても、スタックの代わりに別のエ" +"ラーが表示される場合があります。" -#: ../../library/faulthandler.rst:102 msgid "" "Dumping C stacks can be arbitrarily slow, depending on the DWARF level of " "the binaries in the call stack." msgstr "" +"C スタックのダンプは、呼び出しスタック内のバイナリの DWARF レベルによっては非" +"常に時間がかかる場合があります。" #: ../../library/faulthandler.rst:106 msgid "Fault handler state" msgstr "フォールトハンドラの状態" -#: ../../library/faulthandler.rst:110 msgid "" "Enable the fault handler: install handlers for the :const:`~signal." "SIGSEGV`, :const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal." @@ -221,44 +222,56 @@ msgid "" "*all_threads* is ``True``, produce tracebacks for every running thread. " "Otherwise, dump only the current thread." msgstr "" +"フォールトハンドラを有効にします。\n" +"Python のトレースバックをダンプするために、:const:`~signal.SIGSEGV`、:const:" +"`~signal.SIGFPE`、:const:`~signal.SIGABRT`、:const:`~signal.SIGBUS`、:const:" +"`~signal.SIGILL` シグナルのハンドラを登録します。\n" +"*all_threads* が ``True`` の場合は、実行中のすべてのスレッドのトレースバック" +"を出力します。\n" +"それ以外の場合は現在のスレッドだけをダンプします。" -#: ../../library/faulthandler.rst:117 msgid "" "The *file* must be kept open until the fault handler is disabled: see :ref:" "`issue with file descriptors `." msgstr "" +"フォールトハンドラを無効にするまで *file* を開いたままにしておく必要がありま" +"す。\n" +":ref:`ファイル記述子の問題 ` を参照してください。" -#: ../../library/faulthandler.rst:120 msgid "" "If *c_stack* is ``True``, then the C stack trace is printed after the Python " "traceback, unless the system does not support it. See :func:`dump_c_stack` " "for more information on compatibility." msgstr "" +"*c_stack* が ``True`` の場合、システムがサポートしていれば Python のトレース" +"バックの後に C スタックトレースを表示します。\n" +"互換性の詳細は :func:`dump_c_stack` を参照してください。" -#: ../../library/faulthandler.rst:124 msgid "" "*max_threads* caps the number of threads dumped when a fatal signal fires." msgstr "" +"*max_threads* は、致命的なシグナルの発生時にダンプするスレッド数の上限です。" -#: ../../library/faulthandler.rst:129 msgid "On Windows, a handler for Windows exception is also installed." -msgstr "" +msgstr "Windows では、Windows 例外のハンドラも登録するようになりました。" -#: ../../library/faulthandler.rst:132 msgid "" "The dump now mentions if a garbage collector collection is running if " "*all_threads* is true." msgstr "" +"*all_threads* が真で、ガベージコレクタが回収処理を実行中の場合、そのこともダ" +"ンプに表示するようになりました。" -#: ../../library/faulthandler.rst:136 msgid "" "Only the current thread is dumped if the :term:`GIL` is disabled to prevent " "the risk of data races." msgstr "" +"データ競合の危険を防ぐため、:term:`GIL` が無効の場合は現在のスレッドだけをダ" +"ンプするようになりました。" -#: ../../library/faulthandler.rst:140 msgid "The dump now displays the C stack trace if *c_stack* is true." msgstr "" +"*c_stack* が真の場合、ダンプに C スタックトレースも表示するようになりました。" #: ../../library/faulthandler.rst:148 msgid "" @@ -276,7 +289,6 @@ msgstr "フォールトハンドラが有効かどうかチェックします。 msgid "Dumping the tracebacks after a timeout" msgstr "タイムアウト後にtracebackをダンプする" -#: ../../library/faulthandler.rst:161 msgid "" "Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or " "every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, " @@ -286,21 +298,31 @@ msgid "" "new call replaces previous parameters and resets the timeout. The timer has " "a sub-second resolution. *max_threads* caps the number of threads dumped." msgstr "" +"*timeout* 秒後に、または *repeat* が ``True`` の場合は *timeout* 秒ごとに、す" +"べてのスレッドのトレースバックをダンプします。\n" +"*exit* が ``True`` の場合、トレースバックをダンプした後に終了ステータス 1 " +"で :c:func:`!_exit` を呼び出します。\n" +"(:c:func:`!_exit` はプロセスを直ちに終了するため、ファイルバッファのフラッ" +"シュなどの後処理は行いません。)\n" +"この関数を 2 回呼び出すと、新しい呼び出しで以前のパラメータを置き換え、タイム" +"アウトをリセットします。\n" +"タイマーの分解能は 1 秒未満です。\n" +"*max_threads* はダンプするスレッド数の上限です。" -#: ../../library/faulthandler.rst:169 msgid "" "The *file* must be kept open until the traceback is dumped or :func:" "`cancel_dump_traceback_later` is called: see :ref:`issue with file " "descriptors `." msgstr "" +"トレースバックがダンプされるか :func:`cancel_dump_traceback_later` が呼び出さ" +"れるまで、*file* を開いたままにしておく必要があります。\n" +":ref:`ファイル記述子の問題 ` を参照してください。" -#: ../../library/faulthandler.rst:173 msgid "This function is implemented using a watchdog thread." -msgstr "" +msgstr "この関数は監視用のスレッドを使って実装されています。" -#: ../../library/faulthandler.rst:178 msgid "This function is now always available." -msgstr "" +msgstr "この関数は常に利用可能になりました。" #: ../../library/faulthandler.rst:186 msgid "Cancel the last call to :func:`dump_traceback_later`." @@ -310,19 +332,26 @@ msgstr ":func:`dump_traceback_later` の最新の呼び出しをキャンセル msgid "Dumping the traceback on a user signal" msgstr "ユーザシグナルに対してtracebackをダンプする" -#: ../../library/faulthandler.rst:194 msgid "" "Register a user signal: install a handler for the *signum* signal to dump " "the traceback of all threads, or of the current thread if *all_threads* is " "``False``, into *file*. Call the previous handler if chain is ``True``. " "*max_threads* caps the number of threads dumped." msgstr "" +"ユーザーシグナルを登録します。\n" +"*signum* シグナルのハンドラを登録し、すべてのスレッド、または *all_threads* " +"が ``False`` の場合は現在のスレッドのトレースバックを *file* にダンプしま" +"す。\n" +"``chain`` が ``True`` の場合は以前のハンドラも呼び出します。\n" +"*max_threads* はダンプするスレッド数の上限です。" -#: ../../library/faulthandler.rst:199 msgid "" "The *file* must be kept open until the signal is unregistered by :func:" "`unregister`: see :ref:`issue with file descriptors `." msgstr "" +":func:`unregister` でシグナルの登録を解除するまで、*file* を開いたままにして" +"おく必要があります。\n" +":ref:`ファイル記述子の問題 ` を参照してください。" #: ../../library/faulthandler.rst:202 ../../library/faulthandler.rst:216 msgid "Not available on Windows." @@ -368,7 +397,6 @@ msgstr "" "フォールトハンドラを有効化・無効化したときの Linuxでのセグメンテーション" "フォールトの例:" -#: ../../library/faulthandler.rst:237 msgid "" "$ python -c \"import ctypes; ctypes.string_at(0)\"\n" "Segmentation fault\n" @@ -429,3 +457,61 @@ msgid "" " \n" "Segmentation fault" msgstr "" +"$ python -c \"import ctypes; ctypes.string_at(0)\"\n" +"Segmentation fault\n" +"\n" +"$ python -q -X faulthandler\n" +">>> import ctypes\n" +">>> ctypes.string_at(0)\n" +"Fatal Python error: Segmentation fault\n" +"\n" +"Current thread 0x00007fb899f39700 (most recent call first):\n" +" File \"/opt/python/Lib/ctypes/__init__.py\", line 486 in string_at\n" +" File \"\", line 1 in \n" +"\n" +"Current thread's C stack trace (most recent call first):\n" +" Binary file \"/opt/python/python\", at _Py_DumpStack+0x42 " +"[0x5b27f7d7147e]\n" +" Binary file \"/opt/python/python\", at +0x32dcbd [0x5b27f7d85cbd]\n" +" Binary file \"/opt/python/python\", at +0x32df8a [0x5b27f7d85f8a]\n" +" Binary file \"/usr/lib/libc.so.6\", at +0x3def0 [0x77b73226bef0]\n" +" Binary file \"/usr/lib/libc.so.6\", at +0x17ef9c [0x77b7323acf9c]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0xcdf6 [0x77b7315dddf6]\n" +" Binary file \"/usr/lib/libffi.so.8\", at +0x7976 [0x77b73158f976]\n" +" Binary file \"/usr/lib/libffi.so.8\", at +0x413c [0x77b73158c13c]\n" +" Binary file \"/usr/lib/libffi.so.8\", at ffi_call+0x12e [0x77b73158ef0e]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0x15a33 [0x77b7315e6a33]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0x164fa [0x77b7315e74fa]\n" +" Binary file \"/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-" +"x86_64-linux-gnu.so\", at +0xc624 [0x77b7315dd624]\n" +" Binary file \"/opt/python/python\", at _PyObject_MakeTpCall+0xce " +"[0x5b27f7b73883]\n" +" Binary file \"/opt/python/python\", at +0x11bab6 [0x5b27f7b73ab6]\n" +" Binary file \"/opt/python/python\", at PyObject_Vectorcall+0x23 " +"[0x5b27f7b73b04]\n" +" Binary file \"/opt/python/python\", at _PyEval_EvalFrameDefault+0x490c " +"[0x5b27f7cbb302]\n" +" Binary file \"/opt/python/python\", at +0x2818e6 [0x5b27f7cd98e6]\n" +" Binary file \"/opt/python/python\", at +0x281aab [0x5b27f7cd9aab]\n" +" Binary file \"/opt/python/python\", at PyEval_EvalCode+0xc5 " +"[0x5b27f7cd9ba3]\n" +" Binary file \"/opt/python/python\", at +0x255957 [0x5b27f7cad957]\n" +" Binary file \"/opt/python/python\", at +0x255ab4 [0x5b27f7cadab4]\n" +" Binary file \"/opt/python/python\", at _PyEval_EvalFrameDefault+0x6c3e " +"[0x5b27f7cbd634]\n" +" Binary file \"/opt/python/python\", at +0x2818e6 [0x5b27f7cd98e6]\n" +" Binary file \"/opt/python/python\", at +0x281aab [0x5b27f7cd9aab]\n" +" Binary file \"/opt/python/python\", at +0x11b6e1 [0x5b27f7b736e1]\n" +" Binary file \"/opt/python/python\", at +0x11d348 [0x5b27f7b75348]\n" +" Binary file \"/opt/python/python\", at +0x11d626 [0x5b27f7b75626]\n" +" Binary file \"/opt/python/python\", at PyObject_Call+0x20 " +"[0x5b27f7b7565e]\n" +" Binary file \"/opt/python/python\", at +0x32a67a [0x5b27f7d8267a]\n" +" Binary file \"/opt/python/python\", at +0x32a7f8 [0x5b27f7d827f8]\n" +" Binary file \"/opt/python/python\", at +0x32ac1b [0x5b27f7d82c1b]\n" +" Binary file \"/opt/python/python\", at Py_RunMain+0x31 [0x5b27f7d82ebe]\n" +" \n" +"Segmentation fault" diff --git a/library/fcntl.po b/library/fcntl.po index 5401bf476..e12aa67ce 100644 --- a/library/fcntl.po +++ b/library/fcntl.po @@ -16,27 +16,30 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/fcntl.rst:2 msgid ":mod:`!fcntl` --- The ``fcntl`` and ``ioctl`` system calls" msgstr ":mod:`!fcntl` --- ``fcntl`` および ``ioctl`` システムコール" -#: ../../library/fcntl.rst:13 msgid "" "This module performs file and I/O control on file descriptors. It is an " "interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. See the :" "manpage:`fcntl(2)` and :manpage:`ioctl(2)` Unix manual pages for full " "details." msgstr "" +"このモジュールはファイル記述子に対するファイル制御と I/O 制御を行います。\n" +"Unix の :c:func:`fcntl` と :c:func:`ioctl` ルーチンへのインターフェイスで" +"す。\n" +"詳細は Unix のマニュアルページ :manpage:`fcntl(2)` と :manpage:`ioctl(2)` を" +"参照してください。" -#: ../../library/fcntl.rst:18 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../library/fcntl.rst:20 msgid "" @@ -60,14 +63,15 @@ msgstr "" "以前は :exc:`IOError` を送出していたこのモジュールの操作が、 :exc:`OSError` " "を送出するようになりました。" -#: ../../library/fcntl.rst:30 msgid "" "The :mod:`!fcntl` module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and " "``F_SEAL_*`` constants for sealing of :func:`os.memfd_create` file " "descriptors." msgstr "" +":mod:`!fcntl` モジュールに、:func:`os.memfd_create` のファイル記述子にシール" +"を設定するための定数 ``F_ADD_SEALS``、``F_GET_SEALS``、``F_SEAL_*`` が追加さ" +"れました。" -#: ../../library/fcntl.rst:35 msgid "" "On macOS, the :mod:`!fcntl` module exposes the ``F_GETPATH`` constant, which " "obtains the path of a file from a file descriptor. On Linux(>=3.15), the :" @@ -75,6 +79,11 @@ msgid "" "``F_OFD_SETLKW`` constants, which are used when working with open file " "description locks." msgstr "" +"macOS では、:mod:`!fcntl` モジュールにファイル記述子からファイルのパスを取得" +"する定数 ``F_GETPATH`` が追加されました。\n" +"Linux 3.15 以降では、:mod:`!fcntl` モジュールにオープンファイル記述のロックを" +"扱う定数 ``F_OFD_GETLK``、``F_OFD_SETLK``、``F_OFD_SETLKW`` が追加されまし" +"た。" #: ../../library/fcntl.rst:42 msgid "" @@ -83,22 +92,27 @@ msgid "" "size respectively." msgstr "" -#: ../../library/fcntl.rst:47 msgid "" "On FreeBSD, the :mod:`!fcntl` module exposes the ``F_DUP2FD`` and " "``F_DUP2FD_CLOEXEC`` constants, which allow to duplicate a file descriptor, " "the latter setting ``FD_CLOEXEC`` flag in addition." msgstr "" +"FreeBSD では、:mod:`!fcntl` モジュールにファイル記述子を複製する定数 " +"``F_DUP2FD`` と ``F_DUP2FD_CLOEXEC`` が追加されました。\n" +"後者は ``FD_CLOEXEC`` フラグも設定します。" -#: ../../library/fcntl.rst:52 msgid "" "On Linux >= 4.5, the :mod:`!fcntl` module exposes the ``FICLONE`` and " "``FICLONERANGE`` constants, which allow to share some data of one file with " "another file by reflinking on some filesystems (e.g., btrfs, OCFS2, and " "XFS). This behavior is commonly referred to as \"copy-on-write\"." msgstr "" +"Linux 4.5 以降では、:mod:`!fcntl` モジュールに定数 ``FICLONE`` と " +"``FICLONERANGE`` が追加されました。\n" +"一部のファイルシステム (btrfs、OCFS2、XFS など) で reflink を使い、あるファイ" +"ルのデータの一部を別のファイルと共有できます。\n" +"この動作は一般に「コピーオンライト」と呼ばれます。" -#: ../../library/fcntl.rst:58 msgid "" "On Linux >= 2.6.32, the :mod:`!fcntl` module exposes the ``F_GETOWN_EX``, " "``F_SETOWN_EX``, ``F_OWNER_TID``, ``F_OWNER_PID``, ``F_OWNER_PGRP`` " @@ -118,6 +132,27 @@ msgid "" "macOS and NetBSD, the :mod:`!fcntl` module exposes the ``F_GETNOSIGPIPE`` " "and ``F_SETNOSIGPIPE`` constant." msgstr "" +"Linux 2.6.32 以降では、:mod:`!fcntl` モジュールに定数 ``F_GETOWN_EX``、" +"``F_SETOWN_EX``、``F_OWNER_TID``、``F_OWNER_PID``、``F_OWNER_PGRP`` が追加さ" +"れました。\n" +"これらを使うと、I/O が可能になったことを知らせるシグナルを特定のスレッド、プ" +"ロセス、プロセスグループに送れます。\n" +"Linux 4.13 以降では、:mod:`!fcntl` モジュールに定数 ``F_GET_RW_HINT``、" +"``F_SET_RW_HINT``、``F_GET_FILE_RW_HINT``、``F_SET_FILE_RW_HINT``、" +"``RWH_WRITE_LIFE_*`` が追加されました。\n" +"これらを使うと、指定した inode や特定のオープンファイル記述を介して書き込む" +"データについて、予想される寿命の相対的な長さをカーネルに伝えられます。\n" +"Linux 5.1 以降と NetBSD では、:mod:`!fcntl` モジュールに ``F_ADD_SEALS`` や " +"``F_GET_SEALS`` 操作で使う定数 ``F_SEAL_FUTURE_WRITE`` が追加されました。\n" +"FreeBSD では、:mod:`!fcntl` モジュールに定数 ``F_READAHEAD``、" +"``F_ISUNIONSTACK``、``F_KINFO`` が追加されました。\n" +"macOS と FreeBSD では、:mod:`!fcntl` モジュールに定数 ``F_RDAHEAD`` が追加さ" +"れました。\n" +"NetBSD と AIX では、:mod:`!fcntl` モジュールに定数 ``F_CLOSEM`` が追加されま" +"した。\n" +"NetBSD では、:mod:`!fcntl` モジュールに定数 ``F_MAXFD`` が追加されました。\n" +"macOS と NetBSD では、:mod:`!fcntl` モジュールに定数 ``F_GETNOSIGPIPE`` と " +"``F_SETNOSIGPIPE`` が追加されました。" #: ../../library/fcntl.rst:79 msgid "" @@ -129,7 +164,6 @@ msgstr "" msgid "The module defines the following functions:" msgstr "このモジュールには、以下の関数が定義されています:" -#: ../../library/fcntl.rst:88 msgid "" "Perform the operation *cmd* on file descriptor *fd* (file objects providing " "a :meth:`~io.IOBase.fileno` method are accepted as well). The values used " @@ -140,14 +174,21 @@ msgid "" "type and size of the argument of the operation as specified in the relevant " "C documentation." msgstr "" +"ファイル記述子 *fd* に対して操作 *cmd* を実行します (:meth:`~io.IOBase." +"fileno` メソッドを持つファイルオブジェクトも受け取れます)。\n" +"*cmd* に使う値は OS に依存し、関連する C ヘッダファイルと同じ名前の定数とし" +"て :mod:`!fcntl` モジュールに用意されています。\n" +"*arg* 引数には整数値、:term:`bytes-like object`、文字列のいずれかを指定できま" +"す。\n" +"*arg* の型とサイズは、関連する C のドキュメントで指定された操作の引数の型とサ" +"イズに一致しなければなりません。" -#: ../../library/fcntl.rst:97 msgid "" "When *arg* is an integer, the function returns the integer return value of " "the C :c:func:`fcntl` call." msgstr "" +"*arg* が整数の場合、C の :c:func:`fcntl` 呼び出しの整数の返り値を返します。" -#: ../../library/fcntl.rst:100 msgid "" "When the argument is bytes-like object, it represents a binary structure, " "for example, created by :func:`struct.pack`. A string value is encoded to " @@ -157,12 +198,18 @@ msgid "" "object. The length of the returned object will be the same as the length of " "the *arg* argument." msgstr "" +"引数が bytes-like オブジェクトの場合、:func:`struct.pack` で作成したものなど" +"のバイナリ構造体を表します。\n" +"文字列の値は UTF-8 でバイナリにエンコードされます。\n" +"バイナリデータはバッファにコピーされ、そのアドレスが C の :c:func:`fcntl` 呼" +"び出しに渡されます。\n" +"呼び出しが成功すると、バッファの内容を :class:`bytes` オブジェクトに変換して" +"返します。\n" +"返されるオブジェクトの長さは *arg* 引数の長さと同じです。" -#: ../../library/fcntl.rst:109 msgid "If the :c:func:`fcntl` call fails, an :exc:`OSError` is raised." -msgstr "" +msgstr ":c:func:`fcntl` の呼び出しに失敗すると :exc:`OSError` を送出します。" -#: ../../library/fcntl.rst:112 ../../library/fcntl.rst:161 msgid "" "If the type or size of *arg* does not match the type or size of the " "operation's argument (for example, if an integer is passed when a pointer is " @@ -170,24 +217,28 @@ msgid "" "is larger than the size of *arg*), this is most likely to result in a " "segmentation violation or a more subtle data corruption." msgstr "" +"*arg* の型やサイズが操作の引数の型やサイズに一致しない場合 (例えば、ポインタ" +"が必要なところに整数を渡した場合や、OS がバッファに返す情報のサイズが *arg* " +"より大きい場合)、セグメンテーション違反や、より分かりにくいデータ破損が起きる" +"可能性が非常に高くなります。" -#: ../../library/fcntl.rst:119 msgid "" "Raises an :ref:`auditing event ` ``fcntl.fcntl`` with arguments " "``fd``, ``cmd``, ``arg``." msgstr "" "引数 ``fd``, ``cmd``, ``arg`` を指定して :ref:`監査イベント ` " -"``fcntl.fcntl`` を送出します。 " +"``fcntl.fcntl`` を送出します。" -#: ../../library/fcntl.rst:121 msgid "" "Add support of arbitrary :term:`bytes-like objects `, not " "only :class:`bytes`." msgstr "" +":class:`bytes` だけでなく、任意の :term:`bytes-like オブジェクト ` をサポートするようになりました。" -#: ../../library/fcntl.rst:125 msgid "The size of bytes-like objects is no longer limited to 1024 bytes." msgstr "" +"bytes-like オブジェクトのサイズが 1024 バイトに制限されなくなりました。" #: ../../library/fcntl.rst:131 msgid "" @@ -197,28 +248,35 @@ msgstr "" "この関数は :func:`~fcntl.fcntl` 関数と同じですが、引数の扱いがより複雑である" "ところが異なります。" -#: ../../library/fcntl.rst:134 msgid "" "The *request* parameter is limited to values that can fit in 32-bits or 64-" "bits, depending on the platform. Additional constants of interest for use as " "the *request* argument can be found in the :mod:`termios` module, under the " "same names as used in the relevant C header files." msgstr "" +"*request* パラメータは、プラットフォームに応じて 32 ビットまたは 64 ビットに" +"収まる値に制限されます。\n" +"*request* 引数に使えるその他の定数は :mod:`termios` モジュールに、関連する C " +"ヘッダファイルと同じ名前で用意されています。" -#: ../../library/fcntl.rst:140 msgid "" "The parameter *arg* can be an integer, a :term:`bytes-like object`, or a " "string. The type and size of *arg* must match the type and size of the " "argument of the operation as specified in the relevant C documentation." msgstr "" +"*arg* パラメータには整数、:term:`bytes-like object`、文字列のいずれかを指定で" +"きます。\n" +"*arg* の型とサイズは、関連する C のドキュメントで指定された操作の引数の型とサ" +"イズに一致しなければなりません。" -#: ../../library/fcntl.rst:145 msgid "" "If *arg* does not support the read-write buffer interface or the " "*mutate_flag* is false, behavior is as for the :func:`~fcntl.fcntl` function." msgstr "" +"*arg* が読み書き可能なバッファインターフェイスをサポートしていない場合、また" +"は *mutate_flag* が偽の場合は、:func:`~fcntl.fcntl` 関数と同じ動作になりま" +"す。" -#: ../../library/fcntl.rst:149 msgid "" "If *arg* supports the read-write buffer interface (like :class:`bytearray`) " "and *mutate_flag* is true (the default), then the buffer is (in effect) " @@ -229,17 +287,24 @@ msgid "" "copied into a static buffer 1024 bytes long which is then passed to :func:" "`ioctl` and copied back into the supplied buffer." msgstr "" +"*arg* が :class:`bytearray` のように読み書き可能なバッファインターフェイスを" +"サポートし、*mutate_flag* が真 (デフォルト) の場合、実質的にはそのバッファが" +"基になる :c:func:`!ioctl` システムコールに渡されます。\n" +"システムコールの返り値が呼び出し元の Python に返され、バッファの新しい内容に" +"は :c:func:`ioctl` の処理が反映されます。\n" +"これは少し単純化した説明です。\n" +"実際には、渡したバッファの長さが 1024 バイト未満の場合は、まず長さ 1024 バイ" +"トの静的バッファにコピーしてから :func:`ioctl` に渡し、その後で元のバッファに" +"コピーし直します。" -#: ../../library/fcntl.rst:158 msgid "" "If the :c:func:`ioctl` call fails, an :exc:`OSError` exception is raised." -msgstr "" +msgstr ":c:func:`ioctl` の呼び出しに失敗すると :exc:`OSError` を送出します。" #: ../../library/fcntl.rst:168 msgid "An example::" msgstr "以下に例を示します::" -#: ../../library/fcntl.rst:170 msgid "" ">>> import array, fcntl, struct, termios, os\n" ">>> os.getpgrp()\n" @@ -252,26 +317,37 @@ msgid "" ">>> buf\n" "array('h', [13341])" msgstr "" +">>> import array, fcntl, struct, termios, os\n" +">>> os.getpgrp()\n" +"13341\n" +">>> struct.unpack('h', fcntl.ioctl(0, termios.TIOCGPGRP, \" \"))[0]\n" +"13341\n" +">>> buf = array.array('h', [0])\n" +">>> fcntl.ioctl(0, termios.TIOCGPGRP, buf, 1)\n" +"0\n" +">>> buf\n" +"array('h', [13341])" -#: ../../library/fcntl.rst:181 msgid "" "Raises an :ref:`auditing event ` ``fcntl.ioctl`` with arguments " "``fd``, ``request``, ``arg``." msgstr "" "引数 ``fd``, ``request``, ``arg`` を指定して :ref:`監査イベント ` " -"``fcntl.ioctl`` を送出します。 " +"``fcntl.ioctl`` を送出します。" -#: ../../library/fcntl.rst:183 msgid "" "The GIL is always released during a system call. System calls failing with " "EINTR are automatically retried." msgstr "" +"システムコール中は常に GIL を解放するようになりました。\n" +"EINTR で失敗したシステムコールは自動的に再試行します。" -#: ../../library/fcntl.rst:187 msgid "" "The size of not mutated bytes-like objects is no longer limited to 1024 " "bytes." msgstr "" +"変更されない bytes-like オブジェクトのサイズが 1024 バイトに制限されなくなり" +"ました。" #: ../../library/fcntl.rst:193 msgid "" @@ -285,18 +361,16 @@ msgstr "" "Unix マニュアルの :manpage:`flock(2)` を参照してください (システムによって" "は、この関数は :c:func:`fcntl` を使ってエミュレーションされています)。" -#: ../../library/fcntl.rst:198 msgid "" "If the :c:func:`flock` call fails, an :exc:`OSError` exception is raised." -msgstr "" +msgstr ":c:func:`flock` の呼び出しに失敗すると :exc:`OSError` を送出します。" -#: ../../library/fcntl.rst:200 msgid "" "Raises an :ref:`auditing event ` ``fcntl.flock`` with arguments " "``fd``, ``operation``." msgstr "" "引数 ``fd``, ``operation`` を指定して :ref:`監査イベント ` ``fcntl." -"flock`` を送出します。 " +"flock`` を送出します。" #: ../../library/fcntl.rst:205 msgid "" @@ -310,25 +384,22 @@ msgstr "" "IOBase.fileno` メソッドを提供するファイルオブジェクトも受け付けられます) " "で、 *cmd* は以下の値のうちいずれかになります:" -#: ../../library/fcntl.rst:212 msgid "Release an existing lock." -msgstr "" +msgstr "既存のロックを解放します。" -#: ../../library/fcntl.rst:216 msgid "Acquire a shared lock." -msgstr "" +msgstr "共有ロックを取得します。" -#: ../../library/fcntl.rst:220 msgid "Acquire an exclusive lock." -msgstr "" +msgstr "排他ロックを取得します。" -#: ../../library/fcntl.rst:224 msgid "" "Bitwise OR with any of the other three ``LOCK_*`` constants to make the " "request non-blocking." msgstr "" +"ほかの 3 つの ``LOCK_*`` 定数のいずれかとビット単位の OR を取り、要求を非ブ" +"ロッキングにします。" -#: ../../library/fcntl.rst:227 msgid "" "If :const:`!LOCK_NB` is used and the lock cannot be acquired, an :exc:" "`OSError` will be raised and the exception will have an *errno* attribute " @@ -337,6 +408,13 @@ msgid "" "systems, :const:`!LOCK_EX` can only be used if the file descriptor refers to " "a file opened for writing." msgstr "" +":const:`!LOCK_NB` を使い、ロックを取得できなかった場合は :exc:`OSError` を送" +"出します。\n" +"例外の *errno* 属性には :const:`~errno.EACCES` または :const:`~errno.EAGAIN` " +"が設定されます (OS に依存するため、可搬性を保つには両方の値を確認してくださ" +"い)。\n" +"少なくとも一部のシステムでは、:const:`!LOCK_EX` を使えるのは、書き込み用に開" +"いたファイルを指すファイル記述子の場合だけです。" #: ../../library/fcntl.rst:234 msgid "" @@ -348,17 +426,14 @@ msgstr "" "相対的なバイトオフセット、 *whence* は :func:`io.IOBase.seek` と同じで、具体" "的には:" -#: ../../library/fcntl.rst:238 msgid "``0`` -- relative to the start of the file (:const:`os.SEEK_SET`)" -msgstr "" +msgstr "``0`` -- ファイルの先頭を基準にします (:const:`os.SEEK_SET`)。" -#: ../../library/fcntl.rst:239 msgid "``1`` -- relative to the current buffer position (:const:`os.SEEK_CUR`)" -msgstr "" +msgstr "``1`` -- 現在のバッファ位置を基準にします (:const:`os.SEEK_CUR`)。" -#: ../../library/fcntl.rst:240 msgid "``2`` -- relative to the end of the file (:const:`os.SEEK_END`)" -msgstr "" +msgstr "``2`` -- ファイルの末尾を基準にします (:const:`os.SEEK_END`)。" #: ../../library/fcntl.rst:242 msgid "" @@ -370,19 +445,18 @@ msgstr "" "の標準の値は 0 で、ファイルの終了までロックすることを表します。*whence* の標" "準の値も 0 です。" -#: ../../library/fcntl.rst:246 msgid "" "Raises an :ref:`auditing event ` ``fcntl.lockf`` with arguments " "``fd``, ``cmd``, ``len``, ``start``, ``whence``." msgstr "" "引数 ``fd``, ``cmd``, ``len``, ``start``, ``whence`` を指定して :ref:`監査イ" -"ベント ` ``fcntl.lockf`` を送出します。 " +"ベント ` ``fcntl.lockf`` を送出します。" -#: ../../library/fcntl.rst:248 msgid "Examples (all on a SVR4 compliant system)::" -msgstr "以下に (全ての SVR4 互換システムでの) 例を示します::" +msgstr "" +"以下に例を示します。\n" +"いずれも SVR4 準拠のシステムで実行したものです。 ::" -#: ../../library/fcntl.rst:250 msgid "" "import struct, fcntl, os\n" "\n" @@ -392,6 +466,13 @@ msgid "" "lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)\n" "rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)" msgstr "" +"import struct, fcntl, os\n" +"\n" +"f = open(...)\n" +"rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY)\n" +"\n" +"lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)\n" +"rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)" #: ../../library/fcntl.rst:258 msgid "" @@ -408,20 +489,21 @@ msgstr "" msgid "Module :mod:`os`" msgstr ":mod:`os` モジュール" -#: ../../library/fcntl.rst:267 msgid "" "If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are " "present in the :mod:`os` module (on BSD only), the :func:`os.open` function " "provides an alternative to the :func:`lockf` and :func:`flock` functions." msgstr "" +"ロック用のフラグ :const:`~os.O_SHLOCK` と :const:`~os.O_EXLOCK` が :mod:`os` " +"モジュールにある場合 (BSD のみ)、:func:`os.open` 関数を :func:`lockf` や :" +"func:`flock` の代わりに使えます。" #: ../../library/fcntl.rst:7 msgid "UNIX" msgstr "UNIX" -#: ../../library/fcntl.rst:7 msgid "file control" -msgstr "" +msgstr "ファイル制御" #: ../../library/fcntl.rst:7 msgid "I/O control" diff --git a/library/filecmp.po b/library/filecmp.po index f7a3ba95c..9253041ff 100644 --- a/library/filecmp.po +++ b/library/filecmp.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/filecmp.rst:2 @@ -30,16 +30,18 @@ msgstr ":mod:`!filecmp` --- ファイルとディレクトリの比較" msgid "**Source code:** :source:`Lib/filecmp.py`" msgstr "**ソースコード:** :source:`Lib/filecmp.py`" -#: ../../library/filecmp.rst:11 msgid "" "The :mod:`!filecmp` module defines functions to compare files and " "directories, with various optional time/correctness trade-offs. For " "comparing files, see also the :mod:`difflib` module." msgstr "" +":mod:`!filecmp` モジュールはファイルとディレクトリを比較する関数を定義してい" +"ます。\n" +"オプションによって、処理時間と正確性のさまざまなバランスを選べます。\n" +"ファイルの比較については :mod:`difflib` モジュールも参照してください。" -#: ../../library/filecmp.rst:15 msgid "The :mod:`!filecmp` module defines the following functions:" -msgstr "" +msgstr ":mod:`!filecmp` モジュールは以下の関数を定義しています:" #: ../../library/filecmp.rst:20 msgid "" @@ -49,18 +51,20 @@ msgstr "" "名前が *f1* および *f2* のファイルを比較し、二つのファイルが同じらしければ " "``True`` を返し、そうでなければ ``False`` を返します。" -#: ../../library/filecmp.rst:23 msgid "" "If *shallow* is true and the :func:`os.stat` signatures (file type, size, " "and modification time) of both files are identical, the files are taken to " "be equal." msgstr "" +"*shallow* が真で、両方のファイルの :func:`os.stat` による特徴 (ファイルの種" +"類、サイズ、更新時刻) が同一であれば、ファイルは同じとみなされます。" -#: ../../library/filecmp.rst:27 msgid "" "Otherwise, the files are treated as different if their sizes or contents " "differ." msgstr "" +"それ以外の場合は、サイズまたは内容が異なればファイルを異なるものとして扱いま" +"す。" #: ../../library/filecmp.rst:29 msgid "" @@ -80,11 +84,12 @@ msgstr "" "stat` 情報が変更された場合、キャッシュの項目は無効化されます。:func:" "`clear_cache` を使用して全キャッシュを削除することが出来ます。" -#: ../../library/filecmp.rst:39 msgid "" "Compare the files in the two directories *a* and *b* whose names are given " "by *common*." msgstr "" +"ディレクトリ *a* と *b* の間で、*common* に名前を指定したファイルを比較しま" +"す。" #: ../../library/filecmp.rst:42 msgid "" @@ -132,23 +137,27 @@ msgstr "" msgid "The :class:`dircmp` class" msgstr ":class:`dircmp` クラス" -#: ../../library/filecmp.rst:73 msgid "" "Construct a new directory comparison object, to compare the directories *a* " "and *b*. *ignore* is a list of names to ignore, and defaults to :const:" "`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and defaults " "to ``[os.curdir, os.pardir]``." msgstr "" +"ディレクトリ *a* と *b* を比較する、新しいディレクトリ比較オブジェクトを作成" +"します。\n" +"*ignore* は無視する名前のリストで、デフォルトは :const:`filecmp." +"DEFAULT_IGNORES` です。\n" +"*hide* は隠す名前のリストで、デフォルトは ``[os.curdir, os.pardir]`` です。" -#: ../../library/filecmp.rst:78 msgid "" "The :class:`dircmp` class compares files by doing *shallow* comparisons as " "described for :func:`filecmp.cmp` by default using the *shallow* parameter." msgstr "" +":class:`dircmp` クラスは *shallow* パラメータを使い、デフォルトでは :func:" +"`filecmp.cmp` で説明した浅い比較を行います。" -#: ../../library/filecmp.rst:84 msgid "Added the *shallow* parameter." -msgstr "" +msgstr "*shallow* パラメータが追加されました。" #: ../../library/filecmp.rst:86 msgid "The :class:`dircmp` class provides the following methods:" @@ -173,21 +182,22 @@ msgstr "" "*a* および *b* およびそれらの共通のサブディレクトリ間での比較結果を (再帰的に" "比較して) 出力します。" -#: ../../library/filecmp.rst:102 msgid "" "The :class:`dircmp` class offers a number of interesting attributes that may " "be used to get various bits of information about the directory trees being " "compared." msgstr "" -":class:`dircmp` クラスは、比較されているディレクトリ階層に関する様々な情報の" -"ビットを得るために使用することのできる、興味深い属性を数多く提供しています。" +":class:`dircmp` クラスには、比較するディレクトリツリーについてさまざまな情報" +"を取得できる便利な属性が用意されています。" -#: ../../library/filecmp.rst:106 msgid "" "Note that via :meth:`~object.__getattr__` hooks, all attributes are computed " "lazily, so there is no speed penalty if only those attributes which are " "lightweight to compute are used." msgstr "" +":meth:`~object.__getattr__` フックによって、すべての属性は必要になるまで計算" +"されません。\n" +"そのため計算が軽い属性だけを使う場合、重い計算による速度の低下はありません。" #: ../../library/filecmp.rst:113 msgid "The directory *a*." @@ -253,22 +263,25 @@ msgstr "" "*a* と *b* の両方に存在し、クラスのファイル比較オペレータに基づいて内容が異な" "るファイルです。" -#: ../../library/filecmp.rst:176 msgid "Files which are in both *a* and *b*, but could not be compared." -msgstr "*a* および *b* 両方にあるが、比較されなかったファイルです。" +msgstr "*a* と *b* の両方に存在するものの、比較できなかったファイルです。" -#: ../../library/filecmp.rst:181 msgid "" "A dictionary mapping names in :attr:`common_dirs` to :class:`dircmp` " "instances (or MyDirCmp instances if this instance is of type MyDirCmp, a " "subclass of :class:`dircmp`)." msgstr "" +":attr:`common_dirs` 内の名前を :class:`dircmp` インスタンスに対応付ける辞書で" +"す (このインスタンスの型が :class:`dircmp` のサブクラス ``MyDirCmp`` であれ" +"ば、値も ``MyDirCmp`` インスタンスになります)。" -#: ../../library/filecmp.rst:185 msgid "" "Previously entries were always :class:`dircmp` instances. Now entries are " "the same type as *self*, if *self* is a subclass of :class:`dircmp`." msgstr "" +"以前は各項目が常に :class:`dircmp` インスタンスでした。\n" +"現在は *self* が :class:`dircmp` のサブクラスのインスタンスであれば、各項目" +"も *self* と同じ型になります。" #: ../../library/filecmp.rst:194 msgid "List of directories ignored by :class:`dircmp` by default." @@ -282,7 +295,6 @@ msgstr "" "これは ``subdirs`` 属性を使用して 2 つのディレクトリを再帰的に探索して、共通" "の異なるファイルを示すための単純化された例です::" -#: ../../library/filecmp.rst:200 msgid "" ">>> from filecmp import dircmp\n" ">>> def print_diff_files(dcmp):\n" @@ -295,3 +307,13 @@ msgid "" ">>> dcmp = dircmp('dir1', 'dir2')\n" ">>> print_diff_files(dcmp)" msgstr "" +">>> from filecmp import dircmp\n" +">>> def print_diff_files(dcmp):\n" +"... for name in dcmp.diff_files:\n" +"... print(\"diff_file %s found in %s and %s\" % (name, dcmp.left,\n" +"... dcmp.right))\n" +"... for sub_dcmp in dcmp.subdirs.values():\n" +"... print_diff_files(sub_dcmp)\n" +"...\n" +">>> dcmp = dircmp('dir1', 'dir2')\n" +">>> print_diff_files(dcmp)" diff --git a/library/fileformats.po b/library/fileformats.po index 7f184744a..95257723f 100644 --- a/library/fileformats.po +++ b/library/fileformats.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/fileformats.rst:5 diff --git a/library/fileinput.po b/library/fileinput.po index 98bef83c4..bdf468be0 100644 --- a/library/fileinput.po +++ b/library/fileinput.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/fileinput.rst:2 @@ -44,12 +44,14 @@ msgstr "" msgid "The typical use is::" msgstr "典型的な使い方は以下の通りです::" -#: ../../library/fileinput.rst:17 msgid "" "import fileinput\n" "for line in fileinput.input(encoding=\"utf-8\"):\n" " process(line)" msgstr "" +"import fileinput\n" +"for line in fileinput.input(encoding=\"utf-8\"):\n" +" process(line)" #: ../../library/fileinput.rst:21 msgid "" @@ -114,7 +116,6 @@ msgstr "" "ファイルの各行は、各種改行文字まで含めて返されます。ファイルの最後が改行文字" "で終っていない場合には、改行文字で終わらない行が返されます。" -#: ../../library/fileinput.rst:46 msgid "" "You can control how files are opened by providing an opening hook via the " "*openhook* parameter to :func:`fileinput.input` or :func:`FileInput`. The " @@ -124,21 +125,29 @@ msgid "" "keyword arguments. This module provides a :func:`hook_compressed` to support " "compressed files." msgstr "" +":func:`fileinput.input` または :func:`FileInput` の *openhook* パラメータに" +"オープン時のフックを渡すと、ファイルの開き方を制御できます。\n" +"フックは *filename* と *mode* の 2 つの引数を受け取り、それに従って開いたファ" +"イル類似オブジェクトを返す関数でなければなりません。\n" +"*encoding* や *errors* を指定すると、追加のキーワード引数としてフックに渡され" +"ます。\n" +"このモジュールには圧縮ファイルに対応する :func:`hook_compressed` が用意されて" +"います。" #: ../../library/fileinput.rst:53 msgid "The following function is the primary interface of this module:" msgstr "以下の関数がこのモジュールの基本的なインターフェースです:" -#: ../../library/fileinput.rst:58 msgid "" "Create an instance of the :class:`FileInput` class. The instance will be " "used as global state for the functions of this module, and is also returned " "to use during iteration. The parameters to this function will be passed " "along to the constructor of the :class:`FileInput` class." msgstr "" -":class:`FileInput` クラスのインスタンスを作ります。生成されたインスタンスは、" -"このモジュールの関数群が利用するグローバルな状態として利用されます。この関数" -"への引数は :class:`FileInput` クラスのコンストラクタへ渡されます。" +":class:`FileInput` クラスのインスタンスを作成します。\n" +"このインスタンスはモジュール内の関数が使うグローバルな状態になり、反復処理に" +"使えるよう戻り値としても返されます。\n" +"この関数の引数は :class:`FileInput` クラスのコンストラクタに渡されます。" #: ../../library/fileinput.rst:63 msgid "" @@ -151,13 +160,16 @@ msgstr "" "次の例では、仮に例外が生じたとしても :keyword:`!with` 文から抜けた後で " "*input* は閉じられます::" -#: ../../library/fileinput.rst:67 msgid "" "with fileinput.input(files=('spam.txt', 'eggs.txt'), encoding=\"utf-8\") as " "f:\n" " for line in f:\n" " process(line)" msgstr "" +"with fileinput.input(files=('spam.txt', 'eggs.txt'), encoding=\"utf-8\") as " +"f:\n" +" for line in f:\n" +" process(line)" #: ../../library/fileinput.rst:71 ../../library/fileinput.rst:167 msgid "Can be used as a context manager." @@ -168,10 +180,8 @@ msgid "The keyword parameters *mode* and *openhook* are now keyword-only." msgstr "" "キーワード引数 *mode* と *openhook* は、キーワード専用引数になりました。" -#: ../../library/fileinput.rst:77 ../../library/fileinput.rst:173 -#: ../../library/fileinput.rst:207 msgid "The keyword-only parameter *encoding* and *errors* are added." -msgstr "" +msgstr "キーワード専用引数 *encoding* と *errors* が追加されました。" #: ../../library/fileinput.rst:81 msgid "" @@ -299,11 +309,11 @@ msgstr "" "ければなりません。この関数の返り値は、オープンしたファイルオブジェクトとなり" "ます。*inplace* と *openhook* を同時に使うことはできません。" -#: ../../library/fileinput.rst:158 msgid "" "You can specify *encoding* and *errors* that is passed to :func:`open` or " "*openhook*." msgstr "" +":func:`open` または *openhook* に渡す *encoding* と *errors* を指定できます。" #: ../../library/fileinput.rst:160 msgid "" @@ -316,22 +326,24 @@ msgstr "" "次の例では、仮に例外が生じたとしても :keyword:`!with` 文から抜けた後で " "*input* は閉じられます::" -#: ../../library/fileinput.rst:164 msgid "" "with FileInput(files=('spam.txt', 'eggs.txt')) as input:\n" " process(input)" msgstr "" +"with FileInput(files=('spam.txt', 'eggs.txt')) as input:\n" +" process(input)" #: ../../library/fileinput.rst:170 msgid "The keyword parameter *mode* and *openhook* are now keyword-only." msgstr "" "キーワード引数 *mode* と *openhook* は、キーワード専用引数になりました。" -#: ../../library/fileinput.rst:176 msgid "" "The ``'rU'`` and ``'U'`` modes and the :meth:`!__getitem__` method have been " "removed." msgstr "" +"``'rU'`` と ``'U'`` モード、および :meth:`!__getitem__` メソッドが削除されま" +"した。" #: ../../library/fileinput.rst:181 msgid "" @@ -374,11 +386,12 @@ msgstr "" "ます。ファイルの拡張子が ``'.gz'`` や ``'.bz2'`` でない場合は、通常通りファイ" "ルをオープンします (つまり、 :func:`open` をコールする際に伸長を行いません)。" -#: ../../library/fileinput.rst:202 msgid "" "The *encoding* and *errors* values are passed to :class:`io.TextIOWrapper` " "for compressed files and open for normal files." msgstr "" +"*encoding* と *errors* の値は、圧縮ファイルの場合は :class:`io." +"TextIOWrapper` に、通常のファイルの場合は ``open()`` に渡されます。" #: ../../library/fileinput.rst:205 msgid "" @@ -408,8 +421,9 @@ msgstr "" msgid "Added the optional *errors* parameter." msgstr "オプションの *errors* 引数が追加されました。" -#: ../../library/fileinput.rst:223 msgid "" "This function is deprecated since :func:`fileinput.input` and :class:" "`FileInput` now have *encoding* and *errors* parameters." msgstr "" +":func:`fileinput.input` と :class:`FileInput` に *encoding* と *errors* パラ" +"メータが追加されたため、この関数は非推奨になりました。" diff --git a/library/filesys.po b/library/filesys.po index 35f6f2ea0..3992a59b7 100644 --- a/library/filesys.po +++ b/library/filesys.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/filesys.rst:5 diff --git a/library/fnmatch.po b/library/fnmatch.po index c858e30de..0311e8835 100644 --- a/library/fnmatch.po +++ b/library/fnmatch.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/fnmatch.rst:2 @@ -88,7 +88,6 @@ msgstr "" "リテラルにマッチさせるには、メタ文字を括弧に入れてください。例えば、" "``'[?]'`` は文字 ``'?'`` にマッチします。" -#: ../../library/fnmatch.rst:43 msgid "" "Note that the filename separator (``'/'`` on Unix) is *not* special to this " "module. See module :mod:`glob` for pathname expansion (:mod:`glob` uses :" @@ -96,27 +95,34 @@ msgid "" "with a period are not special for this module, and are matched by the ``*`` " "and ``?`` patterns." msgstr "" -"ファイル名の区切り文字 (Unixでは ``'/'``) はこのモジュールに固有なものでは *" -"ない* ことに注意してください。パス名展開については、 :mod:`glob` モジュールを" -"参照してください (:mod:`glob` はパス名の部分にマッチさせるのに :func:`." -"filter` を使っています)。同様に、ピリオドで始まるファイル名はこのモジュールに" -"固有ではなくて、 ``*`` と ``?`` のパターンでマッチします。" +"ファイル名の区切り文字 (Unix では ``'/'``) は、このモジュールでは特別扱い *さ" +"れません*。\n" +"パス名の展開については :mod:`glob` モジュールを参照してください (:mod:`glob` " +"はパス名の各部分の照合に :func:`.filter` を使います)。\n" +"同様に、ピリオドで始まるファイル名も特別扱いされず、``*`` や ``?`` のパターン" +"にマッチします。" -#: ../../library/fnmatch.rst:49 msgid "" "Unless stated otherwise, \"filename string\" and \"pattern string\" either " "refer to :class:`str` or ``ISO-8859-1`` encoded :class:`bytes` objects. Note " "that the functions documented below do not allow to mix a :class:`!bytes` " "pattern with a :class:`!str` filename, and vice-versa." msgstr "" +"特に断りがなければ、「ファイル名文字列」と「パターン文字列」は :class:`str` " +"または ``ISO-8859-1`` でエンコードされた :class:`bytes` オブジェクトを指しま" +"す。\n" +"以下の関数では、:class:`!bytes` のパターンと :class:`!str` のファイル名を混在" +"させることはできず、その逆も同様です。" -#: ../../library/fnmatch.rst:54 msgid "" "Finally, note that :deco:`functools.lru_cache` with a *maxsize* of 32768 is " "used to cache the (typed) compiled regex patterns in the following " "functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`, :func:`." "filterfalse`." msgstr "" +"なお、:func:`fnmatch`、:func:`fnmatchcase`、:func:`.filter`、:func:`." +"filterfalse` では、*maxsize* が 32768 の :deco:`functools.lru_cache` を使い、" +"コンパイル済みの正規表現パターンを型別にキャッシュしています。" #: ../../library/fnmatch.rst:61 msgid "" @@ -140,7 +146,6 @@ msgstr "" "次の例では、カレントディレクトリにある、拡張子が ``.txt`` である全てのファイ" "ルを表示しています::" -#: ../../library/fnmatch.rst:70 msgid "" "import fnmatch\n" "import os\n" @@ -149,6 +154,12 @@ msgid "" " if fnmatch.fnmatch(file, '*.txt'):\n" " print(file)" msgstr "" +"import fnmatch\n" +"import os\n" +"\n" +"for file in os.listdir('.'):\n" +" if fnmatch.fnmatch(file, '*.txt'):\n" +" print(file)" #: ../../library/fnmatch.rst:80 msgid "" @@ -160,27 +171,35 @@ msgstr "" "``True`` または ``False`` を返します。比較は大文字、小文字を区別し、 :func:" "`os.path.normcase` は適用しません。" -#: ../../library/fnmatch.rst:87 msgid "" "Construct a list from those elements of the :term:`iterable` of filename " "strings *names* that match the pattern string *pat*. It is the same as ``[n " "for n in names if fnmatch(n, pat)]``, but implemented more efficiently." msgstr "" +"ファイル名文字列の :term:`イテラブル ` *names* のうち、パターン文字" +"列 *pat* にマッチする要素からリストを作成します。\n" +"``[n for n in names if fnmatch(n, pat)]`` と同じですが、より効率的に実装され" +"ています。" -#: ../../library/fnmatch.rst:95 msgid "" "Construct a list from those elements of the :term:`iterable` of filename " "strings *names* that do not match the pattern string *pat*. It is the same " "as ``[n for n in names if not fnmatch(n, pat)]``, but implemented more " "efficiently." msgstr "" +"ファイル名文字列の :term:`イテラブル ` *names* のうち、パターン文字" +"列 *pat* にマッチしない要素からリストを作成します。\n" +"``[n for n in names if not fnmatch(n, pat)]`` と同じですが、より効率的に実装" +"されています。" -#: ../../library/fnmatch.rst:105 msgid "" "Return the shell-style pattern *pat* converted to a regular expression for " "using with :func:`re.prefixmatch`. The pattern is expected to be a :class:" "`str`." msgstr "" +"シェル形式のパターン *pat* を :func:`re.prefixmatch` で使う正規表現に変換して" +"返します。\n" +"パターンは :class:`str` でなければなりません。" #: ../../library/fnmatch.rst:109 msgid "Example:" diff --git a/library/fractions.po b/library/fractions.po index b84ea717a..4c088d102 100644 --- a/library/fractions.po +++ b/library/fractions.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/fractions.rst:2 @@ -30,26 +30,28 @@ msgstr ":mod:`!fractions` --- 有理数" msgid "**Source code:** :source:`Lib/fractions.py`" msgstr "**ソースコード:** :source:`Lib/fractions.py`" -#: ../../library/fractions.rst:11 msgid "" "The :mod:`!fractions` module provides support for rational number arithmetic." -msgstr "" +msgstr ":mod:`!fractions` モジュールは有理数の演算をサポートします。" -#: ../../library/fractions.rst:14 msgid "" "A Fraction instance can be constructed from a pair of rational numbers, from " "a single number, or from a string." msgstr "" +"Fraction インスタンスは、2 つの有理数、1 つの数値、または文字列から作成できま" +"す。" -#: ../../library/fractions.rst:23 msgid "" "The first version requires that *numerator* and *denominator* are instances " "of :class:`numbers.Rational` and returns a new :class:`Fraction` instance " "with a value equal to ``numerator/denominator``. If *denominator* is zero, " "it raises a :exc:`ZeroDivisionError`." msgstr "" +"最初の形式では *numerator* と *denominator* が :class:`numbers.Rational` のイ" +"ンスタンスである必要があり、``numerator/denominator`` と等しい値を持つ新し" +"い :class:`Fraction` インスタンスを返します。\n" +"*denominator* がゼロの場合は :exc:`ZeroDivisionError` を送出します。" -#: ../../library/fractions.rst:28 msgid "" "The second version requires that *number* is an instance of :class:`numbers." "Rational` or has the :meth:`!as_integer_ratio` method (this includes :class:" @@ -62,16 +64,26 @@ msgid "" "one might expect. (But see the documentation for the :meth:" "`limit_denominator` method below.)" msgstr "" +"2 番目の形式では *number* が :class:`numbers.Rational` のインスタンスである" +"か、:meth:`!as_integer_ratio` メソッドを持つ必要があります (:class:`float` " +"と :class:`decimal.Decimal` はこれに含まれます)。\n" +"まったく同じ値を持つ :class:`Fraction` インスタンスを返します。\n" +":meth:`!as_integer_ratio` メソッドは互いに素な整数のペアを返し、後者が正であ" +"ることを前提としています。\n" +"二進浮動小数点に伴う一般的な問題 (:ref:`tut-fp-issues` を参照) により、" +"``Fraction(1.1)`` の引数は厳密には 11/10 と等しくないため、``Fraction(1.1)`` " +"は期待するかもしれない ``Fraction(11, 10)`` を返すわけでは *ありません*。\n" +"(ただし、以下の :meth:`limit_denominator` メソッドの説明を参照してください。)" -#: ../../library/fractions.rst:40 msgid "" "The last version of the constructor expects a string. The usual form for " "this instance is::" msgstr "" +"最後の形式のコンストラクタは文字列を受け取ります。\n" +"通常は次の形式です。 ::" -#: ../../library/fractions.rst:43 msgid "[sign] numerator ['/' denominator]" -msgstr "" +msgstr "[sign] numerator ['/' denominator]" #: ../../library/fractions.rst:45 msgid "" @@ -90,7 +102,6 @@ msgstr "" "class:`Fraction` コンストラクタでも受け付けられます。どちらの形式でも、入力さ" "れる文字列は前後に空白があって構いません。以下に、いくつかの例を示します::" -#: ../../library/fractions.rst:54 msgid "" ">>> from fractions import Fraction\n" ">>> Fraction(16, -10)\n" @@ -117,6 +128,30 @@ msgid "" ">>> Fraction(Decimal('1.1'))\n" "Fraction(11, 10)" msgstr "" +">>> from fractions import Fraction\n" +">>> Fraction(16, -10)\n" +"Fraction(-8, 5)\n" +">>> Fraction(123)\n" +"Fraction(123, 1)\n" +">>> Fraction()\n" +"Fraction(0, 1)\n" +">>> Fraction('3/7')\n" +"Fraction(3, 7)\n" +">>> Fraction(' -3/7 ')\n" +"Fraction(-3, 7)\n" +">>> Fraction('1.414213 \\t\\n')\n" +"Fraction(1414213, 1000000)\n" +">>> Fraction('-.125')\n" +"Fraction(-1, 8)\n" +">>> Fraction('7e-6')\n" +"Fraction(7, 1000000)\n" +">>> Fraction(2.25)\n" +"Fraction(9, 4)\n" +">>> Fraction(1.1)\n" +"Fraction(2476979795053773, 2251799813685248)\n" +">>> from decimal import Decimal\n" +">>> Fraction(Decimal('1.1'))\n" +"Fraction(11, 10)" #: ../../library/fractions.rst:80 msgid "" @@ -139,29 +174,35 @@ msgstr "" ":class:`Fraction` のコンストラクタが :class:`float` および :class:`decimal." "Decimal` インスタンスを受け付けるようになりました。" -#: ../../library/fractions.rst:90 msgid "" "The :func:`math.gcd` function is now used to normalize the *numerator* and " "*denominator*. :func:`math.gcd` always returns an :class:`int` type. " "Previously, the GCD type depended on *numerator* and *denominator*." msgstr "" +"*numerator* と *denominator* の正規化に :func:`math.gcd` 関数を使うようになり" +"ました。\n" +":func:`math.gcd` は常に :class:`int` 型を返します。\n" +"以前は最大公約数の型が *numerator* と *denominator* に依存していました。" -#: ../../library/fractions.rst:95 msgid "" "Underscores are now permitted when creating a :class:`Fraction` instance " "from a string, following :PEP:`515` rules." msgstr "" +"文字列から :class:`Fraction` インスタンスを作成する際に、:PEP:`515` の規則に" +"従ってアンダースコアを使えるようになりました。" -#: ../../library/fractions.rst:99 msgid "" ":class:`Fraction` implements ``__int__`` now to satisfy ``typing." "SupportsInt`` instance checks." msgstr "" +":class:`Fraction` は、``typing.SupportsInt`` のインスタンス検査を満たすよう " +"``__int__`` を実装しました。" -#: ../../library/fractions.rst:103 msgid "" "Space is allowed around the slash for string inputs: ``Fraction('2 / 3')``." msgstr "" +"文字列の入力で、``Fraction('2 / 3')`` のようにスラッシュの前後に空白を入れら" +"れるようになりました。" #: ../../library/fractions.rst:106 msgid "" @@ -170,42 +211,48 @@ msgid "" "``\"G\"`` and ``\"%\"\"``." msgstr "" -#: ../../library/fractions.rst:111 msgid "" "Formatting of :class:`Fraction` instances without a presentation type now " "supports fill, alignment, sign handling, minimum width and grouping." msgstr "" +"表現型を指定せずに :class:`Fraction` インスタンスを書式化する場合に、埋め文" +"字、配置、符号の処理、最小幅、桁のグループ化をサポートするようになりました。" -#: ../../library/fractions.rst:115 msgid "" "The :class:`Fraction` constructor now accepts any objects with the :meth:`!" "as_integer_ratio` method." msgstr "" +":class:`Fraction` コンストラクタが :meth:`!as_integer_ratio` メソッドを持つ任" +"意のオブジェクトを受け取れるようになりました。" #: ../../library/fractions.rst:121 msgid "Numerator of the Fraction in lowest term." msgstr "有理数を既約分数で表したときの分子。" -#: ../../library/fractions.rst:125 msgid "Denominator of the Fraction in lowest terms. Guaranteed to be positive." msgstr "" +"有理数を既約分数で表したときの分母です。\n" +"正であることが保証されています。" -#: ../../library/fractions.rst:131 msgid "" "Return a tuple of two integers, whose ratio is equal to the original " "Fraction. The ratio is in lowest terms and has a positive denominator." msgstr "" +"元の Fraction と等しい比を表す、2 つの整数のタプルを返します。\n" +"この比は既約で、分母は正です。" -#: ../../library/fractions.rst:139 msgid "Return ``True`` if the Fraction is an integer." -msgstr "" +msgstr "Fraction が整数なら ``True`` を返します。" -#: ../../library/fractions.rst:145 msgid "" "Alternative constructor which only accepts instances of :class:`float` or :" "class:`numbers.Integral`. Beware that ``Fraction.from_float(0.3)`` is not " "the same value as ``Fraction(3, 10)``." msgstr "" +":class:`float` または :class:`numbers.Integral` のインスタンスだけを受け取る" +"代替コンストラクタです。\n" +"``Fraction.from_float(0.3)`` は ``Fraction(3, 10)`` と同じ値ではないことに注" +"意してください。" #: ../../library/fractions.rst:151 msgid "" @@ -215,11 +262,12 @@ msgstr "" "Python 3.2 以降では、 :class:`float` から直接 :class:`Fraction` インスタンス" "を構築できるようになりました。" -#: ../../library/fractions.rst:157 msgid "" "Alternative constructor which only accepts instances of :class:`decimal." "Decimal` or :class:`numbers.Integral`." msgstr "" +":class:`decimal.Decimal` または :class:`numbers.Integral` のインスタンスだけ" +"を受け取る代替コンストラクタです。" #: ../../library/fractions.rst:162 msgid "" @@ -229,13 +277,16 @@ msgstr "" "Python 3.2 以降では、 :class:`decimal.Decimal` インスタンスから直接 :class:" "`Fraction` インスタンスを構築できるようになりました。" -#: ../../library/fractions.rst:169 msgid "" "Alternative constructor which only accepts instances of :class:`numbers." "Integral`, :class:`numbers.Rational`, :class:`float` or :class:`decimal." "Decimal`, and objects with the :meth:`!as_integer_ratio` method, but not " "strings." msgstr "" +":class:`numbers.Integral`、:class:`numbers.Rational`、:class:`float`、:class:" +"`decimal.Decimal` のインスタンス、および :meth:`!as_integer_ratio` メソッドを" +"持つオブジェクトだけを受け取る代替コンストラクタです。\n" +"文字列は受け取りません。" #: ../../library/fractions.rst:179 msgid "" @@ -280,14 +331,15 @@ msgstr "" "10**ndigits)`` の倍数 (論理的に、 ``ndigits`` が負なら) を、これも偶数丸めで" "丸めます。 :func:`round` 関数からでもアクセスできます。" -#: ../../library/fractions.rst:225 msgid "" "Provides support for formatting of :class:`Fraction` instances via the :meth:" "`str.format` method, the :func:`format` built-in function, or :ref:" "`Formatted string literals `." msgstr "" +":meth:`str.format` メソッド、組み込み関数 :func:`format`、:ref:`フォーマット" +"済み文字列リテラル ` による :class:`Fraction` インスタンスの書式化" +"をサポートします。" -#: ../../library/fractions.rst:229 msgid "" "If the ``format_spec`` format specification string does not end with one of " "the presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` " @@ -298,20 +350,29 @@ msgid "" "include an explicit denominator, even when the value being formatted is an " "exact integer. The zero-fill flag ``'0'`` is not supported." msgstr "" +"書式指定文字列 ``format_spec`` が表現型 ``'e'``、``'E'``、``'f'``、``'F'``、" +"``'g'``、``'G'``、``'%'`` のいずれでも終わらない場合は、:ref:`書式指定ミニ言" +"語 ` で説明する埋め文字、配置、符号の処理、最小幅、桁のグループ化" +"の一般的な規則に従って書式化します。\n" +"「別形式」のフラグ ``'#'`` をサポートします。\n" +"これを指定すると、書式化する値が厳密に整数であっても、出力文字列に常に分母を" +"明示します。\n" +"ゼロ埋めのフラグ ``'0'`` はサポートしません。" -#: ../../library/fractions.rst:239 msgid "" "If the ``format_spec`` format specification string ends with one of the " "presentation types ``'e'``, ``'E'``, ``'f'``, ``'F'``, ``'g'``, ``'G'`` or " "``'%'`` then formatting follows the rules outlined for the :class:`float` " "type in the :ref:`formatspec` section." msgstr "" +"書式指定文字列 ``format_spec`` が表現型 ``'e'``、``'E'``、``'f'``、``'F'``、" +"``'g'``、``'G'``、``'%'`` のいずれかで終わる場合は、:ref:`formatspec` 節に記" +"載された :class:`float` 型の規則に従って書式化します。" #: ../../library/fractions.rst:244 msgid "Here are some examples::" msgstr "ここに例があります::" -#: ../../library/fractions.rst:246 msgid "" ">>> from fractions import Fraction\n" ">>> format(Fraction(103993, 33102), '_')\n" @@ -332,6 +393,24 @@ msgid "" ">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" "'34.67% price increase'" msgstr "" +">>> from fractions import Fraction\n" +">>> format(Fraction(103993, 33102), '_')\n" +"'103_993/33_102'\n" +">>> format(Fraction(1, 7), '.^+10')\n" +"'...+1/7...'\n" +">>> format(Fraction(3, 1), '')\n" +"'3'\n" +">>> format(Fraction(3, 1), '#')\n" +"'3/1'\n" +">>> format(Fraction(1, 7), '.40g')\n" +"'0.1428571428571428571428571428571428571429'\n" +">>> format(Fraction('1234567.855'), '_.2f')\n" +"'1_234_567.86'\n" +">>> f\"{Fraction(355, 113):*>20.6e}\"\n" +"'********3.141593e+00'\n" +">>> old_price, new_price = 499, 672\n" +">>> \"{:.2%} price increase\".format(Fraction(new_price, old_price) - 1)\n" +"'34.67% price increase'" #: ../../library/fractions.rst:268 msgid "Module :mod:`numbers`" @@ -341,6 +420,5 @@ msgstr ":mod:`numbers` モジュール" msgid "The abstract base classes making up the numeric tower." msgstr "数値の塔を作り上げる抽象基底クラス。" -#: ../../library/fractions.rst:17 msgid "as_integer_ratio()" -msgstr "" +msgstr "as_integer_ratio()" diff --git a/library/frameworks.po b/library/frameworks.po index c75da3991..f0f17cea5 100644 --- a/library/frameworks.po +++ b/library/frameworks.po @@ -12,30 +12,29 @@ msgstr "" "PO-Revision-Date: 2025-09-16 00:01+0000\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/frameworks.rst:7 msgid "Program frameworks" -msgstr "" +msgstr "プログラムフレームワーク" -#: ../../library/frameworks.rst:9 msgid "" "This chapter is no longer maintained, and the modules it contained have been " "moved to their respective topical documentation." msgstr "" +"この章はメンテナンスされなくなり、ここに含まれていたモジュールはそれぞれの分" +"野のドキュメントに移動しました。" -#: ../../library/frameworks.rst:11 msgid ":mod:`cmd` — :doc:`Command Line Interface Libraries <./cmdlinelibs>`" msgstr "" +":mod:`cmd` — :doc:`コマンドラインインターフェースライブラリ <./cmdlinelibs>`" -#: ../../library/frameworks.rst:12 msgid ":mod:`shlex` — :doc:`Unix Specific Services <./unix>`" -msgstr "" +msgstr ":mod:`shlex` — :doc:`Unix 固有のサービス <./unix>`" -#: ../../library/frameworks.rst:13 msgid ":mod:`turtle` — :doc:`Graphical User Interfaces with Tk <./tk>`" msgstr "" +":mod:`turtle` — :doc:`Tk を用いたグラフィカルユーザーインターフェース <./tk>`" diff --git a/library/ftplib.po b/library/ftplib.po index 95941b6fe..6bb838ce1 100644 --- a/library/ftplib.po +++ b/library/ftplib.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/ftplib.rst:2 @@ -47,13 +47,11 @@ msgstr "" "使っています。 FTP (File Transfer Protocol)についての詳しい情報はinternet :" "rfc:`959` を参照して下さい。" -#: ../../library/ftplib.rst:22 msgid "The default encoding is UTF-8, following :rfc:`2640`." -msgstr "" +msgstr "デフォルトのエンコーディングは :rfc:`2640` に従い UTF-8 です。" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -63,11 +61,9 @@ msgstr "" "このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、:ref:" "`wasm-availability` を見てください。" -#: ../../library/ftplib.rst:26 msgid "Here's a sample session using the :mod:`!ftplib` module::" -msgstr "" +msgstr ":mod:`!ftplib` モジュールを使ったセッションの例を示します。 ::" -#: ../../library/ftplib.rst:28 msgid "" ">>> from ftplib import FTP\n" ">>> ftp = FTP('ftp.us.debian.org') # connect to host, default port\n" @@ -88,6 +84,25 @@ msgid "" ">>> ftp.quit()\n" "'221 Goodbye.'" msgstr "" +">>> from ftplib import FTP\n" +">>> ftp = FTP('ftp.us.debian.org') # デフォルトのポートでホストに接続\n" +">>> ftp.login() # ユーザー名 anonymous、パスワード " +"anonymous@\n" +"'230 Login successful.'\n" +">>> ftp.cwd('debian') # \"debian\" ディレクトリに移動\n" +"'250 Directory successfully changed.'\n" +">>> ftp.retrlines('LIST') # ディレクトリの内容を一覧表示\n" +"-rw-rw-r-- 1 1176 1176 1063 Jun 15 10:18 README\n" +"...\n" +"drwxr-sr-x 5 1176 1176 4096 Dec 19 2000 pool\n" +"drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project\n" +"drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools\n" +"'226 Directory send OK.'\n" +">>> with open('README', 'wb') as fp:\n" +">>> ftp.retrbinary('RETR README', fp.write)\n" +"'226 Transfer complete.'\n" +">>> ftp.quit()\n" +"'221 Goodbye.'" #: ../../library/ftplib.rst:51 msgid "Reference" @@ -97,19 +112,19 @@ msgstr "リファレンス" msgid "FTP objects" msgstr "FTP オブジェクト" -#: ../../library/ftplib.rst:87 msgid "Return a new instance of the :class:`FTP` class." -msgstr "" +msgstr ":class:`FTP` クラスの新しいインスタンスを返します。" #: ../../library/ftplib.rst:0 msgid "Parameters" msgstr "パラメーター" -#: ../../library/ftplib.rst:89 ../../library/ftplib.rst:461 msgid "" "The hostname to connect to. If given, :code:`connect(host)` is implicitly " "called by the constructor." msgstr "" +"接続先のホスト名。\n" +"指定した場合、コンストラクタが暗黙に :code:`connect(host)` を呼び出します。" #: ../../library/ftplib.rst:93 ../../library/ftplib.rst:465 msgid "" @@ -117,30 +132,24 @@ msgid "" "called by the constructor." msgstr "" -#: ../../library/ftplib.rst:98 ../../library/ftplib.rst:212 -#: ../../library/ftplib.rst:470 msgid "|param_doc_passwd|" -msgstr "" +msgstr "|param_doc_passwd|" -#: ../../library/ftplib.rst:101 ../../library/ftplib.rst:215 -#: ../../library/ftplib.rst:473 msgid "|param_doc_acct|" -msgstr "" +msgstr "|param_doc_acct|" -#: ../../library/ftplib.rst:104 msgid "" "A timeout in seconds for blocking operations like :meth:`connect` (default: " "the global default timeout setting)." msgstr "" +":meth:`connect` などのブロックする操作のタイムアウトを秒単位で指定します (デ" +"フォルト: グローバルなデフォルトのタイムアウト設定)。" -#: ../../library/ftplib.rst:109 ../../library/ftplib.rst:183 -#: ../../library/ftplib.rst:488 msgid "|param_doc_source_address|" -msgstr "" +msgstr "|param_doc_source_address|" -#: ../../library/ftplib.rst:113 ../../library/ftplib.rst:492 msgid "|param_doc_encoding|" -msgstr "" +msgstr "|param_doc_encoding|" #: ../../library/ftplib.rst:116 msgid "The :class:`FTP` class supports the :keyword:`with` statement, e.g.:" @@ -154,80 +163,93 @@ msgstr ":keyword:`with` 構文のサポートが追加されました。" msgid "*source_address* parameter was added." msgstr "*source_address* 引数が追加されました。" -#: ../../library/ftplib.rst:136 ../../library/ftplib.rst:505 msgid "" "If the *timeout* parameter is set to be zero, it will raise a :class:" "`ValueError` to prevent the creation of a non-blocking socket. The " "*encoding* parameter was added, and the default was changed from Latin-1 to " "UTF-8 to follow :rfc:`2640`." msgstr "" +"*timeout* 引数にゼロを指定すると、非ブロッキングソケットの作成を防ぐために :" +"class:`ValueError` を送出するようになりました。\n" +"*encoding* 引数が追加され、:rfc:`2640` に従ってデフォルトが Latin-1 から " +"UTF-8 に変更されました。" -#: ../../library/ftplib.rst:142 msgid "" "Several :class:`!FTP` methods are available in two flavors: one for handling " "text files and another for binary files. The methods are named for the " "command which is used followed by ``lines`` for the text version or " "``binary`` for the binary version." msgstr "" +":class:`!FTP` のいくつかのメソッドには、テキストファイル用とバイナリファイル" +"用の 2 種類があります。\n" +"メソッド名は、使用するコマンドに、テキスト用では ``lines``、バイナリ用では " +"``binary`` を付けたものです。" #: ../../library/ftplib.rst:147 msgid ":class:`FTP` instances have the following methods:" msgstr ":class:`FTP` インスタンスには以下のメソッドがあります:" -#: ../../library/ftplib.rst:151 msgid "" "Set the instance's debugging level as an :class:`int`. This controls the " "amount of debugging output printed. The debug levels are:" msgstr "" +"インスタンスのデバッグレベルを :class:`int` で設定します。\n" +"この値はデバッグ出力の量を制御します。\n" +"デバッグレベルは次のとおりです。" -#: ../../library/ftplib.rst:155 msgid "``0`` (default): No debug output." -msgstr "" +msgstr "``0`` (デフォルト): デバッグ出力を行いません。" -#: ../../library/ftplib.rst:156 msgid "" "``1``: Produce a moderate amount of debug output, generally a single line " "per request." msgstr "" +"``1``: 適度な量のデバッグ出力を行います。\n" +"通常はリクエストごとに 1 行です。" -#: ../../library/ftplib.rst:158 msgid "" "``2`` or higher: Produce the maximum amount of debugging output, logging " "each line sent and received on the control connection." msgstr "" +"``2`` 以上: 最大量のデバッグ出力を行い、制御接続で送受信する各行を記録しま" +"す。" -#: ../../library/ftplib.rst:163 msgid "" "Connect to the given host and port. This function should be called only once " "for each instance; it should not be called if a *host* argument was given " "when the :class:`FTP` instance was created. All other :class:`!FTP` methods " "can only be called after a connection has successfully been made." msgstr "" +"指定したホストとポートに接続します。\n" +"この関数はインスタンスごとに 1 回だけ呼び出してください。\n" +":class:`FTP` インスタンスの作成時に *host* 引数を指定した場合は呼び出さないで" +"ください。\n" +"ほかのすべての :class:`!FTP` メソッドは、接続が成功してから呼び出せます。" -#: ../../library/ftplib.rst:170 msgid "The host to connect to." -msgstr "" +msgstr "接続先のホスト。" -#: ../../library/ftplib.rst:173 msgid "" "The TCP port to connect to (default: ``21``, as specified by the FTP " "protocol specification). It is rarely needed to specify a different port " "number." msgstr "" +"接続先の TCP ポート (デフォルト: FTP プロトコルの仕様で定められた ``21``)。\n" +"別のポート番号を指定する必要はほとんどありません。" -#: ../../library/ftplib.rst:178 msgid "" "A timeout in seconds for the connection attempt (default: the global default " "timeout setting)." msgstr "" +"接続試行のタイムアウトを秒単位で指定します (デフォルト: グローバルなデフォル" +"トのタイムアウト設定)。" -#: ../../library/ftplib.rst:187 msgid "" "Raises an :ref:`auditing event ` ``ftplib.connect`` with arguments " "``self``, ``host``, ``port``." msgstr "" "引数 ``self``, ``host``, ``port`` を指定して :ref:`監査イベント ` " -"``ftplib.connect`` を送出します。 " +"``ftplib.connect`` を送出します。" #: ../../library/ftplib.rst:195 msgid "" @@ -239,7 +261,6 @@ msgstr "" "(このメッセージには時に、ユーザにとって重要な免責事項や ヘルプ情報が入ってい" "ます。)" -#: ../../library/ftplib.rst:202 msgid "" "Log on to the connected FTP server. This function should be called only once " "for each instance, after a connection has been established; it should not be " @@ -247,10 +268,14 @@ msgid "" "instance was created. Most FTP commands are only allowed after the client " "has logged in." msgstr "" +"接続中の FTP サーバーにログインします。\n" +"この関数は接続が確立した後、インスタンスごとに 1 回だけ呼び出してください。\n" +":class:`FTP` インスタンスの作成時に *host* と *user* 引数を指定した場合は呼び" +"出さないでください。\n" +"ほとんどの FTP コマンドは、クライアントがログインした後でのみ使用できます。" -#: ../../library/ftplib.rst:209 msgid "|param_doc_user|" -msgstr "" +msgstr "|param_doc_user|" #: ../../library/ftplib.rst:221 msgid "" @@ -265,49 +290,53 @@ msgid "" "Send a simple command string to the server and return the response string." msgstr "シンプルなコマンド文字列をサーバに送信して、受信した文字列を返します。" -#: ../../library/ftplib.rst:229 ../../library/ftplib.rst:238 msgid "" "Raises an :ref:`auditing event ` ``ftplib.sendcmd`` with arguments " "``self``, ``cmd``." msgstr "" "引数 ``self``, ``cmd`` を指定して :ref:`監査イベント ` ``ftplib." -"sendcmd`` を送出します。 " +"sendcmd`` を送出します。" -#: ../../library/ftplib.rst:234 msgid "" "Send a simple command string to the server and handle the response. Return " "the response string if the response code corresponds to success (codes in " "the range 200--299). Raise :exc:`error_reply` otherwise." msgstr "" +"単純なコマンド文字列をサーバーに送信し、応答を処理します。\n" +"応答コードが成功を表す場合 (200〜299 のコード) は応答文字列を返します。\n" +"それ以外の場合は :exc:`error_reply` を送出します。" -#: ../../library/ftplib.rst:243 msgid "Retrieve a file in binary transfer mode." -msgstr "" +msgstr "バイナリ転送モードでファイルを取得します。" -#: ../../library/ftplib.rst:245 msgid "An appropriate ``RETR`` command: :samp:`\"RETR {filename}\"`." -msgstr "" +msgstr "適切な ``RETR`` コマンド: :samp:`\"RETR {filename}\"`。" -#: ../../library/ftplib.rst:248 msgid "" "A single parameter callable that is called for each block of data received, " "with its single argument being the data as :class:`bytes`." msgstr "" +"受信したデータのブロックごとに呼び出される、引数を 1 つ取る呼び出し可能オブ" +"ジェクト。\n" +"その引数には :class:`bytes` としてデータが渡されます。" -#: ../../library/ftplib.rst:254 msgid "" "The maximum chunk size to read on the low-level :class:`~socket.socket` " "object created to do the actual transfer. This also corresponds to the " "largest size of data that will be passed to *callback*. Defaults to ``8192``." msgstr "" +"実際の転送用に作成される低水準の :class:`~socket.socket` オブジェクトから読み" +"取るチャンクの最大サイズ。\n" +"*callback* に渡すデータの最大サイズでもあります。\n" +"デフォルトは ``8192`` です。" -#: ../../library/ftplib.rst:261 ../../library/ftplib.rst:308 msgid "" "A ``REST`` command to be sent to the server. See the documentation for the " "*rest* parameter of the :meth:`transfercmd` method." msgstr "" +"サーバーに送信する ``REST`` コマンド。\n" +":meth:`transfercmd` メソッドの *rest* 引数の説明を参照してください。" -#: ../../library/ftplib.rst:268 msgid "" "Retrieve a file or directory listing in the encoding specified by the " "*encoding* parameter at initialization. *cmd* should be an appropriate " @@ -318,6 +347,16 @@ msgid "" "argument containing the line with the trailing CRLF stripped. The default " "*callback* prints the line to :data:`sys.stdout`." msgstr "" +"初期化時に *encoding* 引数で指定したエンコーディングで、ファイルまたはディレ" +"クトリ一覧を取得します。\n" +"*cmd* には適切な ``RETR`` コマンド (:meth:`retrbinary` を参照)、または " +"``LIST`` や ``NLST`` などのコマンドを指定してください (通常は単に文字列 " +"``'LIST'``)。\n" +"``LIST`` はファイルの一覧とそれらのファイルに関する情報を取得します。\n" +"``NLST`` はファイル名の一覧を取得します。\n" +"各行について *callback* 関数を呼び出し、末尾の CRLF を除いた行を文字列の引数" +"として渡します。\n" +"デフォルトの *callback* は、その行を :data:`sys.stdout` に出力します。" #: ../../library/ftplib.rst:281 msgid "" @@ -327,36 +366,37 @@ msgstr "" "*val* が真の場合 \"パッシブ\" モードを有効化し、偽の場合は無効化します。 デ" "フォルトではパッシブモードです。" -#: ../../library/ftplib.rst:287 msgid "Store a file in binary transfer mode." -msgstr "" +msgstr "バイナリ転送モードでファイルを保存します。" -#: ../../library/ftplib.rst:289 msgid "An appropriate ``STOR`` command: :samp:`\"STOR {filename}\"`." -msgstr "" +msgstr "適切な ``STOR`` コマンド: :samp:`\"STOR {filename}\"`。" -#: ../../library/ftplib.rst:292 msgid "" "A file object (opened in binary mode) which is read until EOF, using its :" "meth:`~io.RawIOBase.read` method in blocks of size *blocksize* to provide " "the data to be stored." msgstr "" +"バイナリモードで開かれたファイルオブジェクト。\n" +":meth:`~io.RawIOBase.read` メソッドで *blocksize* サイズのブロックごとに EOF " +"まで読み取り、保存するデータを供給します。" -#: ../../library/ftplib.rst:298 msgid "The read block size. Defaults to ``8192``." msgstr "" +"読み取るブロックのサイズ。\n" +"デフォルトは ``8192`` です。" -#: ../../library/ftplib.rst:302 msgid "" "A single parameter callable that is called for each block of data sent, with " "its single argument being the data as :class:`bytes`." msgstr "" +"データのブロックを送信するたびに呼び出される、引数を 1 つ取る呼び出し可能オブ" +"ジェクト。\n" +"その引数には :class:`bytes` としてデータが渡されます。" -#: ../../library/ftplib.rst:312 msgid "The *rest* parameter was added." -msgstr "" +msgstr "*rest* 引数が追加されました。" -#: ../../library/ftplib.rst:318 msgid "" "Store a file in line mode. *cmd* should be an appropriate ``STOR`` command " "(see :meth:`storbinary`). Lines are read until EOF from the :term:`file " @@ -364,8 +404,15 @@ msgid "" "method to provide the data to be stored. *callback* is an optional single " "parameter callable that is called on each line after it is sent." msgstr "" +"行モードでファイルを保存します。\n" +"*cmd* には適切な ``STOR`` コマンドを指定してください (:meth:`storbinary` を参" +"照)。\n" +"バイナリモードで開かれた :term:`file object` *fp* の :meth:`~io.IOBase." +"readline` メソッドを使い、EOF まで行を読み取って保存するデータを供給しま" +"す。\n" +"*callback* は引数を 1 つ取る省略可能な呼び出し可能オブジェクトで、各行の送信" +"後に呼び出されます。" -#: ../../library/ftplib.rst:327 msgid "" "Initiate a transfer over the data connection. If the transfer is active, " "send an ``EPRT`` or ``PORT`` command and the transfer command specified by " @@ -373,12 +420,13 @@ msgid "" "``EPSV`` or ``PASV`` command, connect to it, and start the transfer " "command. Either way, return the socket for the connection." msgstr "" -"データ接続中に転送を初期化します。もし転送中なら、``EPRT`` あるいは ``PORT`` " -"コマンドと、*cmd* で指定したコマンドを送信し、接続を続けます。サーバがパッシ" -"ブなら、``EPSV`` あるいは ``PASV`` コマンドを送信して接続し、転送コマンドを開" -"始します。どちらの場合も、接続のためのソケットを返します。" +"データ接続での転送を開始します。\n" +"アクティブモードの場合は ``EPRT`` または ``PORT`` コマンドと、*cmd* で指定さ" +"れた転送コマンドを送信して、接続を受け入れます。\n" +"パッシブモードの場合は ``EPSV`` または ``PASV`` コマンドを送信してサーバーに" +"接続し、転送コマンドを開始します。\n" +"どちらの場合も、その接続のソケットを返します。" -#: ../../library/ftplib.rst:333 msgid "" "If optional *rest* is given, a ``REST`` command is sent to the server, " "passing *rest* as an argument. *rest* is usually a byte offset into the " @@ -390,19 +438,27 @@ msgid "" "command, an :exc:`error_reply` exception will be raised. If this happens, " "simply call :meth:`transfercmd` without a *rest* argument." msgstr "" +"省略可能な *rest* を指定すると、その値を引数として ``REST`` コマンドをサー" +"バーに送信します。\n" +"通常、*rest* は要求するファイル内のバイトオフセットであり、ファイルの先頭部分" +"を飛ばして、指定した位置から送信を再開するようサーバーに指示します。\n" +"ただし :meth:`transfercmd` メソッドは、初期化時の *encoding* 引数を使って " +"*rest* を文字列に変換するだけで、その内容は検査しません。\n" +"サーバーが ``REST`` コマンドを認識しない場合は :exc:`error_reply` 例外を送出" +"します。\n" +"その場合は *rest* 引数を指定せずに :meth:`transfercmd` を呼び出してください。" -#: ../../library/ftplib.rst:346 msgid "" "Like :meth:`transfercmd`, but returns a tuple of the data connection and the " "expected size of the data. If the expected size could not be computed, " "``None`` will be returned as the expected size. *cmd* and *rest* means the " "same thing as in :meth:`transfercmd`." msgstr "" -":meth:`transfercmd` と同様ですが、データと予想されるサイズとのタプルを返しま" -"す。もしサイズが計算できないなら、サイズの代わりに ``None`` が返されます。 " -"*cmd* と *rest* は :meth:`transfercmd` のものと同じです。" +":meth:`transfercmd` と同様ですが、データ接続と転送データの予想サイズのタプル" +"を返します。\n" +"予想サイズを計算できない場合、その要素は ``None`` になります。\n" +"*cmd* と *rest* の意味は :meth:`transfercmd` と同じです。" -#: ../../library/ftplib.rst:354 msgid "" "List a directory in a standardized format by using ``MLSD`` command (:rfc:" "`3659`). If *path* is omitted the current directory is assumed. *facts* is " @@ -413,6 +469,16 @@ msgid "" "name. Content of this dictionary might be limited by the *facts* argument " "but server is not guaranteed to return all requested facts." msgstr "" +"``MLSD`` コマンド (:rfc:`3659`) を使い、標準化された形式でディレクトリを一覧" +"表示します。\n" +"*path* を省略するとカレントディレクトリを対象とします。\n" +"*facts* は必要な情報の種類を表す文字列のリストです (例: ``[\"type\", " +"\"size\", \"perm\"]``)。\n" +"``path`` に見つかったファイルごとに 2 要素のタプルを yield するジェネレータオ" +"ブジェクトを返します。\n" +"最初の要素はファイル名、2 番目の要素はそのファイルの情報を含む辞書です。\n" +"この辞書の内容は *facts* 引数で制限できる場合がありますが、要求したすべての情" +"報をサーバーが返す保証はありません。" #: ../../library/ftplib.rst:368 msgid "" @@ -426,11 +492,11 @@ msgstr "" "トディレクトリです)。 ``NLST`` コマンドに非標準である複数の引数を渡すことが" "できます。" -#: ../../library/ftplib.rst:373 ../../library/ftplib.rst:385 msgid "If your server supports the command, :meth:`mlsd` offers a better API." msgstr "" +"サーバーがこのコマンドをサポートしている場合は、:meth:`mlsd` の方が優れた " +"API を提供します。" -#: ../../library/ftplib.rst:378 msgid "" "Produce a directory listing as returned by the ``LIST`` command, printing it " "to standard output. The optional *argument* is a directory to list (default " @@ -439,20 +505,28 @@ msgid "" "function, it is used as a *callback* function as for :meth:`retrlines`; the " "default prints to :data:`sys.stdout`. This method returns ``None``." msgstr "" +"``LIST`` コマンドが返すディレクトリ一覧を標準出力に表示します。\n" +"省略可能な *argument* は一覧表示するディレクトリです (デフォルトはサーバーの" +"カレントディレクトリ)。\n" +"複数の引数を使って、非標準のオプションを ``LIST`` コマンドに渡せます。\n" +"最後の引数が関数の場合は、:meth:`retrlines` と同様に *callback* 関数として使" +"います。\n" +"デフォルトでは :data:`sys.stdout` に表示します。\n" +"このメソッドは ``None`` を返します。" #: ../../library/ftplib.rst:390 msgid "Rename file *fromname* on the server to *toname*." msgstr "サーバ上のファイルのファイル名 *fromname* を *toname* へ変更します。" -#: ../../library/ftplib.rst:395 msgid "" "Remove the file named *filename* from the server. If successful, returns " "the text of the response, otherwise raises :exc:`error_perm` on permission " "errors or :exc:`error_reply` on other errors." msgstr "" -"サーバからファイル *filename* を削除します。成功したら応答のテキストを返し、" -"そうでないならパーミッションエラーでは :exc:`error_perm` を、他のエラーでは :" -"exc:`error_reply` を返します。" +"サーバーから *filename* という名前のファイルを削除します。\n" +"成功した場合は応答のテキストを返します。\n" +"失敗した場合は、権限のエラーなら :exc:`error_perm`、それ以外のエラーなら :" +"exc:`error_reply` を送出します。" #: ../../library/ftplib.rst:402 msgid "Set the current directory on the server." @@ -481,7 +555,6 @@ msgstr "" "整数で返され、そうでないなら ``None`` が返されます。 ``SIZE`` コマンドは標準" "化されていませんが、多くの普通のサーバで実装されていることに注意して下さい。" -#: ../../library/ftplib.rst:430 msgid "" "Send a ``QUIT`` command to the server and close the connection. This is the " "\"polite\" way to close a connection, but it may raise an exception if the " @@ -489,11 +562,11 @@ msgid "" "to the :meth:`close` method which renders the :class:`FTP` instance useless " "for subsequent calls (see below)." msgstr "" -"サーバに ``QUIT`` コマンドを送信し、接続を閉じます。これは接続を閉じるのに" -"\"礼儀正しい\"方法ですが、 ``QUIT`` コマンドに反応してサーバの例外が発生する" -"かもしれません。この例外は、 :meth:`close` メソッドによって :class:`FTP` イン" -"スタンスに対するその後のコマンド使用が不可になっていることを示しています(下" -"記参照)。" +"サーバーに ``QUIT`` コマンドを送信して接続を閉じます。\n" +"これは接続を閉じる「礼儀正しい」方法ですが、サーバーが ``QUIT`` コマンドにエ" +"ラーを返した場合には例外が送出されることがあります。\n" +"この処理では :meth:`close` メソッドも呼び出されるため、その後は :class:`FTP` " +"インスタンスを使えなくなります (下記参照)。" #: ../../library/ftplib.rst:439 msgid "" @@ -513,54 +586,55 @@ msgstr "" msgid "FTP_TLS objects" msgstr "FTP_TLS オブジェクト" -#: ../../library/ftplib.rst:452 msgid "" "An :class:`FTP` subclass which adds TLS support to FTP as described in :rfc:" "`4217`. Connect to port 21 implicitly securing the FTP control connection " "before authenticating." msgstr "" +":rfc:`4217` に従って FTP に TLS サポートを追加する :class:`FTP` のサブクラス" +"です。\n" +"ポート 21 に接続し、認証前に FTP の制御接続を暗黙に保護します。" -#: ../../library/ftplib.rst:458 msgid "" "The user must explicitly secure the data connection by calling the :meth:" "`prot_p` method." msgstr "" +"データ接続は、利用者が :meth:`prot_p` メソッドを呼び出して明示的に保護する必" +"要があります。" -#: ../../library/ftplib.rst:476 msgid "" "An SSL context object which allows bundling SSL configuration options, " "certificates and private keys into a single, potentially long-lived, " "structure. Please read :ref:`ssl-security` for best practices." msgstr "" +"SSL の設定オプション、証明書、秘密鍵を、長期間使用できる単一の構造にまとめる " +"SSL コンテキストオブジェクトです。\n" +"推奨される使用方法については :ref:`ssl-security` を参照してください。" -#: ../../library/ftplib.rst:483 msgid "" "A timeout in seconds for blocking operations like :meth:`~FTP.connect` " "(default: the global default timeout setting)." msgstr "" +":meth:`~FTP.connect` などのブロックする操作のタイムアウトを秒単位で指定しま" +"す (デフォルト: グローバルなデフォルトのタイムアウト設定)。" -#: ../../library/ftplib.rst:497 msgid "Added the *source_address* parameter." -msgstr "" +msgstr "*source_address* 引数が追加されました。" -#: ../../library/ftplib.rst:500 msgid "" "The class now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" -"このクラスは :attr:`ssl.SSLContext.check_hostname` と *Server Name " -"Indication* でホスト名のチェックをサポートしました。(:const:`ssl.HAS_SNI` を" -"参照してください)。" +"このクラスは :attr:`ssl.SSLContext.check_hostname` によるホスト名の検証と、" +"*Server Name Indication* に対応しました (:const:`ssl.HAS_SNI` を参照)。" #: ../../library/ftplib.rst:511 msgid "The deprecated *keyfile* and *certfile* parameters have been removed." msgstr "非推奨の *keyfile* と *certfile* 引数を削除しました。" -#: ../../library/ftplib.rst:514 msgid "Here's a sample session using the :class:`FTP_TLS` class::" -msgstr ":class:`FTP_TLS` クラスを使ったサンプルセッションはこちらです:" +msgstr ":class:`FTP_TLS` クラスを使ったセッションの例を示します。 ::" -#: ../../library/ftplib.rst:516 msgid "" ">>> ftps = FTP_TLS('ftp.pureftpd.org')\n" ">>> ftps.login()\n" @@ -576,33 +650,49 @@ msgid "" "'public_keys', 'pure-ftpd', 'qscan', 'qtc', 'sharedance', 'skycache', " "'sound', 'tmp', 'ucarp']" msgstr "" +">>> ftps = FTP_TLS('ftp.pureftpd.org')\n" +">>> ftps.login()\n" +"'230 Anonymous user logged in'\n" +">>> ftps.prot_p()\n" +"'200 Data protection level set to \"private\"'\n" +">>> ftps.nlst()\n" +"['6jack', 'OpenBSD', 'antilink', 'blogbench', 'bsdcam', 'clockspeed', " +"'djbdns-jedi', 'docs', 'eaccelerator-jedi', 'favicon.ico', 'francotone', " +"'fugu', 'ignore', 'libpuzzle', 'metalog', 'minidentd', 'misc', 'mysql-udf-" +"global-user-variables', 'php-jenkins-hash', 'php-skein-hash', 'php-webdav', " +"'phpaudit', 'phpbench', 'pincaster', 'ping', 'posto', 'pub', 'public', " +"'public_keys', 'pure-ftpd', 'qscan', 'qtc', 'sharedance', 'skycache', " +"'sound', 'tmp', 'ucarp']" -#: ../../library/ftplib.rst:524 msgid "" ":class:`!FTP_TLS` class inherits from :class:`FTP`, defining these " "additional methods and attributes:" msgstr "" +":class:`!FTP_TLS` クラスは :class:`FTP` を継承し、次のメソッドと属性を追加で" +"定義します。" -#: ../../library/ftplib.rst:529 msgid "Set up a secure control connection by using TLS." -msgstr "" +msgstr "TLS を使って安全な制御接続を確立します。" -#: ../../library/ftplib.rst:531 msgid "" "The method now supports hostname check with :attr:`ssl.SSLContext." "check_hostname` and *Server Name Indication* (see :const:`ssl.HAS_SNI`)." msgstr "" +"このメソッドは :attr:`ssl.SSLContext.check_hostname` によるホスト名の検証と、" +"*Server Name Indication* (:const:`ssl.HAS_SNI` を参照) をサポートするようにな" +"りました。" -#: ../../library/ftplib.rst:538 msgid "" "Revert control channel back to plaintext. This can be useful to take " "advantage of firewalls that know how to handle NAT with non-secure FTP " "without opening fixed ports." msgstr "" +"制御チャネルを平文に戻します。\n" +"暗号化されていない FTP の NAT を処理できるファイアウォールで、固定ポートを開" +"かずにその機能を利用する場合に役立ちます。" -#: ../../library/ftplib.rst:546 msgid "Set up secure data connection by using TLS." -msgstr "" +msgstr "TLS を使って安全なデータ接続を確立します。" #: ../../library/ftplib.rst:550 msgid "Set up clear text data connection." @@ -641,17 +731,16 @@ msgstr "" "File Transfer Protocol の応答仕様に適合しない、すなわち1--5の数字で始まらない" "応答コードをサーバから受け取った時に発生する例外。" -#: ../../library/ftplib.rst:582 msgid "" "The set of all exceptions (as a tuple) that methods of :class:`FTP` " "instances may raise as a result of problems with the FTP connection (as " "opposed to programming errors made by the caller). This set includes the " "four exceptions listed above as well as :exc:`OSError` and :exc:`EOFError`." msgstr "" -":class:`FTP` インスタンスのメソッド実行時、FTP接続で (プログラミングのエラー" -"と考えられるメソッドの実行によって) 発生する全ての例外 (タプル形式)。この例外" -"には以上の4つのエラーはもちろん、 :exc:`OSError` と :exc:`EOFError` も含まれ" -"ます。" +":class:`FTP` インスタンスのメソッドが FTP 接続の問題によって送出する可能性の" +"ある例外を、すべてまとめたタプルです。\n" +"呼び出し側のプログラミング上の誤りによる例外は含みません。\n" +"上記の 4 つの例外に加え、:exc:`OSError` と :exc:`EOFError` も含まれます。" #: ../../library/ftplib.rst:590 msgid "Module :mod:`netrc`" @@ -675,6 +764,5 @@ msgstr "FTP" msgid "protocol" msgstr "プロトコル" -#: ../../library/ftplib.rst:9 msgid "ftplib (standard module)" -msgstr "" +msgstr "ftplib (標準モジュール)" diff --git a/library/functional.po b/library/functional.po index dc4899a31..f941686dd 100644 --- a/library/functional.po +++ b/library/functional.po @@ -16,23 +16,22 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/functional.rst:3 msgid "Functional Programming Modules" msgstr "関数型プログラミング用モジュール" -#: ../../library/functional.rst:5 msgid "" "The modules described in this chapter provide functions and classes that " "support a functional programming style, and general operations on callables." msgstr "" -"この章では、関数型プログラミングスタイルをサポートする呼び出し可能で汎用な操" -"作を実現する関数やクラスについて説明します。" +"この章で説明するモジュールは、関数型プログラミングのスタイルをサポートする関" +"数やクラスと、呼び出し可能オブジェクトに対する汎用的な操作を提供します。" #: ../../library/functional.rst:8 msgid "The following modules are documented in this chapter:" diff --git a/library/functions.po b/library/functions.po index 32f437472..02d523404 100644 --- a/library/functions.po +++ b/library/functions.po @@ -19,10 +19,10 @@ msgstr "" "Last-Translator: TENMYO Masakazu, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/functions.rst:5 ../../library/functions.rst:11 @@ -454,11 +454,14 @@ msgstr "" " return False\n" " return True" -#: ../../library/functions.rst:91 msgid "" "When awaited, return the next item from the given :term:`asynchronous " "iterator`, or *default* if given and the iterator is :term:`exhausted`." msgstr "" +"待ち受けると、指定した :term:`非同期イテレータ ` の次" +"の要素を返します。\n" +"イテレータが :term:`枯渇して ` おり、*default* が指定されている場" +"合は、その値を返します。" #: ../../library/functions.rst:94 msgid "" @@ -466,7 +469,6 @@ msgid "" msgstr "" "これは組み込みの :func:`next` 関数の非同期版であり、同じように動作します。" -#: ../../library/functions.rst:97 msgid "" "This calls the :meth:`~object.__anext__` method of *async_iterator*, " "returning an :term:`awaitable`. Awaiting this returns the next value of the " @@ -474,10 +476,10 @@ msgid "" "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" "これは *async_iterator* の :meth:`~object.__anext__` メソッドを呼び出し、待ち" -"受け可能オブジェクト (:term:`awaitable`) を返します。待ち受けることによりイテ" -"レータの次の値を返します。 *default* が与えられた場合、イテレータが枯渇したと" -"きにその値が返されます。 *default* が与えられない場合は :exc:" -"`StopAsyncIteration` が送出されます。" +"受け可能オブジェクト (:term:`awaitable`) を返します。\n" +"これを待ち受けると、イテレータの次の値が返されます。\n" +"イテレータが枯渇した場合、*default* が指定されていればその値が返され、\n" +"指定されていなければ :exc:`StopAsyncIteration` が送出されます。" #: ../../library/functions.rst:106 msgid "" @@ -501,17 +503,16 @@ msgstr "" " return True\n" " return False" -#: ../../library/functions.rst:118 msgid "" "As :func:`repr`, return a string containing a printable representation of an " "object, but escape the non-ASCII characters in the string returned by :func:" "`repr` using ``\\x``, ``\\u``, or ``\\U`` escapes. This generates a string " "similar to that returned by :func:`repr` in Python 2." msgstr "" -":func:`repr` と同様、オブジェクトの印字可能な表現を含む文字列を返しますが、:" -"func:`repr` によって返された文字列中の非 ASCII 文字は ``\\x`` 、 ``\\u`` 、 " -"``\\U`` エスケープを使ってエスケープされます。これは Python 2 の :func:" -"`repr` によって返されるのと同じ文字列を作ります。" +":func:`repr` と同様に、オブジェクトの印字可能な表現を含む文字列を返します。\n" +"ただし、:func:`repr` が返す文字列中の非 ASCII 文字は、``\\x``、``\\u``、" +"``\\U`` エスケープを使ってエスケープされます。\n" +"これにより、Python 2 の :func:`repr` が返すものと似た文字列が生成されます。" #: ../../library/functions.rst:126 msgid "" @@ -614,17 +615,19 @@ msgstr "" "引数 ``breakpointhook`` 付きで :ref:`監査イベント ` ``builtins." "breakpoint`` を送出します。" -#: ../../library/functions.rst:193 msgid "" "Return a new array of bytes. The :class:`bytearray` class is a mutable " "sequence of integers in the range 0 <= x < 256. It has most of the usual " "methods of mutable sequences, described in :ref:`typesseq-mutable`, as well " "as most methods that the :class:`bytes` type has, see :ref:`bytes-methods`." msgstr "" -"新しいバイト配列を返します。:class:`bytearray` クラスは0 <= x < 256の範囲の整" -"数からなる変更可能な配列です。:ref:`typesseq-mutable` に記述されている変更可" -"能な配列に対する普通のメソッドの大半を備えています。また、:class:`bytes` 型が" -"持つメソッドの大半も備えています(see :ref:`bytes-methods`)。" +"新しいバイト配列を返します。\n" +":class:`bytearray` クラスは、0 <= x < 256 の範囲の整数からなる可変シーケンス" +"です。\n" +":ref:`typesseq-mutable` で説明されている可変シーケンスの通常のメソッドの大半" +"に加え、\n" +":class:`bytes` 型のメソッドの大半も備えています (:ref:`bytes-methods` を参照" +"してください)。" #: ../../library/functions.rst:198 msgid "" @@ -703,7 +706,6 @@ msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "" ":ref:`binaryseq`, :ref:`typebytes`, :ref:`bytes-methods` も参照してください。" -#: ../../library/functions.rst:238 msgid "" "Return :const:`True` if the *object* argument appears callable, :const:" "`False` if not. If this returns ``True``, it is still possible that a call " @@ -711,12 +713,13 @@ msgid "" "that classes are callable (calling a class returns a new instance); " "instances are callable if their class has a :meth:`~object.__call__` method." msgstr "" -"*object* 引数が呼び出し可能オブジェクトであれば :const:`True` を、そうでなけ" -"れば :const:`False` を返します。この関数が ``True`` を返しても、呼び出しは失" -"敗する可能性がありますが、``False`` であれば、 *object* の呼び出しは決して成" -"功しません。なお、クラスは呼び出し可能 (クラスを呼び出すと新しいインスタンス" -"を返します) です。また、インスタンスはクラスが :meth:`~object.__call__` メ" -"ソッドを持つなら呼び出し可能です。" +"*object* 引数が呼び出せそうなオブジェクトであれば :const:`True` を、そうでな" +"ければ :const:`False` を返します。\n" +"この関数が ``True`` を返しても呼び出しが失敗する可能性はありますが、\n" +"``False`` であれば *object* の呼び出しは決して成功しません。\n" +"クラスは呼び出し可能です (クラスを呼び出すと新しいインスタンスを返します)。\n" +"インスタンスは、そのクラスが :meth:`~object.__call__` メソッドを持つ場合に呼" +"び出し可能です。" #: ../../library/functions.rst:244 msgid "" @@ -725,15 +728,15 @@ msgid "" msgstr "" "この関数は Python 3.0 で一度取り除かれましたが、Python 3.2 で復活しました。" -#: ../../library/functions.rst:251 msgid "" "Return the string representing a character with the specified Unicode code " "point. For example, ``chr(97)`` returns the string ``'a'``, while " "``chr(8364)`` returns the string ``'€'``. This is the inverse of :func:`ord`." msgstr "" -"指定されたUnicode コードポイントが文字を表す文字列を返します。例えば " -"``chr(97)`` は文字列 ``'a'`` を、 ``chr(8364)`` は文字列 ``'€'`` を返しま" -"す。 :func:`ord` の逆です。" +"指定された Unicode コードポイントを持つ文字を表す文字列を返します。\n" +"例えば、``chr(97)`` は文字列 ``'a'`` を、``chr(8364)`` は文字列 ``'€'`` を返" +"します。\n" +":func:`ord` の逆の操作です。" #: ../../library/functions.rst:255 msgid "" @@ -826,28 +829,28 @@ msgstr "" "クラスメソッドは :func:`property` など、他の :term:`デスクリプタ " "` をラップすることができなくなりました。" -#: ../../library/functions.rst:303 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " "string, a byte string, or an AST object. Refer to the :mod:`ast` module " "documentation for information on how to work with AST objects." msgstr "" -"*source* をコードオブジェクト、もしくは、 AST オブジェクトにコンパイルしま" -"す。 コードオブジェクトは :func:`exec` 文で実行したり、 :func:`eval` 呼び出し" -"で評価できます。 *source* は通常の文字列、 バイト列、 AST オブジェクトのいず" -"れでもかまいません。 AST オブジェクトへの、また、 AST オブジェクトからのコン" -"パイルの方法は、 :mod:`ast` モジュールのドキュメントを参照してください。" +"*source* をコードオブジェクトまたは AST オブジェクトにコンパイルします。\n" +"コードオブジェクトは :func:`exec` や :func:`eval` で実行できます。\n" +"*source* には、通常の文字列、バイト列、AST オブジェクトのいずれかを指定できま" +"す。\n" +"AST オブジェクトの扱い方については、:mod:`ast` モジュールのドキュメントを参照" +"してください。" -#: ../../library/functions.rst:308 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " "is commonly used)." msgstr "" -"*filename* 引数には、コードの読み出し元のファイルを与えなければなりません; " -"ファイルから読み出されるのでなければ、認識可能な値を渡して下さい " -"(``''`` が一般的に使われます)。" +"*filename* 引数には、コードの読み出し元のファイルを示す値を指定してくださ" +"い。\n" +"ファイルから読み出していない場合は、識別できる値を渡してください " +"(``''`` がよく使われます)。" #: ../../library/functions.rst:312 msgid "" @@ -1049,7 +1052,6 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../library/functions.rst:416 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -1065,7 +1067,7 @@ msgid "" msgstr "" "引数が文字列の場合、実数部( :func:`float` と同じ形式)、虚数部(同様の形式" "で ``'j'`` または ``'J'`` 接尾辞)どちらか、あるいは両方(この場合、虚数部の" -"符号は必須)を含まなければなりません。文字列 は空白や括弧 ``'('`` と``')'`` " +"符号は必須)を含まなければなりません。文字列 は空白や括弧 ``'('`` と ``')'`` " "で囲むこともできますが、無視されます。文字列は、 ``'+'`` 、``'-'`` 、 " "``'j'`` または ``'J'`` 接尾辞 、そして10進数の間に空白を含んではなりません。" "たとえば ``complex('1+2j')`` はよいですが、 ``complex('1 + 2j')`` は :exc:" @@ -1120,10 +1122,8 @@ msgstr "引数がすべて省略された場合は、 ``0j`` を返します。" msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複素数型については :ref:`typesnumeric` に説明があります。" -#: ../../library/functions.rst:460 ../../library/functions.rst:837 -#: ../../library/functions.rst:1094 msgid "Grouping digits with underscores as in code literals is allowed." -msgstr "コードリテラル中で桁をグループ化するのにアンダースコアを利用できます。" +msgstr "コードリテラルと同様に、アンダースコアで桁を区切れるようになりました。" #: ../../library/functions.rst:463 msgid "" @@ -1209,14 +1209,13 @@ msgstr "" "だけ情報を集めようとします。結果のリストは必ずしも完全ではなく、カスタムの :" "func:`~object.__getattr__` を持つ場合は不正確かもしれません。" -#: ../../library/functions.rst:513 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " "complete, information:" msgstr "" -"デフォルトの :func:`dir` メカニズムは、完全というより最重要な情報を作成しよう" -"とするため、異なる型のオブジェクトでは異なって振る舞います:" +"デフォルトの :func:`dir` の仕組みは、網羅的な情報よりも関連性の高い情報を返そ" +"うとするため、オブジェクトの型によって異なる動作をします:" #: ../../library/functions.rst:517 msgid "" @@ -1226,13 +1225,12 @@ msgstr "" "オブジェクトがモジュールオブジェクトの場合、リストにはモジュールの属性の名前" "が含まれます。" -#: ../../library/functions.rst:520 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." msgstr "" -"オブジェクトが型オブジェクトやクラスオブジェクトの場合、リストにはその属性の" -"名前と、再帰的にたどったその基底クラスの属性が含まれます。" +"オブジェクトが型オブジェクトまたはクラスオブジェクトの場合、リストにはその属" +"性の名前と、基底クラスを再帰的にたどった属性の名前が含まれます。" #: ../../library/functions.rst:523 msgid "" @@ -1451,9 +1449,8 @@ msgstr "" "デフォルトの *locals* 名前空間のセマンティクスは、 組み込み :func:`locals` の" "説明のように調整された。" -#: ../../library/functions.rst:672 ../../library/functions.rst:754 msgid "*globals* can now be a :class:`frozendict`." -msgstr "*globals* は :class:`frozendict` になるようになった。" +msgstr "*globals* に :class:`frozendict` も指定できるようになりました。" #: ../../library/functions.rst:683 msgid "" @@ -1509,7 +1506,6 @@ msgstr "" "を意味します(「トップレベル」変数はクラス定義にてクラス変数として扱われるた" "め)。" -#: ../../library/functions.rst:710 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in module :mod:" @@ -1517,6 +1513,11 @@ msgid "" "used to restrict or change the available names, but this is **not** a " "security mechanism: the executed code can still access all builtins." msgstr "" +"*globals* 辞書にキー ``__builtins__`` の値が含まれていない場合、\n" +"そのキーに組み込みモジュール :mod:`builtins` の辞書への参照が挿入されます。\n" +"``__builtins__`` を上書きすると、利用できる名前を制限したり変更したりできます" +"が、これはセキュリティ機構では **ありません**。\n" +"実行されるコードは、依然としてすべての組み込み機能にアクセスできます。" #: ../../library/functions.rst:717 msgid "" @@ -1550,36 +1551,37 @@ msgstr "" msgid "Added the *closure* parameter." msgstr "*closure* パラメータが追加されました。" -#: ../../library/functions.rst:759 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " "iteration, or an iterator. If *function* is ``None``, the identity function " "is assumed, that is, all elements of *iterable* that are false are removed." msgstr "" -"*iterable* の要素のうち、 *function* が真であるものからイテレータを構築しま" -"す。 *iterable* にはシーケンスか、イテレーションをサポートするコンテナか、イ" -"テレータを渡せます。 *function* が ``None`` のときは恒等関数が指定されたもの" -"として扱われ、 *iterable* のうち偽であるものがすべて取り除かれます。" +"*iterable* の要素のうち、*function* を適用した結果が真になる要素からイテレー" +"タを構築します。\n" +"*iterable* には、シーケンス、イテレーションをサポートするコンテナ、イテレータ" +"のいずれかを指定できます。\n" +"*function* が ``None`` の場合は恒等関数が指定されたものとして扱われ、" +"*iterable* の要素のうち偽であるものがすべて取り除かれます。" -#: ../../library/functions.rst:765 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " "not ``None`` and ``(item for item in iterable if item)`` if function is " "``None``." msgstr "" -"なお、``filter(function, iterable)`` は、関数が ``None`` でなければジェネレー" -"タ式 ``(item for item in iterable if function(item))`` と同等で、関数が " -"``None`` なら ``(item for item in iterable if item)`` と同等です。" +"``filter(function, iterable)`` は、``function`` が ``None`` でなければジェネ" +"レータ式 ``(item for item in iterable if function(item))`` と等価です。\n" +"``function`` が ``None`` なら、``(item for item in iterable if item)`` と等価" +"です。" -#: ../../library/functions.rst:770 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." msgstr "" -"逆の働きをする関数については、 :func:`itertools.filterfalse` を参照してくださ" -"い。 *iterable* の要素のうち、 *function* が偽であるものを返します。" +"逆の働きをする関数については :func:`itertools.filterfalse` を参照してくださ" +"い。\n" +"*iterable* の要素のうち、*function* を適用した結果が偽になる要素を返します。" #: ../../library/functions.rst:781 msgid "Return a floating-point number constructed from a number or a string." @@ -1609,7 +1611,6 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../library/functions.rst:798 msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " @@ -1619,12 +1620,13 @@ msgid "" "conform to the :token:`~float:floatvalue` production rule in the following " "grammar, after leading and trailing whitespace characters are removed:" msgstr "" -"引数が文字列の場合、10進数でなければなりません。先頭に符号または空白を含んで" -"もかまいません。符号は ``'+'`` か ``'-'`` のいずれかです。正符号 ``'+'`` は生" -"成される値に対して何の効果もありません。引数は NaN (not-a-number) や正または" -"負の無限大をあらわす文字列でもかまいません。より正確にいうと、入力は先頭と末" -"尾の空白文字を除き、以下に示す :token:`~float:floatvalue` の生成規則に従う必" -"要があります:" +"引数が文字列の場合、10進数を含み、必要に応じて先頭に符号を付けたり、前後に空" +"白文字を付けたりできます。\n" +"符号は ``'+'`` または ``'-'`` で、``'+'`` は生成される値に影響しません。\n" +"引数には、NaN (not-a-number)、正または負の無限大を表す文字列も指定できま" +"す。\n" +"より正確には、先頭と末尾の空白文字を取り除いた入力が、以下の文法の :token:" +"`~float:floatvalue` の生成規則に従う必要があります:" #: ../../library/functions.rst:819 msgid "" @@ -1645,14 +1647,13 @@ msgstr "" "値の浮動小数点数が返されます。 引数が Python の浮動小数点数の範囲外なら、 :" "exc:`OverflowError` が送出されます。" -#: ../../library/functions.rst:827 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " "back to :meth:`~object.__index__`." msgstr "" "一般の Python オブジェクト ``x`` に対して、``float(x)`` は ``x.__float__()`` " -"に委譲します。 :meth:`~object.__float__()` が定義されていない場合、:meth:" +"に委譲します。 :meth:`~object.__float__` が定義されていない場合、:meth:" "`~object.__index__` へフォールバックします。" #: ../../library/functions.rst:831 @@ -1696,7 +1697,6 @@ msgstr "" "デフォルトの *format_spec* は空の文字列です。それは通常 :func:`str(value) " "` の呼び出しと同じ結果になります。" -#: ../../library/functions.rst:861 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1705,12 +1705,14 @@ msgid "" "and the *format_spec* is non-empty, or if either the *format_spec* or the " "return value are not strings." msgstr "" -"``format(value, format_spec)`` の呼び出しは、 ``type(value)." -"__format__(value, format_spec)`` に翻訳され、これは value の :meth:`~object." -"__format__` メソッドの検索をするとき、インスタンス辞書を回避します。このメ" -"ソッドの探索が :mod:`object` に到達しても *format_spec* が空にならなかった" -"り、 *format_spec* や返り値が文字列でなかったりした場合、 :exc:`TypeError` が" -"送出されます。" +"``format(value, format_spec)`` の呼び出しは、``type(value).__format__(value, " +"format_spec)`` に置き換えられ、\n" +"``value`` の :meth:`~object.__format__` メソッドを探す際にインスタンスの辞書" +"を参照しません。\n" +"メソッドの探索が :mod:`object` に到達し、かつ *format_spec* が空でない場合" +"や、\n" +"*format_spec* または返り値が文字列でない場合は、:exc:`TypeError` が送出されま" +"す。" #: ../../library/functions.rst:868 msgid "" @@ -1720,24 +1722,31 @@ msgstr "" "*format_spec* が空の文字列でない場合 ``object().__format__(format_spec)`` " "は :exc:`TypeError` を送出します。" -#: ../../library/functions.rst:879 msgid "" "Create a new frozen dictionary. The :class:`frozendict` object is a built-" "in class. See also :ref:`typesmapping` for documentation about this class." msgstr "" +"新しい凍結辞書を作成します。\n" +":class:`frozendict` オブジェクトは組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`typesmapping` も参照してください。" -#: ../../library/functions.rst:882 msgid "" "For other containers see the built-in :class:`dict`, :class:`list`, :class:" "`set`, and :class:`tuple` classes, as well as the :mod:`collections` module." msgstr "" +"他のコンテナについては、組み込みの :class:`dict`、:class:`list`、:class:" +"`set`、:class:`tuple` クラスや、:mod:`collections` モジュールを参照してくださ" +"い。" -#: ../../library/functions.rst:892 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. :class:`frozenset` is a built-in class. See also :ref:`types-" "set` for documentation about this class." msgstr "" +"新しい :class:`frozenset` オブジェクトを返します。\n" +"必要に応じて *iterable* から要素を取り込むこともできます。\n" +":class:`frozenset` は組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`types-set` も参照してください。" #: ../../library/functions.rst:896 msgid "" @@ -1776,15 +1785,14 @@ msgstr "" "名前を持つ属性) の値を :func:`getattr` で取り出すためには、属性名を手動でマン" "グリングする必要があります。" -#: ../../library/functions.rst:921 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " "same regardless of where the function is called." msgstr "" -"現在のモジュールの名前空間を実装した辞書を返します。関数内のコードに対して" -"は、関数が定義されるときに辞書が設定され、その関数がどこから呼ばれたかにかか" -"わらず同じ内容になります。" +"現在のモジュールの名前空間を実装する辞書を返します。\n" +"関数内のコードでは、この辞書は関数の定義時に決まり、関数がどこから呼び出され" +"ても同じ辞書が使われます。" #: ../../library/functions.rst:928 msgid "" @@ -1847,11 +1855,10 @@ msgstr "" "さい。より詳しい情報は、 :ref:`位置専用引数についての FAQ の項目 ` を参照してください。" -#: ../../library/functions.rst:962 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "" -"この関数は、 :mod:`site` モジュールから、組み込みの名前空間に移されました。" +"この関数は :mod:`site` モジュールによって組み込み名前空間に追加されます。" #: ../../library/functions.rst:964 msgid "" @@ -1911,24 +1918,24 @@ msgstr "" msgid "This is the address of the object in memory." msgstr "これはオブジェクトのメモリアドレスです。" -#: ../../library/functions.rst:1010 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引数 ``id`` を指定して :ref:`監査イベント ` ``builtins.id`` を送出" -"します。 " +"します。" -#: ../../library/functions.rst:1016 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " "converts it to a string (stripping a trailing newline), and returns that. " "When EOF is read, :exc:`EOFError` is raised. Example::" msgstr "" -"引数 *prompt* が存在すれば、それが末尾の改行を除いて標準出力に書き出されま" -"す。次に、この関数は入力から 1 行を読み込み、文字列に変換して (末尾の改行を除" -"いて) 返します。 EOF が読み込まれたとき、 :exc:`EOFError` が送出されます。" +"実引数 *prompt* が指定されている場合、その値を末尾に改行を付けずに標準出力に" +"書き出します。\n" +"次に、入力から1行を読み取り、文字列に変換して末尾の改行を取り除き、その文字列" +"を返します。\n" +"EOF を読み取ると :exc:`EOFError` が送出されます。\n" "例::" #: ../../library/functions.rst:1021 @@ -2029,7 +2036,6 @@ msgstr "" "の先頭に任意の数のゼロを付けたり、前後に空白文字を付けたり、各桁を単一の下線" "で区切ったりしても有効です。" -#: ../../library/functions.rst:1074 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -2042,17 +2048,17 @@ msgid "" "prefix. Base 0 also disallows leading zeros: ``int('010', 0)`` is not legal, " "while ``int('010')`` and ``int('010', 8)`` are." msgstr "" -"n-進数の整数文字列は、各桁が0から n-1 の数値で表されます。ユニコードの10進数" -"では、各桁は0から9のいずれかです。また10から35までの値は ``a`` から ``z`` (ま" -"たは ``A`` から ``Z``) で表されます。デフォルトの *base* は10です。基数に指定" -"可能な値は0および2から36までの整数です。2進数、8進数、16進数の文字列は、整数" -"リテラルと同様に、それぞれ ``0b``/``0B``, ``0o``/``0O``, または ``0x``/" -"``0X`` をプレフィックスとして追加することができます。基数を0に指定した場合、" -"文字列は :ref:`コードにおける整数リテラル ` と同じように解釈されま" -"す。すなわち、プレフィックスによって基数が2, 8, 10, または 16 のどれになるか" -"が決まります。基数を0にした場合先頭にゼロを追加することはできません: すなわ" -"ち ``int('010', 0)`` は基数を0に指定しているため不正ですが、 ``int('010')`` " -"や ``int('010', 8)`` は有効です。" +"n 進数の整数文字列は、各桁が 0 から n-1 の値を表す数字で構成されます。\n" +"0 から 9 の値は、任意の Unicode 10進数字で表せます。\n" +"10 から 35 の値は、``a`` から ``z`` (または ``A`` から ``Z``) で表せます。\n" +"*base* のデフォルト値は 10 で、指定できる基数は 0 および 2 から 36 です。\n" +"2 進、8 進、16 進の文字列には、コード中の整数リテラルと同様に、それぞれ " +"``0b``/``0B``、``0o``/``0O``、``0x``/``0X`` という接頭辞を付けられます。\n" +"基数が 0 の場合は、:ref:`コード中の整数リテラル ` と同じように、接" +"頭辞によって実際の基数が 2、8、10、16 のいずれかに決まります。\n" +"基数が 0 の場合は先頭に余分なゼロを付けることもできません。\n" +"``int('010', 0)`` は無効ですが、``int('010')`` と ``int('010', 8)`` は有効で" +"す。" #: ../../library/functions.rst:1085 msgid "The integer type is described in :ref:`typesnumeric`." @@ -2098,10 +2104,11 @@ msgstr "" "`ValueError` が送出されます。詳しくは :ref:`整数文字列の変換における長さ制限 " "` を参照してください。" -#: ../../library/functions.rst:1111 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." msgstr "" +":func:`int` は :meth:`~object.__trunc__` メソッドに処理を委譲しなくなりまし" +"た。" #: ../../library/functions.rst:1116 msgid "" @@ -2130,7 +2137,6 @@ msgstr "" msgid "*classinfo* can be a :ref:`types-union`." msgstr "*classinfo* に :ref:`types-union` を指定できるようになりました。" -#: ../../library/functions.rst:1133 msgid "" "Return ``True`` if *cls* is a subclass (direct, indirect, or :term:`virtual " "`) of *classinfo*. A class is considered a subclass of " @@ -2139,6 +2145,14 @@ msgid "" "is a subclass of any entry in *classinfo*. In any other case, a :exc:" "`TypeError` exception is raised." msgstr "" +"*cls* が *classinfo* のサブクラス (直接、間接、または :term:`仮想 ` のサブクラス) である場合、``True`` を返します。\n" +"クラスは、それ自体のサブクラスと見なされます。\n" +"*classinfo* には、クラスオブジェクトのタプル (または再帰的にそのようなタプル" +"を含むタプル) や :ref:`types-union` も指定できます。\n" +"その場合、*cls* が *classinfo* 内のいずれかのサブクラスであれば ``True`` を返" +"します。\n" +"*classinfo* がこれらのいずれでもない場合は、:exc:`TypeError` が送出されます。" #: ../../library/functions.rst:1148 msgid "" @@ -2237,20 +2251,19 @@ msgstr "" "モジュール スコープでは、単一の名前空間で :func:`exec` や :func:`eval` を使う" "場合と同じく、この関数は :func:`globals` と同じ名前空間を返します。" -#: ../../library/functions.rst:1204 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" -"クラス スコープでは、メタクラス コンストラクタに渡された名前空間を返します。" +"クラススコープでは、メタクラスのコンストラクタに渡される名前空間を返します。" -#: ../../library/functions.rst:1207 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" -"``exec()`` や ``eval()`` が引数 local と global が分けて使われてる場合では、" -"関数の呼び出しで渡されたローカル名前空間を返します。" +"ローカル用とグローバル用に別々の実引数を渡して ``exec()`` や ``eval()`` を使" +"う場合、\n" +"その関数呼び出しに渡されたローカル名前空間を返します。" #: ../../library/functions.rst:1210 msgid "" @@ -2327,7 +2340,6 @@ msgstr "" "の振る舞いは上記のようになりました。定義されただけで、その他のスコープの振る" "舞いは以前のバージョンのままです。" -#: ../../library/functions.rst:1249 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2338,6 +2350,17 @@ msgid "" "raised. For cases where the function inputs are already arranged into " "argument tuples, see :func:`itertools.starmap`." msgstr "" +"*iterable* の各要素に *function* を適用し、その結果を生成するイテレータを返し" +"ます。\n" +"追加の *iterables* 引数が渡された場合、*function* はイテラブルの数だけ引数を" +"受け取れる必要があります。\n" +"この関数は、すべてのイテラブルから並行して取り出した要素に適用されます。\n" +"複数のイテラブルがある場合、最も短いイテラブルが :term:`枯渇する " +"` とイテレータは停止します。\n" +"*strict* が ``True`` で、いずれかのイテラブルが他より先に枯渇した場合は、:" +"exc:`ValueError` が送出されます。\n" +"関数への入力がすでに引数のタプルにまとめられている場合は、:func:`itertools." +"starmap` を参照してください。" #: ../../library/functions.rst:1258 msgid "Added the *strict* parameter." @@ -2350,15 +2373,14 @@ msgid "" msgstr "" "iterable の中で最大の要素、または2つ以上の引数の中で最大のものを返します。" -#: ../../library/functions.rst:1269 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " "arguments are provided, the largest of the positional arguments is returned." msgstr "" -"位置引数が1つだけ与えられた場合、それは空でない :term:`iterable` でなくてはい" -"けません。その iterable の最大の要素が返されます。2 つ以上のキーワード無しの" -"位置引数が与えられた場合、その位置引数の中で最大のものが返されます。" +"位置引数が1つの場合は、:term:`iterable` を指定します。\n" +"そのイテラブルの最大の要素を返します。\n" +"位置引数が2つ以上の場合は、それらのうち最大のものを返します。" #: ../../library/functions.rst:1274 ../../library/functions.rst:1312 msgid "" @@ -2411,15 +2433,14 @@ msgid "" msgstr "" "iterable の中で最小の要素、または2つ以上の引数の中で最小のものを返します。" -#: ../../library/functions.rst:1307 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " "arguments are provided, the smallest of the positional arguments is returned." msgstr "" -"位置引数が1つだけ与えられた場合、それは空でない :term:`iterable` でなくてはい" -"けません。その iterable の最小の要素が返されます。2 つ以上のキーワード無しの" -"位置引数が与えられた場合、その位置引数の中で最小のものが返されます。" +"位置引数が1つの場合は、:term:`iterable` を指定します。\n" +"そのイテラブルの最小の要素を返します。\n" +"位置引数が2つ以上の場合は、それらのうち最小のものを返します。" #: ../../library/functions.rst:1318 msgid "" @@ -2432,12 +2453,16 @@ msgstr "" "は、``sorted(iterable, key=keyfunc)[0]`` や ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` のような、他のソート安定性を維持するツールと両立します。" -#: ../../library/functions.rst:1333 msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " "iterator is :term:`exhausted`, otherwise :exc:`StopIteration` is raised." msgstr "" +":term:`イテレータ ` の :meth:`~iterator.__next__` メソッドを呼び出" +"して、次の要素を取得します。\n" +"イテレータが :term:`枯渇した ` 場合、*default* が指定されていれば" +"その値を返し、\n" +"指定されていなければ :exc:`StopIteration` を送出します。" #: ../../library/functions.rst:1340 msgid "" @@ -2491,7 +2516,6 @@ msgstr "" "す。ファイルを開くことができなければ、:exc:`OSError` が送出されます。\n" "この関数の利用例について、 :ref:`tut-files` を参照してください。" -#: ../../library/functions.rst:1385 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2499,11 +2523,12 @@ msgid "" "given, it is closed when the returned I/O object is closed unless *closefd* " "is set to ``False``.)" msgstr "" -"*file* は :term:`path-like object` で、開くファイルのパス名 (絶対パスまたは現" -"在の作業ディレクトリからの相対パス) あるいはラップするファイルの整数のファイ" -"ルデスクリプタを与えます。 (ファイルデスクリプタが与えられた場合、 *closefd* " -"が ``False`` に設定されていないかぎり、この関数が返す I/O オブジェクトがク" -"ローズされるときにファイルデスクリプタもクローズされます。)" +"*file* には、開くファイルのパス名 (絶対パスまたは現在の作業ディレクトリからの" +"相対パス) を示す :term:`path-like object` か、\n" +"ラップするファイルの整数のファイル記述子を指定します。\n" +"(ファイル記述子を指定した場合、*closefd* が ``False`` に設定されていなけれ" +"ば、\n" +"返された I/O オブジェクトを閉じるときにそのファイル記述子も閉じられます。)" #: ../../library/functions.rst:1391 msgid "" @@ -2593,15 +2618,15 @@ msgstr "``'+'``" msgid "open for updating (reading and writing)" msgstr "更新用に開く (読み込み・書き込み用)" -#: ../../library/functions.rst:1419 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " "``'r+b'`` open the file with no truncation." msgstr "" -"デフォルトのモードは ``'r'`` (テキストの読み込み用に開く、 ``'rt'`` と同義) " -"です。 ``'w+'`` と ``'w+b'`` はファイルを開いて上書きします。 ``'r+'`` と " -"``'r+b'`` はファイルを上書きせずに開きます。" +"デフォルトのモードは ``'r'`` です (テキストの読み込み用に開き、``'rt'`` と同" +"義です)。\n" +"モード ``'w+'`` と ``'w+b'`` はファイルを開いて内容を切り詰めます。\n" +"モード ``'r+'`` と ``'r+b'`` は、内容を切り詰めずにファイルを開きます。" #: ../../library/functions.rst:1423 msgid "" @@ -2693,7 +2718,6 @@ msgstr "" "しくは :mod:`codecs` モジュール内のサポートしているエンコーディングのリストを" "参照してください。" -#: ../../library/functions.rst:1462 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " @@ -2701,6 +2725,12 @@ msgid "" "has been registered with :func:`codecs.register_error` is also valid. The " "standard names can be found in :ref:`error-handlers`." msgstr "" +"*errors* は、エンコードやデコードのエラーをどう処理するかを指定するオプション" +"の文字列です。\n" +"バイナリモードでは使えません。\n" +"さまざまな標準のエラーハンドラが利用できるほか、:func:`codecs." +"register_error` で登録された任意のエラー処理名も指定できます。\n" +"標準の名前は :ref:`error-handlers` に記載されています。" #: ../../library/functions.rst:1474 msgid "" @@ -2848,7 +2878,7 @@ msgid "" "``mode``, ``flags``." msgstr "" "引数 ``path``, ``mode``, ``flags`` を指定して :ref:`監査イベント ` " -"``open`` を送出します。 " +"``open`` を送出します。" #: ../../library/functions.rst:1545 msgid "" @@ -2903,13 +2933,12 @@ msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "" ":class:`os.PathLike` を実装したオブジェクトを受け入れるようになりました。" -#: ../../library/functions.rst:1570 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." msgstr "" -"Windowsでは、コンソールバッファのオープンは、:class:`io.FileIO` ではなく、:" -"class:`io.RawIOBase` のサブクラスを返すでしょう。" +"Windows では、コンソールバッファを開くと、:class:`io.FileIO` 以外の :class:" +"`io.RawIOBase` のサブクラスが返される場合があります。" #: ../../library/functions.rst:1573 msgid "The ``'U'`` mode has been removed." @@ -2939,16 +2968,16 @@ msgstr "" "引数が 長さ1の :class:`bytes` または :class:`bytearray` である場合は、そのバ" "イト値を返します。例えば、 ``ord(b'a')`` は ``97`` になります。" -#: ../../library/functions.rst:1592 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " "mod``). The two-argument form ``pow(base, exp)`` is equivalent to using the " "power operator: ``base**exp``." msgstr "" -"*base* の *exp* 乗を返します; *mod* があれば、*base* の *exp* 乗に対する " -"*mod* の剰余を返します (``pow(base, exp) % mod`` より効率よく計算されます)。" -"二引数の形式 ``pow(base, exp)`` は、冪乗演算子を使った ``base**exp`` と等価で" +"*base* の *exp* 乗を返します。\n" +"*mod* を指定した場合は、*base* の *exp* 乗を *mod* で割った余りを返します " +"(``pow(base, exp) % mod`` より効率よく計算されます)。\n" +"2引数形式の ``pow(base, exp)`` は、冪乗演算子を使う ``base**exp`` と等価で" "す。" #: ../../library/functions.rst:1597 @@ -3076,9 +3105,8 @@ msgstr "" "です。*fdel* は属性値を削除するための関数です。*doc* は属性の docstring を作" "成します。" -#: ../../library/functions.rst:1665 msgid "A typical use is to define a managed attribute ``x``::" -msgstr "典型的な使用法は、属性 ``x`` の処理の定義です::" +msgstr "典型的な用途は、アクセスを管理する属性 ``x`` を定義することです。 ::" #: ../../library/functions.rst:1667 msgid "" @@ -3120,13 +3148,18 @@ msgstr "" "*c* が *C* のインスタンスならば、``c.x`` は getter を呼び出し、``c.x = " "value`` は setter を、``del c.x`` は deleter を呼び出します。" -#: ../../library/functions.rst:1685 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " "possible to create read-only properties easily using :deco:`property` as a :" "term:`decorator`::" msgstr "" +"*doc* が指定されていれば、その値がプロパティ属性のドキュメンテーション文字列" +"になります。\n" +"指定されていなければ、*fget* にドキュメンテーション文字列がある場合に、プロパ" +"ティがその文字列をコピーします。\n" +"これにより、:deco:`property` を :term:`デコレータ ` として使うこと" +"で、読み出し専用のプロパティを簡単に作成できます。 ::" #: ../../library/functions.rst:1689 msgid "" @@ -3223,9 +3256,10 @@ msgstr "" "返される property オブジェクトも、コンストラクタの引数に対応した ``fget``, " "``fset``, および ``fdel`` 属性を持ちます。" -#: ../../library/functions.rst:1737 msgid "The docstrings of property objects are now writeable." -msgstr "属性オブジェクトのドックストリングが書き込み可能になりました。" +msgstr "" +"プロパティオブジェクトのドキュメンテーション文字列が書き込み可能になりまし" +"た。" #: ../../library/functions.rst:1742 msgid "" @@ -3241,7 +3275,6 @@ msgstr "" ":class:`range` は、実際には関数ではなくイミュータブルなシーケンス型で、 :ref:" "`typesseq-range` と :ref:`typesseq` にドキュメント化されています。" -#: ../../library/functions.rst:1759 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -3253,20 +3286,21 @@ msgid "" "method. If :func:`sys.displayhook` is not accessible, this function will " "raise :exc:`RuntimeError`." msgstr "" -"オブジェクトの印字可能な表現を含む文字列を返します。この関数は多くの型につい" -"て、 :func:`eval` に渡されたときと同じ値を持つようなオブジェクトを表す文字列" -"を生成しようとします。そうでない場合は、山括弧に囲まれたオブジェクトの型の名" -"前と追加の情報 (大抵の場合はオブジェクトの名前とアドレスを含みます) を返しま" -"す。クラスは、 :meth:`~object.__repr__` メソッドを定義することで、この関数に" -"よりそのクラスのインスタンスが返すものを制御することができます。:func:`sys." -"displayhook` にアクセスできない場合、この関数は :exc:`RuntimeError` を送出し" -"ます。" +"オブジェクトの印字可能な表現を含む文字列を返します。\n" +"多くの型では、:func:`eval` に渡すと元のオブジェクトと同じ値を持つオブジェクト" +"が得られるような文字列を返そうとします。\n" +"それ以外の場合、オブジェクトの型名と追加情報を含む、山括弧で囲まれた文字列を" +"返します。\n" +"追加情報には、オブジェクトの名前やアドレスが含まれることがよくあります。\n" +"クラスに :meth:`~object.__repr__` メソッドを定義すると、そのクラスのインスタ" +"ンスに対してこの関数が返すものを制御できます。\n" +":func:`sys.displayhook` にアクセスできない場合、この関数は :exc:" +"`RuntimeError` を送出します。" #: ../../library/functions.rst:1770 msgid "This class has a custom representation that can be evaluated::" msgstr "このクラスは、eval 評価可能な独自の representation を持ちます::" -#: ../../library/functions.rst:1772 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3276,6 +3310,13 @@ msgid "" " def __repr__(self):\n" " return f\"Person({self.name!r}, {self.age!r})\"" msgstr "" +"class Person:\n" +" def __init__(self, name, age):\n" +" self.name = name\n" +" self.age = age\n" +"\n" +" def __repr__(self):\n" +" return f\"Person({self.name!r}, {self.age!r})\"" #: ../../library/functions.rst:1783 msgid "" @@ -3317,13 +3358,12 @@ msgstr "" "返り値は *ndigits* が指定されていないか ``None`` の場合は整数、そうでなければ" "返り値は *number* と同じ型です。" -#: ../../library/functions.rst:1804 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -"一般的な Python オブジェクト ``number`` に対して、``round`` は処理を `number." -"__round__` に移譲します。" +"一般的な Python オブジェクト ``number`` に対して、``round`` は処理を " +"``number.__round__`` に委譲します。" #: ../../library/functions.rst:1809 msgid "" @@ -3338,12 +3378,15 @@ msgstr "" "これはバグではありません: これはほとんどの小数が浮動小数点数で正確に表せない" "ことの結果です。詳しくは :ref:`tut-fp-issues` を参照してください。" -#: ../../library/functions.rst:1820 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. :class:`set` is a built-in class. See also :ref:`types-set` " "for documentation about this class." msgstr "" +"新しい :class:`set` オブジェクトを返します。\n" +"必要に応じて *iterable* から要素を取り込むこともできます。\n" +":class:`set` は組み込みクラスです。\n" +"このクラスのドキュメントについては :ref:`types-set` も参照してください。" #: ../../library/functions.rst:1824 msgid "" @@ -3393,65 +3436,77 @@ msgstr "" "名前を持つ属性) の値を :func:`setattr` でセットするためには、属性名を手動でマ" "ングリングする必要があります。" -#: ../../library/functions.rst:1853 msgid "" "Return a new unique sentinel object. *name* must be a :class:`str`, and is " "used by default as the returned object's representation::" msgstr "" +"一意な新しいセンチネルオブジェクトを返します。\n" +"*name* は :class:`str` でなければならず、デフォルトでは返されるオブジェクトの" +"文字列表現として使われます。 ::" -#: ../../library/functions.rst:1856 msgid "" ">>> MISSING = sentinel(\"MISSING\")\n" ">>> MISSING\n" "MISSING" msgstr "" +">>> MISSING = sentinel(\"MISSING\")\n" +">>> MISSING\n" +"MISSING" -#: ../../library/functions.rst:1860 msgid "" "The optional *repr* argument can be used to specify a different " "representation::" -msgstr "" +msgstr "オプションの *repr* 引数を使うと、別の文字列表現を指定できます。 ::" -#: ../../library/functions.rst:1862 msgid "" ">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" ">>> MISSING\n" "" msgstr "" +">>> MISSING = sentinel(\"MISSING\", repr=\"\")\n" +">>> MISSING\n" +"" -#: ../../library/functions.rst:1866 msgid "" "Sentinel objects are truthy and compare equal only to themselves. They are " "intended to be compared with the :keyword:`is` operator." msgstr "" +"センチネルオブジェクトは真と評価され、自分自身との比較でのみ等しいと判定され" +"ます。\n" +"比較には :keyword:`is` 演算子を使うことを想定しています。" -#: ../../library/functions.rst:1869 msgid "``sentinel`` does not support subclassing." -msgstr "" +msgstr "``sentinel`` はサブクラス化をサポートしません。" -#: ../../library/functions.rst:1871 msgid "Shallow and deep copies of a sentinel object return the object itself." msgstr "" +"センチネルオブジェクトの浅いコピーと深いコピーは、そのオブジェクト自身を返し" +"ます。" -#: ../../library/functions.rst:1873 msgid "" "Sentinels are conventionally assigned to a variable with a matching name. " "Sentinels defined in this way can be used in :term:`type hints `::" msgstr "" +"慣例として、センチネルはその名前と一致する変数に代入します。\n" +"このように定義したセンチネルは :term:`型ヒント ` に使えます。 ::" -#: ../../library/functions.rst:1876 msgid "" "MISSING = sentinel(\"MISSING\")\n" "\n" "def next_value(default: int | MISSING = MISSING):\n" " ..." msgstr "" +"MISSING = sentinel(\"MISSING\")\n" +"\n" +"def next_value(default: int | MISSING = MISSING):\n" +" ..." -#: ../../library/functions.rst:1881 msgid "" "Sentinel objects support the :ref:`| ` operator for use in type " "expressions." msgstr "" +"センチネルオブジェクトは、型の式で使うための :ref:`| ` 演算子をサ" +"ポートします。" #: ../../library/functions.rst:1883 msgid "" @@ -3463,7 +3518,6 @@ msgid "" "preserved after pickling::" msgstr "" -#: ../../library/functions.rst:1890 msgid "" "import pickle\n" "\n" @@ -3476,20 +3530,29 @@ msgid "" "\n" "assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" msgstr "" +"import pickle\n" +"\n" +"PICKLABLE = sentinel(\"PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(PICKLABLE)) is PICKLABLE\n" +"\n" +"class Cls:\n" +" PICKLABLE = sentinel(\"Cls.PICKLABLE\")\n" +"\n" +"assert pickle.loads(pickle.dumps(Cls.PICKLABLE)) is Cls.PICKLABLE" -#: ../../library/functions.rst:1901 msgid "Sentinel objects have the following attributes:" -msgstr "" +msgstr "センチネルオブジェクトには、次の属性があります:" -#: ../../library/functions.rst:1905 msgid "The sentinel's name." -msgstr "" +msgstr "センチネルの名前。" -#: ../../library/functions.rst:1909 msgid "" "The name of the module where the sentinel was created. This attribute is " "writable." msgstr "" +"センチネルが作成されたモジュールの名前。\n" +"この属性は書き込み可能です。" #: ../../library/functions.rst:1917 msgid "" @@ -3545,14 +3608,13 @@ msgstr "" "2 つのオプション引数があり、これらはキーワード引数として指定されなければなり" "ません。" -#: ../../library/functions.rst:1945 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -"*key* には 1 引数関数を指定します。これは *iterable* の各要素から比較キーを展" -"開するのに使われます (例えば、 ``key=str.lower`` のように指定します)。\n" +"*key* には、*iterable* の各要素から比較キーを取り出すための1引数関数を指定し" +"ます (例えば ``key=str.lower``)。\n" "デフォルト値は ``None`` です (要素を直接比較します)。" #: ../../library/functions.rst:1949 @@ -3583,7 +3645,6 @@ msgstr "" "でソートを行なうのに役立ちます(例えば部署でソートしてから給与の等級でソート" "する場合)。" -#: ../../library/functions.rst:1960 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3594,14 +3655,14 @@ msgid "" "mixed type comparisons which can call the reflected :meth:`~object.__gt__` " "method." msgstr "" -"ソートアルゴリズムは、要素間の比較に ``<`` 演算子だけを使います。したがって" -"ソートのためには :meth:`~object.__lt__` メソッドを定義すれば十分なはずです" -"が、 :PEP:`8` は6つの :ref:`比較演算子 ` を全て実装することを推" -"奨しています。これにより、異なるメソッドを必要とする :func:`max` のような他の" -"ソートツールを、同じデータに対して適用することによって起こりうるバグを避ける" -"助けになります。6つの比較演算子を全て実装することは、リフレクションによって :" -"meth:`~object.__gt__` メソッドを呼び出す可能性のある型混合の比較での混乱を避" -"けることにも役立ちます。 " +"ソートアルゴリズムは、要素間の比較に ``<`` だけを使います。\n" +"ソートには :meth:`~object.__lt__` メソッドを定義すれば十分ですが、:PEP:`8` は" +"6つの :ref:`拡張比較 ` をすべて実装することを推奨しています。\n" +"これにより、異なるメソッドに依存する :func:`max` などの順序付けを行うツールで" +"同じデータを使うときに、バグを避けやすくなります。\n" +"6つの比較をすべて実装すると、異なる型の比較で、被演算子を入れ替えた比較に対応" +"する :meth:`~object.__gt__` メソッドが呼び出される場合の混乱も避けやすくなり" +"ます。" #: ../../library/functions.rst:1969 msgid "" @@ -3651,12 +3712,14 @@ msgstr "" "ソッド :term:`descriptor` は呼び出し可能でもあるため、(``f()`` のように) クラ" "ス定義の中でも使用できます。" -#: ../../library/functions.rst:1990 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :deco:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" +"Python の静的メソッドは、Java や C++ の静的メソッドに似ています。\n" +"別のコンストラクタをクラスに用意する際に便利な :deco:`classmethod` も参照して" +"ください。" #: ../../library/functions.rst:1994 msgid "" @@ -3690,13 +3753,17 @@ msgstr "" msgid "For more information on static methods, see :ref:`types`." msgstr "静的メソッドについて詳しい情報は :ref:`types` を参照してください。" -#: ../../library/functions.rst:2008 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" "attr:`~function.__doc__` and :attr:`~function.__annotations__`), have a new " "``__wrapped__`` attribute, and are now callable as regular functions." msgstr "" +"静的メソッドは、メソッドの属性 (:attr:`~function.__module__`、:attr:" +"`~function.__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__doc__`、:attr:`~function.__annotations__`) を継承し、\n" +"新しい ``__wrapped__`` 属性を持つようになりました。\n" +"また、通常の関数として呼び出せるようになりました。" #: ../../library/functions.rst:2026 msgid "" @@ -3713,14 +3780,13 @@ msgstr "" "``str`` は組み込みの文字列 :term:`クラス` です。文字列に関する一般的な" "情報は、:ref:`textseq` を参照してください。" -#: ../../library/functions.rst:2034 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -"*start* と *iterable* の要素を左から右へ合計し、総和を返します。 *iterable* " -"の要素は通常は数値で、start の値は文字列であってはなりません。" +"*start* と *iterable* の要素を左から右へ加算し、総和を返します。\n" +"*iterable* の要素は通常は数値で、``start`` の値には文字列を指定できません。" #: ../../library/functions.rst:2038 msgid "" @@ -3742,19 +3808,20 @@ msgstr "" "*start* パラメータをキーワード引数として指定することができるようになりまし" "た。" -#: ../../library/functions.rst:2047 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -"浮動小数点数の総和を計算するとき、ほとんどの環境でより高精度な結果とより良い" -"互換性が得られるアルゴリズムを使用するようになりました。" +"浮動小数点数の総和を計算するアルゴリズムが変更され、\n" +"ほとんどのビルドで精度が向上し、加算する順序を入れ替えたときも結果がより一致" +"しやすくなりました。" -#: ../../library/functions.rst:2050 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." msgstr "" +"浮動小数点数の総和と同じアルゴリズムを使う、複素数の総和に特化した処理が追加" +"されました。" #: ../../library/functions.rst:2058 msgid "" @@ -3784,13 +3851,15 @@ msgstr "" "> object`` であり、 *type* の値が ``B`` だとすると、 :func:`super` は ``C -> " "A -> object`` の順番でメソッドを検索します。" -#: ../../library/functions.rst:2070 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" "`getattr` and :func:`super`. The attribute is dynamic and can change " "whenever the inheritance hierarchy is updated." msgstr "" +"*object_or_type* に対応するクラスの :attr:`~type.__mro__` 属性には、:func:" +"`getattr` と :func:`super` の両方が使うメソッド解決順序が記載されています。\n" +"この属性は動的であり、継承階層が更新されると変わることがあります。" #: ../../library/functions.rst:2075 msgid "" @@ -3831,7 +3900,6 @@ msgstr "" "メンテナンスしやすくなります。この用途は他のプログラミング言語で見られる " "*super* の用途によく似ています。" -#: ../../library/functions.rst:2092 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3843,14 +3911,15 @@ msgid "" "changes in the class hierarchy, and because that order can include sibling " "classes that are unknown prior to runtime)." msgstr "" -"2つ目の用途は動的な実行環境において協調的 (cooperative) な多重継承をサポート" -"することです。これは Python に特有の用途で、静的にコンパイルされる言語や、単" -"継承のみをサポートする言語には見られないものです。この機能により、同じ名前の" -"メソッドを実装する複数の基底クラスを使った \"ダイヤモンド型* の継承構造を実装" -"することができます。良い設計は、そのような実装において、どのような場合でも同" -"じ呼び出しシグネチャを持つように強制します。 (理由は呼び出しの順序が実行時に" -"決定されること、呼び出し順序はクラス階層構造の変化に順応すること、そして呼び" -"出し順序が実行時まで未知の兄弟クラスが含まれる場合があることです)。" +"2つ目の用途は、動的な実行環境で協調的な多重継承をサポートすることです。\n" +"これは Python 特有の用途であり、静的にコンパイルされる言語や単継承だけをサ" +"ポートする言語には見られません。\n" +"これにより、複数の基底クラスが同じメソッドを実装する「ダイヤモンド型」の継承" +"構造を実現できます。\n" +"適切に設計するには、これらの実装の呼び出しシグネチャをすべて同じにする必要が" +"あります\n" +"(呼び出しの順序が実行時に決まり、その順序はクラス階層の変化に応じて変わり、\n" +"実行時まで分からない兄弟クラスもその順序に含まれる可能性があるためです)。" #: ../../library/functions.rst:2102 msgid "For both use cases, a typical superclass call looks like this::" @@ -3895,7 +3964,6 @@ msgstr "" "文や ``super()[name]`` のような演算子を使った暗黙の探索向けには定義されていま" "せん。" -#: ../../library/functions.rst:2121 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3904,11 +3972,12 @@ msgid "" "necessary details to correctly retrieve the class being defined, as well as " "accessing the current instance for ordinary methods." msgstr "" -"また、 :func:`super` の使用は引数無しの形式を除きメソッド内部に限定されないこ" -"とにも注目して下さい。2引数の形式は、必要な要素を正確に指定するので、適当な参" -"照を作ることができます。クラス定義中における引数無しの形式は、定義されている" -"クラスを取り出すのに必要な詳細を、通常の方法で現在のインスタンスにアクセスす" -"るようにコンパイラが埋めるのではたらきます。" +"引数なしの形式を除き、:func:`super` はメソッドの外でも使えます。\n" +"2引数形式では、引数を明示的に指定し、適切な参照を作成します。\n" +"引数なしの形式がクラス定義内でのみ機能するのは、\n" +"定義中のクラスを正しく取得し、通常のメソッドでは現在のインスタンスにもアクセ" +"スできるように、\n" +"コンパイラが必要な情報を補うためです。" #: ../../library/functions.rst:2128 msgid "" @@ -3925,8 +3994,8 @@ msgid "" ":class:`super` objects are now :mod:`pickleable ` and :mod:" "`copyable `." msgstr "" -":class:`super` オブジェクトは :term:`pickle 可能 ` かつ :term:`コピー" -"可能 ` になりました。" +":class:`super` オブジェクトは :mod:`pickle 可能 ` かつ :mod:`コピー可" +"能 ` になりました。" #: ../../library/functions.rst:2141 msgid "" @@ -3978,13 +4047,11 @@ msgstr "" msgid "See also:" msgstr "下記を参照してください。" -#: ../../library/functions.rst:2174 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -":ref:`Documentation on attributes and methods on classes `." +":ref:`クラスの属性とメソッドに関するドキュメント `。" #: ../../library/functions.rst:2175 msgid ":ref:`bltin-type-objects`" @@ -4001,12 +4068,15 @@ msgstr "" "定義におけるキーワード引数と同様に、適切なメタクラスの機構 (通常は :meth:" "`~object.__init_subclass__`) に渡されます。" -#: ../../library/functions.rst:2182 msgid "" "Unlike a :keyword:`class` statement, the three argument form does not call " "the metaclass ``__prepare__`` method (see :ref:`prepare`). Use :func:`types." "new_class` to dynamically create a class using the appropriate metaclass." msgstr "" +":keyword:`class` 文とは異なり、3引数形式ではメタクラスの ``__prepare__`` メ" +"ソッドを呼び出しません (:ref:`prepare` を参照してください)。\n" +"適切なメタクラスを使って動的にクラスを作成するには、:func:`types.new_class` " +"を使ってください。" #: ../../library/functions.rst:2187 msgid "See also :ref:`class-customization`." @@ -4020,9 +4090,8 @@ msgstr "" "``type.__new__`` をオーバーライドしていない :class:`!type` のサブクラスは、オ" "ブジェクトの型を得るのに1引数形式を利用することができません。" -#: ../../library/functions.rst:2195 msgid "*dict* can now be a :class:`frozendict`." -msgstr "" +msgstr "``dict`` に :class:`frozendict` を指定できるようになりました。" #: ../../library/functions.rst:2200 msgid "" @@ -4135,12 +4204,15 @@ msgstr "" "備するコードにおけるバグのこともあるでしょう。 Python はこの問題に対して3つの" "異なるアプローチを提供します:" -#: ../../library/functions.rst:2250 msgid "" "By default, :func:`zip` stops when the shortest iterable is :term:" "`exhausted`. It will ignore the remaining items in the longer iterables, " "cutting off the result to the length of the shortest iterable::" msgstr "" +"デフォルトでは、最も短いイテラブルが :term:`枯渇する ` と :func:" +"`zip` は停止します。\n" +"より長いイテラブルに残った要素は無視し、結果を最も短いイテラブルの長さに切り" +"詰めます。 ::" #: ../../library/functions.rst:2254 msgid "" @@ -4168,21 +4240,21 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2264 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is :term:`exhausted` before the others:" msgstr "" +"デフォルトの動作とは異なり、いずれかのイテラブルが他より先に :term:`枯渇した " +"` 場合は、:exc:`ValueError` を送出します:" -#: ../../library/functions.rst:2282 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -"``strict=True`` 引数なしの場合、長さの異なるイテラブルを生じる原因となるいか" -"なるバグも、この時点では問題なく処理されます。そして代わりにプログラムの別の" -"場所で、原因を特定しにくいバグとして検出されることになるでしょう。" +"``strict=True`` を指定しないと、イテラブルの長さが異なる原因となるバグが表面" +"化せず、\n" +"プログラムの別の場所で発見しにくいバグとして現れる場合があります。" #: ../../library/functions.rst:2286 msgid "" @@ -4220,12 +4292,11 @@ msgstr "" "``n`` 回呼び出した結果となるよう、 *同じ* イテレータを ``n`` 回繰り返します。" "これは入力を長さ n のチャンクに分割する効果があります。" -#: ../../library/functions.rst:2301 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -":func:`zip` に続けて ``*`` 演算子を使うと、zip したリストを元に戻せます::" +":func:`zip` と ``*`` 演算子を組み合わせると、zip したリストを元に戻せます::" #: ../../library/functions.rst:2304 msgid "" @@ -4277,7 +4348,6 @@ msgstr "" "`__import__` を直接使用することも推奨されず、 :func:`importlib." "import_module` の方が好まれます。" -#: ../../library/functions.rst:2336 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -4286,14 +4356,14 @@ msgid "" "does not use its *locals* argument at all and uses its *globals* only to " "determine the package context of the :keyword:`import` statement." msgstr "" -"この関数は、モジュール *name* をインポートし、 *globals* と *locals* が与えら" -"れれば、パッケージのコンテキストで名前をどう解釈するか決定するのに使います。 " -"*fromlist* は *name* で与えられるモジュールからインポートされるべきオブジェク" -"トまたはサブモジュールの名前を与ます。標準の実装では *locals* 引数はまったく" -"使われず、 *globals* は :keyword:`import` 文のパッケージコンテキストを決定す" -"るためにのみ使われます。" +"この関数はモジュール *name* をインポートします。\n" +"その際、指定された *globals* と *locals* を使って、パッケージのコンテキストで" +"名前をどう解釈するかを決めることがあります。\n" +"*fromlist* には、*name* が指定するモジュールからインポートするオブジェクトや" +"サブモジュールの名前を指定します。\n" +"標準の実装では *locals* 引数をまったく使わず、:keyword:`import` 文のパッケー" +"ジコンテキストを決めるためにのみ *globals* を使います。" -#: ../../library/functions.rst:2343 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -4301,10 +4371,12 @@ msgid "" "directory of the module calling :func:`__import__` (see :pep:`328` for the " "details)." msgstr "" -"*level* は絶対と相対どちらのインポートを使うかを指定します。 ``0`` (デフォル" -"ト) は絶対インポートのみ実行します。正の *level* の値は、 :func:`__import__` " -"を呼び出したディレクトリから検索対象となる親ディレクトリの数を示します (詳細" -"は :pep:`328` を参照してください)。" +"*level* は、絶対インポートと相対インポートのどちらを使うかを指定します。\n" +"``0`` (デフォルト) は、絶対インポートだけを行うことを意味します。\n" +"正の *level* は、:func:`__import__` を呼び出すモジュールのディレクトリを基準" +"に、\n" +"検索対象となる親ディレクトリの数を示します (詳細は :pep:`328` を参照してくだ" +"さい)。" #: ../../library/functions.rst:2349 msgid "" @@ -4337,14 +4409,12 @@ msgstr "文 ``import spam.ham`` は、この呼び出しになります::" msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2363 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -"ここで :func:`__import__` がどのように最上位モジュールを返しているかに注意し" -"て下さい。 :keyword:`import` 文により名前が束縛されたオブジェクトになっていま" -"す。" +"ここで :func:`__import__` が最上位のモジュールを返すのは、:keyword:`import` " +"文がそのオブジェクトに名前を束縛するためです。" #: ../../library/functions.rst:2366 msgid "" @@ -4390,13 +4460,12 @@ msgstr "" "負の *level* の値はサポートされなくなりました (デフォルト値の 0 に変更されま" "す)。" -#: ../../library/functions.rst:2384 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -"コマンドラインオプション :option:`-E` or :option:`-I` が指定された場合、環境" -"変数 :envvar:`PYTHONCASEOK` は無視されるようになりました。" +"コマンドラインオプション :option:`-E` または :option:`-I` が使われている場" +"合、環境変数 :envvar:`PYTHONCASEOK` は無視されるようになりました。" #: ../../library/functions.rst:2389 msgid "Footnotes" diff --git a/library/functools.po b/library/functools.po index 78da239de..1ce9fa97f 100644 --- a/library/functools.po +++ b/library/functools.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/functools.rst:2 @@ -32,16 +32,18 @@ msgstr ":mod:`!functools` --- 高階関数と呼び出し可能オブジェク msgid "**Source code:** :source:`Lib/functools.py`" msgstr "**ソースコード:** :source:`Lib/functools.py`" -#: ../../library/functools.rst:16 msgid "" "The :mod:`!functools` module is for higher-order functions: functions that " "act on or return other functions. In general, any callable object can be " "treated as a function for the purposes of this module." msgstr "" +":mod:`!functools` モジュールは、ほかの関数を操作したり返したりする高階関数の" +"ためのモジュールです。\n" +"一般に、このモジュールではあらゆる呼び出し可能オブジェクトを関数として扱えま" +"す。" -#: ../../library/functools.rst:20 msgid "The :mod:`!functools` module defines the following functions:" -msgstr "" +msgstr ":mod:`!functools` モジュールは次の関数を定義しています。" #: ../../library/functools.rst:24 msgid "" @@ -51,19 +53,21 @@ msgstr "" "簡単で軽量な無制限の関数キャッシュです。 `\"メモ化 (memoize)\" `_ とも呼ばれることがあります。" -#: ../../library/functools.rst:27 msgid "" "Returns the same as ``lru_cache(maxsize=None)``, creating a thin wrapper " "around a dictionary lookup for the function arguments. Because it never " "needs to evict old values, this is smaller and faster than :deco:`lru_cache` " "with a size limit." msgstr "" +"``lru_cache(maxsize=None)`` と同じものを返します。\n" +"関数の引数を辞書で検索する処理を薄いラッパーで包んだものです。\n" +"古い値を削除する必要がないため、サイズ制限付きの :deco:`lru_cache` より小さく" +"高速です。" #: ../../library/functools.rst:32 ../../library/functools.rst:294 msgid "For example::" msgstr "例えば::" -#: ../../library/functools.rst:34 msgid "" "@cache\n" "def factorial(n):\n" @@ -76,42 +80,64 @@ msgid "" ">>> factorial(12) # two new recursive calls, factorial(10) is cached\n" "479001600" msgstr "" +"@cache\n" +"def factorial(n):\n" +" return n * factorial(n-1) if n else 1\n" +"\n" +">>> factorial(10) # キャッシュ済みの結果がないため、11 回再帰呼び出しする\n" +"3628800\n" +">>> factorial(5) # 新たな呼び出しをせず、キャッシュ済みの結果を返す\n" +"120\n" +">>> factorial(12) # 2 回新たに再帰呼び出しする。factorial(10) はキャッシュ" +"済み\n" +"479001600" -#: ../../library/functools.rst:45 ../../library/functools.rst:155 msgid "" "The cache is threadsafe so that the wrapped function can be used in multiple " "threads. This means that the underlying data structure will remain coherent " "during concurrent updates." msgstr "" +"キャッシュはスレッドセーフなので、ラップされた関数を複数のスレッドで使用でき" +"ます。\n" +"これは、同時に更新が行われても、内部のデータ構造の整合性が保たれるという意味" +"です。" -#: ../../library/functools.rst:49 ../../library/functools.rst:159 msgid "" "It is possible for the wrapped function to be called more than once if " "another thread makes an additional call before the initial call has been " "completed and cached." msgstr "" +"最初の呼び出しが完了して結果がキャッシュされるまでに別のスレッドから呼び出さ" +"れた場合、ラップされた関数が複数回呼び出される可能性があります。" -#: ../../library/functools.rst:53 msgid "" "Call-once behavior is not guaranteed because locks are not held during the " "function call. Potentially another call with the same arguments could occur " "while the first call is still running." msgstr "" +"関数の呼び出し中はロックを保持しないため、呼び出しが 1 回だけになる保証はあり" +"ません。\n" +"最初の呼び出しがまだ実行中でも、同じ引数で別の呼び出しが行われる可能性があり" +"ます。" -#: ../../library/functools.rst:62 msgid "" "Transform a method of a class into a property whose value is computed once " "and then cached as a normal attribute for the life of the instance. Similar " "to :deco:`property`, with the addition of caching. Useful for expensive " "computed properties of instances that are otherwise effectively immutable." msgstr "" +"クラスのメソッドをプロパティに変換します。\n" +"その値は一度だけ計算され、インスタンスが存続する間は通常の属性としてキャッ" +"シュされます。\n" +":deco:`property` にキャッシュ機能を追加したようなものです。\n" +"それ以外の点では実質的にイミュータブルなインスタンスで、計算に時間のかかるプ" +"ロパティに役立ちます。" #: ../../library/functools.rst:67 ../../library/functools.rst:139 #: ../../library/functools.rst:435 msgid "Example::" msgstr "以下はプログラム例です::" -#: ../../library/functools.rst:69 msgid "" "class DataSet:\n" "\n" @@ -122,15 +148,25 @@ msgid "" " def stdev(self):\n" " return statistics.stdev(self._data)" msgstr "" +"class DataSet:\n" +"\n" +" def __init__(self, sequence_of_numbers):\n" +" self._data = tuple(sequence_of_numbers)\n" +"\n" +" @cached_property\n" +" def stdev(self):\n" +" return statistics.stdev(self._data)" -#: ../../library/functools.rst:78 msgid "" "The mechanics of :deco:`cached_property` are somewhat different from :deco:" "`property`. A regular property blocks attribute writes unless a setter is " "defined. In contrast, a *cached_property* allows writes." msgstr "" +":deco:`cached_property` の仕組みは :deco:`property` と少し異なります。\n" +"通常のプロパティでは、セッターが定義されていない限り属性への書き込みができま" +"せん。\n" +"これに対して *cached_property* は書き込みを許可します。" -#: ../../library/functools.rst:82 msgid "" "The *cached_property* decorator only runs on lookups and only when an " "attribute of the same name doesn't exist. When it does run, the " @@ -138,10 +174,11 @@ msgid "" "attribute reads and writes take precedence over the *cached_property* method " "and it works like a normal attribute." msgstr "" -"*cached_property* デコレータはルックアップテーブルで、同名の属性が存在しない" -"場合のみ動作します。動作した場合、 *cached_property* は同名の属性に書き込みを" -"行います。その後の属性の読み込みと書き込みは *cached_property* メソッドより優" -"先され、通常の属性のように働きます。" +"*cached_property* デコレータが実行されるのは、属性が検索され、かつ同名の属性" +"がまだ存在しない場合だけです。\n" +"実行されると、*cached_property* は同名の属性に値を書き込みます。\n" +"その後の属性の読み書きは *cached_property* メソッドより優先されるため、通常の" +"属性と同じように動作します。" #: ../../library/functools.rst:88 msgid "" @@ -151,7 +188,6 @@ msgstr "" "キャッシュされた値は属性を削除することで取り除くことができます。これにより " "*cached_property* メソッドを再度実行することが可能になります。" -#: ../../library/functools.rst:91 msgid "" "The *cached_property* does not prevent a possible race condition in multi-" "threaded usage. The getter function could run more than once on the same " @@ -161,15 +197,23 @@ msgid "" "necessary locking inside the decorated getter function or around the cached " "property access." msgstr "" +"*cached_property* は、複数スレッドで使用する際に起こり得る競合状態を防ぎませ" +"ん。\n" +"同じインスタンスに対してゲッター関数が複数回実行され、最後の実行がキャッシュ" +"の値を設定する場合があります。\n" +"キャッシュされるプロパティが冪等であるなど、同じインスタンスで複数回実行して" +"も害がなければ問題ありません。\n" +"同期が必要な場合は、デコレートしたゲッター関数内か、キャッシュされるプロパ" +"ティにアクセスする箇所の前後で、必要なロックを実装してください。" -#: ../../library/functools.rst:99 msgid "" "Note, this decorator interferes with the operation of :pep:`412` key-sharing " "dictionaries. This means that instance dictionaries can take more space " "than usual." msgstr "" -"このデコレータは :pep:`412` のキー共有辞書のインターフェースを持ちます。これ" -"は、インスタンス辞書がより多くのスペースを使う可能性があることを意味します。" +"このデコレータは :pep:`412` のキー共有辞書の動作を妨げる点に注意してくださ" +"い。\n" +"そのため、インスタンスの辞書が通常より多くのメモリを使うことがあります。" #: ../../library/functools.rst:103 msgid "" @@ -187,7 +231,6 @@ msgstr "" "``__dict__`` を含まない型 (それ自体が ``__dict__`` 属性を提供しないため) に対" "しては動作しないことを意味します。" -#: ../../library/functools.rst:110 msgid "" "If a mutable mapping is not available or if space-efficient key sharing is " "desired, an effect similar to :deco:`cached_property` can also be achieved " @@ -195,8 +238,12 @@ msgid "" "cache-method-calls` for more details on how this differs from :deco:" "`cached_property`." msgstr "" +"ミュータブルなマッピングを利用できない場合や、キーを共有してメモリを節約した" +"い場合は、:deco:`lru_cache` の上に :deco:`property` を重ねることでも :deco:" +"`cached_property` に似た効果を得られます。\n" +":deco:`cached_property` との違いについては :ref:`faq-cache-method-calls` を参" +"照してください。" -#: ../../library/functools.rst:117 msgid "" "Prior to Python 3.12, :deco:`!cached_property` included an undocumented lock " "to ensure that in multi-threaded usage the getter function was guaranteed to " @@ -204,6 +251,12 @@ msgid "" "instance, which could result in unacceptably high lock contention. In Python " "3.12+ this locking is removed." msgstr "" +"Python 3.12 より前の :deco:`!cached_property` にはドキュメントに記載されてい" +"ないロックがあり、複数スレッドで使用してもゲッター関数がインスタンスごとに 1 " +"回だけ実行されるよう保証していました。\n" +"しかし、このロックはインスタンス単位ではなくプロパティ単位だったため、ロック" +"の競合が許容できないほど多くなる場合がありました。\n" +"Python 3.12 以降では、このロックは削除されています。" #: ../../library/functools.rst:127 msgid "" @@ -232,10 +285,11 @@ msgstr "" "し可能オブジェクトです。key 関数は呼び出し可能オブジェクトで、1つの引数を受け" "取り、ソートキーとして使われる値を返します。" -#: ../../library/functools.rst:141 msgid "" "sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order" msgstr "" +"sorted(iterable, key=cmp_to_key(locale.strcoll)) # ロケールに応じた順序で" +"ソート" #: ../../library/functools.rst:143 msgid "" @@ -261,17 +315,16 @@ msgstr "" "結果のキャッシュには辞書が使われるので、関数の位置引数およびキーワード引数" "は :term:`ハッシュ可能 ` でなくてはなりません。" -#: ../../library/functools.rst:166 msgid "" "Distinct argument patterns may be considered to be distinct calls with " "separate cache entries. For example, ``f(a=1, b=2)`` and ``f(b=2, a=1)`` " "differ in their keyword argument order and may have two separate cache " "entries." msgstr "" -"引数のパターンが異なる場合は、異なる呼び出しと見なされ別々のキャッシュエント" -"リーとなります。\n" -"例えば、 ``f(a=1, b=2)`` と ``f(b=2, a=1)`` はキーワード引数の順序が異なって" -"いるので、2つの別個のキャッシュエントリーになります。" +"引数のパターンが異なると、別の呼び出しとして扱われ、個別のキャッシュエント" +"リーになることがあります。\n" +"例えば、``f(a=1, b=2)`` と ``f(b=2, a=1)`` はキーワード引数の順序が異なるた" +"め、2 つの別々のキャッシュエントリーになる可能性があります。" #: ../../library/functools.rst:171 msgid "" @@ -283,12 +336,14 @@ msgstr "" "れにより *lru_cache* デコレータがユーザー関数に直接適用できるようになります。" "このとき *maxsize* の値はデフォルトの 128 となります::" -#: ../../library/functools.rst:175 msgid "" "@lru_cache\n" "def count_vowels(word):\n" " return sum(word.count(vowel) for vowel in 'AEIOUaeiou')" msgstr "" +"@lru_cache\n" +"def count_vowels(word):\n" +" return sum(word.count(vowel) for vowel in 'AEIOUaeiou')" #: ../../library/functools.rst:179 msgid "" @@ -298,15 +353,17 @@ msgstr "" "*maxsize* が ``None`` に設定された場合は、LRU 機能は無効化され、キャッシュは" "際限無く大きくなります。" -#: ../../library/functools.rst:182 msgid "" "If *typed* is set to true, function arguments of different types will be " "cached separately. If *typed* is false, the implementation will usually " "regard them as equivalent calls and only cache a single result. (Some types " "such as *str* and *int* may be cached separately even when *typed* is false.)" msgstr "" +"*typed* を真にすると、型の異なる関数の引数は別々にキャッシュされます。\n" +"*typed* が偽の場合、通常は同等の呼び出しとして扱われ、結果は 1 つだけキャッ" +"シュされます。\n" +"(*str* や *int* など、*typed* が偽でも別々にキャッシュされる型もあります。)" -#: ../../library/functools.rst:188 msgid "" "Note, type specificity applies only to the function's immediate arguments " "rather than their contents. The scalar arguments, ``Decimal(42)`` and " @@ -314,52 +371,65 @@ msgid "" "contrast, the tuple arguments ``('answer', Decimal(42))`` and ``('answer', " "Fraction(42))`` are treated as equivalent." msgstr "" +"型の区別は関数に直接渡す引数にだけ適用され、その内容には適用されない点に注意" +"してください。\n" +"スカラーの引数 ``Decimal(42)`` と ``Fraction(42)`` は、結果の異なる別々の呼び" +"出しとして扱われます。\n" +"一方、タプルの引数 ``('answer', Decimal(42))`` と ``('answer', " +"Fraction(42))`` は同等として扱われます。" -#: ../../library/functools.rst:194 msgid "" "The wrapped function is instrumented with a :func:`!cache_parameters` " "function that returns a new :class:`dict` showing the values for *maxsize* " "and *typed*. This is for information purposes only. Mutating the values " "has no effect." msgstr "" +"ラップされた関数には、*maxsize* と *typed* の値を示す新しい :class:`dict` を" +"返す :func:`!cache_parameters` 関数が追加されます。\n" +"これは情報を得るためだけのもので、値を変更しても効果はありません。" -#: ../../library/functools.rst:202 msgid "" "To help measure the effectiveness of the cache and tune the *maxsize* " "parameter, the wrapped function is instrumented with a :func:`!cache_info` " "function that returns a :term:`named tuple` showing *hits*, *misses*, " "*maxsize* and *currsize*." msgstr "" +"キャッシュの効果の測定や *maxsize* 引数の調整に役立つように、ラップされた関数" +"には :func:`!cache_info` 関数が追加されます。\n" +"この関数は *hits*、*misses*、*maxsize*、*currsize* を示す :term:`名前付きタプ" +"ル ` を返します。" -#: ../../library/functools.rst:210 msgid "" "The decorator also provides a :func:`!cache_clear` function for clearing or " "invalidating the cache." msgstr "" +"このデコレータはキャッシュを消去または無効化するための :func:`!cache_clear` " +"関数も提供します。" -#: ../../library/functools.rst:213 msgid "" "The original underlying function is accessible through the :attr:" "`__wrapped__` attribute. This is useful for introspection, for bypassing " "the cache, or for rewrapping the function with a different cache." msgstr "" -"元々の基底の関数には、 :attr:`__wrapped__` 属性を通してアクセスできます。これ" -"はキャッシュを回避して、または関数を別のキャッシュでラップして、内観するのに" -"便利です。" +"ラップされた元の関数には :attr:`__wrapped__` 属性でアクセスできます。\n" +"これは内観やキャッシュの回避、別のキャッシュによる関数のラップし直しに便利で" +"す。" -#: ../../library/functools.rst:217 msgid "" "The cache keeps references to the arguments and return values until they age " "out of the cache or until the cache is cleared." msgstr "" +"引数と戻り値への参照は、古くなってキャッシュから削除されるか、キャッシュが消" +"去されるまで保持されます。" -#: ../../library/functools.rst:220 msgid "" "If a method is cached, the ``self`` instance argument is included in the " "cache. See :ref:`faq-cache-method-calls`" msgstr "" +"メソッドをキャッシュする場合、インスタンスの引数 ``self`` もキャッシュに含ま" +"れます。\n" +":ref:`faq-cache-method-calls` を参照してください。" -#: ../../library/functools.rst:223 msgid "" "An `LRU (least recently used) cache `_ works best when the " @@ -368,8 +438,13 @@ msgid "" "cache's size limit assures that the cache does not grow without bound on " "long-running processes such as web servers." msgstr "" +"`LRU (least recently used) キャッシュ `_ は、最近の呼び出しか" +"ら今後の呼び出しをよく予測できる場合に最も効果を発揮します (例えば、ニュース" +"サーバーで人気の記事は日ごとに変わる傾向があります)。\n" +"キャッシュのサイズ制限により、ウェブサーバーなど長時間実行するプロセスでも" +"キャッシュが際限なく増えることを防ぎます。" -#: ../../library/functools.rst:230 msgid "" "In general, the LRU cache should only be used when you want to reuse " "previously computed values. Accordingly, it doesn't make sense to cache " @@ -377,12 +452,16 @@ msgid "" "objects on each call (such as generators and async functions), or impure " "functions such as time() or random()." msgstr "" +"一般に LRU キャッシュは、以前計算した値を再利用したい場合にのみ使ってくださ" +"い。\n" +"したがって、副作用のある関数、呼び出すたびに別のミュータブルなオブジェクトを" +"作る必要のある関数 (ジェネレータや非同期関数など)、time() や random() のよう" +"な純粋でない関数をキャッシュしても意味がありません。" #: ../../library/functools.rst:236 msgid "Example of an LRU cache for static web content::" msgstr "静的 web コンテンツ の LRU キャッシュの例::" -#: ../../library/functools.rst:238 msgid "" "@lru_cache(maxsize=32)\n" "def get_pep(num):\n" @@ -401,6 +480,22 @@ msgid "" ">>> get_pep.cache_info()\n" "CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" msgstr "" +"@lru_cache(maxsize=32)\n" +"def get_pep(num):\n" +" 'Python Enhancement Proposal のテキストを取得する'\n" +" resource = f'https://peps.python.org/pep-{num:04d}'\n" +" try:\n" +" with urllib.request.urlopen(resource) as s:\n" +" return s.read()\n" +" except urllib.error.HTTPError:\n" +" return 'Not Found'\n" +"\n" +">>> for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:\n" +"... pep = get_pep(n)\n" +"... print(n, len(pep))\n" +"\n" +">>> get_pep.cache_info()\n" +"CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)" #: ../../library/functools.rst:255 msgid "" @@ -412,7 +507,6 @@ msgstr "" "の技法を実装し、`フィボナッチ数 `_ を効率よく計算する例::" -#: ../../library/functools.rst:261 msgid "" "@lru_cache(maxsize=None)\n" "def fib(n):\n" @@ -426,6 +520,17 @@ msgid "" ">>> fib.cache_info()\n" "CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" msgstr "" +"@lru_cache(maxsize=None)\n" +"def fib(n):\n" +" if n < 2:\n" +" return n\n" +" return fib(n-1) + fib(n-2)\n" +"\n" +">>> [fib(n) for n in range(16)]\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]\n" +"\n" +">>> fib.cache_info()\n" +"CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)" #: ../../library/functools.rst:275 msgid "Added the *typed* option." @@ -435,9 +540,8 @@ msgstr "*typed* オプションが追加されました。" msgid "Added the *user_function* option." msgstr "*user_function* オプションが追加されました。" -#: ../../library/functools.rst:281 msgid "Added the function :func:`!cache_parameters`" -msgstr "" +msgstr ":func:`!cache_parameters` 関数が追加されました。" #: ../../library/functools.rst:286 msgid "" @@ -449,14 +553,15 @@ msgstr "" "たクラスを受け取り、残りを実装するクラスデコレータです。このデコレータは全て" "の拡張順序比較演算をサポートするための労力を軽減します:" -#: ../../library/functools.rst:290 msgid "" "The class must define one of :meth:`~object.__lt__`, :meth:`~object." "__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`. In addition, the " "class should supply an :meth:`~object.__eq__` method." msgstr "" +"クラスには :meth:`~object.__lt__`、:meth:`~object.__le__`、:meth:`~object." +"__gt__`、:meth:`~object.__ge__` のいずれかを定義する必要があります。\n" +"加えて :meth:`~object.__eq__` メソッドも用意してください。" -#: ../../library/functools.rst:296 msgid "" "@total_ordering\n" "class Student:\n" @@ -474,6 +579,21 @@ msgid "" " return ((self.lastname.lower(), self.firstname.lower()) <\n" " (other.lastname.lower(), other.firstname.lower()))" msgstr "" +"@total_ordering\n" +"class Student:\n" +" def _is_valid_operand(self, other):\n" +" return (hasattr(other, \"lastname\") and\n" +" hasattr(other, \"firstname\"))\n" +" def __eq__(self, other):\n" +" if not self._is_valid_operand(other):\n" +" return NotImplemented\n" +" return ((self.lastname.lower(), self.firstname.lower()) ==\n" +" (other.lastname.lower(), other.firstname.lower()))\n" +" def __lt__(self, other):\n" +" if not self._is_valid_operand(other):\n" +" return NotImplemented\n" +" return ((self.lastname.lower(), self.firstname.lower()) <\n" +" (other.lastname.lower(), other.firstname.lower()))" #: ../../library/functools.rst:314 msgid "" @@ -490,25 +610,30 @@ msgstr "" "つの拡張比較メソッドをすべて実装すれば、簡単にスピードアップを図れるでしょ" "う。" -#: ../../library/functools.rst:323 msgid "" "This decorator makes no attempt to override methods that have been declared " "in the class *or its superclasses*. Meaning that if a superclass defines a " "comparison operator, *total_ordering* will not implement it again, even if " "the original method is abstract." msgstr "" +"このデコレータは、クラス *またはそのスーパークラス* で宣言されているメソッド" +"をオーバーライドしません。\n" +"つまり、スーパークラスが比較演算子を定義している場合は、元のメソッドが抽象メ" +"ソッドであっても *total_ordering* はそれを再実装しません。" -#: ../../library/functools.rst:330 msgid "" "Returning ``NotImplemented`` from the underlying comparison function for " "unrecognised types is now supported." msgstr "" +"認識できない型に対して、元の比較関数が ``NotImplemented`` を返すことをサポー" +"トしました。" -#: ../../library/functools.rst:336 msgid "" "A singleton object used as a sentinel to reserve a place for positional " "arguments when calling :func:`partial` and :func:`partialmethod`." msgstr "" +":func:`partial` や :func:`partialmethod` の呼び出し時に、位置引数の場所を確保" +"するための番兵として使うシングルトンオブジェクトです。" #: ../../library/functools.rst:344 msgid "" @@ -525,7 +650,6 @@ msgstr "" "は、それらで *keywords* を拡張または上書きします。おおよそ次のコードと等価で" "す::" -#: ../../library/functools.rst:351 msgid "" "def partial(func, /, *args, **keywords):\n" " def newfunc(*more_args, **more_keywords):\n" @@ -535,8 +659,14 @@ msgid "" " newfunc.keywords = keywords\n" " return newfunc" msgstr "" +"def partial(func, /, *args, **keywords):\n" +" def newfunc(*more_args, **more_keywords):\n" +" return func(*args, *more_args, **(keywords | more_keywords))\n" +" newfunc.func = func\n" +" newfunc.args = args\n" +" newfunc.keywords = keywords\n" +" return newfunc" -#: ../../library/functools.rst:359 msgid "" "The :func:`!partial` function is used for partial function application which " "\"freezes\" some portion of a function's arguments and/or keywords resulting " @@ -544,16 +674,24 @@ msgid "" "can be used to create a callable that behaves like the :func:`int` function " "where the *base* argument defaults to ``2``:" msgstr "" +":func:`!partial` 関数は関数の部分適用に使います。\n" +"関数の位置引数やキーワード引数の一部を「固定」し、より単純なシグネチャの新し" +"いオブジェクトを作ります。\n" +"例えば :func:`partial` を使うと、*base* 引数のデフォルトが ``2`` である点を除" +"いて :func:`int` 関数と同じように動作する、呼び出し可能オブジェクトを作れま" +"す。" -#: ../../library/functools.rst:365 msgid "" ">>> basetwo = partial(int, base=2)\n" ">>> basetwo.__doc__ = 'Convert base 2 string to an int.'\n" ">>> basetwo('10010')\n" "18" msgstr "" +">>> basetwo = partial(int, base=2)\n" +">>> basetwo.__doc__ = '2 進数の文字列を int に変換する。'\n" +">>> basetwo('10010')\n" +"18" -#: ../../library/functools.rst:372 msgid "" "If :data:`Placeholder` sentinels are present in *args*, they will be filled " "first when :func:`!partial` is called. This makes it possible to pre-fill " @@ -561,28 +699,38 @@ msgid "" "Placeholder`, only the chosen number of leading positional arguments can be " "pre-filled." msgstr "" +"*args* に :data:`Placeholder` の番兵が含まれている場合、:func:`!partial` の呼" +"び出し時にはその位置が先に埋められます。\n" +"これにより、:func:`!partial` の呼び出しで任意の位置引数をあらかじめ埋められま" +"す。\n" +":data:`!Placeholder` がなければ、先頭から指定した個数の位置引数しか埋められま" +"せん。" -#: ../../library/functools.rst:377 msgid "" "If any :data:`!Placeholder` sentinels are present, all must be filled at " "call time:" msgstr "" +":data:`!Placeholder` の番兵が含まれる場合、呼び出し時にすべてを埋める必要があ" +"ります。" -#: ../../library/functools.rst:379 msgid "" ">>> say_to_world = partial(print, Placeholder, Placeholder, \"world!\")\n" ">>> say_to_world('Hello', 'dear')\n" "Hello dear world!" msgstr "" +">>> say_to_world = partial(print, Placeholder, Placeholder, \"world!\")\n" +">>> say_to_world('Hello', 'dear')\n" +"Hello dear world!" -#: ../../library/functools.rst:385 msgid "" "Calling ``say_to_world('Hello')`` raises a :exc:`TypeError`, because only " "one positional argument is provided, but there are two placeholders that " "must be filled in." msgstr "" +"``say_to_world('Hello')`` を呼び出すと :exc:`TypeError` を送出します。\n" +"埋めるべきプレースホルダーが 2 つあるのに、位置引数が 1 つしか渡されていない" +"ためです。" -#: ../../library/functools.rst:389 msgid "" "If :func:`!partial` is applied to an existing :ref:`partial object `, :data:`!Placeholder` sentinels of the input object are filled in " @@ -590,8 +738,12 @@ msgid "" "new :data:`!Placeholder` sentinel to the place held by a previous :data:`!" "Placeholder`:" msgstr "" +"既存の :ref:`partial オブジェクト ` に :func:`!partial` を適" +"用すると、入力オブジェクトの :data:`!Placeholder` の番兵が新しい位置引数で埋" +"められます。\n" +"元の :data:`!Placeholder` の位置に新しい :data:`!Placeholder` の番兵を入れる" +"と、プレースホルダーを維持できます。" -#: ../../library/functools.rst:395 msgid "" ">>> from functools import partial, Placeholder as _\n" ">>> remove = partial(str.replace, _, _, '')\n" @@ -605,16 +757,27 @@ msgid "" ">>> remove_first_dear(message)\n" "'Hello, dear world!'" msgstr "" +">>> from functools import partial, Placeholder as _\n" +">>> remove = partial(str.replace, _, _, '')\n" +">>> message = 'Hello, dear dear world!'\n" +">>> remove(message, ' dear')\n" +"'Hello, world!'\n" +">>> remove_dear = partial(remove, _, ' dear')\n" +">>> remove_dear(message)\n" +"'Hello, world!'\n" +">>> remove_first_dear = partial(remove_dear, _, 1)\n" +">>> remove_first_dear(message)\n" +"'Hello, dear world!'" -#: ../../library/functools.rst:409 msgid "" ":data:`!Placeholder` cannot be passed to :func:`!partial` as a keyword " "argument." msgstr "" +":data:`!Placeholder` をキーワード引数として :func:`!partial` に渡すことはでき" +"ません。" -#: ../../library/functools.rst:411 msgid "Added support for :data:`Placeholder` in positional arguments." -msgstr "" +msgstr "位置引数での :data:`Placeholder` のサポートが追加されました。" #: ../../library/functools.rst:416 msgid "" @@ -634,7 +797,6 @@ msgstr "" "*func* は、:term:`descriptor` または呼び出し可能オブジェクトである必要があり" "ます (通常の関数など、両方の性質を持つオブジェクトは記述子として扱われます。)" -#: ../../library/functools.rst:423 msgid "" "When *func* is a descriptor (such as a normal Python function, :func:" "`classmethod`, :func:`staticmethod`, :func:`~abc.abstractmethod` or another " @@ -642,8 +804,11 @@ msgid "" "the underlying descriptor, and an appropriate :ref:`partial object` returned as the result." msgstr "" +"*func* がデスクリプタ (通常の Python 関数、:func:`classmethod`、:func:" +"`staticmethod`、:func:`~abc.abstractmethod`、別の :class:`partialmethod` イン" +"スタンスなど) の場合、``__get__`` の呼び出しは元のデスクリプタに委譲され、適" +"切な :ref:`partial オブジェクト ` が返されます。" -#: ../../library/functools.rst:429 msgid "" "When *func* is a non-descriptor callable, an appropriate bound method is " "created dynamically. This behaves like a normal Python function when used as " @@ -651,13 +816,12 @@ msgid "" "argument, even before the *args* and *keywords* supplied to the :class:" "`partialmethod` constructor." msgstr "" -"*func* が記述子以外の呼び出し可能オブジェクトである場合、適切な束縛メソッドが" -"動的に作成されます。この func は、メソッドとして使用された場合、Python の通常" -"の関数と同様に動作します。 :class:`partialmethod` コンストラクタに *args* と " -"*keywords* が渡されるよりも前に、 *self* 引数が最初の位置引数として挿入されま" -"す。" +"*func* が記述子ではない呼び出し可能オブジェクトの場合、適切な束縛メソッドを動" +"的に作成します。\n" +"これは通常の Python 関数をメソッドとして使う場合と同じように動作します。\n" +"*self* 引数は、:class:`partialmethod` コンストラクタに渡した *args* や " +"*keywords* よりも前に、最初の位置引数として挿入されます。" -#: ../../library/functools.rst:437 msgid "" ">>> class Cell:\n" "... def __init__(self):\n" @@ -677,8 +841,24 @@ msgid "" ">>> c.alive\n" "True" msgstr "" +">>> class Cell:\n" +"... def __init__(self):\n" +"... self._alive = False\n" +"... @property\n" +"... def alive(self):\n" +"... return self._alive\n" +"... def set_state(self, state):\n" +"... self._alive = bool(state)\n" +"... set_alive = partialmethod(set_state, True)\n" +"... set_dead = partialmethod(set_state, False)\n" +"...\n" +">>> c = Cell()\n" +">>> c.alive\n" +"False\n" +">>> c.set_alive()\n" +">>> c.alive\n" +"True" -#: ../../library/functools.rst:460 msgid "" "Apply *function* of two arguments cumulatively to the items of *iterable*, " "from left to right, so as to reduce the iterable to a single value. For " @@ -690,12 +870,21 @@ msgid "" "*initial* is not given and *iterable* contains only one item, the first item " "is returned." msgstr "" +"2 つの引数を取る *function* を、*iterable* の要素に左から右へ累積的に適用し、" +"単一の値にまとめます。\n" +"例えば ``reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])`` は " +"``((((1+2)+3)+4)+5)`` を計算します。\n" +"左の引数 *x* は累積した値、右の引数 *y* は *iterable* から得た、更新に使う値" +"です。\n" +"省略可能な *initial* を指定すると、計算時に ``iterable`` の要素より前に置か" +"れ、``iterable`` が空の場合のデフォルト値にもなります。\n" +"*initial* を指定せず、*iterable* に要素が 1 つしかない場合は、その要素を返し" +"ます。" #: ../../library/functools.rst:469 msgid "Roughly equivalent to::" msgstr "およそ次と等価です::" -#: ../../library/functools.rst:471 msgid "" "initial_missing = sentinel('initial_missing')\n" "\n" @@ -709,6 +898,17 @@ msgid "" " value = function(value, element)\n" " return value" msgstr "" +"initial_missing = sentinel('initial_missing')\n" +"\n" +"def reduce(function, iterable, /, initial=initial_missing):\n" +" it = iter(iterable)\n" +" if initial is initial_missing:\n" +" value = next(it)\n" +" else:\n" +" value = initial\n" +" for element in it:\n" +" value = function(value, element)\n" +" return value" #: ../../library/functools.rst:483 msgid "" @@ -718,9 +918,8 @@ msgstr "" "全ての中間値を返すイテレータについては :func:`itertools.accumulate` を参照し" "てください。" -#: ../../library/functools.rst:486 msgid "*initial* is now supported as a keyword argument." -msgstr "" +msgstr "*initial* をキーワード引数として指定できるようになりました。" #: ../../library/functools.rst:491 msgid "" @@ -730,14 +929,15 @@ msgstr "" "関数を :term:`シングルディスパッチ ` :term:`ジェネリック関" "数 ` に変換します。" -#: ../../library/functools.rst:494 msgid "" "To define a generic function, decorate it with the ``@singledispatch`` " "decorator. When defining a function using ``@singledispatch``, note that the " "dispatch happens on the type of the first argument::" msgstr "" +"ジェネリック関数を定義するには、``@singledispatch`` デコレータを付けます。\n" +"``@singledispatch`` で関数を定義する場合、ディスパッチは最初の引数の型に基づ" +"く点に注意してください。 ::" -#: ../../library/functools.rst:498 msgid "" ">>> from functools import singledispatch\n" ">>> @singledispatch\n" @@ -746,16 +946,25 @@ msgid "" "... print(\"Let me just say,\", end=\" \")\n" "... print(arg)" msgstr "" +">>> from functools import singledispatch\n" +">>> @singledispatch\n" +"... def fun(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Let me just say,\", end=\" \")\n" +"... print(arg)" -#: ../../library/functools.rst:508 msgid "" "To add overloaded implementations to the function, use the :func:`!register` " "attribute of the generic function, which can be used as a decorator. For " "functions annotated with types, the decorator will infer the type of the " "first argument automatically::" msgstr "" +"関数にオーバーロードした実装を追加するには、ジェネリック関数の :func:`!" +"register` 属性を使います。\n" +"この属性はデコレータとして使用できます。\n" +"型アノテーションのある関数の場合、デコレータは最初の引数の型を自動的に推論し" +"ます。 ::" -#: ../../library/functools.rst:513 msgid "" ">>> @fun.register\n" "... def _(arg: int, verbose=False):\n" @@ -770,12 +979,22 @@ msgid "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" msgstr "" +">>> @fun.register\n" +"... def _(arg: int, verbose=False):\n" +"... if verbose:\n" +"... print(\"Strength in numbers, eh?\", end=\" \")\n" +"... print(arg)\n" +"...\n" +">>> @fun.register\n" +"... def _(arg: list, verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" -#: ../../library/functools.rst:526 msgid ":class:`typing.Union` can also be used::" -msgstr "" +msgstr ":class:`typing.Union` も使えます。 ::" -#: ../../library/functools.rst:528 msgid "" ">>> @fun.register\n" "... def _(arg: int | float, verbose=False):\n" @@ -792,6 +1011,20 @@ msgid "" "... print(i, elem)\n" "..." msgstr "" +">>> @fun.register\n" +"... def _(arg: int | float, verbose=False):\n" +"... if verbose:\n" +"... print(\"Strength in numbers, eh?\", end=\" \")\n" +"... print(arg)\n" +"...\n" +">>> from typing import Union\n" +">>> @fun.register\n" +"... def _(arg: Union[list, set], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)\n" +"..." #: ../../library/functools.rst:543 msgid "" @@ -801,7 +1034,6 @@ msgstr "" "型アノテーションを使っていないコードについては、デコレータに適切な型引数を明" "示的に渡せます::" -#: ../../library/functools.rst:546 msgid "" ">>> @fun.register(complex)\n" "... def _(arg, verbose=False):\n" @@ -810,16 +1042,23 @@ msgid "" "... print(arg.real, arg.imag)\n" "..." msgstr "" +">>> @fun.register(complex)\n" +"... def _(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Better than complicated.\", end=\" \")\n" +"... print(arg.real, arg.imag)\n" +"..." -#: ../../library/functools.rst:553 msgid "" "For code that dispatches on a collections type (e.g., ``list``), but wants " "to typehint the items of the collection (e.g., ``list[int]``), the dispatch " "type should be passed explicitly to the decorator itself with the typehint " "going into the function definition::" msgstr "" +"コレクションの型 (例: ``list``) に基づいてディスパッチし、その要素には型ヒン" +"ト (例: ``list[int]``) を付けたい場合は、ディスパッチに使う型をデコレータに明" +"示的に渡し、型ヒントは関数定義に記述してください。 ::" -#: ../../library/functools.rst:558 msgid "" ">>> @fun.register(list)\n" "... def _(arg: list[int], verbose=False):\n" @@ -828,38 +1067,54 @@ msgid "" "... for i, elem in enumerate(arg):\n" "... print(i, elem)" msgstr "" +">>> @fun.register(list)\n" +"... def _(arg: list[int], verbose=False):\n" +"... if verbose:\n" +"... print(\"Enumerate this:\")\n" +"... for i, elem in enumerate(arg):\n" +"... print(i, elem)" -#: ../../library/functools.rst:567 msgid "" "At runtime the function will dispatch on an instance of a list regardless of " "the type contained within the list i.e. ``[1,2,3]`` will be dispatched the " "same as ``[\"foo\", \"bar\", \"baz\"]``. The annotation provided in this " "example is for static type checkers only and has no runtime impact." msgstr "" +"実行時には、リストに含まれる要素の型に関係なく、リストのインスタンスに対して" +"同じ実装を選びます。\n" +"つまり、``[1,2,3]`` と ``[\"foo\", \"bar\", \"baz\"]`` は同じようにディスパッ" +"チされます。\n" +"この例のアノテーションは静的型チェッカーのためだけのもので、実行時には影響し" +"ません。" -#: ../../library/functools.rst:573 msgid "" "To enable registering :term:`lambdas` and pre-existing functions, " "the :func:`~singledispatch.register` attribute can also be used in a " "functional form::" msgstr "" +":term:`ラムダ式 ` や既存の関数を登録できるように、:func:" +"`~singledispatch.register` 属性は関数として呼び出すこともできます。 ::" -#: ../../library/functools.rst:576 msgid "" ">>> def nothing(arg, verbose=False):\n" "... print(\"Nothing.\")\n" "...\n" ">>> fun.register(type(None), nothing)" msgstr "" +">>> def nothing(arg, verbose=False):\n" +"... print(\"Nothing.\")\n" +"...\n" +">>> fun.register(type(None), nothing)" -#: ../../library/functools.rst:581 msgid "" "The :func:`~singledispatch.register` attribute returns the undecorated " "function. This enables decorator stacking, :mod:`pickling`, and the " "creation of unit tests for each variant independently::" msgstr "" +":func:`~singledispatch.register` 属性は、デコレートする前の関数を返します。\n" +"これにより、デコレータを重ねたり、:mod:`pickle 化 ` したり、実装ごと" +"に独立した単体テストを作成したりできます。 ::" -#: ../../library/functools.rst:585 msgid "" ">>> @fun.register(float)\n" "... @fun.register(Decimal)\n" @@ -871,6 +1126,15 @@ msgid "" ">>> fun_num is fun\n" "False" msgstr "" +">>> @fun.register(float)\n" +"... @fun.register(Decimal)\n" +"... def fun_num(arg, verbose=False):\n" +"... if verbose:\n" +"... print(\"Half of your number:\", end=\" \")\n" +"... print(arg / 2)\n" +"...\n" +">>> fun_num is fun\n" +"False" #: ../../library/functools.rst:595 msgid "" @@ -878,7 +1142,6 @@ msgid "" "argument::" msgstr "汎用関数は、呼び出されると 1 つ目の引数の型でディスパッチします::" -#: ../../library/functools.rst:598 msgid "" ">>> fun(\"Hello, world.\")\n" "Hello, world.\n" @@ -897,8 +1160,23 @@ msgid "" ">>> fun(1.23)\n" "0.615" msgstr "" +">>> fun(\"Hello, world.\")\n" +"Hello, world.\n" +">>> fun(\"test.\", verbose=True)\n" +"Let me just say, test.\n" +">>> fun(42, verbose=True)\n" +"Strength in numbers, eh? 42\n" +">>> fun(['spam', 'spam', 'eggs', 'spam'], verbose=True)\n" +"Enumerate this:\n" +"0 spam\n" +"1 spam\n" +"2 eggs\n" +"3 spam\n" +">>> fun(None)\n" +"Nothing.\n" +">>> fun(1.23)\n" +"0.615" -#: ../../library/functools.rst:615 msgid "" "Where there is no registered implementation for a specific type, its method " "resolution order is used to find a more generic implementation. The original " @@ -906,10 +1184,11 @@ msgid "" "class:`object` type, which means it is used if no better implementation is " "found." msgstr "" -"特定の型について登録された実装が存在しない場合、その型のメソッド解決順序が、" -"汎用の実装をさらに検索するために使用されます。``@singledispatch`` でデコレー" -"トされた元の関数は基底の :class:`object` 型に登録されます。これは、他によりよ" -"い実装が見つからないことを意味します。" +"特定の型に対する実装が登録されていない場合、その型のメソッド解決順序に従っ" +"て、より汎用的な実装を探します。\n" +"``@singledispatch`` でデコレートした元の関数は、基底型 :class:`object` に対す" +"る実装として登録されます。\n" +"そのため、より適切な実装が見つからなければ元の関数が使われます。" #: ../../library/functools.rst:621 msgid "" @@ -920,7 +1199,6 @@ msgstr "" "抽象基底クラス (:term:`abstract base class`) に対して実装が登録されると、基底" "クラスの仮想サブクラスに対してもその実装がディスパッチされます::" -#: ../../library/functools.rst:625 msgid "" ">>> from collections.abc import Mapping\n" ">>> @fun.register\n" @@ -933,6 +1211,16 @@ msgid "" ">>> fun({\"a\": \"b\"})\n" "a => b" msgstr "" +">>> from collections.abc import Mapping\n" +">>> @fun.register\n" +"... def _(arg: Mapping, verbose=False):\n" +"... if verbose:\n" +"... print(\"Keys & Values\")\n" +"... for key, value in arg.items():\n" +"... print(key, \"=>\", value)\n" +"...\n" +">>> fun({\"a\": \"b\"})\n" +"a => b" #: ../../library/functools.rst:636 msgid "" @@ -970,17 +1258,19 @@ msgid "" "" msgstr "" -#: ../../library/functools.rst:658 msgid "" "The :func:`~singledispatch.register` attribute now supports using type " "annotations." msgstr "" +":func:`~singledispatch.register` 属性が型アノテーションの使用をサポートしまし" +"た。" -#: ../../library/functools.rst:661 msgid "" "The :func:`~singledispatch.register` attribute now supports :class:`typing." "Union` as a type annotation." msgstr "" +":func:`~singledispatch.register` 属性が型アノテーションとして :class:`typing." +"Union` をサポートしました。" #: ../../library/functools.rst:668 msgid "" @@ -990,15 +1280,17 @@ msgstr "" "メソッドを :term:`シングルディスパッチ ` :term:`ジェネリック" "関数 ` に変換します。" -#: ../../library/functools.rst:671 msgid "" "To define a generic method, decorate it with the ``@singledispatchmethod`` " "decorator. When defining a method using ``@singledispatchmethod``, note that " "the dispatch happens on the type of the first non-*self* or non-*cls* " "argument::" msgstr "" +"ジェネリックメソッドを定義するには、``@singledispatchmethod`` デコレータを付" +"けます。\n" +"``@singledispatchmethod`` でメソッドを定義する場合、*self* と *cls* を除いた" +"最初の引数の型に基づいてディスパッチされる点に注意してください。 ::" -#: ../../library/functools.rst:676 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1013,8 +1305,19 @@ msgid "" " def _(self, arg: bool):\n" " return not arg" msgstr "" +"class Negator:\n" +" @singledispatchmethod\n" +" def neg(self, arg):\n" +" raise NotImplementedError(\"Cannot negate a\")\n" +"\n" +" @neg.register\n" +" def _(self, arg: int):\n" +" return -arg\n" +"\n" +" @neg.register\n" +" def _(self, arg: bool):\n" +" return not arg" -#: ../../library/functools.rst:689 msgid "" "``@singledispatchmethod`` supports nesting with other decorators such as :" "deco:`classmethod`. Note that to allow for ``dispatcher.register``, " @@ -1022,8 +1325,13 @@ msgid "" "``Negator`` class with the ``neg`` methods bound to the class, rather than " "an instance of the class::" msgstr "" +"``@singledispatchmethod`` は :deco:`classmethod` などのデコレータと重ねて使え" +"ます。\n" +"ただし ``dispatcher.register`` を使うには、``singledispatchmethod`` が *最も" +"外側* のデコレータでなければなりません。\n" +"次の ``Negator`` クラスでは、``neg`` メソッドをインスタンスではなくクラスに束" +"縛しています。 ::" -#: ../../library/functools.rst:695 msgid "" "class Negator:\n" " @singledispatchmethod\n" @@ -1041,18 +1349,34 @@ msgid "" " def _(cls, arg: bool):\n" " return not arg" msgstr "" +"class Negator:\n" +" @singledispatchmethod\n" +" @classmethod\n" +" def neg(cls, arg):\n" +" raise NotImplementedError(\"Cannot negate a\")\n" +"\n" +" @neg.register\n" +" @classmethod\n" +" def _(cls, arg: int):\n" +" return -arg\n" +"\n" +" @neg.register\n" +" @classmethod\n" +" def _(cls, arg: bool):\n" +" return not arg" -#: ../../library/functools.rst:711 msgid "" "The same pattern can be used for other similar decorators: :deco:" "`staticmethod`, :deco:`~abc.abstractmethod`, and others." msgstr "" +":deco:`staticmethod`、:deco:`~abc.abstractmethod` など、同様のデコレータにも" +"この方法を使えます。" -#: ../../library/functools.rst:716 msgid "Added support of non-:term:`descriptor` callables." msgstr "" +":term:`descriptor` ではない呼び出し可能オブジェクトのサポートが追加されまし" +"た。" -#: ../../library/functools.rst:722 msgid "" "Update a *wrapper* function to look like the *wrapped* function. The " "optional arguments are tuples to specify which attributes of the original " @@ -1067,14 +1391,28 @@ msgid "" "the wrapper function's :attr:`~function.__dict__`, i.e. the instance " "dictionary)." msgstr "" +"*wrapper* 関数を更新し、*wrapped* 関数と同じ属性を持つようにします。\n" +"省略可能な引数はタプルで、元の関数のどの属性をラッパー関数の同名の属性に直接" +"代入するか、またラッパー関数のどの属性を元の関数の同名の属性で更新するかを指" +"定します。\n" +"これらの引数のデフォルト値はモジュールレベルの定数 ``WRAPPER_ASSIGNMENTS`` " +"と ``WRAPPER_UPDATES`` です。\n" +"前者はラッパー関数の :attr:`~function.__module__`、:attr:`~function." +"__name__`、:attr:`~function.__qualname__`、:attr:`~function." +"__annotations__`、:attr:`~function.__type_params__`、およびドキュメンテーショ" +"ン文字列 :attr:`~function.__doc__` に代入し、後者は :attr:`~function." +"__dict__` (インスタンスの辞書) を更新します。" -#: ../../library/functools.rst:734 msgid "" "To allow access to the original function for introspection and other " "purposes (e.g. bypassing a caching decorator such as :deco:`lru_cache`), " "this function automatically adds a ``__wrapped__`` attribute to the wrapper " "that refers to the function being wrapped." msgstr "" +"内観などの目的で元の関数にアクセスできるように (例えば :deco:`lru_cache` のよ" +"うなキャッシュ用デコレータを回避できるように)、この関数はラッパーに " +"``__wrapped__`` 属性を自動的に追加します。\n" +"この属性はラップされた元の関数を参照します。" #: ../../library/functools.rst:739 msgid "" @@ -1103,27 +1441,30 @@ msgstr "" "とは試みられません)。しかし、 *updated* で指名された属性がラッパー関数自身に" "存在しないなら :exc:`AttributeError` が送出されます。" -#: ../../library/functools.rst:751 msgid "" "The ``__wrapped__`` attribute is now automatically added. The :attr:" "`~function.__annotations__` attribute is now copied by default. Missing " "attributes no longer trigger an :exc:`AttributeError`." msgstr "" +"``__wrapped__`` 属性が自動的に追加されるようになりました。\n" +":attr:`~function.__annotations__` 属性がデフォルトでコピーされるようになりま" +"した。\n" +"属性が欠けていても :exc:`AttributeError` を送出しなくなりました。" -#: ../../library/functools.rst:756 msgid "" "The ``__wrapped__`` attribute now always refers to the wrapped function, " "even if that function defined a ``__wrapped__`` attribute. (see :issue:" "`17482`)" msgstr "" -"ラップされた関数が ``__wrapped__`` を定義していない場合でも、 " -"``__wrapped__`` が常にラップされた関数を参照するようになりました。(:issue:" -"`17482` を参照)" +"ラップされた関数が ``__wrapped__`` を定義している場合でも、 ``__wrapped__`` " +"が常にラップされた関数を参照するようになりました。\n" +"(:issue:`17482` を参照)" -#: ../../library/functools.rst:761 msgid "" "The :attr:`~function.__type_params__` attribute is now copied by default." msgstr "" +":attr:`~function.__type_params__` 属性がデフォルトでコピーされるようになりま" +"した。" #: ../../library/functools.rst:767 msgid "" @@ -1136,7 +1477,6 @@ msgstr "" "して呼び出す便宜関数です。これは ``partial(update_wrapper, wrapped=wrapped, " "assigned=assigned, updated=updated)`` と等価です。例えば::" -#: ../../library/functools.rst:772 msgid "" ">>> from functools import wraps\n" ">>> def my_decorator(f):\n" @@ -1159,13 +1499,35 @@ msgid "" ">>> example.__doc__\n" "'Docstring'" msgstr "" +">>> from functools import wraps\n" +">>> def my_decorator(f):\n" +"... @wraps(f)\n" +"... def wrapper(*args, **kwds):\n" +"... print('Calling decorated function')\n" +"... return f(*args, **kwds)\n" +"... return wrapper\n" +"...\n" +">>> @my_decorator\n" +"... def example():\n" +"... \"\"\"Docstring\"\"\"\n" +"... print('Called example function')\n" +"...\n" +">>> example()\n" +"Calling decorated function\n" +"Called example function\n" +">>> example.__name__\n" +"'example'\n" +">>> example.__doc__\n" +"'Docstring'" -#: ../../library/functools.rst:793 msgid "" "Without the use of this decorator factory, the name of the example function " "would have been ``'wrapper'``, and the docstring of the original :func:`!" "example` would have been lost." msgstr "" +"このデコレータファクトリを使わなければ、例の関数の名前は ``'wrapper'`` にな" +"り、元の :func:`!example` のドキュメンテーション文字列は失われていたはずで" +"す。" #: ../../library/functools.rst:801 msgid ":class:`partial` Objects" @@ -1202,7 +1564,6 @@ msgid "" msgstr "" ":class:`partial` オブジェクトの呼び出し時に渡されるキーワード引数です。" -#: ../../library/functools.rst:824 msgid "" ":class:`partial` objects are like :ref:`function objects ` in that they are callable, weak referenceable, and can have " @@ -1210,3 +1571,8 @@ msgid "" "`~definition.__name__` and :attr:`~definition.__doc__` attributes are not " "created automatically." msgstr "" +":class:`partial` オブジェクトは、呼び出し可能で、弱参照でき、属性を持てるとい" +"う点で :ref:`関数オブジェクト ` に似ています。\n" +"ただし重要な違いもあります。\n" +"例えば :attr:`~definition.__name__` と :attr:`~definition.__doc__` 属性は自動" +"的には作成されません。" diff --git a/library/gc.po b/library/gc.po index 0d1e20a20..f5d8f98f4 100644 --- a/library/gc.po +++ b/library/gc.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/gc.rst:2 @@ -49,9 +49,8 @@ msgstr "" "DEBUG_SAVEALL`` を含んでいることに注意しましょう。ガベージとして検出されたオ" "ブジェクトは、インスペクション用に gc.garbage に保存されます。" -#: ../../library/gc.rst:20 msgid "The :mod:`!gc` module provides the following functions:" -msgstr "" +msgstr ":mod:`!gc` モジュールは次の関数を提供します。" #: ../../library/gc.rst:25 msgid "Enable automatic garbage collection." @@ -65,13 +64,17 @@ msgstr "自動ガベージコレクションを無効にします。" msgid "Return ``True`` if automatic collection is enabled." msgstr "自動ガベージコレクションが有効なら ``True`` を返します。" -#: ../../library/gc.rst:40 msgid "" "With no arguments, run a full collection. The optional argument " "*generation* may be an integer specifying which generation to collect (from " "0 to 2). A :exc:`ValueError` is raised if the generation number is invalid. " "The sum of collected objects and uncollectable objects is returned." msgstr "" +"引数を指定しない場合は完全な回収を行います。\n" +"省略可能な引数 *generation* には、回収する世代を整数 (0〜2) で指定できま" +"す。\n" +"世代の番号が不正な場合は :exc:`ValueError` を送出します。\n" +"回収したオブジェクト数と回収不能だったオブジェクト数の合計を返します。" #: ../../library/gc.rst:45 msgid "" @@ -84,19 +87,18 @@ msgstr "" "れます。 :class:`float` など、実装によって幾つかの free list では全ての要素が" "解放されるわけではありません。" -#: ../../library/gc.rst:50 msgid "" "The effect of calling ``gc.collect()`` while the interpreter is already " "performing a collection is undefined." msgstr "" +"インタープリタがすでに回収を行っている間に ``gc.collect()`` を呼び出した場合" +"の動作は未定義です。" -#: ../../library/gc.rst:53 msgid "``generation=1`` performs an increment of collection." -msgstr "" +msgstr "``generation=1`` は回収を段階的に進めるようになりました。" -#: ../../library/gc.rst:56 msgid "``generation=1`` performs collection of the middle generation." -msgstr "" +msgstr "``generation=1`` は中間の世代を回収するようになりました。" #: ../../library/gc.rst:62 msgid "" @@ -112,32 +114,32 @@ msgstr "" msgid "Return the debugging flags currently set." msgstr "現在のデバッグフラグを返します。" -#: ../../library/gc.rst:74 msgid "" "Returns a list of all objects tracked by the collector, excluding the list " "returned. If *generation* is not ``None``, return only the objects tracked " "by the collector that are in that generation." msgstr "" +"ガベージコレクタが追跡しているすべてのオブジェクトのリストを返します。\n" +"返すリスト自体は含まれません。\n" +"*generation* が ``None`` でない場合は、その世代に属する追跡対象のオブジェクト" +"だけを返します。" #: ../../library/gc.rst:78 msgid "New *generation* parameter." msgstr "新しい *generation* パラメータ。" -#: ../../library/gc.rst:81 msgid "Generation 1 is removed" -msgstr "" +msgstr "世代 1 が削除されました。" -#: ../../library/gc.rst:84 msgid "Generation 1 is reintroduced to maintain GC behavior from 3.13." -msgstr "" +msgstr "3.13 の GC の動作を維持するために、世代 1 が再導入されました。" -#: ../../library/gc.rst:87 msgid "" "Raises an :ref:`auditing event ` ``gc.get_objects`` with argument " "``generation``." msgstr "" "引数 ``generation`` で :ref:`監査イベント ` ``gc.get_objects`` を送" -"出します。 " +"出します。" #: ../../library/gc.rst:91 msgid "" @@ -159,28 +161,28 @@ msgid "" "generation;" msgstr "``collected`` は、この世代内で回収されたオブジェクトの総数です;" -#: ../../library/gc.rst:101 msgid "" "``uncollectable`` is the total number of objects which were found to be " "uncollectable (and were therefore moved to the :data:`garbage` list) inside " "this generation;" msgstr "" +"``uncollectable`` は、この世代で回収不能と判定された (そのため :data:" +"`garbage` リストに移された) オブジェクトの総数です。" -#: ../../library/gc.rst:105 msgid "" "``candidates`` is the total number of objects in this generation which were " "considered for collection and traversed;" msgstr "" +"``candidates`` は、この世代で回収の候補として参照をたどったオブジェクトの総数" +"です。" -#: ../../library/gc.rst:108 msgid "" "``duration`` is the total time in seconds spent in collections for this " "generation." -msgstr "" +msgstr "``duration`` は、この世代の回収に費やした合計時間 (秒) です。" -#: ../../library/gc.rst:113 msgid "Add ``duration`` and ``candidates``." -msgstr "" +msgstr "``duration`` と ``candidates`` が追加されました。" #: ../../library/gc.rst:119 msgid "" @@ -190,7 +192,6 @@ msgstr "" "ガベージコレクションの閾値(検出頻度)を指定します。 *threshold0* を 0 にする" "と、検出は行われません。" -#: ../../library/gc.rst:122 msgid "" "The GC classifies objects into three generations depending on how many " "collection sweeps they have survived. New objects are placed in the " @@ -209,20 +210,35 @@ msgid "" "garbage_collector.md#collecting-the-oldest-generation>`_ for more " "information." msgstr "" +"GC は、何回の回収を生き残ったかに応じてオブジェクトを 3 つの世代に分類しま" +"す。\n" +"新しいオブジェクトは最も若い世代 (世代 ``0``) に置かれます。\n" +"回収を生き残ったオブジェクトは、1 つ古い世代に移されます。\n" +"世代 ``2`` が最も古い世代なので、その世代のオブジェクトは回収後も同じ世代に残" +"ります。\n" +"ガベージコレクタは、実行する時期を決めるために、前回の回収以降のオブジェクト" +"の割り当て数と解放数を記録しています。\n" +"割り当て数から解放数を引いた値が *threshold0* を超えると回収を開始します。\n" +"最初は世代 ``0`` だけを調べます。\n" +"世代 ``1`` を最後に調べてから世代 ``0`` を調べた回数が *threshold1* を超える" +"と、世代 ``1`` も調べます。\n" +"3 番目の世代の処理は少し複雑です。\n" +"詳しくは `最も古い世代の回収 `_ を参照してください。" -#: ../../library/gc.rst:136 msgid "" "See `Garbage collector design `_ for more information." msgstr "" +"詳しくは `ガベージコレクタの設計 `_ を参照してください。" -#: ../../library/gc.rst:138 msgid "*threshold2* is ignored" -msgstr "" +msgstr "*threshold2* が無視されるようになりました。" -#: ../../library/gc.rst:141 msgid "*threshold2* is restored to match Python 3.13 behavior." -msgstr "" +msgstr "Python 3.13 の動作に合わせて *threshold2* が復活しました。" #: ../../library/gc.rst:147 msgid "" @@ -273,15 +289,13 @@ msgstr "" "ある場合があるので、利用する際には注意が必要です。 :func:`get_referrers` をデ" "バッグ以外の目的で利用するのは避けてください。" -#: ../../library/gc.rst:175 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referrers`` with " "argument ``objs``." msgstr "" "引数 ``objs`` を指定して :ref:`監査イベント ` ``gc.get_referrers`` " -"を送出します。 " +"を送出します。" -#: ../../library/gc.rst:180 msgid "" "Return a list of objects directly referred to by any of the arguments. The " "referents returned are those objects visited by the arguments' C-level :c:" @@ -292,22 +306,22 @@ msgid "" "example, if an integer is directly reachable from an argument, that integer " "object may or may not appear in the result list." msgstr "" -"引数で指定したオブジェクトのいずれかから参照されている、全てのオブジェクトの" -"リストを返します。参照先のオブジェクトは、引数で指定したオブジェクトの Cレベ" -"ルメソッド :c:member:`~PyTypeObject.tp_traverse` で取得し、全てのオブジェクト" -"が直接到達可能な全てのオブジェクトを返すわけではありません。 :c:member:" -"`~PyTypeObject.tp_traverse` はガベージコレクションをサポートするオブジェクト" -"のみが実装しており、ここで取得できるオブジェクトは循環参照の一部となる可能性" -"のあるオブジェクトのみです。従って、例えば整数オブジェクトが直接到達可能で" -"あっても、このオブジェクトは戻り値には含まれません。" +"引数のいずれかから直接参照されているオブジェクトのリストを返します。\n" +"返される参照先は、各引数の C レベルの :c:member:`~PyTypeObject.tp_traverse` " +"メソッド (存在する場合) がたどったオブジェクトであり、実際に直接到達できるオ" +"ブジェクトがすべて含まれるとは限りません。\n" +":c:member:`~PyTypeObject.tp_traverse` メソッドをサポートするのはガベージコレ" +"クションをサポートするオブジェクトだけで、循環参照に関与し得るオブジェクトだ" +"けをたどることが要求されます。\n" +"例えば、引数から整数オブジェクトに直接到達できる場合、その整数が結果のリスト" +"に含まれることも、含まれないこともあります。" -#: ../../library/gc.rst:188 msgid "" "Raises an :ref:`auditing event ` ``gc.get_referents`` with " "argument ``objs``." msgstr "" "引数 ``objs`` を指定して :ref:`監査イベント ` ``gc.get_referents`` " -"を送出します。 " +"を送出します。" #: ../../library/gc.rst:192 msgid "" @@ -341,13 +355,13 @@ msgid "" "True" msgstr "" -#: ../../library/gc.rst:215 msgid "" "Returns ``True`` if the given object has been finalized by the garbage " "collector, ``False`` otherwise. ::" msgstr "" +"指定したオブジェクトがガベージコレクタによってファイナライズ済みの場合は " +"``True``、そうでなければ ``False`` を返します。 ::" -#: ../../library/gc.rst:218 msgid "" ">>> x = None\n" ">>> class Lazarus:\n" @@ -362,14 +376,26 @@ msgid "" ">>> gc.is_finalized(x)\n" "True" msgstr "" +">>> x = None\n" +">>> class Lazarus:\n" +"... def __del__(self):\n" +"... global x\n" +"... x = self\n" +"...\n" +">>> lazarus = Lazarus()\n" +">>> gc.is_finalized(lazarus)\n" +"False\n" +">>> del lazarus\n" +">>> gc.is_finalized(x)\n" +"True" -#: ../../library/gc.rst:236 msgid "" "Freeze all the objects tracked by the garbage collector; move them to a " "permanent generation and ignore them in all the future collections." msgstr "" +"ガベージコレクタが追跡しているすべてのオブジェクトを凍結します。\n" +"これらのオブジェクトは永続世代に移され、以降のすべての回収で無視されます。" -#: ../../library/gc.rst:239 msgid "" "If a process will ``fork()`` without ``exec()``, avoiding unnecessary copy-" "on-write in child processes will maximize memory sharing and reduce overall " @@ -380,6 +406,14 @@ msgid "" "early in the parent process, ``gc.freeze()`` right before ``fork()``, and " "``gc.enable()`` early in child processes." msgstr "" +"プロセスが ``exec()`` を行わずに ``fork()`` する場合、子プロセスで不要なコ" +"ピーオンライトを避けることで、メモリ共有を最大限に活用し、全体のメモリ使用量" +"を減らせます。\n" +"そのためには、親プロセスのメモリページ内に解放済みの「穴」ができることを避け" +"るとともに、子プロセスの GC が、親プロセス由来の長寿命オブジェクトの " +"``gc_refs`` カウンタに触れないようにする必要があります。\n" +"両方を実現するには、親プロセスの早い段階で ``gc.disable()``、``fork()`` の直" +"前に ``gc.freeze()``、子プロセスの早い段階で ``gc.enable()`` を呼び出します。" #: ../../library/gc.rst:253 msgid "" @@ -393,13 +427,12 @@ msgstr "" msgid "Return the number of objects in the permanent generation." msgstr "Permanent世代領域にあるオブジェクトの数を返します。" -#: ../../library/gc.rst:266 msgid "" "The following variables are provided for read-only access (you can mutate " "the values but should not rebind them):" msgstr "" -"以下の変数は読み出し専用アクセスのために提供されています。(この変数を操作する" -"ことはできますが、その値は記憶されません):" +"以下の変数は読み出し専用で提供されます (参照先の値を変更することはできます" +"が、変数に別の値を再代入すべきではありません):" #: ../../library/gc.rst:271 msgid "" @@ -433,11 +466,12 @@ msgstr "" "す。 :const:`DEBUG_UNCOLLECTABLE` がセットされていると、加えて回収不能オブ" "ジェクトを出力します。" -#: ../../library/gc.rst:285 msgid "" "Following :pep:`442`, objects with a :meth:`~object.__del__` method don't " "end up in :data:`gc.garbage` anymore." msgstr "" +":pep:`442` に従い、:meth:`~object.__del__` メソッドを持つオブジェクトが :" +"data:`gc.garbage` に入らなくなりました。" #: ../../library/gc.rst:291 msgid "" @@ -487,17 +521,17 @@ msgstr "" "\"uncollectable\": *phase* が \"stop\" のとき、回収出来ずに :data:`garbage` " "リストに入れられたオブジェクトの数。" -#: ../../library/gc.rst:312 msgid "" "\"candidates\": When *phase* is \"stop\", the total number of objects in " "this generation which were considered for collection and traversed." msgstr "" +"\"candidates\": *phase* が \"stop\" の場合、この世代で回収の候補として参照を" +"たどったオブジェクトの総数。" -#: ../../library/gc.rst:315 msgid "" "\"duration\": When *phase* is \"stop\", the time in seconds spent in the " "collection." -msgstr "" +msgstr "\"duration\": *phase* が \"stop\" の場合、回収に費やした時間 (秒)。" #: ../../library/gc.rst:318 msgid "" @@ -523,9 +557,8 @@ msgstr "" ":data:`garbage` に回収できない独自の型のオブジェクトが現れたとき、アプリケー" "ションがそれらを特定し消去できるようにする。" -#: ../../library/gc.rst:330 msgid "Add \"duration\" and \"candidates\"." -msgstr "" +msgstr "\"duration\" と \"candidates\" が追加されました。" #: ../../library/gc.rst:334 msgid "The following constants are provided for use with :func:`set_debug`:" diff --git a/library/getopt.po b/library/getopt.po index af999066e..f8ce51ad5 100644 --- a/library/getopt.po +++ b/library/getopt.po @@ -16,21 +16,19 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" -#: ../../library/getopt.rst:2 msgid ":mod:`!getopt` --- C-style parser for command line options" -msgstr "" +msgstr ":mod:`!getopt` --- C 形式のコマンドラインオプション解析" #: ../../library/getopt.rst:8 msgid "**Source code:** :source:`Lib/getopt.py`" msgstr "**ソースコード:** :source:`Lib/getopt.py`" -#: ../../library/getopt.rst:12 msgid "" "This module is considered feature complete. A more declarative and " "extensible alternative to this API is provided in the :mod:`optparse` " @@ -38,8 +36,12 @@ msgid "" "processing are provided either as third party modules on PyPI, or else as " "features in the :mod:`argparse` module." msgstr "" +"このモジュールは機能が完成したものとされています。\n" +"この API より宣言的で拡張しやすい代替手段として、:mod:`optparse` モジュールが" +"あります。\n" +"コマンドライン引数処理のさらなる機能拡張は、PyPI のサードパーティーモジュール" +"か、:mod:`argparse` モジュールの機能として提供されます。" -#: ../../library/getopt.rst:20 msgid "" "This module helps scripts to parse the command line arguments in ``sys." "argv``. It supports the same conventions as the Unix :c:func:`!getopt` " @@ -47,8 +49,13 @@ msgid "" "and '``--``'). Long options similar to those supported by GNU software may " "be used as well via an optional third argument." msgstr "" +"このモジュールは、スクリプトで ``sys.argv`` のコマンドライン引数を解析する際" +"に役立ちます。\n" +"Unix の :c:func:`!getopt` 関数と同じ規則をサポートします (引数 \"``-``\" と " +"\"``--``\" の特別な意味も含みます)。\n" +"省略可能な第 3 引数により、GNU ソフトウェアがサポートするものと同様の長形式の" +"オプションも使えます。" -#: ../../library/getopt.rst:26 msgid "" "Users who are unfamiliar with the Unix :c:func:`!getopt` function should " "consider using the :mod:`argparse` module instead. Users who are familiar " @@ -57,12 +64,17 @@ msgid "" "should consider using the :mod:`optparse` module. See :ref:`choosing-an-" "argument-parser` for additional details." msgstr "" +"Unix の :c:func:`!getopt` 関数に不慣れな場合は、代わりに :mod:`argparse` モ" +"ジュールの使用を検討してください。\n" +"Unix の :c:func:`!getopt` 関数に慣れていて、同等の動作をより少ないコードで実" +"現し、より適切なヘルプやエラーメッセージを得たい場合は、:mod:`optparse` モ" +"ジュールの使用を検討してください。\n" +"詳しくは :ref:`choosing-an-argument-parser` を参照してください。" #: ../../library/getopt.rst:33 msgid "This module provides two functions and an exception:" msgstr "このモジュールは2つの関数と1つの例外を提供しています:" -#: ../../library/getopt.rst:39 msgid "" "Parses command line options and parameter list. *args* is the argument list " "to be parsed, without the leading reference to the running program. " @@ -72,15 +84,24 @@ msgid "" "argument followed by two colons (``'::'``); i.e., the same format that Unix :" "c:func:`!getopt` uses." msgstr "" +"コマンドラインのオプションと引数のリストを解析します。\n" +"*args* は解析する引数のリストで、先頭にある実行中のプログラムを示す要素は除き" +"ます。\n" +"通常は ``sys.argv[1:]`` です。\n" +"*shortopts* はスクリプトが認識するオプションの文字を並べた文字列です。\n" +"引数が必須のオプションの後ろにはコロン (``':'``) を 1 つ、省略可能な引数を取" +"るオプションの後ろには 2 つ (``'::'``) 付けます。\n" +"これは Unix の :c:func:`!getopt` が使うのと同じ形式です。" -#: ../../library/getopt.rst:48 msgid "" "Unlike GNU :c:func:`!getopt`, after a non-option argument, all further " "arguments are considered also non-options. This is similar to the way non-" "GNU Unix systems work." msgstr "" +"GNU の :c:func:`!getopt` とは異なり、オプションでない引数が現れると、それ以降" +"のすべての引数もオプションではないものとして扱います。\n" +"これは GNU 以外の Unix システムと同様の動作です。" -#: ../../library/getopt.rst:52 msgid "" "*longopts*, if specified, must be a list of strings with the names of the " "long options which should be supported. The leading ``'--'`` characters " @@ -94,11 +115,21 @@ msgid "" "fo`` will match as ``--foo``, but ``--f`` will not match uniquely, so :exc:" "`GetoptError` will be raised." msgstr "" +"*longopts* を指定する場合は、サポートする長形式のオプション名を文字列のリスト" +"として渡してください。\n" +"オプション名には先頭の ``'--'`` を含めません。\n" +"引数が必須の長形式オプションの後ろには等号 (``'='``) を、省略可能な引数を取る" +"ものには等号と疑問符 (``'=?'``) を付けます。\n" +"長形式のオプションだけを受け付けるには、*shortopts* を空文字列にします。\n" +"コマンドライン上の長形式オプションは、その名前の先頭部分だけでも、受け付ける" +"オプションのうちちょうど 1 つに一致すれば認識されます。\n" +"例えば *longopts* が ``['foo', 'frob']`` の場合、``--fo`` は ``--foo`` として" +"認識されますが、``--f`` は一意に決まらないため :exc:`GetoptError` を送出しま" +"す。" -#: ../../library/getopt.rst:65 msgid "" "If *longopts* is a string it gets treated as a list of a single element." -msgstr "" +msgstr "*longopts* が文字列の場合は、要素が 1 つのリストとして扱います。" #: ../../library/getopt.rst:67 msgid "" @@ -121,9 +152,8 @@ msgstr "" "順に並んでいて、複数回同じオプションを指定できます。長形式と短形式のオプショ" "ンは混在できます。" -#: ../../library/getopt.rst:77 msgid "Optional arguments are supported." -msgstr "" +msgstr "省略可能な引数がサポートされました。" #: ../../library/getopt.rst:83 msgid "" @@ -137,14 +167,15 @@ msgstr "" "混在させることができます。:func:`getopt` 関数はオプションでない引数を見つける" "と解析を停止します。" -#: ../../library/getopt.rst:88 msgid "" "If the first character of the option string is ``'+'``, or if the " "environment variable :envvar:`!POSIXLY_CORRECT` is set, then option " "processing stops as soon as a non-option argument is encountered." msgstr "" +"オプション文字列の最初の文字が ``'+'`` の場合、または環境変数 :envvar:`!" +"POSIXLY_CORRECT` が設定されている場合は、オプションでない引数が現れた時点でオ" +"プションの処理を停止します。" -#: ../../library/getopt.rst:92 msgid "" "If the first character of the option string is ``'-'``, non-option arguments " "that are followed by options are added to the list of option-and-value pairs " @@ -152,13 +183,19 @@ msgid "" "arguments as its second element. The second element of the :func:`!" "gnu_getopt` result is a list of program arguments after the last option." msgstr "" +"オプション文字列の最初の文字が ``'-'`` の場合、後ろにオプションが続く非オプ" +"ション引数は、オプションと値のペアのリストに追加されます。\n" +"このペアの最初の要素は ``None``、2 番目の要素は非オプション引数のリストで" +"す。\n" +":func:`!gnu_getopt` の戻り値の 2 番目の要素は、最後のオプションより後にあるプ" +"ログラム引数のリストになります。" -#: ../../library/getopt.rst:99 msgid "" "Support for returning intermixed options and non-option arguments in order." msgstr "" +"混在するオプションと非オプション引数を順序どおりに返すことをサポートしまし" +"た。" -#: ../../library/getopt.rst:105 msgid "" "This is raised when an unrecognized option is found in the argument list or " "when an option requiring an argument is given none. The argument to the " @@ -168,6 +205,14 @@ msgid "" "give the error message and related option; if there is no specific option to " "which the exception relates, :attr:`!opt` is an empty string." msgstr "" +"引数リストに認識できないオプションがある場合、または必須の引数がオプションに" +"指定されていない場合に送出されます。\n" +"例外の引数はエラーの原因を示す文字列です。\n" +"長形式のオプションでは、引数を取らないオプションに引数が指定された場合もこの" +"例外を送出します。\n" +":attr:`!msg` と :attr:`!opt` 属性は、それぞれエラーメッセージと関連するオプ" +"ションを表します。\n" +"エラーに関連する特定のオプションがなければ、:attr:`!opt` は空文字列です。" #: ../../library/getopt.rst:116 msgid "Alias for :exc:`GetoptError`; for backward compatibility." @@ -178,7 +223,6 @@ msgstr "" msgid "An example using only Unix style options:" msgstr "Unix スタイルのオプションを使った例です:" -#: ../../library/getopt.rst:120 msgid "" ">>> import getopt\n" ">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" @@ -190,12 +234,20 @@ msgid "" ">>> args\n" "['a1', 'a2']" msgstr "" +">>> import getopt\n" +">>> args = '-a -b -cfoo -d bar a1 a2'.split()\n" +">>> args\n" +"['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'abc:d:')\n" +">>> optlist\n" +"[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]\n" +">>> args\n" +"['a1', 'a2']" #: ../../library/getopt.rst:132 msgid "Using long option names is equally easy:" msgstr "長形式のオプションを使っても同様です:" -#: ../../library/getopt.rst:134 msgid "" ">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" ">>> args = s.split()\n" @@ -210,12 +262,22 @@ msgid "" ">>> args\n" "['a1', 'a2']" msgstr "" +">>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', " +"'a2']\n" +">>> optlist, args = getopt.getopt(args, 'x', [\n" +"... 'condition=', 'output-file=', 'testing'])\n" +">>> optlist\n" +"[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-" +"x', '')]\n" +">>> args\n" +"['a1', 'a2']" -#: ../../library/getopt.rst:147 msgid "Optional arguments should be specified explicitly:" -msgstr "" +msgstr "省略可能な引数は、次のように明示的に指定してください。" -#: ../../library/getopt.rst:149 msgid "" ">>> s = '-Con -C --color=off --color a1 a2'\n" ">>> args = s.split()\n" @@ -227,12 +289,19 @@ msgid "" ">>> args\n" "['a1', 'a2']" msgstr "" +">>> s = '-Con -C --color=off --color a1 a2'\n" +">>> args = s.split()\n" +">>> args\n" +"['-Con', '-C', '--color=off', '--color', 'a1', 'a2']\n" +">>> optlist, args = getopt.getopt(args, 'C::', ['color=?'])\n" +">>> optlist\n" +"[('-C', 'on'), ('-C', ''), ('--color', 'off'), ('--color', '')]\n" +">>> args\n" +"['a1', 'a2']" -#: ../../library/getopt.rst:161 msgid "The order of options and non-option arguments can be preserved:" -msgstr "" +msgstr "オプションと非オプション引数の順序を保持できます。" -#: ../../library/getopt.rst:163 msgid "" ">>> s = 'a1 -x a2 a3 a4 --long a5 a6'\n" ">>> args = s.split()\n" @@ -244,12 +313,19 @@ msgid "" ">>> args\n" "['a6']" msgstr "" +">>> s = 'a1 -x a2 a3 a4 --long a5 a6'\n" +">>> args = s.split()\n" +">>> args\n" +"['a1', '-x', 'a2', 'a3', 'a4', '--long', 'a5', 'a6']\n" +">>> optlist, args = getopt.gnu_getopt(args, '-x:', ['long='])\n" +">>> optlist\n" +"[(None, ['a1']), ('-x', 'a2'), (None, ['a3', 'a4']), ('--long', 'a5')]\n" +">>> args\n" +"['a6']" -#: ../../library/getopt.rst:175 msgid "In a script, typical usage is something like this:" -msgstr "" +msgstr "スクリプトでの典型的な使用例は次のようになります。" -#: ../../library/getopt.rst:177 msgid "" "import getopt, sys\n" "\n" @@ -280,15 +356,42 @@ msgid "" "if __name__ == \"__main__\":\n" " main()" msgstr "" +"import getopt, sys\n" +"\n" +"def main():\n" +" try:\n" +" opts, args = getopt.getopt(sys.argv[1:], \"ho:v\", [\"help\", " +"\"output=\"])\n" +" except getopt.GetoptError as err:\n" +" # ヘルプ情報を表示して終了する:\n" +" print(err) # \"option -a not recognized\" などと表示する\n" +" usage()\n" +" sys.exit(2)\n" +" output = None\n" +" verbose = False\n" +" for o, a in opts:\n" +" if o == \"-v\":\n" +" verbose = True\n" +" elif o in (\"-h\", \"--help\"):\n" +" usage()\n" +" sys.exit()\n" +" elif o in (\"-o\", \"--output\"):\n" +" output = a\n" +" else:\n" +" assert False, \"unhandled option\"\n" +" process(args, output=output, verbose=verbose)\n" +"\n" +"if __name__ == \"__main__\":\n" +" main()" -#: ../../library/getopt.rst:206 msgid "" "Note that an equivalent command line interface could be produced with less " "code and more informative help and error messages by using the :mod:" "`optparse` module:" msgstr "" +":mod:`optparse` モジュールを使うと、同等のコマンドラインインターフェースをよ" +"り少ないコードで作成でき、ヘルプやエラーメッセージもより詳しくなります。" -#: ../../library/getopt.rst:209 msgid "" "import optparse\n" "\n" @@ -299,14 +402,22 @@ msgid "" " opts, args = parser.parse_args()\n" " process(args, output=opts.output, verbose=opts.verbose)" msgstr "" +"import optparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = optparse.OptionParser()\n" +" parser.add_option('-o', '--output')\n" +" parser.add_option('-v', dest='verbose', action='store_true')\n" +" opts, args = parser.parse_args()\n" +" process(args, output=opts.output, verbose=opts.verbose)" -#: ../../library/getopt.rst:220 msgid "" "A roughly equivalent command line interface for this case can also be " "produced by using the :mod:`argparse` module:" msgstr "" +"この場合は :mod:`argparse` モジュールを使っても、ほぼ同等のコマンドラインイン" +"ターフェースを作成できます。" -#: ../../library/getopt.rst:223 msgid "" "import argparse\n" "\n" @@ -318,26 +429,35 @@ msgid "" " args = parser.parse_args()\n" " process(args.rest, output=args.output, verbose=args.verbose)" msgstr "" +"import argparse\n" +"\n" +"if __name__ == '__main__':\n" +" parser = argparse.ArgumentParser()\n" +" parser.add_argument('-o', '--output')\n" +" parser.add_argument('-v', dest='verbose', action='store_true')\n" +" parser.add_argument('rest', nargs='*')\n" +" args = parser.parse_args()\n" +" process(args.rest, output=args.output, verbose=args.verbose)" -#: ../../library/getopt.rst:235 msgid "" "See :ref:`choosing-an-argument-parser` for details on how the ``argparse`` " "version of this code differs in behaviour from the ``optparse`` (and " "``getopt``) version." msgstr "" +"このコードの ``argparse`` 版と ``optparse`` (および ``getopt``) 版の動作の違" +"いについては、:ref:`choosing-an-argument-parser` を参照してください。" -#: ../../library/getopt.rst:241 msgid "Module :mod:`optparse`" -msgstr "" +msgstr ":mod:`optparse` モジュール" -#: ../../library/getopt.rst:242 msgid "Declarative command line option parsing." -msgstr "" +msgstr "宣言的なコマンドラインオプション解析。" #: ../../library/getopt.rst:244 msgid "Module :mod:`argparse`" msgstr ":mod:`argparse` モジュール" -#: ../../library/getopt.rst:245 msgid "More opinionated command line option and argument parsing library." msgstr "" +"コマンドラインのオプションと引数を、より明確な方針に沿って解析するライブラ" +"リ。" diff --git a/library/getpass.po b/library/getpass.po index a6a83b73d..537f7ea54 100644 --- a/library/getpass.po +++ b/library/getpass.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/getpass.rst:2 @@ -30,9 +30,8 @@ msgstr ":mod:`!getpass` --- 可搬性のあるパスワード入力機構" msgid "**Source code:** :source:`Lib/getpass.py`" msgstr "**ソースコード:** :source:`Lib/getpass.py`" -#: ../../includes/wasm-notavail.rst:3 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../includes/wasm-notavail.rst:5 msgid "" @@ -42,11 +41,9 @@ msgstr "" "このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、:ref:" "`wasm-availability` を見てください。" -#: ../../library/getpass.rst:13 msgid "The :mod:`!getpass` module provides two functions:" -msgstr "" +msgstr ":mod:`!getpass` モジュールは 2 つの関数を提供します。" -#: ../../library/getpass.rst:17 msgid "" "Prompt the user for a password without echoing. The user is prompted using " "the string *prompt*, which defaults to ``'Password: '``. On Unix, the " @@ -55,14 +52,14 @@ msgid "" "dev/tty`) or if that is unavailable to ``sys.stderr`` (this argument is " "ignored on Windows)." msgstr "" -"エコーなしでユーザーにパスワードを入力させるプロンプト。ユーザーは *prompt* " -"の文字列をプロンプトに使え、デフォルトは ``'Password: '`` です。 Unixではプロ" -"ンプトはファイルに似たオブジェクト *stream* へ、必要なら置き換えられたエラー" -"ハンドラを使って出力されます。 *stream* のデフォルトは、制御端末(:file:`/dev/" -"tty`)か、それが利用できない場合は ``sys.stderr`` です (この引数は Windowsでは" -"無視されます)。" - -#: ../../library/getpass.rst:24 +"エコーなしでユーザーにパスワードを入力させるプロンプト。\n" +"ユーザーは *prompt* の文字列をプロンプトに使え、デフォルトは ``'Password: " +"'`` です。\n" +"Unixではプロンプトはファイルに似たオブジェクト *stream* へ、必要なら " +"``replace`` エラーハンドラを使って出力されます。\n" +"*stream* のデフォルトは、制御端末(:file:`/dev/tty`)か、それが利用できない場合" +"は ``sys.stderr`` です (この引数は Windowsでは無視されます)。" + msgid "" "The *echo_char* argument controls how user input is displayed while typing. " "If *echo_char* is ``None`` (default), input remains hidden. Otherwise, " @@ -70,6 +67,12 @@ msgid "" "character is replaced by it. For example, ``echo_char='*'`` will display " "asterisks instead of the actual input." msgstr "" +"*echo_char* 引数は、入力中の文字をどのように表示するかを制御します。\n" +"*echo_char* が ``None`` (デフォルト) の場合、入力は表示されません。\n" +"それ以外の場合、*echo_char* は表示可能な ASCII 文字 1 文字でなければならず、" +"入力した各文字はその文字で置き換えられます。\n" +"例えば ``echo_char='*'`` を指定すると、実際の入力の代わりにアスタリスクを表示" +"します。" #: ../../library/getpass.rst:30 msgid "" @@ -81,72 +84,70 @@ msgstr "" "メッセージを出力し、 ``sys.stdin`` から読み込み、 :exc:`GetPassWarning` 警告" "を発生させます。" -#: ../../library/getpass.rst:35 msgid "" "If you call getpass from within IDLE, the input may be done in the terminal " "you launched IDLE from rather than the idle window itself." msgstr "" -"IDLE から getpass を呼び出した場合、入力はIDLEのウィンドウではなく、IDLE を起" -"動したターミナルから行われます。" +"IDLE 内から ``getpass()`` を呼び出すと、IDLE のウィンドウではなく、IDLE を起" +"動したターミナルで入力することになる場合があります。" -#: ../../library/getpass.rst:39 msgid "" "On Unix systems, when *echo_char* is set, the terminal will be configured to " "operate in :manpage:`noncanonical mode " "`. Common terminal control " "characters are supported:" msgstr "" +"Unix システムで *echo_char* を設定すると、端末は :manpage:`非カノニカルモー" +"ド ` で動作するよう設定されま" +"す。\n" +"一般的な端末制御文字がサポートされます。" -#: ../../library/getpass.rst:44 msgid ":kbd:`Ctrl+A` - Move cursor to beginning of line" -msgstr "" +msgstr ":kbd:`Ctrl+A` - カーソルを行頭に移動" -#: ../../library/getpass.rst:45 msgid ":kbd:`Ctrl+E` - Move cursor to end of line" -msgstr "" +msgstr ":kbd:`Ctrl+E` - カーソルを行末に移動" -#: ../../library/getpass.rst:46 msgid ":kbd:`Ctrl+K` - Kill (delete) from cursor to end of line" -msgstr "" +msgstr ":kbd:`Ctrl+K` - カーソルから行末までを削除" -#: ../../library/getpass.rst:47 msgid ":kbd:`Ctrl+U` - Kill (delete) entire line" -msgstr "" +msgstr ":kbd:`Ctrl+U` - 行全体を削除" -#: ../../library/getpass.rst:48 msgid ":kbd:`Ctrl+W` - Erase previous word" -msgstr "" +msgstr ":kbd:`Ctrl+W` - 直前の単語を削除" -#: ../../library/getpass.rst:49 msgid ":kbd:`Ctrl+V` - Insert next character literally (quote)" -msgstr "" +msgstr ":kbd:`Ctrl+V` - 次の文字をそのまま挿入 (クォート)" -#: ../../library/getpass.rst:50 msgid ":kbd:`Backspace`/:kbd:`DEL` - Delete character before cursor" -msgstr "" +msgstr ":kbd:`Backspace`/:kbd:`DEL` - カーソルの直前の文字を削除" -#: ../../library/getpass.rst:52 msgid "" "These shortcuts work by reading the terminal's configured control character " "mappings from termios settings." msgstr "" +"これらのショートカットは、termios の設定から端末の制御文字の割り当てを読み" +"取って動作します。" -#: ../../library/getpass.rst:55 msgid "Added the *echo_char* parameter for keyboard feedback." msgstr "" +"キーボード入力に視覚的なフィードバックを与える *echo_char* 引数が追加されまし" +"た。" -#: ../../library/getpass.rst:58 msgid "" "When using non-empty *echo_char* on Unix, keyboard shortcuts (including " "cursor movement and line editing) are now properly handled using the " "terminal's control character configuration." msgstr "" +"Unix で空でない *echo_char* を使うとき、端末の制御文字の設定に従ってキーボー" +"ドショートカット (カーソルの移動や行の編集を含む) を適切に処理するようになり" +"ました。" -#: ../../library/getpass.rst:65 msgid "A :exc:`UserWarning` subclass issued when password input may be echoed." msgstr "" -":exc:`UserWarning` のサブクラスで、入力がエコーされてしまった場合に発生しま" -"す。" +"パスワードの入力内容がエコーされる可能性がある場合に発行される、:exc:" +"`UserWarning` のサブクラスです。" #: ../../library/getpass.rst:70 msgid "Return the \"login name\" of the user." @@ -166,9 +167,8 @@ msgstr "" "ム上のパスワードデータベースから返します。それ以外の場合は、 :exc:" "`OSError` が送出されます。" -#: ../../library/getpass.rst:79 msgid "In general, this function should be preferred over :func:`os.getlogin`." -msgstr "" +msgstr "一般に、:func:`os.getlogin` よりもこの関数を使うことを推奨します。" #: ../../library/getpass.rst:81 msgid "Previously, various exceptions beyond just :exc:`OSError` were raised." diff --git a/library/gettext.po b/library/gettext.po index 68a01015b..8cf3f0608 100644 --- a/library/gettext.po +++ b/library/gettext.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/gettext.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!gettext` --- 多言語国際化サービス" msgid "**Source code:** :source:`Lib/gettext.py`" msgstr "**ソースコード:** :source:`Lib/gettext.py`" -#: ../../library/gettext.rst:11 msgid "" "The :mod:`!gettext` module provides internationalization (I18N) and " "localization (L10N) services for your Python modules and applications. It " @@ -40,6 +39,13 @@ msgid "" "messages in one natural language, and provide a catalog of translated " "messages for running under different natural languages." msgstr "" +":mod:`!gettext` モジュールは、Python のモジュールやアプリケーションに国際化 " +"(I18N) と地域化 (L10N) の機能を提供します。\n" +"GNU :program:`gettext` のメッセージカタログ API と、Python ファイルにはより適" +"している場合がある、クラス形式の高水準 API の両方をサポートしています。\n" +"以下のインターフェースを使うと、モジュールやアプリケーションのメッセージを 1 " +"つの自然言語で書き、ほかの自然言語で実行するための翻訳済みメッセージのカタロ" +"グを用意できます。" #: ../../library/gettext.rst:19 msgid "" @@ -52,7 +58,6 @@ msgstr "" msgid "GNU :program:`gettext` API" msgstr "GNU :program:`gettext` API" -#: ../../library/gettext.rst:25 msgid "" "The :mod:`!gettext` module defines the following API, which is very similar " "to the GNU :program:`gettext` API. If you use this API you will affect the " @@ -62,8 +67,14 @@ msgid "" "module, or if your application needs to switch languages on the fly, you " "probably want to use the class-based API instead." msgstr "" +":mod:`!gettext` モジュールは、GNU :program:`gettext` API によく似た次の API " +"を定義しています。\n" +"この API を使うと、アプリケーション全体の翻訳に影響します。\n" +"ユーザーのロケールに応じて 1 つの言語を選択するアプリケーションでは、多くの場" +"合これが望ましい動作です。\n" +"Python モジュールを地域化する場合や、実行中に言語を切り替える必要がある場合" +"は、クラス形式の API を使う方が適しています。" -#: ../../library/gettext.rst:36 msgid "" "Bind the *domain* to the locale directory *localedir*. More concretely, :" "mod:`!gettext` will look for binary :file:`.mo` files for the given domain " @@ -72,6 +83,12 @@ msgid "" "`LANGUAGE`, :envvar:`LC_ALL`, :envvar:`LC_MESSAGES`, and :envvar:`LANG` " "respectively." msgstr "" +"*domain* をロケールディレクトリ *localedir* に結び付けます。\n" +"具体的には、:mod:`!gettext` は指定したドメインのバイナリ :file:`.mo` ファイル" +"を、Unix では :file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo` というパ" +"スで探します。\n" +"ここで *language* は、環境変数 :envvar:`LANGUAGE`、:envvar:`LC_ALL`、:envvar:" +"`LC_MESSAGES`、:envvar:`LANG` から順に探します。" #: ../../library/gettext.rst:42 msgid "" @@ -92,12 +109,15 @@ msgstr "" "場合には、グローバルドメインに *domain* を設定し、その設定されたグローバルド" "メインを返します。" -#: ../../library/gettext.rst:56 msgid "" "Return the localized translation of *message*, based on the current global " "domain, language, and locale directory. This function is usually aliased " "as :func:`!_` in the local namespace (see examples below)." msgstr "" +"現在のグローバルドメイン、言語、ロケールディレクトリに基づいて、*message* の" +"翻訳を返します。\n" +"通常、この関数はローカル名前空間で :func:`!_` という別名で使います (以下の例" +"を参照)。" #: ../../library/gettext.rst:63 msgid "" @@ -105,18 +125,17 @@ msgid "" msgstr "" ":func:`.gettext` と同様ですが、指定された *domain* からメッセージを探します。" -#: ../../library/gettext.rst:68 msgid "" "Like :func:`.gettext`, but consider plural forms. If a translation is found, " "apply the plural formula to *n*, and return the resulting message (some " "languages have more than two plural forms). If no translation is found, " "return *singular* if *n* is 1; return *plural* otherwise." msgstr "" -":func:`.gettext` と同様ですが、複数形を考慮しています。\n" -"翻訳が見つかった場合、複数形の選択公式を *n* に適用し、その結果得られたメッ" -"セージを返します (言語によっては二つ以上の複数形があります)。\n" -"翻訳が見つからなかった場合、 *n* が 1 なら *singular* を返します; そうでない" -"場合 *plural* を返します。" +":func:`.gettext` と同様ですが、複数形を考慮します。\n" +"翻訳が見つかった場合は、複数形の選択公式を *n* に適用し、その結果に対応する" +"メッセージを返します (言語によっては複数形が 3 種類以上あります)。\n" +"翻訳が見つからなかった場合は、*n* が 1 なら *singular*、それ以外なら " +"*plural* を返します。" #: ../../library/gettext.rst:73 msgid "" @@ -140,24 +159,26 @@ msgid "" msgstr "" ":func:`ngettext` と同様ですが、指定された *domain* からメッセージを探します。" -#: ../../library/gettext.rst:91 msgid "" "Similar to the corresponding functions without the ``p`` in the prefix (that " "is, :func:`gettext`, :func:`dgettext`, :func:`ngettext`, :func:`dngettext`), " "but the translation is restricted to the given message *context*." msgstr "" +"接頭辞 ``p`` のない対応する関数 (:func:`gettext`、:func:`dgettext`、:func:" +"`ngettext`、:func:`dngettext`) と同様ですが、翻訳対象が指定したメッセージの " +"*context* に限定されます。" -#: ../../library/gettext.rst:98 msgid "" "Note that GNU :program:`gettext` also defines a :func:`!dcgettext` method, " "but this was deemed not useful and so it is currently unimplemented." msgstr "" +"GNU :program:`gettext` は :func:`!dcgettext` メソッドも定義していますが、有用" +"ではないと判断されたため、現在は実装されていません。" #: ../../library/gettext.rst:101 msgid "Here's an example of typical usage for this API::" msgstr "以下にこの API の典型的な使用法を示します::" -#: ../../library/gettext.rst:103 msgid "" "import gettext\n" "gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')\n" @@ -166,12 +187,17 @@ msgid "" "# ...\n" "print(_('This is a translatable string.'))" msgstr "" +"import gettext\n" +"gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')\n" +"gettext.textdomain('myapplication')\n" +"_ = gettext.gettext\n" +"# ...\n" +"print(_('This is a translatable string.'))" #: ../../library/gettext.rst:112 msgid "Class-based API" msgstr "クラス形式の API" -#: ../../library/gettext.rst:114 msgid "" "The class-based API of the :mod:`!gettext` module gives you more flexibility " "and greater convenience than the GNU :program:`gettext` API. It is the " @@ -181,6 +207,15 @@ msgid "" "strings. Instances of this class can also install themselves in the built-in " "namespace as the function :func:`!_`." msgstr "" +":mod:`!gettext` モジュールのクラス形式の API は、GNU :program:`gettext` API " +"より柔軟で便利です。\n" +"Python のアプリケーションやモジュールの地域化には、この API の使用を推奨しま" +"す。\n" +":mod:`!gettext` は :class:`GNUTranslations` クラスを定義しています。\n" +"このクラスは GNU :file:`.mo` 形式のファイルの解析を実装し、文字列を返すメソッ" +"ドを持ちます。\n" +"このクラスのインスタンスは、組み込み名前空間に :func:`!_` 関数として自身をイ" +"ンストールすることもできます。" #: ../../library/gettext.rst:124 msgid "" @@ -209,35 +244,31 @@ msgstr "" "`LANGUAGE` 、 :envvar:`LC_ALL` 、 :envvar:`LC_MESSAGES` 、および :envvar:" "`LANG` が検索されます。空でない値を返した最初の候補が *languages* 変数として" "使われます。この環境変数は言語名をコロンで分かち書きしたリストを含んでいなけ" -"ればなりません。 :func:`find` はこの文字列をコロンで分割し、言語コードの候補" -"リストを生成します。" +"ればなりません。 ``find()`` はこの文字列をコロンで分割し、言語コードの候補リ" +"ストを生成します。" -#: ../../library/gettext.rst:137 msgid "" ":func:`find` then expands and normalizes the languages, and then iterates " "through them, searching for an existing file built of these components:" msgstr "" -":func:`find` は次に言語コードを展開および正規化し、リストの各要素について、以" -"下のパス構成:" +":func:`find` は言語コードを展開して正規化し、それらを順にたどりながら、次の要" +"素からなるパスにファイルが存在するか調べます。" #: ../../library/gettext.rst:140 msgid ":file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo`" msgstr ":file:`{localedir}/{language}/LC_MESSAGES/{domain}.mo`" -#: ../../library/gettext.rst:142 msgid "" "The first such file name that exists is returned by :func:`find`. If no such " "file is found, then ``None`` is returned. If *all* is given, it returns a " "list of all file names, in the order in which they appear in the languages " "list or the environment variables." msgstr "" -"からなる実在するファイルの探索を反復的に行います。 :func:`find` は上記のよう" -"な実在するファイルで最初に見つかったものを返します。該当するファイルが見つか" -"らなかった場合、 ``None`` が返されます。 *all* が与えられていれば、全ファイル" -"名のリストが言語リストまたは環境変数で指定されている順番に並べられたものを返" -"します。" +":func:`find` は最初に見つかったファイル名を返します。\n" +"ファイルが見つからなければ ``None`` を返します。\n" +"*all* を指定した場合は、見つかったすべてのファイル名のリストを、言語リストま" +"たは環境変数での順序で返します。" -#: ../../library/gettext.rst:150 msgid "" "Return a ``*Translations`` instance based on the *domain*, *localedir*, and " "*languages*, which are first passed to :func:`find` to get a list of the " @@ -246,6 +277,15 @@ msgid "" "provided, otherwise :class:`GNUTranslations`. The class's constructor must " "take a single :term:`file object` argument." msgstr "" +"*domain*、*localedir*、*languages* に基づいて ``*Translations`` インスタンス" +"を返します。\n" +"これらの引数を最初に :func:`find` に渡し、関連する :file:`.mo` ファイルのパス" +"のリストを取得します。\n" +"同じ :file:`.mo` ファイル名を持つインスタンスはキャッシュされます。\n" +"実際にインスタンス化するクラスは、*class_* が指定されていればそのクラス、そう" +"でなければ :class:`GNUTranslations` です。\n" +"クラスのコンストラクタは :term:`file object` を引数として 1 つ受け取る必要が" +"あります。" #: ../../library/gettext.rst:157 msgid "" @@ -276,16 +316,16 @@ msgstr "" "以前は :exc:`IOError` が送出されました; それは現在 :exc:`OSError` のエイリア" "スです。" -#: ../../library/gettext.rst:169 msgid "*codeset* parameter is removed." -msgstr "" +msgstr "*codeset* 引数が削除されました。" -#: ../../library/gettext.rst:174 msgid "" "This installs the function :func:`!_` in Python's builtins namespace, based " "on *domain* and *localedir* which are passed to the function :func:" "`translation`." msgstr "" +"*domain* と *localedir* を :func:`translation` 関数に渡し、それに基づいて " +"Python の組み込み名前空間に :func:`!_` 関数をインストールします。" #: ../../library/gettext.rst:177 msgid "" @@ -295,27 +335,27 @@ msgstr "" "*names* パラメータについては、翻訳オブジェクトの :meth:`~NullTranslations." "install` メソッドの説明を参照ください。" -#: ../../library/gettext.rst:180 msgid "" "As seen below, you usually mark the strings in your application that are " "candidates for translation, by wrapping them in a call to the :func:`!_` " "function, like this::" msgstr "" +"以下のように、アプリケーションで翻訳候補の文字列をマークするには、通常 :func:" +"`!_` 関数の呼び出しで囲みます。 ::" -#: ../../library/gettext.rst:184 msgid "print(_('This string will be translated.'))" -msgstr "" +msgstr "print(_('This string will be translated.'))" -#: ../../library/gettext.rst:186 msgid "" "For convenience, you want the :func:`!_` function to be installed in " "Python's builtins namespace, so it is easily accessible in all modules of " "your application." msgstr "" +"アプリケーションのすべてのモジュールから簡単にアクセスできるように、:func:`!" +"_` 関数を Python の組み込み名前空間にインストールすると便利です。" -#: ../../library/gettext.rst:190 msgid "*names* is now a keyword-only parameter." -msgstr "" +msgstr "*names* がキーワード専用引数になりました。" #: ../../library/gettext.rst:194 msgid "The :class:`NullTranslations` class" @@ -414,11 +454,10 @@ msgstr "" "転送します。そうでない場合、翻訳されたメッセージを返します。派生クラスで上書" "きするメソッドです。" -#: ../../library/gettext.rst:257 msgid "" "Return a dictionary containing the metadata found in the message catalog " "file." -msgstr "" +msgstr "メッセージカタログファイルから取得したメタデータを含む辞書を返します。" #: ../../library/gettext.rst:263 msgid "Return the encoding of the message catalog file." @@ -432,15 +471,17 @@ msgstr "" "このメソッドは :meth:`.gettext` を組み込み名前空間にインストールし、変数 " "``_`` に束縛します。" -#: ../../library/gettext.rst:271 msgid "" "If the *names* parameter is given, it must be a sequence containing the " "names of functions you want to install in the builtins namespace in addition " "to :func:`!_`. Supported names are ``'gettext'``, ``'ngettext'``, " "``'pgettext'``, and ``'npgettext'``." msgstr "" +"*names* 引数を指定する場合は、:func:`!_` に加えて組み込み名前空間にインストー" +"ルする関数名のシーケンスを渡してください。\n" +"サポートされる名前は ``'gettext'``、``'ngettext'``、``'pgettext'``、" +"``'npgettext'`` です。" -#: ../../library/gettext.rst:276 msgid "" "Note that this is only one way, albeit the most convenient way, to make the :" "func:`!_` function available to your application. Because it affects the " @@ -448,19 +489,27 @@ msgid "" "localized modules should never install :func:`!_`. Instead, they should use " "this code to make :func:`!_` available to their module::" msgstr "" +"これは :func:`!_` 関数をアプリケーションで利用可能にする最も便利な方法です" +"が、唯一の方法ではありません。\n" +"アプリケーション全体、特に組み込み名前空間に影響するため、地域化したモジュー" +"ルでは決して :func:`!_` をインストールしないでください。\n" +"代わりに次のコードで、そのモジュール内で :func:`!_` を利用可能にします。 ::" -#: ../../library/gettext.rst:282 msgid "" "import gettext\n" "t = gettext.translation('mymodule', ...)\n" "_ = t.gettext" msgstr "" +"import gettext\n" +"t = gettext.translation('mymodule', ...)\n" +"_ = t.gettext" -#: ../../library/gettext.rst:286 msgid "" "This puts :func:`!_` only in the module's global namespace and so only " "affects calls within this module." msgstr "" +"これにより :func:`!_` はモジュールのグローバル名前空間だけに置かれるので、こ" +"のモジュール内の呼び出しにだけ影響します。" #: ../../library/gettext.rst:289 msgid "Added ``'pgettext'`` and ``'npgettext'``." @@ -470,15 +519,18 @@ msgstr "``'pgettext'`` と ``'npgettext'`` が追加されました。" msgid "The :class:`GNUTranslations` class" msgstr ":class:`GNUTranslations` クラス" -#: ../../library/gettext.rst:296 msgid "" "The :mod:`!gettext` module provides one additional class derived from :class:" "`NullTranslations`: :class:`GNUTranslations`. This class overrides :meth:`!" "_parse` to enable reading GNU :program:`gettext` format :file:`.mo` files in " "both big-endian and little-endian format." msgstr "" +":mod:`!gettext` モジュールは、:class:`NullTranslations` の派生クラスとして :" +"class:`GNUTranslations` も提供します。\n" +"このクラスは :meth:`!_parse` をオーバーライドし、ビッグエンディアンとリトルエ" +"ンディアンの両方の GNU :program:`gettext` 形式の :file:`.mo` ファイルを読み取" +"れるようにします。" -#: ../../library/gettext.rst:301 msgid "" ":class:`GNUTranslations` parses optional metadata out of the translation " "catalog. It is convention with GNU :program:`gettext` to include metadata as " @@ -490,18 +542,34 @@ msgid "" "then all message ids and message strings read from the catalog are converted " "to Unicode using this encoding, else ASCII is assumed." msgstr "" +":class:`GNUTranslations` は翻訳カタログから省略可能なメタデータを解析しま" +"す。\n" +"GNU :program:`gettext` では、空文字列の翻訳としてメタデータを格納する慣習があ" +"ります。\n" +"このメタデータは :rfc:`822` 形式の ``key: value`` ペアで、``Project-Id-" +"Version`` キーを含める必要があります。\n" +"``Content-Type`` キーがあれば、その ``charset`` プロパティを使って「保護され" +"た」インスタンス変数 :attr:`!_charset` を初期化します。\n" +"見つからなければデフォルトの ``None`` になります。\n" +"文字セットのエンコーディングが指定されていれば、カタログから読み取ったすべて" +"のメッセージ ID とメッセージ文字列をそのエンコーディングで Unicode に変換しま" +"す。\n" +"指定されていなければ ASCII と見なします。" -#: ../../library/gettext.rst:311 msgid "" "Since message ids are read as Unicode strings too, all ``*gettext()`` " "methods will assume message ids as Unicode strings, not byte strings." msgstr "" +"メッセージ ID も Unicode 文字列として読み取るため、すべての ``*gettext()`` メ" +"ソッドは、メッセージ ID がバイト文字列ではなく Unicode 文字列であることを前提" +"とします。" -#: ../../library/gettext.rst:314 msgid "" "The entire set of key/value pairs are placed into a dictionary and set as " "the \"protected\" :attr:`!_info` instance variable." msgstr "" +"キーと値のペア全体を辞書に格納し、「保護された」インスタンス変数 :attr:`!" +"_info` に設定します。" #: ../../library/gettext.rst:317 msgid "" @@ -519,7 +587,6 @@ msgid "" "The following methods are overridden from the base class implementation:" msgstr "以下のメソッドは基底クラスの実装からオーバライドされています:" -#: ../../library/gettext.rst:327 msgid "" "Look up the *message* id in the catalog and return the corresponding message " "string, as a Unicode string. If there is no entry in the catalog for the " @@ -527,22 +594,22 @@ msgid "" "fallback's :meth:`~NullTranslations.gettext` method. Otherwise, the " "*message* id is returned." msgstr "" -"カタログから *message* id を検索して、対応するメッセージ文字列を Unicode でエ" -"ンコードして返します。\n" +"カタログから *message* id を検索して、対応するメッセージ文字列を Unicode 文字" +"列として返します。\n" "*message* id に対応するエントリがカタログに存在せず、フォールバックが設定され" "ている場合、検索処理をフォールバックの :meth:`~NullTranslations.gettext` メ" "ソッドに移譲します。\n" "それ以外の場合は、 *message* id 自体が返されます。" -#: ../../library/gettext.rst:336 msgid "" "Do a plural-forms lookup of a message id. *singular* is used as the message " "id for purposes of lookup in the catalog, while *n* is used to determine " "which plural form to use. The returned message string is a Unicode string." msgstr "" -"メッセージ id に対する複数形を検索します。カタログに対する検索では " -"*singular* がメッセージ id として用いられ、 *n* にはどの複数形を用いるかを指" -"定します。返されるメッセージ文字列は Unicode 文字列です。" +"メッセージ ID に対して複数形の検索を行います。\n" +"カタログの検索では *singular* をメッセージ ID として使い、*n* をもとに使う複" +"数形を決定します。\n" +"返されるメッセージ文字列は Unicode 文字列です。" #: ../../library/gettext.rst:340 msgid "" @@ -561,7 +628,6 @@ msgstr "" msgid "Here is an example::" msgstr "以下に例を示します。::" -#: ../../library/gettext.rst:347 msgid "" "n = len(os.listdir('.'))\n" "cat = GNUTranslations(somefile)\n" @@ -570,8 +636,13 @@ msgid "" " 'There are %(num)d files in this directory',\n" " n) % {'num': n}" msgstr "" +"n = len(os.listdir('.'))\n" +"cat = GNUTranslations(somefile)\n" +"message = cat.ngettext(\n" +" 'There is %(num)d file in this directory',\n" +" 'There are %(num)d files in this directory',\n" +" n) % {'num': n}" -#: ../../library/gettext.rst:357 msgid "" "Look up the *context* and *message* id in the catalog and return the " "corresponding message string, as a Unicode string. If there is no entry in " @@ -579,21 +650,21 @@ msgid "" "the look up is forwarded to the fallback's :meth:`pgettext` method. " "Otherwise, the *message* id is returned." msgstr "" -"カタログから *context* と *message* id を検索して、対応するメッセージ文字列" -"を、 Unicode でエンコードして返します。 *message* id と *context* に対するエ" -"ントリがカタログに存在せず、フォールバックが設定されている場合、フォールバッ" -"ク検索はオブジェクトの :meth:`pgettext` メソッドに転送されます。そうでない場" -"合、 *message* id 自体が返されます。" +"カタログから *context* と *message* ID を検索し、対応するメッセージを " +"Unicode 文字列として返します。\n" +"*message* ID と *context* に対応するエントリがなく、フォールバックが設定され" +"ている場合は、そのフォールバックの :meth:`pgettext` メソッドに検索を委ねま" +"す。\n" +"そうでなければ *message* ID 自体を返します。" -#: ../../library/gettext.rst:368 msgid "" "Do a plural-forms lookup of a message id. *singular* is used as the message " "id for purposes of lookup in the catalog, while *n* is used to determine " "which plural form to use." msgstr "" -"メッセージ id に対する複数形を検索します。カタログに対する検索では " -"*singular* がメッセージ id として用いられ、 *n* にはどの複数形を用いるかを指" -"定します。" +"メッセージ ID に対して複数形の検索を行います。\n" +"カタログの検索では *singular* をメッセージ ID として使い、*n* をもとに使う複" +"数形を決定します。" #: ../../library/gettext.rst:372 msgid "" @@ -625,25 +696,31 @@ msgstr "" msgid "The Catalog constructor" msgstr "Catalog コンストラクタ" -#: ../../library/gettext.rst:393 msgid "" "GNOME uses a version of the :mod:`!gettext` module by James Henstridge, but " "this version has a slightly different API. Its documented usage was::" msgstr "" +"GNOME は James Henstridge による :mod:`!gettext` モジュールを使っていますが、" +"このバージョンの API は少し異なります。\n" +"ドキュメントに記載されていた使い方は次のとおりです。 ::" -#: ../../library/gettext.rst:396 msgid "" "import gettext\n" "cat = gettext.Catalog(domain, localedir)\n" "_ = cat.gettext\n" "print(_('hello world'))" msgstr "" +"import gettext\n" +"cat = gettext.Catalog(domain, localedir)\n" +"_ = cat.gettext\n" +"print(_('hello world'))" -#: ../../library/gettext.rst:401 msgid "" "For compatibility with this older module, the function :func:`!Catalog` is " "an alias for the :func:`translation` function described above." msgstr "" +"この古いモジュールとの互換性のために、:func:`!Catalog` 関数は、上記の :func:" +"`translation` 関数の別名になっています。" #: ../../library/gettext.rst:404 msgid "" @@ -689,27 +766,35 @@ msgstr "" msgid "create language-specific translations of the message catalogs" msgstr "特定の言語へのメッセージカタログの翻訳を作成します" -#: ../../library/gettext.rst:425 msgid "" "use the :mod:`!gettext` module so that message strings are properly " "translated" msgstr "" +":mod:`!gettext` モジュールを使って、メッセージ文字列が適切に翻訳されるように" +"します。" -#: ../../library/gettext.rst:427 msgid "" "In order to prepare your code for I18N, you need to look at all the strings " "in your files. Any string that needs to be translated should be marked by " "wrapping it in ``_('...')`` --- that is, a call to the function :func:`_ " "`. For example::" msgstr "" +"コードを国際化に対応させるには、ファイル内のすべての文字列を調べる必要があり" +"ます。\n" +"翻訳が必要な文字列は ``_('...')``、つまり :func:`_ ` 関数の呼び出し" +"で囲んでマークしてください。\n" +"例えば次のようにします。 ::" -#: ../../library/gettext.rst:431 msgid "" "filename = 'mylog.txt'\n" "message = _('writing a log message')\n" "with open(filename, 'w') as fp:\n" " fp.write(message)" msgstr "" +"filename = 'mylog.txt'\n" +"message = _('writing a log message')\n" +"with open(filename, 'w') as fp:\n" +" fp.write(message)" #: ../../library/gettext.rst:436 msgid "" @@ -780,7 +865,6 @@ msgstr "" "このファイルは人間が判読可能な構造をしていて、ソースコード中のマークが着けら" "れた文字列と、その文字列の仮置きの訳文が一緒に書き込まれています。" -#: ../../library/gettext.rst:467 msgid "" "Copies of these :file:`.po` files are then handed over to the individual " "human translators who write translations for every supported natural " @@ -790,13 +874,22 @@ msgid "" "mo` files are used by the :mod:`!gettext` module for the actual translation " "processing at run-time." msgstr "" +"次に、これらの :file:`.po` ファイルのコピーを各翻訳者に渡し、サポートする自然" +"言語ごとに翻訳してもらいます。\n" +"完成した各言語の :file:`.po` ファイルが返されたら、:program:" +"`msgfmt` プログラムで、機械が読み取れるバイナリカタログファイル :file:`.mo` " +"にコンパイルします。\n" +"実行時の翻訳処理では、:mod:`!gettext` モジュールがこの :file:`.mo` ファイルを" +"使います。" -#: ../../library/gettext.rst:476 msgid "" "How you use the :mod:`!gettext` module in your code depends on whether you " "are internationalizing a single module or your entire application. The next " "two sections will discuss each case." msgstr "" +"コードでの :mod:`!gettext` モジュールの使い方は、単一のモジュールを国際化する" +"のか、アプリケーション全体を国際化するのかによって異なります。\n" +"次の 2 つの節では、それぞれの場合について説明します。" #: ../../library/gettext.rst:482 msgid "Localizing your module" @@ -824,24 +917,30 @@ msgstr "" "`gettext` 形式で置かれているとします。この場合、モジュールの最初で以下のよう" "にします::" -#: ../../library/gettext.rst:493 msgid "" "import gettext\n" "t = gettext.translation('spam', '/usr/share/locale')\n" "_ = t.gettext" msgstr "" +"import gettext\n" +"t = gettext.translation('spam', '/usr/share/locale')\n" +"_ = t.gettext" #: ../../library/gettext.rst:499 msgid "Localizing your application" msgstr "アプリケーションを地域化する" -#: ../../library/gettext.rst:501 msgid "" "If you are localizing your application, you can install the :func:`!_` " "function globally into the built-in namespace, usually in the main driver " "file of your application. This will let all your application-specific files " "just use ``_('...')`` without having to explicitly install it in each file." msgstr "" +"アプリケーションを地域化する場合は、:func:`!_` 関数を組み込み名前空間にグロー" +"バルにインストールできます。\n" +"通常はアプリケーションのメインの実行ファイルで行います。\n" +"これにより、アプリケーション固有のすべてのファイルで、ファイルごとに明示的に" +"インストールせずに ``_('...')`` を使えます。" #: ../../library/gettext.rst:506 msgid "" @@ -851,25 +950,26 @@ msgstr "" "単純な場合では、単に以下の短いコードをアプリケーションの主ドライバファイルに" "追加するだけです::" -#: ../../library/gettext.rst:509 msgid "" "import gettext\n" "gettext.install('myapplication')" msgstr "" +"import gettext\n" +"gettext.install('myapplication')" -#: ../../library/gettext.rst:512 msgid "" "If you need to set the locale directory, you can pass it into the :func:" "`install` function::" msgstr "" -"ロケールの辞書を設定する必要がある場合、:func:`install` 関数に渡すことが出来" -"ます::" +"ロケールのディレクトリを設定する必要がある場合は、:func:`install` 関数に渡す" +"ことができます。 ::" -#: ../../library/gettext.rst:515 msgid "" "import gettext\n" "gettext.install('myapplication', '/usr/share/locale')" msgstr "" +"import gettext\n" +"gettext.install('myapplication', '/usr/share/locale')" #: ../../library/gettext.rst:520 msgid "Changing languages on the fly" @@ -885,7 +985,6 @@ msgstr "" "て、例えば以下のコードのように、インスタンスを明示的に切り替えてもかまいませ" "ん。::" -#: ../../library/gettext.rst:526 msgid "" "import gettext\n" "\n" @@ -902,6 +1001,20 @@ msgid "" "# ... more time goes by, user selects language 3\n" "lang3.install()" msgstr "" +"import gettext\n" +"\n" +"lang1 = gettext.translation('myapplication', languages=['en'])\n" +"lang2 = gettext.translation('myapplication', languages=['fr'])\n" +"lang3 = gettext.translation('myapplication', languages=['de'])\n" +"\n" +"# 最初は language1 を使う\n" +"lang1.install()\n" +"\n" +"# ... 時間がたち、ユーザーが言語 2 を選ぶ\n" +"lang2.install()\n" +"\n" +"# ... さらに時間がたち、ユーザーが言語 3 を選ぶ\n" +"lang3.install()" #: ../../library/gettext.rst:543 msgid "Deferred translations" @@ -918,7 +1031,6 @@ msgstr "" "が行われるように遅延させる必要が生じます。古典的な例は以下のようなコートで" "す::" -#: ../../library/gettext.rst:549 msgid "" "animals = ['mollusk',\n" " 'albatross',\n" @@ -929,6 +1041,14 @@ msgid "" "for a in animals:\n" " print(a)" msgstr "" +"animals = ['mollusk',\n" +" 'albatross',\n" +" 'rat',\n" +" 'penguin',\n" +" 'python', ]\n" +"# ...\n" +"for a in animals:\n" +" print(a)" #: ../../library/gettext.rst:558 msgid "" @@ -943,7 +1063,6 @@ msgstr "" msgid "Here is one way you can handle this situation::" msgstr "こうした状況を処理する一つの方法を以下に示します::" -#: ../../library/gettext.rst:564 msgid "" "def _(message): return message\n" "\n" @@ -959,8 +1078,20 @@ msgid "" "for a in animals:\n" " print(_(a))" msgstr "" +"def _(message): return message\n" +"\n" +"animals = [_('mollusk'),\n" +" _('albatross'),\n" +" _('rat'),\n" +" _('penguin'),\n" +" _('python'), ]\n" +"\n" +"del _\n" +"\n" +"# ...\n" +"for a in animals:\n" +" print(_(a))" -#: ../../library/gettext.rst:578 msgid "" "This works because the dummy definition of :func:`!_` simply returns the " "string unchanged. And this dummy definition will temporarily override any " @@ -968,19 +1099,25 @@ msgid "" "command). Take care, though if you have a previous definition of :func:`!_` " "in the local namespace." msgstr "" +":func:`!_` の仮の定義は文字列を変更せずに返すだけなので、この方法でうまくいき" +"ます。\n" +"この仮の定義は、組み込み名前空間にある :func:`!_` の定義を一時的に (:keyword:" +"`del` コマンドまで) 覆い隠します。\n" +"ただし、ローカル名前空間ですでに :func:`!_` を定義している場合には注意してく" +"ださい。" -#: ../../library/gettext.rst:584 msgid "" "Note that the second use of :func:`!_` will not identify \"a\" as being " "translatable to the :program:`gettext` program, because the parameter is not " "a string literal." msgstr "" +"2 回目の :func:`!_` の使用では、引数が文字列リテラルではないため、:program:" +"`gettext` プログラムは \"a\" を翻訳対象として認識しません。" #: ../../library/gettext.rst:588 msgid "Another way to handle this is with the following example::" msgstr "もう一つの処理法は、以下の例のようなやり方です::" -#: ../../library/gettext.rst:590 msgid "" "def N_(message): return message\n" "\n" @@ -994,8 +1131,18 @@ msgid "" "for a in animals:\n" " print(_(a))" msgstr "" +"def N_(message): return message\n" +"\n" +"animals = [N_('mollusk'),\n" +" N_('albatross'),\n" +" N_('rat'),\n" +" N_('penguin'),\n" +" N_('python'), ]\n" +"\n" +"# ...\n" +"for a in animals:\n" +" print(_(a))" -#: ../../library/gettext.rst:602 msgid "" "In this case, you are marking translatable strings with the function :func:`!" "N_`, which won't conflict with any definition of :func:`!_`. However, you " @@ -1006,6 +1153,15 @@ msgid "" "totally arbitrary; it could have just as easily been :func:`!" "MarkThisStringForTranslation`." msgstr "" +"この場合は :func:`!N_` 関数で翻訳対象の文字列をマークするため、:func:`!_` の" +"定義と衝突しません。\n" +"ただし、メッセージ抽出プログラムに、:func:`!N_` でマークされた文字列を探すよ" +"う指定する必要があります。\n" +":program:`xgettext`、:program:`pygettext`、``pybabel extract``、:program:" +"`xpot` は、いずれも :option:`!-k` コマンドラインオプションでこの指定をサポー" +"トします。\n" +"ここで :func:`!N_` という名前を選んだことに特別な意味はありません。\n" +":func:`!MarkThisStringForTranslation` でも同様に使えます。" #: ../../library/gettext.rst:613 msgid "Acknowledgements" @@ -1056,7 +1212,6 @@ msgstr "Gustavo Niemeyer" msgid "Footnotes" msgstr "脚注" -#: ../../library/gettext.rst:636 msgid "" "The default locale directory is system dependent; for example, on Red Hat " "Linux it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/" @@ -1066,6 +1221,14 @@ msgid "" "call :func:`bindtextdomain` with an explicit absolute path at the start of " "your application." msgstr "" +"デフォルトのロケールディレクトリはシステムに依存します。\n" +"例えば Red Hat Linux では :file:`/usr/share/locale`、Solaris では :file:`/" +"usr/lib/locale` です。\n" +":mod:`!gettext` モジュールはこうしたシステムごとのデフォルト値には対応せず、" +"代わりに :file:`{sys.base_prefix}/share/locale` をデフォルトとして使います (:" +"data:`sys.base_prefix` を参照)。\n" +"このため、アプリケーションの開始時に明示的な絶対パスを指定して :func:" +"`bindtextdomain` を呼び出すのが最善です。" #: ../../library/gettext.rst:644 msgid "See the footnote for :func:`bindtextdomain` above." diff --git a/library/glob.po b/library/glob.po index 5eae0d7ef..a1a91f4f1 100644 --- a/library/glob.po +++ b/library/glob.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/glob.rst:2 @@ -30,7 +30,6 @@ msgstr ":mod:`!glob` --- Unix 形式のパス名のパターン展開" msgid "**Source code:** :source:`Lib/glob.py`" msgstr "**ソースコード:** :source:`Lib/glob.py`" -#: ../../library/glob.rst:21 msgid "" "The :mod:`!glob` module finds pathnames using pattern matching rules similar " "to the Unix shell. No tilde expansion is done, but ``*``, ``?``, and " @@ -38,20 +37,32 @@ msgid "" "done by using the :func:`os.scandir` and :func:`fnmatch.fnmatch` functions " "in concert, and not by actually invoking a subshell." msgstr "" +":mod:`!glob` モジュールは、Unix シェルに似たパターンマッチの規則を使ってパス" +"名を探します。\n" +"チルダ展開は行いませんが、``*``、``?``、``[]`` で表す文字の範囲は正しくマッチ" +"します。\n" +"実際にサブシェルを起動するのではなく、:func:`os.scandir` と :func:`fnmatch." +"fnmatch` を組み合わせて処理します。" -#: ../../library/glob.rst:29 msgid "" "The pathnames are returned in no particular order. If you need a specific " "order, sort the results." msgstr "" +"パス名が返される順序は決まっていません。\n" +"特定の順序が必要な場合は、結果をソートしてください。" -#: ../../library/glob.rst:32 msgid "" "By default, files beginning with a dot (``.``) can only be matched by " "patterns that also start with a dot, unlike :func:`fnmatch.fnmatch` or :func:" "`pathlib.Path.glob`. For tilde and shell variable expansion, use :func:`os." "path.expanduser` and :func:`os.path.expandvars`." msgstr "" +"デフォルトでは、ドット (``.``) で始まるファイルは、同じくドットで始まるパター" +"ンにしかマッチしません。\n" +"この点は :func:`fnmatch.fnmatch` や :func:`pathlib.Path.glob` と異なりま" +"す。\n" +"チルダやシェル変数の展開には :func:`os.path.expanduser` と :func:`os.path." +"expandvars` を使ってください。" #: ../../library/glob.rst:38 msgid "" @@ -61,9 +72,8 @@ msgstr "" "リテラルにマッチさせるには、メタ文字を括弧に入れてください。例えば、" "``'[?]'`` は文字 ``'?'`` にマッチします。" -#: ../../library/glob.rst:41 msgid "The :mod:`!glob` module defines the following functions:" -msgstr "" +msgstr ":mod:`!glob` モジュールは次の関数を定義しています。" #: ../../library/glob.rst:47 msgid "" @@ -86,13 +96,17 @@ msgstr "" "合、それらのファイルに対するパス名が結果に含まれるかどうかはの動作は不定で" "す。" -#: ../../library/glob.rst:56 msgid "" "If *root_dir* is not ``None``, it should be a :term:`path-like object` " "specifying the root directory for searching. It has the same effect on :" "func:`!glob` as changing the current directory before calling it. If " "*pathname* is relative, the result will contain paths relative to *root_dir*." msgstr "" +"*root_dir* が ``None`` でない場合は、検索のルートディレクトリを指定する :" +"term:`path-like object` でなければなりません。\n" +":func:`!glob` の呼び出し前にカレントディレクトリを変更するのと同じ効果があり" +"ます。\n" +"*pathname* が相対パスの場合、結果には *root_dir* からの相対パスが含まれます。" #: ../../library/glob.rst:62 msgid "" @@ -114,27 +128,26 @@ msgstr "" "ます。パターンの末尾が :data:`os.sep` または :data:`os.altsep` の場合、ファイ" "ルは一致しません。" -#: ../../library/glob.rst:73 msgid "" "If *include_hidden* is true, wildcards can match path segments that begin " "with a dot (``.``)." msgstr "" +"*include_hidden* が真の場合、ワイルドカードはドット (``.``) で始まるパスのセ" +"グメントにもマッチします。" -#: ../../library/glob.rst:76 ../../library/glob.rst:108 msgid "" "Raises an :ref:`auditing event ` ``glob.glob`` with arguments " "``pathname``, ``recursive``." msgstr "" "引数 ``pathname``, ``recursive`` を指定して :ref:`監査イベント ` " -"``glob.glob`` を送出します。 " +"``glob.glob`` を送出します。" -#: ../../library/glob.rst:77 ../../library/glob.rst:109 msgid "" "Raises an :ref:`auditing event ` ``glob.glob/2`` with arguments " "``pathname``, ``recursive``, ``root_dir``, ``dir_fd``." msgstr "" "引数 ``pathname``, ``recursive``, ``root_dir``, ``dir_fd`` を指定して :ref:`" -"監査イベント ` ``glob.glob/2`` を送出します。 " +"監査イベント ` ``glob.glob/2`` を送出します。" #: ../../library/glob.rst:80 msgid "" @@ -152,12 +165,14 @@ msgstr "" "*pathname* が複数の \"``**``\" パターンを含み、かつ *recursive* が真の場合、" "この関数は同じパスを重複して返す可能性があります。" -#: ../../library/glob.rst:88 ../../library/glob.rst:116 msgid "" "Any :exc:`OSError` exceptions raised from scanning the filesystem are " "suppressed. This includes :exc:`PermissionError` when accessing directories " "without read permission." msgstr "" +"ファイルシステムの走査中に発生した :exc:`OSError` 例外はすべて抑制します。\n" +"これには、読み取り権限のないディレクトリへのアクセスで発生する :exc:" +"`PermissionError` も含まれます。" #: ../../library/glob.rst:92 ../../library/glob.rst:120 msgid "Support for recursive globs using \"``**``\"." @@ -179,7 +194,6 @@ msgstr "" "実際には一度にすべてを格納せずに、:func:`glob` と同じ値を順に生成する :term:`" "イテレーター ` を返します。" -#: ../../library/glob.rst:132 msgid "" "Escape all special characters (``'?'``, ``'*'`` and ``'['``). This is useful " "if you want to match an arbitrary literal string that may have special " @@ -187,13 +201,21 @@ msgid "" "escaped, for example on Windows ``escape('//?/c:/Quo vadis?.txt')`` returns " "``'//?/c:/Quo vadis[?].txt'``." msgstr "" +"すべての特殊文字 (``'?'``、``'*'``、``'['``) をエスケープします。\n" +"特殊文字を含む可能性がある任意の文字列に、そのままマッチさせたい場合に便利で" +"す。\n" +"ドライブ名や UNC 共有ポイントの特殊文字はエスケープしません。\n" +"例えば Windows では、``escape('//?/c:/Quo vadis?.txt')`` は ``'//?/c:/Quo " +"vadis[?].txt'`` を返します。" -#: ../../library/glob.rst:143 msgid "" "Convert the given path specification to a regular expression for use with :" "func:`re.prefixmatch`. The path specification can contain shell-style " "wildcards." msgstr "" +"指定したパスのパターンを、:func:`re.prefixmatch` で使う正規表現に変換しま" +"す。\n" +"パスのパターンにはシェル形式のワイルドカードを含められます。" #: ../../library/glob.rst:147 msgid "For example:" @@ -248,7 +270,6 @@ msgstr "" msgid "Examples" msgstr "使用例" -#: ../../library/glob.rst:183 msgid "" "Consider a directory containing the following files: :file:`1.gif`, :file:`2." "txt`, :file:`card.gif` and a subdirectory :file:`sub` which contains only " @@ -256,9 +277,9 @@ msgid "" "Notice how any leading components of the path are preserved. ::" msgstr "" "次のファイルを含むディレクトリを考えます: :file:`1.gif`, :file:`2.txt`, :" -"file:`card.gif` および:file:`3.txt` だけを含む :file:`sub` サブディレクトリ。" -"このとき、 :func:`glob` は以下の結果を返します。パスにおける先頭の要素がどの" -"ように保持されるかに注意してください::" +"file:`card.gif` および :file:`3.txt` だけを含む :file:`sub` サブディレクト" +"リ。このとき、 :func:`glob` は以下の結果を返します。パスにおける先頭の要素が" +"どのように保持されるかに注意してください::" #: ../../library/glob.rst:189 msgid "" diff --git a/library/graphlib.po b/library/graphlib.po index 63acfbc83..7bd32c85f 100644 --- a/library/graphlib.po +++ b/library/graphlib.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/graphlib.rst:2 @@ -115,13 +115,16 @@ msgstr "" "すぐにグラフのノードをソートした結果が必要で、並行性が不要な場合、便利なメ" "ソッド :meth:`TopologicalSorter.static_order` を直接呼び出すことができます:" -#: ../../library/graphlib.rst:53 msgid "" ">>> graph = {\"D\": {\"B\", \"C\"}, \"C\": {\"A\"}, \"B\": {\"A\"}}\n" ">>> ts = TopologicalSorter(graph)\n" ">>> tuple(ts.static_order())\n" "('A', 'C', 'B', 'D')" msgstr "" +">>> graph = {\"D\": {\"B\", \"C\"}, \"C\": {\"A\"}, \"B\": {\"A\"}}\n" +">>> ts = TopologicalSorter(graph)\n" +">>> tuple(ts.static_order())\n" +"('A', 'C', 'B', 'D')" #: ../../library/graphlib.rst:60 msgid "" @@ -131,7 +134,6 @@ msgstr "" "このクラスは、簡単に準備が整ったノードの並列処理を行えるよう設計されていま" "す。例えば::" -#: ../../library/graphlib.rst:63 msgid "" "topological_sorter = TopologicalSorter()\n" "\n" @@ -155,6 +157,29 @@ msgid "" " node = finalized_tasks_queue.get()\n" " topological_sorter.done(node)" msgstr "" +"topological_sorter = TopologicalSorter()\n" +"\n" +"# 'topological_sorter' にノードを追加する...\n" +"\n" +"topological_sorter.prepare()\n" +"while topological_sorter.is_active():\n" +" for node in topological_sorter.get_ready():\n" +" # ワーカースレッドやプロセスが 'task_queue' キューから\n" +" # 処理するノードを取り出す。\n" +" task_queue.put(node)\n" +"\n" +" # ノードの処理が終わると、ワーカーはそのノードを\n" +" # 'finalized_tasks_queue' に入れる。\n" +" # それによって次の処理対象を得られる。\n" +" # 'is_active()' の定義により、この時点で 'task_queue' に入っていて\n" +" # まだ 'done()' に渡されていないノードが少なくとも 1 つある。\n" +" # したがって、ここでブロックする 'get()' は最終的には成功する。\n" +" # 'done()' の呼び出し後はループの先頭に戻り、再び 'get_ready()' を呼" +"ぶ。\n" +" # これにより、新たに処理可能になったノードを論理的に可能な限り早く\n" +" # 'task_queue' に入れられる。\n" +" node = finalized_tasks_queue.get()\n" +" topological_sorter.done(node)" #: ../../library/graphlib.rst:87 msgid "" @@ -172,13 +197,16 @@ msgstr "" "同じ node 引数で複数回呼び出した場合、依存関係の集合は、それまでに指定した依" "存関係の和集合になります。" -#: ../../library/graphlib.rst:93 msgid "" "It is possible to add a node with no dependencies (*predecessors* is not " "provided) or to provide a dependency twice. If a node that has not been " "provided before is included among *predecessors* it will be automatically " "added to the graph with no predecessors of its own." msgstr "" +"依存先のないノードを追加することも (*predecessors* を指定しない場合)、同じ依" +"存関係を 2 回指定することもできます。\n" +"*predecessors* に、まだ追加していないノードが含まれる場合、そのノードは自身の" +"先行ノードを持たないものとしてグラフに自動的に追加されます。" #: ../../library/graphlib.rst:98 msgid "" @@ -187,7 +215,6 @@ msgstr "" ":meth:`~TopologicalSorter.prepare` を呼び出した後にこのメソッドを呼び出す" "と、:exc:`ValueError` を送出します。" -#: ../../library/graphlib.rst:102 msgid "" "Mark the graph as finished and check for cycles in the graph. If any cycle " "is detected, :exc:`CycleError` will be raised, but :meth:`~TopologicalSorter." @@ -196,20 +223,28 @@ msgid "" "be modified, and therefore no more nodes can be added using :meth:" "`~TopologicalSorter.add`." msgstr "" +"グラフの構築を完了したものとして印を付け、閉路がないか調べます。\n" +"閉路が見つかると :exc:`CycleError` を送出しますが、:meth:`~TopologicalSorter." +"get_ready` は引き続き使えるため、閉路によってそれ以上進めなくなるまで可能な限" +"りノードを取得できます。\n" +"この関数を呼び出した後はグラフを変更できず、:meth:`~TopologicalSorter.add` で" +"ノードを追加することもできません。" -#: ../../library/graphlib.rst:109 msgid "" "A :exc:`ValueError` will be raised if the sort has been started by :meth:`~." "static_order` or :meth:`~.get_ready`." msgstr "" +":meth:`~.static_order` または :meth:`~.get_ready` によってソートが開始されて" +"いる場合は :exc:`ValueError` を送出します。" -#: ../../library/graphlib.rst:114 msgid "" "``prepare()`` can now be called more than once as long as the sort has not " "started. Previously this raised :exc:`ValueError`." msgstr "" +"ソートが開始されていなければ、``prepare()`` を複数回呼び出せるようになりまし" +"た。\n" +"以前は :exc:`ValueError` が送出されていました。" -#: ../../library/graphlib.rst:119 msgid "" "Returns ``True`` if more progress can be made and ``False`` otherwise. " "Progress can be made if cycles do not block the resolution and either there " @@ -218,28 +253,35 @@ msgid "" "`TopologicalSorter.done` is less than the number that have been returned by :" "meth:`TopologicalSorter.get_ready`." msgstr "" +"処理を進められる場合は ``True``、そうでなければ ``False`` を返します。\n" +"閉路によって処理が妨げられておらず、:meth:`TopologicalSorter.get_ready` がま" +"だ返していない処理可能なノードがあるか、:meth:`TopologicalSorter.done` で処理" +"済みとしたノード数が :meth:`TopologicalSorter.get_ready` の返したノード数より" +"少ない場合に、処理を進められます。" -#: ../../library/graphlib.rst:126 msgid "" "The :meth:`~object.__bool__` method of this class defers to this function, " "so instead of::" msgstr "" +"このクラスの :meth:`~object.__bool__` メソッドはこの関数に処理を委ねます。\n" +"そのため、次の書き方は置き換えられます。 ::" -#: ../../library/graphlib.rst:129 msgid "" "if ts.is_active():\n" " ..." msgstr "" +"if ts.is_active():\n" +" ..." -#: ../../library/graphlib.rst:132 msgid "it is possible to simply do::" -msgstr "このように簡単に記述できます:" +msgstr "次のように簡単に書けます。 ::" -#: ../../library/graphlib.rst:134 msgid "" "if ts:\n" " ..." msgstr "" +"if ts:\n" +" ..." #: ../../library/graphlib.rst:137 ../../library/graphlib.rst:160 msgid "" @@ -249,14 +291,17 @@ msgstr "" "前もって :meth:`~TopologicalSorter.prepare` を呼び出さずにこの関数を呼び出す" "と :exc:`ValueError` を送出します。" -#: ../../library/graphlib.rst:142 msgid "" "Marks a set of nodes returned by :meth:`TopologicalSorter.get_ready` as " "processed, unblocking any successor of each node in *nodes* for being " "returned in the future by a call to :meth:`TopologicalSorter.get_ready`." msgstr "" +":meth:`TopologicalSorter.get_ready` が返した一連のノードを処理済みとしま" +"す。\n" +"これにより、*nodes* の各ノードの後続ノードが、それ以降の :meth:" +"`TopologicalSorter.get_ready` の呼び出しで返されるための依存条件が解消されま" +"す。" -#: ../../library/graphlib.rst:146 msgid "" "Raises :exc:`ValueError` if any node in *nodes* has already been marked as " "processed by a previous call to this method or if a node was not added to " @@ -264,8 +309,12 @@ msgid "" "meth:`~TopologicalSorter.prepare` or if node has not yet been returned by :" "meth:`~TopologicalSorter.get_ready`." msgstr "" +"*nodes* のいずれかのノードが、このメソッドの以前の呼び出しですでに処理済みに" +"なっている場合や、:meth:`TopologicalSorter.add` でグラフに追加されていない場" +"合は :exc:`ValueError` を送出します。\n" +":meth:`~TopologicalSorter.prepare` を呼び出す前に呼び出した場合や、ノードがま" +"だ :meth:`~TopologicalSorter.get_ready` から返されていない場合も同様です。" -#: ../../library/graphlib.rst:154 msgid "" "Returns a ``tuple`` with all the nodes that are ready. Initially it returns " "all nodes with no predecessors, and once those are marked as processed by " @@ -273,16 +322,23 @@ msgid "" "nodes that have all their predecessors already processed. Once no more " "progress can be made, empty tuples are returned." msgstr "" +"処理の準備が整ったすべてのノードを ``tuple`` で返します。\n" +"最初は先行ノードのないすべてのノードを返します。\n" +"それらを :meth:`TopologicalSorter.done` で処理済みとすると、以降の呼び出しで" +"は、すべての先行ノードの処理が終わった新たなノードをすべて返します。\n" +"それ以上処理を進められなくなると、空のタプルを返します。" -#: ../../library/graphlib.rst:165 msgid "" "Returns an iterator object which will iterate over nodes in a topological " "order. When using this method, :meth:`~TopologicalSorter.prepare` and :meth:" "`~TopologicalSorter.done` should not be called. This method is equivalent " "to::" msgstr "" +"ノードをトポロジカル順序でたどるイテレータオブジェクトを返します。\n" +"このメソッドを使う場合は、:meth:`~TopologicalSorter.prepare` と :meth:" +"`~TopologicalSorter.done` を呼び出さないでください。\n" +"このメソッドは次と等価です。 ::" -#: ../../library/graphlib.rst:170 msgid "" "def static_order(self):\n" " self.prepare()\n" @@ -291,14 +347,21 @@ msgid "" " yield from node_group\n" " self.done(*node_group)" msgstr "" +"def static_order(self):\n" +" self.prepare()\n" +" while self.is_active():\n" +" node_group = self.get_ready()\n" +" yield from node_group\n" +" self.done(*node_group)" -#: ../../library/graphlib.rst:177 msgid "" "The particular order that is returned may depend on the specific order in " "which the items were inserted in the graph. For example:" msgstr "" +"返される具体的な順序は、グラフに要素を挿入した順序に依存する場合がありま" +"す。\n" +"例えば次のようになります。" -#: ../../library/graphlib.rst:180 msgid "" ">>> ts = TopologicalSorter()\n" ">>> ts.add(3, 2, 1)\n" @@ -312,35 +375,49 @@ msgid "" ">>> print([*ts2.static_order()])\n" "[0, 2, 1, 3]" msgstr "" +">>> ts = TopologicalSorter()\n" +">>> ts.add(3, 2, 1)\n" +">>> ts.add(1, 0)\n" +">>> print([*ts.static_order()])\n" +"[2, 0, 1, 3]\n" +"\n" +">>> ts2 = TopologicalSorter()\n" +">>> ts2.add(1, 0)\n" +">>> ts2.add(3, 2, 1)\n" +">>> print([*ts2.static_order()])\n" +"[0, 2, 1, 3]" -#: ../../library/graphlib.rst:194 msgid "" "This is due to the fact that \"0\" and \"2\" are in the same level in the " "graph (they would have been returned in the same call to :meth:" "`~TopologicalSorter.get_ready`) and the order between them is determined by " "the order of insertion." msgstr "" +"これは、\"0\" と \"2\" がグラフの同じ階層にあり (同じ :meth:" +"`~TopologicalSorter.get_ready` の呼び出しで返される)、両者の間の順序が挿入順" +"で決まるためです。" -#: ../../library/graphlib.rst:200 msgid "If any cycle is detected, :exc:`CycleError` will be raised." -msgstr "" +msgstr "閉路が見つかると :exc:`CycleError` を送出します。" #: ../../library/graphlib.rst:206 msgid "Exceptions" msgstr "例外" -#: ../../library/graphlib.rst:207 msgid "The :mod:`!graphlib` module defines the following exception classes:" -msgstr "" +msgstr ":mod:`!graphlib` モジュールは次の例外クラスを定義しています。" -#: ../../library/graphlib.rst:211 msgid "" "Subclass of :exc:`ValueError` raised by :meth:`TopologicalSorter.prepare` if " "cycles exist in the working graph. If multiple cycles exist, only one " "undefined choice among them will be reported and included in the exception." msgstr "" +"処理対象のグラフに閉路がある場合に :meth:`TopologicalSorter.prepare` が送出す" +"る、:exc:`ValueError` のサブクラスです。\n" +"閉路が複数ある場合は、そのうち 1 つだけが選ばれて報告され、例外に含まれま" +"す。\n" +"どれが選ばれるかは未定義です。" -#: ../../library/graphlib.rst:215 msgid "" "The detected cycle can be accessed via the second element in the :attr:" "`~BaseException.args` attribute of the exception instance and consists in a " @@ -348,3 +425,9 @@ msgid "" "predecessor of the next node in the list. In the reported list, the first " "and the last node will be the same, to make it clear that it is cyclic." msgstr "" +"検出された閉路には、例外インスタンスの :attr:`~BaseException.args` 属性の 2 " +"番目の要素からアクセスできます。\n" +"これはノードのリストで、各ノードはグラフ上でリストの次のノードの直接の先行" +"ノードになっています。\n" +"閉路であることが分かるように、報告されるリストの最初と最後のノードは同じで" +"す。" diff --git a/library/grp.po b/library/grp.po index 4526db454..36028cc01 100644 --- a/library/grp.po +++ b/library/grp.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/grp.rst:2 @@ -34,9 +34,8 @@ msgstr "" "このモジュールでは Unix グループ (group) データベースへのアクセス機構を提供し" "ます。全ての Unix バージョンで利用可能です。" -#: ../../library/grp.rst:12 msgid "Availability" -msgstr "" +msgstr "利用可能な環境" #: ../../library/grp.rst:14 msgid "" @@ -153,9 +152,10 @@ msgstr "" "与えられたグループ名に対するグループデータベースエントリを返します。要求した" "エントリが見つからなかった場合、 :exc:`KeyError` が送出されます。" -#: ../../library/grp.rst:58 msgid "Return a list of all available group entries, in arbitrary order." -msgstr "全ての入手可能なグループエントリを返します。順番は決まっていません。" +msgstr "" +"利用可能なすべてのグループエントリーを、順序の決まっていないリストとして返し" +"ます。" #: ../../library/grp.rst:63 msgid "Module :mod:`pwd`" diff --git a/library/gzip.po b/library/gzip.po index a0cde3858..2ad62ca10 100644 --- a/library/gzip.po +++ b/library/gzip.po @@ -17,10 +17,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/gzip.rst:2 @@ -39,19 +39,21 @@ msgstr "" "このモジュールは、GNU の :program:`gzip` や :program:`gunzip` のようにファイ" "ルを圧縮、展開するシンプルなインターフェイスを提供しています。" -#: ../../includes/optional-module.rst:1 msgid "" "This is an :term:`optional module`. If it is missing from your copy of " "CPython, look for documentation from your distributor (that is, whoever " "provided Python to you). If you are the distributor, see :ref:`optional-" "module-requirements`." msgstr "" +"これは :term:`オプションモジュール ` です。\n" +"使用している CPython に含まれていない場合は、配布元 (Python を提供した組織な" +"ど) のドキュメントを確認してください。\n" +"配布する立場の場合は :ref:`optional-module-requirements` を参照してください。" #: ../../library/gzip.rst:16 msgid "The data compression is provided by the :mod:`zlib` module." msgstr "データ圧縮は :mod:`zlib` モジュールで提供されています。" -#: ../../library/gzip.rst:18 msgid "" "The :mod:`!gzip` module provides the :class:`GzipFile` class, as well as " "the :func:`.open`, :func:`compress` and :func:`decompress` convenience " @@ -59,6 +61,11 @@ msgid "" "format files, automatically compressing or decompressing the data so that it " "looks like an ordinary :term:`file object`." msgstr "" +":mod:`!gzip` モジュールは :class:`GzipFile` クラスと、便利な関数 :func:`." +"open`、:func:`compress`、:func:`decompress` を提供します。\n" +":class:`GzipFile` クラスは :program:`gzip` 形式のファイルを読み書きし、データ" +"を自動的に圧縮・展開するため、通常の :term:`file object` と同じように扱えま" +"す。" #: ../../library/gzip.rst:24 msgid "" @@ -145,32 +152,37 @@ msgstr " ``'x'``、``'xb'``、``'xt'`` モードのサポートが追加され msgid "Accepts a :term:`path-like object`." msgstr ":term:`path-like object` を受け入れるようになりました。" -#: ../../library/gzip.rst:64 ../../library/gzip.rst:195 -#: ../../library/gzip.rst:225 msgid "" "The default compression level was reduced to 6 (down from 9). It is the " "default level used by most compression tools and a better tradeoff between " "speed and performance." msgstr "" +"デフォルトの圧縮レベルが 9 から 6 に下がりました。\n" +"これはほとんどの圧縮ツールのデフォルトで、速度と性能のバランスがよりよいレベ" +"ルです。" -#: ../../library/gzip.rst:71 msgid "" "An exception raised for invalid gzip files. It inherits from :exc:" "`OSError`. :exc:`EOFError` and :exc:`zlib.error` can also be raised for " "invalid gzip files." msgstr "" +"不正な gzip ファイルに対して送出される例外です。\n" +":exc:`OSError` を継承します。\n" +"不正な gzip ファイルに対しては :exc:`EOFError` や :exc:`zlib.error` が送出さ" +"れる場合もあります。" -#: ../../library/gzip.rst:79 msgid "" "Constructor for the :class:`GzipFile` class, which simulates most of the " "methods of a :term:`file object`, with the exception of the :meth:`~io." "IOBase.truncate` method. At least one of *fileobj* and *filename* must be " "given a non-trivial value." msgstr "" -":class:`GzipFile` クラスのコンストラクタです。:class:`GzipFile` オブジェクト" -"は :meth:`~io.IOBase.truncate` メソッドを除くほとんどの :term:`ファイルオブ" -"ジェクト ` のメソッドをシミュレートします。少なくとも *fileobj* " -"および *filename* は有効な値でなければなりません。" +":class:`GzipFile` クラスのコンストラクタです。\n" +"``GzipFile`` オブジェクトは :meth:`~io.IOBase.truncate` メソッドを除くほとん" +"どの :term:`ファイルオブジェクト ` のメソッドをシミュレートしま" +"す。\n" +"*fileobj* と *filename* の少なくとも一方には、有効な値を指定しなければなりま" +"せん。" #: ../../library/gzip.rst:84 msgid "" @@ -198,7 +210,6 @@ msgstr "" "認識可能な場合、規定値は *fileobj* のファイル名です。そうでない場合、規定値は" "空の文字列で、元のファイル名はヘッダにはインクルードされません。" -#: ../../library/gzip.rst:95 msgid "" "The *mode* argument can be any of ``'r'``, ``'rb'``, ``'a'``, ``'ab'``, " "``'w'``, ``'wb'``, ``'x'``, or ``'xb'``, depending on whether the file will " @@ -207,6 +218,12 @@ msgid "" "*fileobj* will not be used. It is better to always specify *mode* for " "writing." msgstr "" +"*mode* 引数には、読み取りか書き込みかに応じて ``'r'``、``'rb'``、``'a'``、" +"``'ab'``、``'w'``、``'wb'``、``'x'``、``'xb'`` のいずれかを指定できます。\n" +"デフォルトは、*fileobj* のモードが分かる場合はそのモード、そうでなければ " +"``'rb'`` です。\n" +"今後の Python のリリースでは *fileobj* のモードを使わなくなります。\n" +"書き込みの場合は、常に *mode* を指定することを推奨します。" #: ../../library/gzip.rst:101 msgid "" @@ -229,7 +246,6 @@ msgstr "" "す; ``1`` は最も高速で最小限の圧縮を行い、``9`` は最も低速ですが最大限の圧縮" "を行います。``0`` は圧縮しません。デフォルトは ``9`` です。" -#: ../../library/gzip.rst:110 msgid "" "The optional *mtime* argument is the timestamp requested by gzip. The time " "is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. Set " @@ -240,11 +256,20 @@ msgid "" "argument is outside the range ``0`` to ``2**32-1``, then the value ``0`` is " "used instead." msgstr "" +"省略可能な *mtime* 引数は、gzip が要求するタイムスタンプです。\n" +"時刻は Unix 形式、つまり 1970 年 1 月 1 日 00:00:00 UTC からの秒数で指定しま" +"す。\n" +"作成時刻に依存しない圧縮ストリームを生成するには、*mtime* を ``0`` にしてくだ" +"さい。\n" +"*mtime* を省略するか ``None`` にすると、現在時刻を使います。\n" +"ただし、現在時刻が 1970 年 1 月 1 日 00:00:00 UTC から 2106 年 2 月 7 日 " +"06:28:15 UTC までの範囲外の場合や、明示的に渡した *mtime* 引数が ``0`` から " +"``2**32-1`` の範囲外の場合は、代わりに ``0`` を使います。" -#: ../../library/gzip.rst:119 msgid "" "See below for the :attr:`mtime` attribute that is set when decompressing." msgstr "" +"展開時に設定される :attr:`mtime` 属性については、以下を参照してください。" #: ../../library/gzip.rst:121 msgid "" @@ -257,9 +282,9 @@ msgstr "" "圧縮したデータの後ろにさらに何か追加したい場合もあるので、:class:`GzipFile` " "オブジェクトの :meth:`!close` メソッド呼び出しは *fileobj* を閉じません。\n" "このため、書き込みのためにオープンした :class:`io.BytesIO` オブジェクトを " -"*fileobj* として渡し、(:class:`GzipFile` を :meth:`close` した後に) :class:" -"`io.BytesIO` オブジェクトの :meth:`~io.BytesIO.getvalue` メソッドを使って書き" -"込んだデータの入っているメモリバッファを取得することができます。" +"*fileobj* として渡し、(``GzipFile`` を ``close()`` した後に) :class:`io." +"BytesIO` オブジェクトの :meth:`~io.BytesIO.getvalue` メソッドを使って書き込ん" +"だデータの入っているメモリバッファを取得することができます。" #: ../../library/gzip.rst:127 msgid "" @@ -275,13 +300,12 @@ msgstr "" msgid ":class:`GzipFile` also provides the following method and attribute:" msgstr ":class:`GzipFile` は以下のメソッドと属性も提供しています:" -#: ../../library/gzip.rst:135 msgid "" "Read *n* uncompressed bytes without advancing the file position. The number " "of bytes returned may be more or less than requested." msgstr "" -"ファイル内の位置を移動せずに展開した *n* バイトを読み込みます。返されるバイト" -"数はほぼ要求した値になります。" +"ファイル位置を進めずに、展開後のデータを *n* バイト読み込みます。\n" +"返されるバイト数は要求した数より多くなることも少なくなることもあります。" #: ../../library/gzip.rst:138 msgid "" @@ -297,24 +321,29 @@ msgstr "" msgid "``'rb'`` for reading and ``'wb'`` for writing." msgstr "``'rb'`` は読み込み用、 ``'wb'`` は書き込み用です。" -#: ../../library/gzip.rst:149 msgid "In previous versions it was an integer ``1`` or ``2``." -msgstr "" +msgstr "以前のバージョンでは整数の ``1`` または ``2`` でした。" -#: ../../library/gzip.rst:154 msgid "" "When decompressing, this attribute is set to the last timestamp in the most " "recently read header. It is an integer, holding the number of seconds since " "the Unix epoch (00:00:00 UTC, January 1, 1970). The initial value before " "reading any headers is ``None``." msgstr "" +"展開時、この属性には最後に読み取ったヘッダーのタイムスタンプが設定されま" +"す。\n" +"Unix エポック (1970 年 1 月 1 日 00:00:00 UTC) からの秒数を表す整数です。\n" +"ヘッダーを読み取る前の初期値は ``None`` です。" -#: ../../library/gzip.rst:161 msgid "" "The path to the gzip file on disk, as a :class:`str` or :class:`bytes`. " "Equivalent to the output of :func:`os.fspath` on the original input path, " "with no other normalization, resolution or expansion." msgstr "" +"ディスク上の gzip ファイルへのパスを表す :class:`str` または :class:`bytes` " +"です。\n" +"元の入力パスに :func:`os.fspath` を適用した結果と等しく、それ以外の正規化、解" +"決、展開は行いません。" #: ../../library/gzip.rst:165 msgid "" @@ -347,31 +376,33 @@ msgstr "" "ポートされました。 :meth:`~io.BufferedIOBase.read` メソッドが ``None`` を引数" "として受け取るようになりました。" -#: ../../library/gzip.rst:187 msgid "" "Opening :class:`GzipFile` for writing without specifying the *mode* argument " "is deprecated." msgstr "" +"*mode* 引数を指定せずに :class:`GzipFile` を書き込み用に開くことは非推奨にな" +"りました。" -#: ../../library/gzip.rst:191 msgid "" "Remove the ``filename`` attribute, use the :attr:`~GzipFile.name` attribute " "instead." msgstr "" +"``filename`` 属性が削除されました。\n" +"代わりに :attr:`~GzipFile.name` 属性を使ってください。" -#: ../../library/gzip.rst:203 msgid "" "Compress the *data*, returning a :class:`bytes` object containing the " "compressed data. *compresslevel* and *mtime* have the same meaning as in " "the :class:`GzipFile` constructor above, but *mtime* defaults to 0 for " "reproducible output." msgstr "" +"*data* を圧縮し、圧縮データを含む :class:`bytes` オブジェクトを返します。\n" +"*compresslevel* と *mtime* は上記の :class:`GzipFile` コンストラクタと同じ意" +"味ですが、再現可能な出力を得るために *mtime* のデフォルトは 0 です。" -#: ../../library/gzip.rst:209 msgid "Added the *mtime* parameter for reproducible output." -msgstr "" +msgstr "再現可能な出力を得るための *mtime* 引数が追加されました。" -#: ../../library/gzip.rst:211 msgid "" "Speed is improved by compressing all data at once instead of in a streamed " "fashion. Calls with *mtime* set to ``0`` are delegated to :func:`zlib." @@ -379,20 +410,27 @@ msgid "" "header \"OS\" byte value other than 255 \"unknown\" as supplied by the " "underlying zlib implementation." msgstr "" +"ストリームとして処理する代わりにすべてのデータを一度に圧縮することで、高速化" +"しました。\n" +"*mtime* が ``0`` の呼び出しは、速度を上げるために :func:`zlib.compress` に委" +"譲されます。\n" +"この場合、内部で使う zlib 実装が設定する値により、出力の gzip ヘッダーの " +"\"OS\" バイトが、255 (\"unknown\") 以外になることがあります。" -#: ../../library/gzip.rst:218 msgid "" "The gzip header OS byte is guaranteed to be set to 255 when this function is " "used as was the case in 3.10 and earlier." msgstr "" +"この関数を使った場合、3.10 以前と同様に、gzip ヘッダーの OS バイトが 255 に設" +"定されることを保証するようになりました。" -#: ../../library/gzip.rst:221 msgid "" "The *mtime* parameter now defaults to 0 for reproducible output. For the " "previous behaviour of using the current time, pass ``None`` to *mtime*." msgstr "" +"再現可能な出力を得るために、*mtime* 引数のデフォルトが 0 になりました。\n" +"以前のように現在時刻を使うには、*mtime* に ``None`` を渡してください。" -#: ../../library/gzip.rst:232 msgid "" "Decompress the *data*, returning a :class:`bytes` object containing the " "uncompressed data. This function is capable of decompressing multi-member " @@ -400,12 +438,19 @@ msgid "" "certain to contain only one member the :func:`zlib.decompress` function with " "*wbits* set to 31 is faster." msgstr "" +"*data* を展開し、展開したデータを含む :class:`bytes` オブジェクトを返しま" +"す。\n" +"この関数は、複数のメンバーからなる gzip データ (複数の gzip ブロックを連結し" +"たもの) を展開できます。\n" +"データにメンバーが 1 つしか含まれないことが確実な場合は、*wbits* を 31 に設定" +"した :func:`zlib.decompress` 関数の方が高速です。" -#: ../../library/gzip.rst:239 msgid "" "Speed is improved by decompressing members at once in memory instead of in a " "streamed fashion." msgstr "" +"ストリームとして処理する代わりに、メモリ内でメンバーを一度に展開することで高" +"速化しました。" #: ../../library/gzip.rst:246 msgid "Examples of usage" @@ -415,30 +460,34 @@ msgstr "使い方の例" msgid "Example of how to read a compressed file::" msgstr "圧縮されたファイルを読み込む例::" -#: ../../library/gzip.rst:250 msgid "" "import gzip\n" "with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" " file_content = f.read()" msgstr "" +"import gzip\n" +"with gzip.open('/home/joe/file.txt.gz', 'rb') as f:\n" +" file_content = f.read()" #: ../../library/gzip.rst:254 msgid "Example of how to create a compressed GZIP file::" msgstr "GZIP 圧縮されたファイルを作成する例::" -#: ../../library/gzip.rst:256 msgid "" "import gzip\n" "content = b\"Lots of content here\"\n" "with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" " f.write(content)" msgstr "" +"import gzip\n" +"content = b\"Lots of content here\"\n" +"with gzip.open('/home/joe/file.txt.gz', 'wb') as f:\n" +" f.write(content)" #: ../../library/gzip.rst:261 msgid "Example of how to GZIP compress an existing file::" msgstr "既存のファイルを GZIP 圧縮する例::" -#: ../../library/gzip.rst:263 msgid "" "import gzip\n" "import shutil\n" @@ -446,17 +495,24 @@ msgid "" " with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" " shutil.copyfileobj(f_in, f_out)" msgstr "" +"import gzip\n" +"import shutil\n" +"with open('/home/joe/file.txt', 'rb') as f_in:\n" +" with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:\n" +" shutil.copyfileobj(f_in, f_out)" #: ../../library/gzip.rst:269 msgid "Example of how to GZIP compress a binary string::" msgstr "バイナリ文字列を GZIP 圧縮する例::" -#: ../../library/gzip.rst:271 msgid "" "import gzip\n" "s_in = b\"Lots of content here\"\n" "s_out = gzip.compress(s_in)" msgstr "" +"import gzip\n" +"s_in = b\"Lots of content here\"\n" +"s_out = gzip.compress(s_in)" #: ../../library/gzip.rst:277 msgid "Module :mod:`zlib`" @@ -470,51 +526,49 @@ msgstr "" ":program:`gzip` ファイル形式のサポートを行うために必要な基本ライブラリモ" "ジュール。" -#: ../../library/gzip.rst:281 msgid "" "In case gzip (de)compression is a bottleneck, the `python-isal`_ package " "speeds up (de)compression with a mostly compatible API." msgstr "" +"gzip の圧縮や展開がボトルネックとなる場合、`python-isal`_ パッケージを使う" +"と、ほぼ互換性のある API で圧縮や展開を高速化できます。" #: ../../library/gzip.rst:291 msgid "Command-line interface" msgstr "コマンドライン・インターフェース" -#: ../../library/gzip.rst:293 msgid "" "The :mod:`!gzip` module provides a simple command line interface to compress " "or decompress files." msgstr "" +":mod:`!gzip` モジュールは、ファイルを圧縮・展開するための簡単なコマンドライン" +"インターフェースを提供します。" -#: ../../library/gzip.rst:296 msgid "Once executed the :mod:`!gzip` module keeps the input file(s)." -msgstr "" +msgstr ":mod:`!gzip` モジュールは、実行後も入力ファイルを残します。" -#: ../../library/gzip.rst:300 msgid "" "Add a new command line interface with a usage. By default, when you will " "execute the CLI, the default compression level is 6." msgstr "" +"使用方法を表示する新しいコマンドラインインターフェースが追加されました。\n" +"CLI 実行時のデフォルトの圧縮レベルは 6 です。" #: ../../library/gzip.rst:304 msgid "Command-line options" msgstr "コマンドラインオプション" -#: ../../library/gzip.rst:308 msgid "If *file* is not specified, read from :data:`sys.stdin`." -msgstr "" +msgstr "*file* を指定しない場合は、:data:`sys.stdin` から読み取ります。" -#: ../../library/gzip.rst:312 msgid "Indicates the fastest compression method (less compression)." -msgstr "" +msgstr "最速の圧縮方法 (低い圧縮率) を指定します。" -#: ../../library/gzip.rst:316 msgid "Indicates the slowest compression method (best compression)." -msgstr "" +msgstr "最も遅い圧縮方法 (最も高い圧縮率) を指定します。" -#: ../../library/gzip.rst:320 msgid "Decompress the given file." -msgstr "" +msgstr "指定したファイルを展開します。" #: ../../library/gzip.rst:324 msgid "Show the help message." diff --git a/library/hashlib.po b/library/hashlib.po index 41db6a94a..8ad34bc2b 100644 --- a/library/hashlib.po +++ b/library/hashlib.po @@ -18,10 +18,10 @@ msgstr "" "Last-Translator: Takanori Suzuki , 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/hashlib.rst:2 @@ -32,7 +32,6 @@ msgstr ":mod:`!hashlib` --- セキュアハッシュとメッセージダイジ msgid "**Source code:** :source:`Lib/hashlib.py`" msgstr "**ソースコード:** :source:`Lib/hashlib.py`" -#: ../../library/hashlib.rst:20 msgid "" "This module implements a common interface to many different hash algorithms. " "Included are the FIPS secure hash algorithms SHA224, SHA256, SHA384, SHA512, " @@ -40,6 +39,12 @@ msgid "" "FIPS 202 standard`_) as well as the legacy algorithms SHA1 (`formerly part " "of FIPS`_) and the MD5 algorithm (defined in internet :rfc:`1321`)." msgstr "" +"このモジュールは、多くの異なるハッシュアルゴリズムに共通のインターフェースを" +"実装しています。\n" +"FIPS のセキュアハッシュアルゴリズム SHA224、SHA256、SHA384、SHA512 (`the " +"FIPS 180-4 standard`_ で定義)、SHA-3 系列 (`the FIPS 202 standard`_ で定義)、" +"および旧来の SHA1 (`formerly part of FIPS`_) と MD5 (インターネット :rfc:" +"`1321` で定義) が含まれます。" #: ../../library/hashlib.rst:28 msgid "" @@ -72,14 +77,15 @@ msgstr "" "て、それまでに渡したデータを連結したものの :dfn:`digest` をいつでも要求するこ" "とができます。" -#: ../../library/hashlib.rst:45 msgid "" "To allow multithreading, the Python :term:`GIL` is released while computing " "a hash supplied more than 2047 bytes of data at once in its constructor or :" "meth:`.update` method." msgstr "" +"複数のスレッドを動作させるため、コンストラクタまたは :meth:`.update ` メソッドに一度に 2047 バイトを超えるデータを渡すと、ハッシュの計算中" +"は Python の :term:`GIL` を解放します。" -#: ../../library/hashlib.rst:52 msgid "" "Constructors for hash algorithms that are always present in this module are :" "func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :" @@ -87,8 +93,13 @@ msgid "" "`sha3_512`, :func:`shake_128`, :func:`shake_256`, :func:`blake2b`, and :func:" "`blake2s`. These correspond to :data:`algorithms_guaranteed`." msgstr "" +"このモジュールに常に含まれるハッシュアルゴリズムのコンストラクタは、:func:" +"`md5`、:func:`sha1`、:func:`sha224`、:func:`sha256`、:func:`sha384`、:func:" +"`sha512`、:func:`sha3_224`、:func:`sha3_256`、:func:`sha3_384`、:func:" +"`sha3_512`、:func:`shake_128`、:func:`shake_256`、:func:`blake2b`、:func:" +"`blake2s` です。\n" +"これらは :data:`algorithms_guaranteed` に対応します。" -#: ../../library/hashlib.rst:58 msgid "" "Any of these may nonetheless be missing or blocked in unusual environments, " "such as a rare \"FIPS compliant\" build of Python or when OpenSSL's \"FIPS " @@ -96,30 +107,46 @@ msgid "" "Calling the constructor of an algorithm that is unavailable raises :exc:" "`ValueError`." msgstr "" +"ただし、まれに見られる「FIPS 準拠」の Python ビルドや、OpenSSL の「FIPS モー" +"ド」でデフォルトのプロバイダから一部のアルゴリズムを除外する設定など、通常と" +"異なる環境では、これらのいずれも欠けていたり使用を制限されていたりする場合が" +"あります。\n" +"利用できないアルゴリズムのコンストラクタを呼び出すと :exc:`ValueError` を送出" +"します。" -#: ../../library/hashlib.rst:63 msgid "" "Additional algorithms may also be available if your Python distribution's :" "mod:`!hashlib` was linked against a build of OpenSSL that provides others. " "Others *are not guaranteed available* on all installations and will only be " "accessible by name via :func:`new`. See :data:`algorithms_available`." msgstr "" +"使用している Python ディストリビューションの :mod:`!hashlib` が、ほかのアルゴ" +"リズムを提供する OpenSSL ビルドにリンクされている場合は、それらも利用できるこ" +"とがあります。\n" +"これらは *すべての環境での利用が保証されているわけではなく*、:func:`new` に名" +"前を渡す方法でのみアクセスできます。\n" +":data:`algorithms_available` を参照してください。" -#: ../../library/hashlib.rst:70 msgid "" "Some algorithms have known hash collision weaknesses (including MD5 and " "SHA1). Refer to `Attacks on cryptographic hash algorithms`_ and the `hashlib-" "seealso`_ section at the end of this document." msgstr "" +"一部のアルゴリズム (MD5 と SHA1 を含む) には、ハッシュの衝突に関する既知の弱" +"点があります。\n" +"`Attacks on cryptographic hash algorithms`_ と、このドキュメントの末尾の " +"`hashlib-seealso`_ 節を参照してください。" -#: ../../library/hashlib.rst:74 msgid "" "SHA3 (Keccak) and SHAKE constructors :func:`sha3_224`, :func:`sha3_256`, :" "func:`sha3_384`, :func:`sha3_512`, :func:`shake_128`, :func:`shake_256` were " "added. :func:`blake2b` and :func:`blake2s` were added." msgstr "" +"SHA3 (Keccak) と SHAKE のコンストラクタ :func:`sha3_224`、:func:`sha3_256`、:" +"func:`sha3_384`、:func:`sha3_512`、:func:`shake_128`、:func:`shake_256` が追" +"加されました。\n" +":func:`blake2b` と :func:`blake2s` も追加されました。" -#: ../../library/hashlib.rst:82 msgid "" "All hashlib constructors take a keyword-only argument *usedforsecurity* with " "default value ``True``. A false value allows the use of insecure and blocked " @@ -127,25 +154,37 @@ msgid "" "hashing algorithm is not used in a security context, e.g. as a non-" "cryptographic one-way compression function." msgstr "" +"hashlib のすべてのコンストラクタが、デフォルト値 ``True`` のキーワード専用引" +"数 *usedforsecurity* を受け取るようになりました。\n" +"偽の値を指定すると、制限のある環境で、安全でないアルゴリズムや使用を制限され" +"たハッシュアルゴリズムを使えます。\n" +"``False`` は、例えば暗号用途でない一方向圧縮関数として使う場合など、そのハッ" +"シュアルゴリズムをセキュリティ目的で使わないことを示します。" -#: ../../library/hashlib.rst:89 msgid "Hashlib now uses SHA3 and SHAKE from OpenSSL if it provides it." msgstr "" +"OpenSSL が SHA3 と SHAKE を提供する場合、hashlib はそれらを使うようになりまし" +"た。" -#: ../../library/hashlib.rst:92 msgid "" "For any of the MD5, SHA1, SHA2, or SHA3 algorithms that the linked OpenSSL " "does not provide we fall back to a verified implementation from the `HACL\\* " "project`_." msgstr "" +"MD5、SHA1、SHA2、SHA3 の各アルゴリズムを、リンク先の OpenSSL が提供していない" +"場合は、`HACL\\* project`_ の検証済み実装にフォールバックするようになりまし" +"た。" -#: ../../library/hashlib.rst:97 msgid "" "The undocumented ``string`` keyword parameter in :func:`!_hashlib.new` and " "hash-named constructors such as :func:`!_md5.md5` is deprecated. Prefer " "passing the initial data as a positional argument for maximum backwards " "compatibility." msgstr "" +":func:`!_hashlib.new` と :func:`!_md5.md5` などのハッシュ名を持つコンストラク" +"タで、ドキュメントに記載されていないキーワード引数 ``string`` が非推奨になり" +"ました。\n" +"後方互換性を最大限に保つには、初期データを位置引数として渡してください。" #: ../../library/hashlib.rst:105 msgid "Usage" @@ -156,10 +195,9 @@ msgid "" "To obtain the digest of the byte string ``b\"Nobody inspects the spammish " "repetition\"``::" msgstr "" -"``b\"Nobody inspects the spammish repetition\"``というバイト文字列のダイジェ" +"``b\"Nobody inspects the spammish repetition\"`` というバイト文字列のダイジェ" "ストを取得するには次のようにします::" -#: ../../library/hashlib.rst:110 msgid "" ">>> import hashlib\n" ">>> m = hashlib.sha256()\n" @@ -172,6 +210,16 @@ msgid "" ">>> m.hexdigest()\n" "'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" msgstr "" +">>> import hashlib\n" +">>> m = hashlib.sha256()\n" +">>> m.update(b\"Nobody inspects\")\n" +">>> m.update(b\" the spammish repetition\")\n" +">>> m.digest()\n" +"b'\\x03\\x1e\\xdd}Ae\\x15\\x93\\xc5\\xfe\\\\" +"\\x00o\\xa5u+7\\xfd\\xdf\\xf7\\xbcN\\x84:" +"\\xa6\\xaf\\x0c\\x95\\x0fK\\x94\\x06'\n" +">>> m.hexdigest()\n" +"'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'" #: ../../library/hashlib.rst:119 msgid "More condensed:" @@ -192,23 +240,22 @@ msgstr "" "ます。他にも、前述のハッシュアルゴリズムだけでなく OpenSSL ライブラリーが提供" "するような他のアルゴリズムにアクセスすることができます。" -#: ../../library/hashlib.rst:134 msgid "Using :func:`new` with an algorithm name:" -msgstr "" +msgstr ":func:`new` にアルゴリズム名を渡す例です。" -#: ../../library/hashlib.rst:153 msgid "" "Named constructors such as these are faster than passing an algorithm name " "to :func:`new`." msgstr "" +"このような名前付きコンストラクタは、:func:`new` にアルゴリズム名を渡すより高" +"速です。" #: ../../library/hashlib.rst:157 msgid "Attributes" msgstr "属性" -#: ../../library/hashlib.rst:159 msgid "Hashlib provides the following constant module attributes:" -msgstr "" +msgstr "hashlib は次の定数をモジュール属性として提供します。" #: ../../library/hashlib.rst:163 msgid "" @@ -235,9 +282,8 @@ msgstr "" "`algorithms_guaranteed` は常にサブセットです。この set の中に同じアルゴリズム" "が違う名前で複数回現れることがあります (OpenSSL 由来)。" -#: ../../library/hashlib.rst:181 msgid "Hash Objects" -msgstr "" +msgstr "ハッシュオブジェクト" #: ../../library/hashlib.rst:183 msgid "" @@ -323,13 +369,18 @@ msgstr "" msgid "SHAKE variable length digests" msgstr "SHAKE 可変長ダイジェスト" -#: ../../library/hashlib.rst:243 msgid "" "The :func:`shake_128` and :func:`shake_256` algorithms provide variable " "length digests with length_in_bits//2 up to 128 or 256 bits of security. As " "such, their digest methods require a length. Maximum length is not limited " "by the SHAKE algorithm." msgstr "" +":func:`shake_128` と :func:`shake_256` アルゴリズムは、可変長のダイジェストを" +"提供します。\n" +"安全性の強度は、ビット単位のダイジェスト長の半分 (length_in_bits//2) で、それ" +"ぞれ最大 128 ビットまたは 256 ビットです。\n" +"そのため、これらの ``digest()`` メソッドには長さの指定が必要です。\n" +"SHAKE アルゴリズム自体には長さの上限はありません。" #: ../../library/hashlib.rst:250 msgid "" @@ -358,18 +409,18 @@ msgstr "使用例:" msgid "File hashing" msgstr "ファイルのハッシュ化" -#: ../../library/hashlib.rst:270 msgid "" "The hashlib module provides a helper function for efficient hashing of a " "file or file-like object." msgstr "" +"hashlib モジュールは、ファイルやファイルに似たオブジェクトのハッシュを効率よ" +"く計算するための補助関数を提供します。" -#: ../../library/hashlib.rst:275 msgid "" "Return a digest object that has been updated with contents of file object." msgstr "" +"ファイルオブジェクトの内容で更新されたダイジェストオブジェクトを返します。" -#: ../../library/hashlib.rst:277 msgid "" "*fileobj* must be a file-like object opened for reading in binary mode. It " "accepts file objects from builtin :func:`open`, :class:`~io.BytesIO` " @@ -377,30 +428,45 @@ msgid "" "similar. *fileobj* must be opened in blocking mode, otherwise a :exc:" "`BlockingIOError` may be raised." msgstr "" +"*fileobj* はバイナリモードで読み取り用に開かれた、ファイルに似たオブジェクト" +"でなければなりません。\n" +"組み込みの :func:`open` が返すファイルオブジェクト、:class:`~io.BytesIO` イン" +"スタンス、:meth:`socket.socket.makefile` が返す SocketIO オブジェクトなどを受" +"け付けます。\n" +"*fileobj* はブロッキングモードで開いておく必要があり、そうでなければ :exc:" +"`BlockingIOError` が送出される場合があります。" -#: ../../library/hashlib.rst:283 msgid "" "The function may bypass Python's I/O and use the file descriptor from :meth:" "`~io.IOBase.fileno` directly. *fileobj* must be assumed to be in an unknown " "state after this function returns or raises. It is up to the caller to close " "*fileobj*." msgstr "" +"この関数は Python の I/O を経由せず、:meth:`~io.IOBase.fileno` から得たファイ" +"ル記述子を直接使う場合があります。\n" +"この関数が値を返したり例外を送出したりした後の *fileobj* の状態は、不明なもの" +"として扱ってください。\n" +"*fileobj* を閉じるのは呼び出し側の責任です。" -#: ../../library/hashlib.rst:288 msgid "" "*digest* must either be a hash algorithm name as a *str*, a hash " "constructor, or a callable that returns a hash object." msgstr "" +"*digest* には、*str* で表したハッシュアルゴリズム名、ハッシュのコンストラク" +"タ、ハッシュオブジェクトを返す呼び出し可能オブジェクトのいずれかを指定する必" +"要があります。" #: ../../library/hashlib.rst:291 msgid "Example:" msgstr "例:" -#: ../../library/hashlib.rst:312 msgid "" "Now raises a :exc:`BlockingIOError` if the file is opened in non-blocking " "mode. Previously, spurious null bytes were added to the digest." msgstr "" +"ファイルが非ブロッキングモードで開かれている場合は :exc:`BlockingIOError` を" +"送出するようになりました。\n" +"以前は、余分なヌルバイトがダイジェストの計算に加わっていました。" #: ../../library/hashlib.rst:318 msgid "Key derivation" @@ -442,7 +508,6 @@ msgstr "" "長さ (例えば 1024) に制限すべきです。 *salt* は :func:`os.urandom` のような適" "切なソースからの、およそ 16 バイトかそれ以上のバイト列にするべきです。" -#: ../../library/hashlib.rst:337 msgid "" "The number of *iterations* should be chosen based on the hash algorithm and " "computing power. As of 2022, hundreds of thousands of iterations of SHA-256 " @@ -450,6 +515,12 @@ msgid "" "your application, read *Appendix A.2.2* of NIST-SP-800-132_. The answers on " "the `stackexchange pbkdf2 iterations question`_ explain in detail." msgstr "" +"*iterations* の回数は、ハッシュアルゴリズムと計算能力に基づいて選んでくださ" +"い。\n" +"2022 年時点では、SHA-256 で数十万回の反復が推奨されています。\n" +"アプリケーションに最適な値を選ぶ方法とその根拠については、NIST-SP-800-132_ " +"の *付録 A.2.2* を参照してください。\n" +"`stackexchange pbkdf2 iterations question`_ の回答にも詳しい説明があります。" #: ../../library/hashlib.rst:343 msgid "" @@ -461,15 +532,18 @@ msgstr "" "ハッシュアルゴリズム *hash_name* のダイジェストサイズが使われます。例えば " "SHA-512 では 64 です。" -#: ../../library/hashlib.rst:352 msgid "Function only available when Python is compiled with OpenSSL." msgstr "" +"この関数は、Python が OpenSSL を使ってコンパイルされている場合にのみ利用でき" +"ます。" -#: ../../library/hashlib.rst:356 msgid "" "Function now only available when Python is built with OpenSSL. The slow pure " "Python implementation has been removed." msgstr "" +"この関数は、Python が OpenSSL を使ってビルドされている場合にのみ利用できるよ" +"うになりました。\n" +"低速な純 Python 実装は削除されました。" #: ../../library/hashlib.rst:362 msgid "" @@ -491,46 +565,54 @@ msgstr "" "きです。 *salt* は :func:`os.urandom` のような適切なソースからの、およそ 16 " "バイトかそれ以上のバイト列にするべきです。" -#: ../../library/hashlib.rst:370 msgid "" "*n* is the CPU/Memory cost factor, *r* the block size, *p* parallelization " "factor and *maxmem* limits memory (OpenSSL 1.1.0 defaults to 32 MiB). " "*dklen* is the length of the derived key in bytes." msgstr "" +"*n* は CPU とメモリのコスト係数、*r* はブロックサイズ、*p* は並列化係数で" +"す。\n" +"*maxmem* はメモリ使用量を制限します (OpenSSL 1.1.0 のデフォルトは 32 MiB)。\n" +"*dklen* は導出する鍵のバイト単位の長さです。" #: ../../library/hashlib.rst:380 msgid "BLAKE2" msgstr "BLAKE2" -#: ../../library/hashlib.rst:385 msgid "" "BLAKE2_ is a cryptographic hash function defined in :rfc:`7693` that comes " "in two flavors:" msgstr "" +"BLAKE2_ は :rfc:`7693` で定義された暗号学的ハッシュ関数で、次の 2 種類があり" +"ます。" -#: ../../library/hashlib.rst:388 msgid "" "**BLAKE2b**, optimized for 64-bit platforms and produces digests of any size " "between 1 and 64 bytes," msgstr "" +"**BLAKE2b** は 64 ビットプラットフォーム向けに最適化されており、1〜64 バイト" +"の任意の長さのダイジェストを生成します。" -#: ../../library/hashlib.rst:391 msgid "" "**BLAKE2s**, optimized for 8- to 32-bit platforms and produces digests of " "any size between 1 and 32 bytes." msgstr "" +"**BLAKE2s** は 8〜32 ビットプラットフォーム向けに最適化されており、1〜32 バイ" +"トの任意の長さのダイジェストを生成します。" -#: ../../library/hashlib.rst:394 msgid "" "BLAKE2 supports **keyed mode** (a faster and simpler replacement for HMAC_), " "**salted hashing**, **personalization**, and **tree hashing**." msgstr "" +"BLAKE2 は **鍵付きモード** (HMAC_ より高速で単純な代替手段)、**ソルト付きハッ" +"シュ化**、**パーソナライズ**、**ツリーハッシング** をサポートします。" -#: ../../library/hashlib.rst:397 msgid "" "Hash objects from this module follow the API of standard library's :mod:`!" "hashlib` objects." msgstr "" +"このモジュールのハッシュオブジェクトは、標準ライブラリの :mod:`!hashlib` オブ" +"ジェクトの API に従います。" #: ../../library/hashlib.rst:402 msgid "Creating hash objects" @@ -541,39 +623,46 @@ msgid "New hash objects are created by calling constructor functions:" msgstr "" "新しいハッシュオブジェクトは、コンストラクタ関数を呼び出すことで生成されます:" -#: ../../library/hashlib.rst:418 msgid "" "These functions return the corresponding hash objects for calculating " "BLAKE2b or BLAKE2s. They optionally take these general parameters:" msgstr "" +"これらの関数は、BLAKE2b または BLAKE2s を計算するための、対応するハッシュオブ" +"ジェクトを返します。\n" +"次の一般的な引数を任意に指定できます。" -#: ../../library/hashlib.rst:421 msgid "" "*data*: initial chunk of data to hash, which must be :term:`bytes-like " "object`. It can be passed only as positional argument." msgstr "" +"*data*: 最初にハッシュ計算に使うデータのチャンクで、:term:`bytes-like " +"object` でなければなりません。\n" +"位置引数としてのみ渡せます。" #: ../../library/hashlib.rst:424 msgid "*digest_size*: size of output digest in bytes." msgstr "*digest_size*: 出力するダイジェストのバイト数。" -#: ../../library/hashlib.rst:426 msgid "" "*key*: key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32 bytes for " "BLAKE2s)." msgstr "" +"*key*: 鍵付きハッシュ化のための鍵 (BLAKE2b では最大 64 バイト、BLAKE2s では最" +"大 32 バイト)。" -#: ../../library/hashlib.rst:429 msgid "" "*salt*: salt for randomized hashing (up to 16 bytes for BLAKE2b, up to 8 " "bytes for BLAKE2s)." msgstr "" +"*salt*: ランダム化ハッシュ化のためのソルト (BLAKE2b では最大 16 バイト、" +"BLAKE2s では最大 8 バイト)。" -#: ../../library/hashlib.rst:432 msgid "" "*person*: personalization string (up to 16 bytes for BLAKE2b, up to 8 bytes " "for BLAKE2s)." msgstr "" +"*person*: パーソナライズ用の文字列 (BLAKE2b では最大 16 バイト、BLAKE2s では" +"最大 8 バイト)。" #: ../../library/hashlib.rst:435 msgid "The following table shows limits for general parameters (in bytes):" @@ -623,7 +712,6 @@ msgstr "32" msgid "8" msgstr "8" -#: ../../library/hashlib.rst:446 msgid "" "BLAKE2 specification defines constant lengths for salt and personalization " "parameters, however, for convenience, this implementation accepts byte " @@ -632,6 +720,11 @@ msgid "" "example, ``b'salt'`` and ``b'salt\\x00'`` is the same value. (This is not " "the case for *key*.)" msgstr "" +"BLAKE2 の仕様はソルトとパーソナライズ引数の長さを固定していますが、この実装で" +"は利便性のため、規定の長さまでの任意のサイズのバイト文字列を受け付けます。\n" +"引数の長さが規定より短ければゼロで埋めるため、例えば ``b'salt'`` と " +"``b'salt\\x00'`` は同じ値になります。\n" +"(*key* はこのようには扱いません。)" #: ../../library/hashlib.rst:453 msgid "These sizes are available as module `constants`_ described below." @@ -642,56 +735,63 @@ msgid "" "Constructor functions also accept the following tree hashing parameters:" msgstr "コンストラクタ関数は以下のツリーハッシングパラメタを受け付けます:" -#: ../../library/hashlib.rst:457 msgid "*fanout*: fanout (0 to 255, 0 if unlimited, 1 in sequential mode)." msgstr "" +"*fanout*: ファンアウト (0〜255。\n" +"無制限なら 0、逐次モードでは 1)。\n" -#: ../../library/hashlib.rst:459 msgid "" "*depth*: maximal depth of tree (1 to 255, 255 if unlimited, 1 in sequential " "mode)." msgstr "" -"*depth*: ツリーの深さの最大値(1から255までの値で、無制限であれば255、シーケ" -"ンスモードでは1)。" +"*depth*: ツリーの深さの最大値 (1〜255。\n" +"無制限なら 255、逐次モードでは 1)。\n" -#: ../../library/hashlib.rst:462 msgid "" "*leaf_size*: maximal byte length of leaf (0 to ``2**32-1``, 0 if unlimited " "or in sequential mode)." msgstr "" +"*leaf_size*: 葉の最大バイト長 (0〜``2**32-1``。\n" +"無制限の場合や逐次モードでは 0)。\n" -#: ../../library/hashlib.rst:465 msgid "" "*node_offset*: node offset (0 to ``2**64-1`` for BLAKE2b, 0 to ``2**48-1`` " "for BLAKE2s, 0 for the first, leftmost, leaf, or in sequential mode)." msgstr "" +"*node_offset*: ノードのオフセット (BLAKE2b では 0〜``2**64-1``、BLAKE2s では " +"0〜``2**48-1``。\n" +"最初の、つまり最も左の葉や、逐次モードでは 0)。\n" -#: ../../library/hashlib.rst:468 msgid "" "*node_depth*: node depth (0 to 255, 0 for leaves, or in sequential mode)." msgstr "" +"*node_depth*: ノードの深さ (0〜255。\n" +"葉や逐次モードでは 0)。\n" -#: ../../library/hashlib.rst:470 msgid "" "*inner_size*: inner digest size (0 to 64 for BLAKE2b, 0 to 32 for BLAKE2s, 0 " "in sequential mode)." msgstr "" +"*inner_size*: 内部ダイジェストのサイズ (BLAKE2b では 0〜64、BLAKE2s では 0〜" +"32。\n" +"逐次モードでは 0)。\n" -#: ../../library/hashlib.rst:473 msgid "" "*last_node*: boolean indicating whether the processed node is the last one " "(``False`` for sequential mode)." msgstr "" +"*last_node*: 処理中のノードが最後のノードかどうかを示すブール値 (逐次モードで" +"は ``False``)。" -#: ../../library/hashlib.rst:476 msgid "Explanation of tree mode parameters." -msgstr "" +msgstr "ツリーモードのパラメータの説明。" -#: ../../library/hashlib.rst:480 msgid "" "See section 2.10 in `BLAKE2 specification `_ for comprehensive review of tree hashing." msgstr "" +"ツリーハッシングの詳しい説明については、`BLAKE2 の仕様 `_ の 2.10 節を参照してください。" #: ../../library/hashlib.rst:486 msgid "Constants" @@ -701,10 +801,9 @@ msgstr "定数" msgid "Salt length (maximum length accepted by constructors)." msgstr "ソルト長(コンストラクタが受け付けれる最大長)" -#: ../../library/hashlib.rst:497 msgid "" "Personalization string length (maximum length accepted by constructors)." -msgstr "" +msgstr "パーソナライズ用の文字列の長さ (コンストラクタが受け付ける最大長)。" #: ../../library/hashlib.rst:503 msgid "Maximum key size." @@ -722,7 +821,6 @@ msgstr "使用例" msgid "Simple hashing" msgstr "簡単なハッシュ化" -#: ../../library/hashlib.rst:518 msgid "" "To calculate hash of some data, you should first construct a hash object by " "calling the appropriate constructor function (:func:`blake2b` or :func:" @@ -730,22 +828,27 @@ msgid "" "the object, and, finally, get the digest out of the object by calling :meth:" "`~hash.digest` (or :meth:`~hash.hexdigest` for hex-encoded string)." msgstr "" +"データのハッシュを計算するには、まず適切なコンストラクタ関数 (:func:" +"`blake2b` または :func:`blake2s`) でハッシュオブジェクトを作成します。\n" +"次にオブジェクトの :meth:`~hash.update` を呼び出してデータで更新し、最後に :" +"meth:`~hash.digest` (16 進数の文字列を得る場合は :meth:`~hash.hexdigest`) を" +"呼び出してダイジェストを取得します。" -#: ../../library/hashlib.rst:531 msgid "" "As a shortcut, you can pass the first chunk of data to update directly to " "the constructor as the positional argument:" msgstr "" +"手順を短くするために、最初のデータのチャンクをコンストラクタに位置引数として" +"直接渡すこともできます。" -#: ../../library/hashlib.rst:538 msgid "" "You can call :meth:`hash.update` as many times as you need to iteratively " "update the hash:" msgstr "" +":meth:`hash.update` を必要な回数だけ呼び出して、ハッシュを順次更新できます。" -#: ../../library/hashlib.rst:552 msgid "Using different digest sizes" -msgstr "" +msgstr "異なるダイジェストサイズの使用" #: ../../library/hashlib.rst:554 msgid "" @@ -758,32 +861,37 @@ msgstr "" "BLAKE2bで置き換えるには、BLAKE2bに20バイトのダイジェストを生成するように指示" "できます:" -#: ../../library/hashlib.rst:568 msgid "" "Hash objects with different digest sizes have completely different outputs " "(shorter hashes are *not* prefixes of longer hashes); BLAKE2b and BLAKE2s " "produce different outputs even if the output length is the same:" msgstr "" +"ダイジェストサイズが異なるハッシュオブジェクトは、まったく異なる出力を生成し" +"ます (短いハッシュは長いハッシュの先頭部分では *ありません*)。\n" +"BLAKE2b と BLAKE2s は、出力の長さが同じでも異なる出力を生成します。" -#: ../../library/hashlib.rst:584 msgid "Keyed hashing" -msgstr "" +msgstr "鍵付きハッシュ化" -#: ../../library/hashlib.rst:586 msgid "" "Keyed hashing can be used for authentication as a faster and simpler " "replacement for `Hash-based message authentication code `_ (HMAC). BLAKE2 can be securely used in prefix-MAC " "mode thanks to the indifferentiability property inherited from BLAKE." msgstr "" +"鍵付きハッシュ化は、`ハッシュベースのメッセージ認証コード `_ (HMAC) より高速で単純な代替手段として、認証に使え" +"ます。\n" +"BLAKE から受け継いだ強強強識別不可能性 (indifferentiability) により、BLAKE2 " +"は prefix-MAC モードで安全に使えます。" -#: ../../library/hashlib.rst:592 msgid "" "This example shows how to get a (hex-encoded) 128-bit authentication code " "for message ``b'message data'`` with key ``b'pseudorandom key'``::" msgstr "" +"この例では、鍵 ``b'pseudorandom key'`` を使って、メッセージ ``b'message " +"data'`` の 128 ビット認証コードを 16 進数形式で取得します。 ::" -#: ../../library/hashlib.rst:595 msgid "" ">>> from hashlib import blake2b\n" ">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" @@ -791,14 +899,19 @@ msgid "" ">>> h.hexdigest()\n" "'3d363ff7401e02026f4a4687d4863ced'" msgstr "" +">>> from hashlib import blake2b\n" +">>> h = blake2b(key=b'pseudorandom key', digest_size=16)\n" +">>> h.update(b'message data')\n" +">>> h.hexdigest()\n" +"'3d363ff7401e02026f4a4687d4863ced'" -#: ../../library/hashlib.rst:602 msgid "" "As a practical example, a web application can symmetrically sign cookies " "sent to users and later verify them to make sure they weren't tampered with::" msgstr "" +"実用例として、ウェブアプリケーションがユーザーに送る Cookie に共通鍵で署名" +"し、後で検証して改ざんされていないことを確認できます。 ::" -#: ../../library/hashlib.rst:605 msgid "" ">>> from hashlib import blake2b\n" ">>> from hmac import compare_digest\n" @@ -826,14 +939,39 @@ msgid "" ">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" "False" msgstr "" +">>> from hashlib import blake2b\n" +">>> from hmac import compare_digest\n" +">>>\n" +">>> SECRET_KEY = b'pseudorandomly generated server secret key'\n" +">>> AUTH_SIZE = 16\n" +">>>\n" +">>> def sign(cookie):\n" +"... h = blake2b(digest_size=AUTH_SIZE, key=SECRET_KEY)\n" +"... h.update(cookie)\n" +"... return h.hexdigest().encode('utf-8')\n" +">>>\n" +">>> def verify(cookie, sig):\n" +"... good_sig = sign(cookie)\n" +"... return compare_digest(good_sig, sig)\n" +">>>\n" +">>> cookie = b'user-alice'\n" +">>> sig = sign(cookie)\n" +">>> print(\"{0},{1}\".format(cookie.decode('utf-8'), sig))\n" +"user-alice,b'43b3c982cf697e0c5ab22172d1ca7421'\n" +">>> verify(cookie, sig)\n" +"True\n" +">>> verify(b'user-bob', sig)\n" +"False\n" +">>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')\n" +"False" -#: ../../library/hashlib.rst:631 msgid "" "Even though there's a native keyed hashing mode, BLAKE2 can, of course, be " "used in HMAC construction with :mod:`hmac` module::" msgstr "" +"BLAKE2 には専用の鍵付きハッシュ化モードがありますが、もちろん :mod:`hmac` モ" +"ジュールを使って HMAC を構成することもできます。 ::" -#: ../../library/hashlib.rst:634 msgid "" ">>> import hmac, hashlib\n" ">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" @@ -841,19 +979,24 @@ msgid "" ">>> m.hexdigest()\n" "'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" msgstr "" +">>> import hmac, hashlib\n" +">>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)\n" +">>> m.update(b'message')\n" +">>> m.hexdigest()\n" +"'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'" -#: ../../library/hashlib.rst:642 msgid "Randomized hashing" -msgstr "" +msgstr "ランダム化ハッシュ化" -#: ../../library/hashlib.rst:644 msgid "" "By setting *salt* parameter users can introduce randomization to the hash " "function. Randomized hashing is useful for protecting against collision " "attacks on the hash function used in digital signatures." msgstr "" +"*salt* 引数を設定すると、ハッシュ関数にランダム性を導入できます。\n" +"ランダム化ハッシュ化は、デジタル署名で使うハッシュ関数への衝突攻撃を防ぐのに" +"役立ちます。" -#: ../../library/hashlib.rst:648 msgid "" "Randomized hashing is designed for situations where one party, the message " "preparer, generates all or part of a message to be signed by a second party, " @@ -873,39 +1016,58 @@ msgid "" "hashing may reduce the amount of security provided by a digital signature " "when all portions of the message are prepared by the signer." msgstr "" +"ランダム化ハッシュ化は、メッセージ作成者がメッセージの全体または一部を作成" +"し、別の当事者である署名者が署名する状況を想定して設計されています。\n" +"作成者が暗号学的ハッシュ関数の衝突 (同じハッシュ値を生成する 2 つのメッセー" +"ジ) を見つけられる場合、同じハッシュ値とデジタル署名を生成しながら異なる結果" +"をもたらす、意味の通る複数のメッセージを用意できるかもしれません (例えば、口" +"座への送金額を 10 ドルではなく 100 万ドルにするなど)。\n" +"暗号学的ハッシュ関数は衝突耐性を主要な目標として設計されていますが、暗号学的" +"ハッシュ関数への攻撃が現在集中的に研究されているため、特定の関数の衝突耐性が" +"期待を下回る可能性があります。\n" +"ランダム化ハッシュ化は、ハッシュ関数の衝突を現実的に見つけられる場合でも、デ" +"ジタル署名の生成過程で最終的に同じハッシュ値になるメッセージを作成者が複数作" +"れる可能性を減らし、署名者をさらに保護します。\n" +"ただし、メッセージのすべてを署名者自身が作成する場合には、ランダム化ハッシュ" +"化の使用によりデジタル署名の安全性が下がることがあります。" -#: ../../library/hashlib.rst:667 msgid "" "(`NIST SP-800-106 \"Randomized Hashing for Digital Signatures\" `_)" msgstr "" +"(`NIST SP-800-106「デジタル署名のためのランダム化ハッシュ化」 `_)" -#: ../../library/hashlib.rst:670 msgid "" "In BLAKE2 the salt is processed as a one-time input to the hash function " "during initialization, rather than as an input to each compression function." msgstr "" +"BLAKE2 では、ソルトを圧縮関数の毎回の入力としてではなく、初期化時にハッシュ関" +"数への一度だけの入力として処理します。" -#: ../../library/hashlib.rst:675 msgid "" "*Salted hashing* (or just hashing) with BLAKE2 or any other general-purpose " "cryptographic hash function, such as SHA-256, is not suitable for hashing " "passwords. See `BLAKE2 FAQ `_ for more " "information." msgstr "" +"BLAKE2 や SHA-256 などの汎用の暗号学的ハッシュ関数による *ソルト付きハッシュ" +"化* (あるいは単なるハッシュ化) は、パスワードのハッシュ化には適していませ" +"ん。\n" +"詳しくは `BLAKE2 FAQ `_ を参照してください。" -#: ../../library/hashlib.rst:698 msgid "Personalization" -msgstr "" +msgstr "パーソナライズ" -#: ../../library/hashlib.rst:700 msgid "" "Sometimes it is useful to force hash function to produce different digests " "for the same input for different purposes. Quoting the authors of the Skein " "hash function:" msgstr "" +"同じ入力でも用途ごとに異なるダイジェストを生成するようにハッシュ関数を設定す" +"ると、役立つ場合があります。\n" +"Skein ハッシュ関数の作者は次のように述べています。" -#: ../../library/hashlib.rst:704 msgid "" "We recommend that all application designers seriously consider doing this; " "we have seen many protocols where a hash that is computed in one part of the " @@ -914,18 +1076,25 @@ msgid "" "force the application to make the hash inputs the same. Personalizing each " "hash function used in the protocol summarily stops this type of attack." msgstr "" +"すべてのアプリケーション設計者に、この方法を真剣に検討することを勧めます。\n" +"私たちは、プロトコルのある部分で計算したハッシュを、まったく別の部分で使えて" +"しまうプロトコルを数多く見てきました。\n" +"これは、2 つのハッシュ計算が似たデータや関連したデータに対して行われ、攻撃者" +"がアプリケーションに同じデータを入力させられるためです。\n" +"プロトコルで使う各ハッシュ関数をパーソナライズすれば、この種の攻撃を完全に防" +"げます。" -#: ../../library/hashlib.rst:711 msgid "" "(`The Skein Hash Function Family `_, p. 21)" msgstr "" +"(`The Skein Hash Function Family `_、21 ページ)" #: ../../library/hashlib.rst:715 msgid "BLAKE2 can be personalized by passing bytes to the *person* argument::" msgstr "BLAKE2は *person* 引数にバイト列を渡すことでパーソナライズできます::" -#: ../../library/hashlib.rst:717 msgid "" ">>> from hashlib import blake2b\n" ">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" @@ -939,12 +1108,24 @@ msgid "" ">>> h.hexdigest()\n" "'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" msgstr "" +">>> from hashlib import blake2b\n" +">>> FILES_HASH_PERSON = b'MyApp Files Hash'\n" +">>> BLOCK_HASH_PERSON = b'MyApp Block Hash'\n" +">>> h = blake2b(digest_size=32, person=FILES_HASH_PERSON)\n" +">>> h.update(b'the same content')\n" +">>> h.hexdigest()\n" +"'20d9cd024d4fb086aae819a1432dd2466de12947831b75c5a30cf2676095d3b4'\n" +">>> h = blake2b(digest_size=32, person=BLOCK_HASH_PERSON)\n" +">>> h.update(b'the same content')\n" +">>> h.hexdigest()\n" +"'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'" -#: ../../library/hashlib.rst:729 msgid "" "Personalization together with the keyed mode can also be used to derive " "different keys from a single one." msgstr "" +"パーソナライズと鍵付きモードを組み合わせることで、1 つの鍵から異なる鍵を導出" +"することもできます。" #: ../../library/hashlib.rst:743 msgid "Tree mode" @@ -954,22 +1135,22 @@ msgstr "ツリーモード" msgid "Here's an example of hashing a minimal tree with two leaf nodes::" msgstr "これが二つの葉ノードからなる最小の木をハッシュする例です::" -#: ../../library/hashlib.rst:747 msgid "" " 10\n" " / \\\n" "00 01" msgstr "" +" 10\n" +" / \\\n" +"00 01" -#: ../../library/hashlib.rst:751 msgid "" "This example uses 64-byte internal digests, and returns the 32-byte final " "digest::" msgstr "" -"次の例では、64バイトの内部桁が使われ、32バイトの最終的なダイジェストを返して" -"います::" +"この例では 64 バイトの内部ダイジェストを使い、32 バイトの最終ダイジェストを返" +"します。 ::" -#: ../../library/hashlib.rst:754 msgid "" ">>> from hashlib import blake2b\n" ">>>\n" @@ -997,6 +1178,31 @@ msgid "" ">>> h10.hexdigest()\n" "'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" msgstr "" +">>> from hashlib import blake2b\n" +">>>\n" +">>> FANOUT = 2\n" +">>> DEPTH = 2\n" +">>> LEAF_SIZE = 4096\n" +">>> INNER_SIZE = 64\n" +">>>\n" +">>> buf = bytearray(6000)\n" +">>>\n" +">>> # 左の葉\n" +"... h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=0, node_depth=0, last_node=False)\n" +">>> # 右の葉\n" +"... h01 = blake2b(buf[LEAF_SIZE:], fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=1, node_depth=0, last_node=True)\n" +">>> # 根ノード\n" +"... h10 = blake2b(digest_size=32, fanout=FANOUT, depth=DEPTH,\n" +"... leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,\n" +"... node_offset=0, node_depth=1, last_node=True)\n" +">>> h10.update(h00.digest())\n" +">>> h10.update(h01.digest())\n" +">>> h10.hexdigest()\n" +"'3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'" #: ../../library/hashlib.rst:781 msgid "Credits" @@ -1047,26 +1253,33 @@ msgstr "" "以下の public domain dedicationが、Cのハッシュ関数実装と、拡張コードと、この" "ドキュメントに適用されます:" -#: ../../library/hashlib.rst:799 msgid "" "To the extent possible under law, the author(s) have dedicated all copyright " "and related and neighboring rights to this software to the public domain " "worldwide. This software is distributed without any warranty." msgstr "" +"法律上可能な範囲で、著作者は、このソフトウェアに関するすべての著作権および関" +"連する権利・著作隣接権を、世界中でパブリックドメインに提供しています。\n" +"このソフトウェアは、いかなる保証もなく配布されています。" -#: ../../library/hashlib.rst:803 msgid "" "You should have received a copy of the CC0 Public Domain Dedication along " "with this software. If not, see https://creativecommons.org/publicdomain/" "zero/1.0/." msgstr "" +"このソフトウェアには CC0 Public Domain Dedication のコピーが同梱されているは" +"ずです。\n" +"ない場合は https://creativecommons.org/publicdomain/zero/1.0/ を参照してくだ" +"さい。" -#: ../../library/hashlib.rst:807 msgid "" "The following people have helped with development or contributed their " "changes to the project and the public domain according to the Creative " "Commons Public Domain Dedication 1.0 Universal:" msgstr "" +"以下の人々は開発を支援し、または Creative Commons Public Domain Dedication " +"1.0 Universal に従って、変更内容をプロジェクトおよびパブリックドメインに提供" +"しました。" #: ../../library/hashlib.rst:811 msgid "*Alexandr Sokolovskiy*" @@ -1089,33 +1302,27 @@ msgid "Another way to encode binary hashes for non-binary environments." msgstr "" "バイナリハッシュを非バイナリ環境用にエンコードするもうひとつの方法です。" -#: ../../library/hashlib.rst:838 msgid "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" -msgstr "" +msgstr "https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf" -#: ../../library/hashlib.rst:839 msgid "The FIPS 180-4 publication on Secure Hash Algorithms." -msgstr "" +msgstr "セキュアハッシュアルゴリズムに関する FIPS 180-4 の刊行物。" -#: ../../library/hashlib.rst:841 msgid "https://csrc.nist.gov/pubs/fips/202/final" -msgstr "" +msgstr "https://csrc.nist.gov/pubs/fips/202/final" -#: ../../library/hashlib.rst:842 msgid "The FIPS 202 publication on the SHA-3 Standard." -msgstr "" +msgstr "SHA-3 標準に関する FIPS 202 の刊行物。" -#: ../../library/hashlib.rst:844 msgid "https://www.blake2.net/" -msgstr "" +msgstr "https://www.blake2.net/" #: ../../library/hashlib.rst:845 msgid "Official BLAKE2 website." msgstr "BLAKE2 の公式ウェブサイト" -#: ../../library/hashlib.rst:847 msgid "https://en.wikipedia.org/wiki/Cryptographic_hash_function" -msgstr "" +msgstr "https://en.wikipedia.org/wiki/Cryptographic_hash_function" #: ../../library/hashlib.rst:848 msgid "" @@ -1129,9 +1336,8 @@ msgstr "" msgid "https://www.ietf.org/rfc/rfc8018.txt" msgstr "https://www.ietf.org/rfc/rfc8018.txt" -#: ../../library/hashlib.rst:852 msgid "PKCS #5: Password-Based Cryptography Specification Version 2.1" -msgstr "" +msgstr "PKCS #5: パスワードに基づく暗号仕様 バージョン 2.1" #: ../../library/hashlib.rst:854 msgid "" @@ -1139,28 +1345,25 @@ msgid "" msgstr "" "https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf" -#: ../../library/hashlib.rst:855 msgid "NIST Recommendation for Password-Based Key Derivation." -msgstr "" +msgstr "パスワードに基づく鍵導出についての NIST の推奨事項。" -#: ../../library/hashlib.rst:9 msgid "message digest, MD5" -msgstr "" +msgstr "メッセージダイジェスト、MD5" -#: ../../library/hashlib.rst:9 msgid "" "secure hash algorithm, SHA1, SHA2, SHA224, SHA256, SHA384, SHA512, SHA3, " "Shake, Blake2" msgstr "" +"セキュアハッシュアルゴリズム、SHA1、SHA2、SHA224、SHA256、SHA384、SHA512、" +"SHA3、Shake、Blake2" #: ../../library/hashlib.rst:50 msgid "OpenSSL" msgstr "OpenSSL" -#: ../../library/hashlib.rst:50 msgid "(use in module hashlib)" -msgstr "" +msgstr "(hashlib モジュールでの使用)" -#: ../../library/hashlib.rst:382 msgid "blake2b, blake2s" -msgstr "" +msgstr "blake2b, blake2s" diff --git a/library/heapq.po b/library/heapq.po index 8eda71aad..aa41ee046 100644 --- a/library/heapq.po +++ b/library/heapq.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2026\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/heapq.rst:2 @@ -38,14 +38,14 @@ msgstr "" "このモジュールではヒープキューアルゴリズムの一実装を提供しています。優先度" "キューアルゴリズムとしても知られています。" -#: ../../library/heapq.rst:14 msgid "" "Min-heaps are binary trees for which every parent node has a value less than " "or equal to any of its children. We refer to this condition as the heap " "invariant." msgstr "" +"最小ヒープは、各親ノードの値がそのどの子ノードの値以下でもある二分木です。\n" +"この条件をヒープ不変式と呼びます。" -#: ../../library/heapq.rst:18 msgid "" "For min-heaps, this implementation uses lists for which ``heap[k] <= " "heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k* for which the " @@ -53,6 +53,11 @@ msgid "" "property of a min-heap is that its smallest element is always the root, " "``heap[0]``." msgstr "" +"この実装では最小ヒープをリストで表し、比較する要素が存在するすべての *k* につ" +"いて ``heap[k] <= heap[2*k+1]`` および ``heap[k] <= heap[2*k+2]`` が成り立ち" +"ます。\n" +"要素は 0 から数えます。\n" +"最小ヒープの興味深い性質は、最小の要素が常に根の ``heap[0]`` にあることです。" #: ../../library/heapq.rst:24 msgid "" @@ -64,7 +69,6 @@ msgid "" "max-heap invariant." msgstr "" -#: ../../library/heapq.rst:31 msgid "" "The :mod:`!heapq` API differs from textbook heap algorithms in two aspects: " "(a) We use zero-based indexing. This makes the relationship between the " @@ -74,63 +78,80 @@ msgid "" "implementation favors min-heaps as they better correspond to Python :class:" "`lists `." msgstr "" +":mod:`!heapq` の API は、教科書に載っているヒープアルゴリズムと 2 つの点で異" +"なります。\n" +"(a) インデックスを 0 から数えます。\n" +"これにより、あるノードのインデックスとその子のインデックスの関係がやや分かり" +"にくくなりますが、Python のインデックスは 0 から始まるため、この方が適してい" +"ます。\n" +"(b) 教科書では、その場でのソートに適した最大ヒープを中心に扱うことがよくあり" +"ます。\n" +"この実装では Python の :class:`リスト ` によりよく対応する最小ヒープを" +"中心に扱います。" -#: ../../library/heapq.rst:38 msgid "" "These two aspects make it possible to view the heap as a regular Python list " "without surprises: ``heap[0]`` is the smallest item, and ``heap.sort()`` " "maintains the heap invariant!" msgstr "" +"この 2 つの特徴により、ヒープを通常の Python リストとして自然に扱えます。\n" +"``heap[0]`` が最小の要素で、``heap.sort()`` を実行してもヒープ不変式が保たれ" +"ます!" -#: ../../library/heapq.rst:42 msgid "" "Like :meth:`list.sort`, this implementation uses only the ``<`` operator for " "comparisons, for both min-heaps and max-heaps." msgstr "" +":meth:`list.sort` と同様、この実装では最小ヒープと最大ヒープのどちらでも、比" +"較に ``<`` 演算子だけを使います。" -#: ../../library/heapq.rst:45 msgid "" "In the API below, and in this documentation, the unqualified term *heap* " "generally refers to a min-heap. The API for max-heaps is named using a " "``_max`` suffix." msgstr "" +"以下の API とこのドキュメントでは、単に *ヒープ* と呼ぶ場合は一般に最小ヒープ" +"を指します。\n" +"最大ヒープの API の名前には ``_max`` 接尾辞が付いています。" -#: ../../library/heapq.rst:49 msgid "" "To create a heap, use a list initialized as ``[]``, or transform an existing " "list into a min-heap or max-heap using the :func:`heapify` or :func:" "`heapify_max` functions, respectively." msgstr "" +"ヒープを作るには、``[]`` で初期化したリストを使うか、既存のリストを :func:" +"`heapify` または :func:`heapify_max` 関数でそれぞれ最小ヒープまたは最大ヒープ" +"に変換します。" -#: ../../library/heapq.rst:53 msgid "The following functions are provided for min-heaps:" -msgstr "" +msgstr "最小ヒープには次の関数が用意されています。" -#: ../../library/heapq.rst:58 msgid "Transform list *x* into a min-heap, in-place, in linear time." msgstr "" +"リスト *x* をその場で最小ヒープに変換します。\n" +"処理時間は要素数に比例します。" -#: ../../library/heapq.rst:63 msgid "" "Push the value *item* onto the *heap*, maintaining the min-heap invariant." -msgstr "" +msgstr "最小ヒープの不変式を保ちながら、値 *item* を *heap* に追加します。" -#: ../../library/heapq.rst:68 msgid "" "Pop and return the smallest item from the *heap*, maintaining the min-heap " "invariant. If the heap is empty, :exc:`IndexError` is raised. To access " "the smallest item without popping it, use ``heap[0]``." msgstr "" +"最小ヒープの不変式を保ちながら、*heap* の最小の要素を取り出して返します。\n" +"ヒープが空の場合は :exc:`IndexError` を送出します。\n" +"最小の要素を削除せずに参照するには ``heap[0]`` を使ってください。" -#: ../../library/heapq.rst:75 msgid "" "Push *item* on the heap, then pop and return the smallest item from the " "*heap*. The combined action runs more efficiently than :func:`heappush` " "followed by a separate call to :func:`heappop`." msgstr "" -"*item* を *heap* に push した後、pop を行って *heap* から最初の要素を返しま" -"す。この一続きの動作を :func:`heappush` に引き続いて :func:`heappop` を別々に" -"呼び出すよりも効率的に実行します。" +"*item* を *heap* に追加し、その後で最小の要素を取り出して返します。\n" +"この操作は、:func:`heappush` に続けて :func:`heappop` を個別に呼び出すより効" +"率的です。" #: ../../library/heapq.rst:82 msgid "" @@ -141,16 +162,16 @@ msgstr "" "*heap* から最小の要素を pop して返し、新たに *item* を push します。ヒープの" "サイズは変更されません。ヒープが空の場合、 :exc:`IndexError` が送出されます。" -#: ../../library/heapq.rst:85 msgid "" "This one step operation is more efficient than a :func:`heappop` followed " "by :func:`heappush` and can be more appropriate when using a fixed-size " "heap. The pop/push combination always returns an element from the heap and " "replaces it with *item*." msgstr "" -"この一息の演算は :func:`heappop` に次いで :func:`heappush` を送出するよりも効" -"率的で、固定サイズのヒープを用いている場合にはより適しています。 pop/push の" -"組み合わせは必ずヒープから要素を一つ返し、それを *item* と置き換えます。" +"この 1 回の操作は、:func:`heappop` に続けて :func:`heappush` を呼び出すより効" +"率的で、固定サイズのヒープを使う場合により適していることがあります。\n" +"pop/push の組み合わせは常にヒープから要素を返し、その要素を *item* で置き換え" +"ます。" #: ../../library/heapq.rst:90 msgid "" @@ -163,46 +184,57 @@ msgstr "" "なら、代わりに :func:`heappushpop` を使うことを考えてください。この push/pop " "の組み合わせは二つの値の小さい方を返し、大きい方の値をヒープに残します。" -#: ../../library/heapq.rst:96 msgid "For max-heaps, the following functions are provided:" -msgstr "" +msgstr "最大ヒープには次の関数が用意されています。" -#: ../../library/heapq.rst:101 msgid "Transform list *x* into a max-heap, in-place, in linear time." msgstr "" +"リスト *x* をその場で最大ヒープに変換します。\n" +"処理時間は要素数に比例します。" -#: ../../library/heapq.rst:108 msgid "" "Push the value *item* onto the max-heap *heap*, maintaining the max-heap " "invariant." msgstr "" +"最大ヒープの不変式を保ちながら、値 *item* を最大ヒープ *heap* に追加します。" -#: ../../library/heapq.rst:116 msgid "" "Pop and return the largest item from the max-heap *heap*, maintaining the " "max-heap invariant. If the max-heap is empty, :exc:`IndexError` is raised. " "To access the largest item without popping it, use ``maxheap[0]``." msgstr "" +"最大ヒープの不変式を保ちながら、最大ヒープ *heap* の最大の要素を取り出して返" +"します。\n" +"最大ヒープが空の場合は :exc:`IndexError` を送出します。\n" +"最大の要素を削除せずに参照するには ``maxheap[0]`` を使ってください。" -#: ../../library/heapq.rst:125 msgid "" "Push *item* on the max-heap *heap*, then pop and return the largest item " "from *heap*. The combined action runs more efficiently than :func:" "`heappush_max` followed by a separate call to :func:`heappop_max`." msgstr "" +"*item* を最大ヒープ *heap* に追加し、その後で *heap* の最大の要素を取り出して" +"返します。\n" +"この操作は、:func:`heappush_max` に続けて :func:`heappop_max` を個別に呼び出" +"すより効率的です。" -#: ../../library/heapq.rst:135 msgid "" "Pop and return the largest item from the max-heap *heap* and also push the " "new *item*. The max-heap size doesn't change. If the max-heap is empty, :exc:" "`IndexError` is raised." msgstr "" +"最大ヒープ *heap* の最大の要素を取り出して返すとともに、新たに *item* を追加" +"します。\n" +"最大ヒープのサイズは変わりません。\n" +"最大ヒープが空の場合は :exc:`IndexError` を送出します。" -#: ../../library/heapq.rst:140 msgid "" "The value returned may be smaller than the *item* added. Refer to the " "analogous function :func:`heapreplace` for detailed usage notes." msgstr "" +"返される値は、追加した *item* より小さい場合があります。\n" +"詳しい使い方の注意点については、対応する関数 :func:`heapreplace` を参照してく" +"ださい。" #: ../../library/heapq.rst:146 msgid "The module also offers three general purpose functions based on heaps." @@ -245,17 +277,16 @@ msgstr "" "力の各要素から比較のキーを取り出すのに使われます。デフォルト値は ``None`` で" "す (要素を直接比較します)。" -#: ../../library/heapq.rst:165 msgid "" "*reverse* is a boolean value. If set to ``True``, then the input elements " "are merged as if each comparison were reversed. To achieve behavior similar " "to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must " "be sorted from largest to smallest." msgstr "" -"*reverse* は真偽値です。 ``True`` を設定した場合、挿入要素は逆向きに比較され" -"たかのように結合されます。 ``sorted(itertools.chain(*iterables), " -"reverse=True)`` でこれに似た挙動を実現するには、全てのイテラブルは降順で並ん" -"でいなければなりません。" +"*reverse* は真偽値です。\n" +"``True`` の場合は比較の向きを逆にして入力要素をマージします。\n" +"``sorted(itertools.chain(*iterables), reverse=True)`` と同様の動作にするに" +"は、すべての入力イテラブルをあらかじめ降順にソートしておく必要があります。" #: ../../library/heapq.rst:170 msgid "Added the optional *key* and *reverse* parameters." @@ -314,7 +345,6 @@ msgstr "" "ソート `_ を実装できます::" -#: ../../library/heapq.rst:205 msgid "" ">>> def heapsort(iterable):\n" "... h = []\n" @@ -325,6 +355,14 @@ msgid "" ">>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" +">>> def heapsort(iterable):\n" +"... h = []\n" +"... for value in iterable:\n" +"... heappush(h, value)\n" +"... return [heappop(h) for i in range(len(h))]\n" +"...\n" +">>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])\n" +"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" #: ../../library/heapq.rst:214 msgid "" @@ -342,7 +380,6 @@ msgstr "" "ヒープの要素はタプルに出来ます。これは、追跡される主レコードとは別に (タスク" "の優先度のような) 比較値を指定するときに便利です::" -#: ../../library/heapq.rst:220 msgid "" ">>> h = []\n" ">>> heappush(h, (5, 'write code'))\n" @@ -352,12 +389,17 @@ msgid "" ">>> heappop(h)\n" "(1, 'write spec')" msgstr "" +">>> h = []\n" +">>> heappush(h, (5, 'write code'))\n" +">>> heappush(h, (7, 'release product'))\n" +">>> heappush(h, (1, 'write spec'))\n" +">>> heappush(h, (3, 'create tests'))\n" +">>> heappop(h)\n" +"(1, 'write spec')" -#: ../../library/heapq.rst:230 msgid "Other Applications" -msgstr "" +msgstr "その他の用途" -#: ../../library/heapq.rst:232 msgid "" "`Medians `_ are a measure of central " "tendency for a set of numbers. In distributions skewed by outliers, the " @@ -365,8 +407,13 @@ msgid "" "running median is an `online algorithm `_ that updates continuously as new data arrives." msgstr "" +"`中央値 `_ は、数値の集まりの中心傾向を" +"表す指標です。\n" +"外れ値によって歪んだ分布では、中央値は平均値 (算術平均) より安定した推定値に" +"なります。\n" +"逐次中央値は、新しいデータが届くたびに中央値を更新する `オンラインアルゴリズ" +"ム `_ です。" -#: ../../library/heapq.rst:239 msgid "" "A running median can be efficiently implemented by balancing two heaps, a " "max-heap for values at or below the midpoint and a min-heap for values above " @@ -374,8 +421,13 @@ msgid "" "average of the tops of the two heaps; otherwise, the median is at the top of " "the larger heap::" msgstr "" +"逐次中央値は、中央値以下の値を保持する最大ヒープと、中央値より大きな値を保持" +"する最小ヒープという 2 つのヒープのサイズを釣り合わせることで効率的に実装でき" +"ます。\n" +"2 つのヒープのサイズが同じなら、新しい中央値は両ヒープの先頭の値の平均になり" +"ます。\n" +"そうでなければ、大きい方のヒープの先頭の値が中央値になります。 ::" -#: ../../library/heapq.rst:245 msgid "" "def running_median(iterable):\n" " \"Yields the cumulative median of values seen so far.\"\n" @@ -391,16 +443,30 @@ msgid "" " heappush(hi, heappushpop_max(lo, x))\n" " yield (lo[0] + hi[0]) / 2" msgstr "" +"def running_median(iterable):\n" +" \"それまでに得られた値全体の中央値を yield します。\"\n" +"\n" +" lo = [] # 最大ヒープ\n" +" hi = [] # 最小ヒープ (lo と同じサイズか、1 つ小さいサイズ)\n" +"\n" +" for x in iterable:\n" +" if len(lo) == len(hi):\n" +" heappush_max(lo, heappushpop(hi, x))\n" +" yield lo[0]\n" +" else:\n" +" heappush(hi, heappushpop_max(lo, x))\n" +" yield (lo[0] + hi[0]) / 2" #: ../../library/heapq.rst:259 msgid "For example::" msgstr "例えば::" -#: ../../library/heapq.rst:261 msgid "" ">>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))\n" "[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]" msgstr "" +">>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))\n" +"[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]" #: ../../library/heapq.rst:266 msgid "Priority Queue Implementation Notes" @@ -439,13 +505,12 @@ msgstr "" "あるタスクの優先度が変化したら、どうやってそれをヒープの新しい位置に移動させ" "るのでしょうか?" -#: ../../library/heapq.rst:280 msgid "" "Or if a pending task needs to be deleted, how do you find it and remove it " "from the queue?" msgstr "" -"未解決のタスクが削除される必要があるとき、どのようにそれをキューから探して削" -"除するのでしょうか?" +"処理待ちのタスクを削除する必要がある場合、キュー内でどのように見つけて削除す" +"ればよいでしょうか?" #: ../../library/heapq.rst:283 msgid "" @@ -470,7 +535,6 @@ msgstr "" "比較できないタスク問題のもう一つの解決法は、タスクアイテムを無視して優先順序" "フィールドだけで比較するラッパークラスです::" -#: ../../library/heapq.rst:292 msgid "" "from dataclasses import dataclass, field\n" "from typing import Any\n" @@ -480,16 +544,22 @@ msgid "" " priority: int\n" " item: Any=field(compare=False)" msgstr "" +"from dataclasses import dataclass, field\n" +"from typing import Any\n" +"\n" +"@dataclass(order=True)\n" +"class PrioritizedItem:\n" +" priority: int\n" +" item: Any=field(compare=False)" -#: ../../library/heapq.rst:300 msgid "" "The remaining challenges revolve around finding a pending task and making " "changes to its priority or removing it entirely. Finding a task can be done " "with a dictionary pointing to an entry in the queue." msgstr "" -"残りの困難は主に、未解決のタスクを探して、その優先度を変更したり、完全に削除" -"することです。タスクを探すことは、キュー内の項目を指し示す辞書によってなされ" -"ます。" +"残る課題は、処理待ちのタスクを見つけて優先度を変更したり、完全に削除したりす" +"ることです。\n" +"キュー内の項目を参照する辞書を使えば、タスクを見つけられます。" #: ../../library/heapq.rst:304 msgid "" @@ -501,7 +571,6 @@ msgstr "" "るので、もっと難しいです。ですから、可能な解決策は、その項目が無効であるもの" "としてマークし、必要なら変更された優先度の項目を加えることです::" -#: ../../library/heapq.rst:308 msgid "" "pq = [] # list of entries arranged in a heap\n" "entry_finder = {} # mapping of tasks to entries\n" @@ -531,6 +600,37 @@ msgid "" " return task\n" " raise KeyError('pop from an empty priority queue')" msgstr "" +"pq = [] # 項目をヒープ順に並べたリスト\n" +"entry_finder = {} # タスクから項目へのマッピング\n" +"REMOVED = '' # 削除したタスクのプレースホルダー\n" +"counter = itertools.count() # 重複しない連番\n" +"\n" +"def add_task(task, priority=0):\n" +" '新しいタスクを追加するか、既存のタスクの優先度を更新します'\n" +" if task in entry_finder:\n" +" remove_task(task)\n" +" count = next(counter)\n" +" entry = [priority, count, task]\n" +" entry_finder[task] = entry\n" +" heappush(pq, entry)\n" +"\n" +"def remove_task(task):\n" +" \"\"\"既存のタスクを REMOVED とマークします。\n" +" 見つからない場合は KeyError を送出します。\n" +" \"\"\"\n" +" entry = entry_finder.pop(task)\n" +" entry[-1] = REMOVED\n" +"\n" +"def pop_task():\n" +" \"\"\"優先度の値が最小のタスクを削除して返します。\n" +" 空の場合は KeyError を送出します。\n" +" \"\"\"\n" +" while pq:\n" +" priority, count, task = heappop(pq)\n" +" if task is not REMOVED:\n" +" del entry_finder[task]\n" +" return task\n" +" raise KeyError('pop from an empty priority queue')" #: ../../library/heapq.rst:338 msgid "Theory" @@ -548,17 +648,17 @@ msgstr "" "い要素を無限大と考えます。ヒープの興味深い属性は ``a[0]`` が常に最小の要素に" "なることです。" -#: ../../library/heapq.rst:345 msgid "" "The strange invariant above is meant to be an efficient memory " "representation for a tournament. The numbers below are *k*, not ``a[k]``:" msgstr "" +"上の一風変わった不変式は、勝ち抜き戦をメモリ上で効率的に表すためのもので" +"す。\n" +"下の数値は ``a[k]`` ではなく *k* です。" -#: ../../library/heapq.rst:348 msgid "Example (min-heap) binary tree." -msgstr "" +msgstr "二分木 (最小ヒープ) の例。" -#: ../../library/heapq.rst:353 msgid "" "In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a " "usual binary tournament we see in sports, each cell is the winner over the " @@ -570,14 +670,16 @@ msgid "" "two cells it tops contain three different items, but the top cell \"wins\" " "over the two topped cells." msgstr "" -"上の木構造では、各セル *k* は ``2*k+1`` および ``2*k+2`` を最大値としていま" -"す。スポーツに見られるような通常の 2 つ組勝ち抜き戦では、各セルはその下にある" -"二つのセルに対する勝者となっていて、個々のセルの勝者を追跡していくことによ" -"り、そのセルに対する全ての相手を見ることができます。しかしながら、このような" -"勝ち抜き戦を使う計算機アプリケーションの多くでは、勝歴を追跡する必要はりませ" -"ん。メモリ効率をより高めるために、勝者が上位に進級した際、下のレベルから持っ" -"てきて置き換えることにすると、あるセルとその下位にある二つのセルは異なる三つ" -"の要素を含み、かつ上位のセルは二つの下位のセルに対して \"勝者と\" なります。" +"上の木構造では、各セル *k* の直下に ``2*k+1`` と ``2*k+2`` があります。\n" +"スポーツで見る通常の勝ち抜き戦では、各セルはその直下の 2 つのセルに対する勝者" +"を表します。\n" +"勝者を木の下方へたどると、それまでに対戦した相手をすべて確認できます。\n" +"しかし、コンピューターでこのような勝ち抜き戦を利用する場合、勝者の履歴をたど" +"る必要がないことも多くあります。\n" +"メモリを節約するため、勝者を上位へ進めたら、空いた場所を下位の別の要素で置き" +"換えます。\n" +"この場合の規則は、あるセルとその直下の 2 つのセルが異なる 3 つの要素を持ち、" +"上のセルが下の 2 つのセルに「勝つ」というものになります。" #: ../../library/heapq.rst:362 msgid "" @@ -631,7 +733,6 @@ msgstr "" "どい速度になるとしても、全体的にはより効率の高い他のデータ構造表現も存在しま" "す。" -#: ../../library/heapq.rst:384 msgid "" "Heaps are also very useful in big disk sorts. You most probably all know " "that a big sort implies producing \"runs\" (which are pre-sorted sequences, " @@ -644,17 +745,18 @@ msgid "" "which are twice the size of the memory for random input, and much better for " "input fuzzily ordered." msgstr "" -"ヒープはまた、巨大なディスクのソートでも非常に有用です。おそらくご存知のよう" -"に、巨大なソートを行うと、複数の \"ラン (run)\" (予めソートされた配列で、その" -"サイズは通常 CPU メモリの量に関係しています) が生成され、続いて統合処理 " -"(merging) がこれらのランを判定します。この統合処理はしばしば非常に巧妙に組織" -"されています [#]_。重要なのは、最初のソートが可能な限り長いランを生成すること" -"です。勝ち抜き戦はこれを達成するための良い方法です。もし利用可能な全てのメモ" -"リを使って勝ち抜き戦を行い、要素を置換および濾過処理して現在のランに収めれ" -"ば、ランダムな入力に対してメモリの二倍のサイズのランを生成することになり、大" -"体順序づけがなされている入力に対してはもっと高い効率になります。" +"ヒープはディスク上の大量のデータのソートにも非常に役立ちます。\n" +"ご存じのように、大規模なソートではまず「ラン」(ソート済みのシーケンスで、その" +"大きさは通常、主記憶の容量に関係します) を生成し、続いてこれらのランをマージ" +"します。\n" +"このマージ処理は非常に巧妙に組み立てられることがよくあります [#]_。\n" +"最初のソートで、できるだけ長いランを生成することが重要です。\n" +"勝ち抜き戦はそのための良い方法です。\n" +"利用可能なメモリをすべて使って勝ち抜き戦を保持し、現在のランに収まる要素を置" +"き換えて木の下方へ移動させると、ランダムな入力に対してはメモリ容量の 2 倍の長" +"さのランを生成できます。\n" +"おおむね順序の揃った入力なら、さらに長いランを生成できます。" -#: ../../library/heapq.rst:394 msgid "" "Moreover, if you output the 0'th item on disk and get an input which may not " "fit in the current tournament (because the value \"wins\" over the last " @@ -664,12 +766,14 @@ msgid "" "the first heap is melting. When the first heap completely vanishes, you " "switch heaps and start a new run. Clever and quite effective!" msgstr "" -"さらに、ディスク上の 0 番目の要素を出力して、現在の勝ち抜き戦に (最後に出力し" -"た値に \"勝って\" しまうために) 収められない入力を得たなら、ヒープには収まら" -"ないため、ヒープのサイズは減少します。解放されたメモリは二つ目のヒープを段階" -"的に構築するために巧妙に再利用することができ、この二つ目のヒープは最初のヒー" -"プが崩壊していくのと同じ速度で成長します。最初のヒープが完全に消滅したら、" -"ヒープを切り替えて新たなランを開始します。なんと巧妙で効率的なのでしょう!" +"さらに、0 番目の要素をディスクに出力して、現在の勝ち抜き戦に (最後に出力した" +"値に \"勝って\" しまうために) 収められない入力を得たなら、ヒープには収まらな" +"いため、ヒープのサイズは減少します。\n" +"解放されたメモリは二つ目のヒープを段階的に構築するために巧妙に再利用すること" +"ができ、この二つ目のヒープは最初のヒープが崩壊していくのと同じ速度で成長しま" +"す。\n" +"最初のヒープが完全に消滅したら、ヒープを切り替えて新たなランを開始します。\n" +"なんと巧妙で効率的なのでしょう!" #: ../../library/heapq.rst:402 msgid "" diff --git a/library/hmac.po b/library/hmac.po index 735941d0b..18d52b0bc 100644 --- a/library/hmac.po +++ b/library/hmac.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/hmac.rst:2 @@ -30,15 +30,19 @@ msgstr ":mod:`!hmac` --- メッセージ認証のための鍵付きハッシュ msgid "**Source code:** :source:`Lib/hmac.py`" msgstr "**ソースコード:** :source:`Lib/hmac.py`" -#: ../../library/hmac.rst:11 msgid "" "This module implements the HMAC algorithm as described by :rfc:`2104`. The " "interface allows to use any hash function with a *fixed* digest size. In " "particular, extendable output functions such as SHAKE-128 or SHAKE-256 " "cannot be used with HMAC." msgstr "" +"このモジュールは :rfc:`2104` で記述された HMAC アルゴリズムを実装していま" +"す。\n" +"このインターフェースでは、ダイジェストのサイズが *固定* された任意のハッシュ" +"関数を使えます。\n" +"特に、SHAKE-128 や SHAKE-256 などの出力長を拡張できる関数は HMAC では使えませ" +"ん。" -#: ../../library/hmac.rst:19 msgid "" "Return a new hmac object. *key* is a bytes or bytearray object giving the " "secret key. If *msg* is present, the method call ``update(msg)`` is made. " @@ -46,6 +50,13 @@ msgid "" "object to use. It may be any name suitable to :func:`hashlib.new`. Despite " "its argument position, it is required." msgstr "" +"新しい hmac オブジェクトを返します。\n" +"*key* は秘密鍵を指定する bytes または bytearray オブジェクトです。\n" +"*msg* が指定されていれば、メソッド ``update(msg)`` を呼び出します。\n" +"*digestmod* は HMAC オブジェクトで使うダイジェストの名前、コンストラクタ、ま" +"たはモジュールです。\n" +"名前には :func:`hashlib.new` に指定できるものを使えます。\n" +"引数の位置にかかわらず、指定は必須です。" #: ../../library/hmac.rst:25 msgid "" @@ -57,13 +68,14 @@ msgstr "" "数 *msg* に :mod:`hashlib` がサポートする全てのタイプを渡せるようになりまし" "た。引数 *digestmod* にハッシュアルゴリズム名を渡せるようになりました。" -#: ../../library/hmac.rst:30 msgid "" "The *digestmod* argument is now required. Pass it as a keyword argument to " "avoid awkwardness when you do not have an initial *msg*." msgstr "" +"*digestmod* 引数の指定が必須になりました。\n" +"初期値の *msg* がない場合は、呼び出しが煩雑になるのを避けるためにキーワード引" +"数として渡してください。" -#: ../../library/hmac.rst:37 msgid "" "Return digest of *msg* for given secret *key* and *digest*. The function is " "equivalent to ``HMAC(key, msg, digest).digest()``, but uses an optimized C " @@ -71,20 +83,21 @@ msgid "" "The parameters *key*, *msg*, and *digest* have the same meaning as in :func:" "`~hmac.new`." msgstr "" -"与えられたsecret *key* と *digest* の *msg* のダイジェストを返します。この関" -"数は ``HMAC(key, msg, digest).digest()`` に似ていますが、最適化されたCやイン" -"ラインの実装を使用しており、メモリに収まるメッセージに対しては高速です。パラ" -"メータ *key* 、 *msg* 、および *digest* は、 :func:`~hmac.new` と同じ意味を持" -"ちます。" +"指定された秘密鍵 *key* と *digest* を使って *msg* のダイジェストを返しま" +"す。\n" +"この関数は ``HMAC(key, msg, digest).digest()`` と同等ですが、最適化された C " +"の実装またはインライン実装を使うため、メモリに収まるメッセージではより高速で" +"す。\n" +"引数 *key*、*msg*、*digest* の意味は :func:`~hmac.new` と同じです。" -#: ../../library/hmac.rst:43 msgid "" "CPython implementation detail, the optimized C implementation is only used " "when *digest* is a string and name of a digest algorithm, which is supported " "by OpenSSL." msgstr "" -"CPython実装の詳細、最適化されたC実装は、OpenSSLがサポートするダイジェストアル" -"ゴリズムの文字列と名前が *digest* の場合にのみ使用されます。" +"CPython の実装上の詳細として、最適化された C 実装が使われるのは、*digest* が " +"OpenSSL でサポートされているダイジェストアルゴリズムの名前を表す文字列の場合" +"だけです。" #: ../../library/hmac.rst:52 msgid "An HMAC object has the following methods:" @@ -105,24 +118,27 @@ msgid "Parameter *msg* can be of any type supported by :mod:`hashlib`." msgstr "" "引数 *msg* は :mod:`hashlib` がサポートしているあらゆる型のいずれかです。" -#: ../../library/hmac.rst:66 msgid "" "Return the digest of the bytes passed to the :meth:`update` method so far. " "This bytes object will be the same length as the *digest_size* of the digest " "given to the constructor. It may contain non-ASCII bytes, including NUL " "bytes." msgstr "" -"これまで :meth:`update` メソッドに渡されたバイト列のダイジェスト値を返しま" -"す。これはコンストラクタに与えられた *digest_size* と同じ長さのバイト列で、 " -"NUL バイトを含む非 ASCII 文字が含まれることがあります。" +"これまで :meth:`update` メソッドに渡されたバイト列のダイジェストを返しま" +"す。\n" +"返される bytes オブジェクトの長さは、コンストラクタに指定したダイジェストの " +"*digest_size* と同じです。\n" +"NUL バイトを含め、非 ASCII のバイトが含まれることがあります。" -#: ../../library/hmac.rst:73 msgid "" "When comparing the output of :meth:`digest` to an externally supplied digest " "during a verification routine, it is recommended to use the :func:" "`compare_digest` function instead of the ``==`` operator to reduce the " "vulnerability to timing attacks." msgstr "" +"検証処理で :meth:`digest` の出力を外部から与えられたダイジェストと比較すると" +"きは、タイミング攻撃に対する脆弱性を軽減するため、\n" +"``==`` 演算子の代わりに :func:`compare_digest` 関数を使うことを推奨します。" #: ../../library/hmac.rst:81 msgid "" @@ -133,13 +149,15 @@ msgstr "" ":meth:`digest` と似ていますが、返される文字列は倍の長さとなり、16進形式となり" "ます。これは、電子メールなどの非バイナリ環境で値を交換する場合に便利です。" -#: ../../library/hmac.rst:87 msgid "" "When comparing the output of :meth:`hexdigest` to an externally supplied " "digest during a verification routine, it is recommended to use the :func:" "`compare_digest` function instead of the ``==`` operator to reduce the " "vulnerability to timing attacks." msgstr "" +"検証処理で :meth:`hexdigest` の出力を外部から与えられたダイジェストと比較する" +"ときは、タイミング攻撃に対する脆弱性を軽減するため、\n" +"``==`` 演算子の代わりに :func:`compare_digest` 関数を使うことを推奨します。" #: ../../library/hmac.rst:95 msgid "" @@ -167,11 +185,12 @@ msgstr "内部で使われるハッシュアルゴリズムのブロックのバ msgid "The canonical name of this HMAC, always lowercase, e.g. ``hmac-md5``." msgstr "このHMAC の正規名で、例えば ``hmac-md5`` のように常に小文字です。" -#: ../../library/hmac.rst:118 msgid "" "Removed the undocumented attributes ``HMAC.digest_cons``, ``HMAC.inner``, " "and ``HMAC.outer``." msgstr "" +"ドキュメントに記載されていなかった属性 ``HMAC.digest_cons``、``HMAC.inner``、" +"``HMAC.outer`` を削除しました。" #: ../../library/hmac.rst:122 msgid "This module also provides the following helper function:" @@ -191,20 +210,20 @@ msgstr "" "えば :meth:`HMAC.hexdigest` が返したような ASCII のみの) :class:`str` また" "は :term:`bytes-like object` のどちらか一方。" -#: ../../library/hmac.rst:134 msgid "" "If *a* and *b* are of different lengths, or if an error occurs, a timing " "attack could theoretically reveal information about the types and lengths of " "*a* and *b*—but not their values." msgstr "" -"*a* と *b* が異なる長さであったりエラーが発生した場合には、タイミング攻撃で理" -"論上 *a* と *b* の型と長さについての情報が暴露されますが、その値は明らかにな" -"りません。" +"*a* と *b* の長さが異なる場合やエラーが発生した場合、理論上はタイミング攻撃に" +"よって *a* と *b* の型や長さに関する情報が漏れる可能性がありますが、値は漏れ" +"ません。" -#: ../../library/hmac.rst:142 msgid "" "The function uses OpenSSL's ``CRYPTO_memcmp()`` internally when available." msgstr "" +"OpenSSL の ``CRYPTO_memcmp()`` が利用可能な場合、この関数は内部でそれを使いま" +"す。" #: ../../library/hmac.rst:148 msgid "Module :mod:`hashlib`" diff --git a/library/html.entities.po b/library/html.entities.po index 5858ba897..be513dff6 100644 --- a/library/html.entities.po +++ b/library/html.entities.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/html.entities.rst:2 diff --git a/library/html.parser.po b/library/html.parser.po index c9fa73173..f4621c59c 100644 --- a/library/html.parser.po +++ b/library/html.parser.po @@ -16,10 +16,10 @@ msgstr "" "Last-Translator: python-doc bot, 2025\n" "Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/" "ja/)\n" +"Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: ja\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/html.parser.rst:2 @@ -44,31 +44,34 @@ msgstr "" msgid "Create a parser instance able to parse invalid markup." msgstr "不正なマークアップをパースできるパーサーインスタンスを作成します。" -#: ../../library/html.parser.rst:22 msgid "" "If *convert_charrefs* is true (the default), all character references " "(except the ones in elements like ``script`` and ``style``) are " "automatically converted to the corresponding Unicode characters." msgstr "" +"*convert_charrefs* が真 (デフォルト) の場合、``script`` や ``style`` などの要" +"素内を除くすべての文字参照を、対応する Unicode 文字に自動で変換します。" -#: ../../library/html.parser.rst:26 msgid "" "If *scripting* is false (the default), the content of the ``noscript`` " "element is parsed normally; if it's true, it's returned as is without being " "parsed." msgstr "" +"*scripting* が偽 (デフォルト) の場合、``noscript`` 要素の内容を通常どおり解析" +"します。\n" +"真の場合は解析せずにそのまま返します。" -#: ../../library/html.parser.rst:30 msgid "" "An :class:`.HTMLParser` instance is fed HTML data and calls handler methods " "when start tags, end tags, text, comments, and other markup elements are " "encountered. The user should subclass :class:`.HTMLParser` and override its " "methods to implement the desired behavior." msgstr "" -":class:`.HTMLParser` インスタンスは、HTML データが入力されると、開始タグ、終" -"了タグ、およびその他の要素が見つかる度にハンドラーメソッドを呼び出します。各" -"メソッドの挙動を実装するには :class:`.HTMLParser` サブクラスを使ってそれぞれ" -"を上書きして行います。" +":class:`.HTMLParser` インスタンスに HTML データを渡すと、開始タグ、終了タグ、" +"テキスト、コメント、その他のマークアップ要素を見つけるたびにハンドラーメソッ" +"ドを呼び出します。\n" +"利用者は :class:`.HTMLParser` のサブクラスを作り、メソッドをオーバーライドし" +"て必要な動作を実装します。" #: ../../library/html.parser.rst:35 msgid "" @@ -88,22 +91,21 @@ msgstr "キーワード引数 *convert_charrefs* を追加。" msgid "The default value for argument *convert_charrefs* is now ``True``." msgstr "*convert_charrefs* のデフォルト値は ``True`` になりました。" -#: ../../library/html.parser.rst:44 msgid "Added the *scripting* parameter." -msgstr "" +msgstr "*scripting* 引数を追加しました。" #: ../../library/html.parser.rst:49 msgid "Example HTML Parser Application" msgstr "HTML パーサーアプリケーションの例" -#: ../../library/html.parser.rst:51 msgid "" "As a basic example, below is a simple HTML parser that uses the :class:" "`HTMLParser` class to print out start tags, end tags, and data as they are " "encountered:" msgstr "" +"基本的な例として、以下は :class:`HTMLParser` クラスを使い、開始タグ、終了タ" +"グ、データを見つけるたびに表示するシンプルな HTML パーサーです。" -#: ../../library/html.parser.rst:55 msgid "" "from html.parser import HTMLParser\n" "\n" @@ -121,12 +123,26 @@ msgid "" "parser.feed('Test'\n" " '

Parse me!

')" msgstr "" +"from html.parser import HTMLParser\n" +"\n" +"class MyHTMLParser(HTMLParser):\n" +" def handle_starttag(self, tag, attrs):\n" +" print(\"Encountered a start tag:\", tag)\n" +"\n" +" def handle_endtag(self, tag):\n" +" print(\"Encountered an end tag :\", tag)\n" +"\n" +" def handle_data(self, data):\n" +" print(\"Encountered some data :\", data)\n" +"\n" +"parser = MyHTMLParser()\n" +"parser.feed('Test'\n" +" '

Parse me!

')" #: ../../library/html.parser.rst:73 msgid "The output will then be:" msgstr "出力は以下のようになります:" -#: ../../library/html.parser.rst:75 msgid "" "Encountered a start tag: html\n" "Encountered a start tag: head\n" @@ -141,6 +157,18 @@ msgid "" "Encountered an end tag : body\n" "Encountered an end tag : html" msgstr "" +"Encountered a start tag: html\n" +"Encountered a start tag: head\n" +"Encountered a start tag: title\n" +"Encountered some data : Test\n" +"Encountered an end tag : title\n" +"Encountered an end tag : head\n" +"Encountered a start tag: body\n" +"Encountered a start tag: h1\n" +"Encountered some data : Parse me!\n" +"Encountered an end tag : h1\n" +"Encountered an end tag : body\n" +"Encountered an end tag : html" #: ../../library/html.parser.rst:92 msgid ":class:`.HTMLParser` Methods" @@ -150,16 +178,15 @@ msgstr ":class:`.HTMLParser` メソッド" msgid ":class:`HTMLParser` instances have the following methods:" msgstr ":class:`HTMLParser` インスタンスは以下のメソッドを提供します:" -#: ../../library/html.parser.rst:99 msgid "" "Feed some text to the parser. It is processed insofar as it consists of " "complete elements; incomplete data is buffered until more data is fed or :" "meth:`close` is called. *data* must be :class:`str`." msgstr "" -"パーサーにテキストを入力します。入力が完全なタグ要素で構成されている場合に限" -"り処理が行われます; 不完全なデータであった場合、新たにデータが入力されるか、:" -"meth:`close` が呼び出されるまでバッファーされます。 *data* は :class:`str` で" -"なければなりません。" +"パーサーにテキストを渡します。\n" +"完全な要素からなる部分までを処理し、不完全なデータは追加のデータが渡される" +"か :meth:`close` が呼ばれるまでバッファーに保持します。\n" +"*data* は :class:`str` でなければなりません。" #: ../../library/html.parser.rst:106 msgid "" @@ -186,17 +213,16 @@ msgstr "" msgid "Return current line number and offset." msgstr "現在の行番号およびオフセット値を返します。" -#: ../../library/html.parser.rst:125 msgid "" "Return the text of the most recently opened start tag. This should not " "normally be needed for structured processing, but may be useful in dealing " "with HTML \"as deployed\" or for re-generating input with minimal changes " "(whitespace between attributes can be preserved, etc.)." msgstr "" -"最も最近開かれた開始タグのテキスト部分を返します。このテキストは必ずしも元" -"データを構造化する上で必須ではありませんが、 \"広く知られている (as " -"deployed)\" HTML を扱ったり、入力を最小限の変更で再生成 (属性間の空白をそのま" -"まにする、など) したりする場合に便利なことがあります。" +"最後に読み込んだ開始タグのテキストを返します。\n" +"構造に基づく処理では通常は不要ですが、実際に使われている HTML を扱ったり、入" +"力を最小限の変更で再生成したりする場合に役立つことがあります (属性間の空白な" +"どを保持できます)。" #: ../../library/html.parser.rst:131 msgid "" @@ -217,7 +243,6 @@ msgstr "" "このメソッドは要素の開始タグを扱うために呼び出されます (例: ``
``)。" -#: ../../library/html.parser.rst:140 msgid "" "The *tag* argument is the name of the tag converted to lower case. The " "*attrs* argument is a list of ``(name, value)`` pairs containing the " @@ -226,6 +251,12 @@ msgid "" "character and entity references have been replaced. For empty attributes, " "*value* is ``None``." msgstr "" +"*tag* 引数は、小文字に変換したタグの名前です。\n" +"*attrs* 引数は、タグの ``<>`` 内にある属性を表す ``(name, value)`` ペアのリス" +"トです。\n" +"*name* は小文字に変換され、*value* を囲む引用符は削除され、文字参照と実体参照" +"は置換されています。\n" +"値のない属性では *value* は ``None`` です。" #: ../../library/html.parser.rst:146 msgid "" @@ -237,12 +268,12 @@ msgstr "" "ドは ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])`` として呼び出" "されます。" -#: ../../library/html.parser.rst:149 msgid "" "All entity references from :mod:`html.entities` are replaced in the " "attribute values." msgstr "" -":mod:`html.entities` からのすべての実態参照は、属性値に置き換えられます。" +"属性値に含まれる実体参照は、:mod:`html.entities` の定義に従ってすべて置換され" +"ます。" #: ../../library/html.parser.rst:155 msgid "" @@ -267,20 +298,23 @@ msgstr "" "合にこのメソッドをサブクラスで上書きすることができます; 既定の実装では、単" "に :meth:`handle_starttag` および :meth:`handle_endtag` を呼び出します。" -#: ../../library/html.parser.rst:170 msgid "" "This method is called to process arbitrary data (e.g. text nodes and the " "content of elements like ``script`` and ``style``)." msgstr "" +"このメソッドは、任意のデータ (テキストノードや ``script``、``style`` などの要" +"素の内容) を処理するために呼び出されます。" -#: ../../library/html.parser.rst:176 msgid "" "This method is called to process a named character reference of the form " "``&name;`` (e.g. ``>``), where *name* is a general entity reference (e.g. " "``'gt'``). This method is only called if *convert_charrefs* is false." msgstr "" +"このメソッドは、``&name;`` 形式の名前付き文字参照 (``>`` など) を処理する" +"ために呼び出されます。\n" +"*name* は一般実体参照 (``'gt'`` など) です。\n" +"このメソッドは *convert_charrefs* が偽の場合にだけ呼び出されます。" -#: ../../library/html.parser.rst:184 msgid "" "This method is called to process decimal and hexadecimal numeric character " "references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, " @@ -288,6 +322,12 @@ msgid "" "``>``; in this case the method will receive ``'62'`` or ``'x3E'``. This " "method is only called if *convert_charrefs* is false." msgstr "" +"このメソッドは、:samp:`&#{NNN};` 形式と :samp:`&#x{NNN};` 形式の、それぞれ " +"10 進数と 16 進数による数値文字参照を処理するために呼び出されます。\n" +"例えば ``>`` に対応する表記は、10 進数では ``>``、16 進数では ``>" +"`` です。\n" +"この場合、メソッドは ``'62'`` または ``'x3E'`` を受け取ります。\n" +"このメソッドは *convert_charrefs* が偽の場合にだけ呼び出されます。" #: ../../library/html.parser.rst:193 msgid "" @@ -305,16 +345,16 @@ msgstr "" "例えば、コメント ```` があると。このメソッドを引数 ``' " "comment '`` で呼び出されます。" -#: ../../library/html.parser.rst:198 msgid "" "The content of Internet Explorer conditional comments (condcoms) will also " "be sent to this method, so, for ````, this method will receive ``'[if IE 9]>IE9-specific contentIE9-specific content`` の場合、こ" -"のメソッドは ``'[if IE 9]>IE9-specific contentIE9-specific content`` に対しては、``'[if " +"IE 9]>IE9-specific content>> parser.feed('')\n" "Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3." "org/TR/html4/strict.dtd\"" msgstr "" +">>> parser.feed('')\n" +"Decl : DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3." +"org/TR/html4/strict.dtd\"" -#: ../../library/html.parser.rst:288 msgid "Parsing an element with a few attributes and a title:" -msgstr "" +msgstr "属性を持つ要素と見出しの解析:" -#: ../../library/html.parser.rst:290 msgid "" ">>> parser.feed('\"The')\n" "Start tag: img\n" @@ -446,14 +517,23 @@ msgid "" "Data : Python\n" "End tag : h1" msgstr "" +">>> parser.feed('\"The')\n" +"Start tag: img\n" +" attr: ('src', 'python-logo.png')\n" +" attr: ('alt', 'The Python logo')\n" +">>>\n" +">>> parser.feed('

Python

')\n" +"Start tag: h1\n" +"Data : Python\n" +"End tag : h1" -#: ../../library/html.parser.rst:302 msgid "" "The content of elements like ``script`` and ``style`` is returned as is, " "without further parsing:" msgstr "" +"``script`` や ``style`` などの要素の内容は、さらに解析せずにそのまま返しま" +"す。" -#: ../../library/html.parser.rst:305 msgid "" ">>> parser.feed('