| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d8fb255 commit cd8947e
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,6 +38,15 @@ msgid "" | |||
| 38 | 38 | "pointer, or ``-1`` if they return an integer (exception: the ``PyArg_*`` " | |
| 39 | 39 | "functions return ``1`` for success and ``0`` for failure)." | |
| 40 | 40 | msgstr "" | |
| 41 | + "この章で説明する関数を使うと、 Python の例外の処理や例外の送出ができるように" | ||
| 42 | + "なります。 Python の例外処理の基本をいくらか理解することが大切です。例外は " | ||
| 43 | + "POSIX :c:data:`errno` 変数にやや似た機能を果たします: 発生した中で最も新しい" | ||
| 44 | + "エラーの (スレッド毎の) グローバルなインジケータがあります。実行に成功した場" | ||
| 45 | + "合にはほとんどの C API 関数がこれをクリアしませんが、失敗したときにはエラーの" | ||
| 46 | + "原因を示すために設定します。ほとんどの C API 関数はエラーインジケータも返し、" | ||
| 47 | + "通常は関数がポインタを返すことになっている場合は ``NULL`` であり、関数が整数" | ||
| 48 | + "を返す場合は ``-1`` です。(例外: ``PyArg_*`` 関数は実行に成功したときに " | ||
| 49 | + "``1`` を返し、失敗したときに ``0`` を返します)." | ||
| 41 | 50 | ||
| 42 | 51 | #: ../../c-api/exceptions.rst:20 | |
| 43 | 52 | msgid "" | |
@@ -106,6 +115,11 @@ msgid "" | |||
| 106 | 115 | "printed and the Python process will exit with the error code specified by " | |
| 107 | 116 | "the ``SystemExit`` instance." | |
| 108 | 117 | msgstr "" | |
| 118 | + "標準のトレースバックを ``sys.stderr`` に出力し、エラーインジケータをクリアし" | ||
| 119 | + "ます。\n" | ||
| 120 | + "ただし、エラーが ``SystemExit`` **である場合を除いて** です。\n" | ||
| 121 | + "その場合、トレースバックは出力されず、 Python プロセスは ``SystemExit`` イン" | ||
| 122 | + "スタンスで指定されたエラーコードで終了します。" | ||
| 109 | 123 | ||
| 110 | 124 | #: ../../c-api/exceptions.rst:60 | |
| 111 | 125 | msgid "" | |
@@ -183,6 +197,10 @@ msgid "" | |||
| 183 | 197 | "count. The second argument is an error message; it is decoded from " | |
| 184 | 198 | "``'utf-8'``." | |
| 185 | 199 | msgstr "" | |
| 200 | + "これはエラーインジケータを設定するための最も一般的な方法です。第一引数は例外" | ||
| 201 | + "の型を指定します。通常は標準例外の一つ、例えば :c:data:`PyExc_RuntimeError` " | ||
| 202 | + "です。その参照カウントを増加させる必要はありません。第二引数はエラーメッセー" | ||
| 203 | + "ジで、 ``'utf-8'`` からデコードされます。" | ||
| 186 | 204 | ||
| 187 | 205 | #: ../../c-api/exceptions.rst:108 | |
| 188 | 206 | msgid "" | |
@@ -289,6 +307,10 @@ msgid "" | |||
| 289 | 307 | "is given as a C string. *filename* is decoded from the :term:`filesystem " | |
| 290 | 308 | "encoding and error handler`." | |
| 291 | 309 | msgstr "" | |
| 310 | + ":c:func:`PyErr_SetFromErrnoWithFilenameObject` に似ていますが、ファイル名は " | ||
| 311 | + "C 文字列として与えられます。\n" | ||
| 312 | + "*filename* は :term:`ファイルシステムのエンコーディングとエラーハンドラ " | ||
| 313 | + "<filesystem encoding and error handler>` でデコードされます。" | ||
| 292 | 314 | ||
| 293 | 315 | #: ../../c-api/exceptions.rst:191 | |
| 294 | 316 | msgid "" | |
@@ -302,6 +324,14 @@ msgid "" | |||
| 302 | 324 | "``PyErr_SetObject(PyExc_WindowsError, object)``. This function always " | |
| 303 | 325 | "returns ``NULL``." | |
| 304 | 326 | msgstr "" | |
| 327 | + "これは :exc:`WindowsError` を発生させるために便利な関数です。 ``0`` の " | ||
| 328 | + "*ierr* とともに呼び出された場合、 :c:func:`GetLastError` が返すエラーコードが" | ||
| 329 | + "代りに使われます。 *ierr* あるいは :c:func:`GetLastError` によって与えられる" | ||
| 330 | + "エラーコードのWindows用の説明を取り出すために、Win32関数 :c:func:" | ||
| 331 | + "`FormatMessage` を呼び出します。それから、第一要素が *ierr* 値で第二要素が(:" | ||
| 332 | + "c:func:`FormatMessage` から得られる) 対応するエラーメッセージであるタプルオブ" | ||
| 333 | + "ジェクトを構成します。そして、 ``PyErr_SetObject(PyExc_WindowsError, " | ||
| 334 | + "object)`` を呼び出します。この関数は常に ``NULL`` を返します。" | ||
| 305 | 335 | ||
| 306 | 336 | #: ../../c-api/exceptions.rst:200 ../../c-api/exceptions.rst:208 | |
| 307 | 337 | #: ../../c-api/exceptions.rst:217 ../../c-api/exceptions.rst:225 | |
@@ -388,12 +418,17 @@ msgid "" | |||
| 388 | 418 | "Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string " | |
| 389 | 419 | "decoded from the :term:`filesystem encoding and error handler`." | |
| 390 | 420 | msgstr "" | |
| 421 | + ":c:func:`PyErr_SyntaxLocationObject` と似ていますが、 *filename* は :term:`" | ||
| 422 | + "ファイルシステムのエンコーディングとエラーハンドラ <filesystem encoding and " | ||
| 423 | + "error handler>` でデコードされたバイト文字列です。" | ||
| 391 | 424 | ||
| 392 | 425 | #: ../../c-api/exceptions.rst:284 | |
| 393 | 426 | msgid "" | |
| 394 | 427 | "Like :c:func:`PyErr_SyntaxLocationEx`, but the *col_offset* parameter is " | |
| 395 | 428 | "omitted." | |
| 396 | 429 | msgstr "" | |
| 430 | + ":c:func:`PyErr_SyntaxLocationEx` と似ていますが、 *col_offset* 引数が除去され" | ||
| 431 | + "ています。" | ||
| 397 | 432 | ||
| 398 | 433 | #: ../../c-api/exceptions.rst:290 | |
| 399 | 434 | msgid "" | |
@@ -486,13 +521,21 @@ msgid "" | |||
| 486 | 521 | "warn_explicit`; see there for more information. The *module* and *registry* " | |
| 487 | 522 | "arguments may be set to ``NULL`` to get the default effect described there." | |
| 488 | 523 | msgstr "" | |
| 524 | + "すべての警告の属性を明示的に制御した警告メッセージを出します。これは Python " | ||
| 525 | + "関数 :func:`warnings.warn_explicit` の直接的なラッパーで、さらに情報を得るに" | ||
| 526 | + "はそちらを参照してください。そこに説明されているデフォルトの効果を得るため" | ||
| 527 | + "に、 *module* と *registry* 引数は ``NULL`` に設定することができます。" | ||
| 489 | 528 | ||
| 490 | 529 | #: ../../c-api/exceptions.rst:345 | |
| 491 | 530 | msgid "" | |
| 492 | 531 | "Similar to :c:func:`PyErr_WarnExplicitObject` except that *message* and " | |
| 493 | 532 | "*module* are UTF-8 encoded strings, and *filename* is decoded from the :term:" | |
| 494 | 533 | "`filesystem encoding and error handler`." | |
| 495 | 534 | msgstr "" | |
| 535 | + ":c:func:`PyErr_WarnExplicitObject` に似ていますが、 *message* と *module* が " | ||
| 536 | + "UTF-8 エンコードされた文字列であるところが異なり、 *filename* は :term:`ファ" | ||
| 537 | + "イルシステムのエンコーディングとエラーハンドラ <filesystem encoding and " | ||
| 538 | + "error handler>` でデコードされます。" | ||
| 496 | 539 | ||
| 497 | 540 | #: ../../c-api/exceptions.rst:352 | |
| 498 | 541 | msgid "" | |
@@ -525,6 +568,11 @@ msgid "" | |||
| 525 | 568 | "do not own a reference to the return value, so you do not need to :c:func:" | |
| 526 | 569 | "`Py_DECREF` it." | |
| 527 | 570 | msgstr "" | |
| 571 | + "エラーインジケータが設定されているかテストします。設定されている場合は、例外" | ||
| 572 | + "の *型* (``PyErr_Set*`` 関数の一つあるいは :c:func:`PyErr_Restore` への最も新" | ||
| 573 | + "しい呼び出しに対する第一引数)を返します。設定されていない場合は ``NULL`` を返" | ||
| 574 | + "します。あなたは戻り値への参照を持っていませんので、それに :c:func:" | ||
| 575 | + "`Py_DECREF` する必要はありません。" | ||
| 528 | 576 | ||
| 529 | 577 | #: ../../c-api/exceptions.rst:378 | |
| 530 | 578 | msgid "The caller must hold the GIL." | |
@@ -762,6 +810,9 @@ msgid "" | |||
| 762 | 810 | "`PyErr_CheckSignals` is called, the Python signal handler for the given " | |
| 763 | 811 | "signal number will be called." | |
| 764 | 812 | msgstr "" | |
| 813 | + "シグナルが到達した効果をシミュレートします。\n" | ||
| 814 | + "次に :c:func:`PyErr_CheckSignals` が呼ばれたとき、与えられたシグナル番号用の " | ||
| 815 | + "Python のシグナルハンドラが呼び出されます。" | ||
| 765 | 816 | ||
| 766 | 817 | #: ../../c-api/exceptions.rst:558 | |
| 767 | 818 | msgid "" | |
@@ -776,6 +827,8 @@ msgid "" | |||
| 776 | 827 | "If the given signal isn't handled by Python (it was set to :data:`signal." | |
| 777 | 828 | "SIG_DFL` or :data:`signal.SIG_IGN`), it will be ignored." | |
| 778 | 829 | msgstr "" | |
| 830 | + "与えられたシグナルが Python に対処されなかった (:data:`signal.SIG_DFL` また" | ||
| 831 | + "は :data:`signal.SIG_IGN` に設定されていた) 場合、無視されます。" | ||
| 779 | 832 | ||
| 780 | 833 | #: ../../c-api/exceptions.rst:566 | |
| 781 | 834 | msgid "" | |
@@ -1085,6 +1138,9 @@ msgid "" | |||
| 1085 | 1138 | "to be concatenated to the :exc:`RecursionError` message caused by the " | |
| 1086 | 1139 | "recursion depth limit." | |
| 1087 | 1140 | msgstr "" | |
| 1141 | + "*where* は ``\" in instance check\"`` のような UTF-8 エンコードされた文字列に" | ||
| 1142 | + "して、再帰の深さの限界に達したことで送出される :exc:`RecursionError` のメッ" | ||
| 1143 | + "セージに連結できるようにすべきです。" | ||
| 1088 | 1144 | ||
| 1089 | 1145 | #: ../../c-api/exceptions.rst:783 ../../c-api/exceptions.rst:791 | |
| 1090 | 1146 | msgid "This function is now also available in the limited API." | |
@@ -1169,6 +1225,9 @@ msgid "" | |||
| 1169 | 1225 | "c:expr:`PyObject*`; they are all class objects. For completeness, here are " | |
| 1170 | 1226 | "all the variables:" | |
| 1171 | 1227 | msgstr "" | |
| 1228 | + "``PyExc_`` の後ろにPythonの例外名が続く名前をもつグローバル変数として、すべて" | ||
| 1229 | + "の標準Python例外が利用可能です。これらは型 :c:expr:`PyObject*` を持ち、すべて" | ||
| 1230 | + "クラスオブジェクトです。完璧を期するために、すべての変数を以下に列挙します:" | ||
| 1172 | 1231 | ||
| 1173 | 1232 | #: ../../c-api/exceptions.rst:890 ../../c-api/exceptions.rst:1023 | |
| 1174 | 1233 | #: ../../c-api/exceptions.rst:1068 | |
@@ -1694,6 +1753,10 @@ msgid "" | |||
| 1694 | 1753 | "the type :c:expr:`PyObject*`; they are all class objects. For completeness, " | |
| 1695 | 1754 | "here are all the variables:" | |
| 1696 | 1755 | msgstr "" | |
| 1756 | + "``PyExc_`` の後ろにPythonの例外名が続く名前をもつグローバル変数として、すべて" | ||
| 1757 | + "の標準Python警告カテゴリが利用可能です。これらは型 :c:expr:`PyObject*` を持" | ||
| 1758 | + "ち、すべてクラスオブジェクトです。完璧を期するために、すべての変数を以下に列" | ||
| 1759 | + "挙します:" | ||
| 1697 | 1760 | ||
| 1698 | 1761 | #: ../../c-api/exceptions.rst:1070 | |
| 1699 | 1762 | msgid ":c:data:`PyExc_Warning`" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -357,6 +357,16 @@ msgid "" | |||
| 357 | 357 | "never be deallocated, they are typically static :c:type:`PyTypeObject` " | |
| 358 | 358 | "objects." | |
| 359 | 359 | msgstr "" | |
| 360 | + "Python/C API 関数は、 :c:expr:`PyObject*` 型の一つ以上の引数と戻り値を持ちま" | ||
| 361 | + "す。この型は、任意の Python オブジェクトを表現する不透明 (opaque) なデータ型" | ||
| 362 | + "へのポインタです。 Python 言語は、全ての Python オブジェクト型をほとんどの状" | ||
| 363 | + "況 (例えば代入、スコープ規則 (scope rule)、引数渡し) で同様に扱います。ほとん" | ||
| 364 | + "ど全ての Python オブジェクトはヒープ (heap) 上に置かれます: このため、 :c:" | ||
| 365 | + "type:`PyObject` 型のオブジェクトは、自動記憶 (automatic) としても静的記憶 " | ||
| 366 | + "(static) としても宣言できません。 :c:expr:`PyObject*` 型のポインタ変数のみ宣" | ||
| 367 | + "言できます。唯一の例外は、型オブジェクトです; 型オブジェクトはメモリ解放 " | ||
| 368 | + "(deallocate) してはならないので、通常は静的記憶の :c:type:`PyTypeObject` オブ" | ||
| 369 | + "ジェクトにします。" | ||
| 360 | 370 | ||
| 361 | 371 | #: ../../c-api/intro.rst:242 | |
| 362 | 372 | msgid "" | |
@@ -519,6 +529,18 @@ msgid "" | |||
| 519 | 529 | "said to *borrow* the reference. Nothing needs to be done for a :term:" | |
| 520 | 530 | "`borrowed reference`." | |
| 521 | 531 | msgstr "" | |
| 532 | + "Python/C API の各関数における参照カウントの振る舞いは、説明するには、 *参照の" | ||
| 533 | + "所有権 (ownership of references)* という言葉でうまく説明できます。所有権は参" | ||
| 534 | + "照に対するもので、オブジェクトに対するものではありません (オブジェクトは誰に" | ||
| 535 | + "も所有されず、常に共有されています)。ある \"参照の所有\" は、その参照が必要な" | ||
| 536 | + "くなった時点で Py_DECREF を呼び出す役割を担うことを意味します。所有権は委譲で" | ||
| 537 | + "き、あるコードが委譲によって所有権を得ると、今度はそのコードが参照が必要なく" | ||
| 538 | + "なった際に最終的に :c:func:`Py_DECREF` や :c:func:`Py_XDECREF` を呼び出して、" | ||
| 539 | + "参照カウンタを1つ減らす役割を担います --- あるいは、その役割を (通常はコード" | ||
| 540 | + "を呼び出した元に) 受け渡します。ある関数が、関数の呼び出し側に対して参照の所" | ||
| 541 | + "有権を渡すと、呼び出し側は *新たな* 参照 (new reference) を得る、と言います。" | ||
| 542 | + "所有権が渡されない場合、呼び出し側は参照を *借りる* (borrow) といいます。:" | ||
| 543 | + "term:`借りた参照 <borrowed reference>` に対しては、何もする必要はありません。" | ||
| 522 | 544 | ||
| 523 | 545 | #: ../../c-api/intro.rst:331 | |
| 524 | 546 | msgid "" | |
@@ -680,6 +702,12 @@ msgid "" | |||
| 680 | 702 | "of a complex number. These will be discussed together with the functions " | |
| 681 | 703 | "that use them." | |
| 682 | 704 | msgstr "" | |
| 705 | + "他にも Python/C API において重要な役割を持つデータ型がいくつかあります; ほと" | ||
| 706 | + "んどは :c:expr:`int`, :c:expr:`long`, :c:expr:`double`, および :c:expr:" | ||
| 707 | + "`char*` といった、単なる C のデータ型です。また、モジュールで公開している関数" | ||
| 708 | + "を列挙する際に用いられる静的なテーブルや、新しいオブジェクト型におけるデータ" | ||
| 709 | + "属性を記述したり、複素数の値を記述したりするために構造体をいくつか使っていま" | ||
| 710 | + "す。これらの型については、その型を使う関数とともに説明してゆきます。" | ||
| 683 | 711 | ||
| 684 | 712 | #: ../../c-api/intro.rst:507 | |
| 685 | 713 | msgid "" | |
@@ -1006,6 +1034,11 @@ msgid "" | |||
| 1006 | 1034 | "most frequently used builds will be described in the remainder of this " | |
| 1007 | 1035 | "section." | |
| 1008 | 1036 | msgstr "" | |
| 1037 | + "Pythonデバッグ版ビルドの全ての種類のリストが、Pythonソース配布(source " | ||
| 1038 | + "distribution)の中の :file:`Misc/SpecialBuilds.txt` にあります。参照カウントの" | ||
| 1039 | + "トレース、メモリアロケータのデバッグ、インタプリタのメインループの低レベルプ" | ||
| 1040 | + "ロファイリングが利用可能です。よく使われるビルドについてのみ、この節の残りの" | ||
| 1041 | + "部分で説明します。" | ||
| 1009 | 1042 | ||
| 1010 | 1043 | #: ../../c-api/intro.rst:751 | |
| 1011 | 1044 | msgid "" | |
@@ -1017,6 +1050,12 @@ msgid "" | |||
| 1017 | 1050 | "macro:`Py_DEBUG` is enabled in the Unix build, compiler optimization is " | |
| 1018 | 1051 | "disabled." | |
| 1019 | 1052 | msgstr "" | |
| 1053 | + "インタプリタを :c:macro:`Py_DEBUG` マクロを有効にしてコンパイルすると、一般的" | ||
| 1054 | + "に :ref:`デバッグビルドといわれる Python <debug-build>` ができます。 Unix で" | ||
| 1055 | + "は、 :file:`./configure` コマンドに :option:`--with-pydebug` を追加すること" | ||
| 1056 | + "で、 :c:macro:`Py_DEBUG` が有効になります。その場合、暗黙的にPython専用ではな" | ||
| 1057 | + "い :c:macro:`_DEBUG` も有効になります。 Unix ビルドでは、 :c:macro:" | ||
| 1058 | + "`Py_DEBUG` が有効な場合、コンパイラの最適化が無効になります。" | ||
| 1020 | 1059 | ||
| 1021 | 1060 | #: ../../c-api/intro.rst:759 | |
| 1022 | 1061 | msgid "" | |
@@ -1033,6 +1072,12 @@ msgid "" | |||
| 1033 | 1072 | "well. Upon exit, all existing references are printed. (In interactive mode " | |
| 1034 | 1073 | "this happens after every statement run by the interpreter.)" | |
| 1035 | 1074 | msgstr "" | |
| 1075 | + ":c:macro:`Py_TRACE_REFS` を宣言すると、参照トレースが有効になります (:option:" | ||
| 1076 | + "`configure --with-trace-refs オプション <--with-trace-refs>` を参照してくださ" | ||
| 1077 | + "い)。全ての :c:type:`PyObject` に二つのフィールドを追加することで、使用中のオ" | ||
| 1078 | + "ブジェクトの循環二重連結リストが管理されます。全ての割り当て(allocation)がト" | ||
| 1079 | + "レースされます。終了時に、全ての残っているオブジェクトが表示されます。 (イン" | ||
| 1080 | + "タラクティブモードでは、インタプリタによる文の実行のたびに表示されます。)" | ||
| 1036 | 1081 | ||
| 1037 | 1082 | #: ../../c-api/intro.rst:769 | |
| 1038 | 1083 | msgid "" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,8 @@ msgid "" | |||
| 49 | 49 | "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " | |
| 50 | 50 | "use :c:func:`Py_XINCREF`." | |
| 51 | 51 | msgstr "" | |
| 52 | + "オブジェクトが ``NULL`` であってはいけません。それが ``NULL`` ではないと確信" | ||
| 53 | + "が持てないならば、 :c:func:`Py_XINCREF` を使ってください。" | ||
| 52 | 54 | ||
| 53 | 55 | #: ../../c-api/refcounting.rst:28 | |
| 54 | 56 | msgid "" | |
@@ -122,6 +124,8 @@ msgid "" | |||
| 122 | 124 | "The object must not be ``NULL``; if you aren't sure that it isn't ``NULL``, " | |
| 123 | 125 | "use :c:func:`Py_XDECREF`." | |
| 124 | 126 | msgstr "" | |
| 127 | + "オブジェクトが ``NULL`` であってはいけません。それが ``NULL`` ではないと確信" | ||
| 128 | + "が持てないならば、 :c:func:`Py_XDECREF` を使ってください。" | ||
| 125 | 129 | ||
| 126 | 130 | #: ../../c-api/refcounting.rst:83 | |
| 127 | 131 | msgid "" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments