"sys" --- システムパラメータと関数
**********************************

======================================================================

このモジュールでは、インタプリタで使用・管理している変数や、インタプリ
タの動作に深く関連する関数を定義しています。このモジュールは常に利用可
能です。

sys.abiflags

   Python が標準的な "configure" でビルトされた POSIX システムにおいて
   、**PEP 3149** に記述された ABI フラグを含みます。

   バージョン 3.8 で変更: デフォルトのフラグは空文字列になりました。
   (pymalloc のための "m" フラグが取り除かれました)

   バージョン 3.2 で追加.

sys.addaudithook(hook)

   呼び出し可能な *hook* を現在の(サブ)インタープリタのアクティブな監
   査用フックのリストに加えます。

   When an auditing event is raised through the "sys.audit()"
   function, each hook will be called in the order it was added with
   the event name and the tuple of arguments. Native hooks added by
   "PySys_AddAuditHook()" are called first, followed by hooks added in
   the current (sub)interpreter.  Hooks can then log the event, raise
   an exception to abort the operation, or terminate the process
   entirely.

   引数無しで 監査イベント "sys.addaudithook" を送出します。

   See the audit events table for all events raised by CPython, and
   **PEP 578** for the original design discussion.

   バージョン 3.8 で追加.

   バージョン 3.8.1 で変更: "RuntimeError" ではない class:*Exception*
   は抑制されなくなりました。

   **CPython implementation detail:** When tracing is enabled (see
   "settrace()"), Python hooks are only traced if the callable has a
   "__cantrace__" member that is set to a true value. Otherwise, trace
   functions will skip the hook.

sys.argv

   Pythonスクリプトに渡されたコマンドライン引数のリスト。 "argv[0]" は
   スクリプトの名前となりますが、フルパス名かどうかは、OSによって異な
   ります。コマンドライン引数に "-c" を付けて Pythonを起動した場合、
   "argv[0]" は文字列 "'-c'" となります。スクリプト名なしでPythonを起
   動した場合、 "argv[0]" は空文字列になります。

   標準入力もしくはコマンドライン引数で指定されたファイルのリストに渡
   ってループするには、 "fileinput" モジュールを参照してください。

   注釈:

     Unix では、コマンドライン引数は OS からバイト列で渡されます。
     Python はそれをファイルシステムエンコーディングと
     "surrogateescape" エラーハンドラを使ってデコードします。 オリジナ
     ルのバイト列が必要なときには、 "[os.fsencode(arg) for arg in
     sys.argv]" で取得できます。

sys.audit(event, *args)

   Raise an auditing event and trigger any active auditing hooks.
   *event* is a string identifying the event, and *args* may contain
   optional arguments with more information about the event.  The
   number and types of arguments for a given event are considered a
   public and stable API and should not be modified between releases.

   For example, one auditing event is named "os.chdir". This event has
   one argument called *path* that will contain the requested new
   working directory.

   "sys.audit()" will call the existing auditing hooks, passing the
   event name and arguments, and will re-raise the first exception
   from any hook. In general, if an exception is raised, it should not
   be handled and the process should be terminated as quickly as
   possible. This allows hook implementations to decide how to respond
   to particular events: they can merely log the event or abort the
   operation by raising an exception.

   Hooks are added using the "sys.addaudithook()" or
   "PySys_AddAuditHook()" functions.

   The native equivalent of this function is "PySys_Audit()". Using
   the native function is preferred when possible.

   See the audit events table for all events raised by CPython.

   バージョン 3.8 で追加.

sys.base_exec_prefix

   Python の起動中、"site.py" が実行される前、"exec_prefix" と同じ値が
   設定されます。仮想環境 で実行されたのでなければ、この値は変化しませ
   ん; "site.py" が仮想環境で使用されていると判断した場合、"prefix" お
   よび "exec_prefix" は仮想環境を示すよう変更され、"base_prefix" およ
   び "base_exec_prefix" は引き続き (仮想環境が作成された) ベースの
   Python インストール先を示します。

   バージョン 3.3 で追加.

sys.base_prefix

   Python の起動中、"site.py" が実行される前、"prefix" と同じ値が設定
   されます。仮想環境 で実行されたのでなければ、この値は変化しません;
   "site.py" が仮想環境で使用されていると検出した場合、"prefix" および
   "exec_prefix" は仮想環境を示すよう変更され、"base_prefix" および
   "base_exec_prefix" は引き続き (仮想環境が作成された) ベースの
   Python インストール先を示します。

   バージョン 3.3 で追加.

sys.byteorder

   プラットフォームのバイト順を示します。ビッグエンディアン (最上位バ
   イトが先頭) のプラットフォームでは "'big'", リトルエンディアン (最
   下位バイトが先頭) では "'little'" となります。

sys.builtin_module_names

   コンパイル時にPythonインタプリタに組み込まれた、全てのモジュール名
   のタプル(この情報は、他の手段では取得することができません。
   "modules.keys()" は、インポートされたモジュールのみのリストを返しま
   す。)

sys.call_tracing(func, args)

   トレーシングが有効な間、 "func(*args)" を呼び出します。トレーシング
   の状態は保存され、後で復元されます。これは、別のコードをチェックポ
   イントから再帰的にデバッグするために、デバッガから呼び出されること
   を意図しています。

sys.copyright

   Python インタプリタの著作権を表示する文字列です。

sys._clear_type_cache()

   内部の型キャッシュをクリアします。型キャッシュは属性とメソッドの検
   索を高速化するために利用されます。この関数は、参照リークをデバッグ
   するときに不要な参照を削除するため **だけ** に利用してください。

   この関数は、内部的かつ特殊な目的にのみ利用されるべきです。

sys._current_frames()

   各スレッドの識別子を関数が呼ばれた時点のそのスレッドでアクティブに
   なっている一番上のスタックフレームに結びつける辞書を返します。モジ
   ュール "traceback" の関数を使えばそのように与えられたフレームのコー
   ルスタックを構築できます。

   この関数はデッドロックをデバッグするのに非常に有効です。デッドロッ
   ク状態のスレッドの協調動作を必要としませんし、そういったスレッドの
   コールスタックはデッドロックである限りフリーズしたままです。デッド
   ロックにないスレッドのフレームについては、そのフレームを調べるコー
   ドを呼んだ時にはそのスレッドの現在の実行状況とは関係ないところを指
   し示しているかもしれません。

   この関数は、内部的かつ特殊な目的にのみ利用されるべきです。

   引数無しで 監査イベント "sys._current_frames" を送出します。

sys.breakpointhook()

   このフック関数は組み込みの "breakpoint()" から呼ばれます。 デフォル
   トでは、この関数は "pdb" デバッガに処理を移行させますが、他の関数を
   設定することもでき、使用するデバッガを選べます。

   この関数のシグネチャは何を呼び出すかに依存します。 例えば、
   ("pdb.set_trace()" などの) デフォルトの結び付けでは引数は求められま
   せんが、追加の引数 (位置引数およびキーワード引数) を求める関数に結
   び付けるかもしれません。 組み込みの "breakpoint()" 関数は、自身の
   "*args" と "**kws" をそのまま渡します。 "breakpointhooks()" の返り
   値が何であれ、そのまま "breakpoint()" から返されます。

   デフォルトの実装では、最初に環境変数 "PYTHONBREAKPOINT" を調べます
   。 それが ""0"" に設定されていた場合は、この関数はすぐに終了します
   。つまり何もしません。 この環境変数が設定されていないか、空文字列に
   設定されていた場合は、 "pdb.set_trace()" が呼ばれます。 それ以外の
   場合は、この変数は実行する関数の名前である必要があります。関数名の
   指定では、例えば "package.subpackage.module.function" のようなドッ
   トでつながれた Python のインポートの命名体系を使ったを使います。 こ
   の場合では、 "package.subpackage.module" がインポートされ、そのイン
   ポートされたモジュールには "function()" という呼び出し可能オブジェ
   クトがなくてはなりません。 この関数が渡された "*args" と "**kws" で
   実行され、 "function()" の返り値が何であれ "sys.breakpointhook()"
   は組み込みの "breakpoint()" 関数にその値をそのまま返します。

   "PYTHONBREAKPOINT" で指名された呼び出し可能オブジェクトのインポート
   で何かしら問題が起きた場合、 "RuntimeWarning" が報告されブレークポ
   イントは無視されることに注意してください。

   また、 "sys.breakpointhook()" がプログラム上で上書きされていた場合
   は "PYTHONBREAKPOINT" は *調べられない* ことにも注意してください。

   バージョン 3.7 で追加.

sys._debugmallocstats()

   CPython のメモリアロケータの状態に関する低レベルの情報を標準エラー
   出力に出力します。

   Python が **configure** 時に --with-pydebug オプションを指定してビ
   ルドされている場合、負荷のかかる一貫性チェックも行います。

   バージョン 3.3 で追加.

   **CPython implementation detail:** この関数は CPython 固有です。正
   確な出力形式は定義されていませんし、変更されるかもしれません。

sys.dllhandle

   Python DLLのハンドルを示す整数です。

   利用可能な環境: Windows 。

sys.displayhook(value)

   *value* が "None" 以外の時、"repr(value)" を "sys.stdout" に出力し
   、"builtins._" に保存します。"repr(value)" がエラーハンドラを
   "sys.stdout.errors" (おそらく "'strict'") として
   "sys.stdout.encoding" にエンコードできない場合、エラーハンドラを
   "'backslashreplace'" として "sys.stdout.encoding" にエンコードしま
   す。

   "sys.displayhook" は、Pythonの対話セッションで入力された *式* が評
   価されたときに呼び出されます。対話セッションの出力をカスタマイズす
   る場合、 "sys.displayhook" に引数の数が一つの関数を指定します。

   擬似コード:

      def displayhook(value):
          if value is None:
              return
          # Set '_' to None to avoid recursion
          builtins._ = None
          text = repr(value)
          try:
              sys.stdout.write(text)
          except UnicodeEncodeError:
              bytes = text.encode(sys.stdout.encoding, 'backslashreplace')
              if hasattr(sys.stdout, 'buffer'):
                  sys.stdout.buffer.write(bytes)
              else:
                  text = bytes.decode(sys.stdout.encoding, 'strict')
                  sys.stdout.write(text)
          sys.stdout.write("\n")
          builtins._ = value

   バージョン 3.2 で変更: "UnicodeEncodeError" には
   "'backslashreplace'" エラーハンドラを指定してください。

sys.dont_write_bytecode

   この値が真の時、Python はソースモジュールをインポートする時に
   ".pyc" ファイルを生成しません。この値は "-B" コマンドラインオプショ
   ンと "PYTHONDONTWRITEBYTECODE" 環境変数の値によって、起動時に
   "True" か "False" に設定されますが、実行時にこの変数を変更してバイ
   トコード生成を制御することもできます。

sys.pycache_prefix

   If this is set (not "None"), Python will write bytecode-cache
   ".pyc" files to (and read them from) a parallel directory tree
   rooted at this directory, rather than from "__pycache__"
   directories in the source code tree. Any "__pycache__" directories
   in the source code tree will be ignored and new *.pyc* files
   written within the pycache prefix. Thus if you use "compileall" as
   a pre-build step, you must ensure you run it with the same pycache
   prefix (if any) that you will use at runtime.

   A relative path is interpreted relative to the current working
   directory.

   This value is initially set based on the value of the "-X"
   "pycache_prefix=PATH" command-line option or the
   "PYTHONPYCACHEPREFIX" environment variable (command-line takes
   precedence). If neither are set, it is "None".

   バージョン 3.8 で追加.

sys.excepthook(type, value, traceback)

   指定したトレースバックと例外を "sys.stderr" に出力します。

   例外が発生し、その例外が捕捉されない場合、インタプリタは例外クラス
   ・例外インスタンス・トレースバックオブジェクトを引数として
   "sys.excepthook" を呼び出します。対話セッション中に発生した場合はプ
   ロンプトに戻る直前に呼び出され、Pythonプログラムの実行中に発生した
   場合はプログラムの終了直前に呼び出されます。このトップレベルでの例
   外情報出力処理をカスタマイズする場合、 "sys.excepthook" に引数の数
   が三つの関数を指定します。

   引数 "hook", "type", "value", "traceback" を指定して 監査イベント
   "sys.excepthook" を送出します。

   参考:

     The "sys.unraisablehook()" function handles unraisable exceptions
     and the "threading.excepthook()" function handles exception
     raised by "threading.Thread.run()".

sys.__breakpointhook__
sys.__displayhook__
sys.__excepthook__
sys.__unraisablehook__

   これらのオブジェクトはそれぞれ、プログラム起動時の
   "breakpointhook", "displayhook", "excepthook", "unraisablehook" の
   値を保存しています。 この値は、 "breakpointhook", "displayhook",
   "excepthook", "unraisablehook" に不正なオブジェクトや別のオブジェク
   トが指定された場合に、元の値に復旧するために使用します。

   バージョン 3.7 で追加: __breakpointhook__

   バージョン 3.8 で追加: __unraisablehook__

sys.exc_info()

   現在処理中の例外を示す 3 個の値のタプルを返します。この値は、現在の
   スレッドおよび現在のスタックフレームのものです。現在のスタックフレ
   ームが例外処理中でない場合、例外処理中のスタックフレームが見つかる
   までその呼び出したスタックフレームや呼び出し元などを調べます。ここ
   で、"例外処理中" とは "except 節を実行中である" フレームを指します
   。どのスタックフレームでも、最後に処理した例外の情報のみを参照でき
   ます。

   If no exception is being handled anywhere on the stack, a tuple
   containing three "None" values is returned.  Otherwise, the values
   returned are "(type, value, traceback)".  Their meaning is: *type*
   gets the type of the exception being handled (a subclass of
   "BaseException"); *value* gets the exception instance (an instance
   of the exception type); *traceback* gets a traceback object which
   encapsulates the call stack at the point where the exception
   originally occurred.

sys.exec_prefix

   Python のプラットフォーム依存なファイルがインストールされているディ
   レクトリ名を示す文字列です。この値はサイト固有であり、デフォルトは
   "'/usr/local'" ですが、ビルド時に **configure** の "--exec-prefix"
   引数で指定することができます。すべての設定ファイル ("pyconfig.h" な
   ど) は "*exec_prefix*/lib/python*X.Y*/config" に、共有ライブラリは
   "*exec_prefix*/lib/python*X.Y*/lib-dynload" にインストールされます
   (*X.Y* は "3.2" のような Python のバージョン番号)。

   注釈:

     仮想環境 で起動されている場合、この値は "site.py" によって仮想環
     境を示すよう変更されます。実際の Python のインストール先は
     "base_exec_prefix" から取得できます。

sys.executable

   Python インタプリタの実行ファイルの絶対パスを示す文字列です。このよ
   うな名前が意味を持つシステムで利用可能です。Python が自身の実行ファ
   イルの実際のパスを取得できない場合、"sys.executable" は空の文字列ま
   たは "None" になります。

sys.exit([arg])

   Raise a "SystemExit" exception, signaling an intention to exit the
   interpreter.

   オプション引数 *arg* には、終了ステータスとして整数 (デフォルトは0
   ）や他の型のオブジェクトを指定することができます。整数を指定した場
   合、シェル等は 0 は "正常終了"、0 以外の整数を "異常終了" として扱
   います。多くのシステムでは、有効な終了ステータスは 0--127 で、これ
   以外の値を返した場合の動作は未定義です。システムによっては特定の終
   了コードに個別の意味を持たせている場合がありますが、このような定義
   は僅かしかありません。Unix プログラムでは構文エラーの場合には 2 を
   、それ以外のエラーならば 1 を返します。*arg* に "None" を指定した場
   合は、数値の 0 を指定した場合と同じです。それ以外の型のオブジェクト
   を指定すると、そのオブェクトが "stderr" に出力され、終了コードとし
   て 1 を返します。エラー発生時には "sys.exit("エラーメッセージ")" と
   書くと、簡単にプログラムを終了することができます。

   Since "exit()" ultimately "only" raises an exception, it will only
   exit the process when called from the main thread, and the
   exception is not intercepted. Cleanup actions specified by finally
   clauses of "try" statements are honored, and it is possible to
   intercept the exit attempt at an outer level.

   バージョン 3.6 で変更: Python インタープリタが (バッファされたデー
   タを標準ストリームに吐き出すときのエラーなどの) "SystemExit" を捕捉
   した後の後始末でエラーが起きた場合、終了ステータスは 120 に変更され
   ます。

sys.flags

   コマンドラインフラグの状態を表す *名前付きタプル* です。各属性は読
   み出し専用になっています。

   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | 属性                          | フラグ                                                                                                         |
   |===============================|================================================================================================================|
   | "debug"                       | "-d"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "inspect"                     | "-i"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "interactive"                 | "-i"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "isolated"                    | "-I"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "optimize"                    | "-O" または "-OO"                                                                                              |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "dont_write_bytecode"         | "-B"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "no_user_site"                | "-s"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "no_site"                     | "-S"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "ignore_environment"          | "-E"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "verbose"                     | "-v"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "bytes_warning"               | "-b"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "quiet"                       | "-q"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "hash_randomization"          | "-R"                                                                                                           |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "dev_mode"                    | "-X dev" (Python Development Mode)                                                                             |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "utf8_mode"                   | "-X utf8"                                                                                                      |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+
   | "int_max_str_digits"          | "-X int_max_str_digits" (integer string conversion length limitation)                                          |
   +-------------------------------+----------------------------------------------------------------------------------------------------------------+

   バージョン 3.2 で変更: 新しい "-q" 向けに "quiet" 属性が追加されま
   した。

   バージョン 3.2.3 で追加: "hash_randomization" 属性が追加されました
   。

   バージョン 3.3 で変更: 廃止済みの "division_warning" 属性を削除しま
   した。

   バージョン 3.4 で変更: "-I" "isolated" フラグ向けに "isolated" 属性
   が追加されました。

   バージョン 3.7 で変更: 新しい Python 開発モード 向けに "dev_mode"
   属性が、新しい "-X" "utf8" フラグ向けに "utf8_mode" 属性が追加され
   ました。

   バージョン 3.9.14 で変更: Added the "int_max_str_digits" attribute.

sys.float_info

   float 型に関する情報を保持している *名前付きタプル* です。精度と内
   部表現に関する低レベル情報を含んでいます。これらの値は 'C' 言語の標
   準ヘッダファイル "float.h" で定義されている様々な浮動小数点定数に対
   応しています。詳細は 1999 ISO/IEC C standard [C99] の 5.2.4.2.2 節
   'Characteristics of floating types' を参照してください。

   +-----------------------+------------------+----------------------------------------------------+
   | 属性                  | float.h のマクロ | 説明                                               |
   |=======================|==================|====================================================|
   | "epsilon"             | DBL_EPSILON      | difference between 1.0 and the least value greater |
   |                       |                  | than 1.0 that is representable as a float          |
   |                       |                  | "math.ulp()" を参照してください。                  |
   +-----------------------+------------------+----------------------------------------------------+
   | "dig"                 | DBL_DIG          | 浮動小数点数で正確に表示できる最大の10進数桁; 以下 |
   |                       |                  | 参照                                               |
   +-----------------------+------------------+----------------------------------------------------+
   | "mant_dig"            | DBL_MANT_DIG     | 浮動小数点精度: 浮動小数点数の主要部の桁           |
   |                       |                  | base-"radix"                                       |
   +-----------------------+------------------+----------------------------------------------------+
   | "max"                 | DBL_MAX          | float が表せる最大の正の (infiniteではない) 値     |
   +-----------------------+------------------+----------------------------------------------------+
   | "max_exp"             | DBL_MAX_EXP      | floatが "radix**(e-1)" で表現可能な、最大の整数    |
   |                       |                  | *e*                                                |
   +-----------------------+------------------+----------------------------------------------------+
   | "max_10_exp"          | DBL_MAX_10_EXP   | float が "10**e" で表現可能な、最大の整数 *e*      |
   +-----------------------+------------------+----------------------------------------------------+
   | "min"                 | DBL_MIN          | minimum representable positive *normalized* float  |
   |                       |                  | Use "math.ulp(0.0)" to get the smallest positive   |
   |                       |                  | *denormalized* representable float.                |
   +-----------------------+------------------+----------------------------------------------------+
   | "min_exp"             | DBL_MIN_EXP      | "radix**(e-1)" が正規化floatであるような最小の整数 |
   |                       |                  | *e*                                                |
   +-----------------------+------------------+----------------------------------------------------+
   | "min_10_exp"          | DBL_MIN_10_EXP   | "10**e" が正規化floatであるような最小の整数 *e*    |
   +-----------------------+------------------+----------------------------------------------------+
   | "radix"               | FLT_RADIX        | 指数部の基数                                       |
   +-----------------------+------------------+----------------------------------------------------+
   | "rounds"              | FLT_ROUNDS       | 算術演算で利用される丸めモードを表す整数定数。これ |
   |                       |                  | はインタプリタ起 動時のシステムの FLT_ROUNDS マク  |
   |                       |                  | ロの値を示します。取りうる値とその 意味については  |
   |                       |                  | 、C99 標準の 5.2.4.2.2 節を参照してください。      |
   +-----------------------+------------------+----------------------------------------------------+

   "sys.float_info.dig" に対してはさらに説明が必要です。もし、文字列
   "s" が表す 10 進数の有効桁数が多くても "sys.float_info.dig" の時に
   は、 "s" を浮動小数点数に変換して戻すと同じ 10 進数を表す文字列に復
   元されます:

      >>> import sys
      >>> sys.float_info.dig
      15
      >>> s = '3.14159265358979'    # decimal string with 15 significant digits
      >>> format(float(s), '.15g')  # convert to float and back -> same value
      '3.14159265358979'

   ただし、文字列が有効桁数 "sys.float_info.dig" より大きい場合には、
   常に復元されるとは限りません:

      >>> s = '9876543211234567'    # 16 significant digits is too many!
      >>> format(float(s), '.16g')  # conversion changes value
      '9876543211234568'

sys.float_repr_style

   "repr()" 関数が浮動小数点数に対してどう振る舞うかを示す文字列です。
   この文字列が値 "'short'" を持てば、有限の浮動小数点数 "x" に対して
   、"repr(x)" は "float(repr(x)) == x" を満たす短い文字列を返そうとし
   ます。これは、Python 3.1 以降での標準の振る舞いです。それ以外の場合
   、"float_repr_style" は値 "'legacy'" を持ち、"repr(x)" は 3.1 以前
   のバージョンの Python と同じように振る舞います。

   バージョン 3.1 で追加.

sys.getallocatedblocks()

   サイズに関わりなく、現在インタプリタから確保されたメモリブロックの
   数を返します。 この関数は主にメモリリークを追跡しバグを見付けるのに
   便利です。 インタプリタの内部的なキャッシュがあるために、呼び出しご
   とに結果が変わることがあります。より結果が予測しやすくなる
   "_clear_type_cache()" や "gc.collect()" を呼ぶ必要があるかもしれま
   せん。

   Python のあるビルドや実装が適切にこの情報を計算できない場合は、その
   代わりに "getallocatedblocks()" は 0 を返すことが許されています。

   バージョン 3.4 で追加.

sys.getandroidapilevel()

   ビルト時の Android のバージョンを整数で返します。

   利用可能な環境: Android 。

   バージョン 3.7 で追加.

sys.getdefaultencoding()

   Unicode 実装で使用される現在のデフォルトエンコーディング名を返しま
   す。

sys.getdlopenflags()

   "dlopen()" の呼び出しで使われるフラグの現在の値を返します。 フラグ
   の値のシンボル名は "os" から見付けられます ("RTLD_xxx" 定数、例えば
   "os.RTLD_LAZY")。

   利用可能な環境: Unix。

sys.getfilesystemencoding()

   Unicode ファイル名と bytes ファイル名どうしを変換するのに使われるエ
   ンコーディングの名前を返します。 最良の互換性のために、たとえファイ
   ル名の表現に bytes がサポートされていたとしても、全てのケースで str
   をファイル名に使うべきです。 ファイル名を受け取ったり返したりする関
   数は str と bytes をサポートし、すぐにシステムにとって好ましい表現
   に変換すべきです。

   このエンコーディングは常に ASCII 互換です。

   "os.fsencode()" や "os.fsdecode()" を、正しいエンコーディングやエラ
   ーモードが使われていることを保証するために使うべきです。

   * UTF-8 モードでは、どのプラットフォームでもエンコーディングは
     "utf-8" です。

   * macOS では、エンコーディングは "'utf-8'" となります。

   * Unix では、エンコーディングはロケールのエンコーディングです。

   * Windows では、エンコーディングはユーザの設定によって "'utf-8'" ま
     たは "'mbcs'" のどちらかになります。

   * Android では、エンコーディングは "'utf-8'" となります。

   * VxWorks では、エンコーディングは "'utf-8'" となります。

   バージョン 3.2 で変更: "getfilesystemencoding()" の結果が "None" に
   なることはなくなりました。

   バージョン 3.6 で変更: Windows はもう "'mbcs'" を返す保証は無くなり
   ました。 より詳しいことは **PEP 529** および
   "_enablelegacywindowsfsencoding()" を参照してください。

   バージョン 3.7 で変更: UTF-8 モードで 'utf-8' を返すようになりまし
   た。

sys.getfilesystemencodeerrors()

   Unicode ファイルシステムと bytes ファイル名どうしの変換で使われるエ
   ラーモード名を返します。 エンコーディング名は
   "getfilesystemencoding()" から返されます。

   "os.fsencode()" や "os.fsdecode()" を、正しいエンコーディングやエラ
   ーモードが使われていることを保証するために使うべきです。

   バージョン 3.6 で追加.

sys.get_int_max_str_digits()

   Returns the current value for the integer string conversion length
   limitation. See also "set_int_max_str_digits()".

   バージョン 3.9.14 で追加.

sys.getrefcount(object)

   *object* の参照数を返します。 *object* は (一時的に)
   "getrefcount()" からも参照されるため、参照数は予想される数よりも 1
   多くなります。

sys.getrecursionlimit()

   現在の最大再帰数を返します。最大再帰数は、Python インタプリタスタッ
   クの最大の深さです。この制限は Python プログラムが無限に再帰し、C
   スタックがオーバーフローしてクラッシュすることを防止するために設け
   られています。この値は "setrecursionlimit()" で指定することができま
   す。

sys.getsizeof(object[, default])

   *object* のサイズをバイト数で返します。*object* は任意の型のオブジ
   ェクトです。すべての組み込みオブジェクトは正しい値を返します。サー
   ドパーティー製の型については実装依存になります。

   オブジェクトに直接起因するメモリ消費のみを表し、参照するオブジェク
   トは含みません。

   オブジェクトがサイズを取得する手段を提供していない時は *default* が
   返されます。*default* が指定されていない場合は "TypeError" が送出さ
   れます。

   "getsizeof()" は *object* の "__sizeof__" メソッドを呼び出し、その
   オブジェクトがガベージコレクタに管理されていた場合はガベージコレク
   タのオーバーヘッドを増やします。

   "getsizeof()" を再帰的に使い、コンテナとその中身のサイズを割り出す
   例は、 再帰的な sizeof のレシピ を参照してください。

sys.getswitchinterval()

   インタプリタの "スレッド切り替え間隔" を返します。
   "setswitchinterval()" を参照してください。

   バージョン 3.2 で追加.

sys._getframe([depth])

   コールスタックからフレームオブジェクトを返します。オプション引数
   *depth* を指定すると、スタックのトップから *depth* だけ下のフレーム
   オブジェクトを取得します。 *depth* がコールスタックよりも深ければ、
   "ValueError" が発生します。 *depth* のデフォルト値は 0 で、この場合
   はコールスタックのトップのフレームを返します。

   引数無しで 監査イベント "sys._getframe" を送出します。

   **CPython implementation detail:** この関数は、内部的かつ特殊な目的
   にのみ利用されるべきです。全ての Python 実装で存在することが保証さ
   れているわけではありません。

sys.getprofile()

   "setprofile()" 関数で設定したプロファイラ関数を取得します。

sys.gettrace()

   "settrace()" 関数で設定したトレース関数を取得します。

   **CPython implementation detail:** "gettrace()" 関数は、デバッガ、
   プロファイラ、カバレッジツールなどの実装に使うことのみを想定してい
   ます。この関数の振る舞いは言語定義ではなく実装プラットフォームの一
   部です。そのため、他の Python 実装では利用できないかもしれません。

sys.getwindowsversion()

   実行中の Windows バージョンを示す、名前付きタプルを返します。 名前
   の付いている要素は、 *major*, *minor*, *build*, *platform*,
   *service_pack*, *service_pack_minor*, *service_pack_major*,
   *suite_mask*, *product_type*, *platform_version* です。
   *service_pack* は文字列を含み、 *platform_version* は 3-タプル、そ
   れ以外は整数です。 この構成要素には名前でもアクセスできるので、
   "sys.getwindowsversion()[0]" は "sys.getwindowsversion().major" と
   等価です。 先行のバージョンとの互換性のため、最初の 5 要素のみが添
   字の指定で取得できます。

   *platform* は "2 (VER_PLATFORM_WIN32_NT)" になっているでしょう。

   *product_type* は、以下の値のいずれかになります。:

   +-----------------------------------------+-----------------------------------+
   | 定数                                    | 意味                              |
   |=========================================|===================================|
   | "1 (VER_NT_WORKSTATION)"                | システムはワークステーションです  |
   |                                         | 。                                |
   +-----------------------------------------+-----------------------------------+
   | "2 (VER_NT_DOMAIN_CONTROLLER)"          | システムはドメインコントローラで  |
   |                                         | す。                              |
   +-----------------------------------------+-----------------------------------+
   | "3 (VER_NT_SERVER)"                     | システムはサーバですが、ドメイン  |
   |                                         | コントローラではありません。      |
   +-----------------------------------------+-----------------------------------+

   この関数は、Win32 "GetVersionEx()" 関数を呼び出します。これらのフィ
   ールドに関する詳細は "OSVERSIONINFOEX()" についてのマイクロソフトの
   ドキュメントを参照してください。

   *platform_version* は、プロセスでエミュレートされているバージョンで
   はなく、現在のオペレーティングシステムのメジャーバージョン、マイナ
   ーバージョン、ビルドナンバーを返します。 この関数は機能の検知ではな
   くロギングで使うためのものです。

   注釈:

     *platform_version* derives the version from kernel32.dll which
     can be of a different version than the OS version. Please use
     "platform" module for achieving accurate OS version.

   利用可能な環境: Windows 。

   バージョン 3.2 で変更: 名前付きタプルに変更され、
   *service_pack_minor*, *service_pack_major*, *suite_mask*, および
   *product_type* が追加されました。

   バージョン 3.6 で変更: *platform_version* の追加

sys.get_asyncgen_hooks()

   *asyncgen_hooks* オブジェクトを返します。このオブジェクトは
   *(firstiter, finalizer)* という形の "namedtuple" に似た形をしていま
   す。 *firstiter* と *finalizer* は両方とも "None" か、
   *asynchronous generator iterator* を引数に取る関数と、イベントルー
   プが非同期ジェネレータの終了処理をスケジューリングするのに使う関数
   であることが求められます。

   バージョン 3.6 で追加: より詳しくは **PEP 525** を参照してください
   。

   注釈:

     This function has been added on a provisional basis (see **PEP
     411** for details.)

sys.get_coroutine_origin_tracking_depth()

   Get the current coroutine origin tracking depth, as set by
   "set_coroutine_origin_tracking_depth()".

   バージョン 3.7 で追加.

   注釈:

     This function has been added on a provisional basis (see **PEP
     411** for details.)  Use it only for debugging purposes.

sys.hash_info

   数値のハッシュ実装のパラメータを与える *named tuple* です。数値型の
   ハッシュ化についての詳細は 数値型のハッシュ化 を参照してください。

   +-----------------------+----------------------------------------------------+
   | 属性                  | 説明                                               |
   |=======================|====================================================|
   | "width"               | ハッシュ値に利用されるビット幅                     |
   +-----------------------+----------------------------------------------------+
   | "modulus"             | 数値ハッシュ計算に利用される素数の法               |
   +-----------------------+----------------------------------------------------+
   | "inf"                 | 正の無限大に対して返されるハッシュ値               |
   +-----------------------+----------------------------------------------------+
   | "nan"                 | nan に対して返されるハッシュ値                     |
   +-----------------------+----------------------------------------------------+
   | "imag"                | 複素数の虚部を表すための乗数                       |
   +-----------------------+----------------------------------------------------+
   | "algorithm"           | "str"、"bytes"、"memoryview" オブジェクトのハッシ  |
   |                       | ュアルゴリズムの名 前                              |
   +-----------------------+----------------------------------------------------+
   | "hash_bits"           | ハッシュアルゴリズムの内部出力サイズ               |
   +-----------------------+----------------------------------------------------+
   | "seed_bits"           | ハッシュアルゴリズムのシードキーのサイズ           |
   +-----------------------+----------------------------------------------------+

   バージョン 3.2 で追加.

   バージョン 3.4 で変更: *algorithm*、*hash_bits*、*seed_bits* を追加

sys.hexversion

   単精度整数にエンコードされたバージョン番号。この値は新バージョン(正
   規リリース以外であっても)ごとにかならず増加します。例えば、Python
   1.5.2 以降でのみ動作するプログラムでは、以下のようなチェックを行い
   ます。

      if sys.hexversion >= 0x010502F0:
          # use some advanced feature
          ...
      else:
          # use an alternative implementation or warn the user
          ...

   "hexversion" は "hex()" 関数を使って 16 進数に変換しなければ値の意
   味を持ちません。より読みやすいバージョン番号が必要な場合には *named
   tuple* "sys.version_info" を使用してください。

   "hexversion" のより詳しい情報については API と ABI のバージョニング
   を参照してください。

sys.implementation

   現在起動している Python インタプリタに関する情報が格納されたオブジ
   ェクトです。すべての Python 実装において、以下の属性が存在すること
   が要求されています。

   *name* は実装の識別子です (例: "'cpython'")。実際の文字列は Python
   実装によって定義されますが、小文字であることが保証されています。

   *version* は "sys.version_info" と同じ形式の、Python *実装* のバー
   ジョンを表す名前付きタプルです。これは現在起動しているインタプリタ
   固有のバージョンを意味します。"sys.version_info" は Python *言語*
   のバージョンであり、これはそのバージョンに準拠した *実装* のバージ
   ョンです。例えば、PyPy 1.8 の "sys.implementation.version" は
   "sys.version_info(1, 8, 0, 'final', 0)" になるのに対し、
   "sys.version_info" は "sys.version_info(2, 7, 2, 'final', 0)" にな
   ります。CPython は、それがリファレンス実装であるため、両者は同じ値
   になります。

   *hexversion* は "sys.hexversion" と同形式の、16 進数での実装のバー
   ジョンです。

   *cache_tag* は、キャッシュされたモジュールのファイル名に使用される
   タグです。慣例により、これは実装名とバージョンを組み合わせた文字列
   になります (例: "'cpython-33'") が、Python 実装はその他の適切な値を
   使う場合があります。"cache_tag" に "None" が設定された場合、モジュ
   ールのキャッシングが無効になっていることを示します。

   "sys.implementation" には Python 実装固有の属性を追加することができ
   ます。それら非標準属性の名前はアンダースコアから始めなくてはならず
   、そしてここでは説明されません。その内容に関係なく、
   "sys.implementation" はインタプリタ起動中や実装のバージョン間で変更
   することはありません (ただし Python 言語のバージョン間についてはそ
   の限りではありません)。詳細は **PEP 421** を参照してください。

   バージョン 3.3 で追加.

   注釈:

     The addition of new required attributes must go through the
     normal PEP process. See **PEP 421** for more information.

sys.int_info

   Python における整数の内部表現に関する情報を保持する、*named tuple*
   です。この属性は読み出し専用です。

   +------------------------------------------+-------------------------------------------------+
   | 属性                                     | 説明                                            |
   |==========================================|=================================================|
   | "bits_per_digit"                         | 各桁に保持されるビットの数です。Python の整数は |
   |                                          | 、内部的に "2**int_info.bits_per_digit" を基数  |
   |                                          | として保存されます                              |
   +------------------------------------------+-------------------------------------------------+
   | "sizeof_digit"                           | 桁を表すために使われる、C 型の大きさ (バイト)   |
   |                                          | です                                            |
   +------------------------------------------+-------------------------------------------------+
   | "default_max_str_digits"                 | default value for                               |
   |                                          | "sys.get_int_max_str_digits()" when it is not   |
   |                                          | otherwise explicitly configured.                |
   +------------------------------------------+-------------------------------------------------+
   | "str_digits_check_threshold"             | minimum non-zero value for                      |
   |                                          | "sys.set_int_max_str_digits()",                 |
   |                                          | "PYTHONINTMAXSTRDIGITS", or "-X                 |
   |                                          | int_max_str_digits".                            |
   +------------------------------------------+-------------------------------------------------+

   バージョン 3.1 で追加.

   バージョン 3.9.14 で変更: Added "default_max_str_digits" and
   "str_digits_check_threshold".

sys.__interactivehook__

   この属性が存在する場合、インタープリタが 対話モード で起動したとき
   に値は (引数なしで) 自動的に呼ばれます。これは "PYTHONSTARTUP" ファ
   イルの読み込み後に行われるため、それにこのフックを設定することが出
   来ます。"site" モジュールで 設定します。

   引数 "hook" を指定して 監査イベント "cpython.run_interactivehook"
   を送出します。

   バージョン 3.4 で追加.

sys.intern(string)

   *string* を "隔離" された文字列のテーブルに入力し、隔離された文字列
   を返します -- この文字列は *string* 自体かコピーです。隔離された文
   字列は辞書検索のパフォーマンスを少しだけ向上させるのに有効です --
   辞書中のキーが隔離されており、検索するキーが隔離されている場合、(ハ
   ッシュ化後の) キーの比較は文字列の比較ではなくポインタの比較で行う
   ことができるからです。通常、Python プログラム内で利用されている名前
   は自動的に隔離され、モジュール、クラス、またはインスタンス属性を保
   持するための辞書は隔離されたキーを持っています。

   隔離された文字列はイモータルではありません。その恩恵を受けるために
   は "intern()" の返り値への参照を維持しなくてはなりません。

sys.is_finalizing()

   Return "True" if the Python interpreter is *shutting down*, "False"
   otherwise.

   バージョン 3.5 で追加.

sys.last_type
sys.last_value
sys.last_traceback

   通常は定義されておらず、捕捉されない例外が発生してインタプリタがエ
   ラーメッセージとトレースバックを出力した場合にのみ設定されます。こ
   の値は、対話セッション中にエラーが発生した時、デバッグモジュールを
   ロード (例: "import pdb; pdb.pm()" など。詳細は "pdb" モジュールを
   参照) して発生したエラーを調査する場合に利用します。デバッガをロー
   ドすると、プログラムを再実行せずに情報を取得することができます

   変数の意味は、上記 "exc_info()" の返り値と同じです。

sys.maxsize

   "Py_ssize_t" 型の変数が取りうる最大値を示す整数です。通常、32 ビッ
   トプラットフォームでは "2**31 - 1"、64 ビットプラットフォームでは
   "2**63 - 1" になります。

sys.maxunicode

   Unicode コードポイントの最大値を示す整数、すなわち "1114111" (16 進
   数で "0x10FFFF") です。

   バージョン 3.3 で変更: **PEP 393** 以前は、オプション設定にUnicode
   文字の保存形式がUCS-2とUCS-4のどちらを指定したかによって、
   "sys.maxunicode" の値は "0xFFFF" が "0x10FFFF" になっていました。

sys.meta_path

   A list of *meta path finder* objects that have their "find_spec()"
   methods called to see if one of the objects can find the module to
   be imported. The "find_spec()" method is called with at least the
   absolute name of the module being imported. If the module to be
   imported is contained in a package, then the parent package's
   "__path__" attribute is passed in as a second argument. The method
   returns a *module spec*, or "None" if the module cannot be found.

   参考:

     "importlib.abc.MetaPathFinder"
        The abstract base class defining the interface of finder
        objects on "meta_path".

     "importlib.machinery.ModuleSpec"
        The concrete class which "find_spec()" should return instances
        of.

   バージョン 3.4 で変更: *Module specs* were introduced in Python
   3.4, by **PEP 451**. Earlier versions of Python looked for a method
   called "find_module()". This is still called as a fallback if a
   "meta_path" entry doesn't have a "find_spec()" method.

sys.modules

   既に読み込まれているモジュールとモジュール名がマップされている辞書
   です。これを使用してモジュールの強制再読み込みやその他のトリック操
   作が行えます。ただし、この辞書の置き換えは想定された操作ではなく、
   必要不可欠なアイテムを削除することで Python が異常終了してしまうか
   もしれません。

sys.path

   モジュールを検索するパスを示す文字列のリスト。 "PYTHONPATH" 環境変
   数と、インストール時に指定したデフォルトパスで初期化されます。

   起動時に初期化された後、リストの先頭 ("path[0]") には Python インタ
   プリタを起動したスクリプトのあるディレクトリが挿入されます。スクリ
   プトのディレクトリがない (インタプリタが対話セッションで起動された
   時や、スクリプトを標準入力から読み込んだ場合など) 場合、 "path[0]"
   は空文字列となり、Python はカレントディレクトリからモジュールの検索
   を開始します。スクリプトディレクトリは、 "PYTHONPATH" で指定したデ
   ィレクトリの *前* に挿入されますので注意が必要です。

   プログラムはその目的のために、このリストを自由に修正できます。文字
   列とバイト列だけが "sys.path" に追加でき、 ほかの全てのデータ型はイ
   ンポート中に無視されます。

   参考: "site" モジュールのドキュメントで、 .pth ファイルを使って
       "sys.path" を拡張する方法を解説しています。

sys.path_hooks

   path を引数にとって、その path に対する *finder* の作成を試みる呼び
   出し可能オブジェクトのリスト。 finder の作成に成功したら、その呼出
   可能オブジェクトのは finder を返します。失敗した場合は、
   "ImportError" を発生させます。

   オリジナルの仕様は **PEP 302** を参照してください。

sys.path_importer_cache

   *finder* オブジェクトのキャッシュ機能を果たす辞書です。キーは
   "sys.path_hooks" に渡されているパスで、値は見つかった finder になり
   ます。パスが正常なファイルシステムパスであり、finder が
   "sys.path_hooks" 上に見つからない場合は "None" が格納されます。

   オリジナルの仕様は **PEP 302** を参照してください。

   バージョン 3.3 で変更: finder が見つからない時、"imp.NullImporter"
   ではなく "None" が格納されるようになりました。

sys.platform

   プラットフォームを識別する文字列で、"sys.path" にプラットフォーム固
   有のサブディレクトリを追加する場合などに利用します。

   Linux と AIX を除く Unix システムでは、"uname -s" が返す小文字の OS
   名に "uname -r" が返すバージョン名の先頭を追加したものになります (
   例: "'sunos5'"、"'freebsd8'")。この値は *Python がビルドされた時点
   のもの* です。システム固有のバージョンをテストする場合を除き、以下
   のような用法で使うことを推奨します:

      if sys.platform.startswith('freebsd'):
          # FreeBSD-specific code here...
      elif sys.platform.startswith('linux'):
          # Linux-specific code here...
      elif sys.platform.startswith('aix'):
          # AIX-specific code here...

   その他のシステムでは以下の値になります:

   +------------------+-----------------------------+
   | システム         | "platform" の値             |
   |==================|=============================|
   | AIX              | "'aix'"                     |
   +------------------+-----------------------------+
   | Linux            | "'linux'"                   |
   +------------------+-----------------------------+
   | Windows          | "'win32'"                   |
   +------------------+-----------------------------+
   | Windows/Cygwin   | "'cygwin'"                  |
   +------------------+-----------------------------+
   | macOS            | "'darwin'"                  |
   +------------------+-----------------------------+

   バージョン 3.3 で変更: Linuxでは、 "sys.platform" はもはやメジャー
   バージョン番号を含みません。 "'linux2'" や "'linux3'" の代わりに
   "'linux'" が格納されます。 古いPythonではこの変数はバージョン番号を
   含むため、前述した "startswith" イディオムを使用することをお勧めし
   ます。

   バージョン 3.8 で変更: AIX では、 "sys.platform" はもはやメジャーバ
   ージョン番号を含みません。 "'aix5'" や "'aix7'" の代わりに "'aix'"
   が格納されます。 古いPythonではこの変数はバージョン番号を含むため、
   前述した "startswith" イディオムを使用することをお勧めします。

   参考:

     "os.name" が持つ情報はおおざっぱな括りであり、"os.uname()" はシス
     テムに依存したバージョン情報になります。

     "platform" モジュールはシステムの詳細な識別情報をチェックする機能
     を提供しています。

sys.platlibdir

   Name of the platform-specific library directory. It is used to
   build the path of standard library and the paths of installed
   extension modules.

   It is equal to ""lib"" on most platforms. On Fedora and SuSE, it is
   equal to ""lib64"" on 64-bit platforms which gives the following
   "sys.path" paths (where "X.Y" is the Python "major.minor" version):

   * "/usr/lib64/pythonX.Y/": Standard library (like "os.py" of the
     "os" module)

   * "/usr/lib64/pythonX.Y/lib-dynload/": C extension modules of the
     standard library (like the "errno" module, the exact filename is
     platform specific)

   * "/usr/lib/pythonX.Y/site-packages/" (always use "lib", not
     "sys.platlibdir"): Third-party modules

   * "/usr/lib64/pythonX.Y/site-packages/": C extension modules of
     third-party packages

   バージョン 3.9 で追加.

sys.prefix

   A string giving the site-specific directory prefix where the
   platform independent Python files are installed; on Unix, the
   default is "'/usr/local'".  This can be set at build time with the
   "--prefix" argument to the **configure** script.  See インストール
   パス for derived paths.

   注釈:

     仮想環境 で起動されている場合、この値は "site.py" によって仮想環
     境を示すよう変更されます。実際の Python のインストール先は
     "base_prefix" から取得できます。

sys.ps1
sys.ps2

   インタプリタの一次プロンプト、二次プロンプトを指定する文字列。対話
   モードで実行中のみ定義され、初期値は "'>>> '" と "'... '" です。文
   字列以外のオブジェクトを指定した場合、インタプリタが対話コマンドを
   読み込むごとにオブジェクトの "str()" を評価します。この機能は、動的
   に変化するプロンプトを実装する場合に利用します。

sys.setdlopenflags(n)

   インタプリタが拡張モジュールをロードする時、"dlopen()" で使用するフ
   ラグを設定します。"sys.setdlopenflags(0)" とすれば、モジュールイン
   ポート時にシンボルの遅延解決を行う事ができます。シンボルを拡張モジ
   ュール間で共有する場合には、"sys.setdlopenflags(os.RTLD_GLOBAL)" と
   指定します。フラグ値の定義名は "os" モジュールで定義されています
   ("RTLD_xxx" 定数、例えば "os.RTLD_LAZY")。

   利用可能な環境: Unix。

sys.set_int_max_str_digits(n)

   Set the integer string conversion length limitation used by this
   interpreter. See also "get_int_max_str_digits()".

   バージョン 3.9.14 で追加.

sys.setprofile(profilefunc)

   Set the system's profile function, which allows you to implement a
   Python source code profiler in Python.  See chapter Python プロファ
   イラ for more information on the Python profiler.  The system's
   profile function is called similarly to the system's trace function
   (see "settrace()"), but it is called with different events, for
   example it isn't called for each executed line of code (only on
   call and return, but the return event is reported even when an
   exception has been set). The function is thread-specific, but there
   is no way for the profiler to know about context switches between
   threads, so it does not make sense to use this in the presence of
   multiple threads. Also, its return value is not used, so it can
   simply return "None".  Error in the profile function will cause
   itself unset.

   Profile関数は 3 個の引数、*frame*、*event*、および *arg* を受け取る
   必要があります。*frame* は現在のスタックフレームです。*event* は文
   字列で、"'call'", "'return'", "'c_call'", "'c_return'",
   "'c_exception'" のどれかが渡されます。*arg* はイベントの種類によっ
   て異なります。

   引数無しで 監査イベント "sys.setprofile" を送出します。

   *event* には以下の意味があります。

   "'call'"
      関数が呼び出された(もしくは、何かのコードブロックに入った)。プロ
      ファイル関数が呼ばれる。 *arg* は "None" が渡される。

   "'return'"
      関数(あるいは別のコードブロック)から戻ろうとしている。プロファイ
      ル関数が呼ばれる。 *arg* は返されようとしている値、または、この
      イベントが例外が送出されることによって起こったなら "None" 。

   "'c_call'"
      C 関数(拡張関数かビルトイン関数)が呼ばれようとしている。 *arg*
      は C 関数オブジェクト。

   "'c_return'"
      C 関数から戻った。 *arg* は C の関数オブジェクト。

   "'c_exception'"
      C 関数が例外を発生させた。 *arg* は C の関数オブジェクト。

sys.setrecursionlimit(limit)

   Python インタプリタの、スタックの最大の深さを *limit* に設定します
   。この制限は Python プログラムが無限に再帰し、 C スタックがオーバー
   フローしてクラッシュすることを防止するために設けられています。

   *limit* の最大値はプラットフォームによって異なります。深い再帰処理
   が必要な場合にはプラットフォームがサポートしている範囲内でより大き
   な値を指定することができますが、この値が大きすぎればクラッシュする
   ので注意が必要です。

   If the new limit is too low at the current recursion depth, a
   "RecursionError" exception is raised.

   バージョン 3.5.1 で変更: A "RecursionError" exception is now raised
   if the new limit is too low at the current recursion depth.

sys.setswitchinterval(interval)

   インタプリタのスレッド切り替え間隔を秒で指定します。この浮動小数点
   値が、並列に動作しているPythonスレッドに割り当てられたタイムスライ
   スの理想的な処理時間です。特に長時間実行される内部関数やメソッドが
   実行されたとき、実際の値はより高くなることがあります。また、どのス
   レッドがスレッド切り替え間隔の終わりにスケジュールされる（次に実行
   される）かはオペレーティングシステムが決定します。インタプリタは自
   身のスケジューラを持ちません。

   バージョン 3.2 で追加.

sys.settrace(tracefunc)

   Set the system's trace function, which allows you to implement a
   Python source code debugger in Python.  The function is thread-
   specific; for a debugger to support multiple threads, it must
   register a trace function using "settrace()" for each thread being
   debugged or use "threading.settrace()".

   Trace関数は 3 個の引数、*frame*、*event*、および *arg* を受け取る必
   要があります。*frame* は現在のスタックフレームです。*event* は文字
   列で、"'call'", "'line'", "'return'", "'exception'", "'opcode'" の
   どれかが渡されます。*arg* はイベントの種類によって異なります。

   trace 関数は (*event* に "'call'" を渡された状態で) 新しいローカル
   スコープに入るたびに呼ばれます。この場合、新しいスコープで利用する
   ローカルの trace 関数への参照か、そのスコープを trace しないのであ
   れば "None" を返します。

   ローカル trace 関数は自身への参照 (もしくはそのスコープの以降の
   trace を行う別の関数) を返すべきです。もしくは、そのスコープの
   trace を止めるために "None" を返します。

   If there is any error occurred in the trace function, it will be
   unset, just like "settrace(None)" is called.

   *event* には以下の意味があります。

   "'call'"
      関数が呼び出された(もしくは、何かのコードブロックに入った)。グロ
      ーバルの trace 関数が呼ばれる。 *arg* は "None" が渡される。戻り
      値はローカルの trace 関数。

   "'line'"
      The interpreter is about to execute a new line of code or re-
      execute the condition of a loop.  The local trace function is
      called; *arg* is "None"; the return value specifies the new
      local trace function.  See "Objects/lnotab_notes.txt" for a
      detailed explanation of how this works. Per-line events may be
      disabled for a frame by setting "f_trace_lines" to "False" on
      that frame.

   "'return'"
      関数(あるいは別のコードブロック)から戻ろうとしている。ローカルの
      trace 関数が呼ばれる。 *arg* は返されようとしている値、または、
      このイベントが例外が送出されることによって起こったなら "None" 。
      trace 関数の戻り値は無視される。

   "'exception'"
      例外が発生した。ローカルの trace 関数が呼ばれる。 *arg* は
      "(exception, value, traceback)" のタプル。戻り値は新しいローカル
      の trace 関数。

   "'opcode'"
      The interpreter is about to execute a new opcode (see "dis" for
      opcode details).  The local trace function is called; *arg* is
      "None"; the return value specifies the new local trace function.
      Per-opcode events are not emitted by default: they must be
      explicitly requested by setting "f_trace_opcodes" to "True" on
      the frame.

   例外が呼び出しチェインを辿って伝播していくことに注意してください。
   "'exception'" イベントは各レベルで発生します。

   For more fine-grained usage, it's possible to set a trace function
   by assigning "frame.f_trace = tracefunc" explicitly, rather than
   relying on it being set indirectly via the return value from an
   already installed trace function. This is also required for
   activating the trace function on the current frame, which
   "settrace()" doesn't do. Note that in order for this to work, a
   global tracing function must have been installed with "settrace()"
   in order to enable the runtime tracing machinery, but it doesn't
   need to be the same tracing function (e.g. it could be a low
   overhead tracing function that simply returns "None" to disable
   itself immediately on each frame).

   code と frame オブジェクトについては、 標準型の階層 を参照してくだ
   さい。

   引数無しで 監査イベント "sys.settrace" を送出します。

   **CPython implementation detail:** "settrace()" 関数は、デバッガ、
   プロファイラ、カバレッジツール等で使うためだけのものです。この関数
   の挙動は言語定義よりも実装プラットフォームの分野の問題で、全ての
   Python 実装で利用できるとは限りません。

   バージョン 3.7 で変更: "'opcode'" event type added; "f_trace_lines"
   and "f_trace_opcodes" attributes added to frames

sys.set_asyncgen_hooks(firstiter, finalizer)

   Accepts two optional keyword arguments which are callables that
   accept an *asynchronous generator iterator* as an argument. The
   *firstiter* callable will be called when an asynchronous generator
   is iterated for the first time. The *finalizer* will be called when
   an asynchronous generator is about to be garbage collected.

   引数無しで 監査イベント "sys.set_asyncgen_hooks_firstiter" を送出し
   ます。

   引数無しで 監査イベント "sys.set_asyncgen_hooks_finalizer" を送出し
   ます。

   Two auditing events are raised because the underlying API consists
   of two calls, each of which must raise its own event.

   バージョン 3.6 で追加: See **PEP 525** for more details, and for a
   reference example of a *finalizer* method see the implementation of
   "asyncio.Loop.shutdown_asyncgens" in Lib/asyncio/base_events.py

   注釈:

     This function has been added on a provisional basis (see **PEP
     411** for details.)

sys.set_coroutine_origin_tracking_depth(depth)

   Allows enabling or disabling coroutine origin tracking. When
   enabled, the "cr_origin" attribute on coroutine objects will
   contain a tuple of (filename, line number, function name) tuples
   describing the traceback where the coroutine object was created,
   with the most recent call first. When disabled, "cr_origin" will be
   None.

   To enable, pass a *depth* value greater than zero; this sets the
   number of frames whose information will be captured. To disable,
   pass set *depth* to zero.

   This setting is thread-specific.

   バージョン 3.7 で追加.

   注釈:

     This function has been added on a provisional basis (see **PEP
     411** for details.)  Use it only for debugging purposes.

sys._enablelegacywindowsfsencoding()

   Changes the default filesystem encoding and errors mode to 'mbcs'
   and 'replace' respectively, for consistency with versions of Python
   prior to 3.6.

   This is equivalent to defining the "PYTHONLEGACYWINDOWSFSENCODING"
   environment variable before launching Python.

   利用可能な環境: Windows 。

   バージョン 3.6 で追加: より詳しくは **PEP 529** を参照してください
   。

sys.stdin
sys.stdout
sys.stderr

   インタプリタが使用する、それぞれ標準入力、標準出力、および標準エラ
   ー出力の *ファイルオブジェクト* です:

   * "stdin" は ("input()" の呼び出しも含む) すべての対話型入力に使わ
     れます。

   * "stdout" は "print()" および *expression* 文の出力と、"input()"
     のプロンプトに使用されます。

   * インタプリタ自身のプロンプトおよびエラーメッセージは "stderr" に
     出力されます。

   これらのストリームは "open()" が返すような通常の *テキストファイル*
   です。引数は以下のように選択されます:

   * The character encoding is platform-dependent.  Non-Windows
     platforms use the locale encoding (see
     "locale.getpreferredencoding()").

     On Windows, UTF-8 is used for the console device.  Non-character
     devices such as disk files and pipes use the system locale
     encoding (i.e. the ANSI codepage).  Non-console character devices
     such as NUL (i.e. where "isatty()" returns "True") use the value
     of the console input and output codepages at startup,
     respectively for stdin and stdout/stderr. This defaults to the
     system locale encoding if the process is not initially attached
     to a console.

     The special behaviour of the console can be overridden by setting
     the environment variable PYTHONLEGACYWINDOWSSTDIO before starting
     Python. In that case, the console codepages are used as for any
     other character device.

     Under all platforms, you can override the character encoding by
     setting the "PYTHONIOENCODING" environment variable before
     starting Python or by using the new "-X" "utf8" command line
     option and "PYTHONUTF8" environment variable.  However, for the
     Windows console, this only applies when
     "PYTHONLEGACYWINDOWSSTDIO" is also set.

   * When interactive, the "stdout" stream is line-buffered.
     Otherwise, it is block-buffered like regular text files.  The
     "stderr" stream is line-buffered in both cases.  You can make
     both streams unbuffered by passing the "-u" command-line option
     or setting the "PYTHONUNBUFFERED" environment variable.

   バージョン 3.9 で変更: Non-interactive "stderr" is now line-
   buffered instead of fully buffered.

   注釈:

     標準ストリームにバイナリーデータの読み書きを行うには下位のバイナ
     リー "buffer" オブジェクトを使用してください。例えば "bytes" を
     "stdout" に書き出す場合は "sys.stdout.buffer.write(b'abc')" を使
     用してください。However, if you are writing a library (and do not
     control in which context its code will be executed), be aware
     that the standard streams may be replaced with file-like objects
     like "io.StringIO" which do not support the "buffer" attribute.

sys.__stdin__
sys.__stdout__
sys.__stderr__

   それぞれ起動時の "stdin", "stderr", "stdout" の値を保存しています。
   終了処理時に利用されます。また、 "sys.std*" オブジェクトが(訳注:別
   のファイルライクオブジェクトに)リダイレクトされている場合でも、実際
   の標準ストリームへの出力に利用できます。

   また、標準ストリームが壊れたオブジェクトに置き換えられた場合に、動
   作する実際のファイルを復元するために利用することもできます。しかし
   、明示的に置き換え前のストリームを保存しておき、そのオブジェクトを
   復元する事を推奨します。

   注釈:

     一部の条件下では、"stdin", "stdout",  "stderr" も、オリジナルの
     "__stdin__", "__stdout__",  "__stderr__" も "None" になることがあ
     ります。これはコンソールに接続しない Windows GUI アプリケーション
     であり、かつ **pythonw** で起動された Python アプリケーションが該
     当します。

sys.thread_info

   スレッドの実装に関する情報が格納された *named tuple* です。

   +--------------------+-----------------------------------------------------------+
   | 属性               | 説明                                                      |
   |====================|===========================================================|
   | "name"             | スレッド実装の名前:  * "'nt'": Windows スレッド  *        |
   |                    | "'pthread'": POSIX スレッド  * "'solaris'": Solaris スレ  |
   |                    | ッド                                                      |
   +--------------------+-----------------------------------------------------------+
   | "lock"             | ロック実装の名前:  * "'semaphore'": セマフォを使用するロ  |
   |                    | ック  * "'mutex+cond'": mutex と条件変数を使用するロック  |
   |                    | * "None" この情報が不明の場合                             |
   +--------------------+-----------------------------------------------------------+
   | "version"          | Name and version of the thread library. It is a string,   |
   |                    | or "None" if this information is unknown.                 |
   +--------------------+-----------------------------------------------------------+

   バージョン 3.3 で追加.

sys.tracebacklimit

   捕捉されない例外が発生した時、出力されるトレースバック情報の最大レ
   ベル数を指定する整数値(デフォルト値は "1000")。 "0" 以下の値が設定
   された場合、トレースバック情報は出力されず例外型と例外値のみが出力
   されます。

sys.unraisablehook(unraisable, /)

   Handle an unraisable exception.

   Called when an exception has occurred but there is no way for
   Python to handle it. For example, when a destructor raises an
   exception or during garbage collection ("gc.collect()").

   The *unraisable* argument has the following attributes:

   * *exc_type*: 例外の型

   * *exc_value*: 例外の値、>>``<<None``の可能性がある。

   * *exc_traceback*: Exception traceback, can be "None".

   * *err_msg*: Error message, can be "None".

   * *object*: Object causing the exception, can be "None".

   The default hook formats *err_msg* and *object* as: "f'{err_msg}:
   {object!r}'"; use "Exception ignored in" error message if *err_msg*
   is "None".

   "sys.unraisablehook()" can be overridden to control how unraisable
   exceptions are handled.

   Storing *exc_value* using a custom hook can create a reference
   cycle. It should be cleared explicitly to break the reference cycle
   when the exception is no longer needed.

   Storing *object* using a custom hook can resurrect it if it is set
   to an object which is being finalized. Avoid storing *object* after
   the custom hook completes to avoid resurrecting objects.

   See also "excepthook()" which handles uncaught exceptions.

   引数 "hook", "unraisable" を指定して 監査イベント
   "sys.unraisablehook" を送出します。

   バージョン 3.8 で追加.

sys.version

   Python インタプリタのバージョン番号の他、ビルド番号や使用コンパイラ
   などの情報を示す文字列です。この文字列は Python 対話型インタプリタ
   が起動した時に表示されます。バージョン情報はここから抜き出さずに、
   "version_info" および "platform" が提供する関数を使って下さい。

sys.api_version

   使用中のインタプリタの C API バージョン。 Python と拡張モジュール間
   の不整合をデバッグする場合などに利用できます。

sys.version_info

   バージョン番号を示す 5 要素タプル:*major*, *minor*, *micro*,
   *releaselevel*, *serial* 。 *releaselevel* 以外は全て整数です。
   *releaselevel* の値は、 "'alpha'", "'beta'", "'candidate'",
   "'final'" の何れかです。 Python 2.0 の "version_info" は、 "(2, 0,
   0, 'final', 0)" となります。構成要素には名前でもアクセスできるので
   、 "sys.version_info[0]" は "sys.version_info.major" と等価、などに
   なります。

   バージョン 3.1 で変更: 名前を使った要素アクセスがサポートされました
   。

sys.warnoptions

   この値は、warnings フレームワーク内部のみ使用され、変更することはで
   きません。詳細は "warnings" を参照してください。

sys.winver

   Windows プラットフォームで、レジストリのキーとなるバージョン番号。
   Python DLL の文字列リソース 1000 に設定されています。通常、この値は
   "version" の先頭三文字となります。この値は参照専用で、別の値を設定
   しても Python が使用するレジストリキーを変更することはできません。

   利用可能な環境: Windows 。

sys._xoptions

   コマンドラインオプション "-X" で渡された様々な実装固有のフラグの辞
   書です。オプション名にはその値が明示されていればそれが、それ以外の
   場合は "True" がマップされます。例えば:

      $ ./python -Xa=b -Xc
      Python 3.2a3+ (py3k, Oct 16 2010, 20:14:50)
      [GCC 4.4.3] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import sys
      >>> sys._xoptions
      {'a': 'b', 'c': True}

   **CPython implementation detail:** この "-X" によって渡されたオプシ
   ョンにアクセスする方法は CPython 固有です。他の実装ではそれらは他の
   意味でエクスポートされるか、あるいは何もしません。

   バージョン 3.2 で追加.

-[ 出典 ]-

[C99] ISO/IEC 9899:1999.  "Programming languages -- C."  この標準のパ
      ブリックドラフトが参照できます: http://www.open-
      std.org/jtc1/sc22/wg14/www/docs/n1256.pdf。
